运行.detector(openCV)时内核死

时间:2019-10-07 00:13:32

标签: python opencv kernel

我目前正在通过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()```

1 个答案:

答案 0 :(得分:1)

请替换:
tX = np.random.rand(100, 256,256) tXnew = np.empty((tX.shape) + (1,)) tXnew[:, :, :, 0] = tX assert(tXnew[1,5,55,0] == tX[1,5, 55]) #tXrestored = ? from tXnew #assert(tXrestored [1,5,55] == tX[1,5, 55])
与:
detector = cv2.SimpleBlobDetector()