some fettling to get it all to work on smrt08
This commit is contained in:
parent
862d563f08
commit
7f2f669e29
@ -150,8 +150,8 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
d = FaceRecognition()
|
d = FaceRecognition()
|
||||||
|
|
||||||
if sys.argv[1]=="kiosk":
|
if sys.argv[1]=="regula":
|
||||||
jsonstr = d.crowd_vs_govid("pic1", "testimg/ox.jpg", 0, "pic2", "testimg/ox_govid.jpg", 0.25)
|
jsonstr = d.crowd_vs_govid("pic1", "/tmp/localcam.jpg", 0, "pic2", "/tmp/regula/Portrait_0.jpg", 0.25)
|
||||||
print(jsonstr)
|
print(jsonstr)
|
||||||
|
|
||||||
if sys.argv[1]=="messi":
|
if sys.argv[1]=="messi":
|
||||||
@ -184,17 +184,3 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if sys.argv[1]=="match":
|
|
||||||
# lfw
|
|
||||||
n=0
|
|
||||||
print("LFW Matching")
|
|
||||||
for lfw in sorted(os.listdir("lfw/0001")):
|
|
||||||
d.load2("localcam","regula", "lfw/0001" + lfw, "lfw/0002/" + lfw)
|
|
||||||
d.get_faces()
|
|
||||||
d.compute_scores()
|
|
||||||
print(d.get_scores())
|
|
||||||
print(d.get_landmarks())
|
|
||||||
n+=1
|
|
||||||
if n > 1:
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
|
|||||||
@ -19,8 +19,17 @@ class FaceClass(object):
|
|||||||
visual = 0
|
visual = 0
|
||||||
files = {}
|
files = {}
|
||||||
boxes = []
|
boxes = []
|
||||||
|
jsonx = ""
|
||||||
errstr = ""
|
errstr = ""
|
||||||
tree = { "device1":"NA", "device2":"NA", "threshold":380, "device1_qual":0.5, "device2_qual":0.5, "score":0, "detectms":0, "comparems":0 }
|
tree = { "device1":"NA", "device2":"NA", "threshold":380, "device1_qual":0.5, "device2_qual":0.5, "score":0, "detectms":0, "comparems":0 }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def json2obj(self,jsonx):
|
||||||
|
self.jsonx = jsonx
|
||||||
|
return json.loads(jsonx)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# # # # #####
|
# # # # #####
|
||||||
# ## # # #
|
# ## # # #
|
||||||
@ -138,29 +147,32 @@ class FaceClass(object):
|
|||||||
print("##1##")
|
print("##1##")
|
||||||
scale1 = float(scale1str)
|
scale1 = float(scale1str)
|
||||||
scale2 = float(scale2str)
|
scale2 = float(scale2str)
|
||||||
self.load1(name1, file1)
|
if self.json2obj(self.load1(name1, file1))["status"] != 0:
|
||||||
|
return self.jsonx
|
||||||
if scale1 !=0:
|
if scale1 !=0:
|
||||||
self.shrink(name1,scale1)
|
self.shrink(name1,scale1)
|
||||||
jsonstr = self.detect(name1)
|
if self.json2obj(self.detect(name1))["status"] != 0:
|
||||||
if json.loads(jsonstr)["status"]!=0:
|
return self.jsonx
|
||||||
return jsonstr
|
|
||||||
self.boxscale(name1,0.3)
|
self.boxscale(name1,0.3)
|
||||||
self.ideal(name1,name1+"_rect",name1+"_crop")
|
|
||||||
|
if self.json2obj(self.ideal(name1,name1+"_rect",name1+"_crop"))["status"] != 0:
|
||||||
|
return self.jsonx
|
||||||
self.save(name1,"/tmp")
|
self.save(name1,"/tmp")
|
||||||
self.save(name1+"_rect","/tmp")
|
self.save(name1+"_rect","/tmp")
|
||||||
self.save(name1+"_crop","/tmp")
|
self.save(name1+"_crop","/tmp")
|
||||||
print(self.imgs.keys())
|
print(self.imgs.keys())
|
||||||
|
|
||||||
print("##2##")
|
print("##2##")
|
||||||
self.load1(name2, file2)
|
if self.json2obj(self.load1(name2, file2))["status"] != 0:
|
||||||
|
return self.jsonx
|
||||||
if scale2 !=0:
|
if scale2 !=0:
|
||||||
self.shrink(name2,scale2)
|
self.shrink(name2,scale2)
|
||||||
self.save(name2,"/tmp")
|
self.save(name2,"/tmp")
|
||||||
jsonstr = self.detect(name2)
|
if self.json2obj(self.detect(name2))["status"]!=0:
|
||||||
if json.loads(jsonstr)["status"]!=0:
|
return self.jsonx
|
||||||
return jsonstr
|
|
||||||
self.boxscale(name2,0.3)
|
self.boxscale(name2,0.3)
|
||||||
self.ideal(name2,name2+"_rect",name2+"_crop")
|
if self.json2obj(self.ideal(name2,name2+"_rect",name2+"_crop"))["status"] != 0:
|
||||||
|
return self.jsonx
|
||||||
self.save(name2,"/tmp")
|
self.save(name2,"/tmp")
|
||||||
self.save(name2+"_rect","/tmp")
|
self.save(name2+"_rect","/tmp")
|
||||||
self.save(name2+"_crop","/tmp")
|
self.save(name2+"_crop","/tmp")
|
||||||
@ -169,6 +181,7 @@ class FaceClass(object):
|
|||||||
print("##R##")
|
print("##R##")
|
||||||
jsonstr = self.compare(name1+"_crop",name2+"_crop")
|
jsonstr = self.compare(name1+"_crop",name2+"_crop")
|
||||||
print(jsonstr)
|
print(jsonstr)
|
||||||
|
return jsonstr
|
||||||
|
|
||||||
|
|
||||||
###### ##### # #####
|
###### ##### # #####
|
||||||
@ -188,10 +201,10 @@ class FaceClass(object):
|
|||||||
|
|
||||||
def rebox(self,x1,y1,x2,y2,shape,scale=0.2):
|
def rebox(self,x1,y1,x2,y2,shape,scale=0.2):
|
||||||
print("!!!!!!1 rebox with shape ",shape)
|
print("!!!!!!1 rebox with shape ",shape)
|
||||||
xx1 = x1 - int((x2-x1)*scale)
|
xx1 = x1 - int((x2-x1)*scale*0.8)
|
||||||
xx2 = x2 + int((x2-x1)*scale)
|
xx2 = x2 + int((x2-x1)*scale*0.8)
|
||||||
yy1 = y1 - int((y2-y1)*scale)
|
yy1 = y1 - int((y2-y1)*scale*1.3)
|
||||||
yy2 = y2 + int((y2-y1)*scale)
|
yy2 = y2 + int((y2-y1)*scale*1.3)
|
||||||
if xx1 < 0:
|
if xx1 < 0:
|
||||||
xx1 = 0
|
xx1 = 0
|
||||||
if yy1 < 0:
|
if yy1 < 0:
|
||||||
@ -226,7 +239,7 @@ class FaceClass(object):
|
|||||||
# # # # # # # # # ##
|
# # # # # # # # # ##
|
||||||
# # ###### # #### # # # #
|
# # ###### # #### # # # #
|
||||||
|
|
||||||
def get_scores(self):
|
def scores(self):
|
||||||
return json.dumps(self.tree)
|
return json.dumps(self.tree)
|
||||||
|
|
||||||
# return a base64 version of the pic in memory
|
# return a base64 version of the pic in memory
|
||||||
|
|||||||
@ -240,7 +240,7 @@ class yoloserv(object):
|
|||||||
return jsonstr
|
return jsonstr
|
||||||
|
|
||||||
def json2obj(self,jsonx):
|
def json2obj(self,jsonx):
|
||||||
return json.laods(jsonx)
|
return json.loads(jsonx)
|
||||||
|
|
||||||
# @doc put all the steps for a retail facematch into one convenient functions
|
# @doc put all the steps for a retail facematch into one convenient functions
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@ -268,7 +268,7 @@ class yoloserv(object):
|
|||||||
|
|
||||||
jsonstr = self.facematcher.crowd_vs_govid(dev1,fil1,scl1, dev2,fil2,scl2)
|
jsonstr = self.facematcher.crowd_vs_govid(dev1,fil1,scl1, dev2,fil2,scl2)
|
||||||
obj = self.json2obj(jsonstr)
|
obj = self.json2obj(jsonstr)
|
||||||
if obj.status > 0:
|
if obj["status"] > 0:
|
||||||
return jsonstr
|
return jsonstr
|
||||||
jsonstr = self.facematcher.scores()
|
jsonstr = self.facematcher.scores()
|
||||||
return '{ "status":0, "remark":"OK", "data": %s }' % (jsonstr)
|
return '{ "status":0, "remark":"OK", "data": %s }' % (jsonstr)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user