Installation
SetUp of the Codebase
Installing Conda
We are providing a conda env yaml file for easy installation of all the dependencies. Therefore, Miniconda installation is recommended for using the UVRSABI package.
Installing Colmap
Another dependency for the package is colmap which needs to be installed as follows for the 3D reconstruction : Colmap Installation
Installing the codebase for all the modules :
Clone the Github repository by running the following commands:
$ git clone https://github.com/charvi-077/civil-structure-inspection
Once all the above dependencies have been installed, create a conda environment by running the following commands:
$ cd civil-structure-inspection
$ conda env create -f civil_code.yaml
$ conda activate civil_code
Running the Modules:
Note : All the detailed instructions are given inside README.md of every module on the above github link.
Distance Between Adjacent Buildings
First we have to 3D reconstruct the scene from the data collected in 3 different modes using “Colmap tool”
Run the below command to get sampled images from Video (from Uvrsabi directory)
$ python3 ./utils/VideoToImage.py
Follow the Colmap tutorial page to 3D resconstruct the scene from respective mode.
With respect to the mode, run the below command
$ cd DistanceModuleFrontalMode
$ python3 FrontalMode.py
or
$ cd DistanceModuleBetweenMode
$ pytho3 InBetweenMode.py
or
$ cd DistanceModuleRoofMode
$ python3 TopViewFinal.py
Roof Occupancy Estimation
Sample the images from video using above script
Traverse to code directory and run LEDNET Model on input images to get the roof masks
$ cd RoofLayoutestimation/utils/LEDNet/test
$ python test.py --datadir <path to input image directory > --resultdir < path to output directory >
Next is getting the object masks using Detic model
$ cd Detic
$ python demo.py --config-file detic/configs/Detic_LCOCOI21k_CLIP_SwinB_896b32_4x_ft4x_max-size.yaml --input ../images/*.jpg --output ../ObjectMasks --vocabulary custom --custom_vocabulary solar_array,air_conditioner,vent,box,sink --confidence-threshold 0.5 --opts MODEL.WEIGHTS Detic_LCOCOI21k_CLIP_SwinB_896b32_4x_ft4x_max-size.pth
Next, to do stitiching of input images and masks
$ python stitch.py -i images -o ObjectMasks -r RoofMasks -s $results_path/stitching_results
Estimating the roof occupancy
$ python calculateoccupancy.py -r ../RoofLayoutEstimationResults/stitching_results/stitched_roof_mask.jpg -o ../RoofLayoutEstimationResults/stitching_results/stitched_object_mask.jpg -t ../RoofLayoutEstimationResults/final_results/final_results_roof_layout_estimation.txt
Roof Area Estimation
Follow the same steps as in Roof Occupancy Estimation to get the roof masks from LEDNet Model
Estimate the Roof Area
$ cd RoofAreaCalculation
$ python find_area.py --roofmasks RoofMasks --log_file $2 --save_dir_intermediate $results_path/intermediate_results --save_dir_final $results_path/final_results
Window Detection and Storey Count Estimation
Traverse to the wind_det_heatmaps and also download the weights of the model provided link in codebase Readme
Run the inference script
$ python infer.py --cfg /path/to/yaml/config \
--model /path/to/model \
--infer /path/to/image/directory
This generates 2 dirs: infer_result and post_process_result and need to prepare respective log file as provided in codebase
Configure the parameters in below file and to run using below command to perform NMS and get the storey count from the images folder
$ cd mapToVerticalPlane
$ python main.py
Crack Detection
Using above script get the sampled images from the video
Model weights are provided in the codebase
Here for evaluation metrics we are labeling the data using v7 lab annotation tool and saving the images with same name as input image in label folder ( sample data folder is provided in the code )
Configure the data paths in the script and run the script using command as below
$ python3 test_target_label.py ( if labels are available )
or
$ python3 test_target.py ( if no labels are available, instead only input images )
Building Tilt Estimation
Approach 1 : Sensor Based Slope Estimation
We are using 2d Lidar and RTK GPS for getting the slope data for setup.
Instructions to run the code : 1. Clone and build the px4 and rplidar ros packages from source
$ roscore
$ roslaunch mavros px4.launch (buid )
$ roslaunch rplidar_ros rplidar_a2m12.launch
$ cd main_code/slope_estimation/scripts/
$ python3 slope_estimation.py
Set the rosparam to record the specific reading at the slope
$ rosparam set /reading_trigger true
Approach 2 : Base Slope Estimation
Instructions to run the code : 1. Run the script
$ python3 fit_plane.py
Approach 3 : Clustering-Based Plane Segmentation Neural Network for Urban Scene Modeling
- Requirements
Python 3.8
Pytorch 1.7.1
scikit-learn 0.24.2
Open3d 0.13.0
Dataset
We used Virtual KITTI Dataset from <a href=”https://github.com/VisualComputingInstitute/vkitti3D-dataset” target=”_blank”>here</a>.
We used voxel downsampling to filter the dataset and extract man-made structures such as roads and buildings.
Sample datasets are stored in the dataset folder
Installation
$ git clone https://github.com/jimmy9704/plane-segmentation-network.git
$ cd plane-segmentation-network/
- Training
Run the following command to start training
$ python train.py
Description of options
$ train(pointnet, dataset,train_loss, epochs=100,make_label=False, save=True)
$ make_labels(dataset,max_k=15,iteration=10)
You can create a label for training PointNet by setting the `make_label` option to ‘True’.
You can change `max_k` and `iteration`.
`max_k` is the maximum number that PointNet will estimate
`iteration` is the number of Hybrid-Kmeans iterations
`iteration` can be reduced to reduce time consumption but it might cause unstable results.
Test Run the following command to start test
$ python test.py
Description of options
$ valid(pointnet, dataset, save_num=99,iteration=5)
`save_num` is the check point to load for PointNet.
Pre-trained checkpoints can be loaded by setting ‘save_num’ to 99.
Installation of GUI (Under Development)
The GUI can be launched by running the following command:
$ cd UVRSABI-Code/
$ python gui.py
The Instructions page can be referred to for more details on how to use the GUI.