diff options
| author | Jon Whiteaker <jbw@jon-th-desktop.(none)> | 2012-02-15 16:51:17 -0800 |
|---|---|---|
| committer | Jon Whiteaker <jbw@jon-th-desktop.(none)> | 2012-02-15 16:51:17 -0800 |
| commit | d889de1824d70e90b2b1e2c51120517b8fbafea7 (patch) | |
| tree | f7d697fe04e79c8c2c819d7fa0f37298ae96c40b /data/face-test.py | |
| parent | 83c5e1cfd0b4b3546dd13ebf9010736ac9410ffa (diff) | |
| download | kinect-d889de1824d70e90b2b1e2c51120517b8fbafea7.tar.gz | |
face-detect and faces.py updates
Diffstat (limited to 'data/face-test.py')
| -rwxr-xr-x | data/face-test.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/data/face-test.py b/data/face-test.py new file mode 100755 index 0000000..a987c49 --- /dev/null +++ b/data/face-test.py @@ -0,0 +1,54 @@ +#!/usr/bin/python +from subprocess import Popen +import os +import sys +from face_client import FaceClient + +api_key = '34a84a7835bf24df2d84b4bded84e838' +api_secret = '5bc9e8c5a9e3a2d916abbe3659a1b3f8' +url_base = 'http://74.95.195.225/static/img/jon/users/' +client = FaceClient(api_key, api_secret) + +def test(ns,dataset,dirs): + f = open('test.log', 'w') + for d in dirs: + tids = [] + nm = 0 + nf = 0 + fp = 0 + count = 0 + user = d.rstrip('/').split('/')[-1] + for line in open(d+'/'+dataset+'-test', 'r'): + pic = line.split(',')[-2].split('/')[-1].split('.')[0]+'.jpeg' + if pic != "face.jpeg": + count += 1 + url = url_base+user+'/test/'+pic + try: + response = client.faces_recognize('all',url,namespace=ns) + sys.stderr.write(str(response)+"\n") + for photo in response['photos']: + if len(photo['tags']) > 0: + if len(photo['tags'][0]['uids']) > 0: + out = [user, pic] + for tag in photo['tags'][0]['uids']: + out += [tag['uid'], str(tag['confidence'])] + f.write("\t".join(out)+"\n") + if photo['tags'][0]['uids'][0]['uid'] != user+'@'+ns: + fp += 1 + else: + f.write("\t".join([user, pic, "no-match", "1"])+"/n") + nm += 1 + else: + f.write("\t".join([user, pic, "no-face", "0"])+"/n") + nf += 1 + except: + sys.stderr.write("Unexpexted error:"+str(sys.exc_info()[0])) + pass + print ','.join([user,str(count),str(nf),str(nm),str(fp)]) + + + +if __name__ == "__main__": + test(sys.argv[1],sys.argv[2],sys.argv[3:]) + + |
