Browse Source

time.sleep(3)

rambo 5 months ago
parent
commit
1c66d52da5

+ 13 - 0
python/mcu/capture/smart_shooter_class.py

@@ -147,6 +147,19 @@ class SmartShooter(metaclass=SingletonType):
             return True, "相机已连接"
         except zmq.Again:
             print("获取相机信息超时,继续监听...")
+            msg_send = "相机未连接或软件未打开"
+            if is_send:
+                message = {
+                    "code": 1,
+                    "msg": msg_send,
+                    "data": None,
+                    "msg_type": self.msg_type,
+                    "device_status": -1,
+                }
+                await self.websocket_manager.send_personal_message(
+                    message, self.websocket
+                )
+            return False, msg_send
         except Exception as e:
             print("拍照异常",e)
             self.connect_status = False

+ 12 - 9
python/service/OnePicTest.py

@@ -46,10 +46,13 @@ class OnePicTest():
         check_path("temp")
         check_path("temp\pic_test")
         root = r"{}\temp\pic_test".format(os.getcwd())
-        for file_name in os.listdir(root):
-            path = "{}\{}".format(root, file_name)
-            if os.path.isfile(path):
-                os.remove(path)
+        try:
+            for file_name in os.listdir(root):
+                path = "{}\{}".format(root, file_name)
+                if os.path.isfile(path):
+                    os.remove(path)
+        except Exception as e:
+            print("deal_image", e)
 
         # ==============抠图处理=====================
         remove_pic_ins = RemoveBgALi()
@@ -66,8 +69,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,9 +79,9 @@ class OnePicTest():
                     out_pic_size=1024,
                     is_logo=False,
             )
-        except Exception as e:
-            print(e)
-            raise UnicornException("处理失败,请重试")
+        # except Exception as e:
+        #     print(e)
+        #     raise UnicornException("处理失败,请重试")
 
         # return_data["code"] = 0
         # return_data["data"]["image_path"] = image_path

+ 7 - 4
python/service/generate_main_image/grenerate_main_image_test.py

@@ -402,11 +402,14 @@ class GeneratePic(object):
         print("242  need_time_1:{}".format(time.time() - _s))
 
         orign_x, orign_y = orign_im.size
-        time.sleep(1)
+        time.sleep(3)
         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)  # 切图
-        new_x, new_y = im_shadow.size
+        try:
+            cut_image, new_box = get_mini_crop_img(img=cut_image)
+            im_shadow = orign_im.crop(new_box)  # 切图
+            new_x, new_y = im_shadow.size
+        except:
+            im_shadow = cut_image
 
         # ================自动色阶处理
         _s = time.time()