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

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...
 
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
 

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 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.

Trying it out

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.

Author
Laurent Itti
Display Name:
FIRST Python
Videomapping:
YUYV 640 252 60.0 YUYV 320 240 60.0 JeVois FirstPython
Videomapping:
YUYV 320 252 60.0 YUYV 320 240 60.0 JeVois FirstPython
Email:
itti@usc.edu
Address:
University of Southern California, HNB-07A, 3641 Watt Way, Los Angeles, CA 90089-2520, USA
Main URL:
http://jevois.org
Support URL:
http://jevois.org/doc
Other URL:
http://iLab.usc.edu
License:
GPL v3
Distribution:
Unrestricted
Restrictions:
None

Definition at line 75 of file FirstPython.py.

Constructor & Destructor Documentation

◆ __init__() [1/2]

def FirstPython.FirstPython.__init__ (   self)

Constructor.

Definition at line 78 of file FirstPython.py.

Referenced by FirstPython.FirstPython.__init__().

◆ __init__() [2/2]

Member Function Documentation

◆ detect() [1/2]

def FirstPython.FirstPython.detect (   self,
  imgbgr,
  outimg = None 
)

◆ detect() [2/2]

◆ drawDetections() [1/2]

def FirstPython.FirstPython.drawDetections (   self,
  outimg,
  hlist,
  rvecs = None,
  tvecs = None 
)

◆ drawDetections() [2/2]

def FirstPython.FirstPython.drawDetections (   self,
  outimg,
  hlist,
  rvecs = None,
  tvecs = None 
)

◆ estimatePose() [1/2]

def FirstPython.FirstPython.estimatePose (   self,
  hlist 
)

Estimate 6D pose of each of the quadrilateral objects in hlist:

Definition at line 251 of file FirstPython.py.

References FirstPython.FirstPython.camMatrix, FirstPython.FirstPython.distCoeffs, FirstPython.FirstPython.estimatePose(), FirstPython.FirstPython.ohm, and FirstPython.FirstPython.owm.

◆ estimatePose() [2/2]

◆ loadCameraCalibration() [1/2]

def FirstPython.FirstPython.loadCameraCalibration (   self,
  w,
  h 
)

Load camera calibration from JeVois share directory.

Definition at line 108 of file FirstPython.py.

References FirstPython.FirstPython.camMatrix, FirstPython.FirstPython.distCoeffs, and FirstPython.FirstPython.loadCameraCalibration().

◆ loadCameraCalibration() [2/2]

def FirstPython.FirstPython.loadCameraCalibration (   self,
  w,
  h 
)

◆ process() [1/2]

◆ process() [2/2]

◆ processNoUSB() [1/2]

◆ processNoUSB() [2/2]

◆ sendAllSerial() [1/2]

def FirstPython.FirstPython.sendAllSerial (   self,
  w,
  h,
  hlist,
  rvecs,
  tvecs 
)

◆ sendAllSerial() [2/2]

def FirstPython.FirstPython.sendAllSerial (   self,
  w,
  h,
  hlist,
  rvecs,
  tvecs 
)

Send serial messages, one per object.

Definition at line 275 of file FirstPython.py.

References FirstPython.FirstPython.ohm, FirstPython.FirstPython.owm, and FirstPython.FirstPython.sendAllSerial().

Member Data Documentation

◆ camMatrix

◆ dilateElement

FirstPython.FirstPython.dilateElement

Definition at line 135 of file FirstPython.py.

Referenced by FirstPython.FirstPython.detect().

◆ distCoeffs

◆ epsilon

FirstPython.FirstPython.epsilon

◆ erodeElement

FirstPython.FirstPython.erodeElement

Definition at line 134 of file FirstPython.py.

Referenced by FirstPython.FirstPython.detect().

◆ ethresh

FirstPython.FirstPython.ethresh

◆ HSVmax

FirstPython.FirstPython.HSVmax

◆ HSVmin

FirstPython.FirstPython.HSVmin

◆ hullarea

FirstPython.FirstPython.hullarea

◆ hullfill

FirstPython.FirstPython.hullfill

◆ margin

FirstPython.FirstPython.margin

◆ ohm

◆ owm

◆ timer


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