| | |
| | | RuleGroupId string // 规则组id |
| | | AlarmLevel int32 // 报警等级 |
| | | RuleText string // 文字版规则组 |
| | | Location []Rect |
| | | } |
| | | type LittleRuleResult struct { |
| | | SdkName string // 记录下此结果是哪个sdk的结果 |
| | |
| | | if len(temp) > 0 { |
| | | if ruleList[i].SetType == "linkTask" { |
| | | // groupId中含有link则为联动任务 |
| | | //LinkTask(args, ruleList[i], taskId) |
| | | LinkTask(args, ruleList[i], taskId) |
| | | } else { |
| | | // 独立任务的处理 |
| | | RunRule(args, ruleList[i], taskId) |
| | |
| | | for _, va := range resultSplice { |
| | | completeFormula = completeFormula + va.Result |
| | | } |
| | | if strings.HasPrefix(completeFormula, "&&") || strings.HasPrefix(completeFormula, "||") || strings.HasPrefix(completeFormula, ">=") || strings.HasPrefix(completeFormula, "<=") || strings.HasPrefix(completeFormula, "==") || strings.HasPrefix(completeFormula, "!=") || strings.HasPrefix(completeFormula, ">") || strings.HasPrefix(completeFormula, "<") { |
| | | // 以这些开头的基本是联动任务 |
| | | if strings.HasPrefix(completeFormula, "&&") || strings.HasPrefix(completeFormula, "||") || strings.HasPrefix(completeFormula, ">=") || strings.HasPrefix(completeFormula, "<=") || strings.HasPrefix(completeFormula, "==") || strings.HasPrefix(completeFormula, "!=") { |
| | | completeFormula = completeFormula[2 :] |
| | | } |
| | | if strings.HasPrefix(completeFormula, ">") || strings.HasPrefix(completeFormula, "<") { |
| | | completeFormula = completeFormula[1 :] |
| | | } |
| | | log.Println("-------------------看看拔毛后的表达式:",completeFormula) |
| | | expression, _ := govaluate.NewEvaluableExpression(completeFormula) |
| | | result, _ := expression.Evaluate(nil) // 得到数学公式的结果 |
| | | return result.(bool) |
| | | } |
| | | if completeFormula != "" { |
| | | log.Println("结果公式-----------:", completeFormula) |
| | | expression, _ := govaluate.NewEvaluableExpression(completeFormula) |
| | |
| | | timeEle.N = timeEle.InitN // 重置定时器 |
| | | } |
| | | } |
| | | log.Println("--------------------走这里了吗---------------") |
| | | return false |
| | | } else { |
| | | // 最后成功报警才把符合条件的人脸数据塞进结果标签里 |
| | |
| | | } |
| | | } |
| | | if sdkName != "" { |
| | | args.RuleResult["yolo"] = append(args.RuleResult["yolo"].([]Result), Result{taskId, sdkName, groupRule.GroupId, groupRule.AlarmLevel, groupRule.GroupText}) |
| | | // 把他们的位置数据也传下去 |
| | | locations := []Rect{} |
| | | for _, sdkData := range args.Sdkdata { |
| | | for _, areaMap := range sdkData.AreaMapList { |
| | | for j := 0; j < len(groupRule.Rules); j++ { |
| | | locations = append(locations, putYolosToResult(groupRule.Rules[j], &areaMap)...) |
| | | } |
| | | } |
| | | } |
| | | //// 配了人脸的算法才把人脸的数据甩出来打标签 |
| | | //flag11 := false |
| | | //for j := 0; j < len(groupRule.Rules); j++ { |
| | | // if groupRule.Rules[j].SdkId == "812b674b-2375-4589-919a-5c1c3278a97e" || groupRule.Rules[j].SdkId == "812b674b-2375-4589-919a-5c1c3278a971" { |
| | | // flag11 = true |
| | | // } |
| | | //} |
| | | //if flag11 { |
| | | // args.RuleResult["face"] = faces |
| | | //} |
| | | args.RuleResult["yolo"] = append(args.RuleResult["yolo"].([]Result), Result{taskId, sdkName, groupRule.GroupId, groupRule.AlarmLevel, groupRule.GroupText,locations}) |
| | | log.Println("-------------------yolo结果标签", args.RuleResult["yolo"].([]Result)) |
| | | } |
| | | if args.RuleResult["face"] != nil { |
| | |
| | | } |
| | | //log.Println("-----------------------------------------------听说你是空的?",faces) |
| | | return faces |
| | | } |
| | | |
| | | func putYolosToResult(rule *protomsg.Rule, am *AreaMap) []Rect { |
| | | locations := []Rect{} |
| | | if rule.SdkId == am.sdkId && rule.SdkId != "812b674b-2375-4589-919a-5c1c3278a97e" && rule.SdkId != "812b674b-2375-4589-919a-5c1c3278a971" { |
| | | if len(am.filterData) > 0 { |
| | | for _, data := range am.filterData { |
| | | locations = append(locations, data.Location) |
| | | } |
| | | } |
| | | } |
| | | //log.Println("-----------------------------------------------听说你是空的?",faces) |
| | | return locations |
| | | } |
| | | |
| | | // 计算区域内的目标数量以及将相似度、占比、尺寸等打包 |
| | |
| | | for _, va := range timeEle.RuleResults { |
| | | if va.CameraId == args.CameraId { |
| | | va.Result = strconv.FormatBool(isOk) |
| | | log.Println("这个摄像机--",args.CameraId,"--被赋予了result",va.Result) |
| | | log.Println("这个摄像机--", args.CameraId, "--被赋予了result", va.Result) |
| | | } |
| | | } |
| | | // 判断结果数组是否完满(即被赋值完毕)可得出报警结果 |
| | | var isPerfect = true |
| | | for _, va := range timeEle.RuleResults { |
| | | log.Println("---------------------瞅瞅当前数组________________:",*va) |
| | | log.Println("---------------------瞅瞅当前数组________________:", *va) |
| | | if va.Result == "" && va.RuleWithPre != "||" { |
| | | isPerfect = false |
| | | } |
| | |
| | | } |
| | | } |
| | | if sdkName != "" { |
| | | args.RuleResult["yolo"] = append(args.RuleResult["yolo"].([]Result), Result{taskId, sdkName, groupRule.GroupId, groupRule.AlarmLevel, groupRule.GroupText}) |
| | | args.RuleResult["yolo"] = append(args.RuleResult["yolo"].([]Result), Result{taskId, sdkName, groupRule.GroupId, groupRule.AlarmLevel, groupRule.GroupText,[]Rect{}}) |
| | | log.Println("-------------------yolo结果标签", args.RuleResult["yolo"].([]Result)) |
| | | } |
| | | if args.RuleResult["face"] != nil { |