Skip to content
Advertisement

Error in my script SyntaxError: missing ) after argument list [closed]

I have this script and he return this error in console SyntaxError: missing ) after argument list but i dont found where is the error in my code.

<video autopĺay id="cam" width="400" height="400" muted></video>

<script>  

    const cam = document.getElementById('cam')

    const startVideo = () => {

        var constraints = { audio: true, video: { width: 1280, height: 720 } }; 
            navigator.mediaDevices.getUserMedia(constraints)
            .then(function(mediaStream) {
                var video = document.querySelector('video');
                video.srcObject = mediaStream;
                video.onloadedmetadata = function(e) {
                    video.play();
                };
            })
        .catch(function(err) { console.log(err.name + ": " + err.message); }); // always check for errors at the end.
}

Promise.all([
       faceapi.nets.tinyFaceDetector.loadFromUri("<%= asset_path('face-api.js/models/tiny_face_detector_model-weights_manifest.json') %>",
       faceapi.nets.faceLandmark68Net.loadFromUri("<%= asset_path('face-api.js/models/face_landmark_68_model-weights_manifest.json') %>", //desenha os traços do rosto
       faceapi.nets.faceRecognitionNet.loadFromUri("<%= asset_path('face-api.js/models/face_recognition_model-weights_manifest.json') %>",//faz o conhecimento do rosto
       faceapi.nets.faceExpressionNet.loadFromUri("<%= asset_path('face-api.js/models/face_expression_model-weights_manifest.json') %>",//detecta expressoes
       faceapi.nets.ageGenderNet.loadFromUri("<%= asset_path('face-api.js/models/age_gender_model-weights_manifest.json') %>", //idade e genero
       faceapi.nets.ssdMobilenetv1.loadFromUri("<%= asset_path('face-api.js/models/ssd_mobilenetv1_model-weights_manifest.json') %>" // usada para detectar rosto
]).then(startVideo)

cam.addEventListener('play', async() => {
    const canvas = faceapi.createCanvasFromMedia(cam)
})  



</script>

Answer

At the end of all your faceapi.nets. lines inside the big Promise.all, you end all the lines with just a comma rather than ending with ),. Since you are calling loadFromUri, you need to close the function before moving onto the next one.

Advertisement