| | |
| | | "github.com/pkg/errors" |
| | | "github.com/satori/go.uuid" |
| | | "gocv.io/x/gocv" |
| | | "io/ioutil" |
| | | "mime/multipart" |
| | | "sync" |
| | | "time" |
| | | ) |
| | | |
| | | type FaceSdkService struct { |
| | | File *multipart.File |
| | | File []byte |
| | | Id string |
| | | Result []*protomsg.ResultFaceExtCom |
| | | } |
| | |
| | | Url_Service_PULL = Ipc_Url_Pre + Virtual_FaceSdkId + Ipc_Pull_Ext |
| | | ) |
| | | |
| | | func NewFaceSdkService(file multipart.File) FaceSdkService{ |
| | | func NewFaceSdkService(fileBytes []byte) FaceSdkService{ |
| | | return FaceSdkService{ |
| | | File:&file, |
| | | File:fileBytes, |
| | | Id:uuid.NewV4().String(), |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | func (s *FaceSdkService) ReadFromUploadImg() (*protomsg.Image,error){ |
| | | defer (*(s.File)).Close() |
| | | imgB, err := ioutil.ReadAll(*(s.File)) |
| | | if err !=nil{ |
| | | fmt.Println("File.Read err:",err) |
| | | return nil,err |
| | | } |
| | | //defer (*(s.File)).Close() |
| | | //imgB, err := ioutil.ReadAll(*(s.File)) |
| | | //if err !=nil{ |
| | | // fmt.Println("File.Read err:",err) |
| | | // return nil,err |
| | | //} |
| | | |
| | | picMat, err := gocv.IMDecode(imgB, gocv.IMReadColor) |
| | | picMat, err := gocv.IMDecode(s.File, gocv.IMReadColor) |
| | | if err !=nil { |
| | | fmt.Println("gocv.IMDecode err:",err) |
| | | return nil,err |