Ask Your Question
2

How to find out if rect is inside another rect ?

asked 2018-04-15 02:38:13 -0600

Kenny Karnama gravatar image

updated 2018-04-15 02:54:14 -0600

berak gravatar image

Hi guys, is there any method in opencv to check if rect is inside another rect ? thanks.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
4

answered 2018-04-15 03:11:10 -0600

berak gravatar image

updated 2018-04-15 03:44:44 -0600

in c++, there is an "intersection" operator:

Rect a(20,20,40,40);
Rect b(30,30,40,40);

Rect c = a & b;
// [30 x 30 from (30, 30)]

(if the intersection is empty, they do not overlap)

if you want to find out, if Rect a is completely inside Rect b, it is:

(a & b) == a;
edit flag offensive delete link more

Comments

so to check if a rectangle is inside other rectangle, what should i do ?

Kenny Karnama gravatar imageKenny Karnama ( 2018-04-15 03:12:59 -0600 )edit
2

the same..

(containment is only a special case of intersection)

berak gravatar imageberak ( 2018-04-15 03:16:26 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-04-15 02:38:13 -0600

Seen: 8,743 times

Last updated: Apr 15 '18