How can I do the Face Recognition on my Android App?

I would like some helpfull indications to implement Face Recognition on my Android App.

This piece of code can help me?

import org.opencv.core.*;
import org.opencv.dnn.*;
import org.opencv.imgcodecs.*;
import org.opencv.imgproc.*;

public class FaceRecognition {
    public static Mat process(Net net, Mat img) {
        Mat inputBlob = Dnn.blobFromImage(img, 1./255, 
             new Size(96,96), new Scalar(0,0,0), true, false);
        net.setInput(inputBlob);
        return net.forward().clone();
    }
    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        Net net = Dnn.readNetFromTorch("openface.nn4.small2.v1.t7");
        Mat feature1 = process(net, Imgcodecs.imread("Abdullah_Gul_0004.jpg"));
        Mat feature2 = process(net, Imgcodecs.imread("Abdullah_Gul_0007.jpg"));
        double dist  = Core.norm(feature1,  feature2);
        if (dist < 0.6)
            System.out.println("SAME !");
    }
}

nice, that you found that code ! :wink:

now, take a look at the android samples, try to integrate it, and report back
(we can help with problems, but no, we wont write your program)

How do I integrate it on my app?

I am neofita about Android Development.

I would like further indications about it.

do you have an app already ?
what exactly do you want to do with the face recognition ?
(how do you plan to acquire images, etc…)

I need to recognize the face of a registered user for executing specific operations.

I have the app, but I need to get some indications about implementing the face recognition.

How do I integrate that repository git on my app?

first part will be for sure - adding opencv libs to your app

(sorry, much outdated …)

I have added opencv on my app.

I want to know how I can integrated opencv/samples/android/tutorial-1-camerapreview at 4.x · opencv/opencv · GitHub on my app.