| | |
| | | "io/ioutil" |
| | | "math" |
| | | "nanomsg.org/go-mangos" |
| | | //"nanomsg.org/go-mangos/protocol/req" |
| | | "nanomsg.org/go-mangos/protocol/req" |
| | | "nanomsg.org/go-mangos/transport/tcp" |
| | | "os" |
| | | "ruleprocess/cache" |
| | |
| | | } |
| | | logger.Debug("本机信息和server信息:", localConfig, serverIp, serverPort) |
| | | bigCache.Init(dbTablePersons, serverIp, serverPort, localConfig.ServerId) |
| | | //sock, err = req.NewSocket(); |
| | | //if err != nil { |
| | | // logger.Error("创建请求socket失败: %s", err.Error()) |
| | | //} |
| | | sock, err = req.NewSocket(); |
| | | if err != nil { |
| | | logger.Error("创建请求socket失败: %s", err.Error()) |
| | | } |
| | | } |
| | | |
| | | type BaseInfo struct { |
| | |
| | | taskGroup = task |
| | | } |
| | | } |
| | | logger.Debug("当前数据帧要匹配的规则组:-------------------------") |
| | | logger.Debug("当前数据帧要匹配的规则组:-------------------------","摄像机id:",cameraId,"任务id",taskId) |
| | | for _,ruleGroup := range taskGroup.GroupRules{ |
| | | logger.Info(ruleGroup.GroupText) |
| | | } |
| | |
| | | |
| | | // 给目标填充liker |
| | | func (arg *Arg) fillLiker(tableId []string, compareThreshold float32) { |
| | | bytes := bigCache.GetComparePersonBaseInfo(tableId, arg.Feature, compareThreshold) |
| | | //comArg := &protomsg.CompareArgs{ |
| | | // TableIds:tableId, |
| | | // FaceFeature:arg.Feature, |
| | | // CompareThreshold:compareThreshold, |
| | | //} |
| | | //bytes := Push("tcp://192.168.1.182:40010",comArg,sock) |
| | | var m map[string]float32 |
| | | err1 := json.Unmarshal(bytes, &m) |
| | | //bytes := bigCache.GetComparePersonBaseInfo(tableId, arg.Feature, compareThreshold) |
| | | comArg := &protomsg.CompareArgs{ |
| | | TableIds:tableId, |
| | | FaceFeature:arg.Feature, |
| | | CompareThreshold:compareThreshold, |
| | | Source:false, |
| | | } |
| | | bytes := Push("tcp://192.168.1.182:40010",comArg,sock) |
| | | var scResult protomsg.SdkCompareResult |
| | | err1 := proto.Unmarshal(bytes, &scResult) |
| | | if err1 != nil { |
| | | logger.Error("getBaseInfo解压错误", err1) |
| | | } |
| | | //logger.Info("----------------------------------------map是", m) |
| | | ids := []string{} |
| | | for key, _ := range m { |
| | | ids = append(ids, key) |
| | | m := make(map[string]*protomsg.SdkCompareEach) |
| | | for _,key := range scResult.CompareResult { |
| | | ids = append(ids, key.Id) |
| | | m[key.Id] = key |
| | | } |
| | | logger.Info("------------------------------------------------------------------------------------------------------------------------") |
| | | //logger.Info("=====================人员id的集合为:",ids) |
| | |
| | | if err != nil || len(table) == 0 { |
| | | logger.Error("根据id查询底库信息出错!", err, "--返回值长度为:", len(table)) |
| | | } |
| | | logger.Debug("看看这个base的对比值是多少:", Decimal(m[baseinfo.Id] * 100)) |
| | | base := BaseInfo{TableId: baseinfo.TableId, TableName: table[0].TableName, BwType: table[0].BwType, CompareScore: Decimal(m[baseinfo.Id] * 100), PersonId: baseinfo.Id, PersonName: baseinfo.PersonName, PersonPicUrl: baseinfo.PersonPicUrl, PhoneNum: baseinfo.PhoneNum, Sex: baseinfo.Sex, IdCard: baseinfo.IdCard, MonitorLevel: baseinfo.MonitorLevel, Content: baseinfo.Reserved} |
| | | logger.Debug("看看这个base的对比值是多少:", Decimal(m[baseinfo.Id].CompareScore)) |
| | | base := BaseInfo{TableId: baseinfo.TableId, TableName: table[0].TableName, BwType: table[0].BwType, CompareScore: Decimal(m[baseinfo.Id].CompareScore), PersonId: baseinfo.Id, PersonName: baseinfo.PersonName, PersonPicUrl: baseinfo.PersonPicUrl, PhoneNum: baseinfo.PhoneNum, Sex: baseinfo.Sex, IdCard: baseinfo.IdCard, MonitorLevel: baseinfo.MonitorLevel, Content: baseinfo.Reserved} |
| | | //os.Exit(1) |
| | | arg.Liker = append(arg.Liker, &base) |
| | | } |
| | |
| | | func Compare(args *SdkDatas, groupRule *protomsg.GroupRule) { |
| | | compareFlag := 0 |
| | | var tableIds []string |
| | | var threshold float32 = 0.5 // 默认阈值为0.5 |
| | | var threshold float32 = 50 // 默认阈值为50 |
| | | // 看看是否有只配人脸比对算法但没有配对比库的规则,如果有,则比对对象为全部底库 |
| | | for j := 0; j < len(groupRule.Rules); j++ { |
| | | if groupRule.Rules[j].SdkId == "812b674b-2375-4589-919a-5c1c3278a972" { // 配了人脸比对 |
| | |
| | | a.filterData = append(a.filterData, &arg1) |
| | | } |
| | | } |
| | | logger.Info("区域是:",areaPoints,"区域内目标数量为:",a.targetNum,"---",len(a.filterData)) |
| | | //logger.Info("区域是:",areaPoints,"区域内目标数量为:",a.targetNum,"---",len(a.filterData)) |
| | | a.time = time.Unix(time.Now().Unix(), 0).String()[11:16] |
| | | a.keepRight = arg.KeepRight |
| | | a.isStatic = arg.IsStatic |