Ask Your Question
1

DLIB hack - for improving face detection rate

asked 2018-02-26 06:16:46 -0600

Ivan888 gravatar image

updated 2018-02-26 06:17:02 -0600

Hi guys!

I have one quick question regarding DLIB, and would appreciate your help!

I noticed HAAR has less face detection rate comparing to DLIB (DLIB is more reliable). But DLIB has its lacks also.

For example, it fails to detect face of woman that covers one eye with hair. Is there any way to get around this (or only way is to train my own model)?

Many thanks! :) Ivan

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
4

answered 2018-02-26 07:18:46 -0600

mshabunin gravatar image

Check the latest DNN-based face detector: https://github.com/opencv/opencv/blob... (python version: https://github.com/opencv/opencv/blob...).

The model is here: https://github.com/opencv/opencv_3rdp... (FP16 model: https://github.com/opencv/opencv_3rdp...).

It consumes ~ 11 Mb memory for weights plus 38 Mb for blobs and runs at 40 ms per frame (25 FPS) on Core-i7. Also there can be possibility to offload processing to GPU using OpenCL backend.

Finally you can train your own model: https://github.com/opencv/opencv/blob...

edit flag offensive delete link more

Comments

Thanks alot!

I will try to play with it...

So obviously DLIB has its limits and DNN approach is better!

Ivan888 gravatar imageIvan888 ( 2018-02-26 08:45:29 -0600 )edit

BTW, DLib also has DNN support but I don't know any details.

mshabunin gravatar imagemshabunin ( 2018-02-26 12:32:57 -0600 )edit

@Ivan888 here is a Python tutorial on how to use the DNN-based face detector that you may be interested in (published today!)

phillity gravatar imagephillity ( 2018-02-26 19:18:50 -0600 )edit

Thanks alot guys!!

Do you know how to run this file (resnet_ssd_face.cpp) in a single separated (independent) folder? Maybe special version of CMakeLists.txt should be used...

Python code version works perfectly, but when I try to run .cpp file I get following error:

OPENCV Error: Unspecified error (FAILED: fs.is_open(): Cant open "") in ReadProtoFromTextFile, file tmp/opencv-20180113-80339-d8g5mw/opencv-3.4.0/modules/dnn/src/caffe/caffe_io,cpp, line 1119...

Abort trap: 6
Ivan888 gravatar imageIvan888 ( 2018-02-28 08:50:04 -0600 )edit

You need to supply file path to the prototext and model files as command line arguments. Then the command line arguments will be used for these lines:

String modelConfiguration = parser.get<string>("proto");
String modelBinary = parser.get<string>("model");

That way you can successfully load the model at this line:

dnn::Net net = readNetFromCaffe(modelConfiguration, modelBinary);

In the python version, these paths are hard-coded into the script:

prototxt = 'face_detector/deploy.prototxt'
caffemodel = 'face_detector/res10_300x300_ssd_iter_140000.caffemodel'

If you want, in the C++ version you can hardcode the modelConfiguration and modelBinary to equal the paths to these files the same way as the Python version. This way you won't need to supply them as arguments

phillity gravatar imagephillity ( 2018-02-28 11:51:12 -0600 )edit

Amazing! Thanks @phillity !

Ivan888 gravatar imageIvan888 ( 2018-03-01 02:33:59 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-02-26 06:16:46 -0600

Seen: 2,428 times

Last updated: Feb 26 '18