Back to Openframeworks

Face detection with yunet

examples/computer_vision/yunetFaceDetection/Readme.md

00731.1 KB
Original Source

Face detection with yunet

Face detection in OpenFrameworks using dnn

It turns out that doing face detection in 2025 is much more efficient with neural networks than cascades. So here is an OF example that uses opencv's facedetectoryn (for yunet).

You will need the file with the pre-trained model. The model version must be compatible with your opencv version.

How to find out your opencv version?

  • It will be printed out during the ofApp::setup() function.
  • If you have a version greater than 4.9, you can download the current face_detection_yunet_2023mar.onnx model
  • If your version is 4.6 or earlier, download the 2022 version of the model.

The versions are coded in the ofApp::setup() function. Different versions might require editing the code.

Expected behavior

The camera starts, and a red square will be drawn around the faces found.