I have been using a Dino Lite USB microscope and OpenCV to build an application to analyze sample on a mechanical factory. The application is developed in C++ and runs on a Linux system. The user has to place the sample on a slide and then press a button: when pressing the button, the microscope is activated and then an image is captured through OpenCV libraries. After the image is grabbed, it is saved on the filesystem for further analysis.
The Dino Lite microscope I have been using is the 5MP Edge model. It has a decent support under Linux: I can control most of its features using the uvcdynctrl
utility. It is recognized by Linux as follows:
uvcvideo: Found UVC 1.00 device Dino-Lite Edge (a168:0990)
This is the result of the command v4l2-ctl --list-devices
:
Dino-Lite Edge (usb-0000:00:14.0-6):
/dev/video0
And this is the result of the command uvcdynctrl -c
(this command lists the available uvc controls for the device):
Listing available controls for device video0:
Brightness
Contrast
Saturation
Hue
White Balance Temperature, Auto
Gamma
Power Line Frequency
White Balance Temperature
Sharpness
Focus (absolute)
Focus, Auto
As you can see, there is no specific command to control the LEDs, so I have to set the raw control value using uvcdynctrl -S
; for example, if I want to switch off the built-in LEDs of the microscope, I can issue the following command:
uvcdynctrl -S 4:2 f2000000000000
. If someone is interested, many commands for the Dino Lite are described here.
So, now my problem. When I activate the microscope using OpenCV, the LEDs are on, and is a problem for me, because the light distorts the image. I can switch them off using the c++ execl()
or system()
: those functions execute an arbitrary command of the operating system, so I use them to execute "uvcdynctrl -S 4:2 f2000000000000" and switch off the LEDs. This solution works... some how, but is really buggy and leads to a lot of crashes, so it is not a viable solution.
Is there a way to use OpenCV to set raw uvc controls? I have try to find something in the class VideoCapture, but I did not find anything relevant to my case.
I have found this question that addresses an issue similar to the one of mine, but there are no answers.