SIFT算法调优

来源:互联网 发布:建立网络共享 编辑:程序博客网 时间:2024/06/15 13:06
// SIFTCalibration.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include<iostream>#include <opencv2/opencv.hpp>#include <opencv2/xfeatures2d/nonfree.hpp>using namespace std;using namespace cv;void main() {    cv::Mat source_1 = cv::imread("D:\\python_opencv\\source_image\\1123\\1\\1.jpg");    cv::Mat source_2 = cv::imread("D:\\python_opencv\\source_image\\1123\\1\\2.jpg");    cv::imshow("source_1", source_1);    cv::imshow("source_2", source_2);    cout << source_1.size() << endl;    vector<KeyPoint> key_points_1, key_points_2;    cv::Mat descriptor_1, descripter_2;    cv::Mat imgShow1, imgShow2;    cv::Ptr<Feature2D> sift = xfeatures2d::SIFT::create(0, 1, 0.04, 10);    double start = double(getTickCount());    sift->detectAndCompute(source_1, noArray(), key_points_1, descriptor_1);    double duration_ms = (double(getTickCount()) - start) * 1000 / getTickFrequency();//计时    std::cout << "It took " << duration_ms << " ms to detect features in pic1 using AKAZE." << std::endl;    sift->detectAndCompute(source_2, noArray(), key_points_2, descripter_2);    cv::drawKeypoints(source_1, key_points_1, imgShow1, cv::Scalar::all(-1), cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);    cv::drawKeypoints(source_2, key_points_2, imgShow2, cv::Scalar::all(-1), cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);    //cv::resize(imgShow2, imgShow2, cv::Size(imgShow2.cols, imgShow2.rows));    //cv::resize(imgShow1, imgShow1, cv::Size(imgShow1.cols, imgShow1.rows));    cv::imshow("SIFTKeypoints1", imgShow1);    cv::imshow("SIFTKeypoints2", imgShow2);    cv::waitKey(0);}