| | |
| | | args.RuleResult["yolo"] = []structure.Result{} |
| | | args.RuleResult["face"] = []structure.Result{} |
| | | args.RuleResult["target"] = []structure.Result{} |
| | | args.RuleResult["plate"] = []structure.Result{} |
| | | //logger.Warn("传进去之前是什么德行:",args.RuleResult["yolo"]) |
| | | if taskGroup != nil && len(taskGroup.GroupRules) > 0 { |
| | | // 先过独立,再过联动 |
| | |
| | | if err != nil { |
| | | panic(err) |
| | | } |
| | | f,err1 := p.Lookup("ReadyData") |
| | | f,err1 := p.Lookup("ReadData") |
| | | if err1 != nil { |
| | | panic("没有找到中间件的数据准备函数") |
| | | } |
| | |
| | | |
| | | if result { |
| | | // 最后过持续时间等时间维度的条件 把时间规则位置调整到这个位置是为了缓存数据 !!!!!ps: 对画面中单个目标做定时器的不用再过画面定时器 |
| | | cacheId := "" |
| | | for j := 0; j < len(groupRule.Rules); j++ { |
| | | for _, sdkData := range args.Sdkdata { |
| | | sdk, err := cache.GetSdkById(groupRule.Rules[j].SdkId) |
| | |
| | | if ipcId == sdkData.IpcId { |
| | | for _, areaMap := range sdkData.AreaMapList { |
| | | // 去开启一个定时器 |
| | | cacheid := duration(groupRule.Rules[j], groupRule.GroupId, areaMap, args, message) |
| | | if cacheid != "" { |
| | | cacheId = cacheid |
| | | } |
| | | duration(groupRule.Rules[j], groupRule.GroupId, areaMap, args, message,label) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // 进行定时器的处理和判断 |
| | | timeFlag := TimerAlarm(&label, groupRule.GroupId, result) |
| | | if timeFlag == "01" || timeFlag == "10" || timeFlag == "11" || cacheId != ""{ // 没有定时器或者满足定时器条件 |
| | | if timeFlag == "01" || timeFlag == "10" || timeFlag == "11"{ // 没有定时器或者满足定时器条件 |
| | | // 打人脸标签和yolo标签 |
| | | // 最后成功报警才把符合条件的人脸数据塞进结果标签里 |
| | | // 配了人脸的算法才把人脸的数据甩出来打标签 |
| | |
| | | // 车辆目标统计 |
| | | cars := []*structure.Arg{} |
| | | for _, sdkData := range args.Sdkdata { |
| | | if sdkData.IpcId == "91d923ef-6200-4549-ab1b-8e773e85d729" && sdkNames != "" { // 把yolo数据的各个目标的坐标输出方便后面画框 |
| | | logger.Info("看看sdkNames",sdkNames) |
| | | if sdkData.IpcId == "91d923ef-6200-4549-ab1b-8e773e85d729" { // 把车牌数据的各个目标的坐标输出方便后面画框 |
| | | for _, areaMap := range sdkData.AreaMapList { |
| | | if areaMap.IsEffective { |
| | | cars = append(cars, putYolosToResult(areaMap)...) |
| | | cars = append(cars, putFaceToResult(areaMap, cars)...) |
| | | } |
| | | } |
| | | } |
| | |
| | | //labelTypes = append(labelTypes,2) |
| | | } |
| | | if len(cars) > 0 { |
| | | args.RuleResult["car"] = append(args.RuleResult["car"].([]structure.Result), structure.Result{taskId, sdkNames, groupRule.GroupId, groupRule.DefenceState, groupRule.AlarmLevel, groupRule.GroupText, cars, polygonId, islink,label}) |
| | | logger.Info("-------------------目标持续结果标签", len(args.RuleResult["target"].([]structure.Result))) |
| | | args.RuleResult["plate"] = append(args.RuleResult["plate"].([]structure.Result), structure.Result{taskId, sdkNames, groupRule.GroupId, groupRule.DefenceState, groupRule.AlarmLevel, groupRule.GroupText, cars, polygonId, islink,label}) |
| | | logger.Info("-------------------车牌结果标签", len(args.RuleResult["plate"].([]structure.Result))) |
| | | //labelTypes = append(labelTypes,2) |
| | | } |
| | | // 给持续时间的第一张赋予缓存数据(遍历复制) |
| | | if cacheId != "" { // 有这帧数据的缓存 |
| | | tempMap := make(map[string]interface{}) |
| | | for k, result := range args.RuleResult { |
| | | if k == "yolo" { |
| | | tempMap[k] = []structure.Result{} |
| | | for _, res := range result.([]structure.Result) { |
| | | tempMap[k] = append(tempMap[k].([]structure.Result), res) |
| | | } |
| | | } |
| | | if k == "face" { |
| | | tempMap[k] = []structure.Result{} |
| | | for _, res := range result.([]structure.Result) { |
| | | tempMap[k] = append(tempMap[k].([]structure.Result), res) |
| | | } |
| | | } |
| | | } |
| | | rw.Lock() |
| | | TimeEleList[cacheId].CacheSdkData.RuleResult = tempMap |
| | | rw.Unlock() |
| | | } |
| | | //if cacheId != "" { // 有这帧数据的缓存 |
| | | // tempMap := make(map[string]interface{}) |
| | | // for k, result := range args.RuleResult { |
| | | // if k == "yolo" { |
| | | // tempMap[k] = []structure.Result{} |
| | | // for _, res := range result.([]structure.Result) { |
| | | // tempMap[k] = append(tempMap[k].([]structure.Result), res) |
| | | // } |
| | | // } |
| | | // if k == "face" { |
| | | // tempMap[k] = []structure.Result{} |
| | | // for _, res := range result.([]structure.Result) { |
| | | // tempMap[k] = append(tempMap[k].([]structure.Result), res) |
| | | // } |
| | | // } |
| | | // } |
| | | // rw.Lock() |
| | | // TimeEleList[cacheId].CacheSdkData.RuleResult = tempMap |
| | | // rw.Unlock() |
| | | //} |
| | | |
| | | return true,labelTypes |
| | | } else { |
| | |
| | | } |
| | | |
| | | // 如果有持续时间条件维护开启一个定时器 |
| | | func duration(rule *protomsg.Rule, groupId string, am *structure.AreaMap, args *structure.SdkDatas, message *protomsg.SdkMessage) string{ |
| | | cacheId := "" |
| | | func duration(rule *protomsg.Rule, groupId string, am *structure.AreaMap, args *structure.SdkDatas, message *protomsg.SdkMessage, label structure.Others){ |
| | | // cacheId := "" |
| | | if rule.PolygonId == am.AreaId { // 首先规则所对应的区域id要跟区域数据的id对的上 配置的算法要对的上 |
| | | if rule.SdkId == "812b674b-2375-4589-919a-5c1c3278a977" { // 排除对画面中单个目标的算法,个体静止以及靠右行这种 |
| | | return "" |
| | | return |
| | | } |
| | | if rule.SdkArgAlias == "duration" { |
| | | //logger.Info("当前小规则是:---------", rule) |
| | |
| | | } |
| | | |
| | | if flag { |
| | | //m := make(map[string]interface{}) |
| | | //m["yolo"] = []structure.Result{} |
| | | //m["yolo"] = append(m["yolo"].([]structure.Result), structure.Result{args.TaskId, "", "", true, 0, "", am.FilterData, am.AreaJson, false,*lable}) |
| | | m := make(map[string]interface{}) |
| | | m["yolo"] = []structure.Result{} |
| | | m["yolo"] = append(m["yolo"].([]structure.Result), structure.Result{args.TaskId, "", "", true, 0, "", am.FilterData, am.AreaJson, false,label}) |
| | | timeLength, _ := strconv.Atoi(rule.SdkArgValue) |
| | | timeEle := TimeElement{N: timeLength, InitN: timeLength, AlarmFlag: false, BufferFlag: 10, CacheSdkData: structure.ResultMsg{message, nil}} // 扔进去一个定时器元素(并缓存当前画面帧数据) |
| | | timeEle := TimeElement{N: timeLength, InitN: timeLength, AlarmFlag: false, BufferFlag: 10, CacheSdkData: structure.ResultMsg{message, m}} // 扔进去一个定时器元素(并缓存当前画面帧数据) |
| | | //TimeEleList = make(map[string]timeElement) |
| | | TimeEleList[groupId+"+"+rule.Id] = &timeEle // 定时器元素以当前持续时间小规则id为键 |
| | | logger.Info("创建了计数器") |
| | | cacheId = groupId+"+"+rule.Id |
| | | //cacheId = groupId+"+"+rule.Id |
| | | } |
| | | rw.Unlock() |
| | | } |
| | | } |
| | | return cacheId |
| | | return |
| | | } |
| | | |