ail-and-colleagues / add_descriptions_to_theta360

equirectangular image and cubed image conversion scripts for adding descriptions to an image.

Home Page:https://ail-and-colleagues.github.io/add_descriptions_to_theta360.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

add_descriptions_to_theta360

RICHO Thetaなどで撮影した全天球画像に説明を追加する、という目的で作成したスクリプトです。

convert_e2c.py

: 全天球画像(equirectangular image)をサイコロ状に展開した画像(cubed image)に展開します。

usage: convert.py [-h] -e EQ_IMAGE [-d DIM_CUBE] [-c CB_IMAGE]

convert an equirectangular image to a cube image.

optional arguments:
  -h, --help            show this help message and exit
  -e EQ_IMAGE, --eq_image EQ_IMAGE
                        captured equirectangular image
  -d DIM_CUBE, --dim_cube DIM_CUBE
                        a dimension of a cube
  -c CB_IMAGE, --cb_image CB_IMAGE
                        a name of output cube image

-eで全天球画像、-dでサイコロ状にした際の一辺のサイズ(ピクセル)、-cで出力するサイコロ画像の名称を指定します。

具体の変換についてはhttps://github.com/sunset1995/py360convert をお借りしています。

image

convet_c2e.py

: サイコロ状に展開した画像(cubed image)を全天球画像(equirectangular image)に変換します。

usage: convert.py [-h] -e EQ_IMAGE -c CB_IMAGE [-o OUT_IMAGE]

convert an equirectangular image to a cube image.

optional arguments:
  -h, --help            show this help message and exit      
  -e EQ_IMAGE, --eq_image EQ_IMAGE
                        captured equirectangular image
  -c CB_IMAGE, --cb_image CB_IMAGE
                        a name of output cube image
  -o OUT_IMAGE, --out_image OUT_IMAGE
                        a name of output equirectangular image

-eで全天球画像、-cでサイコロ画像、-oで出力する全天球画像の名称を指定します。変換については上と同じくhttps://github.com/sunset1995/py360convert をお借りしています。

Google Photoなどに全天球画像をアップロードすると自動的に球状にマップされGoogle Street Viewのように操作可能な状態になりますが、これは画像(jpeg)内に埋め込まれるPhoto Sphere XMPというセグメント(スクリプト内ではphoto_sphere_app_segとしています)の働きのようです。カメラ情報や撮影位置を記録するExifと似たような感じでしょうか。このセグメントは画像処理ソフトウェアで編集すると失われるようですので、このスクリプトでは元の全天球画像からこのセグメントを複製し、出力ファイルに埋め込んでいます(ついでにExifも同様に複製・埋込を行っています)。

出力された画像をGoogle Photoにアップロードすると若干歪みがあるものの、それらしく説明が追加できているのが確認できると思います。全天球画像のままこの手の説明を加えてもよいのですが、キューブ化したほうが直線がちゃんと直線になる(ただしキューブのエッジでは折れる)ので便利でした。

#Google Photoにアップロードしながら試行していたのですが、失敗画像(セグメントの埋め込みに失敗したもの)もしばらくしたら「パノラマを作成した」とのことで全天球画像として認識されていました笑。確認していませんがもしかしたらそれらしい画像には自動的にセグメントを埋め込んでくれるのかもしれません。

image

links

https://github.com/sunset1995/py360convert

下記のサイトですともう少し凝った全天球のセグメントを埋め込む方法が紹介されています。 https://qiita.com/mana_544/items/3245ce87f0a0fca80c2a

https://hp.vector.co.jp/authors/VA032610/JPEGFormat/StructureOfJPEG.htm

About

equirectangular image and cubed image conversion scripts for adding descriptions to an image.

https://ail-and-colleagues.github.io/add_descriptions_to_theta360.html

License:MIT License


Languages

Language:Python 100.0%