B4J Question USB-cameras enumeration

peacemaker

Expert
Licensed User
Longtime User
HI, All

Any solution how to detect USB-cameras to list them for user choice ?
 

thetahsk

Active Member
Licensed User
Longtime User
HI, All

Any solution how to detect USB-cameras to list them for user choice ?

What application-libraries do you use for image grabbing ?

For easy enumeration USB camera's you can use powershell scripts.
B4X:
'try one of these for detecting USB Camera through Powershell

Get-PnpDevice -PresentOnly | Where-Object { $_.Class -match '^Camera' }

Get-PnpDevice -PresentOnly | Where-Object { $_.InstanceId -match '^USB' }

Get-PnpDevice -PresentOnly | Where-Object { $_.Class -match '^Media' }

 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Thanks for the way !

I use jOPenCV to work with cameras. It requires the camera int index 0, 1, 2...

Get-PnpDevice -PresentOnly | Where-Object { $_.Class -match '^Camera' }
This command returns:
B4X:
Status     Class           FriendlyName                                                                     InstanceId
------     -----           ------------                                                                     ----------
OK         Camera          HP Wide Vision HD Camera                                                         USB\VID_...

Get-PnpDevice -PresentOnly | Where-Object { $_.InstanceId -match '^USB' }
Result is not only cameras:

B4X:
Status     Class           FriendlyName                                                                     InstanceId
------     -----           ------------                                                                     ----------
OK         Bluetooth       Realtek Bluetooth 4.2 Adapter                                                    USB\VID_...
OK         Camera          HP Wide Vision HD Camera                                                         USB\VID_...
OK         USB             ������ᠫ�� USB-���業����                                                   USB\VID_...
OK         HIDClass        USB-���ன�⢮ �����                                                             USB\VID_...
OK         HIDClass        USB-���ன�⢮ �����                                                             USB\VID_...
OK         USB             ���⠢��� USB ���ன�⢮                                                         USB\VID_...
OK         USB             ��୥��� USB-���業���� (USB�3.0)                                              USB\ROOT...
OK         USB             ���⠢��� USB ���ன�⢮                                                         USB\VID_...
OK         USB             ��୥��� USB-���業���� (USB�3.0)                                              USB\ROOT...

Get-PnpDevice -PresentOnly | Where-Object { $_.Class -match '^Media' }
Result (here there are only audio devices, indeed "media"):
B4X:
Status     Class           FriendlyName                                                                     InstanceId
------     -----           ------------                                                                     ----------
OK         MEDIA           Galaxy A7 (2017) A2DP SNK                                                        BTHENUM\...
OK         MEDIA           Redmi1 A2DP SNK                                                                  BTHENUM\...
OK         MEDIA           Nokia 3.1 Hands-Free HF Audio                                                    BTHHFENU...
OK         MEDIA           Realtek(R) Audio                                                                 HDAUDIO\...
OK         MEDIA           AMD High Definition Audio Device                                                 HDAUDIO\...
OK         MEDIA           Redmi1 Hands-Free HF Audio                                                       BTHHFENU...
OK         MEDIA           Galaxy A7 (2017) Hands-Free HF Audio                                             BTHHFENU...
OK         MEDIA           Nokia 3.1 A2DP SNK                                                               BTHENUM\...

But it needs to get cameras indexes.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…