[英]OpenCV Error: Unsupported format or combination of formats (Unsupported combination of input and output formats) in getRectSubPix
运行cv2.getRectSubPix(img, (5,5), (0,0))
抛出错误:
OpenCV Error: Unsupported format or combination of formats (Unsupported combination of input and output formats) in getRectSubPix.
的dtype
的img
是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)
或者,您可以使用.astype()
:
img.astype('int8')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.