# I get this error Expected Ptr<cv::UMat> for argument '%s' while resizing image in open cv2

This is my code:

# loading image from folder
folders = glob.glob('path to folder ')

imagenames_list = []

for folder in folders:
for f in glob.glob(folder+'/*.jpg'):
imagenames_list.append(f)

for image in imagenames_list:



I get this error

Expected Ptr<cv::UMat> for argument '%s'


What does this mean and how can I fix it?

I changed the data type from float16 to float32, solving the problem:

images.astype(np.float32)

• not working for me.. Jul 10, 2020 at 15:22

I think your problem is because you are feeding a list instead of numpy array of image to cv2.resize.

re_size = [cv2.resize(img, (50,50), interpolation=cv2.INTER_LINEAR) for img in read_images]


should fix that for you.

I suggest that as it is a function of OpenCV. So the best way is to read the image using cv2 and then utilize the image or convert the image to numpy.ndarray. Hope so it will be helpful

path=r'C:\Users\imzia\Rb\S010_004_00000019.png'