panlei
2019-11-16 9c8bcb851f82123660c7b05b00a526c4283ba4cf
main.go
@@ -7,20 +7,16 @@
   "net/http"
   _ "net/http/pprof"
   "ruleprocess/insertdata"
   "ruleprocess/logger"
   "ruleprocess/labelFilter"
   "ruleprocess/structure"
   "ruleprocess/util"
   "time"
   //"bufio"
   //"bytes"
   "basic.com/valib/logger.git"
   "flag"
   "fmt"
   "github.com/golang/protobuf/proto"
   //"gocv.io/x/gocv"
   //"image"
   //"image/color"
   //"os"
   "ruleprocess/cache"
   "ruleprocess/ruleserver"
   "sync"
@@ -62,6 +58,7 @@
   go cache.Init(initchan, *dbIp, *surveyPort, *pubPort)
   logger.Info("cache init completed!!!", <-initchan) //dbserver初始化完毕
   ruleserver.Init()
   labelFilter.Init()
   go ruleserver.TimeTicker()
   go ruleserver.StartServer()
   nReciever("ipc:///tmp/sdk-2-rules-process.ipc", deliver.PushPull, 1)
@@ -101,13 +98,15 @@
               ruleserver.Judge(&arg, &m) // 把sdkMessage传进去,方便缓存数据时拼出一个resultMag
               // 把arg里的打的标签拿出来给m再封装一层
               resultMsg := structure.ResultMsg{SdkMessage: &m, RuleResult: arg.RuleResult}
               logger.Debug("规则判断完所用时间:", time.Since(start))
               ruleserver.GetAttachInfo(resultMsg.SdkMessage)
               ruleEnd := time.Since(start)
               logger.Debug("规则判断完所用时间:", ruleEnd)
               // 将打完标签的数据插入到ES
               insertdata.InsertToEs(resultMsg)
               logger.Debug("插入完Es所用时间:", time.Since(start))
               esEnd := time.Since(start)
               logger.Debug("插入完Es所用时间:", esEnd)
               //事件推送
               //go labelFilter.Judge(resultMsg)
               logger.OutPutByPanlei()
               labelFilter.PushSomthing(resultMsg)
            //}(msg)
         }
      }
@@ -160,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才有数据
@@ -201,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)
@@ -230,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
}