派生自 Algorithm/baseDetector

cv
Scheaven
2021-06-03 fe1f84a5771290fa36f35478d13e117c58068b63
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//
// Created by Scheaven on 2020/4/20.
//
 
#include "result_util.h"
 
float cul_overlap_area(int Ax, int Ay, int Bx, int By, int Cx, int Cy, int Dx, int Dy)
{
    long x1 = Ax>Cx?Ax:Cx;
    long y1 = Ay>Cy?Ay:Cy;
    long x2 = Bx<Dx?Bx:Dx;
    long y2 = By<Dy?By:Dy;
 
    float w = 0.0>(x2-x1)?0.0:(x2-x1);
    float h = 0.0>(y2-y1)?0.0:(y2-y1);
    float inter_area = w*h;
    float lap_rate = inter_area/((Dx-Cx)*(Dy-Cy));
    return lap_rate;
}