当执行下面代码时出现该问题:
import cv2 as cv
import numpy as np
img = cv.imread('p-1.jpg', 1)
info = img.shape
height = int(info[0]*0.3)
width = int(info[1]*0.3)
img_resize = cv.resize(img, (height, width))
for i in range(0, height):
for j in range(0, width):
img[i, j] = img_resize[i, j]
cv.imshow('dst', img)
cv.waitKey(2000)
解决办法:
在下面这行代码中,错把横纵坐标位置写反:
img_esize = cv.resize(img, (height, width))
正确应该修改为:
img_resize = cv.resize(img, (width, height))