1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59

ash / webui / camera_app_ui / ocr.mojom [blame]

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module ash.camera_app.mojom;

import "ui/gfx/geometry/mojom/geometry.mojom";

// Writing direction of a word.
enum WordDirection {
  kLeftToRight,
  kRightToLeft,
};

// OCR result for a given image.
struct OcrResult {
  array<Line> lines;
};


// Text line with associated bounding box.
struct Line {
  // Words in the text line.
  array<Word> words;

  // Text line in UTF-8 format.
  string text;

  // Line bounding box relative to the original image.
  gfx.mojom.Rect bounding_box;

  // Rotation angle (in degrees, clockwise) of the line bounding box about its
  // top-left corner.
  float bounding_box_angle;

  // Language guess for the line. The format is the ISO 639-1 two-letter
  // language code if that is defined (e.g. "en"), or else the ISO 639-2
  // three-letter code if that is defined, or else a Google-specific code.
  string language;

  // Confidence as computed by the OCR engine. The value is in range [0, 1].
  float confidence;
};

// Word with associated bounding box.
struct Word {
  // A single word in UTF-8 format.
  string text;

  // Word bounding box relative to the original image.
  gfx.mojom.Rect bounding_box;

  // Rotation angle (in degrees, clockwise) of the word bounding box about its
  // top-left corner.
  float bounding_box_angle;

  // The direction of the script contained in the word.
  WordDirection direction;
};