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.
JavaScript
x
37
37
1
<video autopĺay id="cam" width="400" height="400" muted></video>
2
3
<script>
4
5
const cam = document.getElementById('cam')
6
7
const startVideo = () => {
8
9
var constraints = { audio: true, video: { width: 1280, height: 720 } };
10
navigator.mediaDevices.getUserMedia(constraints)
11
.then(function(mediaStream) {
12
var video = document.querySelector('video');
13
video.srcObject = mediaStream;
14
video.onloadedmetadata = function(e) {
15
video.play();
16
};
17
})
18
.catch(function(err) { console.log(err.name + ": " + err.message); }); // always check for errors at the end.
19
}
20
21
Promise.all([
22
faceapi.nets.tinyFaceDetector.loadFromUri("<%= asset_path('face-api.js/models/tiny_face_detector_model-weights_manifest.json') %>",
23
faceapi.nets.faceLandmark68Net.loadFromUri("<%= asset_path('face-api.js/models/face_landmark_68_model-weights_manifest.json') %>", //desenha os traços do rosto
24
faceapi.nets.faceRecognitionNet.loadFromUri("<%= asset_path('face-api.js/models/face_recognition_model-weights_manifest.json') %>",//faz o conhecimento do rosto
25
faceapi.nets.faceExpressionNet.loadFromUri("<%= asset_path('face-api.js/models/face_expression_model-weights_manifest.json') %>",//detecta expressoes
26
faceapi.nets.ageGenderNet.loadFromUri("<%= asset_path('face-api.js/models/age_gender_model-weights_manifest.json') %>", //idade e genero
27
faceapi.nets.ssdMobilenetv1.loadFromUri("<%= asset_path('face-api.js/models/ssd_mobilenetv1_model-weights_manifest.json') %>" // usada para detectar rosto
28
]).then(startVideo)
29
30
cam.addEventListener('play', async() => {
31
const canvas = faceapi.createCanvasFromMedia(cam)
32
})
33
34
35
36
</script>
37
Advertisement
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.