From f4d1c65c0559142665c4c8370c4c3a170226eea8 Mon Sep 17 00:00:00 2001 From: panlei <2799247126@qq.com> Date: 星期一, 16 十二月 2019 11:42:36 +0800 Subject: [PATCH] --- --- algorithm/middleware/readyData.go | 71 ++++++++++++++++++++++++----------- 1 files changed, 48 insertions(+), 23 deletions(-) diff --git a/algorithm/middleware/readyData.go b/algorithm/middleware/readyData.go index 8b367f8..8a31d50 100644 --- a/algorithm/middleware/readyData.go +++ b/algorithm/middleware/readyData.go @@ -2,7 +2,7 @@ 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" @@ -21,7 +21,7 @@ func CountAreaObjs(a *structure.AreaMap,arg *structure.SdkData) { a.TargetNum = 0 - threshold := 70.0 // 鐩镐技搴� + threshold := 0.0 // 鐩镐技搴� intersectionper := 20.0 // 鍗犳瘮 size := 0.0 // 灏哄 @@ -74,16 +74,12 @@ return rect } - - - // 灏嗗閮ㄤ紶杩涙潵鐨剆dk鏁版嵁鍖呰В鎴� SdkDatas func ParamFormat(msg []byte, args *structure.SdkDatas) protomsg.SdkMessage { defer func() { if err := recover(); err != nil { logger.Info("瑙e寘杩囩▼鐨勫紓甯告崟鑾�", err.(string)) } - }() // 鍙嶅簭鍒楀寲鏁版嵁寰楀埌sdk鍏ュ弬 m := protomsg.SdkMessage{} @@ -113,17 +109,13 @@ 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{} @@ -142,7 +134,7 @@ 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) @@ -169,7 +161,7 @@ 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++ } @@ -200,7 +192,7 @@ 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) } } @@ -219,22 +211,55 @@ 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("瑙f瀽璺熻釜鐩爣鏁版嵁鏃跺嚭鐜伴敊璇�", 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("瑙f瀽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 } \ No newline at end of file -- Gitblit v1.8.0