mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Merge pull request #29255 from ArneshBanerjee:samples-blob-contours-29254
samples: demonstrate SimpleBlobDetector contour collection
This commit is contained in:
@@ -107,6 +107,8 @@ int main(int argc, char *argv[])
|
||||
pDefaultBLOB.filterByConvexity = false;
|
||||
pDefaultBLOB.minConvexity = 0.95f;
|
||||
pDefaultBLOB.maxConvexity = (float)1e37;
|
||||
// Enable contour collection so we can draw blob outlines (see getBlobContours() below).
|
||||
pDefaultBLOB.collectContours = true;
|
||||
// Descriptor array for BLOB
|
||||
vector<String> typeDesc;
|
||||
// Param array for BLOB
|
||||
@@ -189,6 +191,11 @@ int main(int argc, char *argv[])
|
||||
int i = 0;
|
||||
for (vector<KeyPoint>::iterator k = keyImg.begin(); k != keyImg.end(); ++k, ++i)
|
||||
circle(result, k->pt, (int)k->size, palette[i % 65536]);
|
||||
// Retrieve the per-blob contours collected during detect() and outline each blob.
|
||||
// Requires SimpleBlobDetector::Params::collectContours to be true.
|
||||
const vector<vector<Point> >& blobContours = sbd->getBlobContours();
|
||||
for (size_t c = 0; c < blobContours.size(); ++c)
|
||||
drawContours(result, blobContours, (int)c, Scalar(0, 255, 0), 1);
|
||||
}
|
||||
namedWindow(*itDesc + label, WINDOW_AUTOSIZE);
|
||||
imshow(*itDesc + label, result);
|
||||
|
||||
Reference in New Issue
Block a user