justadudewhohacks / face-api.js

JavaScript API for face detection and face recognition in the browser and nodejs with tensorflow.js
MIT License
16.68k stars 3.71k forks source link

Face API totally not working on Samsung #868

Open ScratchCoder135 opened 2 years ago

ScratchCoder135 commented 2 years ago

Samsung Internet Browser unsupport?

I've made a Node JS express app,with FaceAPI as client-Side Js.It's good on Windows 10,but when I test the app on Samsung Browser,there is no camera active.Do I have to code something that ask for permisssion or something?

//code learned from WebDevSimplified on Youtube
Promise.all([
    faceapi.nets.tinyFaceDetector.loadFromUri('/models'),
    faceapi.nets.faceLandmark68Net.loadFromUri('/models'),
    faceapi.nets.faceRecognitionNet.loadFromUri('/models'),
    faceapi.nets.faceExpressionNet.loadFromUri('/models'),
    faceapi.nets.ageGenderNet.loadFromUri('/models'),
]).then(startVid)

function startVid(){
    navigator.getUserMedia(
        {video:{}},
        stream=>video.srcObject=stream,
        err=>console.error(err)
    )
}

video.addEventListener('play',()=>{
    setInterval(async ()=>{
        const detections=await faceapi.detectSingleFace(video,new faceapi.TinyFaceDetectorOptions()).withFaceLandmarks().withFaceExpressions().withAgeAndGender()
    },100)
})
vladmandic commented 2 years ago

android chrome does not allow autoplay of videos without user interaction.
easiest is to setup a click event somewhere that calls video.play() - only then you'll actually trigger your play event which does the inference.