feat:优化安全检测与药材识别逻辑
- 在安全检测结果中添加药材识别提示
-优化检测结果的绘制方式,使用副本避免直接修改原始帧
| | |
| | | res_ = "aidetect," + f"{det_res}" |
| | | logger.info("发送安全检测结果:"+str(res_)) |
| | | l.send_msg(res_) |
| | | if 81 in class_ids: |
| | | logger.info("识别到药材,正在上料") |
| | | print("识别到药材,正在上料") |
| | | |
| | | # 上料识别 |
| | | probabilities = load_identifier(frame) |
| | |
| | | cv2.putText(img, label, (x - 10, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2) |
| | | |
| | | def draw_detections(self, frame, class_ids, scores, boxes): |
| | | det_img = frame.copy() |
| | | result_boxes = cv2.dnn.NMSBoxes(boxes, scores, 0.25, 0.45, 0.5) |
| | | |
| | | for i in range(len(result_boxes)): |
| | | index = result_boxes[i] |
| | | box = boxes[index] |
| | | self.draw_bounding_box(frame, class_ids[index], scores[index], round(box[0] * self.scale), round(box[1] * self.scale), |
| | | self.draw_bounding_box(det_img, class_ids[index], scores[index], round(box[0] * self.scale), round(box[1] * self.scale), |
| | | round((box[0] + box[2]) * self.scale), round((box[1] + box[3]) * self.scale)) |
| | | return frame |
| | | return det_img |
| | | |
| | | |
| | | |