---
panlei
2019-11-30 351d03c5ea2ade96c2a796bb6fa3382699c422ee
algorithm/faceCompare/faceCompare.go
@@ -2,19 +2,20 @@
import (
   "basic.com/pubsub/protomsg.git"
   "basic.com/valib/logger.git"
   logger "github.com/alecthomas/log4go"
   "github.com/knetic/govaluate"
   "ruleprocess/structure"
   "strconv"
)
// 人脸算法
func Entrance(rule *protomsg.Rule, am *structure.AreaMap) structure.LittleRuleResult {
func Entrance(rule *protomsg.Rule, am *structure.AreaMap,lable *structure.Others,args *structure.SdkDatas,message *protomsg.SdkMessage) structure.LittleRuleResult {
   logger.Debug("---------走了人脸比对算法",rule.Id,rule.SdkArgAlias,rule.Operator,rule.SdkArgValue,am.AreaId)
   return filterRule1(rule,am)
}
// 过滤规则先筛选出符合条件的目标数量
func filterRule1(rule *protomsg.Rule, am *structure.AreaMap) structure.LittleRuleResult {
   if rule.SdkId == "812b674b-2375-4589-919a-5c1c3278a97e" || rule.SdkId == "812b674b-2375-4589-919a-5c1c3278a972" {
      // 处理的是人脸算法 如果这条规则配置的是人脸算法,过滤完条件之后直接得出结果,因为肯定没有数量条件,自己拼接
      //logger.Info("规则的算法id和区域的算法id:", rule.SdkId, "===", am.sdkId)
@@ -64,15 +65,16 @@
                  //logger.Info("-----------------------人脸过滤的args里的数量:", len(args))
                  for _, arg := range args {
                     var formula string
                     if rule.SdkArgAlias == "score" {
                        formula = strconv.FormatFloat(arg.Score, 'f', -1, 64) + " " + rule.Operator + " " + rule.SdkArgValue // 得到字符串公式
                        logger.Info("当前相似度小公式:", formula)
                     } else if rule.SdkArgAlias == "proportion" {
                        formula = strconv.FormatFloat(arg.Proportion, 'f', -1, 64) + " " + rule.Operator + " " + rule.SdkArgValue // 得到字符串公式
                        logger.Info("当前占比小公式:", formula)
                     } else {
                        formula = strconv.FormatFloat(arg.Size, 'f', -1, 64) + " " + rule.Operator + " " + rule.SdkArgValue // 得到字符串公式
                        logger.Info("当前尺寸小公式:", formula)
                     switch rule.SdkArgAlias {
                     case "score":
                        formula = strconv.FormatFloat(arg.Score, 'f', -1, 64) + " " + rule.Operator + " " + rule.SdkArgValue
                        logger.Info("相似度小公式:", formula)
                     case "proportion":
                        formula = strconv.FormatFloat(arg.Proportion, 'f', -1, 64) + " " + rule.Operator + " " + rule.SdkArgValue
                        logger.Info("占比公式:", formula)
                     case "size":
                        formula = strconv.FormatFloat(arg.Size, 'f', -1, 64) + " " + rule.Operator + " " + rule.SdkArgValue
                        logger.Info("尺寸小公式:", formula)
                     }
                     expression, _ := govaluate.NewEvaluableExpression(formula) // 得到数学公式
                     result, _ := expression.Evaluate(nil)                      // 得到数学公式的结果