Derived Mesh Docstrings
TexturedPhotogrammetryMeshChunked
¶
Bases: TexturedPhotogrammetryMesh
Extends the TexturedPhotogrammtery mesh by allowing chunked operations for large meshes
Source code in geograypher/meshes/derived_meshes.py
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 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
|
Functions¶
aggregate_projected_images(cameras, batch_size=1, aggregate_img_scale=1, n_clusters=8, buffer_dist_meters=CHUNKED_MESH_BUFFER_DIST_METERS, vis_clusters=False, **kwargs)
¶
Aggregate the imagery from multiple cameras into per-face averges. This version chunks the mesh up and performs aggregation on sub-regions to decrease the runtime.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cameras |
Union[PhotogrammetryCamera, PhotogrammetryCameraSet]
|
The cameras to aggregate the images from. cam.get_image() will be called on each element. |
required |
batch_size |
int
|
The number of cameras to compute correspondences for at once. Defaults to 1. |
1
|
aggregate_img_scale |
float
|
The scale of pixel-to-face correspondences image, as a fraction of the original image. Lower values lead to better runtimes but decreased precision at content boundaries in the images. Defaults to 1. |
1
|
n_clusters |
int
|
The mesh is broken up into this many clusters. Defaults to 8. |
8
|
buffer_dist_meters |
float
|
Each cluster contains the mesh that is within this distance in meters of the camera locations. Defaults to 250. |
CHUNKED_MESH_BUFFER_DIST_METERS
|
vis_clusters |
bool
|
Should the location of the cameras and resultant clusters be shown. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
np.ndarray: (n_faces, n_image_channels) The average projected image per face |
||
dict |
Additional information, including the summed projections, observations per face, and potentially each individual projection |
Source code in geograypher/meshes/derived_meshes.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
|
get_mesh_chunks_for_cameras(cameras, n_clusters=8, buffer_dist_meters=CHUNKED_MESH_BUFFER_DIST_METERS, vis_clusters=False, include_texture=False)
¶
Return a generator of sub-meshes, chunked to align with clusters of cameras
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cameras |
Union[PhotogrammetryCamera, PhotogrammetryCameraSet]
|
The chunks of the mesh are generated by clustering the cameras |
required |
n_clusters |
int
|
The mesh is broken up into this many clusters. Defaults to 8. |
8
|
buffer_dist_meters |
float
|
Each cluster contains the mesh that is within this distance in meters of the camera locations. Defaults to 50. |
CHUNKED_MESH_BUFFER_DIST_METERS
|
vis_clusters |
bool
|
Should the location of the cameras and resultant clusters be shown. Defaults to False. |
False
|
include_texture |
bool
|
Should the texture from the full mesh be included in the subset mesh. Defaults to False. |
False
|
Yields:
Name | Type | Description |
---|---|---|
pv.PolyData: The subset mesh |
||
PhotogrammetryCameraSet |
The cameras associated with that mesh |
|
np.ndarray: The IDs of the faces in the original mesh used to generate the sub mesh |
Source code in geograypher/meshes/derived_meshes.py
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 |
|
label_polygons(face_labels, polygons, face_weighting=None, sjoin_overlay=True, return_class_labels=True, unknown_class_label='unknown', buffer_dist_meters=2, n_polygons_per_cluster=1000)
¶
Assign a class label to polygons using labels per face. This implementation is useful for large numbers of polygons. To make the expensive sjoin/overlay more efficient, this implementation first clusters the polygons and labels each cluster indepenently. This makes use of the fact that the mesh faces around this cluster can be extracted relatively quickly. Then the sjoin/overlay is computed with substaintially-fewer polygons and faces, leading to better performance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face_labels |
ndarray
|
(n_faces,) array of integer labels |
required |
polygons |
Union[PATH_TYPE, GeoDataFrame]
|
Geospatial polygons to be labeled |
required |
face_weighting |
Union[None, ndarray]
|
(n_faces,) array of scalar weights for each face, to be multiplied with the contribution of this face. Defaults to None. |
None
|
sjoin_overlay |
bool
|
Whether to use |
True
|
return_class_labels |
bool
|
(bool, optional): Return string representation of class labels rather than float. Defaults to True. |
True
|
unknown_class_label |
str
|
Label for predicted class for polygons with no overlapping faces. Defaults to "unknown". |
'unknown'
|
buffer_dist_meters |
float
|
(Union[float, None], optional) Only applicable if sjoin_overlay=False. In that case, include faces entirely within the region that is this distance in meters from the polygons. Defaults to 2.0. |
2
|
n_polygons_per_cluster |
int
|
(int): Set the number of clusters so there are approximately this number polygons per cluster on average. Defaults to 1000 |
1000
|
Raises:
Type | Description |
---|---|
ValueError
|
if faces_labels or face_weighting is not 1D |
Returns:
Name | Type | Description |
---|---|---|
list |
Union[str, int]
|
(n_polygons,) list of labels. Either float values, represnting integer IDs or nan, or string values representing the class label |
Source code in geograypher/meshes/derived_meshes.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
|
render_flat(cameras, batch_size=1, render_img_scale=1, n_clusters=8, buffer_dist_meters=CHUNKED_MESH_BUFFER_DIST_METERS, vis_clusters=False, **pix2face_kwargs)
¶
Render the texture from the viewpoint of each camera in cameras. Note that this is a generator so if you want to actually execute the computation, call list(*) on the output. This version first clusters the cameras, extracts a region of the mesh surrounding each cluster of cameras, and then performs rendering on each sub-region.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cameras |
Union[PhotogrammetryCamera, PhotogrammetryCameraSet]
|
Either a single camera or a camera set. The texture will be rendered from the perspective of each one |
required |
batch_size |
int
|
The batch size for pix2face. Defaults to 1. |
1
|
render_img_scale |
float
|
The rendered image will be this fraction of the original image corresponding to the virtual camera. Defaults to 1. |
1
|
n_clusters |
int
|
Number of clusters to break the cameras into. Defaults to 8. |
8
|
buffer_dist_meters |
float
|
How far around the cameras to include the mesh. Defaults to 50. |
CHUNKED_MESH_BUFFER_DIST_METERS
|
vis_clusters |
bool
|
Should the clusters of camera locations be shown. Defaults to False. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
If cameras is not the correct type |
Yields:
Type | Description |
---|---|
np.ndarray: The pix2face array for the next camera. The shape is (int(img_hrender_img_scale), int(img_wrender_img_scale)). |