Ask Your Question
1

SimpleBlobDetector crashes silently

asked 2019-09-27 02:03:21 -0500

Watol gravatar image

updated 2019-09-27 05:24:59 -0500

berak gravatar image

Hello,

I am trying to detect blobs in a threshold image.

img = cv2.imread("my_image")

_, img = cv2.threshold(img, 230, 255, cv2.THRESH_BINARY)

blob_detector = cv2.SimpleBlobDetector() 
keypoints = blob_detector.detect(img)

At the last line my jupyter notebook crashes after less than a second saying: "The kernel appears to have died. It will restart automatically"

I also executed the code in a Linux shell receiving the error code -11. I could not find out what the code stand for.

I am using Python version 3.7.3, openCV version is 4.1.1, I am using Ubuntu

I really do not know how to troubleshoot a silent crash so I really appreciate your help!

(This is my first post, so feel free to point out improvement suggestions. :) )

edit retag flag offensive close merge delete

Comments

1

add your image please, so we can try to reproduce the problem

berak gravatar imageberak ( 2019-09-27 02:09:04 -0500 )edit

I have this problem with all the images I am using. So I am not sure a specific example with help here. I have tried 5 different images. All fail in the same way. Sometimes they fail completely silently... Do you still think adding an image will be helpful?

Watol gravatar imageWatol ( 2019-09-27 02:19:00 -0500 )edit

please run it from a plain cmdline, not a notebook, you might be missing some exceptions.

berak gravatar imageberak ( 2019-09-27 02:28:18 -0500 )edit
1

Yes, that is true. The error I get out of bash is: 2221 segmentation fault (core dumped) python filename.py

Watol gravatar imageWatol ( 2019-09-27 03:43:33 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
4

answered 2019-09-27 02:33:06 -0500

berak gravatar image

updated 2019-09-27 02:39:21 -0500

already this little snippet throws (and you missed it in your notebook):

blob_detector = cv2.SimpleBlobDetector() 
keypoints = blob_detector.detect(None)

Traceback (most recent call last):
  File "src/ocv.py", line 7, in <module>
    keypoints = blob_detector.detect(None)
TypeError: Incorrect type of self (must be 'Feature2D' or its derivative)

you MUST use the create() function, to construct a valid detector:

blob_detector = cv2.SimpleBlobDetector_create()

please make sure, you use recent docs, anything 2.4 related will be harmful.

edit flag offensive delete link more

Comments

1

You are right, I needed to take the SimpleBlobDetector_create instantiation methode. I was following an outdated tutorial and did not check my doc versions. However I do not get a proper error when executing the little snippet you provided. Even if I execute it in a shell, all I get is a segFault.

Thank you very much for your prompt help!!!

Watol gravatar imageWatol ( 2019-09-27 03:53:52 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-09-27 02:03:21 -0500

Seen: 178 times

Last updated: Sep 27