繁体   English   中英

OpenCV 错误:getRectSubPix 中不支持的格式或格式组合(不支持的输入和输出格式组合)

[英]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.

dtypeimgfloat64,将其用测定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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM