JeVois Tutorials
1.21
JeVois Smart Embedded Machine Vision Tutorials
|
|
The color-based object tracker of JeVois is a simple but fast and effective way of tracking objects defined by a specific color. The behavior of the module can be fine-tuned by setting ranges for the hue (color tint), saturation (color fade), and value (color brightness) of the objects to track. While this can be achieved by hand, by using the approach studied in Changing machine vision parameters, quickly one becomes tired of typing many setpar
commands while searching for appropriate settings of the 6 color-related parameters (hue min and max, saturation min and max, and value min and max).
Here we write a simple graphical user interface in python to tune the parameters.
Hence, in this tutorial you will learn:
Typing help
in your serial terminal or inspecting the documentation of Object Tracker reveals several parameters. Here we will focus on the hrange, srange, and vrange parameters, which define the range of hue, saturation, and value that we want to track.
If you are not familiar with the HSV color space, check out this Wikipedia page.
Each of these three parameters is a range, that is, we can change them by specifying both the minimum and maximum values, separated by ..., for example, try:
setpar hrange 10...200
We write a simple python script that creates some sliders that one can drag with the mouse. When the sliders are updated, we send the appropriate setpar
command to JeVois. Consider this starter python script, which is located in ~/jevois-tutorials/doc/snip/objectrackertuning.py:
We basically create 6 slider widgets (for the 3 ranges), and we attach a callback to each slider which will update the corresponding global variable and then send the corresponding updated range of values to JeVois.
git clone https://github.com/jevois/jevois-tutorials.git
sudo apt-get install python python-tk python-serial
~/jevois-tutorials/doc/snip/objectrackertuning.py
objectarea
is by default set to look for objects of size between roughly 20x20 and 100x100 pixels). The ObjectTracker module draws green contours around all regions that are within the specified HSV range. Regions that also fit the area range are declared good detection and get an additional green circle drawn onto them.
You can further improve upon this tutorial in many ways. Here are some suggestions:
erodesize
, dilatesize
, etc