Showing posts with label rect. Show all posts
Showing posts with label rect. Show all posts

3/22/2018

Check the rect contains point, opencv tip

https://docs.opencv.org/master/d2/d44/classcv_1_1Rect__.html#a367d5be1a40cc9d423f765ebf2721ee8


Use this function "Rect.contains(Point)".
example:

Rect roi(10,10,20,20);
Point pt(14,14);

if (roi.contains(pt))
  cout << "The pt inside in the rect" << endl;


Thank you.

9/29/2017

openCV Tip, Calculate overlap percent between two rectangle.

Calculate overlap percent between two rectangle




It is not difficult, we just use bit operator : &, |
for more detail information, refer to below source code.

< gist >

< /gist>



11/09/2015

2 rect intersection, union and overlap ratio in opencv Rect

using & and | operator and area() method.

see code


..
Rect A(100, 100, 100, 100); //x, y, width, hegiht
Rect B(80, 80, 100, 100); //x, y, width, hegiht

printf("intersection area= %d\n", (A&B).area());
printf("union area = %d\n", (A|B).area());
printf("instersection ratio %lf \n", (A&B).area() / float( (A | B).area() ));


..