这是我第一次编码python,我想做一个通过填充输入图像来制作正方形图像的程序。我编码了,但是我不知道为什么我会不断出现这些错误:
E1101:模块'cv2'没有'copyMakeBorder'成员
E1101:模块'cv2'没有'BORDER_CONSTANT'成员
我认为一切都很好。这是我的代码:
# -*- coding: utf-8 -*-
import cv2
import numpy as np
import sys
from PIL import Image
path = sys.argv
def cropper(path):
im = Image.open(path)
x , y = im.size
area = (0,0,x,y-20)
cropped_im = im.crop(area)
return cropped_im
def resize(Image):
im = Image
x , y = im.size
ratio = x/y
white = [255,255,255]
if ratio>1: #horizontal side is larger#
vpad = cv2.copyMakeBorder((x-y)/2, (x-y)/2,0,0, cv2.BORDER_CONSTANT,value=white)
return vpad
elif ratio<1: #vertical side is bigger
hpad = cv2.copyMakeBorder(0,0,(y-x)/2,(y-x)/2, cv2.BORDER_CONSTANT,value=white)
return hpad
else:
return im
我正在使用Visual Studio进行编码。请帮助