| | |
| | | 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 { |
| | |
| | | |
| | | // 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 { |
| | |
| | | |
| | | // 往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) |
| | |
| | | // 上传大图 |
| | | 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 |
| | |
| | | face.Liker, |
| | | targetInfos, |
| | | "", |
| | | nil, |
| | | []*LinkInfo{}, |
| | | } |
| | | requstbody, err := json.Marshal(pervideo) |
| | | |
| | |
| | | |
| | | // 归置人脸 |
| | | 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 |
| | |
| | | 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)) |
| | |
| | | } |
| | | } |
| | | |
| | | 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 |
| | |
| | | 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 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, |
| | |
| | | 0, |
| | | nil, |
| | | targetInfos, |
| | | "", |
| | | nil, |
| | | } |
| | | return pervideo |
| | | } else { |