| | |
| | | } |
| | | } |
| | | |
| | | // 将外部传进来的sdk数据包解成 ArgsFromSdk |
| | | //func paramFormat(msg []byte, arg *ruleserver.ArgsFromSdk) protomsg.SdkMessage { |
| | | // defer func() { |
| | | // if err := recover(); err != nil { |
| | | // fmt.Println("解包过程的错误", err.(string)) |
| | | // } |
| | | // |
| | | // }() |
| | | // // 反序列化数据得到sdk入参 |
| | | // m := protomsg.SdkMessage{} |
| | | // err := proto.Unmarshal(msg, &m) |
| | | // if err != nil { |
| | | // panic("解析msg时出现错误") |
| | | // } |
| | | // arg.CameraId = m.Cid |
| | | // arg.TaskId = m.Tasklab.Taskid |
| | | // bdata, err := util.UnCompress(m.Data) |
| | | // if err != nil { |
| | | // panic("解压缩图片时出现错误") |
| | | // } |
| | | // i := protomsg.Image{} |
| | | // err = proto.Unmarshal(bdata, &i) |
| | | // arg.ImageWidth = int(i.Width) |
| | | // arg.ImageHeight = int(i.Height) |
| | | // // 暂时写死,sdk还没有这俩算法 |
| | | // arg.KeepRight = false |
| | | // arg.IsStatic = false |
| | | // for _, sdkinfo := range m.Tasklab.Sdkinfos { // yolo算法 |
| | | // if sdkinfo.Sdktype == "Yolo" { |
| | | // if len(sdkinfo.Sdkdata) > 1 { |
| | | // // 大于1才有数据 |
| | | // fmt.Println("----------------------------------------------------",m.Caddr) |
| | | // yoloParam := protomsg.ParamYoloObj{} |
| | | // err = proto.Unmarshal(sdkinfo.Sdkdata, &yoloParam) |
| | | // if err != nil { |
| | | // fmt.Println("解析YOLO sdk数据时出现错误", err) |
| | | // continue |
| | | // } |
| | | // for _, info := range yoloParam.Infos { |
| | | // if info.Typ == 0 { |
| | | // photoMap := ruleserver.PhotoMap{Rects: rectFormat(info.RcObj), Score: float64(info.Prob)*100,IsYolo:true} |
| | | // arg.Photo = append(arg.Photo, photoMap) |
| | | // } |
| | | // } |
| | | // } else { |
| | | // continue |
| | | // } |
| | | // |
| | | // } |
| | | // if sdkinfo.Sdktype == "FaceDetect" { // 人脸检测 |
| | | // if len(sdkinfo.Sdkdata) > 1 { |
| | | // fmt.Println("----------------------------------------------------",m.Caddr) |
| | | // faceParam := protomsg.ParamFacePos{} |
| | | // err = proto.Unmarshal(sdkinfo.Sdkdata, &faceParam) |
| | | // if err != nil { |
| | | // fmt.Println("解析FACE sdk数据时出现错误", err) |
| | | // continue |
| | | // } |
| | | // for _, info := range faceParam.Faces { |
| | | // photoMap := ruleserver.PhotoMap{Rects: rectFormat(info.Pos.RcFace), Score: float64(info.Pos.Quality), IsYolo:false,ThftRes:*(info.Result)} |
| | | // arg.Photo = append(arg.Photo, photoMap) |
| | | // } |
| | | // } else { |
| | | // continue |
| | | // } |
| | | // } |
| | | // //if sdkinfo.Sdktype == "FaceExtract" { // 人脸提取 |
| | | // |
| | | // //} |
| | | // |
| | | // } |
| | | // return m |
| | | //} |
| | | |
| | | // 将外部传进来的rect(top,bottom,left,right)转化为自己内部的rect(left top width height) |
| | | func rectFormat(rcobj *protomsg.Rect) ruleserver.Rect { |
| | | rect := ruleserver.Rect{} |
| | |
| | | panic("解析msg时出现错误") |
| | | } |
| | | args.CameraId = m.Cid |
| | | // 把图片的二进制解压缩进行画框在压缩回去 |
| | | bdata, err := util.UnCompress(m.Data) |
| | | if err != nil { |
| | | panic("解压缩图片时出现错误") |
| | | } |
| | | i := protomsg.Image{} |
| | | err = proto.Unmarshal(bdata, &i) |
| | | |
| | | for _, sdkinfo := range m.Tasklab.Sdkinfos { // yolo算法 |
| | | if sdkinfo.Sdktype == "Yolo" { |
| | | arg := ruleserver.SdkData{} |
| | |
| | | arg.Photo = append(arg.Photo, photoMap) |
| | | } |
| | | } |
| | | args.Sdkdata = append(args.Sdkdata,arg) |
| | | args.Sdkdata = append(args.Sdkdata,&arg) |
| | | } else { |
| | | continue |
| | | } |
| | |
| | | photoMap := ruleserver.PhotoMap{Rects: rectFormat(info.Pos.RcFace), Score: float64(info.Pos.Quality)*100, IsYolo:false,ThftRes:*(info.Result)} |
| | | arg.Photo = append(arg.Photo, photoMap) |
| | | } |
| | | args.Sdkdata = append(args.Sdkdata,arg) |
| | | args.Sdkdata = append(args.Sdkdata,&arg) |
| | | } else { |
| | | continue |
| | | } |
| | | } |
| | | //if sdkinfo.Sdktype == "FaceExtract" { // 人脸提取 |
| | | |
| | | //} |
| | | if sdkinfo.Sdktype == "FaceExtract" { // 人脸提取 |
| | | arg := ruleserver.SdkData{} |
| | | arg.TaskId = m.Tasklab.Taskid |
| | | arg.SdkId = sdkinfo.Sdkid |
| | | arg.SdkName = sdkinfo.SdkName |
| | | arg.IsYolo = false |
| | | bdata, err := util.UnCompress(m.Data) |
| | | if err != nil { |
| | | panic("解压缩图片时出现错误") |
| | | } |
| | | i := protomsg.Image{} |
| | | err = proto.Unmarshal(bdata, &i) |
| | | arg.ImageWidth = int(i.Width) |
| | | arg.ImageHeight = int(i.Height) |
| | | // 暂时写死,sdk还没有这俩算法 |
| | | arg.KeepRight = false |
| | | arg.IsStatic = false |
| | | if len(sdkinfo.Sdkdata) > 1 { |
| | | fmt.Println("----------------------------------------------------",m.Caddr) |
| | | faceParam := protomsg.ParamFaceFeature{} |
| | | err = proto.Unmarshal(sdkinfo.Sdkdata, &faceParam) |
| | | if err != nil { |
| | | fmt.Println("解析FACE sdk数据时出现错误", err) |
| | | continue |
| | | } |
| | | for _, extComp := range faceParam.ExtComp { |
| | | baseinfos := protomsg.Binfos{} |
| | | err1 := proto.Unmarshal(extComp.Comp, &baseinfos) |
| | | if err1 != nil { |
| | | fmt.Println("解析FACE sdk数据时出现错误", err) |
| | | continue |
| | | } |
| | | photoMap := ruleserver.PhotoMap{Rects: rectFormat(extComp.Pos.Pos.RcFace), Score: float64(extComp.Pos.Pos.Quality)*100, IsYolo:false,ThftRes:*(extComp.Pos.Result),Liker:baseinfos.Infos} |
| | | arg.Photo = append(arg.Photo, photoMap) |
| | | } |
| | | args.Sdkdata = append(args.Sdkdata,&arg) |
| | | } else { |
| | | continue |
| | | } |
| | | } |
| | | |
| | | } |
| | | return m |