实现添加人脸分组服务
This commit is contained in:
parent
6118778bba
commit
ffeee70a5b
@ -177,6 +177,13 @@ async def get_all_employee_pictures(pageNo=1, pageSize=500):
|
||||
f.write(person_id + "\n")
|
||||
|
||||
|
||||
# 添加单个人脸分组
|
||||
async def face_group_addition_service(name, description):
|
||||
result = await HaikangUtil.face_group_addition(name, description)
|
||||
print(result)
|
||||
with open("face_group_addition_service.json", "w", encoding="utf-8") as f:
|
||||
f.write(json.dumps(result[1]))
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@ -38,6 +38,8 @@ class HaiKangSettings:
|
||||
HAIKANG_PERSON_LIST = '/api/resource/v2/person/personList'
|
||||
HAIKANG_GET_PERSON_PICTURE = '/api/resource/v1/person/picture'
|
||||
|
||||
HAIKANG_FACE_GROUP_ADDITION = '/api/frs/v1/face/group/single/addition'
|
||||
|
||||
HAIKANG_FACE_SAVE_PATH = "./face_images"
|
||||
|
||||
|
||||
|
||||
@ -538,3 +538,24 @@ class HaikangUtil:
|
||||
for chunk in back.iter_bytes(chunk_size=8192):
|
||||
if chunk: # 忽略 keep-alive 的空 chunk
|
||||
f.write(chunk)
|
||||
|
||||
|
||||
# 单个添加人脸分组
|
||||
@classmethod
|
||||
async def face_group_addition(cls, name, description):
|
||||
url = f"{HaiKangConfig.HAIKANG_URL}:{HaiKangConfig.HAIKANG_PORT}/artemis{HaiKangConfig.HAIKANG_FACE_GROUP_ADDITION}"
|
||||
body_dict = {
|
||||
"name": name,
|
||||
"description": description,
|
||||
}
|
||||
body_json = json.dumps(body_dict, separators=(",", ":"))
|
||||
headers = cls.build_signed_headers(
|
||||
"POST", url, body_json, HaiKangConfig.HAIKANG_AK, HaiKangConfig.HAIKANG_SK
|
||||
)
|
||||
|
||||
back = await cls.send_request("POST", url, headers, body_json)
|
||||
|
||||
if back["code"] == "0":
|
||||
return [True, back["data"]]
|
||||
else:
|
||||
return [False, back["code"], back["msg"]]
|
||||
Loading…
Reference in New Issue
Block a user