Face Detection in VB.NET: Difference between revisions

From EMGU
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
Line 1: Line 1:
This Example requires [[Version_History#Emgu.CV-1.4.0.0|Emgu CV 1.4.0.0]].
'''This example requires [[Version_History#Emgu.CV-1.5.0.0|Emgu CV 1.5.0.0]]'''


<source lang=vb>
<source lang=vb>

Latest revision as of 03:45, 25 February 2009

This example requires Emgu CV 1.5.0.0

Imports Emgu.CV
Imports Emgu.CV.Structure
Imports Emgu.Util
Imports System.Windows.Forms
Imports System.Drawing


Module Module1

   Sub Main()
      'Load the image from file
      Dim img As New Image(Of Bgr, Byte)("lena.jpg")

      'Load the object detector
      Dim objectToDetect As New HaarCascade("haarcascade_frontalface_alt2.xml")

      'Convert the image to Grayscale
      Dim imgGray As Image(Of Gray, Byte) = img.Convert(Of Gray, Byte)()

      For Each face As MCvAvgComp In imgGray.DetectHaarCascade(objectToDetect)(0)
         img.Draw(face.rect, New Bgr(Color.White), 1)
      Next

      'Show the image
      UI.ImageViewer.Show(img)

   End Sub

End Module
Face Detection using VB.NET