diff --git a/nibio_preprocessing/density_filtering.py b/nibio_preprocessing/density_filtering.py index f2950ebfbd91ac73a793d291a6f8ba905f796090..d837bb3cd4954982f9da97a85c5af46572681117 100644 --- a/nibio_preprocessing/density_filtering.py +++ b/nibio_preprocessing/density_filtering.py @@ -6,11 +6,8 @@ import glob import os from pathlib import Path -# filter the density of the point cloud using pdal -# it does it only for a single file - class DensityFiltering: - def __init__(self, path_data, min_density, count_threshold, buffer_size, verbose=False): + def __init__(self, path_data, min_density=1, count_threshold=15000, buffer_size=0.01, verbose=False): self.path_data = Path(path_data) # remove the extension self.path_data_out = os.path.join(os.path.dirname(path_data), os.path.basename(path_data).split('.')[0]) diff --git a/nibio_preprocessing/density_filtering_in_folders.py b/nibio_preprocessing/density_filtering_in_folders.py index a4506cf7bbc241234b2a750c69ab4f1c3d11866d..b24284092288856c9d64a27e4d1aa2362aa98a99 100644 --- a/nibio_preprocessing/density_filtering_in_folders.py +++ b/nibio_preprocessing/density_filtering_in_folders.py @@ -23,8 +23,8 @@ class DensityFilteringInFolders: # copy files from os.path.join(self.path_data_out, "_clipped.las") to the input folder and rename them as the original file if result is not None: shutil.move( - os.path.join(self.input_folder, os.path.basename(density_filtering.path_data_out), "_clipped.las"), - os.path.join(self.input_folder, file)) + os.path.join(density_filtering.path_data_out, "_clipped.las"), + os.path.join(file)) if __name__ == "__main__": @@ -49,7 +49,7 @@ if __name__ == "__main__": density_filtering_in_folders.filter_density_in_folder() # a simple way to test the code - # python density_filtering_in_folders.py --input_folder /home/nibio/mutable-outside-world/code/gitlab_fsct/instance_segmentation_classic/check_maciek/ --min_density 1 --count_threshold 15000 --buffer_size 0.01 --verbose + # python nibio_preprocessing/density_filtering_in_folders.py --input_folder /home/nibio/mutable-outside-world/code/gitlab_fsct/instance_segmentation_classic/check_maciek/ --min_density 1 --count_threshold 15000 --buffer_size 0.01 --verbose diff --git a/run_bash_scripts/sem_seg_sean.sh b/run_bash_scripts/sem_seg_sean.sh index 1b9d1fe4bee713c5f16ef80999460e4d2844e8c1..b431eaa8ead5e2bc8a0b0a5949be06526face3a1 100755 --- a/run_bash_scripts/sem_seg_sean.sh +++ b/run_bash_scripts/sem_seg_sean.sh @@ -3,7 +3,7 @@ ############################ parameters ################################################# # General parameters CLEAR_INPUT_FOLDER=1 # 1: clear input folder, 0: not clear input folder -CONDA_ENV="pdal-env" # conda environment for running the pipeline +CONDA_ENV="pdal-env-1" # conda environment for running the pipeline # Parameters for the semetnic segmentation data_folder="" # path to the folder containing the data @@ -104,8 +104,8 @@ fi # do the conversion from laz to las if there are laz files in place (this is need for metrics calculation) python nibio_preprocessing/convert_files_in_folder.py --input_folder $data_folder --output_folder $data_folder --out_file_type las --in_place --verbose -# do the conversion to ply -python nibio_preprocessing/convert_files_in_folder.py --input_folder $data_folder --output_folder $data_folder --out_file_type ply --verbose +# do the density filtering +python nibio_preprocessing/density_filtering_in_folders.py --input_folder $data_folder --min_density 1 --count_threshold 15000 --buffer_size 0.01 # clear input folder if CLEAR_INPUT_FOLDER is set to 1 if [ $CLEAR_INPUT_FOLDER -eq 1 ] @@ -117,6 +117,10 @@ then echo "Removed all the files and folders except the ply and las files in the input folder" fi +# do the conversion to ply +python nibio_preprocessing/convert_files_in_folder.py --input_folder $data_folder --output_folder $data_folder --out_file_type ply --verbose + + # move the output of the first step to the input folder of the second step mkdir -p $data_folder/segmented_point_clouds