这就是我通常在openCV中处理视频的方式。
#include <iostream>
#include<opencv2/opencv.hpp>
int main(int argc, char** argv)
{
Mat output;
VideoCapture cap(CV_CAP_ANY);
if( !cap.isOpened() )
{
cout << "Could not initialize capturing...\n";
return 0;
}
while(1){
cap >> output;
imshow("webcam input", output);
char c = (char)waitKey(10);
if( c == 27 ) break;
}
}
现在我有一个覆盆子pi相机,我有以下最小的:
#include <iostream>
#include<opencv2/opencv.hpp>
#include <raspicam/raspicam_cv.h>
int main(int argc, char** argv)
{
Mat image, output;
//VideoCapture cap(CV_CAP_ANY);
raspicam::RaspiCam_Cv cap;
if( !cap.isOpened() )
{
cout << "Could not initialize capturing...\n";
return 0;
}
while(1){
cap >> output;
imshow("webcam input", output);
char c = (char)waitKey(10);
if( c == 27 ) break;
}
}
然而后者不起作用,这是我编译时输出到终端的内容:http://paste.ubuntu.com/24324541/
有人能告诉我这样做的正确方法是什么?
谢谢
答案 0 :(得分:0)
根据the documentation,您不能将其用作流,而是必须这样做:
while(1){
cap.grab();
cap.retrieve(output);
imshow("webcam input", output);
char c = (char)waitKey(10);
if( c == 27 ) break;
}