Coder Social home page Coder Social logo

Comments (4)

erenaud3 avatar erenaud3 commented on June 2, 2024 1

Hi @MohannadBakkar !

If you simply want a small help, this is the approach I used :

  • use opencv4nodejs to get a cv.rect that give you the position of a detected face in your webcam's frame
  • enlarge this rect (it will be too small for face recognition otherwise).
  • get a cropped image of your frame (to make recognition faster). Something like:
_croppedImage = _frame.getRegion(_enlargedRect);

# (you may need to add .resize(width, height)
  • convert your image "from opencv4nodejs to face-recognition"
_frFaceImg = fr.cvImageToImageRGB(fr.CvImage(_croppedImage));
  • recognize face
_faceResults = FaceRecognizer.predictBest(_frFaceImg);

As @justadudewhohacks pointed out in README, you could alternatively use face-api.js, which is newer, faster and more browser-friendly (but probably less "back-end friendly").

from face-recognition.js.

erenaud3 avatar erenaud3 commented on June 2, 2024 1

You welcome !

About face-api.js, I think you should consider give it a try. You will see it is really more efficient.
Even if it's clearly front-end oriented (at least when you look at example), you can also use it in back-end using tensors (from tensorflow).

You can find the code I used here to perform face detection on a webcam feed. (using opencv4nodejs to get webcam frames). You could easily add face recognition. Just do not forget to dispose your tensor, like I did !

from face-recognition.js.

MohannadBakkar avatar MohannadBakkar commented on June 2, 2024

@erenaud3 Thank you for your help.

also, I am actually not using any kind of front end, it's only back-end, that's why I didn't choose face-api.js.

from face-recognition.js.

MohannadBakkar avatar MohannadBakkar commented on June 2, 2024

What do you mean dispose of the tensor?

Now I'm facing a lot of lagging when I run the face recognizer on the webcam, I have 16 GB of ram btw.

from face-recognition.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.