You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{VisionCamera}from'react-vision-camera';functionApp(){const[isActive,setIsActive]=React.useState(true);//whether the camera is activeconst[isPause,setIsPause]=React.useState(false);//whether the video is pausedconstonOpened=(cam:HTMLVideoElement,camLabel:string)=>{// You can access the video element in the onOpened eventconsole.log("opened");}constonClosed=()=>{console.log("closed");}constonDeviceListLoaded=(devices:MediaDeviceInfo[])=>{console.log(devices);}return(<div><VisionCameraisActive={isActive}isPause={isPause}desiredCamera="back"desiredResolution={{width:1280,height:720}}onOpened={onOpened}onClosed={onClosed}onDeviceListLoaded={onDeviceListLoaded}></VisionCamera></div>)}
FAQ
How to specify which camera to use?
Use the desiredCamera prop. If one of the camera's name contains it, then it will be used. You can get the devices list in the onDeviceListLoaded event.
Use the facingMode prop. Set it to environment to use the back camera. Set it to user to use the front camera. Please note that this is not supported on Desktop.
You can use the two props together. facingMode has a higher priority.