gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 16:49:21 33 4
gpt4 key购买 nike

运行 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/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com