*OpenCV/Patch to support WebP format on OpenCV 2.4.2 [#za343d9a] #multilang(ja){{ **概要 OpenCV 2.4.2でWebP形式のフォーマットを扱えるようにするパッチです.&br; ※OpenCV 2.4.2を対象としたパッチです. **ダウンロード |Version|Filename|Size|Date|Type|Download| |BGCOLOR(white):1.0|BGCOLOR(white):opencv2.4.2_webp_enable_patch_20120809.zip|BGCOLOR(white):31.6 KB|BGCOLOR(white):20120809|BGCOLOR(white):zip|BGCOLOR(white):[[http://www.atinfinity.info/img/download.gif:http://www.atinfinity.info/opencv/extension/opencv2.4.2_webp_enable_patch_20120809.zip]]| **変更履歴 |Version|Date|変更内容| |BGCOLOR(white):1.0|BGCOLOR(white):20120809|BGCOLOR(white):新規作成| **使い方 ***WebPライブラリのビルド +[[こちら:https://code.google.com/p/webp/downloads/detail?name=libwebp-0.2.0.tar.gz]]からWebPのソースをダウンロードする.※今回はlibwebp-0.2.0.tar.gzを用いた. +libwebp-0.2.0.tar.gzを展開する. +Visual Studio コマンド プロンプトを起動する. +コマンド プロンプトでlibwebp-0.2.0のディレクトリに移動する. +下記のコマンドを実行する(release用ライブラリが生成される). nmake /f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output ※Linux,Macの場合は以下のコマンドを実行する. make -f makefile.unix ***OpenCV WebPパッチの適用 +上記リンクからopencv2.4.2_webp_enable_patch_20120809.zipをダウンロードして展開します. +展開したディレクトリをOpenCVディレクトリに上書きします. ※Linux,Macに適用する場合には,パッチ(下記ファイル)の改行コードをあらかじめnkfコマンド等でLFに変換して下さい. -opencv2.4.2_webp_enable_patch_20111204\CMakeLists.txt -opencv2.4.2_webp_enable_patch_20111204\cmake\OpenCVFindLibsGrfmt.cmake -opencv2.4.2_webp_enable_patch_20111204\cmake\OpenCVFindWebP.cmake -opencv2.4.2_webp_enable_patch_20111204\modules\highgui\CMakeLists.txt -opencv2.4.2_webp_enable_patch_20111204\modules\highgui\include\opencv2\highgui\highgui.hpp -opencv2.4.2_webp_enable_patch_20111204\modules\highgui\include\opencv2\highgui\highgui_c.h -opencv2.4.2_webp_enable_patch_20111204\modules\highgui\src\grfmt_webp.cpp -opencv2.4.2_webp_enable_patch_20111204\modules\highgui\src\grfmt_webp.hpp -opencv2.4.2_webp_enable_patch_20111204\modules\highgui\src\grfmts.hpp -opencv2.4.2_webp_enable_patch_20111204\modules\highgui\src\loadsave.cpp -opencv2.4.2_webp_enable_patch_20120809\CMakeLists.txt -opencv2.4.2_webp_enable_patch_20120809\cmake\OpenCVFindLibsGrfmt.cmake -opencv2.4.2_webp_enable_patch_20120809\cmake\OpenCVFindWebP.cmake -opencv2.4.2_webp_enable_patch_20120809\modules\highgui\CMakeLists.txt -opencv2.4.2_webp_enable_patch_20120809\modules\highgui\include\opencv2\highgui\highgui.hpp -opencv2.4.2_webp_enable_patch_20120809\modules\highgui\include\opencv2\highgui\highgui_c.h -opencv2.4.2_webp_enable_patch_20120809\modules\highgui\src\grfmt_webp.cpp -opencv2.4.2_webp_enable_patch_20120809\modules\highgui\src\grfmt_webp.hpp -opencv2.4.2_webp_enable_patch_20120809\modules\highgui\src\grfmts.hpp -opencv2.4.2_webp_enable_patch_20120809\modules\highgui\src\loadsave.cpp ***OpenCVのビルド [#f02dfa0a] OpenCVをCMakeを用いてビルドする. +WITH_WEBPにチェックを入れて,「Configure」ボタンを押す. &br;&ref(http://atinfinity.info/img/opencv/cmake_with_webp_0001.png);&br;&br;&br; +WEBP_INCLUDE_DIRSにWebPのソースがあるディレクトリを指定して,「Generate」ボタンを押す. &br;&ref(http://atinfinity.info/img/opencv/cmake_with_webp_0002.png);&br;&br;&br; **おまけ(1) 下記のような設定をすることでデコード時のquality(0~100)を指定できる.&br; ※以下の例では最大品質の100を指定. ***C API int param[2]; param[0] = CV_IMWRITE_WEBP_QUALITY; param[1] = 100; cvSaveImage("img.webp", img, ¶m[0]); ***C++ API vector<int> param = vector<int>(2); param[0] = CV_IMWRITE_WEBP_QUALITY; param[1] = 100; imwrite("img.webp", img, param); **おまけ(2) 下記のような設定をすることでlossless圧縮を指定できる. ***C API int param[2]; param[0] = CV_IMWRITE_WEBP_LOSSLESS; param[1] = 1; cvSaveImage("img.webp", img, ¶m[0]); ***C++ API vector<int> param = vector<int>(2); param[0] = CV_IMWRITE_WEBP_LOSSLESS; param[1] = 1; imwrite("img.webp", img, param); **制限事項 -Windows 32bit/Mac 64bitのみで動作検証. -保存対象画像となるdepthは8Uのみ. **注意点 -CV_IMWRITE_WEBP_QUALITYによる指定が無い場合,デフォルトで95が指定される. }} #multilang(en){{ **Abstract This page describes the method to use WebP format on OpenCV 2.4.2.&br; **Download |Version|Filename|Size|Date|Type|Download| |BGCOLOR(white):1.0|BGCOLOR(white):opencv2.4.2_webp_enable_patch_20120809.zip|BGCOLOR(white):31.6 KB|BGCOLOR(white):20120809|BGCOLOR(white):zip|BGCOLOR(white):[[http://www.atinfinity.info/img/download.gif:http://www.atinfinity.info/opencv/extension/opencv2.4.2_webp_enable_patch_20120809.zip]]| **ChangeLog |Version|Date|Changes| |BGCOLOR(white):1.0|BGCOLOR(white):20120809|BGCOLOR(white):First Release| **Usage ***Build WebP library +Please download ''WebP source code'' from [[Official page:https://code.google.com/p/webp/downloads/detail?name=libwebp-0.2.0.tar.gz]]. I used libwebp-0.2.0.tar.gz for testing. +Please extract libwebp-0.2.0.tar.gz. +Please start Visual Studio command prompt. +Please move to ''libwebp-0.2.0'' directory. +Please run the following command to make WebP library(release build). nmake /f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output If you use on Linux or Max, please run the following command to make WebP library make -f makefile.unix ***Applying WebP patch +Please download opencv2.4.2_webp_enable_patch_20120809.zip. And,extract this file. +Please overwrite to OpenCV's directory. &br;If you want to apply this patch to OpenCV-2.4.2(Linux or Mac), please convert newline character of these file to LF from CRLF. -opencv2.4.2_webp_enable_patch_20111204\CMakeLists.txt -opencv2.4.2_webp_enable_patch_20111204\cmake\OpenCVFindLibsGrfmt.cmake -opencv2.4.2_webp_enable_patch_20111204\cmake\OpenCVFindWebP.cmake -opencv2.4.2_webp_enable_patch_20111204\modules\highgui\CMakeLists.txt -opencv2.4.2_webp_enable_patch_20111204\modules\highgui\include\opencv2\highgui\highgui.hpp -opencv2.4.2_webp_enable_patch_20111204\modules\highgui\include\opencv2\highgui\highgui_c.h -opencv2.4.2_webp_enable_patch_20111204\modules\highgui\src\grfmt_webp.cpp -opencv2.4.2_webp_enable_patch_20111204\modules\highgui\src\grfmt_webp.hpp -opencv2.4.2_webp_enable_patch_20111204\modules\highgui\src\grfmts.hpp -opencv2.4.2_webp_enable_patch_20111204\modules\highgui\src\loadsave.cpp -opencv2.4.2_webp_enable_patch_20120809\CMakeLists.txt -opencv2.4.2_webp_enable_patch_20120809\cmake\OpenCVFindLibsGrfmt.cmake -opencv2.4.2_webp_enable_patch_20120809\cmake\OpenCVFindWebP.cmake -opencv2.4.2_webp_enable_patch_20120809\modules\highgui\CMakeLists.txt -opencv2.4.2_webp_enable_patch_20120809\modules\highgui\include\opencv2\highgui\highgui.hpp -opencv2.4.2_webp_enable_patch_20120809\modules\highgui\include\opencv2\highgui\highgui_c.h -opencv2.4.2_webp_enable_patch_20120809\modules\highgui\src\grfmt_webp.cpp -opencv2.4.2_webp_enable_patch_20120809\modules\highgui\src\grfmt_webp.hpp -opencv2.4.2_webp_enable_patch_20120809\modules\highgui\src\grfmts.hpp -opencv2.4.2_webp_enable_patch_20120809\modules\highgui\src\loadsave.cpp ***Build OpenCV Please build OpenCV using CMake. +Please check ''WITH_WEBP'' and push ''Configure'' button. &br;&ref(http://atinfinity.info/img/opencv/cmake_with_webp_0001.png);&br;&br;&br; +Please specify WebP source's directory to ''WEBP_INCLUDE_DIRS'' and push ''Generate'' button. &br;&ref(http://atinfinity.info/img/opencv/cmake_with_webp_0002.png);&br;&br;&br; **Tips(1) You can specify the compression quality(min:0, max:100) by the following settings. ***C API int param[2]; param[0] = CV_IMWRITE_WEBP_QUALITY; param[1] = 100; cvSaveImage("img.webp", img, ¶m[0]); ***C++ API vector<int> param = vector<int>(2); param[0] = CV_IMWRITE_WEBP_QUALITY; param[1] = 100; imwrite("img.webp", img, param); **Tips(2) You can specify the lossless compression by the following settings. ***C API int param[2]; param[0] = CV_IMWRITE_WEBP_LOSSLESS; param[1] = 1; cvSaveImage("img.webp", img, ¶m[0]); ***C++ API vector<int> param = vector<int>(2); param[0] = CV_IMWRITE_WEBP_LOSSLESS; param[1] = 1; imwrite("img.webp", img, param); **Limitation -I have only tested this environment. --Windows 32bit and Mac 64bit -Save image depth supports 8U only. **Notes -If you does not specify the quality by CV_IMWRITE_WEBP_QUALITY, 95 is specified by default. }}