12/20/2013

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

12/17/2013

Finding largest subset images that is only adjacent(subsequnce) images, (OpenCV, SurfFeaturesFinder, BestOf2NearestMatcher, leaveBiggestComponent funcions example souce code)

The souce code flow is like that...

1.
find features in each images using SurfFeaturesFinder function.
Features value is contained in the ImageFeatures structure.

2.
Matching features.
Matcher(features, pairwise_matches, matching_mask)
in the source code, features is vector.
So the Matcher function get matcing value of each pair images.

3.
leave biggest component,
Using conf_threshold, the function leaves largest correlation images.

Input
Input image is 6 images.
4 images are sequence images, 2 images is another sequence images.

Output
The souce code gives the result that is index of subset images of 4 images component.



////
#include < stdio.h >  
#include < opencv2\opencv.hpp >  
#include < opencv2\features2d\features2d.hpp >
#include < opencv2\nonfree\features2d.hpp >
#include < opencv2\stitching\detail\matchers.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_objdetect247d.lib")   
//#pragma comment(lib, "opencv_gpu247d.lib")  
#pragma comment(lib, "opencv_features2d247d.lib")  
#pragma comment(lib, "opencv_highgui247d.lib")  
//#pragma comment(lib, "opencv_ml247d.lib")
#pragma comment(lib, "opencv_stitching247d.lib");
#pragma comment(lib, "opencv_nonfree247d.lib");

#else  
#pragma comment(lib, "opencv_core247.lib")  
//#pragma comment(lib, "opencv_imgproc247.lib")  
//#pragma comment(lib, "opencv_objdetect247.lib")  
//#pragma comment(lib, "opencv_gpu247.lib")  
#pragma comment(lib, "opencv_features2d247.lib")  
#pragma comment(lib, "opencv_highgui247.lib")  
//#pragma comment(lib, "opencv_ml247.lib")  
#pragma comment(lib, "opencv_stitching247.lib");
#pragma comment(lib, "opencv_nonfree247.lib");
#endif  

using namespace cv;  
using namespace std;


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

 vImg.push_back( imread("./m7.jpg") );
 vImg.push_back( imread("./B1.jpg") );
 vImg.push_back( imread("./m9.jpg") );
 vImg.push_back( imread("./m6.jpg") );
 vImg.push_back( imread("./B2.jpg") );
 vImg.push_back( imread("./m8.jpg") );
 

 //feature extract
 detail::SurfFeaturesFinder FeatureFinder;
 vector< detail::ImageFeatures> features;
 
 for(int i=0; i< vImg.size(); ++i)
 {  
  detail::ImageFeatures F;
  FeatureFinder(vImg[i], F);  
  features.push_back(F);
  features[i].img_idx = i;
  printf("Keypoint of [%d] - %d points \n", i, features[i].keypoints.size() );
 }
 FeatureFinder.collectGarbage();

 //match
 vector<  int> indices_;
 double conf_thresh_ = 1.0;
 Mat matching_mask;
 vector<  detail::MatchesInfo> pairwise_matches;
 detail::BestOf2NearestMatcher Matcher;
 Matcher(features, pairwise_matches, matching_mask);
 Matcher.collectGarbage();

 printf("\nBiggest subset is ...\n");
 // Leave only images we are sure are from the same panorama 
 indices_ = detail::leaveBiggestComponent(features, pairwise_matches, (float)conf_thresh_);
 Matcher.collectGarbage();

 for (size_t i = 0; i <  indices_.size(); ++i)
    {
  printf("%d \n", indices_[i] );
 }
 

}

////









12/16/2013

How to access iOS provisioning portal site?

My question : How to access iOS provisioning portal site?
                       I never find this menu on the iOS development site..

My answer : I have not paid development fee. So I cannot see the menu..


My screen

Paid man screen