cvCaptureFromFile-打开视频从特定路径 - 树莓派 [英] cvCaptureFromFile- Opening Video from specific path - Raspberry Pi
问题描述
我的OpenCV-2.4.9安装在树莓派。现在我试图加载特定路径的视频和我试图用C和C ++ API
C API:cvCaptureFromFile(路径);
C ++ API:VideoCapture帽; cap.open(路径)
我得到的错误,它说不能打开的文件。
它运作良好,在Windows和Linux,但不是在树莓派。我缺少的东西吗?
C ++ code:
的#include<&iostream的GT;
#包括LT&;&stdio.h中GT;
#包括LT&;&stdlib.h中GT;
#包括LT&;&string.h中GT;
#包括LT&; opencv2 / opencv.hpp>使用命名空间的简历;
使用命名空间std;诠释主(){
VideoCapture帽(C:/Users/nava/Videos/file.mp4);
如果(!cap.isOpened()){
COUT<< 错误打开视频流<< ENDL;
返回-1;
}
而(1){
垫框架;
如果(!cap.read(帧)){
COUT<< 无框架可用<< ENDL;
waitKey();
}
imshow(输出,帧);
如果(waitKey(33)== 27)破;
}
}
C code:
的#includehighgui.hINT主(INT ARGC,字符** argv的)
{
cvNamedWindow(视频,CV_WINDOW_AUTOSIZE);
CvCapture *捕获= cvCreateFileCapture(/家庭/ PI /桌面/ test.mp4);
* IplImage结构框架;
而(1)
{
帧= cvQueryFrame(捕捉);
如果突破(帧!);
cvShowImage(视频,帧);
焦C = cvWaitKey(33);
如果(C == 27)破;
}
}
您必须安装UV4L driver.Follow本教程:
的http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=14
块引用>I have OpenCV-2.4.9 installed in Raspberry Pi. Right now I am trying to load a video from specific path and for that I tried with both C and C++ API
C API: cvCaptureFromFile(path);
C++ API: VideoCapture cap; cap.open(path)
I am getting error and it says could not open file.
It works well in Windows and Linux, but not in Raspberry Pi. Am I missing something?
C++ code:
#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 Code:
#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; } }
解决方案You have to install UV4L driver.Follow this tutorial :
http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=14
这篇关于cvCaptureFromFile-打开视频从特定路径 - 树莓派的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!