File size: 2,549 Bytes
d86aa1d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
@author: cuny
@file: idPhotoCreateDebug.py
@time: 2022/4/25 17:43
@description: 
证件照制作的本地调试文件
"""
import time
import cv2
from hivisionai.hyService.utils import Debug
from hivisionai.hycv.vision import resize_image_esp
from idPhotoCreateUtils import IdPhotoCreateService

cbs = IdPhotoCreateService()
db = Debug()
msg = {"uid": "60a5e13da00e6e0001fd53c8",
       "send_msg": {"index": 1,
                    "platform": "test",
                    "obj_key": "wx/certificatePhoto/62b31e4fa866f7af5d361390/61d70e3ba866f7af5df28a3b/old-image/xyz165621950.png",
                    "template_info": {"height": 192, "width": 144, "name": "一寸"},
                    "cloth_number": "girl02",
                    "size": {"name": "一寸",
                             "w": 144,
                             "h": 192},
                    "time": "test",
                    "uid": "60a5e13da00e6e0001fd53c8",
                    }
       }

# ----------------- 本地调试方式 ----------------- #

image_byte = open("../idPhotoCreate/test_image/21.jpg", "rb").read()
# ---------------------------------------------- #
# 开始从云端下载图像,首先获取一些基本数据,这一行基本别动
(w, h, name), (download_path, upload_path_hd, upload_path_common), image_name, send_msg, \
    (uid, connectionID) = cbs.checkKey(msg)
print("upload_path_common", upload_path_common)
# 在这一步我们获得到了用户的数据1
image_pre = cbs.byte_cv2(image_byte, flags=cv2.IMREAD_COLOR)
image_pre = resize_image_esp(image_pre, esp=2000)
# 数据图片下载完毕,开始功能处理
db.debug_print("INFO: processing...", font_color="yellow")
# 开始处理
db.debug_print("INFO: 取消上传照片...", font_color="yellow")
start = time.time()
result_image_HD, result_image, typography_arr, typography_rotate, relative_x, relative_y, w, h, id_temp_info = \
    cbs.process(image_pre=image_pre,
                oss_image_name=image_name,
                w=w,
                h=h,
                beauty=False,
                upload_path_hd=upload_path_hd,
                upload_path_common=upload_path_common,
                if_upload=False)

db.debug_print(f"INFO: 图像处理时间: {round(time.time() - start, 2)}秒", font_color="blue")
db.debug_print("INFO: success.", font_color="green")
# cv2.imshow("test", result_image)
# cv2.waitKey(0)
# ---------------------------------------------- #
cv2.imwrite("result_image_standard.png", result_image)
cv2.imwrite("result_image_HD.png", result_image_HD)