【问题标题】:cv2.error: OpenCV(4.5.2) C:\Users\ ... \modules\imgproc\src\resize.cpp:3929: error: (-215:Assertion failed) func != 0 in function 'cv::hal::resize'cv2.error: OpenCV(4.5.2) C:\Users\ ... \modules\imgproc\src\resize.cpp:3929: error: (-215:Assertion failed) func != 0 in function 'cv::哈尔::调整大小'
【发布时间】:2021-09-26 10:47:11
【问题描述】:

我尝试运行以下代码:

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

得到了这个错误:

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

找不到类似的问题

【问题讨论】:

    标签: python numpy opencv image-resizing cv2


    【解决方案1】:

    错误来自 resize 函数,它需要是一个 dtype=uint8 类型的数组。 有一个相当可靠的答案here

    如果它有效,请更新我:)

    【讨论】:

    • uint8 更适合
    • int8 不起作用,但 float 起作用。谢谢!
    • @ChristophRackwitz 也 uint8 工作,从未听说过这种 dtype。谢谢!
    猜你喜欢
    • 2021-08-16
    • 2021-07-30
    • 1970-01-01
    • 2019-08-30
    • 1970-01-01
    • 2022-07-18
    • 2020-06-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多