diff --git a/Vision/camera_coordinate_dete.py b/Vision/camera_coordinate_dete.py index e04b7ed..e8f3536 100644 --- a/Vision/camera_coordinate_dete.py +++ b/Vision/camera_coordinate_dete.py @@ -15,11 +15,12 @@ from Vision.tool.CameraRVC import camera from Vision.yolo.yolov8_pt_seg import yolov8_segment from Vision.yolo.yolov8_openvino import yolov8_segment_openvino from Vision.tool.utils import find_position +from Vision.tool.utils import class_names import os class Detection: - def __init__(self, use_openvino_model = False): + def __init__(self, use_openvino_model = True): self.use_openvino_model = use_openvino_model if self.use_openvino_model==False: model_path = ''.join([os.getcwd(), '/model/pt/best.pt']) @@ -28,14 +29,14 @@ class Detection: self.model = yolov8_segment() self.model.load_model(model_path, device) else: - model_path = ''.join([os.getcwd(), '/model/openvino/last-0903.xml']) + model_path = ''.join([os.getcwd(), '/model/openvino/best.xml']) device = 'CPU' self.camera_rvc = camera() self.model = yolov8_segment_openvino(model_path, device, conf_thres=0.3, iou_thres=0.3) - def get_position(self, Point_isVision=True): + def get_position(self, Point_isVision=False): "" ''' :param api: None @@ -68,7 +69,10 @@ class Detection: # 画box box_x1, box_y1, box_x2, box_y2 = item[0:4].astype(np.int32) - label = category_names[int(item[5])] + if self.use_openvino_model == False: + label = category_names[int(item[5])] + else: + label = class_names[int(item[4])] rand_color = (0, 255, 255) score = item[4] org = (int((box_x1 + box_x2) / 2), int((box_y1 + box_y2) / 2)) diff --git a/Vision/camera_coordinate_dete_img.py b/Vision/camera_coordinate_dete_img.py index 5976647..125ccd2 100644 --- a/Vision/camera_coordinate_dete_img.py +++ b/Vision/camera_coordinate_dete_img.py @@ -20,7 +20,7 @@ import os class Detection: - def __init__(self, use_openvino_model = False): + def __init__(self, use_openvino_model = True): self.use_openvino_model = use_openvino_model if self.use_openvino_model == False: model_path = ''.join([os.getcwd(), '/model/pt/best.pt']) @@ -32,14 +32,14 @@ class Detection: device = 'CPU' self.model = yolov8_segment_openvino(model_path, device, conf_thres=0.3, iou_thres=0.3) - img_path = ''.join([os.getcwd(), '/model/data/test0910.png']) - point_path = ''.join([os.getcwd(), '/model/data/test0910.xyz']) + img_path = ''.join([os.getcwd(), '/model/data/test0911.png']) + point_path = ''.join([os.getcwd(), '/model/data/test0911.xyz']) self.img = cv2.imread(img_path) self.point = np.loadtxt(point_path).reshape((1080, 1440, 3)) - def get_position(self, Point_isVision=True): + def get_position(self, Point_isVision=False): "" ''' :param api: None diff --git a/Vision/camera_coordinate_dete_test.py b/Vision/camera_coordinate_dete_test.py index 59ea15c..b9fd9e2 100644 --- a/Vision/camera_coordinate_dete_test.py +++ b/Vision/camera_coordinate_dete_test.py @@ -5,7 +5,7 @@ # @Author : hjw # @File : camera_coordinate_dete_test.py.py ''' -from camera_coordinate_dete_img import Detection +from camera_coordinate_dete import Detection import cv2 detection = Detection()