Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.files = []
self.cache = {}
self.data_objects = []
self.transform = transform
self.voxel_size = config.voxel_size
self.root = './ModelNet40'
self.files = open(os.path.join(self.root,
self.DATA_FILES[phase])).read().split()
logging.info(
f"Loading the subset {phase} from {self.root} with {len(self.files)} files"
)
self.density = 4000
# Ignore warnings in obj loader
o3d.utility.set_verbosity_level(o3d.utility.VerbosityLevel.Error)
from model import load_model
from util.file import ensure_dir, get_folder_list, get_file_list
from util.trajectory import read_trajectory, write_trajectory
from util.pointcloud import make_open3d_point_cloud, evaluate_feature_3dmatch
from scripts.benchmark_util import do_single_pair_matching, gen_matching_pair, gather_results
import torch
import MinkowskiEngine as ME
ch = logging.StreamHandler(sys.stdout)
logging.getLogger().setLevel(logging.INFO)
logging.basicConfig(
format='%(asctime)s %(message)s', datefmt='%m/%d %H:%M:%S', handlers=[ch])
o3d.utility.set_verbosity_level(o3d.utility.VerbosityLevel.Error)
def extract_features_batch(model, config, source_path, target_path, voxel_size, device):
folders = get_folder_list(source_path)
f = open(os.path.join(target_path, "list.txt"), "w")
timer, tmeter = Timer(), AverageMeter()
num_feat = 0
model.eval()
for fo in folders:
if 'evaluation' in fo:
continue
files = get_file_list(fo, ".ply")
fo_base = os.path.basename(fo)
f.write("%s %d\n" % (fo_base, len(files)))
# The MIT License (MIT)
# See license file or visit www.open3d.org for details
# examples/Python/Advanced/o3d.color_map.color_map_optimization.py
import open3d as o3d
from trajectory_io import *
import os, sys
sys.path.append("../Utility")
from file import *
path = "[path_to_fountain_dataset]"
debug_mode = False
if __name__ == "__main__":
o3d.utility.set_verbosity_level(o3d.utility.VerbosityLevel.Debug)
# Read RGBD images
rgbd_images = []
depth_image_path = get_file_list(os.path.join(path, "depth/"),
extension=".png")
color_image_path = get_file_list(os.path.join(path, "image/"),
extension=".jpg")
assert (len(depth_image_path) == len(color_image_path))
for i in range(len(depth_image_path)):
depth = o3d.io.read_image(os.path.join(depth_image_path[i]))
color = o3d.io.read_image(os.path.join(color_image_path[i]))
rgbd_image = o3d.geometry.RGBDImage.create_from_color_and_depth(
color, depth, convert_rgb_to_intensity=False)
if debug_mode:
pcd = o3d.geometry.PointCloud.create_from_rgbd_image(
rgbd_image,
def write_color_distances(path, pcd, distances, max_distance):
o3d.utility.set_verbosity_level(o3d.utility.VerbosityLevel.Debug)
# cmap = plt.get_cmap("afmhot")
cmap = plt.get_cmap("hot_r")
distances = np.array(distances)
colors = cmap(np.minimum(distances, max_distance) / max_distance)[:, :3]
pcd.colors = o3d.utility.Vector3dVector(colors)
o3d.io.write_point_cloud(path, pcd)
def run_posegraph_optimization(pose_graph_name, pose_graph_optimized_name,
max_correspondence_distance,
preference_loop_closure):
# to display messages from o3d.registration.global_optimization
o3d.utility.set_verbosity_level(o3d.utility.VerbosityLevel.Debug)
method = o3d.registration.GlobalOptimizationLevenbergMarquardt()
criteria = o3d.registration.GlobalOptimizationConvergenceCriteria()
option = o3d.registration.GlobalOptimizationOption(
max_correspondence_distance=max_correspondence_distance,
edge_prune_threshold=0.25,
preference_loop_closure=preference_loop_closure,
reference_node=0)
pose_graph = o3d.io.read_pose_graph(pose_graph_name)
o3d.registration.global_optimization(pose_graph, method, criteria, option)
o3d.io.write_pose_graph(pose_graph_optimized_name, pose_graph)
o3d.utility.set_verbosity_level(o3d.utility.VerbosityLevel.Error)
def run(config):
print("refine rough registration of fragments.")
o3d.utility.set_verbosity_level(o3d.utility.VerbosityLevel.Debug)
ply_file_names = get_file_list(
join(config["path_dataset"], config["folder_fragment"]), ".ply")
make_posegraph_for_refined_scene(ply_file_names, config)
optimize_posegraph_for_refined_scene(config["path_dataset"], config)
points = []
normals = []
for _ in range(4):
for _ in range(4):
pt = (np.random.uniform(-2, 2), np.random.uniform(-2, 2), 0)
points.append(pt)
normals.append((0, 0, 1))
points = np.array(points, dtype=np.float64)
normals = np.array(normals, dtype=np.float64)
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(points)
pcd.normals = o3d.utility.Vector3dVector(normals)
radii = [1, 2]
yield pcd, radii
o3d.utility.set_verbosity_level(o3d.utility.Info)
gt_mesh = o3d.geometry.TriangleMesh.create_sphere()
gt_mesh.compute_vertex_normals()
pcd = gt_mesh.sample_points_poisson_disk(100)
radii = [0.5, 1, 2]
yield pcd, radii
gt_mesh = meshes.bunny()
gt_mesh.compute_vertex_normals()
pcd = gt_mesh.sample_points_poisson_disk(2000)
radii = [0.005, 0.01, 0.02, 0.04]
yield pcd, radii
gt_mesh = meshes.armadillo()
gt_mesh.compute_vertex_normals()
pcd = gt_mesh.sample_points_poisson_disk(2000)