Difference between revisions of "Face Detection from IronPython"
From Emgu CV: OpenCV in .NET (C#, VB, C++ and more)
m |
|||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | Note: This example is | + | Note: This example is based on Emgu CV 2.2.0.0 |
− | Assume that you have | + | 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 | + | 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 | *Create the detector by calling | ||
− | < | + | <source lang="python"> |
− | detector = HaarCascade(" | + | detector = HaarCascade("haarcascade_frontalface_alt_tree.xml") |
− | </ | + | </source> |
*Read the image | *Read the image | ||
− | < | + | <source lang="python"> |
image = Image[Gray, Byte]("lena.jpg") | image = Image[Gray, Byte]("lena.jpg") | ||
− | </ | + | </source> |
*Detect the objects | *Detect the objects | ||
− | < | + | <source lang="python"> |
objectsDetected = image.DetectHaarCascade(detector)[0] | objectsDetected = image.DetectHaarCascade(detector)[0] | ||
− | </ | + | </source> |
*Draw the objects | *Draw the objects | ||
− | < | + | <source lang="python"> |
− | for obj in objectsDetected: image.Draw | + | for obj in objectsDetected: image.Draw(obj.rect, Gray(255), 1) |
− | </ | + | </source> |
*Display the image | *Display the image | ||
− | < | + | <source lang="python"> |
ImageViewer.Show(image) | ImageViewer.Show(image) | ||
− | </ | + | </source> |
[[image:IronPythonFaceDetect.png|300px|center|thumb|Face Detection from IronPython]] | [[image:IronPythonFaceDetect.png|300px|center|thumb|Face Detection from IronPython]] |
Latest revision as of 21:15, 28 October 2010
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)