I'm going to calibrate GUI elements (Tkinter's Scale indeed) for some video settings.
Can I get the maxima and minima of the parameters of the USB-camera with OpenCV?
One can easily set and get the camera parameters (Setting Camera Parameters in OpenCV/Python), for example, with the following commands:
videoCapture = cv2.VideoCapture(0)
print('Brightness:', videoCapture.get(10))
and so on.
But the different cameras can have not equal ranges of some parameter. For example the Genius Slim 320 USB-camera
has the brightness range 0...255, but an another USB-camera has the brightness range -64...+64.
Is it possible to get the maxima and minima of the USB-camera parameters (such as a brightness, contrast and so on) by means of OpenCV itself?
Or it is possible from the camera driver only?
Of course, I suppose that I can set some parameter and then get it and check, does it change, and I can do it in some loop, and so I shell find the maximum (or the minimum) of this parameter.
Finally I had wrote the following function:
def getExtr(mode, step):
state0 = videoCapture.get(mode)
param0 = state0
sign = 0
while sign==0:
param0 += step
videoCapture.set(mode, param0)
param = videoCapture.get(mode)
if param0 != param:
sign=1
videoCapture.set(mode, state0) # return parameter to initial setting
return param
and I use it:
import cv2
videoCapture = cv2.VideoCapture(0)
print('Max brightness: ', getExtr(10, 1))
print('Min brightness: ', getExtr(10, -1))
It works fine, but it takes several seconds to get all maxima and minima for all camera parameters allowed by OpenCV.
But may be exists a much simpler (and faster) method (standard for OpenCV)?