float JaccardsCoefficient(Rect r1, Rect r2)
{
Point tl1 = r1.tl(), tl2 = r2.tl();
int xOverlap = max(0, min(tl1.x + r1.width , tl2.x + r2.width ) - max(tl1.x, tl2.x));
int yOverlap = max(0, min(tl1.y + r1.height, tl2.y + r2.height) - max(tl1.y, tl2.y));
float intersection = (float) (xOverlap*yOverlap);
float union_area = ((float)(r1.area() + r2.area())) - intersection;
return (intersection / union_area);
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.