【发布时间】:2023-04-08 02:27:02
【问题描述】:
我是 OpenCV 新手,我想通过 OpenCV 显示我的网络摄像头看到的内容。我正在使用 C 编码语言。
我已尝试使用此代码:
#include <stdio.h>
#include <cv.h> // Include the OpenCV library
#include <highgui.h> // Include interfaces for video capturing
int main()
{
cvNamedWindow("Window", CV_WINDOW_AUTOSIZE);
CvCapture* capture =cvCreateCameraCapture(-1);
if (!capture){
printf("Error. Cannot capture.");
}
else{
cvNamedWindow("Window", CV_WINDOW_AUTOSIZE);
while (1){
IplImage* frame = cvQueryFrame(capture);
if(!frame){
printf("Error. Cannot get the frame.");
break;
}
cvShowImage("Window",frame);
}
cvReleaseCapture(&capture);
cvDestroyWindow("Window");
}
return 0;
}
我的网络摄像头灯亮了,但结果是一个完全灰色的窗口,没有图像。
你能帮帮我吗?
【问题讨论】:
标签: c opencv frame webcam video-capture