當我調用方法cvSetCaptureProperty(capture, CV_CAP_PROP_EXPOSURE, 2);
時,它會根據需要設置相機的曝光。但是,當我運行我的戴爾網絡攝像頭中央軟件或Skype或使用我的相機的任何其他設備時,曝光會停留在我在OpenCV程序代碼中設置的最後一次曝光,並且不會像它那樣自動調整之前完成。在OpenCV中,設置曝光會導致我的網絡攝像頭軟件無法自動調整曝光。
如何讓我的網絡攝像頭程序(Dell Webcam Central和Skype)自動再次調整曝光?
下面的代碼:
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY); //CV_CAP_ANY
if (!capture)
{
fprintf(stderr, "ERROR: capture is NULL \n");
getchar();
return -1;
}
cvNamedWindow("mywindow", CV_WINDOW_AUTOSIZE);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480);
int width = (int)(cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH));
int height = (int)(cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT));
IplImage* image = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
IplImage* frame;
char c;
while (true)
{
frame = cvQueryFrame(capture);
if (!frame)
{
fprintf(stderr, "ERROR: frame is null...\n");
getchar();
break;
}
cvShowImage("mywindow", frame);
cvSetCaptureProperty(capture, CV_CAP_PROP_EXPOSURE, 2);
c = cvWaitKey(33);
if((c & 255) == 27) break;
}
cvReleaseCapture(&capture);
cvDestroyWindow("mywindow");
return 0;
}
您可以斷開並重新連接相機? – jomik