ageitgey / face_recognition

The world's simplest facial recognition api for Python and the command line
MIT License
53.54k stars 13.5k forks source link

C++ Support #256

Closed SriramEmarose closed 6 years ago

SriramEmarose commented 6 years ago

Hi All,

It is a great work. Thanks for the efforts. It is giving really good results.

One doubt is, Is there any API for the same library in C/C++? Though it is derived from Dlib, I hope the "FaceRecognition" function that Dlib offers is different from this implementation.

Would be a great help if you could point me to any such API calls if available.

Thanks, Sriram

ageitgey commented 6 years ago

If you want to use C++, just use dlib directly since C++ is what it's mainly designed for. See http://dlib.net/dnn_face_recognition_ex.cpp.html

The goal of this library is just to make face recognition super easy in Python and to provide an off-the-shelf solution that "just works" as much as possible (models automatically included, lots of examples, etc). But dlib is still doing all the face encoding and face detection work, so you should get the same results if you use the dlib's C++ api directly.

Some day this library may pull in alternate face detection/encoding models from outside dlib if needed, but that's not currently the case.

SriramEmarose commented 6 years ago

Hi,

Thank you very much for the prompt response. Will check it.

Thanks

ageitgey commented 6 years ago

Sure thing :)

Jayhello commented 6 years ago

@ageitgey , hello, I use dlib to do face detection (C++ code), core code like below:

dlib::frontal_face_detector detector = dlib::get_frontal_face_detector();

std::string img_path = "/data/service/face_rec/face_test/wlj1 (1).jpg";
dlib::array2d<unsigned char> img;
dlib::load_image(img, img_path);

std::vector<dlib::rectangle> dets = detector(img, 1);

I found the above code is about 5 times slow than python interface, do you know why?

ghost commented 6 years ago

@Jayhello Seriously?.This code is 5 times slower than python interface?.wow?.have you find the reason behind it?

creatist commented 6 years ago

@Jayhello Seriously?.This code is 5 times slower than python interface?.wow?.have you find the reason behind it?

I got the same mistake conclusion ago. But when i test Python API and C++ API again, i found C++ API is faster than Python API. Remember that the speed of face detector will be affected by the image size significantly.