测试完后更新脚本

This commit is contained in:
haotianmingyue 2025-09-19 14:04:34 +08:00
parent 611098b5e2
commit f49208b0f7
4 changed files with 57 additions and 14 deletions

View File

@ -119,7 +119,7 @@ async def get_all_visitor_pictures(pageNo=1, pageSize=10, visitorStatus=1):
else:
break
#
# print(visitor_list)
print(visitor_list)
with open("./visitor/visitorIds.txt", "r", encoding="utf-8") as f:
visitor_ids = [line.rstrip('\n') for line in f]
@ -163,14 +163,16 @@ async def get_all_employee_pictures(pageNo=1, pageSize=500):
# print(visitor_ids)
person_ids_add = list()
for employee in employee_list:
if employee["visitorId"] not in person_ids:
person_ids_add.append(employee["visitorId"])
# print(employee)
if employee["personId"] not in person_ids:
person_ids_add.append(employee["personId"])
# 获取图片
try:
await HaikangUtil.get_person_picture(employee["serverIndexCode"], employee["picUri"], f"./employee/face_images/{employee['personName']}.jpg")
await HaikangUtil.get_person_picture(employee.get("personPhoto")[0]["serverIndexCode"], employee.get("personPhoto")[0]["picUri"], f"./employee/face_images/{employee['personName']}.jpg")
await asyncio.sleep(0.5)
except Exception as e:
print(e, employee["visitorId"])
print(f"error: {e}, personId: {employee['personId']}")
with open("./employee/personIds.txt", "a", encoding="utf-8") as f:
for person_id in person_ids_add:
@ -196,7 +198,8 @@ async def face_single_addition_service(faceGroupIndexCode, image_path, name):
"name": name,
}
facePic = {
"picBinaryData": encoded_image,
"facePicBinaryData": encoded_image,
"facePicUrl":""
}
@ -205,6 +208,13 @@ async def face_single_addition_service(faceGroupIndexCode, image_path, name):
with open("face_single_addition_service.json", "a", encoding="utf-8") as f:
f.write(json.dumps(result[1]))
# 批量删除人脸
async def face_delete_service(faceGroupIndexCode: str, indexCodes: list):
result = await HaikangUtil.face_delete(faceGroupIndexCode, indexCodes)
print(result)
with open("face_delete_service.json", "a", encoding="utf-8") as f:
f.write(json.dumps(result[1]))
if __name__ == '__main__':
#asyncio.run(get_door_list_service())
@ -229,17 +239,20 @@ if __name__ == '__main__':
# asyncio.run(get_all_visitor_pictures())
# 测试获取访客预约记录图片
asyncio.run(get_all_employee_pictures())
# asyncio.run(get_all_visitor_pictures())
# 测试获取员工图片
asyncio.run(get_all_employee_pictures())
# asyncio.run(get_all_employee_pictures())
# 添加单个人脸分组
asyncio.run(face_group_addition_service("访客", "访客分组"))
# asyncio.run(face_group_addition_service("访客", "访客分组"))
# 向分组中添加单个人脸
asyncio.run(face_single_addition_service("d4a610b6554d4544bc35dd3138f128b0", "./a7b3c794281902041c9b823df7667ce7.jpg", "测试"))
# asyncio.run(face_single_addition_service("0e28186bc144490887a6bacfc729c0f1", "./a7b3c794281902041c9b823df7667ce7.jpg", "测试"))
# 人脸分组1vN搜索
asyncio.run(face_group_1vN_search_service("./测试图片1.jpg", ["d4a610b6554d4544bc35dd3138f128b0"]))
# asyncio.run(face_group_1vN_search_service("./7R1X107ED864.png", ["0e28186bc144490887a6bacfc729c0f1"]))
# 批量删除人脸
asyncio.run(face_delete_service("0e28186bc144490887a6bacfc729c0f1", ["9d09c213937441228ea816bc59219a40"]))

View File

@ -41,6 +41,7 @@ class HaiKangSettings:
HAIKANG_FACE_GROUP_ADDITION = '/api/frs/v1/face/group/single/addition'
HAIKANG_FACE_SIGLE_ADDITION = '/api/frs/v1/face/single/addition'
HAIKANG_FACE_DELETE = '/api/frs/v1/face/deletion'
HAIKANG_FACE_SAVE_PATH = "./face_images"

View File

@ -564,10 +564,39 @@ class HaikangUtil:
@classmethod
async def face_single_addition(cls, faceGroupIndexCode: str, faceInfo: dict, facePic: dict):
url = f"{HaiKangConfig.HAIKANG_URL}:{HaiKangConfig.HAIKANG_PORT}/artemis{HaiKangConfig.HAIKANG_FACE_SIGLE_ADDITION}"
body_dict = {
"faceGroupIndexCode": faceGroupIndexCode,
"faceInfo": faceInfo,
"facePic": facePic,
"faceInfo": {
"name": "测1"
},
"facePic": {
#"facePicBinaryData": facePic["facePicBinaryData"]
"facePicUrl":"https://pic-image.yesky.com/uploadImages/newPic/2023/271/38/A3A130JG06X2.png"
}
}
body_json = json.dumps(body_dict, separators=(",", ":"))
# print(body_json)
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"]]
# 批量删除人脸
@classmethod
async def face_delete(cls, faceGroupIndexCode: str, indexCodes: list):
url = f"{HaiKangConfig.HAIKANG_URL}:{HaiKangConfig.HAIKANG_PORT}/artemis{HaiKangConfig.HAIKANG_FACE_DELETE}"
body_dict = {
"faceGroupIndexCode": faceGroupIndexCode,
"indexCodes": indexCodes,
}
body_json = json.dumps(body_dict, separators=(",", ":"))
headers = cls.build_signed_headers(
@ -577,4 +606,4 @@ class HaikangUtil:
if back["code"] == "0":
return [True, back["data"]]
else:
return [False, back["code"], back["msg"]]
return [False, back["code"], back["msg"]]