Right now I have a script in python that allows me to track a colored ball in a video file. We're testing a robots velocity using a stationary camera, so I only need to track the color over a small span of the video's actual frame area and the rest can be discarded/ignored. Right now, my process is to trim the video trials to only what I need to be tracked, but with 15 trials per test, it becomes very time consuming.
black out the sides of the video not within the blue lines
Basically, how would I go about "blacking out" two sides of the video's area so that the color tracking isn't initiated until the robot enters the desired area?
Given that your camera is stationary, I'm assuming that the blue taped lines will not be moving in the video frame. With that said, this is the algorithm you follow:
-calculate the approximate region of interest rectangle in your image. You'd need to get the approximate values of- 1. The top left point from where the tracking should begin, say (x,y), and the height and width of the rect to be tracked. Use the image below for reference.
Once you have x,y,w,h, you can extract the portion of the image inside the rectangle as shown:
img2=img[x:x+w,y:y+h]
You can now run a standard color filter on img2, to track the ball on top of the bot