| | |
| | | IsAckAlarm int `json:"isAckAlarm"` |
| | | IsCollect int `json:"isCollect"` |
| | | IsDelete int `json:"isDelete"` |
| | | BaseInfo []*ruleserver.BaseInfo `json:"baseInfo"` |
| | | BaseInfo []*structure.BaseInfo `json:"baseInfo"` |
| | | } |
| | | |
| | | // yolo行为的数据结构 |
| | |
| | | |
| | | // 一个face对多个规则组的归置人脸的结构体 |
| | | type FaceAndRules struct { |
| | | ruleserver.Arg |
| | | rules []ruleserver.Result |
| | | structure.Arg |
| | | rules []structure.Result |
| | | } |
| | | |
| | | // 往ES插数据 |
| | |
| | | // // ChangeStatusYolo(msg) |
| | | // //} |
| | | //} |
| | | func InsertToEs(msg ruleserver.ResultMsg) { |
| | | func InsertToEs(msg structure.ResultMsg) { |
| | | InsertFace(msg, "") |
| | | // 如果标签中含有持续时间首次报警的timeLabel的话则不需要过人体追踪,不然就没的插入了 |
| | | fk := ruleserver.TrackOrNot(msg.RuleResult) |
| | |
| | | } |
| | | |
| | | // 往es中插入人脸数据 |
| | | func InsertFace(msg ruleserver.ResultMsg, linkId string) { |
| | | if msg.RuleResult["face"] != nil && len(msg.RuleResult["face"].([]ruleserver.FaceResult)) > 0 { |
| | | func InsertFace(msg structure.ResultMsg, linkId string) { |
| | | if msg.RuleResult["face"] != nil && len(msg.RuleResult["face"].([]structure.FaceResult)) > 0 { |
| | | logger.Info("往ES插人脸数据") |
| | | faces := []*FaceAndRules{} |
| | | faces = PutFace(faces,msg) |
| | |
| | | } |
| | | |
| | | // 归置人脸 |
| | | func PutFace(faces []*FaceAndRules,msg ruleserver.ResultMsg)[]*FaceAndRules{ |
| | | if msg.RuleResult["face"] != nil && len(msg.RuleResult["face"].([]ruleserver.FaceResult)) > 0 { |
| | | for _, faceResult := range msg.RuleResult["face"].([]ruleserver.FaceResult) { |
| | | 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) { |
| | | faces = hebingFace(faces, faceResult) |
| | | } |
| | | return faces |
| | |
| | | return nil |
| | | } |
| | | } |
| | | func hebingFace(faces []*FaceAndRules, faceResult ruleserver.FaceResult) []*FaceAndRules{ |
| | | func hebingFace(faces []*FaceAndRules, faceResult structure.FaceResult) []*FaceAndRules{ |
| | | for _, arg := range faceResult.Args { |
| | | // 拿到每一张人脸 |
| | | logger.Info("归置人脸时相似者的数量:",len(arg.Liker)) |
| | |
| | | } |
| | | } |
| | | if !flag { |
| | | faces = append(faces, &FaceAndRules{arg, []ruleserver.Result{faceResult.Result}}) |
| | | faces = append(faces, &FaceAndRules{arg, []structure.Result{faceResult.Result}}) |
| | | } |
| | | } |
| | | return faces |
| | | } |
| | | |
| | | // 往es中插入yolo数据 |
| | | func InsertYolo(msg ruleserver.ResultMsg, linkId string) { |
| | | if msg.RuleResult["yolo"] != nil && len(msg.RuleResult["yolo"].([]ruleserver.Result)) > 0 { |
| | | func InsertYolo(msg structure.ResultMsg, linkId string) { |
| | | if msg.RuleResult["yolo"] != nil && len(msg.RuleResult["yolo"].([]structure.Result)) > 0 { |
| | | // 先判断一下数据带的规则标签是否有可以插入的 |
| | | flag := false |
| | | for _, res := range msg.RuleResult["yolo"].([]ruleserver.Result) { |
| | | for _, res := range msg.RuleResult["yolo"].([]structure.Result) { |
| | | //logger.Info("定时器打的数字标签:",res.Others.TimeLabel) |
| | | if res.Others.TimeLabel == "01" || res.Others.TimeLabel == "10" { |
| | | flag = true |
| | |
| | | var sdkNames string = "" |
| | | alarmRules := []AlarmRule{} |
| | | url := []string{} |
| | | for _, yoloResult := range msg.RuleResult["yolo"].([]ruleserver.Result) { |
| | | for _, yoloResult := range msg.RuleResult["yolo"].([]structure.Result) { |
| | | if yoloResult.Others.TimeLabel == "01" || yoloResult.Others.TimeLabel == "10" { |
| | | // 拼出sdkname |
| | | //logger.Info("应该进来才对的") |
| | |
| | | } |
| | | i := protomsg.Image{} |
| | | err = proto.Unmarshal(bdata, &i) |
| | | resp1, err1 := util.DrawPolygonOnImage(msg1.Cid, i, msg1.RuleResult["yolo"].([]ruleserver.Result), weedfsUrl) |
| | | resp1, err1 := util.DrawPolygonOnImage(msg1.Cid, i, msg1.RuleResult["yolo"].([]structure.Result), weedfsUrl) |
| | | if err1 != nil { |
| | | logger.Error("缓存数据画框或上传图片服务器出错", err) |
| | | } else { |
| | |
| | | } |
| | | } |
| | | linkFlag := false |
| | | for _, yoloResult := range msg.RuleResult["yolo"].([]ruleserver.Result) { |
| | | 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 { |
| | | linkId := uuid.NewV4().String() |
| | | for _, msg2 := range yoloResult.Others.LinkCache { |
| | |
| | | if len(alarmRules) > 0 { |
| | | isAlarm = 1 |
| | | //resp, err = util.PostFormBufferData(weedfsUrl, i, uuid.NewV4().String()) |
| | | resp, err = util.DrawPolygonOnImage(msg.Cid, i, msg.RuleResult["yolo"].([]ruleserver.Result), weedfsUrl) |
| | | resp, err = util.DrawPolygonOnImage(msg.Cid, i, msg.RuleResult["yolo"].([]structure.Result), weedfsUrl) |
| | | if err != nil { |
| | | logger.Error("画框或上传图片服务器出错", err) |
| | | return |
| | | } else { |
| | | logger.Info("上传的图片信息:", resp) |
| | | } |
| | |
| | | logger.Error("查询摄像机信息失败") |
| | | } |
| | | serverIp, err := GetLocalIP() |
| | | if resp["fileUrl"] != nil { |
| | | url = append(url, resp["fileUrl"].(string)) |
| | | esDataId := uuid.NewV4().String() |
| | | linksId := "" |
| | | if linkId != "" { |
| | | linksId = linkId |
| | | } |
| | | peraction := Personaction{ |
| | | esDataId, |
| | | msg.Cid, |
| | | camera.Name, |
| | | camera.Addr, |
| | | msg.Tasklab.Taskid, |
| | | msg.Tasklab.Taskname, |
| | | sdkNames, |
| | | "", |
| | | alarmRules, |
| | | localConfig.ServerId, |
| | | localConfig.ServerName, |
| | | serverIp, |
| | | "", |
| | | url, |
| | | i.Timestamp, |
| | | linksId, |
| | | "", |
| | | isAlarm, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | } |
| | | requstbody, err := json.Marshal(peraction) |
| | | |
| | | url = append(url, resp["fileUrl"].(string)) |
| | | esDataId := uuid.NewV4().String() |
| | | linksId := "" |
| | | if linkId != "" { |
| | | linksId = linkId |
| | | } |
| | | peraction := Personaction{ |
| | | esDataId, |
| | | msg.Cid, |
| | | camera.Name, |
| | | camera.Addr, |
| | | msg.Tasklab.Taskid, |
| | | msg.Tasklab.Taskname, |
| | | sdkNames, |
| | | "", |
| | | alarmRules, |
| | | localConfig.ServerId, |
| | | localConfig.ServerName, |
| | | serverIp, |
| | | "", |
| | | url, |
| | | i.Timestamp, |
| | | linksId, |
| | | "", |
| | | isAlarm, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | } |
| | | requstbody, err := json.Marshal(peraction) |
| | | //<<<<<<< HEAD |
| | | // url = append(url, resp["fileUrl"].(string)) |
| | | // esDataId := uuid.NewV4().String() |
| | | // linksId := "" |
| | | // if linkId != "" { |
| | | // linksId = linkId |
| | | // } |
| | | // peraction := Personaction{ |
| | | // esDataId, |
| | | // msg.Cid, |
| | | // camera.Name, |
| | | // camera.Addr, |
| | | // msg.Tasklab.Taskid, |
| | | // msg.Tasklab.Taskname, |
| | | // sdkNames, |
| | | // "", |
| | | // alarmRules, |
| | | // localConfig.ServerId, |
| | | // localConfig.ServerName, |
| | | // serverIp, |
| | | // "", |
| | | // url, |
| | | // i.Timestamp, |
| | | // linksId, |
| | | // "", |
| | | // isAlarm, |
| | | // 0, |
| | | // 0, |
| | | // 0, |
| | | // } |
| | | // requstbody, err := json.Marshal(peraction) |
| | | // |
| | | // if err != nil { |
| | | // logger.Info("json parse error ", err) |
| | | // return |
| | | //======= |
| | | if err != nil { |
| | | logger.Info("json parse error ", err) |
| | | return |
| | | //>>>>>>> labelFilter |
| | | |
| | | if err != nil { |
| | | logger.Info("json parse error ", err) |
| | | return |
| | | |
| | | } |
| | | resp1, err2 := EsReq("POST", personAction, requstbody) |
| | | if err2 != nil { |
| | | logger.Error("往ES插入数据失败", err) |
| | | } 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}) |
| | | logger.Warn("__________________________________________往ES插入yolo数据成功") |
| | | //os.Exit(1) |
| | | } |
| | | resp1, err2 := EsReq("POST", personAction, requstbody) |
| | | if err2 != nil { |
| | | logger.Error("往ES插入数据失败", err) |
| | | } 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}) |
| | | logger.Warn("__________________________________________往ES插入yolo数据成功") |
| | | //os.Exit(1) |
| | | } |
| | | } |
| | | } else { |
| | | logger.Debug("timeLabel条件都不符合!") |
| | | } |
| | | } |
| | | } |
| | | func ChangeStatusYolo(msg ruleserver.ResultMsg) { |
| | | func ChangeStatusYolo(msg structure.ResultMsg) { |
| | | logger.Info("往ES插yolo非报警状态改变数据") |
| | | var sdkNames string = "" |
| | | alarmRules := []AlarmRule{} |
| | |
| | | i := protomsg.Image{} |
| | | err = proto.Unmarshal(bdata, &i) |
| | | //resp, err = util.PostFormBufferData(weedfsUrl, i, uuid.NewV4().String()) |
| | | resp, err := util.DrawPolygonOnImage(msg.Cid, i, msg.RuleResult["yolo"].([]ruleserver.Result), weedfsUrl) |
| | | resp, err := util.DrawPolygonOnImage(msg.Cid, i, msg.RuleResult["yolo"].([]structure.Result), weedfsUrl) |
| | | if err != nil { |
| | | logger.Error("画框或上传图片服务器出错", err) |
| | | } else { |
| | |
| | | //os.Exit(1) |
| | | } |
| | | } |
| | | func ChangeStatusFace(msg ruleserver.ResultMsg) { |
| | | func ChangeStatusFace(msg structure.ResultMsg) { |
| | | logger.Info("往ES插入人脸非报警但是状态转换数据") |
| | | // 上传大图 |
| | | // 解压缩并上传图片 |
| | |
| | | 0, |
| | | 0, |
| | | 0, |
| | | []*ruleserver.BaseInfo{}, |
| | | []*structure.BaseInfo{}, |
| | | } |
| | | requstbody, err := json.Marshal(pervideo) |
| | | |