update vision
This commit is contained in:
@ -15,11 +15,12 @@ from Vision.tool.CameraRVC import camera
|
|||||||
from Vision.yolo.yolov8_pt_seg import yolov8_segment
|
from Vision.yolo.yolov8_pt_seg import yolov8_segment
|
||||||
from Vision.yolo.yolov8_openvino import yolov8_segment_openvino
|
from Vision.yolo.yolov8_openvino import yolov8_segment_openvino
|
||||||
from Vision.tool.utils import find_position
|
from Vision.tool.utils import find_position
|
||||||
|
from Vision.tool.utils import class_names
|
||||||
import os
|
import os
|
||||||
|
|
||||||
class Detection:
|
class Detection:
|
||||||
|
|
||||||
def __init__(self, use_openvino_model = False):
|
def __init__(self, use_openvino_model = True):
|
||||||
self.use_openvino_model = use_openvino_model
|
self.use_openvino_model = use_openvino_model
|
||||||
if self.use_openvino_model==False:
|
if self.use_openvino_model==False:
|
||||||
model_path = ''.join([os.getcwd(), '/model/pt/best.pt'])
|
model_path = ''.join([os.getcwd(), '/model/pt/best.pt'])
|
||||||
@ -28,14 +29,14 @@ class Detection:
|
|||||||
self.model = yolov8_segment()
|
self.model = yolov8_segment()
|
||||||
self.model.load_model(model_path, device)
|
self.model.load_model(model_path, device)
|
||||||
else:
|
else:
|
||||||
model_path = ''.join([os.getcwd(), '/model/openvino/last-0903.xml'])
|
model_path = ''.join([os.getcwd(), '/model/openvino/best.xml'])
|
||||||
device = 'CPU'
|
device = 'CPU'
|
||||||
self.camera_rvc = camera()
|
self.camera_rvc = camera()
|
||||||
self.model = yolov8_segment_openvino(model_path, device, conf_thres=0.3, iou_thres=0.3)
|
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
|
:param api: None
|
||||||
@ -68,7 +69,10 @@ class Detection:
|
|||||||
|
|
||||||
# 画box
|
# 画box
|
||||||
box_x1, box_y1, box_x2, box_y2 = item[0:4].astype(np.int32)
|
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)
|
rand_color = (0, 255, 255)
|
||||||
score = item[4]
|
score = item[4]
|
||||||
org = (int((box_x1 + box_x2) / 2), int((box_y1 + box_y2) / 2))
|
org = (int((box_x1 + box_x2) / 2), int((box_y1 + box_y2) / 2))
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import os
|
|||||||
|
|
||||||
class Detection:
|
class Detection:
|
||||||
|
|
||||||
def __init__(self, use_openvino_model = False):
|
def __init__(self, use_openvino_model = True):
|
||||||
self.use_openvino_model = use_openvino_model
|
self.use_openvino_model = use_openvino_model
|
||||||
if self.use_openvino_model == False:
|
if self.use_openvino_model == False:
|
||||||
model_path = ''.join([os.getcwd(), '/model/pt/best.pt'])
|
model_path = ''.join([os.getcwd(), '/model/pt/best.pt'])
|
||||||
@ -32,14 +32,14 @@ class Detection:
|
|||||||
device = 'CPU'
|
device = 'CPU'
|
||||||
self.model = yolov8_segment_openvino(model_path, device, conf_thres=0.3, iou_thres=0.3)
|
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'])
|
img_path = ''.join([os.getcwd(), '/model/data/test0911.png'])
|
||||||
point_path = ''.join([os.getcwd(), '/model/data/test0910.xyz'])
|
point_path = ''.join([os.getcwd(), '/model/data/test0911.xyz'])
|
||||||
self.img = cv2.imread(img_path)
|
self.img = cv2.imread(img_path)
|
||||||
self.point = np.loadtxt(point_path).reshape((1080, 1440, 3))
|
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
|
:param api: None
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
# @Author : hjw
|
# @Author : hjw
|
||||||
# @File : camera_coordinate_dete_test.py.py
|
# @File : camera_coordinate_dete_test.py.py
|
||||||
'''
|
'''
|
||||||
from camera_coordinate_dete_img import Detection
|
from camera_coordinate_dete import Detection
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
detection = Detection()
|
detection = Detection()
|
||||||
|
|||||||
Reference in New Issue
Block a user