rambo 6 місяців тому
батько
коміт
116f8407af

+ 6 - 5
python/service/OnePicTest.py

@@ -56,7 +56,7 @@ class OnePicTest():
         file = os.path.split(image_path)[1]
         cut_image_path = r"{}\temp\pic_test\{}.png".format(
             os.getcwd(), os.path.splitext(file)[0]
-        )
+        ).replace("\\", "/")
         remove_pic_ins.get_image_cut(file_path=image_path, out_file_path=cut_image_path)
 
         # ==============生成主图====================
@@ -66,8 +66,8 @@ class OnePicTest():
         print("image_path", image_path)
         print("cut_image_path", cut_image_path)
         print("main_out_path", main_out_path)
-        try:
-            GeneratePic().run(
+        # try:
+        GeneratePic().run(
                 image_path=image_path,
                 cut_image_path=cut_image_path,
                 out_path=main_out_path,
@@ -76,8 +76,9 @@ class OnePicTest():
                 out_pic_size=1024,
                 is_logo=False,
             )
-        except:
-            raise UnicornException("处理失败,请重试")
+        # except Exception as e:
+        #     print(e)
+        #     raise UnicornException("处理失败,请重试")
 
         # return_data["code"] = 0
         # return_data["data"]["image_path"] = image_path

+ 2 - 15
python/service/generate_main_image/grenerate_main_image_test.py

@@ -55,9 +55,6 @@ class GeneratePic(object):
         # 在鞋底最低处增加一条直线蒙版,蒙版宽度为有效区域大小
         image_high = im_jpg.height
         print("图片高度:", image_high)
-        # TODO 待移除
-        if settings.app:
-            settings.app.processEvents()
         cv2_jpg = pil_to_cv2(im_jpg)
 
         # 返回线条图片,以及最低位置
@@ -75,12 +72,9 @@ class GeneratePic(object):
             one_line_pos=(x1, x2),
             line_color=(0, 0, 0),
             line_thickness=20,
-            app=settings.app,
+            app=None,
             crop_image_box=crop_image_box,
         )
-        # TODO 待移除
-        if settings.app:
-            settings.app.processEvents()
         print("66  制作蒙版")
         # 制作蒙版
         mask_line = cv2_to_pil(img_with_shifted_line)
@@ -105,17 +99,11 @@ class GeneratePic(object):
             mask.paste(white_bg, mask=green_areas_mask_pil.convert("L"))
             mask = mask.convert("L")
 
-        # TODO 待移除
-        if settings.app:
-            settings.app.processEvents()
         # ====================生成新的图片
         print("84  生成新的图片")
         bg = Image.new(mode="RGBA", size=im_png.size, color=(255, 255, 255, 255))
         bg.paste(im_png, mask=im_png)
         bg.paste(im_jpg, mask=mask)  # 粘贴有阴影的地方
-        # TODO 待移除
-        if settings.app:
-            settings.app.processEvents()
         if self.is_test:
             _bg = bg.copy()
             draw = ImageDraw.Draw(_bg)
@@ -155,8 +143,6 @@ class GeneratePic(object):
         xunhuan = 0
         while k:
             xunhuan += 1
-            if settings.app:
-                settings.app.processEvents()
             k -= 1
             Midtones += 0.035
             if Midtones > 1.7:
@@ -416,6 +402,7 @@ class GeneratePic(object):
         print("242  need_time_1:{}".format(time.time() - _s))
 
         orign_x, orign_y = orign_im.size
+        time.sleep(1)
         cut_image = Image.open(cut_image_path)  # 原始图的已扣图
         cut_image, new_box = get_mini_crop_img(img=cut_image)
         im_shadow = orign_im.crop(new_box)  # 切图