【问题标题】:cvCaptureFromFile- Opening Video from specific path - Raspberry PicvCaptureFromFile- 从特定路径打开视频 - Raspberry Pi
【发布时间】:2015-07-23 02:29:42
【问题描述】:

我在 Raspberry Pi 中安装了 OpenCV-2.4.9。现在我正在尝试从特定路径加载视频,为此我尝试使用 C 和 C++ API

C API:cvCaptureFromFile(path);

C++ API:VideoCapture 上限; cap.open(路径)

我收到错误消息,提示无法打开文件。

它适用于 Windows 和 Linux,但不适用于 Raspberry Pi。我错过了什么吗?

C++ 代码:

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

int main(){
  VideoCapture cap("C:/Users/nava/Videos/file.mp4");
  if (!cap.isOpened()){
    cout << "Error opening video stream" << endl;
    return -1;
  }
while (1){
    Mat Frame;
    if (!cap.read(Frame)){
        cout << "No Frame available" << endl;
        waitKey();
    }
    imshow("output", Frame);
    if (waitKey(33) == 27) break;
}
}

C 代码:

#include "highgui.h"

int main(int argc, char** argv)
{
  cvNamedWindow("video",CV_WINDOW_AUTOSIZE);
  CvCapture* capture = cvCreateFileCapture("/home/pi/Desktop/test.mp4");
  IplImage* frame;
  while(1)
  {
   frame = cvQueryFrame(capture);
   if(!frame) break;
   cvShowImage("video", frame);
   char c = cvWaitKey(33);
   if(c == 27) break;
  }
  }

【问题讨论】:

  • 对 opencv 的神秘 c-api 的支持正在迅速消失,请避免使用 c。
  • 是的,但是我不明白为什么它在 C++ API 案例中也会失败?
  • 仅在树莓派上也是如此,但在 Windows 和 Linux 上则不然。

标签: c++ c opencv raspberry-pi


【解决方案1】:

你必须安装 UV4L 驱动程序。按照这个教程:

http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=14

【讨论】:

  • uv4l驱动已经是最新版本了。顺便说一句,我忘了告诉相机(罗技)的实时捕捉正在工作,但唯一的问题是,我无法从特定路径打开视频。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-10
相关资源
最近更新 更多