我正在使用来自 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)