Skip to content

Instantly share code, notes, and snippets.

@salilkapur
Created April 25, 2013 22:30
Show Gist options
  • Save salilkapur/5463769 to your computer and use it in GitHub Desktop.
Save salilkapur/5463769 to your computer and use it in GitHub Desktop.
from SimpleCV import *
import cv2
img1 = cv2.imread('lenna.png')
haarClassify = cv2.CascadeClassifier('face.xml')
gray = cv2.cvtColor(img1,cv2.cv.CV_BGR2GRAY)
objects = haarClassify.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=3, minSize=(10, 10), flags = cv.CV_HAAR_SCALE_IMAGE)
print 'Opencv Output:'
print objects
print 'Coordinates of the center of the box'
print [objects[0][0]+objects[0][2]/2,objects[0][1]+objects[0][3]/2,objects[0][2],objects[0][3]]
img2 = Image('lenna.png')
h = HaarCascade('face.xml')
objects2 = img2.findHaarFeatures(h)
print 'SimpleCV output'
print objects2.coordinates(),objects2.width(),objects2.height()
Opencv Output:
[[217 201 174 174]]
Coordinates of the center of the box
[304, 288, 174, 174]
SimpleCV output
[[302 288]] [175] [175]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment