How do I grab frames from a video stream on Windows 8 modern apps?

后端 未结 3 1543
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-03 13:51

I am trying to extract images out of a mp4 video stream. After looking stuff up, it seems like the proper way of doing that is using Media Foundations in C++ and open the frame/

3条回答
  •  猫巷女王i
    2021-02-03 14:07

    I think OpenCV may help you. OpenCV offers api to capture frames from camera or video files. You can download it here http://opencv.org/downloads.html. The following is a demo I writed with "OpenCV 2.3.1".

    #include "opencv.hpp"
    
    using namespace cv;
    int main()
    {
        VideoCapture cap("demo.avi");   // open a video to capture
        if (!cap.isOpened())        // check if succeeded
            return -1;
    
        Mat frame;
        namedWindow("Demo", CV_WINDOW_NORMAL);
        // Loop to capture frame and show on the window
        while (1) {
            cap >> frame;
            if (frame.empty())
                break;
    
            imshow("Demo", frame);
            if (waitKey(33) >= 0)  // pause 33ms every frame
                break;
        }
    
        return 0;
    }
    

提交回复
热议问题