Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Video mask in OpenCV

Hi

I'm just learning OpenCV for a school assignment. I need to mask a specific section of a given video and track the objects within this section. The section is usually specified as a rectangle, and this rectangle represents the section or the slice of the video that needs to be masked. Only objects within this slice or section must be tracked. The rectangle is formulated by getting the x,y coordinates of both the top right corner and the bottom right corner, I have already done this. Now I need to mask those rectangle dimensions out of the video. Attached is a simple representation I made to indicate what exactly should be achieved. The grey rectangle represents the area of the video that should be tracked.

The code is too long to post, but I'm currently reading the video frame by frame using VideoCapture, and every frame is being stored in a matrix (Mat currentFrame).

sample.jpg

I have been reading some things about manipulating the matrix that represents the frame and setting the required pixel values to 0 or something along those lines, but is there any other way ? If anyone could refer me to openCV examples or particular parts of the documentation that I need to look at I would deeply appreciate it.

Thank you.