本文介绍了如何使用SimpleBlobDetector获取blob的额外信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
@robot_sherrick回答我,这是他回答的后续问题。
@robot_sherrick answered me this question, this is a follow-up question for his answer.
cv :: SimpleBlobDetector
看起来非常令人兴奋,但我不确定是否可以使其更详细的数据提取。
cv::SimpleBlobDetector
in Opencv 2.4 looks very exciting but I am not sure I can make it work for more detailed data extraction.
我有以下问题:
- blob,我不能有一个完整的,标记的垫,我可以吗?
- 如何访问检测到的斑点的特征,如面积,凸面,颜色等?
- ? (像是说瀑布)
推荐答案
所以代码应该看起来像这样: / p>
So the code should look something like this:
cv::Mat inputImg = imread(image_file_name, CV_LOAD_IMAGE_COLOR); // Read a file
cv::SimpleBlobDetector::Params params;
params.minDistBetweenBlobs = 10.0; // minimum 10 pixels between blobs
params.filterByArea = true; // filter my blobs by area of blob
params.minArea = 20.0; // min 20 pixels squared
params.maxArea = 500.0; // max 500 pixels squared
SimpleBlobDetector myBlobDetector(params);
std::vector<cv::KeyPoint> myBlobs;
myBlobDetector.detect(inputImg, myBlobs);
如果您想让这些关键点突出显示在您的图片上:
If you then want to have these keypoints highlighted on your image:
cv::Mat blobImg;
cv::drawKeypoints(inputImg, myBlobs, blobImg);
cv::imshow("Blobs", blobImg);
要访问关键点中的信息,您只需访问每个元素:
To access the info in the keypoints, you then just access each element like so:
for(std::vector<cv::KeyPoint>::iterator blobIterator = myBlobs.begin(); blobIterator != myBlobs.end(); blobIterator++){
std::cout << "size of blob is: " << blobIterator->size << std::endl;
std::cout << "point is at: " << blobIterator->pt.x << " " << blobIterator->pt.y << std::endl;
}
注意:这个没有编译,可能有错别字。
Note: this has not been compiled and may have typos.
这篇关于如何使用SimpleBlobDetector获取blob的额外信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!