[英]Error with showing video using Raspberry Pi Camera and Open Cv
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.
我们希望它能够从RaspberryPi相机开始流式传输视频。 We're using a RaspberryPi, the RaspberryPi Camera, openCv, and the Raspicam Library.
我们正在使用RaspberryPi,RaspberryPi相机,openCv和Raspicam库。
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. 这是我们用来安装RaspiCam库的教程的链接。 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: 在循环之前:
if( !Camera.open() )
{
std::cerr << "Cannot open the camera" << std::endl;
}
The grab() method return a boolean. capture()方法返回一个布尔值。 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.
默认值为RGB,但是它会消耗很多CPU。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.