gv22ga / dlib-face-recognition-android

Android app to demo dlib face recognition
MIT License
148 stars 50 forks source link

Regarding Face Recognition #5

Open kpractice opened 6 years ago

kpractice commented 6 years ago

Hi, While googling for dlib face recognition on android, I stumbled upon your code. A nice effort to share the pointers about dlib recognition.

I have few queries on the code. Can you please help in understanding internals of the code? 1) While an image is added -> train() method is called. In native layer: mRecPtr->train(); is called. What exactly is trained here? No arguments were passed to this function

2) After clicking on add[choose image from gallery/camera] -> FaceRect.detect() is called and the bitmap image is written into filesystem [In AddPerson.java -> detectAsync()] fo.write(bytes.toByteArray());

But I couldn't find this data is being used again

3) How does the recognition happening? native method: jniBitmapRec() is called w.r.t what the image recognition is happening?

4) I tried to write my own jni file and do some changes - but while compiling getting open CV undefined reference errors [Testing in android studio] undefined reference to cv::error(int, cv::String const&, char const*, char const*, int)' undefined reference tocv::Mat::copyTo(cv::_OutputArray const&) const'

My Android.mk file is below


OPENCV_PATH := D:/opencv-3.4.1-android-sdk/OpenCV-android-sdk/sdk/native/jni include $(CLEAR_VARS) OpenCV_INSTALL_MODULES := on OPENCV_CAMERA_MODULES := off include $(OPENCV_PATH)/OpenCV.mk

LOCAL_MODULE := tdlib LOCAL_C_INCLUDES := src/main/cpp/ \ $(OPENCV_PATH)/include

LOCAL_SRC_FILES := src/main/cpp/.cpp LOCAL_LDLIBS := -latomic -ljnigraphics -ldl -llog -lm -lz include $(BUILD_SHARED_LIBRARY)


Thank you in advance.

gv22ga commented 6 years ago

Hi,

2 When you add a person, his image get saved in <sd_card>/dlib_rec_example/images/<person_name>.jpg dir.

1 When the train() method is called in native layer, it read all the face images from <sd_card>/dlib_rec_example/images dir and calculates face descriptors for all. It maintains a std::vector of face descriptors and corresponding person names.

3 When face recognition is called, the face descriptors for the current image is calculated and compared with face descriptors calculated above. If there is a match, the person is recognized.

4 Not sure about this. Will look into this when I get time.

Let me know if there is any other problem

kpractice commented 6 years ago

Thank you for your response. When I tested your code as is, I was always getting no match found even for almost same images. I will recheck, whats wrong with that. If you do get time, please do verify that opencv reference errors.

Thank you again.

kuldeepNimawat commented 4 years ago

I have faced issue of getting multiple result when search face. I want to get best match, please help me how I can check best match from multiple results. Confidence for all match return always 0.0 so I found I am not able to achieve my goal. If you can help me, thanks in advance.