Ask Your Question
0

Reading (quick time movie:- .mov) clip as input in Open CV

asked 2013-06-21 11:04:04 -0600

Vijay Kakani gravatar image

Hi Open CV group,

Firstly, thanks for your support till date. As I am new to Open CV, I've gone through some sample tutorials and made a code fragment for background separation.

include "stdafx.h"

include "opencv2/opencv.hpp"

include "iostream"

include "vector"

int main(int argc, char *argv[])

{

cv::Mat frame;
cv::Mat back;
cv::Mat fore;
cv::VideoCapture cap(0);
cv::BackgroundSubtractorMOG2 bg(10000, 25, false);
std::vector<std::vector<cv::Point> > contours;
cv::namedWindow("Frame");
cv::namedWindow("Background");
for(;;)
{
    cap >> frame;
    bg.operator ()(frame,fore);
    bg.getBackgroundImage(back);
    cv::erode(fore,fore,cv::Mat());
    cv::imshow("Frame",fore);
    cv::imshow("Background",back);
    if(cv::waitKey(30) >= 0) break;
}
return 0;

}

I am able to separate the background using camera as input.

How to use the (quick time movie, i.e; .mov video clip) as input to the above program??

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-06-22 20:04:14 -0600

VideoCapture as many prototype. One of them is for reading from a video file. See the doc, and use a code like this one:

cv::VideoCapture cap("myvideofile.avi");

instead of reading from camera first device (aka: cap(0); ).

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-06-21 11:04:04 -0600

Seen: 3,876 times

Last updated: Jun 22 '13