forked from bytefish/libfacerec
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added create_csv.py to ease the creation of the CSV file for new users.
- Loading branch information
Philipp Wagner
committed
Jun 25, 2012
1 parent
c6e3c11
commit e4a2e86
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import sys | ||
import os.path | ||
|
||
# This is a tiny script to help you creating a CSV file from a face | ||
# database with a similar hierarchie: | ||
# | ||
# philipp@mango:~/facerec/data/at$ tree | ||
# . | ||
# |-- README | ||
# |-- s1 | ||
# | |-- 1.pgm | ||
# | |-- ... | ||
# | |-- 10.pgm | ||
# |-- s2 | ||
# | |-- 1.pgm | ||
# | |-- ... | ||
# | |-- 10.pgm | ||
# ... | ||
# |-- s40 | ||
# | |-- 1.pgm | ||
# | |-- ... | ||
# | |-- 10.pgm | ||
# | ||
|
||
if __name__ == "__main__": | ||
|
||
if len(sys.argv) != 2: | ||
print "usage: create_csv <base_path>" | ||
sys.exit(1) | ||
|
||
BASE_PATH=sys.argv[1] | ||
SEPARATOR=";" | ||
|
||
label = 0 | ||
for dirname, dirnames, filenames in os.walk(BASE_PATH): | ||
for subdirname in dirnames: | ||
subject_path = os.path.join(dirname, subdirname) | ||
for filename in os.listdir(subject_path): | ||
abs_path = "%s/%s" % (subject_path, filename) | ||
print "%s%s%d" % (abs_path, SEPARATOR, label) | ||
label = label + 1 |