![]()  | 
| Sample Face Detection | 
Create new WindowsForm Project, and drop a PictureBox Control.
You must add the Emgu libraries, by adding reffences of this DLL:
- Emgu.CV.dll
- Emgu.CV.UI.dll
- Emgu.Util.dll
Write this code:
Imports Emgu.CV
Imports Emgu.Util
Imports Emgu.CV.Structure
Imports Emgu.CV.UI
Public Class Form1
    Private Sub Form1_Load() Handles MyBase.Load
        Dim p As String = Application.StartupPath
        PictureBox1.Image = Image.FromFile("image.jpg")
        Dim ImageBgr As New Image(Of Bgr, Byte)(PictureBox1.Image)
        Dim HaarXML As New HaarCascade("haarcascade_frontalface_alt_tree.xml")
        Dim GrayImage As Image(Of Gray, Byte) = ImageBgr.Convert(Of Gray, Byte)()
        Dim ImgGraphics As Graphics = Graphics.FromImage(PictureBox1.Image)
        Dim MPen As New Pen(Brushes.YellowGreen, 8)
        ' Will take a several minute.. please wait..
        For Each m In GrayImage.DetectHaarCascade(HaarXML)(0)
            ImgGraphics.DrawRectangle(MPen, m.rect)
        Next
    End Sub
End Class
When you execute your program, this DLL file must in the same folder of your exe file:
- cvextern.dll
- Emgu.CV.dll
- Emgu.CV.UI.dll
- Emgu.Util.dll
if you need to download this project, DOWNLOAD HERE
From: http://xkom.blogspot.com 

In the part:
ReplyDeleteFor Each m In GrayImage.DetectHaarCascade(HaarXML)(0)
ImgGraphics.DrawRectangle(MPen, m.rect)
Next
What is "m"?
For each "what?"
:)
I am getting error as type haarcascade is not defined ;(
ReplyDelete