| | |
| | | import ( |
| | | "basic.com/dbapi.git" |
| | | "basic.com/pubsub/protomsg.git" |
| | | "basic.com/valib/logger.git" |
| | | logger "github.com/jeanphorn/log4go" |
| | | "encoding/json" |
| | | "errors" |
| | | "fmt" |
| | | "github.com/golang/protobuf/proto" |
| | | uuid "github.com/satori/go.uuid" |
| | | "math" |
| | | "nanomsg.org/go-mangos" |
| | | "nanomsg.org/go-mangos/protocol/req" |
| | |
| | | //logger.Info("初步保留两位成str::::",value2) |
| | | return value2 |
| | | } |
| | | // 取出某个时间规则的第几天的规则段集合 |
| | | func GetTimeById(id string, index int) []structure.TimeRange { |
| | | _, cameraTimeRule := cache.GetTimeRuleById(id) |
| | | var timeRangeList []structure.Day |
| | | err := json.Unmarshal([]byte(cameraTimeRule.TimeRule), &timeRangeList) |
| | | if err != nil { |
| | | logger.Error("取时间规则时反序列化错误!") |
| | | } |
| | | for _, timerange := range timeRangeList { |
| | | if timerange.Day == index { |
| | | //logger.Println("取到的时间规则:", timerange.TimeRange) |
| | | return timerange.TimeRange |
| | | } |
| | | } |
| | | return nil |
| | | } |
| | | |
| | | // 根据传入的字符串得到其在一周内的索引 周一到周日分别对应1到7 |
| | | func getIndexOfWeek(weekday string) int { |
| | | var weekdays = [7]string{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"} |
| | | for k, value := range weekdays { |
| | | if value == weekday { |
| | | return k + 1 // 因为数据库中存的是1-7代表的周一到周日 |
| | | } |
| | | } |
| | | return 0 |
| | | } |
| | | |
| | | |
| | | |
| | | // 将字符串格式的坐标序列化为Point格式 |
| | | func Json2points(areaPoints string) []Point { |
| | | var pts []Point |
| | | func Json2points(areaPoints string) []structure.Point { |
| | | var pts []structure.Point |
| | | if areaPoints == "[]" || areaPoints == "" { |
| | | logger.Error("=====================此区域为全部区域") |
| | | pts = append(pts, Point{0, 0}) |
| | | pts = append(pts, Point{0, 540}) |
| | | pts = append(pts, Point{960, 540}) |
| | | pts = append(pts, Point{960, 0}) |
| | | pts = append(pts, structure.Point{0, 0}) |
| | | pts = append(pts, structure.Point{0, 540}) |
| | | pts = append(pts, structure.Point{960, 540}) |
| | | pts = append(pts, structure.Point{960, 0}) |
| | | } else { |
| | | err := json.Unmarshal([]byte(areaPoints), &pts) |
| | | if err != nil { |
| | |
| | | logger.Error("根据id查询底库信息出错!", err, "--返回值长度为:", len(table)) |
| | | } |
| | | logger.Debug("看看这个base的对比值是多少:", Decimal(m[baseinfo.Id].CompareScore)) |
| | | base := structure.BaseInfo{TableId: baseinfo.TableId, TableName: table[0].TableName, BwType: table[0].BwType, CompareScore: Decimal(m[baseinfo.Id].CompareScore), PersonId: baseinfo.Id, PersonName: baseinfo.PersonName, PersonPicUrl: baseinfo.PersonPicUrl, PhoneNum: baseinfo.PhoneNum, Sex: baseinfo.Sex, IdCard: baseinfo.IdCard, MonitorLevel: baseinfo.MonitorLevel, Content: baseinfo.Reserved} |
| | | base := structure.BaseInfo{TableId: baseinfo.TableId, TableName: table[0].TableName, BwType: table[0].BwType, CompareScore: Decimal(m[baseinfo.Id].CompareScore), TargetId: baseinfo.Id, TargetName: baseinfo.PersonName, TargetPicUrl: baseinfo.PersonPicUrl, MonitorLevel: baseinfo.MonitorLevel, Content: baseinfo.Reserved,DbLabel: baseinfo.PhoneNum+"/"+baseinfo.Sex+"/"+baseinfo.IdCard,} |
| | | //os.Exit(1) |
| | | arg.Liker = append(arg.Liker, &base) |
| | | } |
| | |
| | | //logger.Info("--------------看看compareFlag的值和tableId和areaMap.args的长度:",compareFlag,tableIds,len(areaMap.args)) |
| | | for _, arg := range areaMap.Args { |
| | | arg.Liker = arg.Liker[0:0] |
| | | //logger.Info("清空之后看看之前打的人脸标签变了没:") |
| | | //if args.RuleResult["face"] != nil && len(args.RuleResult["face"].([]FaceResult)) > 0 { |
| | | // for _, faceResult := range args.RuleResult["face"].([]FaceResult) { |
| | | // for _,arg := range faceResult.Args { |
| | | // logger.Info("人员分值是:",arg.Score,"liker的数量为",arg.Liker) |
| | | // } |
| | | // } |
| | | //} |
| | | if compareFlag == 1 { |
| | | fillLiker(nil, threshold, arg) |
| | | } |
| | |
| | | |
| | | a.TargetNum = 0 |
| | | threshold := 80.0 // 相似度 |
| | | intersectionper := 0.2 // 占比 |
| | | intersectionper := 20.0 // 占比 |
| | | size := 0.0 // 尺寸 |
| | | |
| | | areaPoints := Json2points(a.AreaJson) |
| | |
| | | if obj.Score >= threshold && float64(obj.Rects.Width*obj.Rects.Height) >= size && PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale) >= intersectionper { |
| | | // 这步要备齐表达式里所需要的所有参数 |
| | | a.TargetNum++ |
| | | arg1 := structure.Arg{obj.Id,obj.Score, PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale), float64(obj.Rects.Width * obj.Rects.Height), obj.IsYolo, obj.Rects, obj.Feature, obj.ThftRes, []*structure.BaseInfo{}} |
| | | uuid := uuid.NewV4().String() |
| | | arg1 := structure.Arg{obj.Id,uuid,obj.Score, PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale), float64(obj.Rects.Width * obj.Rects.Height), a.AreaJson,obj.Type, obj.Rects, obj.Car,obj.Feature, obj.ThftRes, []*structure.BaseInfo{},"",structure.ResultMsg{}} |
| | | //logger.Println("放进去的arg:-------", arg1) |
| | | a.Args = append(a.Args, &arg1) |
| | | a.FilterData = append(a.FilterData, &arg1) |
| | |
| | | } |
| | | logger.Info("区域是:",areaPoints,"区域内目标数量为:",a.TargetNum,"---",len(a.FilterData)) |
| | | a.Time = time.Unix(time.Now().Unix(), 0).String()[11:16] |
| | | a.KeepRight = arg.KeepRight |
| | | a.IsStatic = arg.IsStatic |
| | | //logger.Println("--------------------看看区域数据:",*a) |
| | | } |
| | | |