opencv_binding_generator/settings/
generator_module_tweaks.rs

1use super::TypeRefFactory;
2use crate::type_ref::TypeRefDesc;
3
4#[derive(Debug)]
5pub struct ModuleTweak<'l> {
6	pub generate_types: &'l [TypeRefFactory],
7}
8
9impl ModuleTweak<'_> {
10	pub fn empty() -> Self {
11		Self { generate_types: &[] }
12	}
13}
14
15pub fn generator_module_tweaks_factory(module: &str) -> ModuleTweak<'static> {
16	match module {
17		"core" => ModuleTweak {
18			generate_types: &[
19				TypeRefDesc::ptr_of_float,
20				// for the `field_access_on_ptr` test
21				TypeRefDesc::ptr_of_cv_keypoint,
22			],
23		},
24		"aruco" => ModuleTweak {
25			generate_types: &[TypeRefDesc::vector_of_cv_vec3f, TypeRefDesc::vector_of_cv_vec3d],
26		},
27		"ccalib" => ModuleTweak {
28			generate_types: &[
29				// for cv::omnidir::calibrate objectPoints
30				TypeRefDesc::vector_of_vector_of_cv_vec3f,
31				TypeRefDesc::vector_of_vector_of_cv_vec3d,
32				TypeRefDesc::vector_of_vector_of_cv_point3f,
33				TypeRefDesc::vector_of_vector_of_cv_point3d,
34				// for cv::omnidir::calibrate imagePoints
35				TypeRefDesc::vector_of_vector_of_cv_vec2f,
36				TypeRefDesc::vector_of_vector_of_cv_point2f,
37				TypeRefDesc::vector_of_vector_of_cv_vec2d,
38				TypeRefDesc::vector_of_vector_of_cv_point2d,
39			],
40		},
41		"calib3d" | "calib" | "3d" => ModuleTweak {
42			generate_types: &[
43				// for calibrate_camera
44				TypeRefDesc::vector_of_cv_point3i,
45				TypeRefDesc::vector_of_vector_of_cv_point3i,
46				TypeRefDesc::vector_of_cv_point3f,
47				TypeRefDesc::vector_of_vector_of_cv_point3f,
48				TypeRefDesc::vector_of_cv_point3d,
49				TypeRefDesc::vector_of_vector_of_cv_point3d,
50				TypeRefDesc::vector_of_cv_vec3f,
51				TypeRefDesc::vector_of_vector_of_cv_vec3f,
52				// for solve_pnp tvec and rvec parameters
53				TypeRefDesc::vector_of_vector_of_double,
54				// for solve_pnp_ransac imagePoints parameter
55				TypeRefDesc::vector_of_cv_point2d,
56			],
57		},
58		"dnn" => ModuleTweak {
59			generate_types: &[TypeRefDesc::vector_of_vector_of_int], // Make sure that `Vector<MatShape>` is generated
60		},
61		"features2d" | "features" => ModuleTweak {
62			// type used in other modules, thus needs casting (https://github.com/twistedfall/opencv-rust/issues/218)
63			generate_types: &[TypeRefDesc::ptr_of_cv_feature2d],
64		},
65		"imgproc" => ModuleTweak {
66			generate_types: &[
67				// for findContours()
68				TypeRefDesc::vector_of_cv_vec4i,
69				TypeRefDesc::vector_of_vector_of_cv_point,
70				// for HoughLines()
71				TypeRefDesc::vector_of_cv_vec2f,
72				TypeRefDesc::vector_of_cv_vec2d,
73				TypeRefDesc::vector_of_cv_vec3f,
74				TypeRefDesc::vector_of_cv_vec3d,
75			],
76		},
77		_ => ModuleTweak::empty(),
78	}
79}