Version:0.9 StartHTML:0000000105 EndHTML:0000040330 StartFragment:0000001053 EndFragment:0000040314 mXScriptasHTML
{# ImageAI is a Python library built to empower Computer Vision
from imageai.Detection import ObjectDetection
#Using TensorFlow backend.
import wget and integrate in maXbox control }

program Unified_MLDetector21;

const C=CRLF;    
const SCRIPTNAMEP='992_oma_objectdetector21.py';
const DETECTOUTFILE = 'manmachineout.jpg'; //irobit_ekon25_out21.jpg';

const PYSCRIPT5 = 
'from imageai.Detection import ObjectDetection'+C+
'import wget                                  '+C+
'import sys                                   '+C+
'print("this first line fine")                '+C+
'                                             '+C+
'                                             '+C+
'def GraphViz(node):                                           '+C+
'    d = Graph(node)                                           '+C+
'                                                              '+C+
'    from graphviz import Digraph                              '+C+
'    dot = Digraph("Graph", strict=False)                      '+C+
'    dot.format = "png"                                        '+C+
'                                                              '+C+
'    def rec(nodes, parent):                                   '+C+
'        for d in nodes:                                       '+C+
'            if not isinstance(d, dict):                       '+C+
'                dot.node(d, shape=d._graphvizshape)           '+C+
'                dot.edge(d, parent)                           '+C+
'            else:                                             '+C+
'                for k in d:                                   '+C+
'                    dot.node(k._name, shape=k._graphvizshape) '+C+
'                    rec(d[k], k)                              '+C+
'                    dot.edge(k._name, parent._name)           '+C+
'    for k in d:                                               '+C+
'        dot.node(k._name, shape=k._graphvizshape)             '+C+
'        rec(d[k], k)                                          '+C+
'    return dot                                                '+C+
'                                                              '+C+
'                                                              '+C+
'detector = ObjectDetection()                                  '+C+
'                                                              '+C+
'url = "http://www.kleiner.ch/images/italo_max_train.jpg"      '+C+
'url="https://softwareschulecode.files.wordpress.com/2019/12/tee_film4.png?w=750"'+C+
'destination = "./input/film_tee_train.jpg"                    '+C+
'                                                              '+C+
'model_path = "./crypt/models/yolo-tiny.h5"                    '+C+
'input_path = "./crypt/input/manmachine.jpg" #twinwiz.jpg"        '+C+
'                                                                  '+C+
'#wget.download(url, out=destination) #, useragent= "maXbox")      '+C+
'#input_path = destination                                         '+C+
'#output_path = "./crypt/output/manmachine.jpg"                    '+C+
'output_path = sys.argv[1]                                         '+C+
'                                                                  '+C+
'#using the pre-trained TinyYOLOv3 model,                          '+C+
'detector.setModelTypeAsTinyYOLOv3()                               '+C+
'detector.setModelPath(model_path)                                 '+C+
'                                                                  '+C+
'#loads model of path specified above using setModelPath() class method.   '+C+
'detector.loadModel()                                                      '+C+
'                                                                          '+C+
'custom=detector.CustomObjects(person=True,laptop=True,car=True,train=True,'+C+
'                       clock=True, chair=True, bottle=True, keyboard=True)'+C+
'                                                                          '+C+
'detections=detector.detectCustomObjectsFromImage(custom_objects=custom,  \'+C+
'                  input_image=input_path, output_image_path=output_path, \'+C+
'                                     minimum_percentage_probability=0.01) '+C+
'                                                                          '+C+
'for eachItem in detections:                                               '+C+
'    print(eachItem["name"] ," : ", eachItem["percentage_probability"])    '+C+
'                                                                          '+C+
'print("integrate image detector compute ends...") ';
//*)

const ACTIVESCRIPT = PYSCRIPT5;

var RUNSCRIPT, outputPath, ParentName: string;
    startTime64, endTime64, freq64: Int64;

begin //@main

  //-init
  maxform1.console1click(self);
  memo2.height:= 205;
  QueryPerformanceFrequency(freq64);
  ParentName:= strlower(GetParentProcessName());
  ParentName:= PathExtractName(ParentName); 
  
  //-config
  saveString(exepath+SCRIPTNAMEP, ACTIVESCRIPT);
  sleep(400)
  outputPath:= '.\crypt\output\'+DETECTOUTFILE;
  //writeln(parentname)
  //if(ParentName='cmd.exe')or(ParentName='powershell.exe')then begin
  try
    AttachConsole(-1);
    NativeWriteln('Start with maXbox4 Console Output--->');
  except
    writeln('no console attached.. ')
  end;  
  //end;  
  //FreeConsole();
  
  if fileExists(exepath+SCRIPTNAMEP) then begin
    RUNSCRIPT:= exepath+SCRIPTNAMEP;
    QueryPerformanceCounter(startTime64);
    writeln(getDosOutput('py '+RUNSCRIPT+' '+outputpath, exePath));
    QueryPerformanceCounter(endTime64);
    println('elapsedSeconds:= '+floattostr((endTime64-startTime64)/freq64));
    openFile(outputPath)
    //}
  end; 
  // writeln(getDosOutput('maXbox4.exe 755_science_ibz_spektrum3.txt', exePath));
  //if(ParentName='cmd.exe')or(ParentName='powershell.exe')then begin
  try
    NativeWriteln(memo2.text);
    NativeWriteln('Stop with Return Key--->');
    FreeConsole();
  except
    writeln('no console attached.. ')
  end;    
  //end;  
  //FreeConsole();
end.    



#//----app_template_loaded_code----
#//----File newtemplate.txt not exists - now saved!----
#https://stackabuse.com/object-detection-with-imageai-in-python/
# https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/yolo-tiny.h5
#https://imageai.readthedocs.io/en/latest/detection/index.html

https://github.com/dsblank/simple_kernel
https://forum.lazarus.freepascal.org/index.php?topic=38955.0
https://ipython-books.github.io/16-creating-a-simple-kernel-for-jupyter/

The kernel and client live in different processes and this decoupling between the client and kernel makes it possible to write kernels in any language. They communicate via messaging protocols (I think its 0MQ) implemented on top of network sockets and these messages are encoded in JSON in a text-based document format.

"""
There are 80 possible objects that you can detect with the
ObjectDetection class, and they are as seen below.

  person, bicycle, car, motorcycle, airplane, bus,train,truck,boat,traffic light,fire hydrant, stop_sign, parking meter, bench, bird, cat,dog, horse, sheep, cowelephant,bear, zebra, giraffe, backpack, umbrella,handbag,tie, suitcase,frisbee, skis,snowboard, sports ball,kite,baseball bat,baseball glove,skateboard,surfboard,tennis racket, bottle,wine glass,cup,fork, knife, spoon, bowl, banana, apple,sandwich, orange, broccoli, carrot, hot dog, pizza,donot, cake,chair,couch, potted plant, bed, dining table,toilet,tv, laptop, mouse,remote,keyboard, cell phone,microwave, oven, toaster,sink,refrigerator, book,clock,vase,scissors,teddy bear,hair dryer,toothbrush.

To detect only some of the objects above, you will need to call the CustomObjects function and set the name of the
object(s) yiu want to detect to through. The rest are False by default. In below example, we detected only chose detect only person and dog.

custom = detector.CustomObjects(person=True, dog=True)

this first line fine
person  :  11.582126468420029
person  :  15.317463874816895
person  :  25.40428638458252
person  :  41.63033664226532
person  :  42.076510190963745
integrate image detector compute ends...

>>> console output:
car  :  54.72719669342041
car  :  97.26507663726807
car  :  97.5576639175415
person  :  53.6459743976593
person  :  56.598347425460815
person  :  72.28184938430786
laptop  :  57.53162503242493
bottle  :  10.687477886676788
bottle  :  11.373373866081238

image detector compute ends...
image detector compute ends...
"""

Die Safety-Measures sind Massnahmen, welche du im Design und der Implementierung umsetzt, um die Software sicher zu gestalten. Die meisten Safety-Measures wurden bereits durch die Risikoanalyse gefunden, die weiteren findest du auf Grund deiner Erfahrung oder der anzuwendenden Norm. Die Safety-Measures, welche ich immer wieder angetroffen habe sind:

    Bereichsprüfungen an Schnittstellen von Komponenten
    Prüfung der zwischengespeicherten Daten mit CRC oder redundanten Daten
    Plausibilitätsprüfungen über verschiedene Daten-Arten
    Programmflussüberwachung
    Runtime-Tests zur Sicherstellung der Korrektheit des Prozessors, wie z.B. RAM, ROM
    Prüfungen auf nullptr
    Zyklisches verarbeiten und versenden der Daten

----Simple Browser started----