Reputation: 309
This is how I usually process video's in 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;
}
}
Now I have a raspberry pi camera and I have the following minimal:
#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;
}
}
However the latter doesn't work, this is what is output to the terminal when I compile it: http://paste.ubuntu.com/24324541/
Could someone tell me what the correct way to do this is?
Thank you
Upvotes: 4
Views: 11434
Reputation: 15018
According to the documentation, you cannot use it as a stream, but instead must do this:
while(1){
cap.grab();
cap.retrieve(output);
imshow("webcam input", output);
char c = (char)waitKey(10);
if( c == 27 ) break;
}
Upvotes: 1