Exemplo n.º 1
0
def try_open3d_viz(args):
    """Try to visualize sparse 3d point cloud using open3d"""
    try:
        from open3d import visualization as viz
        from open3d import io
        ply_file = os.path.join(args.outdir, "sparse_inliers.ply")
        pc = io.read_point_cloud(ply_file)
        viz.draw_geometries([pc])
    except ImportError as err:
        print("Failed to import `open3d` package, can not visualize"
              " point-cloud, try installing open3d or use meshlab to visualize"
              " ply file.")
Exemplo n.º 2
0
 def runSubsample(self, sourcePath, targetPath, skipScaling, parameters):
     from open3d import io
     print(":: Loading point clouds and downsampling")
     source = io.read_point_cloud(sourcePath)
     sourceSize = np.linalg.norm(
         np.asarray(source.get_max_bound()) -
         np.asarray(source.get_min_bound()))
     target = io.read_point_cloud(targetPath)
     targetSize = np.linalg.norm(
         np.asarray(target.get_max_bound()) -
         np.asarray(target.get_min_bound()))
     voxel_size = targetSize / (55 * parameters["pointDensity"])
     scaling = (targetSize) / sourceSize
     if skipScaling != 0:
         scaling = 1
     source.scale(scaling, center=False)
     source_down, source_fpfh = self.preprocess_point_cloud(
         source, voxel_size, parameters["normalSearchRadius"],
         parameters["FPFHSearchRadius"])
     target_down, target_fpfh = self.preprocess_point_cloud(
         target, voxel_size, parameters["normalSearchRadius"],
         parameters["FPFHSearchRadius"])
     return source, target, source_down, target_down, source_fpfh, target_fpfh, voxel_size, scaling
Exemplo n.º 3
0
def stp2pcd(stpName, modelDir):
    baseName = stpName.split('.')[0]
    stlName = baseName + '.stl'
    plyName = baseName + '.ply'
    pcdName = baseName + '.pcd'
    stp2stl(filename=stpName, fileIODir=modelDir, linDeflection=0.1, solidOnly=True)
    stl2ply(filename=stlName, fileIODir=modelDir)
    print("Load a ply point cloud, print it, and render it")
    pcd = o3d.read_point_cloud(os.path.join(modelDir, plyName))
    # print(pcd)
    # print(np.asarray(pcd.points))
    # draw_geometries([pcd])
    # os.remove(os.path.join(modelDir, stlName))
    os.remove(os.path.join(modelDir, plyName))
    o3d.write_point_cloud(os.path.join(modelDir, pcdName), pcd)
Exemplo n.º 4
0
def label_loop(dir_name):
    global STATUS

    for name in listdir(dir_name):
        if ".zip" in name:
            continue

        try:
            with open(f"{dir_name}/{name}.meta", 'x') as file:
                pcd = io.read_point_cloud(f"{dir_name}/{name}")
                STATUS = 0
                draw_geometries_with_key_callbacks([pcd], {
                    ord('0'): _pass,
                    ord('1'): _alert,
                },
                                                   left=0,
                                                   top=0)
                file.write(f"{STATUS}\n")
        except FileExistsError:
            pass
Exemplo n.º 5
0
def db_read_point_cloud(file):
    path = fsdb._file_path(file, file.filename)
    return read_point_cloud(path)
Exemplo n.º 6
0
def main():
    model_orig_pcd = io.read_point_cloud("model.pcd")
    sample_pcd = io.read_point_cloud(
        "sample.pcd")  # Any sample point cloud can be given here
    Pose = pose3D(model_orig_pcd, sample_pcd)
    Pose.estimate_3Dpose()
Exemplo n.º 7
0
def show(cpd_path):
    pcd = io.read_point_cloud(cpd_path)
    draw_geometries_with_key_callbacks([pcd], {32: _pass})
Exemplo n.º 8
0
 def _get_annotation(self, pair):
     pcd = io.read_point_cloud(pair[0]).voxel_down_sample(voxel_size=0.05)
     image = np.asarray(pcd.points, dtype=np.float32)
     image = cv2.resize(image, (10000, 3))
     image = (image - image.mean()) / (image.std() + 1e-6)
     return image, np.array(pair[1], dtype=np.int32)