Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
261 views
in Technique[技术] by (71.8m points)

javascript - React-webcam会在一段时间后自动关闭(React-webcam turns off after sometime automatically)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...