camera.takePicture with roll and yaw correction

The place to discuss development topics.
Discussions on the RICOH THETA API and SDK, image processing of spherical images, other hardware related topics, introduction of useful libraries, etc.

camera.takePicture with roll and yaw correction

Postby 200cm3 » 04 Apr 2017, 11:16

Hello, I write without much hope for answers, but suddenly ..

I bought a camera with the idea to bypass the entire Kislovodsk park-a few hectares, and record panoramas along the way.

But it turned out that the camera does not write gps tags of each panorama but only the first of the series, and then it will either have to manually specify the location of each picture or do not use interval shooting ... why did they do this not clearly ...

Sam is a little ios programmer and decided to write his application to record panoramas in interval mode, with gps tags. This part works, but it turned out that when shooting, panoramas are not corrected horizontally. I can get yaw and roll of each photo, but first you need to get an image from the camera into the application that will negatively affect the camera's operating time but also the most basic thing is how I then rotate the image to the desired ones. Angles and save the result?

Maybe there is an opportunity to give the camera command for shooting with correction on the horizon, judging by the forum, it's not for me alone that it's interesting.

Without much hope for answers, Vitaly.

Ideally, show a piece of code

Sorry for my English. It's even worse than google translate ;)
200cm3
 
Posts: 6
Joined: 07 Mar 2017, 12:04

Re: camera.takePicture with roll and yaw correction

Postby codetricity » 05 Apr 2017, 00:38

I'm not sure I understand your question, but I'll try and supply the little information I know. The heading, pitch and roll can be placed in XMP data inside the JPEG image.

Image

You can access this data with the open source exiftool.

The heading is supplied by the THETA internal compass. The pitch and roll are supplied by the internal THETA accelerometer.

See Photo Sphere XMP Metadata

See also Adobe Extensible Metadata Platform (XMP)

The community has also accessed the EXIF data.

Read the article above for actual examples in use. In particular this site uses the script below.


Code: Select all
#!/bin/python2

import os
import subprocess
import struct

def find_data(s, tag):
   ix = s.find(tag)
   if ix < 0:
      raise Exception('Cannot find tag')
   return ix + len(tag)

def parse_u_rational(s):
   a, b = struct.unpack('>II', s)
   return float(a) / float(b)

def parse_s_rational(s):
   a, b = struct.unpack('>ii', s)
   return float(a) / float(b)

def get_angles(path):
   f = open(path, 'rb')
   head = f.read(10 * 1000)  # take long enough header

   # Find CompassEs
   ix = find_data(head, '\x00\x04\x00\x05\x00\x00\x00\x01')  # search CompassEs,UnsignedRational,1
   offset = struct.unpack('>I', head[ix : ix + 4])[0] + 12
   compass = parse_u_rational(head[offset : offset + 8])

   # Find ZenithEs
   ix = find_data(head, '\x00\x03\x00\x0a\x00\x00\x00\x02')  # search ZenithEs,SignedRational,2
   offset = struct.unpack('>I', head[ix : ix + 4])[0] + 12
   zenith_x = parse_s_rational(head[offset : offset + 8])
   zenith_y = parse_s_rational(head[offset + 8 : offset + 16])
   
   return {
      'zenith_x': zenith_x,
      'zenith_y': zenith_y,
      'compass': compass
   }


I tested the site above with RICOH THETA images and verified that the code works.

Resized image before editing exif data
Code: Select all
Filename:   20170310215724_R0011023b.JPG
Zenith X:   668.001991272 [deg]
Zenith Y:   0.00668647845468 [deg]
Compass:   0.0 [deg]


original image

Code: Select all
Filename:   20170310202604_R0011023.JPG
Zenith X:   207.4 [deg]
Zenith Y:   10.6 [deg]
Compass:   22.5 [deg]
codetricity
 
Posts: 611
Joined: 31 Jul 2015, 01:56


Return to Development



All times are UTC


cron