1

当我和我的朋友运行这段代码时,输​​出只是一个黑色窗口。我们预计它会开始从我们的 RaspberryPi 相机流式传输视频。我们使用的是 RaspberryPi、RaspberryPi 相机、openCv 和 Raspicam 库。

这是我们的代码:

#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);
}

是我们用来安装 RaspiCam 库的教程的链接。如果您需要更多信息,请告诉我。谢谢!

4

1 回答 1

0

You need to open the camera in order to use it.

Before your loop:

if( !Camera.open() ) 
{
   std::cerr << "Cannot open the camera" << std::endl;
}

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.

于 2013-12-30T18:15:00.163 回答