| | |
| | | |
| | | import ( |
| | | "basic.com/dbapi.git" |
| | | bigCache "basic.com/pubsub/cache.git" |
| | | "basic.com/pubsub/protomsg.git" |
| | | "encoding/json" |
| | | "errors" |
| | | "fmt" |
| | | "github.com/go-yaml/yaml" |
| | | "github.com/golang/protobuf/proto" |
| | | "io/ioutil" |
| | | "math" |
| | | "nanomsg.org/go-mangos" |
| | | "nanomsg.org/go-mangos/protocol/req" |
| | |
| | | } |
| | | |
| | | func Init() { |
| | | data, err := ioutil.ReadFile("./config/conf.yml") |
| | | if err != nil { |
| | | fmt.Println("读取配置文件出错--", err) |
| | | logger.Error("读取配置文件出错--", err) |
| | | } |
| | | c := conf{} |
| | | //把yaml形式的字符串解析成struct类型 |
| | | yaml.Unmarshal(data, &c) |
| | | logger.Debug("配置文件的值为:", c) |
| | | serverIp = c.ServerIp |
| | | serverPort = c.ServerPort |
| | | dbTablePersons = c.DbTablePersons |
| | | localConfig, err1 := cache.GetServerInfo() |
| | | if err1 != nil { |
| | | logger.Error("查询本机信息失败!") |
| | | } |
| | | logger.Debug("本机信息和server信息:", localConfig, serverIp, serverPort) |
| | | bigCache.Init(dbTablePersons, serverIp, serverPort, localConfig.ServerId) |
| | | Push1() |
| | | //logger.Debug("本机信息和server信息:", localConfig, serverIp, serverPort) |
| | | //bigCache.Init(dbTablePersons, serverIp, serverPort, localConfig.ServerId) |
| | | go Push1() |
| | | } |
| | | |
| | | var sender chan *protomsg.CompareArgs = make(chan *protomsg.CompareArgs) |
| | |
| | | } |
| | | } |
| | | logger.Debug("当前数据帧要匹配的规则组:-------------------------","摄像机id:",cameraId,"任务id",taskId) |
| | | for _,ruleGroup := range taskGroup.GroupRules{ |
| | | logger.Info(ruleGroup.GroupText) |
| | | if taskGroup == nil { |
| | | return nil |
| | | } else { |
| | | for _,ruleGroup := range taskGroup.GroupRules{ |
| | | logger.Info(ruleGroup.GroupText) |
| | | } |
| | | return taskGroup |
| | | } |
| | | return taskGroup |
| | | } |
| | | |
| | | // 根据摄像机id拿到摄像机所有区域 |
| | | func GetPolygons(cameraId string) []protomsg.CameraPolygon { |
| | | var cameraPolygons []protomsg.CameraPolygon |
| | | cameraPolygons = cache.GetPolygonsByCameraId(cameraId) |
| | | //logger.Debug("------=======查看下全部区域:",cameraPolygons) |
| | | logger.Debug("------=======查看下全部区域:",cameraPolygons) |
| | | return cameraPolygons |
| | | } |
| | | |
| | |
| | | func (a *AreaMap) CountAreaObjs(arg *SdkData) { |
| | | |
| | | a.targetNum = 0 |
| | | threshold := 0.0 // 相似度 |
| | | threshold := 80.0 // 相似度 |
| | | intersectionper := 0.2 // 占比 |
| | | size := 0.0 // 尺寸 |
| | | |
| | |
| | | if errSize != nil { |
| | | logger.Error("Failed set MaxRecvSize: %v", err) |
| | | } |
| | | //sock.AddTransport(ipc.NewTransport()) |
| | | sock.AddTransport(tcp.NewTransport()) |
| | | serverIP, _ := GetLocalIP() |
| | | if err = sock.Dial("tcp://"+serverIP+":4010"); err != nil { |
| | | logger.Error("请求socket拨号失败: %s", err.Error()) |
| | | } |
| | | //sock.AddTransport(ipc.NewTransport()) |
| | | sock.AddTransport(tcp.NewTransport()) |
| | | |
| | | logger.Info("序列化数据") |
| | | |
| | | for { |