Beispiel #1
0
        except TypeError:
            mesh, stats_dict = out, {}
        time_dict.update(stats_dict)

        # Write output
        mesh_out_file = os.path.join(mesh_dir, '%s.off' % modelname)
        mesh.export(mesh_out_file)
        out_file_dict['mesh'] = mesh_out_file

    if generate_pointcloud:
        t0 = time.time()
        pointcloud = generator.generate_pointcloud(data)
        time_dict['pcl'] = time.time() - t0
        pointcloud_out_file = os.path.join(
            pointcloud_dir, '%s.ply' % modelname)
        export_pointcloud(pointcloud, pointcloud_out_file)
        out_file_dict['pointcloud'] = pointcloud_out_file

    if cfg['generation']['copy_input']:
        # Save inputs
        if input_type == 'pointcloud' or 'partial_pointcloud':
            inputs_path = os.path.join(in_dir, '%s.ply' % modelname)
            inputs = data['inputs'].squeeze(0).cpu().numpy()
            export_pointcloud(inputs, inputs_path, False)
            out_file_dict['in'] = inputs_path

    # Copy to visualization directory for first vis_n_output samples
    c_it = model_counter[category_id]
    if c_it < vis_n_outputs:
        # Save output files
        img_name = '%02d.off' % c_it
Beispiel #2
0
        mesh = deepcopy(mesh)
        mesh.apply_transform(mat_permute)
        if save_part_mesh == True:
            out_file = join(outfile, 'mesh_fused%d.ply' % idx)
            mesh.export(out_file)

    if idx == 0:
        faces = mesh.faces
        vertices = mesh.vertices
        print("AAAA")
    else:
        faces = np.concatenate([faces, mesh.faces + vertices.shape[0]])
        vertices = np.concatenate([vertices, mesh.vertices])
        print("BBBBB")

mesh = trimesh.Trimesh(vertices=vertices, faces=faces, process=False)
out_file = join(outfile, 'mesh_fused.ply')
mesh.export(out_file)

# Sample surface points
pcl, face_idx = mesh.sample(n_pointcloud_points, return_index=True)
normals = mesh.face_normals[face_idx]

# save surface points
out_file = join(outfile, 'pointcloud.npz')
np.savez(out_file, points=pcl.astype(dtype), normals=normals.astype(dtype))
export_pointcloud(pcl, join(outfile, 'pointcloud.ply'))

# create test.lst file
with open(join(out_path, 'test.lst'), "w") as file:
    file.write(scene_name)
Beispiel #3
0
pcl_filter = pcl_filter[pcl_filter[:,0] > -1.85]
pcl_filter = pcl_filter[pcl_filter[:,2] > -0.93]
pcl_filter = pcl_filter[pcl_filter[:,2] < 4.85]
plt.hist(pcl_filter[:,2], bins = 90)
plt.show()

#pcd.transform([[1, 0, 0, 0], [0, 0.5, 0.5, 0], [0, -0.5, 0.5, 0], [0, 0, 0, 1]])


from os.path import join, exists, isdir, exists



out_path = 'data/test'
scene_name = 'a'
outfile = join(out_path, scene_name)
out_file = join(outfile, 'pointcloud.npz')
dtype = np.float16
np.savez('pointcloud.npz', points=pcl_filter.astype(dtype), normals=pcl_filter.astype(dtype))
np.savez('pointcloud.npz', points=pcl_filter.astype(dtype))

# save surface points
out_file = join(outfile, 'pointcloud.npz')
np.savez(out_file, points=pcl.astype(dtype), normals=normals.astype(dtype))
export_pointcloud(pcl_filter, 'pointcloud_align.ply')
export_pointcloud(pcl_filter, 'pointcloud_align_filter.ply')



####### Try create occlusion ######