| | |
| | | "crypto/tls" |
| | | "encoding/hex" |
| | | "encoding/json" |
| | | "image" |
| | | "io" |
| | | "io/ioutil" |
| | | "net" |
| | |
| | | "webserver/extend/code" |
| | | |
| | | "basic.com/pubsub/protomsg.git" |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/pierrec/lz4" |
| | | "gocv.io/x/gocv" |
| | | |
| | | "crypto/rand" |
| | | "fmt" |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/pierrec/lz4" |
| | | "reflect" |
| | | "strings" |
| | | ) |
| | |
| | | return nil, err |
| | | } |
| | | return pix, nil |
| | | } |
| | | |
| | | // 按尺寸去切图 |
| | | 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) |
| | | bytes, _ := gocv.IMEncode(".jpg", region) |
| | | return bytes |
| | | } |
| | | |
| | | // 长宽变为一比一,每边各扩百分之20 |