JeVoisBase
1.22
JeVois Smart Embedded Machine Vision Toolkit Base Modules
|
|
Simple example of parallel image processing using OpenCV in Python on JeVois. More...
Public Member Functions | |
processNoUSB (self, inframe) | |
Process function with no USB output. | |
process (self, inframe, outframe) | |
Process function with USB output. | |
uninit (self) | |
Required multiprocessing pool cleanup to avoid hanging on module unload JeVois engine calls uninit(), if present, before destroying our module. | |
Public Attributes | |
pool | |
timer | |
Simple example of parallel image processing using OpenCV in Python on JeVois.
This module by default simply converts the input image to a grayscale OpenCV image, and then applies the Canny edge detection algorithm, 4 times running in parallel with 4 different edge coarseness settings. The resulting image is simply the 4 horizontally stacked results from the 4 parallel runs. Try to edit it to do something else!
True multi-threaded processing is not supported by Python (the python threading module does not allow concurrent execution of several threads of python code). Parallel processing is somewhat feasible using the mutiprocessing python module, which is a process-based multiprocessing approach. Note that there are significant costs to parallelizing code over multiple processes, the main one being that data needs to be transferred back and forth between processes, using pipes, sockets, or other mechanisms. For machine vision, this is a significant problem as the amount of data (streaming video) that needs to be packaged, transferred, and unpacked is high. C++ is the preferred way of developping multi-threaded JeVois modules, where std::async() makes multi-threaded programming easy.
One way we have been able to use this module with USB video outputs is: start guvcview -f yuyv -x 352x288
(launches PythonSandbox), then use the pull-down menu to select 1280x240 (switches to PythonParallel)
This module is best used with no USB video outputs. Connect to JeVois over serial and issue:
setpar serout USB # to get text results through serial-over-USB, or use Hard if you want results on the 4-pin serial setpar serlog USB # to get log messages through serial-over-USB, or use Hard if you want them on the 4-pin serial setmapping2 YUYV 320 240 25.0 JeVois PythonParallel streamon
As noted above, once you have loaded this module, any later attempts to change format again will fail.
See http://jevois.org/tutorials for tutorials on getting started with programming JeVois in Python without having to install any development software on your host computer.
Definition at line 82 of file PythonParallel.py.
PythonParallel.PythonParallel.process | ( | self, | |
inframe, | |||
outframe | |||
) |
Process function with USB output.
Definition at line 132 of file PythonParallel.py.
References PythonParallel.PythonParallel.pool, AprilTag.AprilTag.timer, FirstPython.FirstPython.timer, PyClassificationDNN.PyClassificationDNN.timer, PyCoralClassify.PyCoralClassify.timer, PyCoralDetect.PyCoralDetect.timer, PyCoralSegment.PyCoralSegment.timer, PyDetectionDNN.PyDetectionDNN.timer, PyDMTX.PyDMTX.timer, PyEmotion.PyEmotion.timer, PyFaceMesh.PyFaceMesh.timer, PyHandDetector.PyHandDetector.timer, PyLicensePlate.PyLicensePlate.timer, PyObjectron.PyObjectron.timer, PyPoseDetector.PyPoseDetector.timer, PySceneText.PySceneText.timer, PySelfie.PySelfie.timer, PythonObject6D.PythonObject6D.timer, PythonOpenCV.PythonOpenCV.timer, PythonParallel.PythonParallel.timer, PythonSandbox.PythonSandbox.timer, and PythonTest.PythonTest.timer.
PythonParallel.PythonParallel.processNoUSB | ( | self, | |
inframe | |||
) |
Process function with no USB output.
Definition at line 90 of file PythonParallel.py.
PythonParallel.PythonParallel.uninit | ( | self | ) |
Required multiprocessing pool cleanup to avoid hanging on module unload JeVois engine calls uninit(), if present, before destroying our module.
FIXME: python multiprocessing still messes up the system deeply, we become unable to allocate mmap'd UVC buffers after this module has been loaded.
Definition at line 174 of file PythonParallel.py.
References PythonParallel.PythonParallel.pool.
PythonParallel.PythonParallel.pool |
Definition at line 94 of file PythonParallel.py.
Referenced by PythonParallel.PythonParallel.process(), and PythonParallel.PythonParallel.uninit().
PythonParallel.PythonParallel.timer |
Definition at line 96 of file PythonParallel.py.
Referenced by FirstPython.FirstPython.process(), PyClassificationDNN.PyClassificationDNN.process(), PyCoralClassify.PyCoralClassify.process(), PyCoralDetect.PyCoralDetect.process(), PyCoralSegment.PyCoralSegment.process(), PyDetectionDNN.PyDetectionDNN.process(), PyDMTX.PyDMTX.process(), PythonObject6D.PythonObject6D.process(), PythonOpenCV.PythonOpenCV.process(), PythonParallel.PythonParallel.process(), PythonSandbox.PythonSandbox.process(), AprilTag.AprilTag.processGUI(), PyCoralClassify.PyCoralClassify.processGUI(), PyCoralDetect.PyCoralDetect.processGUI(), PyCoralSegment.PyCoralSegment.processGUI(), PyFaceMesh.PyFaceMesh.processGUI(), PyHandDetector.PyHandDetector.processGUI(), PyLicensePlate.PyLicensePlate.processGUI(), PyObjectron.PyObjectron.processGUI(), PyPoseDetector.PyPoseDetector.processGUI(), PySceneText.PySceneText.processGUI(), PySelfie.PySelfie.processGUI(), PythonOpenCV.PythonOpenCV.processGUI(), PythonSandbox.PythonSandbox.processGUI(), PythonTest.PythonTest.processGUI(), FirstPython.FirstPython.processNoUSB(), PythonObject6D.PythonObject6D.processNoUSB(), and PythonSandbox.PythonSandbox.processNoUSB().