• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2019 Google LLC.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15
16syntax = "proto3";
17
18package google.cloud.vision.v1p4beta1;
19
20import "google/api/resource.proto";
21import "google/cloud/vision/v1p4beta1/geometry.proto";
22import "google/cloud/vision/v1p4beta1/product_search_service.proto";
23import "google/protobuf/timestamp.proto";
24
25option cc_enable_arenas = true;
26option go_package = "cloud.google.com/go/vision/apiv1p4beta1/visionpb;visionpb";
27option java_multiple_files = true;
28option java_outer_classname = "ProductSearchProto";
29option java_package = "com.google.cloud.vision.v1p4beta1";
30option objc_class_prefix = "GCVN";
31
32// Parameters for a product search request.
33message ProductSearchParams {
34  // The bounding polygon around the area of interest in the image.
35  // If it is not specified, system discretion will be applied.
36  BoundingPoly bounding_poly = 9;
37
38  // The resource name of a
39  // [ProductSet][google.cloud.vision.v1p4beta1.ProductSet] to be searched for
40  // similar images.
41  //
42  // Format is:
43  // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`.
44  string product_set = 6 [(google.api.resource_reference) = {
45    type: "vision.googleapis.com/ProductSet"
46  }];
47
48  // The list of product categories to search in. Currently, we only consider
49  // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2",
50  // "packagedgoods-v1", or "general-v1" should be specified. The legacy
51  // categories "homegoods", "apparel", and "toys" are still supported but will
52  // be deprecated. For new products, please use "homegoods-v2", "apparel-v2",
53  // or "toys-v2" for better product search accuracy. It is recommended to
54  // migrate existing products to these categories as well.
55  repeated string product_categories = 7;
56
57  // The filtering expression. This can be used to restrict search results based
58  // on Product labels. We currently support an AND of OR of key-value
59  // expressions, where each expression within an OR must have the same key. An
60  // '=' should be used to connect the key and value.
61  //
62  // For example, "(color = red OR color = blue) AND brand = Google" is
63  // acceptable, but "(color = red OR brand = Google)" is not acceptable.
64  // "color: red" is not acceptable because it uses a ':' instead of an '='.
65  string filter = 8;
66}
67
68// Results for a product search request.
69message ProductSearchResults {
70  // Information about a product.
71  message Result {
72    // The Product.
73    Product product = 1;
74
75    // A confidence level on the match, ranging from 0 (no confidence) to
76    // 1 (full confidence).
77    float score = 2;
78
79    // The resource name of the image from the product that is the closest match
80    // to the query.
81    string image = 3;
82  }
83
84  // Prediction for what the object in the bounding box is.
85  message ObjectAnnotation {
86    // Object ID that should align with EntityAnnotation mid.
87    string mid = 1;
88
89    // The BCP-47 language code, such as "en-US" or "sr-Latn". For more
90    // information, see
91    // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
92    string language_code = 2;
93
94    // Object name, expressed in its `language_code` language.
95    string name = 3;
96
97    // Score of the result. Range [0, 1].
98    float score = 4;
99  }
100
101  // Information about the products similar to a single product in a query
102  // image.
103  message GroupedResult {
104    // The bounding polygon around the product detected in the query image.
105    BoundingPoly bounding_poly = 1;
106
107    // List of results, one for each product match.
108    repeated Result results = 2;
109
110    // List of generic predictions for the object in the bounding box.
111    repeated ObjectAnnotation object_annotations = 3;
112  }
113
114  // Timestamp of the index which provided these results. Products added to the
115  // product set and products removed from the product set after this time are
116  // not reflected in the current results.
117  google.protobuf.Timestamp index_time = 2;
118
119  // List of results, one for each product match.
120  repeated Result results = 5;
121
122  // List of results grouped by products detected in the query image. Each entry
123  // corresponds to one bounding polygon in the query image, and contains the
124  // matching products specific to that region. There may be duplicate product
125  // matches in the union of all the per-product results.
126  repeated GroupedResult product_grouped_results = 6;
127}
128