阅读视频文件时出现问题“打开CV警告:无法读取电影文件bird.avi”

时间:2016-12-17 20:09:23

标签: c++ xcode opencv

我在使用Xcode中使用C ++的opencv简单教程时遇到了很大的问题。我无法让程序读取电影文件。请注意,如果存在与读取容器格式无关的问题,请注释已注释掉的部分。即所有的路径/ 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;



}

1 个答案:

答案 0 :(得分:1)

替换:

app.component("mycomp", {
  template: "Hello {{$ctrl.name}}<br/>",
  bindings: {
    myVar: "<myvar"
  },
  controller: function() {
    this.$onChanges = function(changeObj) {
        if (changeObj.myVar) {
            this.name = "decorated_" + changeObj.myVar.currentValue;

        }
    }
  }
});

使用完整路径,例如:

string video = "bird.avi";