oneocr_rs/ocr_options.rs
1/// A simple width×height pair.
2#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3pub struct Resolution {
4 pub width: i32,
5 pub height: i32,
6}
7
8impl Default for Resolution {
9 fn default() -> Self {
10 Resolution {
11 width: 1152,
12 height: 768,
13 }
14 }
15}
16
17/// Configuration for OCR processing behavior.
18#[derive(Debug, Clone, PartialEq, Eq, Hash)]
19pub struct OcrOptions {
20 /// The maximum number of lines that can be recognized.
21 /// Default is 100, range is 0-1000.
22 pub max_recognition_line_count: i32,
23
24 /// The maximum internal resize resolution (width, height).
25 ///
26 /// The `resize resolution` defines the maximum dimensions to which an image will be automatically scaled internally before OCR processing.
27 /// It’s a performance and accuracy trade-off rather than a restriction on the original image’s resolution.
28 ///
29 /// The default and maximum resolution is (1152, 768).
30 pub resize_resolution: Resolution,
31
32 /// Whether to include word-level details in the result.
33 /// If `true`, the result will contain bounding boxes and confidence scores for individual words.
34 /// If `false`, only line-level information will be available.
35 pub include_word_level_details: bool,
36}
37
38impl Default for OcrOptions {
39 fn default() -> Self {
40 OcrOptions {
41 max_recognition_line_count: 100,
42 resize_resolution: Resolution::default(),
43 include_word_level_details: false,
44 }
45 }
46}