2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MacでCubemapをEquirectangularにTerminalのコマンドで変換する

Last updated at Posted at 2017-09-20

MacでCubemapをEquirectangularに変換する方法がやや検索しずらいということで手順を示しておきます

環境

  • perl: v5.18.2
  • MacBook Pro (Retina, 15-inch, Mid 2015) macOS Sierra 10.12.6

Equirectangularとは

以下のような画像(こちらから取得しました)でパノラマ画像として使われます。Thetaなどで撮影された画像はこのようになります。

image.png

Cubemapとは

正方形の画像が6枚で一組となった以下のようなものです。Equirectangularに相互変換可能です。

image.png

CubemapからEquirectangularに変換するには

cubic2erectのperlモジュールで変換するのですが、他にもインストールしなければいけないものがあるので手順だけ示します。

Hugin(Panorama photo stitcher)のインストール

Huginにはいっているnonaというツールにcubic2ererctが依存しているので、こちらからダウンロードし、.dmgを開きインストールします。

その後、以下のようにPATHを通して、/Applications/Hugin/HuginStitchProject.app/Contents/MacOS以下のファイルを使用できるようにします。

export PATH="$PATH:/Applications/Hugin/HuginStitchProject.app/Contents/MacOS"

perl 5.18.Xのインストール

後ほど、cubic2erectをソースからコンパイルするのですが、その際にperl 5.18.Xを使ったのでそのバージョンをhomebrewでインストールします。最新だとコンパイルエラー(正確にはmake testでこけた)になったので5.18を使っています。

brew install perl@5.18

最初にcpanの設定をします。各種きかれますので全部enterボタンをおしていればいいです

cpan

次に以下のように必要なモジュールをインストールしておきます。

sudo cpan install Image::ExifTool
sudo cpan install Image/Size.pm

cubic2erectのインストール

ソースからコンパイルします。こちらのサイトのDownloadからパッケージを任意の位置にダウンロードします。

image.png

解凍してからREADMEをみてコンパイルします

perl Makefile.PL
make
make test
sudo make install

cubic2erectの実行

やっと実行できるようになったので、以下のように変換します。front, right, back, left, up, downはそれぞれcubemapの画像です。output.tifが出力ファイルです。

cubic2erect front.jpg right.jpg back.jpg left.jpg up.jpg down.jpg output.tif 

tif画像だと面倒なのでjpgに変換しておきます。

convert output.tif output.jpg

おまけ

ソースを覗いてみます。

  • cubic2erect: nonaをwrapしているだけ
  • nona: 画像の座標などを変換するもの。ndevenish/Huginに説明がある

参考

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?