Converting images to PhotoSpheres from Linux

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.

Converting images to PhotoSpheres from Linux

Postby mbirth » 03 May 2015, 01:39

I'm currently experimenting with converting images from the original format (the files you download from your Theta camera) to the PhotoSphere-format (the files you get when exporting with XMP meta data). The most important step is to correct the horizon, e.g. roll/pitch values. For this, I found the "nano" tool of the "hugin" suite very usable.

First, find out the values for roll/pitch with ImageMagick:

Code: Select all
identify -verbose source.jpg

Find these lines:

Code: Select all
    GPano:PosePitchDegrees: 5.0
    GPano:PoseRollDegrees: -92.0

Now create this control file, name it source.pto:

Code: Select all
i w3584 h1792 f4 v360 r-92 p5 y0 n"source.jpg"
p w3584 h1792 f2 v360 r0 p0 y0 n"JPEG q99"

Note the r-92 and p5 in the i(nput) line which are roll and pitch values.
The p-line is the desired output format - with roll and pitch corrected to 0 degrees.

Finally run this:

Code: Select all
nona -o output.jpg source.pto

This will generate a file output.jpg with the corrected horizon and 99% quality - like the original.

The only thing left is correcting the meta data. We just need to copy the original data and set PosePitchDegrees and PoseRollDegrees to 0. You can do this with "exiv2".

Code: Select all
exiv2 ex source.jpg
mv source.exv output.exv
exiv2 in -M "reg GPano" -M "set Xmp.GPano.PosePitchDegrees 0" -M "set Xmp.GPano.PoseRollDegrees 0" "output.jpg"

This exports the meta data from source.jpg into a file "source.exv". This is renamed to "output.exv". Finally, the meta data is imported and the values are set on-the-fly. Done.

EDIT: I made a shell script.
Posts: 122
Joined: 30 Apr 2015, 13:53

Re: Converting images to PhotoSpheres from Linux

Postby caiman » 07 May 2015, 13:32

oh cool !

But y is PoseHeadingDegrees ?
Posts: 2
Joined: 06 May 2015, 08:38

Re: Converting images to PhotoSpheres from Linux

Postby mbirth » 08 May 2015, 10:52

caiman wrote:But y is PoseHeadingDegrees ?

Yes, "yaw". But since we're telling him that the input yaw and output yaw are exactly the same, it doesn't change anything on that axis. After copying the meta data, the PoseHeadingDegrees value is unchanged.
Posts: 122
Joined: 30 Apr 2015, 13:53

Return to Development

All times are UTC