python - opencv warpPerspective参数计数

标签 python opencv numpy

在我的脚本中有以下代码:

src = numpy.array(cornersSheet, numpy.float32)
dst = numpy.array(cornersDesired, numpy.float32)
transform = cv2.getPerspectiveTransform(src,dst)
finished = cv2.warpPerspective(img, transform, img.shape)

Python 说:

Traceback (most recent call last):
File "./script.py", line 138, in <module>
    finished = cv2.warpPerspective(img, transform, img.shape)
TypeError: function takes exactly 2 arguments (3 given)

但根据文档:

    Python: cv2.warpPerspective(src, M, dsize[, dst[, flags[, borderMode[, borderValue]]]]) → dst

三个参数就OK了。我对 cv2.warpAffine 也有同样的问题。

最佳答案

问题解决了。 img.shape 返回包含 3 个元素的元组,warpPerspective 期望包含 2 个元素的元组。

关于python - opencv warpPerspective参数计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16352962/

相关文章:

python - 在表中按顺序拖动行 python selenium

python - 大于数组的值的 ndarray 行索引

python - AzureML 推理架构中出现 "list index out of range"错误

python - 从插值函数中检索值

python - 使用opencv和tensorflow时如何修复 "ValueError: An initializer for variable conv2d/kernel of is required"

python - pytesseract不适用于数字图像

python - 如何将小型二维阵列添加到大型阵列?

python - 使用 scikit-image 搜索所有模板

python - 如何仅在嵌套模式中解析属性值?

java - 将图像从我的外部存储文件读取到 native c (openCV) Android 中