From 4dbf8d4cf3b277f66e3620589800e812f54df694 Mon Sep 17 00:00:00 2001 From: FrankCV2048 <1395405735@qq.com> Date: Tue, 17 Dec 2024 19:56:40 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E6=9B=B4=E6=96=B0=E8=AE=BE=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CU/Detect.py | 4 +++- CU/Feeding.py | 15 +++++++++++++-- Constant.py | 2 +- Seting.ini | 2 +- main.py | 2 ++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CU/Detect.py b/CU/Detect.py index e9ed6da..3d389e6 100644 --- a/CU/Detect.py +++ b/CU/Detect.py @@ -20,7 +20,9 @@ class Detect: if self.detect_status == DetectStatus.DNone: return if self.detect_status == DetectStatus.DDetect: - + if Constant.Debug: + self.detect_status = DetectStatus.DOk + return _, img, xyz, uvw, points = self.detection.get_position(Point_isVision=False, Box_isPoint=True, First_Depth=True, Iter_Max_Pixel=30, save_img_point=0, Height_reduce=30, width_reduce=30) diff --git a/CU/Feeding.py b/CU/Feeding.py index d65263b..1eec0bf 100644 --- a/CU/Feeding.py +++ b/CU/Feeding.py @@ -188,13 +188,19 @@ class Feeding(QObject): self.pos_near_index = -1 self.catch = Catch(self.robotClient) self.detect = Detect(self.detection) - self.detect_thread_img = threading.Thread(target=self.detect.run) - self.detect_thread_img.start() + self.is_detected = True + self.detect_thread = threading.Thread(target=self.run_detect) + self.detect_thread.start() pass def init_detection_image(self): self.detection_image = cv2.imread(Constant.feed_sign_path) + def run_detect(self): + while self.is_detected: + self.detect.run() + time.sleep(0.02) + def run(self): self.catch.run() # 获取事件坐标 @@ -298,6 +304,11 @@ class Feeding(QObject): if self.detect.detect_status == DetectStatus.DNone: self.detect.detect_status = DetectStatus.DDetect elif self.detect.detect_status == DetectStatus.DOk: + if Constant.Debug: + self.detect.detect_status = DetectStatus.DNone + self.feedConfig.feedLine.set_take_position(real_position) + self.next_position() + if self.detect.detect_position != None: log.log_message(logging.INFO, Constant.str_feed_takePhoto_success) self.feedConfig.feedLine.set_take_position(self.detect.detect_position) diff --git a/Constant.py b/Constant.py index 7d9f405..d25925e 100644 --- a/Constant.py +++ b/Constant.py @@ -1,6 +1,6 @@ import os -Debug = True +Debug = False IO_EmergencyPoint = 3 bag_height = 10 # 一袋的高度 position_accuracy = 0.1 diff --git a/Seting.ini b/Seting.ini index 3c6817e..c71c894 100644 --- a/Seting.ini +++ b/Seting.ini @@ -47,7 +47,7 @@ photo_v5 = 0.0 photo_w5 = 1.0 linecount = 2 remain_linename = 1 -remain_count = 574 +remain_count = 1 io_take_addr = 8 io_zip_addr = 11 io_shake_addr = 12 diff --git a/main.py b/main.py index 849ecdf..296a4cb 100644 --- a/main.py +++ b/main.py @@ -1935,6 +1935,8 @@ class MainWindow(QMainWindow, Ui_MainWindow): def closeEvent(self, event): self.record_remain_num() + self.feeding.is_detected = False + self.feeding.detect_thread.join() self.detection.release() self.thread_signal = False self.robotClient.close()