Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to set or get VideoCapture Properties

Hello all.

I am attempting to set the properties of a nice Webcam with OpenCV. In particular, I would like to be able to change the exposure, gain, and autoexposure/gain properties of my camera. I have tried setting properties with methods such as the following in my project:

bool CaptureThread::connectToCamera()
{
cap = new VideoCapture(0);
cap->set(CV_CAP_PROP_FRAME_WIDTH, width);
cap->set(CV_CAP_PROP_FRAME_HEIGHT, height);
cap->set(CV_CAP_PROP_EXPOSURE, 0.20);
return cap->isOpened();
}

The width and height parameters are set accordingly here and elsewhere, but any other parameters I attempt to pass are ignored. My only real goal is to be able to set these values manually so that the camera doesn't waste time balancing itself for a clearer image. (This will be used in an entirely closed lightening environment.

Can anyone help me with this issue, or let me know if these functions aren't usable by all cameras? Otherwise, do you have suggestions for a workaround?

I apologize if I am not being clear or giving enough information. I will try to clarify anything else that is needed of me.

click to hide/show revision 2
Added clarification comment

How to set or get VideoCapture Properties

Hello all.

I am attempting to set the properties of a nice Webcam with OpenCV. In particular, I would like to be able to change the exposure, gain, and autoexposure/gain auto-exposure/gain properties of my camera. I have tried setting properties with methods such as the following in my project:

bool CaptureThread::connectToCamera()
{
cap = new VideoCapture(0);
cap->set(CV_CAP_PROP_FRAME_WIDTH, width);
cap->set(CV_CAP_PROP_FRAME_HEIGHT, height);
cap->set(CV_CAP_PROP_EXPOSURE, 0.20);
0.20); //Or multiple other values here.
return cap->isOpened();
}

The width and height parameters are set accordingly here and elsewhere, but any other parameters I attempt to pass are ignored. My only real goal is to be able to set these values manually so that the camera doesn't waste time balancing itself for a clearer image. (This will be used in an entirely closed lightening environment.

Can anyone help me with this issue, or let me know if these functions aren't usable by all cameras? Otherwise, do you have suggestions for a workaround?

I apologize if I am not being clear or giving enough information. I will try to clarify anything else that is needed of me.