UPDATE Vision box:bug
This commit is contained in:
@ -63,10 +63,11 @@ 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, save_img_point=0, Height_reduce = 30, width_reduce = 30):
|
||||
def get_position(self, Point_isVision=False, Box_isPoint=True, save_img_point=0, Height_reduce = 30, width_reduce = 30):
|
||||
"""
|
||||
检测料袋相关信息
|
||||
:param Point_isVision: 点云可视化
|
||||
:param Box_isPoint: True 返回点云值; False 返回box相机坐标
|
||||
:param save_img_point: 0不保存 ; 1保存原图 ;2保存处理后的图 ; 3保存点云和原图;4 保存点云和处理后的图
|
||||
:param Height_reduce: 检测框的高内缩像素
|
||||
:param width_reduce: 检测框的宽内缩像素
|
||||
@ -237,7 +238,13 @@ class Detection:
|
||||
box[1][0][1], box[1][0][0] = out_bounds_dete(pm.shape[0], pm.shape[1], box[1][0][1], box[1][0][0])
|
||||
box[2][0][1], box[2][0][0] = out_bounds_dete(pm.shape[0], pm.shape[1], box[2][0][1], box[2][0][0])
|
||||
box[3][0][1], box[3][0][0] = out_bounds_dete(pm.shape[0], pm.shape[1], box[3][0][1], box[3][0][0])
|
||||
|
||||
if Box_isPoint == True:
|
||||
box_point_x1, box_point_y1, box_point_z1 = remove_nan_mean_value(pm, box[0][0][1], box[0][0][0])
|
||||
box_point_x2, box_point_y2, box_point_z2 = remove_nan_mean_value(pm, box[1][0][1], box[1][0][0])
|
||||
box_point_x3, box_point_y3, box_point_z3 = remove_nan_mean_value(pm, box[2][0][1], box[2][0][0])
|
||||
box_point_x4, box_point_y4, box_point_z4 = remove_nan_mean_value(pm, box[3][0][1], box[3][0][0])
|
||||
else:
|
||||
pass
|
||||
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)
|
||||
@ -245,7 +252,14 @@ class Detection:
|
||||
if np.isnan(point_x): # 点云值为无效值
|
||||
continue
|
||||
else:
|
||||
box_list.append(box)
|
||||
if Box_isPoint == True:
|
||||
box_list.append(
|
||||
[[box_point_x1, box_point_y1, box_point_z1],
|
||||
[box_point_x2, box_point_y2, box_point_z2],
|
||||
[box_point_x3, box_point_y3, box_point_z3],
|
||||
[box_point_x4, box_point_y4, box_point_z4]])
|
||||
else:
|
||||
box_list.append(box)
|
||||
if self.cameraType=='RVC':
|
||||
xyz.append([point_x*1000, point_y*1000, point_z*1000])
|
||||
Depth_Z.append(point_z*1000)
|
||||
|
||||
@ -45,10 +45,11 @@ class Detection:
|
||||
pass
|
||||
|
||||
|
||||
def get_position(self, Point_isVision=False, save_img_point=0, seg_distance_threshold = 0.01, Height_reduce = 30, width_reduce = 30):
|
||||
def get_position(self, Point_isVision=False, Box_isPoint=True, save_img_point=0, seg_distance_threshold = 0.01, Height_reduce = 30, width_reduce = 30):
|
||||
"""
|
||||
检测料袋相关信息
|
||||
:param Point_isVision: 点云可视化
|
||||
:param Box_isPoint: True 返回点云值; False 返回box相机坐标
|
||||
:param save_img_point: 0不保存 ; 1保存原图 ;2保存处理后的图 ; 3保存点云和原图;4 保存点云和处理后的图
|
||||
:param Height_reduce: 检测框的高内缩像素
|
||||
:param width_reduce: 检测框的宽内缩像素
|
||||
@ -223,6 +224,13 @@ class Detection:
|
||||
box[1][0][1], box[1][0][0] = out_bounds_dete(pm.shape[0], pm.shape[1], box[1][0][1], box[1][0][0])
|
||||
box[2][0][1], box[2][0][0] = out_bounds_dete(pm.shape[0], pm.shape[1], box[2][0][1], box[2][0][0])
|
||||
box[3][0][1], box[3][0][0] = out_bounds_dete(pm.shape[0], pm.shape[1], box[3][0][1], box[3][0][0])
|
||||
if Box_isPoint == True:
|
||||
box_point_x1, box_point_y1, box_point_z1 = remove_nan_mean_value(pm, box[0][0][1], box[0][0][0])
|
||||
box_point_x2, box_point_y2, box_point_z2 = remove_nan_mean_value(pm, box[1][0][1], box[1][0][0])
|
||||
box_point_x3, box_point_y3, box_point_z3 = remove_nan_mean_value(pm, box[2][0][1], box[2][0][0])
|
||||
box_point_x4, box_point_y4, box_point_z4 = remove_nan_mean_value(pm, box[3][0][1], box[3][0][0])
|
||||
else:
|
||||
pass
|
||||
|
||||
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)
|
||||
@ -231,7 +239,14 @@ class Detection:
|
||||
if np.isnan(point_x): # 点云值为无效值
|
||||
continue
|
||||
else:
|
||||
box_list.append(box)
|
||||
if Box_isPoint == True:
|
||||
box_list.append(
|
||||
[[box_point_x1, box_point_y1, box_point_z1],
|
||||
[box_point_x2, box_point_y2, box_point_z2],
|
||||
[box_point_x3, box_point_y3, box_point_z3],
|
||||
[box_point_x4, box_point_y4, box_point_z4]])
|
||||
else:
|
||||
box_list.append(box)
|
||||
Depth_Z.append(point_z * 1000)
|
||||
nx_ny_nz.append([a, b, c])
|
||||
RegionalArea.append(cv2.contourArea(max_contour))
|
||||
|
||||
Reference in New Issue
Block a user