运行 cv2.getRectSubPix(img, (5,5), (0,0))
抛出错误:
OpenCV Error: Unsupported format or combination of formats (Unsupported combination of input and output formats) in getRectSubPix.
img
的dtype
为float64,由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/