symcode/acute32/
symcode_config.rs1use visioncortex::PointF64;
2use crate::interfaces::{Debugger, DummyDebugger};
3use super::{Acute32Library, CircleFinder};
4
5pub struct Acute32SymcodeConfig {
6 pub symbol_library: Box<Acute32Library>, pub finder: CircleFinder,
8
9 pub code_width: usize,
10 pub code_height: usize,
11
12 pub symbol_width: usize,
13 pub symbol_height: usize,
14
15 pub finder_positions: Vec<PointF64>,
17 pub glyph_anchors: Vec<PointF64>,
19
20 pub max_extra_finder_candidates: usize,
21 pub rectify_error_threshold: f64,
22 pub stat_tolerance: f64,
23 pub max_encoding_difference: usize,
24 pub empty_cluster_threshold: f64,
25 pub quiet_zone_width: usize,
26
27 pub debugger: Box<dyn Debugger>,
28}
29
30impl Default for Acute32SymcodeConfig {
31 fn default() -> Self {
32 Self {
33 code_width: 785,
34 code_height: 785,
35 symbol_width: 155,
36 symbol_height: 155,
37 finder_positions: vec![
38 PointF64::new(392.0, 160.0),
39 PointF64::new(392.0, 392.0),
40 PointF64::new(160.0, 625.0),
41 PointF64::new(625.0, 625.0),
42 ],
43 glyph_anchors: vec![
44 PointF64::new(82.0, 82.0),
45 PointF64::new(82.0, 315.0),
46 PointF64::new(315.0, 547.0),
47 PointF64::new(547.0, 315.0),
48 PointF64::new(547.0, 82.0),
49 ],
50 max_extra_finder_candidates: 3,
51 rectify_error_threshold: 0.5,
52 stat_tolerance: 0.36,
53 max_encoding_difference: 3,
54 empty_cluster_threshold: 0.15,
55 symbol_library: Box::new(Acute32Library::default()),
56 finder: CircleFinder::default(),
57 quiet_zone_width: 10,
58 debugger: Box::new(DummyDebugger),
59 }
60 }
61}
62
63impl Acute32SymcodeConfig {
64 #[inline]
65 pub fn max_finder_candidates(&self) -> usize {
66 self.finder_positions.len() + self.max_extra_finder_candidates
67 }
68
69 #[inline]
70 pub fn absolute_empty_cluster_threshold(&self, image_width: usize, image_height: usize) -> u64 {
71 (self.empty_cluster_threshold * (image_width * image_height) as f64) as u64
72 }
73
74 #[inline]
75 pub fn num_glyphs_in_code(&self) -> usize {
76 self.glyph_anchors.len()
77 }
78}