def get_face_properties(self, images, timeout):
"""
Returns a SkyFace detections list based on a list of images
:param images: List of input images (Faces)
:param timeout: Request timeout
:return: The SkyFaces with their properties
"""
buffers = [cv2.imencode('.jpg', image)[1].tostring() for image in images]
try:
response = self._external_request_with_timeout(buffers, timeout)
except Exception as e:
raise Exception("Skybiometry API call failed:", e)
if not "photos" in response:
raise Exception("Skybiometry API call, 'photos' not found in response:", response)
photos = response["photos"]
if len(photos) != len(buffers):
raise Exception("Skybiometry API call, result length != images length:", response)
fps = []
for photo in photos:
attrs = photo["tags"][0]["attributes"]
fp = SkyFaceProperties()
for name, attr in attrs.iteritems():
if hasattr(fp, name):
setattr(fp, name, Attribute(attr["value"], attr["confidence"] / 100.0))
fps.append(fp)
return fps
评论列表
文章目录