3

I'm currently working on an openCV course through Udemy and have run into the trouble where my kernel is dying. I tried eliminating line by line to see what could the cause, and I found that when the code comes to the line: keypoints = detector.detect(image) it fails. Now I am kind of an amateur when it comes to this kind of stuff, but would appreciate some feedback as to why this could be occurring. Here's the code i'm working with:

import cv2
import numpy as np;

# Read image
image = cv2.imread("images/Sunflowers.jpg")

# Set up the detector with default parameters.
detector = cv2.SimpleBlobDetector()

# Detect blobs.
keypoints = detector.detect(image)

# 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
blank = np.zeros((1,1)) 
blobs = cv2.drawKeypoints(image, keypoints, blank, (0,255,255),
                                      cv2.DRAW_MATCHES_FLAGS_DEFAULT)

# Show keypoints
cv2.imshow("Blobs", blobs)
cv2.waitKey(0)
cv2.destroyAllWindows()```
  • did you run it normally in console/terminal/cmd.exe to see error message ? – furas Oct 07 '19 at 01:35
  • 1
    Perhaps you need to set up your blob detector parameters. See https://chaelatten.wordpress.com/2016/03/22/using-simpleblobdetector/ and https://stackoverflow.com/questions/8076889/how-to-use-opencv-simpleblobdetector, for examples. Suggest you search Google when you have an issue with OpenCV code. – fmw42 Oct 07 '19 at 02:02

1 Answers1

2

Please replace:
detector = cv2.SimpleBlobDetector()
with:
detector = cv2.SimpleBlobDetector_create()

TkrA
  • 439
  • 1
  • 5
  • 19