Ask Your Question
1

Problem with groupRectangles().

asked 2016-03-31 14:47:37 -0600

sjs7007 gravatar image
a = [[1,2,3,4],[1,2,3,4],[4,5,6,7],[4,5,6,7]]
cv2.groupRectangles(a,1,0)

This returns 2 rectangles [1,2,3,4] and [4,5,6,7] as expected. However if I add a big rectangle to the list, which covers them all, I get just that big rectangle whereas what I want is each rectangle individually.

a = [[1,2,3,4],[1,2,3,4],[4,5,6,7],[4,5,6,7],[0,0,100,100],[0,0,100,100]]
cv2.groupRectangles(a,1,0)

The result of this is just one rectangle [0,0,100,100]. I want [1,2,3,4],[4,5,6,7] and [0,0,100,100].

PS : This is just example data. The rectangles in the original data don't always have the exact same values.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
2

answered 2016-04-01 02:52:25 -0600

updated 2016-04-01 02:53:04 -0600

Your problem is simple, if you look at the groupRectangles criteria. There is the eps parameter which you have set to 0. This last parameter to groupRectangles is epsilon ‘eps’, which controls how much overlap is required in order to merge rectangles. Standard it means that two rectangles need to overlap 20%. However in your case they do not need to overlap at all, which means that your biggest rectangle will always end as the final result.

How it is done in detail can be seen here!

I am pretty sure that demanding an overlap of like 0.85 would do the trick here!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-03-31 14:47:37 -0600

Seen: 5,724 times

Last updated: Apr 01 '16