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() ));


..



1 comment: