Skip to content

Commit

Permalink
Add roundtrip example
Browse files Browse the repository at this point in the history
  • Loading branch information
pierotofy committed Sep 13, 2024
1 parent f9d658b commit eb4cb44
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cameralib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* `Hello World`_
* `X-AnyLabeling annotations to GeoJSON`_
* `Yolov7 annotations to GeoJSON`_
* `Round Trip`_
Getting Help / Reporting Issues:
--------------------------------
Expand All @@ -44,6 +45,8 @@
https://github.com/OpenDroneMap/CameraLib/blob/main/examples/anylabeling.py
.. _Yolov7 annotations to GeoJSON:
https://github.com/OpenDroneMap/CameraLib/blob/main/examples/yolov7.py
.. _Round Trip:
https://github.com/OpenDroneMap/CameraLib/blob/main/examples/roundtrip.py
.. _report it:
https://github.com/OpenDroneMap/CameraLib/issues
.. _`GitHub`:
Expand Down
18 changes: 18 additions & 0 deletions examples/roundtrip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import math
from cameralib import Projector
from cameralib.tests import get_test_dataset


p = Projector(get_test_dataset())
coords = [46.8423725961765, -91.99395518749954]
print(f"Input: {coords}")

cams = p.world2cams(*coords)
for cam in cams:
if cam['filename'] == 'DJI_0028.JPG':
print(f"X: {cam['x']} Y: {cam['y']}")
output = p.cam2world('DJI_0028.JPG', [(cam['x'], cam['y'])])
print(f"Output: {output[0]}")
rms = math.sqrt((coords[0] - output[0][0]) ** 2 + (coords[1] - output[0][1]) ** 2)
print(f"Reprojection error: ~{rms / 7.87e-6} meters")

0 comments on commit eb4cb44

Please sign in to comment.