|
21 | 21 |
|
22 | 22 | from libraries.log import logfile |
23 | 23 | from libraries.pyqtFile.AiKit_auto import Ui_AiKit_UI as AiKit_window |
24 | | -from libraries.yolov8File.yolov8_detect import YOLODetection |
25 | 24 | import pymycobot |
26 | 25 | from packaging import version |
27 | 26 |
|
@@ -170,24 +169,15 @@ def _init_variable(self): |
170 | 169 | # yolov8 model and label file path (only for 280 RISCV) |
171 | 170 | self.yolov8_model_path = libraries_path + '/yolov8File/yolov8n.q.onnx' |
172 | 171 | self.yolov8_label_path = libraries_path + '/yolov8File/yolov8_label.txt' |
173 | | - self.yolov8_detect = YOLODetection(self.yolov8_model_path, self.yolov8_label_path) |
| 172 | + self.yolov8_detect = None |
174 | 173 |
|
175 | 174 | self.is_picking = False # 初始化是否正在抓取标志-yolov8 |
176 | 175 | self.cooldown_counter = 0 # 新增冷却计数器(单位:帧)- yolov8 |
177 | 176 | self.detect_history = deque(maxlen=5) # 存放最近5帧识别结果 - yolov8 |
178 | 177 |
|
179 | | - self.mycobot_riscv = open("/sys/devices/soc0/machine").read().strip() == "spacemit k1-x RV4B board" |
180 | | - if self.mycobot_riscv: |
181 | | - from gpiozero.pins.lgpio import LGPIOFactory |
182 | | - from gpiozero import Device, LED |
183 | | - Device.pin_factory = LGPIOFactory(chip=0) # 显式指定/dev/gpiochip0 |
184 | | - # 初始化 GPIO 控制的设备 |
185 | | - self.pump = LED(71) # 气泵 |
186 | | - self.valve = LED(72) # 阀门 |
187 | | - self.pump.on() # 关闭泵 |
188 | | - time.sleep(0.05) |
189 | | - self.valve.on() # 打开阀门 |
190 | | - time.sleep(1) |
| 178 | + self.pump = None |
| 179 | + self.valve =None |
| 180 | + |
191 | 181 |
|
192 | 182 | self._init_ = 20 |
193 | 183 | self.init_num = 0 |
@@ -490,6 +480,19 @@ def buad_choose(self): |
490 | 480 | self.camera_edit.setText('20') |
491 | 481 |
|
492 | 482 | self.set_comboBox_options_mutually_exclusive(self.comboBox_function, 'yolov8', 'yolov5') |
| 483 | + # self.mycobot_riscv = open("/sys/devices/soc0/machine").read().strip() == "spacemit k1-x RV4B board" |
| 484 | + from libraries.yolov8File.yolov8_detect import YOLODetection |
| 485 | + self.yolov8_detect = YOLODetection(self.yolov8_model_path, self.yolov8_label_path) |
| 486 | + from gpiozero.pins.lgpio import LGPIOFactory |
| 487 | + from gpiozero import Device, LED |
| 488 | + Device.pin_factory = LGPIOFactory(chip=0) # 显式指定/dev/gpiochip0 |
| 489 | + # 初始化 GPIO 控制的设备 |
| 490 | + self.pump = LED(71) # 气泵 |
| 491 | + self.valve = LED(72) # 阀门 |
| 492 | + self.pump.on() # 关闭泵 |
| 493 | + time.sleep(0.05) |
| 494 | + self.valve.on() # 打开阀门 |
| 495 | + time.sleep(1) |
493 | 496 |
|
494 | 497 | else: |
495 | 498 | self.camera_edit.setText('0') |
|
0 commit comments