Skip to content

Instantly share code, notes, and snippets.

@boxysean
Created December 10, 2012 23:25
Show Gist options
  • Save boxysean/4254294 to your computer and use it in GitHub Desktop.
Save boxysean/4254294 to your computer and use it in GitHub Desktop.
import cv
import sys
import os
image = cv.LoadImage(sys.argv[1])
storage = cv.CreateMemStorage()
haar=cv.Load('haarcascade_frontalface_default.xml')
detected = cv.HaarDetectObjects(image, haar, storage, 1.1, 2, cv.CV_HAAR_DO_CANNY_PRUNING, (20,20))
if detected:
print "found one! %s", sys.argv[1]
for ((x,y,w,h), z) in detected:
cv.Rectangle(image, (x,y), (x+w,y+h), 255)
basename = os.path.basename(sys.argv[1])
cv.SaveImage(basename, image)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment