Face Detection from IronPython

From EMGU
Jump to navigation Jump to search

Note: This example is based on Emgu CV 2.2.0.0

Assume that you have followed everything from Setting up Emgu CV and IronPython. This example is going to show you how to do face detection from IronPython.

First copy the lena.jpg file from OpenCV sample directory to the IronPython folder. Then copy the haarcascade_frontalface_alt_tree.xml file to the IronPython folder as well. Then follow the steps below:

  • Create the detector by calling
detector = HaarCascade("haarcascade_frontalface_alt_tree.xml")
  • Read the image
image = Image[Gray, Byte]("lena.jpg")
  • Detect the objects
objectsDetected = image.DetectHaarCascade(detector)[0]
  • Draw the objects
for obj in objectsDetected: image.Draw(obj.rect, Gray(255), 1)
  • Display the image
ImageViewer.Show(image)
Face Detection from IronPython