question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught (in promise) TypeError: faceapi.allFacesMtcnn(...).map is not a function

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
chtsngncommented, Aug 11, 2018

Ok. Thanks for help.

1reaction
justadudewhohackscommented, Aug 11, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found