简介
本文档提供关于图片搜索接口的相关 API 概览以及 SDK 示例代码。
API | 操作描述 |
该接口用于检索图片。 |
图片搜索接口
该接口用于检索图片。
方法原型
func (s *CIService) ImageSearch(ctx context.Context, name string, opt *ImageSearchOptions) (*ImageSearchResult, *Response, error)
请求示例
// 将 examplebucket-1250000000 和 COS_REGION 修改为真实的信息// CI 任务需要提供 CIURLbu, _ := url.Parse("https://examplebucket-1250000000.cos.COS_REGION.myqcloud.com")cu, _ := url.Parse("https://examplebucket-1250000000.ci.COS_REGION.myqcloud.com")b := &cos.BaseURL{BucketURL: bu, CIURL: cu}c := cos.NewClient(b, &http.Client{Transport: &cos.AuthorizationTransport{SecretID: os.Getenv("SECRETID"),SecretKey: os.Getenv("SECRETKEY"),}})opt := &cos.ImageSearchOptions{MatchThreshold: 60,}res, _, err := c.CI.ImageSearch(context.Background(), "pic/car.jpg", opt)log_status(err)fmt.Printf("%+v\\n", res)
参数说明
type ImageSearchOptions struct {MatchThreshold int `url:"MatchThreshold,omitempty"`Offset int `url:"Offset,omitempty"`Limit int `url:"Limit,omitempty"`Filter string `url:"Filter,omitempty"`}
参数名称 | 参数描述 | 类型 | 是否必填 |
MatchThreshold | 出参 Score 中,只有超过 MatchThreshold 值的结果才会返回。默认为0 | int | 否 |
Offset | 起始序号,默认值为0 | int | 否 |
Limit | 返回数量,默认值为10,最大值为100 | int | 否 |
Filter | 针对入库时提交的 Tags 信息进行条件过滤。支持>、>=、<、<=、=、!=,多个条件之间支持 AND 和 OR 进行连接 | string | 否 |