#include <stdio.h> 

 #include "opencv2/core/core.hpp" 

 #include "opencv2/features2d/features2d.hpp" 

 #include "opencv2/highgui/highgui.hpp" 

 #include "opencv2/nonfree/nonfree.hpp" 

 #ifndef _DEBUG 

 #pragma  comment(lib,"IlmImf.lib")    

 #pragma  comment(lib,"libjasper.lib")     

 #pragma  comment(lib,"libjpeg.lib")    

 #pragma  comment(lib,"libpng.lib")        

 #pragma  comment(lib,"libtiff.lib")   

 #pragma  comment(lib,"zlib.lib")    

 #pragma  comment(lib,"opencv_calib3d2411.lib") 

 #pragma  comment(lib,"opencv_contrib2411.lib") 

 #pragma  comment(lib,"opencv_core2411.lib") 

 #pragma  comment(lib,"opencv_features2d2411.lib") 

 #pragma  comment(lib,"opencv_flann2411.lib") 

 #pragma  comment(lib,"opencv_gpu2411.lib") 

 #pragma  comment(lib,"opencv_highgui2411.lib") 

 #pragma  comment(lib,"opencv_imgproc2411.lib") 

 #pragma  comment(lib,"opencv_legacy2411.lib") 

 #pragma  comment(lib,"opencv_ml2411.lib") 

 #pragma  comment(lib,"opencv_nonfree2411.lib") 

 #pragma  comment(lib,"opencv_objdetect2411.lib") 

 #pragma  comment(lib,"opencv_ocl2411.lib") 

 #pragma  comment(lib,"opencv_photo2411.lib") 

 #pragma  comment(lib,"opencv_stitching2411.lib") 

 #pragma  comment(lib,"opencv_superres2411.lib") 

 #pragma  comment(lib,"opencv_ts2411.lib") 

 #pragma  comment(lib,"opencv_video2411.lib") 

 #pragma  comment(lib,"opencv_videostab2411.lib") 

 #else 

 #pragma  comment(lib,"zlibd.lib") 

 #pragma  comment(lib,"IlmImfd.lib") 

 #pragma  comment(lib,"libjasperd.lib") 

 #pragma  comment(lib,"libjpegd.lib") 

 #pragma  comment(lib,"libpngd.lib") 

 #pragma  comment(lib,"libtiffd.lib") 

 #pragma  comment(lib,"opencv_calib3d2411d.lib") 

 #pragma  comment(lib,"opencv_contrib2411d.lib") 

 #pragma  comment(lib,"opencv_core2411d.lib") 

 #pragma  comment(lib,"opencv_features2d2411d.lib") 

 #pragma  comment(lib,"opencv_flann2411d.lib") 

 #pragma  comment(lib,"opencv_gpu2411d.lib") 

 #pragma  comment(lib,"opencv_highgui2411d.lib") 

 #pragma  comment(lib,"opencv_imgproc2411d.lib") 

 #pragma  comment(lib,"opencv_legacy2411d.lib") 

 #pragma  comment(lib,"opencv_ml2411d.lib") 

 #pragma  comment(lib,"opencv_nonfree2411d.lib") 

 #pragma  comment(lib,"opencv_objdetect2411d.lib") 

 #pragma  comment(lib,"opencv_ocl2411d.lib") 

 #pragma  comment(lib,"opencv_photo2411d.lib") 

 #pragma  comment(lib,"opencv_stitching2411d.lib") 

 #pragma  comment(lib,"opencv_superres2411d.lib") 

 #pragma  comment(lib,"opencv_ts2411d.lib") 

 #pragma  comment(lib,"opencv_video2411d.lib") 

 #pragma  comment(lib,"opencv_videostab2411d.lib") 

 #endif 





 using namespace cv; 



 static void help() 

 { 

     printf("\nThis program demonstrates using features2d detector, descriptor extractor and simple matcher\n" 

             "Using the SURF desriptor:\n" 

             "\n" 

             "Usage:\n matcher_simple <image1> <image2>\n"); 

getchar(); 

 } 



 int main0(int argc, char** argv) 

 { 

     //if(argc != 3) 

     //{ 

     //    help(); 

     //    return -1; 

     //} 



     Mat img1 = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE); 

     Mat img2 = imread(argv[2], CV_LOAD_IMAGE_GRAYSCALE); 

     if(img1.empty() || img2.empty()) 

     { 

         printf("Can't read one of the images\n"); 

         return -1; 

     } 



     // detecting keypoints 

     SurfFeatureDetector detector(400); 

     vector<KeyPoint> keypoints1, keypoints2; 

     detector.detect(img1, keypoints1); 

     detector.detect(img2, keypoints2); 



     // computing descriptors 

     SurfDescriptorExtractor extractor; 

     Mat descriptors1, descriptors2; 

     extractor.compute(img1, keypoints1, descriptors1); 

     extractor.compute(img2, keypoints2, descriptors2); 



     // matching descriptors 

     BFMatcher matcher(NORM_L2); 

     vector<DMatch> matches; 

     matcher.match(descriptors1, descriptors2, matches); 



     // drawing the results 

     namedWindow("matches", 1); 

     Mat img_matches; 

     drawMatches(img1, keypoints1, img2, keypoints2, matches, img_matches); 

     imshow("matches", img_matches); 

     waitKey(0); 



     return 0; 

 } 

 double calc_norm(int a,int b,int c) 

 { 

double d=a*a+b*b+c*c; 

d=sqrt(d); 

return d; 

 } 



 int main(int argc, char** argv) 

 {  

double d=cv::norm<int,3,1>(cv::Vec3i(2,3,4)); 

int i=static_cast<int>(d); 

printf("d=%lf(%lf)\ni=%d\n",d,calc_norm(2,3,4),i); 

return 0; 

 } 



 //d=5.385165(5.385165) 

 //i=5 
//请按任意键继续. . .