| | |
| | | "net/http" |
| | | _ "net/http/pprof" |
| | | "ruleprocess/insertdata" |
| | | "ruleprocess/labelFilter" |
| | | "ruleprocess/structure" |
| | | "ruleprocess/util" |
| | | "time" |
| | | |
| | | //"bufio" |
| | | //"bytes" |
| | | "basic.com/valib/logger.git" |
| | | "flag" |
| | | "fmt" |
| | | "github.com/golang/protobuf/proto" |
| | | "basic.com/valib/logger.git" |
| | | //"gocv.io/x/gocv" |
| | | //"image" |
| | | //"image/color" |
| | | //"os" |
| | | "github.com/spf13/viper" |
| | | "ruleprocess/cache" |
| | | "ruleprocess/ruleserver" |
| | | "sync" |
| | | "github.com/spf13/viper" |
| | | ) |
| | | |
| | | var dbIp = flag.String("dbIp", "127.0.0.1", "dbserver ip") |
| | |
| | | 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) |
| | |
| | | } 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) |
| | |
| | | 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) |
| | | //}(msg) |
| | | //labelFilter.PushSomthing(resultMsg) |
| | | }(msg) |
| | | } |
| | | } |
| | | } |
| | |
| | | // 将外部传进来的rect(top,bottom,left,right)转化为自己内部的rect(left top width height) |
| | | func rectFormat(rcobj *protomsg.Rect) structure.Rect { |
| | | //logger.Info("++++++++++++++++++++++++++++++收到的yolo的区域坐标:",rcobj) |
| | | rect := ruleserver.Rect{} |
| | | rect := structure.Rect{} |
| | | rect.X = float64(rcobj.Left) |
| | | rect.Y = float64(rcobj.Top) |
| | | rect.Width = float64(rcobj.Right - rcobj.Left) |
| | |
| | | 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, IsYolo: true} |
| | | photoMap := structure.PhotoMap{Rects: rectFormat(info.RcObj), Score: float64(info.Prob) * 100, IsYolo: true,Id:info.ObjID} |
| | | arg.Photo = append(arg.Photo, photoMap) |
| | | yoloNum++ |
| | | } |