drongo-geo 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- drongo_geo-0.1.0/LICENSE +201 -0
- drongo_geo-0.1.0/PKG-INFO +375 -0
- drongo_geo-0.1.0/README.md +338 -0
- drongo_geo-0.1.0/pyproject.toml +52 -0
- drongo_geo-0.1.0/setup.cfg +4 -0
- drongo_geo-0.1.0/src/drongo/__init__.py +18 -0
- drongo_geo-0.1.0/src/drongo/_mp4.py +171 -0
- drongo_geo-0.1.0/src/drongo/camera.py +113 -0
- drongo_geo-0.1.0/src/drongo/dji_embedded.py +282 -0
- drongo_geo-0.1.0/src/drongo/frames.py +84 -0
- drongo_geo-0.1.0/src/drongo/geometry.py +263 -0
- drongo_geo-0.1.0/src/drongo/provider.py +58 -0
- drongo_geo-0.1.0/src/drongo/py.typed +0 -0
- drongo_geo-0.1.0/src/drongo/rectify.py +32 -0
- drongo_geo-0.1.0/src/drongo/telemetry.py +301 -0
- drongo_geo-0.1.0/src/drongo/types.py +70 -0
- drongo_geo-0.1.0/src/drongo_geo.egg-info/PKG-INFO +375 -0
- drongo_geo-0.1.0/src/drongo_geo.egg-info/SOURCES.txt +19 -0
- drongo_geo-0.1.0/src/drongo_geo.egg-info/dependency_links.txt +1 -0
- drongo_geo-0.1.0/src/drongo_geo.egg-info/requires.txt +10 -0
- drongo_geo-0.1.0/src/drongo_geo.egg-info/top_level.txt +1 -0
drongo_geo-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: drongo-geo
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Direct georeferencing for drone video: from flight telemetry to where every pixel is on the ground
|
|
5
|
+
Author: Arie Genkin
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/arie-distillo/drongo
|
|
8
|
+
Project-URL: Documentation, https://github.com/arie-distillo/drongo/tree/main/docs
|
|
9
|
+
Project-URL: Issues, https://github.com/arie-distillo/drongo/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/arie-distillo/drongo/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: drone,uav,georeferencing,photogrammetry,telemetry,dji,computer-vision,gis
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Image Processing
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: numpy>=1.24
|
|
29
|
+
Provides-Extra: cv
|
|
30
|
+
Requires-Dist: opencv-python>=4.8; extra == "cv"
|
|
31
|
+
Provides-Extra: testbed
|
|
32
|
+
Requires-Dist: opencv-python>=4.8; extra == "testbed"
|
|
33
|
+
Requires-Dist: pytest>=7; extra == "testbed"
|
|
34
|
+
Requires-Dist: matplotlib>=3.7; extra == "testbed"
|
|
35
|
+
Requires-Dist: pyproj>=3.5; extra == "testbed"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
<p align="center">
|
|
39
|
+
<img src="https://raw.githubusercontent.com/arie-distillo/drongo/main/docs/assets/logo.svg" alt="drongo" width="140">
|
|
40
|
+
</p>
|
|
41
|
+
|
|
42
|
+
<h1 align="center">drongo</h1>
|
|
43
|
+
|
|
44
|
+
<p align="center">
|
|
45
|
+
<b>Direct georeferencing for drone video.</b><br>
|
|
46
|
+
From flight telemetry to where every pixel is on the ground — for any camera angle, recorded or live.
|
|
47
|
+
</p>
|
|
48
|
+
|
|
49
|
+
<p align="center">
|
|
50
|
+
<a href="https://github.com/arie-distillo/drongo/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/arie-distillo/drongo/actions/workflows/ci.yml/badge.svg"></a>
|
|
51
|
+
<a href="https://pypi.org/project/drongo-geo/"><img alt="PyPI" src="https://img.shields.io/pypi/v/drongo-geo"></a>
|
|
52
|
+
<img alt="Python" src="https://img.shields.io/badge/python-3.10%E2%80%933.13-blue">
|
|
53
|
+
<a href="LICENSE"><img alt="License" src="https://img.shields.io/badge/license-Apache--2.0-green"></a>
|
|
54
|
+
</p>
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
**drongo** reads the telemetry that drones record with their video and gives you, for any frame,
|
|
59
|
+
an exact model of the camera: pixel ↔ latitude/longitude, frame and tile footprints, ground
|
|
60
|
+
resolution, the horizon, and the camera motion between frames. It works the same for straight-down,
|
|
61
|
+
oblique and rolled views, for recorded files and for live streams, and it tells you when the
|
|
62
|
+
telemetry does not match the video.
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from drongo import CameraModel, TelemetryPoseProvider, open_telemetry
|
|
66
|
+
|
|
67
|
+
provider = TelemetryPoseProvider(open_telemetry("flight.mp4"), CameraModel.preset("mavic3_wide"))
|
|
68
|
+
g = provider.geometry(t_ms=12_500, img_w_px=3840, img_h_px=2160)
|
|
69
|
+
g.pixel_to_lat_lon([[1920, 1600], [2400, 1450]]) # -> [[lat, lon], [lat, lon]]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Why drongo
|
|
73
|
+
|
|
74
|
+
Almost every application that analyses drone video needs this geometry, and most write their own.
|
|
75
|
+
The same mistakes recur: footprints computed as if the camera points straight down, then applied to
|
|
76
|
+
oblique footage; bilinear interpolation between footprint corners, which is exact only at nadir;
|
|
77
|
+
sensor dimensions from a spec sheet applied to 16:9 video recorded on a 4:3 sensor; heading
|
|
78
|
+
interpolated from 359° to 1° through 180°; proprietary metadata decoded with the wrong
|
|
79
|
+
field map and passed on unchecked; and no way to tell any of this from plausible-looking numbers.
|
|
80
|
+
drongo does the geometry once, exactly, with tests — and checks the telemetry against the
|
|
81
|
+
video itself.
|
|
82
|
+
|
|
83
|
+
## Features
|
|
84
|
+
|
|
85
|
+
- **One exact camera model** for every attitude: pixel → ground by ray–plane
|
|
86
|
+
intersection, ground → pixel, plane homographies, horizon, footprints clipped below it,
|
|
87
|
+
ground sample distance, off-nadir angle. Points above the ground are handled by giving their height.
|
|
88
|
+
- **Telemetry in**: DJI SRT sidecars (all known layouts), DJI metadata embedded in MP4/MOV
|
|
89
|
+
(pure Python, no ffmpeg or exiftool), a live packet decoder, or your own source through a
|
|
90
|
+
two-method reader interface. Impossible values are rejected and counted, and a missing or
|
|
91
|
+
unreadable source is explained, reader by reader.
|
|
92
|
+
- **Live use**: append telemetry as it arrives; frames that are ahead of the newest telemetry are
|
|
93
|
+
placed by extrapolating the recent motion. A 4K frame's geometry, 100 projected points and
|
|
94
|
+
24 tile footprints cost about 3 ms.
|
|
95
|
+
- **Diagnostics**: one command produces an HTML report for a clip — telemetry sanity checks,
|
|
96
|
+
telemetry-vs-video consistency, the telemetry clock offset, and frames draped on satellite imagery.
|
|
97
|
+
- **Synthetic flights with known answers** for testing your own pipeline: rendered video plus SRT
|
|
98
|
+
or embedded telemetry, with configurable noise, bias and clock offset.
|
|
99
|
+
- **Small and typed**: the core depends only on numpy; OpenCV is optional.
|
|
100
|
+
|
|
101
|
+
## Installation
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
pip install drongo-geo # core (numpy only)
|
|
105
|
+
pip install "drongo-geo[cv]" # + OpenCV: rectification, examples
|
|
106
|
+
pip install "drongo-geo[testbed]" # + test suite, diagnostics and synthetic data tools
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The distribution is called `drongo-geo`; the package you import is `drongo`.
|
|
110
|
+
From a clone: `pip install -e ".[testbed]"`. Python 3.10–3.13 on Linux, macOS and Windows.
|
|
111
|
+
|
|
112
|
+
## Quick start
|
|
113
|
+
|
|
114
|
+
The examples below run as written, in order, from a folder containing `clip.mp4`
|
|
115
|
+
and its telemetry sidecar `clip.SRT`. The test suite runs them on a synthetic clip
|
|
116
|
+
(`testbed/tests/test_readme.py`), so they stay correct as the code changes.
|
|
117
|
+
|
|
118
|
+
### 1. Load telemetry and get the geometry of a frame
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
from pathlib import Path
|
|
122
|
+
import numpy as np
|
|
123
|
+
from drongo import CameraModel, TelemetryPoseProvider, open_telemetry
|
|
124
|
+
|
|
125
|
+
diagnostics = []
|
|
126
|
+
track = open_telemetry(Path("clip.mp4"), diagnostics=diagnostics) # finds clip.SRT next to it
|
|
127
|
+
if track is None:
|
|
128
|
+
raise SystemExit("\n".join(diagnostics)) # says why, per reader
|
|
129
|
+
|
|
130
|
+
camera = CameraModel.preset("equiv_24mm") # or CameraModel(sensor_w_mm=..., focal_mm=...)
|
|
131
|
+
provider = TelemetryPoseProvider(track, camera) # one per flight
|
|
132
|
+
|
|
133
|
+
W, H = 1920, 1080 # size of the frames you process
|
|
134
|
+
g = provider.geometry(t_ms=2000, img_w_px=W, img_h_px=H) # the frame shown at 2.0 s
|
|
135
|
+
|
|
136
|
+
print("camera position (m east, north, up):", g.camera_enu_m.round(1))
|
|
137
|
+
print("ground resolution at image centre (cm/px):", float(g.gsd_m_per_px()[0] * 100))
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
`g` is a model of the camera for that frame. Everything below asks it questions;
|
|
141
|
+
nothing is precomputed.
|
|
142
|
+
|
|
143
|
+
### 2. Put detections on the map
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
# boxes from any detector, in pixels: x0, y0, x1, y1
|
|
147
|
+
boxes = np.array([[900, 600, 960, 640],
|
|
148
|
+
[1400, 820, 1480, 870]])
|
|
149
|
+
|
|
150
|
+
# a vehicle touches the ground at the bottom centre of its box
|
|
151
|
+
feet = np.column_stack([(boxes[:, 0] + boxes[:, 2]) / 2, boxes[:, 3]])
|
|
152
|
+
|
|
153
|
+
lat_lon = g.pixel_to_lat_lon(feet) # all points in one call
|
|
154
|
+
width_m = (boxes[:, 2] - boxes[:, 0]) * g.gsd_m_per_px(feet)
|
|
155
|
+
range_m = g.ground_range_m(feet)
|
|
156
|
+
|
|
157
|
+
for (lat, lon), w, r in zip(lat_lon, width_m, range_m):
|
|
158
|
+
print(f"{lat:.6f}, {lon:.6f} width {w:.1f} m {r:.0f} m from the drone")
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### 3. Points above the ground
|
|
162
|
+
|
|
163
|
+
A pixel defines a ray, not a point. Tell the library how high the point is, or it
|
|
164
|
+
assumes the ground.
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
bird = np.array([[1200, 300]])
|
|
168
|
+
|
|
169
|
+
as_if_on_ground = g.pixel_to_en(bird) # metres east/north of the first fix
|
|
170
|
+
at_30_m = g.pixel_to_en(bird, h_m=30.0) # the same ray, 30 m above ground
|
|
171
|
+
|
|
172
|
+
shift_m = float(np.linalg.norm(as_if_on_ground - at_30_m))
|
|
173
|
+
print(f"ignoring the 30 m height moves the bird by {shift_m:.0f} m")
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
`h_m` also takes one value per point.
|
|
177
|
+
|
|
178
|
+
### 4. Footprints as GeoJSON
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
import json
|
|
182
|
+
|
|
183
|
+
features = [g.footprint().to_geojson({"what": "frame", "t_ms": 2000})]
|
|
184
|
+
for x0 in range(0, W, 640): # a 3 x 2 grid of tiles
|
|
185
|
+
for y0 in range(0, H, 540):
|
|
186
|
+
tile = g.tile_footprint(x0, y0, x0 + 640, y0 + 540)
|
|
187
|
+
if tile is not None: # None if the tile is all sky
|
|
188
|
+
features.append(tile.to_geojson({"what": "tile", "x0": x0, "y0": y0}))
|
|
189
|
+
|
|
190
|
+
Path("footprints.geojson").write_text(
|
|
191
|
+
json.dumps({"type": "FeatureCollection", "features": features}), encoding="utf-8")
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Open `footprints.geojson` in QGIS or geojson.io.
|
|
195
|
+
|
|
196
|
+
### 5. Cancel camera motion between two frames (needs OpenCV)
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
import cv2
|
|
200
|
+
from drongo import relative_homography
|
|
201
|
+
|
|
202
|
+
cap = cv2.VideoCapture("clip.mp4")
|
|
203
|
+
fps = cap.get(cv2.CAP_PROP_FPS)
|
|
204
|
+
frames = []
|
|
205
|
+
for _ in range(31):
|
|
206
|
+
ok, frame = cap.read()
|
|
207
|
+
frames.append(cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY))
|
|
208
|
+
cap.release()
|
|
209
|
+
|
|
210
|
+
i, j = 0, 30 # one second apart at 30 fps
|
|
211
|
+
g_i = provider.geometry(i * 1000 / fps, W, H)
|
|
212
|
+
g_j = provider.geometry(j * 1000 / fps, W, H)
|
|
213
|
+
|
|
214
|
+
H_ij = relative_homography(g_i, g_j) # ground-plane motion predicted by telemetry
|
|
215
|
+
aligned = cv2.warpPerspective(frames[i], H_ij, (W, H))
|
|
216
|
+
residual = cv2.absdiff(aligned, frames[j]) # what is left: movers, parallax, telemetry error
|
|
217
|
+
|
|
218
|
+
both = (aligned > 0) & (frames[j] > 0)
|
|
219
|
+
print("mean residual after alignment:", float(residual[both].mean()))
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### 6. A north-up image of a ground area (needs OpenCV)
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
from drongo.rectify import rectify_roi
|
|
226
|
+
|
|
227
|
+
e, n = g_j.pixel_to_en([[W / 2, H / 2]])[0] # ground point at the image centre
|
|
228
|
+
ortho = rectify_roi(frames[j], g_j, roi_en=(e - 25, n - 25, e + 25, n + 25), gsd_m=0.05)
|
|
229
|
+
cv2.imwrite("ortho.png", ortho) # 50 m x 50 m at 5 cm per pixel
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### 7. Live telemetry
|
|
233
|
+
|
|
234
|
+
Set up once per stream, then feed packets as they arrive and query frames as they come in.
|
|
235
|
+
Here a recording stands in for the live feed.
|
|
236
|
+
|
|
237
|
+
```python
|
|
238
|
+
from drongo import DjiPacketDecoder, TelemetryTrack, iter_dji_packets
|
|
239
|
+
|
|
240
|
+
decoder = DjiPacketDecoder() # one per stream; works out the packet encoding itself
|
|
241
|
+
live = provider_live = None
|
|
242
|
+
|
|
243
|
+
for t_ms, packet in iter_dji_packets("flight.mp4"): # live: packets from your downlink
|
|
244
|
+
for sample in decoder.feed(packet, t_ms): # may buffer the first few packets
|
|
245
|
+
if live is None:
|
|
246
|
+
live = TelemetryTrack([sample]) # extrapolates motion past the newest sample
|
|
247
|
+
provider_live = TelemetryPoseProvider(live, camera, extrapolate_ms=300)
|
|
248
|
+
else:
|
|
249
|
+
live.append(sample) # the provider sees it immediately
|
|
250
|
+
if t_ms > 1000:
|
|
251
|
+
break # pretend we are 1 s into the flight
|
|
252
|
+
|
|
253
|
+
newest = live[-1].t_ms
|
|
254
|
+
g_now = provider_live.geometry(newest + 150, W, H) # a frame 150 ms newer than the telemetry
|
|
255
|
+
print("decoded", len(live), "samples; packet encoding:", decoder.encoding)
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Stamp packets and frames with the same clock. If your source already gives position and
|
|
259
|
+
angles (an SDK, a ground station), skip the decoder: build `PoseSample`s and `append` them.
|
|
260
|
+
|
|
261
|
+
### 8. Check a clip before trusting it
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
python -m testbed.harness.run_video --video clip.mp4 --camera equiv_24mm --out report
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
The report compares the image motion telemetry predicts with the motion measured
|
|
268
|
+
from the video, estimates the telemetry/video sync offset, and writes
|
|
269
|
+
`report.md`, a residual plot, footprints as GeoJSON and grid overlays.
|
|
270
|
+
|
|
271
|
+
### More examples
|
|
272
|
+
|
|
273
|
+
| Script | What it does |
|
|
274
|
+
|---|---|
|
|
275
|
+
| `examples/detections_to_geojson.py` | Detection boxes from a CSV (`frame, x0, y0, x1, y1, label`) to a GeoJSON point layer with time, width in metres and range |
|
|
276
|
+
| `examples/stabilise.py` | Removes camera motion using telemetry alone and writes the frame next to a heat map of what still moves |
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
python examples/detections_to_geojson.py clip.mp4 detections.csv detections.geojson --camera equiv_24mm
|
|
280
|
+
python examples/stabilise.py clip.mp4 stabilised.mp4 --camera equiv_24mm --step 5
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## Concepts in one minute
|
|
284
|
+
|
|
285
|
+
| | Convention |
|
|
286
|
+
|---|---|
|
|
287
|
+
| World frame | ENU: metres East, North, Up from a reference point (by default the first telemetry fix); z = 0 at the takeoff altitude |
|
|
288
|
+
| Angles | Degrees. Yaw clockwise from true North; pitch 0 = horizon, −90 = straight down; roll positive = image right side down |
|
|
289
|
+
| Pixels | (u, v) from the top-left corner, v downwards; arrays of shape (N, 2) |
|
|
290
|
+
| Time | Milliseconds on the video's clock; `time_offset_ms` shifts the telemetry clock onto it |
|
|
291
|
+
| Altitude | Above the takeoff point, as drones report it; set the ground level with `FlatGround(level_m=...)` |
|
|
292
|
+
|
|
293
|
+
A `TelemetryTrack` holds pose samples and interpolates between them. A `TelemetryPoseProvider` turns
|
|
294
|
+
a time into a `FrameGeometry`, an immutable model of the camera for that frame; every query is a
|
|
295
|
+
method on it and is vectorised. More in [docs/concepts.md](https://github.com/arie-distillo/drongo/blob/main/docs/concepts.md).
|
|
296
|
+
|
|
297
|
+
## Supported telemetry
|
|
298
|
+
|
|
299
|
+
| Source | Reader | Status |
|
|
300
|
+
|---|---|---|
|
|
301
|
+
| DJI SRT subtitle sidecar | `DjiSrtReader` | All known layouts (Mini/Air; Mavic/Air 2S, both gimbal-field layouts; FPV/Avata). Found next to the video automatically |
|
|
302
|
+
| DJI metadata embedded in MP4/MOV | `DjiEmbeddedReader` | Verified on Mavic 3 Enterprise; angle encoding detected per file |
|
|
303
|
+
| DJI packets from a live feed | `DjiPacketDecoder` | Same format, one packet at a time; `iter_dji_packets(path)` replays a recording |
|
|
304
|
+
| Anything else | your class with `can_read` / `read` | Pass it to `open_telemetry(..., readers=[...])`; see [docs/telemetry.md](https://github.com/arie-distillo/drongo/blob/main/docs/telemetry.md) |
|
|
305
|
+
|
|
306
|
+
Have footage from another drone? A short clip with its telemetry is the most useful contribution
|
|
307
|
+
you can make — see [CONTRIBUTING.md](https://github.com/arie-distillo/drongo/blob/main/CONTRIBUTING.md).
|
|
308
|
+
|
|
309
|
+
## Accuracy and limits
|
|
310
|
+
|
|
311
|
+
The geometry is exact: round trips agree to 10<sup>−6</sup> px, and on rendered video the motion
|
|
312
|
+
predicted from telemetry matches the motion measured from the images to under 0.5 px. In practice
|
|
313
|
+
accuracy is set by the inputs. For a consumer drone at 85 m: GPS error shifts every point by 1–3 m;
|
|
314
|
+
2° of compass error moves a point 60 m away by 2 m; 1° of pitch error at −45° moves it 3 m;
|
|
315
|
+
terrain 10 m above the takeoff point is a 12% scale error.
|
|
316
|
+
|
|
317
|
+
Release 0.x assumes flat ground: buildings and terrain relief are not modelled, so points above the
|
|
318
|
+
ground need their height (`h_m`), and footprints over tall structures are approximate.
|
|
319
|
+
Details and a full error budget: [docs/accuracy.md](https://github.com/arie-distillo/drongo/blob/main/docs/accuracy.md).
|
|
320
|
+
|
|
321
|
+
## Check a clip before you trust it
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
python -m testbed.harness.run_video --video flight.mp4 --camera mavic3_wide --out report --gap 10 --stride 6
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
Open `report/report.html`: telemetry plots and sanity checks, the difference between image motion
|
|
328
|
+
predicted from telemetry and measured from the video, the telemetry clock offset when the flight
|
|
329
|
+
makes it measurable, and frames draped on satellite imagery. If the draped frames line up with the
|
|
330
|
+
imagery, position, heading and lens are right. How to read every part:
|
|
331
|
+
[docs/diagnostics.md](https://github.com/arie-distillo/drongo/blob/main/docs/diagnostics.md).
|
|
332
|
+
|
|
333
|
+
## Performance
|
|
334
|
+
|
|
335
|
+
Measured on a laptop CPU, single thread, 4K frames:
|
|
336
|
+
|
|
337
|
+
| Operation | Time |
|
|
338
|
+
|---|---|
|
|
339
|
+
| `provider.geometry(t, w, h)` | 0.06 ms |
|
|
340
|
+
| `pixel_to_lat_lon`, 100 points | 0.11 ms |
|
|
341
|
+
| Frame footprint | 0.8 ms (first call per frame; cached after) |
|
|
342
|
+
| Geometry + 100 points + 24 tile footprints | 2.6 ms per frame |
|
|
343
|
+
| `track.append(sample)` | 1 µs |
|
|
344
|
+
|
|
345
|
+
## Project status
|
|
346
|
+
|
|
347
|
+
drongo is **pre-1.0**: the API may still change between minor versions. Planned for 1.0: plugin
|
|
348
|
+
registration of readers, a frozen public API, and published sample clips per supported drone.
|
|
349
|
+
After 1.0: MISB KLV and CSV readers, a terrain (DEM) ground model, GeoTIFF output, lens and
|
|
350
|
+
heading-bias estimation from video. See [CHANGELOG.md](https://github.com/arie-distillo/drongo/blob/main/CHANGELOG.md).
|
|
351
|
+
|
|
352
|
+
## Documentation
|
|
353
|
+
|
|
354
|
+
| | |
|
|
355
|
+
|---|---|
|
|
356
|
+
| [docs/concepts.md](https://github.com/arie-distillo/drongo/blob/main/docs/concepts.md) | Coordinate frames, camera model, how a pixel becomes a coordinate |
|
|
357
|
+
| [docs/telemetry.md](https://github.com/arie-distillo/drongo/blob/main/docs/telemetry.md) | Formats, live streams, clock offset, writing your own reader |
|
|
358
|
+
| [docs/diagnostics.md](https://github.com/arie-distillo/drongo/blob/main/docs/diagnostics.md) | The clip report, the full check, how to read the numbers |
|
|
359
|
+
| [docs/accuracy.md](https://github.com/arie-distillo/drongo/blob/main/docs/accuracy.md) | Error budget, limits, what the checks can and cannot see |
|
|
360
|
+
| [docs/api.md](https://github.com/arie-distillo/drongo/blob/main/docs/api.md) | Public API reference |
|
|
361
|
+
| [docs/testing.md](https://github.com/arie-distillo/drongo/blob/main/docs/testing.md) | The test suite, what each layer proves, running it on your clips |
|
|
362
|
+
|
|
363
|
+
## Contributing
|
|
364
|
+
|
|
365
|
+
Bug reports, footage from new drones and pull requests are welcome. Start with
|
|
366
|
+
[CONTRIBUTING.md](https://github.com/arie-distillo/drongo/blob/main/CONTRIBUTING.md); by participating you agree to the
|
|
367
|
+
[Code of Conduct](https://github.com/arie-distillo/drongo/blob/main/CODE_OF_CONDUCT.md). Security issues: see [SECURITY.md](https://github.com/arie-distillo/drongo/blob/main/SECURITY.md).
|
|
368
|
+
|
|
369
|
+
## License and citation
|
|
370
|
+
|
|
371
|
+
Apache License 2.0 — see [LICENSE](https://github.com/arie-distillo/drongo/blob/main/LICENSE). If drongo helps your research, please cite it
|
|
372
|
+
using [CITATION.cff](CITATION.cff).
|
|
373
|
+
|
|
374
|
+
*The drongo is a small, agile bird that hunts insects on the wing from a high perch — it
|
|
375
|
+
watches from above and knows exactly where things are.*
|