waifu2x (waifu2x-converter-glsl) を Mac でコンパイル

waifu2x-converter-glsl を Macコンパイル出来たのでやり方を書いておきます。

環境

  • OS X Yosemite 10.10.3

コンパイルする為には Xcode が必要です。あらかじめ AppStore からダウンロードしておいて下さい。またコンパイルには GLFW3 と OpenCV 3.0 が必要ですから、別途インストールします。例えば homebrew があれば以下の様にインストールが可能です。

% brew install homebrew/versions/glfw3
% brew install homebrew/science/opencv3

次に waifu2x-converter-glsl の最新版をダウンロードしましょう。ここではデスクトップにダウンロードするとします。

% cd ~/Desktop
% git clone https://github.com/ueshita/waifu2x-converter-glsl.git

フォルダ waifu2x-converter-glsl/build/ へ移動し、次のコマンドを実行しコンパイルします。

% cd waifu2x-converter-glsl/build/
% xcodebuild -project waifu2x-converter-glsl.xcodeproj -target waifu2x-converter-glsl -configuration Release build "HEADER_SEARCH_PATHS =  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include /usr/local/include ../include /usr/local/Cellar/opencv3/3.0.0/include" "LIBRARY_SEARCH_PATHS = /usr/local/lib /usr/local/Cellar/opencv3/3.0.0/lib"

/usr/local/Cellar/opencv3/3.0.0/include と /usr/local/Cellar/opencv3/3.0.0/lib は、導入の仕方によって変更する必要があります。ここでは homebrew を使っていて、かつ OpenCV 3.0.0 がインストールされたとしています。

これでコンパイルが完了し、waifu2x-converter-glsl/build/build/Release/ 内に waifu2x-converter-glsl が出来ているはずです。これを waifu2x-converter-glsl フォルダに移動しましょう。これで waifu2x-converter-glsl が使えるようになりました。例えば以下の様に実行できます。

% ./waifu2x-converter-glsl -i ファイル名 --noise_level 1 --scale_ratio 1.5

waifu2x-converter-glsl は使用する際に、カレントディレクトリに models/ と shaders/ が無いといけないみたいなので、これらは消さないように。