How to manually set exposure on a Facetime HD camcorder in Python opencv 3.2.0 OSX El Capitan

I'm trying to figure out how to manually set the exposure for my Facetime HD camera in opencv , which I write in Python. I am using opencv version 3.2.0, python 2.7 and it works on OSX El Capitan.

I am writing a program that will shoot from a webcam every n seconds and write it to disk. From what I saw in the documentation, I would like to use this method to set the exposure on my camera.

cv2.VideoCapture.set(CV_CAP_PROP_EXPOSURE, value) β†’ retval

After some twisting and searching on the Internet, I found that I was able to access this camera property in my version of opencv using the following:

cv2.CAP_PROP_EXPOSURE

What is strange is that in my function that actually captures the photo, I see that the default exposure value is 0.0, and then when I go to change it using the set method, the exposure did not change when I again check the value. It seems that the set method just doesn't work.

Here is my function:

 def takePhoto(): cam = cv2.VideoCapture(0) print(cam.get(cv2.CAP_PROP_EXPOSURE)) #this prints out 0.0 cam.set(cv2.CAP_PROP_EXPOSURE, 0.5) print(cam.get(cv2.CAP_PROP_EXPOSURE)) #this also prints out 0.0, despite the use of set() in the line above s, im = cam.read() # captures image cv2.imwrite("test.jpg",im) # writes image test.jpg to disk cam.release() 

Is it possible that this camera is not compatible with manual exposure control? I also read in one or two places that opencv on OSX does not allow you to manually control camera properties. Is that what's wrong here? Or am I using the set method incorrectly? I just need to be able to manually control the exposure, since the photos taken by my program are constantly underexposed.

Thanks Brian

+7
python opencv computer-vision osx-elcapitan
source share
1 answer

I do not have a FacetimeHD camera, but I think you need to set the exposure mode manually (turn off automatic exposure) using

cam.set(cv2.CAP_PROP_AUTO_EXPOSURE, 0)

0
source share

All Articles