finish register
This commit is contained in:
@@ -10,8 +10,8 @@ from PytorchBoot.status import status_manager
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.append("/home/user/nbv_rec/nbv_rec_control")
|
||||
from utils.control_util import ControlUtil
|
||||
sys.path.append(r"C:\Document\Local Project\nbv_rec_control")
|
||||
#from utils.control_util import ControlUtil
|
||||
from utils.communicate_util import CommunicateUtil
|
||||
from utils.pts_util import PtsUtil
|
||||
from utils.view_sample_util import ViewSampleUtil
|
||||
@@ -99,8 +99,8 @@ class CADStrategyRunner(Runner):
|
||||
scan_points_indices_list = scan_points_idx_list,
|
||||
init_view=0,
|
||||
threshold=self.voxel_size,
|
||||
soft_overlap_threshold= self.soft_overlap_threshold,
|
||||
hard_overlap_threshold= self.hard_overlap_threshold,
|
||||
soft_overlap_threshold = self.soft_overlap_threshold,
|
||||
hard_overlap_threshold = self.hard_overlap_threshold,
|
||||
scan_points_threshold = self.scan_points_threshold,
|
||||
status_info=self.status_info
|
||||
)
|
||||
@@ -136,13 +136,22 @@ class CADStrategyRunner(Runner):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
model_path = "/home/user/nbv_rec/data/mesh.obj"
|
||||
model_path = r"C:\Users\hofee\Downloads\mesh.obj"
|
||||
model = trimesh.load(model_path)
|
||||
test_pts_L = np.loadtxt("/home/user/nbv_rec/data/cam_pts_0_L.txt")
|
||||
test_pts_R = np.loadtxt("/home/user/nbv_rec/data/cam_pts_0_R.txt")
|
||||
cad_to_cam_L = PtsUtil.register_icp(test_pts_L, model)
|
||||
cad_to_cam_R = PtsUtil.register_icp(test_pts_R, model)
|
||||
cad_pts_L = PtsUtil.transform_point_cloud(test_pts_L, cad_to_cam_L)
|
||||
cad_pts_R = PtsUtil.transform_point_cloud(test_pts_R, cad_to_cam_R)
|
||||
np.savetxt("/home/user/nbv_rec/data/cad_pts_0_L.txt", cad_pts_L)
|
||||
np.savetxt("/home/user/nbv_rec/data/cad_pts_0_R.txt", cad_pts_R)
|
||||
test_pts_L = np.load(r"C:\Users\hofee\Downloads\0.npy")
|
||||
|
||||
import open3d as o3d
|
||||
def add_noise(points, translation, rotation):
|
||||
R = o3d.geometry.get_rotation_matrix_from_axis_angle(rotation)
|
||||
noisy_points = points @ R.T + translation
|
||||
return noisy_points
|
||||
|
||||
translation_noise = np.random.uniform(-0.5, 0.5, size=3)
|
||||
rotation_noise = np.random.uniform(-np.pi/4, np.pi/4, size=3)
|
||||
noisy_pts_L = add_noise(test_pts_L, translation_noise, rotation_noise)
|
||||
|
||||
cad_to_cam_L = PtsUtil.register(noisy_pts_L, model)
|
||||
|
||||
cad_pts_L = PtsUtil.transform_point_cloud(noisy_pts_L, cad_to_cam_L)
|
||||
np.savetxt(r"test.txt", cad_pts_L)
|
||||
np.savetxt(r"src.txt", noisy_pts_L)
|
@@ -23,6 +23,7 @@ class Inferencer(Runner):
|
||||
self.load_experiment("inferencer")
|
||||
self.reconstruct_config = ConfigManager.get("runner", "reconstruct")
|
||||
self.voxel_size = self.reconstruct_config["voxel_size"]
|
||||
self.max_iter = self.reconstruct_config["max_iter"]
|
||||
|
||||
def create_experiment(self, backup_name=None):
|
||||
super().create_experiment(backup_name)
|
||||
@@ -45,6 +46,7 @@ class Inferencer(Runner):
|
||||
"combined_scanned_pts": combined_pts
|
||||
}
|
||||
''' enter loop '''
|
||||
iter = 0
|
||||
while True:
|
||||
''' inference '''
|
||||
inference_result = CommunicateUtil.get_inference_data(input_data)
|
||||
@@ -58,9 +60,14 @@ class Inferencer(Runner):
|
||||
''' update combined pts '''
|
||||
combined_pts = np.concatenate([combined_pts, curr_cam_pts], axis=0)
|
||||
combined_pts = PtsUtil.voxel_downsample_point_cloud(combined_pts, voxel_size=self.voxel_size)
|
||||
|
||||
|
||||
''' update input data '''
|
||||
input_data["combined_scanned_pts"] = combined_pts
|
||||
input_data["scanned_target_points_num"].append(curr_cam_pts.shape[0])
|
||||
input_data["scanned_n_to_world_pose_9d"].append(curr_cam_pose)
|
||||
|
||||
''' check stop condition '''
|
||||
if iter >= self.max_iter:
|
||||
break
|
||||
|
||||
|
||||
def run(self):
|
||||
|
Reference in New Issue
Block a user