Search code examples
tensorflowgetusermedia

React tensorflow: Set back camera with getUserMedia


I'm using tensorflow - react for object recognition on chrome. I want to use the back camera instead of the front one.

Here is the code:

  const webcamPromise = navigator.mediaDevices
        .getUserMedia({
          video: true,
          audio: false,
        })

It seems that adding facingMode: 'environment' doesn't work.


Solution

  • Where have you added facingMode: 'environment'? It should work with

    navigator.mediaDevices
            .getUserMedia({
              video: {facingMode: 'environment'},
              audio: false,
            })