update preprocessor

This commit is contained in:
2024-10-03 23:36:18 +08:00
parent d7561738c6
commit fd7614c847
4 changed files with 58 additions and 27 deletions

View File

@@ -190,7 +190,7 @@ class DataLoadUtil:
mask_path = os.path.join(
os.path.dirname(path), "mask", os.path.basename(path) + ".png"
)
mask_image = cv2.imread(mask_path, cv2.IMREAD_GRAYSCALE)
mask_image = cv2.imread(mask_path, cv2.IMREAD_UNCHANGED)
return mask_image
@staticmethod
@@ -199,23 +199,22 @@ class DataLoadUtil:
normal_path_L = os.path.join(
os.path.dirname(path), "normal", os.path.basename(path) + "_L.png"
)
normal_image_L = cv2.imread(normal_path_L, cv2.IMREAD_UNCHANGED)
normal_image_L = cv2.imread(normal_path_L, cv2.IMREAD_COLOR)
normal_path_R = os.path.join(
os.path.dirname(path), "normal", os.path.basename(path) + "_R.png"
)
normal_image_R = cv2.imread(normal_path_R, cv2.IMREAD_UNCHANGED)
return normal_image_L, normal_image_R
normal_image_R = cv2.imread(normal_path_R, cv2.IMREAD_COLOR)
return normal_image_L[:3,:3], normal_image_R[:3,:3]
else:
if binocular and left_only:
normal_path = os.path.join(
os.path.dirname(path), "normal", os.path.basename(path) + "_L.png"
)
else:
normal_path = os.path.join(
os.path.dirname(path), "normal", os.path.basename(path) + ".png"
)
normal_image = cv2.imread(normal_path, cv2.IMREAD_UNCHANGED)
normal_image = cv2.imread(normal_path, cv2.IMREAD_COLOR)
return normal_image
@staticmethod

View File

@@ -20,6 +20,8 @@ class PtsUtil:
@staticmethod
def random_downsample_point_cloud(point_cloud, num_points, require_idx=False):
if point_cloud.shape[0] == 0:
if require_idx:
return point_cloud, np.array([])
return point_cloud
idx = np.random.choice(len(point_cloud), num_points, replace=True)
if require_idx:
@@ -60,7 +62,11 @@ class PtsUtil:
cos_theta = np.dot(normals_normalized, camera_axis)
theta_rad = np.deg2rad(theta)
idx = cos_theta > np.cos(theta_rad)
print(cos_theta, theta_rad)
filtered_points= points[idx]
# ------ Debug Start ------
import ipdb;ipdb.set_trace()
# ------ Debug End ------
if require_idx:
return filtered_points, idx
return filtered_points