def plot_labelled_volume(self, label_map): volume = self.tsdf_volume.get_volume() grid_labelled = np.argmin(volume, axis=-1) grid_occupied = (np.min(volume, axis=-1) < 0) occupied_idxs = np.column_stack( np.where(grid_occupied == True)) * self.resolution occupied_labels = grid_labelled[np.where(grid_occupied == True)] # voxel colors colors = [] for label in occupied_labels: colors.append(label_map[label]) colors = np.asarray(colors) # voxel alphas alphas = len(colors) * [255] dataframe = dict() dataframe['x'] = occupied_idxs[:, 0] dataframe['y'] = occupied_idxs[:, 1] dataframe['z'] = occupied_idxs[:, 2] dataframe['red'] = colors[:, 0] dataframe['green'] = colors[:, 1] dataframe['blue'] = colors[:, 2] dataframe['alpha'] = alphas pcl = pd.DataFrame(data=dataframe, columns=dataframe.keys()) pcl = PyntCloud(pcl) pcl.plot()
def reconstruction( from_path=None, to_path=None, filtre=None, k=None, z_max=None, r=None, SW_TOF0=False, SW_TOF1=False, SW_TOF2=False, internal=True, distance=0, start_circle=0, stop_circle=None, seuil=200, speed_sample=48, T=7617.43, ): data_calculated = dispose_data(SW_TOF0=SW_TOF0, SW_TOF1=SW_TOF1, SW_TOF2=SW_TOF2, internal=internal, distance=distance, start_circle=start_circle, stop_circle=stop_circle, path=from_path, seuil=seuil, speed_sample=speed_sample, T=T) point = pd.DataFrame(data_calculated, columns=[ 'x', 'y', 'z', ]) cloud = PyntCloud(point) if filtre is None: print("Do not use any filter") pass elif filtre is "SOR": cloud.apply_filter(filtre_SOR(point, k=k, z_max=z_max)) print("Use filter SOR") elif filtre is "ROR": cloud.apply_filter(filtre_ROR(point, k=k, r=r)) print("Use filter ROR") cloud.to_file(to_path) cloud.plot(return_scene=True) print("Generated successfully, the PLY file has been stored in: ", to_path)
import numpy as np import pandas as pd from pyntcloud import PyntCloud positions = np.random.rand(1000, 3) * 10 positions -= positions.mean(0) points = pd.DataFrame(positions.astype(np.float32), columns=['x', 'y', 'z']) points["red"] = (np.random.rand(1000) * 255).astype(np.uint8) points["green"] = (np.random.rand(1000) * 255).astype(np.uint8) points["blue"] = (np.random.rand(1000) * 255).astype(np.uint8) cloud = PyntCloud(points) lines = [{ "color": "red", "vertices": [[0, 0, 0], [10, 0, 0]] }, { "color": "green", "vertices": [[0, 0, 0], [0, 10, 0]] }, { "color": "blue", "vertices": [[0, 0, 0], [0, 0, 10]] }] cloud.plot(polylines=lines)
#plt.show() #point cloud colourImg = imgL indicesArray = np.moveaxis(np.indices((hl, wl)), 0, 2) imageArray = np.dstack((indicesArray, colourImg)).reshape((-1, 5)) df = pd.DataFrame(imageArray, columns=["x", "y", "red", "green", "blue"]) depthImg = filteredImg depthArray = np.array(depthImg[::-2]) df.insert(loc=2, column='z', value=depthArray) df[['x', 'y', 'z']] = df[['x', 'y', 'z']].astype(float) df[['red', 'green', 'blue']] = df[['red', 'green', 'blue']].astype(np.uint) df['z'] = df['z'] * 0.5 cloud = PyntCloud(df) cloud.plot() #cv2.imshow("as", filt_Color) #plt.imshow(image) #plt.colorbar() #plt.show() cv2.waitKey() cv2.destroyAllWindows() main()
log """ fname = fname.replace('\\', '/').rsplit('/')[-1] fname = fname[:fname.find('.')] point_cloud_pynt.points.loc[feature_point_idxs, :].to_csv( "output/{}_{}_{}_{}_{}.txt".format(fname, srm, nmrm, gamma_21, gamma_32), header=False, index=False) # with open("output/stats.txt", "a") as f: # l = [class_, srm, nmrm, gamma_21, gamma_32, len(feature_point_idxs)] # l = [str(e) for e in l] # f.write(','.join(l)+'\n') print(fname, nmrm, gamma_21, gamma_32, "There are", len(feature_point_idxs), "feature points") #%% """ Visualization """ point_cloud_pynt.plot() # scene = point_cloud_pynt.plot(initial_point_size=0.01, return_scene=True) # point_cloud_pynt_feature_points = PyntCloud(point_cloud_pynt.points.iloc[feature_point_idxs,:]) # scene.children += [point_cloud_pynt_feature_points] # point_cloud_pynt_feature_points.plot(initial_point_size=0.5, scene = scene) point_cloud_o3d = point_cloud_pynt.to_instance("open3d", mesh=False) o3d.visualization.draw_geometries([point_cloud_o3d])
from pyntcloud import PyntCloud import pandas as pd df= pd.read_csv("../Data/V_20180816_I285_EB_run1(0).csv") df.rename(columns={'X':'x', 'Y':'y', 'Z':'z'}, inplace=True) anky_cloud = PyntCloud(df) anky_cloud.plot()
def plot_points_from_torch(tensor): cloud = PyntCloud(pd.DataFrame(tensor, columns=['x', 'y', 'z'])) cloud.plot(background='white', initial_point_size=0.003)