| | |
| | | "basic.com/pubsub/cache.git/esutil" |
| | | "basic.com/pubsub/protomsg.git" |
| | | "encoding/json" |
| | | "errors" |
| | | "fmt" |
| | | "github.com/go-yaml/yaml" |
| | | "io/ioutil" |
| | |
| | | "nanomsg.org/go-mangos" |
| | | "nanomsg.org/go-mangos/protocol/req" |
| | | "nanomsg.org/go-mangos/transport/tcp" |
| | | "net" |
| | | "os" |
| | | "ruleprocess/cache" |
| | | "ruleprocess/logger" |
| | |
| | | CompareThreshold:compareThreshold, |
| | | Source:false, |
| | | } |
| | | bytes := Push("tcp://192.168.1.182:40010",comArg,sock) |
| | | serverIp, _ := GetLocalIP() |
| | | bytes := Push("tcp://"+serverIp+":40010",comArg,sock) |
| | | var scResult protomsg.SdkCompareResult |
| | | err1 := proto.Unmarshal(bytes, &scResult) |
| | | if err1 != nil { |
| | |
| | | if threshold <= obj.Score && size <= float64(obj.Rects.Width*obj.Rects.Height) && intersectionper <= PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale) { |
| | | // 这步要备齐表达式里所需要的所有参数 |
| | | a.TargetNum++ |
| | | arg1 := structure.Arg{obj.Id,obj.Score, PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale), float64(obj.Rects.Width * obj.Rects.Height), obj.IsYolo, obj.Rects, obj.Feature, obj.ThftRes, []*BaseInfo{}} |
| | | arg1 := structure.Arg{obj.Id,obj.Score, PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale), float64(obj.Rects.Width * obj.Rects.Height), obj.IsYolo, obj.Rects, obj.Feature, obj.ThftRes, []*structure.BaseInfo{}} |
| | | //logger.Println("放进去的arg:-------", arg1) |
| | | a.Args = append(a.Args, &arg1) |
| | | a.FilterData = append(a.FilterData, &arg1) |
| | |
| | | logger.Debug("数据推送成功!收到响应,数据长度为:",len(msg)) |
| | | return msg |
| | | } |
| | | |
| | | // 获取本机ip |
| | | func GetLocalIP() (ipv4 string, err error) { |
| | | var ( |
| | | addrs []net.Addr |
| | | addr net.Addr |
| | | ipNet *net.IPNet // IP地址 |
| | | isIpNet bool |
| | | ) |
| | | // 获取所有网卡 |
| | | if addrs, err = net.InterfaceAddrs(); err != nil { |
| | | return |
| | | } |
| | | // 取第一个非lo的网卡IP |
| | | for _, addr = range addrs { |
| | | // 这个网络地址是IP地址: ipv4, ipv6 |
| | | if ipNet, isIpNet = addr.(*net.IPNet); isIpNet && !ipNet.IP.IsLoopback() { |
| | | // 跳过IPV6 |
| | | if ipNet.IP.To4() != nil { |
| | | ipv4 = ipNet.IP.String() // 192.168.1.1 |
| | | return |
| | | } |
| | | } |
| | | } |
| | | |
| | | err = errors.New("ipv4 not found") |
| | | return |
| | | } |