Can I create a stream from macro camera when available?

484 Views Asked by At

Is there any way to get a stream of the macro camera using the mediaDevices.getUserMedia(constraints)?

I'm trying to create a web app that will scan printed out barcodes and noticed that on some phones like Samsung A51, if I just use the facingMode: environment as a constraint, it opens the default camera which cannot focus on very small distances and as a result I have to change camera (I get them via enumerateDevices())and test again till I find the proper one (macro).

So, I was thinking of applying some more specific constraints to fetch the macro camera at first try, but I am not sure what exactly constraints to apply.

0

There are 0 best solutions below