Posts Tagged ‘opencv’

Detecting Faces with Dlib from F#. IFSharp Notebook

March 11, 2017 Leave a comment

The Choices

I have experimented with OpenCV and Dlib face detection in my computer vision pipeline. Both work well, but the Dlib one worked better: it is more sensitive with (in my case) almost no false positives right out of the box!

Dlib uses several HOG filters that account for profile as well as frontal views. HOG detectors train quickly and are very effective. OpenCV uses Haar Cascades and doesn’t have the same versatility out of the box: you need separate data files for profiles and frontal views. In the case of OpenCV, you also need to experiment with the parameters quite a bit to get it where you want it to be.

Both libraries allow for custom trained detectors, but in my case it did not come to that: Dlib detector was sufficient.

Using Dlib in F# Code

Dlib is a C++ library, also available for Python. No love for .NET.

The step-by-step of calling dlib face detector from F# code is in the IFSharp Notebook, hosted on my GitHub. Here .NET, EmguCV (OpenCV), and Dlib all work happily together.

(Took Azure Notebooks for a spin, works pretty well).

Capture Video in 2 Lines of Code

March 21, 2016 3 comments

Literally. Well almost. 2 meaningful lines + some boilerplate. This has got to be easier than even Python!

Using EmguCV, a wrapper around OpenCV and F# Interactive:

#I @"C:\<project directory>\packages\EmguCV.3.0.0\lib\net451"
#r "Emgu.CV.dll"
#r "Emgu.Util.dll"
#r "System.Windows.Forms"

open Emgu.CV
open System.Windows.Forms

let capture = new Capture()
Application.Idle.Add(fun _ -> CvInvoke.Imshow("Camera", capture.QueryFrame()))

Categories: F# Tags: , , , ,