dlib vs opencv which one to use when
Asked Answered
T

1

27

I am currently learning OpenCV API with Python and its all good. I am making decent progress. Part of it comes from Python syntax's simplicity as against using it with C++ which I haven't attempted yet. I have come to realize that I have to get dirty with C++ bindings for OpenCV at some point if I intend to do anything production quality.

Just recently I came across dlib which also claims to do all the things OpenCV does and more. Its written in C++ and offers Python API too (surprise). Can anybody vouch for dlib based on their own implementation experience?

Trulatrull answered 13/5, 2016 at 16:28 Comment(7)
I've used opencv extensively for image processing and hadn't heard of dlib. dlib looks like it has far more than just image processing (which you may or may not want) and also doesn't look as fully-featured as opencv. Also, opencv has many optimizations on many algorithms which don't seem to be present in dlibTinge
OpenCV - image processing library. Dlib - machine learning library. They are different and solving different tasks. Some projects need both of themLenka
Just a note: if you are compiling OpenCV from source you can add a huge amount of machine learning stuff to it.Entrails
When it comes to identifying faces, I did test OpenCV in identifying faces from images of decent resolution and I seem to be getting false positives over a small sample size of images (using all 4 available face recognition Haar Cascade xmls). I'm about to test dlib next as it should be better in recognizing faces via machine learning.Wept
You didn't say what kind of project you are working on, what are your goals and what kind of limitations you are facing. As it is there is no way to recommend you anything, because both libraries have different intended usage.Gorky
Use both. DLib even has functionality to work with OpenCV's image format cv::Mat.Sidonius
In addition to Vikas' answer and blog, check out towardsdatascience.com/…Melany
H
40

I have used both OpenCV and dlib extensively for face detection and face recognition and dlib is much accurate as compared to OpenCV Haar based face detector. ( Note that OpenCV now has a DNN module where we get Deep Learning based Face Detector and Face Recognizer models. )

I'm in the middle of comparing the OpenCV-DNN vs Dlib for face detection / recognition. Will post the results once I'm done with it.

There are many useful functions available in dlib, but I prefer OpenCV for any other CV tasks.

EDIT : As promised, I have made a detailed comparison of OpenCV vs Dlib Face Detection methods.

Here is my conclusion :

General Case

In most applications, we won’t know the size of the face in the image before-hand. Thus, it is better to use OpenCV – DNN method as it is pretty fast and very accurate, even for small sized faces. It also detects faces at various angles. We recommend to use OpenCV-DNN in most

For medium to large image sizes

Dlib HoG is the fastest method on CPU. But it does not detect small sized faces ( < 70x70 ). So, if you know that your application will not be dealing with very small sized faces ( for example a selfie app ), then HoG based Face detector is a better option. Also, If you can use a GPU, then MMOD face detector is the best option as it is very fast on GPU and also provides detection at various angles.

For more details, you can have a look at this blog

Hunkydory answered 28/9, 2018 at 12:16 Comment(1)
Gone through your blog. That was very detailed and nicely articulated blog ! .. The article mainly talks about face detection, I am more interested in comparison for face recognition... do you have any data /opinion on it or any such article?Putscher

© 2022 - 2024 — McMap. All rights reserved.