From fa7f3adbefe5bbe533fcfd098bc874f603520a06 Mon Sep 17 00:00:00 2001 From: panlei <2799247126@qq.com> Date: 星期二, 02 七月 2019 20:37:11 +0800 Subject: [PATCH] likeDat额、 --- util/image.go | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/util/image.go b/util/image.go index 2673449..794215c 100644 --- a/util/image.go +++ b/util/image.go @@ -1,11 +1,13 @@ package util import ( + "basic.com/pubsub/protomsg.git" "gocv.io/x/gocv" "image" + "log" ) // 鎸夊昂瀵稿幓鍒囧浘 -func Subimg(dbyte []byte,x0,y0,x1,y1 int,) []byte{ +func SubImg(i protomsg.Image,x0,y0,x1,y1 int,) []byte{ //bbb := bytes.NewBuffer(dbyte) // 蹇呴』鍔犱竴涓猙uffer 涓嶇劧娌℃湁read鏂规硶灏变細鎶ラ敊 ////log.Println("==================鐪嬬湅杩欎釜buffer",bbb) @@ -24,9 +26,10 @@ //f, _ := os.Create("./test.jpg") //鍒涘缓鏂囦欢 //defer f.Close() //鍏抽棴鏂囦欢 //jpeg.Encode(f, subImg, nil) //鍐欏叆鏂囦欢 - - img,_ := gocv.NewMatFromBytes(int(y1-y0),int(x1-x0),gocv.MatTypeCV8UC3,dbyte) - region := img.Region(image.Rectangle{image.Point{x0,y0},image.Point{x1,y1}}) + log.Println("--------------------------鍥涘ぇ閲戝垰锛�",x0,y0,x1,y1) + 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 -} \ No newline at end of file +} -- Gitblit v1.8.0