Skip to content

Commit

Permalink
商品抠图新增参数
Browse files Browse the repository at this point in the history
  • Loading branch information
lilang authored and jojoliang committed Nov 22, 2022
1 parent d427a5c commit b6a81ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 7 additions & 1 deletion ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -1882,11 +1882,17 @@ func (s *CIService) LivenessRecognitionWhenUpload(ctx context.Context, obj, file
return &res, resp, err
}

type GoodsMattingptions struct {
CenterLayout string `url:"center-layout,omitempty"`
PaddingLayout string `url:"padding-layout,omitempty"`
}

// GoodsMatting 商品抠图
func (s *CIService) GoodsMatting(ctx context.Context, key string) (*Response, error) {
func (s *CIService) GoodsMatting(ctx context.Context, key string, opt *GoodsMattingptions) (*Response, error) {
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/" + encodeURIComponent(key) + "?ci-process=GoodsMatting",
optQuery: opt,
method: http.MethodGet,
disableCloseBody: true,
}
Expand Down
10 changes: 7 additions & 3 deletions example/CI/ai_recognition/goods_matting.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func goodsMattingWhenUpload() {
Rules: []cos.PicOperationsRules{
{
FileId: "pic/out.jpeg",
Rule: "ci-process=GoodsMatting",
Rule: "ci-process=GoodsMatting&center-layout=1&padding-layout=500x500",
},
},
}
Expand Down Expand Up @@ -94,7 +94,11 @@ func goodsMattingWhenDownload() {

key := "pic/cup.jpeg"
localPath := "cup.jpeg"
resp, err := c.CI.GoodsMatting(context.Background(), key)
opt := &cos.GoodsMattingptions{
CenterLayout: "1",
PaddingLayout: "500x500",
}
resp, err := c.CI.GoodsMatting(context.Background(), key, opt)
log_status(err)
fd, _ := os.OpenFile(localPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0660)
io.Copy(fd, resp.Body)
Expand Down Expand Up @@ -124,7 +128,7 @@ func goodsMattingWhenCloud() {
Rules: []cos.PicOperationsRules{
{
FileId: "pic/cup_out.jpeg",
Rule: "ci-process=GoodsMatting",
Rule: "ci-process=GoodsMatting&center-layout=1&padding-layout=500x500",
},
},
}
Expand Down

0 comments on commit b6a81ed

Please sign in to comment.