| | |
| | | |
| | | import ( |
| | | "basic.com/pubsub/protomsg.git" |
| | | logger "github.com/alecthomas/log4go" |
| | | "basic.com/valib/logger.git" |
| | | "github.com/golang/protobuf/proto" |
| | | uuid "github.com/satori/go.uuid" |
| | | "ruleprocess/ruleserver" |
| | |
| | | func CountAreaObjs(a *structure.AreaMap,arg *structure.SdkData) { |
| | | |
| | | a.TargetNum = 0 |
| | | threshold := 70.0 // 相似度 |
| | | threshold := 0.0 // 相似度 |
| | | intersectionper := 20.0 // 占比 |
| | | size := 0.0 // 尺寸 |
| | | |
| | |
| | | return rect |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // 将外部传进来的sdk数据包解成 SdkDatas |
| | | func ParamFormat(msg []byte, args *structure.SdkDatas) protomsg.SdkMessage { |
| | | defer func() { |
| | | if err := recover(); err != nil { |
| | | logger.Info("解包过程的异常捕获", err.(string)) |
| | | } |
| | | |
| | | }() |
| | | // 反序列化数据得到sdk入参 |
| | | m := protomsg.SdkMessage{} |
| | |
| | | extractFace(args,m,sdkinfo,i) |
| | | case "Plate": |
| | | extractCar(args,m,sdkinfo,i) |
| | | case "Track": |
| | | case "HumanTrack": |
| | | extractTrack(args,m,sdkinfo,i) |
| | | } |
| | | } |
| | | return m |
| | | } |
| | | |
| | | // 把人脸放进对应的人体 |
| | | func FacePush2Body () { |
| | | |
| | | } |
| | | // 提取face |
| | | func extractFace(args *structure.SdkDatas,m protomsg.SdkMessage,sdkinfo *protomsg.SdkmsgWithTask,i protomsg.Image) { |
| | | arg := structure.SdkData{} |
| | |
| | | logger.Info("--------------追踪之后人脸的个数:", len(faceParam.Faces)) |
| | | for _, info := range faceParam.Faces { |
| | | //logger.Info("_______________________________________________第一次看相似值:",info.Pos.FAngle.Confidence*100) |
| | | photoMap := structure.PhotoMap{Id: strconv.Itoa(int(info.Pos.FaceID)) , Rects: rectFormat(info.Pos.RcFace), Score: float64(info.Pos.FAngle.Confidence * 100), Type: "face", ThftRes: *(info.Result), Feature: info.Feats} |
| | | photoMap := structure.PhotoMap{structure.SourcePhoto{Id: strconv.Itoa(int(info.Pos.FaceID)) , Rects: rectFormat(info.Pos.RcFace), Score: float64(info.Pos.FAngle.Confidence * 100), Type: "face", ThftRes: *(info.Result), Feature: info.Feats},structure.SourcePhoto{}} |
| | | arg.Photo = append(arg.Photo, photoMap) |
| | | } |
| | | args.Sdkdata = append(args.Sdkdata, &arg) |
| | |
| | | for _, info := range yoloParam.Infos { |
| | | if info.Typ == 0 { |
| | | //logger.Debug("-------------yolo的坐标有几个",info.RcObj) |
| | | photoMap := structure.PhotoMap{Rects: rectFormat(info.RcObj), Score: float64(info.Prob) * 100, Type: "yolo",Id:strconv.Itoa(int(info.ObjID))} |
| | | photoMap := structure.PhotoMap{structure.SourcePhoto{Rects: rectFormat(info.RcObj), Score: float64(info.Prob) * 100, Type: "yolo",Id:strconv.Itoa(int(info.ObjID))},structure.SourcePhoto{}} |
| | | arg.Photo = append(arg.Photo, photoMap) |
| | | yoloNum++ |
| | | } |
| | |
| | | logger.Info("接收车牌数据:",info.FvdConf,info.NVehicleColor1,info.NPlateFlag,info.RcCarLocation) |
| | | if info.NConfidence > 70 { |
| | | logger.Info("车牌也符合的数据",info.FvdConf,info.NVehicleColor1,info.NPlateFlag,info.RcCarLocation,info.NConfidence,) |
| | | photoMap := structure.PhotoMap{Id: info.License,Score: float64(info.FvdConf)*100,Rects: rectFormat(info.RcCarLocation), Type: "plate", Car:info} |
| | | photoMap := structure.PhotoMap{structure.SourcePhoto{Id: info.License,Score: float64(info.FvdConf)*100,Rects: rectFormat(info.RcCarLocation), Type: "plate", Car:info},structure.SourcePhoto{}} |
| | | arg.Photo = append(arg.Photo, photoMap) |
| | | } |
| | | } |
| | |
| | | arg.ImageWidth = int(i.Width) |
| | | arg.ImageHeight = int(i.Height) |
| | | if len(sdkinfo.Sdkdata) > 1 { |
| | | plateIDResult := protomsg.PlateIDResult {} |
| | | err := proto.Unmarshal(sdkinfo.Sdkdata, &plateIDResult ) |
| | | |
| | | Track := protomsg.HumanTrackResult {} |
| | | err := proto.Unmarshal(sdkinfo.Sdkdata, &Track) |
| | | if err != nil { |
| | | logger.Info("解析跟踪目标数据时出现错误", err) |
| | | return |
| | | } |
| | | for _, info := range plateIDResult.Result { |
| | | logger.Info("接收车牌数据:",info.FvdConf,info.NVehicleColor1,info.NPlateFlag,info.RcCarLocation) |
| | | if info.NConfidence > 70 { |
| | | logger.Info("车牌也符合的数据",info.FvdConf,info.NVehicleColor1,info.NPlateFlag,info.RcCarLocation,info.NConfidence,) |
| | | photoMap := structure.PhotoMap{Id: info.License,Score: float64(info.FvdConf)*100,Rects: rectFormat(info.RcCarLocation), Type: "plate", Car:info} |
| | | arg.Photo = append(arg.Photo, photoMap) |
| | | } |
| | | for _, info := range Track.Result { |
| | | logger.Info("接收跟踪数据:",info.Id,info.Confidence,info.Feature) |
| | | photoMap := structure.PhotoMap{structure.SourcePhoto{Id: strconv.Itoa(int(info.Id)),Score: float64(info.Confidence)*100,Rects: rectFormat(info.RcHuman), Type: "track"},structure.SourcePhoto{}} |
| | | arg.Photo = append(arg.Photo, photoMap) |
| | | } |
| | | args.Sdkdata = append(args.Sdkdata, &arg) |
| | | } else { |
| | | return |
| | | } |
| | | } |
| | | |
| | | // 把人脸放进对应的人体 |
| | | func FacePush2Body (photomap *structure.PhotoMap,sdkInfos []*protomsg.SdkmsgWithTask) { |
| | | for _,sdkinfo := range sdkInfos { |
| | | if sdkinfo.Sdktype == "FaceDetect" { |
| | | faceParam := protomsg.ParamFacePos{} |
| | | err := proto.Unmarshal(sdkinfo.Sdkdata, &faceParam) |
| | | if err != nil { |
| | | logger.Info("解析FACE sdk数据时出现错误", err) |
| | | return |
| | | } |
| | | logger.Info("--------------追踪之后人脸的个数:", len(faceParam.Faces)) |
| | | for _, info := range faceParam.Faces { |
| | | percent := ruleserver.PgsInterPercent(Rect2Point(photomap.Rects),rectFormat(info.Pos.RcFace), 1, 1) |
| | | if percent > 99 { |
| | | photomap.AttachObj = structure.SourcePhoto{Id:strconv.Itoa(int(info.Pos.FaceID)),Rects: rectFormat(info.Pos.RcFace),Score: float64(info.Pos.FAngle.Confidence * 100), Type: "face", ThftRes: *(info.Result), Feature: info.Feats} |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | func Rect2Point(rect structure.Rect) []structure.Point{ |
| | | // 按逆时针转化 |
| | | points := []structure.Point{} |
| | | leftTop := structure.Point{rect.X,rect.Y} |
| | | points = append(points,leftTop) |
| | | leftBottom := structure.Point{rect.X,rect.Y+rect.Height} |
| | | points = append(points,leftBottom) |
| | | rightBottom := structure.Point{rect.X+rect.Width,rect.Y+rect.Height} |
| | | points = append(points,rightBottom) |
| | | rightTop := structure.Point{rect.X+rect.Width,rect.Y} |
| | | points = append(points,rightTop) |
| | | return points |
| | | } |