0

I am trying to work with the opencv SimpleBlobDetector. My current program is a simple test program like this:

import cv2
import numpy as np;

im = cv2.imread("blobs.jpg", cv2.IMREAD_GRAYSCALE)

params = cv2.SimpleBlobDetector_Params()

params.filterByArea = True;
params.minArea = 1;
params.maxArea = 1000;

detector = cv2.SimpleBlobDetector(params)

keypoints = detector.detect(im)

im_with_keypoints = cv2.drawKeypoints(im, keypoints, np.array([]), (0,0,255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)

cv2.imshow("Keypoints", im_with_keypoints)
cv2.waitKey(0)

code runs until the keypoints line where it should actually detect the blobs. it doesnt show any error message but just restarts the kernel. i used a very easy picture so blobs should be detected.

used image

1 Answer 1

1

Seems to work for me. If you are using Python 3 you want to use detector = cv2.SimpleBlobDetector_create(params) rather than what you had before. I increased the max area to 10000 pixels and I've included a screenshot of the output too:

import cv2
import numpy as np;

im = cv2.imread("blobs.jpg", cv2.IMREAD_GRAYSCALE)

params = cv2.SimpleBlobDetector_Params()

params.filterByArea = True;
params.minArea = 1;
params.maxArea = 10000;

detector = cv2.SimpleBlobDetector_create(params)

keypoints = detector.detect(im)

im_with_keypoints = cv2.drawKeypoints(im, keypoints, np.array([]), (0,0,255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)

cv2.imshow("Keypoints", im_with_keypoints)
cv2.waitKey(0)

output

Sign up to request clarification or add additional context in comments.

1 Comment

If you are using Python 3 you want to use detector = cv2.SimpleBlobDetector_create(params). That one did the job. thanks a lot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.