cv2.rectangle has two ways of calling:
- img = cv.rectangle( img, pt1, pt2, color[, thickness[, lineType[, shift]]] )
- img = cv.rectangle( img, rec, color[, thickness[, lineType[, shift]]]
source:https://docs.opencv.org/4.1.2/d6/d6e/group__imgproc__draw.html#ga07d2f74cadcf8e305e810ce8eed13bc9
I call rectangle as following:
cv2.rectangle(img=cv2_im, pt1=a, pt2=b, color=(0, 255, 0),thickness=3, lineType=cv2.LINE_AA)
Error Message:
cv2.rectangle(img=cv2_im, pt1=a, pt2=b, color=(0, 255, 0), thickness=3, lineType=cv2.LINE_AA)TypeError: rectangle() missing required argument 'rec' (pos 2)
I do not understand why the application tries to call the overloaded version of the method. U explicitly define version 1 call. I tried changing the variable a with (x,y) etc. but it doesn't work. The correct method call only works the first time I call the retangle() afterwards it expects me to use the overloaded version of it.
- Python 3.7.5 64 bit
- Pillow 7.0.0
- numpy 1.18.1
opencv-contrib-python 4.1.2.30
imgname='fly_1.jpg' im = Image.open(imgname) cv2_im = np.array(im)#x,y,w,h aus Image Labeler box= [505.54, 398.334, 1334.43, 2513.223] x,y,w,h = box a = (x, y) b = (x+w, y+h)#First rectanglecall cv2.rectangle(img=cv2_im, pt1=a, pt2=b, color=(0, 255, 0), thickness=3, lineType=cv2.LINE_AA) #calls two cv2 methods which shouldn't influence rectangle rects = getRegionProposals(im,'f',normalized=True) for i,rect in enumerate(rects):x, x_max, y, y_max = recta = (x*width,y*height)b = (x_max*width, y_max*height)if (IoU is not False and IoU > 0.5):#second and further callscv2.rectangle(img=cv2_im, pt1=a, pt2=b, color=(0, 255, 0), thickness=3, lineType=cv2.LINE_AA)
In between the second call I used cv2 selective search and set the following: cv2.setUseOptimized(True)cv2.setNumThreads(4)
Hope u guys see what I'm doin wrong.