diff --git a/Trace/README.md b/Trace/README.md index 79eb44a..9b8def4 100644 --- a/Trace/README.md +++ b/Trace/README.md @@ -1,3 +1,7 @@ +# com_pose.txt 彩色图对齐深度图 +# com_pose2.txt 深度图对齐彩色图 + + # 路径处理 使用model的Position类和Expection的code定义 diff --git a/Trace/com_pose2.txt b/Trace/com_pose2.txt new file mode 100644 index 0000000..f6751a9 --- /dev/null +++ b/Trace/com_pose2.txt @@ -0,0 +1,4 @@ +9.6751729364544639e-02 -9.9459449602428807e-01 3.7694712403242861e-02 4.1708226127179734e+02 +-9.9527317207468335e-01 -9.6998182736478769e-02 -4.7608291523444628e-03 1.9086796578832980e+03 +8.3914130733227475e-03 -3.7055917530319504e-02 -9.9927796091108601e-01 2.7052748714031904e+03 +0. 0. 0. 1 \ No newline at end of file diff --git a/Trace/handeye_calibration.py b/Trace/handeye_calibration.py index 844b314..1c5c2fd 100644 --- a/Trace/handeye_calibration.py +++ b/Trace/handeye_calibration.py @@ -56,7 +56,7 @@ def R_matrix(x,y,z,u,v,w): # 图像识别结果:xyz和法向量 def getPosition(x,y,z,a,b,c,rotation,points): target = np.asarray([x, y, z,1]) - camera2robot = np.loadtxt('./Trace/com_pose.txt', delimiter=' ') #相对目录且分隔符采用os.sep + camera2robot = np.loadtxt('./Trace/com_pose2.txt', delimiter=' ') #相对目录且分隔符采用os.sep # robot2base = rotation # camera2base = robot2base @ camera2robot target_position = np.dot(camera2robot, target) diff --git a/Vision/camera_coordinate_dete.py b/Vision/camera_coordinate_dete.py index e13944a..15ce6cd 100644 --- a/Vision/camera_coordinate_dete.py +++ b/Vision/camera_coordinate_dete.py @@ -75,7 +75,7 @@ class Detection: self.model = yolov8_segment_openvino(model_path, device, conf_thres=0.3, iou_thres=0.3) - def get_position(self, Point_isVision=False, Box_isPoint=True, First_Depth =True, Iter_Max_Pixel = 30, save_img_point=0, Height_reduce = 60, width_reduce = 100): + def get_position(self, Point_isVision=False, Box_isPoint=True, First_Depth =True, Iter_Max_Pixel = 30, save_img_point=0, Height_reduce = 60, width_reduce = 100, Xmin =330, Xmax = 1050, Ymin =290 ,Ymax = 690 ): """ 检测料袋相关信息 :param Point_isVision: 点云可视化 @@ -85,6 +85,11 @@ class Detection: :param save_img_point: 0不保存 ; 1保存原图 ;2保存处理后的图 ; 3保存点云和原图;4 保存点云和处理后的图; 5 异常数据保存(点云NAN) :param Height_reduce: 检测框的高内缩像素 :param width_reduce: 检测框的宽内缩像素 + :param Xmin: 限定料袋中心点的范围 + :param Xmax: 限定料袋中心点的范围 + :param Ymin: 限定料袋中心点的范围 + :param Ymax: 限定料袋中心点的范围 + :return ret: bool 相机是否正常工作 :return img: ndarray 返回img :return xyz: list 目标中心点云值形如[x,y,z] @@ -270,6 +275,8 @@ class Detection: x_rotation_center = int((box[0][0][0] + box[1][0][0] + box[2][0][0] + box[3][0][0]) / 4) y_rotation_center = int((box[0][0][1] + box[1][0][1] + box[2][0][1] + box[3][0][1]) / 4) point_x, point_y, point_z = remove_nan_mean_value(pm, y_rotation_center, x_rotation_center, iter_max=Iter_Max_Pixel) + if x_rotation_centerXmax or y_rotation_centerYmax: + continue cv2.circle(img, (x_rotation_center, y_rotation_center), 4, (255, 255, 255), 5) # 标出中心点 if np.isnan(point_x): # 点云值为无效值 continue diff --git a/Vision/find_img_point.py b/Vision/find_img_point.py index 2d2f031..f874477 100644 --- a/Vision/find_img_point.py +++ b/Vision/find_img_point.py @@ -8,18 +8,20 @@ import cv2 import numpy as np -img = cv2.imread('./model/data/0925_01_28.png') -img2 = img[:600, 380:] -cv2.imshow('img2',img2) -cv2.imshow('img',img) -cv2.waitKey(0) +img = cv2.imread('./model/data/2024_12_16_18_32_40.png') +# img2 = img[:600, 380:] +img = cv2.resize(img,(640,480)) +# cv2.imshow('img3',img3) +# cv2.imshow('img2',img2) +# cv2.imshow('img',img) +# cv2.waitKey(0) def on_EVENT_LBUTTONDOWN(event, x, y, flags, param): if event == cv2.EVENT_LBUTTONDOWN: xy = "%d,%d" % (x, y) - cv2.circle(img, (x, y), 1, (255, 0, 0), thickness = -1) + cv2.circle(img, (x, y), 1, (0, 0, 255), thickness = -1) cv2.putText(img, xy, (x, y), cv2.FONT_HERSHEY_PLAIN, - 1.0, (0,0,0), thickness = 1) + 1.0, (0,0,255), thickness = 1) cv2.imshow("image", img) cv2.namedWindow("image") cv2.setMouseCallback("image", on_EVENT_LBUTTONDOWN) diff --git a/Vision/model/data/2024_12_16_18_32_40.png b/Vision/model/data/2024_12_16_18_32_40.png new file mode 100644 index 0000000..da36795 Binary files /dev/null and b/Vision/model/data/2024_12_16_18_32_40.png differ