Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
sun
Commits
57ccac06
Commit
57ccac06
authored
Feb 15, 2019
by
zhanglu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/create_image_zy' into 'test'
注释扫脸逻辑 See merge request
alpha/sun!63
parents
c84fc087
b939fca8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
23 deletions
+23
-23
user.py
api/user.py
+23
-23
No files found.
api/user.py
View file @
57ccac06
...
...
@@ -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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment