serratus/quaggaJS

Note10 S20 - New phones with multiple cameras

Closed this issue · 6 comments

Seems like there is a problem with the new multicamera phones.
On the "old" phones everything is perfect... on the new ones I can only guess, the wrong camra is used.

Is there any solution for this?

Yep. Such as most LG phones since at least the G6, I think a bit earlier than that, you have multiple rear cameras, one of which is usually a wide-angle, and totally fisheyes whatever it is that you're looking at, which becomes unscannable with Quagga. (maybe someone could implement an anti-fisheye effect...)

You can use Quagga.CameraAccess.enumerateVideoDevices() to get a list of all the camera devices and allow for the user to select which one to use, based on it's deviceId. Then you can pass the deviceId into Quagga.init instead of the 'facing' property, and it will use the given device. I believe this is in the examples in the repo, also

Is there an example of how to use Quagga.CameraAccess.enumerateDevices()?

It works exactly the same way as the built-in enumerateDevices but filters out everything that isn't a video input device.
(i just realized it's "Quagga.CameraAccess.enumerateVideoDevices" and updated my first comment)

Here's the test for CameraAccess.enumerateVideoDevices in my fork https://github.com/ericblade/quagga2/blob/0e7228e29793d132f8f78debcb455b369ed798ad/src/input/test/browser/camera_access.spec.ts#L31

and here's the example from the example folder in the source https://github.com/ericblade/quagga2/blob/master/example/live_w_locator.js#L85

On a PC, you can serve from localhost, and Chrome will let you use the Camera APIs if you're connecting to localhost. You can also run Web Inspector in Chrome on your desktop, and attach it to your Android phone.

Remote debugging Android: https://developers.google.com/web/tools/chrome-devtools/remote-debugging