Object Tracker
Simple color-based object detection/tracking.
By Laurent Ittiitti@usc.eduhttp://jevois.orgGPL v3
Video Mapping: YUYV 320 254 60.0 YUYV 320 240 60.0 JeVois ObjectTracker

This modules isolates pixels within a given HSV range, does some cleanups, and extract object contrours. It sends information about object centers over serial. This module usually works best with the camera sensor set to manual exposure, gain, color balance, etc so that HSV color values are reliable. See the cript.cfg file in this module's directory for an example of how to set the camera settigs 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.


You should adjust parameters hrange, srange, and vrange to isolate the range of Hue, Saturation, and Value (respectively) that correspond to the objects you want to detect. Note that there is a params.cfg file in this module's directory that provides a range tuned to a lighgt blue object, as shown in the demo screenshot.

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

Config file

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 at http://jevois.org/doc/ArduinoTutorial.html

The script.cfg file for ObjectTracker is stored on your microSD at JEVOIS:/modules/JeVois/ObjectTracker/script.cfg and is shown in this JeVois tutorial: http://jevois.org/doc/ArduinoTutorial.html as an example.

ParameterTypeDescriptionDefaultValid Values
(ObjectTracker) hrangejevois::Range<unsigned char>Range of H values for HSV windowjevois::Range<unsigned char>(10, 245)-
(ObjectTracker) srangejevois::Range<unsigned char>Range of S values for HSV windowjevois::Range<unsigned char>(10, 245)-
(ObjectTracker) vrangejevois::Range<unsigned char>Range of V values for HSV windowjevois::Range<unsigned char>(10, 245)-
(ObjectTracker) maxnumobjsize_tMax number of objects to declare a clean image10-
(ObjectTracker) objectareajevois::Range<unsigned int>Range of object area (in pixels) to trackjevois::Range<unsigned int>(20*20, 100*100)-
(ObjectTracker) erodesizesize_tErosion structuring element size (pixels)3-
(ObjectTracker) dilatesizesize_tDilation structuring element size (pixels)8-
(ObjectTracker) debugboolShow contours of all object candidates if truetrue-
Detailed docs:ObjectTracker
Copyright:Copyright (C) 2016 by Laurent Itti, iLab and the University of Southern California
License:GPL v3
Support URL:http://jevois.org/doc
Other URL:http://iLab.usc.edu
Address:University of Southern California, HNB-07A, 3641 Watt Way, Los Angeles, CA 90089-2520, USA