From 75394c1f3c7d34ee6b3639a69efb5e0837065b27 Mon Sep 17 00:00:00 2001 From: panlei <2799247126@qq.com> Date: 星期四, 01 八月 2019 12:40:39 +0800 Subject: [PATCH] --- --- ruleserver/ruleToformula.go | 56 +++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 43 insertions(+), 13 deletions(-) diff --git a/ruleserver/ruleToformula.go b/ruleserver/ruleToformula.go index a691282..db342db 100644 --- a/ruleserver/ruleToformula.go +++ b/ruleserver/ruleToformula.go @@ -88,9 +88,13 @@ RuleText string // 鏂囧瓧鐗堣鍒欑粍 Location []Rect // 鐩爣鐨勫潗鏍� AlarmPolygon string // 瑙﹀彂鐨勬姤璀︽ - Others map[string]interface{} // cacheData: []ResultMsg,(鏈粍瑙勫垯涓惈鏈夋寔缁椂闂寸殑瑙勫垯寮�鍚殑瀹氭椂鍣ㄧ紦瀛樼殑鏁版嵁甯�)锛宭inkCache: []ResultMsg 锛宼imeLabel: 00,01,10,11,12 + Others } - +type Others struct { + CacheData []ResultMsg //(鏈粍瑙勫垯涓惈鏈夋寔缁椂闂寸殑瑙勫垯寮�鍚殑瀹氭椂鍣ㄧ紦瀛樼殑鏁版嵁甯�) + LinkCache []ResultMsg + TimeLabel string +} // 杩囪鍒欏簱鎵撲笂鐨勬爣绛� type FaceResult struct { Result @@ -127,7 +131,7 @@ taskId := taskGroup.TaskId //logger.Println("------------鏈粍浠诲姟涓嬬殑瑙勫垯缁勭殑鏁伴噺锛�",len(ruleList)) temp := group.Rules // temp涓轰竴缁勫畬鏁磋鍒� 鍦ㄦ闇�瑕佸垽鏂鍒欐槸鍚︽槸鑱斿姩瑙勫垯 - label := make(map[string]interface{}) + label := Others{} if len(temp) > 0 { if group.SetType != "linkTask" { // 鐙珛浠诲姟鐨勫鐞� @@ -140,7 +144,7 @@ taskId := taskGroup.TaskId //logger.Println("------------鏈粍浠诲姟涓嬬殑瑙勫垯缁勭殑鏁伴噺锛�",len(ruleList)) temp := group.Rules // temp涓轰竴缁勫畬鏁磋鍒� 鍦ㄦ闇�瑕佸垽鏂鍒欐槸鍚︽槸鑱斿姩瑙勫垯 - label := make(map[string]interface{}) + label := Others{} if len(temp) > 0 { if group.SetType == "linkTask" { // groupId涓惈鏈塴ink鍒欎负鑱斿姩浠诲姟 @@ -152,7 +156,7 @@ } } -func RunRule(args *SdkDatas, groupRule *protomsg.GroupRule, taskId string, message *protomsg.SdkMessage,label map[string]interface{}) bool { +func RunRule(args *SdkDatas, groupRule *protomsg.GroupRule, taskId string, message *protomsg.SdkMessage,label Others) bool { defer func() { if err := recover(); err != nil { logger.Error("姣斿瑙勫垯鏈夎", err.(string)) @@ -296,8 +300,8 @@ } } // 杩涜瀹氭椂鍣ㄧ殑澶勭悊鍜屽垽鏂� - timeFlag := TimerAlarm(label, groupRule.GroupId, result.(bool)) - if timeFlag == "01" || timeFlag == "10" || timeFlag == "11" { // 婊¤冻瀹氭椂鍣ㄦ潯浠� + timeFlag := TimerAlarm(&label, groupRule.GroupId, result.(bool)) + if timeFlag == "01" || timeFlag == "10" || timeFlag == "11" { // 娌℃湁瀹氭椂鍣ㄦ垨鑰呮弧瓒冲畾鏃跺櫒鏉′欢 // 鎵撲汉鑴告爣绛惧拰yolo鏍囩 // 鏈�鍚庢垚鍔熸姤璀︽墠鎶婄鍚堟潯浠剁殑浜鸿劯鏁版嵁濉炶繘缁撴灉鏍囩閲� // 閰嶄簡浜鸿劯鐨勭畻娉曟墠鎶婁汉鑴哥殑鏁版嵁鐢╁嚭鏉ユ墦鏍囩 @@ -385,7 +389,7 @@ } // 鑱斿姩浠诲姟鐨勫鐞� -func LinkTask(args *SdkDatas, groupRule *protomsg.GroupRule, taskId string, message *protomsg.SdkMessage,label map[string]interface{}) { +func LinkTask(args *SdkDatas, groupRule *protomsg.GroupRule, taskId string, message *protomsg.SdkMessage,label Others) { // new涓�涓畾鏃跺櫒锛屽鏋滀互姝roupId涓烘爣蹇楃殑瀹氭椂鍣ㄤ笉瀛樺湪鐨勮瘽 logger.Info("------------------------------------------褰撳墠鏄仈鍔ㄤ换鍔★紝瑙勫垯鏄細", groupRule.GroupText) var flag bool = true @@ -423,7 +427,24 @@ for _, va := range timeEle.RuleResults { if va.CameraId == args.CameraId { va.Result = strconv.FormatBool(isOk) - //va.CacheData = ResultMsg{message,args.RuleResult} + tempMap := make(map[string]interface{}) + for k,result := range args.RuleResult { + if k == "yolo" { + for _,res := range result.([]Result) { + tempMap[k] = append(tempMap[k].([]Result),res) + } + } + if k == "face" { + for _,res := range result.([]FaceResult) { + tempMap[k] = append(tempMap[k].([]FaceResult),res) + } + } + tempMap[k] = result + } + for _,result := range args.RuleResult["yolo"].([]Result) { + logger.Warn("鏀捐繘鑱斿姩缂撳瓨鐨勯暱搴︽槸",len(result.LinkCache)) + } + va.CacheData = ResultMsg{message,tempMap} logger.Info("杩欎釜鎽勫儚鏈�--", args.CameraId, "--琚祴浜堜簡result", va.Result) } } @@ -451,12 +472,21 @@ if result.(bool) { logger.Info("___________________________________________________________________鑱斿姩浠诲姟鎶ヨ") // 鎶婃暟缁勯噷缂撳瓨鐨勬暟鎹彇鍑烘潵涓�璧锋姤璀� - label["linkCache"] = []ResultMsg{} + label.LinkCache = []ResultMsg{} for _, ruleRes := range TimeEleList[groupRule.GroupId].RuleResults { - label["linkCache"] = append(label["linkCache"].([]ResultMsg),ruleRes.CacheData) + label.LinkCache = append(label.LinkCache,ruleRes.CacheData) } - logger.Debug("鑱斿姩浠诲姟缂撳瓨浜嗗嚑涓暟鎹�",len(label["linkCache"].([]ResultMsg))) - //os.Exit(1) + logger.Debug("鑱斿姩浠诲姟缂撳瓨浜嗗嚑涓暟鎹�",len(label.LinkCache)) + //for _,result := range args.RuleResult["yolo"].([]Result) { + // if result.RuleGroupId == groupRule.GroupId { + // result.Others["linkCache"] = label + // } + //} + for i := 0; i < len(args.RuleResult["yolo"].([]Result)); i++ { + if args.RuleResult["yolo"].([]Result)[i].RuleGroupId == groupRule.GroupId { // 鎶婂師鏉ラ偅涓垹鎺夊啀瀛樹竴浠芥柊鐨� + args.RuleResult["yolo"].([]Result)[i].Others.LinkCache = label.LinkCache + } + } } } } else { -- Gitblit v1.8.0