SurfFeatureDetector exmaple source code (OpenCV)

This is 'SurfFeatureDetector' example source code.
On this page(http://feelmare.blogspot.kr/2013/12/surfgpu-example-source-code-feature.html), I introduced SURF_GPU.
In my case, The processing time difference is small.
GPU-> 0.99 sec, CPU-> 1.04 sec.


 



 

////
#include < stdio.h >  
#include < opencv2\opencv.hpp >
#include < opencv2\features2d\features2d.hpp >
#include < opencv2\nonfree\features2d.hpp >

#ifdef _DEBUG  
#pragma comment(lib, "opencv_core246d.lib")   
//#pragma comment(lib, "opencv_imgproc246d.lib")   //MAT processing  
//#pragma comment(lib, "opencv_objdetect246d.lib")   
//#pragma comment(lib, "opencv_gpu246d.lib")  
#pragma comment(lib, "opencv_features2d246d.lib")  
#pragma comment(lib, "opencv_highgui246d.lib")  
//#pragma comment(lib, "opencv_ml246d.lib")
//#pragma comment(lib, "opencv_stitching246d.lib");
#pragma comment(lib, "opencv_nonfree246d.lib");

#else  
#pragma comment(lib, "opencv_core246.lib")  
//#pragma comment(lib, "opencv_imgproc246.lib")  
//#pragma comment(lib, "opencv_objdetect246.lib")  
//#pragma comment(lib, "opencv_gpu246.lib")  
#pragma comment(lib, "opencv_features2d246.lib")  
#pragma comment(lib, "opencv_highgui246.lib")  
//#pragma comment(lib, "opencv_ml246.lib")  
//#pragma comment(lib, "opencv_stitching246.lib");
#pragma comment(lib, "opencv_nonfree246.lib");
#endif  

using namespace cv;  
using namespace std;


void main()  
{
/////CPU mode


//processign tiem measurement
unsigned long AAtime=0, BBtime=0;

//SURF_GPU example source code
Mat inImg,outImg;
vector src_keypoints;
vector src_descriptors;


//image load
inImg = imread("ship.png",0);

//FeatureFinder 
SurfFeatureDetector FeatureFinder(400);

//processing time measure
AAtime = getTickCount();

//Feature Extraction
FeatureFinder.detect( inImg, src_keypoints );

//Processing time measurement
BBtime = getTickCount(); 

//Features Draw
drawKeypoints( inImg, src_keypoints, outImg, Scalar::all(-1), DrawMatchesFlags::DRAW_RICH_KEYPOINTS );

imshow("Show", outImg); 
printf("Processing time = %.2lf(sec) \n",  (BBtime - AAtime)/getTickFrequency() );
printf("Features %d\n", src_keypoints.size() );

waitKey(0);

//save to file
imwrite("output.jpg", outImg);

}
////





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

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

Image warping (using opencv findHomography, warpPerspective)