Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

362
Views
"Error: euclideanDistance: arr1.length !== arr2.length" in face-api

I am currently creating a facial recognition system using this API: https://github.com/justadudewhohacks/face-api.js/

Reference: https://blog.mdzulkarnine.com/building-face-recognition-api-with-nodejs-expressjs-mongodb-face-apijs

In client-side, after successful detection of the face it will fetch post request to the server and send the resizedDetection

        $("#face").attr("src",img_data);
        const input = await $('#face')[0];

        const detection = await faceapi.detectAllFaces(input).withFaceLandmarks().withFaceDescriptors();
        const resized = await faceapi.resizeResults(detection, displaySize);

        if(!fetched && resized) {
            fetched = true;

            await fetch('/establishment/verify', { 
                method: 'POST', 
                headers: {
                    "content-type": "application/json"
                }, 
                body:  JSON.stringify({ resized }) 
                // descriptor
            })
            .then((response)=> {
                console.log(response);
            });
        }

In the server, it will accept the resizedDetection from the client-side.

const verification_post = async (req, res) => {
    try {
        const resizedDetections = req.body.resized;

        let visitors = await Visitor.find();
        
        for(i=0;i<visitors.length;i++) {
            for (j = 0; j < visitors[i].descriptions.length; j++) {
                visitors[i].descriptions[j] = new Float32Array(Object.values(visitors[i].descriptions[j]));
            }
            visitors[i] = new faceapi.LabeledFaceDescriptors(visitors[i]._id.toString(), visitors[i].descriptions);
        }

        const faceMatcher = new faceapi.FaceMatcher(visitors, 0.6);
        console.log("Faces: ", visitors);
        console.log("Resized Detections: ", resizedDetections);
        const results = resizedDetections.map((des) => faceMatcher.findBestMatch(des.descriptor));
    } catch (error) {
        console.log(error);
        res.status(400).send(error);
    }
}

The visitors and resizedDetection is displaying correctly, but it is not proceeding to the part of results, and returning the error "Error: euclideanDistance: arr1.length !== arr2.length". Is there anyone who tried working with it?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!