panlei
2019-11-14 47565f95077f6fe38eb7fe6dbc3b150c7a66b287
insertdata/insertDataToEs.go
@@ -184,7 +184,7 @@
// 往es中插入人脸数据
func InsertFace(msg structure.ResultMsg) {
   if msg.RuleResult["face"] != nil && len(msg.RuleResult["face"].([]structure.TargetResult)) > 0 {
   if msg.RuleResult["face"] != nil && len(msg.RuleResult["face"].([]structure.Result)) > 0 {
      logger.Info("往ES插人脸数据")
      faces := []*FaceAndRules{}
      faces = PutFace(faces, msg)
@@ -216,7 +216,7 @@
            // 上传大图
            if imgMaxUrl == "" {
               bigPhotoUrl := make(map[string]interface{})
               bigPhotoUrl, err = util.DrawPolygonOnImageForFace(msg.Cid, i, msg.RuleResult["face"].([]structure.TargetResult), weedfsUrl)
               bigPhotoUrl, err = util.DrawPolygonOnImageForFace(msg.Cid, i, msg.RuleResult["face"].([]structure.Result), weedfsUrl)
               logger.Debug("========大图路径:", bigPhotoUrl)
               imgMaxUrl = bigPhotoUrl["fileUrl"].(string)
               picTime = i.Timestamp
@@ -295,8 +295,8 @@
// 归置人脸
func PutFace(faces []*FaceAndRules, msg structure.ResultMsg) []*FaceAndRules {
   if msg.RuleResult["face"] != nil && len(msg.RuleResult["face"].([]structure.TargetResult)) > 0 {
      for _, faceResult := range msg.RuleResult["face"].([]structure.TargetResult) {
   if msg.RuleResult["face"] != nil && len(msg.RuleResult["face"].([]structure.Result)) > 0 {
      for _, faceResult := range msg.RuleResult["face"].([]structure.Result) {
         faces = hebingFace(faces, faceResult)
      }
      return faces
@@ -304,8 +304,8 @@
      return nil
   }
}
func hebingFace(faces []*FaceAndRules, faceResult structure.TargetResult) []*FaceAndRules {
   for _, arg := range faceResult.Args {
func hebingFace(faces []*FaceAndRules, faceResult structure.Result) []*FaceAndRules {
   for _, arg := range faceResult.AlarmObj {
      // 拿到每一张人脸
      //logger.Info("归置人脸时相似者的数量:", len(arg.Liker))
      flag := false
@@ -315,7 +315,7 @@
         //}
         if arg.Id == face.Id {
            flag = true
            face.rules = append(face.rules, faceResult.Result)
            face.rules = append(face.rules, faceResult)
            // 相似者去重归并
            for _, liker := range arg.Liker {
               flag1 := true
@@ -332,7 +332,7 @@
         }
      }
      if !flag {
         faces = append(faces, &FaceAndRules{arg, []structure.Result{faceResult.Result}})
         faces = append(faces, &FaceAndRules{*arg, []structure.Result{faceResult}})
      }
   }
   return faces
@@ -391,20 +391,20 @@
                  }
               }
               // 装配目标信息数据
               for _, target := range yoloResult.Location {
               for _, target := range yoloResult.AlarmObj {
                  // 去重添加
                  var flag = true
                  for _, selectTarget := range targetInfos {
                     if strconv.FormatUint(target.TargetId, 10) == selectTarget.TargetId {
                     if strconv.FormatUint(target.Id, 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}}
                     target1.TargetId = strconv.FormatUint(target.Id, 10)
                     target1.TargetScore = target.Score
                     target1.TargetLocation = Points{TopLeft: Point{target.Location.X, target.Location.Y}, BottomRight: Point{target.Location.X + target.Location.Width, target.Location.Y + target.Location.Height}}
                     targetInfos = append(targetInfos, *target1)
                  }
               }
@@ -493,7 +493,11 @@
            } else {
               logger.Debug("插入es返回的数据信息是(yolo):", 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})
               ruleserver.AddLxMessage(&protomsg.VideotapeInfo{EsDataId: msg.Push.PushId, CameraId: msg.Cid, TaskId: msg.Tasklab.Taskid, VideoUrl: msg.Push.VideoUrl, ImgId: i.Id, SdkIds: []string{"-1"}, Type: 2})
               for index,link := range linkTagInfos {
                  logger.Info("联动任务的录像信号:",index)
                  ruleserver.AddLxMessage(&protomsg.VideotapeInfo{EsDataId: msg.Push.PushId, CameraId: link.CameraId, TaskId: msg.Tasklab.Taskid, VideoUrl: msg.Push.VideoUrl, ImgId: i.Id, SdkIds: []string{strconv.Itoa(index)}, Type: 2})
               }
               logger.Warn("__________________________________________往ES插入yolo数据成功")
               //os.Exit(1)
            }
@@ -639,20 +643,20 @@
                  }
               }
               // 装配目标信息数据
               for _, target := range yoloResult.Location {
               for _, target := range yoloResult.AlarmObj {
                  // 去重添加
                  var flag = true
                  for _, selectTarget := range targetInfos {
                     if strconv.FormatUint(target.TargetId, 10) == selectTarget.TargetId {
                     if strconv.FormatUint(target.Id, 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}}
                     target1.TargetId = strconv.FormatUint(target.Id, 10)
                     target1.TargetScore = target.Score
                     target1.TargetLocation = Points{TopLeft: Point{target.Location.X, target.Location.Y}, BottomRight: Point{target.Location.X + target.Location.Width, target.Location.Y + target.Location.Height}}
                     targetInfos = append(targetInfos, *target1)
                  }
               }