Entrypoints
Entrypoints are functions can be directly called to perform a high-level task. Each of the entrypoints listed below can be called as a command line script. These scripts accept arguments that are directly passed to these functions.
render_labels(mesh_file, cameras_file, image_folder, texture, render_savefolder, transform_file=None, subset_images_savefolder=None, texture_column_name=None, DTM_file=None, ground_height_threshold=None, render_ground_class=False, textured_mesh_savefile=None, ROI=None, mesh_ROI_buffer_radius_meters=50, cameras_ROI_buffer_radius_meters=150, IDs_to_labels=None, render_image_scale=1, mesh_downsample=1, n_render_clusters=None, vis=False, mesh_vis_file=None, labels_vis_folder=None)
¶
Renders image-based labels using geospatial ground truth data
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh_file |
PATH_TYPE
|
Path to the Metashape-exported mesh file |
required |
cameras_file |
PATH_TYPE
|
Path to the MetaShape-exported .xml cameras file |
required |
image_folder |
PATH_TYPE
|
Path to the folder of images used to create the mesh |
required |
texture |
Union[PATH_TYPE, ndarray, None]
|
See TexturedPhotogrammetryMesh.load_texture |
required |
render_savefolder |
PATH_TYPE
|
Where to save the rendered labels |
required |
transform_file |
Union[PATH_TYPE, None]
|
File containing the transform from local coordinates to EPSG:4978. Defaults to None. |
None
|
subset_images_savefolder |
Union[PATH_TYPE, None]
|
Where to save the subset of images for which labels are generated. Defaults to None. |
None
|
texture_column_name |
Union[str, None]
|
Column to use in vector file for texture information". Defaults to None. |
None
|
DTM_file |
Union[PATH_TYPE, None]
|
Path to a DTM file to use for ground thresholding. Defaults to None. |
None
|
ground_height_threshold |
Union[float, None]
|
Set points under this height to ground. Only applicable if DTM_file is provided. Defaults to None. |
None
|
render_ground_class |
bool
|
Should the ground class be included in the renders or deleted.. Defaults to False. |
False
|
textured_mesh_savefile |
Union[PATH_TYPE, None]
|
Where to save the textured and subsetted mesh, if needed in the future. Defaults to None. |
None
|
ROI |
Union[PATH_TYPE, GeoDataFrame, MultiPolygon, None]
|
The region of interest to render labels for. Defaults to None. |
None
|
mesh_ROI_buffer_radius_meters |
float
|
The distance in meters to include around the ROI for the mesh. Defaults to 50. |
50
|
cameras_ROI_buffer_radius_meters |
float
|
The distance in meters to include around the ROI for the cameras. Defaults to 150. |
150
|
IDs_to_labels |
Union[None, dict]
|
Mapping between the integer labels and string values for the classes. Defaults to None. |
None
|
render_image_scale |
float
|
Downsample the images to this fraction of the size for increased performance but lower quality. Defaults to 1. |
1
|
mesh_downsample |
float
|
Downsample the mesh to this fraction of vertices for increased performance but lower quality. Defaults to 1. |
1
|
n_render_clusters |
Union[int, None]
|
If set, break the camera set and mesh into this many clusters before rendering. This is useful for large meshes that are otherwise very slow. Defaults to None. |
None
|
Source code in geograypher/entrypoints/render_labels.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
|
aggregate_images(mesh_file, cameras_file, image_folder, label_folder, subset_images_folder=None, take_every_nth_camera=100, mesh_transform_file=None, DTM_file=None, height_above_ground_threshold=2.0, ROI=None, ROI_buffer_radius_meters=50, IDs_to_labels=None, mesh_downsample=1.0, n_aggregation_clusters=None, aggregate_image_scale=1.0, aggregated_face_values_savefile=None, predicted_face_classes_savefile=None, top_down_vector_projection_savefile=None, vis=False)
¶
Aggregate labels from multiple viewpoints onto the surface of the mesh
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh_file |
PATH_TYPE
|
Path to the Metashape-exported mesh file |
required |
cameras_file |
PATH_TYPE
|
Path to the MetaShape-exported .xml cameras file |
required |
image_folder |
PATH_TYPE
|
Path to the folder of images used to create the mesh |
required |
label_folder |
PATH_TYPE
|
Path to the folder of labels to be aggregated onto the mesh. Must be in the same structure as the images |
required |
subset_images_folder |
Union[PATH_TYPE, None]
|
Use only images from this subset. Defaults to None. |
None
|
take_every_nth_camera |
Union[int, None]
|
Downsample the camera set to only every nth camera if set. Defaults to None. |
100
|
mesh_transform_file |
Union[PATH_TYPE, None]
|
Transform from the mesh coordinates to the earth-centered, earth-fixed frame. Can be a 4x4 matrix represented as a .csv, or a Metashape cameras file containing the information. Defaults to None. |
None
|
DTM_file |
Union[PATH_TYPE, None]
|
Path to a digital terrain model file to remove ground points. Defaults to None. |
None
|
height_above_ground_threshold |
float
|
Height in meters above the DTM to consider ground. Only used if DTM_file is set. Defaults to 2.0. |
2.0
|
ROI |
Union[PATH_TYPE, None]
|
Geofile region of interest to crop the mesh to. Defaults to None. |
None
|
ROI_buffer_radius_meters |
float
|
Keep points within this distance of the provided ROI object, if unset, everything will be kept. Defaults to 50. |
50
|
IDs_to_labels |
Union[dict, None]
|
Maps from integer IDs to human-readable class name labels. Defaults to None. |
None
|
mesh_downsample |
float
|
Downsample the mesh to this fraction of vertices for increased performance but lower quality. Defaults to 1.0. |
1.0
|
n_aggregation_clusters |
Union[int, None]
|
If set, aggregate with this many clusters. Defaults to None. |
None
|
aggregate_image_scale |
float
|
Downsample the labels before aggregation for faster runtime but lower quality. Defaults to 1.0. |
1.0
|
aggregated_face_values_savefile |
Union[PATH_TYPE, None]
|
Where to save the aggregated image values as a numpy array. Defaults to None. |
None
|
predicted_face_classes_savefile |
Union[PATH_TYPE, None]
|
Where to save the most common label per face texture as a numpy array. Defaults to None. |
None
|
top_down_vector_projection_savefile |
Union[PATH_TYPE, None]
|
Where to export the predicted map. Defaults to None. |
None
|
vis |
bool
|
Show the mesh model and predicted results. Defaults to False. |
False
|
Source code in geograypher/entrypoints/aggregate_images.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
project_detections(mesh_filename, cameras_filename, project_to_mesh=False, convert_to_geospatial=False, image_folder=None, detections_folder=None, projections_to_mesh_filename=None, projections_to_geospatial_savefilename=None, default_focal_length=None, image_shape=None, segmentor_kwargs={}, vis_mesh=False, vis_geodata=False)
¶
Project per-image detections to geospatial coordinates
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh_filename |
PATH_TYPE
|
Path to mesh file, in local coordinates from Metashape |
required |
cameras_filename |
PATH_TYPE
|
Path to cameras file. This also contains local-to-global coordinate transform to convert the mesh to geospatial units. |
required |
project_to_mesh |
bool
|
Execute the projection to mesh step. Defaults to False. |
False
|
convert_to_geospatial |
bool
|
Execute the conversion to geospatial step. Defaults to False. |
False
|
image_folder |
PATH_TYPE
|
Path to the folder of images used to generate the detections. TODO, see if this can be removed since none of this information is actually used. Defaults to None. |
None
|
detections_folder |
PATH_TYPE
|
Folder of detections in the DeepForest format, one per image. Defaults to None. |
None
|
projections_to_mesh_filename |
PATH_TYPE
|
Where to save and/or load from the data for the detections projected to the mesh faces. Defaults to None. |
None
|
projections_to_geospatial_savefilename |
PATH_TYPE
|
Where to export the geospatial detections. Defaults to None. |
None
|
default_focal_length |
float
|
Since the focal length is not provided in many cameras files, it can be specified. The units are in pixels. TODO, figure out where this information can be reliably obtained from. Defaults to None. |
None
|
segmentor_kwargs |
dict
|
Dict of keyword arguments to pass to the segmentor. Defaults to {}. |
{}
|
vis_mesh |
bool
|
Show the mesh with detections projected onto it. Defaults to False. |
False
|
vis_geodata |
bool
|
Show the geospatial projection. Defaults to False. |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
If convert_to_geospatial but no projections to mesh are available |
FileNotFoundError
|
If the projections_to_mesh_filename is set and needed but not present |
Source code in geograypher/entrypoints/project_detections.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
label_polygons(mesh_file, mesh_transform_file, aggregated_face_values_file, geospatial_polygons_to_label, geospatial_polygons_labeled_savefile, mesh_downsample=1.0, DTM_file=None, height_above_ground_threshold=2.0, ground_voting_weight=0.01, ROI=None, ROI_buffer_radius_meters=50, n_polygons_per_cluster=1000, IDs_to_labels=None, vis_mesh=False)
¶
Label each polygon with the most commonly predicted class as computed by the weighted sum of 3D face areas
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh_file |
PATH_TYPE
|
Path to the Metashape-exported mesh file |
required |
mesh_transform_file |
PATH_TYPE
|
Transform from the mesh coordinates to the earth-centered, earth-fixed frame. Can be a 4x4 matrix represented as a .csv, or a Metashape cameras file containing the information. |
required |
aggregated_face_values_file |
PATH_TYPE
|
Path to a (n_faces, n_classes) numpy array containing the frequency of each class prediction for each face |
required |
geospatial_polygons_to_label |
Union[PATH_TYPE, None]
|
Each polygon/multipolygon will be labeled independently. Defaults to None. |
required |
geospatial_polygons_labeled_savefile |
Union[PATH_TYPE, None]
|
Where to save the labeled results. |
required |
mesh_downsample |
float
|
Fraction to downsample mesh. Should match what was used to generate the aggregated_face_values_file. Defaults to 1.0. |
1.0
|
DTM_file |
Union[PATH_TYPE, None]
|
Path to a digital terrain model file to remove ground points. Defaults to None. |
None
|
height_above_ground_threshold |
float
|
Height in meters above the DTM to consider ground. Only used if DTM_file is set. Defaults to 2.0. |
2.0
|
ground_voting_weight |
float
|
Faces identified as ground are given this weight during voting. Defaults to 0.01. |
0.01
|
ROI |
Union[PATH_TYPE, None]
|
Geofile region of interest to crop the mesh to. Should match what was used to generate aggregated_face_values_file. Defaults to None. |
None
|
ROI_buffer_radius_meters |
float
|
Keep points within this distance of the provided ROI object, if unset, everything will be kept. Should match what was used to generate aggregated_face_values_file. Defaults to 50. |
50
|
n_polygons_per_cluster |
int
|
The number of polygons to use in each cluster, when computing labeling by chunks. Defaults to 1000. |
1000
|
IDs_to_labels |
Union[dict, None]
|
Mapping from integer IDs to human readable labels. Defaults to None. |
None
|
Source code in geograypher/entrypoints/label_polygons.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|