| | |
| | | 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"` |
| | | ShowLable string `json:"showLable"` |
| | | OtherLable string `json:"otherLable"` |
| | | FaceFeature string `json:"faceFeature"` |
| | | PicSmUrl []string `json:"picSmUrl"` |
| | | VideoUrl string `json:"videoUrl"` |
| | |
| | | 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"` |
| | | Lable string `json:"lable"` |
| | | FaceFeature string `json:"faceFeature"` |
| | | PicSmUrl []string `json:"picSmUrl"` |
| | | VideoUrl string `json:"videoUrl"` |
| | |
| | | LinkInfo string `json:"linkInfo"` |
| | | } |
| | | |
| | | // 一个face对多个规则组的归置人脸的结构体 |
| | | type FaceAndRules struct { |
| | | // 一个obj对多个规则组的归置人脸的结构体 可用于人脸 可用于车牌 |
| | | type ObjAndRules struct { |
| | | structure.Arg |
| | | rules []structure.Result |
| | | } |
| | |
| | | InsertTarget(msg) |
| | | } |
| | | |
| | | // 往es中插入人脸数据 |
| | | // 往es中插入人脸类型数据 |
| | | func InsertFace(msg structure.ResultMsg) { |
| | | if msg.RuleResult["face"] != nil && len(msg.RuleResult["face"].([]structure.Result)) > 0 { |
| | | logger.Info("往ES插人脸数据") |
| | | faces := []*FaceAndRules{} |
| | | faces = PutFace(faces, msg) |
| | | if (msg.RuleResult["face"] != nil && len(msg.RuleResult["face"].([]structure.Result)) > 0) || (msg.RuleResult["plate"] != nil && len(msg.RuleResult["plate"].([]structure.Result)) > 0) { |
| | | for key, results := range msg.RuleResult { |
| | | if key == "face" || key == "plate" { |
| | | logger.Info("往ES插人脸数据(或车牌数据)") |
| | | faces := []*ObjAndRules{} |
| | | faces = PutFace(faces, results.([]structure.Result)) |
| | | //logger.Info("整理后的数据:",faces) |
| | | if faces != nil { |
| | | var imgMaxUrl string = "" |
| | |
| | | panic("解压缩图片时出现错误") |
| | | } |
| | | alarmRules := []AlarmRule{} |
| | | //os.Exit(1) |
| | | for _, faceResult := range face.rules { |
| | | alarm := ChangeToString(faceResult.DefenceState, faceResult.AlarmLevel) |
| | | alarmRules = append(alarmRules, AlarmRule{faceResult.RuleGroupId, alarm, faceResult.RuleText, faceResult.DefenceState, ""}) |
| | |
| | | imgMaxUrl = bigPhotoUrl["fileUrl"].(string) |
| | | picTime = i.Timestamp |
| | | } |
| | | sex := "" |
| | | logger.Info(sex) |
| | | if face.ThftRes.Gender == 1 { |
| | | sex = "男" |
| | | } else { |
| | | sex = "女" |
| | | } |
| | | race := getRaceString(face.ThftRes.Race) |
| | | ageDescription := getDescription(face.ThftRes.Age) |
| | | logger.Info(ageDescription) |
| | | lable,lableAttach := Feature2Jsonstr(*face) |
| | | var target = new(Target) |
| | | target.TargetId = face.Id |
| | | target.TargetScore = face.Score |
| | |
| | | time.Now().Format("2006-01-02 15:04:05"), |
| | | alarmRules, |
| | | time.Now().Format("2006-01-02 15:04:05"), // 只检测,没有比对时间 |
| | | sex, //暂改为人脸id strconv.FormatUint(face.Id, 10) |
| | | face.ThftRes.Age, |
| | | ageDescription, // 暂改为分值fmt.Sprintf("%.2f",face.Score) |
| | | race, |
| | | face.ThftRes.Smile, |
| | | face.ThftRes.Beauty, |
| | | lable, |
| | | lableAttach, |
| | | base64.StdEncoding.EncodeToString(face.Feature), |
| | | []string{resp["fileUrl"].(string)}, |
| | | "", |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 归置人脸 |
| | | func PutFace(faces []*FaceAndRules, msg structure.ResultMsg) []*FaceAndRules { |
| | | if msg.RuleResult["face"] != nil && len(msg.RuleResult["face"].([]structure.Result)) > 0 { |
| | | for _, faceResult := range msg.RuleResult["face"].([]structure.Result) { |
| | | faces = hebingFace(faces, faceResult) |
| | | func PutFace(objs []*ObjAndRules, resutls []structure.Result) []*ObjAndRules { |
| | | for _, faceResult := range resutls { |
| | | objs = hebingFace(objs, faceResult) |
| | | } |
| | | return faces |
| | | } else { |
| | | return nil |
| | | return objs |
| | | } |
| | | } |
| | | func hebingFace(faces []*FaceAndRules, faceResult structure.Result) []*FaceAndRules { |
| | | func hebingFace(objs []*ObjAndRules, faceResult structure.Result) []*ObjAndRules { |
| | | for _, arg := range faceResult.AlarmObj { |
| | | // 拿到每一张人脸 |
| | | //logger.Info("归置人脸时相似者的数量:", len(arg.Liker)) |
| | | flag := false |
| | | for _, face := range faces { |
| | | for _, face := range objs { |
| | | //for _, lik := range face.Liker { |
| | | // //logger.Warn("--------合并人脸时相似者:", lik.PersonId, lik.TableName) |
| | | //} |
| | |
| | | } |
| | | } |
| | | if !flag { |
| | | faces = append(faces, &FaceAndRules{*arg, []structure.Result{faceResult}}) |
| | | objs = append(objs, &ObjAndRules{*arg, []structure.Result{faceResult}}) |
| | | } |
| | | } |
| | | return faces |
| | | return objs |
| | | } |
| | | |
| | | // 往es中插入yolo数据 |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 获取本机ip |
| | | func GetLocalIP() (ipv4 string, err error) { |
| | | var ( |
| | |
| | | return "" |
| | | } |
| | | } |
| | | |
| | | //获取年龄描述 |
| | | func getDescription(age int32) string { |
| | | ageInfo := "青年" |
| | |
| | | race = "黑人" |
| | | } |
| | | return race |
| | | } |
| | | |
| | | func Feature2Jsonstr(obj ObjAndRules) (string,string) { |
| | | var lable string |
| | | var lableAttach string |
| | | switch obj.Type { |
| | | case "face": |
| | | sex := "" |
| | | if obj.ThftRes.Gender == 1 { |
| | | sex = "男" |
| | | } else { |
| | | sex = "女" |
| | | } |
| | | race := getRaceString(obj.ThftRes.Race) |
| | | ageDescription := getDescription(obj.ThftRes.Age) |
| | | lable = sex+" / "+ageDescription+" / "+race+" / " |
| | | lableAttach = strconv.Itoa(int(obj.ThftRes.Age))+"岁"+" / "+"微笑值:"+strconv.Itoa(int(obj.ThftRes.Smile))+" / "+"颜值:"+strconv.Itoa(int(obj.ThftRes.Beauty)) |
| | | |
| | | case "plate": |
| | | // 车牌运动方向,0 unknown, 1 left, 2 right, 3 up, 4 down |
| | | lable = obj.Car.License+" / "+cache.GetDic("nColor"+strconv.Itoa(int(obj.Car.NColor)))+"车牌"+" / "+ |
| | | cache.GetDic("nCarColor"+strconv.Itoa(int(obj.Car.NCarColor)))+"车辆"+" / "+ cache.GetDic("nCarLogo"+strconv.Itoa(int(obj.Car.NCarLogo)))+" / "+cache.GetDic("nCarLogo"+strconv.Itoa(int(obj.Car.NCarType))) |
| | | lableAttach = cache.GetDic("nDirection"+strconv.Itoa(int(obj.Car.NDirection)))+" / "+"车牌置信度:"+strconv.Itoa(int(obj.Car.NConfidence))+" / "+ |
| | | "车牌亮度:"+strconv.Itoa(int(obj.Car.NBright))+" / "+"车的亮度:"+strconv.Itoa(int(obj.Car.NCarBright))+" / "+"识别时间:"+strconv.Itoa(int(obj.Car.NTime)) |
| | | } |
| | | return lable,lableAttach |
| | | } |
| | | |
| | | func msg2PersonVideo(msg structure.ResultMsg) *LinkInfo { |
| | |
| | | "", |
| | | alarmRules, |
| | | time.Now().Format("2006-01-02 15:04:05"), // 只检测,没有比对时间 |
| | | "", //暂改为人脸id strconv.FormatUint(face.Id, 10) |
| | | 0, |
| | | "", // 暂改为分值fmt.Sprintf("%.2f",face.Score) |
| | | "", |
| | | 0, |
| | | 0, |
| | | "", |
| | | []string{resp["fileUrl"].(string)}, |
| | | "", |