Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

Java + OpenCV?

Anyone here experienced with Java + OpenCV to help me out with Facial Recognition. I basically wish to make a simple program of running a webcam to scan face, I managed to do the face detecation, but I need to help with comparing faces or rather known as facial recognition..

If anyone can help me out that would be great! Thanks!
I'm assuming you already have loaded the classifiers and have some kind of detection method separate.

First you need to convert the frame in grayscale and equalize histogram.
Code
Imgproc.cvtColor(frame, grayFrame, Imgproc.COLOR_BGR2GRAY);
Imgproc.equalizeHist(grayFrame, grayFrame);

then you'll want to set the min. size for the face to be detected This will set the min. size at 20%
Code
if (this.absoluteFaceSize == 0)
{
    int height = grayFrame.rows();
    if (Math.round(height * 0.2f) > 0)
    {
            this.absoluteFaceSize = Math.round(height * 0.2f);
    }
}

Now initiate the detection
Code
this.faceCascade.detectMultiScale(grayFrame, faces, 1.1, 2, 0 | Objdetect.CASCADE_SCALE_IMAGE, new Size(this.absoluteFaceSize, this.absoluteFaceSize), new Size());

Put results in an aray of rects and draw them out
Code
Rect[] facesArray = faces.toArray();
for (int i = 0; i < facesArray.length; i++)
    Imgproc.rectangle(frame, facesArray[i].tl(), facesArray[i].br(), new Scalar(0, 255, 0, 255), 3);

Should now recognize different faces.
Look at somthing more sophisticated than OpenCV like deep learning facial recognition. This deep neural network stuff is getting very good and very accurate now.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by _NZT_Dec 18, 2020 02:42 AM 4 122 Dec 18, 2020 02:42 AM
Last Post: The-Criminal
[Python] by dondevetoJul 12, 2020 02:28 PM 3 127 Jul 12, 2020 02:28 PM
Last Post: dondeveto
[Python] by severosDec 1, 2017 02:07 PM 0 108 Dec 1, 2017 02:07 PM
Last Post: severos