This directory contains several command line tools for executing the Danesfield algorithms. The run_danesfield.py
tool runs each component of the Danesfield system end-to-end. Each of the following subsections covers a single tool.
Note that several of the tools require model files not included in this repository. These model files may not be publicly available at the time of writing. Please contact Kitware directory to request access to the models.
This script runs each of the Danesfield system components in an integrated end-to-end pipeline. The inputs / outputs of the script are controlled by a single configuration file. A template configuration file (input.ini
) can be found in this repositories root directory.
run_danesfield.py
A completed configuration file. The configuration file requires paths to source materials, paths to model files, and parameters for some algorithms.
python run_danesfield.py \
<input_configuration_file>
generate_point_cloud.py
A completed configuration file. See the VisSat configuration guide for help on creating this file.
python generate_point_cloud.py \
--config_file <aoi_config_path> \
--work_dir <work_directory_path> \
--point_cloud <output_point_cloud_path> \
--utm <utm_zone>
segment_by_height.py
python segment_by_height.py \
<dsm_image_path> \
<dtm_image_path> \
<output_mask_path> \
--msi <msi_image_path>
Can optionally pass in OpenStreetMap road data as a geojson file to include roads in the output mask.
python segment_by_height.py \
<dsm_image_path> \
<dtm_image_path> \
<output_mask_path> \
--msi <msi_image_path> \
--road-vector <road_vector_geojson_path> \
--road-rasterized <output_road_raster> \
--road-rasterized-bridge <output_road_bridge_raster>
building_segmentation.py
Download the files in this folder.
When running the script, specify the path to this folder using the --model_dir
argument
and the common prefix of the model files using the --model_prefix
argument, i.e. "Dayton_best".
python building_segmentation.py \
--rgb_image <rgb_image_path> \
--msi_image <msi_image_path> \
--dsm <dsm_image_path> \
--dtm <dtm_image_path> \
--model_dir <model_directory> \
--model_prefix <model_prefix> \
--save_dir <output_directory> \
--output_tif
kwsemantic_segment.py
Download the pretrained model
here.
A default configuration file is included in this repository at
danesfield/segmentation/semantic/test_denseunet_1x1080_retrain.json
.
python kwsemantic_segment.py \
<config_file_path> \
<model_path> \
<rgb_image_path> \
<dsm_image_path> \
<dtm_image_path> \
<msi_image_path> \
<output_directory> \
<output_filename_prefix>
Material classification from Rutgers University.
- Matthew Purri (matthew.purri@rutgers.edu)
- Orthorectified image (GeoTIFF)
- Image metadata (.IMD or .tar)
- Orthorectified material segmentation map (GeoTIFF)
- Colorized material segmentation map (PNG)
material_classifier.py
Download RN18_All.pth.tar.
When running the script, specify the path to this file using the --model-path
argument.
python material_classifier.py --image_paths <image_paths> --info_paths <info_paths> --output_dir <output_dir> --model_path <model_path> --cuda
PointNet Geon Extraction provided by Columbia University.
- Xu Zhang (xu.zhang@columbia.edu)
- Building point cloud (las text)
- Building point cloud with root type labels (las text)
roof_segmentation.py
Download the files in this folder.
When running the script, specify the path to this folder using the --model_dir
argument
and the common prefix of the model files using the --model_prefix
argument, i.e. "dayton_geon".
python roof_segmentation.py \
--model_dir=<path_to_model_dir> \
--model_prefix=<model_prefix> \
--input_pc=<path_to_input_pointcloud> \
--output_txt=<path_to_output_pointcloud> \
--output_png=<path_to_output_graphic> \
Curve fitting provided by Columbia University.
- Xu Zhang (xu.zhang@columbia.edu)
- Point cloud with roof type labels (las text)
- Point cloud of remaining (planar) points (las text)
- Geon file of fitted curves (npy)
fitting_curved_plane.py
python fitting_curved_plane.py \
--input_pc=<path_to_input_pointcloud> \
--output_png=<path_to_output_png> \
--output_txt=<path_to_output_remainingpoints_pointcloud> \
--output_geon=<path_to_geon_output>
Script to convert geon file to mesh provided by Columbia University.
- Xu Zhang (xu.zhang@columbia.edu)
- Geon file (npy)
- DTM file (tif)
- Mesh file (ply)
geon_to_mesh.py
python geon_to_mesh.py \
--input_geon=<path_to_input_geon_npy> \
--input_dtm=<path_to_input_dtm> \
--output_mesh=<path_to_output_mesh_ply>
Wrapper script for running Purdue's point cloud segmentation and reconstruction code, and Columbia's roof segmentation and geon fitting code in the right sequence.
- Bo Xu (xu1128@purdue.edu)
- Xu Zhang (xu.zhang@columbia.edu)
- P3D Point cloud (las)
- Threshold CLS file (tif)
- DTM file (tif)
- Roof segmentation model dir / prefix
- Mesh files (ply, obj)
- Geon JSON (json)
roof_geon_extraction.py
Download the files in this folder.
When running the script, specify the path to this folder using the --model_dir
argument
and the common prefix of the model files using the --model_prefix
argument, i.e. "dayton_geon".
python roof_geon_extraction.py \
--las=<path_to_p3d_pointcloud> \
--dtm=<path_to_input_dtm> \
--cls=<path_to_input_threshold_cls> \
--model_prefix=<prefix_for_model_files> \
--model_dir=<directory_containing_model_files> \
--output_dir=<path_to_output_directory>
Fetches road vector data from OpenStreetMap for an AOI, and converts to GeoJSON.
- Latitude / Longitude bounds
- Output directory
- Road vector data (GeoJSON)
- Original OSM data (osm)
get_road_vector.py
python get_road_vector.py \
--left <left_bound> \
--bottom <bottom_bound> \
--right <right_bound> \
--top <top_bound> \
--output-dir <path_to_output_directory>
Renders a DSM or CLS from a DTM and polygons representing buildings.
- DTM file (tif)
- Building polygons (vtp or list of obj paths)
- DSM or CLS file (tif)
buildings_to_dsm.py
python buildings_to_dsm.py \
<path_to_dtm> \
<path_to_output_file> \
--input_obj_paths <list_of_obj_paths>
Wrapper script around JHU/APL's Core3D scoring software found here. Given a directory of ground truth files with a common prefix, score our output files.
- DSM file (tif)
- DTM file (tif)
- CLS file (tif)
- MTL file (tif)
- Output scores (json)
run_metrics.py
python run_metrics.py \
--output-dir <output_directory_path> \
--ref-dir <path_to_reference_files> \
--ref-prefix <reference_files_prefix> \
--dsm <dsm_file_to_score> \
--cls <cls_file_to_score> \
--mtl <mtl_file_to_score> \
--dtm <dtm_file_to_score>
Orthorectify a source image using a DSM, DTM, and RPC.
- Source image (tif)
- DSM file (tif)
- DTM file (tif)
- RPC file (txt)
- Orthorectified image (tif)
orthorectify.py
python orthorectify.py \
<source_image_path> \
<DSM_path> \
<output_image_path> \
--dtm <DTM_path> \
--raytheon-rpc <RPC_path>
Textures building models using pre-processed source imagery.
- Cropped and pansharped source imagery (tif)
- Model files (obj)
- DSM file (tif)
- DTM file (tif)
- Textures (png)
- Textured models (obj)
- Textured ground (obj)
python texture_mapping.py \
<DSM_path> \
<DTM_path> \
<output_directory_path> \
<occlusion_mesh_path> \
--crops <list_of_cropped_and_pansharpened_image_paths> \
--buildings <list_of_model_paths_to_texture>
A data representation and meshing utility for CORE3D deliverables. See https://github.com/CORE3D/data_rep_c3d.
Includes the following tools:
json2obj.py
meshIO.py
paramCounter.py
primitiveMeshGen.py