samples: use findFile() in "cpp"
This commit is contained in:
committed by
Alexander Alekhin
parent
2fa9bd221d
commit
c4c31f5bba
@@ -12,7 +12,7 @@ static void help()
|
||||
{
|
||||
cout << "\n This program demonstrates how to detect compute and match ORB BRISK and AKAZE descriptors \n"
|
||||
"Usage: \n"
|
||||
" ./matchmethod_orb_akaze_brisk --image1=<image1(../data/basketball1.png as default)> --image2=<image2(../data/basketball2.png as default)>\n"
|
||||
" ./matchmethod_orb_akaze_brisk --image1=<image1(basketball1.png as default)> --image2=<image2(basketball2.png as default)>\n"
|
||||
"Press a key when image window is active to change algorithm or descriptor";
|
||||
}
|
||||
|
||||
@@ -28,34 +28,34 @@ int main(int argc, char *argv[])
|
||||
typeDesc.push_back("AKAZE"); // see http://docs.opencv.org/trunk/d8/d30/classcv_1_1AKAZE.html
|
||||
typeDesc.push_back("ORB"); // see http://docs.opencv.org/trunk/de/dbf/classcv_1_1BRISK.html
|
||||
typeDesc.push_back("BRISK"); // see http://docs.opencv.org/trunk/db/d95/classcv_1_1ORB.html
|
||||
// This algorithm would be used to match descriptors see http://docs.opencv.org/trunk/db/d39/classcv_1_1DescriptorMatcher.html#ab5dc5036569ecc8d47565007fa518257
|
||||
// This algorithm would be used to match descriptors see http://docs.opencv.org/trunk/db/d39/classcv_1_1DescriptorMatcher.html#ab5dc5036569ecc8d47565007fa518257
|
||||
typeAlgoMatch.push_back("BruteForce");
|
||||
typeAlgoMatch.push_back("BruteForce-L1");
|
||||
typeAlgoMatch.push_back("BruteForce-Hamming");
|
||||
typeAlgoMatch.push_back("BruteForce-Hamming(2)");
|
||||
cv::CommandLineParser parser(argc, argv,
|
||||
"{ @image1 | ../data/basketball1.png | }"
|
||||
"{ @image2 | ../data/basketball2.png | }"
|
||||
"{ @image1 | basketball1.png | }"
|
||||
"{ @image2 | basketball2.png | }"
|
||||
"{help h ||}");
|
||||
if (parser.has("help"))
|
||||
{
|
||||
help();
|
||||
return 0;
|
||||
}
|
||||
fileName.push_back(parser.get<string>(0));
|
||||
fileName.push_back(parser.get<string>(1));
|
||||
fileName.push_back(samples::findFile(parser.get<string>(0)));
|
||||
fileName.push_back(samples::findFile(parser.get<string>(1)));
|
||||
Mat img1 = imread(fileName[0], IMREAD_GRAYSCALE);
|
||||
Mat img2 = imread(fileName[1], IMREAD_GRAYSCALE);
|
||||
if (img1.rows*img1.cols <= 0)
|
||||
{
|
||||
cout << "Image " << fileName[0] << " is empty or cannot be found\n";
|
||||
return(0);
|
||||
}
|
||||
if (img2.rows*img2.cols <= 0)
|
||||
{
|
||||
cout << "Image " << fileName[1] << " is empty or cannot be found\n";
|
||||
return(0);
|
||||
}
|
||||
if (img1.empty())
|
||||
{
|
||||
cerr << "Image " << fileName[0] << " is empty or cannot be found" << endl;
|
||||
return 1;
|
||||
}
|
||||
if (img2.empty())
|
||||
{
|
||||
cerr << "Image " << fileName[1] << " is empty or cannot be found" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
vector<double> desMethCmp;
|
||||
Ptr<Feature2D> b;
|
||||
@@ -74,10 +74,10 @@ int main(int argc, char *argv[])
|
||||
vector<String>::iterator itMatcher = typeAlgoMatch.end();
|
||||
if (*itDesc == "AKAZE-DESCRIPTOR_KAZE_UPRIGHT"){
|
||||
b = AKAZE::create(AKAZE::DESCRIPTOR_KAZE_UPRIGHT);
|
||||
}
|
||||
}
|
||||
if (*itDesc == "AKAZE"){
|
||||
b = AKAZE::create();
|
||||
}
|
||||
}
|
||||
if (*itDesc == "ORB"){
|
||||
b = ORB::create();
|
||||
}
|
||||
@@ -157,12 +157,12 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
catch (const Exception& e)
|
||||
{
|
||||
cerr << "Exception: " << e.what() << endl;
|
||||
cout << "Feature : " << *itDesc << "\n";
|
||||
if (itMatcher != typeAlgoMatch.end())
|
||||
{
|
||||
cout << "Matcher : " << *itMatcher << "\n";
|
||||
}
|
||||
cout << e.msg << endl;
|
||||
}
|
||||
}
|
||||
int i=0;
|
||||
|
||||
Reference in New Issue
Block a user