Face Detection in VB.NET

From EMGU
Revision as of 21:57, 22 November 2008 by Canming (talk | contribs)
Jump to navigation Jump to search

This Example requires Emgu CV 1.4.0.0.

Imports Emgu.CV
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 rect As Rectangle(Of Double) In imgGray.DetectHaarCascade(objectToDetect)(0)
         img.Draw(rect, New Bgr(Color.White), 1)
      Next

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

   End Sub

End Module
Face Detection using VB.NET