Search code examples
c++opencvvideo-capture

VideoCapture will not open the video


I am trying to open a video and write it to a location:

#include <opencv2/opencv.hpp>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "iostream"

using namespace cv;
using namespace std;

int main()
{
    string videoName = "KorExp3.avi";
    VideoCapture video(videoName);

    Mat frame;

    video >> frame;

    VideoWriter w("D:/w.avi", CV_FOURCC('M', 'P', '4', '2'), 30, frame.size(), true);
    while (true) {
        video >> frame;
        imshow("frame", frame);
        w << frame;
    }
    w.release();

    waitKey(0);
    return 0;
}

In debug mode, while hovering the mouse on video it says:

Information not available, no symbols loaded for opencv_world340d.dll

I have copied this dll file and the video file to the same location of .exe, but still same thing happens. I also tried the absolute path to the video string videoName = "D:\\KorExp3.avi"; but didn't work.

How can I capture a video and write it to a location using openCV?


Solution

  • I put the directory of the video instead of moving the video to the project location andthe error was solved:

    string videoName = "D:\\KorExp3.avi";
    while (true) {
        video >> frame;
    ...