From d69768180b26730ee88d978608031ed6386f3580 Mon Sep 17 00:00:00 2001 From: panlei <2799247126@qq.com> Date: 星期二, 05 十一月 2019 19:30:18 +0800 Subject: [PATCH] --- --- insertdata/insertDataToEs.go | 96 +++++++++++++++++++++--------------------------- 1 files changed, 42 insertions(+), 54 deletions(-) diff --git a/insertdata/insertDataToEs.go b/insertdata/insertDataToEs.go index 0b56736..3343ed8 100644 --- a/insertdata/insertDataToEs.go +++ b/insertdata/insertDataToEs.go @@ -109,6 +109,7 @@ IsAckAlarm int `json:"isAckAlarm"` IsCollect int `json:"isCollect"` IsDelete int `json:"isDelete"` + TargetInfo []Target } type AlarmRule struct { @@ -164,20 +165,7 @@ videoPersonUrl = "http://" + localConfig1.AlarmIp + ":" + strconv.Itoa(int(localConfig1.AlarmPort)) + "/" + EsInfo.EsIndex.VideoPersons.IndexName + "/" + EsInfo.EsIndex.VideoPersons.IndexType personAction = "http://" + localConfig1.AlarmIp + ":" + strconv.Itoa(int(localConfig1.AlarmPort)) + "/" + EsInfo.EsIndex.Personaction.IndexName + "/" + EsInfo.EsIndex.Personaction.IndexType InsertFace(msg, "") - // 濡傛灉鏍囩涓惈鏈夋寔缁椂闂撮娆℃姤璀︾殑timeLabel鐨勮瘽鍒欎笉闇�瑕佽繃浜轰綋杩借釜锛屼笉鐒跺氨娌$殑鎻掑叆浜� - fk := ruleserver.TrackOrNot(msg.RuleResult) - if fk { - InsertYolo(msg, "") - //if msg.Cid == "61de081a-7ed9-4970-8432-41d642c35456" { - // logger.Warn("鎹曟崏188鎽勫儚鏈虹殑鎸佺画鏃堕棿浠诲姟.....") - // os.Exit(1) - //} - } else { - flag := ruleserver.BodyIsSame(msg.SdkMessage) - if !flag { - InsertYolo(msg, "") - } - } + InsertYolo(msg, "") } // 寰�es涓彃鍏ヤ汉鑴告暟鎹� @@ -206,6 +194,13 @@ } i := protomsg.Image{} err = proto.Unmarshal(bdata, &i) + // 鍏堜紶灏忓浘锛屽啀浼犲ぇ鍥撅紝闃叉鑴镐笂鏈夌嚎 + bytes := util.SubImg(i, int(face.Location.X), int(face.Location.Y), int(face.Location.X+face.Location.Width), int(face.Location.Y+face.Location.Height)) + resp, err := util.PostFormBufferData1(weedfsUrl, bytes, uuid.NewV4().String()) + if err != nil { + logger.Error("涓婁紶灏忓浘鍑洪敊") + } + // 涓婁紶澶у浘 if imgMaxUrl == "" { bigPhotoUrl := make(map[string]interface{}) bigPhotoUrl, err = util.DrawPolygonOnImageForFace(msg.Cid, i, msg.RuleResult["face"].([]structure.FaceResult), weedfsUrl) @@ -213,23 +208,6 @@ imgMaxUrl = bigPhotoUrl["fileUrl"].(string) picTime = i.Timestamp } - // 浜鸿劯妫�娴嬶紝娌℃湁鐩镐技鐨勫簳搴撲汉鍛� - localConfig, err := cache.GetServerInfo() - if err != nil { - logger.Error("鏌ヨ鏈満淇℃伅澶辫触锛�") - } - serverIp, err := GetLocalIP() - // 鏌ヨcameraName - camera, err := cache.GetCameraById(msg.Cid) - if err != nil { - logger.Error("鏌ヨ鎽勫儚鏈轰俊鎭け璐�") - } - bytes := util.SubImg(i, int(face.Location.X), int(face.Location.Y), int(face.Location.X+face.Location.Width), int(face.Location.Y+face.Location.Height)) - resp, err := util.PostFormBufferData1(weedfsUrl, bytes, uuid.NewV4().String()) - if err != nil { - logger.Error("涓婁紶灏忓浘鍑洪敊") - } - //logger.Info("================灏忓浘鍦板潃:", resp["fileUrl"].(string)) sex := "" logger.Info(sex) if face.ThftRes.Gender == 1 { @@ -254,7 +232,7 @@ pervideo := PerVideoPicture{ esDataId, msg.Cid, - camera.Addr, + msg.Push.Cam.Addr, picTime, imgMaxUrl, msg.Tasklab.Taskid, @@ -272,9 +250,9 @@ base64.StdEncoding.EncodeToString(face.Feature), []string{resp["fileUrl"].(string)}, "鏆傛棤闆嗙兢", - localConfig.ServerId, - localConfig.ServerName, - serverIp, + msg.Push.ServerId, + msg.Push.ServerName, + msg.Push.LocalIp, "", linksId, face.Score, @@ -297,7 +275,7 @@ } else { logger.Info("鎻掑叆es杩斿洖鐨勪俊鎭細", resp1) // 鍙戝嚭褰曞儚淇″彿 - ruleserver.AddLxMessage(&protomsg.VideotapeInfo{EsDataId: esDataId, CameraId: msg.Cid, TaskId: msg.Tasklab.Taskid, ImgId: i.Id, SdkIds: []string{}, Type: 1}) + ruleserver.AddLxMessage(&protomsg.VideotapeInfo{EsDataId: esDataId, CameraId: msg.Cid, TaskId: msg.Tasklab.Taskid, VideoUrl:msg.Push.VideoUrl,ImgId: i.Id, SdkIds: []string{}, Type: 1}) } } } @@ -364,6 +342,7 @@ logger.Info("寰�ES鎻抷olo鏁版嵁") var sdkNames string = "" alarmRules := []AlarmRule{} + var targetInfos []Target url := []string{} for _, yoloResult := range msg.RuleResult["yolo"].([]structure.Result) { if yoloResult.Others.TimeLabel == "01" || yoloResult.Others.TimeLabel == "10" { @@ -398,6 +377,25 @@ if resp1["fileUrl"] != nil { url = append(url, resp1["fileUrl"].(string)) } + } + } + // 瑁呴厤鐩爣淇℃伅鏁版嵁 + for _,target := range yoloResult.Location { + // 鍘婚噸娣诲姞 + logger.Info("瑁呴厤鍓嶇殑鍘熷鏁版嵁鏄細",target) + var flag = true + for _,selectTarget := range targetInfos { + if strconv.FormatUint(target.TargetId, 10) == selectTarget.TargetId { + flag = false + break + } + } + if flag { + var target1 = new(Target) + target1.TargetId = strconv.FormatUint(target.TargetId, 10) + target1.TargetScore = target.TargetScore + target1.TargetLocation = Points{TopLeft:Point{target.X,target.Y},BottomRight:Point{target.X+target.Width,target.Y+target.Height}} + targetInfos = append(targetInfos,*target1) } } } @@ -444,18 +442,7 @@ // 涓嶆槸鎶ヨ鏁版嵁涓嶅瓨 return } - // logger.Println("鍥剧墖涓婁紶杩斿洖鍊硷細", resp) - // 鏌ヨ鏈満淇℃伅 - localConfig, err := cache.GetServerInfo() - if err != nil { - logger.Error("鏌ヨ鏈満淇℃伅澶辫触锛�") - } - // 鏌ヨcameraName - camera, err := cache.GetCameraById(msg.Cid) - if err != nil { - logger.Error("鏌ヨ鎽勫儚鏈轰俊鎭け璐�") - } - serverIp, err := GetLocalIP() + if resp["fileUrl"] != nil { url = append(url, resp["fileUrl"].(string)) esDataId := uuid.NewV4().String() @@ -466,16 +453,16 @@ peraction := Personaction{ esDataId, msg.Cid, - camera.Name, - camera.Addr, + msg.Push.Cam.Name, + msg.Push.Cam.Addr, msg.Tasklab.Taskid, msg.Tasklab.Taskname, sdkNames, "", alarmRules, - localConfig.ServerId, - localConfig.ServerName, - serverIp, + msg.Push.ServerId, + msg.Push.ServerName, + msg.Push.LocalIp, "", url, i.Timestamp, @@ -485,6 +472,7 @@ 0, 0, 0, + targetInfos, } requstbody, err := json.Marshal(peraction) @@ -499,7 +487,7 @@ } else { logger.Debug("鎻掑叆es杩斿洖鐨勬暟鎹俊鎭槸锛�", resp1) // 鍙戝嚭褰曞儚淇″彿 - ruleserver.AddLxMessage(&protomsg.VideotapeInfo{EsDataId: esDataId, CameraId: msg.Cid, TaskId: msg.Tasklab.Taskid, ImgId: i.Id, SdkIds: []string{}, Type: 2}) + ruleserver.AddLxMessage(&protomsg.VideotapeInfo{EsDataId: esDataId, CameraId: msg.Cid, TaskId: msg.Tasklab.Taskid,VideoUrl:msg.Push.VideoUrl, ImgId: i.Id, SdkIds: []string{}, Type: 2}) logger.Warn("__________________________________________寰�ES鎻掑叆yolo鏁版嵁鎴愬姛") //os.Exit(1) } -- Gitblit v1.8.0