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