Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

202
Vistas
use script JavaScript in contoller laravel

i need to use this script inside a laravel controller. the script uses a facial recognition library to compare the faces that are in the photos. How can I use this code inside a public function?

    const imageUpload = document.getElementById('imageUpload')
Promise.all([
    faceapi.nets.faceRecognitionNet.loadFromUri('/models'),
    faceapi.nets.faceLandmark68Net.loadFromUri('/models'),
    faceapi.nets.ssdMobilenetv1.loadFromUri('/models'),
    faceapi.nets.tinyFaceDetector.loadFromUri('/models')
  ]).then(start)

 
  
  

async function start() {
  
  document.body.append('Loaded')
  imageUpload.addEventListener('change', async () => {
    
    image = await faceapi.bufferToImage(imageUpload.files[0])
    
    const descriptions = []
    const detections1 = await faceapi.detectAllFaces(image).withFaceLandmarks().withFaceDescriptors();
    
    const faceMatcher = new faceapi.FaceMatcher(detections1, 0.6)

    var a = 0;
    const images = [];
    for (var i = 100; i <= 618; i++) {
      let image = 0;
      let img = new Image();
      img.src = 'test/' + i + '.jpeg';
      image = i + '.jpeg';
  
      const results = await faceapi.detectAllFaces(img).withFaceLandmarks().withFaceDescriptors()
      results.forEach(fd => {
        const bestMatch = faceMatcher.findBestMatch(fd.descriptor)

        if (bestMatch.label == "person 1") {
          
          images[a] = image;
          a++;
        }
        
      })
    
     
      }
  })
  

  
  }

This project is to work as an API, I don't want it to have views, the user will just have an APP in react native making requests to the laravel API

about 4 years ago · Santiago Gelvez
2 Respuestas
Responde la pregunta

0

Laravel is php. The php interpreter does not execute javascript. You can run JS in a browser OR in a nodeJS micro-service. If you really want to get funky you can setup a headless browser on your server.

about 4 years ago · Santiago Gelvez Denunciar

0

You can't run javascript in Laravel controller. Also this function loads from the DOM, so it needs a document.

about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda