panlei
2019-11-16 9c8bcb851f82123660c7b05b00a526c4283ba4cf
main.go
@@ -16,10 +16,11 @@
   "flag"
   "fmt"
   "github.com/golang/protobuf/proto"
   "github.com/spf13/viper"
   "ruleprocess/cache"
   "ruleprocess/ruleserver"
   "sync"
   "github.com/spf13/viper"
)
var dbIp = flag.String("dbIp", "127.0.0.1", "dbserver ip")
@@ -87,7 +88,7 @@
         } else {
            //runtime.GOMAXPROCS(runtime.NumCPU())
            //logger.Debug("使用的cpu个数:",runtime.NumCPU())
            go func(msg []byte) {
            //go func(msg []byte) {
               logger.Debug("当前时间戳:", time.Now().Unix())
               arg := structure.SdkDatas{}
               //paramFormat(msg, &arg)
@@ -106,7 +107,7 @@
               logger.Debug("插入完Es所用时间:", esEnd)
               //事件推送
               labelFilter.PushSomthing(resultMsg)
            }(msg)
            //}(msg)
         }
      }
   }
@@ -158,17 +159,8 @@
         arg.TaskId = m.Tasklab.Taskid
         arg.IpcId = sdkinfo.Ipcid
         arg.IsYolo = true
         //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
         logger.Info("-----追踪之后sdkinfo.Sdkdata的长度为:----", len(sdkinfo.Sdkdata))
         if len(sdkinfo.Sdkdata) > 1 {
            // 大于1才有数据
@@ -199,17 +191,8 @@
         arg.TaskId = m.Tasklab.Taskid
         arg.IpcId = sdkinfo.Ipcid
         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 {
            faceParam := protomsg.ParamFacePos{}
            err = proto.Unmarshal(sdkinfo.Sdkdata, &faceParam)
@@ -228,6 +211,30 @@
            continue
         }
      }
      if sdkinfo.Sdktype == "Plate" { // 车牌识别
         arg := structure.SdkData{}
         arg.TaskId = m.Tasklab.Taskid
         arg.IpcId = sdkinfo.Ipcid
         arg.IsYolo = false
         arg.ImageWidth = int(i.Width)
         arg.ImageHeight = int(i.Height)
         if len(sdkinfo.Sdkdata) > 1 {
            plateIDResult  := protomsg.PlateIDResult {}
            err = proto.Unmarshal(sdkinfo.Sdkdata, &plateIDResult )
            if err != nil {
               logger.Info("解析车牌数据时出现错误", err)
               continue
            }
            for _, info := range plateIDResult.Result {
               logger.Info("接收车牌数据:",)
               photoMap := structure.PhotoMap{Rects: rectFormat(info.RcLocation), IsYolo: false, Car:info}
               arg.Photo = append(arg.Photo, photoMap)
            }
            args.Sdkdata = append(args.Sdkdata, &arg)
         } else {
            continue
         }
      }
   }
   return m
}