1

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.

vasnakos
  • 61
  • 5
  • 1
    I have a little diagnostic web app that grabs a lot of getUserMedia constraint / characteristic / setting stuff from a mobile phone (or computer) browser. https://lit-mesa-75588.herokuapp.com/ It's not slick; it shows its output in JSON. Give it a try. You may see a constraint you can use. (The desktop version shows a QR code so you don't have to type the URL into your mobile device.) – O. Jones Apr 05 '21 at 12:00
  • Hi @O.Jones, I am planning to make a simple utility web app just for getting cameras and I think this does a similar job but better. I checked your GitHub repo just in case you already shared it but I wasn't able to find it. If it's alright, would you mind sharing the code for this? Thanks. – jp06 Jan 11 '22 at 13:26

0 Answers0