cv2.error: OpenCV(4.5.2) C:\Users\ ... \modules\imgproc\src\resize.cpp:3929: 错误: (-215:断言失败) func != 0 函数 'cv::哈尔::调整大小'

EB9*_*B97 1 python opencv numpy image-resizing

我尝试运行以下代码:

a = np.array([[1,0],[0,0]])
a = cv2.resize(a , (400,400))
cv2.imshow('Image', a)
cv2.waitKey(0)
cv2.destroyAllWindows
Run Code Online (Sandbox Code Playgroud)

并得到这个错误:

cv2.error: OpenCV(4.5.2) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-_8k9tw8n\opencv\modules\imgproc\src\resize.cpp:3929: error: (-215:Assertion failed) func != 0 in function 'cv::hal::resize'

找不到任何类似的问题

jef*_*yle 5

错误来自调整大小函数,它需要是 dtype=uint8 类型数组。这里有一个非常可靠的答案

如果有效的话请更新我:)