I want to implement react-webcam to capture frames from it,but the problem is when the camera turns on the video is not displayed and the camera turns of itself after sometime, I tried many solutions but won't work below is my basic implementation.
(我想实现react-webcam来捕获其中的帧,但是问题是当摄像机打开视频时未显示并且摄像机在一段时间后自身转动时,我尝试了许多解决方案,但下面的工作是我的基本实现。)
setRef = (webcam)=>{
this.webcam= webcam
};
capture= () =>{
const imageSrc=this.webcam.getScreenshot();
this.setState({
imageData:imageSrc
})
};
render() {
const videoConstraints={
width:1280,
height:720,
facingMode: 'user'
};
return (
<div>
<Webcam
audio={false}
height={350}
ref={this.setRef}
screenshotFormat="image/jpeg"
width={350}
videoConstraints={videoConstraints}/>
<button onClick={this.capture}>capture</button>
</div>
);
}
}
how can I fix I have been stucked in this for so long, also tried other method but I want to use react-webcam.
(我该如何解决我已经困扰了这么长时间,也尝试了其他方法,但是我想使用react-webcam。)
ask by Muhammad Nabeel translate from so