gpt4 book ai didi

python - cv2.SimpleBlobDetector()需要什么输入?

转载 作者:行者123 更新时间:2023-12-02 17:29:00 33 4
gpt4 key购买 nike

我输入的mask是一维灰度图像:

detector = cv2.SimpleBlobDetector()

print('mask.shape', mask.shape) #
print('mask.dtype', mask.dtype) #
mask = mask.astype(np.uint8)
mask = np.dstack([mask] * 3)
print('mask.shape', mask.shape) #
print('mask.dtype', mask.dtype) #
keypoints = detector.detect(mask)

print('type(keypoints)', type(keypoints))
print('keypoints', keypoints)

输出:
mask.shape (360, 480)
mask.dtype uint8
mask.shape (360, 480, 3)
mask.dtype uint8

它产生一个错误: TypeError: Incorrect type of self (must be 'Feature2D' or its derivative)
更新:
import cv2

img = cv2.imread('Circles.jpg',0)

print('img.shape', img.shape)
print('img.dtype', img.dtype)

detector = cv2.SimpleBlobDetector_create()

keypoints = detector.detect(img)

print('type(keypoints)', type(keypoints))
print('keypoints', keypoints)

输出:
img.shape (428, 500)
img.dtype uint8
type(keypoints) <class 'list'>
keypoints []

图片:

enter image description here

最佳答案

我不了解背景知识,但是在某些时候,创建检测器对象的方式已更改。
这应该使您的代码正常工作:

detector = cv2.SimpleBlobDetector_create()

Documentation

关于python - cv2.SimpleBlobDetector()需要什么输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57081452/

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