def plot_init_potato(): cla = dcp.Classifier( path_list=['data/potato_fore.png', 'data/potato_back.png'], kind_list=[0, -1], core='dtc') plot = dcp.Plot('data/potato.ply', cla, output_path='output') return plot
def plot_init_brocoli(): cla = dcp.Classifier(path_list=[ 'data/brocoli_train_plant1.ply', 'data/brocoli_train_soil.ply', 'data/brocoli_train_soil_gcp.ply' ], kind_list=[0, -1, -1], core='dtc') plot = dcp.Plot('data/brocoli.ply', cla, output_path='output') return plot
import easydcp as dcp cla = dcp.Classifier( path_list=['training_data/02/fore_rm_r.png', 'training_data/02/back.png'], kind_list=[0, -1], core='dtc', unit='m') # batch processing plot_set = ['SP1G2.ply', 'SP4G1.ply'] #ply files must be in working directory # empty list for batch processing result_container = [] for plot in plot_set: plot_class = dcp.Plot( plot, cla, write_ply=True, unit='m', down_sample=True ) # show_steps=True to display output among calculation to check correct or not # ---------- auto_segment() -------------- plot_class.pcd_classified = plot_class.remove_noise() eps, min_points = plot_class.auto_dbscan_args(eps_grids=13, divide=100) seg = plot_class.dbscan_segment(eps=eps, min_points=min_points) if len(seg[0]) > 3: split = plot_class.kmeans_split() reset_id = plot_class.sort_order(name_by='x', ascending=True) plot_class.save_segment_result(img_folder='plot_out') # ---------------------------------------- traits = plot_class.get_traits() result_container.append(traits) plot_all = pd.concat(result_container, axis=0).reset_index() plot_all.to_csv('traits.csv', index=False)
plant_merge_list = ['S04/class[0]-plant2.ply', 'S04/class[0]-plant3.ply'] pcd_list = [] for ply_path in plant_merge_list: pcd = dcp.read_ply(ply_path) pcd_list.append(pcd) m_pcd = dcp.merge_pcd(pcd_list) #o3d.visualization.draw_geometries([m_pcd]) cla = dcp.Classifier( path_list=['training_data/fore_rm_y.png', 'training_data/back.png'], kind_list=[0, -1], core='dtc') plot1 = dcp.Plot('S04.ply', cla, show_steps=True) plant_m = dcp.Plant(plot1, m_pcd, 0, 0) out_dict = { 'x(m)': [], 'y(m)': [], 'width(m)': [], 'length(m)': [], 'hover_area(m2)': [], 'height(m)': [], 'convex_volume(m3)': [], 'voxel_volume(m3)': [] } out_dict['x(m)'] = plant_m.center[0] out_dict['y(m)'] = plant_m.center[1]
core='dtc', unit='m') # batch processing ## HZ setting #plot_set = ['S01.ply', 'S02.ply', 'S03.ply', 'S04.ply', 'S05.ply', 'S06.ply', 'S18.ply', 'S32.ply'] ## Alex Setting plot_set = ['SP1G2.ply', 'SP4G1.ply'] # empty list for batch processing result_container = [] for plot in plot_set: # show_steps=True to display output among calculation to check correct or not plot_class = dcp.Plot(plot, cla, write_ply=True, unit='m', down_sample=True) # ---------- auto_segment() -------------- plot_class.pcd_classified = plot_class.remove_noise() eps, min_points = plot_class.auto_dbscan_args(eps_grids=13, divide=100) seg = plot_class.dbscan_segment(eps=eps, min_points=min_points) if len(seg[0]) > 3: split = plot_class.kmeans_split() reset_id = plot_class.sort_order(name_by='x', ascending=True) plot_class.save_segment_result(img_folder='plot_out') # ---------------------------------------- traits = plot_class.get_traits(container_ht=0.057) result_container.append(traits) plot_all = pd.concat(result_container, axis=0).reset_index()
import __init__ import easydcp as dcp cla = dcp.Classifier(path_list=[ 'data/down_sample_train_fore.ply', 'data/down_sample_train_back.ply' ], kind_list=[0, -1], core='dtc', unit='mm') plot = dcp.Plot('data/down_sample', cla, output_path='output', write_ply=True, unit='mm') # start auto_segmentation() plot.pcd_classified = plot.remove_noise() eps, min_points = plot.auto_dbscan_args(eps_grids=10) seg = plot.dbscan_segment(eps=eps, min_points=min_points) split = plot.kmeans_split() reset_id = plot.sort_order(name_by='x', ascending=True) plot.save_segment_result() # end auto_segmentation() df = plot.get_traits()
import __init__ import easydcp as dcp cla = dcp.Classifier(path_list=['data/weed_fore.png', 'data/weed_back.png'], kind_list=[0, -1], core='dtc') plot = dcp.Plot('data/weed.ply', cla, output_path='output') # start auto_segmentation() plot.pcd_classified = plot.remove_noise() eps, min_points = plot.auto_dbscan_args(times=10) seg = plot.dbscan_segment(eps=eps, min_points=min_points) split = plot.kmeans_split() reset_id = plot.sort_order(name_by='x', ascending=True) plot.save_segment_result() # end auto_segmentation() df = plot.get_traits()
import __init__ import easydcp as dcp cla = dcp.Classifier( path_list=['training_data/01/fore_rm_y.png', 'training_data/01/back.png'], kind_list=[0, -1], core='dtc', unit='m') plot1 = dcp.Plot(r'S03.ply', cla, unit='m', write_ply=False, down_sample=True) # ----------- auto_segmentation() ---------- plot1.pcd_classified = plot1.remove_noise() # split the shortest axis into 100 parts eps, min_points = plot1.auto_dbscan_args(eps_grids=13, divide=100) # the dbscan eps is the length of 10 grids, (10/100=10% of shortest axis in this case) # the min_points is the mean points of each grids (voxels) seg = plot1.dbscan_segment(eps=eps, min_points=min_points) split = plot1.kmeans_split( ) # the algorithm to remove big noise that can not be removed in previous steps (limited by min_points) reset_id = plot1.sort_order(name_by='x', ascending=True) plot1.save_segment_result(img_folder='plot_out') # ------------------------------------------- traits = plot1.get_traits(container_ht=0.057) # size in meter traits.to_csv('S03/plot1.csv')
import __init__ import easydcp as dcp import pandas as pd cla = dcp.Classifier(path_list=['data/brocoli_train_plant1.ply', 'data/brocoli_train_soil.ply', 'data/brocoli_train_soil_gcp.ply'], kind_list=[0, -1, -1], core='dtc') plot = dcp.Plot('data/brocoli.ply', cla, output_path='output') #seg = plot.auto_segmentation() seg = plot.dbscan_segment(eps=1, min_points=10) print(seg) #df = plot.get_traits() #print(df)