Creates repository
17
.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>FaceMovie</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.python.pydev.PyDevBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.python.pydev.pythonNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
10
.pydevproject
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?eclipse-pydev version="1.0"?>
|
||||
|
||||
<pydev_project>
|
||||
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
|
||||
<path>/FaceMovie</path>
|
||||
</pydev_pathproperty>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
|
||||
</pydev_project>
|
||||
91
face_script.py
Normal file
@@ -0,0 +1,91 @@
|
||||
'''
|
||||
Created on 27 mars 2012
|
||||
|
||||
@author: jll
|
||||
Adaptation from a code found here :
|
||||
http://japskua.wordpress.com/2010/08/04/detecting-eyes-with-python-opencv/
|
||||
'''
|
||||
import cv
|
||||
|
||||
def detectRedEyes(image, faceCascade, eyeCascade):
|
||||
min_size = (20,20)
|
||||
image_scale = 2
|
||||
haar_scale = 1.2
|
||||
min_neighbors = 2
|
||||
haar_flags = 0
|
||||
|
||||
# Allocate the temporary images
|
||||
gray = cv.CreateImage((image.width, image.height), 8, 1)
|
||||
smallImage = cv.CreateImage((cv.Round(image.width / image_scale),
|
||||
cv.Round (image.height / image_scale)), 8 ,1)
|
||||
# Convert color input image to grayscale
|
||||
cv.CvtColor(image, gray, cv.CV_BGR2GRAY)
|
||||
# Scale input image for faster processing
|
||||
cv.Resize(gray, smallImage, cv.CV_INTER_LINEAR)
|
||||
# Equalize the histogram
|
||||
cv.EqualizeHist(smallImage, smallImage)
|
||||
|
||||
# Detect the faces
|
||||
faces = cv.HaarDetectObjects(smallImage, faceCascade, cv.CreateMemStorage(0),
|
||||
haar_scale, min_neighbors, haar_flags, min_size)
|
||||
|
||||
# If faces are found
|
||||
if faces:
|
||||
for ((x, y, w, h), n) in faces:
|
||||
# the input to cv.HaarDetectObjects was resized, so scale the
|
||||
# bounding box of each face and convert it to two CvPoints
|
||||
pt1 = (int(x * image_scale), int(y * image_scale))
|
||||
pt2 = (int((x + w) * image_scale), int((y + h) * image_scale))
|
||||
cv.Rectangle(image, pt1, pt2, cv.RGB(255, 0, 0), 3, 8, 0)# If faces are found
|
||||
|
||||
# Estimate the eyes position
|
||||
# First, set the image region of interest
|
||||
# The last division removes the lower part of the face to lower probability for false recognition
|
||||
cv.SetImageROI(image, (pt1[0],
|
||||
pt1[1],
|
||||
pt2[0] - pt1[0],
|
||||
int((pt2[1] - pt1[1]) * 0.6)))
|
||||
|
||||
# Detect the eyes
|
||||
eyes = cv.HaarDetectObjects(image, eyeCascade,
|
||||
cv.CreateMemStorage(0),
|
||||
haar_scale, min_neighbors,
|
||||
haar_flags, (20,15))
|
||||
# If eyes were found
|
||||
if eyes:
|
||||
# For each eye found
|
||||
for eye in eyes:
|
||||
# Draw a rectangle around the eye
|
||||
cv.Rectangle(image,
|
||||
(eye[0][0],
|
||||
eye[0][1]),
|
||||
(eye[0][0] + eye[0][2],
|
||||
eye[0][1] + eye[0][3]),
|
||||
cv.RGB(255, 0, 0), 1, 8, 0)
|
||||
|
||||
# Finally, reset the image region of interest (otherwise this won t
|
||||
# be drawn correctly
|
||||
cv.ResetImageROI(image)
|
||||
|
||||
return image
|
||||
|
||||
|
||||
def load():
|
||||
|
||||
image = cv.LoadImage("input/Axel/2012-01-12-13h54m34DSCN9766.JPG")
|
||||
faceCascade = cv.Load("haarcascades/haarcascade_frontalface_alt.xml")
|
||||
eyeCascade = cv.Load("haarcascades/haarcascade_eye.xml")
|
||||
return (image, faceCascade, eyeCascade)
|
||||
|
||||
def display(image):
|
||||
cv.NamedWindow("Red Eye Test", cv.CV_WINDOW_AUTOSIZE)
|
||||
cv.ResizeWindow("Red Eye Test", 10, 10)
|
||||
cv.ShowImage("Red Eye Test", image)
|
||||
cv.WaitKey(0)
|
||||
cv.DestroyWindow("Red Eye Test")
|
||||
|
||||
if __name__ == '__main__':
|
||||
print "test"
|
||||
image, faceCascade, eyeCascade = load()
|
||||
image = detectRedEyes(image, faceCascade, eyeCascade)
|
||||
display(image)
|
||||
17
facemovie.py
Normal file
@@ -0,0 +1,17 @@
|
||||
'''
|
||||
Created on 27 mars 2012
|
||||
|
||||
@author: jll
|
||||
'''
|
||||
|
||||
class FaceMovie(object):
|
||||
'''
|
||||
Main class of the project
|
||||
'''
|
||||
|
||||
|
||||
def __init__(self):
|
||||
'''
|
||||
Constructor
|
||||
'''
|
||||
pass
|
||||
15452
haarcascades/haarcascade_eye.xml
Normal file
33158
haarcascades/haarcascade_eye_tree_eyeglasses.xml
Normal file
26161
haarcascades/haarcascade_frontalface_alt.xml
Normal file
23550
haarcascades/haarcascade_frontalface_alt2.xml
Normal file
103493
haarcascades/haarcascade_frontalface_alt_tree.xml
Normal file
35712
haarcascades/haarcascade_frontalface_default.xml
Normal file
18118
haarcascades/haarcascade_fullbody.xml
Normal file
9803
haarcascades/haarcascade_lefteye_2splits.xml
Normal file
15085
haarcascades/haarcascade_lowerbody.xml
Normal file
10930
haarcascades/haarcascade_mcs_eyepair_big.xml
Normal file
12586
haarcascades/haarcascade_mcs_eyepair_small.xml
Normal file
9322
haarcascades/haarcascade_mcs_leftear.xml
Normal file
23791
haarcascades/haarcascade_mcs_lefteye.xml
Normal file
21991
haarcascades/haarcascade_mcs_mouth.xml
Normal file
48433
haarcascades/haarcascade_mcs_nose.xml
Normal file
9671
haarcascades/haarcascade_mcs_rightear.xml
Normal file
42252
haarcascades/haarcascade_mcs_righteye.xml
Normal file
46327
haarcascades/haarcascade_mcs_upperbody.xml
Normal file
31930
haarcascades/haarcascade_profileface.xml
Normal file
9833
haarcascades/haarcascade_righteye_2splits.xml
Normal file
29767
haarcascades/haarcascade_upperbody.xml
Normal file
BIN
input/Axel/2012-01-12-13h54m34DSCN9766.JPG
Normal file
|
After Width: | Height: | Size: 2.4 MiB |
BIN
input/Axel/2012-01-15-06h13m41DSCN9849.JPG
Normal file
|
After Width: | Height: | Size: 2.5 MiB |
BIN
input/Axel/2012-02-01-07h21m31DSCN0179.JPG
Normal file
|
After Width: | Height: | Size: 2.6 MiB |
BIN
input/Axel/2012-02-06-10h22m13DSCN0384.JPG
Normal file
|
After Width: | Height: | Size: 3.5 MiB |
BIN
input/Axel/2012-03-07-10h07m40DSCN1660.JPG
Normal file
|
After Width: | Height: | Size: 2.3 MiB |
BIN
input/Axel/2012-03-08-12h09m30DSCN1671.JPG
Normal file
|
After Width: | Height: | Size: 2.7 MiB |
BIN
input/Axel/2012-03-08-12h10m37DSCN1672.JPG
Normal file
|
After Width: | Height: | Size: 2.6 MiB |
BIN
input/MichaelShanks.jpg
Normal file
|
After Width: | Height: | Size: 9.9 KiB |
BIN
input/search.jpg
Normal file
|
After Width: | Height: | Size: 35 KiB |
9
main_file.py
Normal file
@@ -0,0 +1,9 @@
|
||||
'''
|
||||
Created on 29 mars 2012
|
||||
|
||||
@author: jll
|
||||
'''
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Main test file to test current application
|
||||
print "test"
|
||||