为什么OpenCV SimpleBlobDetector无法在此图像中检测到斑点?

时间:2019-01-28 17:19:35

标签: python opencv blob

我正在尝试检测以下图像中的斑点:

The image after color inversion

尽管如此,未检测到斑点。我检查了一些测试图像,以下代码工作正常。我也尝试调整参数,但没有成功。知道我在做什么错吗?

这是我正在使用的代码:

procpred = cv2.bitwise_not(procpred)
blur = cv2.blur(procpred, (15,15), 0)

params = cv2.SimpleBlobDetector_Params() 
# Change thresholds
params.minThreshold = 10
params.maxThreshold = 200

# Filter by Area.
params.filterByArea = False
params.minArea = 10

# Filter by Circularity
params.filterByCircularity = False
params.minCircularity = 0.1

# Filter by Convexity
params.filterByConvexity = False
params.minConvexity = 0.87

# Filter by Inertia
params.filterByInertia = False
params.minInertiaRatio = 0.01

# Create a detector with the parameters
ver = (cv2.__version__).split('.')
if int(ver[0]) < 3 :
    detector = cv2.SimpleBlobDetector(params)
else: 
    detector = cv2.SimpleBlobDetector_create(params)

# Detect blobs.
keypoints = detector.detect(blur)
print(keypoints)

#Draw detected blobs as red circles.
#cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS ensures the size of the circle corresponds to the size of blob
im_with_keypoints = cv2.drawKeypoints(procpred, keypoints, np.array([]), (0,0,255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)

plt.imshow(im_with_keypoints)

1 个答案:

答案 0 :(得分:0)

不知道在代码的开头会做什么,但是我做到了,而且看起来工作正常:

android:name="parking.sampleProj.testApp.LoginActivity"

enter image description here