update
This commit is contained in:
@@ -210,6 +210,17 @@ class DataLoadUtil:
|
||||
else:
|
||||
pts = np.load(npy_path)
|
||||
return pts
|
||||
|
||||
@staticmethod
|
||||
def load_from_preprocessed_nrm(path, file_type="npy"):
|
||||
npy_path = os.path.join(
|
||||
os.path.dirname(path), "nrm", os.path.basename(path) + "." + file_type
|
||||
)
|
||||
if file_type == "txt":
|
||||
nrm = np.loadtxt(npy_path)
|
||||
else:
|
||||
nrm = np.load(npy_path)
|
||||
return nrm
|
||||
|
||||
@staticmethod
|
||||
def cam_pose_transformation(cam_pose_before):
|
||||
|
27
utils/vis.py
27
utils/vis.py
@@ -158,18 +158,23 @@ class visualizeUtil:
|
||||
np.savetxt(os.path.join(output_dir, "target_normal.txt"), sampled_visualized_normal)
|
||||
|
||||
@staticmethod
|
||||
def save_pts_nrm(pts_nrm, output_dir):
|
||||
pts = pts_nrm[:, :3]
|
||||
nrm = pts_nrm[:, 3:]
|
||||
def save_pts_nrm(root, scene, frame_idx, output_dir, binocular=False):
|
||||
path = DataLoadUtil.get_path(root, scene, frame_idx)
|
||||
pts_world = DataLoadUtil.load_from_preprocessed_pts(path, "npy")
|
||||
nrm_camera = DataLoadUtil.load_from_preprocessed_nrm(path, "npy")
|
||||
cam_info = DataLoadUtil.load_cam_info(path, binocular=binocular)
|
||||
cam_to_world = cam_info["cam_to_world"]
|
||||
nrm_world = nrm_camera @ cam_to_world[:3, :3].T
|
||||
visualized_nrm = []
|
||||
num_samples = 10
|
||||
for i in range(len(pts)):
|
||||
visualized_nrm.append(pts[i] + 0.02*t * nrm[i] for t in range(num_samples))
|
||||
visualized_nrm = np.array(visualized_nrm).reshape(-1, 3)
|
||||
for i in range(len(pts_world)):
|
||||
for t in range(num_samples):
|
||||
visualized_nrm.append(pts_world[i] - 0.02 * t * nrm_world[i])
|
||||
|
||||
visualized_nrm = np.array(visualized_nrm)
|
||||
np.savetxt(os.path.join(output_dir, "nrm.txt"), visualized_nrm)
|
||||
np.savetxt(os.path.join(output_dir, "pts.txt"), pts)
|
||||
|
||||
|
||||
np.savetxt(os.path.join(output_dir, "pts.txt"), pts_world)
|
||||
|
||||
# ------ Debug ------
|
||||
|
||||
if __name__ == "__main__":
|
||||
@@ -184,6 +189,4 @@ if __name__ == "__main__":
|
||||
# visualizeUtil.save_seq_cam_pos_and_cam_axis(root, scene, [0, 121, 286, 175, 111,366,45,230,232,225,255,17,199,78,60], output_dir)
|
||||
# visualizeUtil.save_target_mesh_at_world_space(root, model_dir, scene)
|
||||
#visualizeUtil.save_points_and_normals(root, scene,"10", output_dir, binocular=True)
|
||||
pts_nrm = np.loadtxt(r"C:\Document\Local Project\nbv_rec\nbv_reconstruction\pts_nrm_target.txt")
|
||||
visualizeUtil.save_pts_nrm(pts_nrm, output_dir)
|
||||
|
||||
visualizeUtil.save_pts_nrm(root, scene, "116", output_dir, binocular=True)
|
||||
|
Reference in New Issue
Block a user