samples: use findFile() in "cpp"
This commit is contained in:
committed by
Alexander Alekhin
parent
2fa9bd221d
commit
c4c31f5bba
+14
-12
@@ -14,7 +14,7 @@ static void help()
|
||||
{
|
||||
cout << "\n This program demonstrates how to use BLOB to detect and filter region \n"
|
||||
"Usage: \n"
|
||||
" ./detect_blob <image1(../data/detect_blob.png as default)>\n"
|
||||
" ./detect_blob <image1(detect_blob.png as default)>\n"
|
||||
"Press a key when image window is active to change descriptor";
|
||||
}
|
||||
|
||||
@@ -70,20 +70,19 @@ static String Legende(SimpleBlobDetector::Params &pAct)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
vector<String> fileName;
|
||||
Mat img(600, 800, CV_8UC1);
|
||||
cv::CommandLineParser parser(argc, argv, "{@input |../data/detect_blob.png| }{h help | | }");
|
||||
String fileName;
|
||||
cv::CommandLineParser parser(argc, argv, "{@input |detect_blob.png| }{h help | | }");
|
||||
if (parser.has("h"))
|
||||
{
|
||||
help();
|
||||
return 0;
|
||||
}
|
||||
fileName.push_back(parser.get<string>("@input"));
|
||||
img = imread(fileName[0], IMREAD_COLOR);
|
||||
if (img.rows*img.cols <= 0)
|
||||
fileName = parser.get<string>("@input");
|
||||
Mat img = imread(samples::findFile(fileName), IMREAD_COLOR);
|
||||
if (img.empty())
|
||||
{
|
||||
cout << "Image " << fileName[0] << " is empty or cannot be found\n";
|
||||
return(0);
|
||||
cout << "Image " << fileName << " is empty or cannot be found\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
SimpleBlobDetector::Params pDefaultBLOB;
|
||||
@@ -116,14 +115,17 @@ int main(int argc, char *argv[])
|
||||
vector< Vec3b > palette;
|
||||
for (int i = 0; i<65536; i++)
|
||||
{
|
||||
palette.push_back(Vec3b((uchar)rand(), (uchar)rand(), (uchar)rand()));
|
||||
uchar c1 = (uchar)rand();
|
||||
uchar c2 = (uchar)rand();
|
||||
uchar c3 = (uchar)rand();
|
||||
palette.push_back(Vec3b(c1, c2, c3));
|
||||
}
|
||||
help();
|
||||
|
||||
|
||||
// These descriptors are going to be detecting and computing BLOBS with 6 different params
|
||||
// Param for first BLOB detector we want all
|
||||
typeDesc.push_back("BLOB"); // see http://docs.opencv.org/trunk/d0/d7a/classcv_1_1SimpleBlobDetector.html
|
||||
typeDesc.push_back("BLOB"); // see http://docs.opencv.org/3.4/d0/d7a/classcv_1_1SimpleBlobDetector.html
|
||||
pBLOB.push_back(pDefaultBLOB);
|
||||
pBLOB.back().filterByArea = true;
|
||||
pBLOB.back().minArea = 1;
|
||||
@@ -150,7 +152,7 @@ int main(int argc, char *argv[])
|
||||
pBLOB.back().filterByConvexity = true;
|
||||
pBLOB.back().minConvexity = 0.;
|
||||
pBLOB.back().maxConvexity = (float)0.9;
|
||||
// Param for six BLOB detector we want blob with gravity center color equal to 0 bug #4321 must be fixed
|
||||
// Param for six BLOB detector we want blob with gravity center color equal to 0
|
||||
typeDesc.push_back("BLOB");
|
||||
pBLOB.push_back(pDefaultBLOB);
|
||||
pBLOB.back().filterByColor = true;
|
||||
|
||||
Reference in New Issue
Block a user