From b5df418bd3a9a332caa1559e96136c149b6f0e44 Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期二, 06 八月 2019 13:57:05 +0800
Subject: [PATCH] log

---
 service/FaceSdkService.go |   21 +++++++++------------
 1 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/service/FaceSdkService.go b/service/FaceSdkService.go
index da02375..148375f 100644
--- a/service/FaceSdkService.go
+++ b/service/FaceSdkService.go
@@ -8,6 +8,7 @@
 	"github.com/pkg/errors"
 	"github.com/satori/go.uuid"
 	"gocv.io/x/gocv"
+	"image"
 	"sync"
 	"time"
 	"webserver/extend/logger"
@@ -33,24 +34,19 @@
 )
 
 func GetFaceFeaFromSdk(fileBytes []byte,deadTime time.Duration) ([]*protomsg.ResultFaceDetect,error,*protomsg.Image){
-	tStart :=time.Now()
 	s := NewFaceSdkService(fileBytes, deadTime)
 	i, err := s.ReadFromUploadImg()
-	logger.Debug("ReadFromUploadImg鐢ㄦ椂锛�", time.Since(tStart))
 	if err !=nil{
 		logger.Debug("readFromUploadImg err:",err)
 		return nil,err,i
 	}
 	bc, err := ImgCompress(i)
-	logger.Debug("ImgCompress鐢ㄦ椂锛�", time.Since(tStart))
 	if err !=nil {
 		logger.Debug("ImgCompress err:",err)
 		return nil,err,i
 	}
 	s.PushImgMsg(bc)
-	t1 := time.Now()
 	s.GetFaceFea()
-	logger.Debug("GetFaceFea鐢ㄦ椂:", time.Since(t1))
 	if s.Result == nil{
 		return nil,errors.New("no fea"),i
 	} else {
@@ -87,19 +83,20 @@
 }
 
 func (s *FaceSdkService) ReadFromUploadImg() (*protomsg.Image,error){
-	//defer (*(s.File)).Close()
-	//imgB, err := ioutil.ReadAll(*(s.File))
-	//if err !=nil{
-	//	logger.Debug("File.Read err:",err)
-	//	return nil,err
-	//}
-
 	picMat, err := gocv.IMDecode(s.File, gocv.IMReadColor)
 	if err !=nil {
 		logger.Debug("gocv.IMDecode err:",err)
 		return nil,err
 	}
+	newMat := gocv.NewMat()
+	if picMat.Rows() > 1000 || picMat.Cols() > 1000 {
+		gocv.Resize(picMat,&newMat, image.Pt(0,0), 0.5,  0.5, gocv.InterpolationDefault)
+		picMat = newMat
+	}
+
 	defer picMat.Close()
+	defer newMat.Close()
+
 	if picMat.Empty() {
 		logger.Debug("file not exist")
 		return nil,errors.New("picMat is empty")

--
Gitblit v1.8.0