照片涂抹保存到云端

This commit is contained in:
2024-07-09 21:02:04 +08:00
parent a7d1c479a8
commit 457ed3ed07
2 changed files with 32 additions and 1 deletions

View File

@@ -224,6 +224,9 @@ def photo_mask(pk_phhd, content):
.all()
session.close()
for phrec in phrecs:
is_copy_success = ucloud.copy_file("drg100", phrec.cfjaddress, "drg103", phrec.cfjaddress)
if not is_copy_success:
continue
img_url = ucloud.get_private_url(phrec.cfjaddress)
if not img_url:
continue
@@ -247,7 +250,12 @@ def photo_mask(pk_phhd, content):
)
cv2.rectangle(image, (int(result[0]), int(result[1])), (int(result[2]), int(result[3])),
(255, 255, 255), -1, 0)
cv2.imwrite(f"./mask_test/{phrec.cfjaddress}.jpg", image)
with tempfile.NamedTemporaryFile(delete=False, suffix=".jpg") as temp_file:
cv2.imwrite(temp_file.name, image)
for i in range(3):
is_upload_success = ucloud.upload_file(phrec.cfjaddress, temp_file.name)
if is_upload_success:
break
if __name__ == '__main__':