panlei
2019-07-03 e34842cd216baafef7d0b5ec56aab5a24362986c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package util
 
import (
    "basic.com/pubsub/protomsg.git"
    "gocv.io/x/gocv"
    "image"
)
// 按尺寸去切图
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(x0,y0,x1,y1)
    region := img.Region(rect)
    bytes, _ := gocv.IMEncode(".jpg", region)
    return bytes
}