ptrgags / panoramas

Scripts for reprojecting 360° panoramas to other formats (2021)
Apache License 2.0
2 stars 0 forks source link

coordinate transformation #2

Closed 514398473 closed 1 year ago

514398473 commented 3 years ago

Hello, I use the tool to convert the panorama into a cube, then divide the cube into 6 pictures, and then detect the target of 6 pictures. Each picture has target boxes in [xmin, Ymin, xmax, ymax] format. How can the coordinates of these boxes be converted into the coordinates of the panorama?

ptrgags commented 1 year ago

@514398473 Aah sorry I never replied to this... nearly 2 years ago.

If you're asking for the formula to convert coordinates of the box (in pixels) to coordinates of the panorama in pixels, the calculations would look roughly like this:

  1. Convert the pixel coordinates to world space coordinates. The 6 images are faces of the unit cube.
  2. Do the inverse gnomonic projection to map a face of the unit cube to the unit sphere. See https://github.com/ptrgags/panoramas/blob/main/geometry/cubemap.py#L26 for example.
  3. Use the equirectangular "projection" to map the unit sphere to the panorama. See https://github.com/ptrgags/panoramas/blob/main/geometry/unitsphere.py#L57 for example

Note that this is not currently supported, and I'm actually about to archive it as I haven't used it or plan to maintain this hobby project. You're still welcome to use the code or fork the repo.