C# Face recognition app with Emgu CV library

in #utopian-io8 years ago (edited)

Emgu Cv - Face recognition app

This app is recognizing faces in your webcam.

Emgu Cv install

You can install Emgu Cv library in NuGet Packages.
image.png

After that you must call libraries. You can do it with this code:

using Emgu.CV;
using Emgu.Util;
using Emgu.CV.Structure;
using Emgu.CV.CvEnum;

Now you can use Emgu cv functions.
Here is Emgu CV documantation

İnput Format - Machine Learning

When the application is started, it captures the image on the camera. And this image made by frames.

Image<Bgr, byte> binaryGoruntu = webcam.QueryFrame().ToImage<Bgr, Byte>()

in this row we are converting frames to Image<Bgr, byte> Array.

After that for the process this converted image , we need to convert image to grayscale.

 Image<Gray, byte> greyScaleGoruntu = binaryGoruntu.Convert<Gray, byte>();

This type of facial recognition, object detection apps generally use XML based HAAR CASCADEfiles.
These files are containing training data for machine learning. You can find these files in the Internet.

The images are searching in the Haar file and the found faces are return. And the binary image we captured at the beginning is overwritten.

Rectangle[] rectangles = haar.DetectMultiScale(greyScaleGoruntu, 1.4, 1, new Size(100, 100), new Size(800, 800));
                    foreach (var face in rectangles)
                    {
                        binaryGoruntu.Draw(face, new Bgr(0, double.MaxValue, 0), 3);
                    }
                    pictureBox1.Image = binaryGoruntu.ToBitmap();

Complexity Analysis

When you examine the Emgu Cv library, detectMultiScale method is the method of machine learning.

Ekran Alıntısı22.JPG

In the worst case Complexity is O(n).

The complexity of the test phase is O(n) because foreach loop will return once.

Test

In this app we have two buttons:

  • Open Cam
  • Close Cam

Screenshot_7.jpg

My Github profile
Projects Github Link



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Nice post followed and up vote u i hope u will do same for me please

Your contribution cannot be approved because it does not follow the Utopian Rules.

Your work is entirely focused on an existing library which offers this functionality already and your own code is very little contribution to be considered as a Development Contribution.

And with that there is already a tutorial present on the existing website itself to do it, Click here if you want to check it.

Thanks!!

You can contact us on Discord.
[utopian-moderator]

Coin Marketplace

STEEM 0.13
TRX 0.34
JST 0.033
BTC 115467.20
ETH 4473.72
SBD 0.86