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
1
Merge Requests
1
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
alpha
sun
Commits
b939fca8
Commit
b939fca8
authored
Feb 14, 2019
by
张永
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
注释扫脸逻辑
parent
b329f630
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 @
b939fca8
...
@@ -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
()
...
...
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