Procházet zdrojové kódy

feat(config): 添加新配置参数并优化图像处理流程

- 添加伺服力矩限制、中断触发反转等新配置参数
- 修复环境配置从dev切换到prod
- 优化消息处理器中的货号字符串处理
- 改进图像处理服务中的图像裁剪逻辑
- 重构背景遮罩处理流程
- 更新图像处理函数接口以支持新的参数传递
rambo před 1 měsícem
rodič
revize
ca9204948e

+ 1 - 1
python/config.ini

@@ -10,7 +10,7 @@ app_run = api:app
 # 端口号
 port = 7074
 debug = false
-env = dev
+env = prod
 # 线程数
 works = 1
 project = 惠利玛

+ 24 - 0
python/conifg_info.py

@@ -541,3 +541,27 @@ class ConfigManager:
         self._set_key_float(
             _key="camera_focal_set", _addr=400, _tips="相机焦段功能设置", _readonly=True
         )
+        # 伺服力矩限制
+        self.servo_torque = 60
+        self._set_key_int(_key="servo_torque", _addr=219, _tips="伺服力矩限制", )
+        # 中断触发是否反转
+        self.irq_change = 1
+        self._set_key_int(_key="irq_change", _addr=220, _tips="中断触发是否反转", )
+
+        # 光栅升降沿触发
+        self.light_estop_irq = 1
+        self._set_key_int(_key="light_estop_irq", _addr=217, _tips="光栅升降沿触发", )
+
+        # 升降底部预留高度
+        self.bottom_limit = 20
+        self._set_key_int(_key="bottom_limit", _addr=218, _tips="升降底部预留高度", )
+
+        # 转盘加速度
+        self.turntable_up_speed = 250
+        self._set_key_int(_key="turntable_up_speed", _addr=133, _tips="转盘加速度", )
+        # 转盘减速度
+        self.turntable_down_speed = 250
+        self._set_key_int(_key="turntable_down_speed", _addr=134, _tips="转盘减速度", )
+        # 转盘最大速度 默认可以是1000
+        self.turntable_max_speed = 0
+        self._set_key_int(_key="turntable_max_speed", _addr=135, _tips="转盘最大速度", )

+ 5 - 8
python/service/grenerate_main_image_test.py

@@ -174,6 +174,7 @@ class GeneratePic(object):
             bg_mask = bg_mask.resize(im_png.size)
             # bg_mask = expand_or_shrink_mask(pil_image=bg_mask, expansion_radius=6, blur_radius=0)
         else:
+            bg_mask = False
             bg_mask = Image.new("RGB", im_png.size, (255, 255, 255))
             bg_mask = bg_mask.convert("L")
 
@@ -699,16 +700,11 @@ class GeneratePic(object):
         rgb_color = settings.hex_to_rgb(color_800image)
         # ==========先进行剪切原图
         _s = time.time()
-        with Image.open(image_path) as orign_im:
-            # 复制图像以便后续操作
-            orign_im = orign_im.copy()
+        orign_im = Image.open(image_path)
         print("242  need_time_1:{}".format(time.time() - _s))
         orign_x, orign_y = orign_im.size
-        with Image.open(cut_image_path) as cut_image:
-            # 复制图像以便后续操作
-            cut_image = cut_image.copy()
-            cut_image_basic = cut_image.copy()
-        cut_image, new_box = get_mini_crop_img(img=cut_image)
+        orign_im_cut = Image.open(cut_image_path)  # 原始图的已扣图
+        cut_image, new_box = get_mini_crop_img(img=orign_im_cut)
         im_shadow = orign_im.crop(new_box)  # 切图
         new_x, new_y = im_shadow.size
 
@@ -729,6 +725,7 @@ class GeneratePic(object):
                                                               grenerate_main_pic_brightness=image_mask_grenerate_main_pic_brightness)
         elif image_mask_mode == 2:
             shadow_mask, config = self.get_mask_and_config_v4_online(ori_im_jpg=orign_im,
+                                                                     ori_im_png=orign_im_cut,
                                                                      im_jpg=im_shadow,
                                                                      im_png=cut_image)
         else:

+ 2 - 0
python/sockets/message_handler.py

@@ -279,6 +279,7 @@ async def handlerSend(
             msg_type = "run_mcu"
             action_info = data.get("action", "执行左脚程序")
             goods_art_no = data.get("goods_art_no", None)
+            goods_art_no = goods_art_no.strip()
             if goods_art_no == None or goods_art_no == "":
                 # 判断货号是否存在
                 data = manager.jsonMessage(
@@ -619,6 +620,7 @@ async def handlerSend(
             # 兼容主图测试
             id = data.get("id", 0)
             goods_art_no = data.get("goods_art_no", "")
+            goods_art_no = goods_art_no.strip()
             if goods_art_no:
                 try:
                     limit_path = "{}/{}".format(settings.OUTPUT_DIR,