question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUESTION] Project shots over flat plane.

See original GitHub issue

Hello, and thank you for the project and your efforts on this project. 🙂

I would like to know if you could, please, throw some light to how to project all the images over a plane. More precisely I have some drone pictures taken at high altitude (no perspective affected) and I would like to put them all together like it can be seen in the viewer. I’m setting the use_altitude_tag to True in the config during the reconstruction.

image

My code so far is:

project_path = </path/to/project>
data = DataSet(project_path)

rec: Reconstruction = data.load_reconstruction()[0]
ref: TopocentricConverter = rec.reference

# Plane will be created at the mean altitude (z position) of 3D points
points = rec.get_points().values()
plane_altitude: LandmarkView = np.median([p.coordinates[2] for p in points])

for shot_id in rec.get_shots():
    
    shot: Shot = rec.shots[shot_id]
    cam: Camera = shot.camera
    pose: Pose = shot.pose

   # Scale

    x,y,z = pose.get_origin()
    z_scale = z - plane_altitude

   # Rotation

    # I think the main problem is here (?):
    # I ignore the Z axis because I suppose shot is "almost" facing down
    rot_matrix = pose.get_rotation_matrix()[:2,:2].T
    rot_matrix /= z_scale   # Set scale at floor level so images have correct size (is it correct?)

    # Translation

    x,y,z = ref.to_lla(x,y,z)  # Convert to GPS coordinates
    
    # Internal camera parameters

    K = cam.get_K()

    # Create affine to georeference image

    affine = np.eye(3)
    affine[:2,:2] = rot_matrix  # Insert rotation and scale
    affine[:2,2] = np.array((x,y))  # Insert translation
    
    K_inv = np.linalg.inv(K) 
    affine = affine.dot(K_inv)  # Add K to image

    ## Follows the code to insert Affine into TIF ##

Is this approximation correct? Once this is solved I would really like to help improving OpenSFM docs. Thank you in advance.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Matesanzcommented, Jun 18, 2021

Hello @pierotofy and thank you so much for the answer. (btw: I admire you so much for your work at ODM.)

I’ll check it out 😃

0reactions
pierotofycommented, Jun 10, 2021

A bit off-topic perhaps, but you could use a tool such as ddb geoproj to do this: https://docs.dronedb.app/commands/geoproj.html

(disclaimer: I wrote the tool).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cases in Medical Ethics: Student-Led Discussions
A selection of medical ethics cases designed to help determine whether medicine is the correct calling for pre-medical students.
Read more >
Project Habakkuk - Wikipedia
Project Habakkuk or Habbakuk (spelling varies) was a plan by the British during the Second World War to construct an aircraft carrier out...
Read more >
PROJECTILE MOTION - Dropping a package from an aeroplane
An explanation of the Projectile Motion concepts involved in dropping a package from a rescue plane. The plane needs to 'lead' the target...
Read more >
Frequently Asked Questions, Per Diem - GSA.gov
Can I combine the lodging and M&IE per diem rates ("mix and match") in order to get a nicer hotel room or spend...
Read more >
Sparks seen trailing behind plane during emergency landing ...
“There was some kind of problem shortly after takeoff in Calgary and as a result of a cross-wind situation, the decision was made...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found