Ask Your Question
0

How to find out if rect is inside another rect ?

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

Kenny Karnama gravatar image

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

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
3

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

berak gravatar image

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

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 -0500 )edit
1

the same..

(containment is only a special case of intersection)

berak gravatar imageberak ( 2018-04-15 03:16:26 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

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

Seen: 571 times

Last updated: Apr 15