| | |
| | | import ( |
| | | "encoding/json" |
| | | "fmt" |
| | | "log" |
| | | "sort" |
| | | "strconv" |
| | | "strings" |
| | |
| | | func singleTask(aml *AreaMapList, arg *ArgsFromSdk, groupRule *protomsg.GroupRule, taskId string) bool { |
| | | var completeFormula string = "" |
| | | for _, areaMap := range aml.areaMapList { |
| | | //fmt.Println("当前规则组为---------:",groupRule) |
| | | for j := 0; j < len(groupRule.Rules); j++ { |
| | | // 先过完条件数据 |
| | | filterRule(groupRule.Rules[j], &areaMap) |
| | |
| | | if completeFormula != "" { |
| | | expression, _ := govaluate.NewEvaluableExpression(completeFormula) |
| | | result, _ := expression.Evaluate(nil) // 得到数学公式的结果 |
| | | fmt.Println("这帧图像在任务下的除了持续时间外的一整条规则下的判断结果", result) |
| | | //fmt.Println("这帧图像在任务下的除了持续时间外的一整条规则下的判断结果", result) |
| | | // 由于天然或的关系,满足一个就该报警,即该帧数据对于某个任务的某个规则组应该报警 |
| | | if !result.(bool) { // 如果不符合条件,应该重置定时器元素,等符合时再开启,把key中包含任务id的timeEle都重置 |
| | | for k, timeEle := range TimeEleList { |
| | |
| | | } |
| | | // 先清空过滤后的数据,再往里塞本次过滤后的数据 |
| | | am.filterData = am.filterData[0:0] |
| | | log.Println("看一下当前小规则:",*rule) |
| | | for _, arg := range args { |
| | | var formula string |
| | | if rule.SdkArgAlias == "score" { |
| | | formula = strconv.FormatFloat(arg.score, 'f', -1, 64) + " " + rule.Operator + " " + rule.SdkArgValue // 得到字符串公式 |
| | | } else if rule.SdkArgAlias == "proportion" { |
| | | formula = strconv.FormatFloat(arg.proportion, 'f', -1, 64) + " " + rule.Operator + " " + rule.SdkArgValue // 得到字符串公式 |
| | | fmt.Println("占比的字符串公式:--------",formula) |
| | | } else { |
| | | formula = strconv.FormatFloat(arg.size, 'f', -1, 64) + " " + rule.Operator + " " + rule.SdkArgValue // 得到字符串公式 |
| | | } |
| | |
| | | // 冗余拼接 |
| | | func splice1(am *AreaMap) string { |
| | | args := am.targetNum |
| | | log.Println("看看区域内目标数量:----------",args) |
| | | formula := strconv.Itoa(args) + " " + ">" + "0" |
| | | expression, _ := govaluate.NewEvaluableExpression(formula) // 得到数学公式 |
| | | result, _ := expression.Evaluate(nil) // 得到数学公式的结果 |
| | |
| | | return "false" |
| | | } |
| | | } else if rule.SdkId == "FaceCompare"{ |
| | | // 只需要过滤阈值,过滤完后数组长度大于0即为报警,但如何对每一张都报警呢 |
| | | |
| | | } |
| | | |