【问题标题】:opencv simpleblobdetector - get blob attributes for identified blobsopencv simpleblobdetector - 获取已识别 blob 的 blob 属性
【发布时间】:2017-04-23 07:01:07
【问题描述】:

我正在使用 opencv 中的 simpleblobdetector 和 python 来识别图像中的 blob。

我可以让简单的斑点检测器工作并为我提供已识别斑点的位置。但是我也可以获得已识别斑点的惯性/凸度/圆度/等属性吗?

img = cv2.imread('image.png', cv2.IMREAD_GRAYSCALE)

# set up blob detector params
detector_params = cv2.SimpleBlobDetector_Params()
detector_params.filterByInertia = True
detector_params.minInertiaRatio = 0.001
detector_params.filterByArea = True
detector_params.maxArea = 10000000
detector_params.minArea = 1000
detector_params.filterByCircularity = True
detector_params.minCircularity = 0.0001
detector_params.filterByConvexity = True
detector_params.minConvexity = 0.01

detector = cv2.SimpleBlobDetector_create(detector_params)

# Detect blobs.
keypoints = detector.detect(img)

# print properties of identified blobs
for p in keypoints:
    print(p.pt) # locations of blobs
    # circularity???
    # inertia???
    # area???
    # convexity???
    # etc...

谢谢

【问题讨论】:

  • 除了p.pt,你还可以得到p.size,不确定是否有帮助

标签: python opencv


【解决方案1】:

根据opencv.org,检测器返回的关键点不包含有关找到它们的算法的任何信息:

cv::KeyPoint:突出点检测器的数据结构。

类实例存储一个关键点,即通过以下方式找到的点特征 许多可用的关键点检测器之一,例如哈里斯角 检测器, cv::FAST, cv::StarDetector, cv::SURF, cv::SIFT, cv::LDetector 等

关键点的特征是2D位置、比例(比例 到需要考虑的邻域的直径 帐户)、方向和一些其他参数。

您可以绘制关键点,显示大小和旋转:

img = cv2.drawKeypoints(img, keypoints, None, color=(0,255,0), flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)

【讨论】:

  • 太糟糕了,这对参数化很有帮助。
  • 我仍然无法理解这一切。对于某些情况,仅检测一个斑点及其位置可能就足够了,但还有很多其他情况,例如大小(在我的情况下,我使用检测器来检测膜中的孔并计算每个孔的直径)会非常有帮助。
  • 我同意@rbaleksandar 这非常令人沮丧,因为blob 检测器清楚地计算了所有这些值,但根本不返回它们。我更希望 blob 检测器返回带有所有这些参数的关键点,然后自己手动过滤掉它们,我知道 matlab 具有此功能,但我更愿意留在 python 中 ....
猜你喜欢
  • 2018-09-07
  • 2012-11-12
  • 2021-02-19
  • 1970-01-01
  • 2020-03-27
  • 2021-11-14
  • 2021-07-26
  • 2011-12-19
  • 1970-01-01
相关资源
最近更新 更多