From 7d57c67a1c98b9f8c0256b95999c3e801d90b3f4 Mon Sep 17 00:00:00 2001
From: panlei <2799247126@qq.com>
Date: 星期四, 07 十一月 2019 19:30:51 +0800
Subject: [PATCH] ---
---
ruleserver/ruleToformula.go | 53 +++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/ruleserver/ruleToformula.go b/ruleserver/ruleToformula.go
index 5be5d66..d7062ee 100644
--- a/ruleserver/ruleToformula.go
+++ b/ruleserver/ruleToformula.go
@@ -67,6 +67,12 @@
}
}
}
+ // 浜轰綋杩借釜
+ // 濡傛灉鏍囩涓惈鏈夋寔缁椂闂撮娆℃姤璀︾殑timeLabel鐨勮瘽鍒欎笉闇�瑕佽繃浜轰綋杩借釜锛屼笉鐒跺氨娌$殑鎻掑叆浜�
+ fk := TrackOrNot(args.RuleResult)
+ if !fk {
+ BodyIsSame(args,message)
+ }
}
}
}
@@ -207,6 +213,7 @@
if result.(bool) {
// 鏈�鍚庤繃鎸佺画鏃堕棿绛夋椂闂寸淮搴︾殑鏉′欢 鎶婃椂闂磋鍒欎綅缃皟鏁村埌杩欎釜浣嶇疆鏄负浜嗙紦瀛樻暟鎹�
+ cacheId := ""
for j := 0; j < len(groupRule.Rules); j++ {
for _, sdkData := range args.Sdkdata {
sdk, err := cache.GetSdkById(groupRule.Rules[j].SdkId)
@@ -217,14 +224,17 @@
if ipcId == sdkData.IpcId {
for _, areaMap := range sdkData.AreaMapList {
// 鍘诲紑鍚竴涓畾鏃跺櫒
- duration(groupRule.Rules[j], groupRule.GroupId, areaMap, args, message)
+ cacheid := duration(groupRule.Rules[j], groupRule.GroupId, areaMap, args, message)
+ if cacheid != "" {
+ cacheId = cacheid
+ }
}
}
}
}
// 杩涜瀹氭椂鍣ㄧ殑澶勭悊鍜屽垽鏂�
timeFlag := TimerAlarm(&label, groupRule.GroupId, result.(bool))
- if timeFlag == "01" || timeFlag == "10" || timeFlag == "11" { // 娌℃湁瀹氭椂鍣ㄦ垨鑰呮弧瓒冲畾鏃跺櫒鏉′欢
+ if timeFlag == "01" || timeFlag == "10" || timeFlag == "11" || cacheId != ""{ // 娌℃湁瀹氭椂鍣ㄦ垨鑰呮弧瓒冲畾鏃跺櫒鏉′欢
// 鎵撲汉鑴告爣绛惧拰yolo鏍囩
// 鏈�鍚庢垚鍔熸姤璀︽墠鎶婄鍚堟潯浠剁殑浜鸿劯鏁版嵁濉炶繘缁撴灉鏍囩閲�
// 閰嶄簡浜鸿劯鐨勭畻娉曟墠鎶婁汉鑴哥殑鏁版嵁鐢╁嚭鏉ユ墦鏍囩
@@ -254,7 +264,9 @@
for _, sdkData := range args.Sdkdata {
if sdkData.IpcId == "02D54B61-0F16-C604-8567-FC4BE493C523" && sdkNames != "" { // 鎶妝olo鏁版嵁鐨勫悇涓洰鏍囩殑鍧愭爣杈撳嚭鏂逛究鍚庨潰鐢绘
for _, areaMap := range sdkData.AreaMapList {
- locations = append(locations, putYolosToResult(areaMap)...)
+ if areaMap.IsEffective {
+ locations = append(locations, putYolosToResult(areaMap)...)
+ }
}
}
}
@@ -276,6 +288,28 @@
//logger.Info("-------------------face缁撴灉鏍囩", len(args.RuleResult["face"].([]FaceResult)))
labelTypes = append(labelTypes,1)
}
+ // 缁欐寔缁椂闂寸殑绗竴寮犺祴浜堢紦瀛樻暟鎹紙閬嶅巻澶嶅埗锛�
+ 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.FaceResult{}
+ for _, res := range result.([]structure.FaceResult) {
+ tempMap[k] = append(tempMap[k].([]structure.FaceResult), res)
+ }
+ }
+ }
+ rw.Lock()
+ TimeEleList[cacheId].CacheSdkData.RuleResult = tempMap
+ rw.Unlock()
+ }
+
return true,labelTypes
} else {
return false,[]int{}
@@ -565,6 +599,7 @@
// 澶勭悊鐨勯兘鏄痽olo鏁版嵁
if rule.PolygonId == am.AreaId { // 棣栧厛杩欐潯瑙勫垯寰楁槸杩欎釜绠楁硶鐨勮鍒欙紝鍏舵瑙勫垯鎵�瀵瑰簲鐨勫尯鍩焛d瑕佽窡鍖哄煙鏁版嵁鐨刬d瀵圭殑涓�
if rule.SdkArgAlias == "score" || rule.SdkArgAlias == "proportion" || rule.SdkArgAlias == "size" { // 鍒ゆ柇鐨勬槸鐩镐技鍊硷紝鍗犳瘮锛屽昂瀵哥瓑杩囨护鏉′欢锛屽鏋滃啀鏈夛紝杩樺彲浠ュ啀鍔�
+ logger.Info("鍖哄煙鏁版嵁锛�",am.AreaJson)
var args []*structure.Arg
if rule.RuleWithPre == "&&" {
args = am.FilterData
@@ -593,6 +628,9 @@
}
}
am.TargetNum = len(am.FilterData) // 鎶婄鍚堟潯浠剁殑鐩爣鏁伴噺鏇存柊鍒皌argetNum瀛楁
+ for _,tar := range am.FilterData {
+ logger.Info("鍏蜂綋鐩爣鐨勫潗鏍囦负",tar.Id,tar.Location)
+ }
if am.TargetNum > 0 {
return structure.LittleRuleResult{am.SdkName, rule.RuleWithPre + "" + "true", rule.Sort}
} else {
@@ -612,7 +650,8 @@
}
// 濡傛灉鏈夋寔缁椂闂存潯浠剁淮鎶ゅ紑鍚竴涓畾鏃跺櫒
-func duration(rule *protomsg.Rule, groupId string, am *structure.AreaMap, args *structure.SdkDatas, message *protomsg.SdkMessage) {
+func duration(rule *protomsg.Rule, groupId string, am *structure.AreaMap, args *structure.SdkDatas, message *protomsg.SdkMessage) string{
+ cacheId := ""
if rule.PolygonId == am.AreaId { // 棣栧厛瑙勫垯鎵�瀵瑰簲鐨勫尯鍩焛d瑕佽窡鍖哄煙鏁版嵁鐨刬d瀵圭殑涓� 閰嶇疆鐨勭畻娉曡瀵圭殑涓�
if rule.SdkArgAlias == "duration" { //
//logger.Info("褰撳墠灏忚鍒欐槸锛�---------", rule)
@@ -628,14 +667,16 @@
if flag {
timeLength, _ := strconv.Atoi(rule.SdkArgValue)
- timeEle := TimeElement{N: timeLength, InitN: timeLength, AlarmFlag: false, BufferFlag: 10, CacheSdkData: structure.ResultMsg{message, args.RuleResult}} // 鎵旇繘鍘讳竴涓畾鏃跺櫒鍏冪礌锛堝苟缂撳瓨褰撳墠鐢婚潰甯ф暟鎹級
+ timeEle := TimeElement{N: timeLength, InitN: timeLength, AlarmFlag: false, BufferFlag: 10, CacheSdkData: structure.ResultMsg{message, nil}} // 鎵旇繘鍘讳竴涓畾鏃跺櫒鍏冪礌锛堝苟缂撳瓨褰撳墠鐢婚潰甯ф暟鎹級
//TimeEleList = make(map[string]timeElement)
TimeEleList[groupId+"+"+rule.Id] = &timeEle // 瀹氭椂鍣ㄥ厓绱犱互褰撳墠鎸佺画鏃堕棿灏忚鍒檌d涓洪敭
- //logger.Info("鍒涘缓浜嗚鏁板櫒")
+ logger.Info("鍒涘缓浜嗚鏁板櫒")
+ cacheId = groupId+"+"+rule.Id
}
rw.Unlock()
}
}
+ return cacheId
}
// 缁欐暟鎹簱鐨勮鍒欒〃杈惧紡浠e弬 args: 涓�鏉″瓙瑙勫垯锛屽尯鍩熸暟鎹�
--
Gitblit v1.8.0