FancyAM
FancyAM

Reputation: 11

Mapping Degrees to (x,y) pixels on a 360 Image

I am looking to plot out points on a 2d spherical image from a GoPro Max given an Altitude° and an Azimuth°.

Here's what you can assume:

  1. The center of the image is always facing south
  2. the image is always level looking straight at the equator.

Here's what I know:

  1. The image size is 5760x2880 which means the equator is at 1440px vertically.
  2. I have found an image online and labeled it with the Azimuth° going left to right and the Altitude° going up and down. You can find that image here

I hope that this will give you a better idea of what I'm trying to do here.

Put simply, I'm imagining a method something like:

ConvertCoords(Azimuth°, Altitude°){
     ...
     return (x,y)
}

Is this possible? I will probably implement this using Python but I'm open to suggestions. Any sort of information to point me in the right direction is greatly appreciated!

Edit: I should mention that from my research I believe the GoPro Max uses an equirectangular projection. I was able to overlay that image I attached on one of the 360 photos and plot out some data manually which seemed to come out correct.

Upvotes: 1

Views: 1275

Answers (1)

Tim Roberts
Tim Roberts

Reputation: 54698

With an equirectangular projection, the mapping is direct and linear.

def convertCoords( azimuth, altitude ):
    # Assumptions:
    # - Both values are in radians
    # - South is an azimuth of 0, negative to the left, range -pi to +pi
    # - Altitude range is -pi/2 to +pi/2, negative down
    x = 2880 + (azimuth * 2880 / math.pi)
    y = 1440 - (altitude * 2880 / math.pi)
    return x,y

If you'd rather use degrees, change "math.pi" to "180".

Upvotes: 1

Related Questions