[問題] 用opencv開啟webcam,畫面卻是黑的
用opencv開啟webcam,畫面卻是黑的,沒有影像
而且capture跟frame都不是NULL
cvcamGetCamerasCount的值是1
請問各位大大這是為什麼呢?
感謝大家幫忙
在此附上我的程式碼
#include <cv.h>
#include <highgui.h>
#include <stdio.h>
#include <cvcam.h>
int main()
{
CvCapture *capture;
IplImage *frame;
int CamerasCount= cvcamGetCamerasCount();
printf("視訊裝置總數量: %d\n",CamerasCount);
capture =cvCaptureFromCAM(0) ;
if(!capture)
{return -1;}
else
{printf("Camera is OK! \n");}
cvNamedWindow("Webcam",0);
frame = cvQueryFrame(capture);
if(!frame)
{return -1;}
else
{printf("frame is OK! \n");}
while(true)
{
frame = cvQueryFrame(capture);
cvShowImage("Webcam",frame);
if(cvWaitKey(1)>=0)
{
break;
}
}
cvReleaseCapture(&capture);
cvDestroyWindow("Webcam");
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.43.63.243
→
02/05 22:44, , 1F
02/05 22:44, 1F
→
02/06 13:30, , 2F
02/06 13:30, 2F
推
02/07 01:52, , 3F
02/07 01:52, 3F
→
02/07 22:49, , 4F
02/07 22:49, 4F
討論串 (同標題文章)
完整討論串 (本文為第 1 之 2 篇):
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章