From a94fdbe0f0434d1cbc4e8c19c60c8137a45352f5 Mon Sep 17 00:00:00 2001 From: laurentBerger Date: Mon, 11 May 2015 13:13:20 +0200 Subject: [PATCH] Example about BLOB with a new image in data folder --- data/example_blob.bmp | Bin 0 -> 414518 bytes samples/cpp/exampleBLOB.cpp | 210 ++++++++++++++++++++++++++++++++++++ 2 files changed, 210 insertions(+) create mode 100644 data/example_blob.bmp create mode 100644 samples/cpp/exampleBLOB.cpp diff --git a/data/example_blob.bmp b/data/example_blob.bmp new file mode 100644 index 0000000000000000000000000000000000000000..a974ef2c20a35c06ed06ccd08dd495cb096fa286 GIT binary patch literal 414518 zcmeI5y^iF_vY4sH;vQjV&Vqfc#sC5uJx-f#U7L_~uc5op$`R%`1&kwL#@m*+Mm+Kv=?&5a(tFpzY4`RBX@GQsbcXZ>=>q8;gzO+aLK+~QAe|w-LApSC z?>hLudw+y9KsrG>LwbXBf%M)D9f;XILK^=&K{`WvgLHxPKHu8oBfJifPLR%!-XL8d zz0bEjJi_Y$=>+Kv=?&5a()+BE(<8hNkWP@!klr9&AidA(IzPhe0O&9Uz?`oguwJx3ufa@CdI1q!Xkwq&G+xNbj>r zPml0AKsrG>LwbXBf%HC`8wNR_2S_JKXGm|5E|A`56y6@;b%1n&bcXZ>=>q9}#^mw{ zuLGnLq%)*9NEb-&6GG?rM|d3|ogkedy+OJ_dhaf9|CjC&(g5iM=?v)&()i!|jMn2L zybh2~kj{|aAYCB6&)5x*@H#*`K{`WvgLHxPJ|lU0gx3Mm3DOzT8>9=Q_ZipoBfJif zPLR%!-XL8dz0WAWJ;Lh%=>+Kv=?&5a()*10{|)M$p}(&C z`}BYJ_rH&4kl?>D3;y{7T=T&iFlk_9h50aPhVw=ZFdxhTrUB*y(+-z0AIt!z0p%mAhV<^$6XmoXpA0Hy)v1Je$dF(1qTrUB*y(+-z0AIt!z0p%mAhV z<^$6XmoXpA0Hy)v1Je$dF(1qTrUB*y(+-z0AIt!z0p%mAhV<^$6XmoXpA z0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ZNS^2GwgIkPmrg8NpbO+YLmjH)aL_!}xe!X)v7JY8aA1`}KDj z!bfj_Ld@bQq<*_oB@E!hg~!Va1431Q_4NYy5M71koTr%T4Nnx%pAR(lSa{(em8k#P zt9kSBupofHG9a~Eo+h6+A2=3kDTg35{nuX0mk(s)V`XDHVFyyX=}Gc=^3lr>AXn@_ zNcyk6k|!Ue;B=;j9Z2oAr^x5Y2jVc)qMV<^z+(l^cengZ0mXDh>iF@|s}Nwqvva{etaml!7sCHq8bQg7m|^XjC|w>K!mAf zgEI?=8Fk)L*BSZ9;Q5Vsyu2_V*^u+%qu<`MgtPQ~7$%ol4xVCi0g{oA5`HfA0TWaJ}t{9y@BXRpE`Y6X0Bh=YI?*j}O$vt42$_=tRShmzTt&HDSC0Li+LHu#rqi zV(G1$AM>cpM`C@?-TCp+%LJfTsUrf1?_xeG;KL^XNgRH3%tsag9G&|4kIv!bMTg=T z*t^&%2Kk%p(wh%g954ftBN{--Y*P6R z2<^{@YoR#;k^_$p8<^ckCe{M@!0a@8k4)A=97rbZaJM0RxB$uHJ-}Ah#S_~xmj;6P zz_-b=;nCT~%{XE%y|>bD7$2S8)#qJk8aGiHk9@QR^0C`n*#IWvkq-~Q=TBuh4DaO< zrc#E@6bs9@dfcmE|1qje`T_Q0Kff-FT5Qb20usf?#7GZ6w$S$_JcnSUc~BvPPxELX znvXnUaj%tVfcdDz5S5C-d{kM{M5SUdAC(%W60w+%N(@n{7|chd zhN(m>=A#lrR4NAZQK?}n5sUe##1NH=!F*I|m`cQAJ}NOprD8B2l^UiJv6zoa3{j~V z%txh$sYER1qY^_@DhBgWsbMM+i}|R;5S5C-d{k +#include +#include +#include + +using namespace std; +using namespace cv; + + +static void help() +{ + cout << "\n This program demonstrates how to use BLOB and MSER to detect region \n" + "Usage: \n" + " ./BLOB_MSER \n" + "Press a key when image window is active to change descriptor"; +} + + +String Legende(SimpleBlobDetector::Params &pAct) +{ + String s = ""; + if (pAct.filterByArea) + { + String inf = static_cast(&(ostringstream() << pAct.minArea))->str(); + String sup = static_cast(&(ostringstream() << pAct.maxArea))->str(); + s = " Area range [" + inf + " to " + sup + "]"; + } + if (pAct.filterByCircularity) + { + String inf = static_cast(&(ostringstream() << pAct.minCircularity))->str(); + String sup = static_cast(&(ostringstream() << pAct.maxCircularity))->str(); + if (s.length() == 0) + s = " Circularity range [" + inf + " to " + sup + "]"; + else + s += " AND Circularity range [" + inf + " to " + sup + "]"; + } + if (pAct.filterByColor) + { + String inf = static_cast(&(ostringstream() << (int)pAct.blobColor))->str(); + if (s.length() == 0) + s = " Blob color " + inf; + else + s += " AND Blob color " + inf; + } + if (pAct.filterByConvexity) + { + String inf = static_cast(&(ostringstream() << pAct.minConvexity))->str(); + String sup = static_cast(&(ostringstream() << pAct.maxConvexity))->str(); + if (s.length() == 0) + s = " Convexity range[" + inf + " to " + sup + "]"; + else + s += " AND Convexity range[" + inf + " to " + sup + "]"; + } + if (pAct.filterByInertia) + { + String inf = static_cast(&(ostringstream() << pAct.minInertiaRatio))->str(); + String sup = static_cast(&(ostringstream() << pAct.maxInertiaRatio))->str(); + if (s.length() == 0) + s = " Inertia ratio range [" + inf + " to " + sup + "]"; + else + s += " AND Inertia ratio range [" + inf + " to " + sup + "]"; + } + return s; +} + + + +int main(int argc, char *argv[]) +{ + vector fileName; + Mat img(600, 800, CV_8UC1); + if (argc == 1) + { + fileName.push_back("../data/example_blob.bmp"); + } + else if (argc == 2) + { + fileName.push_back(argv[1]); + } + else + { + help(); + return(0); + } + img = imread(fileName[0], IMREAD_UNCHANGED); + if (img.rows*img.cols <= 0) + { + cout << "Image " << fileName[0] << " is empty or cannot be found\n"; + return(0); + } + + SimpleBlobDetector::Params pDefaultBLOB; + // This is default parameters for SimpleBlobDetector + pDefaultBLOB.thresholdStep = 10; + pDefaultBLOB.minThreshold = 10; + pDefaultBLOB.maxThreshold = 220; + pDefaultBLOB.minRepeatability = 2; + pDefaultBLOB.minDistBetweenBlobs = 10; + pDefaultBLOB.filterByColor = false; + pDefaultBLOB.blobColor = 0; + pDefaultBLOB.filterByArea = false; + pDefaultBLOB.minArea = 25; + pDefaultBLOB.maxArea = 5000; + pDefaultBLOB.filterByCircularity = false; + pDefaultBLOB.minCircularity = 0.9f; + pDefaultBLOB.maxCircularity = std::numeric_limits::max(); + pDefaultBLOB.filterByInertia = false; + pDefaultBLOB.minInertiaRatio = 0.1f; + pDefaultBLOB.maxInertiaRatio = std::numeric_limits::max(); + pDefaultBLOB.filterByConvexity = false; + pDefaultBLOB.minConvexity = 0.95f; + pDefaultBLOB.maxConvexity = std::numeric_limits::max(); + // Descriptor array (BLOB or MSER) + vector typeDesc; + // Param array for BLOB + vector pBLOB; + vector::iterator itBLOB; + // Param array for MSER + + // Color palette + vector< Vec3b > palette; + for (int i = 0; i<65536; i++) + { + palette.push_back(Vec3b((uchar)rand(), (uchar)rand(), (uchar)rand())); + } + help(); + + typeDesc.push_back("BLOB"); + pBLOB.push_back(pDefaultBLOB); + pBLOB.back().filterByColor = true; + pBLOB.back().blobColor = 0; + + // This descriptor are going to be detect and compute BLOBS with 5 differents 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 + pBLOB.push_back(pDefaultBLOB); + pBLOB.back().filterByArea = true; + pBLOB.back().minArea = 1; + pBLOB.back().maxArea = float(img.rows*img.cols); + // Param for second BLOB detector we want area between 500 and 2900 pixels + typeDesc.push_back("BLOB"); + pBLOB.push_back(pDefaultBLOB); + pBLOB.back().filterByArea = true; + pBLOB.back().minArea = 500; + pBLOB.back().maxArea = 2900; + // Param for third BLOB detector we want only circular object + typeDesc.push_back("BLOB"); + pBLOB.push_back(pDefaultBLOB); + pBLOB.back().filterByCircularity = true; + // Param for Fourth BLOB detector we want ratio inertia + typeDesc.push_back("BLOB"); + pBLOB.push_back(pDefaultBLOB); + pBLOB.back().filterByInertia = true; + pBLOB.back().minInertiaRatio = 0; + pBLOB.back().maxInertiaRatio = (float)0.2; + // Param for Fourth BLOB detector we want ratio inertia + typeDesc.push_back("BLOB"); + pBLOB.push_back(pDefaultBLOB); + pBLOB.back().filterByConvexity = true; + pBLOB.back().minConvexity = 0.; + pBLOB.back().maxConvexity = (float)0.9; + + itBLOB = pBLOB.begin(); + vector desMethCmp; + Ptr b; + String label; + // Descriptor loop + vector::iterator itDesc; + for (itDesc = typeDesc.begin(); itDesc != typeDesc.end(); itDesc++) + { + vector keyImg1; + if (*itDesc == "BLOB") + { + b = SimpleBlobDetector::create(*itBLOB); + label = Legende(*itBLOB); + itBLOB++; + } + try + { + // We can detect keypoint with detect method + vector keyImg; + vector zone; + vector> region; + Mat desc, result(img.rows, img.cols, CV_8UC3); + if (b.dynamicCast() != NULL) + { + Ptr sbd = b.dynamicCast(); + sbd->detect(img, keyImg, Mat()); + drawKeypoints(img, keyImg, result); + int i = 0; + for (vector::iterator k = keyImg.begin(); k != keyImg.end(); k++, i++) + circle(result, k->pt, (int)k->size, palette[i % 65536]); + } + namedWindow(*itDesc + label, WINDOW_AUTOSIZE); + imshow(*itDesc + label, result); + imshow("Original", img); + waitKey(); + } + catch (Exception& e) + { + cout << "Feature : " << *itDesc << "\n"; + cout << e.msg << endl; + } + } + return 0; +} + + + +