ロゴ メインコンテンツへ
RSSフィード
「ソフトウェア開発」に関連する記事一覧

OpenCV 2.2のGPU機能を64bitで使えるようにする

2011/06/11
(この記事の文字数: 2464)

OpenCV 2.2のGPU機能を64ビットで使ってみたかったので、Visual Studio 2010で64bit版のライブラリファイルをビルドしてみました。ついでにその他の機能も使えるようにしました。

こちらのブログでご丁寧にもPDFでインストール方法を紹介してくれていたので、こちらを参考にさせていただきました。

まとめ?ブログ
http://kgxpx834.blog58.fc2.com/blog-entry-23.html

私が利用したIDEと各ライブラリのバージョンです。

Visual Studio 2010 Premium

CMake 2.8.4
http://www.cmake.org/cmake/resources/software.html

OpenCV 2.2.0
http://sourceforge.net/projects/opencvlibrary/
files/opencv-win/2.2/

追記 ---------------------------------------------------
OpenCV2.2.0ではドキュメントにあるgpuの関数がすべては使えなかったので結局OpenCV SVNから2.2.9をダウンロードしてきて使いました。
https://code.ros.org/svn/opencv
----------------------------------------------------------

TBB 3.0
http://threadingbuildingblocks.org/file.php?fid=77

CUDA Toolkit 4.0.17 64bit
GPU Computing SDK code samples 4.0.17 64bit
http://developer.nvidia.com/cuda-toolkit-40

NVIDIA Performance Primitives (NPP) library 3.2.16 64bit
http://developer.nvidia.com/cuda-toolkit-32-downloads

Qt 4.7.1 64bit
http://qt.nokia.com/downloads-jp

Eigen 2.0.16
http://eigen.tuxfamily.org/index.php?
title=Main_Page#Download


しかし、64bitだからなのかわからないですが、手順通りにやってもすんなりとはうまくゆかず、うまくバイナリを生成できるまでかなり苦戦しました。

特にopencv_gpuをコンパイルするときに次のようなエラーが出て困ってしまいました。

..\..\..\modules\gpu\src\imgproc_gpu.cpp(601): error C3861: 'nppiCannyGetBufferSize': identifier not found

..\..\..\modules\gpu\src\imgproc_gpu.cpp(605): error C3861: 'nppiCanny_32f8u_C1R': identifier not found

..\..\..\modules\gpu\src\arithm.cpp(503): error C2664: 'nppiSum_8u_C1R' : cannot convert parameter 4 from 'Npp32s *' to 'Npp8u *'
          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

..\..\..\modules\gpu\src\arithm.cpp(510): error C2664: 'nppiSum_8u_C4R' : cannot convert parameter 4 from 'Npp32s *' to 'Npp8u *'
          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast


こちらのブログのコメント部分に同じ問題に遭遇した人が解決策を記していてくれていたので助かりました。

http://blog.cuvilib.com/2011/03/22/
how-to-build-opencv-2-2-with-gpu-cuda-on-windows-7/

コメントにあった解決策をそのまま抜き出してここにも書いておきます。

- Code generation -> runtime library -> Multithreaded dll
- Linker -> Input -> Ignore Specific Library = nothing
- C/C++ -> General -> Additional Include Libraries -> invert the order of the include path for CUDA and NPP (put first npp include folder and then CUDA include folder)

日本語でも一応書いておきます。

opencv_gpuプロジェクトのプロパティを開き、次の3つのプロパティを変更します。
1. Code generation -> runtime libraryをマルチスレッドDLLに変更(おそらく初めからこうなっている)
2. Linker -> Input -> Ignore Specific Libraryを全部無くす。(おそらくlibcがあるので、それを消す)
3. C/C++ -> General -> Additional Include LibrariesのNPPとCUDAのインクルードパスの順番を入れ替える

私の場合はこれで無事にコンパイルが通りました。同じエラーに遭遇してしまった方は一度試してみて下さい。


  このエントリーをはてなブックマークに追加  

<<「ソフトウェア開発」の記事一覧に戻る

<<「ソフトウェア開発」の次の記事

コメント(0 件)



コンテンツロード: 0.0089 sec
Copyright(C)2006-2024 puarts All Rights Reserved