How to call create_csv.py and crop_face.py

asked 2014-04-22 23:41:00 -0600

mit gravatar image

updated 2014-04-23 01:47:06 -0600

berak gravatar image

I have never worked on python, please if anyone could tell me "how" and "where" to call create_csv.py and crop_face.py. In the python scripts, create_csv.py and crop_face.py, provided in the following link where is the editing needed to be done: (http://docs.opencv.org/trunk/modules/contrib/doc/facerec/tutorial/facerec_video_recognition.html). I have installed python 2.7 and PIL-1.1.7.win-amd64-py2.7. I have read the documentation of face recognition in video using opencv 2.4.8, on which i am working, but there is no syntax provided of how to call these python scripts. Please help.

edit retag flag offensive close merge delete

Comments

1

the 1st one is easy. you open a cmdline, cd to the directory you need, and type:

python create_csv.py img_dir

(where img_dir is the folder with your training-database, like d:\att)

crop_face.py is a bit more tricky. it's more a demo/example, if you want to use it with your own images, you'd have to edit it, and change the image names (and eye locations) at the bottom in the __main__ part.

berak gravatar imageberak ( 2014-04-23 00:57:23 -0600 )edit

Do I have to provide the path to csv also in crop_face.py script(http://docs.opencv.org/trunk/modules/contrib/doc/facerec/tutorial/facerec_video_recognition.html) in def readFileNames(): try: inFile = open('path_to_created_csv_file.csv') except: raise IOError('There is no file named path_to_created_csv_file.csv in current directory.') return False Also as i have created a folder ,in D drive, containing three folders of the three subjects containing 2 photos each, what editing should be done in the crop_face.py script at the last while calling the function Crop?

mit gravatar imagemit ( 2014-04-23 03:07:00 -0600 )edit

oh, sorry, my local (3.0) copy does not have that part. (i'm sure, bytefish removed it for a reason.)

yes, you probably want to change this line:

inFile = open('path_to_created_csv_file.csv') # put your *real* csv filename here

still ,this won't solve the hardcoded eye positions (which leaves the whole thing quite unusable). and this is the hard part, since you have to add an automatic eye-finding procedure here (haarcascades, better even flandmark.)

so again, take it with a grain of salt. imho, the code there is more to give you an idea of appropriate measures to take on face images, i doubt, you can use it "as is".

berak gravatar imageberak ( 2014-04-23 03:31:59 -0600 )edit

Ok please tell me, where should I call it and the syntax. I tried doing it in python command line and typed: python crop_face.py d:/path to the folder, but it gave error as invalid syntax. How should run it after I 've done editing.?

mit gravatar imagemit ( 2014-04-23 04:02:26 -0600 )edit

if you edited the filename, it does not need additional cmdline args.

and to clear up the sytax error, you'd have to show the code (and where the error happens) . can't read you mind here

berak gravatar imageberak ( 2014-04-23 04:07:53 -0600 )edit