Module: JPSClient::API::ImageSearch
- Included in:
- Client
- Defined in:
- lib/jpsclient/api/image_search.rb
Overview
ImageSearch 相关 API 处理图片搜索相关接口
Instance Method Summary collapse
-
#search_image_by_image(image_url: nil, image_data: nil, limit: 10, threshold: 0.7) ⇒ Hash
通过图片搜索相似图片(以图搜图).
-
#search_image_by_text(query:, limit: 10, offset: 0) ⇒ Hash
通过文本搜索相似图片.
Instance Method Details
#search_image_by_image(image_url: nil, image_data: nil, limit: 10, threshold: 0.7) ⇒ Hash
通过图片搜索相似图片(以图搜图)
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/jpsclient/api/image_search.rb', line 34 def search_image_by_image(image_url: nil, image_data: nil, limit: 10, threshold: 0.7) config = @request_config && @request_config["image_search_by_image"] raise JPSClient::ExceptionError, "Missing config for image_search_by_image" unless config && config["url"] # 验证参数 unless image_url || image_data raise JPSClient::ExceptionError, "Either image_url or image_data must be provided" end path = config["url"] params = { limit: limit, threshold: threshold } params[:image_url] = image_url if image_url params[:image_data] = image_data if image_data return request_with_auth(:get, path, params: params) end |
#search_image_by_text(query:, limit: 10, offset: 0) ⇒ Hash
通过文本搜索相似图片
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jpsclient/api/image_search.rb', line 13 def search_image_by_text(query:, limit: 10, offset: 0) config = @request_config && @request_config["image_search_by_text"] raise JPSClient::ExceptionError, "Missing config for image_search_by_text" unless config && config["url"] path = config["url"] params = { query: query, limit: limit, offset: offset } return request_with_auth(:get, path, params: params) end |