Uncaught (in promise) TypeError: faceapi.allFacesMtcnn(...).map is not a function
See original GitHub issueI’m using VueJS. How can I fix these errors?
Code (VueJS)
onPlay: async function(videoEl) {
if(videoEl.paused || videoEl.ended || !modelLoaded)
return false;
let minFaceSize = 200;
const { width, height } = faceapi.getMediaDimensions(videoEl);
const canvas = document.getElementById('inputVideo');
canvas.width = width;
canvas.height = height;
const mtcnnParams = {
minFaceSize
};
const fullFaceDescriptions = (faceapi.allFacesMtcnn(videoEl, mtcnnParams)).map(fd => fd.forSize(width, height));
fullFaceDescriptions.forEach(({ detection, landmarks, descriptor }) => {
faceapi.drawDetection('overlay', [detection], { withScore: false });
faceapi.drawLandmarks('overlay', landmarks.forSize(width, height), { lineWidth: 4, color: 'red' });
const bestMatch = getBestMatch(trainDescriptorsByClass, descriptor);
const text = `${bestMatch.distance < maxDistance ? bestMatch.className : 'unkown'} (${bestMatch.distance})`;
const { x, y, height: boxHeight } = detection.getBox();
faceapi.drawText(
canvas.getContext('2d'),
x,
y + boxHeight,
text,
Object.assign(faceapi.getDefaultDrawOptions(), { color: 'red', fontSize: 16 })
)
});
setTimeout(() => onPlay(videoEl), 150);
},
run: async function() {
await faceapi.loadMtcnnModel("/img/face-api/weights");
await faceapi.loadFaceRecognitionModel("/img/face-api/weights/");
trainDescriptorsByClass = initTrainDescriptorsByClass(faceapi.recognitionNet);
modelLoaded = true;
const videoEl = document.getElementById('inputVideo');
navigator.getUserMedia(
{ video: {} },
stream => videoEl.srcObject = stream,
err => console.error(err)
);
this.onPlay(videoEl);
}
Code (HTML)
<div style="position: relative" class="margin">
<video ref="inputVideo" onload="onPlay(this)" id="inputVideo" autoplay="true" muted></video>
<canvas id="overlay" />
</div>
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
d is not a function when running faceapi using vue js in ...
Unfortunately, it keep throw me Uncaught (in promise) TypeError: d is not a function on this line of code but run smoothly when...
Read more >Uncaught (in promise) TypeError: data.map is not a function at ...
So I'm fairly new to Javascript (Started learning a few days ago), and I can't figure out how I could fix the code....
Read more >face-api.js
For face recognition, a ResNet-34 like architecture is implemented to compute a face descriptor (a feature vector with 128 values) from any given...
Read more >Object.map is not a function || How to map Object in Js, React ...
Hey Guys,In this video I have explained about map and how you can solve them. Also, how you can map on objects and...
Read more >Default MAP is Not a Function | React JS Tutorial - YouTube
While working with react js, you may get this error like: Default.a. map is not a function in react. I am using map...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok. Thanks for help.
You could use multiple images to compute reference descriptors and then compute the average of the euclidean distances between all reference descriptors and a input descriptor.
Usually, you should already get quite good results using a single image only. Can you share the image/s you are using as reference and the images of the faces, you are trying to recognize.