Image restiching (changing stiching point)

Hi there.
On iPhone app, while downloading picture, software was changing stitching point to have image pointed accordingly to data up and forward (if you take picture upside down for example). Now, app is not doing it.
Do you know, how to achieve this by own? Perfect scenariu would be:
Picture taken in strange orientation -> Doing things with software -> Image is positioned correctly, so there is no need for sphere rotations etc.

I’m not using an iPhone, but is it possible that you imported the photos into some editor that stripped out the XMP data?

You can see information on XMP data in the article below.

http://theta360.guide/thetamedia/#_orientation_and_tilt

I know about xmp, i’ve been using it for sphere correction :slight_smile:. What i saw, was picture taken by camera upside down, after downloading it via iphone app, xmp correction was not required after that. I don’t own iphone so i can’t record movie ;). But it was quite nice feature. That’s why i’ve been asking if someone know algorithm for restiching using xmp data to reorient image.

There’s an example application to use the XMP data to rectify the image. It’s using povray, so it’s probably not what you’re looking for. However, it may give you an idea of how to get started on your project.

http://theta360.guide/thetamedia/#_sample_application

  #!/bin/bash
  #
  # Automatically levels Theta S spherical images
  # depends on exiftools / imagemagick and POVRay
  # Should work on most Linux installs and on
  # OSX using homebrew installs or similar

  # get the filename without the extension
  noextension=`echo $1 | sed 's/\(.*\)\..*/\1/'`

  # grab the width and height of the images
  height=`exiftool $1 | grep "^Image Height" | cut -d':' -f2 | sed 's/ //g'`
  width=`exiftool $1 | grep "^Image Width" | cut -d':' -f2 | sed 's/ //g'`

  # grab pitch roll
  roll=`exiftool $1 | grep "Roll" | cut -d':' -f2 | sed 's/ //g'`
  pitch=`exiftool $1 | grep "Pitch" | cut -d':' -f2 | sed 's/ //g'`
  pitch=$(bc <<< "$pitch * -1")

  # flip the image horizontally
  convert -flop $1 tmp.jpg

  # create povray script with correct image parameters
  cat <<EOF > tmp.pov
  // Equirectangular Panorama Render
  // bare bones script
  // camera settings
  camera {
    spherical // equirectangular projection
    up    y * 1
    right  x * image_width / image_height
    location <0,0,0>     // put camera at origin
    angle 360 180        // full image
    rotate x * 0         // Tilt up (+) or down (-)
    rotate y * -90         // Look left (+) or right (-)
    rotate z * 0         // Rotate CCW (+) or CW (-)
  }
  // create a sphere shape
  sphere {
    // center of sphere
    <0,0,0>, 1
    texture {
      pigment {
        image_map {
          jpeg "tmp.jpg"
          interpolate 2 // smooth it
          once   // don't tile image, just one copy
          map_type 1
        }
      }
      rotate x * $roll   //Tilt up (+) or down (-) or PITCH
      rotate y * 0       //shift left (+) or right (-)
      rotate z * $pitch  //Rotate CCW (+) or CW (-) or ROLL
      finish { ambient 1 }
    }
  }
  EOF

  # execute povray script and rename file
  povray +W$width +H$height -D +fj tmp.pov +O${noextension}_rectified.jpg

  # remove temporary files / clean up
  rm tmp.jpg
  rm tmp.pov

More
https://www.regentechlog.com/2014/06/26/python-thetaexif/