error: (-215:Assertion failed) func != 0 in function

created at 07-31-2021 views: 75

problem

Problems encountered when using the resize function in opencv.

my code:

import cv2
import numpy as np
a = np.array([[1,2,3,4,5],[6,7,8,9,10],[11,12,13,14,15]])
orign = a.copy()
cv_r = cv2.resize(a, None,fx = 0.5,fy = 0.5,interpolation=cv2.INTER_LINEAR)

In order to test the effect of resize, I typed the above code by myself, and the following error occurred:

error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\imgproc\src\resize.cpp:3863: error: (-215:Assertion failed) func != 0 in function 'cv::hal::resize'

solution

a should be of type numpy.uint8

created at:07-31-2021
edited at: 07-31-2021: