Commit 57ccac06 authored by zhanglu's avatar zhanglu

Merge branch 'feature/create_image_zy' into 'test'

注释扫脸逻辑

See merge request alpha/sun!63
parents c84fc087 b939fca8
......@@ -113,29 +113,29 @@ class UserImage(APIView):
user_id=user_id, image_id=image_id).unwrap()
if resp:
return self.write_success(data='', message='操作成功')
try:
data = self.rpc['saber/face/detect'](url=image_url).unwrap()
except Exception as e:
error_logger.error(u'分析人脸失败:%s', e)
return self.write_fail(code=-1, message='分析人脸失败')
faces = [{
"point": [
item["rect"]["left"],
item["rect"]["top"],
item["rect"]["right"]-item["rect"]["left"],
item["rect"]["bottom"]-item["rect"]["top"]]} for item in data.get("faces", [])]
if faces:
point = faces[0].get('point', [])
else:
return self.write_fail(code=-1, message='获取人脸失败')
file_path = download_img_func(image_url, user_id, suffix="png")
images = tailor_image(file_path, [point])
header_pic_path = images[0]
with open(header_pic_path, 'rb') as f:
image_url = upload_with_short(f, img_type=IMG_TYPE.USEREXTRA)[0]
# 目前不需要 从图片中切出人脸
# try:
# data = self.rpc['saber/face/detect'](url=image_url).unwrap()
# except Exception as e:
# error_logger.error(u'分析人脸失败:%s', e)
# return self.write_fail(code=-1, message='分析人脸失败')
# faces = [{
# "point": [
# item["rect"]["left"],
# item["rect"]["top"],
# item["rect"]["right"]-item["rect"]["left"],
# item["rect"]["bottom"]-item["rect"]["top"]]} for item in data.get("faces", [])]
# if faces:
# point = faces[0].get('point', [])
# else:
# return self.write_fail(code=-1, message='获取人脸失败')
# file_path = download_img_func(image_url, user_id, suffix="png")
# images = tailor_image(file_path, [point])
# header_pic_path = images[0]
# with open(header_pic_path, 'rb') as f:
# image_url = upload_with_short(f, img_type=IMG_TYPE.USEREXTRA)[0]
try:
result = self.rpc['venus/sun/user/create_update_image'](
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