gpt4 book ai didi

c++ - 读取视频文件 "Open CV WARNING: Couldn' 时出现问题 t 读取电影文件 bird.avi"

转载 作者:行者123 更新时间:2023-11-28 05:22:23 24 4
gpt4 key购买 nike

在 Xcode 中使用 C++ 完成与 opencv 相关的简单教程时,我遇到了很多问题。我无法让程序读取电影文件。请注意注释掉的部分是我测试是否存在与读取容器格式无关的问题。 IE。所有路径/图书馆等都很好。我试过 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";

关于c++ - 读取视频文件 "Open CV WARNING: Couldn' 时出现问题 t 读取电影文件 bird.avi",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41202600/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com