victordibia / handtrack.js

A library for prototyping realtime hand detection (bounding box), directly in the browser.
https://victordibia.com/handtrack.js/
MIT License
2.83k stars 250 forks source link

Cannot detect for live camera? #52

Open ngochai27595 opened 3 years ago

ngochai27595 commented 3 years ago

Hi author, I'm trying to detect hand of two cameras in my conference like below image. But the result always return null. Could you help me? Thanks Here is my code: const largeVideo = ((document.getElementById('largeVideo'): any): HTMLVideoElement); const localVideo = ((document.getElementById('localVideo_container'): any): HTMLVideoElement); // Load the model. const defaultParams = { flipHorizontal: false, modelType: "ssd640fpnlite", modelSize: "medium", }; handTrack.load(defaultParams).then(model => { console.log("model loaded"); setTimeout(() => { clearInterval(checkHighFive); }, 6000); checkHighFive = setInterval(()=>{ let localHand = false; model.detect(localVideo).then(predictions => { console.log('Predictions localVideo: ', predictions); if(predictions.lenght > 0 && predictions[0].label == "open"){ localHand = true; } }); model.detect(remoteVideo).then(predictions => { console.log('Predictions remoteVideo: ', predictions); if(predictions.lenght > 0 && predictions[0].label == "open" && localHand){ this.props.dispatch(highFive(true)); setTimeout(() => { this.props.dispatch(highFive(false)); }, 4000); this.props.conference.sendCommandOnce('HIGH_FIVE', { value:_participant.id }); clearInterval(checkHighFive); } }); }, 500); }) image