Basically I need to capture the video from videocamera do some processing on frames and for each frame show a rectangle of detection.
Example: http://www.youtube.com/watch?v=aYd2kAN0Y20
How would you superimpose this rectangle on the output of videocamera (usb)? (c++)
I would use OpenCV, an open source imaging library to get input from a webcam/video file.
Here is a tutorial on how to install it:
http://opensourcecollection.blogspot.com.es/2011/04/how-to-setup-opencv-22-in-codeblocks.html
Then I would use this code:
To get the image,
framefrom theCvCapture,capture.In this case,
captureis taken directly from a video camera, but you can also create it from a video file with:CvCapture *capture = cvCreateFileCapture("filename.avi");Then, I would draw on the image with functions defined here: http://opencv.willowgarage.com/documentation/drawing_functions.html
By the way, the shape in the Youtube video is not a rectangle. It’s a parallelogram.
If you want to do it live, then you can basically put this in a loop, getting a frame, processing it, drawing on it, and then outputting the image, like this:
You would include this before your loop:
cvNamedWindow("Capture", CV_WINDOW_AUTOSIZE);And then, in your loop, you would say this:
cvShowImage("Capture", frame);After the processing.
EDIT To do this in C++, open your webcam like this:
To initialize it from a file, instead of putting in the camera index, put the file path.
Get a frame from the camera like this:
Then you can find drawing functions here:
http://opencv.willowgarage.com/documentation/cpp/core_drawing_functions.html
Cheers!