Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cv2.groupRectangles returning an array with len=1

I'm trying to use cv2.groupRectangles to join the bounding boxes proposed by a neural network.

The problem is, for the following bounding boxes, it is returning [[4]] as one of the joined areas. I expected it to output 4 values. x0, y0, x1, y1

>>> import cv2
>>> aa = [[1050, 0, 1260, 144], [1085, 0, 1295, 144], [1015, 23, 1225, 168], [1050, 23, 1260, 168], [280, 782, 490, 960]]
>>> cv2.groupRectangles(aa, 1, 0.7)
(array([[1050,   12, 1260,  156]], dtype=int32), array([[4]], dtype=int32))
>>> 
like image 590
BernardoGO Avatar asked Jul 25 '26 10:07

BernardoGO


1 Answers

Function cv2.groupRectangles(rectList,groupThreshold,eps) requires 3 parameters and I assumed that you understood about these 3 parameters. Following documentation is useful to better understand each of these parameters.

Such function will return 2 values: rectList and weights. rectList represents a list of rectangles which could be used to represent a group of rectangles that you have provided to the function. In your case, there is only one rectangle, it means, the function were able to produce one rectangle to represent group of 4 given rectangles. The weights value will correlate with how many rectangles are represented by a single rectangle. In your case, there is only one weight since the function only able to form a single rectangle based on 4 neighboring rectangles.

like image 135
user1594231 Avatar answered Jul 27 '26 00:07

user1594231



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!