gpt4 book ai didi

python - 运行 .detector (openCV) 时内核死机

转载 作者:行者123 更新时间:2023-12-04 04:24:04 25 4
gpt4 key购买 nike

我目前正在通过 Udemy 学习 openCV 类(class),但遇到了我的内核即将死机的问题。我尝试逐行消除以查看可能的原因,我发现当代码到达该行时: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()```

最佳答案

请替换:
检测器 = cv2.SimpleBlobDetector()
与:
检测器 = cv2.SimpleBlobDetector_create()

关于python - 运行 .detector (openCV) 时内核死机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58262213/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com