Webcam.set({ width: 490, height: 450, image_format: 'jpeg', jpeg_quality: 90, constraints: { facingMode: { exact: 'environment' } } });
This code works for all browsers.
constraints: {facingMode: { exact: 'environment' }}
Above the line is responsible for opening the rear camera, set limits: null to open the front camera. You can also customize this code by using the "switch camera" method
source share