小编Pet*_*ter的帖子

opencv simpleblobdetector - 获取已识别 blob 的 blob 属性

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

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

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??? …
Run Code Online (Sandbox Code Playgroud)

python opencv

8
推荐指数
1
解决办法
1879
查看次数

标签 统计

opencv ×1

python ×1