#include <opencv/cv.h>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/objdetect.hpp>
#include <vector>
#include <iostream>
#include <string>
Go to the source code of this file.
|
int | main (int argc, char *argv[]) |
|
◆ main()
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 31 of file detect-test.cpp.
33 vector<String> typeDesc;
43 typeDesc.push_back(
"AKAZE-DESCRIPTOR_KAZE_UPRIGHT");
44 typeDesc.push_back(
"AKAZE");
45 typeDesc.push_back(
"ORB");
46 typeDesc.push_back(
"BRISK");
47 typeDesc.push_back(
"CORNER");
49 const String keys =
"{@image1 | | Reference image } {help h | | }";
50 CommandLineParser parser(argc, argv, keys);
51 if (parser.has(
"help"))
56 fileName = parser.get<
string>((int) 0);
60 Mat img1 = imread(fileName, IMREAD_GRAYSCALE);
61 if (img1.rows * img1.cols <= 0)
63 cout <<
"Image " << fileName <<
" is empty or cannot be found\n";
67 vector<double> desMethCmp;
71 vector<String>::iterator itDesc;
72 for (itDesc = typeDesc.begin(); itDesc != typeDesc.end(); ++itDesc)
75 vector<KeyPoint> keypoints;
78 if (*itDesc ==
"AKAZE-DESCRIPTOR_KAZE_UPRIGHT")
79 b = AKAZE::create(AKAZE::DESCRIPTOR_KAZE_UPRIGHT);
80 else if (*itDesc ==
"AKAZE")
82 else if (*itDesc ==
"ORB")
84 else if (*itDesc ==
"BRISK")
86 else if (*itDesc ==
"CORNER")
90 cout <<
"\nUnknown descriptor type requested: <"<<*itDesc<<
">\n"<<endl;
98 b->detect(img1, keypoints);
99 b->compute(img1, keypoints, descImg1);
105 vector<Point2f> features;
106 int maxCorners = 1000;
107 double qualityLevel = 0.001;
108 double minDistance = 5.0;
109 goodFeaturesToTrack(img1, features, maxCorners, qualityLevel, minDistance);
110 KeyPoint::convert(features, keypoints, 10.0);
114 drawKeypoints(img1, keypoints, descImg1, Scalar::all(-1),
115 DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
116 namedWindow(*itDesc, WINDOW_AUTOSIZE);
117 imshow(*itDesc, descImg1);
123 cout <<
"\nHit exception: "<<e.msg << endl;