| | |
| | | "basic.com/pubsub/protomsg.git" |
| | | "bytes" |
| | | "encoding/base64" |
| | | "errors" |
| | | "fmt" |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/satori/go.uuid" |
| | |
| | | return nil,err |
| | | } |
| | | s.PushImgMsg(bc) |
| | | return s.GetFaceFea() |
| | | s.GetFaceFea() |
| | | if s.Result == nil{ |
| | | return nil,errors.New("no fea") |
| | | } else { |
| | | return s.Result,nil |
| | | } |
| | | } |
| | | |
| | | /**上传方法**/ |
| | |
| | | type FaceSdkService struct { |
| | | File *multipart.File |
| | | Id string |
| | | Result []*protomsg.ResultFaceExtCom |
| | | } |
| | | |
| | | const ( |
| | |
| | | } |
| | | } |
| | | |
| | | func (s *FaceSdkService) GetFaceFea() (feas []*protomsg.ResultFaceExtCom,err error){ |
| | | func (s *FaceSdkService) GetFaceFea(){ |
| | | var wg sync.WaitGroup |
| | | wg.Add(1) |
| | | ch := make(chan []*protomsg.ResultFaceExtCom,0) |
| | | |
| | | go func() { |
| | | for { |
| | | select { |
| | | case <-time.Tick(time.Second*5): |
| | | case <-time.Tick(time.Second*2): |
| | | fmt.Println("倒计时结束") |
| | | ch <- nil |
| | | wg.Done() |
| | | return |
| | | default: |
| | | if feas,ok := resultMap[s.Id];ok { |
| | | fmt.Println("faceFea got!!!") |
| | | ch <- feas |
| | | s.Result = feas |
| | | return |
| | | } else { |
| | | fmt.Println("尚未拿到fea") |
| | |
| | | fmt.Println("wa.Wait") |
| | | wg.Wait() |
| | | fmt.Println("<-ch") |
| | | msg := <- ch |
| | | if msg != nil { |
| | | return msg,nil |
| | | } else { |
| | | return msg,errors.New("no fea") |
| | | } |
| | | } |
| | | |
| | | func readTestImgFile() protomsg.Image{ |