JeVoisBase
1.20
JeVois Smart Embedded Machine Vision Toolkit Base Modules
|
|
Simple example of FIRST Robotics image processing pipeline using OpenCV in Python on JeVois. More...
Public Member Functions | |
def | __init__ (self) |
Constructor. More... | |
def | loadCameraCalibration (self, w, h) |
Load camera calibration from JeVois share directory. More... | |
def | detect (self, imgbgr, outimg=None) |
Detect objects within our HSV range. More... | |
def | estimatePose (self, hlist) |
Estimate 6D pose of each of the quadrilateral objects in hlist: More... | |
def | sendAllSerial (self, w, h, hlist, rvecs, tvecs) |
Send serial messages, one per object. More... | |
def | drawDetections (self, outimg, hlist, rvecs=None, tvecs=None) |
Draw all detected objects in 3D. More... | |
def | processNoUSB (self, inframe) |
Process function with no USB output. More... | |
def | process (self, inframe, outframe) |
Process function with USB output. More... | |
Public Attributes | |
HSVmin | |
HSVmax | |
owm | |
ohm | |
epsilon | |
hullarea | |
hullfill | |
ethresh | |
margin | |
timer | |
camMatrix | |
distCoeffs | |
erodeElement | |
dilateElement | |
Simple example of FIRST Robotics image processing pipeline using OpenCV in Python on JeVois.
This module is a simplified version of the C++ module FirstVision. It is available with JeVois v1.6.2 or later.
This module implements a simple color-based object detector using OpenCV in Python. Its main goal is to also demonstrate full 6D pose recovery of the detected object, in Python.
This module isolates pixels within a given HSV range (hue, saturation, and value of color pixels), does some cleanups, and extracts object contours. It is looking for a rectangular U shape of a specific size (set by parameters owm
and ohm
for object width and height in meters). See screenshots for an example of shape. It sends information about detected objects over serial.
This module usually works best with the camera sensor set to manual exposure, manual gain, manual color balance, etc so that HSV color values are reliable. See the file script.cfg file in this module's directory for an example of how to set the camera settings each time this module is loaded.
This module is provided for inspiration. It has no pretension of actually solving the FIRST Robotics vision problem in a complete and reliable way. It is released in the hope that FRC teams will try it out and get inspired to develop something much better for their own robot.
Check out this tutorial first, for the FirstVision module written in C++ and also check out the doc for FirstVision. Then you can just dive in and start editing the python code of FirstPython.
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.
Edit the module's file at JEVOIS:/modules/JeVois/FirstPython/FirstPython.py and set the parameters self.owm
and self.ohm
to the physical width and height of your U-shaped object in meters. You should also review and edit the other parameters in the module's constructor, such as the range of HSV colors.
Definition at line 77 of file FirstPython.py.
def FirstPython.FirstPython.__init__ | ( | self | ) |
Constructor.
Definition at line 80 of file FirstPython.py.
def FirstPython.FirstPython.detect | ( | self, | |
imgbgr, | |||
outimg = None |
|||
) |
Detect objects within our HSV range.
Definition at line 124 of file FirstPython.py.
References hasattr(), FirstPython.FirstPython.HSVmax, and FirstPython.FirstPython.HSVmin.
Referenced by PythonObject6D.PythonObject6D.process(), FirstPython.FirstPython.process(), PythonObject6D.PythonObject6D.processNoUSB(), and FirstPython.FirstPython.processNoUSB().
def FirstPython.FirstPython.drawDetections | ( | self, | |
outimg, | |||
hlist, | |||
rvecs = None , |
|||
tvecs = None |
|||
) |
Draw all detected objects in 3D.
Definition at line 303 of file FirstPython.py.
References FirstPython.FirstPython.camMatrix, FirstPython.FirstPython.distCoeffs, demo.int, FirstPython.FirstPython.ohm, and FirstPython.FirstPython.owm.
Referenced by PythonObject6D.PythonObject6D.process(), and FirstPython.FirstPython.process().
def FirstPython.FirstPython.estimatePose | ( | self, | |
hlist | |||
) |
Estimate 6D pose of each of the quadrilateral objects in hlist:
Definition at line 255 of file FirstPython.py.
References FirstPython.FirstPython.camMatrix, FirstPython.FirstPython.distCoeffs, FirstPython.FirstPython.ohm, and FirstPython.FirstPython.owm.
Referenced by PythonObject6D.PythonObject6D.process(), FirstPython.FirstPython.process(), PythonObject6D.PythonObject6D.processNoUSB(), and FirstPython.FirstPython.processNoUSB().
def FirstPython.FirstPython.loadCameraCalibration | ( | self, | |
w, | |||
h | |||
) |
Load camera calibration from JeVois share directory.
Definition at line 110 of file FirstPython.py.
Referenced by PythonObject6D.PythonObject6D.process(), FirstPython.FirstPython.process(), PythonObject6D.PythonObject6D.processNoUSB(), and FirstPython.FirstPython.processNoUSB().
def FirstPython.FirstPython.process | ( | self, | |
inframe, | |||
outframe | |||
) |
Process function with USB output.
Definition at line 395 of file FirstPython.py.
References ObjectMatcher.detect(), BlobDetector.detect(), FirstPython.FirstPython.detect(), QRcode.drawDetections(), ARtoolkit.drawDetections(), Yolo.drawDetections(), ArUco.drawDetections(), FirstPython.FirstPython.drawDetections(), FirstPython.FirstPython.estimatePose(), hasattr(), FirstPython.FirstPython.loadCameraCalibration(), FirstPython.FirstPython.sendAllSerial(), PythonTutorial2::PythonTutorial2.timer, PyModule::__MODULE__.timer, and FirstPython.FirstPython.timer.
def FirstPython.FirstPython.processNoUSB | ( | self, | |
inframe | |||
) |
Process function with no USB output.
Definition at line 370 of file FirstPython.py.
References ObjectMatcher.detect(), BlobDetector.detect(), FirstPython.FirstPython.detect(), FirstPython.FirstPython.estimatePose(), hasattr(), FirstPython.FirstPython.loadCameraCalibration(), FirstPython.FirstPython.sendAllSerial(), PythonTutorial2::PythonTutorial2.timer, PyModule::__MODULE__.timer, and FirstPython.FirstPython.timer.
def FirstPython.FirstPython.sendAllSerial | ( | self, | |
w, | |||
h, | |||
hlist, | |||
rvecs, | |||
tvecs | |||
) |
Send serial messages, one per object.
Definition at line 279 of file FirstPython.py.
References FirstPython.FirstPython.ohm, and FirstPython.FirstPython.owm.
Referenced by PythonObject6D.PythonObject6D.process(), FirstPython.FirstPython.process(), PythonObject6D.PythonObject6D.processNoUSB(), and FirstPython.FirstPython.processNoUSB().
FirstPython.FirstPython.camMatrix |
Definition at line 114 of file FirstPython.py.
Referenced by PythonObject6D.PythonObject6D.drawDetections(), FirstPython.FirstPython.drawDetections(), PythonObject6D.PythonObject6D.estimatePose(), and FirstPython.FirstPython.estimatePose().
FirstPython.FirstPython.dilateElement |
Definition at line 139 of file FirstPython.py.
FirstPython.FirstPython.distCoeffs |
Definition at line 115 of file FirstPython.py.
Referenced by PythonObject6D.PythonObject6D.drawDetections(), FirstPython.FirstPython.drawDetections(), PythonObject6D.PythonObject6D.estimatePose(), and FirstPython.FirstPython.estimatePose().
FirstPython.FirstPython.epsilon |
Definition at line 95 of file FirstPython.py.
FirstPython.FirstPython.erodeElement |
Definition at line 138 of file FirstPython.py.
FirstPython.FirstPython.ethresh |
Definition at line 98 of file FirstPython.py.
FirstPython.FirstPython.HSVmax |
Definition at line 88 of file FirstPython.py.
Referenced by FirstPython.FirstPython.detect().
FirstPython.FirstPython.HSVmin |
Definition at line 87 of file FirstPython.py.
Referenced by FirstPython.FirstPython.detect().
FirstPython.FirstPython.hullarea |
Definition at line 96 of file FirstPython.py.
FirstPython.FirstPython.hullfill |
Definition at line 97 of file FirstPython.py.
FirstPython.FirstPython.margin |
Definition at line 99 of file FirstPython.py.
FirstPython.FirstPython.ohm |
Definition at line 92 of file FirstPython.py.
Referenced by FirstPython.FirstPython.drawDetections(), FirstPython.FirstPython.estimatePose(), PythonObject6D.PythonObject6D.sendAllSerial(), and FirstPython.FirstPython.sendAllSerial().
FirstPython.FirstPython.owm |
Definition at line 91 of file FirstPython.py.
Referenced by FirstPython.FirstPython.drawDetections(), FirstPython.FirstPython.estimatePose(), PythonObject6D.PythonObject6D.sendAllSerial(), and FirstPython.FirstPython.sendAllSerial().
FirstPython.FirstPython.timer |
Definition at line 102 of file FirstPython.py.
Referenced by PyDMTX.PyDMTX.process(), PythonOpenCV.PythonOpenCV.process(), PythonSandbox.PythonSandbox.process(), PyCoralDetect.PyCoralDetect.process(), PyCoralClassify.PyCoralClassify.process(), PyClassificationDNN.PyClassificationDNN.process(), PyCoralSegment.PyCoralSegment.process(), PythonParallel.PythonParallel.process(), PyDetectionDNN.PyDetectionDNN.process(), PythonObject6D.PythonObject6D.process(), FirstPython.FirstPython.process(), PyPoseDetector.PyPoseDetector.processGUI(), PyFaceMesh.PyFaceMesh.processGUI(), PyHandDetector.PyHandDetector.processGUI(), PySelfie.PySelfie.processGUI(), PyObjectron.PyObjectron.processGUI(), PyLicensePlate.PyLicensePlate.processGUI(), PySceneText.PySceneText.processGUI(), PythonTest.PythonTest.processGUI(), PythonSandbox.PythonSandbox.processGUI(), PyCoralClassify.PyCoralClassify.processGUI(), PyCoralDetect.PyCoralDetect.processGUI(), PyCoralSegment.PyCoralSegment.processGUI(), PythonSandbox.PythonSandbox.processNoUSB(), PythonObject6D.PythonObject6D.processNoUSB(), and FirstPython.FirstPython.processNoUSB().