Skip to content

OpenCV – HSL Range Tracker Class

OpenCV – HSL Range Tracker Class published on

While working on various vision-based tracking projects, I found it necessary to filter the image from the HSL colourspace to locate coloured markers. This led me to create a class in order to visually pick ranges of HSL values, speeding up the process of finding the proper ranges used to filter the image.

The class source files can be downloaded here or found in the downloads page. It is written in C++ and requires (at least) OpenCV 2.0 to run.


The following code snippet shows an example on how the class is used:

[cc lang='cpp' line_numbers='false']
#include "vision_hslrangetracker.h"

int main()
	//name of class window
	char* hsl_tracker_name = "HSL Range Tracker";
	//initialize class (name, window width, window height)
	cls_imgHSLRangeTracker H = cls_imgHSLRangeTracker(hsl_tracker_name, 1024, 768);

		//access current selected min and max HSL values
		//H.hue_min, H.hue_max - hue values (0-255)
		//H.sat_min, H.sat_max - saturation values (0-255)
		//H.lum_min, H.lum_max - lightness values (0-255)

Primary Sidebar