Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

376
Visualizações
"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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda