2024-05-13 19:34:08 发布
网友
运行cv2.getRectSubPix(img, (5,5), (0,0))将引发错误:
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的数据类型是float64,它是通过运行
print(img.dtype).
或者可以使用.astype():
.astype()
img.astype('int8')
通过查看源代码可以看出,getrectsubix的输入组合只有:
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()
:通过查看源代码可以看出,getrectsubix的输入组合只有:
这意味着需要将输入数组转换为要传入的int8或float32,这可以通过以下操作完成:
或者
相关问题 更多 >
编程相关推荐