ui_detection.proto 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. syntax = "proto3";
  15. package google.chromeos.uidetection.v1;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. option go_package = "google.golang.org/genproto/googleapis/chromeos/uidetection/v1;uidetection";
  20. option java_multiple_files = true;
  21. option java_outer_classname = "UiDetectionProto";
  22. option java_package = "com.google.chromeos.uidetection.v1";
  23. // Provides image-based UI detection service.
  24. service UiDetectionService {
  25. option (google.api.default_host) = "chromeosuidetection.googleapis.com";
  26. // Runs the detection.
  27. rpc ExecuteDetection(UiDetectionRequest) returns (UiDetectionResponse) {
  28. option (google.api.http) = {
  29. get: "/v1/executeDetection:execute"
  30. };
  31. }
  32. }
  33. // Request message for UI detection.
  34. message UiDetectionRequest {
  35. // Required. Required field that represents a PNG image.
  36. bytes image_png = 1 [(google.api.field_behavior) = REQUIRED];
  37. // Required. Required field that indicates the detection type.
  38. DetectionRequest request = 2 [(google.api.field_behavior) = REQUIRED];
  39. }
  40. // Detection type specifies what to detect in the image.
  41. message DetectionRequest {
  42. oneof detection_request_type {
  43. // Detection type for word detection.
  44. WordDetectionRequest word_detection_request = 1;
  45. // Detection type for text block detection.
  46. TextBlockDetectionRequest text_block_detection_request = 2;
  47. // Detection type for custom icon detection.
  48. CustomIconDetectionRequest custom_icon_detection_request = 3;
  49. }
  50. }
  51. // Detection type for word detection.
  52. message WordDetectionRequest {
  53. // Required. The word to locate in the image.
  54. string word = 1 [(google.api.field_behavior) = REQUIRED];
  55. // Indicating whether the query string is a regex or not.
  56. bool regex_mode = 2;
  57. // Indicating whether the detection is an approximate match.
  58. bool disable_approx_match = 3;
  59. // Levenshtein distance threshold.
  60. // Applicable only if regex_mode is False.
  61. optional int32 max_edit_distance = 4;
  62. }
  63. // Detection type for text block detection.
  64. message TextBlockDetectionRequest {
  65. // Required. The text block consisting a list of words to locate in the image.
  66. repeated string words = 1 [(google.api.field_behavior) = REQUIRED];
  67. // Indicating whether the query string is a regex or not.
  68. bool regex_mode = 2;
  69. // Indicating whether the detection is an approximate match.
  70. bool disable_approx_match = 3;
  71. // Levenshtein distance threshold.
  72. // Applicable only if regex_mode is False.
  73. optional int32 max_edit_distance = 4;
  74. }
  75. // Detection type for custom icon detection.
  76. message CustomIconDetectionRequest {
  77. // Required. Required field that represents an icon in PNG format.
  78. bytes icon_png = 1 [(google.api.field_behavior) = REQUIRED];
  79. // Set match_count to -1 to not limit the number of matches.
  80. int32 match_count = 2;
  81. // Confidence threshold in the range [0.0, 1.0] below which the matches will
  82. // be considered as non-existent.
  83. double min_confidence_threshold = 3;
  84. }
  85. // Response message for UI detection.
  86. message UiDetectionResponse {
  87. // Locations of matching UI elements.
  88. repeated BoundingBox bounding_boxes = 1;
  89. }
  90. // The location of a UI element.
  91. // A bounding box is reprensented by its top-left point [left, top]
  92. // and its bottom-right point [right, bottom].
  93. message BoundingBox {
  94. // The text found in the bounding box.
  95. string text = 1;
  96. // The y-coordinate of the top-left point.
  97. int32 top = 2;
  98. // The x-coordinate of the top-left point.
  99. int32 left = 3;
  100. // The y-coordinate of the bottom-right point.
  101. int32 bottom = 4;
  102. // The x-coordinate of the bottom-right point.
  103. int32 right = 5;
  104. }