*OpenCV/Patch to support WebP format on OpenCV 2.3.1 [#hbc1c807]
#multilang(ja){{
**概要 [#j276217c]
OpenCV 2.3.1でWebP形式のフォーマットを扱えるようにするパッチです.&br;
※OpenCV 2.3.1を対象としたパッチです.
**ダウンロード [#q861d79e]
|Version|Filename|Size|Date|Type|Download|
|BGCOLOR(white):1.0|BGCOLOR(white):opencv2.3.1_webp_enable_patch_20111204.zip|BGCOLOR(white):15.7 KB|BGCOLOR(white):20111204|BGCOLOR(white):zip|BGCOLOR(white):[[http://www.atinfinity.info/img/download.gif:http://www.atinfinity.info/opencv/extension/opencv2.3.1_webp_enable_patch_20111204.zip]]|

**変更履歴 [#x7461d35]
|Version|Date|変更内容|
|BGCOLOR(white):1.0|BGCOLOR(white):20111204|BGCOLOR(white):新規作成|

**使い方 [#n51b2068]
***OpenCV WebPパッチの適用 [#o43a62c2]
+上記リンクからopencv2.3.1_webp_enable_patch_20111204.zipをダウンロードして展開します.
+展開したmodulesディレクトリをOpenCVのmodulesディレクトリに上書きします.

&br;Linux,Macに適用する場合には,パッチ(下記ファイル)の改行コードをあらかじめnkfコマンド等でLFに変換して下さい.
-opencv2.3.1_webp_enable_patch_20111204\modules\highgui\include\opencv2\highgui\highgui_c.h
-opencv2.3.1_webp_enable_patch_20111204\modules\highgui\src\grfmt_webp.cpp
-opencv2.3.1_webp_enable_patch_20111204\modules\highgui\src\grfmt_webp.hpp
-opencv2.3.1_webp_enable_patch_20111204\modules\highgui\src\grfmts.hpp
-opencv2.3.1_webp_enable_patch_20111204\modules\highgui\src\loadsave.cpp

***WebPライブラリのビルド [#t5f9380e]
+[[こちら:http://git.chromium.org/gitweb/?p=webm/libwebp.git;a=summary]]からWebPのソースをダウンロードします.
※検証にはアルファチャンネル付画像のエンコード,デコードが可能となった[[こちら:http://git.chromium.org/gitweb/?p=webm/libwebp.git;a=commit;h=721f3f48e71867ba1c088f0595283962d05d197a]]を使用しました.
+libwebp-721f3f4.tar.gzを展開します.
+Visual Studio コマンド プロンプトを起動する.
+コマンド プロンプトでlibwebp-721f3f4のディレクトリに移動する.
+下記のコマンドを実行する(release用ライブラリが生成される).
 nmake /f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output
+同様に下記のコマンドを実行する(debug用ライブラリが生成される).
 nmake /f Makefile.vc CFG=debug-static RTLIBCFG=static OBJDIR=output
+libwebp-d71fbdc\output\release-static\x86\libにある''libwebp_a.lib''をOpenCVの下記ディレクトリにコピーします.
 3rdparty\lib
+libwebp-d71fbdc\output\debug-static\x86\libにある''libwebp_a_debug.lib''をOpenCVの下記ディレクトリにコピーします.
 3rdparty\lib
+libwebp-d71fbdc.tar\libwebp-d71fbdc\srcにあるwebpディレクトリをOpenCVの下記ディレクトリにコピーします.
 3rdparty\include
***OpenCVのビルド [#f02dfa0a]
+OpenCVをCMakeを用いてビルドします.

**実行例
&br;&ref(http://atinfinity.info/img/opencv/WebPViewer_00.png);&br;

**おまけ [#sf29ec4d]
下記のような設定をすることでデコード時のquality(0~100)を指定できます.&br;
※以下の例では最大品質の100を指定.
***C API [#oad05acc]
 int param[2];
 param[0] = CV_IMWRITE_WEBP_QUALITY;
 param[1] = 100;
 cvSaveImage("img.webp", img, &param[0]);

***C++ API [#o012d46b]
 vector<int> param = vector<int>(2);
 param[0]=CV_IMWRITE_WEBP_QUALITY;
 param[1]=100;
 imwrite("img.webp", img, param);
**制限事項 [#j0d18270]
-Windows 32bitのみで動作検証.
-保存対象画像となるdepthは8Uのみです
**注意点
-CV_IMWRITE_WEBP_QUALITYによる指定が無い場合,デフォルトで95が指定されます.

**参考情報
WebPConfigのpreset別パラメータ(個人用メモ).&br;
※[[こちら:http://git.chromium.org/gitweb/?p=webm/libwebp.git;a=commit;h=721f3f48e71867ba1c088f0595283962d05d197a]]のソース上の値のため,今後変更される可能性があります.
||WebPConfigInit|WEBP_PRESET_DEFAULT|WEBP_PRESET_PHOTO|WEBP_PRESET_PICTURE|WEBP_PRESET_DRAWING|WEBP_PRESET_ICON|WEBP_PRESET_TEXT|
|quality|BGCOLOR(white):75|BGCOLOR(white):X|BGCOLOR(white):X|BGCOLOR(white):X|BGCOLOR(white):X|BGCOLOR(white):X|BGCOLOR(white):X|
|target_size|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|
|target_PSNR|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|
|method|BGCOLOR(white):4|BGCOLOR(white):4|BGCOLOR(white):4|BGCOLOR(white):4|BGCOLOR(white):4|BGCOLOR(white):4|BGCOLOR(white):4|
|segments|BGCOLOR(white):4|BGCOLOR(white):4|BGCOLOR(white):4|BGCOLOR(white):4|BGCOLOR(white):4|BGCOLOR(white):4|BGCOLOR(white):2|
|sns_strength|BGCOLOR(white):50|BGCOLOR(white):50|BGCOLOR(white):80|BGCOLOR(white):80|BGCOLOR(white):25|BGCOLOR(white):0|BGCOLOR(white):0|
|filter_strength|BGCOLOR(white):20|BGCOLOR(white):20|BGCOLOR(white):30|BGCOLOR(white):35|BGCOLOR(white):10|BGCOLOR(white):0|BGCOLOR(white):0|
|filter_sharpness|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):3|BGCOLOR(white):4|BGCOLOR(white):6|BGCOLOR(white):0|BGCOLOR(white):0|
|filter_type|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|
|autofilter|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|
|pass|BGCOLOR(white):1|BGCOLOR(white):1|BGCOLOR(white):1|BGCOLOR(white):1|BGCOLOR(white):1|BGCOLOR(white):1|BGCOLOR(white):1|
|show_compressed|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|
|preprocessing|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|
|partitions|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|
|partition_limit|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|BGCOLOR(white):0|
|alpha_compression|BGCOLOR(white):1|BGCOLOR(white):1|BGCOLOR(white):1|BGCOLOR(white):1|BGCOLOR(white):1|BGCOLOR(white):1|BGCOLOR(white):1|
|alpha_quality|BGCOLOR(white):100|BGCOLOR(white):100|BGCOLOR(white):100|BGCOLOR(white):100|BGCOLOR(white):100|BGCOLOR(white):100|BGCOLOR(white):100|

※Xは初期化の際に指定したqualityの値が入ります.
}}
#multilang(en){{
**Abstract
This page describes the method to use WebP format on OpenCV 2.3.1.&br;
**Download
|Version|Filename|Size|Date|Type|Download|
|BGCOLOR(white):1.0|BGCOLOR(white):opencv2.3.1_webp_enable_patch_20111204.zip|BGCOLOR(white):15.7 KB|BGCOLOR(white):20111204|BGCOLOR(white):zip|BGCOLOR(white):[[http://www.atinfinity.info/img/download.gif:http://www.atinfinity.info/opencv/extension/opencv2.3.1_webp_enable_patch_20111204.zip]]|

**ChangeLog
|Version|Date|Changes|
|BGCOLOR(white):1.0|BGCOLOR(white):20111204|BGCOLOR(white):First Release|

**Usage
***Applying WebP patch
+Please download opencv2.3.1_webp_enable_patch_20111204.zip. And,extract this file.
+Please overwrite the patch's modules directory to OpenCV/modules.

&br;If you want to apply this patch to OpenCV-2.3.1(Linux or Mac), please convert newline character of these file to LF from CRLF.
-opencv2.3.1_webp_enable_patch_20111204\modules\highgui\include\opencv2\highgui\highgui_c.h
-opencv2.3.1_webp_enable_patch_20111204\modules\highgui\src\grfmt_webp.cpp
-opencv2.3.1_webp_enable_patch_20111204\modules\highgui\src\grfmt_webp.hpp
-opencv2.3.1_webp_enable_patch_20111204\modules\highgui\src\grfmts.hpp
-opencv2.3.1_webp_enable_patch_20111204\modules\highgui\src\loadsave.cpp

***Build WebP library
+Please download ''WebP source code'' from [[Official Git page:http://git.chromium.org/gitweb/?p=webm/libwebp.git;a=summary]]. I used [[this version's code:http://git.chromium.org/gitweb/?p=webm/libwebp.git;a=commit;h=721f3f48e71867ba1c088f0595283962d05d197a]] for testing.
+Please extract libwebp-721f3f4.tar.gz.
+Please start Visual Studio command prompt.
+Please move to ''libwebp-721f3f4'' directory.
+Please run the following command to make WebP library(release build).
 nmake /f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output
+Please run the following command to make WebP library(debug build).
 nmake /f Makefile.vc CFG=debug-static RTLIBCFG=static OBJDIR=output
+Please copy ''libwebp_a.lib'' to the following directory from libwebp-d71fbdc\output\release-static\x86\lib.
 3rdparty\lib
+Please copy ''libwebp_a_debug.lib'' to the following directory from libwebp-d71fbdc\output\debug-static\x86\lib
 3rdparty\lib.
+Please copy ''webp directory'' to the following directory from libwebp-d71fbdc.tar\libwebp-d71fbdc\src.
 3rdparty\include
***Build OpenCV
+Please build OpenCV using CMake
**The result of Execution
&br;&ref(http://atinfinity.info/img/opencv/WebPViewer_00.png);&br;
**Tips
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, &param[0]);

***C++ API
 vector<int> param = vector<int>(2);
 param[0]=CV_IMWRITE_WEBP_QUALITY;
 param[1]=100;
 imwrite("img.webp", img, param);

**Limitation
-I have only tested this environment.
--Windows 32bit
-Save image depth supports 8U only.

**Notes
-If you does not specify the quality by CV_IMWRITE_WEBP_QUALITY, 95 is specified by default.
}}

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS