读取视频文件"Open CV WARNING: Couldn't read movie file bird.avi"时出现问题

Problems reading video file "Open CV WARNING: Couldn't read movie file bird.avi"

本文关键字:file bird movie read avi 问题 CV Open 文件 视频 WARNING      更新时间:2023-10-16

我在Xcode中使用C 的简单教程遇到了巨大的问题。我无法获得该程序来读取电影文件。请注意,如果存在与阅读集装箱格式无关的问题,请注意,评论的部分是我测试。IE。所有的路径/ibraries等都很好。我尝试了AVI容器MP4,MOV等 - 这是代码:

#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp> 
#include <iostream>
#include <unistd.h>

using namespace std;
using namespace cv;

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

Mat frame; // Container for each frame
string video = "bird.avi";
//    string video = "hat.jpg";
VideoCapture vid(video);
if (!vid.isOpened()) { // Check if video file was opened
    cout << "ERROR: Video file not opened...n";
    return -1;
}
// Get fps from video inputCvCapture *input_video = cvCreateFileCapture("guitarplaying.avi");
int fps = (int)vid.get(CV_CAP_PROP_FPS); // Gets FPS from video
cout << "FPS=" << fps << endl;
// Create a window for displaying the video
namedWindow("hello"); // Creates a window
while (1) {
    if (!vid.read(frame)) { // Check end of video file
        cout << "Video file ends.n";
        break;
    }
    // Show the frame on window
    imshow("hello", frame); // Show current frame on window
    // Wait for read next frame or key pressed
    if (waitKey(1000/fps) >= 0)
        break;
}
return 0;

}

替换:

string video = "bird.avi";

以完整的路径,例如:

string video = "c:\samples\bird.avi";