When myself and my friend run this code, the output is just a black window. We expected it to start streaming video from our RaspberryPi camera. We're using a RaspberryPi, the RaspberryPi Camera, openCv, and the Raspicam Library.
Here is our code:
#include <opencv2/opencv.hpp>
#include "opencv2/highgui/highgui.hpp"
#include <raspicam_cv.h>
#include <iostream>
using namespace std;
using namespace cv;
int main()
{
raspicam::RaspiCam_Cv Camera;
namedWindow("color", CV_WINDOW_AUTOSIZE);
while(1)
{
Mat image;
Camera.grab();
Camera.retrieve(image);
imshow("color", image);
waitKey(33);
}
return (0);
}
Here is a link to a tutorial we used to install the RaspiCam library. If you need any more information, please let me know. Thanks!
You need to open the camera in order to use it.
Before your loop:
The grab() method return a boolean. You can check if there is an error or not when you want to grab a picture.
Moreover, you should specify the color encoding you want. The default is RGB, but it consume many CPU.