Tracking Object Using OpenCV
How to track objects
Tracking an object requires to know Min/Max of the HSV (Hue,Saturation and Value) of the image, that way we can generate the threshold (or binary) Image. Knowing the binary image, we will be able to find the contours as well as the hierarchy of the contours.
Steps to start tracking
Sliding the Min/Max of HSV will effect the binary image. The goal is to have the binary image all black except what you would like to track.
This image is just for show, how the HSV is compare to the Original image.
Binary / Threshold Image
As you move the sliders / track-bars the binary image will reflect these changes. You goal here that the image will be all black except what you would like to track
Original Image With Tracking
This is the original Image with the tracking circle around the object (at this case it is just a red book on the shelf.)
There are many options to run the code, but the main ones are:
- InitTrackbars - This function will take the name of the trackbar window, and will initialize the trackbars (including setting the Min/Max Values for the Binary Window)
- tracker.SetUseDilate(true/false) - if you want to use Dilate while the program is calculating the tracking object
- tracker.SetUseErode(true/false) - if you want to use Erode while the program is calculating the tracking object