Python 内核在运行时死亡。检测器(openCV)
我目前正在通过Udemy学习openCV课程,遇到了内核即将消亡的麻烦。我试图一行一行地排除,看看原因是什么,我发现当代码到达这行时:keypoints=detector.detect(image)失败了。现在,我是一个业余爱好者,但我希望能得到一些关于为什么会发生这种情况的反馈。以下是我正在使用的代码:Python 内核在运行时死亡。检测器(openCV),python,opencv,kernel,Python,Opencv,Kernel,我目前正在通过Udemy学习openCV课程,遇到了内核即将消亡的麻烦。我试图一行一行地排除,看看原因是什么,我发现当代码到达这行时:keypoints=detector.detect(image)失败了。现在,我是一个业余爱好者,但我希望能得到一些关于为什么会发生这种情况的反馈。以下是我正在使用的代码: import cv2 import numpy as np; # Read image image = cv2.imread("images/Sunflowers.jpg") # Set
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()```
请更换:detector=cv2.SimpleBlobDetector()
与:
detector=cv2.SimpleBlobDetector_create()
是否在console/terminal/cmd.exe中正常运行以查看错误消息?可能需要设置blob检测器参数。有关示例,请参见和。建议您在OpenCV代码出现问题时搜索Google。谢谢!这是一个被低估的答案。干得好。