Commit b939fca8 authored by 张永's avatar 张永

注释扫脸逻辑

parent b329f630
...@@ -113,29 +113,29 @@ class UserImage(APIView): ...@@ -113,29 +113,29 @@ class UserImage(APIView):
user_id=user_id, image_id=image_id).unwrap() user_id=user_id, image_id=image_id).unwrap()
if resp: if resp:
return self.write_success(data='', message='操作成功') return self.write_success(data='', message='操作成功')
# 目前不需要 从图片中切出人脸
try: # try:
data = self.rpc['saber/face/detect'](url=image_url).unwrap() # data = self.rpc['saber/face/detect'](url=image_url).unwrap()
except Exception as e: # except Exception as e:
error_logger.error(u'分析人脸失败:%s', e) # error_logger.error(u'分析人脸失败:%s', e)
return self.write_fail(code=-1, message='分析人脸失败') # return self.write_fail(code=-1, message='分析人脸失败')
faces = [{ # faces = [{
"point": [ # "point": [
item["rect"]["left"], # item["rect"]["left"],
item["rect"]["top"], # item["rect"]["top"],
item["rect"]["right"]-item["rect"]["left"], # item["rect"]["right"]-item["rect"]["left"],
item["rect"]["bottom"]-item["rect"]["top"]]} for item in data.get("faces", [])] # item["rect"]["bottom"]-item["rect"]["top"]]} for item in data.get("faces", [])]
if faces: # if faces:
point = faces[0].get('point', []) # point = faces[0].get('point', [])
else: # else:
return self.write_fail(code=-1, message='获取人脸失败') # return self.write_fail(code=-1, message='获取人脸失败')
file_path = download_img_func(image_url, user_id, suffix="png") # file_path = download_img_func(image_url, user_id, suffix="png")
images = tailor_image(file_path, [point]) # images = tailor_image(file_path, [point])
header_pic_path = images[0] # header_pic_path = images[0]
with open(header_pic_path, 'rb') as f: # with open(header_pic_path, 'rb') as f:
image_url = upload_with_short(f, img_type=IMG_TYPE.USEREXTRA)[0] # image_url = upload_with_short(f, img_type=IMG_TYPE.USEREXTRA)[0]
try: try:
result = self.rpc['venus/sun/user/create_update_image']( result = self.rpc['venus/sun/user/create_update_image'](
image_url=image_url, user_id=user_id, image_id=image_id).unwrap() image_url=image_url, user_id=user_id, image_id=image_id).unwrap()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment