在拆分通道、(单独)模糊拆分结果并对组成组件应用拉普拉斯操作之后,我尝试在image上执行霍夫圆操作。
img = cv2.imread(fileName)
b, g, r = cv2.split(img)
kSize = 3
gBlur = cv2.blur(g, (kSize, kSize))
print(gBlur.shape)
test = np.array([])
gEdges = cv2.Laplacian(gBlur, cv2.CV_64F)
circles = cv2.HoughCircles(gEdges, cv2.HOUGH_GRADIENT, 40, 10,
param1=50,param2=60,minRadius=2,maxRadius=15)
但是,我从OpenCV收到一个错误,指出:
OpenCV(3.4.1) Error: Assertion failed (!_image.empty() &&
_image.type() == (((0) & ((1 << 3) - 1)) + (((1)-1) << 3)) &&
(_image.isMat() || _image.isUMat())) in HoughCircles, file
/io/opencv/modules/imgproc/src/hough.cpp, line 1659
和
cv2.error: OpenCV(3.4.1) /io/opencv/modules/imgproc/src/hough.cpp:1659:
error: (-215) !_image.empty() && _image.type() == (((0) & ((1 << 3) - 1))
+ (((1)-1) << 3)) && (_image.isMat() || _image.isUMat()) in function
HoughCircles
我不明白为什么会发生这样的事情。图像是灰度图像。我还尝试将拉普拉斯操作中的数据类型更改为cv2.CV_16U,甚至是cv2.CV_8U;然而,这些操作会产生一个空白图像--而且opencv会抛出一个不同的错误。
https://stackoverflow.com/questions/50731170
复制相似问题