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