8

I need to detect semicircles on image and I find follow stuff for this:

import cv2
import numpy as np


def get_circle(img_path):
    im = cv2.imread(img_path, cv2.IMREAD_GRAYSCALE)
    detector = cv2.SimpleBlobDetector()
    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)

But I give follow error when I try to run it:

Traceback (most recent call last):
  File "D:\giveaway_bot\main.py", line 16, in <module>
    get_circle("blob.png")
  File "D:\giveaway_bot\main.py", line 11, in get_circle
    keypoints = detector.detect(im)
cv2.error: Unknown C++ exception from OpenCV code

Image: click

1
  • I think Hough circles will find semicircles, too. Commented Aug 28, 2021 at 17:14

1 Answer 1

23

I figured out your problem. You have used cv2.SimpleBlobDetector() which is old version. Use cv2.SimpleBlobDetector_create() instead.

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

1 Comment

Hi, I have a similar problem but my IDE (pycharm) doesn't suggest a new method "cv2.SimpleBlobDetector_create()" what should I do for this? Should I say that my opencv version is opencv-python==4.10.0.84?

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.