Ask Your Question

Mr.OakenShield's profile - activity

2016-08-14 13:03:51 -0500 asked a question OpenCv- VideoRecord (1 min or any certain time)‏‏‏‏‏?

Hello guys, Greetings from Turkey, I'm working on image processing. (OpenCv 3.0, c++)

Actually, I try to doing:

1- Record Video as a 1 minunte,

2- After recording video, read recorded video

3- Do necessary image processing process

4- Go back 1 state and do same process until escape to running

I try to someting like that I write steps above.

I attache code for "1" state, How Should I edit. Could you help me, how can I record video 1 min or 10 min or any certain time?

Thank you.

#include "opencv2/opencv.hpp"
#include <iostream>

using namespace std;
using namespace cv;

int main() {

    VideoCapture vcap(0);
    if (!vcap.isOpened()) {
        cout << "Error opening video stream or file" << endl;
        return -1;
    }

    int frame_width = vcap.get(CV_CAP_PROP_FRAME_WIDTH);
    int frame_height = vcap.get(CV_CAP_PROP_FRAME_HEIGHT);
    VideoWriter video("/MyVideo.avi", CV_FOURCC('M', 'J', 'P', 'G'), 10, Size(frame_width, frame_height), true);

    for (;;) {

        Mat frame;
        vcap >> frame;
        video.write(frame);
        imshow("Frame", frame);
        char c = (char)waitKey(33);
        if (c == 27) break;
    }
    return 0;
}