gelsightinc / gsrobotics

GelSight SDK for robotic sensors
GNU General Public License v3.0
80 stars 24 forks source link

The way to grab camera id on Windows is problematic. And my solution included #21

Open IrvingF7 opened 5 months ago

IrvingF7 commented 5 months ago

Hi, Gelsight team!

I noticed that in gsdevice.py, the current way to grab the camera ID is through pygrabber. But as this comment on StackOverflow pointed out, pygrabber sometimes gives problematic ordering of the camera devices and can be different from the actual order that OpenCV accesses them.

For example, in this case, my Windows 11 PC has a Logitech webcam and is connected to a Gelsight mini. pygrabber thinks Gelsight is at index 0, but my PC thinks the default camera is the Logitech webcam. As a result, running \examples\showimages.py will simply open my webcam Untitled picture

I have a solution that's modified based on this this post and can correctly display device ids on Windows 11 that is based on Window's official API Python/WinRT. If it's okay, I will make a pull request.

Untitled picture2