jorisparet / hamoco

Real-time mouse control via webcam-recorded hand gestures.
GNU General Public License v3.0
14 stars 1 forks source link

Select webcam #2

Open omlins opened 1 year ago

omlins commented 1 year ago

First, congratulations on the great project! (I have made quite a bit of google search before deciding to go with your project...)

Is there a way to select the webcam? In my case, on Ubuntu 22.04, it automatically selects the notebook integrated webcam. However, I would need to use a webcam connected with USB.

jorisparet commented 1 year ago

Thank you, I'm honored! :)

It's something that I didn't think of, thank you for letting me know.

Well, I expect it to be fairly easy to solve by just changing the integer index here. At the moment, I enforce this index to be zero, because I only expect one device to be connected (a built-in camera for a laptop, or a USB camera for a larger computer). If your USB camera is properly detected, it should simply be given 1 as index.

Unfortunately, I cannot try this myself as I have no USB camera (only a built-in one)... If you have the opportunity to do it, I would kindly ask you to clone the repo, change this index to 1 in hamoco_run.py, locally install the project and tell me whether this solved your problem. If so, I will release a new version on PyPI where one can specify the device index directly in the command line or in the configuration file.

Thanks again. Let me know.

omlins commented 1 year ago

Thanks! It works when I change the integer to 4. The thing is Linux creates more device nodes for each device to store additional metadata in them as I just recently learned. So if you would like to make it user friendly, then you would somehow need to extract these mapping between these virtual devices and the actual hardware. For me personally, in would be enough to be able to set this integer via a command line argument.

jorisparet commented 1 year ago

This is great, thank you. I'll explore a bit your reference about device nodes and update the code accordingly, depending on my ability to create such a mapping.

jorisparet commented 1 year ago

Hi, in commit db9967d482b761f201ee950c2a02453d6b2dbf51 (branch dev) I added a --device flag to specify the index of the camera being used, e.g. hamoco-run --device 2.

Let me know what you think.