📜 ⬆️ ⬇️

Face Detection on Java is easy!

I hasten to share my joy with you :) I recently encountered a problem - it was necessary to determine the locations of the persons in the picture.

Why this is needed is another question: I, personally, needed to create a model of distribution of attention on the picture, and maybe it would be necessary for someone to select people automatically on a group photo like on Facebook.

Algorithms, in principle, well known. One of the best is the Viola & Jones algorithm, but the search for ready-made implementations did not bring results. It was upset, but drew attention to the wonderful native library - OpenCV . The library is valuable not only the implementation of the basic algorithms of computer vision, but the fact that it is found strongly on all platforms.
')
And what do you think? One of the first things on Google is that such a great project is the JNI interface to OpenCV!

A few minutes of downloading, ten minutes of reading the documentation with the installation of the program, and another ten - writing a test. And then, and here with these four lines, we simply take and recognize faces in the picture!

OpenCV cv = new OpenCV();
cv.loadImage("test.jpg", 300, 400);
cv.cascade("haarcascade_frontalface_default.xml");
Rectangle bounds[] = cv.detect();




As I understand it, the JNI interface was written by Bryan Chung for the Processing language (by the way, the video on the website is an illustration of the program's work), and the code was then finalized and uploaded to the Atelier hypermédia under the BSD license.

Source: https://habr.com/ru/post/60782/


All Articles