This modules isolates pixels within a given HSV range (hue, saturation, and value of color pixels), does some cleanups, and extracts object contours. It sends information about object centers 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 code was loosely inspired by: https://raw.githubusercontent.com/kylehounslow/opencv-tuts/master/object-tracking-tut/objectTrackingTut.cpp written by Kyle Hounslow, 2013.
This module can send standardized serial messages as described in Standardized serial messages formatting. One message is issued on every video frame for each detected and good object (good objects have a pixel area within the range specified by
JeVois v1.8.1: Note that this module sends one message per detected object (blob) and per frame. You may want to specify
2940 D2 blob 4 -238 237 -238 19 13 19 13 237 2940 D2 blob 4 266 209 194 206 213 -277 285 -274 2940 D2 blob 4 575 -243 499 -511 613 -544 689 -275 2940 D2 blob 4 -150 -413 -150 -613 50 -613 50 -413 2940 D2 blob 4 -913 -306 -1000 -306 -1000 -750 -913 -750 2941 D2 blob 4 -313 119 -313 -106 -63 -106 -63 119 2941 D2 blob 4 189 105 115 99 157 -385 231 -379 2941 D2 blob 4 469 -275 469 -500 575 -500 575 -275 2941 D2 blob 4 -200 -531 -200 -744 -13 -744 -13 -531 2942 D2 blob 4 -381 -13 -381 -244 -113 -244 -113 -13 2942 D2 blob 4 478 -213 310 -402 414 -494 582 -305 2942 D2 blob 4 144 -6 53 -15 114 -668 206 -660
In this example, we detected 5 blobs on frame 2940, then 4 blobs on frame 2941, then 3 blobs on frame 2942.
See Standardized serial messages formatting for more on standardized serial messages, and Helper functions to convert coordinates from camera resolution to standardized for more info on standardized coordinates.
Trying it out
The default parameter settings (which are set in script.cfg explained below) attempt to detect light blue objects. Present a light blue object to the JeVois camera and see whether it is detected. When detected and good enough according to
For further use of this module, you may want to check out the following tutorials:
You should adjust parameters
Tuning the parameters is best done interactively by connecting to your JeVois camera while it is looking at some object of the desired color. Once you have achieved a tuning, you may want to set the hrange, srange, and vrange parameters in your script.cfg file for this module on the microSD card (see below).
Typically, you would start by narrowing down on the hue, then the value, and finally the saturation. Make sure you also move your camera around and show it typical background clutter so check for false positives (detections of things which you are not interested, which can happen if your ranges are too wide).
JeVois allows you to store parameter settings and commands in a file named script.cfg stored in the directory of a module. The file script.cfg may contain any sequence of commands as you would type them interactively in the JeVois command-line interface. For the ObjectTracker module, a default script is provided that sets the camera to manual color, gain, and exposure mode (for more reliable color values), and to setup communication with a pan/tilt head as described in Tutorial on how to write Arduino code that interacts with JeVois.
The script.cfg file for ObjectTracker is stored on your microSD at JEVOIS:/modules/JeVois/ObjectTracker/script.cfg and is shown in Tutorial on how to write Arduino code that interacts with JeVois as an example.