zhangzengfei
2019-10-21 e871758bd82d9a4fbce42e43c9665d869c240dfb
extend/util/util.go
@@ -1,14 +1,9 @@
package util
import (
   "basic.com/pubsub/protomsg.git"
   "bytes"
   "encoding/json"
   "errors"
   "github.com/gin-gonic/gin"
   "github.com/golang/glog"
   "github.com/pierrec/lz4"
   "gocv.io/x/gocv"
   "image"
   "io/ioutil"
   "net"
@@ -16,6 +11,12 @@
   "os/exec"
   "strconv"
   "webserver/extend/code"
   "basic.com/pubsub/protomsg.git"
   "github.com/gin-gonic/gin"
   "github.com/golang/glog"
   "github.com/pierrec/lz4"
   "gocv.io/x/gocv"
   "crypto/rand"
   "fmt"
@@ -93,7 +94,7 @@
}
// 按尺寸去切图
func SubImg(i protomsg.Image, x0, y0, x1, y1 int, ) []byte {
func SubImg(i protomsg.Image, x0, y0, x1, y1 int) []byte {
   img, _ := gocv.NewMatFromBytes(int(i.Height), int(i.Width), gocv.MatTypeCV8UC3, i.Data)
   rect := image.Rect(EnlargeSize(x0, y0, x1, y1, i))
   region := img.Region(rect)
@@ -135,7 +136,6 @@
   return
}
// 获取本机网卡IP
func GetLocalIP(networkName string) (ipv4 string,mask string, err error) {
   interfaces, err := net.Interfaces()
@@ -165,14 +165,14 @@
}
func GetDefaultRoute(networkName string)(route string,err error){
   cmdStr := fmt.Sprintf("route | grep -P \"^default.*%s$\" | awk '{print $2}'",networkName)
   cmdStr := fmt.Sprintf("ip route show | grep -P \"^default.*%s\" | awk '{print $3}'", networkName)
   cmd := exec.Command("/bin/sh","-c",cmdStr)
   b, err := cmd.Output()
   if err!=nil{
      return "",err
   }
   return string(b),nil
   return string(b), nil
}
func StringIpToInt(ipstring string) int {