---
panlei
2019-07-03 b0fecafd3e44fa7919249e01e7f6446e1214d46a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
}