Attention! This forum will be made read-only by Dec-20. Please migrate to Most of existing active users should've received invitation by e-mail.
Ask Your Question

how to run python script to align faces in windows 7

asked 2013-03-14 02:52:59 -0500

sujith.92 gravatar image

hi friends i am new to opencv . i'm trying to create training set to recognize person. but the problem is i cant align faces in proper manner. so i googled it and found python script in opencv documentation but i am gettin this error

Traceback (most recent call last): File "", line 34, in <module> import sys, math, Image ImportError: No module named 'Image'

iam new to opencv and p[ython please help...

thanks in advanc

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2013-03-14 03:52:28 -0500

berak gravatar image

updated 2013-03-14 05:22:34 -0500

"ImportError: No module named 'Image'"

it seems, you're lacking PIL

it does not come with the standard python windows installer, you have to get that separately

but, please reconsider what StevenPuttemans said in his answer, once you've trained your face-reco, and try to detect candidates, you'll probably have a cascade-detector in front of that anyway, and it really pays to do exactly the same kind of cropping in the training and the detection stage!

edit flag offensive delete link more

answered 2013-03-14 03:56:18 -0500

Something you could do is apply the viola&jones framework to detect the face and the eyes using the provided cascades in the data folder. Then once you know the eyes bounding boxes, you can calculate a rotation to get them at the same height, then apply translation to your images in order to place all eye regions on the same level.

I have read that isn't the best approach around, but I have used it and it worked. Have done it in C++ but I guess the functionality will be available in python also, since the same libraries are actually used.

Just be sure that your python environment is configured correctly, meaning the correct includes and linker options are set, and that your system has the correct PATH variables added.

Link of the C++ tutorial:


edit flag offensive delete link more
Login/Signup to Answer

Question Tools


Asked: 2013-03-14 02:52:59 -0500

Seen: 405 times

Last updated: Mar 14 '13