Detection and Tracking Red , Green and Blue objects in live video in MATLAB

  • 9 years ago
Hi, Everyone, In this video, I want to show you how you can detect and track red,Green,Blue, objects in live video. To detect the red color in every single frame we need to know different approaches.

The popular approach is to convert the whole RGB frame into correcponding HSV (Hue-Saturation-Value) plane and extract the pixel values for RED , Green and Blue. So choose a range in which different shades of these color's exists. in this way you can detect almost all distinguishable colors in a frame.

But this approach is a bit difficult in real life problem especially in Live video due to ambient light. One more simple solution exists there if you decide to detect only red or green or blue color. So this approach is not versatile for all colors, but its simpler than anything and you can easily eleminate the ambient light problem using it. So I am gonna use this approach to detect these color.


Step 1: First acquire an RGB Frame from the Video.
Step 2: Extract the Red Layer Matrix from the RGB frame
Step 3: Get the grey image of the RGB frame.
Step 4: Subtract the grayFrame from the redFrame , blueframe , Greenframe.
Step 5: Filter out unwanted noises using Median Filter.
Step 6: Now convert the diffFrame into corresponding Binary Image using proper threshold value. Change its value for different light conditions.
Step 7: Now you are all done. Your Red,Green,Blue color has been detected. Now you can put any blob statistics analysis on this image. You can calculate the centroid, area or bounding box of those blobs.