#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/nonfree/features2d.hpp>
#include <opencv2/legacy/legacy.hpp>
#include <iostream>
#include <vector>
using namespace cv;
using namespace std;
int main17070703(void)
{
VideoCapture cap(0);
Mat image;
// Freak
//SurfFeatureDetector detector_Freak(2000);
SurfFeatureDetector detector_Freak;
vector<KeyPoint> keypoints_Freak;
vector<DMatch> matches_Freak;
vector<DMatch> matches1to2;
Mat descriptors_Freak;
Mat OutImage_Freak;
FREAK freak;
//ORB
ORB orb;
Mat OutImage_ORB;
vector<KeyPoint> keypoints_ORB;
//brisk
BRISK brisk;
Mat OutImage_BRISK;
vector<KeyPoint> Keypoints_BRISK;
if (!cap.isOpened())
{
cout << " cannot open the camera!\n";
getchar();
}
else
{
while (waitKey(3) != 27)
{
cap >> image;
// Freak
double t = (double)getTickCount();
detector_Freak.detect(image, keypoints_Freak);
//t = ((double)getTickCount() - t) / getTickFrequency();
//cout << "FREAK detection time [s]: " << t / 1.0 << endl;
// extract
t = (double)getTickCount();
freak.compute(image, keypoints_Freak, descriptors_Freak);
t = ((double)getTickCount() - t) / getTickFrequency();
cout << "FREAK extraction time [s]: " << t << endl;
// Draw keypoints.
//CV_EXPORTS_W void drawKeypoints(const Mat& image, const vector<KeyPoint>& keypoints, CV_OUT Mat& outImage,
// const Scalar& color = Scalar::all(-1), int flags = DrawMatchesFlags::DEFAULT);
drawKeypoints(image, keypoints_Freak, OutImage_Freak, Scalar::all(-1));
imshow("OutImage_Freak", OutImage_Freak);
//ORB
orb.operator()(image, Mat(), keypoints_ORB);
drawKeypoints(image, keypoints_ORB, OutImage_ORB, Scalar::all(-1));
imshow("OutImage_ORB", OutImage_ORB);
//BRISK
brisk.operator()(image, Mat(), Keypoints_BRISK);
drawKeypoints(image, Keypoints_BRISK, OutImage_BRISK, Scalar::all(-1));
imshow("OutImage_BRISK", OutImage_BRISK);
waitKey(1);
}
}
return 0;
}
int main0(void)
{
string filename1 = "hua.jpg";
string filename2 = "hua.jpg";
// FREAK
Mat imgA_Freak = imread(filename1);
Mat imgB_Freak = imread(filename2);
resize(imgA_Freak, imgA_Freak, Size(640, 480));
resize(imgB_Freak, imgB_Freak, Size(640, 480));
//VideoCapture cap(0);
//if (!cap.isOpened())
//{
// cout << " cannot open the camera!\n";
// getchar();
//}
//else
//{
// while (waitKey(3) != 27)
// {
// cap >> imgB_Freak;
//
// }
//}
vector<KeyPoint> keypointsA_Freak, keypointsB_Freak;
Mat descriptorsA_Freak, descriptorsB_Freak;
vector<DMatch> matches_Freak;
// DETECTION
// Any openCV detector such as
SurfFeatureDetector detector_Freak(200);
// DESCRIPTOR
// Our proposed FREAK descriptor
// (roation invariance, scale invariance, pattern radius corresponding to SMALLEST_KP_SIZE,
// number of octaves, optional vector containing the selected pairs)
// FREAK extractor(true, true, 22, 4, std::vector<int>());
FREAK freak;
FREAK freak1;
// MATCHER
// The standard Hamming distance can be used such as
// BruteForceMatcher<Hamming> matcher;
// or the proposed cascade of hamming distance using SSSE3
BruteForceMatcher<HammingLUT> matcher_Freak;
// detect
double t = (double)getTickCount();
detector_Freak.detect(imgA_Freak, keypointsA_Freak);
detector_Freak.detect(imgB_Freak, keypointsB_Freak);
//t = ((double)getTickCount() - t) / getTickFrequency();
//cout << "FREAK detection time [s]: " << t / 1.0 << endl;
// extract
t = (double)getTickCount();
freak.compute(imgA_Freak, keypointsA_Freak, descriptorsA_Freak);
freak.compute(imgB_Freak, keypointsB_Freak, descriptorsB_Freak);
t = ((double)getTickCount() - t) / getTickFrequency();
cout << "FREAK extraction time [s]: " << t << endl;
Mat image;
vector<DMatch> matches1to2;
drawMatches(imgA_Freak, keypointsA_Freak, imgB_Freak, keypointsB_Freak, matches1to2, image);
imshow("image", image);
waitKey(0);
return 0;
}
Freak 和 brisk描述符与匹配
最新推荐文章于 2022-12-05 12:00:00 发布