| | |
| | | "ruleprocess/structure" |
| | | "strconv" |
| | | ) |
| | | |
| | | //个体静止算法 |
| | | var StaticMap = make(map[string]CameraArea) |
| | | |
| | | type CameraArea struct { |
| | | targets []Obj |
| | | duration int |
| | | cache structure.ResultMsg |
| | | } |
| | | type Obj struct { |
| | | id string |
| | | location []structure.Rect |
| | | staticStatus int |
| | | } |
| | | |
| | | func Entrance(rule *protomsg.Rule, am *structure.AreaMap) structure.LittleRuleResult { |
| | | for _,obj := range am.FilterData { |
| | | var flag bool = true |
| | |
| | | return structure.LittleRuleResult{am.SdkName, rule.RuleWithPre + "" + "false", rule.Sort} |
| | | } |
| | | } |
| | | |
| | | // 判断两个矩形的重合度,把面积更大的做分母 |
| | | func PgsInterPercent(pgpts []structure.Point, box structure.Rect, widthScale float64, heightScale float64) (percent float64) { |
| | | |
| | | areapts, areaBox := ruleserver.GetLocation(box, 10) |
| | | var count = 0 |
| | | for _, pts := range areapts { |
| | | if ruleserver.PintIsInPolygon(pts, pgpts, widthScale, heightScale) { |
| | | count++ |
| | | } |
| | | } |
| | | perInterBox := float64(count) / float64(len(areapts)) // 重合面积占矩形的比例 |
| | | areaInter := perInterBox * areaBox |
| | | areaPg := ruleserver.ComputePolygonArea(pgpts) |
| | | perInterPg := areaInter / areaPg // 重合面积占多边形区域的比例 |
| | | // 哪个占的比例小按哪个计算,比如人站起来了,大框套住了小框 |
| | | if perInterBox < perInterPg { |
| | | return (perInterBox * 100) |
| | | } |
| | | return (perInterPg * 100) |
| | | } |