简体   繁体   中英

Error playing video when using OpenCV C++ on a Visual Studio platform

I tried to get it running, but it didn't do anything, didn't show up errors and automatically terminated the program.

#include"opencv2/core/core.hpp"
#include"opencv2/highgui/highgui.hpp"
#include"opencv2/imgproc/imgproc.hpp"
#include<stdio.h>
int main(int argc, char* argv)
{
    cvNamedWindow("Example2", CV_WINDOW_AUTOSIZE);
    CvCapture* capture = cvCreateFileCapture("C:/Users/Nam/Pictures/YALQ6371.MP4");
    IplImage* frame;
    while (1){
        frame = cvQueryFrame(capture);
        if (!frame) break;
        cvShowImage("Example2", frame);
        char c = cvWaitKey(33);
        if (c == 27) break;
    }
    cvReleaseCapture(&capture);
    cvDestroyWindow("Example2");
    return 0;
}

Try using imshow instead of cvShowImage , but don't forget to add using namespace cv; at the beginning.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM