Help this is my first time coding python and I want to make a program that makes square images by padding the input image. I coded but I don't know why i keep getting these errors:
E1101:Module 'cv2' has no 'copyMakeBorder' member
E1101:Module 'cv2' has no 'BORDER_CONSTANT' member
I think everything looks alright. here is my code:
# -*- 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
I'm using visual studio to code. please help