UPDATE Vision bug 坐标超范围

This commit is contained in:
HJW
2024-09-26 20:06:25 +08:00
parent 5ee1e49b1b
commit 0b03bc4c3c

View File

@ -15,21 +15,22 @@ from psutil._common import bytes2human
def out_bounds_dete(pm_y, pm_x, piont_y, piont_x):
if piont_y>pm_y:
piont_y = pm_y
if piont_y>=pm_y:
piont_y = pm_y-1
print('四坐标点超出点云大小')
if piont_y<0:
piont_y=0
print('四坐标点超出点云大小')
if piont_x>pm_x:
piont_x = pm_x
if piont_x>=pm_x:
piont_x = pm_x-1
print('四坐标点超出点云大小')
if piont_x<0:
piont_x=0
print('四坐标点超出点云大小')
return piont_y, piont_x
def remove_nan_mean_value(pm, y, x, iter_max=15):
def remove_nan_mean_value(pm, y, x, iter_max=50):
y, x = out_bounds_dete(pm.shape[0], pm.shape[1], y, x)
point_x, point_y, point_z = pm[y, x]
if np.isnan(point_x):
print('Nan值去除')
@ -66,7 +67,7 @@ def remove_nan_mean_value(pm, y, x, iter_max=15):
point_z_list.append(pm[y_current, x_current][2])
len_point_x = len(point_x_list)
if len_point_x>0:
if len_point_x > 0:
point_x = sum(point_x_list)/len_point_x
point_y = sum(point_y_list)/len_point_x
point_z = sum(point_z_list)/len_point_x
@ -78,7 +79,7 @@ def remove_nan_mean_value(pm, y, x, iter_max=15):
if remove_nan_isok == True:
return point_x, point_y, point_z
else:
print('15*15范围中未找到有效值,所有点云值为无效值')
print(f'{iter_max}*{iter_max}范围中未找到有效值,所有点云值为无效值')
return np.nan, np.nan, np.nan
def remove_nan(pm, y, x):