| | |
| | | |
| | | import ( |
| | | "basic.com/pubsub/protomsg.git" |
| | | "basic.com/fileServer/WeedFSClient.git" |
| | | "bytes" |
| | | "encoding/base64" |
| | | "errors" |
| | |
| | | faceArr, err, pI := service.GetFaceFeaFromSdk(fileBytes, time.Second*5) |
| | | if err ==nil && len(faceArr) >0 { |
| | | var faceBase64= "" |
| | | var field = "" |
| | | var rcFace *protomsg.Rect |
| | | for _,r := range faceArr { |
| | | rcFace = r.Pos.RcFace |
| | |
| | | } |
| | | //根据人脸坐标扣出人脸小图 |
| | | cutFaceImgData := util.SubImg(*pI, int(rcFace.Left), int(rcFace.Top), int(rcFace.Right), int(rcFace.Bottom)) |
| | | fileInfo, e := esutil.PostFormData(weedfsUri, "测试人脸切图", "file", cutFaceImgData) |
| | | if e != nil { |
| | | fmt.Println(e.Error()) |
| | | |
| | | weedFilePath, e := WeedFSClient.UploadFile(weedfsUri, "testCutFace", cutFaceImgData) |
| | | if e !=nil{ |
| | | util.ResponseFormat(c,code.ComError,"文件上传失败") |
| | | } else { |
| | | field = fileInfo[picUrlField].(string) // 文件路径 |
| | | util.ResponseFormat(c,code.Success,weedFilePath + ";" + faceBase64) |
| | | } |
| | | if strings.Contains(field,"/"){ |
| | | idx := strings.Index(field, "/") |
| | | field = field[idx+1:] |
| | | } |
| | | fmt.Println("field:",field) |
| | | util.ResponseFormat(c,code.Success,field + ";" + faceBase64) |
| | | } else { |
| | | util.ResponseFormat(c,code.ComError,"未提取到人脸") |
| | | } |