gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 12:03:15 29 4
gpt4 key购买 nike

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

我能够让简单的 Blob 检测器工作,并为我提供已识别 Blob 的位置。但是我也可以得到已识别 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...

谢谢

最佳答案

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

cv::KeyPoint: Data structure for salient point detectors.

The class instance stores a keypoint, i.e. a point feature found byone of many available keypoint detectors, such as Harris cornerdetector, cv::FAST, cv::StarDetector, cv::SURF, cv::SIFT,cv::LDetector etc.

The keypoint is characterized by the 2D position, scale (proportionalto the diameter of the neighborhood that needs to be taken intoaccount), orientation and some other parameters.

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

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

关于python - opencv simpleblobdetector - 获取已识别 blob 的 blob 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41032639/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com