| | |
| | | IsCollect int `json:"isCollect"` |
| | | IsDelete int `json:"isDelete"` |
| | | BaseInfo []*structure.BaseInfo `json:"baseInfo"` |
| | | TargetInfo []Target |
| | | LinkTag string `json:"linkTag"` |
| | | LinkTagInfo []*PerVideoPicture `json:"linkTagInfo"` |
| | | TargetInfo []Target `json:"targetInfo"` |
| | | LinkTag string `json:"linkTag"` |
| | | 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 { |
| | |
| | | } |
| | | |
| | | type Point struct { |
| | | Lat float64 `json:"lat"` |
| | | Lon float64 `json:"lon"` |
| | | X float64 `json:"x"` |
| | | Y float64 `json:"y"` |
| | | } |
| | | |
| | | // yolo行为的数据结构 |
| | |
| | | IsAckAlarm int `json:"isAckAlarm"` |
| | | IsCollect int `json:"isCollect"` |
| | | IsDelete int `json:"isDelete"` |
| | | TargetInfo []Target |
| | | LinkTag string `json:"linkTag"` |
| | | LinkTagInfo []*PerVideoPicture `json:"linkTagInfo"` |
| | | TargetInfo []Target `json:"targetInfo"` |
| | | LinkTag string `json:"linkTag"` |
| | | LinkTagInfo []*LinkInfo `json:"linkTagInfo"` |
| | | } |
| | | |
| | | type AlarmRule struct { |
| | |
| | | |
| | | // 往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.Result)) > 0 { |
| | | logger.Info("往ES插人脸数据") |
| | | faces := []*FaceAndRules{} |
| | | faces = PutFace(faces, msg) |
| | |
| | | // 上传大图 |
| | | 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.Result), weedfsUrl) |
| | | logger.Debug("========大图路径:", bigPhotoUrl) |
| | | imgMaxUrl = bigPhotoUrl["fileUrl"].(string) |
| | | picTime = i.Timestamp |
| | |
| | | target.TargetLocation = Points{TopLeft: Point{face.Location.X, face.Location.Y}, BottomRight: Point{face.Location.X + face.Location.Width, face.Location.Y + face.Location.Height}} |
| | | //logger.Info("人脸的id:",strconv.FormatUint(face.Id, 10)) |
| | | var targetInfos []Target |
| | | targetInfos = append(targetInfos,*target) |
| | | targetInfos = append(targetInfos, *target) |
| | | pervideo := PerVideoPicture{ |
| | | face.Uuid, |
| | | msg.Cid, |
| | |
| | | face.Liker, |
| | | targetInfos, |
| | | "", |
| | | nil, |
| | | []*LinkInfo{}, |
| | | } |
| | | requstbody, err := json.Marshal(pervideo) |
| | | |
| | |
| | | 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}) |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | // 归置人脸 |
| | | 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.Result)) > 0 { |
| | | for _, faceResult := range msg.RuleResult["face"].([]structure.Result) { |
| | | faces = hebingFace(faces, faceResult) |
| | | } |
| | | return faces |
| | |
| | | return nil |
| | | } |
| | | } |
| | | func hebingFace(faces []*FaceAndRules, faceResult structure.FaceResult) []*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 |
| | |
| | | //} |
| | | 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 |
| | |
| | | } |
| | | } |
| | | if !flag { |
| | | faces = append(faces, &FaceAndRules{arg, []structure.Result{faceResult.Result}}) |
| | | faces = append(faces, &FaceAndRules{*arg, []structure.Result{faceResult}}) |
| | | } |
| | | } |
| | | return faces |
| | |
| | | } |
| | | } |
| | | // 装配目标信息数据 |
| | | 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) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | 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 { |
| | | // 把msg2的数据装配成一个PerVideoPicture结构体 |
| | | linkTagInfos = append(linkTagInfos,msg2PersonVideo(msg2)) |
| | | if msg2.Cid != msg.Cid { |
| | | linkTagInfos = append(linkTagInfos, msg2PersonVideo(msg2)) |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | requstbody, err := json.Marshal(peraction) |
| | | |
| | | if len(linkTagInfos)>0 { |
| | | logger.Info("联动任务1111") |
| | | } |
| | | if err != nil { |
| | | logger.Info("json parse error ", err) |
| | | return |
| | |
| | | if err2 != nil { |
| | | logger.Error("往ES插入数据失败", err) |
| | | } else { |
| | | logger.Debug("插入es返回的数据信息是:", resp1) |
| | | 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) |
| | | } |
| | |
| | | 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 |
| | |
| | | if yoloResult.IsLink { |
| | | linkInfo = "联动任务" |
| | | } |
| | | alarmRules = append(alarmRules, AlarmRule{yoloResult.RuleGroupId, alarm, yoloResult.RuleText, yoloResult.DefenceState,linkInfo}) |
| | | alarmRules = append(alarmRules, AlarmRule{yoloResult.RuleGroupId, alarm, yoloResult.RuleText, yoloResult.DefenceState, linkInfo}) |
| | | // 上传缓存数据的图片拿到url |
| | | if yoloResult.Others.CacheData != nil { |
| | | //InsertYolo(msg.RuleResult["cacheData"].(ruleserver.ResultMsg)) |
| | |
| | | } |
| | | } |
| | | // 装配目标信息数据 |
| | | 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) |
| | | } |
| | | } |
| | |
| | | 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, |
| | |
| | | "", |
| | | alarmRules, |
| | | time.Now().Format("2006-01-02 15:04:05"), // 只检测,没有比对时间 |
| | | "", //暂改为人脸id strconv.FormatUint(face.Id, 10) |
| | | "", //暂改为人脸id strconv.FormatUint(face.Id, 10) |
| | | 0, |
| | | "", // 暂改为分值fmt.Sprintf("%.2f",face.Score) |
| | | "", |
| | |
| | | 0, |
| | | nil, |
| | | targetInfos, |
| | | "", |
| | | nil, |
| | | } |
| | | return pervideo |
| | | } else { |
| | |
| | | } else { |
| | | return nil |
| | | } |
| | | } |
| | | } |