UPDATE Vision 图漾相机代码融合

This commit is contained in:
HJW
2024-09-27 15:29:07 +08:00
parent 65a649cc21
commit ac3606b8b3
4 changed files with 35 additions and 16 deletions

View File

@ -12,7 +12,8 @@ import numpy as np
import cv2
import open3d as o3d
import time
from Vision.tool.CameraRVC import camera
from Vision.tool.CameraRVC import camera_rvc
from Vision.tool.CameraPe import camera_pe
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
@ -24,7 +25,7 @@ import os
class Detection:
def __init__(self, use_openvino_model = True):
def __init__(self, use_openvino_model = True, cameraIsRVC = True):
self.use_openvino_model = use_openvino_model
if self.use_openvino_model == False:
model_path = ''.join([os.getcwd(), '/Vision/model/pt/best.pt'])
@ -36,14 +37,15 @@ 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(), '/Vision/model/data/test0911.png'])
point_path = ''.join([os.getcwd(), '/Vision/model/data/test0911.xyz'])
img_path = ''.join([os.getcwd(), '/Vision/model/data/1.png'])
point_path = ''.join([os.getcwd(), '/Vision/model/data/1.xyz'])
self.img = cv2.imread(img_path)
self.point = np.loadtxt(point_path).reshape((1080, 1440, 3))
pass
def get_position(self, Point_isVision=False, save_img_point=True, seg_distance_threshold = 10):
def get_position(self, Point_isVision=False, save_img_point=True, seg_distance_threshold = 0.01):
""
'''
:param api: None
@ -186,8 +188,15 @@ class Detection:
# 这一步不影响后面的画图,但是可以保证四个角点坐标为顺时针
startidx = box.sum(axis=1).argmin()
box1 = np.roll(box, 4 - startidx, 0)
box = np.roll(box, 4 - startidx, 0)
box = np.int0(box)
# 在原图上画出预测的外接矩形
'''
拟合最大内接矩形,计算矩形中心
'''
box = box.reshape((-1, 1, 2)).astype(np.int32)
box = box + [[[box_x1, box_y1]], [[box_x1, box_y1]], [[box_x1, box_y1]], [[box_x1, box_y1]]]