JeVoisBase  1.21
JeVois Smart Embedded Machine Vision Toolkit Base Modules
Share this page:
No Matches
FirstPython.FirstPython Class Reference

Simple example of FIRST Robotics image processing pipeline using OpenCV in Python on JeVois. More...

Public Member Functions

 __init__ (self)
 loadCameraCalibration (self, w, h)
 Load camera calibration from JeVois share directory.
 detect (self, imgbgr, outimg=None)
 Detect objects within our HSV range.
 estimatePose (self, hlist)
 Estimate 6D pose of each of the quadrilateral objects in hlist:
 sendAllSerial (self, w, h, hlist, rvecs, tvecs)
 Send serial messages, one per object.
 drawDetections (self, outimg, hlist, rvecs=None, tvecs=None)
 Draw all detected objects in 3D.
 processNoUSB (self, inframe)
 Process function with no USB output.
 process (self, inframe, outframe)
 Process function with USB output.

Public Attributes


Detailed Description

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.

Using this module

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 for tutorials on getting started with programming JeVois in Python without having to install any development software on your host computer.

Trying it out

Edit the module's file at JEVOIS:/modules/JeVois/FirstPython/ 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.

Laurent Itti
Display Name:
FIRST Python
YUYV 640 252 60.0 YUYV 320 240 60.0 JeVois FirstPython
YUYV 320 252 60.0 YUYV 320 240 60.0 JeVois FirstPython
University of Southern California, HNB-07A, 3641 Watt Way, Los Angeles, CA 90089-2520, USA
Main URL:
Support URL:
Other URL:
GPL v3

Definition at line 77 of file

Constructor & Destructor Documentation

◆ __init__()

FirstPython.FirstPython.__init__ (   self)


Definition at line 80 of file

Member Function Documentation

◆ detect()

FirstPython.FirstPython.detect (   self,
  outimg = None 

◆ drawDetections()

◆ estimatePose()

◆ loadCameraCalibration()

FirstPython.FirstPython.loadCameraCalibration (   self,

◆ process()

FirstPython.FirstPython.process (   self,

Process function with USB output.

Definition at line 392 of file

References ObjectMatcher.detect(), BlobDetector.detect(), FirstVision.detect(), FirstPython.FirstPython.detect(), PythonObject6D.PythonObject6D.detect(), ARtoolkit.drawDetections(), ArUco.drawDetections(), QRcode.drawDetections(), Yolo.drawDetections(), ArUco.drawDetections(), QRcode.drawDetections(), ARtoolkit.drawDetections(), FirstVision.drawDetections(), FirstPython.FirstPython.drawDetections(), PythonObject6D.PythonObject6D.drawDetections(), FirstPython.FirstPython.estimatePose(), PythonObject6D.PythonObject6D.estimatePose(), FirstVision.estimatePose(), FirstPython.FirstPython.loadCameraCalibration(), PythonObject6D.PythonObject6D.loadCameraCalibration(), jevois::Engine.loadCameraCalibration(), FirstVision.sendAllSerial(), FirstPython.FirstPython.sendAllSerial(), PythonObject6D.PythonObject6D.sendAllSerial(), 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.

◆ processNoUSB()

◆ sendAllSerial()

FirstPython.FirstPython.sendAllSerial (   self,

Member Data Documentation

◆ camMatrix

◆ dilateElement


Definition at line 136 of file

◆ distCoeffs

◆ epsilon


Definition at line 95 of file

◆ erodeElement


Definition at line 135 of file

◆ ethresh


Definition at line 98 of file

◆ HSVmax


Definition at line 88 of file

Referenced by FirstPython.FirstPython.detect().

◆ HSVmin


Definition at line 87 of file

Referenced by FirstPython.FirstPython.detect().

◆ hullarea


Definition at line 96 of file

◆ hullfill


Definition at line 97 of file

◆ margin


Definition at line 99 of file

◆ ohm

◆ owm

◆ timer

The documentation for this class was generated from the following file: