forked from hjlin0515/face-detection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
faceDetection.py
executable file
·42 lines (34 loc) · 1.18 KB
/
faceDetection.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# coding=utf-8
from time import time
from features import loadFeatures, calAndSaveFeatures
from setting import TEST
from model import calAndSaveModel, loadModel, getModel
from numpy import random
from sklearn.metrics import accuracy_score
from adaboost import Adaboost
from detector import Detector
from matplotlib import image
from PIL import Image
import os
import sys
def main():
starttime = time()
if len(sys.argv) <= 1:
print("Missing arguments")
else:
fileName = sys.argv[1]
arguments = {"show" : True, "save" : False, "saveInfo" : False}
for i in range(2, len(sys.argv)):
if (sys.argv[i].split("=")[0])[2:] in arguments.keys():
arguments[(sys.argv[i].split("=")[0])[2:]] = \
(sys.argv[i].split("=")[1] == str(True))
print("loading model...")
clf = loadModel()
detector = Detector(clf)
print("detecting...")
detector.detectFace(fileName, _show=arguments['show'], _save=arguments['save'],
_saveInfo=arguments['saveInfo'])
endtime = time()
print("cost: " + str(endtime - starttime))
if __name__ == "__main__":
main()