14 result = {0:
"成功", 1:
"请求超时",2:
"识别/核身解析结果错误",3:
"识别解析结果错误",4:
"识别解析相似度错误",
15 5:
"输入信息错误",6:
"无该Userid对应信息",7:
"获取注册人脸图片数据错误",
16 8:
"Base64解码错误",9:
"人脸数据提取失败",10:
"删除人脸失败",11:
"图片过大,不超过初始配置大小(1280,720",
17 12:
"文件不存在",13:
"人脸图片打开失败",14:
"人脸已存在(注册人脸时method=normal情况下,userid重复",
18 15:
"未检测到网卡",16:
"输入信息不合法",17:
"一键开门失败",18:
"文件读取失败",2019:
"恢复出厂设置失败",
19 2010:
"数据清除失败",2021:
"获取日志列表失败",22:
"MAC地址不匹配"}
21 cmd =
"ls /dev/video* > vs.out" 23 vf = open(
'vs.out',
'r') 30 cmd =
"udevadm info "+vd+
" |grep 'ID_VENDOR_ID=0bda' > vs.info" 32 infof = open(
"vs.info",
'r') 33 info = infof.readlines() 46 user_name = sys.argv[1]
47 image_path = sys.argv[2]
52 except KeyboardInterrupt:
53 print(
" Has Exited or Finished!")
56 print(
"Please input the correct command and try again!")
58 print(
"rosrun xbot_face 01face_register.py camera [camera_index]")
60 print(
"rosrun xbot_face 01face_register.py image [user_name] ")
65 url =
"http://192.168.8.141:8000/management/register?method=force" 68 post_data[
"Userid"] = user_name
69 image_path = tkFileDialog.askopenfilename()
71 with open(image_path,
"rb")
as fp:
72 image_binary = fp.read()
73 image_binary = base64.b64encode(image_binary)
74 post_data[
"Image"] = image_binary
76 body = JSONEncoder().encode(post_data)
77 req = urllib2.Request(url, body)
78 response = urllib2.urlopen(req)
80 body = JSONDecoder().decode(buf)
90 url =
"http://192.168.8.141:8000/management/register?method=normal" 91 cap = cv2.VideoCapture(camera_index)
96 ret, frame = cap.read()
99 cv2.imshow(
'frame',frame)
100 if cv2.waitKey(1) & 0xFF == ord(
'r'): 101 cv2.imwrite('tmp.jpg',frame)
102 tip =
'请用拼音输入你的名字:\n' 104 post_data[
"Userid"] = name
105 with open(
'tmp.jpg',
"rb")
as fp:
106 image_binary = fp.read()
107 image_binary = base64.b64encode(image_binary)
108 post_data[
"Image"] = image_binary
110 body = JSONEncoder().encode(post_data)
111 req = urllib2.Request(url, body)
112 response = urllib2.urlopen(req)
113 buf = response.read()
114 body = JSONDecoder().decode(buf)
119 elif cv2.waitKey(1) & 0xFF == ord(
'q'):
124 cv2.destroyAllWindows()
127 if __name__ ==
'__main__':
def camera_register(self, camera_index)
def image_register(self, user_name)