From 168266264d89a7e9f10401178937a7dd15e76de3 Mon Sep 17 00:00:00 2001
From: panlei <2799247126@qq.com>
Date: 星期四, 14 十一月 2019 11:52:56 +0800
Subject: [PATCH] 限制一下score等过滤条件走的次数
---
insertdata/insertDataToEs.go | 122 ++++++++++++++++++++++++++--------------
1 files changed, 80 insertions(+), 42 deletions(-)
diff --git a/insertdata/insertDataToEs.go b/insertdata/insertDataToEs.go
index b273033..77773db 100644
--- a/insertdata/insertDataToEs.go
+++ b/insertdata/insertDataToEs.go
@@ -70,13 +70,48 @@
BaseInfo []*structure.BaseInfo `json:"baseInfo"`
TargetInfo []Target `json:"targetInfo"`
LinkTag string `json:"linkTag"`
- LinkTagInfo []*PerVideoPicture `json:"linkTagInfo"`
+ LinkTagInfo []*LinkInfo `json:"linkTagInfo"`
+}
+
+type LinkInfo struct {
+ Id string `json:"id"`
+ CameraId string `json:"cameraId"`
+ CameraAddr string `json:"cameraAddr"`
+ CameraName string `json:"cameraName"`
+ PicDate string `json:"picDate"`
+ PicMaxUrl string `json:"picMaxUrl"`
+ TaskId string `json:"taskId"`
+ TaskName string `json:"taskName"`
+ SdkName string `json:"sdkName"`
+ Content string `json:"content"`
+ AlarmRules []AlarmRule `json:"alarmRules"`
+ LikeDate string `json:"likeDate"`
+ Sex string `json:"sex"`
+ Age int32 `json:"age"`
+ AgeDescription string `json:"ageDescription"`
+ Race string `json:"race"`
+ SmileLevel int32 `json:"smileLevel"`
+ BeautyLevel int32 `json:"beautyLevel"`
+ FaceFeature string `json:"faceFeature"`
+ PicSmUrl []string `json:"picSmUrl"`
+ VideoUrl string `json:"videoUrl"`
+ AnalyServerId string `json:"analyServerId"`
+ AnalyServerName string `json:"analyServerName"`
+ AnalyServerIp string `json:"analyServerIp"`
+ ClusterId string `json:"clusterId"`
+ DetectScore float64 `json:"detectScore"`
+ IsAlarm int `json:"isAlarm"`
+ IsAckAlarm int `json:"isAckAlarm"`
+ IsCollect int `json:"isCollect"`
+ IsDelete int `json:"isDelete"`
+ BaseInfo []*structure.BaseInfo `json:"baseInfo"`
+ TargetInfo []Target `json:"targetInfo"`
}
type Target struct {
TargetId string `json:"targetId"`
TargetScore float64 `json:"targetScore"`
- TargetLocation Points
+ TargetLocation Points `json:"targetLocation"`
}
type Points struct {
@@ -85,35 +120,35 @@
}
type Point struct {
- Lat float64 `json:"lat"`
- Lon float64 `json:"lon"`
+ X float64 `json:"x"`
+ Y float64 `json:"y"`
}
// yolo琛屼负鐨勬暟鎹粨鏋�
type Personaction struct {
- Id string `json:"id"`
- CameraId string `json:"cameraId"`
- CameraName string `json:"cameraName"`
- CameraAddr string `json:"cameraAddr"`
- TaskId string `json:"taskId"`
- TaskName string `json:"taskName"`
- SdkName string `json:"sdkName"`
- Content string `json:"content"`
- AlarmRules []AlarmRule `json:"alarmRules"`
- AnalyServerId string `json:"analyServerId"`
- AnalyServerName string `json:"analyServerName"`
- AnalyServerIp string `json:"analyServerIp"`
- ClusterId string `json:"clusterId"`
- PicSmUrl []string `json:"picSmUrl"`
- PicDate string `json:"picDate"`
- VideoUrl string `json:"videoUrl"`
- IsAlarm int `json:"isAlarm"`
- IsAckAlarm int `json:"isAckAlarm"`
- IsCollect int `json:"isCollect"`
- IsDelete int `json:"isDelete"`
- TargetInfo []Target `json:"targetInfo"`
- LinkTag string `json:"linkTag"`
- LinkTagInfo []*PerVideoPicture `json:"linkTagInfo"`
+ Id string `json:"id"`
+ CameraId string `json:"cameraId"`
+ CameraName string `json:"cameraName"`
+ CameraAddr string `json:"cameraAddr"`
+ TaskId string `json:"taskId"`
+ TaskName string `json:"taskName"`
+ SdkName string `json:"sdkName"`
+ Content string `json:"content"`
+ AlarmRules []AlarmRule `json:"alarmRules"`
+ AnalyServerId string `json:"analyServerId"`
+ AnalyServerName string `json:"analyServerName"`
+ AnalyServerIp string `json:"analyServerIp"`
+ ClusterId string `json:"clusterId"`
+ PicSmUrl []string `json:"picSmUrl"`
+ PicDate string `json:"picDate"`
+ VideoUrl string `json:"videoUrl"`
+ IsAlarm int `json:"isAlarm"`
+ IsAckAlarm int `json:"isAckAlarm"`
+ IsCollect int `json:"isCollect"`
+ IsDelete int `json:"isDelete"`
+ TargetInfo []Target `json:"targetInfo"`
+ LinkTag string `json:"linkTag"`
+ LinkTagInfo []*LinkInfo `json:"linkTagInfo"`
}
type AlarmRule struct {
@@ -149,7 +184,7 @@
// 寰�es涓彃鍏ヤ汉鑴告暟鎹�
func InsertFace(msg structure.ResultMsg) {
- if msg.RuleResult["face"] != nil && len(msg.RuleResult["face"].([]structure.FaceResult)) > 0 {
+ if msg.RuleResult["face"] != nil && len(msg.RuleResult["face"].([]structure.TargetResult)) > 0 {
logger.Info("寰�ES鎻掍汉鑴告暟鎹�")
faces := []*FaceAndRules{}
faces = PutFace(faces, msg)
@@ -181,7 +216,7 @@
// 涓婁紶澶у浘
if imgMaxUrl == "" {
bigPhotoUrl := make(map[string]interface{})
- bigPhotoUrl, err = util.DrawPolygonOnImageForFace(msg.Cid, i, msg.RuleResult["face"].([]structure.FaceResult), weedfsUrl)
+ bigPhotoUrl, err = util.DrawPolygonOnImageForFace(msg.Cid, i, msg.RuleResult["face"].([]structure.TargetResult), weedfsUrl)
logger.Debug("========澶у浘璺緞锛�", bigPhotoUrl)
imgMaxUrl = bigPhotoUrl["fileUrl"].(string)
picTime = i.Timestamp
@@ -237,7 +272,7 @@
face.Liker,
targetInfos,
"",
- nil,
+ []*LinkInfo{},
}
requstbody, err := json.Marshal(pervideo)
@@ -249,9 +284,9 @@
if err1 != nil {
logger.Error("涓婁紶ES鍑洪敊锛�---", err1)
} else {
- logger.Info("鎻掑叆es杩斿洖鐨勪俊鎭細", resp1)
+ logger.Info("鎻掑叆es杩斿洖鐨勪俊鎭�(浜鸿劯)锛�", resp1)
// 鍙戝嚭褰曞儚淇″彿
- ruleserver.AddLxMessage(&protomsg.VideotapeInfo{EsDataId: msg.Push.PushId, CameraId: msg.Cid, TaskId: msg.Tasklab.Taskid, VideoUrl: msg.Push.VideoUrl, ImgId: i.Id, SdkIds: []string{}, Type: 1})
+ ruleserver.AddLxMessage(&protomsg.VideotapeInfo{EsDataId: face.Uuid, CameraId: msg.Cid, TaskId: msg.Tasklab.Taskid, VideoUrl: msg.Push.VideoUrl, ImgId: i.Id, SdkIds: []string{}, Type: 1})
}
}
}
@@ -260,8 +295,8 @@
// 褰掔疆浜鸿劯
func PutFace(faces []*FaceAndRules, msg structure.ResultMsg) []*FaceAndRules {
- if msg.RuleResult["face"] != nil && len(msg.RuleResult["face"].([]structure.FaceResult)) > 0 {
- for _, faceResult := range msg.RuleResult["face"].([]structure.FaceResult) {
+ if msg.RuleResult["face"] != nil && len(msg.RuleResult["face"].([]structure.TargetResult)) > 0 {
+ for _, faceResult := range msg.RuleResult["face"].([]structure.TargetResult) {
faces = hebingFace(faces, faceResult)
}
return faces
@@ -269,7 +304,7 @@
return nil
}
}
-func hebingFace(faces []*FaceAndRules, faceResult structure.FaceResult) []*FaceAndRules {
+func hebingFace(faces []*FaceAndRules, faceResult structure.TargetResult) []*FaceAndRules {
for _, arg := range faceResult.Args {
// 鎷垮埌姣忎竴寮犱汉鑴�
//logger.Info("褰掔疆浜鸿劯鏃剁浉浼艰�呯殑鏁伴噺锛�", len(arg.Liker))
@@ -376,12 +411,14 @@
}
}
- linkTagInfos := []*PerVideoPicture{}
+ linkTagInfos := []*LinkInfo{}
for _, yoloResult := range msg.RuleResult["yolo"].([]structure.Result) {
if (yoloResult.Others.TimeLabel == "01" || yoloResult.Others.TimeLabel == "10") && yoloResult.Others.LinkCache != nil && len(yoloResult.Others.LinkCache) > 1 {
for _, msg2 := range yoloResult.Others.LinkCache {
// 鎶妋sg2鐨勬暟鎹閰嶆垚涓�涓狿erVideoPicture缁撴瀯浣�
- linkTagInfos = append(linkTagInfos, msg2PersonVideo(msg2))
+ if msg2.Cid != msg.Cid {
+ linkTagInfos = append(linkTagInfos, msg2PersonVideo(msg2))
+ }
}
}
}
@@ -443,6 +480,9 @@
}
requstbody, err := json.Marshal(peraction)
+ if len(linkTagInfos)>0 {
+ logger.Info("鑱斿姩浠诲姟1111")
+ }
if err != nil {
logger.Info("json parse error ", err)
return
@@ -451,7 +491,7 @@
if err2 != nil {
logger.Error("寰�ES鎻掑叆鏁版嵁澶辫触", err)
} else {
- logger.Debug("鎻掑叆es杩斿洖鐨勬暟鎹俊鎭槸锛�", resp1)
+ logger.Debug("鎻掑叆es杩斿洖鐨勬暟鎹俊鎭槸锛坹olo锛夛細", resp1)
// 鍙戝嚭褰曞儚淇″彿
ruleserver.AddLxMessage(&protomsg.VideotapeInfo{EsDataId: msg.Push.PushId, CameraId: msg.Cid, TaskId: msg.Tasklab.Taskid, VideoUrl: msg.Push.VideoUrl, ImgId: i.Id, SdkIds: []string{}, Type: 2})
logger.Warn("__________________________________________寰�ES鎻掑叆yolo鏁版嵁鎴愬姛")
@@ -547,7 +587,7 @@
return race
}
-func msg2PersonVideo(msg structure.ResultMsg) *PerVideoPicture {
+func msg2PersonVideo(msg structure.ResultMsg) *LinkInfo {
if msg.RuleResult["yolo"] != nil && len(msg.RuleResult["yolo"].([]structure.Result)) > 0 {
// 鍏堝垽鏂竴涓嬫暟鎹甫鐨勮鍒欐爣绛炬槸鍚︽湁鍙互鎻掑叆鐨�
flag := false
@@ -645,7 +685,7 @@
if resp["fileUrl"] != nil {
url = append(url, resp["fileUrl"].(string))
//esDataId := uuid.NewV4().String()
- pervideo := &PerVideoPicture{
+ pervideo := &LinkInfo{
msg.Push.PushId + "-" + uuid.NewV4().String(),
msg.Cid,
msg.Push.Cam.Addr,
@@ -678,8 +718,6 @@
0,
nil,
targetInfos,
- "",
- nil,
}
return pervideo
} else {
--
Gitblit v1.8.0