UPDATE Vision test
This commit is contained in:
@ -23,17 +23,17 @@ class Detection:
|
|||||||
def __init__(self, use_openvino_model = True):
|
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(), '/Vision/model/pt/best.pt'])
|
||||||
device = 'cpu'
|
device = 'cpu'
|
||||||
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/best.xml'])
|
model_path = ''.join([os.getcwd(), '/Vision/model/openvino/best.xml'])
|
||||||
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/test0911.png'])
|
img_path = ''.join([os.getcwd(), '/Vision/model/data/test0910.png'])
|
||||||
point_path = ''.join([os.getcwd(), '/model/data/test0911.xyz'])
|
point_path = ''.join([os.getcwd(), '/Vision/model/data/test0910.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))
|
||||||
|
|
||||||
|
|||||||
26
get_position_test.py
Normal file
26
get_position_test.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
'''
|
||||||
|
# @Time : 2024/9/7 11:49
|
||||||
|
# @Author : hjw
|
||||||
|
# @File : get_position_test.py
|
||||||
|
'''
|
||||||
|
from Vision.camera_coordinate_dete_img import Detection
|
||||||
|
from Trace.handeye_calibration import *
|
||||||
|
|
||||||
|
import cv2
|
||||||
|
|
||||||
|
detection = Detection()
|
||||||
|
|
||||||
|
while True:
|
||||||
|
ret, img, xyz, nx_ny_nz = detection.get_position()
|
||||||
|
if ret==1:
|
||||||
|
print('xyz点云坐标:', xyz)
|
||||||
|
print('nx_ny_nz法向量:', nx_ny_nz)
|
||||||
|
img = cv2.resize(img,(720, 540))
|
||||||
|
transformation_matrix = R_matrix(521.534, 0.705, 850.03, 0.0, 90.0, 0.0) # (x, y, z, u, v, w)
|
||||||
|
target_position, noraml_base = getPosition(xyz[0], xyz[1], xyz[2], nx_ny_nz[0], nx_ny_nz[1], nx_ny_nz[2], transformation_matrix)
|
||||||
|
print("target_position:", target_position)
|
||||||
|
print("noraml_base", noraml_base)
|
||||||
|
cv2.imshow('img', img)
|
||||||
|
cv2.waitKey(0)
|
||||||
Reference in New Issue
Block a user