OpenCV/Method to enable OpenEXR on OpenCV

#multilang(ja){{

概要

OpenCV(Windows)でOpenEXRの画像読み書きを有効にする方法を紹介する.

下記のバージョンで確認を行った.

  • Windows Vista 32bit
  • OpenCV SVN rev6330(未確認ですがOpenCV 2.3.0では動作しないと思われます)
  • Visual Studio 2010 pro

必要なファイル

OpenEXR

  1. OpenEXR公式サイトから下記のファイルをダウンロードする.
    • ilmbase-1.0.2.tar.gz
    • openexr-1.7.0.tar.gz

zlib

  1. zlib公式サイトから下記のファイルをダウンロードする.
    • zlib125.zip

サンプル画像

  1. OpenEXR公式サイトから下記のファイルをダウンロードする.
    • openexr-images-1.7.0.tar.gz

ファイル配置

前述のファイルを展開して,下記のように配置する.
DeployディレクトリはOpenEXRのDLL,ライブラリ,ヘッダがコピー,生成されるディレクトリである.


openexr.png


OpenEXRのビルド

Ilmbaseのビルド

  1. ilmbase-1.0.2.tar.gzを展開し,Visual Studioで下記のファイルを開く.
    ilmbase-1.0.2.tar\ilmbase-1.0.2\vc\vc8\IlmBase.sln
  2. 下記の設定でソリューションをビルド.ビルド完了後,Deployディレクトリが生成される.
    ソリューション構成Release
    ソリューションプラットフォームWin32

zlibのビルド

  1. zlib125.zipを展開する.
  2. Visual Studio 2010コマンドプロンプトでzlib-1.2.5\contrib\masmx86に移動して下記コマンドを実行する.
    bld_ml32.bat
  3. Visual Studioで下記のファイルを開く.
    zlib-1.2.5\contrib\vstudio\vc10\zlibvc.sln
  4. zlibvcプロジェクトを下記の構成でビルドする.
    ソリューション構成Release
    ソリューションプラットフォームWin32
  5. zlib-1.2.5\contrib\vstudio\vc10\x86\ZlibDllRelease?にDLL,ライブラリが生成される.
  6. 下記DLLをDeploy\bin\Win32\Releaseにコピー.
    zlibwapi.dll
  7. 下記ライブラリをDeploy\lib\Win32\Releaseにコピー.
    zlibwapi.lib
    zlibwapi.map
  8. zlib-1.2.5にある下記ヘッダファイルをDeploy\includeにコピー.
    zlib.h
    zconf.h

IlmImf?のビルド

  1. openexr-1.7.0.tar.gzを展開し,Visual Studioで下記のファイルを開く.
    openexr-1.7.0\vc\vc8\OpenEXR\OpenEXR.sln
  2. IlmImf?プロジェクトを下記の構成でビルドする.
    ソリューション構成Release
    ソリューションプラットフォームWin32

OpenCVのビルド

  1. CMakeでWITH_OPENEXRをONにする
  2. Deployディレクトリ中のOpenEXRのインクルードパスとライブラリを指定する
  3. OpenCV.slnのopencv_highguiプロジェクトがリンクするライブラリとして下記ファイルを追加する
    IlmThread.lib
  4. OpenCV.slnのopencv_highguiプロジェクトのプリプロセッサ定義に下記の値を追加する
    OPENEXR_DLL
  5. OpenCVを下記の構成でビルドする.
    ソリューション構成Release
    ソリューションプラットフォームWin32

サンプルプログラム

ダウンロードしておいた下記ファイル(サンプル画像)を展開する.

  • openexr-images-1.7.0.tar.gz

下記にファイル読み込みのサンプルプログラムを記載する.

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

int main(int argc, char *argv[])
{
  cv::Mat src_img = cv::imread("PrismsLenses.exr", 1);
  cv::namedWindow("src", CV_WINDOW_AUTOSIZE|CV_WINDOW_FREERATIO);
  cv::imshow("src", src_img);
  cv::waitKey(0);

  return 0;
 }

Contact

間違い・御指摘等ありましたら,

mail.png

までメールにてご連絡ください.

}}

#multilang(en){{

Abstract

This page describes the way to enable OpenEXR on OpenCV.

I checked in the following environment.

  • Windows Vista 32bit
  • OpenCV SVN rev6330(Maybe, I think that this function does not work properly on OpenCV 2.3.0)
  • Visual Studio 2010 pro

Required files

OpenEXR

  1. Please download the following files from OpenEXR Official site.
    • ilmbase-1.0.2.tar.gz
    • openexr-1.7.0.tar.gz

zlib

  1. Please download the following file from zlib Official site.
    • zlib125.zip

Sample images

  1. Please download the following files from OpenEXR Official site.
    • openexr-images-1.7.0.tar.gz

File placement

Please extract the above files and placed as follows.
The OpenEXR's files(DLLs, libraries, header files) are generated to Deploy directory..


openexr_en.png


Building of OpenEXR

Building of Ilmbase

  1. Please extract ilmbase-1.0.2.tar.gz and open the following file in Visual Studio.
    ilmbase-1.0.2.tar\ilmbase-1.0.2\vc\vc8\IlmBase.sln
  2. Please build the solution with the following settings. After the building, Deploy directory is created.
    Solution ConfigurationRelease
    Solution PlatformWin32

Building of zlib

  1. Please extract zlib125.zip.
  2. Please launch Visual Studio 2010 Command Prompt and move to zlib-1.2.5\contrib\masmx86
  3. Please run the following command.
    bld_ml32.bat
  4. Please open the following file in Visual Studio.
    zlib-1.2.5\contrib\vstudio\vc10\zlibvc.sln
  5. Please build the zlibvc project with the following settings.
    Solution ConfigurationRelease
    Solution PlatformWin32
    After the building, DLLs and liraries are generated to zlib-1.2.5\contrib\vstudio\vc10\x86\ZlibDllRelease?..
  6. Please copy the following DLL to Deploy\bin\Win32\Release.
    zlibwapi.dll
  7. Please copy the following libraries to Deploy\lib\Win32\Release.
    zlibwapi.lib
    zlibwapi.map
  8. Please copy the following header files in zlib-1.2.5 to Deploy\include.
    zlib.h
    zconf.h

Building of IlmImf?

  1. Please extract openexr-1.7.0.tar.gz and open the following file in Visual Studio.
    openexr-1.7.0\vc\vc8\OpenEXR\OpenEXR.sln
  2. Please build the IlmImf? project with the following settings.
    Solution ConfigurationRelease
    Solution PlatformWin32

Building of OpenCV

  1. Please enable WITH_OPENEXR on CMake.
  2. Please specify the include path and library for OpenEXR in the Deploy directory.
  3. Please add the following file to opencv_highgui project in OpenCV.sln as a linked library.
    IlmThread.lib
  4. Please add the following preprocessor definition to opencv_highgui project in OpenCV.sln
    OPENEXR_DLL
  5. Please build the OpenCV with the following settings.
    Solution ConfigurationRelease
    Solution PlatformWin32

Sample program

Please extract the following zip flie.

  • openexr-images-1.7.0.tar.gz

I describes a sample program to read OpenEXR image.

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

int main(int argc, char *argv[])
{
  cv::Mat src_img = cv::imread("PrismsLenses.exr", 1);
  cv::namedWindow("src", CV_WINDOW_AUTOSIZE|CV_WINDOW_FREERATIO);
  cv::imshow("src", src_img);
  cv::waitKey(0);

  return 0;
 }

Contact

If you have question,please send e-mail to the following address.

mail.png

}}


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2011-08-15 (月) 20:16:00 (4631d)