-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_compare.py
More file actions
46 lines (37 loc) · 1.46 KB
/
test_compare.py
File metadata and controls
46 lines (37 loc) · 1.46 KB
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
43
44
45
46
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -----------------------------------------------
# 测试人脸匹配
# python ./tests/test_compare.py
# -----------------------------------------------
# 把父级目录(项目根目录)添加到工作路径
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../')
# ----------------------------------------------------------------------
import argparse
from src.app import record_face_feature, match_face_feature
from src.cache.face_feature_cache import FACE_FEATURE_CACHE
def args() :
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
prog='测试人脸匹配',
description='测试人脸匹配',
epilog='\r\n'.join([
'摄像头拍摄: ',
' python ./tests/test_compare.py -c',
'上传人脸图片: ',
' python ./tests/test_compare.py',
'注意:',
' 需要至少执行一次 python ./presrc/gen_feature.py 录入预设人脸,作为特征匹配的比对基准',
])
)
parser.add_argument('-c', '--camera', dest='camera', action='store_true', default=False, help='摄像头模式; 默认为图片上传模式')
return parser.parse_args()
def test(args) :
if not FACE_FEATURE_CACHE.load() :
return
feature = record_face_feature(args)
match_face_feature(feature)
if '__main__' == __name__ :
test(args())