Install TBB + CUDA with OpenCV, ( How to setup TBB, CUDA on the OpenCV, VS 2011, window)

I introduced CUDA + OpenCV on this page -> http://feelmare.blogspot.kr/2013/12/gpicuda-opencv-setting-method-and.html

In this post, I will introduce TBB + CUDA + OpenCV install(setup) method.
TBB is abbreviation of Intel Threading Builidng Block.
This supports speed up method using parallel processing of CPU.

TBB is free and you can download on this site - > https://www.threadingbuildingblocks.org/download
Downloaded TBB file don't need setup. Just unzip the file in the appropreate directory.
There is Bin, Lib and include folder in the unzeipped directory. You can be programming directly using these files.


But if you want to use the TBB supported function of OpenCV, you have to make new OpenCV libs, dlls on your computer.
It is same procees with CUDA + OpenCV -> http://feelmare.blogspot.kr/2013/12/gpicuda-opencv-setting-method-and.html.

1. run cmake.
 
"C:/opencv_247/source" is the location of OpenCV folder.
"C:/opencv_247/source/OpenCV_CUDA_Tbb_247" is target folder to make source codes.
Make target folder at any where freely.
 
2. configuration click and select your compiler.
3. Check option


 
4. click configuration and select the location of TBB's include folder.

 
 
5. click configuration
 
You will see this red line, but the direction infomation will probably correct.
so click configuration again.
 
 
Do you see yes sign in the "Use TBB : " list?
Check~!!
 
This is my last option check list.


 
This list included cuda and TBB options.
Now, click gnerate. and you can see files made newly in the target folder.
Open OpenCV.sln file by your Visual Studio Tool.
 
And complie ~!! praying..
 
After compile realese and debug mode.
Gathering the bin and lib file in the properly folder.
 
 
 
 

 
 
----------------------------------------------------------------------------------------------
#Tip 1 : If you fail to compile opencv_source code, try rebuild again.
              In my case, I have successed by twice compile( build -> rebuild )
----------------------------------------------------------------------------------------------
 
To use TBB, You should set tbb include, lib path on your visual studio.

 
 
And copy tbb dll files in to the Windows->systems folder.
 

 
 
This is example source code using TBB
 
////
#include <  stdio.h >  
#include <  vector >
#include <  opencv2\opencv.hpp > 
#include <  opencv2\stitching\stitcher.hpp >

#ifdef _DEBUG  
#pragma comment(lib, "opencv_core247d.lib")   
#pragma comment(lib, "opencv_imgproc247d.lib")   //MAT processing  
//#pragma comment(lib, "opencv_objdetect246d.lib")   
//#pragma comment(lib, "opencv_gpu247d.lib")  
//#pragma comment(lib, "opencv_features2d246d.lib")  
#pragma comment(lib, "opencv_highgui247d.lib")  
//#pragma comment(lib, "opencv_ml246d.lib")
#pragma comment(lib, "opencv_stitching247d.lib")
#pragma comment(lib, "tbb_debug.lib")

#else  
#pragma comment(lib, "opencv_core247.lib")  
#pragma comment(lib, "opencv_imgproc247.lib")  
//#pragma comment(lib, "opencv_objdetect246.lib")  
//#pragma comment(lib, "opencv_gpu247.lib")  
//#pragma comment(lib, "opencv_features2d246.lib")  
#pragma comment(lib, "opencv_highgui247.lib")  
//#pragma comment(lib, "opencv_ml246.lib") 
#pragma comment(lib, "opencv_stitching247.lib")
#pragma comment(lib, "tbb.lib")
#endif  


using namespace cv;  
using namespace std;


void main()  
{
 
 vector<  Mat > vImg; 
 vector<  vector<  Rect > > vvRect;
 Mat rImg;

 vImg.push_back( imread("./stitching_img/m1.jpg") );
 //vImg.push_back( imread("./stitching_img/m8.jpg") );
 //vImg.push_back( imread("./stitching_img/m5.jpg") );
 vImg.push_back( imread("./stitching_img/m4.jpg") );
 vImg.push_back( imread("./stitching_img/m2.jpg") );
 //vImg.push_back( imread("./stitching_img/m7.jpg") );
 //vImg.push_back( imread("./stitching_img/m6.jpg") );
 vImg.push_back( imread("./stitching_img/m3.jpg") );
 //vImg.push_back( imread("./stitching_img/m9.jpg") );
 //vImg.push_back( imread("./stitching_img/m10.jpg") );
 //vImg.push_back( imread("./stitching_img/m11.jpg") );
 //vImg.push_back( imread("./stitching_img/m12.jpg") );
 //vImg.push_back( imread("./stitching_img/m13.jpg") );
  
  
 
 
 int c = gpu::getCudaEnabledDeviceCount();
 printf("%d\n", c);
    

 Stitcher stitcher = Stitcher::createDefault(1);


 unsigned long AAtime=0, BBtime=0;
 AAtime = getTickCount();

 //stitcher.stitch(vImg, vvRect, rImg);
 stitcher.stitch(vImg, rImg);

 BBtime = getTickCount(); 
 printf("%.2lf sec \n",  (BBtime - AAtime)/getTickFrequency() );

 imshow("Stitching Result", rImg);
 
 waitKey(0); 

}  
////

----------------------------------
#Tip 2 : If you don't know setting method Opencv + Visual Studio, reference this page http://feelmare.blogspot.kr/2013/08/visual-studio-2012-opencv-246-setting.html
#Tip 3 : If you want to GPU + Opencv, reference this page
 http://feelmare.blogspot.kr/2013/12/gpicuda-opencv-setting-method-and.html.
#Tip 4: You want to know my TBB run successfully or not, reference this page
http://feelmare.blogspot.kr/2013/12/tbb-example-source-code-parallelinvoke.html

Comments

Popular posts from this blog

(OpenCV Study) Background subtractor MOG, MOG2, GMG example source code (BackgroundSubtractorMOG, BackgroundSubtractorMOG2, BackgroundSubtractorGMG)

OpenCV Stitching example (Stitcher class, Panorama)

AMP dose run on my pc?, AMP(Accelerated Massive Parallelism)

Example source code of extract HOG feature from images, save descriptor values to xml file, using opencv (using HOGDescriptor )

Optical Flow sample source code using OpenCV

Real-time N camera stitching Class.

OpenCV meanShiftFiltering example source code ( cpu: pyrMeanShiftFiltering, gpu:meanShiftFiltering, gpu:meanShiftSegmentation )

8 point algorithm (Matlab source code) / The method to get the Fundamental Matrix and the Essential matrix

Image warping (using opencv findHomography, warpPerspective)

Video Stabilization example source code, (using cvFindHomography, cvWarpPerspective functions in openCV)