0.57.0 Regenerate bindings
MODIFY
CHANGES.md
CHANGES.md
+* 0.57.0
+ * Add support for mathematical operations on `Mat` (kudos to fzyzcjy).
+ * `VecNT` (e.g. `Vec3b`) are now rewritten using const generics which makes them more flexible. That raises the minimum Rust
+ version requirement to 1.51. Also be mindful of the name clash between `opencv::core::Vec` and `std::vec::Vec`.
+ * Added mathematical operations on `Vec` that are available in the OpenCV library.
+ * Added support for generating bindings for the `==` operator.
+
* 0.56.1
* Structs that have infallible default constructors (e.g. `Mat`) now implement `Default` trait.
* Make sure to generate `std::vector<cv::Vec[23][fd]>` bindings for `imgproc::HoughLines` function.

MODIFY
Cargo.toml
Cargo.toml
@@ -6,7 +6,7 @@ repository = "https://github.com/twistedfall/opencv-rust"
readme = "README.md"
keywords = ["opencv", "vision"]
license = "MIT"
-version = "0.56.1"
+version = "0.57.0"
edition = "2018"
authors = ["Pro <twisted.fall@gmail.com>", "Mathieu Poumeyrol <kali@zoy.org>"]
autoexamples = false # not all examples compile on just any system
@@ -62,7 +62,7 @@ clang-runtime = ["clang/runtime"]
docs-only = []
[build-dependencies]
-binding-generator = { package = "opencv-binding-generator", version = "0.31.0", path = "binding-generator" }
+binding-generator = { package = "opencv-binding-generator", version = "0.32.0", path = "binding-generator" }
cc = { version = "1.0", features = ["parallel"] }
clang = { version = "1.0", features = ["clang_6_0"] }
dunce = "1.0"

MODIFY
binding-generator/Cargo.toml
binding-generator/Cargo.toml
name = "opencv-binding-generator"
description = "Binding generator for opencv crate"
repository = "https://github.com/twistedfall/opencv-rust"
-version = "0.31.0"
+version = "0.32.0"
license = "MIT"
authors = ["Pro <twisted.fall@gmail.com>"]
edition = "2018"

MODIFY
src/opencv/hub/core.rs
src/opencv/hub/core.rs
@@ -1693,28 +1693,28 @@ pub type Size2l = core::Size_<i64>;
pub type SparseMat_const_iterator = core::SparseMatConstIterator;
pub type SparseMat_iterator = core::SparseMatIterator;
/// @name Shorter aliases for the most popular specializations of Vec<T,n>
-pub type Vec2b = core::Vec2<u8>;
-pub type Vec2d = core::Vec2<f64>;
-pub type Vec2f = core::Vec2<f32>;
-pub type Vec2i = core::Vec2<i32>;
-pub type Vec2s = core::Vec2<i16>;
-pub type Vec2w = core::Vec2<u16>;
-pub type Vec3b = core::Vec3<u8>;
-pub type Vec3d = core::Vec3<f64>;
-pub type Vec3f = core::Vec3<f32>;
-pub type Vec3i = core::Vec3<i32>;
-pub type Vec3s = core::Vec3<i16>;
-pub type Vec3w = core::Vec3<u16>;
-pub type Vec4b = core::Vec4<u8>;
-pub type Vec4d = core::Vec4<f64>;
-pub type Vec4f = core::Vec4<f32>;
-pub type Vec4i = core::Vec4<i32>;
-pub type Vec4s = core::Vec4<i16>;
-pub type Vec4w = core::Vec4<u16>;
-pub type Vec6d = core::Vec6<f64>;
-pub type Vec6f = core::Vec6<f32>;
-pub type Vec6i = core::Vec6<i32>;
-pub type Vec8i = core::Vec8<i32>;
+pub type Vec2b = core::Vec<u8, 2>;
+pub type Vec2d = core::Vec<f64, 2>;
+pub type Vec2f = core::Vec<f32, 2>;
+pub type Vec2i = core::Vec<i32, 2>;
+pub type Vec2s = core::Vec<i16, 2>;
+pub type Vec2w = core::Vec<u16, 2>;
+pub type Vec3b = core::Vec<u8, 3>;
+pub type Vec3d = core::Vec<f64, 3>;
+pub type Vec3f = core::Vec<f32, 3>;
+pub type Vec3i = core::Vec<i32, 3>;
+pub type Vec3s = core::Vec<i16, 3>;
+pub type Vec3w = core::Vec<u16, 3>;
+pub type Vec4b = core::Vec<u8, 4>;
+pub type Vec4d = core::Vec<f64, 4>;
+pub type Vec4f = core::Vec<f32, 4>;
+pub type Vec4i = core::Vec<i32, 4>;
+pub type Vec4s = core::Vec<i16, 4>;
+pub type Vec4w = core::Vec<u16, 4>;
+pub type Vec6d = core::Vec<f64, 6>;
+pub type Vec6f = core::Vec<f32, 6>;
+pub type Vec6i = core::Vec<i32, 6>;
+pub type Vec8i = core::Vec<i32, 8>;
pub type GpuMatND_IndexArray = core::Vector<i32>;
pub type GpuMatND_SizeArray = core::Vector<i32>;
pub type GpuMatND_StepArray = core::Vector<size_t>;
@@ -5202,6 +5202,27 @@ pub fn div_f64_mat(s: f64, a: &core::Mat) -> Result<core::MatExpr> {
unsafe { sys::cv_operatorD_double_const_MatR(s, a.as_raw_Mat()) }.into_result().map(|r| unsafe { core::MatExpr::opencv_from_extern(r) } )
}
+/// @relates cv::FileNodeIterator
+#[inline]
+pub fn equals_filenode_iter(it1: &core::FileNodeIterator, it2: &core::FileNodeIterator) -> Result<bool> {
+ unsafe { sys::cv_operatorEQ_const_FileNodeIteratorR_const_FileNodeIteratorR(it1.as_raw_FileNodeIterator(), it2.as_raw_FileNodeIterator()) }.into_result()
+}
+
+#[inline]
+pub fn equals(a: &core::Mat, b: &core::Mat) -> Result<core::MatExpr> {
+ unsafe { sys::cv_operatorEQ_const_MatR_const_MatR(a.as_raw_Mat(), b.as_raw_Mat()) }.into_result().map(|r| unsafe { core::MatExpr::opencv_from_extern(r) } )
+}
+
+#[inline]
+pub fn equals_mat_f64(a: &core::Mat, s: f64) -> Result<core::MatExpr> {
+ unsafe { sys::cv_operatorEQ_const_MatR_double(a.as_raw_Mat(), s) }.into_result().map(|r| unsafe { core::MatExpr::opencv_from_extern(r) } )
+}
+
+#[inline]
+pub fn equals_f64_mat(s: f64, a: &core::Mat) -> Result<core::MatExpr> {
+ unsafe { sys::cv_operatorEQ_double_const_MatR(s, a.as_raw_Mat()) }.into_result().map(|r| unsafe { core::MatExpr::opencv_from_extern(r) } )
+}
+
#[inline]
pub fn sub_matexpr(e: &core::MatExpr) -> Result<core::MatExpr> {
unsafe { sys::cv_operatorS_const_MatExprR(e.as_raw_MatExpr()) }.into_result().map(|r| unsafe { core::MatExpr::opencv_from_extern(r) } )
@@ -12049,6 +12070,11 @@ pub trait MatSizeTraitConst {
unsafe { sys::cv_MatSize_operator_const_intX_const(self.as_raw_MatSize()) }.into_result().and_then(|x| unsafe { x.as_ref() }.ok_or_else(|| Error::new(core::StsNullPtr, "Function returned Null pointer".to_string()))).expect("Infallible function failed: to_ri32")
}
+ #[inline]
+ fn equals(&self, sz: &core::MatSize) -> bool {
+ unsafe { sys::cv_MatSize_operatorEQ_const_const_MatSizeR(self.as_raw_MatSize(), sz.as_raw_MatSize()) }.into_result().expect("Infallible function failed: equals")
+ }
+
}
pub trait MatSizeTrait: core::MatSizeTraitConst {
@@ -13133,6 +13159,11 @@ pub trait RNGTraitConst {
unsafe { sys::cv_RNG_getPropState_const(self.as_raw_RNG()) }.into_result().expect("Infallible function failed: state")
}
+ #[inline]
+ fn equals(&self, other: &core::RNG) -> Result<bool> {
+ unsafe { sys::cv_RNG_operatorEQ_const_const_RNGR(self.as_raw_RNG(), other.as_raw_RNG()) }.into_result()
+ }
+
}
pub trait RNGTrait: core::RNGTraitConst {

MODIFY
src/opencv/hub/optflow.rs
src/opencv/hub/optflow.rs
@@ -1186,12 +1186,12 @@ pub trait GPCPatchDescriptorTraitConst {
fn as_raw_GPCPatchDescriptor(&self) -> *const c_void;
#[inline]
- fn feature(&self) -> core::Vec18<f64> {
+ fn feature(&self) -> core::Vec<f64, 18> {
unsafe { sys::cv_optflow_GPCPatchDescriptor_getPropFeature_const(self.as_raw_GPCPatchDescriptor()) }.into_result().expect("Infallible function failed: feature")
}
#[inline]
- fn dot(&self, coef: core::Vec18<f64>) -> Result<f64> {
+ fn dot(&self, coef: core::Vec<f64, 18>) -> Result<f64> {
unsafe { sys::cv_optflow_GPCPatchDescriptor_dot_const_const_Vec_double__18_R(self.as_raw_GPCPatchDescriptor(), &coef) }.into_result()
}
@@ -1206,7 +1206,7 @@ pub trait GPCPatchDescriptorTrait: crate::optflow::GPCPatchDescriptorTraitConst
fn as_raw_mut_GPCPatchDescriptor(&mut self) -> *mut c_void;
#[inline]
- fn set_feature(&mut self, val: core::Vec18<f64>) {
+ fn set_feature(&mut self, val: core::Vec<f64, 18>) {
unsafe { sys::cv_optflow_GPCPatchDescriptor_setPropFeature_Vec_double__18_(self.as_raw_mut_GPCPatchDescriptor(), val.opencv_as_extern()) }.into_result().expect("Infallible function failed: set_feature")
}
@@ -1264,7 +1264,7 @@ pub trait GPCPatchSampleTraitConst {
}
#[inline]
- fn get_directions(&self, refdir: &mut bool, posdir: &mut bool, negdir: &mut bool, coef: core::Vec18<f64>, rhs: f64) -> Result<()> {
+ fn get_directions(&self, refdir: &mut bool, posdir: &mut bool, negdir: &mut bool, coef: core::Vec<f64, 18>, rhs: f64) -> Result<()> {
unsafe { sys::cv_optflow_GPCPatchSample_getDirections_const_boolR_boolR_boolR_const_Vec_double__18_R_double(self.as_raw_GPCPatchSample(), refdir, posdir, negdir, &coef, rhs) }.into_result()
}
@@ -1427,6 +1427,11 @@ pub trait GPCTreeTraitConst: core::AlgorithmTraitConst {
unsafe { sys::cv_optflow_GPCTree_findLeafForPatch_const_const_GPCPatchDescriptorR(self.as_raw_GPCTree(), descr.as_raw_GPCPatchDescriptor()) }.into_result()
}
+ #[inline]
+ fn equals(&self, t: &crate::optflow::GPCTree) -> Result<bool> {
+ unsafe { sys::cv_optflow_GPCTree_operatorEQ_const_const_GPCTreeR(self.as_raw_GPCTree(), t.as_raw_GPCTree()) }.into_result()
+ }
+
#[inline]
fn get_descriptor_type(&self) -> Result<i32> {
unsafe { sys::cv_optflow_GPCTree_getDescriptorType_const(self.as_raw_GPCTree()) }.into_result()
@@ -1497,7 +1502,7 @@ boxed_cast_base! { GPCTree, core::Algorithm, cv_GPCTree_to_Algorithm }
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct GPCTree_Node {
/// Hyperplane coefficients
- pub coef: core::Vec18<f64>,
+ pub coef: core::Vec<f64, 18>,
/// Bias term of the hyperplane
pub rhs: f64,
pub left: u32,
@@ -1507,6 +1512,11 @@ pub struct GPCTree_Node {
opencv_type_simple! { crate::optflow::GPCTree_Node }
impl GPCTree_Node {
+ #[inline]
+ pub fn equals(self, n: crate::optflow::GPCTree_Node) -> Result<bool> {
+ unsafe { sys::cv_optflow_GPCTree_Node_operatorEQ_const_const_NodeR(self.opencv_as_extern(), &n) }.into_result()
+ }
+
}
/// PCAFlow algorithm.

MODIFY
src/opencv/hub/rgbd.rs
src/opencv/hub/rgbd.rs
@@ -2761,6 +2761,11 @@ pub trait Linemod_MatchTraitConst {
unsafe { sys::cv_linemod_Match_getPropTemplate_id_const(self.as_raw_Linemod_Match()) }.into_result().expect("Infallible function failed: template_id")
}
+ #[inline]
+ fn equals(&self, rhs: &crate::rgbd::Linemod_Match) -> Result<bool> {
+ unsafe { sys::cv_linemod_Match_operatorEQ_const_const_MatchR(self.as_raw_Linemod_Match(), rhs.as_raw_Linemod_Match()) }.into_result()
+ }
+
}
pub trait Linemod_MatchTrait: crate::rgbd::Linemod_MatchTraitConst {

MODIFY
src/opencv/hub/sys.rs
src/opencv/hub/sys.rs
@@ -706,6 +706,10 @@ mod core_sys {
pub fn cv_operatorD_const_MatR_double(a: *const c_void, s: f64) -> Result<*mut c_void>;
pub fn cv_operatorD_double_const_MatExprR(s: f64, e: *const c_void) -> Result<*mut c_void>;
pub fn cv_operatorD_double_const_MatR(s: f64, a: *const c_void) -> Result<*mut c_void>;
+ pub fn cv_operatorEQ_const_FileNodeIteratorR_const_FileNodeIteratorR(it1: *const c_void, it2: *const c_void) -> Result<bool>;
+ pub fn cv_operatorEQ_const_MatR_const_MatR(a: *const c_void, b: *const c_void) -> Result<*mut c_void>;
+ pub fn cv_operatorEQ_const_MatR_double(a: *const c_void, s: f64) -> Result<*mut c_void>;
+ pub fn cv_operatorEQ_double_const_MatR(s: f64, a: *const c_void) -> Result<*mut c_void>;
pub fn cv_operatorS_const_MatExprR(e: *const c_void) -> Result<*mut c_void>;
pub fn cv_operatorS_const_MatExprR_const_MatExprR(e1: *const c_void, e2: *const c_void) -> Result<*mut c_void>;
pub fn cv_operatorS_const_MatExprR_const_MatR(e: *const c_void, m: *const c_void) -> Result<*mut c_void>;
@@ -1176,6 +1180,7 @@ mod core_sys {
pub fn cv_MatSize_operator___const_int(instance: *const c_void, i: i32) -> Result<i32>;
pub fn cv_MatSize_operator___int(instance: *mut c_void, i: i32) -> Result<i32>;
pub fn cv_MatSize_operator_const_intX_const(instance: *const c_void) -> Result<*const i32>;
+ pub fn cv_MatSize_operatorEQ_const_const_MatSizeR(instance: *const c_void, sz: *const c_void) -> Result<bool>;
pub fn cv_MatStep_getPropP(instance: *mut c_void) -> Result<*mut size_t>;
pub fn cv_MatStep_setPropP_size_tX(instance: *mut c_void, val: *mut size_t) -> Result_void;
pub fn cv_MatStep_getPropBuf(instance: *mut c_void) -> Result<*mut [size_t; 2]>;
@@ -1242,6 +1247,7 @@ mod core_sys {
pub fn cv_RNG_uniform_double_double(instance: *mut c_void, a: f64, b: f64) -> Result<f64>;
pub fn cv_RNG_fill_const__InputOutputArrayR_int_const__InputArrayR_const__InputArrayR_bool(instance: *mut c_void, mat: *const c_void, dist_type: i32, a: *const c_void, b: *const c_void, saturate_range: bool) -> Result_void;
pub fn cv_RNG_gaussian_double(instance: *mut c_void, sigma: f64) -> Result<f64>;
+ pub fn cv_RNG_operatorEQ_const_const_RNGR(instance: *const c_void, other: *const c_void) -> Result<bool>;
pub fn cv_RNG_MT19937_RNG_MT19937() -> Result<*mut c_void>;
pub fn cv_RNG_MT19937_RNG_MT19937_unsigned_int(s: u32) -> Result<*mut c_void>;
pub fn cv_RNG_MT19937_seed_unsigned_int(instance: *mut c_void, s: u32) -> Result_void;
@@ -5017,9 +5023,9 @@ mod optflow_sys {
pub fn cv_optflow_GPCDetails_getCoordinatesFromIndex_size_t_Size_intR_intR(index: size_t, sz: *const core::Size, x: *mut i32, y: *mut i32) -> Result_void;
pub fn cv_optflow_GPCMatchingParams_GPCMatchingParams_bool(_use_opencl: bool) -> Result<crate::optflow::GPCMatchingParams>;
pub fn cv_optflow_GPCMatchingParams_GPCMatchingParams_const_GPCMatchingParamsR(params: *const crate::optflow::GPCMatchingParams) -> Result<crate::optflow::GPCMatchingParams>;
- pub fn cv_optflow_GPCPatchDescriptor_getPropFeature_const(instance: *const c_void) -> Result<core::Vec18<f64>>;
- pub fn cv_optflow_GPCPatchDescriptor_setPropFeature_Vec_double__18_(instance: *mut c_void, val: *const core::Vec18<f64>) -> Result_void;
- pub fn cv_optflow_GPCPatchDescriptor_dot_const_const_Vec_double__18_R(instance: *const c_void, coef: *const core::Vec18<f64>) -> Result<f64>;
+ pub fn cv_optflow_GPCPatchDescriptor_getPropFeature_const(instance: *const c_void) -> Result<core::Vec<f64, 18>>;
+ pub fn cv_optflow_GPCPatchDescriptor_setPropFeature_Vec_double__18_(instance: *mut c_void, val: *const core::Vec<f64, 18>) -> Result_void;
+ pub fn cv_optflow_GPCPatchDescriptor_dot_const_const_Vec_double__18_R(instance: *const c_void, coef: *const core::Vec<f64, 18>) -> Result<f64>;
pub fn cv_optflow_GPCPatchDescriptor_markAsSeparated(instance: *mut c_void) -> Result_void;
pub fn cv_optflow_GPCPatchDescriptor_isSeparated_const(instance: *const c_void) -> Result<bool>;
pub fn cv_optflow_GPCPatchSample_getPropRef_const(instance: *const c_void) -> Result<*mut c_void>;
@@ -5028,7 +5034,7 @@ mod optflow_sys {
pub fn cv_optflow_GPCPatchSample_setPropPos_GPCPatchDescriptor(instance: *mut c_void, val: *mut c_void) -> Result_void;
pub fn cv_optflow_GPCPatchSample_getPropNeg_const(instance: *const c_void) -> Result<*mut c_void>;
pub fn cv_optflow_GPCPatchSample_setPropNeg_GPCPatchDescriptor(instance: *mut c_void, val: *mut c_void) -> Result_void;
- pub fn cv_optflow_GPCPatchSample_getDirections_const_boolR_boolR_boolR_const_Vec_double__18_R_double(instance: *const c_void, refdir: *mut bool, posdir: *mut bool, negdir: *mut bool, coef: *const core::Vec18<f64>, rhs: f64) -> Result_void;
+ pub fn cv_optflow_GPCPatchSample_getDirections_const_boolR_boolR_boolR_const_Vec_double__18_R_double(instance: *const c_void, refdir: *mut bool, posdir: *mut bool, negdir: *mut bool, coef: *const core::Vec<f64, 18>, rhs: f64) -> Result_void;
pub fn cv_optflow_GPCTrainingParams_GPCTrainingParams_unsigned_int_int_GPCDescType_bool(_max_tree_depth: u32, _min_number_of_samples: i32, _descriptor_type: crate::optflow::GPCDescType, _print_progress: bool) -> Result<crate::optflow::GPCTrainingParams>;
pub fn cv_optflow_GPCTrainingParams_check_const(instance: *const crate::optflow::GPCTrainingParams) -> Result<bool>;
pub fn cv_optflow_GPCTrainingSamples_create_const_vector_String_R_const_vector_String_R_const_vector_String_R_int(images_from: *const c_void, images_to: *const c_void, gt: *const c_void, descriptor_type: i32) -> Result<*mut c_void>;
@@ -5040,7 +5046,9 @@ mod optflow_sys {
pub fn cv_optflow_GPCTree_read_const_FileNodeR(instance: *mut c_void, fn_: *const c_void) -> Result_void;
pub fn cv_optflow_GPCTree_findLeafForPatch_const_const_GPCPatchDescriptorR(instance: *const c_void, descr: *const c_void) -> Result<u32>;
pub fn cv_optflow_GPCTree_create() -> Result<*mut c_void>;
+ pub fn cv_optflow_GPCTree_operatorEQ_const_const_GPCTreeR(instance: *const c_void, t: *const c_void) -> Result<bool>;
pub fn cv_optflow_GPCTree_getDescriptorType_const(instance: *const c_void) -> Result<i32>;
+ pub fn cv_optflow_GPCTree_Node_operatorEQ_const_const_NodeR(instance: *const crate::optflow::GPCTree_Node, n: *const crate::optflow::GPCTree_Node) -> Result<bool>;
pub fn cv_optflow_OpticalFlowPCAFlow_OpticalFlowPCAFlow_Ptr_const_PCAPrior__const_Size_float_float_float_float_float(_prior: *const c_void, _basis_size: *const core::Size, _sparse_rate: f32, _retained_corners_fraction: f32, _occlusions_threshold: f32, _damping_factor: f32, _clahe_clip: f32) -> Result<*mut c_void>;
pub fn cv_optflow_OpticalFlowPCAFlow_calc_const__InputArrayR_const__InputArrayR_const__InputOutputArrayR(instance: *mut c_void, i0: *const c_void, i1: *const c_void, flow: *const c_void) -> Result_void;
pub fn cv_optflow_OpticalFlowPCAFlow_collectGarbage(instance: *mut c_void) -> Result_void;
@@ -5684,6 +5692,7 @@ mod rgbd_sys {
pub fn cv_linemod_Match_setPropTemplate_id_int(instance: *mut c_void, val: i32) -> Result_void;
pub fn cv_linemod_Match_Match() -> Result<*mut c_void>;
pub fn cv_linemod_Match_Match_int_int_float_const_StringR_int(x: i32, y: i32, similarity: f32, class_id: *const c_char, template_id: i32) -> Result<*mut c_void>;
+ pub fn cv_linemod_Match_operatorEQ_const_const_MatchR(instance: *const c_void, rhs: *const c_void) -> Result<bool>;
pub fn cv_linemod_Modality_process_const_const_MatR_const_MatR(instance: *const c_void, src: *const c_void, mask: *const c_void) -> Result<*mut c_void>;
pub fn cv_linemod_Modality_name_const(instance: *const c_void) -> Result<*mut c_void>;
pub fn cv_linemod_Modality_read_const_FileNodeR(instance: *mut c_void, fn_: *const c_void) -> Result_void;

0.57.0 Regenerate bindings