API Reference¶
This page is generated from Python docstrings.
Projector¶
cameralib.projector.Projector
¶
A projector to perform camera coordinates operations on ODX datasets
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_path
|
str
|
Path to ODX project |
required |
z_sample_window
|
int
|
Size of the window to use when sampling elevation values |
1
|
z_sample_strategy
|
str
|
Strategy to use when sampling elevation values. Can be one of: ['minimum', 'maximum', 'average', 'median'] |
'median'
|
z_sample_target
|
str
|
Elevation raster to use for sampling elevation. One of: ['dsm', 'dtm'] |
'dsm'
|
z_fill_nodata
|
bool
|
Whether to fill nodata cells with nearest neighbor cell values. This gives a wider coverage for queries, but increases the initialization time. |
True
|
raycast_resolution_multiplier
|
float
|
Value that affects the ray sampling resolution. Lower values can lead to slightly more precise results, but increase processing time. |
0.7071
|
dem_path
|
str | None
|
Manually set a path to a valid GeoTIFF DEM for sampling Z values instead of using the default. |
None
|
Source code in cameralib/projector.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 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 | |
cam2world(image, coordinates, normalized=False)
¶
Project 2D pixel coordinates in camera space to geographic coordinates
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
str
|
Image filename. |
required |
coordinates
|
list[tuple[float, float]] | ndarray
|
Pixel coordinates as (x, y) pairs. |
required |
normalized
|
bool
|
Whether the input coordinates are normalized to [0..1]. |
False
|
Returns:
| Type | Description |
|---|---|
list[tuple[float, float, float] | None]
|
Geographic coordinates (list[tuple[float, float, float] | None]): Geographic coordinates as (lat, lon, elevation) for each coordinate pair. Returns None for rays that do not intersect the DEM. |
Source code in cameralib/projector.py
cam2geoJSON(image, coordinates, properties=None, normalized=False)
¶
Project 2D pixel coordinates in camera space to geographic coordinates and output the result as GeoJSON. A single coordinate results in a Point, two coordinates into a LineString and more than two into a Polygon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
str
|
Image filename. |
required |
coordinates
|
list[tuple[float, float]] | ndarray
|
Pixel coordinates as (x, y) pairs. |
required |
properties
|
dict[str, Any] | None
|
Optional GeoJSON feature properties. |
None
|
normalized
|
bool
|
Whether the input coordinates are normalized to [0..1]. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: GeoJSON FeatureCollection. |
Source code in cameralib/projector.py
world2cams(longitude, latitude, normalized=False)
¶
Find which cameras in the reconstruction see a particular location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
longitude
|
float
|
Longitude |
required |
latitude
|
float
|
Latitude |
required |
normalized
|
bool
|
Whether to normalize pixel coordinates by the image dimension. By default pixel coordinates are in range [0..image width], [0..image height]. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
Cameras |
list[dict[str, str | float]]
|
A list of camera dictionaries containing filename, x, and y keys. |
Source code in cameralib/projector.py
Utilities¶
cameralib.utils
¶
read_xanylabeling_annotations(labels_dir)
¶
Read an annotation file generated with X-AnyLabeling (https://github.com/CVHub520/X-AnyLabeling)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels_dir
|
str
|
Path to a directory containing X-AnyLabeling labels. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Annotations |
list[dict[str, Any]]
|
A list of annotations with image, coordinates, properties, and normalized fields. |
Source code in cameralib/utils.py
read_yolov7_annotations(labels_dir, image_suffix='.JPG')
¶
Read an annotation directory in YOLOv7 format
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels_dir
|
str
|
Path to a directory containing YOLOv7 labels. |
required |
image_suffix
|
str
|
Extension of the target images. |
'.JPG'
|
Returns:
| Name | Type | Description |
|---|---|---|
Annotations |
list[dict[str, Any]]
|
A list of annotations with image, coordinates, properties, and normalized fields. |