python - OpenCV 错误 : Unsupported format or combination of formats (Unsupported combination of input and output formats) in getRectSubPix

标签 python numpy opencv

运行 cv2.getRectSubPix(img, (5,5), (0,0)) 抛出错误:

OpenCV Error: Unsupported format or combination of formats (Unsupported combination of input and output formats) in getRectSubPix.

imgdtypefloat64,由img.dtype决定。

最佳答案

查看源代码表明 getRectSubPix 的输入组合只有:

depth == CV_8U && ddepth == CV_8U

depth == CV_8U && ddepth == CV_32F

depth == CV_32F && ddepth == CV_32F

这意味着输入数组需要转换为int8或float32才能传入,这可以通过以下方式完成:

np.int8(img)

np.float32(img)

关于python - OpenCV 错误 : Unsupported format or combination of formats (Unsupported combination of input and output formats) in getRectSubPix,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48453576/

相关文章:

python - 按 numpy 数组的对象字段对对象列表进行排序?

opencv 2.4 SIFT编译错误

python - OpenCV:如何将图像传递给其他方法?

python - 为什么 setuptools 不创建我的入口点?

python - 401 未经授权,来自 https ://test. pypi.org/legacy/

python - 结合条形图和线图的问题(python)

python - numpy 中 RandomState 和种子之间的区别

python - 如何永久添加 Python 导入路径?

python - 如何使用python从字符串定义函数

python - 如何在Python中使用OpenCV查找图片上的最大矩形?