Ask Your Question
0

OpenCv and Dino Lite USB microscope under Linux

asked 2018-12-21 11:06:51 -0600

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.

edit retag flag offensive close merge delete

Comments

1

Is there a way to use OpenCV to set raw uvc controls?

a straight NO.

berak gravatar imageberak ( 2018-12-22 02:01:05 -0600 )edit

I see... is there any other c++ library able to do that?

Giorgio gravatar imageGiorgio ( 2019-01-03 05:07:13 -0600 )edit

@Giorgio. It will works with raspberry pi using linux

supra56 gravatar imagesupra56 ( 2019-01-25 09:17:27 -0600 )edit

@Giorgio.. Here is link raw uvc controls

supra56 gravatar imagesupra56 ( 2019-01-25 09:20:20 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-01-25 08:26:32 -0600

stryfe gravatar image

updated 2019-01-25 08:34:58 -0600

berak gravatar image

led controls for dinolite in lunix: .

//led on
memcpy(buf, "\x80\x01\xf1", 0x0000003);
ret = usb_control_msg(devh, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 0x0000001, 0x0000300, 0x0000400, buf, 0x0000003, 1000);

//led off
memcpy(buf, "\x80\x01\xf0", 0x0000003);
ret = usb_control_msg(devh, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 0x0000001, 0x0000300, 0x0000400, buf, 0x0000003, 1000);
edit flag offensive delete link more

Comments

1

@stryfe -- it would be perfect, if you could add, where to find the usb_control_msg function, what headers to use, liibs to link, etc. !

berak gravatar imageberak ( 2019-01-25 08:36:45 -0600 )edit
1

unfortunately, as i don't use linux myself , i would not know where to start. I got sent thesesomeone who got it from Dino-lite, but i haven't used it myself, sorry

stryfe gravatar imagestryfe ( 2019-01-25 08:39:15 -0600 )edit

ok, nvm, -- at least an improvement on the previous situation ;)

berak gravatar imageberak ( 2019-01-25 08:40:15 -0600 )edit
1

@berak. here is link: usb_control_msg

supra56 gravatar imagesupra56 ( 2019-01-25 09:13:48 -0600 )edit

thanks, @supra56 !

berak gravatar imageberak ( 2019-01-25 09:15:58 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-12-21 11:06:51 -0600

Seen: 4,054 times

Last updated: Jan 25 '19