| | |
| | | score float64 // 区域内的目标的相似度 |
| | | proportion float64 // 区域内的目标的占比 |
| | | size float64 // 区域内的目标的尺寸 |
| | | liker []LikePerson |
| | | } |
| | | |
| | | type LikePerson struct { |
| | | Id string // 与之相似的底库人员的id |
| | | Score float64 // 与底库人员的相似值 |
| | | } |
| | | |
| | | // 每个区域内的图片数据集合 |
| | |
| | | // sdk输出的图片上单个目标的数据 |
| | | type PhotoMap struct { |
| | | Rects Rect // 矩形区域参数 |
| | | Score float64 // 相似度得分 |
| | | Score float64 // 相似度得分(有多大程度像一个目标。人脸,人体或车等等) |
| | | Liker []LikePerson // 如果是人脸的话尤其是比对,应存下他跟底库的人员的相似情况 yolo的话给nil就行 |
| | | } |
| | | |
| | | // 从通道中获取的sdk输出的图像数据(目前主要是yolo算法的数据) |
| | |
| | | type Result struct { |
| | | TaskId string // 任务id |
| | | RuleGroupId string // 规则组id |
| | | AlarmLevel int32 // 报警等级 |
| | | AlarmLevel int32 // 报警等级 |
| | | RuleText string // 文字版规则组 |
| | | } |
| | | |
| | |
| | | // 将字符串格式的坐标序列化为Point格式 |
| | | func Json2points(areaPoints string) []Point { |
| | | var pts []Point |
| | | |
| | | err := json.Unmarshal([]byte(areaPoints), &pts) |
| | | if err != nil { |
| | | fmt.Println("json.Unmarshal错误", err) |
| | | panic("序列化坐标异常,程序退出") |
| | | if areaPoints == "" { |
| | | pts = append(pts, Point{0, 0}) |
| | | pts = append(pts, Point{0, 540}) |
| | | pts = append(pts, Point{960, 540}) |
| | | pts = append(pts, Point{960, 0}) |
| | | } else { |
| | | err := json.Unmarshal([]byte(areaPoints), &pts) |
| | | if err != nil { |
| | | fmt.Println("json.Unmarshal错误", err) |
| | | panic("序列化坐标异常,程序退出") |
| | | } |
| | | } |
| | | return pts |
| | | } |
| | |
| | | flag := splice1(&areaMap) |
| | | if flag != "" { |
| | | fmt.Println("强行拼凑一个人数是否大于0的结果", flag) |
| | | completeFormula = completeFormula + groupRule.Rules[j].RuleWithPre + "" + flag |
| | | completeFormula = flag |
| | | } |
| | | |
| | | } |
| | | for j := 0; j < len(groupRule.Rules); j++ { |
| | | // 这步过的是时间规则(时间段等) |
| | |
| | | if flag { |
| | | fmt.Println("定时器报警了") |
| | | // 过完规则后打个标签,告诉调用者本帧数据针对哪个任务哪组规则报警了 |
| | | arg.RuleResult = append(arg.RuleResult, Result{taskId, groupRule.GroupId,groupRule.AlarmLevel,groupRule.GroupText}) |
| | | arg.RuleResult = append(arg.RuleResult, Result{taskId, groupRule.GroupId, groupRule.AlarmLevel, groupRule.GroupText}) |
| | | return true |
| | | } else { |
| | | return false |
| | |
| | | formula = strconv.FormatFloat(arg.size, 'f', -1, 64) + " " + rule.Operator + " " + rule.SdkArgValue // 得到字符串公式 |
| | | } |
| | | expression, _ := govaluate.NewEvaluableExpression(formula) // 得到数学公式 |
| | | result, _ := expression.Evaluate(nil) // 得到数学公式的结果 |
| | | result, _ := expression.Evaluate(nil) // 得到数学公式的结果 |
| | | if result.(bool) { |
| | | am.filterData = append(am.filterData, arg) // 得到符合条件的过滤数据 |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 冗余拼接 |
| | | func splice1 (am *AreaMap) string { |
| | | func splice1(am *AreaMap) string { |
| | | args := am.targetNum |
| | | formula := strconv.Itoa(args) + " " + ">" + "0" |
| | | formula := strconv.Itoa(args) + " " + ">" + "0" |
| | | expression, _ := govaluate.NewEvaluableExpression(formula) // 得到数学公式 |
| | | result, _ := expression.Evaluate(nil) // 得到数学公式的结果 |
| | | return strconv.FormatBool(result.(bool)) |
| | | } |
| | | |
| | | // 给数据库的规则表达式代参 args: 一条子规则,区域数据 |
| | | func transferParameters(rule *protomsg.Rule, am *AreaMap) string { |
| | | if rule.PolygonId == am.areaId { // 首先规则所对应的区域id要跟区域数据的id对的上 |
| | |
| | | } else if rule.SdkId == "FaceDetect" { // 人脸检测 |
| | | if rule.Operator == "==" || rule.Operator == ">=" || rule.Operator == "<=" || rule.Operator == "<" || rule.Operator == ">" || rule.Operator == "!=" { |
| | | // 如果是不规矩的连接符统统返回false 规则也只能判断人脸的相似度,所以不存在别的连接符 |
| | | |
| | | return "false" |
| | | } else { |
| | | return "false" |
| | | } |
| | | } else { |
| | | } else if rule.SdkId == "FaceCompare"{ |
| | | |
| | | } |
| | | |