Friday, 13 May 2011

Color and shape based tracking of a ball

In image processing, there are various color models like RGB, HSV, HSI, CMYK. For image proccessing regaurding color detection, RGB and HSV models are commonly used.

The HSV( Hue Saturation Value ) color model solves our purpose of color detection best. In RGB, to define a color, the ranges of red, blue and green must be defined, but in HSV model, for a color we need to define only the value of Hue, which is defined as the color descriptor, or the parameter for wavelength describing a particular color. The saturation is defined as the prominence of hue, and value is a parameter dependent upon the lighting conditions.

This is in accordance with the color to be detected. It is also highly dependent on lighting conditions. The values of Hue Saturation and Value can be checked by using the software colorpic.

STEP4:Color detection

cvInRangeS(hsv_frame, hsv_min, hsv_max, thresholded);
This command checks for the regions in the image having the values of h, s and v within the permissible range, i.e. between hsv_min and hsv_max, and the binary image thus formed is stored in thresholded.

This command is used to smooth a image using gaussian smoothing using a square of size 11x11. The area can range from 0x0 to 11x11, depending on whether the smoothing we require is used to detect small objects or not. The greater the area the better the detection of large objects.