【发布时间】:2021-03-14 01:32:34
【问题描述】:
我目前正在通过 Udemy 学习 openCV 课程,但遇到了内核死机的问题。我尝试逐行消除以查看可能的原因,我发现当代码到达该行时:keypoints =detector.detect(image) 它失败了。现在,当谈到这类事情时,我有点像一个业余爱好者,但希望得到一些关于为什么会发生这种情况的反馈。这是我正在使用的代码:
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()```
【问题讨论】:
-
你在console/terminal/cmd.exe中正常运行看到错误信息了吗?
-
也许您需要设置斑点检测器参数。有关示例,请参见 chaelatten.wordpress.com/2016/03/22/using-simpleblobdetector 和 stackoverflow.com/questions/8076889/…。建议您在遇到 OpenCV 代码问题时搜索 Google。