diff --git a/docs/alphamat.rs b/docs/alphamat.rs index 7aa97a11a..1d1c0b61d 100644 --- a/docs/alphamat.rs +++ b/docs/alphamat.rs @@ -31,4 +31,5 @@ pub mod alphamat { let ret = ret.into_result()?; Ok(ret) } + } diff --git a/docs/aruco.rs b/docs/aruco.rs index 57b9cab4f..06959372d 100644 --- a/docs/aruco.rs +++ b/docs/aruco.rs @@ -1011,6 +1011,48 @@ pub mod aruco { Ok(ret) } + /// Pose estimation parameters + /// + /// ## Parameters + /// * pattern: Defines center this system and axes direction (default PatternPositionType::ARUCO_CCW_CENTER). + /// * useExtrinsicGuess: Parameter used for SOLVEPNP_ITERATIVE. If true (1), the function uses the provided + /// rvec and tvec values as initial approximations of the rotation and translation vectors, respectively, and further + /// optimizes them (default false). + /// * solvePnPMethod: Method for solving a PnP problem: see [calib3d_solvePnP_flags] (default SOLVEPNP_ITERATIVE). + /// + /// + /// **Deprecated**: Use Board::matchImagePoints and cv::solvePnP + /// ## See also + /// PatternPositionType, solvePnP() + #[deprecated = "Use Board::matchImagePoints and cv::solvePnP"] + pub struct EstimateParameters { + ptr: *mut c_void, + } + + opencv_type_boxed! { EstimateParameters } + + impl Drop for EstimateParameters { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_aruco_EstimateParameters_delete(self.as_raw_mut_EstimateParameters()) }; + } + } + + unsafe impl Send for EstimateParameters {} + + impl EstimateParameters { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_aruco_EstimateParameters_EstimateParameters(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::aruco::EstimateParameters::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::aruco::EstimateParameters] pub trait EstimateParametersTraitConst { fn as_raw_EstimateParameters(&self) -> *const c_void; @@ -1061,58 +1103,6 @@ pub mod aruco { } - /// Pose estimation parameters - /// - /// ## Parameters - /// * pattern: Defines center this system and axes direction (default PatternPositionType::ARUCO_CCW_CENTER). - /// * useExtrinsicGuess: Parameter used for SOLVEPNP_ITERATIVE. If true (1), the function uses the provided - /// rvec and tvec values as initial approximations of the rotation and translation vectors, respectively, and further - /// optimizes them (default false). - /// * solvePnPMethod: Method for solving a PnP problem: see [calib3d_solvePnP_flags] (default SOLVEPNP_ITERATIVE). - /// - /// - /// **Deprecated**: Use Board::matchImagePoints and cv::solvePnP - /// ## See also - /// PatternPositionType, solvePnP() - #[deprecated = "Use Board::matchImagePoints and cv::solvePnP"] - pub struct EstimateParameters { - ptr: *mut c_void, - } - - opencv_type_boxed! { EstimateParameters } - - impl Drop for EstimateParameters { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_aruco_EstimateParameters_delete(self.as_raw_mut_EstimateParameters()) }; - } - } - - unsafe impl Send for EstimateParameters {} - - impl crate::aruco::EstimateParametersTraitConst for EstimateParameters { - #[inline] fn as_raw_EstimateParameters(&self) -> *const c_void { self.as_raw() } - } - - impl crate::aruco::EstimateParametersTrait for EstimateParameters { - #[inline] fn as_raw_mut_EstimateParameters(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { EstimateParameters, crate::aruco::EstimateParametersTraitConst, as_raw_EstimateParameters, crate::aruco::EstimateParametersTrait, as_raw_mut_EstimateParameters } - - impl EstimateParameters { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_EstimateParameters_EstimateParameters(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::aruco::EstimateParameters::opencv_from_extern(ret) }; - Ok(ret) - } - - } - impl Clone for EstimateParameters { #[inline] fn clone(&self) -> Self { @@ -1130,4 +1120,15 @@ pub mod aruco { .finish() } } + + impl crate::aruco::EstimateParametersTraitConst for EstimateParameters { + #[inline] fn as_raw_EstimateParameters(&self) -> *const c_void { self.as_raw() } + } + + impl crate::aruco::EstimateParametersTrait for EstimateParameters { + #[inline] fn as_raw_mut_EstimateParameters(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { EstimateParameters, crate::aruco::EstimateParametersTraitConst, as_raw_EstimateParameters, crate::aruco::EstimateParametersTrait, as_raw_mut_EstimateParameters } + } diff --git a/docs/bgsegm.rs b/docs/bgsegm.rs index 047148f81..7a4c608c9 100644 --- a/docs/bgsegm.rs +++ b/docs/bgsegm.rs @@ -385,6 +385,27 @@ pub mod bgsegm { Ok(ret) } + /// Background subtraction based on counting. + /// + /// About as fast as MOG2 on a high end system. + /// More than twice faster than MOG2 on cheap hardware (benchmarked on Raspberry Pi3). + /// + /// %Algorithm by Sagi Zeevi ( ) + pub struct BackgroundSubtractorCNT { + ptr: *mut c_void, + } + + opencv_type_boxed! { BackgroundSubtractorCNT } + + impl Drop for BackgroundSubtractorCNT { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_bgsegm_BackgroundSubtractorCNT_delete(self.as_raw_mut_BackgroundSubtractorCNT()) }; + } + } + + unsafe impl Send for BackgroundSubtractorCNT {} + /// Constant methods for [crate::bgsegm::BackgroundSubtractorCNT] pub trait BackgroundSubtractorCNTTraitConst: crate::video::BackgroundSubtractorTraitConst { fn as_raw_BackgroundSubtractorCNT(&self) -> *const c_void; @@ -514,26 +535,17 @@ pub mod bgsegm { } - /// Background subtraction based on counting. - /// - /// About as fast as MOG2 on a high end system. - /// More than twice faster than MOG2 on cheap hardware (benchmarked on Raspberry Pi3). - /// - /// %Algorithm by Sagi Zeevi ( ) - pub struct BackgroundSubtractorCNT { - ptr: *mut c_void, - } - - opencv_type_boxed! { BackgroundSubtractorCNT } - - impl Drop for BackgroundSubtractorCNT { + impl std::fmt::Debug for BackgroundSubtractorCNT { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_bgsegm_BackgroundSubtractorCNT_delete(self.as_raw_mut_BackgroundSubtractorCNT()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BackgroundSubtractorCNT") + .finish() } } - unsafe impl Send for BackgroundSubtractorCNT {} + boxed_cast_base! { BackgroundSubtractorCNT, core::Algorithm, cv_bgsegm_BackgroundSubtractorCNT_to_Algorithm } + + boxed_cast_base! { BackgroundSubtractorCNT, crate::video::BackgroundSubtractor, cv_bgsegm_BackgroundSubtractorCNT_to_BackgroundSubtractor } impl core::AlgorithmTraitConst for BackgroundSubtractorCNT { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -565,21 +577,28 @@ pub mod bgsegm { boxed_ref! { BackgroundSubtractorCNT, crate::bgsegm::BackgroundSubtractorCNTTraitConst, as_raw_BackgroundSubtractorCNT, crate::bgsegm::BackgroundSubtractorCNTTrait, as_raw_mut_BackgroundSubtractorCNT } - impl BackgroundSubtractorCNT { + /// Background Subtractor module based on the algorithm given in [Gold2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Gold2012) . + /// + /// Takes a series of images and returns a sequence of mask (8UC1) + /// images of the same size, where 255 indicates Foreground and 0 represents Background. + /// This class implements an algorithm described in "Visual Tracking of Human Visitors under + /// Variable-Lighting Conditions for a Responsive Audio Art Installation," A. Godbehere, + /// A. Matsukawa, K. Goldberg, American Control Conference, Montreal, June 2012. + pub struct BackgroundSubtractorGMG { + ptr: *mut c_void, } - boxed_cast_base! { BackgroundSubtractorCNT, core::Algorithm, cv_bgsegm_BackgroundSubtractorCNT_to_Algorithm } - - boxed_cast_base! { BackgroundSubtractorCNT, crate::video::BackgroundSubtractor, cv_bgsegm_BackgroundSubtractorCNT_to_BackgroundSubtractor } + opencv_type_boxed! { BackgroundSubtractorGMG } - impl std::fmt::Debug for BackgroundSubtractorCNT { + impl Drop for BackgroundSubtractorGMG { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BackgroundSubtractorCNT") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_bgsegm_BackgroundSubtractorGMG_delete(self.as_raw_mut_BackgroundSubtractorGMG()) }; } } + unsafe impl Send for BackgroundSubtractorGMG {} + /// Constant methods for [crate::bgsegm::BackgroundSubtractorGMG] pub trait BackgroundSubtractorGMGTraitConst: crate::video::BackgroundSubtractorTraitConst { fn as_raw_BackgroundSubtractorGMG(&self) -> *const c_void; @@ -856,27 +875,17 @@ pub mod bgsegm { } - /// Background Subtractor module based on the algorithm given in [Gold2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Gold2012) . - /// - /// Takes a series of images and returns a sequence of mask (8UC1) - /// images of the same size, where 255 indicates Foreground and 0 represents Background. - /// This class implements an algorithm described in "Visual Tracking of Human Visitors under - /// Variable-Lighting Conditions for a Responsive Audio Art Installation," A. Godbehere, - /// A. Matsukawa, K. Goldberg, American Control Conference, Montreal, June 2012. - pub struct BackgroundSubtractorGMG { - ptr: *mut c_void, - } - - opencv_type_boxed! { BackgroundSubtractorGMG } - - impl Drop for BackgroundSubtractorGMG { + impl std::fmt::Debug for BackgroundSubtractorGMG { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_bgsegm_BackgroundSubtractorGMG_delete(self.as_raw_mut_BackgroundSubtractorGMG()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BackgroundSubtractorGMG") + .finish() } } - unsafe impl Send for BackgroundSubtractorGMG {} + boxed_cast_base! { BackgroundSubtractorGMG, core::Algorithm, cv_bgsegm_BackgroundSubtractorGMG_to_Algorithm } + + boxed_cast_base! { BackgroundSubtractorGMG, crate::video::BackgroundSubtractor, cv_bgsegm_BackgroundSubtractorGMG_to_BackgroundSubtractor } impl core::AlgorithmTraitConst for BackgroundSubtractorGMG { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -908,21 +917,24 @@ pub mod bgsegm { boxed_ref! { BackgroundSubtractorGMG, crate::bgsegm::BackgroundSubtractorGMGTraitConst, as_raw_BackgroundSubtractorGMG, crate::bgsegm::BackgroundSubtractorGMGTrait, as_raw_mut_BackgroundSubtractorGMG } - impl BackgroundSubtractorGMG { + /// Implementation of the different yet better algorithm which is called GSOC, as it was implemented during GSOC and was not originated from any paper. + /// + /// This algorithm demonstrates better performance on CDNET 2014 dataset compared to other algorithms in OpenCV. + pub struct BackgroundSubtractorGSOC { + ptr: *mut c_void, } - boxed_cast_base! { BackgroundSubtractorGMG, core::Algorithm, cv_bgsegm_BackgroundSubtractorGMG_to_Algorithm } - - boxed_cast_base! { BackgroundSubtractorGMG, crate::video::BackgroundSubtractor, cv_bgsegm_BackgroundSubtractorGMG_to_BackgroundSubtractor } + opencv_type_boxed! { BackgroundSubtractorGSOC } - impl std::fmt::Debug for BackgroundSubtractorGMG { + impl Drop for BackgroundSubtractorGSOC { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BackgroundSubtractorGMG") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_bgsegm_BackgroundSubtractorGSOC_delete(self.as_raw_mut_BackgroundSubtractorGSOC()) }; } } + unsafe impl Send for BackgroundSubtractorGSOC {} + /// Constant methods for [crate::bgsegm::BackgroundSubtractorGSOC] pub trait BackgroundSubtractorGSOCTraitConst: crate::video::BackgroundSubtractorTraitConst { fn as_raw_BackgroundSubtractorGSOC(&self) -> *const c_void; @@ -972,23 +984,17 @@ pub mod bgsegm { } - /// Implementation of the different yet better algorithm which is called GSOC, as it was implemented during GSOC and was not originated from any paper. - /// - /// This algorithm demonstrates better performance on CDNET 2014 dataset compared to other algorithms in OpenCV. - pub struct BackgroundSubtractorGSOC { - ptr: *mut c_void, - } - - opencv_type_boxed! { BackgroundSubtractorGSOC } - - impl Drop for BackgroundSubtractorGSOC { + impl std::fmt::Debug for BackgroundSubtractorGSOC { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_bgsegm_BackgroundSubtractorGSOC_delete(self.as_raw_mut_BackgroundSubtractorGSOC()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BackgroundSubtractorGSOC") + .finish() } } - unsafe impl Send for BackgroundSubtractorGSOC {} + boxed_cast_base! { BackgroundSubtractorGSOC, core::Algorithm, cv_bgsegm_BackgroundSubtractorGSOC_to_Algorithm } + + boxed_cast_base! { BackgroundSubtractorGSOC, crate::video::BackgroundSubtractor, cv_bgsegm_BackgroundSubtractorGSOC_to_BackgroundSubtractor } impl core::AlgorithmTraitConst for BackgroundSubtractorGSOC { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1020,21 +1026,22 @@ pub mod bgsegm { boxed_ref! { BackgroundSubtractorGSOC, crate::bgsegm::BackgroundSubtractorGSOCTraitConst, as_raw_BackgroundSubtractorGSOC, crate::bgsegm::BackgroundSubtractorGSOCTrait, as_raw_mut_BackgroundSubtractorGSOC } - impl BackgroundSubtractorGSOC { + /// Background Subtraction using Local SVD Binary Pattern. More details about the algorithm can be found at [LGuo2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_LGuo2016) + pub struct BackgroundSubtractorLSBP { + ptr: *mut c_void, } - boxed_cast_base! { BackgroundSubtractorGSOC, core::Algorithm, cv_bgsegm_BackgroundSubtractorGSOC_to_Algorithm } - - boxed_cast_base! { BackgroundSubtractorGSOC, crate::video::BackgroundSubtractor, cv_bgsegm_BackgroundSubtractorGSOC_to_BackgroundSubtractor } + opencv_type_boxed! { BackgroundSubtractorLSBP } - impl std::fmt::Debug for BackgroundSubtractorGSOC { + impl Drop for BackgroundSubtractorLSBP { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BackgroundSubtractorGSOC") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_bgsegm_BackgroundSubtractorLSBP_delete(self.as_raw_mut_BackgroundSubtractorLSBP()) }; } } + unsafe impl Send for BackgroundSubtractorLSBP {} + /// Constant methods for [crate::bgsegm::BackgroundSubtractorLSBP] pub trait BackgroundSubtractorLSBPTraitConst: crate::video::BackgroundSubtractorTraitConst { fn as_raw_BackgroundSubtractorLSBP(&self) -> *const c_void; @@ -1084,21 +1091,17 @@ pub mod bgsegm { } - /// Background Subtraction using Local SVD Binary Pattern. More details about the algorithm can be found at [LGuo2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_LGuo2016) - pub struct BackgroundSubtractorLSBP { - ptr: *mut c_void, - } - - opencv_type_boxed! { BackgroundSubtractorLSBP } - - impl Drop for BackgroundSubtractorLSBP { + impl std::fmt::Debug for BackgroundSubtractorLSBP { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_bgsegm_BackgroundSubtractorLSBP_delete(self.as_raw_mut_BackgroundSubtractorLSBP()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BackgroundSubtractorLSBP") + .finish() } } - unsafe impl Send for BackgroundSubtractorLSBP {} + boxed_cast_base! { BackgroundSubtractorLSBP, core::Algorithm, cv_bgsegm_BackgroundSubtractorLSBP_to_Algorithm } + + boxed_cast_base! { BackgroundSubtractorLSBP, crate::video::BackgroundSubtractor, cv_bgsegm_BackgroundSubtractorLSBP_to_BackgroundSubtractor } impl core::AlgorithmTraitConst for BackgroundSubtractorLSBP { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1130,33 +1133,6 @@ pub mod bgsegm { boxed_ref! { BackgroundSubtractorLSBP, crate::bgsegm::BackgroundSubtractorLSBPTraitConst, as_raw_BackgroundSubtractorLSBP, crate::bgsegm::BackgroundSubtractorLSBPTrait, as_raw_mut_BackgroundSubtractorLSBP } - impl BackgroundSubtractorLSBP { - } - - boxed_cast_base! { BackgroundSubtractorLSBP, core::Algorithm, cv_bgsegm_BackgroundSubtractorLSBP_to_Algorithm } - - boxed_cast_base! { BackgroundSubtractorLSBP, crate::video::BackgroundSubtractor, cv_bgsegm_BackgroundSubtractorLSBP_to_BackgroundSubtractor } - - impl std::fmt::Debug for BackgroundSubtractorLSBP { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BackgroundSubtractorLSBP") - .finish() - } - } - - /// Constant methods for [crate::bgsegm::BackgroundSubtractorLSBPDesc] - pub trait BackgroundSubtractorLSBPDescTraitConst { - fn as_raw_BackgroundSubtractorLSBPDesc(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::bgsegm::BackgroundSubtractorLSBPDesc] - pub trait BackgroundSubtractorLSBPDescTrait: crate::bgsegm::BackgroundSubtractorLSBPDescTraitConst { - fn as_raw_mut_BackgroundSubtractorLSBPDesc(&mut self) -> *mut c_void; - - } - /// This is for calculation of the LSBP descriptors. pub struct BackgroundSubtractorLSBPDesc { ptr: *mut c_void, @@ -1173,21 +1149,13 @@ pub mod bgsegm { unsafe impl Send for BackgroundSubtractorLSBPDesc {} - impl crate::bgsegm::BackgroundSubtractorLSBPDescTraitConst for BackgroundSubtractorLSBPDesc { - #[inline] fn as_raw_BackgroundSubtractorLSBPDesc(&self) -> *const c_void { self.as_raw() } - } - - impl crate::bgsegm::BackgroundSubtractorLSBPDescTrait for BackgroundSubtractorLSBPDesc { - #[inline] fn as_raw_mut_BackgroundSubtractorLSBPDesc(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { BackgroundSubtractorLSBPDesc, crate::bgsegm::BackgroundSubtractorLSBPDescTraitConst, as_raw_BackgroundSubtractorLSBPDesc, crate::bgsegm::BackgroundSubtractorLSBPDescTrait, as_raw_mut_BackgroundSubtractorLSBPDesc } - impl BackgroundSubtractorLSBPDesc { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_bgsegm_BackgroundSubtractorLSBPDesc_defaultNew_const()) } + pub fn default() -> crate::bgsegm::BackgroundSubtractorLSBPDesc { + let ret = unsafe { sys::cv_bgsegm_BackgroundSubtractorLSBPDesc_defaultNew_const() }; + let ret = unsafe { crate::bgsegm::BackgroundSubtractorLSBPDesc::opencv_from_extern(ret) }; + ret } #[inline] @@ -1222,6 +1190,26 @@ pub mod bgsegm { } + /// Constant methods for [crate::bgsegm::BackgroundSubtractorLSBPDesc] + pub trait BackgroundSubtractorLSBPDescTraitConst { + fn as_raw_BackgroundSubtractorLSBPDesc(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::bgsegm::BackgroundSubtractorLSBPDesc] + pub trait BackgroundSubtractorLSBPDescTrait: crate::bgsegm::BackgroundSubtractorLSBPDescTraitConst { + fn as_raw_mut_BackgroundSubtractorLSBPDesc(&mut self) -> *mut c_void; + + } + + impl Default for BackgroundSubtractorLSBPDesc { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } + } + impl std::fmt::Debug for BackgroundSubtractorLSBPDesc { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -1230,14 +1218,34 @@ pub mod bgsegm { } } - impl Default for BackgroundSubtractorLSBPDesc { + impl crate::bgsegm::BackgroundSubtractorLSBPDescTraitConst for BackgroundSubtractorLSBPDesc { + #[inline] fn as_raw_BackgroundSubtractorLSBPDesc(&self) -> *const c_void { self.as_raw() } + } + + impl crate::bgsegm::BackgroundSubtractorLSBPDescTrait for BackgroundSubtractorLSBPDesc { + #[inline] fn as_raw_mut_BackgroundSubtractorLSBPDesc(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { BackgroundSubtractorLSBPDesc, crate::bgsegm::BackgroundSubtractorLSBPDescTraitConst, as_raw_BackgroundSubtractorLSBPDesc, crate::bgsegm::BackgroundSubtractorLSBPDescTrait, as_raw_mut_BackgroundSubtractorLSBPDesc } + + /// Gaussian Mixture-based Background/Foreground Segmentation Algorithm. + /// + /// The class implements the algorithm described in [KB2001](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_KB2001) . + pub struct BackgroundSubtractorMOG { + ptr: *mut c_void, + } + + opencv_type_boxed! { BackgroundSubtractorMOG } + + impl Drop for BackgroundSubtractorMOG { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + fn drop(&mut self) { + unsafe { sys::cv_bgsegm_BackgroundSubtractorMOG_delete(self.as_raw_mut_BackgroundSubtractorMOG()) }; } } + unsafe impl Send for BackgroundSubtractorMOG {} + /// Constant methods for [crate::bgsegm::BackgroundSubtractorMOG] pub trait BackgroundSubtractorMOGTraitConst: crate::video::BackgroundSubtractorTraitConst { fn as_raw_BackgroundSubtractorMOG(&self) -> *const c_void; @@ -1322,23 +1330,17 @@ pub mod bgsegm { } - /// Gaussian Mixture-based Background/Foreground Segmentation Algorithm. - /// - /// The class implements the algorithm described in [KB2001](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_KB2001) . - pub struct BackgroundSubtractorMOG { - ptr: *mut c_void, - } - - opencv_type_boxed! { BackgroundSubtractorMOG } - - impl Drop for BackgroundSubtractorMOG { + impl std::fmt::Debug for BackgroundSubtractorMOG { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_bgsegm_BackgroundSubtractorMOG_delete(self.as_raw_mut_BackgroundSubtractorMOG()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BackgroundSubtractorMOG") + .finish() } } - unsafe impl Send for BackgroundSubtractorMOG {} + boxed_cast_base! { BackgroundSubtractorMOG, core::Algorithm, cv_bgsegm_BackgroundSubtractorMOG_to_Algorithm } + + boxed_cast_base! { BackgroundSubtractorMOG, crate::video::BackgroundSubtractor, cv_bgsegm_BackgroundSubtractorMOG_to_BackgroundSubtractor } impl core::AlgorithmTraitConst for BackgroundSubtractorMOG { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1370,19 +1372,47 @@ pub mod bgsegm { boxed_ref! { BackgroundSubtractorMOG, crate::bgsegm::BackgroundSubtractorMOGTraitConst, as_raw_BackgroundSubtractorMOG, crate::bgsegm::BackgroundSubtractorMOGTrait, as_raw_mut_BackgroundSubtractorMOG } - impl BackgroundSubtractorMOG { + /// Synthetic frame sequence generator for testing background subtraction algorithms. + /// + /// It will generate the moving object on top of the background. + /// It will apply some distortion to the background to make the test more complex. + pub struct SyntheticSequenceGenerator { + ptr: *mut c_void, } - boxed_cast_base! { BackgroundSubtractorMOG, core::Algorithm, cv_bgsegm_BackgroundSubtractorMOG_to_Algorithm } + opencv_type_boxed! { SyntheticSequenceGenerator } - boxed_cast_base! { BackgroundSubtractorMOG, crate::video::BackgroundSubtractor, cv_bgsegm_BackgroundSubtractorMOG_to_BackgroundSubtractor } + impl Drop for SyntheticSequenceGenerator { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_bgsegm_SyntheticSequenceGenerator_delete(self.as_raw_mut_SyntheticSequenceGenerator()) }; + } + } - impl std::fmt::Debug for BackgroundSubtractorMOG { + unsafe impl Send for SyntheticSequenceGenerator {} + + impl SyntheticSequenceGenerator { + /// Creates an instance of SyntheticSequenceGenerator. + /// + /// ## Parameters + /// * background: Background image for object. + /// * object: Object image which will move slowly over the background. + /// * amplitude: Amplitude of wave distortion applied to background. + /// * wavelength: Length of waves in distortion applied to background. + /// * wavespeed: How fast waves will move. + /// * objspeed: How fast object will fly over background. #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BackgroundSubtractorMOG") - .finish() + pub fn new(background: &impl ToInputArray, object: &impl ToInputArray, amplitude: f64, wavelength: f64, wavespeed: f64, objspeed: f64) -> Result { + input_array_arg!(background); + input_array_arg!(object); + return_send!(via ocvrs_return); + unsafe { sys::cv_bgsegm_SyntheticSequenceGenerator_SyntheticSequenceGenerator_const__InputArrayR_const__InputArrayR_double_double_double_double(background.as_raw__InputArray(), object.as_raw__InputArray(), amplitude, wavelength, wavespeed, objspeed, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::bgsegm::SyntheticSequenceGenerator::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::bgsegm::SyntheticSequenceGenerator] @@ -1413,24 +1443,15 @@ pub mod bgsegm { } - /// Synthetic frame sequence generator for testing background subtraction algorithms. - /// - /// It will generate the moving object on top of the background. - /// It will apply some distortion to the background to make the test more complex. - pub struct SyntheticSequenceGenerator { - ptr: *mut c_void, - } - - opencv_type_boxed! { SyntheticSequenceGenerator } - - impl Drop for SyntheticSequenceGenerator { + impl std::fmt::Debug for SyntheticSequenceGenerator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_bgsegm_SyntheticSequenceGenerator_delete(self.as_raw_mut_SyntheticSequenceGenerator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SyntheticSequenceGenerator") + .finish() } } - unsafe impl Send for SyntheticSequenceGenerator {} + boxed_cast_base! { SyntheticSequenceGenerator, core::Algorithm, cv_bgsegm_SyntheticSequenceGenerator_to_Algorithm } impl core::AlgorithmTraitConst for SyntheticSequenceGenerator { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1452,37 +1473,4 @@ pub mod bgsegm { boxed_ref! { SyntheticSequenceGenerator, crate::bgsegm::SyntheticSequenceGeneratorTraitConst, as_raw_SyntheticSequenceGenerator, crate::bgsegm::SyntheticSequenceGeneratorTrait, as_raw_mut_SyntheticSequenceGenerator } - impl SyntheticSequenceGenerator { - /// Creates an instance of SyntheticSequenceGenerator. - /// - /// ## Parameters - /// * background: Background image for object. - /// * object: Object image which will move slowly over the background. - /// * amplitude: Amplitude of wave distortion applied to background. - /// * wavelength: Length of waves in distortion applied to background. - /// * wavespeed: How fast waves will move. - /// * objspeed: How fast object will fly over background. - #[inline] - pub fn new(background: &impl ToInputArray, object: &impl ToInputArray, amplitude: f64, wavelength: f64, wavespeed: f64, objspeed: f64) -> Result { - input_array_arg!(background); - input_array_arg!(object); - return_send!(via ocvrs_return); - unsafe { sys::cv_bgsegm_SyntheticSequenceGenerator_SyntheticSequenceGenerator_const__InputArrayR_const__InputArrayR_double_double_double_double(background.as_raw__InputArray(), object.as_raw__InputArray(), amplitude, wavelength, wavespeed, objspeed, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::bgsegm::SyntheticSequenceGenerator::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { SyntheticSequenceGenerator, core::Algorithm, cv_bgsegm_SyntheticSequenceGenerator_to_Algorithm } - - impl std::fmt::Debug for SyntheticSequenceGenerator { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SyntheticSequenceGenerator") - .finish() - } - } } diff --git a/docs/bioinspired.rs b/docs/bioinspired.rs index 5a73a584b..36f71b010 100644 --- a/docs/bioinspired.rs +++ b/docs/bioinspired.rs @@ -17,6 +17,139 @@ pub mod bioinspired { pub const RETINA_COLOR_DIAGONAL: i32 = 1; /// each pixel position is either R, G or B in a random choice pub const RETINA_COLOR_RANDOM: i32 = 0; + /// class which allows the Gipsa/Listic Labs model to be used with OpenCV. + /// + /// This retina model allows spatio-temporal image processing (applied on still images, video sequences). + /// As a summary, these are the retina model properties: + /// - It applies a spectral whithening (mid-frequency details enhancement) + /// - high frequency spatio-temporal noise reduction + /// - low frequency luminance to be reduced (luminance range compression) + /// - local logarithmic luminance compression allows details to be enhanced in low light conditions + /// + /// USE : this model can be used basically for spatio-temporal video effects but also for : + /// _using the getParvo method output matrix : texture analysiswith enhanced signal to noise ratio and enhanced details robust against input images luminance ranges + /// _using the getMagno method output matrix : motion analysis also with the previously cited properties + /// + /// for more information, reer to the following papers : + /// Benoit A., Caplier A., Durette B., Herault, J., "USING HUMAN VISUAL SYSTEM MODELING FOR BIO-INSPIRED LOW LEVEL IMAGE PROCESSING", Elsevier, Computer Vision and Image Understanding 114 (2010), pp. 758-773, DOI: + /// Vision: Images, Signals and Neural Networks: Models of Neural Processing in Visual Perception (Progress in Neural Processing),By: Jeanny Herault, ISBN: 9814273686. WAPI (Tower ID): 113266891. + /// + /// The retina filter includes the research contributions of phd/research collegues from which code has been redrawn by the author : + /// take a look at the retinacolor.hpp module to discover Brice Chaix de Lavarene color mosaicing/demosaicing and the reference paper: + /// B. Chaix de Lavarene, D. Alleysson, B. Durette, J. Herault (2007). "Efficient demosaicing through recursive filtering", IEEE International Conference on Image Processing ICIP 2007 + /// take a look at imagelogpolprojection.hpp to discover retina spatial log sampling which originates from Barthelemy Durette phd with Jeanny Herault. A Retina / V1 cortex projection is also proposed and originates from Jeanny's discussions. + /// more informations in the above cited Jeanny Heraults's book. + pub struct Retina { + ptr: *mut c_void, + } + + opencv_type_boxed! { Retina } + + impl Drop for Retina { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_bioinspired_Retina_delete(self.as_raw_mut_Retina()) }; + } + } + + unsafe impl Send for Retina {} + + impl Retina { + /// Constructors from standardized interfaces : retreive a smart pointer to a Retina instance + /// + /// ## Parameters + /// * inputSize: the input frame size + /// * colorMode: the chosen processing mode : with or without color processing + /// * colorSamplingMethod: specifies which kind of color sampling will be used : + /// * cv::bioinspired::RETINA_COLOR_RANDOM: each pixel position is either R, G or B in a random choice + /// * cv::bioinspired::RETINA_COLOR_DIAGONAL: color sampling is RGBRGBRGB..., line 2 BRGBRGBRG..., line 3, GBRGBRGBR... + /// * cv::bioinspired::RETINA_COLOR_BAYER: standard bayer sampling + /// * useRetinaLogSampling: activate retina log sampling, if true, the 2 following parameters can + /// be used + /// * reductionFactor: only usefull if param useRetinaLogSampling=true, specifies the reduction + /// factor of the output frame (as the center (fovea) is high resolution and corners can be + /// underscaled, then a reduction of the output is allowed without precision leak + /// * samplingStrength: only usefull if param useRetinaLogSampling=true, specifies the strength of + /// the log scale that is applied + /// + /// ## Overloaded parameters + #[inline] + pub fn create(input_size: core::Size) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_bioinspired_Retina_create_Size(&input_size, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Constructors from standardized interfaces : retreive a smart pointer to a Retina instance + /// + /// ## Parameters + /// * inputSize: the input frame size + /// * colorMode: the chosen processing mode : with or without color processing + /// * colorSamplingMethod: specifies which kind of color sampling will be used : + /// * cv::bioinspired::RETINA_COLOR_RANDOM: each pixel position is either R, G or B in a random choice + /// * cv::bioinspired::RETINA_COLOR_DIAGONAL: color sampling is RGBRGBRGB..., line 2 BRGBRGBRG..., line 3, GBRGBRGBR... + /// * cv::bioinspired::RETINA_COLOR_BAYER: standard bayer sampling + /// * useRetinaLogSampling: activate retina log sampling, if true, the 2 following parameters can + /// be used + /// * reductionFactor: only usefull if param useRetinaLogSampling=true, specifies the reduction + /// factor of the output frame (as the center (fovea) is high resolution and corners can be + /// underscaled, then a reduction of the output is allowed without precision leak + /// * samplingStrength: only usefull if param useRetinaLogSampling=true, specifies the strength of + /// the log scale that is applied + /// + /// ## C++ default parameters + /// * color_sampling_method: RETINA_COLOR_BAYER + /// * use_retina_log_sampling: false + /// * reduction_factor: 1.0f + /// * sampling_strength: 10.0f + #[inline] + pub fn create_ext(input_size: core::Size, color_mode: bool, color_sampling_method: i32, use_retina_log_sampling: bool, reduction_factor: f32, sampling_strength: f32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_bioinspired_Retina_create_Size_const_bool_int_const_bool_const_float_const_float(&input_size, color_mode, color_sampling_method, use_retina_log_sampling, reduction_factor, sampling_strength, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Constructors from standardized interfaces : retreive a smart pointer to a Retina instance + /// + /// ## Parameters + /// * inputSize: the input frame size + /// * colorMode: the chosen processing mode : with or without color processing + /// * colorSamplingMethod: specifies which kind of color sampling will be used : + /// * cv::bioinspired::RETINA_COLOR_RANDOM: each pixel position is either R, G or B in a random choice + /// * cv::bioinspired::RETINA_COLOR_DIAGONAL: color sampling is RGBRGBRGB..., line 2 BRGBRGBRG..., line 3, GBRGBRGBR... + /// * cv::bioinspired::RETINA_COLOR_BAYER: standard bayer sampling + /// * useRetinaLogSampling: activate retina log sampling, if true, the 2 following parameters can + /// be used + /// * reductionFactor: only usefull if param useRetinaLogSampling=true, specifies the reduction + /// factor of the output frame (as the center (fovea) is high resolution and corners can be + /// underscaled, then a reduction of the output is allowed without precision leak + /// * samplingStrength: only usefull if param useRetinaLogSampling=true, specifies the strength of + /// the log scale that is applied + /// + /// ## Note + /// This alternative version of [Retina::create_ext] function uses the following default values for its arguments: + /// * color_sampling_method: RETINA_COLOR_BAYER + /// * use_retina_log_sampling: false + /// * reduction_factor: 1.0f + /// * sampling_strength: 10.0f + #[inline] + pub fn create_ext_def(input_size: core::Size, color_mode: bool) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_bioinspired_Retina_create_Size_const_bool(&input_size, color_mode, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::bioinspired::Retina] pub trait RetinaTraitConst: core::AlgorithmTraitConst { fn as_raw_Retina(&self) -> *const c_void; @@ -646,42 +779,15 @@ pub mod bioinspired { } - /// class which allows the Gipsa/Listic Labs model to be used with OpenCV. - /// - /// This retina model allows spatio-temporal image processing (applied on still images, video sequences). - /// As a summary, these are the retina model properties: - /// - It applies a spectral whithening (mid-frequency details enhancement) - /// - high frequency spatio-temporal noise reduction - /// - low frequency luminance to be reduced (luminance range compression) - /// - local logarithmic luminance compression allows details to be enhanced in low light conditions - /// - /// USE : this model can be used basically for spatio-temporal video effects but also for : - /// _using the getParvo method output matrix : texture analysiswith enhanced signal to noise ratio and enhanced details robust against input images luminance ranges - /// _using the getMagno method output matrix : motion analysis also with the previously cited properties - /// - /// for more information, reer to the following papers : - /// Benoit A., Caplier A., Durette B., Herault, J., "USING HUMAN VISUAL SYSTEM MODELING FOR BIO-INSPIRED LOW LEVEL IMAGE PROCESSING", Elsevier, Computer Vision and Image Understanding 114 (2010), pp. 758-773, DOI: - /// Vision: Images, Signals and Neural Networks: Models of Neural Processing in Visual Perception (Progress in Neural Processing),By: Jeanny Herault, ISBN: 9814273686. WAPI (Tower ID): 113266891. - /// - /// The retina filter includes the research contributions of phd/research collegues from which code has been redrawn by the author : - /// take a look at the retinacolor.hpp module to discover Brice Chaix de Lavarene color mosaicing/demosaicing and the reference paper: - /// B. Chaix de Lavarene, D. Alleysson, B. Durette, J. Herault (2007). "Efficient demosaicing through recursive filtering", IEEE International Conference on Image Processing ICIP 2007 - /// take a look at imagelogpolprojection.hpp to discover retina spatial log sampling which originates from Barthelemy Durette phd with Jeanny Herault. A Retina / V1 cortex projection is also proposed and originates from Jeanny's discussions. - /// more informations in the above cited Jeanny Heraults's book. - pub struct Retina { - ptr: *mut c_void, - } - - opencv_type_boxed! { Retina } - - impl Drop for Retina { + impl std::fmt::Debug for Retina { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_bioinspired_Retina_delete(self.as_raw_mut_Retina()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Retina") + .finish() } } - unsafe impl Send for Retina {} + boxed_cast_base! { Retina, core::Algorithm, cv_bioinspired_Retina_to_Algorithm } impl core::AlgorithmTraitConst for Retina { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -703,112 +809,48 @@ pub mod bioinspired { boxed_ref! { Retina, crate::bioinspired::RetinaTraitConst, as_raw_Retina, crate::bioinspired::RetinaTrait, as_raw_mut_Retina } - impl Retina { - /// Constructors from standardized interfaces : retreive a smart pointer to a Retina instance - /// - /// ## Parameters - /// * inputSize: the input frame size - /// * colorMode: the chosen processing mode : with or without color processing - /// * colorSamplingMethod: specifies which kind of color sampling will be used : - /// * cv::bioinspired::RETINA_COLOR_RANDOM: each pixel position is either R, G or B in a random choice - /// * cv::bioinspired::RETINA_COLOR_DIAGONAL: color sampling is RGBRGBRGB..., line 2 BRGBRGBRG..., line 3, GBRGBRGBR... - /// * cv::bioinspired::RETINA_COLOR_BAYER: standard bayer sampling - /// * useRetinaLogSampling: activate retina log sampling, if true, the 2 following parameters can - /// be used - /// * reductionFactor: only usefull if param useRetinaLogSampling=true, specifies the reduction - /// factor of the output frame (as the center (fovea) is high resolution and corners can be - /// underscaled, then a reduction of the output is allowed without precision leak - /// * samplingStrength: only usefull if param useRetinaLogSampling=true, specifies the strength of - /// the log scale that is applied - /// - /// ## Overloaded parameters + /// a wrapper class which allows the tone mapping algorithm of Meylan&al(2007) to be used with OpenCV. + /// + /// This algorithm is already implemented in thre Retina class (retina::applyFastToneMapping) but used it does not require all the retina model to be allocated. This allows a light memory use for low memory devices (smartphones, etc. + /// As a summary, these are the model properties: + /// - 2 stages of local luminance adaptation with a different local neighborhood for each. + /// - first stage models the retina photorecetors local luminance adaptation + /// - second stage models th ganglion cells local information adaptation + /// - compared to the initial publication, this class uses spatio-temporal low pass filters instead of spatial only filters. + /// this can help noise robustness and temporal stability for video sequence use cases. + /// + /// for more information, read to the following papers : + /// Meylan L., Alleysson D., and Susstrunk S., A Model of Retinal Local Adaptation for the Tone Mapping of Color Filter Array Images, Journal of Optical Society of America, A, Vol. 24, N 9, September, 1st, 2007, pp. 2807-2816Benoit A., Caplier A., Durette B., Herault, J., "USING HUMAN VISUAL SYSTEM MODELING FOR BIO-INSPIRED LOW LEVEL IMAGE PROCESSING", Elsevier, Computer Vision and Image Understanding 114 (2010), pp. 758-773, DOI: + /// regarding spatio-temporal filter and the bigger retina model : + /// Vision: Images, Signals and Neural Networks: Models of Neural Processing in Visual Perception (Progress in Neural Processing),By: Jeanny Herault, ISBN: 9814273686. WAPI (Tower ID): 113266891. + pub struct RetinaFastToneMapping { + ptr: *mut c_void, + } + + opencv_type_boxed! { RetinaFastToneMapping } + + impl Drop for RetinaFastToneMapping { #[inline] - pub fn create(input_size: core::Size) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_bioinspired_Retina_create_Size(&input_size, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_bioinspired_RetinaFastToneMapping_delete(self.as_raw_mut_RetinaFastToneMapping()) }; } + } - /// Constructors from standardized interfaces : retreive a smart pointer to a Retina instance - /// - /// ## Parameters - /// * inputSize: the input frame size - /// * colorMode: the chosen processing mode : with or without color processing - /// * colorSamplingMethod: specifies which kind of color sampling will be used : - /// * cv::bioinspired::RETINA_COLOR_RANDOM: each pixel position is either R, G or B in a random choice - /// * cv::bioinspired::RETINA_COLOR_DIAGONAL: color sampling is RGBRGBRGB..., line 2 BRGBRGBRG..., line 3, GBRGBRGBR... - /// * cv::bioinspired::RETINA_COLOR_BAYER: standard bayer sampling - /// * useRetinaLogSampling: activate retina log sampling, if true, the 2 following parameters can - /// be used - /// * reductionFactor: only usefull if param useRetinaLogSampling=true, specifies the reduction - /// factor of the output frame (as the center (fovea) is high resolution and corners can be - /// underscaled, then a reduction of the output is allowed without precision leak - /// * samplingStrength: only usefull if param useRetinaLogSampling=true, specifies the strength of - /// the log scale that is applied - /// - /// ## C++ default parameters - /// * color_sampling_method: RETINA_COLOR_BAYER - /// * use_retina_log_sampling: false - /// * reduction_factor: 1.0f - /// * sampling_strength: 10.0f + unsafe impl Send for RetinaFastToneMapping {} + + impl RetinaFastToneMapping { #[inline] - pub fn create_ext(input_size: core::Size, color_mode: bool, color_sampling_method: i32, use_retina_log_sampling: bool, reduction_factor: f32, sampling_strength: f32) -> Result> { + pub fn create(input_size: core::Size) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_bioinspired_Retina_create_Size_const_bool_int_const_bool_const_float_const_float(&input_size, color_mode, color_sampling_method, use_retina_log_sampling, reduction_factor, sampling_strength, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_bioinspired_RetinaFastToneMapping_create_Size(&input_size, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Constructors from standardized interfaces : retreive a smart pointer to a Retina instance - /// - /// ## Parameters - /// * inputSize: the input frame size - /// * colorMode: the chosen processing mode : with or without color processing - /// * colorSamplingMethod: specifies which kind of color sampling will be used : - /// * cv::bioinspired::RETINA_COLOR_RANDOM: each pixel position is either R, G or B in a random choice - /// * cv::bioinspired::RETINA_COLOR_DIAGONAL: color sampling is RGBRGBRGB..., line 2 BRGBRGBRG..., line 3, GBRGBRGBR... - /// * cv::bioinspired::RETINA_COLOR_BAYER: standard bayer sampling - /// * useRetinaLogSampling: activate retina log sampling, if true, the 2 following parameters can - /// be used - /// * reductionFactor: only usefull if param useRetinaLogSampling=true, specifies the reduction - /// factor of the output frame (as the center (fovea) is high resolution and corners can be - /// underscaled, then a reduction of the output is allowed without precision leak - /// * samplingStrength: only usefull if param useRetinaLogSampling=true, specifies the strength of - /// the log scale that is applied - /// - /// ## Note - /// This alternative version of [Retina::create_ext] function uses the following default values for its arguments: - /// * color_sampling_method: RETINA_COLOR_BAYER - /// * use_retina_log_sampling: false - /// * reduction_factor: 1.0f - /// * sampling_strength: 10.0f - #[inline] - pub fn create_ext_def(input_size: core::Size, color_mode: bool) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_bioinspired_Retina_create_Size_const_bool(&input_size, color_mode, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { Retina, core::Algorithm, cv_bioinspired_Retina_to_Algorithm } - - impl std::fmt::Debug for Retina { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Retina") - .finish() - } - } - /// Constant methods for [crate::bioinspired::RetinaFastToneMapping] pub trait RetinaFastToneMappingTraitConst: core::AlgorithmTraitConst { fn as_raw_RetinaFastToneMapping(&self) -> *const c_void; @@ -891,34 +933,15 @@ pub mod bioinspired { } - /// a wrapper class which allows the tone mapping algorithm of Meylan&al(2007) to be used with OpenCV. - /// - /// This algorithm is already implemented in thre Retina class (retina::applyFastToneMapping) but used it does not require all the retina model to be allocated. This allows a light memory use for low memory devices (smartphones, etc. - /// As a summary, these are the model properties: - /// - 2 stages of local luminance adaptation with a different local neighborhood for each. - /// - first stage models the retina photorecetors local luminance adaptation - /// - second stage models th ganglion cells local information adaptation - /// - compared to the initial publication, this class uses spatio-temporal low pass filters instead of spatial only filters. - /// this can help noise robustness and temporal stability for video sequence use cases. - /// - /// for more information, read to the following papers : - /// Meylan L., Alleysson D., and Susstrunk S., A Model of Retinal Local Adaptation for the Tone Mapping of Color Filter Array Images, Journal of Optical Society of America, A, Vol. 24, N 9, September, 1st, 2007, pp. 2807-2816Benoit A., Caplier A., Durette B., Herault, J., "USING HUMAN VISUAL SYSTEM MODELING FOR BIO-INSPIRED LOW LEVEL IMAGE PROCESSING", Elsevier, Computer Vision and Image Understanding 114 (2010), pp. 758-773, DOI: - /// regarding spatio-temporal filter and the bigger retina model : - /// Vision: Images, Signals and Neural Networks: Models of Neural Processing in Visual Perception (Progress in Neural Processing),By: Jeanny Herault, ISBN: 9814273686. WAPI (Tower ID): 113266891. - pub struct RetinaFastToneMapping { - ptr: *mut c_void, - } - - opencv_type_boxed! { RetinaFastToneMapping } - - impl Drop for RetinaFastToneMapping { + impl std::fmt::Debug for RetinaFastToneMapping { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_bioinspired_RetinaFastToneMapping_delete(self.as_raw_mut_RetinaFastToneMapping()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RetinaFastToneMapping") + .finish() } } - unsafe impl Send for RetinaFastToneMapping {} + boxed_cast_base! { RetinaFastToneMapping, core::Algorithm, cv_bioinspired_RetinaFastToneMapping_to_Algorithm } impl core::AlgorithmTraitConst for RetinaFastToneMapping { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -940,27 +963,42 @@ pub mod bioinspired { boxed_ref! { RetinaFastToneMapping, crate::bioinspired::RetinaFastToneMappingTraitConst, as_raw_RetinaFastToneMapping, crate::bioinspired::RetinaFastToneMappingTrait, as_raw_mut_RetinaFastToneMapping } - impl RetinaFastToneMapping { + /// retina model parameters structure + /// + /// For better clarity, check explenations on the comments of methods : setupOPLandIPLParvoChannel and setupIPLMagnoChannel + /// + /// Here is the default configuration file of the retina module. It gives results such as the first + /// retina output shown on the top of this page. + /// + /// @include default_retina_config.xml + /// + /// Here is the 'realistic" setup used to obtain the second retina output shown on the top of this page. + /// + /// @include realistic_retina_config.xml + pub struct RetinaParameters { + ptr: *mut c_void, + } + + opencv_type_boxed! { RetinaParameters } + + impl Drop for RetinaParameters { #[inline] - pub fn create(input_size: core::Size) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_bioinspired_RetinaFastToneMapping_create_Size(&input_size, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_bioinspired_RetinaParameters_delete(self.as_raw_mut_RetinaParameters()) }; } - } - boxed_cast_base! { RetinaFastToneMapping, core::Algorithm, cv_bioinspired_RetinaFastToneMapping_to_Algorithm } + unsafe impl Send for RetinaParameters {} - impl std::fmt::Debug for RetinaFastToneMapping { + impl RetinaParameters { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RetinaFastToneMapping") - .finish() + pub fn default() -> crate::bioinspired::RetinaParameters { + let ret = unsafe { sys::cv_bioinspired_RetinaParameters_defaultNew_const() }; + let ret = unsafe { crate::bioinspired::RetinaParameters::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::bioinspired::RetinaParameters] @@ -1003,50 +1041,12 @@ pub mod bioinspired { } - /// retina model parameters structure - /// - /// For better clarity, check explenations on the comments of methods : setupOPLandIPLParvoChannel and setupIPLMagnoChannel - /// - /// Here is the default configuration file of the retina module. It gives results such as the first - /// retina output shown on the top of this page. - /// - /// @include default_retina_config.xml - /// - /// Here is the 'realistic" setup used to obtain the second retina output shown on the top of this page. - /// - /// @include realistic_retina_config.xml - pub struct RetinaParameters { - ptr: *mut c_void, - } - - opencv_type_boxed! { RetinaParameters } - - impl Drop for RetinaParameters { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_bioinspired_RetinaParameters_delete(self.as_raw_mut_RetinaParameters()) }; - } - } - - unsafe impl Send for RetinaParameters {} - - impl crate::bioinspired::RetinaParametersTraitConst for RetinaParameters { - #[inline] fn as_raw_RetinaParameters(&self) -> *const c_void { self.as_raw() } - } - - impl crate::bioinspired::RetinaParametersTrait for RetinaParameters { - #[inline] fn as_raw_mut_RetinaParameters(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { RetinaParameters, crate::bioinspired::RetinaParametersTraitConst, as_raw_RetinaParameters, crate::bioinspired::RetinaParametersTrait, as_raw_mut_RetinaParameters } - - impl RetinaParameters { - /// Creates a default instance of the class by calling the default constructor + impl Default for RetinaParameters { #[inline] + /// Forwards to infallible Self::default() fn default() -> Self { - unsafe { Self::from_raw(sys::cv_bioinspired_RetinaParameters_defaultNew_const()) } + Self::default() } - } impl Clone for RetinaParameters { @@ -1066,14 +1066,16 @@ pub mod bioinspired { } } - impl Default for RetinaParameters { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } + impl crate::bioinspired::RetinaParametersTraitConst for RetinaParameters { + #[inline] fn as_raw_RetinaParameters(&self) -> *const c_void { self.as_raw() } + } + + impl crate::bioinspired::RetinaParametersTrait for RetinaParameters { + #[inline] fn as_raw_mut_RetinaParameters(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { RetinaParameters, crate::bioinspired::RetinaParametersTraitConst, as_raw_RetinaParameters, crate::bioinspired::RetinaParametersTrait, as_raw_mut_RetinaParameters } + /// Inner Plexiform Layer Magnocellular channel (IplMagno) #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] @@ -1163,6 +1165,49 @@ pub mod bioinspired { } + /// class which provides a transient/moving areas segmentation module + /// + /// perform a locally adapted segmentation by using the retina magno input data Based on Alexandre + /// BENOIT thesis: "Le système visuel humain au secours de la vision par ordinateur" + /// + /// 3 spatio temporal filters are used: + /// - a first one which filters the noise and local variations of the input motion energy + /// - a second (more powerfull low pass spatial filter) which gives the neighborhood motion energy the + /// segmentation consists in the comparison of these both outputs, if the local motion energy is higher + /// to the neighborhood otion energy, then the area is considered as moving and is segmented + /// - a stronger third low pass filter helps decision by providing a smooth information about the + /// "motion context" in a wider area + pub struct TransientAreasSegmentationModule { + ptr: *mut c_void, + } + + opencv_type_boxed! { TransientAreasSegmentationModule } + + impl Drop for TransientAreasSegmentationModule { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_bioinspired_TransientAreasSegmentationModule_delete(self.as_raw_mut_TransientAreasSegmentationModule()) }; + } + } + + unsafe impl Send for TransientAreasSegmentationModule {} + + impl TransientAreasSegmentationModule { + /// allocator + /// ## Parameters + /// * inputSize: : size of the images input to segment (output will be the same size) + #[inline] + pub fn create(input_size: core::Size) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_bioinspired_TransientAreasSegmentationModule_create_Size(&input_size, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::bioinspired::TransientAreasSegmentationModule] pub trait TransientAreasSegmentationModuleTraitConst: core::AlgorithmTraitConst { fn as_raw_TransientAreasSegmentationModule(&self) -> *const c_void; @@ -1386,32 +1431,15 @@ pub mod bioinspired { } - /// class which provides a transient/moving areas segmentation module - /// - /// perform a locally adapted segmentation by using the retina magno input data Based on Alexandre - /// BENOIT thesis: "Le système visuel humain au secours de la vision par ordinateur" - /// - /// 3 spatio temporal filters are used: - /// - a first one which filters the noise and local variations of the input motion energy - /// - a second (more powerfull low pass spatial filter) which gives the neighborhood motion energy the - /// segmentation consists in the comparison of these both outputs, if the local motion energy is higher - /// to the neighborhood otion energy, then the area is considered as moving and is segmented - /// - a stronger third low pass filter helps decision by providing a smooth information about the - /// "motion context" in a wider area - pub struct TransientAreasSegmentationModule { - ptr: *mut c_void, - } - - opencv_type_boxed! { TransientAreasSegmentationModule } - - impl Drop for TransientAreasSegmentationModule { + impl std::fmt::Debug for TransientAreasSegmentationModule { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_bioinspired_TransientAreasSegmentationModule_delete(self.as_raw_mut_TransientAreasSegmentationModule()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TransientAreasSegmentationModule") + .finish() } } - unsafe impl Send for TransientAreasSegmentationModule {} + boxed_cast_base! { TransientAreasSegmentationModule, core::Algorithm, cv_bioinspired_TransientAreasSegmentationModule_to_Algorithm } impl core::AlgorithmTraitConst for TransientAreasSegmentationModule { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1433,29 +1461,4 @@ pub mod bioinspired { boxed_ref! { TransientAreasSegmentationModule, crate::bioinspired::TransientAreasSegmentationModuleTraitConst, as_raw_TransientAreasSegmentationModule, crate::bioinspired::TransientAreasSegmentationModuleTrait, as_raw_mut_TransientAreasSegmentationModule } - impl TransientAreasSegmentationModule { - /// allocator - /// ## Parameters - /// * inputSize: : size of the images input to segment (output will be the same size) - #[inline] - pub fn create(input_size: core::Size) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_bioinspired_TransientAreasSegmentationModule_create_Size(&input_size, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { TransientAreasSegmentationModule, core::Algorithm, cv_bioinspired_TransientAreasSegmentationModule_to_Algorithm } - - impl std::fmt::Debug for TransientAreasSegmentationModule { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TransientAreasSegmentationModule") - .finish() - } - } } diff --git a/docs/calib3d.rs b/docs/calib3d.rs index 8382bc87f..b16e44686 100644 --- a/docs/calib3d.rs +++ b/docs/calib3d.rs @@ -9074,6 +9074,55 @@ pub mod calib3d { } + /// Levenberg-Marquardt solver. Starting with the specified vector of parameters it + /// optimizes the target vector criteria "err" + /// (finds local minima of each target vector component absolute value). + /// + /// When needed, it calls user-provided callback. + pub struct LMSolver { + ptr: *mut c_void, + } + + opencv_type_boxed! { LMSolver } + + impl Drop for LMSolver { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_LMSolver_delete(self.as_raw_mut_LMSolver()) }; + } + } + + unsafe impl Send for LMSolver {} + + impl LMSolver { + /// Creates Levenberg-Marquard solver + /// + /// ## Parameters + /// * cb: callback + /// * maxIters: maximum number of iterations that can be further + /// modified using setMaxIters() method. + #[inline] + pub fn create(cb: &core::Ptr, max_iters: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_LMSolver_create_const_PtrLCallbackGR_int(cb.as_raw_PtrOfLMSolver_Callback(), max_iters, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn create_ext(cb: &core::Ptr, max_iters: i32, eps: f64) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_LMSolver_create_const_PtrLCallbackGR_int_double(cb.as_raw_PtrOfLMSolver_Callback(), max_iters, eps, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::calib3d::LMSolver] pub trait LMSolverTraitConst: core::AlgorithmTraitConst { fn as_raw_LMSolver(&self) -> *const c_void; @@ -9129,25 +9178,15 @@ pub mod calib3d { } - /// Levenberg-Marquardt solver. Starting with the specified vector of parameters it - /// optimizes the target vector criteria "err" - /// (finds local minima of each target vector component absolute value). - /// - /// When needed, it calls user-provided callback. - pub struct LMSolver { - ptr: *mut c_void, - } - - opencv_type_boxed! { LMSolver } - - impl Drop for LMSolver { + impl std::fmt::Debug for LMSolver { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_LMSolver_delete(self.as_raw_mut_LMSolver()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LMSolver") + .finish() } } - unsafe impl Send for LMSolver {} + boxed_cast_base! { LMSolver, core::Algorithm, cv_LMSolver_to_Algorithm } impl core::AlgorithmTraitConst for LMSolver { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -9169,45 +9208,21 @@ pub mod calib3d { boxed_ref! { LMSolver, crate::calib3d::LMSolverTraitConst, as_raw_LMSolver, crate::calib3d::LMSolverTrait, as_raw_mut_LMSolver } - impl LMSolver { - /// Creates Levenberg-Marquard solver - /// - /// ## Parameters - /// * cb: callback - /// * maxIters: maximum number of iterations that can be further - /// modified using setMaxIters() method. - #[inline] - pub fn create(cb: &core::Ptr, max_iters: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_LMSolver_create_const_PtrLCallbackGR_int(cb.as_raw_PtrOfLMSolver_Callback(), max_iters, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn create_ext(cb: &core::Ptr, max_iters: i32, eps: f64) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_LMSolver_create_const_PtrLCallbackGR_int_double(cb.as_raw_PtrOfLMSolver_Callback(), max_iters, eps, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + pub struct LMSolver_Callback { + ptr: *mut c_void, } - boxed_cast_base! { LMSolver, core::Algorithm, cv_LMSolver_to_Algorithm } + opencv_type_boxed! { LMSolver_Callback } - impl std::fmt::Debug for LMSolver { + impl Drop for LMSolver_Callback { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LMSolver") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_LMSolver_Callback_delete(self.as_raw_mut_LMSolver_Callback()) }; } } + unsafe impl Send for LMSolver_Callback {} + /// Constant methods for [crate::calib3d::LMSolver_Callback] pub trait LMSolver_CallbackTraitConst { fn as_raw_LMSolver_Callback(&self) -> *const c_void; @@ -9243,21 +9258,14 @@ pub mod calib3d { } - pub struct LMSolver_Callback { - ptr: *mut c_void, - } - - opencv_type_boxed! { LMSolver_Callback } - - impl Drop for LMSolver_Callback { + impl std::fmt::Debug for LMSolver_Callback { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_LMSolver_Callback_delete(self.as_raw_mut_LMSolver_Callback()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LMSolver_Callback") + .finish() } } - unsafe impl Send for LMSolver_Callback {} - impl crate::calib3d::LMSolver_CallbackTraitConst for LMSolver_Callback { #[inline] fn as_raw_LMSolver_Callback(&self) -> *const c_void { self.as_raw() } } @@ -9268,15 +9276,79 @@ pub mod calib3d { boxed_ref! { LMSolver_Callback, crate::calib3d::LMSolver_CallbackTraitConst, as_raw_LMSolver_Callback, crate::calib3d::LMSolver_CallbackTrait, as_raw_mut_LMSolver_Callback } - impl LMSolver_Callback { + /// Class for computing stereo correspondence using the block matching algorithm, introduced and + /// contributed to OpenCV by K. Konolige. + pub struct StereoBM { + ptr: *mut c_void, + } + + opencv_type_boxed! { StereoBM } + + impl Drop for StereoBM { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_StereoBM_delete(self.as_raw_mut_StereoBM()) }; + } } - impl std::fmt::Debug for LMSolver_Callback { + unsafe impl Send for StereoBM {} + + impl StereoBM { + /// Creates StereoBM object + /// + /// ## Parameters + /// * numDisparities: the disparity search range. For each pixel algorithm will find the best + /// disparity from 0 (default minimum disparity) to numDisparities. The search range can then be + /// shifted by changing the minimum disparity. + /// * blockSize: the linear size of the blocks compared by the algorithm. The size should be odd + /// (as the block is centered at the current pixel). Larger block size implies smoother, though less + /// accurate disparity map. Smaller block size gives more detailed disparity map, but there is higher + /// chance for algorithm to find a wrong correspondence. + /// + /// The function create StereoBM object. You can then call StereoBM::compute() to compute disparity for + /// a specific stereo pair. + /// + /// ## C++ default parameters + /// * num_disparities: 0 + /// * block_size: 21 #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LMSolver_Callback") - .finish() + pub fn create(num_disparities: i32, block_size: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_StereoBM_create_int_int(num_disparities, block_size, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Creates StereoBM object + /// + /// ## Parameters + /// * numDisparities: the disparity search range. For each pixel algorithm will find the best + /// disparity from 0 (default minimum disparity) to numDisparities. The search range can then be + /// shifted by changing the minimum disparity. + /// * blockSize: the linear size of the blocks compared by the algorithm. The size should be odd + /// (as the block is centered at the current pixel). Larger block size implies smoother, though less + /// accurate disparity map. Smaller block size gives more detailed disparity map, but there is higher + /// chance for algorithm to find a wrong correspondence. + /// + /// The function create StereoBM object. You can then call StereoBM::compute() to compute disparity for + /// a specific stereo pair. + /// + /// ## Note + /// This alternative version of [StereoBM::create] function uses the following default values for its arguments: + /// * num_disparities: 0 + /// * block_size: 21 + #[inline] + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_StereoBM_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::calib3d::StereoBM] @@ -9435,22 +9507,17 @@ pub mod calib3d { } - /// Class for computing stereo correspondence using the block matching algorithm, introduced and - /// contributed to OpenCV by K. Konolige. - pub struct StereoBM { - ptr: *mut c_void, - } - - opencv_type_boxed! { StereoBM } - - impl Drop for StereoBM { + impl std::fmt::Debug for StereoBM { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_StereoBM_delete(self.as_raw_mut_StereoBM()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("StereoBM") + .finish() } } - unsafe impl Send for StereoBM {} + boxed_cast_base! { StereoBM, core::Algorithm, cv_StereoBM_to_Algorithm } + + boxed_cast_base! { StereoBM, crate::calib3d::StereoMatcher, cv_StereoBM_to_StereoMatcher } impl core::AlgorithmTraitConst for StereoBM { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -9482,75 +9549,21 @@ pub mod calib3d { boxed_ref! { StereoBM, crate::calib3d::StereoBMTraitConst, as_raw_StereoBM, crate::calib3d::StereoBMTrait, as_raw_mut_StereoBM } - impl StereoBM { - /// Creates StereoBM object - /// - /// ## Parameters - /// * numDisparities: the disparity search range. For each pixel algorithm will find the best - /// disparity from 0 (default minimum disparity) to numDisparities. The search range can then be - /// shifted by changing the minimum disparity. - /// * blockSize: the linear size of the blocks compared by the algorithm. The size should be odd - /// (as the block is centered at the current pixel). Larger block size implies smoother, though less - /// accurate disparity map. Smaller block size gives more detailed disparity map, but there is higher - /// chance for algorithm to find a wrong correspondence. - /// - /// The function create StereoBM object. You can then call StereoBM::compute() to compute disparity for - /// a specific stereo pair. - /// - /// ## C++ default parameters - /// * num_disparities: 0 - /// * block_size: 21 + /// The base class for stereo correspondence algorithms. + pub struct StereoMatcher { + ptr: *mut c_void, + } + + opencv_type_boxed! { StereoMatcher } + + impl Drop for StereoMatcher { #[inline] - pub fn create(num_disparities: i32, block_size: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_StereoBM_create_int_int(num_disparities, block_size, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_StereoMatcher_delete(self.as_raw_mut_StereoMatcher()) }; } + } - /// Creates StereoBM object - /// - /// ## Parameters - /// * numDisparities: the disparity search range. For each pixel algorithm will find the best - /// disparity from 0 (default minimum disparity) to numDisparities. The search range can then be - /// shifted by changing the minimum disparity. - /// * blockSize: the linear size of the blocks compared by the algorithm. The size should be odd - /// (as the block is centered at the current pixel). Larger block size implies smoother, though less - /// accurate disparity map. Smaller block size gives more detailed disparity map, but there is higher - /// chance for algorithm to find a wrong correspondence. - /// - /// The function create StereoBM object. You can then call StereoBM::compute() to compute disparity for - /// a specific stereo pair. - /// - /// ## Note - /// This alternative version of [StereoBM::create] function uses the following default values for its arguments: - /// * num_disparities: 0 - /// * block_size: 21 - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_StereoBM_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { StereoBM, core::Algorithm, cv_StereoBM_to_Algorithm } - - boxed_cast_base! { StereoBM, crate::calib3d::StereoMatcher, cv_StereoBM_to_StereoMatcher } - - impl std::fmt::Debug for StereoBM { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("StereoBM") - .finish() - } - } + unsafe impl Send for StereoMatcher {} /// Constant methods for [crate::calib3d::StereoMatcher] pub trait StereoMatcherTraitConst: core::AlgorithmTraitConst { @@ -9692,21 +9705,19 @@ pub mod calib3d { } - /// The base class for stereo correspondence algorithms. - pub struct StereoMatcher { - ptr: *mut c_void, - } - - opencv_type_boxed! { StereoMatcher } - - impl Drop for StereoMatcher { + impl std::fmt::Debug for StereoMatcher { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_StereoMatcher_delete(self.as_raw_mut_StereoMatcher()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("StereoMatcher") + .finish() } } - unsafe impl Send for StereoMatcher {} + boxed_cast_base! { StereoMatcher, core::Algorithm, cv_StereoMatcher_to_Algorithm } + + boxed_cast_descendant! { StereoMatcher, crate::calib3d::StereoBM, cv_StereoMatcher_to_StereoBM } + + boxed_cast_descendant! { StereoMatcher, crate::calib3d::StereoSGBM, cv_StereoMatcher_to_StereoSGBM } impl core::AlgorithmTraitConst for StereoMatcher { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -9728,125 +9739,6 @@ pub mod calib3d { boxed_ref! { StereoMatcher, crate::calib3d::StereoMatcherTraitConst, as_raw_StereoMatcher, crate::calib3d::StereoMatcherTrait, as_raw_mut_StereoMatcher } - impl StereoMatcher { - } - - boxed_cast_descendant! { StereoMatcher, crate::calib3d::StereoBM, cv_StereoMatcher_to_StereoBM } - - boxed_cast_descendant! { StereoMatcher, crate::calib3d::StereoSGBM, cv_StereoMatcher_to_StereoSGBM } - - boxed_cast_base! { StereoMatcher, core::Algorithm, cv_StereoMatcher_to_Algorithm } - - impl std::fmt::Debug for StereoMatcher { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("StereoMatcher") - .finish() - } - } - - /// Constant methods for [crate::calib3d::StereoSGBM] - pub trait StereoSGBMTraitConst: crate::calib3d::StereoMatcherTraitConst { - fn as_raw_StereoSGBM(&self) -> *const c_void; - - #[inline] - fn get_pre_filter_cap(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_StereoSGBM_getPreFilterCap_const(self.as_raw_StereoSGBM(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_uniqueness_ratio(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_StereoSGBM_getUniquenessRatio_const(self.as_raw_StereoSGBM(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_p1(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_StereoSGBM_getP1_const(self.as_raw_StereoSGBM(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_p2(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_StereoSGBM_getP2_const(self.as_raw_StereoSGBM(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_mode(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_StereoSGBM_getMode_const(self.as_raw_StereoSGBM(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - /// Mutable methods for [crate::calib3d::StereoSGBM] - pub trait StereoSGBMTrait: crate::calib3d::StereoMatcherTrait + crate::calib3d::StereoSGBMTraitConst { - fn as_raw_mut_StereoSGBM(&mut self) -> *mut c_void; - - #[inline] - fn set_pre_filter_cap(&mut self, pre_filter_cap: i32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_StereoSGBM_setPreFilterCap_int(self.as_raw_mut_StereoSGBM(), pre_filter_cap, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn set_uniqueness_ratio(&mut self, uniqueness_ratio: i32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_StereoSGBM_setUniquenessRatio_int(self.as_raw_mut_StereoSGBM(), uniqueness_ratio, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn set_p1(&mut self, p1: i32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_StereoSGBM_setP1_int(self.as_raw_mut_StereoSGBM(), p1, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn set_p2(&mut self, p2: i32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_StereoSGBM_setP2_int(self.as_raw_mut_StereoSGBM(), p2, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn set_mode(&mut self, mode: i32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_StereoSGBM_setMode_int(self.as_raw_mut_StereoSGBM(), mode, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - /// The class implements the modified H. Hirschmuller algorithm [HH08](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_HH08) that differs from the original /// one as follows: /// @@ -9880,36 +9772,6 @@ pub mod calib3d { unsafe impl Send for StereoSGBM {} - impl core::AlgorithmTraitConst for StereoSGBM { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for StereoSGBM { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { StereoSGBM, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::calib3d::StereoMatcherTraitConst for StereoSGBM { - #[inline] fn as_raw_StereoMatcher(&self) -> *const c_void { self.as_raw() } - } - - impl crate::calib3d::StereoMatcherTrait for StereoSGBM { - #[inline] fn as_raw_mut_StereoMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { StereoSGBM, crate::calib3d::StereoMatcherTraitConst, as_raw_StereoMatcher, crate::calib3d::StereoMatcherTrait, as_raw_mut_StereoMatcher } - - impl crate::calib3d::StereoSGBMTraitConst for StereoSGBM { - #[inline] fn as_raw_StereoSGBM(&self) -> *const c_void { self.as_raw() } - } - - impl crate::calib3d::StereoSGBMTrait for StereoSGBM { - #[inline] fn as_raw_mut_StereoSGBM(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { StereoSGBM, crate::calib3d::StereoSGBMTraitConst, as_raw_StereoSGBM, crate::calib3d::StereoSGBMTrait, as_raw_mut_StereoSGBM } - impl StereoSGBM { /// Creates StereoSGBM object /// @@ -10034,9 +9896,107 @@ pub mod calib3d { } - boxed_cast_base! { StereoSGBM, core::Algorithm, cv_StereoSGBM_to_Algorithm } + /// Constant methods for [crate::calib3d::StereoSGBM] + pub trait StereoSGBMTraitConst: crate::calib3d::StereoMatcherTraitConst { + fn as_raw_StereoSGBM(&self) -> *const c_void; - boxed_cast_base! { StereoSGBM, crate::calib3d::StereoMatcher, cv_StereoSGBM_to_StereoMatcher } + #[inline] + fn get_pre_filter_cap(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_StereoSGBM_getPreFilterCap_const(self.as_raw_StereoSGBM(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn get_uniqueness_ratio(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_StereoSGBM_getUniquenessRatio_const(self.as_raw_StereoSGBM(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn get_p1(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_StereoSGBM_getP1_const(self.as_raw_StereoSGBM(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn get_p2(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_StereoSGBM_getP2_const(self.as_raw_StereoSGBM(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn get_mode(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_StereoSGBM_getMode_const(self.as_raw_StereoSGBM(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + /// Mutable methods for [crate::calib3d::StereoSGBM] + pub trait StereoSGBMTrait: crate::calib3d::StereoMatcherTrait + crate::calib3d::StereoSGBMTraitConst { + fn as_raw_mut_StereoSGBM(&mut self) -> *mut c_void; + + #[inline] + fn set_pre_filter_cap(&mut self, pre_filter_cap: i32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_StereoSGBM_setPreFilterCap_int(self.as_raw_mut_StereoSGBM(), pre_filter_cap, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn set_uniqueness_ratio(&mut self, uniqueness_ratio: i32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_StereoSGBM_setUniquenessRatio_int(self.as_raw_mut_StereoSGBM(), uniqueness_ratio, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn set_p1(&mut self, p1: i32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_StereoSGBM_setP1_int(self.as_raw_mut_StereoSGBM(), p1, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn set_p2(&mut self, p2: i32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_StereoSGBM_setP2_int(self.as_raw_mut_StereoSGBM(), p2, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn set_mode(&mut self, mode: i32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_StereoSGBM_setMode_int(self.as_raw_mut_StereoSGBM(), mode, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } impl std::fmt::Debug for StereoSGBM { #[inline] @@ -10046,6 +10006,40 @@ pub mod calib3d { } } + boxed_cast_base! { StereoSGBM, core::Algorithm, cv_StereoSGBM_to_Algorithm } + + boxed_cast_base! { StereoSGBM, crate::calib3d::StereoMatcher, cv_StereoSGBM_to_StereoMatcher } + + impl core::AlgorithmTraitConst for StereoSGBM { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } + } + + impl core::AlgorithmTrait for StereoSGBM { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { StereoSGBM, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + + impl crate::calib3d::StereoMatcherTraitConst for StereoSGBM { + #[inline] fn as_raw_StereoMatcher(&self) -> *const c_void { self.as_raw() } + } + + impl crate::calib3d::StereoMatcherTrait for StereoSGBM { + #[inline] fn as_raw_mut_StereoMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { StereoSGBM, crate::calib3d::StereoMatcherTraitConst, as_raw_StereoMatcher, crate::calib3d::StereoMatcherTrait, as_raw_mut_StereoMatcher } + + impl crate::calib3d::StereoSGBMTraitConst for StereoSGBM { + #[inline] fn as_raw_StereoSGBM(&self) -> *const c_void { self.as_raw() } + } + + impl crate::calib3d::StereoSGBMTrait for StereoSGBM { + #[inline] fn as_raw_mut_StereoSGBM(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { StereoSGBM, crate::calib3d::StereoSGBMTraitConst, as_raw_StereoSGBM, crate::calib3d::StereoSGBMTrait, as_raw_mut_StereoSGBM } + #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] pub struct UsacParams { @@ -10077,4 +10071,5 @@ pub mod calib3d { } } + } diff --git a/docs/ccalib.rs b/docs/ccalib.rs index cc54fc079..9444c1653 100644 --- a/docs/ccalib.rs +++ b/docs/ccalib.rs @@ -587,6 +587,34 @@ pub mod ccalib { Ok(ret) } + pub struct CustomPattern { + ptr: *mut c_void, + } + + opencv_type_boxed! { CustomPattern } + + impl Drop for CustomPattern { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_ccalib_CustomPattern_delete(self.as_raw_mut_CustomPattern()) }; + } + } + + unsafe impl Send for CustomPattern {} + + impl CustomPattern { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ccalib_CustomPattern_CustomPattern(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::ccalib::CustomPattern::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::ccalib::CustomPattern] pub trait CustomPatternTraitConst: core::AlgorithmTraitConst { fn as_raw_CustomPattern(&self) -> *const c_void; @@ -985,20 +1013,15 @@ pub mod ccalib { } - pub struct CustomPattern { - ptr: *mut c_void, - } - - opencv_type_boxed! { CustomPattern } - - impl Drop for CustomPattern { + impl std::fmt::Debug for CustomPattern { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ccalib_CustomPattern_delete(self.as_raw_mut_CustomPattern()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CustomPattern") + .finish() } } - unsafe impl Send for CustomPattern {} + boxed_cast_base! { CustomPattern, core::Algorithm, cv_ccalib_CustomPattern_to_Algorithm } impl core::AlgorithmTraitConst for CustomPattern { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1020,27 +1043,75 @@ pub mod ccalib { boxed_ref! { CustomPattern, crate::ccalib::CustomPatternTraitConst, as_raw_CustomPattern, crate::ccalib::CustomPatternTrait, as_raw_mut_CustomPattern } - impl CustomPattern { + /// Class for multiple camera calibration that supports pinhole camera and omnidirection camera. + /// For omnidirectional camera model, please refer to omnidir.hpp in ccalib module. + /// It first calibrate each camera individually, then a bundle adjustment like optimization is applied to + /// refine extrinsic parameters. So far, it only support "random" pattern for calibration, + /// see randomPattern.hpp in ccalib module for details. + /// Images that are used should be named by "cameraIdx-timestamp.*", several images with the same timestamp + /// means that they are the same pattern that are photographed. cameraIdx should start from 0. + /// + /// For more details, please refer to paper + /// B. Li, L. Heng, K. Kevin and M. Pollefeys, "A Multiple-Camera System + /// Calibration Toolbox Using A Feature Descriptor-Based Calibration + /// Pattern", in IROS 2013. + pub struct MultiCameraCalibration { + ptr: *mut c_void, + } + + opencv_type_boxed! { MultiCameraCalibration } + + impl Drop for MultiCameraCalibration { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_multicalib_MultiCameraCalibration_delete(self.as_raw_mut_MultiCameraCalibration()) }; + } + } + + unsafe impl Send for MultiCameraCalibration {} + + impl MultiCameraCalibration { + /// ## C++ default parameters + /// * verbose: 0 + /// * show_extration: 0 + /// * n_mini_matches: 20 + /// * flags: 0 + /// * criteria: TermCriteria(TermCriteria::COUNT+TermCriteria::EPS,200,1e-7) + /// * detector: AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0,3,0.006f) + /// * descriptor: AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0,3,0.006f) + /// * matcher: DescriptorMatcher::create("BruteForce-L1") + #[inline] + pub fn new(camera_type: i32, n_cameras: i32, file_name: &str, pattern_width: f32, pattern_height: f32, verbose: i32, show_extration: i32, n_mini_matches: i32, flags: i32, criteria: core::TermCriteria, mut detector: core::Ptr, mut descriptor: core::Ptr, mut matcher: core::Ptr) -> Result { + extern_container_arg!(file_name); return_send!(via ocvrs_return); - unsafe { sys::cv_ccalib_CustomPattern_CustomPattern(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_multicalib_MultiCameraCalibration_MultiCameraCalibration_int_int_const_stringR_float_float_int_int_int_int_TermCriteria_PtrLFeature2DG_PtrLFeature2DG_PtrLDescriptorMatcherG(camera_type, n_cameras, file_name.opencv_as_extern(), pattern_width, pattern_height, verbose, show_extration, n_mini_matches, flags, &criteria, detector.as_raw_mut_PtrOfFeature2D(), descriptor.as_raw_mut_PtrOfFeature2D(), matcher.as_raw_mut_PtrOfDescriptorMatcher(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::ccalib::CustomPattern::opencv_from_extern(ret) }; + let ret = unsafe { crate::ccalib::MultiCameraCalibration::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { CustomPattern, core::Algorithm, cv_ccalib_CustomPattern_to_Algorithm } - - impl std::fmt::Debug for CustomPattern { + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * verbose: 0 + /// * show_extration: 0 + /// * n_mini_matches: 20 + /// * flags: 0 + /// * criteria: TermCriteria(TermCriteria::COUNT+TermCriteria::EPS,200,1e-7) + /// * detector: AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0,3,0.006f) + /// * descriptor: AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0,3,0.006f) + /// * matcher: DescriptorMatcher::create("BruteForce-L1") #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CustomPattern") - .finish() + pub fn new_def(camera_type: i32, n_cameras: i32, file_name: &str, pattern_width: f32, pattern_height: f32) -> Result { + extern_container_arg!(file_name); + return_send!(via ocvrs_return); + unsafe { sys::cv_multicalib_MultiCameraCalibration_MultiCameraCalibration_int_int_const_stringR_float_float(camera_type, n_cameras, file_name.opencv_as_extern(), pattern_width, pattern_height, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::ccalib::MultiCameraCalibration::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::ccalib::MultiCameraCalibration] @@ -1101,33 +1172,14 @@ pub mod ccalib { } - /// Class for multiple camera calibration that supports pinhole camera and omnidirection camera. - /// For omnidirectional camera model, please refer to omnidir.hpp in ccalib module. - /// It first calibrate each camera individually, then a bundle adjustment like optimization is applied to - /// refine extrinsic parameters. So far, it only support "random" pattern for calibration, - /// see randomPattern.hpp in ccalib module for details. - /// Images that are used should be named by "cameraIdx-timestamp.*", several images with the same timestamp - /// means that they are the same pattern that are photographed. cameraIdx should start from 0. - /// - /// For more details, please refer to paper - /// B. Li, L. Heng, K. Kevin and M. Pollefeys, "A Multiple-Camera System - /// Calibration Toolbox Using A Feature Descriptor-Based Calibration - /// Pattern", in IROS 2013. - pub struct MultiCameraCalibration { - ptr: *mut c_void, - } - - opencv_type_boxed! { MultiCameraCalibration } - - impl Drop for MultiCameraCalibration { + impl std::fmt::Debug for MultiCameraCalibration { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_multicalib_MultiCameraCalibration_delete(self.as_raw_mut_MultiCameraCalibration()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MultiCameraCalibration") + .finish() } } - unsafe impl Send for MultiCameraCalibration {} - impl crate::ccalib::MultiCameraCalibrationTraitConst for MultiCameraCalibration { #[inline] fn as_raw_MultiCameraCalibration(&self) -> *const c_void { self.as_raw() } } @@ -1138,58 +1190,34 @@ pub mod ccalib { boxed_ref! { MultiCameraCalibration, crate::ccalib::MultiCameraCalibrationTraitConst, as_raw_MultiCameraCalibration, crate::ccalib::MultiCameraCalibrationTrait, as_raw_mut_MultiCameraCalibration } - impl MultiCameraCalibration { - /// ## C++ default parameters - /// * verbose: 0 - /// * show_extration: 0 - /// * n_mini_matches: 20 - /// * flags: 0 - /// * criteria: TermCriteria(TermCriteria::COUNT+TermCriteria::EPS,200,1e-7) - /// * detector: AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0,3,0.006f) - /// * descriptor: AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0,3,0.006f) - /// * matcher: DescriptorMatcher::create("BruteForce-L1") + pub struct MultiCameraCalibration_edge { + ptr: *mut c_void, + } + + opencv_type_boxed! { MultiCameraCalibration_edge } + + impl Drop for MultiCameraCalibration_edge { #[inline] - pub fn new(camera_type: i32, n_cameras: i32, file_name: &str, pattern_width: f32, pattern_height: f32, verbose: i32, show_extration: i32, n_mini_matches: i32, flags: i32, criteria: core::TermCriteria, mut detector: core::Ptr, mut descriptor: core::Ptr, mut matcher: core::Ptr) -> Result { - extern_container_arg!(file_name); - return_send!(via ocvrs_return); - unsafe { sys::cv_multicalib_MultiCameraCalibration_MultiCameraCalibration_int_int_const_stringR_float_float_int_int_int_int_TermCriteria_PtrLFeature2DG_PtrLFeature2DG_PtrLDescriptorMatcherG(camera_type, n_cameras, file_name.opencv_as_extern(), pattern_width, pattern_height, verbose, show_extration, n_mini_matches, flags, &criteria, detector.as_raw_mut_PtrOfFeature2D(), descriptor.as_raw_mut_PtrOfFeature2D(), matcher.as_raw_mut_PtrOfDescriptorMatcher(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::ccalib::MultiCameraCalibration::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_multicalib_MultiCameraCalibration_edge_delete(self.as_raw_mut_MultiCameraCalibration_edge()) }; } + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * verbose: 0 - /// * show_extration: 0 - /// * n_mini_matches: 20 - /// * flags: 0 - /// * criteria: TermCriteria(TermCriteria::COUNT+TermCriteria::EPS,200,1e-7) - /// * detector: AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0,3,0.006f) - /// * descriptor: AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0,3,0.006f) - /// * matcher: DescriptorMatcher::create("BruteForce-L1") + unsafe impl Send for MultiCameraCalibration_edge {} + + impl MultiCameraCalibration_edge { #[inline] - pub fn new_def(camera_type: i32, n_cameras: i32, file_name: &str, pattern_width: f32, pattern_height: f32) -> Result { - extern_container_arg!(file_name); + pub fn new(cv: i32, pv: i32, pi: i32, mut trans: impl core::MatTrait) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_multicalib_MultiCameraCalibration_MultiCameraCalibration_int_int_const_stringR_float_float(camera_type, n_cameras, file_name.opencv_as_extern(), pattern_width, pattern_height, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_multicalib_MultiCameraCalibration_edge_edge_int_int_int_Mat(cv, pv, pi, trans.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::ccalib::MultiCameraCalibration::opencv_from_extern(ret) }; + let ret = unsafe { crate::ccalib::MultiCameraCalibration_edge::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for MultiCameraCalibration { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MultiCameraCalibration") - .finish() - } - } - /// Constant methods for [crate::ccalib::MultiCameraCalibration_edge] pub trait MultiCameraCalibration_edgeTraitConst { fn as_raw_MultiCameraCalibration_edge(&self) -> *const c_void; @@ -1251,21 +1279,18 @@ pub mod ccalib { } - pub struct MultiCameraCalibration_edge { - ptr: *mut c_void, - } - - opencv_type_boxed! { MultiCameraCalibration_edge } - - impl Drop for MultiCameraCalibration_edge { + impl std::fmt::Debug for MultiCameraCalibration_edge { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_multicalib_MultiCameraCalibration_edge_delete(self.as_raw_mut_MultiCameraCalibration_edge()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MultiCameraCalibration_edge") + .field("camera_vertex", &crate::ccalib::MultiCameraCalibration_edgeTraitConst::camera_vertex(self)) + .field("photo_vertex", &crate::ccalib::MultiCameraCalibration_edgeTraitConst::photo_vertex(self)) + .field("photo_index", &crate::ccalib::MultiCameraCalibration_edgeTraitConst::photo_index(self)) + .field("transform", &crate::ccalib::MultiCameraCalibration_edgeTraitConst::transform(self)) + .finish() } } - unsafe impl Send for MultiCameraCalibration_edge {} - impl crate::ccalib::MultiCameraCalibration_edgeTraitConst for MultiCameraCalibration_edge { #[inline] fn as_raw_MultiCameraCalibration_edge(&self) -> *const c_void { self.as_raw() } } @@ -1276,29 +1301,42 @@ pub mod ccalib { boxed_ref! { MultiCameraCalibration_edge, crate::ccalib::MultiCameraCalibration_edgeTraitConst, as_raw_MultiCameraCalibration_edge, crate::ccalib::MultiCameraCalibration_edgeTrait, as_raw_mut_MultiCameraCalibration_edge } - impl MultiCameraCalibration_edge { + pub struct MultiCameraCalibration_vertex { + ptr: *mut c_void, + } + + opencv_type_boxed! { MultiCameraCalibration_vertex } + + impl Drop for MultiCameraCalibration_vertex { #[inline] - pub fn new(cv: i32, pv: i32, pi: i32, mut trans: impl core::MatTrait) -> Result { + fn drop(&mut self) { + unsafe { sys::cv_multicalib_MultiCameraCalibration_vertex_delete(self.as_raw_mut_MultiCameraCalibration_vertex()) }; + } + } + + unsafe impl Send for MultiCameraCalibration_vertex {} + + impl MultiCameraCalibration_vertex { + #[inline] + pub fn new(mut po: impl core::MatTrait, ts: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_multicalib_MultiCameraCalibration_edge_edge_int_int_int_Mat(cv, pv, pi, trans.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_multicalib_MultiCameraCalibration_vertex_vertex_Mat_int(po.as_raw_mut_Mat(), ts, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::ccalib::MultiCameraCalibration_edge::opencv_from_extern(ret) }; + let ret = unsafe { crate::ccalib::MultiCameraCalibration_vertex::opencv_from_extern(ret) }; Ok(ret) } - } - - impl std::fmt::Debug for MultiCameraCalibration_edge { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MultiCameraCalibration_edge") - .field("camera_vertex", &crate::ccalib::MultiCameraCalibration_edgeTraitConst::camera_vertex(self)) - .field("photo_vertex", &crate::ccalib::MultiCameraCalibration_edgeTraitConst::photo_vertex(self)) - .field("photo_index", &crate::ccalib::MultiCameraCalibration_edgeTraitConst::photo_index(self)) - .field("transform", &crate::ccalib::MultiCameraCalibration_edgeTraitConst::transform(self)) - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_multicalib_MultiCameraCalibration_vertex_vertex(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::ccalib::MultiCameraCalibration_vertex::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::ccalib::MultiCameraCalibration_vertex] @@ -1338,21 +1376,16 @@ pub mod ccalib { } - pub struct MultiCameraCalibration_vertex { - ptr: *mut c_void, - } - - opencv_type_boxed! { MultiCameraCalibration_vertex } - - impl Drop for MultiCameraCalibration_vertex { + impl std::fmt::Debug for MultiCameraCalibration_vertex { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_multicalib_MultiCameraCalibration_vertex_delete(self.as_raw_mut_MultiCameraCalibration_vertex()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MultiCameraCalibration_vertex") + .field("pose", &crate::ccalib::MultiCameraCalibration_vertexTraitConst::pose(self)) + .field("timestamp", &crate::ccalib::MultiCameraCalibration_vertexTraitConst::timestamp(self)) + .finish() } } - unsafe impl Send for MultiCameraCalibration_vertex {} - impl crate::ccalib::MultiCameraCalibration_vertexTraitConst for MultiCameraCalibration_vertex { #[inline] fn as_raw_MultiCameraCalibration_vertex(&self) -> *const c_void { self.as_raw() } } @@ -1363,39 +1396,70 @@ pub mod ccalib { boxed_ref! { MultiCameraCalibration_vertex, crate::ccalib::MultiCameraCalibration_vertexTraitConst, as_raw_MultiCameraCalibration_vertex, crate::ccalib::MultiCameraCalibration_vertexTrait, as_raw_mut_MultiCameraCalibration_vertex } - impl MultiCameraCalibration_vertex { + /// Class for finding features points and corresponding 3D in world coordinate of + /// a "random" pattern, which can be to be used in calibration. It is useful when pattern is + /// partly occluded or only a part of pattern can be observed in multiple cameras calibration. + /// The pattern can be generated by RandomPatternGenerator class described in this file. + /// + /// Please refer to paper + /// B. Li, L. Heng, K. Kevin and M. Pollefeys, "A Multiple-Camera System + /// Calibration Toolbox Using A Feature Descriptor-Based Calibration + /// Pattern", in IROS 2013. + pub struct RandomPatternCornerFinder { + ptr: *mut c_void, + } + + opencv_type_boxed! { RandomPatternCornerFinder } + + impl Drop for RandomPatternCornerFinder { #[inline] - pub fn new(mut po: impl core::MatTrait, ts: i32) -> Result { + fn drop(&mut self) { + unsafe { sys::cv_randpattern_RandomPatternCornerFinder_delete(self.as_raw_mut_RandomPatternCornerFinder()) }; + } + } + + unsafe impl Send for RandomPatternCornerFinder {} + + impl RandomPatternCornerFinder { + /// ## C++ default parameters + /// * nmini_match: 20 + /// * depth: CV_32F + /// * verbose: 0 + /// * show_extraction: 0 + /// * detector: AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0,3,0.005f) + /// * descriptor: AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0,3,0.005f) + /// * matcher: DescriptorMatcher::create("BruteForce-L1") + #[inline] + pub fn new(pattern_width: f32, pattern_height: f32, nmini_match: i32, depth: i32, verbose: i32, show_extraction: i32, mut detector: core::Ptr, mut descriptor: core::Ptr, mut matcher: core::Ptr) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_multicalib_MultiCameraCalibration_vertex_vertex_Mat_int(po.as_raw_mut_Mat(), ts, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_randpattern_RandomPatternCornerFinder_RandomPatternCornerFinder_float_float_int_int_int_int_PtrLFeature2DG_PtrLFeature2DG_PtrLDescriptorMatcherG(pattern_width, pattern_height, nmini_match, depth, verbose, show_extraction, detector.as_raw_mut_PtrOfFeature2D(), descriptor.as_raw_mut_PtrOfFeature2D(), matcher.as_raw_mut_PtrOfDescriptorMatcher(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::ccalib::MultiCameraCalibration_vertex::opencv_from_extern(ret) }; + let ret = unsafe { crate::ccalib::RandomPatternCornerFinder::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * nmini_match: 20 + /// * depth: CV_32F + /// * verbose: 0 + /// * show_extraction: 0 + /// * detector: AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0,3,0.005f) + /// * descriptor: AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0,3,0.005f) + /// * matcher: DescriptorMatcher::create("BruteForce-L1") #[inline] - pub fn default() -> Result { + pub fn new_def(pattern_width: f32, pattern_height: f32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_multicalib_MultiCameraCalibration_vertex_vertex(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_randpattern_RandomPatternCornerFinder_RandomPatternCornerFinder_float_float(pattern_width, pattern_height, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::ccalib::MultiCameraCalibration_vertex::opencv_from_extern(ret) }; + let ret = unsafe { crate::ccalib::RandomPatternCornerFinder::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for MultiCameraCalibration_vertex { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MultiCameraCalibration_vertex") - .field("pose", &crate::ccalib::MultiCameraCalibration_vertexTraitConst::pose(self)) - .field("timestamp", &crate::ccalib::MultiCameraCalibration_vertexTraitConst::timestamp(self)) - .finish() - } - } - /// Constant methods for [crate::ccalib::RandomPatternCornerFinder] pub trait RandomPatternCornerFinderTraitConst { fn as_raw_RandomPatternCornerFinder(&self) -> *const c_void; @@ -1465,30 +1529,14 @@ pub mod ccalib { } - /// Class for finding features points and corresponding 3D in world coordinate of - /// a "random" pattern, which can be to be used in calibration. It is useful when pattern is - /// partly occluded or only a part of pattern can be observed in multiple cameras calibration. - /// The pattern can be generated by RandomPatternGenerator class described in this file. - /// - /// Please refer to paper - /// B. Li, L. Heng, K. Kevin and M. Pollefeys, "A Multiple-Camera System - /// Calibration Toolbox Using A Feature Descriptor-Based Calibration - /// Pattern", in IROS 2013. - pub struct RandomPatternCornerFinder { - ptr: *mut c_void, - } - - opencv_type_boxed! { RandomPatternCornerFinder } - - impl Drop for RandomPatternCornerFinder { + impl std::fmt::Debug for RandomPatternCornerFinder { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_randpattern_RandomPatternCornerFinder_delete(self.as_raw_mut_RandomPatternCornerFinder()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RandomPatternCornerFinder") + .finish() } } - unsafe impl Send for RandomPatternCornerFinder {} - impl crate::ccalib::RandomPatternCornerFinderTraitConst for RandomPatternCornerFinder { #[inline] fn as_raw_RandomPatternCornerFinder(&self) -> *const c_void { self.as_raw() } } @@ -1499,54 +1547,34 @@ pub mod ccalib { boxed_ref! { RandomPatternCornerFinder, crate::ccalib::RandomPatternCornerFinderTraitConst, as_raw_RandomPatternCornerFinder, crate::ccalib::RandomPatternCornerFinderTrait, as_raw_mut_RandomPatternCornerFinder } - impl RandomPatternCornerFinder { - /// ## C++ default parameters - /// * nmini_match: 20 - /// * depth: CV_32F - /// * verbose: 0 - /// * show_extraction: 0 - /// * detector: AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0,3,0.005f) - /// * descriptor: AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0,3,0.005f) - /// * matcher: DescriptorMatcher::create("BruteForce-L1") + pub struct RandomPatternGenerator { + ptr: *mut c_void, + } + + opencv_type_boxed! { RandomPatternGenerator } + + impl Drop for RandomPatternGenerator { #[inline] - pub fn new(pattern_width: f32, pattern_height: f32, nmini_match: i32, depth: i32, verbose: i32, show_extraction: i32, mut detector: core::Ptr, mut descriptor: core::Ptr, mut matcher: core::Ptr) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_randpattern_RandomPatternCornerFinder_RandomPatternCornerFinder_float_float_int_int_int_int_PtrLFeature2DG_PtrLFeature2DG_PtrLDescriptorMatcherG(pattern_width, pattern_height, nmini_match, depth, verbose, show_extraction, detector.as_raw_mut_PtrOfFeature2D(), descriptor.as_raw_mut_PtrOfFeature2D(), matcher.as_raw_mut_PtrOfDescriptorMatcher(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::ccalib::RandomPatternCornerFinder::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_randpattern_RandomPatternGenerator_delete(self.as_raw_mut_RandomPatternGenerator()) }; } + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * nmini_match: 20 - /// * depth: CV_32F - /// * verbose: 0 - /// * show_extraction: 0 - /// * detector: AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0,3,0.005f) - /// * descriptor: AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0,3,0.005f) - /// * matcher: DescriptorMatcher::create("BruteForce-L1") + unsafe impl Send for RandomPatternGenerator {} + + impl RandomPatternGenerator { #[inline] - pub fn new_def(pattern_width: f32, pattern_height: f32) -> Result { + pub fn new(image_width: i32, image_height: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_randpattern_RandomPatternCornerFinder_RandomPatternCornerFinder_float_float(pattern_width, pattern_height, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_randpattern_RandomPatternGenerator_RandomPatternGenerator_int_int(image_width, image_height, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::ccalib::RandomPatternCornerFinder::opencv_from_extern(ret) }; + let ret = unsafe { crate::ccalib::RandomPatternGenerator::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for RandomPatternCornerFinder { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RandomPatternCornerFinder") - .finish() - } - } - /// Constant methods for [crate::ccalib::RandomPatternGenerator] pub trait RandomPatternGeneratorTraitConst { fn as_raw_RandomPatternGenerator(&self) -> *const c_void; @@ -1578,21 +1606,14 @@ pub mod ccalib { } - pub struct RandomPatternGenerator { - ptr: *mut c_void, - } - - opencv_type_boxed! { RandomPatternGenerator } - - impl Drop for RandomPatternGenerator { + impl std::fmt::Debug for RandomPatternGenerator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_randpattern_RandomPatternGenerator_delete(self.as_raw_mut_RandomPatternGenerator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RandomPatternGenerator") + .finish() } } - unsafe impl Send for RandomPatternGenerator {} - impl crate::ccalib::RandomPatternGeneratorTraitConst for RandomPatternGenerator { #[inline] fn as_raw_RandomPatternGenerator(&self) -> *const c_void { self.as_raw() } } @@ -1603,24 +1624,4 @@ pub mod ccalib { boxed_ref! { RandomPatternGenerator, crate::ccalib::RandomPatternGeneratorTraitConst, as_raw_RandomPatternGenerator, crate::ccalib::RandomPatternGeneratorTrait, as_raw_mut_RandomPatternGenerator } - impl RandomPatternGenerator { - #[inline] - pub fn new(image_width: i32, image_height: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_randpattern_RandomPatternGenerator_RandomPatternGenerator_int_int(image_width, image_height, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::ccalib::RandomPatternGenerator::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for RandomPatternGenerator { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RandomPatternGenerator") - .finish() - } - } } diff --git a/docs/core.rs b/docs/core.rs index 6ba87540e..43ae485b1 100644 --- a/docs/core.rs +++ b/docs/core.rs @@ -12456,6 +12456,44 @@ pub mod core { Ok(ret) } + /// This is a base class for all more or less complex algorithms in OpenCV + /// + /// especially for classes of algorithms, for which there can be multiple implementations. The examples + /// are stereo correspondence (for which there are algorithms like block matching, semi-global block + /// matching, graph-cut etc.), background subtraction (which can be done using mixture-of-gaussians + /// models, codebook-based algorithm etc.), optical flow (block matching, Lucas-Kanade, Horn-Schunck + /// etc.). + /// + /// Here is example of SimpleBlobDetector use in your application via Algorithm interface: + /// [Algorithm](https://github.com/opencv/opencv/blob/4.11.0/samples/cpp/tutorial_code/snippets/core_various.cpp#L1) + pub struct Algorithm { + ptr: *mut c_void, + } + + opencv_type_boxed! { Algorithm } + + impl Drop for Algorithm { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_Algorithm_delete(self.as_raw_mut_Algorithm()) }; + } + } + + unsafe impl Send for Algorithm {} + + impl Algorithm { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_Algorithm_Algorithm(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Algorithm::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [core::Algorithm] pub trait AlgorithmTraitConst { fn as_raw_Algorithm(&self) -> *const c_void; @@ -12573,30 +12611,19 @@ pub mod core { } - /// This is a base class for all more or less complex algorithms in OpenCV - /// - /// especially for classes of algorithms, for which there can be multiple implementations. The examples - /// are stereo correspondence (for which there are algorithms like block matching, semi-global block - /// matching, graph-cut etc.), background subtraction (which can be done using mixture-of-gaussians - /// models, codebook-based algorithm etc.), optical flow (block matching, Lucas-Kanade, Horn-Schunck - /// etc.). - /// - /// Here is example of SimpleBlobDetector use in your application via Algorithm interface: - /// [Algorithm](https://github.com/opencv/opencv/blob/4.11.0/samples/cpp/tutorial_code/snippets/core_various.cpp#L1) - pub struct Algorithm { - ptr: *mut c_void, - } - - opencv_type_boxed! { Algorithm } - - impl Drop for Algorithm { + impl std::fmt::Debug for Algorithm { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_Algorithm_delete(self.as_raw_mut_Algorithm()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Algorithm") + .finish() } } - unsafe impl Send for Algorithm {} + boxed_cast_descendant! { Algorithm, core::ConjGradSolver, cv_Algorithm_to_ConjGradSolver } + + boxed_cast_descendant! { Algorithm, core::DownhillSolver, cv_Algorithm_to_DownhillSolver } + + boxed_cast_descendant! { Algorithm, core::MinProblemSolver, cv_Algorithm_to_MinProblemSolver } impl core::AlgorithmTraitConst for Algorithm { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -12608,31 +12635,52 @@ pub mod core { boxed_ref! { Algorithm, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - impl Algorithm { + /// Returns result of asynchronous operations + /// + /// Object has attached asynchronous state. + /// Assignment operator doesn't clone asynchronous state (it is shared between all instances). + /// + /// Result can be fetched via get() method only once. + pub struct AsyncArray { + ptr: *mut c_void, + } + + opencv_type_boxed! { AsyncArray } + + impl Drop for AsyncArray { #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_Algorithm_Algorithm(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Algorithm::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_AsyncArray_delete(self.as_raw_mut_AsyncArray()) }; } - } - boxed_cast_descendant! { Algorithm, core::ConjGradSolver, cv_Algorithm_to_ConjGradSolver } + unsafe impl Send for AsyncArray {} - boxed_cast_descendant! { Algorithm, core::DownhillSolver, cv_Algorithm_to_DownhillSolver } + impl AsyncArray { + #[inline] + pub fn default() -> core::AsyncArray { + let ret = unsafe { sys::cv_AsyncArray_AsyncArray() }; + let ret = unsafe { core::AsyncArray::opencv_from_extern(ret) }; + ret + } - boxed_cast_descendant! { Algorithm, core::MinProblemSolver, cv_Algorithm_to_MinProblemSolver } + #[inline] + pub fn copy(o: &impl core::AsyncArrayTraitConst) -> core::AsyncArray { + let ret = unsafe { sys::cv_AsyncArray_AsyncArray_const_AsyncArrayR(o.as_raw_AsyncArray()) }; + let ret = unsafe { core::AsyncArray::opencv_from_extern(ret) }; + ret + } - impl std::fmt::Debug for Algorithm { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Algorithm") - .finish() + pub fn copy_mut(mut o: core::AsyncArray) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_AsyncArray_AsyncArray_AsyncArrayRR(o.as_raw_mut_AsyncArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::AsyncArray::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [core::AsyncArray] @@ -12740,27 +12788,22 @@ pub mod core { } - /// Returns result of asynchronous operations - /// - /// Object has attached asynchronous state. - /// Assignment operator doesn't clone asynchronous state (it is shared between all instances). - /// - /// Result can be fetched via get() method only once. - pub struct AsyncArray { - ptr: *mut c_void, + impl Default for AsyncArray { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { AsyncArray } - - impl Drop for AsyncArray { + impl std::fmt::Debug for AsyncArray { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_AsyncArray_delete(self.as_raw_mut_AsyncArray()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AsyncArray") + .finish() } } - unsafe impl Send for AsyncArray {} - impl core::AsyncArrayTraitConst for AsyncArray { #[inline] fn as_raw_AsyncArray(&self) -> *const c_void { self.as_raw() } } @@ -12771,49 +12814,49 @@ pub mod core { boxed_ref! { AsyncArray, core::AsyncArrayTraitConst, as_raw_AsyncArray, core::AsyncArrayTrait, as_raw_mut_AsyncArray } - impl AsyncArray { + /// Provides result of asynchronous operations + pub struct AsyncPromise { + ptr: *mut c_void, + } + + opencv_type_boxed! { AsyncPromise } + + impl Drop for AsyncPromise { #[inline] - pub fn default() -> core::AsyncArray { - let ret = unsafe { sys::cv_AsyncArray_AsyncArray() }; - let ret = unsafe { core::AsyncArray::opencv_from_extern(ret) }; + fn drop(&mut self) { + unsafe { sys::cv_AsyncPromise_delete(self.as_raw_mut_AsyncPromise()) }; + } + } + + unsafe impl Send for AsyncPromise {} + + impl AsyncPromise { + #[inline] + pub fn default() -> core::AsyncPromise { + let ret = unsafe { sys::cv_AsyncPromise_AsyncPromise() }; + let ret = unsafe { core::AsyncPromise::opencv_from_extern(ret) }; ret } #[inline] - pub fn copy(o: &impl core::AsyncArrayTraitConst) -> core::AsyncArray { - let ret = unsafe { sys::cv_AsyncArray_AsyncArray_const_AsyncArrayR(o.as_raw_AsyncArray()) }; - let ret = unsafe { core::AsyncArray::opencv_from_extern(ret) }; + pub fn copy(o: &impl core::AsyncPromiseTraitConst) -> core::AsyncPromise { + let ret = unsafe { sys::cv_AsyncPromise_AsyncPromise_const_AsyncPromiseR(o.as_raw_AsyncPromise()) }; + let ret = unsafe { core::AsyncPromise::opencv_from_extern(ret) }; ret } #[inline] - pub fn copy_mut(mut o: core::AsyncArray) -> Result { + pub fn copy_mut(mut o: core::AsyncPromise) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_AsyncArray_AsyncArray_AsyncArrayRR(o.as_raw_mut_AsyncArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_AsyncPromise_AsyncPromise_AsyncPromiseRR(o.as_raw_mut_AsyncPromise(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::AsyncArray::opencv_from_extern(ret) }; + let ret = unsafe { core::AsyncPromise::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for AsyncArray { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AsyncArray") - .finish() - } - } - - impl Default for AsyncArray { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - /// Constant methods for [core::AsyncPromise] pub trait AsyncPromiseTraitConst { fn as_raw_AsyncPromise(&self) -> *const c_void; @@ -12888,22 +12931,22 @@ pub mod core { } - /// Provides result of asynchronous operations - pub struct AsyncPromise { - ptr: *mut c_void, + impl Default for AsyncPromise { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { AsyncPromise } - - impl Drop for AsyncPromise { + impl std::fmt::Debug for AsyncPromise { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_AsyncPromise_delete(self.as_raw_mut_AsyncPromise()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AsyncPromise") + .finish() } } - unsafe impl Send for AsyncPromise {} - impl core::AsyncPromiseTraitConst for AsyncPromise { #[inline] fn as_raw_AsyncPromise(&self) -> *const c_void { self.as_raw() } } @@ -12914,47 +12957,134 @@ pub mod core { boxed_ref! { AsyncPromise, core::AsyncPromiseTraitConst, as_raw_AsyncPromise, core::AsyncPromiseTrait, as_raw_mut_AsyncPromise } - impl AsyncPromise { - #[inline] - pub fn default() -> core::AsyncPromise { - let ret = unsafe { sys::cv_AsyncPromise_AsyncPromise() }; - let ret = unsafe { core::AsyncPromise::opencv_from_extern(ret) }; - ret - } - - #[inline] - pub fn copy(o: &impl core::AsyncPromiseTraitConst) -> core::AsyncPromise { - let ret = unsafe { sys::cv_AsyncPromise_AsyncPromise_const_AsyncPromiseR(o.as_raw_AsyncPromise()) }; - let ret = unsafe { core::AsyncPromise::opencv_from_extern(ret) }; - ret - } - - #[inline] - pub fn copy_mut(mut o: core::AsyncPromise) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_AsyncPromise_AsyncPromise_AsyncPromiseRR(o.as_raw_mut_AsyncPromise(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::AsyncPromise::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for AsyncPromise { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AsyncPromise") - .finish() - } - } - - impl Default for AsyncPromise { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + /// Designed for command line parsing + /// + /// The sample below demonstrates how to use CommandLineParser: + /// ```C++ + /// CommandLineParser parser(argc, argv, keys); + /// parser.about("Application name v1.0.0"); + /// + /// if (parser.has("help")) + /// { + /// parser.printMessage(); + /// return 0; + /// } + /// + /// int N = parser.get("N"); + /// double fps = parser.get("fps"); + /// String path = parser.get("path"); + /// + /// use_time_stamp = parser.has("timestamp"); + /// + /// String img1 = parser.get(0); + /// String img2 = parser.get(1); + /// + /// int repeat = parser.get(2); + /// + /// if (!parser.check()) + /// { + /// parser.printErrors(); + /// return 0; + /// } + /// ``` + /// + /// + /// ### Keys syntax + /// + /// The keys parameter is a string containing several blocks, each one is enclosed in curly braces and + /// describes one argument. Each argument contains three parts separated by the `|` symbol: + /// + /// -# argument names is a list of option synonyms separated by standard space characters ' ' (to mark argument as positional, prefix it with the `@` symbol) + /// -# default value will be used if the argument was not provided (can be empty) + /// -# help message (can be empty) + /// + /// For example: + /// + /// ```C++ + /// const String keys = + /// "{help h usage ? | | print this message }" + /// "{@image1 | | image1 for compare }" + /// "{@image2 || image2 for compare }" + /// "{@repeat |1 | number }" + /// "{path |. | path to file }" + /// "{fps | -1.0 | fps for output video }" + /// "{N count |100 | count of objects }" + /// "{ts timestamp | | use time stamp }" + /// ; + /// } + /// ``` + /// + /// + /// Note that there are no default values for `help` and `timestamp` so we can check their presence using the `has()` method. + /// Arguments with default values are considered to be always present. Use the `get()` method in these cases to check their + /// actual value instead. + /// Note that whitespace characters other than standard spaces are considered part of the string. + /// Additionally, leading and trailing standard spaces around the help messages are ignored. + /// + /// String keys like `get("@image1")` return the empty string `""` by default - even with an empty default value. + /// Use the special `` default value to enforce that the returned string must not be empty. (like in `get("@image2")`) + /// + /// ### Usage + /// + /// For the described keys: + /// + /// ```C++ + /// # Good call (3 positional parameters: image1, image2 and repeat; N is 200, ts is true) + /// $ ./app -N=200 1.png 2.jpg 19 -ts + /// + /// # Bad call + /// $ ./app -fps=aaa + /// ERRORS: + /// Parameter "fps": can not convert: [aaa] to [double] + /// ``` + /// + pub struct CommandLineParser { + ptr: *mut c_void, + } + + opencv_type_boxed! { CommandLineParser } + + impl Drop for CommandLineParser { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_CommandLineParser_delete(self.as_raw_mut_CommandLineParser()) }; + } + } + + unsafe impl Send for CommandLineParser {} + + impl CommandLineParser { + /// Constructor + /// + /// Initializes command line parser object + /// + /// ## Parameters + /// * argc: number of command line arguments (from main()) + /// * argv: array of command line arguments (from main()) + /// * keys: string describing acceptable command line parameters (see class description for syntax) + #[inline] + pub fn new(argv: &[&str], keys: &str) -> Result { + string_array_arg!(argv); + extern_container_arg!(keys); + return_send!(via ocvrs_return); + unsafe { sys::cv_CommandLineParser_CommandLineParser_int_const_charXX_const_StringR(argv.len().try_into()?, argv.as_ptr(), keys.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::CommandLineParser::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Copy constructor + #[inline] + pub fn copy(parser: &impl core::CommandLineParserTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_CommandLineParser_CommandLineParser_const_CommandLineParserR(parser.as_raw_CommandLineParser(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::CommandLineParser::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [core::CommandLineParser] @@ -13959,245 +14089,73 @@ pub mod core { } - /// Designed for command line parsing - /// - /// The sample below demonstrates how to use CommandLineParser: - /// ```C++ - /// CommandLineParser parser(argc, argv, keys); - /// parser.about("Application name v1.0.0"); - /// - /// if (parser.has("help")) - /// { - /// parser.printMessage(); - /// return 0; - /// } - /// - /// int N = parser.get("N"); - /// double fps = parser.get("fps"); - /// String path = parser.get("path"); - /// - /// use_time_stamp = parser.has("timestamp"); - /// - /// String img1 = parser.get(0); - /// String img2 = parser.get(1); - /// - /// int repeat = parser.get(2); - /// - /// if (!parser.check()) - /// { - /// parser.printErrors(); - /// return 0; - /// } - /// ``` - /// - /// - /// ### Keys syntax - /// - /// The keys parameter is a string containing several blocks, each one is enclosed in curly braces and - /// describes one argument. Each argument contains three parts separated by the `|` symbol: - /// - /// -# argument names is a list of option synonyms separated by standard space characters ' ' (to mark argument as positional, prefix it with the `@` symbol) - /// -# default value will be used if the argument was not provided (can be empty) - /// -# help message (can be empty) - /// - /// For example: + impl std::fmt::Debug for CommandLineParser { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CommandLineParser") + .finish() + } + } + + impl core::CommandLineParserTraitConst for CommandLineParser { + #[inline] fn as_raw_CommandLineParser(&self) -> *const c_void { self.as_raw() } + } + + impl core::CommandLineParserTrait for CommandLineParser { + #[inline] fn as_raw_mut_CommandLineParser(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { CommandLineParser, core::CommandLineParserTraitConst, as_raw_CommandLineParser, core::CommandLineParserTrait, as_raw_mut_CommandLineParser } + + /// This class is used to perform the non-linear non-constrained minimization of a function + /// with known gradient, /// - /// ```C++ - /// const String keys = - /// "{help h usage ? | | print this message }" - /// "{@image1 | | image1 for compare }" - /// "{@image2 || image2 for compare }" - /// "{@repeat |1 | number }" - /// "{path |. | path to file }" - /// "{fps | -1.0 | fps for output video }" - /// "{N count |100 | count of objects }" - /// "{ts timestamp | | use time stamp }" - /// ; - /// } - /// ``` + /// defined on an *n*-dimensional Euclidean space, using the **Nonlinear Conjugate Gradient method**. + /// The implementation was done based on the beautifully clear explanatory article [An Introduction to + /// the Conjugate Gradient Method Without the Agonizing + /// Pain](http://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf) by Jonathan Richard + /// Shewchuk. The method can be seen as an adaptation of a standard Conjugate Gradient method (see, for + /// example ) for numerically solving the + /// systems of linear equations. /// + /// It should be noted, that this method, although deterministic, is rather a heuristic method and + /// therefore may converge to a local minima, not necessary a global one. What is even more disastrous, + /// most of its behaviour is ruled by gradient, therefore it essentially cannot distinguish between + /// local minima and maxima. Therefore, if it starts sufficiently near to the local maximum, it may + /// converge to it. Another obvious restriction is that it should be possible to compute the gradient of + /// a function at any point, thus it is preferable to have analytic expression for gradient and + /// computational burden should be born by the user. /// - /// Note that there are no default values for `help` and `timestamp` so we can check their presence using the `has()` method. - /// Arguments with default values are considered to be always present. Use the `get()` method in these cases to check their - /// actual value instead. - /// Note that whitespace characters other than standard spaces are considered part of the string. - /// Additionally, leading and trailing standard spaces around the help messages are ignored. + /// The latter responsibility is accomplished via the getGradient method of a + /// MinProblemSolver::Function interface (which represents function being optimized). This method takes + /// point a point in *n*-dimensional space (first argument represents the array of coordinates of that + /// point) and compute its gradient (it should be stored in the second argument as an array). /// - /// String keys like `get("@image1")` return the empty string `""` by default - even with an empty default value. - /// Use the special `` default value to enforce that the returned string must not be empty. (like in `get("@image2")`) /// - /// ### Usage + /// Note: class ConjGradSolver thus does not add any new methods to the basic MinProblemSolver interface. /// - /// For the described keys: /// + /// Note: term criteria should meet following condition: /// ```C++ - /// # Good call (3 positional parameters: image1, image2 and repeat; N is 200, ts is true) - /// $ ./app -N=200 1.png 2.jpg 19 -ts - /// - /// # Bad call - /// $ ./app -fps=aaa - /// ERRORS: - /// Parameter "fps": can not convert: [aaa] to [double] + /// termcrit.type == (TermCriteria::MAX_ITER + TermCriteria::EPS) && termcrit.epsilon > 0 && termcrit.maxCount > 0 + /// // or + /// termcrit.type == TermCriteria::MAX_ITER) && termcrit.maxCount > 0 /// ``` /// - pub struct CommandLineParser { + pub struct ConjGradSolver { ptr: *mut c_void, } - opencv_type_boxed! { CommandLineParser } + opencv_type_boxed! { ConjGradSolver } - impl Drop for CommandLineParser { + impl Drop for ConjGradSolver { #[inline] fn drop(&mut self) { - unsafe { sys::cv_CommandLineParser_delete(self.as_raw_mut_CommandLineParser()) }; + unsafe { sys::cv_ConjGradSolver_delete(self.as_raw_mut_ConjGradSolver()) }; } } - unsafe impl Send for CommandLineParser {} - - impl core::CommandLineParserTraitConst for CommandLineParser { - #[inline] fn as_raw_CommandLineParser(&self) -> *const c_void { self.as_raw() } - } - - impl core::CommandLineParserTrait for CommandLineParser { - #[inline] fn as_raw_mut_CommandLineParser(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { CommandLineParser, core::CommandLineParserTraitConst, as_raw_CommandLineParser, core::CommandLineParserTrait, as_raw_mut_CommandLineParser } - - impl CommandLineParser { - /// Constructor - /// - /// Initializes command line parser object - /// - /// ## Parameters - /// * argc: number of command line arguments (from main()) - /// * argv: array of command line arguments (from main()) - /// * keys: string describing acceptable command line parameters (see class description for syntax) - #[inline] - pub fn new(argv: &[&str], keys: &str) -> Result { - string_array_arg!(argv); - extern_container_arg!(keys); - return_send!(via ocvrs_return); - unsafe { sys::cv_CommandLineParser_CommandLineParser_int_const_charXX_const_StringR(argv.len().try_into()?, argv.as_ptr(), keys.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::CommandLineParser::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Copy constructor - #[inline] - pub fn copy(parser: &impl core::CommandLineParserTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_CommandLineParser_CommandLineParser_const_CommandLineParserR(parser.as_raw_CommandLineParser(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::CommandLineParser::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for CommandLineParser { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CommandLineParser") - .finish() - } - } - - /// Constant methods for [core::ConjGradSolver] - pub trait ConjGradSolverTraitConst: core::MinProblemSolverTraitConst { - fn as_raw_ConjGradSolver(&self) -> *const c_void; - - } - - /// Mutable methods for [core::ConjGradSolver] - pub trait ConjGradSolverTrait: core::ConjGradSolverTraitConst + core::MinProblemSolverTrait { - fn as_raw_mut_ConjGradSolver(&mut self) -> *mut c_void; - - } - - /// This class is used to perform the non-linear non-constrained minimization of a function - /// with known gradient, - /// - /// defined on an *n*-dimensional Euclidean space, using the **Nonlinear Conjugate Gradient method**. - /// The implementation was done based on the beautifully clear explanatory article [An Introduction to - /// the Conjugate Gradient Method Without the Agonizing - /// Pain](http://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf) by Jonathan Richard - /// Shewchuk. The method can be seen as an adaptation of a standard Conjugate Gradient method (see, for - /// example ) for numerically solving the - /// systems of linear equations. - /// - /// It should be noted, that this method, although deterministic, is rather a heuristic method and - /// therefore may converge to a local minima, not necessary a global one. What is even more disastrous, - /// most of its behaviour is ruled by gradient, therefore it essentially cannot distinguish between - /// local minima and maxima. Therefore, if it starts sufficiently near to the local maximum, it may - /// converge to it. Another obvious restriction is that it should be possible to compute the gradient of - /// a function at any point, thus it is preferable to have analytic expression for gradient and - /// computational burden should be born by the user. - /// - /// The latter responsibility is accomplished via the getGradient method of a - /// MinProblemSolver::Function interface (which represents function being optimized). This method takes - /// point a point in *n*-dimensional space (first argument represents the array of coordinates of that - /// point) and compute its gradient (it should be stored in the second argument as an array). - /// - /// - /// Note: class ConjGradSolver thus does not add any new methods to the basic MinProblemSolver interface. - /// - /// - /// Note: term criteria should meet following condition: - /// ```C++ - /// termcrit.type == (TermCriteria::MAX_ITER + TermCriteria::EPS) && termcrit.epsilon > 0 && termcrit.maxCount > 0 - /// // or - /// termcrit.type == TermCriteria::MAX_ITER) && termcrit.maxCount > 0 - /// ``` - /// - pub struct ConjGradSolver { - ptr: *mut c_void, - } - - opencv_type_boxed! { ConjGradSolver } - - impl Drop for ConjGradSolver { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ConjGradSolver_delete(self.as_raw_mut_ConjGradSolver()) }; - } - } - - unsafe impl Send for ConjGradSolver {} - - impl core::AlgorithmTraitConst for ConjGradSolver { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for ConjGradSolver { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { ConjGradSolver, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl core::MinProblemSolverTraitConst for ConjGradSolver { - #[inline] fn as_raw_MinProblemSolver(&self) -> *const c_void { self.as_raw() } - } - - impl core::MinProblemSolverTrait for ConjGradSolver { - #[inline] fn as_raw_mut_MinProblemSolver(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { ConjGradSolver, core::MinProblemSolverTraitConst, as_raw_MinProblemSolver, core::MinProblemSolverTrait, as_raw_mut_MinProblemSolver } - - impl core::ConjGradSolverTraitConst for ConjGradSolver { - #[inline] fn as_raw_ConjGradSolver(&self) -> *const c_void { self.as_raw() } - } - - impl core::ConjGradSolverTrait for ConjGradSolver { - #[inline] fn as_raw_mut_ConjGradSolver(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { ConjGradSolver, core::ConjGradSolverTraitConst, as_raw_ConjGradSolver, core::ConjGradSolverTrait, as_raw_mut_ConjGradSolver } + unsafe impl Send for ConjGradSolver {} impl ConjGradSolver { /// This function returns the reference to the ready-to-use ConjGradSolver object. @@ -14257,9 +14215,17 @@ pub mod core { } - boxed_cast_base! { ConjGradSolver, core::Algorithm, cv_ConjGradSolver_to_Algorithm } + /// Constant methods for [core::ConjGradSolver] + pub trait ConjGradSolverTraitConst: core::MinProblemSolverTraitConst { + fn as_raw_ConjGradSolver(&self) -> *const c_void; - boxed_cast_base! { ConjGradSolver, core::MinProblemSolver, cv_ConjGradSolver_to_MinProblemSolver } + } + + /// Mutable methods for [core::ConjGradSolver] + pub trait ConjGradSolverTrait: core::ConjGradSolverTraitConst + core::MinProblemSolverTrait { + fn as_raw_mut_ConjGradSolver(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for ConjGradSolver { #[inline] @@ -14269,6 +14235,40 @@ pub mod core { } } + boxed_cast_base! { ConjGradSolver, core::Algorithm, cv_ConjGradSolver_to_Algorithm } + + boxed_cast_base! { ConjGradSolver, core::MinProblemSolver, cv_ConjGradSolver_to_MinProblemSolver } + + impl core::AlgorithmTraitConst for ConjGradSolver { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } + } + + impl core::AlgorithmTrait for ConjGradSolver { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { ConjGradSolver, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + + impl core::MinProblemSolverTraitConst for ConjGradSolver { + #[inline] fn as_raw_MinProblemSolver(&self) -> *const c_void { self.as_raw() } + } + + impl core::MinProblemSolverTrait for ConjGradSolver { + #[inline] fn as_raw_mut_MinProblemSolver(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { ConjGradSolver, core::MinProblemSolverTraitConst, as_raw_MinProblemSolver, core::MinProblemSolverTrait, as_raw_mut_MinProblemSolver } + + impl core::ConjGradSolverTraitConst for ConjGradSolver { + #[inline] fn as_raw_ConjGradSolver(&self) -> *const c_void { self.as_raw() } + } + + impl core::ConjGradSolverTrait for ConjGradSolver { + #[inline] fn as_raw_mut_ConjGradSolver(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { ConjGradSolver, core::ConjGradSolverTraitConst, as_raw_ConjGradSolver, core::ConjGradSolverTrait, as_raw_mut_ConjGradSolver } + /// Class for matching keypoint descriptors /// /// query descriptor index, train descriptor index, train image index, and distance between @@ -14327,59 +14327,6 @@ pub mod core { } - /// Constant methods for [core::DownhillSolver] - pub trait DownhillSolverTraitConst: core::MinProblemSolverTraitConst { - fn as_raw_DownhillSolver(&self) -> *const c_void; - - /// Returns the initial step that will be used in downhill simplex algorithm. - /// - /// ## Parameters - /// * step: Initial step that will be used in algorithm. Note, that although corresponding setter - /// accepts column-vectors as well as row-vectors, this method will return a row-vector. - /// ## See also - /// DownhillSolver::setInitStep - #[inline] - fn get_init_step(&self, step: &mut impl ToOutputArray) -> Result<()> { - output_array_arg!(step); - return_send!(via ocvrs_return); - unsafe { sys::cv_DownhillSolver_getInitStep_const_const__OutputArrayR(self.as_raw_DownhillSolver(), step.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - /// Mutable methods for [core::DownhillSolver] - pub trait DownhillSolverTrait: core::DownhillSolverTraitConst + core::MinProblemSolverTrait { - fn as_raw_mut_DownhillSolver(&mut self) -> *mut c_void; - - /// Sets the initial step that will be used in downhill simplex algorithm. - /// - /// Step, together with initial point (given in DownhillSolver::minimize) are two `n`-dimensional - /// vectors that are used to determine the shape of initial simplex. Roughly said, initial point - /// determines the position of a simplex (it will become simplex's centroid), while step determines the - /// spread (size in each dimension) of a simplex. To be more precise, if ![inline formula](https://latex.codecogs.com/png.latex?s%2Cx%5F0%5Cin%5Cmathbb%7BR%7D%5En) are - /// the initial step and initial point respectively, the vertices of a simplex will be: - /// ![inline formula](https://latex.codecogs.com/png.latex?v%5F0%3A%3Dx%5F0%2D%5Cfrac%7B1%7D%7B2%7D%20s) and ![inline formula](https://latex.codecogs.com/png.latex?v%5Fi%3A%3Dx%5F0%2Bs%5Fi) for ![inline formula](https://latex.codecogs.com/png.latex?i%3D1%2C2%2C%5Cdots%2Cn) where ![inline formula](https://latex.codecogs.com/png.latex?s%5Fi) denotes - /// projections of the initial step of *n*-th coordinate (the result of projection is treated to be - /// vector given by ![inline formula](https://latex.codecogs.com/png.latex?s%5Fi%3A%3De%5Fi%5Ccdot%5Cleft%3Ce%5Fi%5Ccdot%20s%5Cright%3E), where ![inline formula](https://latex.codecogs.com/png.latex?e%5Fi) form canonical basis) - /// - /// ## Parameters - /// * step: Initial step that will be used in algorithm. Roughly said, it determines the spread - /// (size in each dimension) of an initial simplex. - #[inline] - fn set_init_step(&mut self, step: &impl ToInputArray) -> Result<()> { - input_array_arg!(step); - return_send!(via ocvrs_return); - unsafe { sys::cv_DownhillSolver_setInitStep_const__InputArrayR(self.as_raw_mut_DownhillSolver(), step.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - /// This class is used to perform the non-linear non-constrained minimization of a function, /// /// defined on an `n`-dimensional Euclidean space, using the **Nelder-Mead method**, also known as @@ -14427,36 +14374,6 @@ pub mod core { unsafe impl Send for DownhillSolver {} - impl core::AlgorithmTraitConst for DownhillSolver { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for DownhillSolver { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { DownhillSolver, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl core::MinProblemSolverTraitConst for DownhillSolver { - #[inline] fn as_raw_MinProblemSolver(&self) -> *const c_void { self.as_raw() } - } - - impl core::MinProblemSolverTrait for DownhillSolver { - #[inline] fn as_raw_mut_MinProblemSolver(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { DownhillSolver, core::MinProblemSolverTraitConst, as_raw_MinProblemSolver, core::MinProblemSolverTrait, as_raw_mut_MinProblemSolver } - - impl core::DownhillSolverTraitConst for DownhillSolver { - #[inline] fn as_raw_DownhillSolver(&self) -> *const c_void { self.as_raw() } - } - - impl core::DownhillSolverTrait for DownhillSolver { - #[inline] fn as_raw_mut_DownhillSolver(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { DownhillSolver, core::DownhillSolverTraitConst, as_raw_DownhillSolver, core::DownhillSolverTrait, as_raw_mut_DownhillSolver } - impl DownhillSolver { /// This function returns the reference to the ready-to-use DownhillSolver object. /// @@ -14524,9 +14441,58 @@ pub mod core { } - boxed_cast_base! { DownhillSolver, core::Algorithm, cv_DownhillSolver_to_Algorithm } + /// Constant methods for [core::DownhillSolver] + pub trait DownhillSolverTraitConst: core::MinProblemSolverTraitConst { + fn as_raw_DownhillSolver(&self) -> *const c_void; - boxed_cast_base! { DownhillSolver, core::MinProblemSolver, cv_DownhillSolver_to_MinProblemSolver } + /// Returns the initial step that will be used in downhill simplex algorithm. + /// + /// ## Parameters + /// * step: Initial step that will be used in algorithm. Note, that although corresponding setter + /// accepts column-vectors as well as row-vectors, this method will return a row-vector. + /// ## See also + /// DownhillSolver::setInitStep + #[inline] + fn get_init_step(&self, step: &mut impl ToOutputArray) -> Result<()> { + output_array_arg!(step); + return_send!(via ocvrs_return); + unsafe { sys::cv_DownhillSolver_getInitStep_const_const__OutputArrayR(self.as_raw_DownhillSolver(), step.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + /// Mutable methods for [core::DownhillSolver] + pub trait DownhillSolverTrait: core::DownhillSolverTraitConst + core::MinProblemSolverTrait { + fn as_raw_mut_DownhillSolver(&mut self) -> *mut c_void; + + /// Sets the initial step that will be used in downhill simplex algorithm. + /// + /// Step, together with initial point (given in DownhillSolver::minimize) are two `n`-dimensional + /// vectors that are used to determine the shape of initial simplex. Roughly said, initial point + /// determines the position of a simplex (it will become simplex's centroid), while step determines the + /// spread (size in each dimension) of a simplex. To be more precise, if ![inline formula](https://latex.codecogs.com/png.latex?s%2Cx%5F0%5Cin%5Cmathbb%7BR%7D%5En) are + /// the initial step and initial point respectively, the vertices of a simplex will be: + /// ![inline formula](https://latex.codecogs.com/png.latex?v%5F0%3A%3Dx%5F0%2D%5Cfrac%7B1%7D%7B2%7D%20s) and ![inline formula](https://latex.codecogs.com/png.latex?v%5Fi%3A%3Dx%5F0%2Bs%5Fi) for ![inline formula](https://latex.codecogs.com/png.latex?i%3D1%2C2%2C%5Cdots%2Cn) where ![inline formula](https://latex.codecogs.com/png.latex?s%5Fi) denotes + /// projections of the initial step of *n*-th coordinate (the result of projection is treated to be + /// vector given by ![inline formula](https://latex.codecogs.com/png.latex?s%5Fi%3A%3De%5Fi%5Ccdot%5Cleft%3Ce%5Fi%5Ccdot%20s%5Cright%3E), where ![inline formula](https://latex.codecogs.com/png.latex?e%5Fi) form canonical basis) + /// + /// ## Parameters + /// * step: Initial step that will be used in algorithm. Roughly said, it determines the spread + /// (size in each dimension) of an initial simplex. + #[inline] + fn set_init_step(&mut self, step: &impl ToInputArray) -> Result<()> { + input_array_arg!(step); + return_send!(via ocvrs_return); + unsafe { sys::cv_DownhillSolver_setInitStep_const__InputArrayR(self.as_raw_mut_DownhillSolver(), step.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } impl std::fmt::Debug for DownhillSolver { #[inline] @@ -14536,6 +14502,93 @@ pub mod core { } } + boxed_cast_base! { DownhillSolver, core::Algorithm, cv_DownhillSolver_to_Algorithm } + + boxed_cast_base! { DownhillSolver, core::MinProblemSolver, cv_DownhillSolver_to_MinProblemSolver } + + impl core::AlgorithmTraitConst for DownhillSolver { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } + } + + impl core::AlgorithmTrait for DownhillSolver { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { DownhillSolver, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + + impl core::MinProblemSolverTraitConst for DownhillSolver { + #[inline] fn as_raw_MinProblemSolver(&self) -> *const c_void { self.as_raw() } + } + + impl core::MinProblemSolverTrait for DownhillSolver { + #[inline] fn as_raw_mut_MinProblemSolver(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { DownhillSolver, core::MinProblemSolverTraitConst, as_raw_MinProblemSolver, core::MinProblemSolverTrait, as_raw_mut_MinProblemSolver } + + impl core::DownhillSolverTraitConst for DownhillSolver { + #[inline] fn as_raw_DownhillSolver(&self) -> *const c_void { self.as_raw() } + } + + impl core::DownhillSolverTrait for DownhillSolver { + #[inline] fn as_raw_mut_DownhillSolver(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { DownhillSolver, core::DownhillSolverTraitConst, as_raw_DownhillSolver, core::DownhillSolverTrait, as_raw_mut_DownhillSolver } + + /// ! Class passed to an error. + /// + /// This class encapsulates all or almost all necessary + /// information about the error happened in the program. The exception is + /// usually constructed and thrown implicitly via CV_Error and CV_Error_ macros. + /// ## See also + /// error + pub struct Exception { + ptr: *mut c_void, + } + + opencv_type_boxed! { Exception } + + impl Drop for Exception { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_Exception_delete(self.as_raw_mut_Exception()) }; + } + } + + unsafe impl Send for Exception {} + + impl Exception { + /// ! + /// Default constructor + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_Exception_Exception(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Exception::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ! + /// Full constructor. Normally the constructor is not called explicitly. + /// Instead, the macros CV_Error(), CV_Error_() and CV_Assert() are used. + #[inline] + pub fn new(_code: i32, _err: &str, _func: &str, _file: &str, _line: i32) -> Result { + extern_container_arg!(_err); + extern_container_arg!(_func); + extern_container_arg!(_file); + return_send!(via ocvrs_return); + unsafe { sys::cv_Exception_Exception_int_const_StringR_const_StringR_const_StringR_int(_code, _err.opencv_as_extern(), _func.opencv_as_extern(), _file.opencv_as_extern(), _line, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Exception::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [core::Exception] pub trait ExceptionTraitConst { fn as_raw_Exception(&self) -> *const c_void; @@ -14658,28 +14711,20 @@ pub mod core { } - /// ! Class passed to an error. - /// - /// This class encapsulates all or almost all necessary - /// information about the error happened in the program. The exception is - /// usually constructed and thrown implicitly via CV_Error and CV_Error_ macros. - /// ## See also - /// error - pub struct Exception { - ptr: *mut c_void, - } - - opencv_type_boxed! { Exception } - - impl Drop for Exception { + impl std::fmt::Debug for Exception { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_Exception_delete(self.as_raw_mut_Exception()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Exception") + .field("msg", &core::ExceptionTraitConst::msg(self)) + .field("code", &core::ExceptionTraitConst::code(self)) + .field("err", &core::ExceptionTraitConst::err(self)) + .field("func", &core::ExceptionTraitConst::func(self)) + .field("file", &core::ExceptionTraitConst::file(self)) + .field("line", &core::ExceptionTraitConst::line(self)) + .finish() } } - unsafe impl Send for Exception {} - impl core::ExceptionTraitConst for Exception { #[inline] fn as_raw_Exception(&self) -> *const c_void { self.as_raw() } } @@ -14690,49 +14735,134 @@ pub mod core { boxed_ref! { Exception, core::ExceptionTraitConst, as_raw_Exception, core::ExceptionTrait, as_raw_mut_Exception } - impl Exception { - /// ! - /// Default constructor + /// File Storage Node class. + /// + /// The node is used to store each and every element of the file storage opened for reading. When + /// XML/YAML file is read, it is first parsed and stored in the memory as a hierarchical collection of + /// nodes. Each node can be a "leaf" that is contain a single number or a string, or be a collection of + /// other nodes. There can be named collections (mappings) where each element has a name and it is + /// accessed by a name, and ordered collections (sequences) where elements do not have names but rather + /// accessed by index. Type of the file node can be determined using FileNode::type method. + /// + /// Note that file nodes are only used for navigating file storages opened for reading. When a file + /// storage is opened for writing, no data is stored in memory after it is written. + pub struct FileNode { + ptr: *mut c_void, + } + + opencv_type_boxed! { FileNode } + + impl Drop for FileNode { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_FileNode_delete(self.as_raw_mut_FileNode()) }; + } + } + + unsafe impl Send for FileNode {} + + impl FileNode { + /// The constructors. + /// + /// These constructors are used to create a default file node, construct it from obsolete structures or + /// from the another file node. + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Exception_Exception(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_FileNode_FileNode(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Exception::opencv_from_extern(ret) }; + let ret = unsafe { core::FileNode::opencv_from_extern(ret) }; Ok(ret) } - /// ! - /// Full constructor. Normally the constructor is not called explicitly. - /// Instead, the macros CV_Error(), CV_Error_() and CV_Assert() are used. + /// The constructors. + /// + /// These constructors are used to create a default file node, construct it from obsolete structures or + /// from the another file node. + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * fs: Pointer to the file storage structure. + /// * blockIdx: Index of the memory block where the file node is stored + /// * ofs: Offset in bytes from the beginning of the serialized storage + /// + /// @deprecated #[inline] - pub fn new(_code: i32, _err: &str, _func: &str, _file: &str, _line: i32) -> Result { - extern_container_arg!(_err); - extern_container_arg!(_func); - extern_container_arg!(_file); + pub fn new(fs: &impl core::FileStorageTraitConst, block_idx: size_t, ofs: size_t) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Exception_Exception_int_const_StringR_const_StringR_const_StringR_int(_code, _err.opencv_as_extern(), _func.opencv_as_extern(), _file.opencv_as_extern(), _line, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_FileNode_FileNode_const_FileStorageX_size_t_size_t(fs.as_raw_FileStorage(), block_idx, ofs, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Exception::opencv_from_extern(ret) }; + let ret = unsafe { core::FileNode::opencv_from_extern(ret) }; Ok(ret) } - } - - impl std::fmt::Debug for Exception { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Exception") - .field("msg", &core::ExceptionTraitConst::msg(self)) - .field("code", &core::ExceptionTraitConst::code(self)) - .field("err", &core::ExceptionTraitConst::err(self)) - .field("func", &core::ExceptionTraitConst::func(self)) - .field("file", &core::ExceptionTraitConst::file(self)) - .field("line", &core::ExceptionTraitConst::line(self)) - .finish() + /// The constructors. + /// + /// These constructors are used to create a default file node, construct it from obsolete structures or + /// from the another file node. + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * node: File node to be used as initialization for the created file node. + #[inline] + pub fn copy(node: &impl core::FileNodeTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_FileNode_FileNode_const_FileNodeR(node.as_raw_FileNode(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::FileNode::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn is_map(flags: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_FileNode_isMap_int(flags, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + pub fn is_seq(flags: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_FileNode_isSeq_int(flags, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + pub fn is_collection(flags: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_FileNode_isCollection_int(flags, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + pub fn is_empty_collection(flags: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_FileNode_isEmptyCollection_int(flags, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + pub fn is_flow(flags: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_FileNode_isFlow_int(flags, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } + } /// Constant methods for [core::FileNode] @@ -15123,32 +15253,23 @@ pub mod core { } - /// File Storage Node class. - /// - /// The node is used to store each and every element of the file storage opened for reading. When - /// XML/YAML file is read, it is first parsed and stored in the memory as a hierarchical collection of - /// nodes. Each node can be a "leaf" that is contain a single number or a string, or be a collection of - /// other nodes. There can be named collections (mappings) where each element has a name and it is - /// accessed by a name, and ordered collections (sequences) where elements do not have names but rather - /// accessed by index. Type of the file node can be determined using FileNode::type method. - /// - /// Note that file nodes are only used for navigating file storages opened for reading. When a file - /// storage is opened for writing, no data is stored in memory after it is written. - pub struct FileNode { - ptr: *mut c_void, + impl Clone for FileNode { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_FileNode_implicitClone_const(self.as_raw_FileNode())) } + } } - opencv_type_boxed! { FileNode } - - impl Drop for FileNode { + impl std::fmt::Debug for FileNode { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_FileNode_delete(self.as_raw_mut_FileNode()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FileNode") + .field("block_idx", &core::FileNodeTraitConst::block_idx(self)) + .field("ofs", &core::FileNodeTraitConst::ofs(self)) + .finish() } } - unsafe impl Send for FileNode {} - impl core::FileNodeTraitConst for FileNode { #[inline] fn as_raw_FileNode(&self) -> *const c_void { self.as_raw() } } @@ -15159,127 +15280,85 @@ pub mod core { boxed_ref! { FileNode, core::FileNodeTraitConst, as_raw_FileNode, core::FileNodeTrait, as_raw_mut_FileNode } - impl FileNode { + /// used to iterate through sequences and mappings. + /// + /// A standard STL notation, with node.begin(), node.end() denoting the beginning and the end of a + /// sequence, stored in node. See the data reading sample in the beginning of the section. + pub struct FileNodeIterator { + ptr: *mut c_void, + } + + opencv_type_boxed! { FileNodeIterator } + + impl Drop for FileNodeIterator { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_FileNodeIterator_delete(self.as_raw_mut_FileNodeIterator()) }; + } + } + + unsafe impl Send for FileNodeIterator {} + + impl FileNodeIterator { /// The constructors. /// - /// These constructors are used to create a default file node, construct it from obsolete structures or - /// from the another file node. + /// These constructors are used to create a default iterator, set it to specific element in a file node + /// or construct it from another iterator. #[inline] - pub fn default() -> Result { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_FileNode_FileNode(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_FileNodeIterator_FileNodeIterator(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::FileNode::opencv_from_extern(ret) }; + let ret = unsafe { core::FileNodeIterator::opencv_from_extern(ret) }; Ok(ret) } /// The constructors. /// - /// These constructors are used to create a default file node, construct it from obsolete structures or - /// from the another file node. + /// These constructors are used to create a default iterator, set it to specific element in a file node + /// or construct it from another iterator. /// /// ## Overloaded parameters /// /// ## Parameters - /// * fs: Pointer to the file storage structure. - /// * blockIdx: Index of the memory block where the file node is stored - /// * ofs: Offset in bytes from the beginning of the serialized storage - /// - /// @deprecated + /// * node: File node - the collection to iterate over; + /// it can be a scalar (equivalent to 1-element collection) or "none" (equivalent to empty collection). + /// * seekEnd: - true if iterator needs to be set after the last element of the node; + /// that is: + /// * node.begin() => FileNodeIterator(node, false) + /// * node.end() => FileNodeIterator(node, true) #[inline] - pub fn new(fs: &impl core::FileStorageTraitConst, block_idx: size_t, ofs: size_t) -> Result { + pub fn new(node: &impl core::FileNodeTraitConst, seek_end: bool) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_FileNode_FileNode_const_FileStorageX_size_t_size_t(fs.as_raw_FileStorage(), block_idx, ofs, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_FileNodeIterator_FileNodeIterator_const_FileNodeR_bool(node.as_raw_FileNode(), seek_end, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::FileNode::opencv_from_extern(ret) }; + let ret = unsafe { core::FileNodeIterator::opencv_from_extern(ret) }; Ok(ret) } /// The constructors. /// - /// These constructors are used to create a default file node, construct it from obsolete structures or - /// from the another file node. + /// These constructors are used to create a default iterator, set it to specific element in a file node + /// or construct it from another iterator. /// /// ## Overloaded parameters /// /// ## Parameters - /// * node: File node to be used as initialization for the created file node. - #[inline] - pub fn copy(node: &impl core::FileNodeTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_FileNode_FileNode_const_FileNodeR(node.as_raw_FileNode(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::FileNode::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn is_map(flags: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_FileNode_isMap_int(flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - pub fn is_seq(flags: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_FileNode_isSeq_int(flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - pub fn is_collection(flags: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_FileNode_isCollection_int(flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - pub fn is_empty_collection(flags: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_FileNode_isEmptyCollection_int(flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - + /// * it: Iterator to be used as initialization for the created iterator. #[inline] - pub fn is_flow(flags: i32) -> Result { + pub fn copy(it: &impl core::FileNodeIteratorTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_FileNode_isFlow_int(flags, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_FileNodeIterator_FileNodeIterator_const_FileNodeIteratorR(it.as_raw_FileNodeIterator(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::FileNodeIterator::opencv_from_extern(ret) }; Ok(ret) } } - impl Clone for FileNode { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_FileNode_implicitClone_const(self.as_raw_FileNode())) } - } - } - - impl std::fmt::Debug for FileNode { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FileNode") - .field("block_idx", &core::FileNodeTraitConst::block_idx(self)) - .field("ofs", &core::FileNodeTraitConst::ofs(self)) - .finish() - } - } - /// Constant methods for [core::FileNodeIterator] pub trait FileNodeIteratorTraitConst { fn as_raw_FileNodeIterator(&self) -> *const c_void; @@ -15361,25 +15440,14 @@ pub mod core { } - /// used to iterate through sequences and mappings. - /// - /// A standard STL notation, with node.begin(), node.end() denoting the beginning and the end of a - /// sequence, stored in node. See the data reading sample in the beginning of the section. - pub struct FileNodeIterator { - ptr: *mut c_void, - } - - opencv_type_boxed! { FileNodeIterator } - - impl Drop for FileNodeIterator { + impl std::fmt::Debug for FileNodeIterator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_FileNodeIterator_delete(self.as_raw_mut_FileNodeIterator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FileNodeIterator") + .finish() } } - unsafe impl Send for FileNodeIterator {} - impl core::FileNodeIteratorTraitConst for FileNodeIterator { #[inline] fn as_raw_FileNodeIterator(&self) -> *const c_void { self.as_raw() } } @@ -15390,72 +15458,94 @@ pub mod core { boxed_ref! { FileNodeIterator, core::FileNodeIteratorTraitConst, as_raw_FileNodeIterator, core::FileNodeIteratorTrait, as_raw_mut_FileNodeIterator } - impl FileNodeIterator { - /// The constructors. - /// - /// These constructors are used to create a default iterator, set it to specific element in a file node - /// or construct it from another iterator. + /// XML/YAML/JSON file storage class that encapsulates all the information necessary for writing or + /// reading data to/from a file. + pub struct FileStorage { + ptr: *mut c_void, + } + + opencv_type_boxed! { FileStorage } + + impl Drop for FileStorage { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_FileStorage_delete(self.as_raw_mut_FileStorage()) }; + } + } + + unsafe impl Send for FileStorage {} + + impl FileStorage { + /// The constructors. + /// + /// The full constructor opens the file. Alternatively you can use the default constructor and then + /// call FileStorage::open. + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_FileNodeIterator_FileNodeIterator(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_FileStorage_FileStorage(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::FileNodeIterator::opencv_from_extern(ret) }; + let ret = unsafe { core::FileStorage::opencv_from_extern(ret) }; Ok(ret) } /// The constructors. /// - /// These constructors are used to create a default iterator, set it to specific element in a file node - /// or construct it from another iterator. + /// The full constructor opens the file. Alternatively you can use the default constructor and then + /// call FileStorage::open. /// /// ## Overloaded parameters /// - /// ## Parameters - /// * node: File node - the collection to iterate over; - /// it can be a scalar (equivalent to 1-element collection) or "none" (equivalent to empty collection). - /// * seekEnd: - true if iterator needs to be set after the last element of the node; - /// that is: - /// * node.begin() => FileNodeIterator(node, false) - /// * node.end() => FileNodeIterator(node, true) + /// @copydoc open() + /// + /// ## C++ default parameters + /// * encoding: String() #[inline] - pub fn new(node: &impl core::FileNodeTraitConst, seek_end: bool) -> Result { + pub fn new(filename: &str, flags: i32, encoding: &str) -> Result { + extern_container_arg!(filename); + extern_container_arg!(encoding); return_send!(via ocvrs_return); - unsafe { sys::cv_FileNodeIterator_FileNodeIterator_const_FileNodeR_bool(node.as_raw_FileNode(), seek_end, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_FileStorage_FileStorage_const_StringR_int_const_StringR(filename.opencv_as_extern(), flags, encoding.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::FileNodeIterator::opencv_from_extern(ret) }; + let ret = unsafe { core::FileStorage::opencv_from_extern(ret) }; Ok(ret) } - /// The constructors. - /// - /// These constructors are used to create a default iterator, set it to specific element in a file node - /// or construct it from another iterator. - /// - /// ## Overloaded parameters + /// @overload + /// @copydoc open() /// - /// ## Parameters - /// * it: Iterator to be used as initialization for the created iterator. + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * encoding: String() #[inline] - pub fn copy(it: &impl core::FileNodeIteratorTraitConst) -> Result { + pub fn new_def(filename: &str, flags: i32) -> Result { + extern_container_arg!(filename); return_send!(via ocvrs_return); - unsafe { sys::cv_FileNodeIterator_FileNodeIterator_const_FileNodeIteratorR(it.as_raw_FileNodeIterator(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_FileStorage_FileStorage_const_StringR_int(filename.opencv_as_extern(), flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::FileNodeIterator::opencv_from_extern(ret) }; + let ret = unsafe { core::FileStorage::opencv_from_extern(ret) }; Ok(ret) } - } - - impl std::fmt::Debug for FileNodeIterator { + /// Returns the normalized object name for the specified name of a file. + /// ## Parameters + /// * filename: Name of a file + /// ## Returns + /// The normalized object name. #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FileNodeIterator") - .finish() + pub fn get_default_object_name(filename: &str) -> Result { + extern_container_arg!(filename); + return_send!(via ocvrs_return); + unsafe { sys::cv_FileStorage_getDefaultObjectName_const_StringR(filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { String::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [core::FileStorage] @@ -15898,23 +15988,16 @@ pub mod core { } - /// XML/YAML/JSON file storage class that encapsulates all the information necessary for writing or - /// reading data to/from a file. - pub struct FileStorage { - ptr: *mut c_void, - } - - opencv_type_boxed! { FileStorage } - - impl Drop for FileStorage { + impl std::fmt::Debug for FileStorage { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_FileStorage_delete(self.as_raw_mut_FileStorage()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FileStorage") + .field("state", &core::FileStorageTraitConst::state(self)) + .field("elname", &core::FileStorageTraitConst::elname(self)) + .finish() } } - unsafe impl Send for FileStorage {} - impl core::FileStorageTraitConst for FileStorage { #[inline] fn as_raw_FileStorage(&self) -> *const c_void { self.as_raw() } } @@ -15925,88 +16008,21 @@ pub mod core { boxed_ref! { FileStorage, core::FileStorageTraitConst, as_raw_FileStorage, core::FileStorageTrait, as_raw_mut_FileStorage } - impl FileStorage { - /// The constructors. - /// - /// The full constructor opens the file. Alternatively you can use the default constructor and then - /// call FileStorage::open. - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_FileStorage_FileStorage(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::FileStorage::opencv_from_extern(ret) }; - Ok(ret) - } - - /// The constructors. - /// - /// The full constructor opens the file. Alternatively you can use the default constructor and then - /// call FileStorage::open. - /// - /// ## Overloaded parameters - /// - /// @copydoc open() - /// - /// ## C++ default parameters - /// * encoding: String() - #[inline] - pub fn new(filename: &str, flags: i32, encoding: &str) -> Result { - extern_container_arg!(filename); - extern_container_arg!(encoding); - return_send!(via ocvrs_return); - unsafe { sys::cv_FileStorage_FileStorage_const_StringR_int_const_StringR(filename.opencv_as_extern(), flags, encoding.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::FileStorage::opencv_from_extern(ret) }; - Ok(ret) - } + /// @todo document + pub struct Formatted { + ptr: *mut c_void, + } - /// @overload - /// @copydoc open() - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * encoding: String() - #[inline] - pub fn new_def(filename: &str, flags: i32) -> Result { - extern_container_arg!(filename); - return_send!(via ocvrs_return); - unsafe { sys::cv_FileStorage_FileStorage_const_StringR_int(filename.opencv_as_extern(), flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::FileStorage::opencv_from_extern(ret) }; - Ok(ret) - } + opencv_type_boxed! { Formatted } - /// Returns the normalized object name for the specified name of a file. - /// ## Parameters - /// * filename: Name of a file - /// ## Returns - /// The normalized object name. + impl Drop for Formatted { #[inline] - pub fn get_default_object_name(filename: &str) -> Result { - extern_container_arg!(filename); - return_send!(via ocvrs_return); - unsafe { sys::cv_FileStorage_getDefaultObjectName_const_StringR(filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { String::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_Formatted_delete(self.as_raw_mut_Formatted()) }; } - } - impl std::fmt::Debug for FileStorage { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FileStorage") - .field("state", &core::FileStorageTraitConst::state(self)) - .field("elname", &core::FileStorageTraitConst::elname(self)) - .finish() - } - } + unsafe impl Send for Formatted {} /// Constant methods for [core::Formatted] pub trait FormattedTraitConst { @@ -16039,22 +16055,14 @@ pub mod core { } - /// @todo document - pub struct Formatted { - ptr: *mut c_void, - } - - opencv_type_boxed! { Formatted } - - impl Drop for Formatted { + impl std::fmt::Debug for Formatted { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_Formatted_delete(self.as_raw_mut_Formatted()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Formatted") + .finish() } } - unsafe impl Send for Formatted {} - impl core::FormattedTraitConst for Formatted { #[inline] fn as_raw_Formatted(&self) -> *const c_void { self.as_raw() } } @@ -16065,15 +16073,48 @@ pub mod core { boxed_ref! { Formatted, core::FormattedTraitConst, as_raw_Formatted, core::FormattedTrait, as_raw_mut_Formatted } - impl Formatted { + /// @todo document + pub struct Formatter { + ptr: *mut c_void, } - impl std::fmt::Debug for Formatted { + opencv_type_boxed! { Formatter } + + impl Drop for Formatter { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Formatted") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_Formatter_delete(self.as_raw_mut_Formatter()) }; + } + } + + unsafe impl Send for Formatter {} + + impl Formatter { + /// ## C++ default parameters + /// * fmt: FMT_DEFAULT + #[inline] + pub fn get(fmt: core::Formatter_FormatType) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Formatter_get_FormatType(fmt, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [Formatter::get] function uses the following default values for its arguments: + /// * fmt: FMT_DEFAULT + #[inline] + pub fn get_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Formatter_get(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [core::Formatter] @@ -16190,22 +16231,14 @@ pub mod core { } - /// @todo document - pub struct Formatter { - ptr: *mut c_void, + impl std::fmt::Debug for Formatter { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Formatter") + .finish() + } } - opencv_type_boxed! { Formatter } - - impl Drop for Formatter { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_Formatter_delete(self.as_raw_mut_Formatter()) }; - } - } - - unsafe impl Send for Formatter {} - impl core::FormatterTraitConst for Formatter { #[inline] fn as_raw_Formatter(&self) -> *const c_void { self.as_raw() } } @@ -16216,40 +16249,31 @@ pub mod core { boxed_ref! { Formatter, core::FormatterTraitConst, as_raw_Formatter, core::FormatterTrait, as_raw_mut_Formatter } - impl Formatter { - /// ## C++ default parameters - /// * fmt: FMT_DEFAULT - #[inline] - pub fn get(fmt: core::Formatter_FormatType) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Formatter_get_FormatType(fmt, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } + pub struct Hamming { + ptr: *mut c_void, + } - /// ## Note - /// This alternative version of [Formatter::get] function uses the following default values for its arguments: - /// * fmt: FMT_DEFAULT + opencv_type_boxed! { Hamming } + + impl Drop for Hamming { #[inline] - pub fn get_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Formatter_get(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_Hamming_delete(self.as_raw_mut_Hamming()) }; } - } - impl std::fmt::Debug for Formatter { + unsafe impl Send for Hamming {} + + impl Hamming { + pub const normType: u32 = 6; + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Formatter") - .finish() + pub fn default() -> core::Hamming { + let ret = unsafe { sys::cv_Hamming_defaultNew_const() }; + let ret = unsafe { core::Hamming::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [core::Hamming] @@ -16274,39 +16298,12 @@ pub mod core { } - pub struct Hamming { - ptr: *mut c_void, - } - - opencv_type_boxed! { Hamming } - - impl Drop for Hamming { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_Hamming_delete(self.as_raw_mut_Hamming()) }; - } - } - - unsafe impl Send for Hamming {} - - impl core::HammingTraitConst for Hamming { - #[inline] fn as_raw_Hamming(&self) -> *const c_void { self.as_raw() } - } - - impl core::HammingTrait for Hamming { - #[inline] fn as_raw_mut_Hamming(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Hamming, core::HammingTraitConst, as_raw_Hamming, core::HammingTrait, as_raw_mut_Hamming } - - impl Hamming { - pub const normType: u32 = 6; - /// Creates a default instance of the class by calling the default constructor + impl Default for Hamming { #[inline] + /// Forwards to infallible Self::default() fn default() -> Self { - unsafe { Self::from_raw(sys::cv_Hamming_defaultNew_const()) } + Self::default() } - } impl std::fmt::Debug for Hamming { @@ -16317,124 +16314,15 @@ pub mod core { } } - impl Default for Hamming { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } + impl core::HammingTraitConst for Hamming { + #[inline] fn as_raw_Hamming(&self) -> *const c_void { self.as_raw() } } - /// Constant methods for [core::KeyPoint] - pub trait KeyPointTraitConst { - fn as_raw_KeyPoint(&self) -> *const c_void; - - /// coordinates of the keypoints - #[inline] - fn pt(&self) -> core::Point2f { - return_send!(via ocvrs_return); - unsafe { sys::cv_KeyPoint_propPt_const(self.as_raw_KeyPoint(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - ret - } - - /// diameter of the meaningful keypoint neighborhood - #[inline] - fn size(&self) -> f32 { - let ret = unsafe { sys::cv_KeyPoint_propSize_const(self.as_raw_KeyPoint()) }; - ret - } - - /// computed orientation of the keypoint (-1 if not applicable); - /// it's in [0,360) degrees and measured relative to - /// image coordinate system, ie in clockwise. - #[inline] - fn angle(&self) -> f32 { - let ret = unsafe { sys::cv_KeyPoint_propAngle_const(self.as_raw_KeyPoint()) }; - ret - } - - /// the response by which the most strong keypoints have been selected. Can be used for the further sorting or subsampling - #[inline] - fn response(&self) -> f32 { - let ret = unsafe { sys::cv_KeyPoint_propResponse_const(self.as_raw_KeyPoint()) }; - ret - } - - /// octave (pyramid layer) from which the keypoint has been extracted - #[inline] - fn octave(&self) -> i32 { - let ret = unsafe { sys::cv_KeyPoint_propOctave_const(self.as_raw_KeyPoint()) }; - ret - } - - /// object class (if the keypoints need to be clustered by an object they belong to) - #[inline] - fn class_id(&self) -> i32 { - let ret = unsafe { sys::cv_KeyPoint_propClass_id_const(self.as_raw_KeyPoint()) }; - ret - } - - #[inline] - fn hash(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_KeyPoint_hash_const(self.as_raw_KeyPoint(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - + impl core::HammingTrait for Hamming { + #[inline] fn as_raw_mut_Hamming(&mut self) -> *mut c_void { self.as_raw_mut() } } - /// Mutable methods for [core::KeyPoint] - pub trait KeyPointTrait: core::KeyPointTraitConst { - fn as_raw_mut_KeyPoint(&mut self) -> *mut c_void; - - /// coordinates of the keypoints - #[inline] - fn set_pt(&mut self, val: core::Point2f) { - let ret = unsafe { sys::cv_KeyPoint_propPt_const_Point2f(self.as_raw_mut_KeyPoint(), &val) }; - ret - } - - /// diameter of the meaningful keypoint neighborhood - #[inline] - fn set_size(&mut self, val: f32) { - let ret = unsafe { sys::cv_KeyPoint_propSize_const_float(self.as_raw_mut_KeyPoint(), val) }; - ret - } - - /// computed orientation of the keypoint (-1 if not applicable); - /// it's in [0,360) degrees and measured relative to - /// image coordinate system, ie in clockwise. - #[inline] - fn set_angle(&mut self, val: f32) { - let ret = unsafe { sys::cv_KeyPoint_propAngle_const_float(self.as_raw_mut_KeyPoint(), val) }; - ret - } - - /// the response by which the most strong keypoints have been selected. Can be used for the further sorting or subsampling - #[inline] - fn set_response(&mut self, val: f32) { - let ret = unsafe { sys::cv_KeyPoint_propResponse_const_float(self.as_raw_mut_KeyPoint(), val) }; - ret - } - - /// octave (pyramid layer) from which the keypoint has been extracted - #[inline] - fn set_octave(&mut self, val: i32) { - let ret = unsafe { sys::cv_KeyPoint_propOctave_const_int(self.as_raw_mut_KeyPoint(), val) }; - ret - } - - /// object class (if the keypoints need to be clustered by an object they belong to) - #[inline] - fn set_class_id(&mut self, val: i32) { - let ret = unsafe { sys::cv_KeyPoint_propClass_id_const_int(self.as_raw_mut_KeyPoint(), val) }; - ret - } - - } + boxed_ref! { Hamming, core::HammingTraitConst, as_raw_Hamming, core::HammingTrait, as_raw_mut_Hamming } /// Data structure for salient point detectors. /// @@ -16461,16 +16349,6 @@ pub mod core { unsafe impl Send for KeyPoint {} - impl core::KeyPointTraitConst for KeyPoint { - #[inline] fn as_raw_KeyPoint(&self) -> *const c_void { self.as_raw() } - } - - impl core::KeyPointTrait for KeyPoint { - #[inline] fn as_raw_mut_KeyPoint(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { KeyPoint, core::KeyPointTraitConst, as_raw_KeyPoint, core::KeyPointTrait, as_raw_mut_KeyPoint } - impl KeyPoint { /// the default constructor #[inline] @@ -16693,141 +16571,148 @@ pub mod core { } - impl Clone for KeyPoint { + /// Constant methods for [core::KeyPoint] + pub trait KeyPointTraitConst { + fn as_raw_KeyPoint(&self) -> *const c_void; + + /// coordinates of the keypoints #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_KeyPoint_implicitClone_const(self.as_raw_KeyPoint())) } + fn pt(&self) -> core::Point2f { + return_send!(via ocvrs_return); + unsafe { sys::cv_KeyPoint_propPt_const(self.as_raw_KeyPoint(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + ret } - } - impl std::fmt::Debug for KeyPoint { + /// diameter of the meaningful keypoint neighborhood #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("KeyPoint") - .field("pt", &core::KeyPointTraitConst::pt(self)) - .field("size", &core::KeyPointTraitConst::size(self)) - .field("angle", &core::KeyPointTraitConst::angle(self)) - .field("response", &core::KeyPointTraitConst::response(self)) - .field("octave", &core::KeyPointTraitConst::octave(self)) - .field("class_id", &core::KeyPointTraitConst::class_id(self)) - .finish() + fn size(&self) -> f32 { + let ret = unsafe { sys::cv_KeyPoint_propSize_const(self.as_raw_KeyPoint()) }; + ret } - } - /// Constant methods for [core::LDA] - pub trait LDATraitConst { - fn as_raw_LDA(&self) -> *const c_void; + /// computed orientation of the keypoint (-1 if not applicable); + /// it's in [0,360) degrees and measured relative to + /// image coordinate system, ie in clockwise. + #[inline] + fn angle(&self) -> f32 { + let ret = unsafe { sys::cv_KeyPoint_propAngle_const(self.as_raw_KeyPoint()) }; + ret + } - /// Serializes this object to a given filename. + /// the response by which the most strong keypoints have been selected. Can be used for the further sorting or subsampling #[inline] - fn save(&self, filename: &str) -> Result<()> { - extern_container_arg!(filename); - return_send!(via ocvrs_return); - unsafe { sys::cv_LDA_save_const_const_StringR(self.as_raw_LDA(), filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn response(&self) -> f32 { + let ret = unsafe { sys::cv_KeyPoint_propResponse_const(self.as_raw_KeyPoint()) }; + ret } - /// Serializes this object to a given cv::FileStorage. + /// octave (pyramid layer) from which the keypoint has been extracted #[inline] - fn save_1(&self, fs: &mut impl core::FileStorageTrait) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_LDA_save_const_FileStorageR(self.as_raw_LDA(), fs.as_raw_mut_FileStorage(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn octave(&self) -> i32 { + let ret = unsafe { sys::cv_KeyPoint_propOctave_const(self.as_raw_KeyPoint()) }; + ret } - /// Returns the eigenvectors of this LDA. + /// object class (if the keypoints need to be clustered by an object they belong to) #[inline] - fn eigenvectors(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_LDA_eigenvectors_const(self.as_raw_LDA(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; - Ok(ret) + fn class_id(&self) -> i32 { + let ret = unsafe { sys::cv_KeyPoint_propClass_id_const(self.as_raw_KeyPoint()) }; + ret } - /// Returns the eigenvalues of this LDA. #[inline] - fn eigenvalues(&self) -> Result { + fn hash(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_LDA_eigenvalues_const(self.as_raw_LDA(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_KeyPoint_hash_const(self.as_raw_KeyPoint(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } } - /// Mutable methods for [core::LDA] - pub trait LDATrait: core::LDATraitConst { - fn as_raw_mut_LDA(&mut self) -> *mut c_void; + /// Mutable methods for [core::KeyPoint] + pub trait KeyPointTrait: core::KeyPointTraitConst { + fn as_raw_mut_KeyPoint(&mut self) -> *mut c_void; - /// Deserializes this object from a given filename. + /// coordinates of the keypoints #[inline] - fn load(&mut self, filename: &str) -> Result<()> { - extern_container_arg!(filename); - return_send!(via ocvrs_return); - unsafe { sys::cv_LDA_load_const_StringR(self.as_raw_mut_LDA(), filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn set_pt(&mut self, val: core::Point2f) { + let ret = unsafe { sys::cv_KeyPoint_propPt_const_Point2f(self.as_raw_mut_KeyPoint(), &val) }; + ret } - /// Deserializes this object from a given cv::FileStorage. + /// diameter of the meaningful keypoint neighborhood #[inline] - fn load_1(&mut self, node: &impl core::FileStorageTraitConst) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_LDA_load_const_FileStorageR(self.as_raw_mut_LDA(), node.as_raw_FileStorage(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn set_size(&mut self, val: f32) { + let ret = unsafe { sys::cv_KeyPoint_propSize_const_float(self.as_raw_mut_KeyPoint(), val) }; + ret } - /// Compute the discriminants for data in src (row aligned) and labels. + /// computed orientation of the keypoint (-1 if not applicable); + /// it's in [0,360) degrees and measured relative to + /// image coordinate system, ie in clockwise. #[inline] - fn compute(&mut self, src: &impl ToInputArray, labels: &impl ToInputArray) -> Result<()> { - input_array_arg!(src); - input_array_arg!(labels); - return_send!(via ocvrs_return); - unsafe { sys::cv_LDA_compute_const__InputArrayR_const__InputArrayR(self.as_raw_mut_LDA(), src.as_raw__InputArray(), labels.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn set_angle(&mut self, val: f32) { + let ret = unsafe { sys::cv_KeyPoint_propAngle_const_float(self.as_raw_mut_KeyPoint(), val) }; + ret } - /// Projects samples into the LDA subspace. - /// src may be one or more row aligned samples. + /// the response by which the most strong keypoints have been selected. Can be used for the further sorting or subsampling #[inline] - fn project(&mut self, src: &impl ToInputArray) -> Result { - input_array_arg!(src); - return_send!(via ocvrs_return); - unsafe { sys::cv_LDA_project_const__InputArrayR(self.as_raw_mut_LDA(), src.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; - Ok(ret) + fn set_response(&mut self, val: f32) { + let ret = unsafe { sys::cv_KeyPoint_propResponse_const_float(self.as_raw_mut_KeyPoint(), val) }; + ret } - /// Reconstructs projections from the LDA subspace. - /// src may be one or more row aligned projections. + /// octave (pyramid layer) from which the keypoint has been extracted #[inline] - fn reconstruct(&mut self, src: &impl ToInputArray) -> Result { - input_array_arg!(src); - return_send!(via ocvrs_return); - unsafe { sys::cv_LDA_reconstruct_const__InputArrayR(self.as_raw_mut_LDA(), src.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; - Ok(ret) + fn set_octave(&mut self, val: i32) { + let ret = unsafe { sys::cv_KeyPoint_propOctave_const_int(self.as_raw_mut_KeyPoint(), val) }; + ret + } + + /// object class (if the keypoints need to be clustered by an object they belong to) + #[inline] + fn set_class_id(&mut self, val: i32) { + let ret = unsafe { sys::cv_KeyPoint_propClass_id_const_int(self.as_raw_mut_KeyPoint(), val) }; + ret + } + + } + + impl Clone for KeyPoint { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_KeyPoint_implicitClone_const(self.as_raw_KeyPoint())) } + } + } + + impl std::fmt::Debug for KeyPoint { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("KeyPoint") + .field("pt", &core::KeyPointTraitConst::pt(self)) + .field("size", &core::KeyPointTraitConst::size(self)) + .field("angle", &core::KeyPointTraitConst::angle(self)) + .field("response", &core::KeyPointTraitConst::response(self)) + .field("octave", &core::KeyPointTraitConst::octave(self)) + .field("class_id", &core::KeyPointTraitConst::class_id(self)) + .finish() } + } + + impl core::KeyPointTraitConst for KeyPoint { + #[inline] fn as_raw_KeyPoint(&self) -> *const c_void { self.as_raw() } + } + impl core::KeyPointTrait for KeyPoint { + #[inline] fn as_raw_mut_KeyPoint(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { KeyPoint, core::KeyPointTraitConst, as_raw_KeyPoint, core::KeyPointTrait, as_raw_mut_KeyPoint } + /// Linear Discriminant Analysis /// @todo document this class pub struct LDA { @@ -16845,16 +16730,6 @@ pub mod core { unsafe impl Send for LDA {} - impl core::LDATraitConst for LDA { - #[inline] fn as_raw_LDA(&self) -> *const c_void { self.as_raw() } - } - - impl core::LDATrait for LDA { - #[inline] fn as_raw_mut_LDA(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { LDA, core::LDATraitConst, as_raw_LDA, core::LDATrait, as_raw_mut_LDA } - impl LDA { /// constructor /// Initializes a LDA with num_components (default 0). @@ -16954,2589 +16829,3094 @@ pub mod core { } - impl std::fmt::Debug for LDA { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LDA") - .finish() - } - } - - /// Constant methods for [core::Mat] - pub trait MatTraitConst { - fn as_raw_Mat(&self) -> *const c_void; + /// Constant methods for [core::LDA] + pub trait LDATraitConst { + fn as_raw_LDA(&self) -> *const c_void; - /// ! includes several bit-fields: - /// - the magic signature - /// - continuity flag - /// - depth - /// - number of channels + /// Serializes this object to a given filename. #[inline] - fn flags(&self) -> i32 { - let ret = unsafe { sys::cv_Mat_propFlags_const(self.as_raw_Mat()) }; - ret + fn save(&self, filename: &str) -> Result<()> { + extern_container_arg!(filename); + return_send!(via ocvrs_return); + unsafe { sys::cv_LDA_save_const_const_StringR(self.as_raw_LDA(), filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } - /// the matrix dimensionality, >= 2 + /// Serializes this object to a given cv::FileStorage. #[inline] - fn dims(&self) -> i32 { - let ret = unsafe { sys::cv_Mat_propDims_const(self.as_raw_Mat()) }; - ret + fn save_1(&self, fs: &mut impl core::FileStorageTrait) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_LDA_save_const_FileStorageR(self.as_raw_LDA(), fs.as_raw_mut_FileStorage(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } - /// the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions + /// Returns the eigenvectors of this LDA. #[inline] - fn rows(&self) -> i32 { - let ret = unsafe { sys::cv_Mat_propRows_const(self.as_raw_Mat()) }; - ret + fn eigenvectors(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_LDA_eigenvectors_const(self.as_raw_LDA(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + Ok(ret) } - /// the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions + /// Returns the eigenvalues of this LDA. #[inline] - fn cols(&self) -> i32 { - let ret = unsafe { sys::cv_Mat_propCols_const(self.as_raw_Mat()) }; - ret + fn eigenvalues(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_LDA_eigenvalues_const(self.as_raw_LDA(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + Ok(ret) } - /// pointer to the data - #[inline] - fn data(&self) -> *const u8 { - let ret = unsafe { sys::cv_Mat_propData_const(self.as_raw_Mat()) }; - ret - } + } - /// helper fields used in locateROI and adjustROI + /// Mutable methods for [core::LDA] + pub trait LDATrait: core::LDATraitConst { + fn as_raw_mut_LDA(&mut self) -> *mut c_void; + + /// Deserializes this object from a given filename. #[inline] - fn datastart(&self) -> *const u8 { - let ret = unsafe { sys::cv_Mat_propDatastart_const(self.as_raw_Mat()) }; - ret + fn load(&mut self, filename: &str) -> Result<()> { + extern_container_arg!(filename); + return_send!(via ocvrs_return); + unsafe { sys::cv_LDA_load_const_StringR(self.as_raw_mut_LDA(), filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } + /// Deserializes this object from a given cv::FileStorage. #[inline] - fn dataend(&self) -> *const u8 { - let ret = unsafe { sys::cv_Mat_propDataend_const(self.as_raw_Mat()) }; - ret + fn load_1(&mut self, node: &impl core::FileStorageTraitConst) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_LDA_load_const_FileStorageR(self.as_raw_mut_LDA(), node.as_raw_FileStorage(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } + /// Compute the discriminants for data in src (row aligned) and labels. #[inline] - fn datalimit(&self) -> *const u8 { - let ret = unsafe { sys::cv_Mat_propDatalimit_const(self.as_raw_Mat()) }; - ret - } - - #[inline] - fn mat_size(&self) -> core::MatSize { - let ret = unsafe { sys::cv_Mat_propSize_const(self.as_raw_Mat()) }; - let ret = unsafe { core::MatSize::opencv_from_extern(ret) }; - ret - } - - #[inline] - fn mat_step(&self) -> core::MatStep { - let ret = unsafe { sys::cv_Mat_propStep_const(self.as_raw_Mat()) }; - let ret = unsafe { core::MatStep::opencv_from_extern(ret) }; - ret - } - - /// retrieve UMat from Mat - /// - /// ## C++ default parameters - /// * usage_flags: USAGE_DEFAULT - #[inline] - fn get_umat(&self, access_flags: core::AccessFlag, usage_flags: core::UMatUsageFlags) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_getUMat_const_AccessFlag_UMatUsageFlags(self.as_raw_Mat(), access_flags, usage_flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; - Ok(ret) - } - - /// retrieve UMat from Mat - /// - /// ## Note - /// This alternative version of [MatTraitConst::get_umat] function uses the following default values for its arguments: - /// * usage_flags: USAGE_DEFAULT - #[inline] - fn get_umat_def(&self, access_flags: core::AccessFlag) -> Result { + fn compute(&mut self, src: &impl ToInputArray, labels: &impl ToInputArray) -> Result<()> { + input_array_arg!(src); + input_array_arg!(labels); return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_getUMat_const_AccessFlag(self.as_raw_Mat(), access_flags, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_LDA_compute_const__InputArrayR_const__InputArrayR(self.as_raw_mut_LDA(), src.as_raw__InputArray(), labels.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// Creates a matrix header for the specified matrix row. - /// - /// The method makes a new header for the specified matrix row and returns it. This is an O(1) - /// operation, regardless of the matrix size. The underlying data of the new matrix is shared with the - /// original matrix. Here is the example of one of the classical basic matrix processing operations, - /// axpy, used by LU and many other algorithms: - /// ```C++ - /// inline void matrix_axpy(Mat& A, int i, int j, double alpha) - /// { - /// A.row(i) += A.row(j)*alpha; - /// } - /// ``` - /// - /// - /// Note: In the current implementation, the following code does not work as expected: - /// ```C++ - /// Mat A; - /// ... - /// A.row(i) = A.row(j); // will not work - /// ``` - /// - /// This happens because A.row(i) forms a temporary header that is further assigned to another header. - /// Remember that each of these operations is O(1), that is, no data is copied. Thus, the above - /// assignment is not true if you may have expected the j-th row to be copied to the i-th row. To - /// achieve that, you should either turn this simple assignment into an expression or use the - /// Mat::copyTo method: - /// ```C++ - /// Mat A; - /// ... - /// // works, but looks a bit obscure. - /// A.row(i) = A.row(j) + 0; - /// // this is a bit longer, but the recommended method. - /// A.row(j).copyTo(A.row(i)); - /// ``` - /// - /// ## Parameters - /// * y: A 0-based row index. + /// Projects samples into the LDA subspace. + /// src may be one or more row aligned samples. #[inline] - fn row(&self, y: i32) -> Result> { + fn project(&mut self, src: &impl ToInputArray) -> Result { + input_array_arg!(src); return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_row_const_int(self.as_raw_Mat(), y, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_LDA_project_const__InputArrayR(self.as_raw_mut_LDA(), src.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// Creates a matrix header for the specified matrix column. - /// - /// The method makes a new header for the specified matrix column and returns it. This is an O(1) - /// operation, regardless of the matrix size. The underlying data of the new matrix is shared with the - /// original matrix. See also the Mat::row description. - /// ## Parameters - /// * x: A 0-based column index. + /// Reconstructs projections from the LDA subspace. + /// src may be one or more row aligned projections. #[inline] - fn col(&self, x: i32) -> Result> { + fn reconstruct(&mut self, src: &impl ToInputArray) -> Result { + input_array_arg!(src); return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_col_const_int(self.as_raw_Mat(), x, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_LDA_reconstruct_const__InputArrayR(self.as_raw_mut_LDA(), src.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// Creates a matrix header for the specified row span. - /// - /// The method makes a new header for the specified row span of the matrix. Similarly to Mat::row and - /// Mat::col , this is an O(1) operation. - /// ## Parameters - /// * startrow: An inclusive 0-based start index of the row span. - /// * endrow: An exclusive 0-based ending index of the row span. - #[inline] - fn row_bounds(&self, startrow: i32, endrow: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_rowRange_const_int_int(self.as_raw_Mat(), startrow, endrow, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; - Ok(ret) - } + } - /// Creates a matrix header for the specified row span. - /// - /// The method makes a new header for the specified row span of the matrix. Similarly to Mat::row and - /// Mat::col , this is an O(1) operation. - /// ## Parameters - /// * startrow: An inclusive 0-based start index of the row span. - /// * endrow: An exclusive 0-based ending index of the row span. - /// - /// ## Overloaded parameters - /// - /// * r: Range structure containing both the start and the end indices. + impl std::fmt::Debug for LDA { #[inline] - fn row_range(&self, r: &impl core::RangeTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_rowRange_const_const_RangeR(self.as_raw_Mat(), r.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; - Ok(ret) + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LDA") + .finish() } + } - /// Creates a matrix header for the specified column span. - /// - /// The method makes a new header for the specified column span of the matrix. Similarly to Mat::row and - /// Mat::col , this is an O(1) operation. - /// ## Parameters - /// * startcol: An inclusive 0-based start index of the column span. - /// * endcol: An exclusive 0-based ending index of the column span. - #[inline] - fn col_bounds(&self, startcol: i32, endcol: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_colRange_const_int_int(self.as_raw_Mat(), startcol, endcol, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; - Ok(ret) - } + impl core::LDATraitConst for LDA { + #[inline] fn as_raw_LDA(&self) -> *const c_void { self.as_raw() } + } - /// Creates a matrix header for the specified column span. - /// - /// The method makes a new header for the specified column span of the matrix. Similarly to Mat::row and - /// Mat::col , this is an O(1) operation. - /// ## Parameters - /// * startcol: An inclusive 0-based start index of the column span. - /// * endcol: An exclusive 0-based ending index of the column span. - /// - /// ## Overloaded parameters - /// - /// * r: Range structure containing both the start and the end indices. - #[inline] - fn col_range(&self, r: &impl core::RangeTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_colRange_const_const_RangeR(self.as_raw_Mat(), r.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; - Ok(ret) - } + impl core::LDATrait for LDA { + #[inline] fn as_raw_mut_LDA(&mut self) -> *mut c_void { self.as_raw_mut() } + } - /// Extracts a diagonal from a matrix - /// - /// The method makes a new header for the specified matrix diagonal. The new matrix is represented as a - /// single-column matrix. Similarly to Mat::row and Mat::col, this is an O(1) operation. - /// ## Parameters - /// * d: index of the diagonal, with the following values: - /// - `d=0` is the main diagonal. - /// - `d<0` is a diagonal from the lower half. For example, d=-1 means the diagonal is set - /// immediately below the main one. - /// - `d>0` is a diagonal from the upper half. For example, d=1 means the diagonal is set - /// immediately above the main one. - /// For example: - /// ```C++ - /// Mat m = (Mat_(3,3) << - /// 1,2,3, - /// 4,5,6, - /// 7,8,9); - /// Mat d0 = m.diag(0); - /// Mat d1 = m.diag(1); - /// Mat d_1 = m.diag(-1); - /// ``` - /// - /// The resulting matrices are - /// ```C++ - /// d0 = - /// [1; - /// 5; - /// 9] - /// d1 = - /// [2; - /// 6] - /// d_1 = - /// [4; - /// 8] - /// ``` - /// - /// - /// ## C++ default parameters - /// * d: 0 - #[inline] - fn diag(&self, d: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_diag_const_int(self.as_raw_Mat(), d, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; - Ok(ret) - } + boxed_ref! { LDA, core::LDATraitConst, as_raw_LDA, core::LDATrait, as_raw_mut_LDA } - /// Extracts a diagonal from a matrix - /// - /// The method makes a new header for the specified matrix diagonal. The new matrix is represented as a - /// single-column matrix. Similarly to Mat::row and Mat::col, this is an O(1) operation. - /// ## Parameters - /// * d: index of the diagonal, with the following values: - /// - `d=0` is the main diagonal. - /// - `d<0` is a diagonal from the lower half. For example, d=-1 means the diagonal is set - /// immediately below the main one. - /// - `d>0` is a diagonal from the upper half. For example, d=1 means the diagonal is set - /// immediately above the main one. - /// For example: - /// ```C++ - /// Mat m = (Mat_(3,3) << - /// 1,2,3, - /// 4,5,6, - /// 7,8,9); - /// Mat d0 = m.diag(0); - /// Mat d1 = m.diag(1); - /// Mat d_1 = m.diag(-1); - /// ``` + /// n-dimensional dense array class \anchor CVMat_Details + /// + /// The class Mat represents an n-dimensional dense numerical single-channel or multi-channel array. It + /// can be used to store real or complex-valued vectors and matrices, grayscale or color images, voxel + /// volumes, vector fields, point clouds, tensors, histograms (though, very high-dimensional histograms + /// may be better stored in a SparseMat ). The data layout of the array `M` is defined by the array + /// `M.step[]`, so that the address of element ![inline formula](https://latex.codecogs.com/png.latex?%28i%5F0%2C%2E%2E%2E%2Ci%5F%7BM%2Edims%2D1%7D%29), where ![inline formula](https://latex.codecogs.com/png.latex?0%5Cleq%20i%5Fk%3CM%2Esize%5Bk%5D), is + /// computed as: + /// ![block formula](https://latex.codecogs.com/png.latex?addr%28M%5F%7Bi%5F0%2C%2E%2E%2E%2Ci%5F%7BM%2Edims%2D1%7D%7D%29%20%3D%20M%2Edata%20%2B%20M%2Estep%5B0%5D%2Ai%5F0%20%2B%20M%2Estep%5B1%5D%2Ai%5F1%20%2B%20%2E%2E%2E%20%2B%20M%2Estep%5BM%2Edims%2D1%5D%2Ai%5F%7BM%2Edims%2D1%7D) + /// In case of a 2-dimensional array, the above formula is reduced to: + /// ![block formula](https://latex.codecogs.com/png.latex?addr%28M%5F%7Bi%2Cj%7D%29%20%3D%20M%2Edata%20%2B%20M%2Estep%5B0%5D%2Ai%20%2B%20M%2Estep%5B1%5D%2Aj) + /// Note that `M.step[i] >= M.step[i+1]` (in fact, `M.step[i] >= M.step[i+1]*M.size[i+1]` ). This means + /// that 2-dimensional matrices are stored row-by-row, 3-dimensional matrices are stored plane-by-plane, + /// and so on. M.step[M.dims-1] is minimal and always equal to the element size M.elemSize() . + /// + /// So, the data layout in Mat is compatible with the majority of dense array types from the standard + /// toolkits and SDKs, such as Numpy (ndarray), Win32 (independent device bitmaps), and others, + /// that is, with any array that uses *steps* (or *strides*) to compute the position of a pixel. + /// Due to this compatibility, it is possible to make a Mat header for user-allocated data and process + /// it in-place using OpenCV functions. + /// + /// There are many different ways to create a Mat object. The most popular options are listed below: + /// + /// - Use the create(nrows, ncols, type) method or the similar Mat(nrows, ncols, type[, fillValue]) + /// constructor. A new array of the specified size and type is allocated. type has the same meaning as + /// in the cvCreateMat method. For example, CV_8UC1 means a 8-bit single-channel array, CV_32FC2 + /// means a 2-channel (complex) floating-point array, and so on. + /// ```C++ + /// // make a 7x7 complex matrix filled with 1+3j. + /// Mat M(7,7,CV_32FC2,Scalar(1,3)); + /// // and now turn M to a 100x60 15-channel 8-bit matrix. + /// // The old content will be deallocated + /// M.create(100,60,CV_8UC(15)); + /// ``` + /// + /// As noted in the introduction to this chapter, create() allocates only a new array when the shape + /// or type of the current array are different from the specified ones. + /// + /// - Create a multi-dimensional array: + /// ```C++ + /// // create a 100x100x100 8-bit array + /// int sz[] = {100, 100, 100}; + /// Mat bigCube(3, sz, CV_8U, Scalar::all(0)); + /// ``` + /// + /// It passes the number of dimensions =1 to the Mat constructor but the created array will be + /// 2-dimensional with the number of columns set to 1. So, Mat::dims is always \>= 2 (can also be 0 + /// when the array is empty). + /// + /// - Use a copy constructor or assignment operator where there can be an array or expression on the + /// right side (see below). As noted in the introduction, the array assignment is an O(1) operation + /// because it only copies the header and increases the reference counter. The Mat::clone() method can + /// be used to get a full (deep) copy of the array when you need it. + /// + /// - Construct a header for a part of another array. It can be a single row, single column, several + /// rows, several columns, rectangular region in the array (called a *minor* in algebra) or a + /// diagonal. Such operations are also O(1) because the new header references the same data. You can + /// actually modify a part of the array using this feature, for example: + /// ```C++ + /// // add the 5-th row, multiplied by 3 to the 3rd row + /// M.row(3) = M.row(3) + M.row(5)*3; + /// // now copy the 7-th column to the 1-st column + /// // M.col(1) = M.col(7); // this will not work + /// Mat M1 = M.col(1); + /// M.col(7).copyTo(M1); + /// // create a new 320x240 image + /// Mat img(Size(320,240),CV_8UC3); + /// // select a ROI + /// Mat roi(img, Rect(10,10,100,100)); + /// // fill the ROI with (0,255,0) (which is green in RGB space); + /// // the original 320x240 image will be modified + /// roi = Scalar(0,255,0); + /// ``` + /// + /// Due to the additional datastart and dataend members, it is possible to compute a relative + /// sub-array position in the main *container* array using locateROI(): + /// ```C++ + /// Mat A = Mat::eye(10, 10, CV_32S); + /// // extracts A columns, 1 (inclusive) to 3 (exclusive). + /// Mat B = A(Range::all(), Range(1, 3)); + /// // extracts B rows, 5 (inclusive) to 9 (exclusive). + /// // that is, C \~ A(Range(5, 9), Range(1, 3)) + /// Mat C = B(Range(5, 9), Range::all()); + /// Size size; Point ofs; + /// C.locateROI(size, ofs); + /// // size will be (width=10,height=10) and the ofs will be (x=1, y=5) + /// ``` + /// + /// As in case of whole matrices, if you need a deep copy, use the `clone()` method of the extracted + /// sub-matrices. + /// + /// - Make a header for user-allocated data. It can be useful to do the following: + /// -# Process "foreign" data using OpenCV (for example, when you implement a DirectShow\* filter or + /// a processing module for gstreamer, and so on). For example: + /// ```C++ + /// Mat process_video_frame(const unsigned char* pixels, + /// int width, int height, int step) + /// { + /// // wrap input buffer + /// Mat img(height, width, CV_8UC3, (unsigned char*)pixels, step); + /// + /// Mat result; + /// GaussianBlur(img, result, Size(7, 7), 1.5, 1.5); + /// + /// return result; + /// } + /// ``` + /// + /// -# Quickly initialize small matrices and/or get a super-fast element access. + /// ```C++ + /// double m[3][3] = {{a, b, c}, {d, e, f}, {g, h, i}}; + /// Mat M = Mat(3, 3, CV_64F, m).inv(); + /// ``` + /// + /// . + /// + /// - Use MATLAB-style array initializers, zeros(), ones(), eye(), for example: + /// ```C++ + /// // create a double-precision identity matrix and add it to M. + /// M += Mat::eye(M.rows, M.cols, CV_64F); + /// ``` + /// + /// + /// - Use a comma-separated initializer: + /// ```C++ + /// // create a 3x3 double-precision identity matrix + /// Mat M = (Mat_(3,3) << 1, 0, 0, 0, 1, 0, 0, 0, 1); + /// ``` + /// + /// With this approach, you first call a constructor of the Mat class with the proper parameters, and + /// then you just put `<< operator` followed by comma-separated values that can be constants, + /// variables, expressions, and so on. Also, note the extra parentheses required to avoid compilation + /// errors. + /// + /// Once the array is created, it is automatically managed via a reference-counting mechanism. If the + /// array header is built on top of user-allocated data, you should handle the data by yourself. The + /// array data is deallocated when no one points to it. If you want to release the data pointed by a + /// array header before the array destructor is called, use Mat::release(). + /// + /// The next important thing to learn about the array class is element access. This manual already + /// described how to compute an address of each array element. Normally, you are not required to use the + /// formula directly in the code. If you know the array element type (which can be retrieved using the + /// method Mat::type() ), you can access the element ![inline formula](https://latex.codecogs.com/png.latex?M%5F%7Bij%7D) of a 2-dimensional array as: + /// ```C++ + /// M.at(i,j) += 1.f; + /// ``` + /// + /// assuming that `M` is a double-precision floating-point array. There are several variants of the method + /// at for a different number of dimensions. + /// + /// If you need to process a whole row of a 2D array, the most efficient way is to get the pointer to + /// the row first, and then just use the plain C operator [] : + /// ```C++ + /// // compute sum of positive matrix elements + /// // (assuming that M is a double-precision matrix) + /// double sum=0; + /// for(int i = 0; i < M.rows; i++) + /// { + /// const double* Mi = M.ptr(i); + /// for(int j = 0; j < M.cols; j++) + /// sum += std::max(Mi[j], 0.); + /// } + /// ``` + /// + /// Some operations, like the one above, do not actually depend on the array shape. They just process + /// elements of an array one by one (or elements from multiple arrays that have the same coordinates, + /// for example, array addition). Such operations are called *element-wise*. It makes sense to check + /// whether all the input/output arrays are continuous, namely, have no gaps at the end of each row. If + /// yes, process them as a long single row: + /// ```C++ + /// // compute the sum of positive matrix elements, optimized variant + /// double sum=0; + /// int cols = M.cols, rows = M.rows; + /// if(M.isContinuous()) + /// { + /// cols *= rows; + /// rows = 1; + /// } + /// for(int i = 0; i < rows; i++) + /// { + /// const double* Mi = M.ptr(i); + /// for(int j = 0; j < cols; j++) + /// sum += std::max(Mi[j], 0.); + /// } + /// ``` + /// + /// In case of the continuous matrix, the outer loop body is executed just once. So, the overhead is + /// smaller, which is especially noticeable in case of small matrices. + /// + /// Finally, there are STL-style iterators that are smart enough to skip gaps between successive rows: + /// ```C++ + /// // compute sum of positive matrix elements, iterator-based variant + /// double sum=0; + /// MatConstIterator_ it = M.begin(), it_end = M.end(); + /// for(; it != it_end; ++it) + /// sum += std::max(*it, 0.); + /// ``` + /// + /// The matrix iterators are random-access iterators, so they can be passed to any STL algorithm, + /// including std::sort(). + /// + /// + /// Note: Matrix Expressions and arithmetic see MatExpr + pub struct Mat { + ptr: *mut c_void, + } + + opencv_type_boxed! { Mat } + + impl Drop for Mat { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_Mat_delete(self.as_raw_mut_Mat()) }; + } + } + + unsafe impl Send for Mat {} + + impl Mat { + /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often + /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. + /// The constructed matrix can further be assigned to another matrix or matrix expression or can be + /// allocated with Mat::create . In the former case, the old content is de-referenced. + #[inline] + pub fn default() -> core::Mat { + let ret = unsafe { sys::cv_Mat_Mat() }; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + ret + } + + /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often + /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. + /// The constructed matrix can further be assigned to another matrix or matrix expression or can be + /// allocated with Mat::create . In the former case, the old content is de-referenced. + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * rows: Number of rows in a 2D array. + /// * cols: Number of columns in a 2D array. + /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + #[inline] + pub unsafe fn new_rows_cols(rows: i32, cols: i32, typ: i32) -> Result { + return_send!(via ocvrs_return); + { sys::cv_Mat_Mat_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = { core::Mat::opencv_from_extern(ret) }; + Ok(ret) + } + + /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often + /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. + /// The constructed matrix can further be assigned to another matrix or matrix expression or can be + /// allocated with Mat::create . In the former case, the old content is de-referenced. + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * size: 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the + /// number of columns go in the reverse order. + /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + #[inline] + pub unsafe fn new_size(size: core::Size, typ: i32) -> Result { + return_send!(via ocvrs_return); + { sys::cv_Mat_Mat_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = { core::Mat::opencv_from_extern(ret) }; + Ok(ret) + } + + /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often + /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. + /// The constructed matrix can further be assigned to another matrix or matrix expression or can be + /// allocated with Mat::create . In the former case, the old content is de-referenced. + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * rows: Number of rows in a 2D array. + /// * cols: Number of columns in a 2D array. + /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + /// * s: An optional value to initialize each matrix element with. To set all the matrix elements to + /// the particular value after the construction, use the assignment operator + /// Mat::operator=(const Scalar& value) . + #[inline] + pub fn new_rows_cols_with_default(rows: i32, cols: i32, typ: i32, s: core::Scalar) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_Mat_int_int_int_const_ScalarR(rows, cols, typ, &s, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + Ok(ret) + } + + /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often + /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. + /// The constructed matrix can further be assigned to another matrix or matrix expression or can be + /// allocated with Mat::create . In the former case, the old content is de-referenced. + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * size: 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the + /// number of columns go in the reverse order. + /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + /// * s: An optional value to initialize each matrix element with. To set all the matrix elements to + /// the particular value after the construction, use the assignment operator + /// Mat::operator=(const Scalar& value) . + #[inline] + pub fn new_size_with_default(size: core::Size, typ: i32, s: core::Scalar) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_Mat_Size_int_const_ScalarR(&size, typ, &s, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + Ok(ret) + } + + /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often + /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. + /// The constructed matrix can further be assigned to another matrix or matrix expression or can be + /// allocated with Mat::create . In the former case, the old content is de-referenced. + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * ndims: Array dimensionality. + /// * sizes: Array of integers specifying an n-dimensional array shape. + /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + #[inline] + pub unsafe fn new_nd(sizes: &[i32], typ: i32) -> Result { + return_send!(via ocvrs_return); + { sys::cv_Mat_Mat_int_const_intX_int(sizes.len().try_into()?, sizes.as_ptr(), typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = { core::Mat::opencv_from_extern(ret) }; + Ok(ret) + } + + /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often + /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. + /// The constructed matrix can further be assigned to another matrix or matrix expression or can be + /// allocated with Mat::create . In the former case, the old content is de-referenced. + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * sizes: Array of integers specifying an n-dimensional array shape. + /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + #[inline] + pub unsafe fn new_nd_vec(sizes: &core::Vector, typ: i32) -> Result { + return_send!(via ocvrs_return); + { sys::cv_Mat_Mat_const_vectorLintGR_int(sizes.as_raw_VectorOfi32(), typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = { core::Mat::opencv_from_extern(ret) }; + Ok(ret) + } + + /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often + /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. + /// The constructed matrix can further be assigned to another matrix or matrix expression or can be + /// allocated with Mat::create . In the former case, the old content is de-referenced. /// - /// The resulting matrices are - /// ```C++ - /// d0 = - /// [1; - /// 5; - /// 9] - /// d1 = - /// [2; - /// 6] - /// d_1 = - /// [4; - /// 8] - /// ``` + /// ## Overloaded parameters + /// + /// ## Parameters + /// * ndims: Array dimensionality. + /// * sizes: Array of integers specifying an n-dimensional array shape. + /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + /// * s: An optional value to initialize each matrix element with. To set all the matrix elements to + /// the particular value after the construction, use the assignment operator + /// Mat::operator=(const Scalar& value) . + #[inline] + pub fn new_nd_with_default(sizes: &[i32], typ: i32, s: core::Scalar) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_Mat_int_const_intX_int_const_ScalarR(sizes.len().try_into()?, sizes.as_ptr(), typ, &s, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + Ok(ret) + } + + /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often + /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. + /// The constructed matrix can further be assigned to another matrix or matrix expression or can be + /// allocated with Mat::create . In the former case, the old content is de-referenced. + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * sizes: Array of integers specifying an n-dimensional array shape. + /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + /// * s: An optional value to initialize each matrix element with. To set all the matrix elements to + /// the particular value after the construction, use the assignment operator + /// Mat::operator=(const Scalar& value) . + #[inline] + pub fn new_nd_vec_with_default(sizes: &core::Vector, typ: i32, s: core::Scalar) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_Mat_const_vectorLintGR_int_const_ScalarR(sizes.as_raw_VectorOfi32(), typ, &s, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + Ok(ret) + } + + /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often + /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. + /// The constructed matrix can further be assigned to another matrix or matrix expression or can be + /// allocated with Mat::create . In the former case, the old content is de-referenced. + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + /// formed using such a constructor, you also modify the corresponding elements of m . If you want to + /// have an independent copy of the sub-array, use Mat::clone() . + #[inline] + pub fn copy(m: &impl core::MatTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_Mat_const_MatR(m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// @overload + /// ## Parameters + /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + /// formed using such a constructor, you also modify the corresponding elements of m . If you want to + /// have an independent copy of the sub-array, use Mat::clone() . + #[inline] + pub fn copy_mut(m: &mut impl core::MatTrait) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_Mat_MatR(m.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often + /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. + /// The constructed matrix can further be assigned to another matrix or matrix expression or can be + /// allocated with Mat::create . In the former case, the old content is de-referenced. + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * rows: Number of rows in a 2D array. + /// * cols: Number of columns in a 2D array. + /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not + /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified + /// data, which means that no data is copied. This operation is very efficient and can be used to + /// process external data using OpenCV functions. The external data is not automatically deallocated, so + /// you should take care of it. + /// * step: Number of bytes each matrix row occupies. The value should include the padding bytes at + /// the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed + /// and the actual step is calculated as cols*elemSize(). See Mat::elemSize. /// + /// ## C++ default parameters + /// * step: AUTO_STEP + #[inline] + pub unsafe fn new_rows_cols_with_data_unsafe(rows: i32, cols: i32, typ: i32, data: *mut c_void, step: size_t) -> Result { + return_send!(via ocvrs_return); + { sys::cv_Mat_Mat_int_int_int_voidX_size_t(rows, cols, typ, data, step, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = { core::Mat::opencv_from_extern(ret) }; + Ok(ret) + } + + /// @overload + /// ## Parameters + /// * rows: Number of rows in a 2D array. + /// * cols: Number of columns in a 2D array. + /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not + /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified + /// data, which means that no data is copied. This operation is very efficient and can be used to + /// process external data using OpenCV functions. The external data is not automatically deallocated, so + /// you should take care of it. + /// * step: Number of bytes each matrix row occupies. The value should include the padding bytes at + /// the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed + /// and the actual step is calculated as cols*elemSize(). See Mat::elemSize. /// /// ## Note - /// This alternative version of [MatTraitConst::diag] function uses the following default values for its arguments: - /// * d: 0 + /// This alternative version of [new_rows_cols_with_data_unsafe] function uses the following default values for its arguments: + /// * step: AUTO_STEP + #[inline] + pub unsafe fn new_rows_cols_with_data_unsafe_def(rows: i32, cols: i32, typ: i32, data: *mut c_void) -> Result { + return_send!(via ocvrs_return); + { sys::cv_Mat_Mat_int_int_int_voidX(rows, cols, typ, data, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = { core::Mat::opencv_from_extern(ret) }; + Ok(ret) + } + + /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often + /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. + /// The constructed matrix can further be assigned to another matrix or matrix expression or can be + /// allocated with Mat::create . In the former case, the old content is de-referenced. + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * size: 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the + /// number of columns go in the reverse order. + /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not + /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified + /// data, which means that no data is copied. This operation is very efficient and can be used to + /// process external data using OpenCV functions. The external data is not automatically deallocated, so + /// you should take care of it. + /// * step: Number of bytes each matrix row occupies. The value should include the padding bytes at + /// the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed + /// and the actual step is calculated as cols*elemSize(). See Mat::elemSize. + /// + /// ## C++ default parameters + /// * step: AUTO_STEP + #[inline] + pub unsafe fn new_size_with_data_unsafe(size: core::Size, typ: i32, data: *mut c_void, step: size_t) -> Result { + return_send!(via ocvrs_return); + { sys::cv_Mat_Mat_Size_int_voidX_size_t(&size, typ, data, step, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = { core::Mat::opencv_from_extern(ret) }; + Ok(ret) + } + + /// @overload + /// ## Parameters + /// * size: 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the + /// number of columns go in the reverse order. + /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not + /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified + /// data, which means that no data is copied. This operation is very efficient and can be used to + /// process external data using OpenCV functions. The external data is not automatically deallocated, so + /// you should take care of it. + /// * step: Number of bytes each matrix row occupies. The value should include the padding bytes at + /// the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed + /// and the actual step is calculated as cols*elemSize(). See Mat::elemSize. + /// + /// ## Note + /// This alternative version of [new_size_with_data_unsafe] function uses the following default values for its arguments: + /// * step: AUTO_STEP + #[inline] + pub unsafe fn new_size_with_data_unsafe_def(size: core::Size, typ: i32, data: *mut c_void) -> Result { + return_send!(via ocvrs_return); + { sys::cv_Mat_Mat_Size_int_voidX(&size, typ, data, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = { core::Mat::opencv_from_extern(ret) }; + Ok(ret) + } + + /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often + /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. + /// The constructed matrix can further be assigned to another matrix or matrix expression or can be + /// allocated with Mat::create . In the former case, the old content is de-referenced. + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * ndims: Array dimensionality. + /// * sizes: Array of integers specifying an n-dimensional array shape. + /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not + /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified + /// data, which means that no data is copied. This operation is very efficient and can be used to + /// process external data using OpenCV functions. The external data is not automatically deallocated, so + /// you should take care of it. + /// * steps: Array of ndims-1 steps in case of a multi-dimensional array (the last step is always + /// set to the element size). If not specified, the matrix is assumed to be continuous. + /// + /// ## C++ default parameters + /// * steps: 0 #[inline] - fn diag_def(&self) -> Result> { + pub unsafe fn new_nd_with_data_unsafe(sizes: &[i32], typ: i32, data: *mut c_void, steps: Option<&[size_t]>) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_diag_const(self.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_Mat_Mat_int_const_intX_int_voidX_const_size_tX(sizes.len().try_into()?, sizes.as_ptr(), typ, data, steps.map_or(::core::ptr::null(), |steps| steps.as_ptr()), ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// Creates a full copy of the array and the underlying data. + /// @overload + /// ## Parameters + /// * ndims: Array dimensionality. + /// * sizes: Array of integers specifying an n-dimensional array shape. + /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not + /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified + /// data, which means that no data is copied. This operation is very efficient and can be used to + /// process external data using OpenCV functions. The external data is not automatically deallocated, so + /// you should take care of it. + /// * steps: Array of ndims-1 steps in case of a multi-dimensional array (the last step is always + /// set to the element size). If not specified, the matrix is assumed to be continuous. /// - /// The method creates a full copy of the array. The original step[] is not taken into account. So, the - /// array copy is a continuous array occupying total()*elemSize() bytes. + /// ## Note + /// This alternative version of [new_nd_with_data_unsafe] function uses the following default values for its arguments: + /// * steps: 0 #[inline] - #[must_use] - fn try_clone(&self) -> Result { + pub unsafe fn new_nd_with_data_unsafe_def(sizes: &[i32], typ: i32, data: *mut c_void) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_clone_const(self.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_Mat_Mat_int_const_intX_int_voidX(sizes.len().try_into()?, sizes.as_ptr(), typ, data, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + let ret = { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// Copies the matrix to another one. - /// - /// The method copies the matrix data to another matrix. Before copying the data, the method invokes : - /// ```C++ - /// m.create(this->size(), this->type()); - /// ``` + /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often + /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. + /// The constructed matrix can further be assigned to another matrix or matrix expression or can be + /// allocated with Mat::create . In the former case, the old content is de-referenced. /// - /// so that the destination matrix is reallocated if needed. While m.copyTo(m); works flawlessly, the - /// function does not handle the case of a partial overlap between the source and the destination - /// matrices. + /// ## Overloaded parameters /// - /// When the operation mask is specified, if the Mat::create call shown above reallocates the matrix, - /// the newly allocated matrix is initialized with all zeros before copying the data. /// ## Parameters - /// * m: Destination matrix. If it does not have a proper size or type before the operation, it is - /// reallocated. + /// * sizes: Array of integers specifying an n-dimensional array shape. + /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not + /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified + /// data, which means that no data is copied. This operation is very efficient and can be used to + /// process external data using OpenCV functions. The external data is not automatically deallocated, so + /// you should take care of it. + /// * steps: Array of ndims-1 steps in case of a multi-dimensional array (the last step is always + /// set to the element size). If not specified, the matrix is assumed to be continuous. + /// + /// ## C++ default parameters + /// * steps: 0 #[inline] - fn copy_to(&self, m: &mut impl ToOutputArray) -> Result<()> { - output_array_arg!(m); + pub unsafe fn new_nd_vec_with_data_unsafe(sizes: &core::Vector, typ: i32, data: *mut c_void, steps: Option<&[size_t]>) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_copyTo_const_const__OutputArrayR(self.as_raw_Mat(), m.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_Mat_Mat_const_vectorLintGR_int_voidX_const_size_tX(sizes.as_raw_VectorOfi32(), typ, data, steps.map_or(::core::ptr::null(), |steps| steps.as_ptr()), ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; + let ret = { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// Copies the matrix to another one. + /// @overload + /// ## Parameters + /// * sizes: Array of integers specifying an n-dimensional array shape. + /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not + /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified + /// data, which means that no data is copied. This operation is very efficient and can be used to + /// process external data using OpenCV functions. The external data is not automatically deallocated, so + /// you should take care of it. + /// * steps: Array of ndims-1 steps in case of a multi-dimensional array (the last step is always + /// set to the element size). If not specified, the matrix is assumed to be continuous. /// - /// The method copies the matrix data to another matrix. Before copying the data, the method invokes : - /// ```C++ - /// m.create(this->size(), this->type()); - /// ``` + /// ## Note + /// This alternative version of [new_nd_vec_with_data_unsafe] function uses the following default values for its arguments: + /// * steps: 0 + #[inline] + pub unsafe fn new_nd_vec_with_data_unsafe_def(sizes: &core::Vector, typ: i32, data: *mut c_void) -> Result { + return_send!(via ocvrs_return); + { sys::cv_Mat_Mat_const_vectorLintGR_int_voidX(sizes.as_raw_VectorOfi32(), typ, data, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = { core::Mat::opencv_from_extern(ret) }; + Ok(ret) + } + + /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often + /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. + /// The constructed matrix can further be assigned to another matrix or matrix expression or can be + /// allocated with Mat::create . In the former case, the old content is de-referenced. /// - /// so that the destination matrix is reallocated if needed. While m.copyTo(m); works flawlessly, the - /// function does not handle the case of a partial overlap between the source and the destination - /// matrices. + /// ## Overloaded parameters /// - /// When the operation mask is specified, if the Mat::create call shown above reallocates the matrix, - /// the newly allocated matrix is initialized with all zeros before copying the data. /// ## Parameters - /// * m: Destination matrix. If it does not have a proper size or type before the operation, it is - /// reallocated. - /// - /// ## Overloaded parameters + /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + /// formed using such a constructor, you also modify the corresponding elements of m . If you want to + /// have an independent copy of the sub-array, use Mat::clone() . + /// * rowRange: Range of the m rows to take. As usual, the range start is inclusive and the range + /// end is exclusive. Use Range::all() to take all the rows. + /// * colRange: Range of the m columns to take. Use Range::all() to take all the columns. /// - /// * m: Destination matrix. If it does not have a proper size or type before the operation, it is - /// reallocated. - /// * mask: Operation mask of the same size as \*this. Its non-zero elements indicate which matrix - /// elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels. + /// ## C++ default parameters + /// * col_range: Range::all() #[inline] - fn copy_to_masked(&self, m: &mut impl ToOutputArray, mask: &impl ToInputArray) -> Result<()> { - output_array_arg!(m); - input_array_arg!(mask); + pub fn rowscols<'boxed>(m: &'boxed impl core::MatTraitConst, row_range: &impl core::RangeTraitConst, col_range: &impl core::RangeTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_copyTo_const_const__OutputArrayR_const__InputArrayR(self.as_raw_Mat(), m.as_raw__OutputArray(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_Mat_const_MatR_const_RangeR_const_RangeR(m.as_raw_Mat(), row_range.as_raw_Range(), col_range.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::<'boxed, core::Mat>::opencv_from_extern(ret) }; Ok(ret) } - /// Converts an array to another data type with optional scaling. + /// @overload + /// ## Parameters + /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + /// formed using such a constructor, you also modify the corresponding elements of m . If you want to + /// have an independent copy of the sub-array, use Mat::clone() . + /// * rowRange: Range of the m rows to take. As usual, the range start is inclusive and the range + /// end is exclusive. Use Range::all() to take all the rows. + /// * colRange: Range of the m columns to take. Use Range::all() to take all the columns. /// - /// The method converts source pixel values to the target data type. saturate_cast\<\> is applied at - /// the end to avoid possible overflows: + /// ## Note + /// This alternative version of [rowscols] function uses the following default values for its arguments: + /// * col_range: Range::all() + #[inline] + pub fn rowscols_def_mut<'boxed>(m: &'boxed mut impl core::MatTrait, row_range: &impl core::RangeTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_Mat_MatR_const_RangeR(m.as_raw_mut_Mat(), row_range.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRefMut::<'boxed, core::Mat>::opencv_from_extern(ret) }; + Ok(ret) + } + + /// @overload + /// ## Parameters + /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + /// formed using such a constructor, you also modify the corresponding elements of m . If you want to + /// have an independent copy of the sub-array, use Mat::clone() . + /// * rowRange: Range of the m rows to take. As usual, the range start is inclusive and the range + /// end is exclusive. Use Range::all() to take all the rows. + /// * colRange: Range of the m columns to take. Use Range::all() to take all the columns. /// - /// ![block formula](https://latex.codecogs.com/png.latex?m%28x%2Cy%29%20%3D%20saturate%20%5C%5F%20cast%3CrType%3E%28%20%5Calpha%20%28%2Athis%29%28x%2Cy%29%20%2B%20%20%5Cbeta%20%29) + /// ## Note + /// This alternative version of [rowscols] function uses the following default values for its arguments: + /// * col_range: Range::all() + #[inline] + pub fn rowscols_def<'boxed>(m: &'boxed impl core::MatTraitConst, row_range: &impl core::RangeTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_Mat_const_MatR_const_RangeR(m.as_raw_Mat(), row_range.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::<'boxed, core::Mat>::opencv_from_extern(ret) }; + Ok(ret) + } + + /// @overload /// ## Parameters - /// * m: output matrix; if it does not have a proper size or type before the operation, it is - /// reallocated. - /// * rtype: desired output matrix type or, rather, the depth since the number of channels are the - /// same as the input has; if rtype is negative, the output matrix will have the same type as the input. - /// * alpha: optional scale factor. - /// * beta: optional delta added to the scaled values. + /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + /// formed using such a constructor, you also modify the corresponding elements of m . If you want to + /// have an independent copy of the sub-array, use Mat::clone() . + /// * rowRange: Range of the m rows to take. As usual, the range start is inclusive and the range + /// end is exclusive. Use Range::all() to take all the rows. + /// * colRange: Range of the m columns to take. Use Range::all() to take all the columns. /// /// ## C++ default parameters - /// * alpha: 1 - /// * beta: 0 + /// * col_range: Range::all() #[inline] - fn convert_to(&self, m: &mut impl ToOutputArray, rtype: i32, alpha: f64, beta: f64) -> Result<()> { - output_array_arg!(m); + pub fn rowscols_mut<'boxed>(m: &'boxed mut impl core::MatTrait, row_range: &impl core::RangeTraitConst, col_range: &impl core::RangeTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_convertTo_const_const__OutputArrayR_int_double_double(self.as_raw_Mat(), m.as_raw__OutputArray(), rtype, alpha, beta, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_Mat_MatR_const_RangeR_const_RangeR(m.as_raw_mut_Mat(), row_range.as_raw_Range(), col_range.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRefMut::<'boxed, core::Mat>::opencv_from_extern(ret) }; Ok(ret) } - /// Converts an array to another data type with optional scaling. + /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often + /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. + /// The constructed matrix can further be assigned to another matrix or matrix expression or can be + /// allocated with Mat::create . In the former case, the old content is de-referenced. /// - /// The method converts source pixel values to the target data type. saturate_cast\<\> is applied at - /// the end to avoid possible overflows: + /// ## Overloaded parameters /// - /// ![block formula](https://latex.codecogs.com/png.latex?m%28x%2Cy%29%20%3D%20saturate%20%5C%5F%20cast%3CrType%3E%28%20%5Calpha%20%28%2Athis%29%28x%2Cy%29%20%2B%20%20%5Cbeta%20%29) /// ## Parameters - /// * m: output matrix; if it does not have a proper size or type before the operation, it is - /// reallocated. - /// * rtype: desired output matrix type or, rather, the depth since the number of channels are the - /// same as the input has; if rtype is negative, the output matrix will have the same type as the input. - /// * alpha: optional scale factor. - /// * beta: optional delta added to the scaled values. - /// - /// ## Note - /// This alternative version of [MatTraitConst::convert_to] function uses the following default values for its arguments: - /// * alpha: 1 - /// * beta: 0 + /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + /// formed using such a constructor, you also modify the corresponding elements of m . If you want to + /// have an independent copy of the sub-array, use Mat::clone() . + /// * roi: Region of interest. + #[inline] + pub fn roi(m: &impl core::MatTraitConst, roi: core::Rect) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_Mat_const_MatR_const_RectR(m.as_raw_Mat(), &roi, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// @overload + /// ## Parameters + /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + /// formed using such a constructor, you also modify the corresponding elements of m . If you want to + /// have an independent copy of the sub-array, use Mat::clone() . + /// * roi: Region of interest. #[inline] - fn convert_to_def(&self, m: &mut impl ToOutputArray, rtype: i32) -> Result<()> { - output_array_arg!(m); + pub fn roi_mut(m: &mut impl core::MatTrait, roi: core::Rect) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_convertTo_const_const__OutputArrayR_int(self.as_raw_Mat(), m.as_raw__OutputArray(), rtype, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_Mat_MatR_const_RectR(m.as_raw_mut_Mat(), &roi, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// Provides a functional form of convertTo. + /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often + /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. + /// The constructed matrix can further be assigned to another matrix or matrix expression or can be + /// allocated with Mat::create . In the former case, the old content is de-referenced. /// - /// This is an internally used method called by the [MatrixExpressions] engine. - /// ## Parameters - /// * m: Destination array. - /// * type: Desired destination array depth (or -1 if it should be the same as the source type). + /// ## Overloaded parameters /// - /// ## C++ default parameters - /// * typ: -1 + /// ## Parameters + /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + /// formed using such a constructor, you also modify the corresponding elements of m . If you want to + /// have an independent copy of the sub-array, use Mat::clone() . + /// * ranges: Array of selected ranges of m along each dimensionality. #[inline] - fn assign_to(&self, m: &mut impl core::MatTrait, typ: i32) -> Result<()> { + pub fn ranges<'boxed>(m: &'boxed impl core::MatTraitConst, ranges: &core::Vector) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_assignTo_const_MatR_int(self.as_raw_Mat(), m.as_raw_mut_Mat(), typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_Mat_const_MatR_const_vectorLRangeGR(m.as_raw_Mat(), ranges.as_raw_VectorOfRange(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::<'boxed, core::Mat>::opencv_from_extern(ret) }; Ok(ret) } - /// Provides a functional form of convertTo. - /// - /// This is an internally used method called by the [MatrixExpressions] engine. + /// @overload /// ## Parameters - /// * m: Destination array. - /// * type: Desired destination array depth (or -1 if it should be the same as the source type). - /// - /// ## Note - /// This alternative version of [MatTraitConst::assign_to] function uses the following default values for its arguments: - /// * typ: -1 + /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + /// formed using such a constructor, you also modify the corresponding elements of m . If you want to + /// have an independent copy of the sub-array, use Mat::clone() . + /// * ranges: Array of selected ranges of m along each dimensionality. #[inline] - fn assign_to_def(&self, m: &mut impl core::MatTrait) -> Result<()> { + pub fn ranges_mut<'boxed>(m: &'boxed mut impl core::MatTrait, ranges: &core::Vector) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_assignTo_const_MatR(self.as_raw_Mat(), m.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_Mat_MatR_const_vectorLRangeGR(m.as_raw_mut_Mat(), ranges.as_raw_VectorOfRange(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRefMut::<'boxed, core::Mat>::opencv_from_extern(ret) }; Ok(ret) } - /// Changes the shape and/or the number of channels of a 2D matrix without copying the data. - /// - /// The method makes a new matrix header for \*this elements. The new matrix may have a different size - /// and/or different number of channels. Any combination is possible if: - /// * No extra elements are included into the new matrix and no elements are excluded. Consequently, - /// the product rows\*cols\*channels() must stay the same after the transformation. - /// * No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of - /// rows, or the operation changes the indices of elements row in some other way, the matrix must be - /// continuous. See Mat::isContinuous . - /// - /// For example, if there is a set of 3D points stored as an STL vector, and you want to represent the - /// points as a 3xN matrix, do the following: - /// ```C++ - /// std::vector vec; - /// ... - /// Mat pointMat = Mat(vec). // convert vector to Mat, O(1) operation - /// reshape(1). // make Nx3 1-channel matrix out of Nx1 3-channel. - /// // Also, an O(1) operation - /// t(); // finally, transpose the Nx3 matrix. - /// // This involves copying all the elements - /// ``` - /// - /// 3-channel 2x2 matrix reshaped to 1-channel 4x3 matrix, each column has values from one of original channels: - /// ```C++ - /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); - /// vector new_shape {4, 3}; - /// m = m.reshape(1, new_shape); - /// ``` - /// - /// or: - /// ```C++ - /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); - /// const int new_shape[] = {4, 3}; - /// m = m.reshape(1, 2, new_shape); - /// ``` - /// - /// ## Parameters - /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. - /// * rows: New number of rows. If the parameter is 0, the number of rows remains the same. - /// - /// ## C++ default parameters - /// * rows: 0 + /// download data from GpuMat #[inline] - fn reshape(&self, cn: i32, rows: i32) -> Result> { + pub fn from_gpumat(m: &impl core::GpuMatTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_reshape_const_int_int(self.as_raw_Mat(), cn, rows, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_Mat_const_GpuMatR(m.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// Changes the shape and/or the number of channels of a 2D matrix without copying the data. - /// - /// The method makes a new matrix header for \*this elements. The new matrix may have a different size - /// and/or different number of channels. Any combination is possible if: - /// * No extra elements are included into the new matrix and no elements are excluded. Consequently, - /// the product rows\*cols\*channels() must stay the same after the transformation. - /// * No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of - /// rows, or the operation changes the indices of elements row in some other way, the matrix must be - /// continuous. See Mat::isContinuous . - /// - /// For example, if there is a set of 3D points stored as an STL vector, and you want to represent the - /// points as a 3xN matrix, do the following: - /// ```C++ - /// std::vector vec; - /// ... - /// Mat pointMat = Mat(vec). // convert vector to Mat, O(1) operation - /// reshape(1). // make Nx3 1-channel matrix out of Nx1 3-channel. - /// // Also, an O(1) operation - /// t(); // finally, transpose the Nx3 matrix. - /// // This involves copying all the elements - /// ``` - /// - /// 3-channel 2x2 matrix reshaped to 1-channel 4x3 matrix, each column has values from one of original channels: - /// ```C++ - /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); - /// vector new_shape {4, 3}; - /// m = m.reshape(1, new_shape); - /// ``` - /// - /// or: - /// ```C++ - /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); - /// const int new_shape[] = {4, 3}; - /// m = m.reshape(1, 2, new_shape); - /// ``` + /// creates a diagonal matrix /// + /// The method creates a square diagonal matrix from specified main diagonal. /// ## Parameters - /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. - /// * rows: New number of rows. If the parameter is 0, the number of rows remains the same. - /// - /// ## Note - /// This alternative version of [MatTraitConst::reshape] function uses the following default values for its arguments: - /// * rows: 0 + /// * d: One-dimensional matrix that represents the main diagonal. #[inline] - fn reshape_def(&self, cn: i32) -> Result> { + #[must_use] + pub fn diag_mat(d: &impl core::MatTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_reshape_const_int(self.as_raw_Mat(), cn, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_diag_const_MatR(d.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// Changes the shape and/or the number of channels of a 2D matrix without copying the data. - /// - /// The method makes a new matrix header for \*this elements. The new matrix may have a different size - /// and/or different number of channels. Any combination is possible if: - /// * No extra elements are included into the new matrix and no elements are excluded. Consequently, - /// the product rows\*cols\*channels() must stay the same after the transformation. - /// * No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of - /// rows, or the operation changes the indices of elements row in some other way, the matrix must be - /// continuous. See Mat::isContinuous . - /// - /// For example, if there is a set of 3D points stored as an STL vector, and you want to represent the - /// points as a 3xN matrix, do the following: - /// ```C++ - /// std::vector vec; - /// ... - /// Mat pointMat = Mat(vec). // convert vector to Mat, O(1) operation - /// reshape(1). // make Nx3 1-channel matrix out of Nx1 3-channel. - /// // Also, an O(1) operation - /// t(); // finally, transpose the Nx3 matrix. - /// // This involves copying all the elements - /// ``` - /// - /// 3-channel 2x2 matrix reshaped to 1-channel 4x3 matrix, each column has values from one of original channels: - /// ```C++ - /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); - /// vector new_shape {4, 3}; - /// m = m.reshape(1, new_shape); - /// ``` + /// Returns a zero array of the specified size and type. /// - /// or: + /// The method returns a Matlab-style zero array initializer. It can be used to quickly form a constant + /// array as a function parameter, part of a matrix expression, or as a matrix initializer: /// ```C++ - /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); - /// const int new_shape[] = {4, 3}; - /// m = m.reshape(1, 2, new_shape); + /// Mat A; + /// A = Mat::zeros(3, 3, CV_32F); /// ``` /// + /// In the example above, a new matrix is allocated only if A is not a 3x3 floating-point matrix. + /// Otherwise, the existing matrix A is filled with zeros. /// ## Parameters - /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. - /// * rows: New number of rows. If the parameter is 0, the number of rows remains the same. - /// - /// ## Overloaded parameters - /// - /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. - /// * newndims: New number of dimentions. - /// * newsz: Array with new matrix size by all dimentions. If some sizes are zero, - /// the original sizes in those dimensions are presumed. + /// * rows: Number of rows. + /// * cols: Number of columns. + /// * type: Created matrix type. #[inline] - fn reshape_nd(&self, cn: i32, newsz: &[i32]) -> Result> { + #[must_use] + pub fn zeros(rows: i32, cols: i32, typ: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_reshape_const_int_int_const_intX(self.as_raw_Mat(), cn, newsz.len().try_into()?, newsz.as_ptr(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_zeros_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; Ok(ret) } - /// Changes the shape and/or the number of channels of a 2D matrix without copying the data. - /// - /// The method makes a new matrix header for \*this elements. The new matrix may have a different size - /// and/or different number of channels. Any combination is possible if: - /// * No extra elements are included into the new matrix and no elements are excluded. Consequently, - /// the product rows\*cols\*channels() must stay the same after the transformation. - /// * No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of - /// rows, or the operation changes the indices of elements row in some other way, the matrix must be - /// continuous. See Mat::isContinuous . + /// Returns a zero array of the specified size and type. /// - /// For example, if there is a set of 3D points stored as an STL vector, and you want to represent the - /// points as a 3xN matrix, do the following: + /// The method returns a Matlab-style zero array initializer. It can be used to quickly form a constant + /// array as a function parameter, part of a matrix expression, or as a matrix initializer: /// ```C++ - /// std::vector vec; - /// ... - /// Mat pointMat = Mat(vec). // convert vector to Mat, O(1) operation - /// reshape(1). // make Nx3 1-channel matrix out of Nx1 3-channel. - /// // Also, an O(1) operation - /// t(); // finally, transpose the Nx3 matrix. - /// // This involves copying all the elements + /// Mat A; + /// A = Mat::zeros(3, 3, CV_32F); /// ``` /// - /// 3-channel 2x2 matrix reshaped to 1-channel 4x3 matrix, each column has values from one of original channels: - /// ```C++ - /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); - /// vector new_shape {4, 3}; - /// m = m.reshape(1, new_shape); - /// ``` + /// In the example above, a new matrix is allocated only if A is not a 3x3 floating-point matrix. + /// Otherwise, the existing matrix A is filled with zeros. + /// ## Parameters + /// * rows: Number of rows. + /// * cols: Number of columns. + /// * type: Created matrix type. + /// + /// ## Overloaded parameters + /// + /// * size: Alternative to the matrix size specification Size(cols, rows) . + /// * type: Created matrix type. + #[inline] + #[must_use] + pub fn zeros_size(size: core::Size, typ: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_zeros_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Returns a zero array of the specified size and type. /// - /// or: + /// The method returns a Matlab-style zero array initializer. It can be used to quickly form a constant + /// array as a function parameter, part of a matrix expression, or as a matrix initializer: /// ```C++ - /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); - /// const int new_shape[] = {4, 3}; - /// m = m.reshape(1, 2, new_shape); + /// Mat A; + /// A = Mat::zeros(3, 3, CV_32F); /// ``` /// + /// In the example above, a new matrix is allocated only if A is not a 3x3 floating-point matrix. + /// Otherwise, the existing matrix A is filled with zeros. /// ## Parameters - /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. - /// * rows: New number of rows. If the parameter is 0, the number of rows remains the same. + /// * rows: Number of rows. + /// * cols: Number of columns. + /// * type: Created matrix type. /// /// ## Overloaded parameters /// - /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. - /// * newshape: Vector with new matrix size by all dimentions. If some sizes are zero, - /// the original sizes in those dimensions are presumed. + /// * ndims: Array dimensionality. + /// * sz: Array of integers specifying the array shape. + /// * type: Created matrix type. #[inline] - fn reshape_nd_vec(&self, cn: i32, newshape: &core::Vector) -> Result> { + #[must_use] + pub fn zeros_nd(sz: &[i32], typ: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_reshape_const_int_const_vectorLintGR(self.as_raw_Mat(), cn, newshape.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_zeros_int_const_intX_int(sz.len().try_into()?, sz.as_ptr(), typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; Ok(ret) } - /// Transposes a matrix. + /// Returns an array of all 1's of the specified size and type. /// - /// The method performs matrix transposition by means of matrix expressions. It does not perform the - /// actual transposition but returns a temporary matrix transposition object that can be further used as - /// a part of more complex matrix expressions or can be assigned to a matrix: + /// The method returns a Matlab-style 1's array initializer, similarly to Mat::zeros. Note that using + /// this method you can initialize an array with an arbitrary value, using the following Matlab idiom: /// ```C++ - /// Mat A1 = A + Mat::eye(A.size(), A.type())*lambda; - /// Mat C = A1.t()*A1; // compute (A + lambda*I)^t * (A + lamda*I) + /// Mat A = Mat::ones(100, 100, CV_8U)*3; // make 100x100 matrix filled with 3. /// ``` /// + /// The above operation does not form a 100x100 matrix of 1's and then multiply it by 3. Instead, it + /// just remembers the scale factor (3 in this case) and use it when actually invoking the matrix + /// initializer. + /// + /// Note: In case of multi-channels type, only the first channel will be initialized with 1's, the + /// others will be set to 0's. + /// ## Parameters + /// * rows: Number of rows. + /// * cols: Number of columns. + /// * type: Created matrix type. #[inline] - fn t(&self) -> Result { + #[must_use] + pub fn ones(rows: i32, cols: i32, typ: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_t_const(self.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_ones_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; Ok(ret) } - /// Inverses a matrix. + /// Returns an array of all 1's of the specified size and type. /// - /// The method performs a matrix inversion by means of matrix expressions. This means that a temporary - /// matrix inversion object is returned by the method and can be used further as a part of more complex - /// matrix expressions or can be assigned to a matrix. + /// The method returns a Matlab-style 1's array initializer, similarly to Mat::zeros. Note that using + /// this method you can initialize an array with an arbitrary value, using the following Matlab idiom: + /// ```C++ + /// Mat A = Mat::ones(100, 100, CV_8U)*3; // make 100x100 matrix filled with 3. + /// ``` + /// + /// The above operation does not form a 100x100 matrix of 1's and then multiply it by 3. Instead, it + /// just remembers the scale factor (3 in this case) and use it when actually invoking the matrix + /// initializer. + /// + /// Note: In case of multi-channels type, only the first channel will be initialized with 1's, the + /// others will be set to 0's. /// ## Parameters - /// * method: Matrix inversion method. One of cv::DecompTypes + /// * rows: Number of rows. + /// * cols: Number of columns. + /// * type: Created matrix type. /// - /// ## C++ default parameters - /// * method: DECOMP_LU + /// ## Overloaded parameters + /// + /// * size: Alternative to the matrix size specification Size(cols, rows) . + /// * type: Created matrix type. #[inline] - fn inv(&self, method: i32) -> Result { + #[must_use] + pub fn ones_size(size: core::Size, typ: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_inv_const_int(self.as_raw_Mat(), method, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_ones_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; Ok(ret) } - /// Inverses a matrix. + /// Returns an array of all 1's of the specified size and type. /// - /// The method performs a matrix inversion by means of matrix expressions. This means that a temporary - /// matrix inversion object is returned by the method and can be used further as a part of more complex - /// matrix expressions or can be assigned to a matrix. + /// The method returns a Matlab-style 1's array initializer, similarly to Mat::zeros. Note that using + /// this method you can initialize an array with an arbitrary value, using the following Matlab idiom: + /// ```C++ + /// Mat A = Mat::ones(100, 100, CV_8U)*3; // make 100x100 matrix filled with 3. + /// ``` + /// + /// The above operation does not form a 100x100 matrix of 1's and then multiply it by 3. Instead, it + /// just remembers the scale factor (3 in this case) and use it when actually invoking the matrix + /// initializer. + /// + /// Note: In case of multi-channels type, only the first channel will be initialized with 1's, the + /// others will be set to 0's. /// ## Parameters - /// * method: Matrix inversion method. One of cv::DecompTypes + /// * rows: Number of rows. + /// * cols: Number of columns. + /// * type: Created matrix type. /// - /// ## Note - /// This alternative version of [MatTraitConst::inv] function uses the following default values for its arguments: - /// * method: DECOMP_LU + /// ## Overloaded parameters + /// + /// * ndims: Array dimensionality. + /// * sz: Array of integers specifying the array shape. + /// * type: Created matrix type. #[inline] - fn inv_def(&self) -> Result { + #[must_use] + pub fn ones_nd(sz: &[i32], typ: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_inv_const(self.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_ones_int_const_intX_int(sz.len().try_into()?, sz.as_ptr(), typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; Ok(ret) } - /// Performs an element-wise multiplication or division of the two matrices. - /// - /// The method returns a temporary object encoding per-element array multiplication, with optional - /// scale. Note that this is not a matrix multiplication that corresponds to a simpler "\*" operator. + /// Returns an identity matrix of the specified size and type. /// - /// Example: + /// The method returns a Matlab-style identity matrix initializer, similarly to Mat::zeros. Similarly to + /// Mat::ones, you can use a scale operation to create a scaled identity matrix efficiently: /// ```C++ - /// Mat C = A.mul(5/B); // equivalent to divide(A, B, C, 5) + /// // make a 4x4 diagonal matrix with 0.1's on the diagonal. + /// Mat A = Mat::eye(4, 4, CV_32F)*0.1; /// ``` /// - /// ## Parameters - /// * m: Another array of the same type and the same size as \*this, or a matrix expression. - /// * scale: Optional scale factor. /// - /// ## C++ default parameters - /// * scale: 1 + /// Note: In case of multi-channels type, identity matrix will be initialized only for the first channel, + /// the others will be set to 0's + /// ## Parameters + /// * rows: Number of rows. + /// * cols: Number of columns. + /// * type: Created matrix type. #[inline] - fn mul(&self, m: &impl ToInputArray, scale: f64) -> Result { - input_array_arg!(m); + #[must_use] + pub fn eye(rows: i32, cols: i32, typ: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_mul_const_const__InputArrayR_double(self.as_raw_Mat(), m.as_raw__InputArray(), scale, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_eye_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; Ok(ret) } - /// Performs an element-wise multiplication or division of the two matrices. - /// - /// The method returns a temporary object encoding per-element array multiplication, with optional - /// scale. Note that this is not a matrix multiplication that corresponds to a simpler "\*" operator. + /// Returns an identity matrix of the specified size and type. /// - /// Example: + /// The method returns a Matlab-style identity matrix initializer, similarly to Mat::zeros. Similarly to + /// Mat::ones, you can use a scale operation to create a scaled identity matrix efficiently: /// ```C++ - /// Mat C = A.mul(5/B); // equivalent to divide(A, B, C, 5) + /// // make a 4x4 diagonal matrix with 0.1's on the diagonal. + /// Mat A = Mat::eye(4, 4, CV_32F)*0.1; /// ``` /// + /// + /// Note: In case of multi-channels type, identity matrix will be initialized only for the first channel, + /// the others will be set to 0's /// ## Parameters - /// * m: Another array of the same type and the same size as \*this, or a matrix expression. - /// * scale: Optional scale factor. + /// * rows: Number of rows. + /// * cols: Number of columns. + /// * type: Created matrix type. /// - /// ## Note - /// This alternative version of [MatTraitConst::mul] function uses the following default values for its arguments: - /// * scale: 1 + /// ## Overloaded parameters + /// + /// * size: Alternative matrix size specification as Size(cols, rows) . + /// * type: Created matrix type. + #[inline] + #[must_use] + pub fn eye_size(size: core::Size, typ: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_eye_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [core::Mat] + pub trait MatTraitConst { + fn as_raw_Mat(&self) -> *const c_void; + + /// ! includes several bit-fields: + /// - the magic signature + /// - continuity flag + /// - depth + /// - number of channels + #[inline] + fn flags(&self) -> i32 { + let ret = unsafe { sys::cv_Mat_propFlags_const(self.as_raw_Mat()) }; + ret + } + + /// the matrix dimensionality, >= 2 + #[inline] + fn dims(&self) -> i32 { + let ret = unsafe { sys::cv_Mat_propDims_const(self.as_raw_Mat()) }; + ret + } + + /// the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions + #[inline] + fn rows(&self) -> i32 { + let ret = unsafe { sys::cv_Mat_propRows_const(self.as_raw_Mat()) }; + ret + } + + /// the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions + #[inline] + fn cols(&self) -> i32 { + let ret = unsafe { sys::cv_Mat_propCols_const(self.as_raw_Mat()) }; + ret + } + + /// pointer to the data + #[inline] + fn data(&self) -> *const u8 { + let ret = unsafe { sys::cv_Mat_propData_const(self.as_raw_Mat()) }; + ret + } + + /// helper fields used in locateROI and adjustROI + #[inline] + fn datastart(&self) -> *const u8 { + let ret = unsafe { sys::cv_Mat_propDatastart_const(self.as_raw_Mat()) }; + ret + } + + #[inline] + fn dataend(&self) -> *const u8 { + let ret = unsafe { sys::cv_Mat_propDataend_const(self.as_raw_Mat()) }; + ret + } + + #[inline] + fn datalimit(&self) -> *const u8 { + let ret = unsafe { sys::cv_Mat_propDatalimit_const(self.as_raw_Mat()) }; + ret + } + + #[inline] + fn mat_size(&self) -> core::MatSize { + let ret = unsafe { sys::cv_Mat_propSize_const(self.as_raw_Mat()) }; + let ret = unsafe { core::MatSize::opencv_from_extern(ret) }; + ret + } + #[inline] - fn mul_def(&self, m: &impl ToInputArray) -> Result { - input_array_arg!(m); - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_mul_const_const__InputArrayR(self.as_raw_Mat(), m.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; - Ok(ret) + fn mat_step(&self) -> core::MatStep { + let ret = unsafe { sys::cv_Mat_propStep_const(self.as_raw_Mat()) }; + let ret = unsafe { core::MatStep::opencv_from_extern(ret) }; + ret } - /// Computes a cross-product of two 3-element vectors. + /// retrieve UMat from Mat /// - /// The method computes a cross-product of two 3-element vectors. The vectors must be 3-element - /// floating-point vectors of the same shape and size. The result is another 3-element vector of the - /// same shape and type as operands. - /// ## Parameters - /// * m: Another cross-product operand. + /// ## C++ default parameters + /// * usage_flags: USAGE_DEFAULT #[inline] - fn cross(&self, m: &impl ToInputArray) -> Result { - input_array_arg!(m); + fn get_umat(&self, access_flags: core::AccessFlag, usage_flags: core::UMatUsageFlags) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_cross_const_const__InputArrayR(self.as_raw_Mat(), m.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_getUMat_const_AccessFlag_UMatUsageFlags(self.as_raw_Mat(), access_flags, usage_flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// Computes a dot-product of two vectors. + /// retrieve UMat from Mat /// - /// The method computes a dot-product of two matrices. If the matrices are not single-column or - /// single-row vectors, the top-to-bottom left-to-right scan ordering is used to treat them as 1D - /// vectors. The vectors must have the same size and type. If the matrices have more than one channel, - /// the dot products from all the channels are summed together. - /// ## Parameters - /// * m: another dot-product operand. + /// ## Note + /// This alternative version of [MatTraitConst::get_umat] function uses the following default values for its arguments: + /// * usage_flags: USAGE_DEFAULT #[inline] - fn dot(&self, m: &impl ToInputArray) -> Result { - input_array_arg!(m); + fn get_umat_def(&self, access_flags: core::AccessFlag) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_dot_const_const__InputArrayR(self.as_raw_Mat(), m.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_getUMat_const_AccessFlag(self.as_raw_Mat(), access_flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// Locates the matrix header within a parent matrix. + /// Creates a matrix header for the specified matrix row. + /// + /// The method makes a new header for the specified matrix row and returns it. This is an O(1) + /// operation, regardless of the matrix size. The underlying data of the new matrix is shared with the + /// original matrix. Here is the example of one of the classical basic matrix processing operations, + /// axpy, used by LU and many other algorithms: + /// ```C++ + /// inline void matrix_axpy(Mat& A, int i, int j, double alpha) + /// { + /// A.row(i) += A.row(j)*alpha; + /// } + /// ``` + /// + /// + /// Note: In the current implementation, the following code does not work as expected: + /// ```C++ + /// Mat A; + /// ... + /// A.row(i) = A.row(j); // will not work + /// ``` + /// + /// This happens because A.row(i) forms a temporary header that is further assigned to another header. + /// Remember that each of these operations is O(1), that is, no data is copied. Thus, the above + /// assignment is not true if you may have expected the j-th row to be copied to the i-th row. To + /// achieve that, you should either turn this simple assignment into an expression or use the + /// Mat::copyTo method: + /// ```C++ + /// Mat A; + /// ... + /// // works, but looks a bit obscure. + /// A.row(i) = A.row(j) + 0; + /// // this is a bit longer, but the recommended method. + /// A.row(j).copyTo(A.row(i)); + /// ``` /// - /// After you extracted a submatrix from a matrix using Mat::row, Mat::col, Mat::rowRange, - /// Mat::colRange, and others, the resultant submatrix points just to the part of the original big - /// matrix. However, each submatrix contains information (represented by datastart and dataend - /// fields) that helps reconstruct the original matrix size and the position of the extracted - /// submatrix within the original matrix. The method locateROI does exactly that. /// ## Parameters - /// * wholeSize: Output parameter that contains the size of the whole matrix containing *this* - /// as a part. - /// * ofs: Output parameter that contains an offset of *this* inside the whole matrix. + /// * y: A 0-based row index. #[inline] - fn locate_roi(&self, whole_size: &mut core::Size, ofs: &mut core::Point) -> Result<()> { + fn row(&self, y: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_locateROI_const_SizeR_PointR(self.as_raw_Mat(), whole_size, ofs, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_row_const_int(self.as_raw_Mat(), y, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// Extracts a rectangular submatrix. + /// Creates a matrix header for the specified matrix column. /// - /// The operators make a new header for the specified sub-array of \*this . They are the most - /// generalized forms of Mat::row, Mat::col, Mat::rowRange, and Mat::colRange . For example, - /// `A(Range(0, 10), Range::all())` is equivalent to `A.rowRange(0, 10)`. Similarly to all of the above, - /// the operators are O(1) operations, that is, no matrix data is copied. + /// The method makes a new header for the specified matrix column and returns it. This is an O(1) + /// operation, regardless of the matrix size. The underlying data of the new matrix is shared with the + /// original matrix. See also the Mat::row description. /// ## Parameters - /// * rowRange: Start and end row of the extracted submatrix. The upper boundary is not included. To - /// select all the rows, use Range::all(). - /// * colRange: Start and end column of the extracted submatrix. The upper boundary is not included. - /// To select all the columns, use Range::all(). + /// * x: A 0-based column index. #[inline] - fn rowscols(&self, mut row_range: impl core::RangeTrait, mut col_range: impl core::RangeTrait) -> Result> { + fn col(&self, x: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_operator___const_Range_Range(self.as_raw_Mat(), row_range.as_raw_mut_Range(), col_range.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_col_const_int(self.as_raw_Mat(), x, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// Extracts a rectangular submatrix. + /// Creates a matrix header for the specified row span. /// - /// The operators make a new header for the specified sub-array of \*this . They are the most - /// generalized forms of Mat::row, Mat::col, Mat::rowRange, and Mat::colRange . For example, - /// `A(Range(0, 10), Range::all())` is equivalent to `A.rowRange(0, 10)`. Similarly to all of the above, - /// the operators are O(1) operations, that is, no matrix data is copied. + /// The method makes a new header for the specified row span of the matrix. Similarly to Mat::row and + /// Mat::col , this is an O(1) operation. /// ## Parameters - /// * rowRange: Start and end row of the extracted submatrix. The upper boundary is not included. To - /// select all the rows, use Range::all(). - /// * colRange: Start and end column of the extracted submatrix. The upper boundary is not included. - /// To select all the columns, use Range::all(). - /// - /// ## Overloaded parameters - /// - /// * roi: Extracted submatrix specified as a rectangle. + /// * startrow: An inclusive 0-based start index of the row span. + /// * endrow: An exclusive 0-based ending index of the row span. #[inline] - fn roi(&self, roi: core::Rect) -> Result> { + fn row_bounds(&self, startrow: i32, endrow: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_operator___const_const_RectR(self.as_raw_Mat(), &roi, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_rowRange_const_int_int(self.as_raw_Mat(), startrow, endrow, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// Extracts a rectangular submatrix. + /// Creates a matrix header for the specified row span. /// - /// The operators make a new header for the specified sub-array of \*this . They are the most - /// generalized forms of Mat::row, Mat::col, Mat::rowRange, and Mat::colRange . For example, - /// `A(Range(0, 10), Range::all())` is equivalent to `A.rowRange(0, 10)`. Similarly to all of the above, - /// the operators are O(1) operations, that is, no matrix data is copied. + /// The method makes a new header for the specified row span of the matrix. Similarly to Mat::row and + /// Mat::col , this is an O(1) operation. /// ## Parameters - /// * rowRange: Start and end row of the extracted submatrix. The upper boundary is not included. To - /// select all the rows, use Range::all(). - /// * colRange: Start and end column of the extracted submatrix. The upper boundary is not included. - /// To select all the columns, use Range::all(). + /// * startrow: An inclusive 0-based start index of the row span. + /// * endrow: An exclusive 0-based ending index of the row span. /// /// ## Overloaded parameters /// - /// * ranges: Array of selected ranges along each array dimension. + /// * r: Range structure containing both the start and the end indices. #[inline] - fn ranges(&self, ranges: &core::Vector) -> Result> { + fn row_range(&self, r: &impl core::RangeTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_operator___const_const_vectorLRangeGR(self.as_raw_Mat(), ranges.as_raw_VectorOfRange(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_rowRange_const_const_RangeR(self.as_raw_Mat(), r.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// Reports whether the matrix is continuous or not. - /// - /// The method returns true if the matrix elements are stored continuously without gaps at the end of - /// each row. Otherwise, it returns false. Obviously, 1x1 or 1xN matrices are always continuous. - /// Matrices created with Mat::create are always continuous. But if you extract a part of the matrix - /// using Mat::col, Mat::diag, and so on, or constructed a matrix header for externally allocated data, - /// such matrices may no longer have this property. - /// - /// The continuity flag is stored as a bit in the Mat::flags field and is computed automatically when - /// you construct a matrix header. Thus, the continuity check is a very fast operation, though - /// theoretically it could be done as follows: - /// ```C++ - /// // alternative implementation of Mat::isContinuous() - /// bool myCheckMatContinuity(const Mat& m) - /// { - /// //return (m.flags & Mat::CONTINUOUS_FLAG) != 0; - /// return m.rows == 1 || m.step == m.cols*m.elemSize(); - /// } - /// ``` - /// - /// The method is used in quite a few of OpenCV functions. The point is that element-wise operations - /// (such as arithmetic and logical operations, math functions, alpha blending, color space - /// transformations, and others) do not depend on the image geometry. Thus, if all the input and output - /// arrays are continuous, the functions can process them as very long single-row vectors. The example - /// below illustrates how an alpha-blending function can be implemented: - /// ```C++ - /// template - /// void alphaBlendRGBA(const Mat& src1, const Mat& src2, Mat& dst) - /// { - /// const float alpha_scale = (float)std::numeric_limits::max(), - /// inv_scale = 1.f/alpha_scale; - /// - /// CV_Assert( src1.type() == src2.type() && - /// src1.type() == CV_MAKETYPE(traits::Depth::value, 4) && - /// src1.size() == src2.size()); - /// Size size = src1.size(); - /// dst.create(size, src1.type()); - /// - /// // here is the idiom: check the arrays for continuity and, - /// // if this is the case, - /// // treat the arrays as 1D vectors - /// if( src1.isContinuous() && src2.isContinuous() && dst.isContinuous() ) - /// { - /// size.width *= size.height; - /// size.height = 1; - /// } - /// size.width *= 4; - /// - /// for( int i = 0; i < size.height; i++ ) - /// { - /// // when the arrays are continuous, - /// // the outer loop is executed only once - /// const T* ptr1 = src1.ptr(i); - /// const T* ptr2 = src2.ptr(i); - /// T* dptr = dst.ptr(i); - /// - /// for( int j = 0; j < size.width; j += 4 ) - /// { - /// float alpha = ptr1[j+3]*inv_scale, beta = ptr2[j+3]*inv_scale; - /// dptr[j] = saturate_cast(ptr1[j]*alpha + ptr2[j]*beta); - /// dptr[j+1] = saturate_cast(ptr1[j+1]*alpha + ptr2[j+1]*beta); - /// dptr[j+2] = saturate_cast(ptr1[j+2]*alpha + ptr2[j+2]*beta); - /// dptr[j+3] = saturate_cast((1 - (1-alpha)*(1-beta))*alpha_scale); - /// } - /// } - /// } - /// ``` - /// - /// This approach, while being very simple, can boost the performance of a simple element-operation by - /// 10-20 percents, especially if the image is rather small and the operation is quite simple. - /// - /// Another OpenCV idiom in this function, a call of Mat::create for the destination array, that - /// allocates the destination array unless it already has the proper size and type. And while the newly - /// allocated arrays are always continuous, you still need to check the destination array because - /// Mat::create does not always allocate a new matrix. - #[inline] - fn is_continuous(&self) -> bool { - let ret = unsafe { sys::cv_Mat_isContinuous_const(self.as_raw_Mat()) }; - ret - } - - /// returns true if the matrix is a submatrix of another matrix - #[inline] - fn is_submatrix(&self) -> bool { - let ret = unsafe { sys::cv_Mat_isSubmatrix_const(self.as_raw_Mat()) }; - ret - } - - /// Returns the matrix element size in bytes. + /// Creates a matrix header for the specified column span. /// - /// The method returns the matrix element size in bytes. For example, if the matrix type is CV_16SC3 , - /// the method returns 3\*sizeof(short) or 6. + /// The method makes a new header for the specified column span of the matrix. Similarly to Mat::row and + /// Mat::col , this is an O(1) operation. + /// ## Parameters + /// * startcol: An inclusive 0-based start index of the column span. + /// * endcol: An exclusive 0-based ending index of the column span. #[inline] - fn elem_size(&self) -> Result { + fn col_bounds(&self, startcol: i32, endcol: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_elemSize_const(self.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_colRange_const_int_int(self.as_raw_Mat(), startcol, endcol, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// Returns the size of each matrix element channel in bytes. + /// Creates a matrix header for the specified column span. /// - /// The method returns the matrix element channel size in bytes, that is, it ignores the number of - /// channels. For example, if the matrix type is CV_16SC3 , the method returns sizeof(short) or 2. - #[inline] - fn elem_size1(&self) -> size_t { - let ret = unsafe { sys::cv_Mat_elemSize1_const(self.as_raw_Mat()) }; - ret - } - - /// Returns the type of a matrix element. + /// The method makes a new header for the specified column span of the matrix. Similarly to Mat::row and + /// Mat::col , this is an O(1) operation. + /// ## Parameters + /// * startcol: An inclusive 0-based start index of the column span. + /// * endcol: An exclusive 0-based ending index of the column span. /// - /// The method returns a matrix element type. This is an identifier compatible with the CvMat type - /// system, like CV_16SC3 or 16-bit signed 3-channel array, and so on. - #[inline] - fn typ(&self) -> i32 { - let ret = unsafe { sys::cv_Mat_type_const(self.as_raw_Mat()) }; - ret - } - - /// Returns the depth of a matrix element. + /// ## Overloaded parameters /// - /// The method returns the identifier of the matrix element depth (the type of each individual channel). - /// For example, for a 16-bit signed element array, the method returns CV_16S . A complete list of - /// matrix types contains the following values: - /// * CV_8U - 8-bit unsigned integers ( 0..255 ) - /// * CV_8S - 8-bit signed integers ( -128..127 ) - /// * CV_16U - 16-bit unsigned integers ( 0..65535 ) - /// * CV_16S - 16-bit signed integers ( -32768..32767 ) - /// * CV_32S - 32-bit signed integers ( -2147483648..2147483647 ) - /// * CV_32F - 32-bit floating-point numbers ( -FLT_MAX..FLT_MAX, INF, NAN ) - /// * CV_64F - 64-bit floating-point numbers ( -DBL_MAX..DBL_MAX, INF, NAN ) + /// * r: Range structure containing both the start and the end indices. #[inline] - fn depth(&self) -> i32 { - let ret = unsafe { sys::cv_Mat_depth_const(self.as_raw_Mat()) }; - ret + fn col_range(&self, r: &impl core::RangeTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_colRange_const_const_RangeR(self.as_raw_Mat(), r.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + Ok(ret) } - /// Returns the number of matrix channels. + /// Extracts a diagonal from a matrix /// - /// The method returns the number of matrix channels. - #[inline] - fn channels(&self) -> i32 { - let ret = unsafe { sys::cv_Mat_channels_const(self.as_raw_Mat()) }; - ret - } - - /// Returns a normalized step. + /// The method makes a new header for the specified matrix diagonal. The new matrix is represented as a + /// single-column matrix. Similarly to Mat::row and Mat::col, this is an O(1) operation. + /// ## Parameters + /// * d: index of the diagonal, with the following values: + /// - `d=0` is the main diagonal. + /// - `d<0` is a diagonal from the lower half. For example, d=-1 means the diagonal is set + /// immediately below the main one. + /// - `d>0` is a diagonal from the upper half. For example, d=1 means the diagonal is set + /// immediately above the main one. + /// For example: + /// ```C++ + /// Mat m = (Mat_(3,3) << + /// 1,2,3, + /// 4,5,6, + /// 7,8,9); + /// Mat d0 = m.diag(0); + /// Mat d1 = m.diag(1); + /// Mat d_1 = m.diag(-1); + /// ``` + /// + /// The resulting matrices are + /// ```C++ + /// d0 = + /// [1; + /// 5; + /// 9] + /// d1 = + /// [2; + /// 6] + /// d_1 = + /// [4; + /// 8] + /// ``` /// - /// The method returns a matrix step divided by Mat::elemSize1() . It can be useful to quickly access an - /// arbitrary matrix element. /// /// ## C++ default parameters - /// * i: 0 + /// * d: 0 #[inline] - fn step1(&self, i: i32) -> Result { + fn diag(&self, d: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_step1_const_int(self.as_raw_Mat(), i, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_diag_const_int(self.as_raw_Mat(), d, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// Returns a normalized step. + /// Extracts a diagonal from a matrix + /// + /// The method makes a new header for the specified matrix diagonal. The new matrix is represented as a + /// single-column matrix. Similarly to Mat::row and Mat::col, this is an O(1) operation. + /// ## Parameters + /// * d: index of the diagonal, with the following values: + /// - `d=0` is the main diagonal. + /// - `d<0` is a diagonal from the lower half. For example, d=-1 means the diagonal is set + /// immediately below the main one. + /// - `d>0` is a diagonal from the upper half. For example, d=1 means the diagonal is set + /// immediately above the main one. + /// For example: + /// ```C++ + /// Mat m = (Mat_(3,3) << + /// 1,2,3, + /// 4,5,6, + /// 7,8,9); + /// Mat d0 = m.diag(0); + /// Mat d1 = m.diag(1); + /// Mat d_1 = m.diag(-1); + /// ``` + /// + /// The resulting matrices are + /// ```C++ + /// d0 = + /// [1; + /// 5; + /// 9] + /// d1 = + /// [2; + /// 6] + /// d_1 = + /// [4; + /// 8] + /// ``` /// - /// The method returns a matrix step divided by Mat::elemSize1() . It can be useful to quickly access an - /// arbitrary matrix element. /// /// ## Note - /// This alternative version of [MatTraitConst::step1] function uses the following default values for its arguments: - /// * i: 0 + /// This alternative version of [MatTraitConst::diag] function uses the following default values for its arguments: + /// * d: 0 #[inline] - fn step1_def(&self) -> Result { + fn diag_def(&self) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_step1_const(self.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_diag_const(self.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// Returns true if the array has no elements. - /// - /// The method returns true if Mat::total() is 0 or if Mat::data is NULL. Because of pop_back() and - /// resize() methods `M.total() == 0` does not imply that `M.data == NULL`. - #[inline] - fn empty(&self) -> bool { - let ret = unsafe { sys::cv_Mat_empty_const(self.as_raw_Mat()) }; - ret - } - - /// Returns the total number of array elements. - /// - /// The method returns the number of array elements (a number of pixels if the array represents an - /// image). - #[inline] - fn total(&self) -> size_t { - let ret = unsafe { sys::cv_Mat_total_const(self.as_raw_Mat()) }; - ret - } - - /// Returns the total number of array elements. - /// - /// The method returns the number of elements within a certain sub-array slice with startDim <= dim < endDim + /// Creates a full copy of the array and the underlying data. /// - /// ## C++ default parameters - /// * end_dim: INT_MAX + /// The method creates a full copy of the array. The original step[] is not taken into account. So, the + /// array copy is a continuous array occupying total()*elemSize() bytes. #[inline] - fn total_slice(&self, start_dim: i32, end_dim: i32) -> Result { + #[must_use] + fn try_clone(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_total_const_int_int(self.as_raw_Mat(), start_dim, end_dim, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_clone_const(self.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// Returns the total number of array elements. + /// Copies the matrix to another one. /// - /// The method returns the number of elements within a certain sub-array slice with startDim <= dim < endDim + /// The method copies the matrix data to another matrix. Before copying the data, the method invokes : + /// ```C++ + /// m.create(this->size(), this->type()); + /// ``` /// - /// ## Note - /// This alternative version of [MatTraitConst::total_slice] function uses the following default values for its arguments: - /// * end_dim: INT_MAX + /// so that the destination matrix is reallocated if needed. While m.copyTo(m); works flawlessly, the + /// function does not handle the case of a partial overlap between the source and the destination + /// matrices. + /// + /// When the operation mask is specified, if the Mat::create call shown above reallocates the matrix, + /// the newly allocated matrix is initialized with all zeros before copying the data. + /// ## Parameters + /// * m: Destination matrix. If it does not have a proper size or type before the operation, it is + /// reallocated. #[inline] - fn total_slice_def(&self, start_dim: i32) -> Result { + fn copy_to(&self, m: &mut impl ToOutputArray) -> Result<()> { + output_array_arg!(m); return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_total_const_int(self.as_raw_Mat(), start_dim, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_copyTo_const_const__OutputArrayR(self.as_raw_Mat(), m.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// ## Parameters - /// * elemChannels: Number of channels or number of columns the matrix should have. - /// For a 2-D matrix, when the matrix has only 1 column, then it should have - /// elemChannels channels; When the matrix has only 1 channel, - /// then it should have elemChannels columns. - /// For a 3-D matrix, it should have only one channel. Furthermore, - /// if the number of planes is not one, then the number of rows - /// within every plane has to be 1; if the number of rows within - /// every plane is not 1, then the number of planes has to be 1. - /// * depth: The depth the matrix should have. Set it to -1 when any depth is fine. - /// * requireContinuous: Set it to true to require the matrix to be continuous - /// ## Returns - /// -1 if the requirement is not satisfied. - /// Otherwise, it returns the number of elements in the matrix. Note - /// that an element may have multiple channels. + /// Copies the matrix to another one. /// - /// The following code demonstrates its usage for a 2-d matrix: - /// [example-2d](https://github.com/opencv/opencv/blob/4.11.0/samples/cpp/tutorial_code/snippets/core_mat_checkVector.cpp#L1) + /// The method copies the matrix data to another matrix. Before copying the data, the method invokes : + /// ```C++ + /// m.create(this->size(), this->type()); + /// ``` /// - /// The following code demonstrates its usage for a 3-d matrix: - /// [example-3d](https://github.com/opencv/opencv/blob/4.11.0/samples/cpp/tutorial_code/snippets/core_mat_checkVector.cpp#L1) + /// so that the destination matrix is reallocated if needed. While m.copyTo(m); works flawlessly, the + /// function does not handle the case of a partial overlap between the source and the destination + /// matrices. /// - /// ## C++ default parameters - /// * depth: -1 - /// * require_continuous: true + /// When the operation mask is specified, if the Mat::create call shown above reallocates the matrix, + /// the newly allocated matrix is initialized with all zeros before copying the data. + /// ## Parameters + /// * m: Destination matrix. If it does not have a proper size or type before the operation, it is + /// reallocated. + /// + /// ## Overloaded parameters + /// + /// * m: Destination matrix. If it does not have a proper size or type before the operation, it is + /// reallocated. + /// * mask: Operation mask of the same size as \*this. Its non-zero elements indicate which matrix + /// elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels. #[inline] - fn check_vector(&self, elem_channels: i32, depth: i32, require_continuous: bool) -> Result { + fn copy_to_masked(&self, m: &mut impl ToOutputArray, mask: &impl ToInputArray) -> Result<()> { + output_array_arg!(m); + input_array_arg!(mask); return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_checkVector_const_int_int_bool(self.as_raw_Mat(), elem_channels, depth, require_continuous, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_copyTo_const_const__OutputArrayR_const__InputArrayR(self.as_raw_Mat(), m.as_raw__OutputArray(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// ## Parameters - /// * elemChannels: Number of channels or number of columns the matrix should have. - /// For a 2-D matrix, when the matrix has only 1 column, then it should have - /// elemChannels channels; When the matrix has only 1 channel, - /// then it should have elemChannels columns. - /// For a 3-D matrix, it should have only one channel. Furthermore, - /// if the number of planes is not one, then the number of rows - /// within every plane has to be 1; if the number of rows within - /// every plane is not 1, then the number of planes has to be 1. - /// * depth: The depth the matrix should have. Set it to -1 when any depth is fine. - /// * requireContinuous: Set it to true to require the matrix to be continuous - /// ## Returns - /// -1 if the requirement is not satisfied. - /// Otherwise, it returns the number of elements in the matrix. Note - /// that an element may have multiple channels. + /// Converts an array to another data type with optional scaling. /// - /// The following code demonstrates its usage for a 2-d matrix: - /// [example-2d](https://github.com/opencv/opencv/blob/4.11.0/samples/cpp/tutorial_code/snippets/core_mat_checkVector.cpp#L1) + /// The method converts source pixel values to the target data type. saturate_cast\<\> is applied at + /// the end to avoid possible overflows: /// - /// The following code demonstrates its usage for a 3-d matrix: - /// [example-3d](https://github.com/opencv/opencv/blob/4.11.0/samples/cpp/tutorial_code/snippets/core_mat_checkVector.cpp#L1) + /// ![block formula](https://latex.codecogs.com/png.latex?m%28x%2Cy%29%20%3D%20saturate%20%5C%5F%20cast%3CrType%3E%28%20%5Calpha%20%28%2Athis%29%28x%2Cy%29%20%2B%20%20%5Cbeta%20%29) + /// ## Parameters + /// * m: output matrix; if it does not have a proper size or type before the operation, it is + /// reallocated. + /// * rtype: desired output matrix type or, rather, the depth since the number of channels are the + /// same as the input has; if rtype is negative, the output matrix will have the same type as the input. + /// * alpha: optional scale factor. + /// * beta: optional delta added to the scaled values. /// - /// ## Note - /// This alternative version of [MatTraitConst::check_vector] function uses the following default values for its arguments: - /// * depth: -1 - /// * require_continuous: true + /// ## C++ default parameters + /// * alpha: 1 + /// * beta: 0 #[inline] - fn check_vector_def(&self, elem_channels: i32) -> Result { + fn convert_to(&self, m: &mut impl ToOutputArray, rtype: i32, alpha: f64, beta: f64) -> Result<()> { + output_array_arg!(m); return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_checkVector_const_int(self.as_raw_Mat(), elem_channels, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_convertTo_const_const__OutputArrayR_int_double_double(self.as_raw_Mat(), m.as_raw__OutputArray(), rtype, alpha, beta, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// Returns a pointer to the specified matrix row. + /// Converts an array to another data type with optional scaling. /// - /// The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in - /// Mat::isContinuous to know how to use these methods. - /// ## Parameters - /// * i0: A 0-based row index. + /// The method converts source pixel values to the target data type. saturate_cast\<\> is applied at + /// the end to avoid possible overflows: /// - /// ## Overloaded parameters + /// ![block formula](https://latex.codecogs.com/png.latex?m%28x%2Cy%29%20%3D%20saturate%20%5C%5F%20cast%3CrType%3E%28%20%5Calpha%20%28%2Athis%29%28x%2Cy%29%20%2B%20%20%5Cbeta%20%29) + /// ## Parameters + /// * m: output matrix; if it does not have a proper size or type before the operation, it is + /// reallocated. + /// * rtype: desired output matrix type or, rather, the depth since the number of channels are the + /// same as the input has; if rtype is negative, the output matrix will have the same type as the input. + /// * alpha: optional scale factor. + /// * beta: optional delta added to the scaled values. /// - /// ## C++ default parameters - /// * i0: 0 + /// ## Note + /// This alternative version of [MatTraitConst::convert_to] function uses the following default values for its arguments: + /// * alpha: 1 + /// * beta: 0 #[inline] - fn ptr(&self, i0: i32) -> Result<*const u8> { + fn convert_to_def(&self, m: &mut impl ToOutputArray, rtype: i32) -> Result<()> { + output_array_arg!(m); return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_ptr_const_int(self.as_raw_Mat(), i0, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_convertTo_const_const__OutputArrayR_int(self.as_raw_Mat(), m.as_raw__OutputArray(), rtype, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// @overload + /// Provides a functional form of convertTo. /// - /// ## Note - /// This alternative version of [MatTraitConst::ptr] function uses the following default values for its arguments: - /// * i0: 0 + /// This is an internally used method called by the [MatrixExpressions] engine. + /// ## Parameters + /// * m: Destination array. + /// * type: Desired destination array depth (or -1 if it should be the same as the source type). + /// + /// ## C++ default parameters + /// * typ: -1 #[inline] - fn ptr_def(&self) -> Result<*const u8> { + fn assign_to(&self, m: &mut impl core::MatTrait, typ: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_ptr_const(self.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_assignTo_const_MatR_int(self.as_raw_Mat(), m.as_raw_mut_Mat(), typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// Returns a pointer to the specified matrix row. + /// Provides a functional form of convertTo. /// - /// The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in - /// Mat::isContinuous to know how to use these methods. + /// This is an internally used method called by the [MatrixExpressions] engine. /// ## Parameters - /// * i0: A 0-based row index. - /// - /// ## Overloaded parameters + /// * m: Destination array. + /// * type: Desired destination array depth (or -1 if it should be the same as the source type). /// - /// * row: Index along the dimension 0 - /// * col: Index along the dimension 1 + /// ## Note + /// This alternative version of [MatTraitConst::assign_to] function uses the following default values for its arguments: + /// * typ: -1 #[inline] - fn ptr_2d(&self, row: i32, col: i32) -> Result<*const u8> { + fn assign_to_def(&self, m: &mut impl core::MatTrait) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_ptr_const_int_int(self.as_raw_Mat(), row, col, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_assignTo_const_MatR(self.as_raw_Mat(), m.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// Returns a pointer to the specified matrix row. + /// Changes the shape and/or the number of channels of a 2D matrix without copying the data. + /// + /// The method makes a new matrix header for \*this elements. The new matrix may have a different size + /// and/or different number of channels. Any combination is possible if: + /// * No extra elements are included into the new matrix and no elements are excluded. Consequently, + /// the product rows\*cols\*channels() must stay the same after the transformation. + /// * No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of + /// rows, or the operation changes the indices of elements row in some other way, the matrix must be + /// continuous. See Mat::isContinuous . + /// + /// For example, if there is a set of 3D points stored as an STL vector, and you want to represent the + /// points as a 3xN matrix, do the following: + /// ```C++ + /// std::vector vec; + /// ... + /// Mat pointMat = Mat(vec). // convert vector to Mat, O(1) operation + /// reshape(1). // make Nx3 1-channel matrix out of Nx1 3-channel. + /// // Also, an O(1) operation + /// t(); // finally, transpose the Nx3 matrix. + /// // This involves copying all the elements + /// ``` + /// + /// 3-channel 2x2 matrix reshaped to 1-channel 4x3 matrix, each column has values from one of original channels: + /// ```C++ + /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); + /// vector new_shape {4, 3}; + /// m = m.reshape(1, new_shape); + /// ``` + /// + /// or: + /// ```C++ + /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); + /// const int new_shape[] = {4, 3}; + /// m = m.reshape(1, 2, new_shape); + /// ``` /// - /// The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in - /// Mat::isContinuous to know how to use these methods. /// ## Parameters - /// * i0: A 0-based row index. + /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. + /// * rows: New number of rows. If the parameter is 0, the number of rows remains the same. /// - /// ## Overloaded parameters + /// ## C++ default parameters + /// * rows: 0 #[inline] - fn ptr_3d(&self, i0: i32, i1: i32, i2: i32) -> Result<*const u8> { + fn reshape(&self, cn: i32, rows: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_ptr_const_int_int_int(self.as_raw_Mat(), i0, i1, i2, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_reshape_const_int_int(self.as_raw_Mat(), cn, rows, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// Returns a pointer to the specified matrix row. + /// Changes the shape and/or the number of channels of a 2D matrix without copying the data. + /// + /// The method makes a new matrix header for \*this elements. The new matrix may have a different size + /// and/or different number of channels. Any combination is possible if: + /// * No extra elements are included into the new matrix and no elements are excluded. Consequently, + /// the product rows\*cols\*channels() must stay the same after the transformation. + /// * No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of + /// rows, or the operation changes the indices of elements row in some other way, the matrix must be + /// continuous. See Mat::isContinuous . + /// + /// For example, if there is a set of 3D points stored as an STL vector, and you want to represent the + /// points as a 3xN matrix, do the following: + /// ```C++ + /// std::vector vec; + /// ... + /// Mat pointMat = Mat(vec). // convert vector to Mat, O(1) operation + /// reshape(1). // make Nx3 1-channel matrix out of Nx1 3-channel. + /// // Also, an O(1) operation + /// t(); // finally, transpose the Nx3 matrix. + /// // This involves copying all the elements + /// ``` + /// + /// 3-channel 2x2 matrix reshaped to 1-channel 4x3 matrix, each column has values from one of original channels: + /// ```C++ + /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); + /// vector new_shape {4, 3}; + /// m = m.reshape(1, new_shape); + /// ``` + /// + /// or: + /// ```C++ + /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); + /// const int new_shape[] = {4, 3}; + /// m = m.reshape(1, 2, new_shape); + /// ``` /// - /// The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in - /// Mat::isContinuous to know how to use these methods. /// ## Parameters - /// * i0: A 0-based row index. + /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. + /// * rows: New number of rows. If the parameter is 0, the number of rows remains the same. /// - /// ## Overloaded parameters + /// ## Note + /// This alternative version of [MatTraitConst::reshape] function uses the following default values for its arguments: + /// * rows: 0 #[inline] - fn ptr_nd(&self, idx: &[i32]) -> Result<*const u8> { + fn reshape_def(&self, cn: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_ptr_const_const_intX(self.as_raw_Mat(), idx.as_ptr(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_reshape_const_int(self.as_raw_Mat(), cn, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// Returns a reference to the specified array element. - /// - /// The template methods return a reference to the specified array element. For the sake of higher - /// performance, the index range checks are only performed in the Debug configuration. + /// Changes the shape and/or the number of channels of a 2D matrix without copying the data. /// - /// Note that the variants with a single index (i) can be used to access elements of single-row or - /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and - /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` - /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. + /// The method makes a new matrix header for \*this elements. The new matrix may have a different size + /// and/or different number of channels. Any combination is possible if: + /// * No extra elements are included into the new matrix and no elements are excluded. Consequently, + /// the product rows\*cols\*channels() must stay the same after the transformation. + /// * No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of + /// rows, or the operation changes the indices of elements row in some other way, the matrix must be + /// continuous. See Mat::isContinuous . /// - /// The example below initializes a Hilbert matrix: + /// For example, if there is a set of 3D points stored as an STL vector, and you want to represent the + /// points as a 3xN matrix, do the following: /// ```C++ - /// Mat H(100, 100, CV_64F); - /// for(int i = 0; i < H.rows; i++) - /// for(int j = 0; j < H.cols; j++) - /// H.at(i,j)=1./(i+j+1); + /// std::vector vec; + /// ... + /// Mat pointMat = Mat(vec). // convert vector to Mat, O(1) operation + /// reshape(1). // make Nx3 1-channel matrix out of Nx1 3-channel. + /// // Also, an O(1) operation + /// t(); // finally, transpose the Nx3 matrix. + /// // This involves copying all the elements /// ``` /// + /// 3-channel 2x2 matrix reshaped to 1-channel 4x3 matrix, each column has values from one of original channels: + /// ```C++ + /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); + /// vector new_shape {4, 3}; + /// m = m.reshape(1, new_shape); + /// ``` /// - /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends - /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: - /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. + /// or: + /// ```C++ + /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); + /// const int new_shape[] = {4, 3}; + /// m = m.reshape(1, 2, new_shape); + /// ``` /// /// ## Parameters - /// * i0: Index along the dimension 0 + /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. + /// * rows: New number of rows. If the parameter is 0, the number of rows remains the same. /// /// ## Overloaded parameters /// - /// * i0: Index along the dimension 0 - /// - /// ## C++ default parameters - /// * i0: 0 + /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. + /// * newndims: New number of dimentions. + /// * newsz: Array with new matrix size by all dimentions. If some sizes are zero, + /// the original sizes in those dimensions are presumed. #[inline] - fn at(&self, i0: i32) -> Result<&T> { - core::mat_forward::at(self, i0) + fn reshape_nd(&self, cn: i32, newsz: &[i32]) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_reshape_const_int_int_const_intX(self.as_raw_Mat(), cn, newsz.len().try_into()?, newsz.as_ptr(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + Ok(ret) } - /// Returns a reference to the specified array element. - /// - /// The template methods return a reference to the specified array element. For the sake of higher - /// performance, the index range checks are only performed in the Debug configuration. + /// Changes the shape and/or the number of channels of a 2D matrix without copying the data. /// - /// Note that the variants with a single index (i) can be used to access elements of single-row or - /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and - /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` - /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. + /// The method makes a new matrix header for \*this elements. The new matrix may have a different size + /// and/or different number of channels. Any combination is possible if: + /// * No extra elements are included into the new matrix and no elements are excluded. Consequently, + /// the product rows\*cols\*channels() must stay the same after the transformation. + /// * No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of + /// rows, or the operation changes the indices of elements row in some other way, the matrix must be + /// continuous. See Mat::isContinuous . /// - /// The example below initializes a Hilbert matrix: + /// For example, if there is a set of 3D points stored as an STL vector, and you want to represent the + /// points as a 3xN matrix, do the following: /// ```C++ - /// Mat H(100, 100, CV_64F); - /// for(int i = 0; i < H.rows; i++) - /// for(int j = 0; j < H.cols; j++) - /// H.at(i,j)=1./(i+j+1); + /// std::vector vec; + /// ... + /// Mat pointMat = Mat(vec). // convert vector to Mat, O(1) operation + /// reshape(1). // make Nx3 1-channel matrix out of Nx1 3-channel. + /// // Also, an O(1) operation + /// t(); // finally, transpose the Nx3 matrix. + /// // This involves copying all the elements /// ``` /// + /// 3-channel 2x2 matrix reshaped to 1-channel 4x3 matrix, each column has values from one of original channels: + /// ```C++ + /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); + /// vector new_shape {4, 3}; + /// m = m.reshape(1, new_shape); + /// ``` /// - /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends - /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: - /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. + /// or: + /// ```C++ + /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); + /// const int new_shape[] = {4, 3}; + /// m = m.reshape(1, 2, new_shape); + /// ``` /// /// ## Parameters - /// * i0: Index along the dimension 0 + /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. + /// * rows: New number of rows. If the parameter is 0, the number of rows remains the same. /// /// ## Overloaded parameters /// - /// * i0: Index along the dimension 0 - /// - /// ## Note - /// This alternative version of [MatTraitConst::at] function uses the following default values for its arguments: - /// * i0: 0 + /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. + /// * newshape: Vector with new matrix size by all dimentions. If some sizes are zero, + /// the original sizes in those dimensions are presumed. #[inline] - fn at_def(&self) -> Result<&T> { - core::mat_forward::at_def(self, ) + fn reshape_nd_vec(&self, cn: i32, newshape: &core::Vector) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_reshape_const_int_const_vectorLintGR(self.as_raw_Mat(), cn, newshape.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + Ok(ret) } - /// Returns a reference to the specified array element. - /// - /// The template methods return a reference to the specified array element. For the sake of higher - /// performance, the index range checks are only performed in the Debug configuration. - /// - /// Note that the variants with a single index (i) can be used to access elements of single-row or - /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and - /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` - /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. + /// Transposes a matrix. /// - /// The example below initializes a Hilbert matrix: + /// The method performs matrix transposition by means of matrix expressions. It does not perform the + /// actual transposition but returns a temporary matrix transposition object that can be further used as + /// a part of more complex matrix expressions or can be assigned to a matrix: /// ```C++ - /// Mat H(100, 100, CV_64F); - /// for(int i = 0; i < H.rows; i++) - /// for(int j = 0; j < H.cols; j++) - /// H.at(i,j)=1./(i+j+1); + /// Mat A1 = A + Mat::eye(A.size(), A.type())*lambda; + /// Mat C = A1.t()*A1; // compute (A + lambda*I)^t * (A + lamda*I) /// ``` /// + #[inline] + fn t(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_t_const(self.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Inverses a matrix. /// - /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends - /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: - /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. - /// + /// The method performs a matrix inversion by means of matrix expressions. This means that a temporary + /// matrix inversion object is returned by the method and can be used further as a part of more complex + /// matrix expressions or can be assigned to a matrix. /// ## Parameters - /// * i0: Index along the dimension 0 - /// - /// ## Overloaded parameters + /// * method: Matrix inversion method. One of cv::DecompTypes /// - /// * row: Index along the dimension 0 - /// * col: Index along the dimension 1 + /// ## C++ default parameters + /// * method: DECOMP_LU #[inline] - fn at_2d(&self, row: i32, col: i32) -> Result<&T> { - core::mat_forward::at_2d(self, row, col) + fn inv(&self, method: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_inv_const_int(self.as_raw_Mat(), method, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; + Ok(ret) } - /// Returns a reference to the specified array element. - /// - /// The template methods return a reference to the specified array element. For the sake of higher - /// performance, the index range checks are only performed in the Debug configuration. - /// - /// Note that the variants with a single index (i) can be used to access elements of single-row or - /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and - /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` - /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. - /// - /// The example below initializes a Hilbert matrix: - /// ```C++ - /// Mat H(100, 100, CV_64F); - /// for(int i = 0; i < H.rows; i++) - /// for(int j = 0; j < H.cols; j++) - /// H.at(i,j)=1./(i+j+1); - /// ``` - /// - /// - /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends - /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: - /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. + /// Inverses a matrix. /// + /// The method performs a matrix inversion by means of matrix expressions. This means that a temporary + /// matrix inversion object is returned by the method and can be used further as a part of more complex + /// matrix expressions or can be assigned to a matrix. /// ## Parameters - /// * i0: Index along the dimension 0 - /// - /// ## Overloaded parameters + /// * method: Matrix inversion method. One of cv::DecompTypes /// - /// * i0: Index along the dimension 0 - /// * i1: Index along the dimension 1 - /// * i2: Index along the dimension 2 + /// ## Note + /// This alternative version of [MatTraitConst::inv] function uses the following default values for its arguments: + /// * method: DECOMP_LU #[inline] - fn at_3d(&self, i0: i32, i1: i32, i2: i32) -> Result<&T> { - core::mat_forward::at_3d(self, i0, i1, i2) + fn inv_def(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_inv_const(self.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; + Ok(ret) } - /// Returns a reference to the specified array element. - /// - /// The template methods return a reference to the specified array element. For the sake of higher - /// performance, the index range checks are only performed in the Debug configuration. + /// Performs an element-wise multiplication or division of the two matrices. /// - /// Note that the variants with a single index (i) can be used to access elements of single-row or - /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and - /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` - /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. + /// The method returns a temporary object encoding per-element array multiplication, with optional + /// scale. Note that this is not a matrix multiplication that corresponds to a simpler "\*" operator. /// - /// The example below initializes a Hilbert matrix: + /// Example: /// ```C++ - /// Mat H(100, 100, CV_64F); - /// for(int i = 0; i < H.rows; i++) - /// for(int j = 0; j < H.cols; j++) - /// H.at(i,j)=1./(i+j+1); + /// Mat C = A.mul(5/B); // equivalent to divide(A, B, C, 5) /// ``` /// - /// - /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends - /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: - /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. - /// /// ## Parameters - /// * i0: Index along the dimension 0 - /// - /// ## Overloaded parameters + /// * m: Another array of the same type and the same size as \*this, or a matrix expression. + /// * scale: Optional scale factor. /// - /// * idx: Array of Mat::dims indices. + /// ## C++ default parameters + /// * scale: 1 #[inline] - fn at_nd(&self, idx: &[i32]) -> Result<&T> { - core::mat_forward::at_nd(self, idx) + fn mul(&self, m: &impl ToInputArray, scale: f64) -> Result { + input_array_arg!(m); + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_mul_const_const__InputArrayR_double(self.as_raw_Mat(), m.as_raw__InputArray(), scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; + Ok(ret) } - /// Returns a reference to the specified array element. - /// - /// The template methods return a reference to the specified array element. For the sake of higher - /// performance, the index range checks are only performed in the Debug configuration. + /// Performs an element-wise multiplication or division of the two matrices. /// - /// Note that the variants with a single index (i) can be used to access elements of single-row or - /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and - /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` - /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. + /// The method returns a temporary object encoding per-element array multiplication, with optional + /// scale. Note that this is not a matrix multiplication that corresponds to a simpler "\*" operator. /// - /// The example below initializes a Hilbert matrix: + /// Example: /// ```C++ - /// Mat H(100, 100, CV_64F); - /// for(int i = 0; i < H.rows; i++) - /// for(int j = 0; j < H.cols; j++) - /// H.at(i,j)=1./(i+j+1); + /// Mat C = A.mul(5/B); // equivalent to divide(A, B, C, 5) /// ``` /// - /// - /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends - /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: - /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. - /// /// ## Parameters - /// * i0: Index along the dimension 0 - /// - /// ## Overloaded parameters + /// * m: Another array of the same type and the same size as \*this, or a matrix expression. + /// * scale: Optional scale factor. /// - /// special versions for 2D arrays (especially convenient for referencing image pixels) - /// * pt: Element position specified as Point(j,i) . + /// ## Note + /// This alternative version of [MatTraitConst::mul] function uses the following default values for its arguments: + /// * scale: 1 #[inline] - fn at_pt(&self, pt: core::Point) -> Result<&T> { - core::mat_forward::at_pt(self, pt) + fn mul_def(&self, m: &impl ToInputArray) -> Result { + input_array_arg!(m); + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_mul_const_const__InputArrayR(self.as_raw_Mat(), m.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; + Ok(ret) } + /// Computes a cross-product of two 3-element vectors. + /// + /// The method computes a cross-product of two 3-element vectors. The vectors must be 3-element + /// floating-point vectors of the same shape and size. The result is another 3-element vector of the + /// same shape and type as operands. + /// ## Parameters + /// * m: Another cross-product operand. #[inline] - fn size(&self) -> Result { + fn cross(&self, m: &impl ToInputArray) -> Result { + input_array_arg!(m); return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_size_const(self.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_cross_const_const__InputArrayR(self.as_raw_Mat(), m.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// Return the dump of the Mat's data + /// Computes a dot-product of two vectors. + /// + /// The method computes a dot-product of two matrices. If the matrices are not single-column or + /// single-row vectors, the top-to-bottom left-to-right scan ordering is used to treat them as 1D + /// vectors. The vectors must have the same size and type. If the matrices have more than one channel, + /// the dot products from all the channels are summed together. + /// ## Parameters + /// * m: another dot-product operand. #[inline] - fn get_data_dump(&self) -> Result { + fn dot(&self, m: &impl ToInputArray) -> Result { + input_array_arg!(m); return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_getDataDump_const(self.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_dot_const_const__InputArrayR(self.as_raw_Mat(), m.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { String::opencv_from_extern(ret) }; Ok(ret) } - } + /// Locates the matrix header within a parent matrix. + /// + /// After you extracted a submatrix from a matrix using Mat::row, Mat::col, Mat::rowRange, + /// Mat::colRange, and others, the resultant submatrix points just to the part of the original big + /// matrix. However, each submatrix contains information (represented by datastart and dataend + /// fields) that helps reconstruct the original matrix size and the position of the extracted + /// submatrix within the original matrix. The method locateROI does exactly that. + /// ## Parameters + /// * wholeSize: Output parameter that contains the size of the whole matrix containing *this* + /// as a part. + /// * ofs: Output parameter that contains an offset of *this* inside the whole matrix. + #[inline] + fn locate_roi(&self, whole_size: &mut core::Size, ofs: &mut core::Point) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_locateROI_const_SizeR_PointR(self.as_raw_Mat(), whole_size, ofs, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - /// Mutable methods for [core::Mat] - pub trait MatTrait: core::MatTraitConst { - fn as_raw_mut_Mat(&mut self) -> *mut c_void; + /// Extracts a rectangular submatrix. + /// + /// The operators make a new header for the specified sub-array of \*this . They are the most + /// generalized forms of Mat::row, Mat::col, Mat::rowRange, and Mat::colRange . For example, + /// `A(Range(0, 10), Range::all())` is equivalent to `A.rowRange(0, 10)`. Similarly to all of the above, + /// the operators are O(1) operations, that is, no matrix data is copied. + /// ## Parameters + /// * rowRange: Start and end row of the extracted submatrix. The upper boundary is not included. To + /// select all the rows, use Range::all(). + /// * colRange: Start and end column of the extracted submatrix. The upper boundary is not included. + /// To select all the columns, use Range::all(). + #[inline] + fn rowscols(&self, mut row_range: impl core::RangeTrait, mut col_range: impl core::RangeTrait) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_operator___const_Range_Range(self.as_raw_Mat(), row_range.as_raw_mut_Range(), col_range.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + Ok(ret) + } - /// ! includes several bit-fields: - /// - the magic signature - /// - continuity flag - /// - depth - /// - number of channels + /// Extracts a rectangular submatrix. + /// + /// The operators make a new header for the specified sub-array of \*this . They are the most + /// generalized forms of Mat::row, Mat::col, Mat::rowRange, and Mat::colRange . For example, + /// `A(Range(0, 10), Range::all())` is equivalent to `A.rowRange(0, 10)`. Similarly to all of the above, + /// the operators are O(1) operations, that is, no matrix data is copied. + /// ## Parameters + /// * rowRange: Start and end row of the extracted submatrix. The upper boundary is not included. To + /// select all the rows, use Range::all(). + /// * colRange: Start and end column of the extracted submatrix. The upper boundary is not included. + /// To select all the columns, use Range::all(). + /// + /// ## Overloaded parameters + /// + /// * roi: Extracted submatrix specified as a rectangle. #[inline] - fn set_flags(&mut self, val: i32) { - let ret = unsafe { sys::cv_Mat_propFlags_const_int(self.as_raw_mut_Mat(), val) }; - ret + fn roi(&self, roi: core::Rect) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_operator___const_const_RectR(self.as_raw_Mat(), &roi, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + Ok(ret) } - /// the matrix dimensionality, >= 2 + /// Extracts a rectangular submatrix. + /// + /// The operators make a new header for the specified sub-array of \*this . They are the most + /// generalized forms of Mat::row, Mat::col, Mat::rowRange, and Mat::colRange . For example, + /// `A(Range(0, 10), Range::all())` is equivalent to `A.rowRange(0, 10)`. Similarly to all of the above, + /// the operators are O(1) operations, that is, no matrix data is copied. + /// ## Parameters + /// * rowRange: Start and end row of the extracted submatrix. The upper boundary is not included. To + /// select all the rows, use Range::all(). + /// * colRange: Start and end column of the extracted submatrix. The upper boundary is not included. + /// To select all the columns, use Range::all(). + /// + /// ## Overloaded parameters + /// + /// * ranges: Array of selected ranges along each array dimension. #[inline] - fn set_dims(&mut self, val: i32) { - let ret = unsafe { sys::cv_Mat_propDims_const_int(self.as_raw_mut_Mat(), val) }; - ret + fn ranges(&self, ranges: &core::Vector) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_operator___const_const_vectorLRangeGR(self.as_raw_Mat(), ranges.as_raw_VectorOfRange(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + Ok(ret) } - /// the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions + /// Reports whether the matrix is continuous or not. + /// + /// The method returns true if the matrix elements are stored continuously without gaps at the end of + /// each row. Otherwise, it returns false. Obviously, 1x1 or 1xN matrices are always continuous. + /// Matrices created with Mat::create are always continuous. But if you extract a part of the matrix + /// using Mat::col, Mat::diag, and so on, or constructed a matrix header for externally allocated data, + /// such matrices may no longer have this property. + /// + /// The continuity flag is stored as a bit in the Mat::flags field and is computed automatically when + /// you construct a matrix header. Thus, the continuity check is a very fast operation, though + /// theoretically it could be done as follows: + /// ```C++ + /// // alternative implementation of Mat::isContinuous() + /// bool myCheckMatContinuity(const Mat& m) + /// { + /// //return (m.flags & Mat::CONTINUOUS_FLAG) != 0; + /// return m.rows == 1 || m.step == m.cols*m.elemSize(); + /// } + /// ``` + /// + /// The method is used in quite a few of OpenCV functions. The point is that element-wise operations + /// (such as arithmetic and logical operations, math functions, alpha blending, color space + /// transformations, and others) do not depend on the image geometry. Thus, if all the input and output + /// arrays are continuous, the functions can process them as very long single-row vectors. The example + /// below illustrates how an alpha-blending function can be implemented: + /// ```C++ + /// template + /// void alphaBlendRGBA(const Mat& src1, const Mat& src2, Mat& dst) + /// { + /// const float alpha_scale = (float)std::numeric_limits::max(), + /// inv_scale = 1.f/alpha_scale; + /// + /// CV_Assert( src1.type() == src2.type() && + /// src1.type() == CV_MAKETYPE(traits::Depth::value, 4) && + /// src1.size() == src2.size()); + /// Size size = src1.size(); + /// dst.create(size, src1.type()); + /// + /// // here is the idiom: check the arrays for continuity and, + /// // if this is the case, + /// // treat the arrays as 1D vectors + /// if( src1.isContinuous() && src2.isContinuous() && dst.isContinuous() ) + /// { + /// size.width *= size.height; + /// size.height = 1; + /// } + /// size.width *= 4; + /// + /// for( int i = 0; i < size.height; i++ ) + /// { + /// // when the arrays are continuous, + /// // the outer loop is executed only once + /// const T* ptr1 = src1.ptr(i); + /// const T* ptr2 = src2.ptr(i); + /// T* dptr = dst.ptr(i); + /// + /// for( int j = 0; j < size.width; j += 4 ) + /// { + /// float alpha = ptr1[j+3]*inv_scale, beta = ptr2[j+3]*inv_scale; + /// dptr[j] = saturate_cast(ptr1[j]*alpha + ptr2[j]*beta); + /// dptr[j+1] = saturate_cast(ptr1[j+1]*alpha + ptr2[j+1]*beta); + /// dptr[j+2] = saturate_cast(ptr1[j+2]*alpha + ptr2[j+2]*beta); + /// dptr[j+3] = saturate_cast((1 - (1-alpha)*(1-beta))*alpha_scale); + /// } + /// } + /// } + /// ``` + /// + /// This approach, while being very simple, can boost the performance of a simple element-operation by + /// 10-20 percents, especially if the image is rather small and the operation is quite simple. + /// + /// Another OpenCV idiom in this function, a call of Mat::create for the destination array, that + /// allocates the destination array unless it already has the proper size and type. And while the newly + /// allocated arrays are always continuous, you still need to check the destination array because + /// Mat::create does not always allocate a new matrix. #[inline] - fn set_rows(&mut self, val: i32) { - let ret = unsafe { sys::cv_Mat_propRows_const_int(self.as_raw_mut_Mat(), val) }; + fn is_continuous(&self) -> bool { + let ret = unsafe { sys::cv_Mat_isContinuous_const(self.as_raw_Mat()) }; ret } - /// the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions + /// returns true if the matrix is a submatrix of another matrix #[inline] - fn set_cols(&mut self, val: i32) { - let ret = unsafe { sys::cv_Mat_propCols_const_int(self.as_raw_mut_Mat(), val) }; + fn is_submatrix(&self) -> bool { + let ret = unsafe { sys::cv_Mat_isSubmatrix_const(self.as_raw_Mat()) }; ret } - /// pointer to the data + /// Returns the matrix element size in bytes. + /// + /// The method returns the matrix element size in bytes. For example, if the matrix type is CV_16SC3 , + /// the method returns 3\*sizeof(short) or 6. #[inline] - fn data_mut(&mut self) -> *mut u8 { - let ret = unsafe { sys::cv_Mat_propData(self.as_raw_mut_Mat()) }; - ret + fn elem_size(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_elemSize_const(self.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } - /// pointer to the data + /// Returns the size of each matrix element channel in bytes. + /// + /// The method returns the matrix element channel size in bytes, that is, it ignores the number of + /// channels. For example, if the matrix type is CV_16SC3 , the method returns sizeof(short) or 2. #[inline] - unsafe fn set_data(&mut self, val: *const u8) { - let ret = { sys::cv_Mat_propData_unsigned_charX(self.as_raw_mut_Mat(), val) }; + fn elem_size1(&self) -> size_t { + let ret = unsafe { sys::cv_Mat_elemSize1_const(self.as_raw_Mat()) }; ret } - /// interaction with UMat + /// Returns the type of a matrix element. + /// + /// The method returns a matrix element type. This is an identifier compatible with the CvMat type + /// system, like CV_16SC3 or 16-bit signed 3-channel array, and so on. #[inline] - fn u(&mut self) -> core::UMatData { - let ret = unsafe { sys::cv_Mat_propU(self.as_raw_mut_Mat()) }; - let ret = unsafe { core::UMatData::opencv_from_extern(ret) }; + fn typ(&self) -> i32 { + let ret = unsafe { sys::cv_Mat_type_const(self.as_raw_Mat()) }; ret } - /// interaction with UMat + /// Returns the depth of a matrix element. + /// + /// The method returns the identifier of the matrix element depth (the type of each individual channel). + /// For example, for a 16-bit signed element array, the method returns CV_16S . A complete list of + /// matrix types contains the following values: + /// * CV_8U - 8-bit unsigned integers ( 0..255 ) + /// * CV_8S - 8-bit signed integers ( -128..127 ) + /// * CV_16U - 16-bit unsigned integers ( 0..65535 ) + /// * CV_16S - 16-bit signed integers ( -32768..32767 ) + /// * CV_32S - 32-bit signed integers ( -2147483648..2147483647 ) + /// * CV_32F - 32-bit floating-point numbers ( -FLT_MAX..FLT_MAX, INF, NAN ) + /// * CV_64F - 64-bit floating-point numbers ( -DBL_MAX..DBL_MAX, INF, NAN ) #[inline] - fn set_u(&mut self, val: &impl core::UMatDataTraitConst) { - let ret = unsafe { sys::cv_Mat_propU_UMatDataX(self.as_raw_mut_Mat(), val.as_raw_UMatData()) }; + fn depth(&self) -> i32 { + let ret = unsafe { sys::cv_Mat_depth_const(self.as_raw_Mat()) }; ret } + /// Returns the number of matrix channels. + /// + /// The method returns the number of matrix channels. #[inline] - fn set_mat_size(&mut self, val: core::MatSize) { - let ret = unsafe { sys::cv_Mat_propSize_const_MatSize(self.as_raw_mut_Mat(), val.as_raw_MatSize()) }; + fn channels(&self) -> i32 { + let ret = unsafe { sys::cv_Mat_channels_const(self.as_raw_Mat()) }; ret } - /// assignment operators - /// - /// These are available assignment operators. Since they all are very different, make sure to read the - /// operator parameters description. - /// ## Parameters - /// * m: Assigned, right-hand-side matrix. Matrix assignment is an O(1) operation. This means that - /// no data is copied but the data is shared and the reference counter, if any, is incremented. Before - /// assigning new data, the old data is de-referenced via Mat::release . + /// Returns a normalized step. /// - /// ## Overloaded parameters + /// The method returns a matrix step divided by Mat::elemSize1() . It can be useful to quickly access an + /// arbitrary matrix element. /// - /// * expr: Assigned matrix expression object. As opposite to the first form of the assignment - /// operation, the second form can reuse already allocated matrix if it has the right size and type to - /// fit the matrix expression result. It is automatically handled by the real function that the matrix - /// expressions is expanded to. For example, C=A+B is expanded to add(A, B, C), and add takes care of - /// automatic C reallocation. + /// ## C++ default parameters + /// * i: 0 #[inline] - fn set_matexpr(&mut self, expr: &impl core::MatExprTraitConst) -> Result<()> { + fn step1(&self, i: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_operatorST_const_MatExprR(self.as_raw_mut_Mat(), expr.as_raw_MatExpr(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_step1_const_int(self.as_raw_Mat(), i, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// Creates a matrix header for the specified matrix row. - /// - /// The method makes a new header for the specified matrix row and returns it. This is an O(1) - /// operation, regardless of the matrix size. The underlying data of the new matrix is shared with the - /// original matrix. Here is the example of one of the classical basic matrix processing operations, - /// axpy, used by LU and many other algorithms: - /// ```C++ - /// inline void matrix_axpy(Mat& A, int i, int j, double alpha) - /// { - /// A.row(i) += A.row(j)*alpha; - /// } - /// ``` - /// - /// - /// Note: In the current implementation, the following code does not work as expected: - /// ```C++ - /// Mat A; - /// ... - /// A.row(i) = A.row(j); // will not work - /// ``` + /// Returns a normalized step. /// - /// This happens because A.row(i) forms a temporary header that is further assigned to another header. - /// Remember that each of these operations is O(1), that is, no data is copied. Thus, the above - /// assignment is not true if you may have expected the j-th row to be copied to the i-th row. To - /// achieve that, you should either turn this simple assignment into an expression or use the - /// Mat::copyTo method: - /// ```C++ - /// Mat A; - /// ... - /// // works, but looks a bit obscure. - /// A.row(i) = A.row(j) + 0; - /// // this is a bit longer, but the recommended method. - /// A.row(j).copyTo(A.row(i)); - /// ``` + /// The method returns a matrix step divided by Mat::elemSize1() . It can be useful to quickly access an + /// arbitrary matrix element. /// - /// ## Parameters - /// * y: A 0-based row index. + /// ## Note + /// This alternative version of [MatTraitConst::step1] function uses the following default values for its arguments: + /// * i: 0 #[inline] - fn row_mut(&mut self, y: i32) -> Result> { + fn step1_def(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_row_int(self.as_raw_mut_Mat(), y, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_step1_const(self.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// Creates a matrix header for the specified matrix column. + /// Returns true if the array has no elements. /// - /// The method makes a new header for the specified matrix column and returns it. This is an O(1) - /// operation, regardless of the matrix size. The underlying data of the new matrix is shared with the - /// original matrix. See also the Mat::row description. - /// ## Parameters - /// * x: A 0-based column index. + /// The method returns true if Mat::total() is 0 or if Mat::data is NULL. Because of pop_back() and + /// resize() methods `M.total() == 0` does not imply that `M.data == NULL`. #[inline] - fn col_mut(&mut self, x: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_col_int(self.as_raw_mut_Mat(), x, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; - Ok(ret) + fn empty(&self) -> bool { + let ret = unsafe { sys::cv_Mat_empty_const(self.as_raw_Mat()) }; + ret } - /// Creates a matrix header for the specified row span. + /// Returns the total number of array elements. /// - /// The method makes a new header for the specified row span of the matrix. Similarly to Mat::row and - /// Mat::col , this is an O(1) operation. - /// ## Parameters - /// * startrow: An inclusive 0-based start index of the row span. - /// * endrow: An exclusive 0-based ending index of the row span. + /// The method returns the number of array elements (a number of pixels if the array represents an + /// image). #[inline] - fn row_bounds_mut(&mut self, startrow: i32, endrow: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_rowRange_int_int(self.as_raw_mut_Mat(), startrow, endrow, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; - Ok(ret) + fn total(&self) -> size_t { + let ret = unsafe { sys::cv_Mat_total_const(self.as_raw_Mat()) }; + ret } - /// @overload - /// ## Parameters - /// * r: Range structure containing both the start and the end indices. + /// Returns the total number of array elements. + /// + /// The method returns the number of elements within a certain sub-array slice with startDim <= dim < endDim + /// + /// ## C++ default parameters + /// * end_dim: INT_MAX #[inline] - fn row_range_mut(&mut self, r: &impl core::RangeTraitConst) -> Result> { + fn total_slice(&self, start_dim: i32, end_dim: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_rowRange_const_RangeR(self.as_raw_mut_Mat(), r.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_total_const_int_int(self.as_raw_Mat(), start_dim, end_dim, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// Creates a matrix header for the specified column span. + /// Returns the total number of array elements. /// - /// The method makes a new header for the specified column span of the matrix. Similarly to Mat::row and - /// Mat::col , this is an O(1) operation. - /// ## Parameters - /// * startcol: An inclusive 0-based start index of the column span. - /// * endcol: An exclusive 0-based ending index of the column span. + /// The method returns the number of elements within a certain sub-array slice with startDim <= dim < endDim + /// + /// ## Note + /// This alternative version of [MatTraitConst::total_slice] function uses the following default values for its arguments: + /// * end_dim: INT_MAX #[inline] - fn col_bounds_mut(&mut self, startcol: i32, endcol: i32) -> Result> { + fn total_slice_def(&self, start_dim: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_colRange_int_int(self.as_raw_mut_Mat(), startcol, endcol, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_total_const_int(self.as_raw_Mat(), start_dim, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// @overload /// ## Parameters - /// * r: Range structure containing both the start and the end indices. + /// * elemChannels: Number of channels or number of columns the matrix should have. + /// For a 2-D matrix, when the matrix has only 1 column, then it should have + /// elemChannels channels; When the matrix has only 1 channel, + /// then it should have elemChannels columns. + /// For a 3-D matrix, it should have only one channel. Furthermore, + /// if the number of planes is not one, then the number of rows + /// within every plane has to be 1; if the number of rows within + /// every plane is not 1, then the number of planes has to be 1. + /// * depth: The depth the matrix should have. Set it to -1 when any depth is fine. + /// * requireContinuous: Set it to true to require the matrix to be continuous + /// ## Returns + /// -1 if the requirement is not satisfied. + /// Otherwise, it returns the number of elements in the matrix. Note + /// that an element may have multiple channels. + /// + /// The following code demonstrates its usage for a 2-d matrix: + /// [example-2d](https://github.com/opencv/opencv/blob/4.11.0/samples/cpp/tutorial_code/snippets/core_mat_checkVector.cpp#L1) + /// + /// The following code demonstrates its usage for a 3-d matrix: + /// [example-3d](https://github.com/opencv/opencv/blob/4.11.0/samples/cpp/tutorial_code/snippets/core_mat_checkVector.cpp#L1) + /// + /// ## C++ default parameters + /// * depth: -1 + /// * require_continuous: true #[inline] - fn col_range_mut(&mut self, r: &impl core::RangeTraitConst) -> Result> { + fn check_vector(&self, elem_channels: i32, depth: i32, require_continuous: bool) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_colRange_const_RangeR(self.as_raw_mut_Mat(), r.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_checkVector_const_int_int_bool(self.as_raw_Mat(), elem_channels, depth, require_continuous, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// Extracts a diagonal from a matrix - /// - /// The method makes a new header for the specified matrix diagonal. The new matrix is represented as a - /// single-column matrix. Similarly to Mat::row and Mat::col, this is an O(1) operation. /// ## Parameters - /// * d: index of the diagonal, with the following values: - /// - `d=0` is the main diagonal. - /// - `d<0` is a diagonal from the lower half. For example, d=-1 means the diagonal is set - /// immediately below the main one. - /// - `d>0` is a diagonal from the upper half. For example, d=1 means the diagonal is set - /// immediately above the main one. - /// For example: - /// ```C++ - /// Mat m = (Mat_(3,3) << - /// 1,2,3, - /// 4,5,6, - /// 7,8,9); - /// Mat d0 = m.diag(0); - /// Mat d1 = m.diag(1); - /// Mat d_1 = m.diag(-1); - /// ``` + /// * elemChannels: Number of channels or number of columns the matrix should have. + /// For a 2-D matrix, when the matrix has only 1 column, then it should have + /// elemChannels channels; When the matrix has only 1 channel, + /// then it should have elemChannels columns. + /// For a 3-D matrix, it should have only one channel. Furthermore, + /// if the number of planes is not one, then the number of rows + /// within every plane has to be 1; if the number of rows within + /// every plane is not 1, then the number of planes has to be 1. + /// * depth: The depth the matrix should have. Set it to -1 when any depth is fine. + /// * requireContinuous: Set it to true to require the matrix to be continuous + /// ## Returns + /// -1 if the requirement is not satisfied. + /// Otherwise, it returns the number of elements in the matrix. Note + /// that an element may have multiple channels. /// - /// The resulting matrices are - /// ```C++ - /// d0 = - /// [1; - /// 5; - /// 9] - /// d1 = - /// [2; - /// 6] - /// d_1 = - /// [4; - /// 8] - /// ``` + /// The following code demonstrates its usage for a 2-d matrix: + /// [example-2d](https://github.com/opencv/opencv/blob/4.11.0/samples/cpp/tutorial_code/snippets/core_mat_checkVector.cpp#L1) /// + /// The following code demonstrates its usage for a 3-d matrix: + /// [example-3d](https://github.com/opencv/opencv/blob/4.11.0/samples/cpp/tutorial_code/snippets/core_mat_checkVector.cpp#L1) /// /// ## Note - /// This alternative version of [MatTraitConst::diag] function uses the following default values for its arguments: - /// * d: 0 + /// This alternative version of [MatTraitConst::check_vector] function uses the following default values for its arguments: + /// * depth: -1 + /// * require_continuous: true #[inline] - fn diag_def_mut(&mut self) -> Result> { + fn check_vector_def(&self, elem_channels: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_diag(self.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_checkVector_const_int(self.as_raw_Mat(), elem_channels, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// Extracts a diagonal from a matrix + /// Returns a pointer to the specified matrix row. /// - /// The method makes a new header for the specified matrix diagonal. The new matrix is represented as a - /// single-column matrix. Similarly to Mat::row and Mat::col, this is an O(1) operation. + /// The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in + /// Mat::isContinuous to know how to use these methods. /// ## Parameters - /// * d: index of the diagonal, with the following values: - /// - `d=0` is the main diagonal. - /// - `d<0` is a diagonal from the lower half. For example, d=-1 means the diagonal is set - /// immediately below the main one. - /// - `d>0` is a diagonal from the upper half. For example, d=1 means the diagonal is set - /// immediately above the main one. - /// For example: - /// ```C++ - /// Mat m = (Mat_(3,3) << - /// 1,2,3, - /// 4,5,6, - /// 7,8,9); - /// Mat d0 = m.diag(0); - /// Mat d1 = m.diag(1); - /// Mat d_1 = m.diag(-1); - /// ``` - /// - /// The resulting matrices are - /// ```C++ - /// d0 = - /// [1; - /// 5; - /// 9] - /// d1 = - /// [2; - /// 6] - /// d_1 = - /// [4; - /// 8] - /// ``` + /// * i0: A 0-based row index. /// + /// ## Overloaded parameters /// /// ## C++ default parameters - /// * d: 0 + /// * i0: 0 #[inline] - fn diag_mut(&mut self, d: i32) -> Result> { + fn ptr(&self, i0: i32) -> Result<*const u8> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_diag_int(self.as_raw_mut_Mat(), d, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_ptr_const_int(self.as_raw_Mat(), i0, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// Sets all or some of the array elements to the specified value. - /// ## Parameters - /// * s: Assigned scalar converted to the actual array type. + /// @overload + /// + /// ## Note + /// This alternative version of [MatTraitConst::ptr] function uses the following default values for its arguments: + /// * i0: 0 #[inline] - fn set_scalar(&mut self, s: core::Scalar) -> Result<()> { + fn ptr_def(&self) -> Result<*const u8> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_operatorST_const_ScalarR(self.as_raw_mut_Mat(), &s, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_ptr_const(self.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// Sets all or some of the array elements to the specified value. + /// Returns a pointer to the specified matrix row. /// - /// This is an advanced variant of the Mat::operator=(const Scalar& s) operator. + /// The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in + /// Mat::isContinuous to know how to use these methods. /// ## Parameters - /// * value: Assigned scalar converted to the actual array type. - /// * mask: Operation mask of the same size as \*this. Its non-zero elements indicate which matrix - /// elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels + /// * i0: A 0-based row index. /// - /// ## C++ default parameters - /// * mask: noArray() + /// ## Overloaded parameters + /// + /// * row: Index along the dimension 0 + /// * col: Index along the dimension 1 #[inline] - fn set_to(&mut self, value: &impl ToInputArray, mask: &impl ToInputArray) -> Result { - input_array_arg!(value); - input_array_arg!(mask); + fn ptr_2d(&self, row: i32, col: i32) -> Result<*const u8> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_setTo_const__InputArrayR_const__InputArrayR(self.as_raw_mut_Mat(), value.as_raw__InputArray(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_ptr_const_int_int(self.as_raw_Mat(), row, col, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// Sets all or some of the array elements to the specified value. + /// Returns a pointer to the specified matrix row. /// - /// This is an advanced variant of the Mat::operator=(const Scalar& s) operator. + /// The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in + /// Mat::isContinuous to know how to use these methods. /// ## Parameters - /// * value: Assigned scalar converted to the actual array type. - /// * mask: Operation mask of the same size as \*this. Its non-zero elements indicate which matrix - /// elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels + /// * i0: A 0-based row index. /// - /// ## Note - /// This alternative version of [MatTrait::set_to] function uses the following default values for its arguments: - /// * mask: noArray() + /// ## Overloaded parameters #[inline] - fn set_to_def(&mut self, value: &impl ToInputArray) -> Result { - input_array_arg!(value); + fn ptr_3d(&self, i0: i32, i1: i32, i2: i32) -> Result<*const u8> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_setTo_const__InputArrayR(self.as_raw_mut_Mat(), value.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_ptr_const_int_int_int(self.as_raw_Mat(), i0, i1, i2, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// Changes the shape and/or the number of channels of a 2D matrix without copying the data. - /// - /// The method makes a new matrix header for \*this elements. The new matrix may have a different size - /// and/or different number of channels. Any combination is possible if: - /// * No extra elements are included into the new matrix and no elements are excluded. Consequently, - /// the product rows\*cols\*channels() must stay the same after the transformation. - /// * No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of - /// rows, or the operation changes the indices of elements row in some other way, the matrix must be - /// continuous. See Mat::isContinuous . - /// - /// For example, if there is a set of 3D points stored as an STL vector, and you want to represent the - /// points as a 3xN matrix, do the following: - /// ```C++ - /// std::vector vec; - /// ... - /// Mat pointMat = Mat(vec). // convert vector to Mat, O(1) operation - /// reshape(1). // make Nx3 1-channel matrix out of Nx1 3-channel. - /// // Also, an O(1) operation - /// t(); // finally, transpose the Nx3 matrix. - /// // This involves copying all the elements - /// ``` - /// - /// 3-channel 2x2 matrix reshaped to 1-channel 4x3 matrix, each column has values from one of original channels: - /// ```C++ - /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); - /// vector new_shape {4, 3}; - /// m = m.reshape(1, new_shape); - /// ``` - /// - /// or: - /// ```C++ - /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); - /// const int new_shape[] = {4, 3}; - /// m = m.reshape(1, 2, new_shape); - /// ``` + /// Returns a pointer to the specified matrix row. /// + /// The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in + /// Mat::isContinuous to know how to use these methods. /// ## Parameters - /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. - /// * rows: New number of rows. If the parameter is 0, the number of rows remains the same. + /// * i0: A 0-based row index. /// - /// ## Note - /// This alternative version of [MatTraitConst::reshape] function uses the following default values for its arguments: - /// * rows: 0 + /// ## Overloaded parameters #[inline] - fn reshape_def_mut(&mut self, cn: i32) -> Result> { + fn ptr_nd(&self, idx: &[i32]) -> Result<*const u8> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_reshape_int(self.as_raw_mut_Mat(), cn, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_ptr_const_const_intX(self.as_raw_Mat(), idx.as_ptr(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// Changes the shape and/or the number of channels of a 2D matrix without copying the data. + /// Returns a reference to the specified array element. /// - /// The method makes a new matrix header for \*this elements. The new matrix may have a different size - /// and/or different number of channels. Any combination is possible if: - /// * No extra elements are included into the new matrix and no elements are excluded. Consequently, - /// the product rows\*cols\*channels() must stay the same after the transformation. - /// * No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of - /// rows, or the operation changes the indices of elements row in some other way, the matrix must be - /// continuous. See Mat::isContinuous . + /// The template methods return a reference to the specified array element. For the sake of higher + /// performance, the index range checks are only performed in the Debug configuration. /// - /// For example, if there is a set of 3D points stored as an STL vector, and you want to represent the - /// points as a 3xN matrix, do the following: - /// ```C++ - /// std::vector vec; - /// ... - /// Mat pointMat = Mat(vec). // convert vector to Mat, O(1) operation - /// reshape(1). // make Nx3 1-channel matrix out of Nx1 3-channel. - /// // Also, an O(1) operation - /// t(); // finally, transpose the Nx3 matrix. - /// // This involves copying all the elements - /// ``` + /// Note that the variants with a single index (i) can be used to access elements of single-row or + /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and + /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` + /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. /// - /// 3-channel 2x2 matrix reshaped to 1-channel 4x3 matrix, each column has values from one of original channels: + /// The example below initializes a Hilbert matrix: /// ```C++ - /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); - /// vector new_shape {4, 3}; - /// m = m.reshape(1, new_shape); + /// Mat H(100, 100, CV_64F); + /// for(int i = 0; i < H.rows; i++) + /// for(int j = 0; j < H.cols; j++) + /// H.at(i,j)=1./(i+j+1); /// ``` /// - /// or: - /// ```C++ - /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); - /// const int new_shape[] = {4, 3}; - /// m = m.reshape(1, 2, new_shape); - /// ``` /// - /// ## Parameters - /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. - /// * rows: New number of rows. If the parameter is 0, the number of rows remains the same. + /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends + /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: + /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. /// - /// ## C++ default parameters - /// * rows: 0 - #[inline] - fn reshape_mut(&mut self, cn: i32, rows: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_reshape_int_int(self.as_raw_mut_Mat(), cn, rows, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// @overload /// ## Parameters - /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. - /// * newndims: New number of dimentions. - /// * newsz: Array with new matrix size by all dimentions. If some sizes are zero, - /// the original sizes in those dimensions are presumed. + /// * i0: Index along the dimension 0 + /// + /// ## Overloaded parameters + /// + /// * i0: Index along the dimension 0 + /// + /// ## C++ default parameters + /// * i0: 0 #[inline] - fn reshape_nd_mut(&mut self, cn: i32, newsz: &[i32]) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_reshape_int_int_const_intX(self.as_raw_mut_Mat(), cn, newsz.len().try_into()?, newsz.as_ptr(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; - Ok(ret) + fn at(&self, i0: i32) -> Result<&T> { + core::mat_forward::at(self, i0) } - /// @overload + /// Returns a reference to the specified array element. + /// + /// The template methods return a reference to the specified array element. For the sake of higher + /// performance, the index range checks are only performed in the Debug configuration. + /// + /// Note that the variants with a single index (i) can be used to access elements of single-row or + /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and + /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` + /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. + /// + /// The example below initializes a Hilbert matrix: + /// ```C++ + /// Mat H(100, 100, CV_64F); + /// for(int i = 0; i < H.rows; i++) + /// for(int j = 0; j < H.cols; j++) + /// H.at(i,j)=1./(i+j+1); + /// ``` + /// + /// + /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends + /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: + /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. + /// /// ## Parameters - /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. - /// * newshape: Vector with new matrix size by all dimentions. If some sizes are zero, - /// the original sizes in those dimensions are presumed. + /// * i0: Index along the dimension 0 + /// + /// ## Overloaded parameters + /// + /// * i0: Index along the dimension 0 + /// + /// ## Note + /// This alternative version of [MatTraitConst::at] function uses the following default values for its arguments: + /// * i0: 0 #[inline] - fn reshape_nd_vec_mut(&mut self, cn: i32, newshape: &core::Vector) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_reshape_int_const_vectorLintGR(self.as_raw_mut_Mat(), cn, newshape.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; - Ok(ret) + fn at_def(&self) -> Result<&T> { + core::mat_forward::at_def(self, ) } - /// Allocates new array data if needed. + /// Returns a reference to the specified array element. /// - /// This is one of the key Mat methods. Most new-style OpenCV functions and methods that produce arrays - /// call this method for each output array. The method uses the following algorithm: + /// The template methods return a reference to the specified array element. For the sake of higher + /// performance, the index range checks are only performed in the Debug configuration. /// - /// -# If the current array shape and the type match the new ones, return immediately. Otherwise, - /// de-reference the previous data by calling Mat::release. - /// -# Initialize the new header. - /// -# Allocate the new data of total()\*elemSize() bytes. - /// -# Allocate the new, associated with the data, reference counter and set it to 1. + /// Note that the variants with a single index (i) can be used to access elements of single-row or + /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and + /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` + /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. /// - /// Such a scheme makes the memory management robust and efficient at the same time and helps avoid - /// extra typing for you. This means that usually there is no need to explicitly allocate output arrays. - /// That is, instead of writing: + /// The example below initializes a Hilbert matrix: /// ```C++ - /// Mat color; - /// ... - /// Mat gray(color.rows, color.cols, color.depth()); - /// cvtColor(color, gray, COLOR_BGR2GRAY); + /// Mat H(100, 100, CV_64F); + /// for(int i = 0; i < H.rows; i++) + /// for(int j = 0; j < H.cols; j++) + /// H.at(i,j)=1./(i+j+1); /// ``` /// - /// you can simply write: - /// ```C++ - /// Mat color; - /// ... - /// Mat gray; - /// cvtColor(color, gray, COLOR_BGR2GRAY); - /// ``` /// - /// because cvtColor, as well as the most of OpenCV functions, calls Mat::create() for the output array - /// internally. + /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends + /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: + /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. + /// /// ## Parameters - /// * rows: New number of rows. - /// * cols: New number of columns. - /// * type: New matrix type. + /// * i0: Index along the dimension 0 + /// + /// ## Overloaded parameters + /// + /// * row: Index along the dimension 0 + /// * col: Index along the dimension 1 #[inline] - unsafe fn create_rows_cols(&mut self, rows: i32, cols: i32, typ: i32) -> Result<()> { - return_send!(via ocvrs_return); - { sys::cv_Mat_create_int_int_int(self.as_raw_mut_Mat(), rows, cols, typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn at_2d(&self, row: i32, col: i32) -> Result<&T> { + core::mat_forward::at_2d(self, row, col) } - /// Allocates new array data if needed. + /// Returns a reference to the specified array element. /// - /// This is one of the key Mat methods. Most new-style OpenCV functions and methods that produce arrays - /// call this method for each output array. The method uses the following algorithm: + /// The template methods return a reference to the specified array element. For the sake of higher + /// performance, the index range checks are only performed in the Debug configuration. /// - /// -# If the current array shape and the type match the new ones, return immediately. Otherwise, - /// de-reference the previous data by calling Mat::release. - /// -# Initialize the new header. - /// -# Allocate the new data of total()\*elemSize() bytes. - /// -# Allocate the new, associated with the data, reference counter and set it to 1. + /// Note that the variants with a single index (i) can be used to access elements of single-row or + /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and + /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` + /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. /// - /// Such a scheme makes the memory management robust and efficient at the same time and helps avoid - /// extra typing for you. This means that usually there is no need to explicitly allocate output arrays. - /// That is, instead of writing: + /// The example below initializes a Hilbert matrix: /// ```C++ - /// Mat color; - /// ... - /// Mat gray(color.rows, color.cols, color.depth()); - /// cvtColor(color, gray, COLOR_BGR2GRAY); + /// Mat H(100, 100, CV_64F); + /// for(int i = 0; i < H.rows; i++) + /// for(int j = 0; j < H.cols; j++) + /// H.at(i,j)=1./(i+j+1); /// ``` /// - /// you can simply write: - /// ```C++ - /// Mat color; - /// ... - /// Mat gray; - /// cvtColor(color, gray, COLOR_BGR2GRAY); - /// ``` /// - /// because cvtColor, as well as the most of OpenCV functions, calls Mat::create() for the output array - /// internally. + /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends + /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: + /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. + /// /// ## Parameters - /// * rows: New number of rows. - /// * cols: New number of columns. - /// * type: New matrix type. + /// * i0: Index along the dimension 0 /// /// ## Overloaded parameters /// - /// * size: Alternative new matrix size specification: Size(cols, rows) - /// * type: New matrix type. + /// * i0: Index along the dimension 0 + /// * i1: Index along the dimension 1 + /// * i2: Index along the dimension 2 #[inline] - unsafe fn create_size(&mut self, size: core::Size, typ: i32) -> Result<()> { - return_send!(via ocvrs_return); - { sys::cv_Mat_create_Size_int(self.as_raw_mut_Mat(), &size, typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn at_3d(&self, i0: i32, i1: i32, i2: i32) -> Result<&T> { + core::mat_forward::at_3d(self, i0, i1, i2) } - /// Allocates new array data if needed. + /// Returns a reference to the specified array element. /// - /// This is one of the key Mat methods. Most new-style OpenCV functions and methods that produce arrays - /// call this method for each output array. The method uses the following algorithm: + /// The template methods return a reference to the specified array element. For the sake of higher + /// performance, the index range checks are only performed in the Debug configuration. /// - /// -# If the current array shape and the type match the new ones, return immediately. Otherwise, - /// de-reference the previous data by calling Mat::release. - /// -# Initialize the new header. - /// -# Allocate the new data of total()\*elemSize() bytes. - /// -# Allocate the new, associated with the data, reference counter and set it to 1. + /// Note that the variants with a single index (i) can be used to access elements of single-row or + /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and + /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` + /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. /// - /// Such a scheme makes the memory management robust and efficient at the same time and helps avoid - /// extra typing for you. This means that usually there is no need to explicitly allocate output arrays. - /// That is, instead of writing: + /// The example below initializes a Hilbert matrix: /// ```C++ - /// Mat color; - /// ... - /// Mat gray(color.rows, color.cols, color.depth()); - /// cvtColor(color, gray, COLOR_BGR2GRAY); + /// Mat H(100, 100, CV_64F); + /// for(int i = 0; i < H.rows; i++) + /// for(int j = 0; j < H.cols; j++) + /// H.at(i,j)=1./(i+j+1); /// ``` /// - /// you can simply write: - /// ```C++ - /// Mat color; - /// ... - /// Mat gray; - /// cvtColor(color, gray, COLOR_BGR2GRAY); - /// ``` /// - /// because cvtColor, as well as the most of OpenCV functions, calls Mat::create() for the output array - /// internally. + /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends + /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: + /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. + /// /// ## Parameters - /// * rows: New number of rows. - /// * cols: New number of columns. - /// * type: New matrix type. + /// * i0: Index along the dimension 0 /// /// ## Overloaded parameters /// - /// * ndims: New array dimensionality. - /// * sizes: Array of integers specifying a new array shape. - /// * type: New matrix type. + /// * idx: Array of Mat::dims indices. #[inline] - unsafe fn create_nd(&mut self, sizes: &[i32], typ: i32) -> Result<()> { - return_send!(via ocvrs_return); - { sys::cv_Mat_create_int_const_intX_int(self.as_raw_mut_Mat(), sizes.len().try_into()?, sizes.as_ptr(), typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn at_nd(&self, idx: &[i32]) -> Result<&T> { + core::mat_forward::at_nd(self, idx) } - /// Allocates new array data if needed. + /// Returns a reference to the specified array element. /// - /// This is one of the key Mat methods. Most new-style OpenCV functions and methods that produce arrays - /// call this method for each output array. The method uses the following algorithm: + /// The template methods return a reference to the specified array element. For the sake of higher + /// performance, the index range checks are only performed in the Debug configuration. /// - /// -# If the current array shape and the type match the new ones, return immediately. Otherwise, - /// de-reference the previous data by calling Mat::release. - /// -# Initialize the new header. - /// -# Allocate the new data of total()\*elemSize() bytes. - /// -# Allocate the new, associated with the data, reference counter and set it to 1. + /// Note that the variants with a single index (i) can be used to access elements of single-row or + /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and + /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` + /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. /// - /// Such a scheme makes the memory management robust and efficient at the same time and helps avoid - /// extra typing for you. This means that usually there is no need to explicitly allocate output arrays. - /// That is, instead of writing: + /// The example below initializes a Hilbert matrix: /// ```C++ - /// Mat color; - /// ... - /// Mat gray(color.rows, color.cols, color.depth()); - /// cvtColor(color, gray, COLOR_BGR2GRAY); + /// Mat H(100, 100, CV_64F); + /// for(int i = 0; i < H.rows; i++) + /// for(int j = 0; j < H.cols; j++) + /// H.at(i,j)=1./(i+j+1); /// ``` /// - /// you can simply write: - /// ```C++ - /// Mat color; - /// ... - /// Mat gray; - /// cvtColor(color, gray, COLOR_BGR2GRAY); - /// ``` /// - /// because cvtColor, as well as the most of OpenCV functions, calls Mat::create() for the output array - /// internally. + /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends + /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: + /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. + /// /// ## Parameters - /// * rows: New number of rows. - /// * cols: New number of columns. - /// * type: New matrix type. + /// * i0: Index along the dimension 0 /// /// ## Overloaded parameters /// - /// * sizes: Array of integers specifying a new array shape. - /// * type: New matrix type. + /// special versions for 2D arrays (especially convenient for referencing image pixels) + /// * pt: Element position specified as Point(j,i) . #[inline] - unsafe fn create_nd_vec(&mut self, sizes: &core::Vector, typ: i32) -> Result<()> { - return_send!(via ocvrs_return); - { sys::cv_Mat_create_const_vectorLintGR_int(self.as_raw_mut_Mat(), sizes.as_raw_VectorOfi32(), typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn at_pt(&self, pt: core::Point) -> Result<&T> { + core::mat_forward::at_pt(self, pt) } - /// Increments the reference counter. - /// - /// The method increments the reference counter associated with the matrix data. If the matrix header - /// points to an external data set (see Mat::Mat ), the reference counter is NULL, and the method has no - /// effect in this case. Normally, to avoid memory leaks, the method should not be called explicitly. It - /// is called implicitly by the matrix assignment operator. The reference counter increment is an atomic - /// operation on the platforms that support it. Thus, it is safe to operate on the same matrices - /// asynchronously in different threads. #[inline] - unsafe fn addref(&mut self) -> Result<()> { + fn size(&self) -> Result { return_send!(via ocvrs_return); - { sys::cv_Mat_addref(self.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_Mat_size_const(self.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// Decrements the reference counter and deallocates the matrix if needed. - /// - /// The method decrements the reference counter associated with the matrix data. When the reference - /// counter reaches 0, the matrix data is deallocated and the data and the reference counter pointers - /// are set to NULL's. If the matrix header points to an external data set (see Mat::Mat ), the - /// reference counter is NULL, and the method has no effect in this case. - /// - /// This method can be called manually to force the matrix data deallocation. But since this method is - /// automatically called in the destructor, or by any other method that changes the data pointer, it is - /// usually not needed. The reference counter decrement and check for 0 is an atomic operation on the - /// platforms that support it. Thus, it is safe to operate on the same matrices asynchronously in - /// different threads. + /// Return the dump of the Mat's data #[inline] - unsafe fn release(&mut self) -> Result<()> { + fn get_data_dump(&self) -> Result { return_send!(via ocvrs_return); - { sys::cv_Mat_release(self.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_Mat_getDataDump_const(self.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { String::opencv_from_extern(ret) }; Ok(ret) } - /// internal use function, consider to use 'release' method instead; deallocates the matrix data + } + + /// Mutable methods for [core::Mat] + pub trait MatTrait: core::MatTraitConst { + fn as_raw_mut_Mat(&mut self) -> *mut c_void; + + /// ! includes several bit-fields: + /// - the magic signature + /// - continuity flag + /// - depth + /// - number of channels #[inline] - fn deallocate(&mut self) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_deallocate(self.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn set_flags(&mut self, val: i32) { + let ret = unsafe { sys::cv_Mat_propFlags_const_int(self.as_raw_mut_Mat(), val) }; + ret } - /// Reserves space for the certain number of rows. - /// - /// The method reserves space for sz rows. If the matrix already has enough space to store sz rows, - /// nothing happens. If the matrix is reallocated, the first Mat::rows rows are preserved. The method - /// emulates the corresponding method of the STL vector class. - /// ## Parameters - /// * sz: Number of rows. + /// the matrix dimensionality, >= 2 #[inline] - fn reserve(&mut self, sz: size_t) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_reserve_size_t(self.as_raw_mut_Mat(), sz, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn set_dims(&mut self, val: i32) { + let ret = unsafe { sys::cv_Mat_propDims_const_int(self.as_raw_mut_Mat(), val) }; + ret } - /// Reserves space for the certain number of bytes. - /// - /// The method reserves space for sz bytes. If the matrix already has enough space to store sz bytes, - /// nothing happens. If matrix has to be reallocated its previous content could be lost. - /// ## Parameters - /// * sz: Number of bytes. + /// the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions #[inline] - fn reserve_buffer(&mut self, sz: size_t) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_reserveBuffer_size_t(self.as_raw_mut_Mat(), sz, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn set_rows(&mut self, val: i32) { + let ret = unsafe { sys::cv_Mat_propRows_const_int(self.as_raw_mut_Mat(), val) }; + ret } - /// Changes the number of matrix rows. - /// - /// The methods change the number of matrix rows. If the matrix is reallocated, the first - /// min(Mat::rows, sz) rows are preserved. The methods emulate the corresponding methods of the STL - /// vector class. - /// ## Parameters - /// * sz: New number of rows. + /// the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions #[inline] - fn resize(&mut self, sz: size_t) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_resize_size_t(self.as_raw_mut_Mat(), sz, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn set_cols(&mut self, val: i32) { + let ret = unsafe { sys::cv_Mat_propCols_const_int(self.as_raw_mut_Mat(), val) }; + ret } - /// Changes the number of matrix rows. - /// - /// The methods change the number of matrix rows. If the matrix is reallocated, the first - /// min(Mat::rows, sz) rows are preserved. The methods emulate the corresponding methods of the STL - /// vector class. - /// ## Parameters - /// * sz: New number of rows. - /// - /// ## Overloaded parameters - /// - /// * sz: New number of rows. - /// * s: Value assigned to the newly added elements. + /// pointer to the data #[inline] - fn resize_with_default(&mut self, sz: size_t, s: core::Scalar) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_resize_size_t_const_ScalarR(self.as_raw_mut_Mat(), sz, &s, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn data_mut(&mut self) -> *mut u8 { + let ret = unsafe { sys::cv_Mat_propData(self.as_raw_mut_Mat()) }; + ret } - /// Adds elements to the bottom of the matrix. - /// - /// The methods add one or more elements to the bottom of the matrix. They emulate the corresponding - /// method of the STL vector class. When elem is Mat , its type and the number of columns must be the - /// same as in the container matrix. - /// ## Parameters - /// * elem: Added element(s). - /// - /// ## Overloaded parameters - /// - /// * m: Added line(s). + /// pointer to the data #[inline] - fn push_back(&mut self, m: &impl core::MatTraitConst) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_push_back_const_MatR(self.as_raw_mut_Mat(), m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + unsafe fn set_data(&mut self, val: *const u8) { + let ret = { sys::cv_Mat_propData_unsigned_charX(self.as_raw_mut_Mat(), val) }; + ret } - /// Removes elements from the bottom of the matrix. - /// - /// The method removes one or more rows from the bottom of the matrix. - /// ## Parameters - /// * nelems: Number of removed rows. If it is greater than the total number of rows, an exception - /// is thrown. - /// - /// ## C++ default parameters - /// * nelems: 1 + /// interaction with UMat #[inline] - fn pop_back(&mut self, nelems: size_t) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_pop_back_size_t(self.as_raw_mut_Mat(), nelems, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn u(&mut self) -> core::UMatData { + let ret = unsafe { sys::cv_Mat_propU(self.as_raw_mut_Mat()) }; + let ret = unsafe { core::UMatData::opencv_from_extern(ret) }; + ret } - /// Removes elements from the bottom of the matrix. + /// interaction with UMat + #[inline] + fn set_u(&mut self, val: &impl core::UMatDataTraitConst) { + let ret = unsafe { sys::cv_Mat_propU_UMatDataX(self.as_raw_mut_Mat(), val.as_raw_UMatData()) }; + ret + } + + #[inline] + fn set_mat_size(&mut self, val: core::MatSize) { + let ret = unsafe { sys::cv_Mat_propSize_const_MatSize(self.as_raw_mut_Mat(), val.as_raw_MatSize()) }; + ret + } + + /// assignment operators /// - /// The method removes one or more rows from the bottom of the matrix. + /// These are available assignment operators. Since they all are very different, make sure to read the + /// operator parameters description. /// ## Parameters - /// * nelems: Number of removed rows. If it is greater than the total number of rows, an exception - /// is thrown. + /// * m: Assigned, right-hand-side matrix. Matrix assignment is an O(1) operation. This means that + /// no data is copied but the data is shared and the reference counter, if any, is incremented. Before + /// assigning new data, the old data is de-referenced via Mat::release . /// - /// ## Note - /// This alternative version of [MatTrait::pop_back] function uses the following default values for its arguments: - /// * nelems: 1 + /// ## Overloaded parameters + /// + /// * expr: Assigned matrix expression object. As opposite to the first form of the assignment + /// operation, the second form can reuse already allocated matrix if it has the right size and type to + /// fit the matrix expression result. It is automatically handled by the real function that the matrix + /// expressions is expanded to. For example, C=A+B is expanded to add(A, B, C), and add takes care of + /// automatic C reallocation. #[inline] - fn pop_back_def(&mut self) -> Result<()> { + fn set_matexpr(&mut self, expr: &impl core::MatExprTraitConst) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_pop_back(self.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_operatorST_const_MatExprR(self.as_raw_mut_Mat(), expr.as_raw_MatExpr(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// Adjusts a submatrix size and position within the parent matrix. + /// Creates a matrix header for the specified matrix row. /// - /// The method is complimentary to Mat::locateROI . The typical use of these functions is to determine - /// the submatrix position within the parent matrix and then shift the position somehow. Typically, it - /// can be required for filtering operations when pixels outside of the ROI should be taken into - /// account. When all the method parameters are positive, the ROI needs to grow in all directions by the - /// specified amount, for example: + /// The method makes a new header for the specified matrix row and returns it. This is an O(1) + /// operation, regardless of the matrix size. The underlying data of the new matrix is shared with the + /// original matrix. Here is the example of one of the classical basic matrix processing operations, + /// axpy, used by LU and many other algorithms: /// ```C++ - /// A.adjustROI(2, 2, 2, 2); + /// inline void matrix_axpy(Mat& A, int i, int j, double alpha) + /// { + /// A.row(i) += A.row(j)*alpha; + /// } /// ``` /// - /// In this example, the matrix size is increased by 4 elements in each direction. The matrix is shifted - /// by 2 elements to the left and 2 elements up, which brings in all the necessary pixels for the - /// filtering with the 5x5 kernel. /// - /// adjustROI forces the adjusted ROI to be inside of the parent matrix that is boundaries of the - /// adjusted ROI are constrained by boundaries of the parent matrix. For example, if the submatrix A is - /// located in the first row of a parent matrix and you called A.adjustROI(2, 2, 2, 2) then A will not - /// be increased in the upward direction. + /// Note: In the current implementation, the following code does not work as expected: + /// ```C++ + /// Mat A; + /// ... + /// A.row(i) = A.row(j); // will not work + /// ``` + /// + /// This happens because A.row(i) forms a temporary header that is further assigned to another header. + /// Remember that each of these operations is O(1), that is, no data is copied. Thus, the above + /// assignment is not true if you may have expected the j-th row to be copied to the i-th row. To + /// achieve that, you should either turn this simple assignment into an expression or use the + /// Mat::copyTo method: + /// ```C++ + /// Mat A; + /// ... + /// // works, but looks a bit obscure. + /// A.row(i) = A.row(j) + 0; + /// // this is a bit longer, but the recommended method. + /// A.row(j).copyTo(A.row(i)); + /// ``` /// - /// The function is used internally by the OpenCV filtering functions, like filter2D , morphological - /// operations, and so on. /// ## Parameters - /// * dtop: Shift of the top submatrix boundary upwards. - /// * dbottom: Shift of the bottom submatrix boundary downwards. - /// * dleft: Shift of the left submatrix boundary to the left. - /// * dright: Shift of the right submatrix boundary to the right. - /// ## See also - /// copyMakeBorder + /// * y: A 0-based row index. #[inline] - fn adjust_roi(&mut self, dtop: i32, dbottom: i32, dleft: i32, dright: i32) -> Result { + fn row_mut(&mut self, y: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_adjustROI_int_int_int_int(self.as_raw_mut_Mat(), dtop, dbottom, dleft, dright, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_row_int(self.as_raw_mut_Mat(), y, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// Extracts a rectangular submatrix. + /// Creates a matrix header for the specified matrix column. /// - /// The operators make a new header for the specified sub-array of \*this . They are the most - /// generalized forms of Mat::row, Mat::col, Mat::rowRange, and Mat::colRange . For example, - /// `A(Range(0, 10), Range::all())` is equivalent to `A.rowRange(0, 10)`. Similarly to all of the above, - /// the operators are O(1) operations, that is, no matrix data is copied. + /// The method makes a new header for the specified matrix column and returns it. This is an O(1) + /// operation, regardless of the matrix size. The underlying data of the new matrix is shared with the + /// original matrix. See also the Mat::row description. /// ## Parameters - /// * rowRange: Start and end row of the extracted submatrix. The upper boundary is not included. To - /// select all the rows, use Range::all(). - /// * colRange: Start and end column of the extracted submatrix. The upper boundary is not included. - /// To select all the columns, use Range::all(). + /// * x: A 0-based column index. #[inline] - fn rowscols_mut(&mut self, mut row_range: impl core::RangeTrait, mut col_range: impl core::RangeTrait) -> Result> { + fn col_mut(&mut self, x: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_operator___Range_Range(self.as_raw_mut_Mat(), row_range.as_raw_mut_Range(), col_range.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_col_int(self.as_raw_mut_Mat(), x, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// @overload + /// Creates a matrix header for the specified row span. + /// + /// The method makes a new header for the specified row span of the matrix. Similarly to Mat::row and + /// Mat::col , this is an O(1) operation. /// ## Parameters - /// * roi: Extracted submatrix specified as a rectangle. + /// * startrow: An inclusive 0-based start index of the row span. + /// * endrow: An exclusive 0-based ending index of the row span. #[inline] - fn roi_mut(&mut self, roi: core::Rect) -> Result> { + fn row_bounds_mut(&mut self, startrow: i32, endrow: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_operator___const_RectR(self.as_raw_mut_Mat(), &roi, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_rowRange_int_int(self.as_raw_mut_Mat(), startrow, endrow, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; @@ -19545,1551 +19925,1262 @@ pub mod core { /// @overload /// ## Parameters - /// * ranges: Array of selected ranges along each array dimension. + /// * r: Range structure containing both the start and the end indices. #[inline] - fn ranges_mut(&mut self, ranges: &core::Vector) -> Result> { + fn row_range_mut(&mut self, r: &impl core::RangeTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_operator___const_vectorLRangeGR(self.as_raw_mut_Mat(), ranges.as_raw_VectorOfRange(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_rowRange_const_RangeR(self.as_raw_mut_Mat(), r.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// Returns a pointer to the specified matrix row. - /// - /// The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in - /// Mat::isContinuous to know how to use these methods. - /// ## Parameters - /// * i0: A 0-based row index. - /// - /// ## C++ default parameters - /// * i0: 0 - #[inline] - fn ptr_mut(&mut self, i0: i32) -> Result<*mut u8> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_ptr_int(self.as_raw_mut_Mat(), i0, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Returns a pointer to the specified matrix row. - /// - /// The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in - /// Mat::isContinuous to know how to use these methods. - /// ## Parameters - /// * i0: A 0-based row index. - /// - /// ## Note - /// This alternative version of [MatTrait::ptr_mut] function uses the following default values for its arguments: - /// * i0: 0 - #[inline] - fn ptr_mut_def(&mut self) -> Result<*mut u8> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_ptr(self.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Returns a pointer to the specified matrix row. + /// Creates a matrix header for the specified column span. /// - /// The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in - /// Mat::isContinuous to know how to use these methods. + /// The method makes a new header for the specified column span of the matrix. Similarly to Mat::row and + /// Mat::col , this is an O(1) operation. /// ## Parameters - /// * i0: A 0-based row index. - /// - /// ## Overloaded parameters - /// - /// * row: Index along the dimension 0 - /// * col: Index along the dimension 1 + /// * startcol: An inclusive 0-based start index of the column span. + /// * endcol: An exclusive 0-based ending index of the column span. #[inline] - fn ptr_2d_mut(&mut self, row: i32, col: i32) -> Result<*mut u8> { + fn col_bounds_mut(&mut self, startcol: i32, endcol: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_ptr_int_int(self.as_raw_mut_Mat(), row, col, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_colRange_int_int(self.as_raw_mut_Mat(), startcol, endcol, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// Returns a pointer to the specified matrix row. - /// - /// The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in - /// Mat::isContinuous to know how to use these methods. + /// @overload /// ## Parameters - /// * i0: A 0-based row index. - /// - /// ## Overloaded parameters + /// * r: Range structure containing both the start and the end indices. #[inline] - fn ptr_3d_mut(&mut self, i0: i32, i1: i32, i2: i32) -> Result<*mut u8> { + fn col_range_mut(&mut self, r: &impl core::RangeTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_ptr_int_int_int(self.as_raw_mut_Mat(), i0, i1, i2, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_colRange_const_RangeR(self.as_raw_mut_Mat(), r.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// Returns a pointer to the specified matrix row. + /// Extracts a diagonal from a matrix /// - /// The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in - /// Mat::isContinuous to know how to use these methods. + /// The method makes a new header for the specified matrix diagonal. The new matrix is represented as a + /// single-column matrix. Similarly to Mat::row and Mat::col, this is an O(1) operation. /// ## Parameters - /// * i0: A 0-based row index. - /// - /// ## Overloaded parameters - #[inline] - fn ptr_nd_mut(&mut self, idx: &[i32]) -> Result<*mut u8> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_ptr_const_intX(self.as_raw_mut_Mat(), idx.as_ptr(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Returns a reference to the specified array element. - /// - /// The template methods return a reference to the specified array element. For the sake of higher - /// performance, the index range checks are only performed in the Debug configuration. - /// - /// Note that the variants with a single index (i) can be used to access elements of single-row or - /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and - /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` - /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. - /// - /// The example below initializes a Hilbert matrix: + /// * d: index of the diagonal, with the following values: + /// - `d=0` is the main diagonal. + /// - `d<0` is a diagonal from the lower half. For example, d=-1 means the diagonal is set + /// immediately below the main one. + /// - `d>0` is a diagonal from the upper half. For example, d=1 means the diagonal is set + /// immediately above the main one. + /// For example: /// ```C++ - /// Mat H(100, 100, CV_64F); - /// for(int i = 0; i < H.rows; i++) - /// for(int j = 0; j < H.cols; j++) - /// H.at(i,j)=1./(i+j+1); + /// Mat m = (Mat_(3,3) << + /// 1,2,3, + /// 4,5,6, + /// 7,8,9); + /// Mat d0 = m.diag(0); + /// Mat d1 = m.diag(1); + /// Mat d_1 = m.diag(-1); /// ``` /// - /// - /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends - /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: - /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. - /// - /// ## Parameters - /// * i0: Index along the dimension 0 - /// - /// ## C++ default parameters - /// * i0: 0 - #[inline] - fn at_mut(&mut self, i0: i32) -> Result<&mut T> { - core::mat_forward::at_mut(self, i0) - } - - /// Returns a reference to the specified array element. - /// - /// The template methods return a reference to the specified array element. For the sake of higher - /// performance, the index range checks are only performed in the Debug configuration. - /// - /// Note that the variants with a single index (i) can be used to access elements of single-row or - /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and - /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` - /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. - /// - /// The example below initializes a Hilbert matrix: + /// The resulting matrices are /// ```C++ - /// Mat H(100, 100, CV_64F); - /// for(int i = 0; i < H.rows; i++) - /// for(int j = 0; j < H.cols; j++) - /// H.at(i,j)=1./(i+j+1); + /// d0 = + /// [1; + /// 5; + /// 9] + /// d1 = + /// [2; + /// 6] + /// d_1 = + /// [4; + /// 8] /// ``` /// /// - /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends - /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: - /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. - /// - /// ## Parameters - /// * i0: Index along the dimension 0 - /// /// ## Note - /// This alternative version of [MatTrait::at_mut] function uses the following default values for its arguments: - /// * i0: 0 + /// This alternative version of [MatTraitConst::diag] function uses the following default values for its arguments: + /// * d: 0 #[inline] - fn at_mut_def(&mut self) -> Result<&mut T> { - core::mat_forward::at_mut_def(self, ) + fn diag_def_mut(&mut self) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_diag(self.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; + Ok(ret) } - /// Returns a reference to the specified array element. - /// - /// The template methods return a reference to the specified array element. For the sake of higher - /// performance, the index range checks are only performed in the Debug configuration. - /// - /// Note that the variants with a single index (i) can be used to access elements of single-row or - /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and - /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` - /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. + /// Extracts a diagonal from a matrix /// - /// The example below initializes a Hilbert matrix: + /// The method makes a new header for the specified matrix diagonal. The new matrix is represented as a + /// single-column matrix. Similarly to Mat::row and Mat::col, this is an O(1) operation. + /// ## Parameters + /// * d: index of the diagonal, with the following values: + /// - `d=0` is the main diagonal. + /// - `d<0` is a diagonal from the lower half. For example, d=-1 means the diagonal is set + /// immediately below the main one. + /// - `d>0` is a diagonal from the upper half. For example, d=1 means the diagonal is set + /// immediately above the main one. + /// For example: /// ```C++ - /// Mat H(100, 100, CV_64F); - /// for(int i = 0; i < H.rows; i++) - /// for(int j = 0; j < H.cols; j++) - /// H.at(i,j)=1./(i+j+1); + /// Mat m = (Mat_(3,3) << + /// 1,2,3, + /// 4,5,6, + /// 7,8,9); + /// Mat d0 = m.diag(0); + /// Mat d1 = m.diag(1); + /// Mat d_1 = m.diag(-1); /// ``` /// + /// The resulting matrices are + /// ```C++ + /// d0 = + /// [1; + /// 5; + /// 9] + /// d1 = + /// [2; + /// 6] + /// d_1 = + /// [4; + /// 8] + /// ``` /// - /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends - /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: - /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. /// + /// ## C++ default parameters + /// * d: 0 + #[inline] + fn diag_mut(&mut self, d: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_diag_int(self.as_raw_mut_Mat(), d, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Sets all or some of the array elements to the specified value. /// ## Parameters - /// * i0: Index along the dimension 0 - /// - /// ## Overloaded parameters - /// - /// * row: Index along the dimension 0 - /// * col: Index along the dimension 1 + /// * s: Assigned scalar converted to the actual array type. #[inline] - fn at_2d_mut(&mut self, row: i32, col: i32) -> Result<&mut T> { - core::mat_forward::at_2d_mut(self, row, col) + fn set_scalar(&mut self, s: core::Scalar) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_operatorST_const_ScalarR(self.as_raw_mut_Mat(), &s, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } - /// Returns a reference to the specified array element. - /// - /// The template methods return a reference to the specified array element. For the sake of higher - /// performance, the index range checks are only performed in the Debug configuration. - /// - /// Note that the variants with a single index (i) can be used to access elements of single-row or - /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and - /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` - /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. - /// - /// The example below initializes a Hilbert matrix: - /// ```C++ - /// Mat H(100, 100, CV_64F); - /// for(int i = 0; i < H.rows; i++) - /// for(int j = 0; j < H.cols; j++) - /// H.at(i,j)=1./(i+j+1); - /// ``` - /// - /// - /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends - /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: - /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. + /// Sets all or some of the array elements to the specified value. /// + /// This is an advanced variant of the Mat::operator=(const Scalar& s) operator. /// ## Parameters - /// * i0: Index along the dimension 0 - /// - /// ## Overloaded parameters + /// * value: Assigned scalar converted to the actual array type. + /// * mask: Operation mask of the same size as \*this. Its non-zero elements indicate which matrix + /// elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels /// - /// * i0: Index along the dimension 0 - /// * i1: Index along the dimension 1 - /// * i2: Index along the dimension 2 + /// ## C++ default parameters + /// * mask: noArray() #[inline] - fn at_3d_mut(&mut self, i0: i32, i1: i32, i2: i32) -> Result<&mut T> { - core::mat_forward::at_3d_mut(self, i0, i1, i2) + fn set_to(&mut self, value: &impl ToInputArray, mask: &impl ToInputArray) -> Result { + input_array_arg!(value); + input_array_arg!(mask); + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_setTo_const__InputArrayR_const__InputArrayR(self.as_raw_mut_Mat(), value.as_raw__InputArray(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + Ok(ret) } - /// Returns a reference to the specified array element. - /// - /// The template methods return a reference to the specified array element. For the sake of higher - /// performance, the index range checks are only performed in the Debug configuration. - /// - /// Note that the variants with a single index (i) can be used to access elements of single-row or - /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and - /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` - /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. - /// - /// The example below initializes a Hilbert matrix: - /// ```C++ - /// Mat H(100, 100, CV_64F); - /// for(int i = 0; i < H.rows; i++) - /// for(int j = 0; j < H.cols; j++) - /// H.at(i,j)=1./(i+j+1); - /// ``` - /// - /// - /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends - /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: - /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. + /// Sets all or some of the array elements to the specified value. /// + /// This is an advanced variant of the Mat::operator=(const Scalar& s) operator. /// ## Parameters - /// * i0: Index along the dimension 0 - /// - /// ## Overloaded parameters + /// * value: Assigned scalar converted to the actual array type. + /// * mask: Operation mask of the same size as \*this. Its non-zero elements indicate which matrix + /// elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels /// - /// * idx: Array of Mat::dims indices. + /// ## Note + /// This alternative version of [MatTrait::set_to] function uses the following default values for its arguments: + /// * mask: noArray() #[inline] - fn at_nd_mut(&mut self, idx: &[i32]) -> Result<&mut T> { - core::mat_forward::at_nd_mut(self, idx) + fn set_to_def(&mut self, value: &impl ToInputArray) -> Result { + input_array_arg!(value); + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_setTo_const__InputArrayR(self.as_raw_mut_Mat(), value.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + Ok(ret) } - /// Returns a reference to the specified array element. + /// Changes the shape and/or the number of channels of a 2D matrix without copying the data. /// - /// The template methods return a reference to the specified array element. For the sake of higher - /// performance, the index range checks are only performed in the Debug configuration. + /// The method makes a new matrix header for \*this elements. The new matrix may have a different size + /// and/or different number of channels. Any combination is possible if: + /// * No extra elements are included into the new matrix and no elements are excluded. Consequently, + /// the product rows\*cols\*channels() must stay the same after the transformation. + /// * No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of + /// rows, or the operation changes the indices of elements row in some other way, the matrix must be + /// continuous. See Mat::isContinuous . /// - /// Note that the variants with a single index (i) can be used to access elements of single-row or - /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and - /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` - /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. + /// For example, if there is a set of 3D points stored as an STL vector, and you want to represent the + /// points as a 3xN matrix, do the following: + /// ```C++ + /// std::vector vec; + /// ... + /// Mat pointMat = Mat(vec). // convert vector to Mat, O(1) operation + /// reshape(1). // make Nx3 1-channel matrix out of Nx1 3-channel. + /// // Also, an O(1) operation + /// t(); // finally, transpose the Nx3 matrix. + /// // This involves copying all the elements + /// ``` /// - /// The example below initializes a Hilbert matrix: + /// 3-channel 2x2 matrix reshaped to 1-channel 4x3 matrix, each column has values from one of original channels: /// ```C++ - /// Mat H(100, 100, CV_64F); - /// for(int i = 0; i < H.rows; i++) - /// for(int j = 0; j < H.cols; j++) - /// H.at(i,j)=1./(i+j+1); + /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); + /// vector new_shape {4, 3}; + /// m = m.reshape(1, new_shape); + /// ``` + /// + /// or: + /// ```C++ + /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); + /// const int new_shape[] = {4, 3}; + /// m = m.reshape(1, 2, new_shape); /// ``` /// - /// - /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends - /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: - /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. - /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. - /// /// ## Parameters - /// * i0: Index along the dimension 0 - /// - /// ## Overloaded parameters + /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. + /// * rows: New number of rows. If the parameter is 0, the number of rows remains the same. /// - /// special versions for 2D arrays (especially convenient for referencing image pixels) - /// * pt: Element position specified as Point(j,i) . - #[inline] - fn at_pt_mut(&mut self, pt: core::Point) -> Result<&mut T> { - core::mat_forward::at_pt_mut(self, pt) - } - - #[inline] - fn set(&mut self, mut m: core::Mat) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_operatorST_MatRR(self.as_raw_mut_Mat(), m.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// internal use method: updates the continuity flag + /// ## Note + /// This alternative version of [MatTraitConst::reshape] function uses the following default values for its arguments: + /// * rows: 0 #[inline] - fn update_continuity_flag(&mut self) -> Result<()> { + fn reshape_def_mut(&mut self, cn: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_updateContinuityFlag(self.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_reshape_int(self.as_raw_mut_Mat(), cn, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - } - - /// n-dimensional dense array class \anchor CVMat_Details - /// - /// The class Mat represents an n-dimensional dense numerical single-channel or multi-channel array. It - /// can be used to store real or complex-valued vectors and matrices, grayscale or color images, voxel - /// volumes, vector fields, point clouds, tensors, histograms (though, very high-dimensional histograms - /// may be better stored in a SparseMat ). The data layout of the array `M` is defined by the array - /// `M.step[]`, so that the address of element ![inline formula](https://latex.codecogs.com/png.latex?%28i%5F0%2C%2E%2E%2E%2Ci%5F%7BM%2Edims%2D1%7D%29), where ![inline formula](https://latex.codecogs.com/png.latex?0%5Cleq%20i%5Fk%3CM%2Esize%5Bk%5D), is - /// computed as: - /// ![block formula](https://latex.codecogs.com/png.latex?addr%28M%5F%7Bi%5F0%2C%2E%2E%2E%2Ci%5F%7BM%2Edims%2D1%7D%7D%29%20%3D%20M%2Edata%20%2B%20M%2Estep%5B0%5D%2Ai%5F0%20%2B%20M%2Estep%5B1%5D%2Ai%5F1%20%2B%20%2E%2E%2E%20%2B%20M%2Estep%5BM%2Edims%2D1%5D%2Ai%5F%7BM%2Edims%2D1%7D) - /// In case of a 2-dimensional array, the above formula is reduced to: - /// ![block formula](https://latex.codecogs.com/png.latex?addr%28M%5F%7Bi%2Cj%7D%29%20%3D%20M%2Edata%20%2B%20M%2Estep%5B0%5D%2Ai%20%2B%20M%2Estep%5B1%5D%2Aj) - /// Note that `M.step[i] >= M.step[i+1]` (in fact, `M.step[i] >= M.step[i+1]*M.size[i+1]` ). This means - /// that 2-dimensional matrices are stored row-by-row, 3-dimensional matrices are stored plane-by-plane, - /// and so on. M.step[M.dims-1] is minimal and always equal to the element size M.elemSize() . - /// - /// So, the data layout in Mat is compatible with the majority of dense array types from the standard - /// toolkits and SDKs, such as Numpy (ndarray), Win32 (independent device bitmaps), and others, - /// that is, with any array that uses *steps* (or *strides*) to compute the position of a pixel. - /// Due to this compatibility, it is possible to make a Mat header for user-allocated data and process - /// it in-place using OpenCV functions. - /// - /// There are many different ways to create a Mat object. The most popular options are listed below: - /// - /// - Use the create(nrows, ncols, type) method or the similar Mat(nrows, ncols, type[, fillValue]) - /// constructor. A new array of the specified size and type is allocated. type has the same meaning as - /// in the cvCreateMat method. For example, CV_8UC1 means a 8-bit single-channel array, CV_32FC2 - /// means a 2-channel (complex) floating-point array, and so on. - /// ```C++ - /// // make a 7x7 complex matrix filled with 1+3j. - /// Mat M(7,7,CV_32FC2,Scalar(1,3)); - /// // and now turn M to a 100x60 15-channel 8-bit matrix. - /// // The old content will be deallocated - /// M.create(100,60,CV_8UC(15)); - /// ``` - /// - /// As noted in the introduction to this chapter, create() allocates only a new array when the shape - /// or type of the current array are different from the specified ones. - /// - /// - Create a multi-dimensional array: - /// ```C++ - /// // create a 100x100x100 8-bit array - /// int sz[] = {100, 100, 100}; - /// Mat bigCube(3, sz, CV_8U, Scalar::all(0)); - /// ``` - /// - /// It passes the number of dimensions =1 to the Mat constructor but the created array will be - /// 2-dimensional with the number of columns set to 1. So, Mat::dims is always \>= 2 (can also be 0 - /// when the array is empty). - /// - /// - Use a copy constructor or assignment operator where there can be an array or expression on the - /// right side (see below). As noted in the introduction, the array assignment is an O(1) operation - /// because it only copies the header and increases the reference counter. The Mat::clone() method can - /// be used to get a full (deep) copy of the array when you need it. - /// - /// - Construct a header for a part of another array. It can be a single row, single column, several - /// rows, several columns, rectangular region in the array (called a *minor* in algebra) or a - /// diagonal. Such operations are also O(1) because the new header references the same data. You can - /// actually modify a part of the array using this feature, for example: - /// ```C++ - /// // add the 5-th row, multiplied by 3 to the 3rd row - /// M.row(3) = M.row(3) + M.row(5)*3; - /// // now copy the 7-th column to the 1-st column - /// // M.col(1) = M.col(7); // this will not work - /// Mat M1 = M.col(1); - /// M.col(7).copyTo(M1); - /// // create a new 320x240 image - /// Mat img(Size(320,240),CV_8UC3); - /// // select a ROI - /// Mat roi(img, Rect(10,10,100,100)); - /// // fill the ROI with (0,255,0) (which is green in RGB space); - /// // the original 320x240 image will be modified - /// roi = Scalar(0,255,0); - /// ``` - /// - /// Due to the additional datastart and dataend members, it is possible to compute a relative - /// sub-array position in the main *container* array using locateROI(): - /// ```C++ - /// Mat A = Mat::eye(10, 10, CV_32S); - /// // extracts A columns, 1 (inclusive) to 3 (exclusive). - /// Mat B = A(Range::all(), Range(1, 3)); - /// // extracts B rows, 5 (inclusive) to 9 (exclusive). - /// // that is, C \~ A(Range(5, 9), Range(1, 3)) - /// Mat C = B(Range(5, 9), Range::all()); - /// Size size; Point ofs; - /// C.locateROI(size, ofs); - /// // size will be (width=10,height=10) and the ofs will be (x=1, y=5) - /// ``` - /// - /// As in case of whole matrices, if you need a deep copy, use the `clone()` method of the extracted - /// sub-matrices. - /// - /// - Make a header for user-allocated data. It can be useful to do the following: - /// -# Process "foreign" data using OpenCV (for example, when you implement a DirectShow\* filter or - /// a processing module for gstreamer, and so on). For example: - /// ```C++ - /// Mat process_video_frame(const unsigned char* pixels, - /// int width, int height, int step) - /// { - /// // wrap input buffer - /// Mat img(height, width, CV_8UC3, (unsigned char*)pixels, step); - /// - /// Mat result; - /// GaussianBlur(img, result, Size(7, 7), 1.5, 1.5); - /// - /// return result; - /// } - /// ``` - /// - /// -# Quickly initialize small matrices and/or get a super-fast element access. - /// ```C++ - /// double m[3][3] = {{a, b, c}, {d, e, f}, {g, h, i}}; - /// Mat M = Mat(3, 3, CV_64F, m).inv(); - /// ``` - /// - /// . - /// - /// - Use MATLAB-style array initializers, zeros(), ones(), eye(), for example: - /// ```C++ - /// // create a double-precision identity matrix and add it to M. - /// M += Mat::eye(M.rows, M.cols, CV_64F); - /// ``` - /// - /// - /// - Use a comma-separated initializer: - /// ```C++ - /// // create a 3x3 double-precision identity matrix - /// Mat M = (Mat_(3,3) << 1, 0, 0, 0, 1, 0, 0, 0, 1); - /// ``` - /// - /// With this approach, you first call a constructor of the Mat class with the proper parameters, and - /// then you just put `<< operator` followed by comma-separated values that can be constants, - /// variables, expressions, and so on. Also, note the extra parentheses required to avoid compilation - /// errors. - /// - /// Once the array is created, it is automatically managed via a reference-counting mechanism. If the - /// array header is built on top of user-allocated data, you should handle the data by yourself. The - /// array data is deallocated when no one points to it. If you want to release the data pointed by a - /// array header before the array destructor is called, use Mat::release(). - /// - /// The next important thing to learn about the array class is element access. This manual already - /// described how to compute an address of each array element. Normally, you are not required to use the - /// formula directly in the code. If you know the array element type (which can be retrieved using the - /// method Mat::type() ), you can access the element ![inline formula](https://latex.codecogs.com/png.latex?M%5F%7Bij%7D) of a 2-dimensional array as: - /// ```C++ - /// M.at(i,j) += 1.f; - /// ``` - /// - /// assuming that `M` is a double-precision floating-point array. There are several variants of the method - /// at for a different number of dimensions. - /// - /// If you need to process a whole row of a 2D array, the most efficient way is to get the pointer to - /// the row first, and then just use the plain C operator [] : - /// ```C++ - /// // compute sum of positive matrix elements - /// // (assuming that M is a double-precision matrix) - /// double sum=0; - /// for(int i = 0; i < M.rows; i++) - /// { - /// const double* Mi = M.ptr(i); - /// for(int j = 0; j < M.cols; j++) - /// sum += std::max(Mi[j], 0.); - /// } - /// ``` - /// - /// Some operations, like the one above, do not actually depend on the array shape. They just process - /// elements of an array one by one (or elements from multiple arrays that have the same coordinates, - /// for example, array addition). Such operations are called *element-wise*. It makes sense to check - /// whether all the input/output arrays are continuous, namely, have no gaps at the end of each row. If - /// yes, process them as a long single row: - /// ```C++ - /// // compute the sum of positive matrix elements, optimized variant - /// double sum=0; - /// int cols = M.cols, rows = M.rows; - /// if(M.isContinuous()) - /// { - /// cols *= rows; - /// rows = 1; - /// } - /// for(int i = 0; i < rows; i++) - /// { - /// const double* Mi = M.ptr(i); - /// for(int j = 0; j < cols; j++) - /// sum += std::max(Mi[j], 0.); - /// } - /// ``` - /// - /// In case of the continuous matrix, the outer loop body is executed just once. So, the overhead is - /// smaller, which is especially noticeable in case of small matrices. - /// - /// Finally, there are STL-style iterators that are smart enough to skip gaps between successive rows: - /// ```C++ - /// // compute sum of positive matrix elements, iterator-based variant - /// double sum=0; - /// MatConstIterator_ it = M.begin(), it_end = M.end(); - /// for(; it != it_end; ++it) - /// sum += std::max(*it, 0.); - /// ``` - /// - /// The matrix iterators are random-access iterators, so they can be passed to any STL algorithm, - /// including std::sort(). - /// - /// - /// Note: Matrix Expressions and arithmetic see MatExpr - pub struct Mat { - ptr: *mut c_void, - } - - opencv_type_boxed! { Mat } - - impl Drop for Mat { + /// Changes the shape and/or the number of channels of a 2D matrix without copying the data. + /// + /// The method makes a new matrix header for \*this elements. The new matrix may have a different size + /// and/or different number of channels. Any combination is possible if: + /// * No extra elements are included into the new matrix and no elements are excluded. Consequently, + /// the product rows\*cols\*channels() must stay the same after the transformation. + /// * No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of + /// rows, or the operation changes the indices of elements row in some other way, the matrix must be + /// continuous. See Mat::isContinuous . + /// + /// For example, if there is a set of 3D points stored as an STL vector, and you want to represent the + /// points as a 3xN matrix, do the following: + /// ```C++ + /// std::vector vec; + /// ... + /// Mat pointMat = Mat(vec). // convert vector to Mat, O(1) operation + /// reshape(1). // make Nx3 1-channel matrix out of Nx1 3-channel. + /// // Also, an O(1) operation + /// t(); // finally, transpose the Nx3 matrix. + /// // This involves copying all the elements + /// ``` + /// + /// 3-channel 2x2 matrix reshaped to 1-channel 4x3 matrix, each column has values from one of original channels: + /// ```C++ + /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); + /// vector new_shape {4, 3}; + /// m = m.reshape(1, new_shape); + /// ``` + /// + /// or: + /// ```C++ + /// Mat m(Size(2, 2), CV_8UC3, Scalar(1, 2, 3)); + /// const int new_shape[] = {4, 3}; + /// m = m.reshape(1, 2, new_shape); + /// ``` + /// + /// ## Parameters + /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. + /// * rows: New number of rows. If the parameter is 0, the number of rows remains the same. + /// + /// ## C++ default parameters + /// * rows: 0 #[inline] - fn drop(&mut self) { - unsafe { sys::cv_Mat_delete(self.as_raw_mut_Mat()) }; + fn reshape_mut(&mut self, cn: i32, rows: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_reshape_int_int(self.as_raw_mut_Mat(), cn, rows, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; + Ok(ret) } - } - unsafe impl Send for Mat {} + /// @overload + /// ## Parameters + /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. + /// * newndims: New number of dimentions. + /// * newsz: Array with new matrix size by all dimentions. If some sizes are zero, + /// the original sizes in those dimensions are presumed. + #[inline] + fn reshape_nd_mut(&mut self, cn: i32, newsz: &[i32]) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_reshape_int_int_const_intX(self.as_raw_mut_Mat(), cn, newsz.len().try_into()?, newsz.as_ptr(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; + Ok(ret) + } - impl core::MatTraitConst for Mat { - #[inline] fn as_raw_Mat(&self) -> *const c_void { self.as_raw() } - } + /// @overload + /// ## Parameters + /// * cn: New number of channels. If the parameter is 0, the number of channels remains the same. + /// * newshape: Vector with new matrix size by all dimentions. If some sizes are zero, + /// the original sizes in those dimensions are presumed. + #[inline] + fn reshape_nd_vec_mut(&mut self, cn: i32, newshape: &core::Vector) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_reshape_int_const_vectorLintGR(self.as_raw_mut_Mat(), cn, newshape.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; + Ok(ret) + } - impl core::MatTrait for Mat { - #[inline] fn as_raw_mut_Mat(&mut self) -> *mut c_void { self.as_raw_mut() } - } + /// Allocates new array data if needed. + /// + /// This is one of the key Mat methods. Most new-style OpenCV functions and methods that produce arrays + /// call this method for each output array. The method uses the following algorithm: + /// + /// -# If the current array shape and the type match the new ones, return immediately. Otherwise, + /// de-reference the previous data by calling Mat::release. + /// -# Initialize the new header. + /// -# Allocate the new data of total()\*elemSize() bytes. + /// -# Allocate the new, associated with the data, reference counter and set it to 1. + /// + /// Such a scheme makes the memory management robust and efficient at the same time and helps avoid + /// extra typing for you. This means that usually there is no need to explicitly allocate output arrays. + /// That is, instead of writing: + /// ```C++ + /// Mat color; + /// ... + /// Mat gray(color.rows, color.cols, color.depth()); + /// cvtColor(color, gray, COLOR_BGR2GRAY); + /// ``` + /// + /// you can simply write: + /// ```C++ + /// Mat color; + /// ... + /// Mat gray; + /// cvtColor(color, gray, COLOR_BGR2GRAY); + /// ``` + /// + /// because cvtColor, as well as the most of OpenCV functions, calls Mat::create() for the output array + /// internally. + /// ## Parameters + /// * rows: New number of rows. + /// * cols: New number of columns. + /// * type: New matrix type. + #[inline] + unsafe fn create_rows_cols(&mut self, rows: i32, cols: i32, typ: i32) -> Result<()> { + return_send!(via ocvrs_return); + { sys::cv_Mat_create_int_int_int(self.as_raw_mut_Mat(), rows, cols, typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - boxed_ref! { Mat, core::MatTraitConst, as_raw_Mat, core::MatTrait, as_raw_mut_Mat } + /// Allocates new array data if needed. + /// + /// This is one of the key Mat methods. Most new-style OpenCV functions and methods that produce arrays + /// call this method for each output array. The method uses the following algorithm: + /// + /// -# If the current array shape and the type match the new ones, return immediately. Otherwise, + /// de-reference the previous data by calling Mat::release. + /// -# Initialize the new header. + /// -# Allocate the new data of total()\*elemSize() bytes. + /// -# Allocate the new, associated with the data, reference counter and set it to 1. + /// + /// Such a scheme makes the memory management robust and efficient at the same time and helps avoid + /// extra typing for you. This means that usually there is no need to explicitly allocate output arrays. + /// That is, instead of writing: + /// ```C++ + /// Mat color; + /// ... + /// Mat gray(color.rows, color.cols, color.depth()); + /// cvtColor(color, gray, COLOR_BGR2GRAY); + /// ``` + /// + /// you can simply write: + /// ```C++ + /// Mat color; + /// ... + /// Mat gray; + /// cvtColor(color, gray, COLOR_BGR2GRAY); + /// ``` + /// + /// because cvtColor, as well as the most of OpenCV functions, calls Mat::create() for the output array + /// internally. + /// ## Parameters + /// * rows: New number of rows. + /// * cols: New number of columns. + /// * type: New matrix type. + /// + /// ## Overloaded parameters + /// + /// * size: Alternative new matrix size specification: Size(cols, rows) + /// * type: New matrix type. + #[inline] + unsafe fn create_size(&mut self, size: core::Size, typ: i32) -> Result<()> { + return_send!(via ocvrs_return); + { sys::cv_Mat_create_Size_int(self.as_raw_mut_Mat(), &size, typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - impl Mat { - /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often - /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. - /// The constructed matrix can further be assigned to another matrix or matrix expression or can be - /// allocated with Mat::create . In the former case, the old content is de-referenced. + /// Allocates new array data if needed. + /// + /// This is one of the key Mat methods. Most new-style OpenCV functions and methods that produce arrays + /// call this method for each output array. The method uses the following algorithm: + /// + /// -# If the current array shape and the type match the new ones, return immediately. Otherwise, + /// de-reference the previous data by calling Mat::release. + /// -# Initialize the new header. + /// -# Allocate the new data of total()\*elemSize() bytes. + /// -# Allocate the new, associated with the data, reference counter and set it to 1. + /// + /// Such a scheme makes the memory management robust and efficient at the same time and helps avoid + /// extra typing for you. This means that usually there is no need to explicitly allocate output arrays. + /// That is, instead of writing: + /// ```C++ + /// Mat color; + /// ... + /// Mat gray(color.rows, color.cols, color.depth()); + /// cvtColor(color, gray, COLOR_BGR2GRAY); + /// ``` + /// + /// you can simply write: + /// ```C++ + /// Mat color; + /// ... + /// Mat gray; + /// cvtColor(color, gray, COLOR_BGR2GRAY); + /// ``` + /// + /// because cvtColor, as well as the most of OpenCV functions, calls Mat::create() for the output array + /// internally. + /// ## Parameters + /// * rows: New number of rows. + /// * cols: New number of columns. + /// * type: New matrix type. + /// + /// ## Overloaded parameters + /// + /// * ndims: New array dimensionality. + /// * sizes: Array of integers specifying a new array shape. + /// * type: New matrix type. #[inline] - pub fn default() -> core::Mat { - let ret = unsafe { sys::cv_Mat_Mat() }; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; - ret + unsafe fn create_nd(&mut self, sizes: &[i32], typ: i32) -> Result<()> { + return_send!(via ocvrs_return); + { sys::cv_Mat_create_int_const_intX_int(self.as_raw_mut_Mat(), sizes.len().try_into()?, sizes.as_ptr(), typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } - /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often - /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. - /// The constructed matrix can further be assigned to another matrix or matrix expression or can be - /// allocated with Mat::create . In the former case, the old content is de-referenced. + /// Allocates new array data if needed. + /// + /// This is one of the key Mat methods. Most new-style OpenCV functions and methods that produce arrays + /// call this method for each output array. The method uses the following algorithm: + /// + /// -# If the current array shape and the type match the new ones, return immediately. Otherwise, + /// de-reference the previous data by calling Mat::release. + /// -# Initialize the new header. + /// -# Allocate the new data of total()\*elemSize() bytes. + /// -# Allocate the new, associated with the data, reference counter and set it to 1. + /// + /// Such a scheme makes the memory management robust and efficient at the same time and helps avoid + /// extra typing for you. This means that usually there is no need to explicitly allocate output arrays. + /// That is, instead of writing: + /// ```C++ + /// Mat color; + /// ... + /// Mat gray(color.rows, color.cols, color.depth()); + /// cvtColor(color, gray, COLOR_BGR2GRAY); + /// ``` /// - /// ## Overloaded parameters + /// you can simply write: + /// ```C++ + /// Mat color; + /// ... + /// Mat gray; + /// cvtColor(color, gray, COLOR_BGR2GRAY); + /// ``` /// + /// because cvtColor, as well as the most of OpenCV functions, calls Mat::create() for the output array + /// internally. /// ## Parameters - /// * rows: Number of rows in a 2D array. - /// * cols: Number of columns in a 2D array. - /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or - /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. - #[inline] - pub unsafe fn new_rows_cols(rows: i32, cols: i32, typ: i32) -> Result { - return_send!(via ocvrs_return); - { sys::cv_Mat_Mat_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = { core::Mat::opencv_from_extern(ret) }; - Ok(ret) - } - - /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often - /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. - /// The constructed matrix can further be assigned to another matrix or matrix expression or can be - /// allocated with Mat::create . In the former case, the old content is de-referenced. + /// * rows: New number of rows. + /// * cols: New number of columns. + /// * type: New matrix type. /// /// ## Overloaded parameters /// - /// ## Parameters - /// * size: 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the - /// number of columns go in the reverse order. - /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or - /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + /// * sizes: Array of integers specifying a new array shape. + /// * type: New matrix type. #[inline] - pub unsafe fn new_size(size: core::Size, typ: i32) -> Result { + unsafe fn create_nd_vec(&mut self, sizes: &core::Vector, typ: i32) -> Result<()> { return_send!(via ocvrs_return); - { sys::cv_Mat_Mat_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; + { sys::cv_Mat_create_const_vectorLintGR_int(self.as_raw_mut_Mat(), sizes.as_raw_VectorOfi32(), typ, ocvrs_return.as_mut_ptr()) }; return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often - /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. - /// The constructed matrix can further be assigned to another matrix or matrix expression or can be - /// allocated with Mat::create . In the former case, the old content is de-referenced. - /// - /// ## Overloaded parameters + /// Increments the reference counter. /// - /// ## Parameters - /// * rows: Number of rows in a 2D array. - /// * cols: Number of columns in a 2D array. - /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or - /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. - /// * s: An optional value to initialize each matrix element with. To set all the matrix elements to - /// the particular value after the construction, use the assignment operator - /// Mat::operator=(const Scalar& value) . + /// The method increments the reference counter associated with the matrix data. If the matrix header + /// points to an external data set (see Mat::Mat ), the reference counter is NULL, and the method has no + /// effect in this case. Normally, to avoid memory leaks, the method should not be called explicitly. It + /// is called implicitly by the matrix assignment operator. The reference counter increment is an atomic + /// operation on the platforms that support it. Thus, it is safe to operate on the same matrices + /// asynchronously in different threads. #[inline] - pub fn new_rows_cols_with_default(rows: i32, cols: i32, typ: i32, s: core::Scalar) -> Result { + unsafe fn addref(&mut self) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_Mat_int_int_int_const_ScalarR(rows, cols, typ, &s, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_Mat_addref(self.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often - /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. - /// The constructed matrix can further be assigned to another matrix or matrix expression or can be - /// allocated with Mat::create . In the former case, the old content is de-referenced. + /// Decrements the reference counter and deallocates the matrix if needed. /// - /// ## Overloaded parameters + /// The method decrements the reference counter associated with the matrix data. When the reference + /// counter reaches 0, the matrix data is deallocated and the data and the reference counter pointers + /// are set to NULL's. If the matrix header points to an external data set (see Mat::Mat ), the + /// reference counter is NULL, and the method has no effect in this case. /// - /// ## Parameters - /// * size: 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the - /// number of columns go in the reverse order. - /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or - /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. - /// * s: An optional value to initialize each matrix element with. To set all the matrix elements to - /// the particular value after the construction, use the assignment operator - /// Mat::operator=(const Scalar& value) . + /// This method can be called manually to force the matrix data deallocation. But since this method is + /// automatically called in the destructor, or by any other method that changes the data pointer, it is + /// usually not needed. The reference counter decrement and check for 0 is an atomic operation on the + /// platforms that support it. Thus, it is safe to operate on the same matrices asynchronously in + /// different threads. #[inline] - pub fn new_size_with_default(size: core::Size, typ: i32, s: core::Scalar) -> Result { + unsafe fn release(&mut self) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_Mat_Size_int_const_ScalarR(&size, typ, &s, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_Mat_release(self.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often - /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. - /// The constructed matrix can further be assigned to another matrix or matrix expression or can be - /// allocated with Mat::create . In the former case, the old content is de-referenced. - /// - /// ## Overloaded parameters - /// - /// ## Parameters - /// * ndims: Array dimensionality. - /// * sizes: Array of integers specifying an n-dimensional array shape. - /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or - /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + /// internal use function, consider to use 'release' method instead; deallocates the matrix data #[inline] - pub unsafe fn new_nd(sizes: &[i32], typ: i32) -> Result { + fn deallocate(&mut self) -> Result<()> { return_send!(via ocvrs_return); - { sys::cv_Mat_Mat_int_const_intX_int(sizes.len().try_into()?, sizes.as_ptr(), typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_Mat_deallocate(self.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often - /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. - /// The constructed matrix can further be assigned to another matrix or matrix expression or can be - /// allocated with Mat::create . In the former case, the old content is de-referenced. - /// - /// ## Overloaded parameters + /// Reserves space for the certain number of rows. /// + /// The method reserves space for sz rows. If the matrix already has enough space to store sz rows, + /// nothing happens. If the matrix is reallocated, the first Mat::rows rows are preserved. The method + /// emulates the corresponding method of the STL vector class. /// ## Parameters - /// * sizes: Array of integers specifying an n-dimensional array shape. - /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or - /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + /// * sz: Number of rows. #[inline] - pub unsafe fn new_nd_vec(sizes: &core::Vector, typ: i32) -> Result { + fn reserve(&mut self, sz: size_t) -> Result<()> { return_send!(via ocvrs_return); - { sys::cv_Mat_Mat_const_vectorLintGR_int(sizes.as_raw_VectorOfi32(), typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_Mat_reserve_size_t(self.as_raw_mut_Mat(), sz, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often - /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. - /// The constructed matrix can further be assigned to another matrix or matrix expression or can be - /// allocated with Mat::create . In the former case, the old content is de-referenced. - /// - /// ## Overloaded parameters + /// Reserves space for the certain number of bytes. /// + /// The method reserves space for sz bytes. If the matrix already has enough space to store sz bytes, + /// nothing happens. If matrix has to be reallocated its previous content could be lost. /// ## Parameters - /// * ndims: Array dimensionality. - /// * sizes: Array of integers specifying an n-dimensional array shape. - /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or - /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. - /// * s: An optional value to initialize each matrix element with. To set all the matrix elements to - /// the particular value after the construction, use the assignment operator - /// Mat::operator=(const Scalar& value) . + /// * sz: Number of bytes. #[inline] - pub fn new_nd_with_default(sizes: &[i32], typ: i32, s: core::Scalar) -> Result { + fn reserve_buffer(&mut self, sz: size_t) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_Mat_int_const_intX_int_const_ScalarR(sizes.len().try_into()?, sizes.as_ptr(), typ, &s, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_reserveBuffer_size_t(self.as_raw_mut_Mat(), sz, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often - /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. - /// The constructed matrix can further be assigned to another matrix or matrix expression or can be - /// allocated with Mat::create . In the former case, the old content is de-referenced. - /// - /// ## Overloaded parameters + /// Changes the number of matrix rows. /// + /// The methods change the number of matrix rows. If the matrix is reallocated, the first + /// min(Mat::rows, sz) rows are preserved. The methods emulate the corresponding methods of the STL + /// vector class. /// ## Parameters - /// * sizes: Array of integers specifying an n-dimensional array shape. - /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or - /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. - /// * s: An optional value to initialize each matrix element with. To set all the matrix elements to - /// the particular value after the construction, use the assignment operator - /// Mat::operator=(const Scalar& value) . + /// * sz: New number of rows. #[inline] - pub fn new_nd_vec_with_default(sizes: &core::Vector, typ: i32, s: core::Scalar) -> Result { + fn resize(&mut self, sz: size_t) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_Mat_const_vectorLintGR_int_const_ScalarR(sizes.as_raw_VectorOfi32(), typ, &s, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_resize_size_t(self.as_raw_mut_Mat(), sz, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often - /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. - /// The constructed matrix can further be assigned to another matrix or matrix expression or can be - /// allocated with Mat::create . In the former case, the old content is de-referenced. + /// Changes the number of matrix rows. + /// + /// The methods change the number of matrix rows. If the matrix is reallocated, the first + /// min(Mat::rows, sz) rows are preserved. The methods emulate the corresponding methods of the STL + /// vector class. + /// ## Parameters + /// * sz: New number of rows. /// /// ## Overloaded parameters /// - /// ## Parameters - /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied - /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and - /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix - /// formed using such a constructor, you also modify the corresponding elements of m . If you want to - /// have an independent copy of the sub-array, use Mat::clone() . + /// * sz: New number of rows. + /// * s: Value assigned to the newly added elements. #[inline] - pub fn copy(m: &impl core::MatTraitConst) -> Result> { + fn resize_with_default(&mut self, sz: size_t, s: core::Scalar) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_Mat_const_MatR(m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_resize_size_t_const_ScalarR(self.as_raw_mut_Mat(), sz, &s, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// @overload + /// Adds elements to the bottom of the matrix. + /// + /// The methods add one or more elements to the bottom of the matrix. They emulate the corresponding + /// method of the STL vector class. When elem is Mat , its type and the number of columns must be the + /// same as in the container matrix. /// ## Parameters - /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied - /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and - /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix - /// formed using such a constructor, you also modify the corresponding elements of m . If you want to - /// have an independent copy of the sub-array, use Mat::clone() . + /// * elem: Added element(s). + /// + /// ## Overloaded parameters + /// + /// * m: Added line(s). #[inline] - pub fn copy_mut(m: &mut impl core::MatTrait) -> Result> { + fn push_back(&mut self, m: &impl core::MatTraitConst) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_Mat_MatR(m.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_push_back_const_MatR(self.as_raw_mut_Mat(), m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - - /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often - /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. - /// The constructed matrix can further be assigned to another matrix or matrix expression or can be - /// allocated with Mat::create . In the former case, the old content is de-referenced. - /// - /// ## Overloaded parameters - /// - /// ## Parameters - /// * rows: Number of rows in a 2D array. - /// * cols: Number of columns in a 2D array. - /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or - /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. - /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not - /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified - /// data, which means that no data is copied. This operation is very efficient and can be used to - /// process external data using OpenCV functions. The external data is not automatically deallocated, so - /// you should take care of it. - /// * step: Number of bytes each matrix row occupies. The value should include the padding bytes at - /// the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed - /// and the actual step is calculated as cols*elemSize(). See Mat::elemSize. + + /// Removes elements from the bottom of the matrix. + /// + /// The method removes one or more rows from the bottom of the matrix. + /// ## Parameters + /// * nelems: Number of removed rows. If it is greater than the total number of rows, an exception + /// is thrown. /// /// ## C++ default parameters - /// * step: AUTO_STEP + /// * nelems: 1 #[inline] - pub unsafe fn new_rows_cols_with_data_unsafe(rows: i32, cols: i32, typ: i32, data: *mut c_void, step: size_t) -> Result { + fn pop_back(&mut self, nelems: size_t) -> Result<()> { return_send!(via ocvrs_return); - { sys::cv_Mat_Mat_int_int_int_voidX_size_t(rows, cols, typ, data, step, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_Mat_pop_back_size_t(self.as_raw_mut_Mat(), nelems, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// @overload + /// Removes elements from the bottom of the matrix. + /// + /// The method removes one or more rows from the bottom of the matrix. /// ## Parameters - /// * rows: Number of rows in a 2D array. - /// * cols: Number of columns in a 2D array. - /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or - /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. - /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not - /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified - /// data, which means that no data is copied. This operation is very efficient and can be used to - /// process external data using OpenCV functions. The external data is not automatically deallocated, so - /// you should take care of it. - /// * step: Number of bytes each matrix row occupies. The value should include the padding bytes at - /// the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed - /// and the actual step is calculated as cols*elemSize(). See Mat::elemSize. + /// * nelems: Number of removed rows. If it is greater than the total number of rows, an exception + /// is thrown. /// /// ## Note - /// This alternative version of [new_rows_cols_with_data_unsafe] function uses the following default values for its arguments: - /// * step: AUTO_STEP + /// This alternative version of [MatTrait::pop_back] function uses the following default values for its arguments: + /// * nelems: 1 #[inline] - pub unsafe fn new_rows_cols_with_data_unsafe_def(rows: i32, cols: i32, typ: i32, data: *mut c_void) -> Result { + fn pop_back_def(&mut self) -> Result<()> { return_send!(via ocvrs_return); - { sys::cv_Mat_Mat_int_int_int_voidX(rows, cols, typ, data, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_Mat_pop_back(self.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often - /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. - /// The constructed matrix can further be assigned to another matrix or matrix expression or can be - /// allocated with Mat::create . In the former case, the old content is de-referenced. + /// Adjusts a submatrix size and position within the parent matrix. /// - /// ## Overloaded parameters + /// The method is complimentary to Mat::locateROI . The typical use of these functions is to determine + /// the submatrix position within the parent matrix and then shift the position somehow. Typically, it + /// can be required for filtering operations when pixels outside of the ROI should be taken into + /// account. When all the method parameters are positive, the ROI needs to grow in all directions by the + /// specified amount, for example: + /// ```C++ + /// A.adjustROI(2, 2, 2, 2); + /// ``` /// - /// ## Parameters - /// * size: 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the - /// number of columns go in the reverse order. - /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or - /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. - /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not - /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified - /// data, which means that no data is copied. This operation is very efficient and can be used to - /// process external data using OpenCV functions. The external data is not automatically deallocated, so - /// you should take care of it. - /// * step: Number of bytes each matrix row occupies. The value should include the padding bytes at - /// the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed - /// and the actual step is calculated as cols*elemSize(). See Mat::elemSize. + /// In this example, the matrix size is increased by 4 elements in each direction. The matrix is shifted + /// by 2 elements to the left and 2 elements up, which brings in all the necessary pixels for the + /// filtering with the 5x5 kernel. /// - /// ## C++ default parameters - /// * step: AUTO_STEP + /// adjustROI forces the adjusted ROI to be inside of the parent matrix that is boundaries of the + /// adjusted ROI are constrained by boundaries of the parent matrix. For example, if the submatrix A is + /// located in the first row of a parent matrix and you called A.adjustROI(2, 2, 2, 2) then A will not + /// be increased in the upward direction. + /// + /// The function is used internally by the OpenCV filtering functions, like filter2D , morphological + /// operations, and so on. + /// ## Parameters + /// * dtop: Shift of the top submatrix boundary upwards. + /// * dbottom: Shift of the bottom submatrix boundary downwards. + /// * dleft: Shift of the left submatrix boundary to the left. + /// * dright: Shift of the right submatrix boundary to the right. + /// ## See also + /// copyMakeBorder #[inline] - pub unsafe fn new_size_with_data_unsafe(size: core::Size, typ: i32, data: *mut c_void, step: size_t) -> Result { + fn adjust_roi(&mut self, dtop: i32, dbottom: i32, dleft: i32, dright: i32) -> Result { return_send!(via ocvrs_return); - { sys::cv_Mat_Mat_Size_int_voidX_size_t(&size, typ, data, step, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_Mat_adjustROI_int_int_int_int(self.as_raw_mut_Mat(), dtop, dbottom, dleft, dright, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::Mat::opencv_from_extern(ret) }; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// @overload - /// ## Parameters - /// * size: 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the - /// number of columns go in the reverse order. - /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or - /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. - /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not - /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified - /// data, which means that no data is copied. This operation is very efficient and can be used to - /// process external data using OpenCV functions. The external data is not automatically deallocated, so - /// you should take care of it. - /// * step: Number of bytes each matrix row occupies. The value should include the padding bytes at - /// the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed - /// and the actual step is calculated as cols*elemSize(). See Mat::elemSize. + /// Extracts a rectangular submatrix. /// - /// ## Note - /// This alternative version of [new_size_with_data_unsafe] function uses the following default values for its arguments: - /// * step: AUTO_STEP + /// The operators make a new header for the specified sub-array of \*this . They are the most + /// generalized forms of Mat::row, Mat::col, Mat::rowRange, and Mat::colRange . For example, + /// `A(Range(0, 10), Range::all())` is equivalent to `A.rowRange(0, 10)`. Similarly to all of the above, + /// the operators are O(1) operations, that is, no matrix data is copied. + /// ## Parameters + /// * rowRange: Start and end row of the extracted submatrix. The upper boundary is not included. To + /// select all the rows, use Range::all(). + /// * colRange: Start and end column of the extracted submatrix. The upper boundary is not included. + /// To select all the columns, use Range::all(). #[inline] - pub unsafe fn new_size_with_data_unsafe_def(size: core::Size, typ: i32, data: *mut c_void) -> Result { + fn rowscols_mut(&mut self, mut row_range: impl core::RangeTrait, mut col_range: impl core::RangeTrait) -> Result> { return_send!(via ocvrs_return); - { sys::cv_Mat_Mat_Size_int_voidX(&size, typ, data, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_Mat_operator___Range_Range(self.as_raw_mut_Mat(), row_range.as_raw_mut_Range(), col_range.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::Mat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often - /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. - /// The constructed matrix can further be assigned to another matrix or matrix expression or can be - /// allocated with Mat::create . In the former case, the old content is de-referenced. - /// - /// ## Overloaded parameters - /// + /// @overload /// ## Parameters - /// * ndims: Array dimensionality. - /// * sizes: Array of integers specifying an n-dimensional array shape. - /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or - /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. - /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not - /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified - /// data, which means that no data is copied. This operation is very efficient and can be used to - /// process external data using OpenCV functions. The external data is not automatically deallocated, so - /// you should take care of it. - /// * steps: Array of ndims-1 steps in case of a multi-dimensional array (the last step is always - /// set to the element size). If not specified, the matrix is assumed to be continuous. - /// - /// ## C++ default parameters - /// * steps: 0 + /// * roi: Extracted submatrix specified as a rectangle. #[inline] - pub unsafe fn new_nd_with_data_unsafe(sizes: &[i32], typ: i32, data: *mut c_void, steps: Option<&[size_t]>) -> Result { + fn roi_mut(&mut self, roi: core::Rect) -> Result> { return_send!(via ocvrs_return); - { sys::cv_Mat_Mat_int_const_intX_int_voidX_const_size_tX(sizes.len().try_into()?, sizes.as_ptr(), typ, data, steps.map_or(::core::ptr::null(), |steps| steps.as_ptr()), ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_Mat_operator___const_RectR(self.as_raw_mut_Mat(), &roi, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::Mat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } /// @overload /// ## Parameters - /// * ndims: Array dimensionality. - /// * sizes: Array of integers specifying an n-dimensional array shape. - /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or - /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. - /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not - /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified - /// data, which means that no data is copied. This operation is very efficient and can be used to - /// process external data using OpenCV functions. The external data is not automatically deallocated, so - /// you should take care of it. - /// * steps: Array of ndims-1 steps in case of a multi-dimensional array (the last step is always - /// set to the element size). If not specified, the matrix is assumed to be continuous. - /// - /// ## Note - /// This alternative version of [new_nd_with_data_unsafe] function uses the following default values for its arguments: - /// * steps: 0 + /// * ranges: Array of selected ranges along each array dimension. #[inline] - pub unsafe fn new_nd_with_data_unsafe_def(sizes: &[i32], typ: i32, data: *mut c_void) -> Result { + fn ranges_mut(&mut self, ranges: &core::Vector) -> Result> { return_send!(via ocvrs_return); - { sys::cv_Mat_Mat_int_const_intX_int_voidX(sizes.len().try_into()?, sizes.as_ptr(), typ, data, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_Mat_operator___const_vectorLRangeGR(self.as_raw_mut_Mat(), ranges.as_raw_VectorOfRange(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::Mat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often - /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. - /// The constructed matrix can further be assigned to another matrix or matrix expression or can be - /// allocated with Mat::create . In the former case, the old content is de-referenced. - /// - /// ## Overloaded parameters + /// Returns a pointer to the specified matrix row. /// + /// The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in + /// Mat::isContinuous to know how to use these methods. /// ## Parameters - /// * sizes: Array of integers specifying an n-dimensional array shape. - /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or - /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. - /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not - /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified - /// data, which means that no data is copied. This operation is very efficient and can be used to - /// process external data using OpenCV functions. The external data is not automatically deallocated, so - /// you should take care of it. - /// * steps: Array of ndims-1 steps in case of a multi-dimensional array (the last step is always - /// set to the element size). If not specified, the matrix is assumed to be continuous. + /// * i0: A 0-based row index. /// /// ## C++ default parameters - /// * steps: 0 + /// * i0: 0 #[inline] - pub unsafe fn new_nd_vec_with_data_unsafe(sizes: &core::Vector, typ: i32, data: *mut c_void, steps: Option<&[size_t]>) -> Result { + fn ptr_mut(&mut self, i0: i32) -> Result<*mut u8> { return_send!(via ocvrs_return); - { sys::cv_Mat_Mat_const_vectorLintGR_int_voidX_const_size_tX(sizes.as_raw_VectorOfi32(), typ, data, steps.map_or(::core::ptr::null(), |steps| steps.as_ptr()), ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_Mat_ptr_int(self.as_raw_mut_Mat(), i0, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// @overload + /// Returns a pointer to the specified matrix row. + /// + /// The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in + /// Mat::isContinuous to know how to use these methods. /// ## Parameters - /// * sizes: Array of integers specifying an n-dimensional array shape. - /// * type: Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or - /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. - /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not - /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified - /// data, which means that no data is copied. This operation is very efficient and can be used to - /// process external data using OpenCV functions. The external data is not automatically deallocated, so - /// you should take care of it. - /// * steps: Array of ndims-1 steps in case of a multi-dimensional array (the last step is always - /// set to the element size). If not specified, the matrix is assumed to be continuous. + /// * i0: A 0-based row index. /// /// ## Note - /// This alternative version of [new_nd_vec_with_data_unsafe] function uses the following default values for its arguments: - /// * steps: 0 + /// This alternative version of [MatTrait::ptr_mut] function uses the following default values for its arguments: + /// * i0: 0 + #[inline] + fn ptr_mut_def(&mut self) -> Result<*mut u8> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Mat_ptr(self.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Returns a pointer to the specified matrix row. + /// + /// The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in + /// Mat::isContinuous to know how to use these methods. + /// ## Parameters + /// * i0: A 0-based row index. + /// + /// ## Overloaded parameters + /// + /// * row: Index along the dimension 0 + /// * col: Index along the dimension 1 #[inline] - pub unsafe fn new_nd_vec_with_data_unsafe_def(sizes: &core::Vector, typ: i32, data: *mut c_void) -> Result { + fn ptr_2d_mut(&mut self, row: i32, col: i32) -> Result<*mut u8> { return_send!(via ocvrs_return); - { sys::cv_Mat_Mat_const_vectorLintGR_int_voidX(sizes.as_raw_VectorOfi32(), typ, data, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_Mat_ptr_int_int(self.as_raw_mut_Mat(), row, col, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often - /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. - /// The constructed matrix can further be assigned to another matrix or matrix expression or can be - /// allocated with Mat::create . In the former case, the old content is de-referenced. - /// - /// ## Overloaded parameters + /// Returns a pointer to the specified matrix row. /// + /// The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in + /// Mat::isContinuous to know how to use these methods. /// ## Parameters - /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied - /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and - /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix - /// formed using such a constructor, you also modify the corresponding elements of m . If you want to - /// have an independent copy of the sub-array, use Mat::clone() . - /// * rowRange: Range of the m rows to take. As usual, the range start is inclusive and the range - /// end is exclusive. Use Range::all() to take all the rows. - /// * colRange: Range of the m columns to take. Use Range::all() to take all the columns. + /// * i0: A 0-based row index. /// - /// ## C++ default parameters - /// * col_range: Range::all() + /// ## Overloaded parameters #[inline] - pub fn rowscols<'boxed>(m: &'boxed impl core::MatTraitConst, row_range: &impl core::RangeTraitConst, col_range: &impl core::RangeTraitConst) -> Result> { + fn ptr_3d_mut(&mut self, i0: i32, i1: i32, i2: i32) -> Result<*mut u8> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_Mat_const_MatR_const_RangeR_const_RangeR(m.as_raw_Mat(), row_range.as_raw_Range(), col_range.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_ptr_int_int_int(self.as_raw_mut_Mat(), i0, i1, i2, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::<'boxed, core::Mat>::opencv_from_extern(ret) }; Ok(ret) } - /// @overload + /// Returns a pointer to the specified matrix row. + /// + /// The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in + /// Mat::isContinuous to know how to use these methods. /// ## Parameters - /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied - /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and - /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix - /// formed using such a constructor, you also modify the corresponding elements of m . If you want to - /// have an independent copy of the sub-array, use Mat::clone() . - /// * rowRange: Range of the m rows to take. As usual, the range start is inclusive and the range - /// end is exclusive. Use Range::all() to take all the rows. - /// * colRange: Range of the m columns to take. Use Range::all() to take all the columns. + /// * i0: A 0-based row index. /// - /// ## Note - /// This alternative version of [rowscols] function uses the following default values for its arguments: - /// * col_range: Range::all() + /// ## Overloaded parameters #[inline] - pub fn rowscols_def_mut<'boxed>(m: &'boxed mut impl core::MatTrait, row_range: &impl core::RangeTraitConst) -> Result> { + fn ptr_nd_mut(&mut self, idx: &[i32]) -> Result<*mut u8> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_Mat_MatR_const_RangeR(m.as_raw_mut_Mat(), row_range.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_ptr_const_intX(self.as_raw_mut_Mat(), idx.as_ptr(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::<'boxed, core::Mat>::opencv_from_extern(ret) }; Ok(ret) } - /// @overload + /// Returns a reference to the specified array element. + /// + /// The template methods return a reference to the specified array element. For the sake of higher + /// performance, the index range checks are only performed in the Debug configuration. + /// + /// Note that the variants with a single index (i) can be used to access elements of single-row or + /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and + /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` + /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. + /// + /// The example below initializes a Hilbert matrix: + /// ```C++ + /// Mat H(100, 100, CV_64F); + /// for(int i = 0; i < H.rows; i++) + /// for(int j = 0; j < H.cols; j++) + /// H.at(i,j)=1./(i+j+1); + /// ``` + /// + /// + /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends + /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: + /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. + /// /// ## Parameters - /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied - /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and - /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix - /// formed using such a constructor, you also modify the corresponding elements of m . If you want to - /// have an independent copy of the sub-array, use Mat::clone() . - /// * rowRange: Range of the m rows to take. As usual, the range start is inclusive and the range - /// end is exclusive. Use Range::all() to take all the rows. - /// * colRange: Range of the m columns to take. Use Range::all() to take all the columns. + /// * i0: Index along the dimension 0 + /// + /// ## C++ default parameters + /// * i0: 0 + #[inline] + fn at_mut(&mut self, i0: i32) -> Result<&mut T> { + core::mat_forward::at_mut(self, i0) + } + + /// Returns a reference to the specified array element. + /// + /// The template methods return a reference to the specified array element. For the sake of higher + /// performance, the index range checks are only performed in the Debug configuration. + /// + /// Note that the variants with a single index (i) can be used to access elements of single-row or + /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and + /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` + /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. + /// + /// The example below initializes a Hilbert matrix: + /// ```C++ + /// Mat H(100, 100, CV_64F); + /// for(int i = 0; i < H.rows; i++) + /// for(int j = 0; j < H.cols; j++) + /// H.at(i,j)=1./(i+j+1); + /// ``` + /// + /// + /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends + /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: + /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. + /// + /// ## Parameters + /// * i0: Index along the dimension 0 /// /// ## Note - /// This alternative version of [rowscols] function uses the following default values for its arguments: - /// * col_range: Range::all() + /// This alternative version of [MatTrait::at_mut] function uses the following default values for its arguments: + /// * i0: 0 #[inline] - pub fn rowscols_def<'boxed>(m: &'boxed impl core::MatTraitConst, row_range: &impl core::RangeTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_Mat_const_MatR_const_RangeR(m.as_raw_Mat(), row_range.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::<'boxed, core::Mat>::opencv_from_extern(ret) }; - Ok(ret) + fn at_mut_def(&mut self) -> Result<&mut T> { + core::mat_forward::at_mut_def(self, ) } - /// @overload + /// Returns a reference to the specified array element. + /// + /// The template methods return a reference to the specified array element. For the sake of higher + /// performance, the index range checks are only performed in the Debug configuration. + /// + /// Note that the variants with a single index (i) can be used to access elements of single-row or + /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and + /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` + /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. + /// + /// The example below initializes a Hilbert matrix: + /// ```C++ + /// Mat H(100, 100, CV_64F); + /// for(int i = 0; i < H.rows; i++) + /// for(int j = 0; j < H.cols; j++) + /// H.at(i,j)=1./(i+j+1); + /// ``` + /// + /// + /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends + /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: + /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. + /// /// ## Parameters - /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied - /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and - /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix - /// formed using such a constructor, you also modify the corresponding elements of m . If you want to - /// have an independent copy of the sub-array, use Mat::clone() . - /// * rowRange: Range of the m rows to take. As usual, the range start is inclusive and the range - /// end is exclusive. Use Range::all() to take all the rows. - /// * colRange: Range of the m columns to take. Use Range::all() to take all the columns. + /// * i0: Index along the dimension 0 + /// + /// ## Overloaded parameters + /// + /// * row: Index along the dimension 0 + /// * col: Index along the dimension 1 + #[inline] + fn at_2d_mut(&mut self, row: i32, col: i32) -> Result<&mut T> { + core::mat_forward::at_2d_mut(self, row, col) + } + + /// Returns a reference to the specified array element. + /// + /// The template methods return a reference to the specified array element. For the sake of higher + /// performance, the index range checks are only performed in the Debug configuration. + /// + /// Note that the variants with a single index (i) can be used to access elements of single-row or + /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and + /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` + /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. + /// + /// The example below initializes a Hilbert matrix: + /// ```C++ + /// Mat H(100, 100, CV_64F); + /// for(int i = 0; i < H.rows; i++) + /// for(int j = 0; j < H.cols; j++) + /// H.at(i,j)=1./(i+j+1); + /// ``` + /// + /// + /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends + /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: + /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. + /// + /// ## Parameters + /// * i0: Index along the dimension 0 + /// + /// ## Overloaded parameters + /// + /// * i0: Index along the dimension 0 + /// * i1: Index along the dimension 1 + /// * i2: Index along the dimension 2 + #[inline] + fn at_3d_mut(&mut self, i0: i32, i1: i32, i2: i32) -> Result<&mut T> { + core::mat_forward::at_3d_mut(self, i0, i1, i2) + } + + /// Returns a reference to the specified array element. + /// + /// The template methods return a reference to the specified array element. For the sake of higher + /// performance, the index range checks are only performed in the Debug configuration. + /// + /// Note that the variants with a single index (i) can be used to access elements of single-row or + /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and + /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` + /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. + /// + /// The example below initializes a Hilbert matrix: + /// ```C++ + /// Mat H(100, 100, CV_64F); + /// for(int i = 0; i < H.rows; i++) + /// for(int j = 0; j < H.cols; j++) + /// H.at(i,j)=1./(i+j+1); + /// ``` /// - /// ## C++ default parameters - /// * col_range: Range::all() - #[inline] - pub fn rowscols_mut<'boxed>(m: &'boxed mut impl core::MatTrait, row_range: &impl core::RangeTraitConst, col_range: &impl core::RangeTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_Mat_MatR_const_RangeR_const_RangeR(m.as_raw_mut_Mat(), row_range.as_raw_Range(), col_range.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::<'boxed, core::Mat>::opencv_from_extern(ret) }; - Ok(ret) - } - - /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often - /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. - /// The constructed matrix can further be assigned to another matrix or matrix expression or can be - /// allocated with Mat::create . In the former case, the old content is de-referenced. /// - /// ## Overloaded parameters + /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends + /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: + /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. /// /// ## Parameters - /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied - /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and - /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix - /// formed using such a constructor, you also modify the corresponding elements of m . If you want to - /// have an independent copy of the sub-array, use Mat::clone() . - /// * roi: Region of interest. + /// * i0: Index along the dimension 0 + /// + /// ## Overloaded parameters + /// + /// * idx: Array of Mat::dims indices. #[inline] - pub fn roi(m: &impl core::MatTraitConst, roi: core::Rect) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_Mat_const_MatR_const_RectR(m.as_raw_Mat(), &roi, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; - Ok(ret) + fn at_nd_mut(&mut self, idx: &[i32]) -> Result<&mut T> { + core::mat_forward::at_nd_mut(self, idx) } - /// @overload + /// Returns a reference to the specified array element. + /// + /// The template methods return a reference to the specified array element. For the sake of higher + /// performance, the index range checks are only performed in the Debug configuration. + /// + /// Note that the variants with a single index (i) can be used to access elements of single-row or + /// single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and + /// B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` + /// instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. + /// + /// The example below initializes a Hilbert matrix: + /// ```C++ + /// Mat H(100, 100, CV_64F); + /// for(int i = 0; i < H.rows; i++) + /// for(int j = 0; j < H.cols; j++) + /// H.at(i,j)=1./(i+j+1); + /// ``` + /// + /// + /// Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends + /// on the image from which you are trying to retrieve the data. The table below gives a better insight in this: + /// - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. + /// - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. + /// /// ## Parameters - /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied - /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and - /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix - /// formed using such a constructor, you also modify the corresponding elements of m . If you want to - /// have an independent copy of the sub-array, use Mat::clone() . - /// * roi: Region of interest. - #[inline] - pub fn roi_mut(m: &mut impl core::MatTrait, roi: core::Rect) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_Mat_MatR_const_RectR(m.as_raw_mut_Mat(), &roi, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// These are various constructors that form a matrix. As noted in the AutomaticAllocation, often - /// the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. - /// The constructed matrix can further be assigned to another matrix or matrix expression or can be - /// allocated with Mat::create . In the former case, the old content is de-referenced. + /// * i0: Index along the dimension 0 /// /// ## Overloaded parameters /// - /// ## Parameters - /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied - /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and - /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix - /// formed using such a constructor, you also modify the corresponding elements of m . If you want to - /// have an independent copy of the sub-array, use Mat::clone() . - /// * ranges: Array of selected ranges of m along each dimensionality. + /// special versions for 2D arrays (especially convenient for referencing image pixels) + /// * pt: Element position specified as Point(j,i) . #[inline] - pub fn ranges<'boxed>(m: &'boxed impl core::MatTraitConst, ranges: &core::Vector) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_Mat_const_MatR_const_vectorLRangeGR(m.as_raw_Mat(), ranges.as_raw_VectorOfRange(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::<'boxed, core::Mat>::opencv_from_extern(ret) }; - Ok(ret) + fn at_pt_mut(&mut self, pt: core::Point) -> Result<&mut T> { + core::mat_forward::at_pt_mut(self, pt) } - /// @overload - /// ## Parameters - /// * m: Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied - /// by these constructors. Instead, the header pointing to m data or its sub-array is constructed and - /// associated with it. The reference counter, if any, is incremented. So, when you modify the matrix - /// formed using such a constructor, you also modify the corresponding elements of m . If you want to - /// have an independent copy of the sub-array, use Mat::clone() . - /// * ranges: Array of selected ranges of m along each dimensionality. #[inline] - pub fn ranges_mut<'boxed>(m: &'boxed mut impl core::MatTrait, ranges: &core::Vector) -> Result> { + fn set(&mut self, mut m: core::Mat) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_Mat_MatR_const_vectorLRangeGR(m.as_raw_mut_Mat(), ranges.as_raw_VectorOfRange(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_operatorST_MatRR(self.as_raw_mut_Mat(), m.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::<'boxed, core::Mat>::opencv_from_extern(ret) }; Ok(ret) } - /// download data from GpuMat + /// internal use method: updates the continuity flag #[inline] - pub fn from_gpumat(m: &impl core::GpuMatTraitConst) -> Result { + fn update_continuity_flag(&mut self) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_Mat_const_GpuMatR(m.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Mat_updateContinuityFlag(self.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// creates a diagonal matrix - /// - /// The method creates a square diagonal matrix from specified main diagonal. - /// ## Parameters - /// * d: One-dimensional matrix that represents the main diagonal. + } + + impl Default for Mat { #[inline] - #[must_use] - pub fn diag_mat(d: &impl core::MatTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_diag_const_MatR(d.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; - Ok(ret) + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() } + } - /// Returns a zero array of the specified size and type. - /// - /// The method returns a Matlab-style zero array initializer. It can be used to quickly form a constant - /// array as a function parameter, part of a matrix expression, or as a matrix initializer: - /// ```C++ - /// Mat A; - /// A = Mat::zeros(3, 3, CV_32F); - /// ``` - /// - /// In the example above, a new matrix is allocated only if A is not a 3x3 floating-point matrix. - /// Otherwise, the existing matrix A is filled with zeros. - /// ## Parameters - /// * rows: Number of rows. - /// * cols: Number of columns. - /// * type: Created matrix type. + impl Clone for Mat { #[inline] - #[must_use] - pub fn zeros(rows: i32, cols: i32, typ: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_zeros_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; - Ok(ret) + /// Calls try_clone() and panics if that fails + fn clone(&self) -> Self { + self.try_clone().expect("Cannot clone Mat") } + } - /// Returns a zero array of the specified size and type. - /// - /// The method returns a Matlab-style zero array initializer. It can be used to quickly form a constant - /// array as a function parameter, part of a matrix expression, or as a matrix initializer: - /// ```C++ - /// Mat A; - /// A = Mat::zeros(3, 3, CV_32F); - /// ``` - /// - /// In the example above, a new matrix is allocated only if A is not a 3x3 floating-point matrix. - /// Otherwise, the existing matrix A is filled with zeros. - /// ## Parameters - /// * rows: Number of rows. - /// * cols: Number of columns. - /// * type: Created matrix type. - /// - /// ## Overloaded parameters - /// - /// * size: Alternative to the matrix size specification Size(cols, rows) . - /// * type: Created matrix type. + impl core::MatTraitConst for Mat { + #[inline] fn as_raw_Mat(&self) -> *const c_void { self.as_raw() } + } + + impl core::MatTrait for Mat { + #[inline] fn as_raw_mut_Mat(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Mat, core::MatTraitConst, as_raw_Mat, core::MatTrait, as_raw_mut_Mat } + + /// /////////////////////////////// MatConstIterator ////////////////////////////////// + pub struct MatConstIterator { + ptr: *mut c_void, + } + + opencv_type_boxed! { MatConstIterator } + + impl Drop for MatConstIterator { #[inline] - #[must_use] - pub fn zeros_size(size: core::Size, typ: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_zeros_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_MatConstIterator_delete(self.as_raw_mut_MatConstIterator()) }; } + } - /// Returns a zero array of the specified size and type. - /// - /// The method returns a Matlab-style zero array initializer. It can be used to quickly form a constant - /// array as a function parameter, part of a matrix expression, or as a matrix initializer: - /// ```C++ - /// Mat A; - /// A = Mat::zeros(3, 3, CV_32F); - /// ``` - /// - /// In the example above, a new matrix is allocated only if A is not a 3x3 floating-point matrix. - /// Otherwise, the existing matrix A is filled with zeros. - /// ## Parameters - /// * rows: Number of rows. - /// * cols: Number of columns. - /// * type: Created matrix type. - /// - /// ## Overloaded parameters - /// - /// * ndims: Array dimensionality. - /// * sz: Array of integers specifying the array shape. - /// * type: Created matrix type. + unsafe impl Send for MatConstIterator {} + + impl MatConstIterator { + /// default constructor #[inline] - #[must_use] - pub fn zeros_nd(sz: &[i32], typ: i32) -> Result { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_zeros_int_const_intX_int(sz.len().try_into()?, sz.as_ptr(), typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MatConstIterator_MatConstIterator(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; + let ret = unsafe { core::MatConstIterator::opencv_from_extern(ret) }; Ok(ret) } - /// Returns an array of all 1's of the specified size and type. - /// - /// The method returns a Matlab-style 1's array initializer, similarly to Mat::zeros. Note that using - /// this method you can initialize an array with an arbitrary value, using the following Matlab idiom: - /// ```C++ - /// Mat A = Mat::ones(100, 100, CV_8U)*3; // make 100x100 matrix filled with 3. - /// ``` - /// - /// The above operation does not form a 100x100 matrix of 1's and then multiply it by 3. Instead, it - /// just remembers the scale factor (3 in this case) and use it when actually invoking the matrix - /// initializer. - /// - /// Note: In case of multi-channels type, only the first channel will be initialized with 1's, the - /// others will be set to 0's. - /// ## Parameters - /// * rows: Number of rows. - /// * cols: Number of columns. - /// * type: Created matrix type. + /// constructor that sets the iterator to the beginning of the matrix #[inline] - #[must_use] - pub fn ones(rows: i32, cols: i32, typ: i32) -> Result { + pub fn over(_m: &impl core::MatTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_ones_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MatConstIterator_MatConstIterator_const_MatX(_m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; + let ret = unsafe { core::MatConstIterator::opencv_from_extern(ret) }; Ok(ret) } - /// Returns an array of all 1's of the specified size and type. - /// - /// The method returns a Matlab-style 1's array initializer, similarly to Mat::zeros. Note that using - /// this method you can initialize an array with an arbitrary value, using the following Matlab idiom: - /// ```C++ - /// Mat A = Mat::ones(100, 100, CV_8U)*3; // make 100x100 matrix filled with 3. - /// ``` - /// - /// The above operation does not form a 100x100 matrix of 1's and then multiply it by 3. Instead, it - /// just remembers the scale factor (3 in this case) and use it when actually invoking the matrix - /// initializer. - /// - /// Note: In case of multi-channels type, only the first channel will be initialized with 1's, the - /// others will be set to 0's. - /// ## Parameters - /// * rows: Number of rows. - /// * cols: Number of columns. - /// * type: Created matrix type. - /// - /// ## Overloaded parameters + /// constructor that sets the iterator to the specified element of the matrix /// - /// * size: Alternative to the matrix size specification Size(cols, rows) . - /// * type: Created matrix type. + /// ## C++ default parameters + /// * _col: 0 #[inline] - #[must_use] - pub fn ones_size(size: core::Size, typ: i32) -> Result { + pub fn with_rows_cols(_m: &impl core::MatTraitConst, _row: i32, _col: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_ones_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MatConstIterator_MatConstIterator_const_MatX_int_int(_m.as_raw_Mat(), _row, _col, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; + let ret = unsafe { core::MatConstIterator::opencv_from_extern(ret) }; Ok(ret) } - /// Returns an array of all 1's of the specified size and type. - /// - /// The method returns a Matlab-style 1's array initializer, similarly to Mat::zeros. Note that using - /// this method you can initialize an array with an arbitrary value, using the following Matlab idiom: - /// ```C++ - /// Mat A = Mat::ones(100, 100, CV_8U)*3; // make 100x100 matrix filled with 3. - /// ``` - /// - /// The above operation does not form a 100x100 matrix of 1's and then multiply it by 3. Instead, it - /// just remembers the scale factor (3 in this case) and use it when actually invoking the matrix - /// initializer. - /// - /// Note: In case of multi-channels type, only the first channel will be initialized with 1's, the - /// others will be set to 0's. - /// ## Parameters - /// * rows: Number of rows. - /// * cols: Number of columns. - /// * type: Created matrix type. - /// - /// ## Overloaded parameters + /// constructor that sets the iterator to the specified element of the matrix /// - /// * ndims: Array dimensionality. - /// * sz: Array of integers specifying the array shape. - /// * type: Created matrix type. + /// ## Note + /// This alternative version of [with_rows_cols] function uses the following default values for its arguments: + /// * _col: 0 #[inline] - #[must_use] - pub fn ones_nd(sz: &[i32], typ: i32) -> Result { + pub fn with_rows_cols_def(_m: &impl core::MatTraitConst, _row: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_ones_int_const_intX_int(sz.len().try_into()?, sz.as_ptr(), typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MatConstIterator_MatConstIterator_const_MatX_int(_m.as_raw_Mat(), _row, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; + let ret = unsafe { core::MatConstIterator::opencv_from_extern(ret) }; Ok(ret) } - /// Returns an identity matrix of the specified size and type. - /// - /// The method returns a Matlab-style identity matrix initializer, similarly to Mat::zeros. Similarly to - /// Mat::ones, you can use a scale operation to create a scaled identity matrix efficiently: - /// ```C++ - /// // make a 4x4 diagonal matrix with 0.1's on the diagonal. - /// Mat A = Mat::eye(4, 4, CV_32F)*0.1; - /// ``` - /// - /// - /// Note: In case of multi-channels type, identity matrix will be initialized only for the first channel, - /// the others will be set to 0's - /// ## Parameters - /// * rows: Number of rows. - /// * cols: Number of columns. - /// * type: Created matrix type. + /// constructor that sets the iterator to the specified element of the matrix #[inline] - #[must_use] - pub fn eye(rows: i32, cols: i32, typ: i32) -> Result { + pub fn with_start(_m: &impl core::MatTraitConst, _pt: core::Point) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_eye_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MatConstIterator_MatConstIterator_const_MatX_Point(_m.as_raw_Mat(), &_pt, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; + let ret = unsafe { core::MatConstIterator::opencv_from_extern(ret) }; Ok(ret) } - /// Returns an identity matrix of the specified size and type. - /// - /// The method returns a Matlab-style identity matrix initializer, similarly to Mat::zeros. Similarly to - /// Mat::ones, you can use a scale operation to create a scaled identity matrix efficiently: - /// ```C++ - /// // make a 4x4 diagonal matrix with 0.1's on the diagonal. - /// Mat A = Mat::eye(4, 4, CV_32F)*0.1; - /// ``` - /// - /// - /// Note: In case of multi-channels type, identity matrix will be initialized only for the first channel, - /// the others will be set to 0's - /// ## Parameters - /// * rows: Number of rows. - /// * cols: Number of columns. - /// * type: Created matrix type. - /// - /// ## Overloaded parameters - /// - /// * size: Alternative matrix size specification as Size(cols, rows) . - /// * type: Created matrix type. + /// copy constructor #[inline] - #[must_use] - pub fn eye_size(size: core::Size, typ: i32) -> Result { + pub fn copy(it: &impl core::MatConstIteratorTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Mat_eye_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MatConstIterator_MatConstIterator_const_MatConstIteratorR(it.as_raw_MatConstIterator(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; + let ret = unsafe { core::MatConstIterator::opencv_from_extern(ret) }; Ok(ret) } } - impl Clone for Mat { - #[inline] - /// Calls try_clone() and panics if that fails - fn clone(&self) -> Self { - self.try_clone().expect("Cannot clone Mat") - } - } - - impl Default for Mat { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - /// Constant methods for [core::MatConstIterator] pub trait MatConstIteratorTraitConst { fn as_raw_MatConstIterator(&self) -> *const c_void; @@ -21272,22 +21363,19 @@ pub mod core { } - /// /////////////////////////////// MatConstIterator ////////////////////////////////// - pub struct MatConstIterator { - ptr: *mut c_void, - } - - opencv_type_boxed! { MatConstIterator } - - impl Drop for MatConstIterator { + impl std::fmt::Debug for MatConstIterator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_MatConstIterator_delete(self.as_raw_mut_MatConstIterator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MatConstIterator") + .field("m", &core::MatConstIteratorTraitConst::m(self)) + .field("elem_size", &core::MatConstIteratorTraitConst::elem_size(self)) + .field("ptr", &core::MatConstIteratorTraitConst::ptr(self)) + .field("slice_start", &core::MatConstIteratorTraitConst::slice_start(self)) + .field("slice_end", &core::MatConstIteratorTraitConst::slice_end(self)) + .finish() } } - unsafe impl Send for MatConstIterator {} - impl core::MatConstIteratorTraitConst for MatConstIterator { #[inline] fn as_raw_MatConstIterator(&self) -> *const c_void { self.as_raw() } } @@ -21298,95 +21386,126 @@ pub mod core { boxed_ref! { MatConstIterator, core::MatConstIteratorTraitConst, as_raw_MatConstIterator, core::MatConstIteratorTrait, as_raw_mut_MatConstIterator } - impl MatConstIterator { - /// default constructor - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_MatConstIterator_MatConstIterator(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::MatConstIterator::opencv_from_extern(ret) }; - Ok(ret) - } + /// Matrix expression representation + /// @anchor MatrixExpressions + /// This is a list of implemented matrix operations that can be combined in arbitrary complex + /// expressions (here A, B stand for matrices ( Mat ), s for a scalar ( Scalar ), alpha for a + /// real-valued scalar ( double )): + /// * Addition, subtraction, negation: `A+B`, `A-B`, `A+s`, `A-s`, `s+A`, `s-A`, `-A` + /// * Scaling: `A*alpha` + /// * Per-element multiplication and division: `A.mul(B)`, `A/B`, `alpha/A` + /// * Matrix multiplication: `A*B` + /// * Transposition: `A.t()` (means AT) + /// * Matrix inversion and pseudo-inversion, solving linear systems and least-squares problems: + /// `A.inv([method]) (~ A-1)`, `A.inv([method])*B (~ X: AX=B)` + /// * Comparison: `A cmpop B`, `A cmpop alpha`, `alpha cmpop A`, where *cmpop* is one of + /// `>`, `>=`, `==`, `!=`, `<=`, `<`. The result of comparison is an 8-bit single channel mask whose + /// elements are set to 255 (if the particular element or pair of elements satisfy the condition) or + /// 0. + /// * Bitwise logical operations: `A logicop B`, `A logicop s`, `s logicop A`, `~A`, where *logicop* is one of + /// `&`, `|`, `^`. + /// * Element-wise minimum and maximum: `min(A, B)`, `min(A, alpha)`, `max(A, B)`, `max(A, alpha)` + /// * Element-wise absolute value: `abs(A)` + /// * Cross-product, dot-product: `A.cross(B)`, `A.dot(B)` + /// * Any function of matrix or matrices and scalars that returns a matrix or a scalar, such as norm, + /// mean, sum, countNonZero, trace, determinant, repeat, and others. + /// * Matrix initializers ( Mat::eye(), Mat::zeros(), Mat::ones() ), matrix comma-separated + /// initializers, matrix constructors and operators that extract sub-matrices (see Mat description). + /// * Mat_() constructors to cast the result to the proper type. + /// + /// Note: Comma-separated initializers and probably some other operations may require additional + /// explicit Mat() or Mat_() constructor calls to resolve a possible ambiguity. + /// + /// Here are examples of matrix expressions: + /// ```C++ + /// // compute pseudo-inverse of A, equivalent to A.inv(DECOMP_SVD) + /// SVD svd(A); + /// Mat pinvA = svd.vt.t()*Mat::diag(1./svd.w)*svd.u.t(); + /// + /// // compute the new vector of parameters in the Levenberg-Marquardt algorithm + /// x -= (A.t()*A + lambda*Mat::eye(A.cols,A.cols,A.type())).inv(DECOMP_CHOLESKY)*(A.t()*err); + /// + /// // sharpen image using "unsharp mask" algorithm + /// Mat blurred; double sigma = 1, threshold = 5, amount = 1; + /// GaussianBlur(img, blurred, Size(), sigma, sigma); + /// Mat lowContrastMask = abs(img - blurred) < threshold; + /// Mat sharpened = img*(1+amount) + blurred*(-amount); + /// img.copyTo(sharpened, lowContrastMask); + /// ``` + /// + pub struct MatExpr { + ptr: *mut c_void, + } - /// constructor that sets the iterator to the beginning of the matrix + opencv_type_boxed! { MatExpr } + + impl Drop for MatExpr { #[inline] - pub fn over(_m: &impl core::MatTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_MatConstIterator_MatConstIterator_const_MatX(_m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::MatConstIterator::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_MatExpr_delete(self.as_raw_mut_MatExpr()) }; } + } - /// constructor that sets the iterator to the specified element of the matrix - /// - /// ## C++ default parameters - /// * _col: 0 + unsafe impl Send for MatExpr {} + + impl MatExpr { #[inline] - pub fn with_rows_cols(_m: &impl core::MatTraitConst, _row: i32, _col: i32) -> Result { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_MatConstIterator_MatConstIterator_const_MatX_int_int(_m.as_raw_Mat(), _row, _col, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MatExpr_MatExpr(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::MatConstIterator::opencv_from_extern(ret) }; + let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; Ok(ret) } - /// constructor that sets the iterator to the specified element of the matrix - /// - /// ## Note - /// This alternative version of [with_rows_cols] function uses the following default values for its arguments: - /// * _col: 0 #[inline] - pub fn with_rows_cols_def(_m: &impl core::MatTraitConst, _row: i32) -> Result { + pub fn from_mat(m: &impl core::MatTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_MatConstIterator_MatConstIterator_const_MatX_int(_m.as_raw_Mat(), _row, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MatExpr_MatExpr_const_MatR(m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::MatConstIterator::opencv_from_extern(ret) }; + let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; Ok(ret) } - /// constructor that sets the iterator to the specified element of the matrix + /// ## C++ default parameters + /// * _a: Mat() + /// * _b: Mat() + /// * _c: Mat() + /// * _alpha: 1 + /// * _beta: 1 + /// * _s: Scalar() #[inline] - pub fn with_start(_m: &impl core::MatTraitConst, _pt: core::Point) -> Result { + pub fn new(_op: &impl core::MatOpTraitConst, _flags: i32, _a: &impl core::MatTraitConst, _b: &impl core::MatTraitConst, _c: &impl core::MatTraitConst, _alpha: f64, _beta: f64, _s: core::Scalar) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_MatConstIterator_MatConstIterator_const_MatX_Point(_m.as_raw_Mat(), &_pt, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MatExpr_MatExpr_const_MatOpX_int_const_MatR_const_MatR_const_MatR_double_double_const_ScalarR(_op.as_raw_MatOp(), _flags, _a.as_raw_Mat(), _b.as_raw_Mat(), _c.as_raw_Mat(), _alpha, _beta, &_s, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::MatConstIterator::opencv_from_extern(ret) }; + let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; Ok(ret) } - /// copy constructor + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * _a: Mat() + /// * _b: Mat() + /// * _c: Mat() + /// * _alpha: 1 + /// * _beta: 1 + /// * _s: Scalar() #[inline] - pub fn copy(it: &impl core::MatConstIteratorTraitConst) -> Result { + pub fn new_def(_op: &impl core::MatOpTraitConst, _flags: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_MatConstIterator_MatConstIterator_const_MatConstIteratorR(it.as_raw_MatConstIterator(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MatExpr_MatExpr_const_MatOpX_int(_op.as_raw_MatOp(), _flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::MatConstIterator::opencv_from_extern(ret) }; + let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for MatConstIterator { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MatConstIterator") - .field("m", &core::MatConstIteratorTraitConst::m(self)) - .field("elem_size", &core::MatConstIteratorTraitConst::elem_size(self)) - .field("ptr", &core::MatConstIteratorTraitConst::ptr(self)) - .field("slice_start", &core::MatConstIteratorTraitConst::slice_start(self)) - .field("slice_end", &core::MatConstIteratorTraitConst::slice_end(self)) - .finish() - } - } - /// Constant methods for [core::MatExpr] pub trait MatExprTraitConst { fn as_raw_MatExpr(&self) -> *const c_void; @@ -21585,240 +21704,110 @@ pub mod core { fn mul_matexpr_def(&self, e: &impl core::MatExprTraitConst) -> Result { return_send!(via ocvrs_return); unsafe { sys::cv_MatExpr_mul_const_const_MatExprR(self.as_raw_MatExpr(), e.as_raw_MatExpr(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## C++ default parameters - /// * scale: 1 - #[inline] - fn mul(&self, m: &impl core::MatTraitConst, scale: f64) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_MatExpr_mul_const_const_MatR_double(self.as_raw_MatExpr(), m.as_raw_Mat(), scale, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [MatExprTraitConst::mul] function uses the following default values for its arguments: - /// * scale: 1 - #[inline] - fn mul_def(&self, m: &impl core::MatTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_MatExpr_mul_const_const_MatR(self.as_raw_MatExpr(), m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - fn cross(&self, m: &impl core::MatTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_MatExpr_cross_const_const_MatR(self.as_raw_MatExpr(), m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - fn dot(&self, m: &impl core::MatTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_MatExpr_dot_const_const_MatR(self.as_raw_MatExpr(), m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - /// Mutable methods for [core::MatExpr] - pub trait MatExprTrait: core::MatExprTraitConst { - fn as_raw_mut_MatExpr(&mut self) -> *mut c_void; - - #[inline] - fn set_flags(&mut self, val: i32) { - let ret = unsafe { sys::cv_MatExpr_propFlags_const_int(self.as_raw_mut_MatExpr(), val) }; - ret - } - - #[inline] - fn set_a(&mut self, val: core::Mat) { - let ret = unsafe { sys::cv_MatExpr_propA_const_Mat(self.as_raw_mut_MatExpr(), val.as_raw_Mat()) }; - ret - } - - #[inline] - fn set_b(&mut self, val: core::Mat) { - let ret = unsafe { sys::cv_MatExpr_propB_const_Mat(self.as_raw_mut_MatExpr(), val.as_raw_Mat()) }; - ret - } - - #[inline] - fn set_c(&mut self, val: core::Mat) { - let ret = unsafe { sys::cv_MatExpr_propC_const_Mat(self.as_raw_mut_MatExpr(), val.as_raw_Mat()) }; - ret - } - - #[inline] - fn set_alpha(&mut self, val: f64) { - let ret = unsafe { sys::cv_MatExpr_propAlpha_const_double(self.as_raw_mut_MatExpr(), val) }; - ret - } - - #[inline] - fn set_beta(&mut self, val: f64) { - let ret = unsafe { sys::cv_MatExpr_propBeta_const_double(self.as_raw_mut_MatExpr(), val) }; - ret - } - - #[inline] - fn set_s(&mut self, val: core::Scalar) { - let ret = unsafe { sys::cv_MatExpr_propS_const_Scalar(self.as_raw_mut_MatExpr(), &val) }; - ret - } - - #[inline] - fn swap(&mut self, b: &mut impl core::MatExprTrait) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_MatExpr_swap_MatExprR(self.as_raw_mut_MatExpr(), b.as_raw_mut_MatExpr(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - /// Matrix expression representation - /// @anchor MatrixExpressions - /// This is a list of implemented matrix operations that can be combined in arbitrary complex - /// expressions (here A, B stand for matrices ( Mat ), s for a scalar ( Scalar ), alpha for a - /// real-valued scalar ( double )): - /// * Addition, subtraction, negation: `A+B`, `A-B`, `A+s`, `A-s`, `s+A`, `s-A`, `-A` - /// * Scaling: `A*alpha` - /// * Per-element multiplication and division: `A.mul(B)`, `A/B`, `alpha/A` - /// * Matrix multiplication: `A*B` - /// * Transposition: `A.t()` (means AT) - /// * Matrix inversion and pseudo-inversion, solving linear systems and least-squares problems: - /// `A.inv([method]) (~ A-1)`, `A.inv([method])*B (~ X: AX=B)` - /// * Comparison: `A cmpop B`, `A cmpop alpha`, `alpha cmpop A`, where *cmpop* is one of - /// `>`, `>=`, `==`, `!=`, `<=`, `<`. The result of comparison is an 8-bit single channel mask whose - /// elements are set to 255 (if the particular element or pair of elements satisfy the condition) or - /// 0. - /// * Bitwise logical operations: `A logicop B`, `A logicop s`, `s logicop A`, `~A`, where *logicop* is one of - /// `&`, `|`, `^`. - /// * Element-wise minimum and maximum: `min(A, B)`, `min(A, alpha)`, `max(A, B)`, `max(A, alpha)` - /// * Element-wise absolute value: `abs(A)` - /// * Cross-product, dot-product: `A.cross(B)`, `A.dot(B)` - /// * Any function of matrix or matrices and scalars that returns a matrix or a scalar, such as norm, - /// mean, sum, countNonZero, trace, determinant, repeat, and others. - /// * Matrix initializers ( Mat::eye(), Mat::zeros(), Mat::ones() ), matrix comma-separated - /// initializers, matrix constructors and operators that extract sub-matrices (see Mat description). - /// * Mat_() constructors to cast the result to the proper type. - /// - /// Note: Comma-separated initializers and probably some other operations may require additional - /// explicit Mat() or Mat_() constructor calls to resolve a possible ambiguity. - /// - /// Here are examples of matrix expressions: - /// ```C++ - /// // compute pseudo-inverse of A, equivalent to A.inv(DECOMP_SVD) - /// SVD svd(A); - /// Mat pinvA = svd.vt.t()*Mat::diag(1./svd.w)*svd.u.t(); - /// - /// // compute the new vector of parameters in the Levenberg-Marquardt algorithm - /// x -= (A.t()*A + lambda*Mat::eye(A.cols,A.cols,A.type())).inv(DECOMP_CHOLESKY)*(A.t()*err); - /// - /// // sharpen image using "unsharp mask" algorithm - /// Mat blurred; double sigma = 1, threshold = 5, amount = 1; - /// GaussianBlur(img, blurred, Size(), sigma, sigma); - /// Mat lowContrastMask = abs(img - blurred) < threshold; - /// Mat sharpened = img*(1+amount) + blurred*(-amount); - /// img.copyTo(sharpened, lowContrastMask); - /// ``` - /// - pub struct MatExpr { - ptr: *mut c_void, - } - - opencv_type_boxed! { MatExpr } - - impl Drop for MatExpr { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_MatExpr_delete(self.as_raw_mut_MatExpr()) }; - } - } - - unsafe impl Send for MatExpr {} - - impl core::MatExprTraitConst for MatExpr { - #[inline] fn as_raw_MatExpr(&self) -> *const c_void { self.as_raw() } - } - - impl core::MatExprTrait for MatExpr { - #[inline] fn as_raw_mut_MatExpr(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { MatExpr, core::MatExprTraitConst, as_raw_MatExpr, core::MatExprTrait, as_raw_mut_MatExpr } + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; + Ok(ret) + } - impl MatExpr { + /// ## C++ default parameters + /// * scale: 1 #[inline] - pub fn default() -> Result { + fn mul(&self, m: &impl core::MatTraitConst, scale: f64) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_MatExpr_MatExpr(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MatExpr_mul_const_const_MatR_double(self.as_raw_MatExpr(), m.as_raw_Mat(), scale, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [MatExprTraitConst::mul] function uses the following default values for its arguments: + /// * scale: 1 #[inline] - pub fn from_mat(m: &impl core::MatTraitConst) -> Result { + fn mul_def(&self, m: &impl core::MatTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_MatExpr_MatExpr_const_MatR(m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MatExpr_mul_const_const_MatR(self.as_raw_MatExpr(), m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; Ok(ret) } - /// ## C++ default parameters - /// * _a: Mat() - /// * _b: Mat() - /// * _c: Mat() - /// * _alpha: 1 - /// * _beta: 1 - /// * _s: Scalar() #[inline] - pub fn new(_op: &impl core::MatOpTraitConst, _flags: i32, _a: &impl core::MatTraitConst, _b: &impl core::MatTraitConst, _c: &impl core::MatTraitConst, _alpha: f64, _beta: f64, _s: core::Scalar) -> Result { + fn cross(&self, m: &impl core::MatTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_MatExpr_MatExpr_const_MatOpX_int_const_MatR_const_MatR_const_MatR_double_double_const_ScalarR(_op.as_raw_MatOp(), _flags, _a.as_raw_Mat(), _b.as_raw_Mat(), _c.as_raw_Mat(), _alpha, _beta, &_s, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MatExpr_cross_const_const_MatR(self.as_raw_MatExpr(), m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * _a: Mat() - /// * _b: Mat() - /// * _c: Mat() - /// * _alpha: 1 - /// * _beta: 1 - /// * _s: Scalar() #[inline] - pub fn new_def(_op: &impl core::MatOpTraitConst, _flags: i32) -> Result { + fn dot(&self, m: &impl core::MatTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_MatExpr_MatExpr_const_MatOpX_int(_op.as_raw_MatOp(), _flags, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MatExpr_dot_const_const_MatR(self.as_raw_MatExpr(), m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + /// Mutable methods for [core::MatExpr] + pub trait MatExprTrait: core::MatExprTraitConst { + fn as_raw_mut_MatExpr(&mut self) -> *mut c_void; + + #[inline] + fn set_flags(&mut self, val: i32) { + let ret = unsafe { sys::cv_MatExpr_propFlags_const_int(self.as_raw_mut_MatExpr(), val) }; + ret + } + + #[inline] + fn set_a(&mut self, val: core::Mat) { + let ret = unsafe { sys::cv_MatExpr_propA_const_Mat(self.as_raw_mut_MatExpr(), val.as_raw_Mat()) }; + ret + } + + #[inline] + fn set_b(&mut self, val: core::Mat) { + let ret = unsafe { sys::cv_MatExpr_propB_const_Mat(self.as_raw_mut_MatExpr(), val.as_raw_Mat()) }; + ret + } + + #[inline] + fn set_c(&mut self, val: core::Mat) { + let ret = unsafe { sys::cv_MatExpr_propC_const_Mat(self.as_raw_mut_MatExpr(), val.as_raw_Mat()) }; + ret + } + + #[inline] + fn set_alpha(&mut self, val: f64) { + let ret = unsafe { sys::cv_MatExpr_propAlpha_const_double(self.as_raw_mut_MatExpr(), val) }; + ret + } + + #[inline] + fn set_beta(&mut self, val: f64) { + let ret = unsafe { sys::cv_MatExpr_propBeta_const_double(self.as_raw_mut_MatExpr(), val) }; + ret + } + + #[inline] + fn set_s(&mut self, val: core::Scalar) { + let ret = unsafe { sys::cv_MatExpr_propS_const_Scalar(self.as_raw_mut_MatExpr(), &val) }; + ret + } + + #[inline] + fn swap(&mut self, b: &mut impl core::MatExprTrait) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_MatExpr_swap_MatExprR(self.as_raw_mut_MatExpr(), b.as_raw_mut_MatExpr(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::MatExpr::opencv_from_extern(ret) }; Ok(ret) } @@ -21839,6 +21828,32 @@ pub mod core { } } + impl core::MatExprTraitConst for MatExpr { + #[inline] fn as_raw_MatExpr(&self) -> *const c_void { self.as_raw() } + } + + impl core::MatExprTrait for MatExpr { + #[inline] fn as_raw_mut_MatExpr(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { MatExpr, core::MatExprTraitConst, as_raw_MatExpr, core::MatExprTrait, as_raw_mut_MatExpr } + + /// ////////////////////////////// Matrix Expressions ///////////////////////////////// + pub struct MatOp { + ptr: *mut c_void, + } + + opencv_type_boxed! { MatOp } + + impl Drop for MatOp { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_MatOp_delete(self.as_raw_mut_MatOp()) }; + } + } + + unsafe impl Send for MatOp {} + /// Constant methods for [core::MatOp] pub trait MatOpTraitConst { fn as_raw_MatOp(&self) -> *const c_void; @@ -22118,22 +22133,14 @@ pub mod core { } - /// ////////////////////////////// Matrix Expressions ///////////////////////////////// - pub struct MatOp { - ptr: *mut c_void, - } - - opencv_type_boxed! { MatOp } - - impl Drop for MatOp { + impl std::fmt::Debug for MatOp { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_MatOp_delete(self.as_raw_mut_MatOp()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MatOp") + .finish() } } - unsafe impl Send for MatOp {} - impl core::MatOpTraitConst for MatOp { #[inline] fn as_raw_MatOp(&self) -> *const c_void { self.as_raw() } } @@ -22144,15 +22151,31 @@ pub mod core { boxed_ref! { MatOp, core::MatOpTraitConst, as_raw_MatOp, core::MatOpTrait, as_raw_mut_MatOp } - impl MatOp { + pub struct MatSize<'mat> { + ptr: *mut c_void, + _d: PhantomData<&'mat mut ()>, } - impl std::fmt::Debug for MatOp { + opencv_type_boxed! { MatSize<'mat>: for <'mat> } + + impl Drop for MatSize<'_> { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MatOp") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_MatSize_delete(self.as_raw_mut_MatSize()) }; + } + } + + unsafe impl Send for MatSize<'_> {} + + impl<'mat> MatSize<'mat> { + /// ////////////////////////// MatSize //////////////////////////// + #[inline] + pub unsafe fn new(_p: *mut i32) -> core::MatSize<'mat> { + let ret = { sys::cv_MatSize_MatSize_intX(_p) }; + let ret = { core::MatSize::<'mat>::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [core::MatSize] @@ -22236,37 +22259,44 @@ pub mod core { } - pub struct MatSize { + impl core::MatSizeTraitConst for MatSize<'_> { + #[inline] fn as_raw_MatSize(&self) -> *const c_void { self.as_raw() } + } + + impl core::MatSizeTrait for MatSize<'_> { + #[inline] fn as_raw_mut_MatSize(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { MatSize<'_>, core::MatSizeTraitConst, as_raw_MatSize, core::MatSizeTrait, as_raw_mut_MatSize } + + pub struct MatStep { ptr: *mut c_void, } - opencv_type_boxed! { MatSize } + opencv_type_boxed! { MatStep } - impl Drop for MatSize { + impl Drop for MatStep { #[inline] fn drop(&mut self) { - unsafe { sys::cv_MatSize_delete(self.as_raw_mut_MatSize()) }; + unsafe { sys::cv_MatStep_delete(self.as_raw_mut_MatStep()) }; } } - unsafe impl Send for MatSize {} - - impl core::MatSizeTraitConst for MatSize { - #[inline] fn as_raw_MatSize(&self) -> *const c_void { self.as_raw() } - } - - impl core::MatSizeTrait for MatSize { - #[inline] fn as_raw_mut_MatSize(&mut self) -> *mut c_void { self.as_raw_mut() } - } + unsafe impl Send for MatStep {} - boxed_ref! { MatSize, core::MatSizeTraitConst, as_raw_MatSize, core::MatSizeTrait, as_raw_mut_MatSize } + impl MatStep { + /// ////////////////////////// MatStep //////////////////////////// + #[inline] + pub fn default() -> core::MatStep { + let ret = unsafe { sys::cv_MatStep_MatStep() }; + let ret = unsafe { core::MatStep::opencv_from_extern(ret) }; + ret + } - impl MatSize { - /// ////////////////////////// MatSize //////////////////////////// #[inline] - pub unsafe fn new(_p: *mut i32) -> core::MatSize { - let ret = { sys::cv_MatSize_MatSize_intX(_p) }; - let ret = { core::MatSize::opencv_from_extern(ret) }; + pub fn new(s: size_t) -> core::MatStep { + let ret = unsafe { sys::cv_MatStep_MatStep_size_t(s) }; + let ret = unsafe { core::MatStep::opencv_from_extern(ret) }; ret } @@ -22346,47 +22376,12 @@ pub mod core { } - pub struct MatStep { - ptr: *mut c_void, - } - - opencv_type_boxed! { MatStep } - - impl Drop for MatStep { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_MatStep_delete(self.as_raw_mut_MatStep()) }; - } - } - - unsafe impl Send for MatStep {} - - impl core::MatStepTraitConst for MatStep { - #[inline] fn as_raw_MatStep(&self) -> *const c_void { self.as_raw() } - } - - impl core::MatStepTrait for MatStep { - #[inline] fn as_raw_mut_MatStep(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { MatStep, core::MatStepTraitConst, as_raw_MatStep, core::MatStepTrait, as_raw_mut_MatStep } - - impl MatStep { - /// ////////////////////////// MatStep //////////////////////////// - #[inline] - pub fn default() -> core::MatStep { - let ret = unsafe { sys::cv_MatStep_MatStep() }; - let ret = unsafe { core::MatStep::opencv_from_extern(ret) }; - ret - } - + impl Default for MatStep { #[inline] - pub fn new(s: size_t) -> core::MatStep { - let ret = unsafe { sys::cv_MatStep_MatStep_size_t(s) }; - let ret = unsafe { core::MatStep::opencv_from_extern(ret) }; - ret + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() } - } impl std::fmt::Debug for MatStep { @@ -22399,26 +22394,16 @@ pub mod core { } } - impl Default for MatStep { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - - /// Constant methods for [core::Matx_AddOp] - pub trait Matx_AddOpTraitConst { - fn as_raw_Matx_AddOp(&self) -> *const c_void; - + impl core::MatStepTraitConst for MatStep { + #[inline] fn as_raw_MatStep(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [core::Matx_AddOp] - pub trait Matx_AddOpTrait: core::Matx_AddOpTraitConst { - fn as_raw_mut_Matx_AddOp(&mut self) -> *mut c_void; - + impl core::MatStepTrait for MatStep { + #[inline] fn as_raw_mut_MatStep(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { MatStep, core::MatStepTraitConst, as_raw_MatStep, core::MatStepTrait, as_raw_mut_MatStep } + /// @cond IGNORED pub struct Matx_AddOp { ptr: *mut c_void, @@ -22435,16 +22420,6 @@ pub mod core { unsafe impl Send for Matx_AddOp {} - impl core::Matx_AddOpTraitConst for Matx_AddOp { - #[inline] fn as_raw_Matx_AddOp(&self) -> *const c_void { self.as_raw() } - } - - impl core::Matx_AddOpTrait for Matx_AddOp { - #[inline] fn as_raw_mut_Matx_AddOp(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Matx_AddOp, core::Matx_AddOpTraitConst, as_raw_Matx_AddOp, core::Matx_AddOpTrait, as_raw_mut_Matx_AddOp } - impl Matx_AddOp { #[inline] pub fn default() -> Result { @@ -22468,6 +22443,18 @@ pub mod core { } + /// Constant methods for [core::Matx_AddOp] + pub trait Matx_AddOpTraitConst { + fn as_raw_Matx_AddOp(&self) -> *const c_void; + + } + + /// Mutable methods for [core::Matx_AddOp] + pub trait Matx_AddOpTrait: core::Matx_AddOpTraitConst { + fn as_raw_mut_Matx_AddOp(&mut self) -> *mut c_void; + + } + impl std::fmt::Debug for Matx_AddOp { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -22476,18 +22463,16 @@ pub mod core { } } - /// Constant methods for [core::Matx_DivOp] - pub trait Matx_DivOpTraitConst { - fn as_raw_Matx_DivOp(&self) -> *const c_void; - + impl core::Matx_AddOpTraitConst for Matx_AddOp { + #[inline] fn as_raw_Matx_AddOp(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [core::Matx_DivOp] - pub trait Matx_DivOpTrait: core::Matx_DivOpTraitConst { - fn as_raw_mut_Matx_DivOp(&mut self) -> *mut c_void; - + impl core::Matx_AddOpTrait for Matx_AddOp { + #[inline] fn as_raw_mut_Matx_AddOp(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { Matx_AddOp, core::Matx_AddOpTraitConst, as_raw_Matx_AddOp, core::Matx_AddOpTrait, as_raw_mut_Matx_AddOp } + pub struct Matx_DivOp { ptr: *mut c_void, } @@ -22503,16 +22488,6 @@ pub mod core { unsafe impl Send for Matx_DivOp {} - impl core::Matx_DivOpTraitConst for Matx_DivOp { - #[inline] fn as_raw_Matx_DivOp(&self) -> *const c_void { self.as_raw() } - } - - impl core::Matx_DivOpTrait for Matx_DivOp { - #[inline] fn as_raw_mut_Matx_DivOp(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Matx_DivOp, core::Matx_DivOpTraitConst, as_raw_Matx_DivOp, core::Matx_DivOpTrait, as_raw_mut_Matx_DivOp } - impl Matx_DivOp { #[inline] pub fn default() -> Result { @@ -22536,6 +22511,18 @@ pub mod core { } + /// Constant methods for [core::Matx_DivOp] + pub trait Matx_DivOpTraitConst { + fn as_raw_Matx_DivOp(&self) -> *const c_void; + + } + + /// Mutable methods for [core::Matx_DivOp] + pub trait Matx_DivOpTrait: core::Matx_DivOpTraitConst { + fn as_raw_mut_Matx_DivOp(&mut self) -> *mut c_void; + + } + impl std::fmt::Debug for Matx_DivOp { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -22544,18 +22531,16 @@ pub mod core { } } - /// Constant methods for [core::Matx_MatMulOp] - pub trait Matx_MatMulOpTraitConst { - fn as_raw_Matx_MatMulOp(&self) -> *const c_void; - + impl core::Matx_DivOpTraitConst for Matx_DivOp { + #[inline] fn as_raw_Matx_DivOp(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [core::Matx_MatMulOp] - pub trait Matx_MatMulOpTrait: core::Matx_MatMulOpTraitConst { - fn as_raw_mut_Matx_MatMulOp(&mut self) -> *mut c_void; - + impl core::Matx_DivOpTrait for Matx_DivOp { + #[inline] fn as_raw_mut_Matx_DivOp(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { Matx_DivOp, core::Matx_DivOpTraitConst, as_raw_Matx_DivOp, core::Matx_DivOpTrait, as_raw_mut_Matx_DivOp } + pub struct Matx_MatMulOp { ptr: *mut c_void, } @@ -22571,16 +22556,6 @@ pub mod core { unsafe impl Send for Matx_MatMulOp {} - impl core::Matx_MatMulOpTraitConst for Matx_MatMulOp { - #[inline] fn as_raw_Matx_MatMulOp(&self) -> *const c_void { self.as_raw() } - } - - impl core::Matx_MatMulOpTrait for Matx_MatMulOp { - #[inline] fn as_raw_mut_Matx_MatMulOp(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Matx_MatMulOp, core::Matx_MatMulOpTraitConst, as_raw_Matx_MatMulOp, core::Matx_MatMulOpTrait, as_raw_mut_Matx_MatMulOp } - impl Matx_MatMulOp { #[inline] pub fn default() -> Result { @@ -22604,6 +22579,18 @@ pub mod core { } + /// Constant methods for [core::Matx_MatMulOp] + pub trait Matx_MatMulOpTraitConst { + fn as_raw_Matx_MatMulOp(&self) -> *const c_void; + + } + + /// Mutable methods for [core::Matx_MatMulOp] + pub trait Matx_MatMulOpTrait: core::Matx_MatMulOpTraitConst { + fn as_raw_mut_Matx_MatMulOp(&mut self) -> *mut c_void; + + } + impl std::fmt::Debug for Matx_MatMulOp { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -22612,18 +22599,16 @@ pub mod core { } } - /// Constant methods for [core::Matx_MulOp] - pub trait Matx_MulOpTraitConst { - fn as_raw_Matx_MulOp(&self) -> *const c_void; - + impl core::Matx_MatMulOpTraitConst for Matx_MatMulOp { + #[inline] fn as_raw_Matx_MatMulOp(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [core::Matx_MulOp] - pub trait Matx_MulOpTrait: core::Matx_MulOpTraitConst { - fn as_raw_mut_Matx_MulOp(&mut self) -> *mut c_void; - + impl core::Matx_MatMulOpTrait for Matx_MatMulOp { + #[inline] fn as_raw_mut_Matx_MatMulOp(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { Matx_MatMulOp, core::Matx_MatMulOpTraitConst, as_raw_Matx_MatMulOp, core::Matx_MatMulOpTrait, as_raw_mut_Matx_MatMulOp } + pub struct Matx_MulOp { ptr: *mut c_void, } @@ -22639,16 +22624,6 @@ pub mod core { unsafe impl Send for Matx_MulOp {} - impl core::Matx_MulOpTraitConst for Matx_MulOp { - #[inline] fn as_raw_Matx_MulOp(&self) -> *const c_void { self.as_raw() } - } - - impl core::Matx_MulOpTrait for Matx_MulOp { - #[inline] fn as_raw_mut_Matx_MulOp(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Matx_MulOp, core::Matx_MulOpTraitConst, as_raw_Matx_MulOp, core::Matx_MulOpTrait, as_raw_mut_Matx_MulOp } - impl Matx_MulOp { #[inline] pub fn default() -> Result { @@ -22672,6 +22647,18 @@ pub mod core { } + /// Constant methods for [core::Matx_MulOp] + pub trait Matx_MulOpTraitConst { + fn as_raw_Matx_MulOp(&self) -> *const c_void; + + } + + /// Mutable methods for [core::Matx_MulOp] + pub trait Matx_MulOpTrait: core::Matx_MulOpTraitConst { + fn as_raw_mut_Matx_MulOp(&mut self) -> *mut c_void; + + } + impl std::fmt::Debug for Matx_MulOp { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -22680,18 +22667,16 @@ pub mod core { } } - /// Constant methods for [core::Matx_ScaleOp] - pub trait Matx_ScaleOpTraitConst { - fn as_raw_Matx_ScaleOp(&self) -> *const c_void; - + impl core::Matx_MulOpTraitConst for Matx_MulOp { + #[inline] fn as_raw_Matx_MulOp(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [core::Matx_ScaleOp] - pub trait Matx_ScaleOpTrait: core::Matx_ScaleOpTraitConst { - fn as_raw_mut_Matx_ScaleOp(&mut self) -> *mut c_void; - + impl core::Matx_MulOpTrait for Matx_MulOp { + #[inline] fn as_raw_mut_Matx_MulOp(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { Matx_MulOp, core::Matx_MulOpTraitConst, as_raw_Matx_MulOp, core::Matx_MulOpTrait, as_raw_mut_Matx_MulOp } + pub struct Matx_ScaleOp { ptr: *mut c_void, } @@ -22707,16 +22692,6 @@ pub mod core { unsafe impl Send for Matx_ScaleOp {} - impl core::Matx_ScaleOpTraitConst for Matx_ScaleOp { - #[inline] fn as_raw_Matx_ScaleOp(&self) -> *const c_void { self.as_raw() } - } - - impl core::Matx_ScaleOpTrait for Matx_ScaleOp { - #[inline] fn as_raw_mut_Matx_ScaleOp(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Matx_ScaleOp, core::Matx_ScaleOpTraitConst, as_raw_Matx_ScaleOp, core::Matx_ScaleOpTrait, as_raw_mut_Matx_ScaleOp } - impl Matx_ScaleOp { #[inline] pub fn default() -> Result { @@ -22740,6 +22715,18 @@ pub mod core { } + /// Constant methods for [core::Matx_ScaleOp] + pub trait Matx_ScaleOpTraitConst { + fn as_raw_Matx_ScaleOp(&self) -> *const c_void; + + } + + /// Mutable methods for [core::Matx_ScaleOp] + pub trait Matx_ScaleOpTrait: core::Matx_ScaleOpTraitConst { + fn as_raw_mut_Matx_ScaleOp(&mut self) -> *mut c_void; + + } + impl std::fmt::Debug for Matx_ScaleOp { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -22748,18 +22735,16 @@ pub mod core { } } - /// Constant methods for [core::Matx_SubOp] - pub trait Matx_SubOpTraitConst { - fn as_raw_Matx_SubOp(&self) -> *const c_void; - + impl core::Matx_ScaleOpTraitConst for Matx_ScaleOp { + #[inline] fn as_raw_Matx_ScaleOp(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [core::Matx_SubOp] - pub trait Matx_SubOpTrait: core::Matx_SubOpTraitConst { - fn as_raw_mut_Matx_SubOp(&mut self) -> *mut c_void; - + impl core::Matx_ScaleOpTrait for Matx_ScaleOp { + #[inline] fn as_raw_mut_Matx_ScaleOp(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { Matx_ScaleOp, core::Matx_ScaleOpTraitConst, as_raw_Matx_ScaleOp, core::Matx_ScaleOpTrait, as_raw_mut_Matx_ScaleOp } + pub struct Matx_SubOp { ptr: *mut c_void, } @@ -22775,16 +22760,6 @@ pub mod core { unsafe impl Send for Matx_SubOp {} - impl core::Matx_SubOpTraitConst for Matx_SubOp { - #[inline] fn as_raw_Matx_SubOp(&self) -> *const c_void { self.as_raw() } - } - - impl core::Matx_SubOpTrait for Matx_SubOp { - #[inline] fn as_raw_mut_Matx_SubOp(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Matx_SubOp, core::Matx_SubOpTraitConst, as_raw_Matx_SubOp, core::Matx_SubOpTrait, as_raw_mut_Matx_SubOp } - impl Matx_SubOp { #[inline] pub fn default() -> Result { @@ -22808,6 +22783,18 @@ pub mod core { } + /// Constant methods for [core::Matx_SubOp] + pub trait Matx_SubOpTraitConst { + fn as_raw_Matx_SubOp(&self) -> *const c_void; + + } + + /// Mutable methods for [core::Matx_SubOp] + pub trait Matx_SubOpTrait: core::Matx_SubOpTraitConst { + fn as_raw_mut_Matx_SubOp(&mut self) -> *mut c_void; + + } + impl std::fmt::Debug for Matx_SubOp { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -22816,18 +22803,16 @@ pub mod core { } } - /// Constant methods for [core::Matx_TOp] - pub trait Matx_TOpTraitConst { - fn as_raw_Matx_TOp(&self) -> *const c_void; - + impl core::Matx_SubOpTraitConst for Matx_SubOp { + #[inline] fn as_raw_Matx_SubOp(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [core::Matx_TOp] - pub trait Matx_TOpTrait: core::Matx_TOpTraitConst { - fn as_raw_mut_Matx_TOp(&mut self) -> *mut c_void; - + impl core::Matx_SubOpTrait for Matx_SubOp { + #[inline] fn as_raw_mut_Matx_SubOp(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { Matx_SubOp, core::Matx_SubOpTraitConst, as_raw_Matx_SubOp, core::Matx_SubOpTrait, as_raw_mut_Matx_SubOp } + pub struct Matx_TOp { ptr: *mut c_void, } @@ -22843,16 +22828,6 @@ pub mod core { unsafe impl Send for Matx_TOp {} - impl core::Matx_TOpTraitConst for Matx_TOp { - #[inline] fn as_raw_Matx_TOp(&self) -> *const c_void { self.as_raw() } - } - - impl core::Matx_TOpTrait for Matx_TOp { - #[inline] fn as_raw_mut_Matx_TOp(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Matx_TOp, core::Matx_TOpTraitConst, as_raw_Matx_TOp, core::Matx_TOpTrait, as_raw_mut_Matx_TOp } - impl Matx_TOp { #[inline] pub fn default() -> Result { @@ -22876,14 +22851,52 @@ pub mod core { } - impl std::fmt::Debug for Matx_TOp { + /// Constant methods for [core::Matx_TOp] + pub trait Matx_TOpTraitConst { + fn as_raw_Matx_TOp(&self) -> *const c_void; + + } + + /// Mutable methods for [core::Matx_TOp] + pub trait Matx_TOpTrait: core::Matx_TOpTraitConst { + fn as_raw_mut_Matx_TOp(&mut self) -> *mut c_void; + + } + + impl std::fmt::Debug for Matx_TOp { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Matx_TOp") + .finish() + } + } + + impl core::Matx_TOpTraitConst for Matx_TOp { + #[inline] fn as_raw_Matx_TOp(&self) -> *const c_void { self.as_raw() } + } + + impl core::Matx_TOpTrait for Matx_TOp { + #[inline] fn as_raw_mut_Matx_TOp(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Matx_TOp, core::Matx_TOpTraitConst, as_raw_Matx_TOp, core::Matx_TOpTrait, as_raw_mut_Matx_TOp } + + /// Basic interface for all solvers + pub struct MinProblemSolver { + ptr: *mut c_void, + } + + opencv_type_boxed! { MinProblemSolver } + + impl Drop for MinProblemSolver { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Matx_TOp") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_MinProblemSolver_delete(self.as_raw_mut_MinProblemSolver()) }; } } + unsafe impl Send for MinProblemSolver {} + /// Constant methods for [core::MinProblemSolver] pub trait MinProblemSolverTraitConst: core::AlgorithmTraitConst { fn as_raw_MinProblemSolver(&self) -> *const c_void; @@ -22985,21 +22998,19 @@ pub mod core { } - /// Basic interface for all solvers - pub struct MinProblemSolver { - ptr: *mut c_void, - } - - opencv_type_boxed! { MinProblemSolver } - - impl Drop for MinProblemSolver { + impl std::fmt::Debug for MinProblemSolver { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_MinProblemSolver_delete(self.as_raw_mut_MinProblemSolver()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MinProblemSolver") + .finish() } } - unsafe impl Send for MinProblemSolver {} + boxed_cast_base! { MinProblemSolver, core::Algorithm, cv_MinProblemSolver_to_Algorithm } + + boxed_cast_descendant! { MinProblemSolver, core::ConjGradSolver, cv_MinProblemSolver_to_ConjGradSolver } + + boxed_cast_descendant! { MinProblemSolver, core::DownhillSolver, cv_MinProblemSolver_to_DownhillSolver } impl core::AlgorithmTraitConst for MinProblemSolver { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -23021,23 +23032,22 @@ pub mod core { boxed_ref! { MinProblemSolver, core::MinProblemSolverTraitConst, as_raw_MinProblemSolver, core::MinProblemSolverTrait, as_raw_mut_MinProblemSolver } - impl MinProblemSolver { + /// Represents function being optimized + pub struct MinProblemSolver_Function { + ptr: *mut c_void, } - boxed_cast_descendant! { MinProblemSolver, core::ConjGradSolver, cv_MinProblemSolver_to_ConjGradSolver } - - boxed_cast_descendant! { MinProblemSolver, core::DownhillSolver, cv_MinProblemSolver_to_DownhillSolver } - - boxed_cast_base! { MinProblemSolver, core::Algorithm, cv_MinProblemSolver_to_Algorithm } + opencv_type_boxed! { MinProblemSolver_Function } - impl std::fmt::Debug for MinProblemSolver { + impl Drop for MinProblemSolver_Function { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MinProblemSolver") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_MinProblemSolver_Function_delete(self.as_raw_mut_MinProblemSolver_Function()) }; } } + unsafe impl Send for MinProblemSolver_Function {} + /// Constant methods for [core::MinProblemSolver_Function] pub trait MinProblemSolver_FunctionTraitConst { fn as_raw_MinProblemSolver_Function(&self) -> *const c_void; @@ -23086,22 +23096,14 @@ pub mod core { } - /// Represents function being optimized - pub struct MinProblemSolver_Function { - ptr: *mut c_void, - } - - opencv_type_boxed! { MinProblemSolver_Function } - - impl Drop for MinProblemSolver_Function { + impl std::fmt::Debug for MinProblemSolver_Function { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_MinProblemSolver_Function_delete(self.as_raw_mut_MinProblemSolver_Function()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MinProblemSolver_Function") + .finish() } } - unsafe impl Send for MinProblemSolver_Function {} - impl core::MinProblemSolver_FunctionTraitConst for MinProblemSolver_Function { #[inline] fn as_raw_MinProblemSolver_Function(&self) -> *const c_void { self.as_raw() } } @@ -23112,17 +23114,6 @@ pub mod core { boxed_ref! { MinProblemSolver_Function, core::MinProblemSolver_FunctionTraitConst, as_raw_MinProblemSolver_Function, core::MinProblemSolver_FunctionTrait, as_raw_mut_MinProblemSolver_Function } - impl MinProblemSolver_Function { - } - - impl std::fmt::Debug for MinProblemSolver_Function { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MinProblemSolver_Function") - .finish() - } - } - /// struct returned by cv::moments /// /// The spatial moments ![inline formula](https://latex.codecogs.com/png.latex?%5Ctexttt%7BMoments%3A%3Am%7D%5F%7Bji%7D) are computed as: @@ -23224,11 +23215,191 @@ pub mod core { /// the full constructor #[inline] - pub fn new(m00: f64, m10: f64, m01: f64, m20: f64, m11: f64, m02: f64, m30: f64, m21: f64, m12: f64, m03: f64) -> Result { + pub fn new(m00: f64, m10: f64, m01: f64, m20: f64, m11: f64, m02: f64, m30: f64, m21: f64, m12: f64, m03: f64) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_Moments_Moments_double_double_double_double_double_double_double_double_double_double(m00, m10, m01, m20, m11, m02, m30, m21, m12, m03, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + /// Principal Component Analysis + /// + /// The class is used to calculate a special basis for a set of vectors. The + /// basis will consist of eigenvectors of the covariance matrix calculated + /// from the input set of vectors. The class %PCA can also transform + /// vectors to/from the new coordinate space defined by the basis. Usually, + /// in this new coordinate system, each vector from the original set (and + /// any linear combination of such vectors) can be quite accurately + /// approximated by taking its first few components, corresponding to the + /// eigenvectors of the largest eigenvalues of the covariance matrix. + /// Geometrically it means that you calculate a projection of the vector to + /// a subspace formed by a few eigenvectors corresponding to the dominant + /// eigenvalues of the covariance matrix. And usually such a projection is + /// very close to the original vector. So, you can represent the original + /// vector from a high-dimensional space with a much shorter vector + /// consisting of the projected vector's coordinates in the subspace. Such a + /// transformation is also known as Karhunen-Loeve Transform, or KLT. + /// See + /// + /// The sample below is the function that takes two matrices. The first + /// function stores a set of vectors (a row per vector) that is used to + /// calculate PCA. The second function stores another "test" set of vectors + /// (a row per vector). First, these vectors are compressed with PCA, then + /// reconstructed back, and then the reconstruction error norm is computed + /// and printed for each vector. : + /// + /// ```C++ + /// using namespace cv; + /// + /// PCA compressPCA(const Mat& pcaset, int maxComponents, + /// const Mat& testset, Mat& compressed) + /// { + /// PCA pca(pcaset, // pass the data + /// Mat(), // we do not have a pre-computed mean vector, + /// // so let the PCA engine to compute it + /// PCA::DATA_AS_ROW, // indicate that the vectors + /// // are stored as matrix rows + /// // (use PCA::DATA_AS_COL if the vectors are + /// // the matrix columns) + /// maxComponents // specify, how many principal components to retain + /// ); + /// // if there is no test data, just return the computed basis, ready-to-use + /// if( !testset.data ) + /// return pca; + /// CV_Assert( testset.cols == pcaset.cols ); + /// + /// compressed.create(testset.rows, maxComponents, testset.type()); + /// + /// Mat reconstructed; + /// for( int i = 0; i < testset.rows; i++ ) + /// { + /// Mat vec = testset.row(i), coeffs = compressed.row(i), reconstructed; + /// // compress the vector, the result will be stored + /// // in the i-th row of the output matrix + /// pca.project(vec, coeffs); + /// // and then reconstruct it + /// pca.backProject(coeffs, reconstructed); + /// // and measure the error + /// printf("%d. diff = %g\n", i, norm(vec, reconstructed, NORM_L2)); + /// } + /// return pca; + /// } + /// ``` + /// ## See also + /// calcCovarMatrix, mulTransposed, SVD, dft, dct + pub struct PCA { + ptr: *mut c_void, + } + + opencv_type_boxed! { PCA } + + impl Drop for PCA { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_PCA_delete(self.as_raw_mut_PCA()) }; + } + } + + unsafe impl Send for PCA {} + + impl PCA { + /// default constructor + /// + /// The default constructor initializes an empty %PCA structure. The other + /// constructors initialize the structure and call PCA::operator()(). + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_PCA_PCA(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::PCA::opencv_from_extern(ret) }; + Ok(ret) + } + + /// default constructor + /// + /// The default constructor initializes an empty %PCA structure. The other + /// constructors initialize the structure and call PCA::operator()(). + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * data: input samples stored as matrix rows or matrix columns. + /// * mean: optional mean value; if the matrix is empty (@c noArray()), + /// the mean is computed from the data. + /// * flags: operation flags; currently the parameter is only used to + /// specify the data layout (PCA::Flags) + /// * maxComponents: maximum number of components that %PCA should + /// retain; by default, all the components are retained. + /// + /// ## C++ default parameters + /// * max_components: 0 + #[inline] + pub fn new(data: &impl ToInputArray, mean: &impl ToInputArray, flags: i32, max_components: i32) -> Result { + input_array_arg!(data); + input_array_arg!(mean); + return_send!(via ocvrs_return); + unsafe { sys::cv_PCA_PCA_const__InputArrayR_const__InputArrayR_int_int(data.as_raw__InputArray(), mean.as_raw__InputArray(), flags, max_components, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::PCA::opencv_from_extern(ret) }; + Ok(ret) + } + + /// @overload + /// ## Parameters + /// * data: input samples stored as matrix rows or matrix columns. + /// * mean: optional mean value; if the matrix is empty (@c noArray()), + /// the mean is computed from the data. + /// * flags: operation flags; currently the parameter is only used to + /// specify the data layout (PCA::Flags) + /// * maxComponents: maximum number of components that %PCA should + /// retain; by default, all the components are retained. + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * max_components: 0 + #[inline] + pub fn new_def(data: &impl ToInputArray, mean: &impl ToInputArray, flags: i32) -> Result { + input_array_arg!(data); + input_array_arg!(mean); + return_send!(via ocvrs_return); + unsafe { sys::cv_PCA_PCA_const__InputArrayR_const__InputArrayR_int(data.as_raw__InputArray(), mean.as_raw__InputArray(), flags, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::PCA::opencv_from_extern(ret) }; + Ok(ret) + } + + /// default constructor + /// + /// The default constructor initializes an empty %PCA structure. The other + /// constructors initialize the structure and call PCA::operator()(). + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * data: input samples stored as matrix rows or matrix columns. + /// * mean: optional mean value; if the matrix is empty (noArray()), + /// the mean is computed from the data. + /// * flags: operation flags; currently the parameter is only used to + /// specify the data layout (PCA::Flags) + /// * retainedVariance: Percentage of variance that PCA should retain. + /// Using this parameter will let the PCA decided how many components to + /// retain but it will always keep at least 2. + #[inline] + pub fn new_with_variance(data: &impl ToInputArray, mean: &impl ToInputArray, flags: i32, retained_variance: f64) -> Result { + input_array_arg!(data); + input_array_arg!(mean); return_send!(via ocvrs_return); - unsafe { sys::cv_Moments_Moments_double_double_double_double_double_double_double_double_double_double(m00, m10, m01, m20, m11, m02, m30, m21, m12, m03, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_PCA_PCA_const__InputArrayR_const__InputArrayR_int_double(data.as_raw__InputArray(), mean.as_raw__InputArray(), flags, retained_variance, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::PCA::opencv_from_extern(ret) }; Ok(ret) } @@ -23546,86 +23717,17 @@ pub mod core { } - /// Principal Component Analysis - /// - /// The class is used to calculate a special basis for a set of vectors. The - /// basis will consist of eigenvectors of the covariance matrix calculated - /// from the input set of vectors. The class %PCA can also transform - /// vectors to/from the new coordinate space defined by the basis. Usually, - /// in this new coordinate system, each vector from the original set (and - /// any linear combination of such vectors) can be quite accurately - /// approximated by taking its first few components, corresponding to the - /// eigenvectors of the largest eigenvalues of the covariance matrix. - /// Geometrically it means that you calculate a projection of the vector to - /// a subspace formed by a few eigenvectors corresponding to the dominant - /// eigenvalues of the covariance matrix. And usually such a projection is - /// very close to the original vector. So, you can represent the original - /// vector from a high-dimensional space with a much shorter vector - /// consisting of the projected vector's coordinates in the subspace. Such a - /// transformation is also known as Karhunen-Loeve Transform, or KLT. - /// See - /// - /// The sample below is the function that takes two matrices. The first - /// function stores a set of vectors (a row per vector) that is used to - /// calculate PCA. The second function stores another "test" set of vectors - /// (a row per vector). First, these vectors are compressed with PCA, then - /// reconstructed back, and then the reconstruction error norm is computed - /// and printed for each vector. : - /// - /// ```C++ - /// using namespace cv; - /// - /// PCA compressPCA(const Mat& pcaset, int maxComponents, - /// const Mat& testset, Mat& compressed) - /// { - /// PCA pca(pcaset, // pass the data - /// Mat(), // we do not have a pre-computed mean vector, - /// // so let the PCA engine to compute it - /// PCA::DATA_AS_ROW, // indicate that the vectors - /// // are stored as matrix rows - /// // (use PCA::DATA_AS_COL if the vectors are - /// // the matrix columns) - /// maxComponents // specify, how many principal components to retain - /// ); - /// // if there is no test data, just return the computed basis, ready-to-use - /// if( !testset.data ) - /// return pca; - /// CV_Assert( testset.cols == pcaset.cols ); - /// - /// compressed.create(testset.rows, maxComponents, testset.type()); - /// - /// Mat reconstructed; - /// for( int i = 0; i < testset.rows; i++ ) - /// { - /// Mat vec = testset.row(i), coeffs = compressed.row(i), reconstructed; - /// // compress the vector, the result will be stored - /// // in the i-th row of the output matrix - /// pca.project(vec, coeffs); - /// // and then reconstruct it - /// pca.backProject(coeffs, reconstructed); - /// // and measure the error - /// printf("%d. diff = %g\n", i, norm(vec, reconstructed, NORM_L2)); - /// } - /// return pca; - /// } - /// ``` - /// ## See also - /// calcCovarMatrix, mulTransposed, SVD, dft, dct - pub struct PCA { - ptr: *mut c_void, - } - - opencv_type_boxed! { PCA } - - impl Drop for PCA { + impl std::fmt::Debug for PCA { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_PCA_delete(self.as_raw_mut_PCA()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PCA") + .field("eigenvectors", &core::PCATraitConst::eigenvectors(self)) + .field("eigenvalues", &core::PCATraitConst::eigenvalues(self)) + .field("mean", &core::PCATraitConst::mean(self)) + .finish() } } - unsafe impl Send for PCA {} - impl core::PCATraitConst for PCA { #[inline] fn as_raw_PCA(&self) -> *const c_void { self.as_raw() } } @@ -23636,116 +23738,23 @@ pub mod core { boxed_ref! { PCA, core::PCATraitConst, as_raw_PCA, core::PCATrait, as_raw_mut_PCA } - impl PCA { - /// default constructor - /// - /// The default constructor initializes an empty %PCA structure. The other - /// constructors initialize the structure and call PCA::operator()(). - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_PCA_PCA(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::PCA::opencv_from_extern(ret) }; - Ok(ret) - } - - /// default constructor - /// - /// The default constructor initializes an empty %PCA structure. The other - /// constructors initialize the structure and call PCA::operator()(). - /// - /// ## Overloaded parameters - /// - /// ## Parameters - /// * data: input samples stored as matrix rows or matrix columns. - /// * mean: optional mean value; if the matrix is empty (@c noArray()), - /// the mean is computed from the data. - /// * flags: operation flags; currently the parameter is only used to - /// specify the data layout (PCA::Flags) - /// * maxComponents: maximum number of components that %PCA should - /// retain; by default, all the components are retained. - /// - /// ## C++ default parameters - /// * max_components: 0 - #[inline] - pub fn new(data: &impl ToInputArray, mean: &impl ToInputArray, flags: i32, max_components: i32) -> Result { - input_array_arg!(data); - input_array_arg!(mean); - return_send!(via ocvrs_return); - unsafe { sys::cv_PCA_PCA_const__InputArrayR_const__InputArrayR_int_int(data.as_raw__InputArray(), mean.as_raw__InputArray(), flags, max_components, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::PCA::opencv_from_extern(ret) }; - Ok(ret) - } + /// Base class for parallel data processors + /// + /// @ingroup core_parallel + pub struct ParallelLoopBody { + ptr: *mut c_void, + } - /// @overload - /// ## Parameters - /// * data: input samples stored as matrix rows or matrix columns. - /// * mean: optional mean value; if the matrix is empty (@c noArray()), - /// the mean is computed from the data. - /// * flags: operation flags; currently the parameter is only used to - /// specify the data layout (PCA::Flags) - /// * maxComponents: maximum number of components that %PCA should - /// retain; by default, all the components are retained. - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * max_components: 0 - #[inline] - pub fn new_def(data: &impl ToInputArray, mean: &impl ToInputArray, flags: i32) -> Result { - input_array_arg!(data); - input_array_arg!(mean); - return_send!(via ocvrs_return); - unsafe { sys::cv_PCA_PCA_const__InputArrayR_const__InputArrayR_int(data.as_raw__InputArray(), mean.as_raw__InputArray(), flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::PCA::opencv_from_extern(ret) }; - Ok(ret) - } + opencv_type_boxed! { ParallelLoopBody } - /// default constructor - /// - /// The default constructor initializes an empty %PCA structure. The other - /// constructors initialize the structure and call PCA::operator()(). - /// - /// ## Overloaded parameters - /// - /// ## Parameters - /// * data: input samples stored as matrix rows or matrix columns. - /// * mean: optional mean value; if the matrix is empty (noArray()), - /// the mean is computed from the data. - /// * flags: operation flags; currently the parameter is only used to - /// specify the data layout (PCA::Flags) - /// * retainedVariance: Percentage of variance that PCA should retain. - /// Using this parameter will let the PCA decided how many components to - /// retain but it will always keep at least 2. + impl Drop for ParallelLoopBody { #[inline] - pub fn new_with_variance(data: &impl ToInputArray, mean: &impl ToInputArray, flags: i32, retained_variance: f64) -> Result { - input_array_arg!(data); - input_array_arg!(mean); - return_send!(via ocvrs_return); - unsafe { sys::cv_PCA_PCA_const__InputArrayR_const__InputArrayR_int_double(data.as_raw__InputArray(), mean.as_raw__InputArray(), flags, retained_variance, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::PCA::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_ParallelLoopBody_delete(self.as_raw_mut_ParallelLoopBody()) }; } - } - impl std::fmt::Debug for PCA { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PCA") - .field("eigenvectors", &core::PCATraitConst::eigenvectors(self)) - .field("eigenvalues", &core::PCATraitConst::eigenvalues(self)) - .field("mean", &core::PCATraitConst::mean(self)) - .finish() - } - } + unsafe impl Send for ParallelLoopBody {} /// Constant methods for [core::ParallelLoopBody] pub trait ParallelLoopBodyTraitConst { @@ -23768,24 +23777,14 @@ pub mod core { } - /// Base class for parallel data processors - /// - /// @ingroup core_parallel - pub struct ParallelLoopBody { - ptr: *mut c_void, - } - - opencv_type_boxed! { ParallelLoopBody } - - impl Drop for ParallelLoopBody { + impl std::fmt::Debug for ParallelLoopBody { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ParallelLoopBody_delete(self.as_raw_mut_ParallelLoopBody()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ParallelLoopBody") + .finish() } } - unsafe impl Send for ParallelLoopBody {} - impl core::ParallelLoopBodyTraitConst for ParallelLoopBody { #[inline] fn as_raw_ParallelLoopBody(&self) -> *const c_void { self.as_raw() } } @@ -23796,15 +23795,72 @@ pub mod core { boxed_ref! { ParallelLoopBody, core::ParallelLoopBodyTraitConst, as_raw_ParallelLoopBody, core::ParallelLoopBodyTrait, as_raw_mut_ParallelLoopBody } - impl ParallelLoopBody { + /// Random Number Generator + /// + /// Random number generator. It encapsulates the state (currently, a 64-bit + /// integer) and has methods to return scalar random values and to fill + /// arrays with random values. Currently it supports uniform and Gaussian + /// (normal) distributions. The generator uses Multiply-With-Carry + /// algorithm, introduced by G. Marsaglia ( + /// ). + /// Gaussian-distribution random numbers are generated using the Ziggurat + /// algorithm ( ), + /// introduced by G. Marsaglia and W. W. Tsang. + pub struct RNG { + ptr: *mut c_void, + } + + opencv_type_boxed! { RNG } + + impl Drop for RNG { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_RNG_delete(self.as_raw_mut_RNG()) }; + } } - impl std::fmt::Debug for ParallelLoopBody { + unsafe impl Send for RNG {} + + impl RNG { + /// constructor + /// + /// These are the RNG constructors. The first form sets the state to some + /// pre-defined value, equal to 2\*\*32-1 in the current implementation. The + /// second form sets the state to the specified value. If you passed state=0 + /// , the constructor uses the above default value instead to avoid the + /// singular random number sequence, consisting of all zeros. + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_RNG_RNG(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::RNG::opencv_from_extern(ret) }; + Ok(ret) + } + + /// constructor + /// + /// These are the RNG constructors. The first form sets the state to some + /// pre-defined value, equal to 2\*\*32-1 in the current implementation. The + /// second form sets the state to the specified value. If you passed state=0 + /// , the constructor uses the above default value instead to avoid the + /// singular random number sequence, consisting of all zeros. + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * state: 64-bit value used to initialize the RNG. #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ParallelLoopBody") - .finish() + pub fn new(state: u64) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_RNG_RNG_uint64_t(state, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::RNG::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [core::RNG] @@ -24228,32 +24284,15 @@ pub mod core { } - /// Random Number Generator - /// - /// Random number generator. It encapsulates the state (currently, a 64-bit - /// integer) and has methods to return scalar random values and to fill - /// arrays with random values. Currently it supports uniform and Gaussian - /// (normal) distributions. The generator uses Multiply-With-Carry - /// algorithm, introduced by G. Marsaglia ( - /// ). - /// Gaussian-distribution random numbers are generated using the Ziggurat - /// algorithm ( ), - /// introduced by G. Marsaglia and W. W. Tsang. - pub struct RNG { - ptr: *mut c_void, - } - - opencv_type_boxed! { RNG } - - impl Drop for RNG { + impl std::fmt::Debug for RNG { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_RNG_delete(self.as_raw_mut_RNG()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RNG") + .field("state", &core::RNGTraitConst::state(self)) + .finish() } } - unsafe impl Send for RNG {} - impl core::RNGTraitConst for RNG { #[inline] fn as_raw_RNG(&self) -> *const c_void { self.as_raw() } } @@ -24264,57 +24303,48 @@ pub mod core { boxed_ref! { RNG, core::RNGTraitConst, as_raw_RNG, core::RNGTrait, as_raw_mut_RNG } - impl RNG { - /// constructor - /// - /// These are the RNG constructors. The first form sets the state to some - /// pre-defined value, equal to 2\*\*32-1 in the current implementation. The - /// second form sets the state to the specified value. If you passed state=0 - /// , the constructor uses the above default value instead to avoid the - /// singular random number sequence, consisting of all zeros. + /// Mersenne Twister random number generator + /// + /// Inspired by + /// @todo document + pub struct RNG_MT19937 { + ptr: *mut c_void, + } + + opencv_type_boxed! { RNG_MT19937 } + + impl Drop for RNG_MT19937 { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_RNG_MT19937_delete(self.as_raw_mut_RNG_MT19937()) }; + } + } + + unsafe impl Send for RNG_MT19937 {} + + impl RNG_MT19937 { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_RNG_RNG(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_RNG_MT19937_RNG_MT19937(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::RNG::opencv_from_extern(ret) }; + let ret = unsafe { core::RNG_MT19937::opencv_from_extern(ret) }; Ok(ret) } - /// constructor - /// - /// These are the RNG constructors. The first form sets the state to some - /// pre-defined value, equal to 2\*\*32-1 in the current implementation. The - /// second form sets the state to the specified value. If you passed state=0 - /// , the constructor uses the above default value instead to avoid the - /// singular random number sequence, consisting of all zeros. - /// - /// ## Overloaded parameters - /// - /// ## Parameters - /// * state: 64-bit value used to initialize the RNG. #[inline] - pub fn new(state: u64) -> Result { + pub fn new(s: u32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_RNG_RNG_uint64_t(state, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_RNG_MT19937_RNG_MT19937_unsigned_int(s, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::RNG::opencv_from_extern(ret) }; + let ret = unsafe { core::RNG_MT19937::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for RNG { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RNG") - .field("state", &core::RNGTraitConst::state(self)) - .finish() - } - } - /// Constant methods for [core::RNG_MT19937] pub trait RNG_MT19937TraitConst { fn as_raw_RNG_MT19937(&self) -> *const c_void; @@ -24420,25 +24450,14 @@ pub mod core { } - /// Mersenne Twister random number generator - /// - /// Inspired by - /// @todo document - pub struct RNG_MT19937 { - ptr: *mut c_void, - } - - opencv_type_boxed! { RNG_MT19937 } - - impl Drop for RNG_MT19937 { + impl std::fmt::Debug for RNG_MT19937 { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_RNG_MT19937_delete(self.as_raw_mut_RNG_MT19937()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RNG_MT19937") + .finish() } } - unsafe impl Send for RNG_MT19937 {} - impl core::RNG_MT19937TraitConst for RNG_MT19937 { #[inline] fn as_raw_RNG_MT19937(&self) -> *const c_void { self.as_raw() } } @@ -24449,91 +24468,6 @@ pub mod core { boxed_ref! { RNG_MT19937, core::RNG_MT19937TraitConst, as_raw_RNG_MT19937, core::RNG_MT19937Trait, as_raw_mut_RNG_MT19937 } - impl RNG_MT19937 { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_RNG_MT19937_RNG_MT19937(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::RNG_MT19937::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn new(s: u32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_RNG_MT19937_RNG_MT19937_unsigned_int(s, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::RNG_MT19937::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for RNG_MT19937 { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RNG_MT19937") - .finish() - } - } - - /// Constant methods for [core::Range] - pub trait RangeTraitConst { - fn as_raw_Range(&self) -> *const c_void; - - #[inline] - fn start(&self) -> i32 { - let ret = unsafe { sys::cv_Range_propStart_const(self.as_raw_Range()) }; - ret - } - - #[inline] - fn end(&self) -> i32 { - let ret = unsafe { sys::cv_Range_propEnd_const(self.as_raw_Range()) }; - ret - } - - #[inline] - fn size(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_Range_size_const(self.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn empty(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_Range_empty_const(self.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - /// Mutable methods for [core::Range] - pub trait RangeTrait: core::RangeTraitConst { - fn as_raw_mut_Range(&mut self) -> *mut c_void; - - #[inline] - fn set_start(&mut self, val: i32) { - let ret = unsafe { sys::cv_Range_propStart_const_int(self.as_raw_mut_Range(), val) }; - ret - } - - #[inline] - fn set_end(&mut self, val: i32) { - let ret = unsafe { sys::cv_Range_propEnd_const_int(self.as_raw_mut_Range(), val) }; - ret - } - - } - /// Template class specifying a continuous subsequence (slice) of a sequence. /// /// The class is used to specify a row or a column span in a matrix ( Mat ) and for many other purposes. @@ -24572,50 +24506,94 @@ pub mod core { unsafe impl Send for Range {} - impl core::RangeTraitConst for Range { - #[inline] fn as_raw_Range(&self) -> *const c_void { self.as_raw() } - } - - impl core::RangeTrait for Range { - #[inline] fn as_raw_mut_Range(&mut self) -> *mut c_void { self.as_raw_mut() } - } + impl Range { + /// ////////////////////////////// Range ///////////////////////////////// + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_Range_Range(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Range::opencv_from_extern(ret) }; + Ok(ret) + } - boxed_ref! { Range, core::RangeTraitConst, as_raw_Range, core::RangeTrait, as_raw_mut_Range } + #[inline] + pub fn new(_start: i32, _end: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_Range_Range_int_int(_start, _end, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Range::opencv_from_extern(ret) }; + Ok(ret) + } - impl Range { - /// ////////////////////////////// Range ///////////////////////////////// #[inline] - pub fn default() -> Result { + pub fn all() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Range_Range(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Range_all(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { core::Range::opencv_from_extern(ret) }; Ok(ret) } + } + + /// Constant methods for [core::Range] + pub trait RangeTraitConst { + fn as_raw_Range(&self) -> *const c_void; + #[inline] - pub fn new(_start: i32, _end: i32) -> Result { + fn start(&self) -> i32 { + let ret = unsafe { sys::cv_Range_propStart_const(self.as_raw_Range()) }; + ret + } + + #[inline] + fn end(&self) -> i32 { + let ret = unsafe { sys::cv_Range_propEnd_const(self.as_raw_Range()) }; + ret + } + + #[inline] + fn size(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Range_Range_int_int(_start, _end, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Range_size_const(self.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Range::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn all() -> Result { + fn empty(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Range_all(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_Range_empty_const(self.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Range::opencv_from_extern(ret) }; Ok(ret) } } + /// Mutable methods for [core::Range] + pub trait RangeTrait: core::RangeTraitConst { + fn as_raw_mut_Range(&mut self) -> *mut c_void; + + #[inline] + fn set_start(&mut self, val: i32) { + let ret = unsafe { sys::cv_Range_propStart_const_int(self.as_raw_mut_Range(), val) }; + ret + } + + #[inline] + fn set_end(&mut self, val: i32) { + let ret = unsafe { sys::cv_Range_propEnd_const_int(self.as_raw_mut_Range(), val) }; + ret + } + + } + impl std::fmt::Debug for Range { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -24626,6 +24604,16 @@ pub mod core { } } + impl core::RangeTraitConst for Range { + #[inline] fn as_raw_Range(&self) -> *const c_void { self.as_raw() } + } + + impl core::RangeTrait for Range { + #[inline] fn as_raw_mut_Range(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Range, core::RangeTraitConst, as_raw_Range, core::RangeTrait, as_raw_mut_Range } + /// The class represents rotated (i.e. not up-right) rectangles on a plane. /// /// Each rectangle is specified by the center point (mass center), length of each side (represented by @@ -24677,55 +24665,308 @@ pub mod core { /// returns the minimal up-right integer rectangle containing the rotated rectangle #[inline] - pub fn bounding_rect(self) -> Result { + pub fn bounding_rect(self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_RotatedRect_boundingRect_const(&self, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// returns the minimal (exact) floating point rectangle containing the rotated rectangle, not intended for use with images + #[inline] + pub fn bounding_rect2f(self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_RotatedRect_boundingRect2f_const(&self, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// default constructor + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_RotatedRect_RotatedRect(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// full constructor + /// ## Parameters + /// * center: The rectangle mass center. + /// * size: Width and height of the rectangle. + /// * angle: The rotation angle in a clockwise direction. When the angle is 0, 90, 180, 270 etc., + /// the rectangle becomes an up-right rectangle. + #[inline] + pub fn new(center: core::Point2f, size: core::Size2f, angle: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_RotatedRect_RotatedRect_const_Point2fR_const_Size2fR_float(¢er, &size, angle, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Any 3 end points of the RotatedRect. They must be given in order (either clockwise or + /// anticlockwise). + #[inline] + pub fn for_points(point1: core::Point2f, point2: core::Point2f, point3: core::Point2f) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_RotatedRect_RotatedRect_const_Point2fR_const_Point2fR_const_Point2fR(&point1, &point2, &point3, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + /// Singular Value Decomposition + /// + /// Class for computing Singular Value Decomposition of a floating-point + /// matrix. The Singular Value Decomposition is used to solve least-square + /// problems, under-determined linear systems, invert matrices, compute + /// condition numbers, and so on. + /// + /// If you want to compute a condition number of a matrix or an absolute value of + /// its determinant, you do not need `u` and `vt`. You can pass + /// flags=SVD::NO_UV|... . Another flag SVD::FULL_UV indicates that full-size u + /// and vt must be computed, which is not necessary most of the time. + /// ## See also + /// invert, solve, eigen, determinant + pub struct SVD { + ptr: *mut c_void, + } + + opencv_type_boxed! { SVD } + + impl Drop for SVD { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_SVD_delete(self.as_raw_mut_SVD()) }; + } + } + + unsafe impl Send for SVD {} + + impl SVD { + /// the default constructor + /// + /// initializes an empty SVD structure + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_SVD_SVD(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::SVD::opencv_from_extern(ret) }; + Ok(ret) + } + + /// the default constructor + /// + /// initializes an empty SVD structure + /// + /// ## Overloaded parameters + /// + /// initializes an empty SVD structure and then calls SVD::operator() + /// ## Parameters + /// * src: decomposed matrix. The depth has to be CV_32F or CV_64F. + /// * flags: operation flags (SVD::Flags) + /// + /// ## C++ default parameters + /// * flags: 0 + #[inline] + pub fn new(src: &impl ToInputArray, flags: i32) -> Result { + input_array_arg!(src); + return_send!(via ocvrs_return); + unsafe { sys::cv_SVD_SVD_const__InputArrayR_int(src.as_raw__InputArray(), flags, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::SVD::opencv_from_extern(ret) }; + Ok(ret) + } + + /// @overload + /// initializes an empty SVD structure and then calls SVD::operator() + /// ## Parameters + /// * src: decomposed matrix. The depth has to be CV_32F or CV_64F. + /// * flags: operation flags (SVD::Flags) + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * flags: 0 + #[inline] + pub fn new_def(src: &impl ToInputArray) -> Result { + input_array_arg!(src); + return_send!(via ocvrs_return); + unsafe { sys::cv_SVD_SVD_const__InputArrayR(src.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::SVD::opencv_from_extern(ret) }; + Ok(ret) + } + + /// decomposes matrix and stores the results to user-provided matrices + /// + /// The methods/functions perform SVD of matrix. Unlike SVD::SVD constructor + /// and SVD::operator(), they store the results to the user-provided + /// matrices: + /// + /// ```C++ + /// Mat A, w, u, vt; + /// SVD::compute(A, w, u, vt); + /// ``` + /// + /// + /// ## Parameters + /// * src: decomposed matrix. The depth has to be CV_32F or CV_64F. + /// * w: calculated singular values + /// * u: calculated left singular vectors + /// * vt: transposed matrix of right singular vectors + /// * flags: operation flags - see SVD::Flags. + /// + /// ## C++ default parameters + /// * flags: 0 + #[inline] + pub fn compute_ext(src: &impl ToInputArray, w: &mut impl ToOutputArray, u: &mut impl ToOutputArray, vt: &mut impl ToOutputArray, flags: i32) -> Result<()> { + input_array_arg!(src); + output_array_arg!(w); + output_array_arg!(u); + output_array_arg!(vt); + return_send!(via ocvrs_return); + unsafe { sys::cv_SVD_compute_const__InputArrayR_const__OutputArrayR_const__OutputArrayR_const__OutputArrayR_int(src.as_raw__InputArray(), w.as_raw__OutputArray(), u.as_raw__OutputArray(), vt.as_raw__OutputArray(), flags, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// decomposes matrix and stores the results to user-provided matrices + /// + /// The methods/functions perform SVD of matrix. Unlike SVD::SVD constructor + /// and SVD::operator(), they store the results to the user-provided + /// matrices: + /// + /// ```C++ + /// Mat A, w, u, vt; + /// SVD::compute(A, w, u, vt); + /// ``` + /// + /// + /// ## Parameters + /// * src: decomposed matrix. The depth has to be CV_32F or CV_64F. + /// * w: calculated singular values + /// * u: calculated left singular vectors + /// * vt: transposed matrix of right singular vectors + /// * flags: operation flags - see SVD::Flags. + /// + /// ## Note + /// This alternative version of [SVD::compute_ext] function uses the following default values for its arguments: + /// * flags: 0 + #[inline] + pub fn compute_ext_def(src: &impl ToInputArray, w: &mut impl ToOutputArray, u: &mut impl ToOutputArray, vt: &mut impl ToOutputArray) -> Result<()> { + input_array_arg!(src); + output_array_arg!(w); + output_array_arg!(u); + output_array_arg!(vt); return_send!(via ocvrs_return); - unsafe { sys::cv_RotatedRect_boundingRect_const(&self, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_SVD_compute_const__InputArrayR_const__OutputArrayR_const__OutputArrayR_const__OutputArrayR(src.as_raw__InputArray(), w.as_raw__OutputArray(), u.as_raw__OutputArray(), vt.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// returns the minimal (exact) floating point rectangle containing the rotated rectangle, not intended for use with images + /// decomposes matrix and stores the results to user-provided matrices + /// + /// The methods/functions perform SVD of matrix. Unlike SVD::SVD constructor + /// and SVD::operator(), they store the results to the user-provided + /// matrices: + /// + /// ```C++ + /// Mat A, w, u, vt; + /// SVD::compute(A, w, u, vt); + /// ``` + /// + /// + /// ## Parameters + /// * src: decomposed matrix. The depth has to be CV_32F or CV_64F. + /// * w: calculated singular values + /// * u: calculated left singular vectors + /// * vt: transposed matrix of right singular vectors + /// * flags: operation flags - see SVD::Flags. + /// + /// ## Overloaded parameters + /// + /// computes singular values of a matrix + /// * src: decomposed matrix. The depth has to be CV_32F or CV_64F. + /// * w: calculated singular values + /// * flags: operation flags - see SVD::Flags. + /// + /// ## C++ default parameters + /// * flags: 0 #[inline] - pub fn bounding_rect2f(self) -> Result { + pub fn compute(src: &impl ToInputArray, w: &mut impl ToOutputArray, flags: i32) -> Result<()> { + input_array_arg!(src); + output_array_arg!(w); return_send!(via ocvrs_return); - unsafe { sys::cv_RotatedRect_boundingRect2f_const(&self, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_SVD_compute_const__InputArrayR_const__OutputArrayR_int(src.as_raw__InputArray(), w.as_raw__OutputArray(), flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// default constructor + /// @overload + /// computes singular values of a matrix + /// ## Parameters + /// * src: decomposed matrix. The depth has to be CV_32F or CV_64F. + /// * w: calculated singular values + /// * flags: operation flags - see SVD::Flags. + /// + /// ## Note + /// This alternative version of [SVD::compute] function uses the following default values for its arguments: + /// * flags: 0 #[inline] - pub fn default() -> Result { + pub fn compute_def(src: &impl ToInputArray, w: &mut impl ToOutputArray) -> Result<()> { + input_array_arg!(src); + output_array_arg!(w); return_send!(via ocvrs_return); - unsafe { sys::cv_RotatedRect_RotatedRect(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_SVD_compute_const__InputArrayR_const__OutputArrayR(src.as_raw__InputArray(), w.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// full constructor - /// ## Parameters - /// * center: The rectangle mass center. - /// * size: Width and height of the rectangle. - /// * angle: The rotation angle in a clockwise direction. When the angle is 0, 90, 180, 270 etc., - /// the rectangle becomes an up-right rectangle. + /// performs back substitution #[inline] - pub fn new(center: core::Point2f, size: core::Size2f, angle: f32) -> Result { + pub fn back_subst_multi(w: &impl ToInputArray, u: &impl ToInputArray, vt: &impl ToInputArray, rhs: &impl ToInputArray, dst: &mut impl ToOutputArray) -> Result<()> { + input_array_arg!(w); + input_array_arg!(u); + input_array_arg!(vt); + input_array_arg!(rhs); + output_array_arg!(dst); return_send!(via ocvrs_return); - unsafe { sys::cv_RotatedRect_RotatedRect_const_Point2fR_const_Size2fR_float(¢er, &size, angle, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_SVD_backSubst_const__InputArrayR_const__InputArrayR_const__InputArrayR_const__InputArrayR_const__OutputArrayR(w.as_raw__InputArray(), u.as_raw__InputArray(), vt.as_raw__InputArray(), rhs.as_raw__InputArray(), dst.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// Any 3 end points of the RotatedRect. They must be given in order (either clockwise or - /// anticlockwise). + /// solves an under-determined singular linear system + /// + /// The method finds a unit-length solution x of a singular linear system + /// A\*x = 0. Depending on the rank of A, there can be no solutions, a + /// single solution or an infinite number of solutions. In general, the + /// algorithm solves the following problem: + /// ![block formula](https://latex.codecogs.com/png.latex?dst%20%3D%20%20%5Carg%20%5Cmin%20%5F%7Bx%3A%20%20%5C%7C%20x%20%5C%7C%20%3D1%7D%20%20%5C%7C%20src%20%20%5Ccdot%20x%20%20%5C%7C) + /// ## Parameters + /// * src: left-hand-side matrix. + /// * dst: found solution. #[inline] - pub fn for_points(point1: core::Point2f, point2: core::Point2f, point3: core::Point2f) -> Result { + pub fn solve_z(src: &impl ToInputArray, dst: &mut impl ToOutputArray) -> Result<()> { + input_array_arg!(src); + output_array_arg!(dst); return_send!(via ocvrs_return); - unsafe { sys::cv_RotatedRect_RotatedRect_const_Point2fR_const_Point2fR_const_Point2fR(&point1, &point2, &point3, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_SVD_solveZ_const__InputArrayR_const__OutputArrayR(src.as_raw__InputArray(), dst.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -24831,318 +25072,227 @@ pub mod core { /// ## C++ default parameters /// * flags: 0 #[inline] - fn apply(&mut self, src: &impl ToInputArray, flags: i32) -> Result { - input_array_arg!(src); - return_send!(via ocvrs_return); - unsafe { sys::cv_SVD_operator___const__InputArrayR_int(self.as_raw_mut_SVD(), src.as_raw__InputArray(), flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::SVD::opencv_from_extern(ret) }; - Ok(ret) - } - - /// the operator that performs SVD. The previously allocated u, w and vt are released. - /// - /// The operator performs the singular value decomposition of the supplied - /// matrix. The u,`vt` , and the vector of singular values w are stored in - /// the structure. The same SVD structure can be reused many times with - /// different matrices. Each time, if needed, the previous u,`vt` , and w - /// are reclaimed and the new matrices are created, which is all handled by - /// Mat::create. - /// ## Parameters - /// * src: decomposed matrix. The depth has to be CV_32F or CV_64F. - /// * flags: operation flags (SVD::Flags) - /// - /// ## Note - /// This alternative version of [SVDTrait::apply] function uses the following default values for its arguments: - /// * flags: 0 - #[inline] - fn apply_def(&mut self, src: &impl ToInputArray) -> Result { - input_array_arg!(src); - return_send!(via ocvrs_return); - unsafe { sys::cv_SVD_operator___const__InputArrayR(self.as_raw_mut_SVD(), src.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::SVD::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - /// Singular Value Decomposition - /// - /// Class for computing Singular Value Decomposition of a floating-point - /// matrix. The Singular Value Decomposition is used to solve least-square - /// problems, under-determined linear systems, invert matrices, compute - /// condition numbers, and so on. - /// - /// If you want to compute a condition number of a matrix or an absolute value of - /// its determinant, you do not need `u` and `vt`. You can pass - /// flags=SVD::NO_UV|... . Another flag SVD::FULL_UV indicates that full-size u - /// and vt must be computed, which is not necessary most of the time. - /// ## See also - /// invert, solve, eigen, determinant - pub struct SVD { - ptr: *mut c_void, - } - - opencv_type_boxed! { SVD } - - impl Drop for SVD { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_SVD_delete(self.as_raw_mut_SVD()) }; - } - } - - unsafe impl Send for SVD {} - - impl core::SVDTraitConst for SVD { - #[inline] fn as_raw_SVD(&self) -> *const c_void { self.as_raw() } - } - - impl core::SVDTrait for SVD { - #[inline] fn as_raw_mut_SVD(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { SVD, core::SVDTraitConst, as_raw_SVD, core::SVDTrait, as_raw_mut_SVD } - - impl SVD { - /// the default constructor - /// - /// initializes an empty SVD structure - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_SVD_SVD(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::SVD::opencv_from_extern(ret) }; - Ok(ret) - } - - /// the default constructor - /// - /// initializes an empty SVD structure - /// - /// ## Overloaded parameters - /// - /// initializes an empty SVD structure and then calls SVD::operator() - /// ## Parameters - /// * src: decomposed matrix. The depth has to be CV_32F or CV_64F. - /// * flags: operation flags (SVD::Flags) - /// - /// ## C++ default parameters - /// * flags: 0 - #[inline] - pub fn new(src: &impl ToInputArray, flags: i32) -> Result { - input_array_arg!(src); - return_send!(via ocvrs_return); - unsafe { sys::cv_SVD_SVD_const__InputArrayR_int(src.as_raw__InputArray(), flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::SVD::opencv_from_extern(ret) }; - Ok(ret) - } - - /// @overload - /// initializes an empty SVD structure and then calls SVD::operator() - /// ## Parameters - /// * src: decomposed matrix. The depth has to be CV_32F or CV_64F. - /// * flags: operation flags (SVD::Flags) - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * flags: 0 - #[inline] - pub fn new_def(src: &impl ToInputArray) -> Result { - input_array_arg!(src); - return_send!(via ocvrs_return); - unsafe { sys::cv_SVD_SVD_const__InputArrayR(src.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::SVD::opencv_from_extern(ret) }; - Ok(ret) - } - - /// decomposes matrix and stores the results to user-provided matrices - /// - /// The methods/functions perform SVD of matrix. Unlike SVD::SVD constructor - /// and SVD::operator(), they store the results to the user-provided - /// matrices: - /// - /// ```C++ - /// Mat A, w, u, vt; - /// SVD::compute(A, w, u, vt); - /// ``` - /// - /// - /// ## Parameters - /// * src: decomposed matrix. The depth has to be CV_32F or CV_64F. - /// * w: calculated singular values - /// * u: calculated left singular vectors - /// * vt: transposed matrix of right singular vectors - /// * flags: operation flags - see SVD::Flags. - /// - /// ## C++ default parameters - /// * flags: 0 - #[inline] - pub fn compute_ext(src: &impl ToInputArray, w: &mut impl ToOutputArray, u: &mut impl ToOutputArray, vt: &mut impl ToOutputArray, flags: i32) -> Result<()> { + fn apply(&mut self, src: &impl ToInputArray, flags: i32) -> Result { input_array_arg!(src); - output_array_arg!(w); - output_array_arg!(u); - output_array_arg!(vt); return_send!(via ocvrs_return); - unsafe { sys::cv_SVD_compute_const__InputArrayR_const__OutputArrayR_const__OutputArrayR_const__OutputArrayR_int(src.as_raw__InputArray(), w.as_raw__OutputArray(), u.as_raw__OutputArray(), vt.as_raw__OutputArray(), flags, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_SVD_operator___const__InputArrayR_int(self.as_raw_mut_SVD(), src.as_raw__InputArray(), flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::SVD::opencv_from_extern(ret) }; Ok(ret) } - /// decomposes matrix and stores the results to user-provided matrices - /// - /// The methods/functions perform SVD of matrix. Unlike SVD::SVD constructor - /// and SVD::operator(), they store the results to the user-provided - /// matrices: - /// - /// ```C++ - /// Mat A, w, u, vt; - /// SVD::compute(A, w, u, vt); - /// ``` - /// + /// the operator that performs SVD. The previously allocated u, w and vt are released. /// + /// The operator performs the singular value decomposition of the supplied + /// matrix. The u,`vt` , and the vector of singular values w are stored in + /// the structure. The same SVD structure can be reused many times with + /// different matrices. Each time, if needed, the previous u,`vt` , and w + /// are reclaimed and the new matrices are created, which is all handled by + /// Mat::create. /// ## Parameters /// * src: decomposed matrix. The depth has to be CV_32F or CV_64F. - /// * w: calculated singular values - /// * u: calculated left singular vectors - /// * vt: transposed matrix of right singular vectors - /// * flags: operation flags - see SVD::Flags. + /// * flags: operation flags (SVD::Flags) /// /// ## Note - /// This alternative version of [SVD::compute_ext] function uses the following default values for its arguments: + /// This alternative version of [SVDTrait::apply] function uses the following default values for its arguments: /// * flags: 0 #[inline] - pub fn compute_ext_def(src: &impl ToInputArray, w: &mut impl ToOutputArray, u: &mut impl ToOutputArray, vt: &mut impl ToOutputArray) -> Result<()> { + fn apply_def(&mut self, src: &impl ToInputArray) -> Result { input_array_arg!(src); - output_array_arg!(w); - output_array_arg!(u); - output_array_arg!(vt); return_send!(via ocvrs_return); - unsafe { sys::cv_SVD_compute_const__InputArrayR_const__OutputArrayR_const__OutputArrayR_const__OutputArrayR(src.as_raw__InputArray(), w.as_raw__OutputArray(), u.as_raw__OutputArray(), vt.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_SVD_operator___const__InputArrayR(self.as_raw_mut_SVD(), src.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::SVD::opencv_from_extern(ret) }; Ok(ret) } - /// decomposes matrix and stores the results to user-provided matrices - /// - /// The methods/functions perform SVD of matrix. Unlike SVD::SVD constructor - /// and SVD::operator(), they store the results to the user-provided - /// matrices: - /// - /// ```C++ - /// Mat A, w, u, vt; - /// SVD::compute(A, w, u, vt); - /// ``` - /// - /// - /// ## Parameters - /// * src: decomposed matrix. The depth has to be CV_32F or CV_64F. - /// * w: calculated singular values - /// * u: calculated left singular vectors - /// * vt: transposed matrix of right singular vectors - /// * flags: operation flags - see SVD::Flags. - /// - /// ## Overloaded parameters - /// - /// computes singular values of a matrix - /// * src: decomposed matrix. The depth has to be CV_32F or CV_64F. - /// * w: calculated singular values - /// * flags: operation flags - see SVD::Flags. - /// - /// ## C++ default parameters - /// * flags: 0 + } + + impl std::fmt::Debug for SVD { #[inline] - pub fn compute(src: &impl ToInputArray, w: &mut impl ToOutputArray, flags: i32) -> Result<()> { - input_array_arg!(src); - output_array_arg!(w); + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SVD") + .field("u", &core::SVDTraitConst::u(self)) + .field("w", &core::SVDTraitConst::w(self)) + .field("vt", &core::SVDTraitConst::vt(self)) + .finish() + } + } + + impl core::SVDTraitConst for SVD { + #[inline] fn as_raw_SVD(&self) -> *const c_void { self.as_raw() } + } + + impl core::SVDTrait for SVD { + #[inline] fn as_raw_mut_SVD(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { SVD, core::SVDTraitConst, as_raw_SVD, core::SVDTrait, as_raw_mut_SVD } + + /// The class SparseMat represents multi-dimensional sparse numerical arrays. + /// + /// Such a sparse array can store elements of any type that Mat can store. *Sparse* means that only + /// non-zero elements are stored (though, as a result of operations on a sparse matrix, some of its + /// stored elements can actually become 0. It is up to you to detect such elements and delete them + /// using SparseMat::erase ). The non-zero elements are stored in a hash table that grows when it is + /// filled so that the search time is O(1) in average (regardless of whether element is there or not). + /// Elements can be accessed using the following methods: + /// * Query operations (SparseMat::ptr and the higher-level SparseMat::ref, SparseMat::value and + /// SparseMat::find), for example: + /// ```C++ + /// const int dims = 5; + /// int size[5] = {10, 10, 10, 10, 10}; + /// SparseMat sparse_mat(dims, size, CV_32F); + /// for(int i = 0; i < 1000; i++) + /// { + /// int idx[dims]; + /// for(int k = 0; k < dims; k++) + /// idx[k] = rand() % size[k]; + /// sparse_mat.ref(idx) += 1.f; + /// } + /// cout << "nnz = " << sparse_mat.nzcount() << endl; + /// ``` + /// + /// * Sparse matrix iterators. They are similar to MatIterator but different from NAryMatIterator. + /// That is, the iteration loop is familiar to STL users: + /// ```C++ + /// // prints elements of a sparse floating-point matrix + /// // and the sum of elements. + /// SparseMatConstIterator_ + /// it = sparse_mat.begin(), + /// it_end = sparse_mat.end(); + /// double s = 0; + /// int dims = sparse_mat.dims(); + /// for(; it != it_end; ++it) + /// { + /// // print element indices and the element value + /// const SparseMat::Node* n = it.node(); + /// printf("("); + /// for(int i = 0; i < dims; i++) + /// printf("%d%s", n->idx[i], i < dims-1 ? ", " : ")"); + /// printf(": %g\n", it.value()); + /// s += *it; + /// } + /// printf("Element sum is %g\n", s); + /// ``` + /// + /// If you run this loop, you will notice that elements are not enumerated in a logical order + /// (lexicographical, and so on). They come in the same order as they are stored in the hash table + /// (semi-randomly). You may collect pointers to the nodes and sort them to get the proper ordering. + /// Note, however, that pointers to the nodes may become invalid when you add more elements to the + /// matrix. This may happen due to possible buffer reallocation. + /// * Combination of the above 2 methods when you need to process 2 or more sparse matrices + /// simultaneously. For example, this is how you can compute unnormalized cross-correlation of the 2 + /// floating-point sparse matrices: + /// ```C++ + /// double cross_corr(const SparseMat& a, const SparseMat& b) + /// { + /// const SparseMat *_a = &a, *_b = &b; + /// // if b contains less elements than a, + /// // it is faster to iterate through b + /// if(_a->nzcount() > _b->nzcount()) + /// std::swap(_a, _b); + /// SparseMatConstIterator_ it = _a->begin(), + /// it_end = _a->end(); + /// double ccorr = 0; + /// for(; it != it_end; ++it) + /// { + /// // take the next element from the first matrix + /// float avalue = *it; + /// const Node* anode = it.node(); + /// // and try to find an element with the same index in the second matrix. + /// // since the hash value depends only on the element index, + /// // reuse the hash value stored in the node + /// float bvalue = _b->value(anode->idx,&anode->hashval); + /// ccorr += avalue*bvalue; + /// } + /// return ccorr; + /// } + /// ``` + /// + pub struct SparseMat { + ptr: *mut c_void, + } + + opencv_type_boxed! { SparseMat } + + impl Drop for SparseMat { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_SparseMat_delete(self.as_raw_mut_SparseMat()) }; + } + } + + unsafe impl Send for SparseMat {} + + impl SparseMat { + /// Various SparseMat constructors. + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_SVD_compute_const__InputArrayR_const__OutputArrayR_int(src.as_raw__InputArray(), w.as_raw__OutputArray(), flags, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_SparseMat_SparseMat(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::SparseMat::opencv_from_extern(ret) }; Ok(ret) } - /// @overload - /// computes singular values of a matrix - /// ## Parameters - /// * src: decomposed matrix. The depth has to be CV_32F or CV_64F. - /// * w: calculated singular values - /// * flags: operation flags - see SVD::Flags. + /// Various SparseMat constructors. /// - /// ## Note - /// This alternative version of [SVD::compute] function uses the following default values for its arguments: - /// * flags: 0 + /// ## Overloaded parameters + /// + /// ## Parameters + /// * dims: Array dimensionality. + /// * _sizes: Sparce matrix size on all dementions. + /// * _type: Sparse matrix data type. #[inline] - pub fn compute_def(src: &impl ToInputArray, w: &mut impl ToOutputArray) -> Result<()> { - input_array_arg!(src); - output_array_arg!(w); + pub fn new(_sizes: &[i32], _type: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_SVD_compute_const__InputArrayR_const__OutputArrayR(src.as_raw__InputArray(), w.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_SparseMat_SparseMat_int_const_intX_int(_sizes.len().try_into()?, _sizes.as_ptr(), _type, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::SparseMat::opencv_from_extern(ret) }; Ok(ret) } - /// performs back substitution + /// Various SparseMat constructors. + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * m: Source matrix for copy constructor. If m is dense matrix (ocvMat) then it will be converted + /// to sparse representation. #[inline] - pub fn back_subst_multi(w: &impl ToInputArray, u: &impl ToInputArray, vt: &impl ToInputArray, rhs: &impl ToInputArray, dst: &mut impl ToOutputArray) -> Result<()> { - input_array_arg!(w); - input_array_arg!(u); - input_array_arg!(vt); - input_array_arg!(rhs); - output_array_arg!(dst); + pub fn copy(m: &impl core::SparseMatTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_SVD_backSubst_const__InputArrayR_const__InputArrayR_const__InputArrayR_const__InputArrayR_const__OutputArrayR(w.as_raw__InputArray(), u.as_raw__InputArray(), vt.as_raw__InputArray(), rhs.as_raw__InputArray(), dst.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_SparseMat_SparseMat_const_SparseMatR(m.as_raw_SparseMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::SparseMat::opencv_from_extern(ret) }; Ok(ret) } - /// solves an under-determined singular linear system + /// Various SparseMat constructors. + /// + /// ## Overloaded parameters /// - /// The method finds a unit-length solution x of a singular linear system - /// A\*x = 0. Depending on the rank of A, there can be no solutions, a - /// single solution or an infinite number of solutions. In general, the - /// algorithm solves the following problem: - /// ![block formula](https://latex.codecogs.com/png.latex?dst%20%3D%20%20%5Carg%20%5Cmin%20%5F%7Bx%3A%20%20%5C%7C%20x%20%5C%7C%20%3D1%7D%20%20%5C%7C%20src%20%20%5Ccdot%20x%20%20%5C%7C) /// ## Parameters - /// * src: left-hand-side matrix. - /// * dst: found solution. + /// * m: Source matrix for copy constructor. If m is dense matrix (ocvMat) then it will be converted + /// to sparse representation. #[inline] - pub fn solve_z(src: &impl ToInputArray, dst: &mut impl ToOutputArray) -> Result<()> { - input_array_arg!(src); - output_array_arg!(dst); + pub fn from_mat(m: &impl core::MatTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_SVD_solveZ_const__InputArrayR_const__OutputArrayR(src.as_raw__InputArray(), dst.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_SparseMat_SparseMat_const_MatR(m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::SparseMat::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for SVD { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SVD") - .field("u", &core::SVDTraitConst::u(self)) - .field("w", &core::SVDTraitConst::w(self)) - .field("vt", &core::SVDTraitConst::vt(self)) - .finish() - } - } - /// Constant methods for [core::SparseMat] pub trait SparseMatTraitConst { fn as_raw_SparseMat(&self) -> *const c_void; @@ -25790,102 +25940,23 @@ pub mod core { } - /// The class SparseMat represents multi-dimensional sparse numerical arrays. - /// - /// Such a sparse array can store elements of any type that Mat can store. *Sparse* means that only - /// non-zero elements are stored (though, as a result of operations on a sparse matrix, some of its - /// stored elements can actually become 0. It is up to you to detect such elements and delete them - /// using SparseMat::erase ). The non-zero elements are stored in a hash table that grows when it is - /// filled so that the search time is O(1) in average (regardless of whether element is there or not). - /// Elements can be accessed using the following methods: - /// * Query operations (SparseMat::ptr and the higher-level SparseMat::ref, SparseMat::value and - /// SparseMat::find), for example: - /// ```C++ - /// const int dims = 5; - /// int size[5] = {10, 10, 10, 10, 10}; - /// SparseMat sparse_mat(dims, size, CV_32F); - /// for(int i = 0; i < 1000; i++) - /// { - /// int idx[dims]; - /// for(int k = 0; k < dims; k++) - /// idx[k] = rand() % size[k]; - /// sparse_mat.ref(idx) += 1.f; - /// } - /// cout << "nnz = " << sparse_mat.nzcount() << endl; - /// ``` - /// - /// * Sparse matrix iterators. They are similar to MatIterator but different from NAryMatIterator. - /// That is, the iteration loop is familiar to STL users: - /// ```C++ - /// // prints elements of a sparse floating-point matrix - /// // and the sum of elements. - /// SparseMatConstIterator_ - /// it = sparse_mat.begin(), - /// it_end = sparse_mat.end(); - /// double s = 0; - /// int dims = sparse_mat.dims(); - /// for(; it != it_end; ++it) - /// { - /// // print element indices and the element value - /// const SparseMat::Node* n = it.node(); - /// printf("("); - /// for(int i = 0; i < dims; i++) - /// printf("%d%s", n->idx[i], i < dims-1 ? ", " : ")"); - /// printf(": %g\n", it.value()); - /// s += *it; - /// } - /// printf("Element sum is %g\n", s); - /// ``` - /// - /// If you run this loop, you will notice that elements are not enumerated in a logical order - /// (lexicographical, and so on). They come in the same order as they are stored in the hash table - /// (semi-randomly). You may collect pointers to the nodes and sort them to get the proper ordering. - /// Note, however, that pointers to the nodes may become invalid when you add more elements to the - /// matrix. This may happen due to possible buffer reallocation. - /// * Combination of the above 2 methods when you need to process 2 or more sparse matrices - /// simultaneously. For example, this is how you can compute unnormalized cross-correlation of the 2 - /// floating-point sparse matrices: - /// ```C++ - /// double cross_corr(const SparseMat& a, const SparseMat& b) - /// { - /// const SparseMat *_a = &a, *_b = &b; - /// // if b contains less elements than a, - /// // it is faster to iterate through b - /// if(_a->nzcount() > _b->nzcount()) - /// std::swap(_a, _b); - /// SparseMatConstIterator_ it = _a->begin(), - /// it_end = _a->end(); - /// double ccorr = 0; - /// for(; it != it_end; ++it) - /// { - /// // take the next element from the first matrix - /// float avalue = *it; - /// const Node* anode = it.node(); - /// // and try to find an element with the same index in the second matrix. - /// // since the hash value depends only on the element index, - /// // reuse the hash value stored in the node - /// float bvalue = _b->value(anode->idx,&anode->hashval); - /// ccorr += avalue*bvalue; - /// } - /// return ccorr; - /// } - /// ``` - /// - pub struct SparseMat { - ptr: *mut c_void, + impl Clone for SparseMat { + #[inline] + /// Calls try_clone() and panics if that fails + fn clone(&self) -> Self { + self.try_clone().expect("Cannot clone SparseMat") + } } - opencv_type_boxed! { SparseMat } - - impl Drop for SparseMat { + impl std::fmt::Debug for SparseMat { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_SparseMat_delete(self.as_raw_mut_SparseMat()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SparseMat") + .field("flags", &core::SparseMatTraitConst::flags(self)) + .finish() } } - unsafe impl Send for SparseMat {} - impl core::SparseMatTraitConst for SparseMat { #[inline] fn as_raw_SparseMat(&self) -> *const c_void { self.as_raw() } } @@ -25896,89 +25967,35 @@ pub mod core { boxed_ref! { SparseMat, core::SparseMatTraitConst, as_raw_SparseMat, core::SparseMatTrait, as_raw_mut_SparseMat } - impl SparseMat { - /// Various SparseMat constructors. - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_SparseMat_SparseMat(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::SparseMat::opencv_from_extern(ret) }; - Ok(ret) - } + /// the sparse matrix header + pub struct SparseMat_Hdr { + ptr: *mut c_void, + } - /// Various SparseMat constructors. - /// - /// ## Overloaded parameters - /// - /// ## Parameters - /// * dims: Array dimensionality. - /// * _sizes: Sparce matrix size on all dementions. - /// * _type: Sparse matrix data type. - #[inline] - pub fn new(_sizes: &[i32], _type: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_SparseMat_SparseMat_int_const_intX_int(_sizes.len().try_into()?, _sizes.as_ptr(), _type, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::SparseMat::opencv_from_extern(ret) }; - Ok(ret) - } + opencv_type_boxed! { SparseMat_Hdr } - /// Various SparseMat constructors. - /// - /// ## Overloaded parameters - /// - /// ## Parameters - /// * m: Source matrix for copy constructor. If m is dense matrix (ocvMat) then it will be converted - /// to sparse representation. + impl Drop for SparseMat_Hdr { #[inline] - pub fn copy(m: &impl core::SparseMatTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_SparseMat_SparseMat_const_SparseMatR(m.as_raw_SparseMat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::SparseMat::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_SparseMat_Hdr_delete(self.as_raw_mut_SparseMat_Hdr()) }; } + } - /// Various SparseMat constructors. - /// - /// ## Overloaded parameters - /// - /// ## Parameters - /// * m: Source matrix for copy constructor. If m is dense matrix (ocvMat) then it will be converted - /// to sparse representation. + unsafe impl Send for SparseMat_Hdr {} + + impl SparseMat_Hdr { #[inline] - pub fn from_mat(m: &impl core::MatTraitConst) -> Result { + pub fn new(_sizes: &[i32], _type: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_SparseMat_SparseMat_const_MatR(m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_SparseMat_Hdr_Hdr_int_const_intX_int(_sizes.len().try_into()?, _sizes.as_ptr(), _type, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::SparseMat::opencv_from_extern(ret) }; + let ret = unsafe { core::SparseMat_Hdr::opencv_from_extern(ret) }; Ok(ret) } } - impl Clone for SparseMat { - #[inline] - /// Calls try_clone() and panics if that fails - fn clone(&self) -> Self { - self.try_clone().expect("Cannot clone SparseMat") - } - } - - impl std::fmt::Debug for SparseMat { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SparseMat") - .field("flags", &core::SparseMatTraitConst::flags(self)) - .finish() - } - } - /// Constant methods for [core::SparseMat_Hdr] pub trait SparseMat_HdrTraitConst { fn as_raw_SparseMat_Hdr(&self) -> *const c_void; @@ -26112,22 +26129,23 @@ pub mod core { } - /// the sparse matrix header - pub struct SparseMat_Hdr { - ptr: *mut c_void, - } - - opencv_type_boxed! { SparseMat_Hdr } - - impl Drop for SparseMat_Hdr { + impl std::fmt::Debug for SparseMat_Hdr { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_SparseMat_Hdr_delete(self.as_raw_mut_SparseMat_Hdr()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SparseMat_Hdr") + .field("refcount", &core::SparseMat_HdrTraitConst::refcount(self)) + .field("dims", &core::SparseMat_HdrTraitConst::dims(self)) + .field("value_offset", &core::SparseMat_HdrTraitConst::value_offset(self)) + .field("node_size", &core::SparseMat_HdrTraitConst::node_size(self)) + .field("node_count", &core::SparseMat_HdrTraitConst::node_count(self)) + .field("free_list", &core::SparseMat_HdrTraitConst::free_list(self)) + .field("pool", &core::SparseMat_HdrTraitConst::pool(self)) + .field("hashtab", &core::SparseMat_HdrTraitConst::hashtab(self)) + .field("size", &core::SparseMat_HdrTraitConst::size(self)) + .finish() } } - unsafe impl Send for SparseMat_Hdr {} - impl core::SparseMat_HdrTraitConst for SparseMat_Hdr { #[inline] fn as_raw_SparseMat_Hdr(&self) -> *const c_void { self.as_raw() } } @@ -26138,34 +26156,31 @@ pub mod core { boxed_ref! { SparseMat_Hdr, core::SparseMat_HdrTraitConst, as_raw_SparseMat_Hdr, core::SparseMat_HdrTrait, as_raw_mut_SparseMat_Hdr } - impl SparseMat_Hdr { - #[inline] - pub fn new(_sizes: &[i32], _type: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_SparseMat_Hdr_Hdr_int_const_intX_int(_sizes.len().try_into()?, _sizes.as_ptr(), _type, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::SparseMat_Hdr::opencv_from_extern(ret) }; - Ok(ret) - } - + /// sparse matrix node - element of a hash table + pub struct SparseMat_Node { + ptr: *mut c_void, } - impl std::fmt::Debug for SparseMat_Hdr { + opencv_type_boxed! { SparseMat_Node } + + impl Drop for SparseMat_Node { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SparseMat_Hdr") - .field("refcount", &core::SparseMat_HdrTraitConst::refcount(self)) - .field("dims", &core::SparseMat_HdrTraitConst::dims(self)) - .field("value_offset", &core::SparseMat_HdrTraitConst::value_offset(self)) - .field("node_size", &core::SparseMat_HdrTraitConst::node_size(self)) - .field("node_count", &core::SparseMat_HdrTraitConst::node_count(self)) - .field("free_list", &core::SparseMat_HdrTraitConst::free_list(self)) - .field("pool", &core::SparseMat_HdrTraitConst::pool(self)) - .field("hashtab", &core::SparseMat_HdrTraitConst::hashtab(self)) - .field("size", &core::SparseMat_HdrTraitConst::size(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_SparseMat_Node_delete(self.as_raw_mut_SparseMat_Node()) }; + } + } + + unsafe impl Send for SparseMat_Node {} + + impl SparseMat_Node { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> core::SparseMat_Node { + let ret = unsafe { sys::cv_SparseMat_Node_defaultNew_const() }; + let ret = unsafe { core::SparseMat_Node::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [core::SparseMat_Node] @@ -26224,22 +26239,25 @@ pub mod core { } - /// sparse matrix node - element of a hash table - pub struct SparseMat_Node { - ptr: *mut c_void, + impl Default for SparseMat_Node { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { SparseMat_Node } - - impl Drop for SparseMat_Node { + impl std::fmt::Debug for SparseMat_Node { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_SparseMat_Node_delete(self.as_raw_mut_SparseMat_Node()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SparseMat_Node") + .field("hashval", &core::SparseMat_NodeTraitConst::hashval(self)) + .field("next", &core::SparseMat_NodeTraitConst::next(self)) + .field("idx", &core::SparseMat_NodeTraitConst::idx(self)) + .finish() } } - unsafe impl Send for SparseMat_Node {} - impl core::SparseMat_NodeTraitConst for SparseMat_Node { #[inline] fn as_raw_SparseMat_Node(&self) -> *const c_void { self.as_raw() } } @@ -26250,32 +26268,66 @@ pub mod core { boxed_ref! { SparseMat_Node, core::SparseMat_NodeTraitConst, as_raw_SparseMat_Node, core::SparseMat_NodeTrait, as_raw_mut_SparseMat_Node } - impl SparseMat_Node { - /// Creates a default instance of the class by calling the default constructor + /// Read-Only Sparse Matrix Iterator. + /// + /// Here is how to use the iterator to compute the sum of floating-point sparse matrix elements: + /// + /// \code + /// SparseMatConstIterator it = m.begin(), it_end = m.end(); + /// double s = 0; + /// CV_Assert( m.type() == CV_32F ); + /// for( ; it != it_end; ++it ) + /// s += it.value(); + /// \endcode + pub struct SparseMatConstIterator { + ptr: *mut c_void, + } + + opencv_type_boxed! { SparseMatConstIterator } + + impl Drop for SparseMatConstIterator { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_SparseMat_Node_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_SparseMatConstIterator_delete(self.as_raw_mut_SparseMatConstIterator()) }; } - } - impl std::fmt::Debug for SparseMat_Node { + unsafe impl Send for SparseMatConstIterator {} + + impl SparseMatConstIterator { + /// the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SparseMat_Node") - .field("hashval", &core::SparseMat_NodeTraitConst::hashval(self)) - .field("next", &core::SparseMat_NodeTraitConst::next(self)) - .field("idx", &core::SparseMat_NodeTraitConst::idx(self)) - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_SparseMatConstIterator_SparseMatConstIterator(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::SparseMatConstIterator::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for SparseMat_Node { + /// the full constructor setting the iterator to the first sparse matrix element #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new(_m: &impl core::SparseMatTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_SparseMatConstIterator_SparseMatConstIterator_const_SparseMatX(_m.as_raw_SparseMat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::SparseMatConstIterator::opencv_from_extern(ret) }; + Ok(ret) + } + + /// the copy constructor + #[inline] + pub fn copy(it: &impl core::SparseMatConstIteratorTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_SparseMatConstIterator_SparseMatConstIterator_const_SparseMatConstIteratorR(it.as_raw_SparseMatConstIterator(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::SparseMatConstIterator::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [core::SparseMatConstIterator] @@ -26369,32 +26421,17 @@ pub mod core { } - /// Read-Only Sparse Matrix Iterator. - /// - /// Here is how to use the iterator to compute the sum of floating-point sparse matrix elements: - /// - /// \code - /// SparseMatConstIterator it = m.begin(), it_end = m.end(); - /// double s = 0; - /// CV_Assert( m.type() == CV_32F ); - /// for( ; it != it_end; ++it ) - /// s += it.value(); - /// \endcode - pub struct SparseMatConstIterator { - ptr: *mut c_void, - } - - opencv_type_boxed! { SparseMatConstIterator } - - impl Drop for SparseMatConstIterator { + impl std::fmt::Debug for SparseMatConstIterator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_SparseMatConstIterator_delete(self.as_raw_mut_SparseMatConstIterator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SparseMatConstIterator") + .field("m", &core::SparseMatConstIteratorTraitConst::m(self)) + .field("hashidx", &core::SparseMatConstIteratorTraitConst::hashidx(self)) + .field("ptr", &core::SparseMatConstIteratorTraitConst::ptr(self)) + .finish() } } - unsafe impl Send for SparseMatConstIterator {} - impl core::SparseMatConstIteratorTraitConst for SparseMatConstIterator { #[inline] fn as_raw_SparseMatConstIterator(&self) -> *const c_void { self.as_raw() } } @@ -26405,53 +26442,61 @@ pub mod core { boxed_ref! { SparseMatConstIterator, core::SparseMatConstIteratorTraitConst, as_raw_SparseMatConstIterator, core::SparseMatConstIteratorTrait, as_raw_mut_SparseMatConstIterator } - impl SparseMatConstIterator { + /// Read-write Sparse Matrix Iterator + /// + /// The class is similar to cv::SparseMatConstIterator, + /// but can be used for in-place modification of the matrix elements. + pub struct SparseMatIterator { + ptr: *mut c_void, + } + + opencv_type_boxed! { SparseMatIterator } + + impl Drop for SparseMatIterator { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_SparseMatIterator_delete(self.as_raw_mut_SparseMatIterator()) }; + } + } + + unsafe impl Send for SparseMatIterator {} + + impl SparseMatIterator { /// the default constructor #[inline] - pub fn default() -> Result { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_SparseMatConstIterator_SparseMatConstIterator(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_SparseMatIterator_SparseMatIterator(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::SparseMatConstIterator::opencv_from_extern(ret) }; + let ret = unsafe { core::SparseMatIterator::opencv_from_extern(ret) }; Ok(ret) } /// the full constructor setting the iterator to the first sparse matrix element #[inline] - pub fn new(_m: &impl core::SparseMatTraitConst) -> Result { + pub fn new(_m: &mut impl core::SparseMatTrait) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_SparseMatConstIterator_SparseMatConstIterator_const_SparseMatX(_m.as_raw_SparseMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_SparseMatIterator_SparseMatIterator_SparseMatX(_m.as_raw_mut_SparseMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::SparseMatConstIterator::opencv_from_extern(ret) }; + let ret = unsafe { core::SparseMatIterator::opencv_from_extern(ret) }; Ok(ret) } /// the copy constructor #[inline] - pub fn copy(it: &impl core::SparseMatConstIteratorTraitConst) -> Result { + pub fn copy(it: &impl core::SparseMatIteratorTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_SparseMatConstIterator_SparseMatConstIterator_const_SparseMatConstIteratorR(it.as_raw_SparseMatConstIterator(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_SparseMatIterator_SparseMatIterator_const_SparseMatIteratorR(it.as_raw_SparseMatIterator(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::SparseMatConstIterator::opencv_from_extern(ret) }; + let ret = unsafe { core::SparseMatIterator::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for SparseMatConstIterator { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SparseMatConstIterator") - .field("m", &core::SparseMatConstIteratorTraitConst::m(self)) - .field("hashidx", &core::SparseMatConstIteratorTraitConst::hashidx(self)) - .field("ptr", &core::SparseMatConstIteratorTraitConst::ptr(self)) - .finish() - } - } - /// Constant methods for [core::SparseMatIterator] pub trait SparseMatIteratorTraitConst: core::SparseMatConstIteratorTraitConst { fn as_raw_SparseMatIterator(&self) -> *const c_void; @@ -26496,24 +26541,18 @@ pub mod core { } - /// Read-write Sparse Matrix Iterator - /// - /// The class is similar to cv::SparseMatConstIterator, - /// but can be used for in-place modification of the matrix elements. - pub struct SparseMatIterator { - ptr: *mut c_void, - } - - opencv_type_boxed! { SparseMatIterator } - - impl Drop for SparseMatIterator { + impl std::fmt::Debug for SparseMatIterator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_SparseMatIterator_delete(self.as_raw_mut_SparseMatIterator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SparseMatIterator") + .field("m", &core::SparseMatConstIteratorTraitConst::m(self)) + .field("hashidx", &core::SparseMatConstIteratorTraitConst::hashidx(self)) + .field("ptr", &core::SparseMatConstIteratorTraitConst::ptr(self)) + .finish() } } - unsafe impl Send for SparseMatIterator {} + boxed_cast_base! { SparseMatIterator, core::SparseMatConstIterator, cv_SparseMatIterator_to_SparseMatConstIterator } impl core::SparseMatConstIteratorTraitConst for SparseMatIterator { #[inline] fn as_raw_SparseMatConstIterator(&self) -> *const c_void { self.as_raw() } @@ -26526,64 +26565,15 @@ pub mod core { boxed_ref! { SparseMatIterator, core::SparseMatConstIteratorTraitConst, as_raw_SparseMatConstIterator, core::SparseMatConstIteratorTrait, as_raw_mut_SparseMatConstIterator } impl core::SparseMatIteratorTraitConst for SparseMatIterator { - #[inline] fn as_raw_SparseMatIterator(&self) -> *const c_void { self.as_raw() } - } - - impl core::SparseMatIteratorTrait for SparseMatIterator { - #[inline] fn as_raw_mut_SparseMatIterator(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { SparseMatIterator, core::SparseMatIteratorTraitConst, as_raw_SparseMatIterator, core::SparseMatIteratorTrait, as_raw_mut_SparseMatIterator } - - impl SparseMatIterator { - /// the default constructor - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_SparseMatIterator_SparseMatIterator(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::SparseMatIterator::opencv_from_extern(ret) }; - Ok(ret) - } - - /// the full constructor setting the iterator to the first sparse matrix element - #[inline] - pub fn new(_m: &mut impl core::SparseMatTrait) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_SparseMatIterator_SparseMatIterator_SparseMatX(_m.as_raw_mut_SparseMat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::SparseMatIterator::opencv_from_extern(ret) }; - Ok(ret) - } - - /// the copy constructor - #[inline] - pub fn copy(it: &impl core::SparseMatIteratorTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_SparseMatIterator_SparseMatIterator_const_SparseMatIteratorR(it.as_raw_SparseMatIterator(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::SparseMatIterator::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { SparseMatIterator, core::SparseMatConstIterator, cv_SparseMatIterator_to_SparseMatConstIterator } - - impl std::fmt::Debug for SparseMatIterator { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SparseMatIterator") - .field("m", &core::SparseMatConstIteratorTraitConst::m(self)) - .field("hashidx", &core::SparseMatConstIteratorTraitConst::hashidx(self)) - .field("ptr", &core::SparseMatConstIteratorTraitConst::ptr(self)) - .finish() - } + #[inline] fn as_raw_SparseMatIterator(&self) -> *const c_void { self.as_raw() } + } + + impl core::SparseMatIteratorTrait for SparseMatIterator { + #[inline] fn as_raw_mut_SparseMatIterator(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { SparseMatIterator, core::SparseMatIteratorTraitConst, as_raw_SparseMatIterator, core::SparseMatIteratorTrait, as_raw_mut_SparseMatIterator } + /// The class defining termination criteria for iterative algorithms. /// /// You can initialize it by default constructor and then override any parameters, or the structure may @@ -26636,6 +26626,45 @@ pub mod core { } + /// a Class to measure passing time. + /// + /// The class computes passing time by counting the number of ticks per second. That is, the following code computes the + /// execution time in seconds: + /// [TickMeter_total](https://github.com/opencv/opencv/blob/4.11.0/samples/cpp/tutorial_code/snippets/core_various.cpp#L1) + /// + /// It is also possible to compute the average time over multiple runs: + /// [TickMeter_average](https://github.com/opencv/opencv/blob/4.11.0/samples/cpp/tutorial_code/snippets/core_various.cpp#L1) + /// ## See also + /// getTickCount, getTickFrequency + pub struct TickMeter { + ptr: *mut c_void, + } + + opencv_type_boxed! { TickMeter } + + impl Drop for TickMeter { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_TickMeter_delete(self.as_raw_mut_TickMeter()) }; + } + } + + unsafe impl Send for TickMeter {} + + impl TickMeter { + /// the default constructor + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_TickMeter_TickMeter(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::TickMeter::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [core::TickMeter] pub trait TickMeterTraitConst { fn as_raw_TickMeter(&self) -> *const c_void; @@ -26798,31 +26827,14 @@ pub mod core { } - /// a Class to measure passing time. - /// - /// The class computes passing time by counting the number of ticks per second. That is, the following code computes the - /// execution time in seconds: - /// [TickMeter_total](https://github.com/opencv/opencv/blob/4.11.0/samples/cpp/tutorial_code/snippets/core_various.cpp#L1) - /// - /// It is also possible to compute the average time over multiple runs: - /// [TickMeter_average](https://github.com/opencv/opencv/blob/4.11.0/samples/cpp/tutorial_code/snippets/core_various.cpp#L1) - /// ## See also - /// getTickCount, getTickFrequency - pub struct TickMeter { - ptr: *mut c_void, - } - - opencv_type_boxed! { TickMeter } - - impl Drop for TickMeter { + impl std::fmt::Debug for TickMeter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_TickMeter_delete(self.as_raw_mut_TickMeter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TickMeter") + .finish() } } - unsafe impl Send for TickMeter {} - impl core::TickMeterTraitConst for TickMeter { #[inline] fn as_raw_TickMeter(&self) -> *const c_void { self.as_raw() } } @@ -26833,317 +26845,281 @@ pub mod core { boxed_ref! { TickMeter, core::TickMeterTraitConst, as_raw_TickMeter, core::TickMeterTrait, as_raw_mut_TickMeter } - impl TickMeter { - /// the default constructor - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_TickMeter_TickMeter(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::TickMeter::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for TickMeter { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TickMeter") - .finish() - } + /// @todo document + pub struct UMat { + ptr: *mut c_void, } - /// Constant methods for [core::UMat] - pub trait UMatTraitConst { - fn as_raw_UMat(&self) -> *const c_void; + opencv_type_boxed! { UMat } - /// ! includes several bit-fields: - /// - the magic signature - /// - continuity flag - /// - depth - /// - number of channels + impl Drop for UMat { #[inline] - fn flags(&self) -> i32 { - let ret = unsafe { sys::cv_UMat_propFlags_const(self.as_raw_UMat()) }; - ret + fn drop(&mut self) { + unsafe { sys::cv_UMat_delete(self.as_raw_mut_UMat()) }; } + } - /// the matrix dimensionality, >= 2 - #[inline] - fn dims(&self) -> i32 { - let ret = unsafe { sys::cv_UMat_propDims_const(self.as_raw_UMat()) }; - ret - } + unsafe impl Send for UMat {} - /// number of rows in the matrix; -1 when the matrix has more than 2 dimensions + impl UMat { + /// default constructor + /// + /// ## C++ default parameters + /// * usage_flags: USAGE_DEFAULT #[inline] - fn rows(&self) -> i32 { - let ret = unsafe { sys::cv_UMat_propRows_const(self.as_raw_UMat()) }; + pub fn new(usage_flags: core::UMatUsageFlags) -> core::UMat { + let ret = unsafe { sys::cv_UMat_UMat_UMatUsageFlags(usage_flags) }; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; ret } - /// number of columns in the matrix; -1 when the matrix has more than 2 dimensions + /// default constructor + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * usage_flags: USAGE_DEFAULT #[inline] - fn cols(&self) -> i32 { - let ret = unsafe { sys::cv_UMat_propCols_const(self.as_raw_UMat()) }; + pub fn new_def() -> core::UMat { + let ret = unsafe { sys::cv_UMat_UMat() }; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; ret } - /// usage flags for allocator; recommend do not set directly, instead set during construct/create/getUMat + /// constructs 2D matrix of the specified size and type + /// + /// ## C++ default parameters + /// * usage_flags: USAGE_DEFAULT #[inline] - fn usage_flags(&self) -> core::UMatUsageFlags { + pub unsafe fn new_rows_cols(rows: i32, cols: i32, typ: i32, usage_flags: core::UMatUsageFlags) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_propUsageFlags_const(self.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - ret - } - - /// offset of the submatrix (or 0) - #[inline] - fn offset(&self) -> size_t { - let ret = unsafe { sys::cv_UMat_propOffset_const(self.as_raw_UMat()) }; - ret - } - - /// dimensional size of the matrix; accessible in various formats - #[inline] - fn mat_size(&self) -> core::MatSize { - let ret = unsafe { sys::cv_UMat_propSize_const(self.as_raw_UMat()) }; - let ret = unsafe { core::MatSize::opencv_from_extern(ret) }; - ret - } - - /// number of bytes each matrix element/row/plane/dimension occupies - #[inline] - fn mat_step(&self) -> core::MatStep { - let ret = unsafe { sys::cv_UMat_propStep_const(self.as_raw_UMat()) }; - let ret = unsafe { core::MatStep::opencv_from_extern(ret) }; - ret + { sys::cv_UMat_UMat_int_int_int_UMatUsageFlags(rows, cols, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = { core::UMat::opencv_from_extern(ret) }; + Ok(ret) } + /// constructs 2D matrix of the specified size and type + /// + /// ## Note + /// This alternative version of [new_rows_cols] function uses the following default values for its arguments: + /// * usage_flags: USAGE_DEFAULT #[inline] - fn get_mat(&self, flags: core::AccessFlag) -> Result { + pub fn new_rows_cols_def(rows: i32, cols: i32, typ: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_getMat_const_AccessFlag(self.as_raw_UMat(), flags, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_UMat_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// returns a new matrix header for the specified row + /// ## C++ default parameters + /// * usage_flags: USAGE_DEFAULT #[inline] - fn row(&self, y: i32) -> Result> { + pub unsafe fn new_size(size: core::Size, typ: i32, usage_flags: core::UMatUsageFlags) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_row_const_int(self.as_raw_UMat(), y, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_UMat_UMat_Size_int_UMatUsageFlags(&size, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// returns a new matrix header for the specified column + /// ## Note + /// This alternative version of [new_size] function uses the following default values for its arguments: + /// * usage_flags: USAGE_DEFAULT #[inline] - fn col(&self, x: i32) -> Result> { + pub fn new_size_def(size: core::Size, typ: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_col_const_int(self.as_raw_UMat(), x, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_UMat_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// ... for the specified row span + /// constructs 2D matrix and fills it with the specified value _s. + /// + /// ## C++ default parameters + /// * usage_flags: USAGE_DEFAULT #[inline] - fn row_bounds(&self, startrow: i32, endrow: i32) -> Result> { + pub fn new_rows_cols_with_default(rows: i32, cols: i32, typ: i32, s: core::Scalar, usage_flags: core::UMatUsageFlags) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_rowRange_const_int_int(self.as_raw_UMat(), startrow, endrow, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_UMat_int_int_int_const_ScalarR_UMatUsageFlags(rows, cols, typ, &s, usage_flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// constructs 2D matrix and fills it with the specified value _s. + /// + /// ## Note + /// This alternative version of [new_rows_cols_with_default] function uses the following default values for its arguments: + /// * usage_flags: USAGE_DEFAULT #[inline] - fn row_range(&self, r: &impl core::RangeTraitConst) -> Result> { + pub fn new_rows_cols_with_default_def(rows: i32, cols: i32, typ: i32, s: core::Scalar) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_rowRange_const_const_RangeR(self.as_raw_UMat(), r.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_UMat_int_int_int_const_ScalarR(rows, cols, typ, &s, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// ... for the specified column span + /// ## C++ default parameters + /// * usage_flags: USAGE_DEFAULT #[inline] - fn col_bounds(&self, startcol: i32, endcol: i32) -> Result> { + pub fn new_size_with_default(size: core::Size, typ: i32, s: core::Scalar, usage_flags: core::UMatUsageFlags) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_colRange_const_int_int(self.as_raw_UMat(), startcol, endcol, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_UMat_Size_int_const_ScalarR_UMatUsageFlags(&size, typ, &s, usage_flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [new_size_with_default] function uses the following default values for its arguments: + /// * usage_flags: USAGE_DEFAULT #[inline] - fn col_range(&self, r: &impl core::RangeTraitConst) -> Result> { + pub fn new_size_with_default_def(size: core::Size, typ: i32, s: core::Scalar) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_colRange_const_const_RangeR(self.as_raw_UMat(), r.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_UMat_Size_int_const_ScalarR(&size, typ, &s, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// ... for the specified diagonal - /// (d=0 - the main diagonal, - /// >0 - a diagonal from the upper half, - /// <0 - a diagonal from the lower half) + /// constructs n-dimensional matrix /// /// ## C++ default parameters - /// * d: 0 + /// * usage_flags: USAGE_DEFAULT #[inline] - fn diag(&self, d: i32) -> Result> { + pub unsafe fn new_nd(sizes: &[i32], typ: i32, usage_flags: core::UMatUsageFlags) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_diag_const_int(self.as_raw_UMat(), d, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_UMat_UMat_int_const_intX_int_UMatUsageFlags(sizes.len().try_into()?, sizes.as_ptr(), typ, usage_flags, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// ... for the specified diagonal - /// (d=0 - the main diagonal, - /// >0 - a diagonal from the upper half, - /// <0 - a diagonal from the lower half) + /// constructs n-dimensional matrix /// /// ## Note - /// This alternative version of [UMatTraitConst::diag] function uses the following default values for its arguments: - /// * d: 0 + /// This alternative version of [new_nd] function uses the following default values for its arguments: + /// * usage_flags: USAGE_DEFAULT #[inline] - fn diag_def(&self) -> Result> { + pub fn new_nd_def(sizes: &[i32], typ: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_diag_const(self.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_UMat_int_const_intX_int(sizes.len().try_into()?, sizes.as_ptr(), typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// returns deep copy of the matrix, i.e. the data is copied + /// ## C++ default parameters + /// * usage_flags: USAGE_DEFAULT #[inline] - #[must_use] - fn try_clone(&self) -> Result { + pub fn new_nd_with_default(sizes: &[i32], typ: i32, s: core::Scalar, usage_flags: core::UMatUsageFlags) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_clone_const(self.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_UMat_int_const_intX_int_const_ScalarR_UMatUsageFlags(sizes.len().try_into()?, sizes.as_ptr(), typ, &s, usage_flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// copies the matrix content to "m". + /// ## Note + /// This alternative version of [new_nd_with_default] function uses the following default values for its arguments: + /// * usage_flags: USAGE_DEFAULT #[inline] - fn copy_to(&self, m: &mut impl ToOutputArray) -> Result<()> { - output_array_arg!(m); + pub fn new_nd_with_default_def(sizes: &[i32], typ: i32, s: core::Scalar) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_copyTo_const_const__OutputArrayR(self.as_raw_UMat(), m.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_UMat_int_const_intX_int_const_ScalarR(sizes.len().try_into()?, sizes.as_ptr(), typ, &s, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// copies those matrix elements to "m" that are marked with non-zero mask elements. + /// copy constructor #[inline] - fn copy_to_masked(&self, m: &mut impl ToOutputArray, mask: &impl ToInputArray) -> Result<()> { - output_array_arg!(m); - input_array_arg!(mask); + pub fn copy(m: &impl core::UMatTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_copyTo_const_const__OutputArrayR_const__InputArrayR(self.as_raw_UMat(), m.as_raw__OutputArray(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_UMat_const_UMatR(m.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// converts matrix to another datatype with optional scaling. See cvConvertScale. + /// creates a matrix header for a part of the bigger matrix /// /// ## C++ default parameters - /// * alpha: 1 - /// * beta: 0 + /// * col_range: Range::all() #[inline] - fn convert_to(&self, m: &mut impl ToOutputArray, rtype: i32, alpha: f64, beta: f64) -> Result<()> { - output_array_arg!(m); + pub fn rowscols<'boxed>(m: &'boxed impl core::UMatTraitConst, row_range: &impl core::RangeTraitConst, col_range: &impl core::RangeTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_convertTo_const_const__OutputArrayR_int_double_double(self.as_raw_UMat(), m.as_raw__OutputArray(), rtype, alpha, beta, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_UMat_const_UMatR_const_RangeR_const_RangeR(m.as_raw_UMat(), row_range.as_raw_Range(), col_range.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::<'boxed, core::UMat>::opencv_from_extern(ret) }; Ok(ret) } - /// converts matrix to another datatype with optional scaling. See cvConvertScale. + /// creates a matrix header for a part of the bigger matrix /// /// ## Note - /// This alternative version of [UMatTraitConst::convert_to] function uses the following default values for its arguments: - /// * alpha: 1 - /// * beta: 0 - #[inline] - fn convert_to_def(&self, m: &mut impl ToOutputArray, rtype: i32) -> Result<()> { - output_array_arg!(m); - return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_convertTo_const_const__OutputArrayR_int(self.as_raw_UMat(), m.as_raw__OutputArray(), rtype, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// ## C++ default parameters - /// * typ: -1 + /// This alternative version of [rowscols] function uses the following default values for its arguments: + /// * col_range: Range::all() #[inline] - fn assign_to(&self, m: &mut impl core::UMatTrait, typ: i32) -> Result<()> { + pub fn rowscols_def_mut<'boxed>(m: &'boxed mut impl core::UMatTrait, row_range: &impl core::RangeTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_assignTo_const_UMatR_int(self.as_raw_UMat(), m.as_raw_mut_UMat(), typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_UMat_UMatR_const_RangeR(m.as_raw_mut_UMat(), row_range.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRefMut::<'boxed, core::UMat>::opencv_from_extern(ret) }; Ok(ret) } + /// creates a matrix header for a part of the bigger matrix + /// /// ## Note - /// This alternative version of [UMatTraitConst::assign_to] function uses the following default values for its arguments: - /// * typ: -1 + /// This alternative version of [rowscols] function uses the following default values for its arguments: + /// * col_range: Range::all() #[inline] - fn assign_to_def(&self, m: &mut impl core::UMatTrait) -> Result<()> { + pub fn rowscols_def<'boxed>(m: &'boxed impl core::UMatTraitConst, row_range: &impl core::RangeTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_assignTo_const_UMatR(self.as_raw_UMat(), m.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_UMat_const_UMatR_const_RangeR(m.as_raw_UMat(), row_range.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::<'boxed, core::UMat>::opencv_from_extern(ret) }; Ok(ret) } - /// creates alternative matrix header for the same data, with different + /// creates a matrix header for a part of the bigger matrix /// /// ## C++ default parameters - /// * rows: 0 + /// * col_range: Range::all() #[inline] - fn reshape(&self, cn: i32, rows: i32) -> Result> { + pub fn rowscols_mut<'boxed>(m: &'boxed mut impl core::UMatTrait, row_range: &impl core::RangeTraitConst, col_range: &impl core::RangeTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_reshape_const_int_int(self.as_raw_UMat(), cn, rows, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_UMat_UMatR_const_RangeR_const_RangeR(m.as_raw_mut_UMat(), row_range.as_raw_Range(), col_range.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::<'boxed, core::UMat>::opencv_from_extern(ret) }; Ok(ret) } - /// creates alternative matrix header for the same data, with different - /// - /// ## Note - /// This alternative version of [UMatTraitConst::reshape] function uses the following default values for its arguments: - /// * rows: 0 #[inline] - fn reshape_def(&self, cn: i32) -> Result> { + pub fn roi(m: &impl core::UMatTraitConst, roi: core::Rect) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_reshape_const_int(self.as_raw_UMat(), cn, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_UMat_const_UMatR_const_RectR(m.as_raw_UMat(), &roi, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; @@ -27151,295 +27127,250 @@ pub mod core { } #[inline] - fn reshape_nd(&self, cn: i32, newsz: &[i32]) -> Result> { + pub fn roi_mut(m: &mut impl core::UMatTrait, roi: core::Rect) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_reshape_const_int_int_const_intX(self.as_raw_UMat(), cn, newsz.len().try_into()?, newsz.as_ptr(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_UMat_UMatR_const_RectR(m.as_raw_mut_UMat(), &roi, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// matrix transposition by means of matrix expressions #[inline] - fn t(&self) -> Result { + pub fn ranges<'boxed>(m: &'boxed impl core::UMatTraitConst, ranges: &core::Vector) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_t_const(self.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_UMat_const_UMatR_const_vectorLRangeGR(m.as_raw_UMat(), ranges.as_raw_VectorOfRange(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRef::<'boxed, core::UMat>::opencv_from_extern(ret) }; Ok(ret) } - /// matrix inversion by means of matrix expressions - /// - /// ## C++ default parameters - /// * method: DECOMP_LU #[inline] - fn inv(&self, method: i32) -> Result { + pub fn ranges_mut<'boxed>(m: &'boxed mut impl core::UMatTrait, ranges: &core::Vector) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_inv_const_int(self.as_raw_UMat(), method, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_UMat_UMatR_const_vectorLRangeGR(m.as_raw_mut_UMat(), ranges.as_raw_VectorOfRange(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::<'boxed, core::UMat>::opencv_from_extern(ret) }; Ok(ret) } - /// matrix inversion by means of matrix expressions - /// - /// ## Note - /// This alternative version of [UMatTraitConst::inv] function uses the following default values for its arguments: - /// * method: DECOMP_LU + /// constructs a square diagonal matrix which main diagonal is vector "d" #[inline] - fn inv_def(&self) -> Result { + #[must_use] + pub fn diag_flags(d: &impl core::UMatTraitConst, usage_flags: core::UMatUsageFlags) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_inv_const(self.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_diag_const_UMatR_UMatUsageFlags(d.as_raw_UMat(), usage_flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// per-element matrix multiplication by means of matrix expressions - /// - /// ## C++ default parameters - /// * scale: 1 #[inline] - fn mul(&self, m: &impl ToInputArray, scale: f64) -> Result { - input_array_arg!(m); + #[must_use] + pub fn diag(d: &impl core::UMatTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_mul_const_const__InputArrayR_double(self.as_raw_UMat(), m.as_raw__InputArray(), scale, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_diag_const_UMatR(d.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// per-element matrix multiplication by means of matrix expressions - /// - /// ## Note - /// This alternative version of [UMatTraitConst::mul] function uses the following default values for its arguments: - /// * scale: 1 + /// Matlab-style matrix initialization #[inline] - fn mul_def(&self, m: &impl ToInputArray) -> Result { - input_array_arg!(m); + #[must_use] + pub fn zeros_flags(rows: i32, cols: i32, typ: i32, usage_flags: core::UMatUsageFlags) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_mul_const_const__InputArrayR(self.as_raw_UMat(), m.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_zeros_int_int_int_UMatUsageFlags(rows, cols, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// computes dot-product #[inline] - fn dot(&self, m: &impl ToInputArray) -> Result { - input_array_arg!(m); + #[must_use] + pub fn zeros_size_flags(size: core::Size, typ: i32, usage_flags: core::UMatUsageFlags) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_dot_const_const__InputArrayR(self.as_raw_UMat(), m.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_zeros_Size_int_UMatUsageFlags(&size, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// locates matrix header within a parent matrix. See below #[inline] - fn locate_roi(&self, whole_size: &mut core::Size, ofs: &mut core::Point) -> Result<()> { + #[must_use] + pub fn zeros_nd_flags(sz: &[i32], typ: i32, usage_flags: core::UMatUsageFlags) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_locateROI_const_SizeR_PointR(self.as_raw_UMat(), whole_size, ofs, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_zeros_int_const_intX_int_UMatUsageFlags(sz.len().try_into()?, sz.as_ptr(), typ, usage_flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// extracts a rectangular sub-matrix #[inline] - fn rowscols(&self, mut row_range: impl core::RangeTrait, mut col_range: impl core::RangeTrait) -> Result> { + #[must_use] + pub fn zeros(rows: i32, cols: i32, typ: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_operator___const_Range_Range(self.as_raw_UMat(), row_range.as_raw_mut_Range(), col_range.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_zeros_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn roi(&self, roi: core::Rect) -> Result> { + #[must_use] + pub fn zeros_size(size: core::Size, typ: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_operator___const_const_RectR(self.as_raw_UMat(), &roi, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_zeros_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn ranges(&self, ranges: &core::Vector) -> Result> { + #[must_use] + pub fn zeros_nd(sz: &[i32], typ: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_operator___const_const_vectorLRangeGR(self.as_raw_UMat(), ranges.as_raw_VectorOfRange(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_zeros_int_const_intX_int(sz.len().try_into()?, sz.as_ptr(), typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// returns true iff the matrix data is continuous - #[inline] - fn is_continuous(&self) -> bool { - let ret = unsafe { sys::cv_UMat_isContinuous_const(self.as_raw_UMat()) }; - ret - } - - /// returns true if the matrix is a submatrix of another matrix #[inline] - fn is_submatrix(&self) -> bool { - let ret = unsafe { sys::cv_UMat_isSubmatrix_const(self.as_raw_UMat()) }; - ret - } - - /// returns element size in bytes, - #[inline] - fn elem_size(&self) -> Result { + #[must_use] + pub fn ones_flags(rows: i32, cols: i32, typ: i32, usage_flags: core::UMatUsageFlags) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_elemSize_const(self.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_ones_int_int_int_UMatUsageFlags(rows, cols, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// returns the size of element channel in bytes. - #[inline] - fn elem_size1(&self) -> size_t { - let ret = unsafe { sys::cv_UMat_elemSize1_const(self.as_raw_UMat()) }; - ret - } - - /// returns element type, similar to CV_MAT_TYPE(cvmat->type) - #[inline] - fn typ(&self) -> i32 { - let ret = unsafe { sys::cv_UMat_type_const(self.as_raw_UMat()) }; - ret - } - - /// returns element type, similar to CV_MAT_DEPTH(cvmat->type) - #[inline] - fn depth(&self) -> i32 { - let ret = unsafe { sys::cv_UMat_depth_const(self.as_raw_UMat()) }; - ret - } - - /// returns element type, similar to CV_MAT_CN(cvmat->type) #[inline] - fn channels(&self) -> i32 { - let ret = unsafe { sys::cv_UMat_channels_const(self.as_raw_UMat()) }; - ret + #[must_use] + pub fn ones_size_flags(size: core::Size, typ: i32, usage_flags: core::UMatUsageFlags) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_UMat_ones_Size_int_UMatUsageFlags(&size, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + Ok(ret) } - /// returns step/elemSize1() - /// - /// ## C++ default parameters - /// * i: 0 #[inline] - fn step1(&self, i: i32) -> Result { + #[must_use] + pub fn ones_nd_flags(sz: &[i32], typ: i32, usage_flags: core::UMatUsageFlags) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_step1_const_int(self.as_raw_UMat(), i, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_ones_int_const_intX_int_UMatUsageFlags(sz.len().try_into()?, sz.as_ptr(), typ, usage_flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// returns step/elemSize1() - /// - /// ## Note - /// This alternative version of [UMatTraitConst::step1] function uses the following default values for its arguments: - /// * i: 0 #[inline] - fn step1_def(&self) -> Result { + #[must_use] + pub fn ones(rows: i32, cols: i32, typ: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_step1_const(self.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_ones_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// returns true if matrix data is NULL #[inline] - fn empty(&self) -> bool { - let ret = unsafe { sys::cv_UMat_empty_const(self.as_raw_UMat()) }; - ret + #[must_use] + pub fn ones_size(size: core::Size, typ: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_UMat_ones_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + Ok(ret) } - /// returns the total number of matrix elements #[inline] - fn total(&self) -> size_t { - let ret = unsafe { sys::cv_UMat_total_const(self.as_raw_UMat()) }; - ret + #[must_use] + pub fn ones_nd(sz: &[i32], typ: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_UMat_ones_int_const_intX_int(sz.len().try_into()?, sz.as_ptr(), typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + Ok(ret) } - /// returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise - /// - /// ## C++ default parameters - /// * depth: -1 - /// * require_continuous: true #[inline] - fn check_vector(&self, elem_channels: i32, depth: i32, require_continuous: bool) -> Result { + #[must_use] + pub fn eye_flags(rows: i32, cols: i32, typ: i32, usage_flags: core::UMatUsageFlags) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_checkVector_const_int_int_bool(self.as_raw_UMat(), elem_channels, depth, require_continuous, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_eye_int_int_int_UMatUsageFlags(rows, cols, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise - /// - /// ## Note - /// This alternative version of [UMatTraitConst::check_vector] function uses the following default values for its arguments: - /// * depth: -1 - /// * require_continuous: true #[inline] - fn check_vector_def(&self, elem_channels: i32) -> Result { + #[must_use] + pub fn eye_size_flags(size: core::Size, typ: i32, usage_flags: core::UMatUsageFlags) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_checkVector_const_int(self.as_raw_UMat(), elem_channels, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_eye_Size_int_UMatUsageFlags(&size, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// ! Returns the OpenCL buffer handle on which UMat operates on. - /// The UMat instance should be kept alive during the use of the handle to prevent the buffer to be - /// returned to the OpenCV buffer pool. #[inline] - fn handle(&self, access_flags: core::AccessFlag) -> Result<*mut c_void> { + #[must_use] + pub fn eye(rows: i32, cols: i32, typ: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_handle_const_AccessFlag(self.as_raw_UMat(), access_flags, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_eye_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn ndoffset(&self, ofs: &mut size_t) -> Result<()> { + #[must_use] + pub fn eye_size(size: core::Size, typ: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_ndoffset_const_size_tX(self.as_raw_UMat(), ofs, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_eye_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn size(&self) -> Result { + pub fn copy_mut(mut m: core::UMat) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_size_const(self.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_UMat_UMatRR(m.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } } - /// Mutable methods for [core::UMat] - pub trait UMatTrait: core::UMatTraitConst { - fn as_raw_mut_UMat(&mut self) -> *mut c_void; + /// Constant methods for [core::UMat] + pub trait UMatTraitConst { + fn as_raw_UMat(&self) -> *const c_void; /// ! includes several bit-fields: /// - the magic signature @@ -27447,139 +27378,152 @@ pub mod core { /// - depth /// - number of channels #[inline] - fn set_flags(&mut self, val: i32) { - let ret = unsafe { sys::cv_UMat_propFlags_const_int(self.as_raw_mut_UMat(), val) }; + fn flags(&self) -> i32 { + let ret = unsafe { sys::cv_UMat_propFlags_const(self.as_raw_UMat()) }; ret } /// the matrix dimensionality, >= 2 #[inline] - fn set_dims(&mut self, val: i32) { - let ret = unsafe { sys::cv_UMat_propDims_const_int(self.as_raw_mut_UMat(), val) }; + fn dims(&self) -> i32 { + let ret = unsafe { sys::cv_UMat_propDims_const(self.as_raw_UMat()) }; ret } /// number of rows in the matrix; -1 when the matrix has more than 2 dimensions #[inline] - fn set_rows(&mut self, val: i32) { - let ret = unsafe { sys::cv_UMat_propRows_const_int(self.as_raw_mut_UMat(), val) }; + fn rows(&self) -> i32 { + let ret = unsafe { sys::cv_UMat_propRows_const(self.as_raw_UMat()) }; ret } /// number of columns in the matrix; -1 when the matrix has more than 2 dimensions #[inline] - fn set_cols(&mut self, val: i32) { - let ret = unsafe { sys::cv_UMat_propCols_const_int(self.as_raw_mut_UMat(), val) }; + fn cols(&self) -> i32 { + let ret = unsafe { sys::cv_UMat_propCols_const(self.as_raw_UMat()) }; ret } /// usage flags for allocator; recommend do not set directly, instead set during construct/create/getUMat #[inline] - fn set_usage_flags(&mut self, val: core::UMatUsageFlags) { - let ret = unsafe { sys::cv_UMat_propUsageFlags_const_UMatUsageFlags(self.as_raw_mut_UMat(), val) }; - ret - } - - /// black-box container of UMat data - #[inline] - fn u(&mut self) -> core::UMatData { - let ret = unsafe { sys::cv_UMat_propU(self.as_raw_mut_UMat()) }; - let ret = unsafe { core::UMatData::opencv_from_extern(ret) }; + fn usage_flags(&self) -> core::UMatUsageFlags { + return_send!(via ocvrs_return); + unsafe { sys::cv_UMat_propUsageFlags_const(self.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); ret } - /// black-box container of UMat data + /// offset of the submatrix (or 0) #[inline] - fn set_u(&mut self, val: &impl core::UMatDataTraitConst) { - let ret = unsafe { sys::cv_UMat_propU_UMatDataX(self.as_raw_mut_UMat(), val.as_raw_UMatData()) }; + fn offset(&self) -> size_t { + let ret = unsafe { sys::cv_UMat_propOffset_const(self.as_raw_UMat()) }; ret } - /// offset of the submatrix (or 0) + /// dimensional size of the matrix; accessible in various formats #[inline] - fn set_offset(&mut self, val: size_t) { - let ret = unsafe { sys::cv_UMat_propOffset_const_size_t(self.as_raw_mut_UMat(), val) }; + fn mat_size(&self) -> core::MatSize { + let ret = unsafe { sys::cv_UMat_propSize_const(self.as_raw_UMat()) }; + let ret = unsafe { core::MatSize::opencv_from_extern(ret) }; ret } - /// dimensional size of the matrix; accessible in various formats + /// number of bytes each matrix element/row/plane/dimension occupies #[inline] - fn set_mat_size(&mut self, val: core::MatSize) { - let ret = unsafe { sys::cv_UMat_propSize_const_MatSize(self.as_raw_mut_UMat(), val.as_raw_MatSize()) }; + fn mat_step(&self) -> core::MatStep { + let ret = unsafe { sys::cv_UMat_propStep_const(self.as_raw_UMat()) }; + let ret = unsafe { core::MatStep::opencv_from_extern(ret) }; ret } - /// assignment operators #[inline] - fn set(&mut self, m: &impl core::UMatTraitConst) -> Result<()> { + fn get_mat(&self, flags: core::AccessFlag) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_operatorST_const_UMatR(self.as_raw_mut_UMat(), m.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_getMat_const_AccessFlag(self.as_raw_UMat(), flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } /// returns a new matrix header for the specified row #[inline] - fn row_mut(&mut self, y: i32) -> Result> { + fn row(&self, y: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_row_int(self.as_raw_mut_UMat(), y, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_row_const_int(self.as_raw_UMat(), y, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } /// returns a new matrix header for the specified column #[inline] - fn col_mut(&mut self, x: i32) -> Result> { + fn col(&self, x: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_col_int(self.as_raw_mut_UMat(), x, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_col_const_int(self.as_raw_UMat(), x, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } /// ... for the specified row span #[inline] - fn row_bounds_mut(&mut self, startrow: i32, endrow: i32) -> Result> { + fn row_bounds(&self, startrow: i32, endrow: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_rowRange_int_int(self.as_raw_mut_UMat(), startrow, endrow, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_rowRange_const_int_int(self.as_raw_UMat(), startrow, endrow, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn row_range_mut(&mut self, r: &impl core::RangeTraitConst) -> Result> { + fn row_range(&self, r: &impl core::RangeTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_rowRange_const_RangeR(self.as_raw_mut_UMat(), r.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_rowRange_const_const_RangeR(self.as_raw_UMat(), r.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } /// ... for the specified column span #[inline] - fn col_bounds_mut(&mut self, startcol: i32, endcol: i32) -> Result> { + fn col_bounds(&self, startcol: i32, endcol: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_colRange_int_int(self.as_raw_mut_UMat(), startcol, endcol, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_colRange_const_int_int(self.as_raw_UMat(), startcol, endcol, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn col_range_mut(&mut self, r: &impl core::RangeTraitConst) -> Result> { + fn col_range(&self, r: &impl core::RangeTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_colRange_const_RangeR(self.as_raw_mut_UMat(), r.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_colRange_const_const_RangeR(self.as_raw_UMat(), r.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ... for the specified diagonal + /// (d=0 - the main diagonal, + /// >0 - a diagonal from the upper half, + /// <0 - a diagonal from the lower half) + /// + /// ## C++ default parameters + /// * d: 0 + #[inline] + fn diag(&self, d: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_UMat_diag_const_int(self.as_raw_UMat(), d, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } @@ -27592,71 +27536,115 @@ pub mod core { /// This alternative version of [UMatTraitConst::diag] function uses the following default values for its arguments: /// * d: 0 #[inline] - fn diag_def_mut(&mut self) -> Result> { + fn diag_def(&self) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_UMat_diag_const(self.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// returns deep copy of the matrix, i.e. the data is copied + #[inline] + #[must_use] + fn try_clone(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_UMat_clone_const(self.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + Ok(ret) + } + + /// copies the matrix content to "m". + #[inline] + fn copy_to(&self, m: &mut impl ToOutputArray) -> Result<()> { + output_array_arg!(m); + return_send!(via ocvrs_return); + unsafe { sys::cv_UMat_copyTo_const_const__OutputArrayR(self.as_raw_UMat(), m.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// copies those matrix elements to "m" that are marked with non-zero mask elements. + #[inline] + fn copy_to_masked(&self, m: &mut impl ToOutputArray, mask: &impl ToInputArray) -> Result<()> { + output_array_arg!(m); + input_array_arg!(mask); + return_send!(via ocvrs_return); + unsafe { sys::cv_UMat_copyTo_const_const__OutputArrayR_const__InputArrayR(self.as_raw_UMat(), m.as_raw__OutputArray(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// converts matrix to another datatype with optional scaling. See cvConvertScale. + /// + /// ## C++ default parameters + /// * alpha: 1 + /// * beta: 0 + #[inline] + fn convert_to(&self, m: &mut impl ToOutputArray, rtype: i32, alpha: f64, beta: f64) -> Result<()> { + output_array_arg!(m); return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_diag(self.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_convertTo_const_const__OutputArrayR_int_double_double(self.as_raw_UMat(), m.as_raw__OutputArray(), rtype, alpha, beta, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// ... for the specified diagonal - /// (d=0 - the main diagonal, - /// >0 - a diagonal from the upper half, - /// <0 - a diagonal from the lower half) + /// converts matrix to another datatype with optional scaling. See cvConvertScale. /// - /// ## C++ default parameters - /// * d: 0 + /// ## Note + /// This alternative version of [UMatTraitConst::convert_to] function uses the following default values for its arguments: + /// * alpha: 1 + /// * beta: 0 #[inline] - fn diag_mut(&mut self, d: i32) -> Result> { + fn convert_to_def(&self, m: &mut impl ToOutputArray, rtype: i32) -> Result<()> { + output_array_arg!(m); return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_diag_int(self.as_raw_mut_UMat(), d, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_convertTo_const_const__OutputArrayR_int(self.as_raw_UMat(), m.as_raw__OutputArray(), rtype, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// sets every matrix element to s + /// ## C++ default parameters + /// * typ: -1 #[inline] - fn set_scalar(&mut self, s: core::Scalar) -> Result<()> { + fn assign_to(&self, m: &mut impl core::UMatTrait, typ: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_operatorST_const_ScalarR(self.as_raw_mut_UMat(), &s, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_assignTo_const_UMatR_int(self.as_raw_UMat(), m.as_raw_mut_UMat(), typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// sets some of the matrix elements to s, according to the mask - /// - /// ## C++ default parameters - /// * mask: noArray() + /// ## Note + /// This alternative version of [UMatTraitConst::assign_to] function uses the following default values for its arguments: + /// * typ: -1 #[inline] - fn set_to(&mut self, value: &impl ToInputArray, mask: &impl ToInputArray) -> Result { - input_array_arg!(value); - input_array_arg!(mask); + fn assign_to_def(&self, m: &mut impl core::UMatTrait) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_setTo_const__InputArrayR_const__InputArrayR(self.as_raw_mut_UMat(), value.as_raw__InputArray(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_assignTo_const_UMatR(self.as_raw_UMat(), m.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// sets some of the matrix elements to s, according to the mask + /// creates alternative matrix header for the same data, with different /// - /// ## Note - /// This alternative version of [UMatTrait::set_to] function uses the following default values for its arguments: - /// * mask: noArray() + /// ## C++ default parameters + /// * rows: 0 #[inline] - fn set_to_def(&mut self, value: &impl ToInputArray) -> Result { - input_array_arg!(value); + fn reshape(&self, cn: i32, rows: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_setTo_const__InputArrayR(self.as_raw_mut_UMat(), value.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_reshape_const_int_int(self.as_raw_UMat(), cn, rows, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } @@ -27666,221 +27654,295 @@ pub mod core { /// This alternative version of [UMatTraitConst::reshape] function uses the following default values for its arguments: /// * rows: 0 #[inline] - fn reshape_def_mut(&mut self, cn: i32) -> Result> { + fn reshape_def(&self, cn: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_reshape_int(self.as_raw_mut_UMat(), cn, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_reshape_const_int(self.as_raw_UMat(), cn, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// creates alternative matrix header for the same data, with different - /// - /// ## C++ default parameters - /// * rows: 0 #[inline] - fn reshape_mut(&mut self, cn: i32, rows: i32) -> Result> { + fn reshape_nd(&self, cn: i32, newsz: &[i32]) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_reshape_int_int(self.as_raw_mut_UMat(), cn, rows, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_reshape_const_int_int_const_intX(self.as_raw_UMat(), cn, newsz.len().try_into()?, newsz.as_ptr(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } + /// matrix transposition by means of matrix expressions #[inline] - fn reshape_nd_mut(&mut self, cn: i32, newsz: &[i32]) -> Result> { + fn t(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_reshape_int_int_const_intX(self.as_raw_mut_UMat(), cn, newsz.len().try_into()?, newsz.as_ptr(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_t_const(self.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// allocates new matrix data unless the matrix already has specified size and type. + /// matrix inversion by means of matrix expressions /// /// ## C++ default parameters - /// * usage_flags: USAGE_DEFAULT + /// * method: DECOMP_LU #[inline] - unsafe fn create_rows_cols(&mut self, rows: i32, cols: i32, typ: i32, usage_flags: core::UMatUsageFlags) -> Result<()> { + fn inv(&self, method: i32) -> Result { return_send!(via ocvrs_return); - { sys::cv_UMat_create_int_int_int_UMatUsageFlags(self.as_raw_mut_UMat(), rows, cols, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_UMat_inv_const_int(self.as_raw_UMat(), method, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// allocates new matrix data unless the matrix already has specified size and type. + /// matrix inversion by means of matrix expressions /// /// ## Note - /// This alternative version of [UMatTrait::create_rows_cols] function uses the following default values for its arguments: - /// * usage_flags: USAGE_DEFAULT + /// This alternative version of [UMatTraitConst::inv] function uses the following default values for its arguments: + /// * method: DECOMP_LU #[inline] - fn create_rows_cols_def(&mut self, rows: i32, cols: i32, typ: i32) -> Result<()> { + fn inv_def(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_create_int_int_int(self.as_raw_mut_UMat(), rows, cols, typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_inv_const(self.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// per-element matrix multiplication by means of matrix expressions + /// /// ## C++ default parameters - /// * usage_flags: USAGE_DEFAULT + /// * scale: 1 #[inline] - unsafe fn create_size(&mut self, size: core::Size, typ: i32, usage_flags: core::UMatUsageFlags) -> Result<()> { + fn mul(&self, m: &impl ToInputArray, scale: f64) -> Result { + input_array_arg!(m); return_send!(via ocvrs_return); - { sys::cv_UMat_create_Size_int_UMatUsageFlags(self.as_raw_mut_UMat(), &size, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_UMat_mul_const_const__InputArrayR_double(self.as_raw_UMat(), m.as_raw__InputArray(), scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// per-element matrix multiplication by means of matrix expressions + /// /// ## Note - /// This alternative version of [UMatTrait::create_size] function uses the following default values for its arguments: - /// * usage_flags: USAGE_DEFAULT + /// This alternative version of [UMatTraitConst::mul] function uses the following default values for its arguments: + /// * scale: 1 #[inline] - fn create_size_def(&mut self, size: core::Size, typ: i32) -> Result<()> { + fn mul_def(&self, m: &impl ToInputArray) -> Result { + input_array_arg!(m); return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_create_Size_int(self.as_raw_mut_UMat(), &size, typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_mul_const_const__InputArrayR(self.as_raw_UMat(), m.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// ## C++ default parameters - /// * usage_flags: USAGE_DEFAULT + /// computes dot-product #[inline] - unsafe fn create_nd(&mut self, sizes: &[i32], typ: i32, usage_flags: core::UMatUsageFlags) -> Result<()> { + fn dot(&self, m: &impl ToInputArray) -> Result { + input_array_arg!(m); return_send!(via ocvrs_return); - { sys::cv_UMat_create_int_const_intX_int_UMatUsageFlags(self.as_raw_mut_UMat(), sizes.len().try_into()?, sizes.as_ptr(), typ, usage_flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_UMat_dot_const_const__InputArrayR(self.as_raw_UMat(), m.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// ## Note - /// This alternative version of [UMatTrait::create_nd] function uses the following default values for its arguments: - /// * usage_flags: USAGE_DEFAULT + /// locates matrix header within a parent matrix. See below #[inline] - fn create_nd_def(&mut self, sizes: &[i32], typ: i32) -> Result<()> { + fn locate_roi(&self, whole_size: &mut core::Size, ofs: &mut core::Point) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_create_int_const_intX_int(self.as_raw_mut_UMat(), sizes.len().try_into()?, sizes.as_ptr(), typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_locateROI_const_SizeR_PointR(self.as_raw_UMat(), whole_size, ofs, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// ## C++ default parameters - /// * usage_flags: USAGE_DEFAULT + /// extracts a rectangular sub-matrix #[inline] - unsafe fn create_nd_vec(&mut self, sizes: &core::Vector, typ: i32, usage_flags: core::UMatUsageFlags) -> Result<()> { + fn rowscols(&self, mut row_range: impl core::RangeTrait, mut col_range: impl core::RangeTrait) -> Result> { return_send!(via ocvrs_return); - { sys::cv_UMat_create_const_vectorLintGR_int_UMatUsageFlags(self.as_raw_mut_UMat(), sizes.as_raw_VectorOfi32(), typ, usage_flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_UMat_operator___const_Range_Range(self.as_raw_UMat(), row_range.as_raw_mut_Range(), col_range.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [UMatTrait::create_nd_vec] function uses the following default values for its arguments: - /// * usage_flags: USAGE_DEFAULT #[inline] - fn create_nd_vec_def(&mut self, sizes: &core::Vector, typ: i32) -> Result<()> { + fn roi(&self, roi: core::Rect) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_create_const_vectorLintGR_int(self.as_raw_mut_UMat(), sizes.as_raw_VectorOfi32(), typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_operator___const_const_RectR(self.as_raw_UMat(), &roi, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// increases the reference counter; use with care to avoid memleaks #[inline] - unsafe fn addref(&mut self) -> Result<()> { + fn ranges(&self, ranges: &core::Vector) -> Result> { return_send!(via ocvrs_return); - { sys::cv_UMat_addref(self.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_UMat_operator___const_const_vectorLRangeGR(self.as_raw_UMat(), ranges.as_raw_VectorOfRange(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// decreases reference counter; + /// returns true iff the matrix data is continuous #[inline] - unsafe fn release(&mut self) -> Result<()> { + fn is_continuous(&self) -> bool { + let ret = unsafe { sys::cv_UMat_isContinuous_const(self.as_raw_UMat()) }; + ret + } + + /// returns true if the matrix is a submatrix of another matrix + #[inline] + fn is_submatrix(&self) -> bool { + let ret = unsafe { sys::cv_UMat_isSubmatrix_const(self.as_raw_UMat()) }; + ret + } + + /// returns element size in bytes, + #[inline] + fn elem_size(&self) -> Result { return_send!(via ocvrs_return); - { sys::cv_UMat_release(self.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_UMat_elemSize_const(self.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// deallocates the matrix data + /// returns the size of element channel in bytes. #[inline] - fn deallocate(&mut self) -> Result<()> { + fn elem_size1(&self) -> size_t { + let ret = unsafe { sys::cv_UMat_elemSize1_const(self.as_raw_UMat()) }; + ret + } + + /// returns element type, similar to CV_MAT_TYPE(cvmat->type) + #[inline] + fn typ(&self) -> i32 { + let ret = unsafe { sys::cv_UMat_type_const(self.as_raw_UMat()) }; + ret + } + + /// returns element type, similar to CV_MAT_DEPTH(cvmat->type) + #[inline] + fn depth(&self) -> i32 { + let ret = unsafe { sys::cv_UMat_depth_const(self.as_raw_UMat()) }; + ret + } + + /// returns element type, similar to CV_MAT_CN(cvmat->type) + #[inline] + fn channels(&self) -> i32 { + let ret = unsafe { sys::cv_UMat_channels_const(self.as_raw_UMat()) }; + ret + } + + /// returns step/elemSize1() + /// + /// ## C++ default parameters + /// * i: 0 + #[inline] + fn step1(&self, i: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_deallocate(self.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_step1_const_int(self.as_raw_UMat(), i, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// moves/resizes the current matrix ROI inside the parent matrix. + /// returns step/elemSize1() + /// + /// ## Note + /// This alternative version of [UMatTraitConst::step1] function uses the following default values for its arguments: + /// * i: 0 #[inline] - fn adjust_roi(&mut self, dtop: i32, dbottom: i32, dleft: i32, dright: i32) -> Result { + fn step1_def(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_adjustROI_int_int_int_int(self.as_raw_mut_UMat(), dtop, dbottom, dleft, dright, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_step1_const(self.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// extracts a rectangular sub-matrix + /// returns true if matrix data is NULL + #[inline] + fn empty(&self) -> bool { + let ret = unsafe { sys::cv_UMat_empty_const(self.as_raw_UMat()) }; + ret + } + + /// returns the total number of matrix elements + #[inline] + fn total(&self) -> size_t { + let ret = unsafe { sys::cv_UMat_total_const(self.as_raw_UMat()) }; + ret + } + + /// returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise + /// + /// ## C++ default parameters + /// * depth: -1 + /// * require_continuous: true #[inline] - fn rowscols_mut(&mut self, mut row_range: impl core::RangeTrait, mut col_range: impl core::RangeTrait) -> Result> { + fn check_vector(&self, elem_channels: i32, depth: i32, require_continuous: bool) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_operator___Range_Range(self.as_raw_mut_UMat(), row_range.as_raw_mut_Range(), col_range.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_checkVector_const_int_int_bool(self.as_raw_UMat(), elem_channels, depth, require_continuous, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } + /// returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise + /// + /// ## Note + /// This alternative version of [UMatTraitConst::check_vector] function uses the following default values for its arguments: + /// * depth: -1 + /// * require_continuous: true #[inline] - fn roi_mut(&mut self, roi: core::Rect) -> Result> { + fn check_vector_def(&self, elem_channels: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_operator___const_RectR(self.as_raw_mut_UMat(), &roi, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_checkVector_const_int(self.as_raw_UMat(), elem_channels, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } + /// ! Returns the OpenCL buffer handle on which UMat operates on. + /// The UMat instance should be kept alive during the use of the handle to prevent the buffer to be + /// returned to the OpenCV buffer pool. #[inline] - fn ranges_mut(&mut self, ranges: &core::Vector) -> Result> { + fn handle(&self, access_flags: core::AccessFlag) -> Result<*mut c_void> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_operator___const_vectorLRangeGR(self.as_raw_mut_UMat(), ranges.as_raw_VectorOfRange(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_handle_const_AccessFlag(self.as_raw_UMat(), access_flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn set_1(&mut self, mut m: core::UMat) -> Result<()> { + fn ndoffset(&self, ofs: &mut size_t) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_operatorST_UMatRR(self.as_raw_mut_UMat(), m.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_ndoffset_const_size_tX(self.as_raw_UMat(), ofs, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// internal use method: updates the continuity flag #[inline] - fn update_continuity_flag(&mut self) -> Result<()> { + fn size(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_updateContinuityFlag(self.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_size_const(self.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -27888,534 +27950,452 @@ pub mod core { } - /// @todo document - pub struct UMat { - ptr: *mut c_void, - } - - opencv_type_boxed! { UMat } - - impl Drop for UMat { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_UMat_delete(self.as_raw_mut_UMat()) }; - } - } - - unsafe impl Send for UMat {} - - impl core::UMatTraitConst for UMat { - #[inline] fn as_raw_UMat(&self) -> *const c_void { self.as_raw() } - } - - impl core::UMatTrait for UMat { - #[inline] fn as_raw_mut_UMat(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { UMat, core::UMatTraitConst, as_raw_UMat, core::UMatTrait, as_raw_mut_UMat } + /// Mutable methods for [core::UMat] + pub trait UMatTrait: core::UMatTraitConst { + fn as_raw_mut_UMat(&mut self) -> *mut c_void; - impl UMat { - /// default constructor - /// - /// ## C++ default parameters - /// * usage_flags: USAGE_DEFAULT + /// ! includes several bit-fields: + /// - the magic signature + /// - continuity flag + /// - depth + /// - number of channels #[inline] - pub fn new(usage_flags: core::UMatUsageFlags) -> core::UMat { - let ret = unsafe { sys::cv_UMat_UMat_UMatUsageFlags(usage_flags) }; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + fn set_flags(&mut self, val: i32) { + let ret = unsafe { sys::cv_UMat_propFlags_const_int(self.as_raw_mut_UMat(), val) }; ret } - /// default constructor - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * usage_flags: USAGE_DEFAULT + /// the matrix dimensionality, >= 2 #[inline] - pub fn new_def() -> core::UMat { - let ret = unsafe { sys::cv_UMat_UMat() }; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + fn set_dims(&mut self, val: i32) { + let ret = unsafe { sys::cv_UMat_propDims_const_int(self.as_raw_mut_UMat(), val) }; ret } - /// constructs 2D matrix of the specified size and type - /// - /// ## C++ default parameters - /// * usage_flags: USAGE_DEFAULT + /// number of rows in the matrix; -1 when the matrix has more than 2 dimensions #[inline] - pub unsafe fn new_rows_cols(rows: i32, cols: i32, typ: i32, usage_flags: core::UMatUsageFlags) -> Result { - return_send!(via ocvrs_return); - { sys::cv_UMat_UMat_int_int_int_UMatUsageFlags(rows, cols, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = { core::UMat::opencv_from_extern(ret) }; - Ok(ret) + fn set_rows(&mut self, val: i32) { + let ret = unsafe { sys::cv_UMat_propRows_const_int(self.as_raw_mut_UMat(), val) }; + ret } - /// constructs 2D matrix of the specified size and type - /// - /// ## Note - /// This alternative version of [new_rows_cols] function uses the following default values for its arguments: - /// * usage_flags: USAGE_DEFAULT + /// number of columns in the matrix; -1 when the matrix has more than 2 dimensions #[inline] - pub fn new_rows_cols_def(rows: i32, cols: i32, typ: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_UMat_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; - Ok(ret) + fn set_cols(&mut self, val: i32) { + let ret = unsafe { sys::cv_UMat_propCols_const_int(self.as_raw_mut_UMat(), val) }; + ret } - /// ## C++ default parameters - /// * usage_flags: USAGE_DEFAULT + /// usage flags for allocator; recommend do not set directly, instead set during construct/create/getUMat #[inline] - pub unsafe fn new_size(size: core::Size, typ: i32, usage_flags: core::UMatUsageFlags) -> Result { - return_send!(via ocvrs_return); - { sys::cv_UMat_UMat_Size_int_UMatUsageFlags(&size, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = { core::UMat::opencv_from_extern(ret) }; - Ok(ret) + fn set_usage_flags(&mut self, val: core::UMatUsageFlags) { + let ret = unsafe { sys::cv_UMat_propUsageFlags_const_UMatUsageFlags(self.as_raw_mut_UMat(), val) }; + ret } - /// ## Note - /// This alternative version of [new_size] function uses the following default values for its arguments: - /// * usage_flags: USAGE_DEFAULT + /// black-box container of UMat data #[inline] - pub fn new_size_def(size: core::Size, typ: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_UMat_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; - Ok(ret) + fn u(&mut self) -> core::UMatData { + let ret = unsafe { sys::cv_UMat_propU(self.as_raw_mut_UMat()) }; + let ret = unsafe { core::UMatData::opencv_from_extern(ret) }; + ret } - /// constructs 2D matrix and fills it with the specified value _s. - /// - /// ## C++ default parameters - /// * usage_flags: USAGE_DEFAULT + /// black-box container of UMat data #[inline] - pub fn new_rows_cols_with_default(rows: i32, cols: i32, typ: i32, s: core::Scalar, usage_flags: core::UMatUsageFlags) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_UMat_int_int_int_const_ScalarR_UMatUsageFlags(rows, cols, typ, &s, usage_flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; - Ok(ret) + fn set_u(&mut self, val: &impl core::UMatDataTraitConst) { + let ret = unsafe { sys::cv_UMat_propU_UMatDataX(self.as_raw_mut_UMat(), val.as_raw_UMatData()) }; + ret } - /// constructs 2D matrix and fills it with the specified value _s. - /// - /// ## Note - /// This alternative version of [new_rows_cols_with_default] function uses the following default values for its arguments: - /// * usage_flags: USAGE_DEFAULT + /// offset of the submatrix (or 0) #[inline] - pub fn new_rows_cols_with_default_def(rows: i32, cols: i32, typ: i32, s: core::Scalar) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_UMat_int_int_int_const_ScalarR(rows, cols, typ, &s, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; - Ok(ret) + fn set_offset(&mut self, val: size_t) { + let ret = unsafe { sys::cv_UMat_propOffset_const_size_t(self.as_raw_mut_UMat(), val) }; + ret } - /// ## C++ default parameters - /// * usage_flags: USAGE_DEFAULT + /// dimensional size of the matrix; accessible in various formats #[inline] - pub fn new_size_with_default(size: core::Size, typ: i32, s: core::Scalar, usage_flags: core::UMatUsageFlags) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_UMat_Size_int_const_ScalarR_UMatUsageFlags(&size, typ, &s, usage_flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; - Ok(ret) + fn set_mat_size(&mut self, val: core::MatSize) { + let ret = unsafe { sys::cv_UMat_propSize_const_MatSize(self.as_raw_mut_UMat(), val.as_raw_MatSize()) }; + ret } - /// ## Note - /// This alternative version of [new_size_with_default] function uses the following default values for its arguments: - /// * usage_flags: USAGE_DEFAULT + /// assignment operators #[inline] - pub fn new_size_with_default_def(size: core::Size, typ: i32, s: core::Scalar) -> Result { + fn set(&mut self, m: &impl core::UMatTraitConst) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_UMat_Size_int_const_ScalarR(&size, typ, &s, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_operatorST_const_UMatR(self.as_raw_mut_UMat(), m.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; - Ok(ret) - } - - /// constructs n-dimensional matrix - /// - /// ## C++ default parameters - /// * usage_flags: USAGE_DEFAULT - #[inline] - pub unsafe fn new_nd(sizes: &[i32], typ: i32, usage_flags: core::UMatUsageFlags) -> Result { - return_send!(via ocvrs_return); - { sys::cv_UMat_UMat_int_const_intX_int_UMatUsageFlags(sizes.len().try_into()?, sizes.as_ptr(), typ, usage_flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = { core::UMat::opencv_from_extern(ret) }; Ok(ret) } - /// constructs n-dimensional matrix - /// - /// ## Note - /// This alternative version of [new_nd] function uses the following default values for its arguments: - /// * usage_flags: USAGE_DEFAULT + /// returns a new matrix header for the specified row #[inline] - pub fn new_nd_def(sizes: &[i32], typ: i32) -> Result { + fn row_mut(&mut self, y: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_UMat_int_const_intX_int(sizes.len().try_into()?, sizes.as_ptr(), typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_row_int(self.as_raw_mut_UMat(), y, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// ## C++ default parameters - /// * usage_flags: USAGE_DEFAULT + /// returns a new matrix header for the specified column #[inline] - pub fn new_nd_with_default(sizes: &[i32], typ: i32, s: core::Scalar, usage_flags: core::UMatUsageFlags) -> Result { + fn col_mut(&mut self, x: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_UMat_int_const_intX_int_const_ScalarR_UMatUsageFlags(sizes.len().try_into()?, sizes.as_ptr(), typ, &s, usage_flags, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_col_int(self.as_raw_mut_UMat(), x, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [new_nd_with_default] function uses the following default values for its arguments: - /// * usage_flags: USAGE_DEFAULT + /// ... for the specified row span #[inline] - pub fn new_nd_with_default_def(sizes: &[i32], typ: i32, s: core::Scalar) -> Result { + fn row_bounds_mut(&mut self, startrow: i32, endrow: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_UMat_int_const_intX_int_const_ScalarR(sizes.len().try_into()?, sizes.as_ptr(), typ, &s, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_rowRange_int_int(self.as_raw_mut_UMat(), startrow, endrow, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// copy constructor #[inline] - pub fn copy(m: &impl core::UMatTraitConst) -> Result { + fn row_range_mut(&mut self, r: &impl core::RangeTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_UMat_const_UMatR(m.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_rowRange_const_RangeR(self.as_raw_mut_UMat(), r.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// creates a matrix header for a part of the bigger matrix - /// - /// ## C++ default parameters - /// * col_range: Range::all() + /// ... for the specified column span #[inline] - pub fn rowscols<'boxed>(m: &'boxed impl core::UMatTraitConst, row_range: &impl core::RangeTraitConst, col_range: &impl core::RangeTraitConst) -> Result> { + fn col_bounds_mut(&mut self, startcol: i32, endcol: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_UMat_const_UMatR_const_RangeR_const_RangeR(m.as_raw_UMat(), row_range.as_raw_Range(), col_range.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_colRange_int_int(self.as_raw_mut_UMat(), startcol, endcol, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::<'boxed, core::UMat>::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// creates a matrix header for a part of the bigger matrix - /// - /// ## Note - /// This alternative version of [rowscols] function uses the following default values for its arguments: - /// * col_range: Range::all() #[inline] - pub fn rowscols_def_mut<'boxed>(m: &'boxed mut impl core::UMatTrait, row_range: &impl core::RangeTraitConst) -> Result> { + fn col_range_mut(&mut self, r: &impl core::RangeTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_UMat_UMatR_const_RangeR(m.as_raw_mut_UMat(), row_range.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_colRange_const_RangeR(self.as_raw_mut_UMat(), r.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::<'boxed, core::UMat>::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// creates a matrix header for a part of the bigger matrix + /// ... for the specified diagonal + /// (d=0 - the main diagonal, + /// >0 - a diagonal from the upper half, + /// <0 - a diagonal from the lower half) /// /// ## Note - /// This alternative version of [rowscols] function uses the following default values for its arguments: - /// * col_range: Range::all() + /// This alternative version of [UMatTraitConst::diag] function uses the following default values for its arguments: + /// * d: 0 #[inline] - pub fn rowscols_def<'boxed>(m: &'boxed impl core::UMatTraitConst, row_range: &impl core::RangeTraitConst) -> Result> { + fn diag_def_mut(&mut self) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_UMat_const_UMatR_const_RangeR(m.as_raw_UMat(), row_range.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_diag(self.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::<'boxed, core::UMat>::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// creates a matrix header for a part of the bigger matrix + /// ... for the specified diagonal + /// (d=0 - the main diagonal, + /// >0 - a diagonal from the upper half, + /// <0 - a diagonal from the lower half) /// /// ## C++ default parameters - /// * col_range: Range::all() + /// * d: 0 #[inline] - pub fn rowscols_mut<'boxed>(m: &'boxed mut impl core::UMatTrait, row_range: &impl core::RangeTraitConst, col_range: &impl core::RangeTraitConst) -> Result> { + fn diag_mut(&mut self, d: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_UMat_UMatR_const_RangeR_const_RangeR(m.as_raw_mut_UMat(), row_range.as_raw_Range(), col_range.as_raw_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_diag_int(self.as_raw_mut_UMat(), d, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::<'boxed, core::UMat>::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } + /// sets every matrix element to s #[inline] - pub fn roi(m: &impl core::UMatTraitConst, roi: core::Rect) -> Result> { + fn set_scalar(&mut self, s: core::Scalar) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_UMat_const_UMatR_const_RectR(m.as_raw_UMat(), &roi, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_operatorST_const_ScalarR(self.as_raw_mut_UMat(), &s, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } + /// sets some of the matrix elements to s, according to the mask + /// + /// ## C++ default parameters + /// * mask: noArray() #[inline] - pub fn roi_mut(m: &mut impl core::UMatTrait, roi: core::Rect) -> Result> { + fn set_to(&mut self, value: &impl ToInputArray, mask: &impl ToInputArray) -> Result { + input_array_arg!(value); + input_array_arg!(mask); return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_UMat_UMatR_const_RectR(m.as_raw_mut_UMat(), &roi, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_setTo_const__InputArrayR_const__InputArrayR(self.as_raw_mut_UMat(), value.as_raw__InputArray(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// sets some of the matrix elements to s, according to the mask + /// + /// ## Note + /// This alternative version of [UMatTrait::set_to] function uses the following default values for its arguments: + /// * mask: noArray() #[inline] - pub fn ranges<'boxed>(m: &'boxed impl core::UMatTraitConst, ranges: &core::Vector) -> Result> { + fn set_to_def(&mut self, value: &impl ToInputArray) -> Result { + input_array_arg!(value); return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_UMat_const_UMatR_const_vectorLRangeGR(m.as_raw_UMat(), ranges.as_raw_VectorOfRange(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_setTo_const__InputArrayR(self.as_raw_mut_UMat(), value.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::<'boxed, core::UMat>::opencv_from_extern(ret) }; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// creates alternative matrix header for the same data, with different + /// + /// ## Note + /// This alternative version of [UMatTraitConst::reshape] function uses the following default values for its arguments: + /// * rows: 0 #[inline] - pub fn ranges_mut<'boxed>(m: &'boxed mut impl core::UMatTrait, ranges: &core::Vector) -> Result> { + fn reshape_def_mut(&mut self, cn: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_UMat_UMatR_const_vectorLRangeGR(m.as_raw_mut_UMat(), ranges.as_raw_VectorOfRange(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_reshape_int(self.as_raw_mut_UMat(), cn, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::<'boxed, core::UMat>::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// constructs a square diagonal matrix which main diagonal is vector "d" + /// creates alternative matrix header for the same data, with different + /// + /// ## C++ default parameters + /// * rows: 0 #[inline] - #[must_use] - pub fn diag_flags(d: &impl core::UMatTraitConst, usage_flags: core::UMatUsageFlags) -> Result { + fn reshape_mut(&mut self, cn: i32, rows: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_diag_const_UMatR_UMatUsageFlags(d.as_raw_UMat(), usage_flags, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_reshape_int_int(self.as_raw_mut_UMat(), cn, rows, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - #[must_use] - pub fn diag(d: &impl core::UMatTraitConst) -> Result { + fn reshape_nd_mut(&mut self, cn: i32, newsz: &[i32]) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_diag_const_UMatR(d.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_reshape_int_int_const_intX(self.as_raw_mut_UMat(), cn, newsz.len().try_into()?, newsz.as_ptr(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// Matlab-style matrix initialization + /// allocates new matrix data unless the matrix already has specified size and type. + /// + /// ## C++ default parameters + /// * usage_flags: USAGE_DEFAULT #[inline] - #[must_use] - pub fn zeros_flags(rows: i32, cols: i32, typ: i32, usage_flags: core::UMatUsageFlags) -> Result { + unsafe fn create_rows_cols(&mut self, rows: i32, cols: i32, typ: i32, usage_flags: core::UMatUsageFlags) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_zeros_int_int_int_UMatUsageFlags(rows, cols, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_UMat_create_int_int_int_UMatUsageFlags(self.as_raw_mut_UMat(), rows, cols, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// allocates new matrix data unless the matrix already has specified size and type. + /// + /// ## Note + /// This alternative version of [UMatTrait::create_rows_cols] function uses the following default values for its arguments: + /// * usage_flags: USAGE_DEFAULT #[inline] - #[must_use] - pub fn zeros_size_flags(size: core::Size, typ: i32, usage_flags: core::UMatUsageFlags) -> Result { + fn create_rows_cols_def(&mut self, rows: i32, cols: i32, typ: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_zeros_Size_int_UMatUsageFlags(&size, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_create_int_int_int(self.as_raw_mut_UMat(), rows, cols, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// ## C++ default parameters + /// * usage_flags: USAGE_DEFAULT #[inline] - #[must_use] - pub fn zeros_nd_flags(sz: &[i32], typ: i32, usage_flags: core::UMatUsageFlags) -> Result { + unsafe fn create_size(&mut self, size: core::Size, typ: i32, usage_flags: core::UMatUsageFlags) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_zeros_int_const_intX_int_UMatUsageFlags(sz.len().try_into()?, sz.as_ptr(), typ, usage_flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_UMat_create_Size_int_UMatUsageFlags(self.as_raw_mut_UMat(), &size, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [UMatTrait::create_size] function uses the following default values for its arguments: + /// * usage_flags: USAGE_DEFAULT #[inline] - #[must_use] - pub fn zeros(rows: i32, cols: i32, typ: i32) -> Result { + fn create_size_def(&mut self, size: core::Size, typ: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_zeros_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_create_Size_int(self.as_raw_mut_UMat(), &size, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// ## C++ default parameters + /// * usage_flags: USAGE_DEFAULT #[inline] - #[must_use] - pub fn zeros_size(size: core::Size, typ: i32) -> Result { + unsafe fn create_nd(&mut self, sizes: &[i32], typ: i32, usage_flags: core::UMatUsageFlags) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_zeros_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_UMat_create_int_const_intX_int_UMatUsageFlags(self.as_raw_mut_UMat(), sizes.len().try_into()?, sizes.as_ptr(), typ, usage_flags, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [UMatTrait::create_nd] function uses the following default values for its arguments: + /// * usage_flags: USAGE_DEFAULT #[inline] - #[must_use] - pub fn zeros_nd(sz: &[i32], typ: i32) -> Result { + fn create_nd_def(&mut self, sizes: &[i32], typ: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_zeros_int_const_intX_int(sz.len().try_into()?, sz.as_ptr(), typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_create_int_const_intX_int(self.as_raw_mut_UMat(), sizes.len().try_into()?, sizes.as_ptr(), typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// ## C++ default parameters + /// * usage_flags: USAGE_DEFAULT #[inline] - #[must_use] - pub fn ones_flags(rows: i32, cols: i32, typ: i32, usage_flags: core::UMatUsageFlags) -> Result { + unsafe fn create_nd_vec(&mut self, sizes: &core::Vector, typ: i32, usage_flags: core::UMatUsageFlags) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_ones_int_int_int_UMatUsageFlags(rows, cols, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_UMat_create_const_vectorLintGR_int_UMatUsageFlags(self.as_raw_mut_UMat(), sizes.as_raw_VectorOfi32(), typ, usage_flags, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [UMatTrait::create_nd_vec] function uses the following default values for its arguments: + /// * usage_flags: USAGE_DEFAULT #[inline] - #[must_use] - pub fn ones_size_flags(size: core::Size, typ: i32, usage_flags: core::UMatUsageFlags) -> Result { + fn create_nd_vec_def(&mut self, sizes: &core::Vector, typ: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_ones_Size_int_UMatUsageFlags(&size, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_create_const_vectorLintGR_int(self.as_raw_mut_UMat(), sizes.as_raw_VectorOfi32(), typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// increases the reference counter; use with care to avoid memleaks #[inline] - #[must_use] - pub fn ones_nd_flags(sz: &[i32], typ: i32, usage_flags: core::UMatUsageFlags) -> Result { + unsafe fn addref(&mut self) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_ones_int_const_intX_int_UMatUsageFlags(sz.len().try_into()?, sz.as_ptr(), typ, usage_flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_UMat_addref(self.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// decreases reference counter; #[inline] - #[must_use] - pub fn ones(rows: i32, cols: i32, typ: i32) -> Result { + unsafe fn release(&mut self) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_ones_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_UMat_release(self.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// deallocates the matrix data #[inline] - #[must_use] - pub fn ones_size(size: core::Size, typ: i32) -> Result { + fn deallocate(&mut self) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_ones_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_deallocate(self.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// moves/resizes the current matrix ROI inside the parent matrix. #[inline] - #[must_use] - pub fn ones_nd(sz: &[i32], typ: i32) -> Result { + fn adjust_roi(&mut self, dtop: i32, dbottom: i32, dleft: i32, dright: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_ones_int_const_intX_int(sz.len().try_into()?, sz.as_ptr(), typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_adjustROI_int_int_int_int(self.as_raw_mut_UMat(), dtop, dbottom, dleft, dright, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// extracts a rectangular sub-matrix #[inline] - #[must_use] - pub fn eye_flags(rows: i32, cols: i32, typ: i32, usage_flags: core::UMatUsageFlags) -> Result { + fn rowscols_mut(&mut self, mut row_range: impl core::RangeTrait, mut col_range: impl core::RangeTrait) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_eye_int_int_int_UMatUsageFlags(rows, cols, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_operator___Range_Range(self.as_raw_mut_UMat(), row_range.as_raw_mut_Range(), col_range.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - #[must_use] - pub fn eye_size_flags(size: core::Size, typ: i32, usage_flags: core::UMatUsageFlags) -> Result { + fn roi_mut(&mut self, roi: core::Rect) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_eye_Size_int_UMatUsageFlags(&size, typ, usage_flags, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_operator___const_RectR(self.as_raw_mut_UMat(), &roi, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - #[must_use] - pub fn eye(rows: i32, cols: i32, typ: i32) -> Result { + fn ranges_mut(&mut self, ranges: &core::Vector) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_eye_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_operator___const_vectorLRangeGR(self.as_raw_mut_UMat(), ranges.as_raw_VectorOfRange(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - #[must_use] - pub fn eye_size(size: core::Size, typ: i32) -> Result { + fn set_1(&mut self, mut m: core::UMat) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_eye_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_operatorST_UMatRR(self.as_raw_mut_UMat(), m.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// internal use method: updates the continuity flag #[inline] - pub fn copy_mut(mut m: core::UMat) -> Result { + fn update_continuity_flag(&mut self) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMat_UMat_UMatRR(m.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_UMat_updateContinuityFlag(self.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } @@ -28445,6 +28425,31 @@ pub mod core { } } + impl core::UMatTraitConst for UMat { + #[inline] fn as_raw_UMat(&self) -> *const c_void { self.as_raw() } + } + + impl core::UMatTrait for UMat { + #[inline] fn as_raw_mut_UMat(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { UMat, core::UMatTraitConst, as_raw_UMat, core::UMatTrait, as_raw_mut_UMat } + + pub struct UMatData { + ptr: *mut c_void, + } + + opencv_type_boxed! { UMatData } + + impl Drop for UMatData { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_UMatData_delete(self.as_raw_mut_UMatData()) }; + } + } + + unsafe impl Send for UMatData {} + /// Constant methods for [core::UMatData] pub trait UMatDataTraitConst { fn as_raw_UMatData(&self) -> *const c_void; @@ -28644,107 +28649,334 @@ pub mod core { } #[inline] - fn original_umat_data(&mut self) -> core::UMatData { - let ret = unsafe { sys::cv_UMatData_propOriginalUMatData(self.as_raw_mut_UMatData()) }; - let ret = unsafe { core::UMatData::opencv_from_extern(ret) }; - ret + fn original_umat_data(&mut self) -> core::UMatData { + let ret = unsafe { sys::cv_UMatData_propOriginalUMatData(self.as_raw_mut_UMatData()) }; + let ret = unsafe { core::UMatData::opencv_from_extern(ret) }; + ret + } + + #[inline] + fn set_original_umat_data(&mut self, val: &impl core::UMatDataTraitConst) { + let ret = unsafe { sys::cv_UMatData_propOriginalUMatData_UMatDataX(self.as_raw_mut_UMatData(), val.as_raw_UMatData()) }; + ret + } + + #[inline] + fn lock(&mut self) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_UMatData_lock(self.as_raw_mut_UMatData(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn unlock(&mut self) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_UMatData_unlock(self.as_raw_mut_UMatData(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn mark_host_copy_obsolete(&mut self, flag: bool) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_UMatData_markHostCopyObsolete_bool(self.as_raw_mut_UMatData(), flag, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn mark_device_copy_obsolete(&mut self, flag: bool) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_UMatData_markDeviceCopyObsolete_bool(self.as_raw_mut_UMatData(), flag, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn mark_device_mem_mapped(&mut self, flag: bool) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_UMatData_markDeviceMemMapped_bool(self.as_raw_mut_UMatData(), flag, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + impl std::fmt::Debug for UMatData { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("UMatData") + .field("urefcount", &core::UMatDataTraitConst::urefcount(self)) + .field("refcount", &core::UMatDataTraitConst::refcount(self)) + .field("data", &core::UMatDataTraitConst::data(self)) + .field("origdata", &core::UMatDataTraitConst::origdata(self)) + .field("size", &core::UMatDataTraitConst::size(self)) + .field("flags", &core::UMatDataTraitConst::flags(self)) + .field("allocator_flags_", &core::UMatDataTraitConst::allocator_flags_(self)) + .field("mapcount", &core::UMatDataTraitConst::mapcount(self)) + .finish() + } + } + + impl core::UMatDataTraitConst for UMatData { + #[inline] fn as_raw_UMatData(&self) -> *const c_void { self.as_raw() } + } + + impl core::UMatDataTrait for UMatData { + #[inline] fn as_raw_mut_UMatData(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { UMatData, core::UMatDataTraitConst, as_raw_UMatData, core::UMatDataTrait, as_raw_mut_UMatData } + + /// This is the proxy class for passing read-only input arrays into OpenCV functions. + /// + /// It is defined as: + /// ```C++ + /// typedef const _InputArray& InputArray; + /// ``` + /// + /// where \ref cv::_InputArray is a class that can be constructed from \ref cv::Mat, \ref cv::Mat_, + /// \ref cv::Matx, std::vector, std::vector>, std::vector, + /// std::vector>, \ref cv::UMat, std::vector or `double`. It can also be constructed from + /// a matrix expression. + /// + /// Since this is mostly implementation-level class, and its interface may change in future versions, we + /// do not describe it in details. There are a few key things, though, that should be kept in mind: + /// + /// * When you see in the reference manual or in OpenCV source code a function that takes + /// InputArray, it means that you can actually pass `Mat`, `Matx`, `vector` etc. (see above the + /// complete list). + /// * Optional input arguments: If some of the input arrays may be empty, pass cv::noArray() (or + /// simply cv::Mat() as you probably did before). + /// * The class is designed solely for passing parameters. That is, normally you *should not* + /// declare class members, local and global variables of this type. + /// * If you want to design your own function or a class method that can operate of arrays of + /// multiple types, you can use InputArray (or OutputArray) for the respective parameters. Inside + /// a function you should use _InputArray::getMat() method to construct a matrix header for the + /// array (without copying data). _InputArray::kind() can be used to distinguish Mat from + /// `vector<>` etc., but normally it is not needed. + /// + /// Here is how you can use a function that takes InputArray : + /// ```C++ + /// std::vector vec; + /// // points or a circle + /// for( int i = 0; i < 30; i++ ) + /// vec.push_back(Point2f((float)(100 + 30*cos(i*CV_PI*2/5)), + /// (float)(100 - 30*sin(i*CV_PI*2/5)))); + /// cv::transform(vec, vec, cv::Matx23f(0.707, -0.707, 10, 0.707, 0.707, 20)); + /// ``` + /// + /// That is, we form an STL vector containing points, and apply in-place affine transformation to the + /// vector using the 2x3 matrix created inline as `Matx` instance. + /// + /// Here is how such a function can be implemented (for simplicity, we implement a very specific case of + /// it, according to the assertion statement inside) : + /// ```C++ + /// void myAffineTransform(InputArray _src, OutputArray _dst, InputArray _m) + /// { + /// // get Mat headers for input arrays. This is O(1) operation, + /// // unless _src and/or _m are matrix expressions. + /// Mat src = _src.getMat(), m = _m.getMat(); + /// CV_Assert( src.type() == CV_32FC2 && m.type() == CV_32F && m.size() == Size(3, 2) ); + /// + /// // [re]create the output array so that it has the proper size and type. + /// // In case of Mat it calls Mat::create, in case of STL vector it calls vector::resize. + /// _dst.create(src.size(), src.type()); + /// Mat dst = _dst.getMat(); + /// + /// for( int i = 0; i < src.rows; i++ ) + /// for( int j = 0; j < src.cols; j++ ) + /// { + /// Point2f pt = src.at(i, j); + /// dst.at(i, j) = Point2f(m.at(0, 0)*pt.x + + /// m.at(0, 1)*pt.y + + /// m.at(0, 2), + /// m.at(1, 0)*pt.x + + /// m.at(1, 1)*pt.y + + /// m.at(1, 2)); + /// } + /// } + /// ``` + /// + /// There is another related type, InputArrayOfArrays, which is currently defined as a synonym for + /// InputArray: + /// ```C++ + /// typedef InputArray InputArrayOfArrays; + /// ``` + /// + /// It denotes function arguments that are either vectors of vectors or vectors of matrices. A separate + /// synonym is needed to generate Python/Java etc. wrappers properly. At the function implementation + /// level their use is similar, but _InputArray::getMat(idx) should be used to get header for the + /// idx-th component of the outer vector and _InputArray::size().area() should be used to find the + /// number of components (vectors/matrices) of the outer vector. + /// + /// In general, type support is limited to cv::Mat types. Other types are forbidden. + /// But in some cases we need to support passing of custom non-general Mat types, like arrays of cv::KeyPoint, cv::DMatch, etc. + /// This data is not intended to be interpreted as an image data, or processed somehow like regular cv::Mat. + /// To pass such custom type use rawIn() / rawOut() / rawInOut() wrappers. + /// Custom type is wrapped as Mat-compatible `CV_8UC` values (N = sizeof(T), N <= CV_CN_MAX). + pub struct _InputArray { + ptr: *mut c_void, + } + + opencv_type_boxed! { _InputArray } + + impl Drop for _InputArray { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv__InputArray_delete(self.as_raw_mut__InputArray()) }; + } + } + + unsafe impl Send for _InputArray {} + + impl _InputArray { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv__InputArray__InputArray(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::_InputArray::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub unsafe fn new(_flags: i32, _obj: *mut c_void) -> Result { + return_send!(via ocvrs_return); + { sys::cv__InputArray__InputArray_int_voidX(_flags, _obj, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = { core::_InputArray::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn from_mat(m: &impl core::MatTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv__InputArray__InputArray_const_MatR(m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn from_matexpr(expr: &impl core::MatExprTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv__InputArray__InputArray_const_MatExprR(expr.as_raw_MatExpr(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn from_mat_vec(vec: &core::Vector) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv__InputArray__InputArray_const_vectorLMatGR(vec.as_raw_VectorOfMat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + Ok(ret) } #[inline] - fn set_original_umat_data(&mut self, val: &impl core::UMatDataTraitConst) { - let ret = unsafe { sys::cv_UMatData_propOriginalUMatData_UMatDataX(self.as_raw_mut_UMatData(), val.as_raw_UMatData()) }; - ret + pub fn from_bool_vec(vec: &core::Vector) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv__InputArray__InputArray_const_vectorLboolGR(vec.as_raw_VectorOfbool(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + Ok(ret) } #[inline] - fn lock(&mut self) -> Result<()> { + pub fn from_f64(val: &f64) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMatData_lock(self.as_raw_mut_UMatData(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray__InputArray_const_doubleR(val, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn unlock(&mut self) -> Result<()> { + pub fn from_gpumat(d_mat: &impl core::GpuMatTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMatData_unlock(self.as_raw_mut_UMatData(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray__InputArray_const_GpuMatR(d_mat.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn mark_host_copy_obsolete(&mut self, flag: bool) -> Result<()> { + pub fn from_gpumat_vec(d_mat_array: &core::Vector) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMatData_markHostCopyObsolete_bool(self.as_raw_mut_UMatData(), flag, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray__InputArray_const_vectorLGpuMatGR(d_mat_array.as_raw_VectorOfGpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn mark_device_copy_obsolete(&mut self, flag: bool) -> Result<()> { + pub fn from_opengl(buf: &impl core::BufferTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMatData_markDeviceCopyObsolete_bool(self.as_raw_mut_UMatData(), flag, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray__InputArray_const_BufferR(buf.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn mark_device_mem_mapped(&mut self, flag: bool) -> Result<()> { + pub fn from_hostmem(cuda_mem: &impl core::HostMemTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_UMatData_markDeviceMemMapped_bool(self.as_raw_mut_UMatData(), flag, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray__InputArray_const_HostMemR(cuda_mem.as_raw_HostMem(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - } - - pub struct UMatData { - ptr: *mut c_void, - } - - opencv_type_boxed! { UMatData } - - impl Drop for UMatData { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_UMatData_delete(self.as_raw_mut_UMatData()) }; + pub fn from_umat(um: &impl core::UMatTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv__InputArray__InputArray_const_UMatR(um.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + Ok(ret) } - } - - unsafe impl Send for UMatData {} - - impl core::UMatDataTraitConst for UMatData { - #[inline] fn as_raw_UMatData(&self) -> *const c_void { self.as_raw() } - } - impl core::UMatDataTrait for UMatData { - #[inline] fn as_raw_mut_UMatData(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { UMatData, core::UMatDataTraitConst, as_raw_UMatData, core::UMatDataTrait, as_raw_mut_UMatData } - - impl UMatData { - } + #[inline] + pub fn from_umat_vec(umv: &core::Vector) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv__InputArray__InputArray_const_vectorLUMatGR(umv.as_raw_VectorOfUMat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for UMatData { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("UMatData") - .field("urefcount", &core::UMatDataTraitConst::urefcount(self)) - .field("refcount", &core::UMatDataTraitConst::refcount(self)) - .field("data", &core::UMatDataTraitConst::data(self)) - .field("origdata", &core::UMatDataTraitConst::origdata(self)) - .field("size", &core::UMatDataTraitConst::size(self)) - .field("flags", &core::UMatDataTraitConst::flags(self)) - .field("allocator_flags_", &core::UMatDataTraitConst::allocator_flags_(self)) - .field("mapcount", &core::UMatDataTraitConst::mapcount(self)) - .finish() + pub fn from_byte_slice(vec: &[u8]) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv__InputArray__InputArray_const_unsigned_charX_int(vec.as_ptr(), vec.len().try_into()?, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [core::_InputArray] @@ -28958,169 +29190,21 @@ pub mod core { /// ## C++ default parameters /// * i: -1 #[inline] - fn rows(&self, i: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_rows_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// ## Note - /// This alternative version of [_InputArrayTraitConst::rows] function uses the following default values for its arguments: - /// * i: -1 - #[inline] - fn rows_def(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_rows_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// ## C++ default parameters - /// * i: -1 - #[inline] - fn size(&self, i: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_size_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// ## Note - /// This alternative version of [_InputArrayTraitConst::size] function uses the following default values for its arguments: - /// * i: -1 - #[inline] - fn size_def(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_size_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// ## C++ default parameters - /// * i: -1 - #[inline] - fn sizend(&self, sz: &mut i32, i: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_sizend_const_intX_int(self.as_raw__InputArray(), sz, i, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// ## Note - /// This alternative version of [_InputArrayTraitConst::sizend] function uses the following default values for its arguments: - /// * i: -1 - #[inline] - fn sizend_def(&self, sz: &mut i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_sizend_const_intX(self.as_raw__InputArray(), sz, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn same_size(&self, arr: &impl ToInputArray) -> Result { - input_array_arg!(arr); - return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_sameSize_const_const__InputArrayR(self.as_raw__InputArray(), arr.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// ## C++ default parameters - /// * i: -1 - #[inline] - fn total(&self, i: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_total_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// ## Note - /// This alternative version of [_InputArrayTraitConst::total] function uses the following default values for its arguments: - /// * i: -1 - #[inline] - fn total_def(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_total_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// ## C++ default parameters - /// * i: -1 - #[inline] - fn typ(&self, i: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_type_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// ## Note - /// This alternative version of [_InputArrayTraitConst::typ] function uses the following default values for its arguments: - /// * i: -1 - #[inline] - fn typ_def(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_type_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// ## C++ default parameters - /// * i: -1 - #[inline] - fn depth(&self, i: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_depth_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// ## Note - /// This alternative version of [_InputArrayTraitConst::depth] function uses the following default values for its arguments: - /// * i: -1 - #[inline] - fn depth_def(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_depth_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// ## C++ default parameters - /// * i: -1 - #[inline] - fn channels(&self, i: i32) -> Result { + fn rows(&self, i: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_channels_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_rows_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } /// ## Note - /// This alternative version of [_InputArrayTraitConst::channels] function uses the following default values for its arguments: + /// This alternative version of [_InputArrayTraitConst::rows] function uses the following default values for its arguments: /// * i: -1 #[inline] - fn channels_def(&self) -> Result { + fn rows_def(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_channels_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_rows_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -29129,21 +29213,21 @@ pub mod core { /// ## C++ default parameters /// * i: -1 #[inline] - fn is_continuous(&self, i: i32) -> Result { + fn size(&self, i: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_isContinuous_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_size_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } /// ## Note - /// This alternative version of [_InputArrayTraitConst::is_continuous] function uses the following default values for its arguments: + /// This alternative version of [_InputArrayTraitConst::size] function uses the following default values for its arguments: /// * i: -1 #[inline] - fn is_continuous_def(&self) -> Result { + fn size_def(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_isContinuous_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_size_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -29152,51 +29236,54 @@ pub mod core { /// ## C++ default parameters /// * i: -1 #[inline] - fn is_submatrix(&self, i: i32) -> Result { + fn sizend(&self, sz: &mut i32, i: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_isSubmatrix_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_sizend_const_intX_int(self.as_raw__InputArray(), sz, i, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } /// ## Note - /// This alternative version of [_InputArrayTraitConst::is_submatrix] function uses the following default values for its arguments: + /// This alternative version of [_InputArrayTraitConst::sizend] function uses the following default values for its arguments: /// * i: -1 #[inline] - fn is_submatrix_def(&self) -> Result { + fn sizend_def(&self, sz: &mut i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_isSubmatrix_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_sizend_const_intX(self.as_raw__InputArray(), sz, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn empty(&self) -> Result { + fn same_size(&self, arr: &impl ToInputArray) -> Result { + input_array_arg!(arr); return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_empty_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_sameSize_const_const__InputArrayR(self.as_raw__InputArray(), arr.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } + /// ## C++ default parameters + /// * i: -1 #[inline] - fn copy_to(&self, arr: &mut impl ToOutputArray) -> Result<()> { - output_array_arg!(arr); + fn total(&self, i: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_copyTo_const_const__OutputArrayR(self.as_raw__InputArray(), arr.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_total_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } + /// ## Note + /// This alternative version of [_InputArrayTraitConst::total] function uses the following default values for its arguments: + /// * i: -1 #[inline] - fn copy_to_masked(&self, arr: &mut impl ToOutputArray, mask: &impl ToInputArray) -> Result<()> { - output_array_arg!(arr); - input_array_arg!(mask); + fn total_def(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_copyTo_const_const__OutputArrayR_const__InputArrayR(self.as_raw__InputArray(), arr.as_raw__OutputArray(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_total_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -29205,21 +29292,21 @@ pub mod core { /// ## C++ default parameters /// * i: -1 #[inline] - fn offset(&self, i: i32) -> Result { + fn typ(&self, i: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_offset_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_type_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } /// ## Note - /// This alternative version of [_InputArrayTraitConst::offset] function uses the following default values for its arguments: + /// This alternative version of [_InputArrayTraitConst::typ] function uses the following default values for its arguments: /// * i: -1 #[inline] - fn offset_def(&self) -> Result { + fn typ_def(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_offset_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_type_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -29228,361 +29315,251 @@ pub mod core { /// ## C++ default parameters /// * i: -1 #[inline] - fn step(&self, i: i32) -> Result { + fn depth(&self, i: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_step_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_depth_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } /// ## Note - /// This alternative version of [_InputArrayTraitConst::step] function uses the following default values for its arguments: + /// This alternative version of [_InputArrayTraitConst::depth] function uses the following default values for its arguments: /// * i: -1 #[inline] - fn step_def(&self) -> Result { + fn depth_def(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_step_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_depth_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } + /// ## C++ default parameters + /// * i: -1 #[inline] - fn is_mat(&self) -> Result { + fn channels(&self, i: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_isMat_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_channels_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } + /// ## Note + /// This alternative version of [_InputArrayTraitConst::channels] function uses the following default values for its arguments: + /// * i: -1 #[inline] - fn is_umat(&self) -> Result { + fn channels_def(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_isUMat_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_channels_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } + /// ## C++ default parameters + /// * i: -1 #[inline] - fn is_mat_vector(&self) -> Result { + fn is_continuous(&self, i: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_isMatVector_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_isContinuous_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } + /// ## Note + /// This alternative version of [_InputArrayTraitConst::is_continuous] function uses the following default values for its arguments: + /// * i: -1 #[inline] - fn is_umat_vector(&self) -> Result { + fn is_continuous_def(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_isUMatVector_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_isContinuous_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } + /// ## C++ default parameters + /// * i: -1 #[inline] - fn is_matx(&self) -> Result { + fn is_submatrix(&self, i: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_isMatx_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_isSubmatrix_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } + /// ## Note + /// This alternative version of [_InputArrayTraitConst::is_submatrix] function uses the following default values for its arguments: + /// * i: -1 #[inline] - fn is_vector(&self) -> Result { + fn is_submatrix_def(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_isVector_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_isSubmatrix_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn is_gpu_mat(&self) -> Result { + fn empty(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_isGpuMat_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_empty_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn is_gpu_mat_vector(&self) -> Result { + fn copy_to(&self, arr: &mut impl ToOutputArray) -> Result<()> { + output_array_arg!(arr); return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray_isGpuMatVector_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_copyTo_const_const__OutputArrayR(self.as_raw__InputArray(), arr.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - } - - /// Mutable methods for [core::_InputArray] - pub trait _InputArrayTrait: core::_InputArrayTraitConst { - fn as_raw_mut__InputArray(&mut self) -> *mut c_void; - - } - - /// This is the proxy class for passing read-only input arrays into OpenCV functions. - /// - /// It is defined as: - /// ```C++ - /// typedef const _InputArray& InputArray; - /// ``` - /// - /// where \ref cv::_InputArray is a class that can be constructed from \ref cv::Mat, \ref cv::Mat_, - /// \ref cv::Matx, std::vector, std::vector>, std::vector, - /// std::vector>, \ref cv::UMat, std::vector or `double`. It can also be constructed from - /// a matrix expression. - /// - /// Since this is mostly implementation-level class, and its interface may change in future versions, we - /// do not describe it in details. There are a few key things, though, that should be kept in mind: - /// - /// * When you see in the reference manual or in OpenCV source code a function that takes - /// InputArray, it means that you can actually pass `Mat`, `Matx`, `vector` etc. (see above the - /// complete list). - /// * Optional input arguments: If some of the input arrays may be empty, pass cv::noArray() (or - /// simply cv::Mat() as you probably did before). - /// * The class is designed solely for passing parameters. That is, normally you *should not* - /// declare class members, local and global variables of this type. - /// * If you want to design your own function or a class method that can operate of arrays of - /// multiple types, you can use InputArray (or OutputArray) for the respective parameters. Inside - /// a function you should use _InputArray::getMat() method to construct a matrix header for the - /// array (without copying data). _InputArray::kind() can be used to distinguish Mat from - /// `vector<>` etc., but normally it is not needed. - /// - /// Here is how you can use a function that takes InputArray : - /// ```C++ - /// std::vector vec; - /// // points or a circle - /// for( int i = 0; i < 30; i++ ) - /// vec.push_back(Point2f((float)(100 + 30*cos(i*CV_PI*2/5)), - /// (float)(100 - 30*sin(i*CV_PI*2/5)))); - /// cv::transform(vec, vec, cv::Matx23f(0.707, -0.707, 10, 0.707, 0.707, 20)); - /// ``` - /// - /// That is, we form an STL vector containing points, and apply in-place affine transformation to the - /// vector using the 2x3 matrix created inline as `Matx` instance. - /// - /// Here is how such a function can be implemented (for simplicity, we implement a very specific case of - /// it, according to the assertion statement inside) : - /// ```C++ - /// void myAffineTransform(InputArray _src, OutputArray _dst, InputArray _m) - /// { - /// // get Mat headers for input arrays. This is O(1) operation, - /// // unless _src and/or _m are matrix expressions. - /// Mat src = _src.getMat(), m = _m.getMat(); - /// CV_Assert( src.type() == CV_32FC2 && m.type() == CV_32F && m.size() == Size(3, 2) ); - /// - /// // [re]create the output array so that it has the proper size and type. - /// // In case of Mat it calls Mat::create, in case of STL vector it calls vector::resize. - /// _dst.create(src.size(), src.type()); - /// Mat dst = _dst.getMat(); - /// - /// for( int i = 0; i < src.rows; i++ ) - /// for( int j = 0; j < src.cols; j++ ) - /// { - /// Point2f pt = src.at(i, j); - /// dst.at(i, j) = Point2f(m.at(0, 0)*pt.x + - /// m.at(0, 1)*pt.y + - /// m.at(0, 2), - /// m.at(1, 0)*pt.x + - /// m.at(1, 1)*pt.y + - /// m.at(1, 2)); - /// } - /// } - /// ``` - /// - /// There is another related type, InputArrayOfArrays, which is currently defined as a synonym for - /// InputArray: - /// ```C++ - /// typedef InputArray InputArrayOfArrays; - /// ``` - /// - /// It denotes function arguments that are either vectors of vectors or vectors of matrices. A separate - /// synonym is needed to generate Python/Java etc. wrappers properly. At the function implementation - /// level their use is similar, but _InputArray::getMat(idx) should be used to get header for the - /// idx-th component of the outer vector and _InputArray::size().area() should be used to find the - /// number of components (vectors/matrices) of the outer vector. - /// - /// In general, type support is limited to cv::Mat types. Other types are forbidden. - /// But in some cases we need to support passing of custom non-general Mat types, like arrays of cv::KeyPoint, cv::DMatch, etc. - /// This data is not intended to be interpreted as an image data, or processed somehow like regular cv::Mat. - /// To pass such custom type use rawIn() / rawOut() / rawInOut() wrappers. - /// Custom type is wrapped as Mat-compatible `CV_8UC` values (N = sizeof(T), N <= CV_CN_MAX). - pub struct _InputArray { - ptr: *mut c_void, - } - - opencv_type_boxed! { _InputArray } - - impl Drop for _InputArray { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv__InputArray_delete(self.as_raw_mut__InputArray()) }; - } - } - - unsafe impl Send for _InputArray {} - - impl core::_InputArrayTraitConst for _InputArray { - #[inline] fn as_raw__InputArray(&self) -> *const c_void { self.as_raw() } - } - - impl core::_InputArrayTrait for _InputArray { - #[inline] fn as_raw_mut__InputArray(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { _InputArray, core::_InputArrayTraitConst, as_raw__InputArray, core::_InputArrayTrait, as_raw_mut__InputArray } - - impl _InputArray { #[inline] - pub fn default() -> Result { + fn copy_to_masked(&self, arr: &mut impl ToOutputArray, mask: &impl ToInputArray) -> Result<()> { + output_array_arg!(arr); + input_array_arg!(mask); return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray__InputArray(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_copyTo_const_const__OutputArrayR_const__InputArrayR(self.as_raw__InputArray(), arr.as_raw__OutputArray(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::_InputArray::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub unsafe fn new(_flags: i32, _obj: *mut c_void) -> Result { - return_send!(via ocvrs_return); - { sys::cv__InputArray__InputArray_int_voidX(_flags, _obj, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = { core::_InputArray::opencv_from_extern(ret) }; Ok(ret) } + /// ## C++ default parameters + /// * i: -1 #[inline] - pub fn from_mat(m: &impl core::MatTraitConst) -> Result> { + fn offset(&self, i: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray__InputArray_const_MatR(m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_offset_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [_InputArrayTraitConst::offset] function uses the following default values for its arguments: + /// * i: -1 #[inline] - pub fn from_matexpr(expr: &impl core::MatExprTraitConst) -> Result> { + fn offset_def(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray__InputArray_const_MatExprR(expr.as_raw_MatExpr(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_offset_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } + /// ## C++ default parameters + /// * i: -1 #[inline] - pub fn from_mat_vec(vec: &core::Vector) -> Result> { + fn step(&self, i: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray__InputArray_const_vectorLMatGR(vec.as_raw_VectorOfMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_step_const_int(self.as_raw__InputArray(), i, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [_InputArrayTraitConst::step] function uses the following default values for its arguments: + /// * i: -1 #[inline] - pub fn from_bool_vec(vec: &core::Vector) -> Result> { + fn step_def(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray__InputArray_const_vectorLboolGR(vec.as_raw_VectorOfbool(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_step_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn from_f64(val: &f64) -> Result> { + fn is_mat(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray__InputArray_const_doubleR(val, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_isMat_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn from_gpumat(d_mat: &impl core::GpuMatTraitConst) -> Result> { + fn is_umat(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray__InputArray_const_GpuMatR(d_mat.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_isUMat_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn from_gpumat_vec(d_mat_array: &core::Vector) -> Result> { + fn is_mat_vector(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray__InputArray_const_vectorLGpuMatGR(d_mat_array.as_raw_VectorOfGpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_isMatVector_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn from_opengl(buf: &impl core::BufferTraitConst) -> Result> { + fn is_umat_vector(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray__InputArray_const_BufferR(buf.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_isUMatVector_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn from_hostmem(cuda_mem: &impl core::HostMemTraitConst) -> Result> { + fn is_matx(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray__InputArray_const_HostMemR(cuda_mem.as_raw_HostMem(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_isMatx_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn from_umat(um: &impl core::UMatTraitConst) -> Result> { + fn is_vector(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray__InputArray_const_UMatR(um.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_isVector_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn from_umat_vec(umv: &core::Vector) -> Result> { + fn is_gpu_mat(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray__InputArray_const_vectorLUMatGR(umv.as_raw_VectorOfUMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_isGpuMat_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn from_byte_slice(vec: &[u8]) -> Result> { + fn is_gpu_mat_vector(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__InputArray__InputArray_const_unsigned_charX_int(vec.as_ptr(), vec.len().try_into()?, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__InputArray_isGpuMatVector_const(self.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } } + /// Mutable methods for [core::_InputArray] + pub trait _InputArrayTrait: core::_InputArrayTraitConst { + fn as_raw_mut__InputArray(&mut self) -> *mut c_void; + + } + impl std::fmt::Debug for _InputArray { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -29591,18 +29568,16 @@ pub mod core { } } - /// Constant methods for [core::_InputOutputArray] - pub trait _InputOutputArrayTraitConst: core::_OutputArrayTraitConst { - fn as_raw__InputOutputArray(&self) -> *const c_void; - + impl core::_InputArrayTraitConst for _InputArray { + #[inline] fn as_raw__InputArray(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [core::_InputOutputArray] - pub trait _InputOutputArrayTrait: core::_InputOutputArrayTraitConst + core::_OutputArrayTrait { - fn as_raw_mut__InputOutputArray(&mut self) -> *mut c_void; - + impl core::_InputArrayTrait for _InputArray { + #[inline] fn as_raw_mut__InputArray(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { _InputArray, core::_InputArrayTraitConst, as_raw__InputArray, core::_InputArrayTrait, as_raw_mut__InputArray } + pub struct _InputOutputArray { ptr: *mut c_void, } @@ -29618,36 +29593,6 @@ pub mod core { unsafe impl Send for _InputOutputArray {} - impl core::_InputArrayTraitConst for _InputOutputArray { - #[inline] fn as_raw__InputArray(&self) -> *const c_void { self.as_raw() } - } - - impl core::_InputArrayTrait for _InputOutputArray { - #[inline] fn as_raw_mut__InputArray(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { _InputOutputArray, core::_InputArrayTraitConst, as_raw__InputArray, core::_InputArrayTrait, as_raw_mut__InputArray } - - impl core::_OutputArrayTraitConst for _InputOutputArray { - #[inline] fn as_raw__OutputArray(&self) -> *const c_void { self.as_raw() } - } - - impl core::_OutputArrayTrait for _InputOutputArray { - #[inline] fn as_raw_mut__OutputArray(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { _InputOutputArray, core::_OutputArrayTraitConst, as_raw__OutputArray, core::_OutputArrayTrait, as_raw_mut__OutputArray } - - impl core::_InputOutputArrayTraitConst for _InputOutputArray { - #[inline] fn as_raw__InputOutputArray(&self) -> *const c_void { self.as_raw() } - } - - impl core::_InputOutputArrayTrait for _InputOutputArray { - #[inline] fn as_raw_mut__InputOutputArray(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { _InputOutputArray, core::_InputOutputArrayTraitConst, as_raw__InputOutputArray, core::_InputOutputArrayTrait, as_raw_mut__InputOutputArray } - impl _InputOutputArray { /// //////////////////////////////////////////////////////////////////////////////////////// #[inline] @@ -29822,9 +29767,17 @@ pub mod core { } - boxed_cast_base! { _InputOutputArray, core::_InputArray, cv__InputOutputArray_to__InputArray } + /// Constant methods for [core::_InputOutputArray] + pub trait _InputOutputArrayTraitConst: core::_OutputArrayTraitConst { + fn as_raw__InputOutputArray(&self) -> *const c_void; - boxed_cast_base! { _InputOutputArray, core::_OutputArray, cv__InputOutputArray_to__OutputArray } + } + + /// Mutable methods for [core::_InputOutputArray] + pub trait _InputOutputArrayTrait: core::_InputOutputArrayTraitConst + core::_OutputArrayTrait { + fn as_raw_mut__InputOutputArray(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for _InputOutputArray { #[inline] @@ -29834,559 +29787,571 @@ pub mod core { } } - /// Constant methods for [core::_OutputArray] - pub trait _OutputArrayTraitConst: core::_InputArrayTraitConst { - fn as_raw__OutputArray(&self) -> *const c_void; + boxed_cast_base! { _InputOutputArray, core::_InputArray, cv__InputOutputArray_to__InputArray } + + boxed_cast_base! { _InputOutputArray, core::_OutputArray, cv__InputOutputArray_to__OutputArray } + + impl core::_InputArrayTraitConst for _InputOutputArray { + #[inline] fn as_raw__InputArray(&self) -> *const c_void { self.as_raw() } + } + + impl core::_InputArrayTrait for _InputOutputArray { + #[inline] fn as_raw_mut__InputArray(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { _InputOutputArray, core::_InputArrayTraitConst, as_raw__InputArray, core::_InputArrayTrait, as_raw_mut__InputArray } + + impl core::_OutputArrayTraitConst for _InputOutputArray { + #[inline] fn as_raw__OutputArray(&self) -> *const c_void { self.as_raw() } + } + + impl core::_OutputArrayTrait for _InputOutputArray { + #[inline] fn as_raw_mut__OutputArray(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { _InputOutputArray, core::_OutputArrayTraitConst, as_raw__OutputArray, core::_OutputArrayTrait, as_raw_mut__OutputArray } + + impl core::_InputOutputArrayTraitConst for _InputOutputArray { + #[inline] fn as_raw__InputOutputArray(&self) -> *const c_void { self.as_raw() } + } + + impl core::_InputOutputArrayTrait for _InputOutputArray { + #[inline] fn as_raw_mut__InputOutputArray(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { _InputOutputArray, core::_InputOutputArrayTraitConst, as_raw__InputOutputArray, core::_InputOutputArrayTrait, as_raw_mut__InputOutputArray } + + /// This type is very similar to InputArray except that it is used for input/output and output function + /// parameters. + /// + /// Just like with InputArray, OpenCV users should not care about OutputArray, they just pass `Mat`, + /// `vector` etc. to the functions. The same limitation as for `InputArray`: *Do not explicitly + /// create OutputArray instances* applies here too. + /// + /// If you want to make your function polymorphic (i.e. accept different arrays as output parameters), + /// it is also not very difficult. Take the sample above as the reference. Note that + /// _OutputArray::create() needs to be called before _OutputArray::getMat(). This way you guarantee + /// that the output array is properly allocated. + /// + /// Optional output parameters. If you do not need certain output array to be computed and returned to + /// you, pass cv::noArray(), just like you would in the case of optional input array. At the + /// implementation level, use _OutputArray::needed() to check if certain output array needs to be + /// computed or not. + /// + /// There are several synonyms for OutputArray that are used to assist automatic Python/Java/... wrapper + /// generators: + /// ```C++ + /// typedef OutputArray OutputArrayOfArrays; + /// typedef OutputArray InputOutputArray; + /// typedef OutputArray InputOutputArrayOfArrays; + /// ``` + /// + pub struct _OutputArray { + ptr: *mut c_void, + } + + opencv_type_boxed! { _OutputArray } + impl Drop for _OutputArray { #[inline] - fn fixed_size(&self) -> Result { + fn drop(&mut self) { + unsafe { sys::cv__OutputArray_delete(self.as_raw_mut__OutputArray()) }; + } + } + + unsafe impl Send for _OutputArray {} + + impl _OutputArray { + /// ///////////////////////////////////////////////////////////////////////////////////// + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_fixedSize_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray__OutputArray(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::_OutputArray::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn fixed_type(&self) -> Result { + pub unsafe fn new(_flags: i32, _obj: *mut c_void) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_fixedType_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv__OutputArray__OutputArray_int_voidX(_flags, _obj, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; + let ret = { core::_OutputArray::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn needed(&self) -> Result { + pub fn from_mat_mut(m: &mut impl core::MatTrait) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_needed_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray__OutputArray_MatR(m.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// ## C++ default parameters - /// * i: -1 #[inline] - fn get_mat_ref(&self, i: i32) -> Result { + pub fn from_mat_vec_mut(vec: &mut core::Vector) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_getMatRef_const_int(self.as_raw__OutputArray(), i, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray__OutputArray_vectorLMatGR(vec.as_raw_mut_VectorOfMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [_OutputArrayTraitConst::get_mat_ref] function uses the following default values for its arguments: - /// * i: -1 #[inline] - fn get_mat_ref_def(&self) -> Result { + pub fn from_gpumat_mut(d_mat: &mut impl core::GpuMatTrait) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_getMatRef_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray__OutputArray_GpuMatR(d_mat.as_raw_mut_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// ## C++ default parameters - /// * i: -1 #[inline] - fn get_umat_ref(&self, i: i32) -> Result { + pub fn from_gpumat_vec_mut(d_mat: &mut core::Vector) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_getUMatRef_const_int(self.as_raw__OutputArray(), i, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray__OutputArray_vectorLGpuMatGR(d_mat.as_raw_mut_VectorOfGpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [_OutputArrayTraitConst::get_umat_ref] function uses the following default values for its arguments: - /// * i: -1 #[inline] - fn get_umat_ref_def(&self) -> Result { + pub fn from_opengl_mut(buf: &mut impl core::BufferTrait) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_getUMatRef_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray__OutputArray_BufferR(buf.as_raw_mut_Buffer(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn get_gpu_mat_ref(&self) -> Result { + pub fn from_hostmem_mut(cuda_mem: &mut impl core::HostMemTrait) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_getGpuMatRef_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray__OutputArray_HostMemR(cuda_mem.as_raw_mut_HostMem(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn get_gpu_mat_vec_ref(&self) -> Result> { + pub fn from_umat_mut(m: &mut impl core::UMatTrait) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_getGpuMatVecRef_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray__OutputArray_UMatR(m.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Vector::::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn get_o_gl_buffer_ref(&self) -> Result { + pub fn from_umat_vec_mut(vec: &mut core::Vector) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_getOGlBufferRef_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray__OutputArray_vectorLUMatGR(vec.as_raw_mut_VectorOfUMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn get_host_mem_ref(&self) -> Result { + pub fn from_mat(m: &impl core::MatTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_getHostMemRef_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray__OutputArray_const_MatR(m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// ## C++ default parameters - /// * i: -1 - /// * allow_transposed: false - /// * fixed_depth_mask: static_cast<_OutputArray::DepthMask>(0) #[inline] - fn create_size(&self, sz: core::Size, typ: i32, i: i32, allow_transposed: bool, fixed_depth_mask: core::_OutputArray_DepthMask) -> Result<()> { + pub fn from_mat_vec(vec: &core::Vector) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_create_const_Size_int_int_bool_DepthMask(self.as_raw__OutputArray(), &sz, typ, i, allow_transposed, fixed_depth_mask, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray__OutputArray_const_vectorLMatGR(vec.as_raw_VectorOfMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [_OutputArrayTraitConst::create_size] function uses the following default values for its arguments: - /// * i: -1 - /// * allow_transposed: false - /// * fixed_depth_mask: static_cast<_OutputArray::DepthMask>(0) #[inline] - fn create_size_def(&self, sz: core::Size, typ: i32) -> Result<()> { + pub fn from_gpumat(d_mat: &impl core::GpuMatTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_create_const_Size_int(self.as_raw__OutputArray(), &sz, typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray__OutputArray_const_GpuMatR(d_mat.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// ## C++ default parameters - /// * i: -1 - /// * allow_transposed: false - /// * fixed_depth_mask: static_cast<_OutputArray::DepthMask>(0) #[inline] - fn create(&self, rows: i32, cols: i32, typ: i32, i: i32, allow_transposed: bool, fixed_depth_mask: core::_OutputArray_DepthMask) -> Result<()> { + pub fn from_opengl(buf: &impl core::BufferTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_create_const_int_int_int_int_bool_DepthMask(self.as_raw__OutputArray(), rows, cols, typ, i, allow_transposed, fixed_depth_mask, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray__OutputArray_const_BufferR(buf.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [_OutputArrayTraitConst::create] function uses the following default values for its arguments: - /// * i: -1 - /// * allow_transposed: false - /// * fixed_depth_mask: static_cast<_OutputArray::DepthMask>(0) #[inline] - fn create_def(&self, rows: i32, cols: i32, typ: i32) -> Result<()> { + pub fn from_hostmem(cuda_mem: &impl core::HostMemTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_create_const_int_int_int(self.as_raw__OutputArray(), rows, cols, typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray__OutputArray_const_HostMemR(cuda_mem.as_raw_HostMem(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// ## C++ default parameters - /// * i: -1 - /// * allow_transposed: false - /// * fixed_depth_mask: static_cast<_OutputArray::DepthMask>(0) #[inline] - fn create_nd(&self, size: &[i32], typ: i32, i: i32, allow_transposed: bool, fixed_depth_mask: core::_OutputArray_DepthMask) -> Result<()> { + pub fn from_umat(m: &impl core::UMatTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_create_const_int_const_intX_int_int_bool_DepthMask(self.as_raw__OutputArray(), size.len().try_into()?, size.as_ptr(), typ, i, allow_transposed, fixed_depth_mask, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray__OutputArray_const_UMatR(m.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [_OutputArrayTraitConst::create_nd] function uses the following default values for its arguments: - /// * i: -1 - /// * allow_transposed: false - /// * fixed_depth_mask: static_cast<_OutputArray::DepthMask>(0) #[inline] - fn create_nd_def(&self, size: &[i32], typ: i32) -> Result<()> { + pub fn from_umat_vec(vec: &core::Vector) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_create_const_int_const_intX_int(self.as_raw__OutputArray(), size.len().try_into()?, size.as_ptr(), typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray__OutputArray_const_vectorLUMatGR(vec.as_raw_VectorOfUMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } + } + + /// Constant methods for [core::_OutputArray] + pub trait _OutputArrayTraitConst: core::_InputArrayTraitConst { + fn as_raw__OutputArray(&self) -> *const c_void; + #[inline] - unsafe fn create_same_size(&self, arr: &impl ToInputArray, mtype: i32) -> Result<()> { - input_array_arg!(arr); + fn fixed_size(&self) -> Result { return_send!(via ocvrs_return); - { sys::cv__OutputArray_createSameSize_const_const__InputArrayR_int(self.as_raw__OutputArray(), arr.as_raw__InputArray(), mtype, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv__OutputArray_fixedSize_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn release(&self) -> Result<()> { + fn fixed_type(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_release_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_fixedType_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn clear(&self) -> Result<()> { + fn needed(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_clear_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_needed_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } /// ## C++ default parameters - /// * mask: _InputArray() + /// * i: -1 #[inline] - fn set_to(&self, value: &impl ToInputArray, mask: &impl ToInputArray) -> Result<()> { - input_array_arg!(value); - input_array_arg!(mask); + fn get_mat_ref(&self, i: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_setTo_const_const__InputArrayR_const__InputArrayR(self.as_raw__OutputArray(), value.as_raw__InputArray(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_getMatRef_const_int(self.as_raw__OutputArray(), i, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } /// ## Note - /// This alternative version of [_OutputArrayTraitConst::set_to] function uses the following default values for its arguments: - /// * mask: _InputArray() + /// This alternative version of [_OutputArrayTraitConst::get_mat_ref] function uses the following default values for its arguments: + /// * i: -1 #[inline] - fn set_to_def(&self, value: &impl ToInputArray) -> Result<()> { - input_array_arg!(value); + fn get_mat_ref_def(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_setTo_const_const__InputArrayR(self.as_raw__OutputArray(), value.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_getMatRef_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } + /// ## C++ default parameters + /// * i: -1 #[inline] - fn assign_umat(&self, u: &impl core::UMatTraitConst) -> Result<()> { + fn get_umat_ref(&self, i: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_assign_const_const_UMatR(self.as_raw__OutputArray(), u.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_getUMatRef_const_int(self.as_raw__OutputArray(), i, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [_OutputArrayTraitConst::get_umat_ref] function uses the following default values for its arguments: + /// * i: -1 #[inline] - fn assign_mat(&self, m: &impl core::MatTraitConst) -> Result<()> { + fn get_umat_ref_def(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_assign_const_const_MatR(self.as_raw__OutputArray(), m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_getUMatRef_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn assign_umat_vec(&self, v: &core::Vector) -> Result<()> { + fn get_gpu_mat_ref(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_assign_const_const_vectorLUMatGR(self.as_raw__OutputArray(), v.as_raw_VectorOfUMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_getGpuMatRef_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn assign_mat_vec(&self, v: &core::Vector) -> Result<()> { + fn get_gpu_mat_vec_ref(&self) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_assign_const_const_vectorLMatGR(self.as_raw__OutputArray(), v.as_raw_VectorOfMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_getGpuMatVecRef_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Vector::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn move_umat(&self, u: &mut impl core::UMatTrait) -> Result<()> { + fn get_o_gl_buffer_ref(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_move_const_UMatR(self.as_raw__OutputArray(), u.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_getOGlBufferRef_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn move_mat(&self, m: &mut impl core::MatTrait) -> Result<()> { + fn get_host_mem_ref(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray_move_const_MatR(self.as_raw__OutputArray(), m.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_getHostMemRef_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; Ok(ret) } - } - - /// Mutable methods for [core::_OutputArray] - pub trait _OutputArrayTrait: core::_InputArrayTrait + core::_OutputArrayTraitConst { - fn as_raw_mut__OutputArray(&mut self) -> *mut c_void; - - } - - /// This type is very similar to InputArray except that it is used for input/output and output function - /// parameters. - /// - /// Just like with InputArray, OpenCV users should not care about OutputArray, they just pass `Mat`, - /// `vector` etc. to the functions. The same limitation as for `InputArray`: *Do not explicitly - /// create OutputArray instances* applies here too. - /// - /// If you want to make your function polymorphic (i.e. accept different arrays as output parameters), - /// it is also not very difficult. Take the sample above as the reference. Note that - /// _OutputArray::create() needs to be called before _OutputArray::getMat(). This way you guarantee - /// that the output array is properly allocated. - /// - /// Optional output parameters. If you do not need certain output array to be computed and returned to - /// you, pass cv::noArray(), just like you would in the case of optional input array. At the - /// implementation level, use _OutputArray::needed() to check if certain output array needs to be - /// computed or not. - /// - /// There are several synonyms for OutputArray that are used to assist automatic Python/Java/... wrapper - /// generators: - /// ```C++ - /// typedef OutputArray OutputArrayOfArrays; - /// typedef OutputArray InputOutputArray; - /// typedef OutputArray InputOutputArrayOfArrays; - /// ``` - /// - pub struct _OutputArray { - ptr: *mut c_void, - } - - opencv_type_boxed! { _OutputArray } - - impl Drop for _OutputArray { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv__OutputArray_delete(self.as_raw_mut__OutputArray()) }; - } - } - - unsafe impl Send for _OutputArray {} - - impl core::_InputArrayTraitConst for _OutputArray { - #[inline] fn as_raw__InputArray(&self) -> *const c_void { self.as_raw() } - } - - impl core::_InputArrayTrait for _OutputArray { - #[inline] fn as_raw_mut__InputArray(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { _OutputArray, core::_InputArrayTraitConst, as_raw__InputArray, core::_InputArrayTrait, as_raw_mut__InputArray } - - impl core::_OutputArrayTraitConst for _OutputArray { - #[inline] fn as_raw__OutputArray(&self) -> *const c_void { self.as_raw() } - } - - impl core::_OutputArrayTrait for _OutputArray { - #[inline] fn as_raw_mut__OutputArray(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { _OutputArray, core::_OutputArrayTraitConst, as_raw__OutputArray, core::_OutputArrayTrait, as_raw_mut__OutputArray } - - impl _OutputArray { - /// ///////////////////////////////////////////////////////////////////////////////////// + /// ## C++ default parameters + /// * i: -1 + /// * allow_transposed: false + /// * fixed_depth_mask: static_cast<_OutputArray::DepthMask>(0) #[inline] - pub fn default() -> Result { + fn create_size(&self, sz: core::Size, typ: i32, i: i32, allow_transposed: bool, fixed_depth_mask: core::_OutputArray_DepthMask) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray__OutputArray(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_create_const_Size_int_int_bool_DepthMask(self.as_raw__OutputArray(), &sz, typ, i, allow_transposed, fixed_depth_mask, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::_OutputArray::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [_OutputArrayTraitConst::create_size] function uses the following default values for its arguments: + /// * i: -1 + /// * allow_transposed: false + /// * fixed_depth_mask: static_cast<_OutputArray::DepthMask>(0) #[inline] - pub unsafe fn new(_flags: i32, _obj: *mut c_void) -> Result { + fn create_size_def(&self, sz: core::Size, typ: i32) -> Result<()> { return_send!(via ocvrs_return); - { sys::cv__OutputArray__OutputArray_int_voidX(_flags, _obj, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv__OutputArray_create_const_Size_int(self.as_raw__OutputArray(), &sz, typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::_OutputArray::opencv_from_extern(ret) }; Ok(ret) } + /// ## C++ default parameters + /// * i: -1 + /// * allow_transposed: false + /// * fixed_depth_mask: static_cast<_OutputArray::DepthMask>(0) #[inline] - pub fn from_mat_mut(m: &mut impl core::MatTrait) -> Result> { + fn create(&self, rows: i32, cols: i32, typ: i32, i: i32, allow_transposed: bool, fixed_depth_mask: core::_OutputArray_DepthMask) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray__OutputArray_MatR(m.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_create_const_int_int_int_int_bool_DepthMask(self.as_raw__OutputArray(), rows, cols, typ, i, allow_transposed, fixed_depth_mask, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [_OutputArrayTraitConst::create] function uses the following default values for its arguments: + /// * i: -1 + /// * allow_transposed: false + /// * fixed_depth_mask: static_cast<_OutputArray::DepthMask>(0) #[inline] - pub fn from_mat_vec_mut(vec: &mut core::Vector) -> Result> { + fn create_def(&self, rows: i32, cols: i32, typ: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray__OutputArray_vectorLMatGR(vec.as_raw_mut_VectorOfMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_create_const_int_int_int(self.as_raw__OutputArray(), rows, cols, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } + /// ## C++ default parameters + /// * i: -1 + /// * allow_transposed: false + /// * fixed_depth_mask: static_cast<_OutputArray::DepthMask>(0) #[inline] - pub fn from_gpumat_mut(d_mat: &mut impl core::GpuMatTrait) -> Result> { + fn create_nd(&self, size: &[i32], typ: i32, i: i32, allow_transposed: bool, fixed_depth_mask: core::_OutputArray_DepthMask) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray__OutputArray_GpuMatR(d_mat.as_raw_mut_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_create_const_int_const_intX_int_int_bool_DepthMask(self.as_raw__OutputArray(), size.len().try_into()?, size.as_ptr(), typ, i, allow_transposed, fixed_depth_mask, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [_OutputArrayTraitConst::create_nd] function uses the following default values for its arguments: + /// * i: -1 + /// * allow_transposed: false + /// * fixed_depth_mask: static_cast<_OutputArray::DepthMask>(0) #[inline] - pub fn from_gpumat_vec_mut(d_mat: &mut core::Vector) -> Result> { + fn create_nd_def(&self, size: &[i32], typ: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray__OutputArray_vectorLGpuMatGR(d_mat.as_raw_mut_VectorOfGpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_create_const_int_const_intX_int(self.as_raw__OutputArray(), size.len().try_into()?, size.as_ptr(), typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn from_opengl_mut(buf: &mut impl core::BufferTrait) -> Result> { + unsafe fn create_same_size(&self, arr: &impl ToInputArray, mtype: i32) -> Result<()> { + input_array_arg!(arr); return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray__OutputArray_BufferR(buf.as_raw_mut_Buffer(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv__OutputArray_createSameSize_const_const__InputArrayR_int(self.as_raw__OutputArray(), arr.as_raw__InputArray(), mtype, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn from_hostmem_mut(cuda_mem: &mut impl core::HostMemTrait) -> Result> { + fn release(&self) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray__OutputArray_HostMemR(cuda_mem.as_raw_mut_HostMem(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_release_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn from_umat_mut(m: &mut impl core::UMatTrait) -> Result> { + fn clear(&self) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray__OutputArray_UMatR(m.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_clear_const(self.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } + /// ## C++ default parameters + /// * mask: _InputArray() #[inline] - pub fn from_umat_vec_mut(vec: &mut core::Vector) -> Result> { + fn set_to(&self, value: &impl ToInputArray, mask: &impl ToInputArray) -> Result<()> { + input_array_arg!(value); + input_array_arg!(mask); return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray__OutputArray_vectorLUMatGR(vec.as_raw_mut_VectorOfUMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_setTo_const_const__InputArrayR_const__InputArrayR(self.as_raw__OutputArray(), value.as_raw__InputArray(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [_OutputArrayTraitConst::set_to] function uses the following default values for its arguments: + /// * mask: _InputArray() #[inline] - pub fn from_mat(m: &impl core::MatTraitConst) -> Result> { + fn set_to_def(&self, value: &impl ToInputArray) -> Result<()> { + input_array_arg!(value); return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray__OutputArray_const_MatR(m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_setTo_const_const__InputArrayR(self.as_raw__OutputArray(), value.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn from_mat_vec(vec: &core::Vector) -> Result> { + fn assign_umat(&self, u: &impl core::UMatTraitConst) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray__OutputArray_const_vectorLMatGR(vec.as_raw_VectorOfMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_assign_const_const_UMatR(self.as_raw__OutputArray(), u.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn from_gpumat(d_mat: &impl core::GpuMatTraitConst) -> Result> { + fn assign_mat(&self, m: &impl core::MatTraitConst) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray__OutputArray_const_GpuMatR(d_mat.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_assign_const_const_MatR(self.as_raw__OutputArray(), m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn from_opengl(buf: &impl core::BufferTraitConst) -> Result> { + fn assign_umat_vec(&self, v: &core::Vector) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray__OutputArray_const_BufferR(buf.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_assign_const_const_vectorLUMatGR(self.as_raw__OutputArray(), v.as_raw_VectorOfUMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn from_hostmem(cuda_mem: &impl core::HostMemTraitConst) -> Result> { + fn assign_mat_vec(&self, v: &core::Vector) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray__OutputArray_const_HostMemR(cuda_mem.as_raw_HostMem(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_assign_const_const_vectorLMatGR(self.as_raw__OutputArray(), v.as_raw_VectorOfMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn from_umat(m: &impl core::UMatTraitConst) -> Result> { + fn move_umat(&self, u: &mut impl core::UMatTrait) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray__OutputArray_const_UMatR(m.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_move_const_UMatR(self.as_raw__OutputArray(), u.as_raw_mut_UMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn from_umat_vec(vec: &core::Vector) -> Result> { + fn move_mat(&self, m: &mut impl core::MatTrait) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv__OutputArray__OutputArray_const_vectorLUMatGR(vec.as_raw_VectorOfUMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv__OutputArray_move_const_MatR(self.as_raw__OutputArray(), m.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { _OutputArray, core::_InputArray, cv__OutputArray_to__InputArray } + /// Mutable methods for [core::_OutputArray] + pub trait _OutputArrayTrait: core::_InputArrayTrait + core::_OutputArrayTraitConst { + fn as_raw_mut__OutputArray(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for _OutputArray { #[inline] @@ -30396,51 +30361,28 @@ pub mod core { } } - /// Constant methods for [core::BufferPool] - pub trait BufferPoolTraitConst { - fn as_raw_BufferPool(&self) -> *const c_void; - - /// Returns the allocator associated with the stream. - #[inline] - fn get_allocator(&self) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_BufferPool_getAllocator_const(self.as_raw_BufferPool(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } + boxed_cast_base! { _OutputArray, core::_InputArray, cv__OutputArray_to__InputArray } + impl core::_InputArrayTraitConst for _OutputArray { + #[inline] fn as_raw__InputArray(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [core::BufferPool] - pub trait BufferPoolTrait: core::BufferPoolTraitConst { - fn as_raw_mut_BufferPool(&mut self) -> *mut c_void; + impl core::_InputArrayTrait for _OutputArray { + #[inline] fn as_raw_mut__InputArray(&mut self) -> *mut c_void { self.as_raw_mut() } + } - /// Allocates a new GpuMat of given size and type. - #[inline] - fn get_buffer(&mut self, rows: i32, cols: i32, typ: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_BufferPool_getBuffer_int_int_int(self.as_raw_mut_BufferPool(), rows, cols, typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; - Ok(ret) - } + boxed_ref! { _OutputArray, core::_InputArrayTraitConst, as_raw__InputArray, core::_InputArrayTrait, as_raw_mut__InputArray } - /// Allocates a new GpuMat of given size and type. - #[inline] - fn get_buffer_1(&mut self, size: core::Size, typ: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_BufferPool_getBuffer_Size_int(self.as_raw_mut_BufferPool(), &size, typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; - Ok(ret) - } + impl core::_OutputArrayTraitConst for _OutputArray { + #[inline] fn as_raw__OutputArray(&self) -> *const c_void { self.as_raw() } + } + impl core::_OutputArrayTrait for _OutputArray { + #[inline] fn as_raw_mut__OutputArray(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { _OutputArray, core::_OutputArrayTraitConst, as_raw__OutputArray, core::_OutputArrayTrait, as_raw_mut__OutputArray } + /// BufferPool for use with CUDA streams /// /// BufferPool utilizes Stream's allocator to create new buffers for GpuMat's. It is @@ -30579,6 +30521,73 @@ pub mod core { unsafe impl Send for BufferPool {} + impl BufferPool { + /// Gets the BufferPool for the given stream. + #[inline] + pub fn new(stream: &mut impl core::StreamTrait) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_BufferPool_BufferPool_StreamR(stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::BufferPool::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [core::BufferPool] + pub trait BufferPoolTraitConst { + fn as_raw_BufferPool(&self) -> *const c_void; + + /// Returns the allocator associated with the stream. + #[inline] + fn get_allocator(&self) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_BufferPool_getAllocator_const(self.as_raw_BufferPool(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Mutable methods for [core::BufferPool] + pub trait BufferPoolTrait: core::BufferPoolTraitConst { + fn as_raw_mut_BufferPool(&mut self) -> *mut c_void; + + /// Allocates a new GpuMat of given size and type. + #[inline] + fn get_buffer(&mut self, rows: i32, cols: i32, typ: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_BufferPool_getBuffer_int_int_int(self.as_raw_mut_BufferPool(), rows, cols, typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Allocates a new GpuMat of given size and type. + #[inline] + fn get_buffer_1(&mut self, size: core::Size, typ: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_BufferPool_getBuffer_Size_int(self.as_raw_mut_BufferPool(), &size, typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + impl std::fmt::Debug for BufferPool { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BufferPool") + .finish() + } + } + impl core::BufferPoolTraitConst for BufferPool { #[inline] fn as_raw_BufferPool(&self) -> *const c_void { self.as_raw() } } @@ -30589,28 +30598,53 @@ pub mod core { boxed_ref! { BufferPool, core::BufferPoolTraitConst, as_raw_BufferPool, core::BufferPoolTrait, as_raw_mut_BufferPool } - impl BufferPool { - /// Gets the BufferPool for the given stream. + /// Class providing functionality for querying the specified GPU properties. + pub struct DeviceInfo { + ptr: *mut c_void, + } + + opencv_type_boxed! { DeviceInfo } + + impl Drop for DeviceInfo { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_DeviceInfo_delete(self.as_raw_mut_DeviceInfo()) }; + } + } + + unsafe impl Send for DeviceInfo {} + + impl DeviceInfo { + /// creates DeviceInfo object for the current GPU + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_DeviceInfo_DeviceInfo(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::DeviceInfo::opencv_from_extern(ret) }; + Ok(ret) + } + + /// The constructors. + /// + /// ## Parameters + /// * device_id: System index of the CUDA device starting with 0. + /// + /// Constructs the DeviceInfo object for the specified device. If device_id parameter is missed, it + /// constructs an object for the current device. #[inline] - pub fn new(stream: &mut impl core::StreamTrait) -> Result { + pub fn new(device_id: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_BufferPool_BufferPool_StreamR(stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_DeviceInfo_DeviceInfo_int(device_id, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::BufferPool::opencv_from_extern(ret) }; + let ret = unsafe { core::DeviceInfo::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for BufferPool { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BufferPool") - .finish() - } - } - /// Constant methods for [core::DeviceInfo] pub trait DeviceInfoTraitConst { fn as_raw_DeviceInfo(&self) -> *const c_void; @@ -31210,22 +31244,14 @@ pub mod core { } - /// Class providing functionality for querying the specified GPU properties. - pub struct DeviceInfo { - ptr: *mut c_void, - } - - opencv_type_boxed! { DeviceInfo } - - impl Drop for DeviceInfo { + impl std::fmt::Debug for DeviceInfo { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_DeviceInfo_delete(self.as_raw_mut_DeviceInfo()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DeviceInfo") + .finish() } } - unsafe impl Send for DeviceInfo {} - impl core::DeviceInfoTraitConst for DeviceInfo { #[inline] fn as_raw_DeviceInfo(&self) -> *const c_void { self.as_raw() } } @@ -31236,43 +31262,57 @@ pub mod core { boxed_ref! { DeviceInfo, core::DeviceInfoTraitConst, as_raw_DeviceInfo, core::DeviceInfoTrait, as_raw_mut_DeviceInfo } - impl DeviceInfo { - /// creates DeviceInfo object for the current GPU + pub struct Event { + ptr: *mut c_void, + } + + opencv_type_boxed! { Event } + + impl Drop for Event { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_cuda_Event_delete(self.as_raw_mut_Event()) }; + } + } + + unsafe impl Send for Event {} + + impl Event { + /// ## C++ default parameters + /// * flags: Event::CreateFlags::DEFAULT + #[inline] + pub fn new(flags: core::Event_CreateFlags) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_DeviceInfo_DeviceInfo(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_Event_Event_const_CreateFlags(flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::DeviceInfo::opencv_from_extern(ret) }; + let ret = unsafe { core::Event::opencv_from_extern(ret) }; Ok(ret) } - /// The constructors. - /// - /// ## Parameters - /// * device_id: System index of the CUDA device starting with 0. - /// - /// Constructs the DeviceInfo object for the specified device. If device_id parameter is missed, it - /// constructs an object for the current device. + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * flags: Event::CreateFlags::DEFAULT #[inline] - pub fn new(device_id: i32) -> Result { + pub fn new_def() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_DeviceInfo_DeviceInfo_int(device_id, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_Event_Event(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::DeviceInfo::opencv_from_extern(ret) }; + let ret = unsafe { core::Event::opencv_from_extern(ret) }; Ok(ret) } - } - - impl std::fmt::Debug for DeviceInfo { + /// computes the elapsed time between events #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DeviceInfo") - .finish() + pub fn elapsed_time(start: &impl core::EventTraitConst, end: &impl core::EventTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_Event_elapsedTime_const_EventR_const_EventR(start.as_raw_Event(), end.as_raw_Event(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } + } /// Constant methods for [core::Event] @@ -31334,21 +31374,14 @@ pub mod core { } - pub struct Event { - ptr: *mut c_void, - } - - opencv_type_boxed! { Event } - - impl Drop for Event { + impl std::fmt::Debug for Event { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_Event_delete(self.as_raw_mut_Event()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Event") + .finish() } } - unsafe impl Send for Event {} - impl core::EventTraitConst for Event { #[inline] fn as_raw_Event(&self) -> *const c_void { self.as_raw() } } @@ -31359,52 +31392,34 @@ pub mod core { boxed_ref! { Event, core::EventTraitConst, as_raw_Event, core::EventTrait, as_raw_mut_Event } - impl Event { - /// ## C++ default parameters - /// * flags: Event::CreateFlags::DEFAULT - #[inline] - pub fn new(flags: core::Event_CreateFlags) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_Event_Event_const_CreateFlags(flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Event::opencv_from_extern(ret) }; - Ok(ret) - } + pub struct GpuData { + ptr: *mut c_void, + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * flags: Event::CreateFlags::DEFAULT + opencv_type_boxed! { GpuData } + + impl Drop for GpuData { #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_Event_Event(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Event::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_cuda_GpuData_delete(self.as_raw_mut_GpuData()) }; } + } - /// computes the elapsed time between events + unsafe impl Send for GpuData {} + + impl GpuData { #[inline] - pub fn elapsed_time(start: &impl core::EventTraitConst, end: &impl core::EventTraitConst) -> Result { + pub fn new(_size: size_t) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_Event_elapsedTime_const_EventR_const_EventR(start.as_raw_Event(), end.as_raw_Event(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuData_GpuData_size_t(_size, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::GpuData::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for Event { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Event") - .finish() - } - } - /// Constant methods for [core::GpuData] pub trait GpuDataTraitConst { fn as_raw_GpuData(&self) -> *const c_void; @@ -31447,21 +31462,16 @@ pub mod core { } - pub struct GpuData { - ptr: *mut c_void, - } - - opencv_type_boxed! { GpuData } - - impl Drop for GpuData { + impl std::fmt::Debug for GpuData { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_GpuData_delete(self.as_raw_mut_GpuData()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GpuData") + .field("data", &core::GpuDataTraitConst::data(self)) + .field("size", &core::GpuDataTraitConst::size(self)) + .finish() } } - unsafe impl Send for GpuData {} - impl core::GpuDataTraitConst for GpuData { #[inline] fn as_raw_GpuData(&self) -> *const c_void { self.as_raw() } } @@ -31472,997 +31482,942 @@ pub mod core { boxed_ref! { GpuData, core::GpuDataTraitConst, as_raw_GpuData, core::GpuDataTrait, as_raw_mut_GpuData } - impl GpuData { - #[inline] - pub fn new(_size: size_t) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuData_GpuData_size_t(_size, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::GpuData::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for GpuData { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GpuData") - .field("data", &core::GpuDataTraitConst::data(self)) - .field("size", &core::GpuDataTraitConst::size(self)) - .finish() - } - } - - /// Constant methods for [core::GpuMat] - pub trait GpuMatTraitConst { - fn as_raw_GpuMat(&self) -> *const c_void; - - /// ! includes several bit-fields: - /// - the magic signature - /// - continuity flag - /// - depth - /// - number of channels - #[inline] - fn flags(&self) -> i32 { - let ret = unsafe { sys::cv_cuda_GpuMat_propFlags_const(self.as_raw_GpuMat()) }; - ret - } - - /// the number of rows and columns - #[inline] - fn rows(&self) -> i32 { - let ret = unsafe { sys::cv_cuda_GpuMat_propRows_const(self.as_raw_GpuMat()) }; - ret - } - - /// the number of rows and columns - #[inline] - fn cols(&self) -> i32 { - let ret = unsafe { sys::cv_cuda_GpuMat_propCols_const(self.as_raw_GpuMat()) }; - ret - } - - /// a distance between successive rows in bytes; includes the gap if any - #[inline] - fn step(&self) -> size_t { - let ret = unsafe { sys::cv_cuda_GpuMat_propStep_const(self.as_raw_GpuMat()) }; - ret - } - - /// pointer to the data - #[inline] - fn data(&self) -> *const u8 { - let ret = unsafe { sys::cv_cuda_GpuMat_propData_const(self.as_raw_GpuMat()) }; - ret - } + /// Base storage class for GPU memory with reference counting. + /// + /// Its interface matches the Mat interface with the following limitations: + /// + /// * no arbitrary dimensions support (only 2D) + /// * no functions that return references to their data (because references on GPU are not valid for + /// CPU) + /// * no expression templates technique support + /// + /// Beware that the latter limitation may lead to overloaded matrix operators that cause memory + /// allocations. The GpuMat class is convertible to cuda::PtrStepSz and cuda::PtrStep so it can be + /// passed directly to the kernel. + /// + /// + /// Note: In contrast with Mat, in most cases GpuMat::isContinuous() == false . This means that rows are + /// aligned to a size depending on the hardware. Single-row GpuMat is always a continuous matrix. + /// + /// + /// Note: You are not recommended to leave static or global GpuMat variables allocated, that is, to rely + /// on its destructor. The destruction order of such variables and CUDA context is undefined. GPU memory + /// release function returns error if the CUDA context has been destroyed before. + /// + /// Some member functions are described as a "Blocking Call" while some are described as a + /// "Non-Blocking Call". Blocking functions are synchronous to host. It is guaranteed that the GPU + /// operation is finished when the function returns. However, non-blocking functions are asynchronous to + /// host. Those functions may return even if the GPU operation is not finished. + /// + /// Compared to their blocking counterpart, non-blocking functions accept Stream as an additional + /// argument. If a non-default stream is passed, the GPU operation may overlap with operations in other + /// streams. + /// ## See also + /// Mat + pub struct GpuMat { + ptr: *mut c_void, + } - /// pointer to the reference counter; - /// when GpuMat points to user-allocated data, the pointer is NULL - #[inline] - fn refcount(&self) -> *const i32 { - let ret = unsafe { sys::cv_cuda_GpuMat_propRefcount_const(self.as_raw_GpuMat()) }; - ret - } + opencv_type_boxed! { GpuMat } - /// helper fields used in locateROI and adjustROI + impl Drop for GpuMat { #[inline] - fn datastart(&self) -> *const u8 { - let ret = unsafe { sys::cv_cuda_GpuMat_propDatastart_const(self.as_raw_GpuMat()) }; - ret + fn drop(&mut self) { + unsafe { sys::cv_cuda_GpuMat_delete(self.as_raw_mut_GpuMat()) }; } + } - #[inline] - fn dataend(&self) -> *const u8 { - let ret = unsafe { sys::cv_cuda_GpuMat_propDataend_const(self.as_raw_GpuMat()) }; - ret - } + unsafe impl Send for GpuMat {} - /// Performs data download from GpuMat (Blocking call) - /// - /// This function copies data from device memory to host memory. As being a blocking call, it is - /// guaranteed that the copy operation is finished when this function returns. + impl GpuMat { + /// default allocator #[inline] - fn download(&self, dst: &mut impl ToOutputArray) -> Result<()> { - output_array_arg!(dst); + pub fn default_allocator() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_download_const_const__OutputArrayR(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_defaultAllocator(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { types::AbstractRefMut::<'static, core::GpuMat_Allocator>::opencv_from_extern(ret) }; Ok(ret) } - /// Performs data download from GpuMat (Non-Blocking call) - /// - /// This function copies data from device memory to host memory. As being a non-blocking call, this - /// function may return even if the copy operation is not finished. - /// - /// The copy operation may be overlapped with operations in other non-default streams if \p stream is - /// not the default stream and \p dst is HostMem allocated with HostMem::PAGE_LOCKED option. #[inline] - fn download_async(&self, dst: &mut impl ToOutputArray, stream: &mut impl core::StreamTrait) -> Result<()> { - output_array_arg!(dst); + pub fn set_default_allocator(allocator: &'static mut impl core::GpuMat_AllocatorTrait) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_download_const_const__OutputArrayR_StreamR(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_setDefaultAllocator_AllocatorX(allocator.as_raw_mut_GpuMat_Allocator(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// returns deep copy of the GpuMat, i.e. the data is copied #[inline] - fn try_clone(&self) -> Result { + pub fn get_std_allocator() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_clone_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_getStdAllocator(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; + let ret = unsafe { types::AbstractRefMut::<'static, core::GpuMat_Allocator>::opencv_from_extern(ret) }; Ok(ret) } - /// copies the GpuMat content to device memory (Blocking call) + /// default constructor + /// + /// ## C++ default parameters + /// * allocator: GpuMat::defaultAllocator() #[inline] - fn copy_to(&self, dst: &mut impl ToOutputArray) -> Result<()> { - output_array_arg!(dst); + pub unsafe fn new(allocator: &mut impl core::GpuMat_AllocatorTrait) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_copyTo_const_const__OutputArrayR(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_cuda_GpuMat_GpuMat_AllocatorX(allocator.as_raw_mut_GpuMat_Allocator(), ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; + let ret = { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// bindings overload which copies the GpuMat content to device memory (Blocking call) + /// default constructor + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * allocator: GpuMat::defaultAllocator() #[inline] - fn copy_to_gpu_mat(&self, dst: &mut impl core::GpuMatTrait) -> Result<()> { + pub fn new_def() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_copyTo_const_GpuMatR(self.as_raw_GpuMat(), dst.as_raw_mut_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_GpuMat(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// copies the GpuMat content to device memory (Non-Blocking call) + /// constructs GpuMat of the specified size and type + /// + /// ## C++ default parameters + /// * allocator: GpuMat::defaultAllocator() #[inline] - fn copy_to_stream(&self, dst: &mut impl ToOutputArray, stream: &mut impl core::StreamTrait) -> Result<()> { - output_array_arg!(dst); + pub unsafe fn new_rows_cols(rows: i32, cols: i32, typ: i32, allocator: &mut impl core::GpuMat_AllocatorTrait) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_copyTo_const_const__OutputArrayR_StreamR(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_cuda_GpuMat_GpuMat_int_int_int_AllocatorX(rows, cols, typ, allocator.as_raw_mut_GpuMat_Allocator(), ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; + let ret = { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// bindings overload which copies the GpuMat content to device memory (Non-Blocking call) + /// constructs GpuMat of the specified size and type + /// + /// ## Note + /// This alternative version of [new_rows_cols] function uses the following default values for its arguments: + /// * allocator: GpuMat::defaultAllocator() #[inline] - fn copy_to_gpu_mat_stream(&self, dst: &mut impl core::GpuMatTrait, stream: &mut impl core::StreamTrait) -> Result<()> { + pub fn new_rows_cols_def(rows: i32, cols: i32, typ: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_copyTo_const_GpuMatR_StreamR(self.as_raw_GpuMat(), dst.as_raw_mut_GpuMat(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_GpuMat_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// copies those GpuMat elements to "m" that are marked with non-zero mask elements (Blocking call) + /// ## C++ default parameters + /// * allocator: GpuMat::defaultAllocator() #[inline] - fn copy_to_mask(&self, dst: &mut impl ToOutputArray, mask: &impl ToInputArray) -> Result<()> { - output_array_arg!(dst); - input_array_arg!(mask); + pub unsafe fn new_size(size: core::Size, typ: i32, allocator: &mut impl core::GpuMat_AllocatorTrait) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_copyTo_const_const__OutputArrayR_const__InputArrayR(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_cuda_GpuMat_GpuMat_Size_int_AllocatorX(&size, typ, allocator.as_raw_mut_GpuMat_Allocator(), ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; + let ret = { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// bindings overload which copies those GpuMat elements to "m" that are marked with non-zero mask elements (Blocking call) + /// ## Note + /// This alternative version of [new_size] function uses the following default values for its arguments: + /// * allocator: GpuMat::defaultAllocator() #[inline] - fn copy_to_gpu_mat_mask(&self, dst: &mut impl core::GpuMatTrait, mask: &mut impl core::GpuMatTrait) -> Result<()> { + pub fn new_size_def(size: core::Size, typ: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_copyTo_const_GpuMatR_GpuMatR(self.as_raw_GpuMat(), dst.as_raw_mut_GpuMat(), mask.as_raw_mut_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_GpuMat_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// copies those GpuMat elements to "m" that are marked with non-zero mask elements (Non-Blocking call) + /// constructs GpuMat and fills it with the specified value _s + /// + /// ## C++ default parameters + /// * allocator: GpuMat::defaultAllocator() #[inline] - fn copy_to_mask_stream(&self, dst: &mut impl ToOutputArray, mask: &impl ToInputArray, stream: &mut impl core::StreamTrait) -> Result<()> { - output_array_arg!(dst); - input_array_arg!(mask); + pub unsafe fn new_rows_cols_with_default(rows: i32, cols: i32, typ: i32, s: core::Scalar, allocator: &mut impl core::GpuMat_AllocatorTrait) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_copyTo_const_const__OutputArrayR_const__InputArrayR_StreamR(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), mask.as_raw__InputArray(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_cuda_GpuMat_GpuMat_int_int_int_Scalar_AllocatorX(rows, cols, typ, &s, allocator.as_raw_mut_GpuMat_Allocator(), ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; + let ret = { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// bindings overload which copies those GpuMat elements to "m" that are marked with non-zero mask elements (Non-Blocking call) + /// constructs GpuMat and fills it with the specified value _s + /// + /// ## Note + /// This alternative version of [new_rows_cols_with_default] function uses the following default values for its arguments: + /// * allocator: GpuMat::defaultAllocator() #[inline] - fn copy_to_gpu_mat_mask_stream(&self, dst: &mut impl core::GpuMatTrait, mask: &mut impl core::GpuMatTrait, stream: &mut impl core::StreamTrait) -> Result<()> { + pub fn new_rows_cols_with_default_def(rows: i32, cols: i32, typ: i32, s: core::Scalar) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_copyTo_const_GpuMatR_GpuMatR_StreamR(self.as_raw_GpuMat(), dst.as_raw_mut_GpuMat(), mask.as_raw_mut_GpuMat(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_GpuMat_int_int_int_Scalar(rows, cols, typ, &s, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// converts GpuMat to another datatype (Blocking call) + /// ## C++ default parameters + /// * allocator: GpuMat::defaultAllocator() #[inline] - fn convert_to(&self, dst: &mut impl ToOutputArray, rtype: i32) -> Result<()> { - output_array_arg!(dst); + pub unsafe fn new_size_with_default(size: core::Size, typ: i32, s: core::Scalar, allocator: &mut impl core::GpuMat_AllocatorTrait) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_convertTo_const_const__OutputArrayR_int(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), rtype, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_cuda_GpuMat_GpuMat_Size_int_Scalar_AllocatorX(&size, typ, &s, allocator.as_raw_mut_GpuMat_Allocator(), ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; + let ret = { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// converts GpuMat to another datatype (Non-Blocking call) + /// ## Note + /// This alternative version of [new_size_with_default] function uses the following default values for its arguments: + /// * allocator: GpuMat::defaultAllocator() #[inline] - fn convert_to_1(&self, dst: &mut impl ToOutputArray, rtype: i32, stream: &mut impl core::StreamTrait) -> Result<()> { - output_array_arg!(dst); + pub fn new_size_with_default_def(size: core::Size, typ: i32, s: core::Scalar) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_convertTo_const_const__OutputArrayR_int_StreamR(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), rtype, stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_GpuMat_Size_int_Scalar(&size, typ, &s, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// bindings overload which converts GpuMat to another datatype (Non-Blocking call) + /// copy constructor #[inline] - fn convert_to_2(&self, dst: &mut impl core::GpuMatTrait, rtype: i32, stream: &mut impl core::StreamTrait) -> Result<()> { + pub fn copy(m: &impl core::GpuMatTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_convertTo_const_GpuMatR_int_StreamR(self.as_raw_GpuMat(), dst.as_raw_mut_GpuMat(), rtype, stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_GpuMat_const_GpuMatR(m.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// converts GpuMat to another datatype with scaling (Blocking call) + /// constructor for GpuMat headers pointing to user-allocated data /// /// ## C++ default parameters - /// * beta: 0.0 + /// * step: Mat::AUTO_STEP #[inline] - fn convert_to_3(&self, dst: &mut impl ToOutputArray, rtype: i32, alpha: f64, beta: f64) -> Result<()> { - output_array_arg!(dst); + pub unsafe fn new_rows_cols_with_data(rows: i32, cols: i32, typ: i32, data: *mut c_void, step: size_t) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_convertTo_const_const__OutputArrayR_int_double_double(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), rtype, alpha, beta, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_cuda_GpuMat_GpuMat_int_int_int_voidX_size_t(rows, cols, typ, data, step, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; + let ret = { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// converts GpuMat to another datatype with scaling (Blocking call) + /// constructor for GpuMat headers pointing to user-allocated data /// /// ## Note - /// This alternative version of [GpuMatTraitConst::convert_to] function uses the following default values for its arguments: - /// * beta: 0.0 + /// This alternative version of [new_rows_cols_with_data] function uses the following default values for its arguments: + /// * step: Mat::AUTO_STEP #[inline] - fn convert_to_def(&self, dst: &mut impl ToOutputArray, rtype: i32, alpha: f64) -> Result<()> { - output_array_arg!(dst); + pub unsafe fn new_rows_cols_with_data_def(rows: i32, cols: i32, typ: i32, data: *mut c_void) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_convertTo_const_const__OutputArrayR_int_double(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), rtype, alpha, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_cuda_GpuMat_GpuMat_int_int_int_voidX(rows, cols, typ, data, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; + let ret = { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// bindings overload which converts GpuMat to another datatype with scaling(Blocking call) - /// /// ## C++ default parameters - /// * alpha: 1.0 - /// * beta: 0.0 + /// * step: Mat::AUTO_STEP #[inline] - fn convert_to_4(&self, dst: &mut impl core::GpuMatTrait, rtype: i32, alpha: f64, beta: f64) -> Result<()> { + pub unsafe fn new_size_with_data(size: core::Size, typ: i32, data: *mut c_void, step: size_t) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_convertTo_const_GpuMatR_int_double_double(self.as_raw_GpuMat(), dst.as_raw_mut_GpuMat(), rtype, alpha, beta, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_cuda_GpuMat_GpuMat_Size_int_voidX_size_t(&size, typ, data, step, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; + let ret = { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// bindings overload which converts GpuMat to another datatype with scaling(Blocking call) - /// /// ## Note - /// This alternative version of [GpuMatTraitConst::convert_to] function uses the following default values for its arguments: - /// * alpha: 1.0 - /// * beta: 0.0 - #[inline] - fn convert_to_def_1(&self, dst: &mut impl core::GpuMatTrait, rtype: i32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_convertTo_const_GpuMatR_int(self.as_raw_GpuMat(), dst.as_raw_mut_GpuMat(), rtype, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// converts GpuMat to another datatype with scaling (Non-Blocking call) + /// This alternative version of [new_size_with_data] function uses the following default values for its arguments: + /// * step: Mat::AUTO_STEP #[inline] - fn convert_to_5(&self, dst: &mut impl ToOutputArray, rtype: i32, alpha: f64, stream: &mut impl core::StreamTrait) -> Result<()> { - output_array_arg!(dst); + pub unsafe fn new_size_with_data_def(size: core::Size, typ: i32, data: *mut c_void) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_convertTo_const_const__OutputArrayR_int_double_StreamR(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), rtype, alpha, stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_cuda_GpuMat_GpuMat_Size_int_voidX(&size, typ, data, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; + let ret = { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// converts GpuMat to another datatype with scaling (Non-Blocking call) + /// creates a GpuMat header for a part of the bigger matrix #[inline] - fn convert_to_6(&self, dst: &mut impl ToOutputArray, rtype: i32, alpha: f64, beta: f64, stream: &mut impl core::StreamTrait) -> Result<()> { - output_array_arg!(dst); + pub fn rowscols(m: &impl core::GpuMatTraitConst, mut row_range: impl core::RangeTrait, mut col_range: impl core::RangeTrait) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_convertTo_const_const__OutputArrayR_int_double_double_StreamR(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), rtype, alpha, beta, stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_GpuMat_const_GpuMatR_Range_Range(m.as_raw_GpuMat(), row_range.as_raw_mut_Range(), col_range.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// bindings overload which converts GpuMat to another datatype with scaling (Non-Blocking call) + /// creates a GpuMat header for a part of the bigger matrix #[inline] - fn convert_to_7(&self, dst: &mut impl core::GpuMatTrait, rtype: i32, alpha: f64, beta: f64, stream: &mut impl core::StreamTrait) -> Result<()> { + pub fn rowscols_mut(m: &mut impl core::GpuMatTrait, mut row_range: impl core::RangeTrait, mut col_range: impl core::RangeTrait) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_convertTo_const_GpuMatR_int_double_double_StreamR(self.as_raw_GpuMat(), dst.as_raw_mut_GpuMat(), rtype, alpha, beta, stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_GpuMat_GpuMatR_Range_Range(m.as_raw_mut_GpuMat(), row_range.as_raw_mut_Range(), col_range.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// ## C++ default parameters - /// * typ: -1 #[inline] - fn assign_to(&self, m: &mut impl core::GpuMatTrait, typ: i32) -> Result<()> { + pub fn roi(m: &impl core::GpuMatTraitConst, roi: core::Rect) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_assignTo_const_GpuMatR_int(self.as_raw_GpuMat(), m.as_raw_mut_GpuMat(), typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_GpuMat_const_GpuMatR_Rect(m.as_raw_GpuMat(), &roi, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [GpuMatTraitConst::assign_to] function uses the following default values for its arguments: - /// * typ: -1 #[inline] - fn assign_to_def(&self, m: &mut impl core::GpuMatTrait) -> Result<()> { + pub fn roi_mut(m: &mut impl core::GpuMatTrait, roi: core::Rect) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_assignTo_const_GpuMatR(self.as_raw_GpuMat(), m.as_raw_mut_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_GpuMat_GpuMatR_Rect(m.as_raw_mut_GpuMat(), &roi, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } + /// builds GpuMat from host memory (Blocking call) + /// /// ## C++ default parameters - /// * y: 0 + /// * allocator: GpuMat::defaultAllocator() #[inline] - fn ptr(&self, y: i32) -> Result<*const u8> { + pub unsafe fn from_hostmem(arr: &impl ToInputArray, allocator: &mut impl core::GpuMat_AllocatorTrait) -> Result { + input_array_arg!(arr); return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_ptr_const_int(self.as_raw_GpuMat(), y, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_cuda_GpuMat_GpuMat_const__InputArrayR_AllocatorX(arr.as_raw__InputArray(), allocator.as_raw_mut_GpuMat_Allocator(), ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; + let ret = { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } + /// builds GpuMat from host memory (Blocking call) + /// /// ## Note - /// This alternative version of [GpuMatTraitConst::ptr] function uses the following default values for its arguments: - /// * y: 0 + /// This alternative version of [from_hostmem] function uses the following default values for its arguments: + /// * allocator: GpuMat::defaultAllocator() #[inline] - fn ptr_def(&self) -> Result<*const u8> { + pub fn from_hostmem_def(arr: &impl ToInputArray) -> Result { + input_array_arg!(arr); return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_ptr_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_GpuMat_const__InputArrayR(arr.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// returns a new GpuMat header for the specified row + } + + /// Constant methods for [core::GpuMat] + pub trait GpuMatTraitConst { + fn as_raw_GpuMat(&self) -> *const c_void; + + /// ! includes several bit-fields: + /// - the magic signature + /// - continuity flag + /// - depth + /// - number of channels #[inline] - fn row(&self, y: i32) -> Result> { + fn flags(&self) -> i32 { + let ret = unsafe { sys::cv_cuda_GpuMat_propFlags_const(self.as_raw_GpuMat()) }; + ret + } + + /// the number of rows and columns + #[inline] + fn rows(&self) -> i32 { + let ret = unsafe { sys::cv_cuda_GpuMat_propRows_const(self.as_raw_GpuMat()) }; + ret + } + + /// the number of rows and columns + #[inline] + fn cols(&self) -> i32 { + let ret = unsafe { sys::cv_cuda_GpuMat_propCols_const(self.as_raw_GpuMat()) }; + ret + } + + /// a distance between successive rows in bytes; includes the gap if any + #[inline] + fn step(&self) -> size_t { + let ret = unsafe { sys::cv_cuda_GpuMat_propStep_const(self.as_raw_GpuMat()) }; + ret + } + + /// pointer to the data + #[inline] + fn data(&self) -> *const u8 { + let ret = unsafe { sys::cv_cuda_GpuMat_propData_const(self.as_raw_GpuMat()) }; + ret + } + + /// pointer to the reference counter; + /// when GpuMat points to user-allocated data, the pointer is NULL + #[inline] + fn refcount(&self) -> *const i32 { + let ret = unsafe { sys::cv_cuda_GpuMat_propRefcount_const(self.as_raw_GpuMat()) }; + ret + } + + /// helper fields used in locateROI and adjustROI + #[inline] + fn datastart(&self) -> *const u8 { + let ret = unsafe { sys::cv_cuda_GpuMat_propDatastart_const(self.as_raw_GpuMat()) }; + ret + } + + #[inline] + fn dataend(&self) -> *const u8 { + let ret = unsafe { sys::cv_cuda_GpuMat_propDataend_const(self.as_raw_GpuMat()) }; + ret + } + + /// Performs data download from GpuMat (Blocking call) + /// + /// This function copies data from device memory to host memory. As being a blocking call, it is + /// guaranteed that the copy operation is finished when this function returns. + #[inline] + fn download(&self, dst: &mut impl ToOutputArray) -> Result<()> { + output_array_arg!(dst); return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_row_const_int(self.as_raw_GpuMat(), y, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_download_const_const__OutputArrayR(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// returns a new GpuMat header for the specified column + /// Performs data download from GpuMat (Non-Blocking call) + /// + /// This function copies data from device memory to host memory. As being a non-blocking call, this + /// function may return even if the copy operation is not finished. + /// + /// The copy operation may be overlapped with operations in other non-default streams if \p stream is + /// not the default stream and \p dst is HostMem allocated with HostMem::PAGE_LOCKED option. #[inline] - fn col(&self, x: i32) -> Result> { + fn download_async(&self, dst: &mut impl ToOutputArray, stream: &mut impl core::StreamTrait) -> Result<()> { + output_array_arg!(dst); return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_col_const_int(self.as_raw_GpuMat(), x, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_download_const_const__OutputArrayR_StreamR(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// ... for the specified row span + /// returns deep copy of the GpuMat, i.e. the data is copied #[inline] - fn row_bounds(&self, startrow: i32, endrow: i32) -> Result> { + fn try_clone(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_rowRange_const_int_int(self.as_raw_GpuMat(), startrow, endrow, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_clone_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } + /// copies the GpuMat content to device memory (Blocking call) #[inline] - fn row_range(&self, mut r: impl core::RangeTrait) -> Result> { + fn copy_to(&self, dst: &mut impl ToOutputArray) -> Result<()> { + output_array_arg!(dst); return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_rowRange_const_Range(self.as_raw_GpuMat(), r.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_copyTo_const_const__OutputArrayR(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// ... for the specified column span + /// bindings overload which copies the GpuMat content to device memory (Blocking call) #[inline] - fn col_bounds(&self, startcol: i32, endcol: i32) -> Result> { + fn copy_to_gpu_mat(&self, dst: &mut impl core::GpuMatTrait) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_colRange_const_int_int(self.as_raw_GpuMat(), startcol, endcol, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_copyTo_const_GpuMatR(self.as_raw_GpuMat(), dst.as_raw_mut_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } + /// copies the GpuMat content to device memory (Non-Blocking call) #[inline] - fn col_range(&self, mut r: impl core::RangeTrait) -> Result> { + fn copy_to_stream(&self, dst: &mut impl ToOutputArray, stream: &mut impl core::StreamTrait) -> Result<()> { + output_array_arg!(dst); return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_colRange_const_Range(self.as_raw_GpuMat(), r.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_copyTo_const_const__OutputArrayR_StreamR(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// extracts a rectangular sub-GpuMat (this is a generalized form of row, rowRange etc.) + /// bindings overload which copies the GpuMat content to device memory (Non-Blocking call) #[inline] - fn rowscols(&self, mut row_range: impl core::RangeTrait, mut col_range: impl core::RangeTrait) -> Result> { + fn copy_to_gpu_mat_stream(&self, dst: &mut impl core::GpuMatTrait, stream: &mut impl core::StreamTrait) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_operator___const_Range_Range(self.as_raw_GpuMat(), row_range.as_raw_mut_Range(), col_range.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_copyTo_const_GpuMatR_StreamR(self.as_raw_GpuMat(), dst.as_raw_mut_GpuMat(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } + /// copies those GpuMat elements to "m" that are marked with non-zero mask elements (Blocking call) #[inline] - fn roi(&self, roi: core::Rect) -> Result> { + fn copy_to_mask(&self, dst: &mut impl ToOutputArray, mask: &impl ToInputArray) -> Result<()> { + output_array_arg!(dst); + input_array_arg!(mask); return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_operator___const_Rect(self.as_raw_GpuMat(), &roi, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_copyTo_const_const__OutputArrayR_const__InputArrayR(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// creates alternative GpuMat header for the same data, with different - /// number of channels and/or different number of rows - /// - /// ## C++ default parameters - /// * rows: 0 + /// bindings overload which copies those GpuMat elements to "m" that are marked with non-zero mask elements (Blocking call) #[inline] - fn reshape(&self, cn: i32, rows: i32) -> Result> { + fn copy_to_gpu_mat_mask(&self, dst: &mut impl core::GpuMatTrait, mask: &mut impl core::GpuMatTrait) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_reshape_const_int_int(self.as_raw_GpuMat(), cn, rows, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_copyTo_const_GpuMatR_GpuMatR(self.as_raw_GpuMat(), dst.as_raw_mut_GpuMat(), mask.as_raw_mut_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// creates alternative GpuMat header for the same data, with different - /// number of channels and/or different number of rows - /// - /// ## Note - /// This alternative version of [GpuMatTraitConst::reshape] function uses the following default values for its arguments: - /// * rows: 0 + /// copies those GpuMat elements to "m" that are marked with non-zero mask elements (Non-Blocking call) #[inline] - fn reshape_def(&self, cn: i32) -> Result> { + fn copy_to_mask_stream(&self, dst: &mut impl ToOutputArray, mask: &impl ToInputArray, stream: &mut impl core::StreamTrait) -> Result<()> { + output_array_arg!(dst); + input_array_arg!(mask); return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_reshape_const_int(self.as_raw_GpuMat(), cn, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_copyTo_const_const__OutputArrayR_const__InputArrayR_StreamR(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), mask.as_raw__InputArray(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// locates GpuMat header within a parent GpuMat + /// bindings overload which copies those GpuMat elements to "m" that are marked with non-zero mask elements (Non-Blocking call) #[inline] - fn locate_roi(&self, whole_size: &mut core::Size, ofs: &mut core::Point) -> Result<()> { + fn copy_to_gpu_mat_mask_stream(&self, dst: &mut impl core::GpuMatTrait, mask: &mut impl core::GpuMatTrait, stream: &mut impl core::StreamTrait) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_locateROI_const_SizeR_PointR(self.as_raw_GpuMat(), whole_size, ofs, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_copyTo_const_GpuMatR_GpuMatR_StreamR(self.as_raw_GpuMat(), dst.as_raw_mut_GpuMat(), mask.as_raw_mut_GpuMat(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// returns true iff the GpuMat data is continuous - /// (i.e. when there are no gaps between successive rows) + /// converts GpuMat to another datatype (Blocking call) #[inline] - fn is_continuous(&self) -> Result { + fn convert_to(&self, dst: &mut impl ToOutputArray, rtype: i32) -> Result<()> { + output_array_arg!(dst); return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_isContinuous_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_convertTo_const_const__OutputArrayR_int(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), rtype, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// returns element size in bytes + /// converts GpuMat to another datatype (Non-Blocking call) #[inline] - fn elem_size(&self) -> Result { + fn convert_to_1(&self, dst: &mut impl ToOutputArray, rtype: i32, stream: &mut impl core::StreamTrait) -> Result<()> { + output_array_arg!(dst); return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_elemSize_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_convertTo_const_const__OutputArrayR_int_StreamR(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), rtype, stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// returns the size of element channel in bytes + /// bindings overload which converts GpuMat to another datatype (Non-Blocking call) #[inline] - fn elem_size1(&self) -> Result { + fn convert_to_2(&self, dst: &mut impl core::GpuMatTrait, rtype: i32, stream: &mut impl core::StreamTrait) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_elemSize1_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_convertTo_const_GpuMatR_int_StreamR(self.as_raw_GpuMat(), dst.as_raw_mut_GpuMat(), rtype, stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// returns element type + /// converts GpuMat to another datatype with scaling (Blocking call) + /// + /// ## C++ default parameters + /// * beta: 0.0 #[inline] - fn typ(&self) -> Result { + fn convert_to_3(&self, dst: &mut impl ToOutputArray, rtype: i32, alpha: f64, beta: f64) -> Result<()> { + output_array_arg!(dst); return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_type_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_convertTo_const_const__OutputArrayR_int_double_double(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), rtype, alpha, beta, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// returns element type + /// converts GpuMat to another datatype with scaling (Blocking call) + /// + /// ## Note + /// This alternative version of [GpuMatTraitConst::convert_to] function uses the following default values for its arguments: + /// * beta: 0.0 #[inline] - fn depth(&self) -> Result { + fn convert_to_def(&self, dst: &mut impl ToOutputArray, rtype: i32, alpha: f64) -> Result<()> { + output_array_arg!(dst); return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_depth_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_convertTo_const_const__OutputArrayR_int_double(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), rtype, alpha, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// returns number of channels + /// bindings overload which converts GpuMat to another datatype with scaling(Blocking call) + /// + /// ## C++ default parameters + /// * alpha: 1.0 + /// * beta: 0.0 #[inline] - fn channels(&self) -> Result { + fn convert_to_4(&self, dst: &mut impl core::GpuMatTrait, rtype: i32, alpha: f64, beta: f64) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_channels_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_convertTo_const_GpuMatR_int_double_double(self.as_raw_GpuMat(), dst.as_raw_mut_GpuMat(), rtype, alpha, beta, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// returns step/elemSize1() + /// bindings overload which converts GpuMat to another datatype with scaling(Blocking call) + /// + /// ## Note + /// This alternative version of [GpuMatTraitConst::convert_to] function uses the following default values for its arguments: + /// * alpha: 1.0 + /// * beta: 0.0 #[inline] - fn step1(&self) -> Result { + fn convert_to_def_1(&self, dst: &mut impl core::GpuMatTrait, rtype: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_step1_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_convertTo_const_GpuMatR_int(self.as_raw_GpuMat(), dst.as_raw_mut_GpuMat(), rtype, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// returns GpuMat size : width == number of columns, height == number of rows + /// converts GpuMat to another datatype with scaling (Non-Blocking call) #[inline] - fn size(&self) -> Result { + fn convert_to_5(&self, dst: &mut impl ToOutputArray, rtype: i32, alpha: f64, stream: &mut impl core::StreamTrait) -> Result<()> { + output_array_arg!(dst); return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_size_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_convertTo_const_const__OutputArrayR_int_double_StreamR(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), rtype, alpha, stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// returns true if GpuMat data is NULL + /// converts GpuMat to another datatype with scaling (Non-Blocking call) #[inline] - fn empty(&self) -> Result { + fn convert_to_6(&self, dst: &mut impl ToOutputArray, rtype: i32, alpha: f64, beta: f64, stream: &mut impl core::StreamTrait) -> Result<()> { + output_array_arg!(dst); return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_empty_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_convertTo_const_const__OutputArrayR_int_double_double_StreamR(self.as_raw_GpuMat(), dst.as_raw__OutputArray(), rtype, alpha, beta, stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } + /// bindings overload which converts GpuMat to another datatype with scaling (Non-Blocking call) #[inline] - fn cuda_ptr(&self) -> Result<*mut c_void> { + fn convert_to_7(&self, dst: &mut impl core::GpuMatTrait, rtype: i32, alpha: f64, beta: f64, stream: &mut impl core::StreamTrait) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_cudaPtr_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_convertTo_const_GpuMatR_int_double_double_StreamR(self.as_raw_GpuMat(), dst.as_raw_mut_GpuMat(), rtype, alpha, beta, stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - } - - /// Mutable methods for [core::GpuMat] - pub trait GpuMatTrait: core::GpuMatTraitConst { - fn as_raw_mut_GpuMat(&mut self) -> *mut c_void; - - /// ! includes several bit-fields: - /// - the magic signature - /// - continuity flag - /// - depth - /// - number of channels - #[inline] - fn set_flags(&mut self, val: i32) { - let ret = unsafe { sys::cv_cuda_GpuMat_propFlags_const_int(self.as_raw_mut_GpuMat(), val) }; - ret - } - - /// the number of rows and columns - #[inline] - fn set_rows(&mut self, val: i32) { - let ret = unsafe { sys::cv_cuda_GpuMat_propRows_const_int(self.as_raw_mut_GpuMat(), val) }; - ret - } - - /// the number of rows and columns - #[inline] - fn set_cols(&mut self, val: i32) { - let ret = unsafe { sys::cv_cuda_GpuMat_propCols_const_int(self.as_raw_mut_GpuMat(), val) }; - ret - } - - /// a distance between successive rows in bytes; includes the gap if any - #[inline] - fn set_step(&mut self, val: size_t) { - let ret = unsafe { sys::cv_cuda_GpuMat_propStep_const_size_t(self.as_raw_mut_GpuMat(), val) }; - ret - } - - /// pointer to the data - #[inline] - fn data_mut(&mut self) -> *mut u8 { - let ret = unsafe { sys::cv_cuda_GpuMat_propData(self.as_raw_mut_GpuMat()) }; - ret - } - - /// pointer to the data - #[inline] - unsafe fn set_data(&mut self, val: *const u8) { - let ret = { sys::cv_cuda_GpuMat_propData_unsigned_charX(self.as_raw_mut_GpuMat(), val) }; - ret - } - - /// pointer to the reference counter; - /// when GpuMat points to user-allocated data, the pointer is NULL - #[inline] - fn refcount_mut(&mut self) -> *mut i32 { - let ret = unsafe { sys::cv_cuda_GpuMat_propRefcount(self.as_raw_mut_GpuMat()) }; - ret - } - - /// pointer to the reference counter; - /// when GpuMat points to user-allocated data, the pointer is NULL - #[inline] - unsafe fn set_refcount(&mut self, val: *const i32) { - let ret = { sys::cv_cuda_GpuMat_propRefcount_intX(self.as_raw_mut_GpuMat(), val) }; - ret - } - - /// helper fields used in locateROI and adjustROI - #[inline] - fn datastart_mut(&mut self) -> *mut u8 { - let ret = unsafe { sys::cv_cuda_GpuMat_propDatastart(self.as_raw_mut_GpuMat()) }; - ret - } - - /// helper fields used in locateROI and adjustROI - #[inline] - unsafe fn set_datastart(&mut self, val: *const u8) { - let ret = { sys::cv_cuda_GpuMat_propDatastart_unsigned_charX(self.as_raw_mut_GpuMat(), val) }; - ret - } - - /// allocator - #[inline] - fn allocator(&mut self) -> types::AbstractRefMut { - let ret = unsafe { sys::cv_cuda_GpuMat_propAllocator(self.as_raw_mut_GpuMat()) }; - let ret = unsafe { types::AbstractRefMut::::opencv_from_extern(ret) }; - ret - } - - /// allocator - #[inline] - fn set_allocator(&mut self, val: &'static impl core::GpuMat_AllocatorTraitConst) { - let ret = unsafe { sys::cv_cuda_GpuMat_propAllocator_AllocatorX(self.as_raw_mut_GpuMat(), val.as_raw_GpuMat_Allocator()) }; - ret - } - - /// assignment operators + /// ## C++ default parameters + /// * typ: -1 #[inline] - fn set(&mut self, m: &impl core::GpuMatTraitConst) -> Result<()> { + fn assign_to(&self, m: &mut impl core::GpuMatTrait, typ: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_operatorST_const_GpuMatR(self.as_raw_mut_GpuMat(), m.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_assignTo_const_GpuMatR_int(self.as_raw_GpuMat(), m.as_raw_mut_GpuMat(), typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// allocates new GpuMat data unless the GpuMat already has specified size and type + /// ## Note + /// This alternative version of [GpuMatTraitConst::assign_to] function uses the following default values for its arguments: + /// * typ: -1 #[inline] - fn create(&mut self, rows: i32, cols: i32, typ: i32) -> Result<()> { + fn assign_to_def(&self, m: &mut impl core::GpuMatTrait) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_create_int_int_int(self.as_raw_mut_GpuMat(), rows, cols, typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_assignTo_const_GpuMatR(self.as_raw_GpuMat(), m.as_raw_mut_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } + /// ## C++ default parameters + /// * y: 0 #[inline] - fn create_1(&mut self, size: core::Size, typ: i32) -> Result<()> { + fn ptr(&self, y: i32) -> Result<*const u8> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_create_Size_int(self.as_raw_mut_GpuMat(), &size, typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_ptr_const_int(self.as_raw_GpuMat(), y, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// decreases reference counter, deallocate the data when reference counter reaches 0 + /// ## Note + /// This alternative version of [GpuMatTraitConst::ptr] function uses the following default values for its arguments: + /// * y: 0 #[inline] - fn release(&mut self) -> Result<()> { + fn ptr_def(&self) -> Result<*const u8> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_release(self.as_raw_mut_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_ptr_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// swaps with other smart pointer + /// returns a new GpuMat header for the specified row #[inline] - fn swap(&mut self, mat: &mut impl core::GpuMatTrait) -> Result<()> { + fn row(&self, y: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_swap_GpuMatR(self.as_raw_mut_GpuMat(), mat.as_raw_mut_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_row_const_int(self.as_raw_GpuMat(), y, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// Performs data upload to GpuMat (Blocking call) - /// - /// This function copies data from host memory to device memory. As being a blocking call, it is - /// guaranteed that the copy operation is finished when this function returns. + /// returns a new GpuMat header for the specified column #[inline] - fn upload(&mut self, arr: &impl ToInputArray) -> Result<()> { - input_array_arg!(arr); + fn col(&self, x: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_upload_const__InputArrayR(self.as_raw_mut_GpuMat(), arr.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_col_const_int(self.as_raw_GpuMat(), x, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// Performs data upload to GpuMat (Non-Blocking call) - /// - /// This function copies data from host memory to device memory. As being a non-blocking call, this - /// function may return even if the copy operation is not finished. - /// - /// The copy operation may be overlapped with operations in other non-default streams if \p stream is - /// not the default stream and \p dst is HostMem allocated with HostMem::PAGE_LOCKED option. + /// ... for the specified row span #[inline] - fn upload_async(&mut self, arr: &impl ToInputArray, stream: &mut impl core::StreamTrait) -> Result<()> { - input_array_arg!(arr); + fn row_bounds(&self, startrow: i32, endrow: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_upload_const__InputArrayR_StreamR(self.as_raw_mut_GpuMat(), arr.as_raw__InputArray(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_rowRange_const_int_int(self.as_raw_GpuMat(), startrow, endrow, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// sets some of the GpuMat elements to s (Blocking call) #[inline] - fn set_to(&mut self, s: core::Scalar) -> Result { + fn row_range(&self, mut r: impl core::RangeTrait) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_setTo_Scalar(self.as_raw_mut_GpuMat(), &s, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_rowRange_const_Range(self.as_raw_GpuMat(), r.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// sets some of the GpuMat elements to s (Non-Blocking call) + /// ... for the specified column span #[inline] - fn set_to_1(&mut self, s: core::Scalar, stream: &mut impl core::StreamTrait) -> Result { + fn col_bounds(&self, startcol: i32, endcol: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_setTo_Scalar_StreamR(self.as_raw_mut_GpuMat(), &s, stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_colRange_const_int_int(self.as_raw_GpuMat(), startcol, endcol, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// sets some of the GpuMat elements to s, according to the mask (Blocking call) #[inline] - fn set_to_2(&mut self, s: core::Scalar, mask: &impl ToInputArray) -> Result { - input_array_arg!(mask); + fn col_range(&self, mut r: impl core::RangeTrait) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_setTo_Scalar_const__InputArrayR(self.as_raw_mut_GpuMat(), &s, mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_colRange_const_Range(self.as_raw_GpuMat(), r.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// sets some of the GpuMat elements to s, according to the mask (Non-Blocking call) + /// extracts a rectangular sub-GpuMat (this is a generalized form of row, rowRange etc.) #[inline] - fn set_to_3(&mut self, s: core::Scalar, mask: &impl ToInputArray, stream: &mut impl core::StreamTrait) -> Result { - input_array_arg!(mask); + fn rowscols(&self, mut row_range: impl core::RangeTrait, mut col_range: impl core::RangeTrait) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_setTo_Scalar_const__InputArrayR_StreamR(self.as_raw_mut_GpuMat(), &s, mask.as_raw__InputArray(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_operator___const_Range_Range(self.as_raw_GpuMat(), row_range.as_raw_mut_Range(), col_range.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// returns pointer to y-th row - /// - /// ## C++ default parameters - /// * y: 0 #[inline] - fn ptr_mut(&mut self, y: i32) -> Result<*mut u8> { + fn roi(&self, roi: core::Rect) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_ptr_int(self.as_raw_mut_GpuMat(), y, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_operator___const_Rect(self.as_raw_GpuMat(), &roi, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// returns pointer to y-th row + /// creates alternative GpuMat header for the same data, with different + /// number of channels and/or different number of rows /// - /// ## Note - /// This alternative version of [GpuMatTrait::ptr_mut] function uses the following default values for its arguments: - /// * y: 0 + /// ## C++ default parameters + /// * rows: 0 #[inline] - fn ptr_mut_def(&mut self) -> Result<*mut u8> { + fn reshape(&self, cn: i32, rows: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_ptr(self.as_raw_mut_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_reshape_const_int_int(self.as_raw_GpuMat(), cn, rows, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// returns a new GpuMat header for the specified row + /// creates alternative GpuMat header for the same data, with different + /// number of channels and/or different number of rows + /// + /// ## Note + /// This alternative version of [GpuMatTraitConst::reshape] function uses the following default values for its arguments: + /// * rows: 0 #[inline] - fn row_mut(&mut self, y: i32) -> Result> { + fn reshape_def(&self, cn: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_row_int(self.as_raw_mut_GpuMat(), y, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_reshape_const_int(self.as_raw_GpuMat(), cn, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; Ok(ret) } - /// returns a new GpuMat header for the specified column + /// locates GpuMat header within a parent GpuMat #[inline] - fn col_mut(&mut self, x: i32) -> Result> { + fn locate_roi(&self, whole_size: &mut core::Size, ofs: &mut core::Point) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_col_int(self.as_raw_mut_GpuMat(), x, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_locateROI_const_SizeR_PointR(self.as_raw_GpuMat(), whole_size, ofs, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// ... for the specified row span + /// returns true iff the GpuMat data is continuous + /// (i.e. when there are no gaps between successive rows) #[inline] - fn row_bounds_mut(&mut self, startrow: i32, endrow: i32) -> Result> { + fn is_continuous(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_rowRange_int_int(self.as_raw_mut_GpuMat(), startrow, endrow, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_isContinuous_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } + /// returns element size in bytes #[inline] - fn row_range_mut(&mut self, mut r: impl core::RangeTrait) -> Result> { + fn elem_size(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_rowRange_Range(self.as_raw_mut_GpuMat(), r.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_elemSize_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// ... for the specified column span + /// returns the size of element channel in bytes #[inline] - fn col_bounds_mut(&mut self, startcol: i32, endcol: i32) -> Result> { + fn elem_size1(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_colRange_int_int(self.as_raw_mut_GpuMat(), startcol, endcol, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_elemSize1_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } + /// returns element type #[inline] - fn col_range_mut(&mut self, mut r: impl core::RangeTrait) -> Result> { + fn typ(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_colRange_Range(self.as_raw_mut_GpuMat(), r.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_type_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// extracts a rectangular sub-GpuMat (this is a generalized form of row, rowRange etc.) + /// returns element type #[inline] - fn rowscols_mut(&mut self, mut row_range: impl core::RangeTrait, mut col_range: impl core::RangeTrait) -> Result> { + fn depth(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_operator___Range_Range(self.as_raw_mut_GpuMat(), row_range.as_raw_mut_Range(), col_range.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_depth_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } + /// returns number of channels #[inline] - fn roi_mut(&mut self, roi: core::Rect) -> Result> { + fn channels(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_operator___Rect(self.as_raw_mut_GpuMat(), &roi, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_channels_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// creates alternative GpuMat header for the same data, with different - /// number of channels and/or different number of rows - /// - /// ## Note - /// This alternative version of [GpuMatTraitConst::reshape] function uses the following default values for its arguments: - /// * rows: 0 + /// returns step/elemSize1() #[inline] - fn reshape_def_mut(&mut self, cn: i32) -> Result> { + fn step1(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_reshape_int(self.as_raw_mut_GpuMat(), cn, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_step1_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// creates alternative GpuMat header for the same data, with different - /// number of channels and/or different number of rows - /// - /// ## C++ default parameters - /// * rows: 0 + /// returns GpuMat size : width == number of columns, height == number of rows #[inline] - fn reshape_mut(&mut self, cn: i32, rows: i32) -> Result> { + fn size(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_reshape_int_int(self.as_raw_mut_GpuMat(), cn, rows, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_size_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// moves/resizes the current GpuMat ROI inside the parent GpuMat + /// returns true if GpuMat data is NULL #[inline] - fn adjust_roi(&mut self, dtop: i32, dbottom: i32, dleft: i32, dright: i32) -> Result { + fn empty(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_adjustROI_int_int_int_int(self.as_raw_mut_GpuMat(), dtop, dbottom, dleft, dright, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_empty_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// internal use method: updates the continuity flag #[inline] - fn update_continuity_flag(&mut self) -> Result<()> { + fn cuda_ptr(&self) -> Result<*mut c_void> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_updateContinuityFlag(self.as_raw_mut_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_cudaPtr_const(self.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -32470,366 +32425,388 @@ pub mod core { } - /// Base storage class for GPU memory with reference counting. - /// - /// Its interface matches the Mat interface with the following limitations: - /// - /// * no arbitrary dimensions support (only 2D) - /// * no functions that return references to their data (because references on GPU are not valid for - /// CPU) - /// * no expression templates technique support - /// - /// Beware that the latter limitation may lead to overloaded matrix operators that cause memory - /// allocations. The GpuMat class is convertible to cuda::PtrStepSz and cuda::PtrStep so it can be - /// passed directly to the kernel. - /// - /// - /// Note: In contrast with Mat, in most cases GpuMat::isContinuous() == false . This means that rows are - /// aligned to a size depending on the hardware. Single-row GpuMat is always a continuous matrix. - /// - /// - /// Note: You are not recommended to leave static or global GpuMat variables allocated, that is, to rely - /// on its destructor. The destruction order of such variables and CUDA context is undefined. GPU memory - /// release function returns error if the CUDA context has been destroyed before. - /// - /// Some member functions are described as a "Blocking Call" while some are described as a - /// "Non-Blocking Call". Blocking functions are synchronous to host. It is guaranteed that the GPU - /// operation is finished when the function returns. However, non-blocking functions are asynchronous to - /// host. Those functions may return even if the GPU operation is not finished. - /// - /// Compared to their blocking counterpart, non-blocking functions accept Stream as an additional - /// argument. If a non-default stream is passed, the GPU operation may overlap with operations in other - /// streams. - /// ## See also - /// Mat - pub struct GpuMat { - ptr: *mut c_void, - } + /// Mutable methods for [core::GpuMat] + pub trait GpuMatTrait: core::GpuMatTraitConst { + fn as_raw_mut_GpuMat(&mut self) -> *mut c_void; - opencv_type_boxed! { GpuMat } + /// ! includes several bit-fields: + /// - the magic signature + /// - continuity flag + /// - depth + /// - number of channels + #[inline] + fn set_flags(&mut self, val: i32) { + let ret = unsafe { sys::cv_cuda_GpuMat_propFlags_const_int(self.as_raw_mut_GpuMat(), val) }; + ret + } - impl Drop for GpuMat { + /// the number of rows and columns #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_GpuMat_delete(self.as_raw_mut_GpuMat()) }; + fn set_rows(&mut self, val: i32) { + let ret = unsafe { sys::cv_cuda_GpuMat_propRows_const_int(self.as_raw_mut_GpuMat(), val) }; + ret } - } - unsafe impl Send for GpuMat {} + /// the number of rows and columns + #[inline] + fn set_cols(&mut self, val: i32) { + let ret = unsafe { sys::cv_cuda_GpuMat_propCols_const_int(self.as_raw_mut_GpuMat(), val) }; + ret + } - impl core::GpuMatTraitConst for GpuMat { - #[inline] fn as_raw_GpuMat(&self) -> *const c_void { self.as_raw() } - } + /// a distance between successive rows in bytes; includes the gap if any + #[inline] + fn set_step(&mut self, val: size_t) { + let ret = unsafe { sys::cv_cuda_GpuMat_propStep_const_size_t(self.as_raw_mut_GpuMat(), val) }; + ret + } - impl core::GpuMatTrait for GpuMat { - #[inline] fn as_raw_mut_GpuMat(&mut self) -> *mut c_void { self.as_raw_mut() } - } + /// pointer to the data + #[inline] + fn data_mut(&mut self) -> *mut u8 { + let ret = unsafe { sys::cv_cuda_GpuMat_propData(self.as_raw_mut_GpuMat()) }; + ret + } - boxed_ref! { GpuMat, core::GpuMatTraitConst, as_raw_GpuMat, core::GpuMatTrait, as_raw_mut_GpuMat } + /// pointer to the data + #[inline] + unsafe fn set_data(&mut self, val: *const u8) { + let ret = { sys::cv_cuda_GpuMat_propData_unsigned_charX(self.as_raw_mut_GpuMat(), val) }; + ret + } - impl GpuMat { - /// default allocator + /// pointer to the reference counter; + /// when GpuMat points to user-allocated data, the pointer is NULL #[inline] - pub fn default_allocator() -> Result> { + fn refcount_mut(&mut self) -> *mut i32 { + let ret = unsafe { sys::cv_cuda_GpuMat_propRefcount(self.as_raw_mut_GpuMat()) }; + ret + } + + /// pointer to the reference counter; + /// when GpuMat points to user-allocated data, the pointer is NULL + #[inline] + unsafe fn set_refcount(&mut self, val: *const i32) { + let ret = { sys::cv_cuda_GpuMat_propRefcount_intX(self.as_raw_mut_GpuMat(), val) }; + ret + } + + /// helper fields used in locateROI and adjustROI + #[inline] + fn datastart_mut(&mut self) -> *mut u8 { + let ret = unsafe { sys::cv_cuda_GpuMat_propDatastart(self.as_raw_mut_GpuMat()) }; + ret + } + + /// helper fields used in locateROI and adjustROI + #[inline] + unsafe fn set_datastart(&mut self, val: *const u8) { + let ret = { sys::cv_cuda_GpuMat_propDatastart_unsigned_charX(self.as_raw_mut_GpuMat(), val) }; + ret + } + + /// allocator + #[inline] + fn allocator(&mut self) -> types::AbstractRefMut { + let ret = unsafe { sys::cv_cuda_GpuMat_propAllocator(self.as_raw_mut_GpuMat()) }; + let ret = unsafe { types::AbstractRefMut::::opencv_from_extern(ret) }; + ret + } + + /// allocator + #[inline] + fn set_allocator(&mut self, val: &'static impl core::GpuMat_AllocatorTraitConst) { + let ret = unsafe { sys::cv_cuda_GpuMat_propAllocator_AllocatorX(self.as_raw_mut_GpuMat(), val.as_raw_GpuMat_Allocator()) }; + ret + } + + /// assignment operators + #[inline] + fn set(&mut self, m: &impl core::GpuMatTraitConst) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_defaultAllocator(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_operatorST_const_GpuMatR(self.as_raw_mut_GpuMat(), m.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { types::AbstractRefMut::<'static, core::GpuMat_Allocator>::opencv_from_extern(ret) }; Ok(ret) } + /// allocates new GpuMat data unless the GpuMat already has specified size and type #[inline] - pub fn set_default_allocator(allocator: &'static mut impl core::GpuMat_AllocatorTrait) -> Result<()> { + fn create(&mut self, rows: i32, cols: i32, typ: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_setDefaultAllocator_AllocatorX(allocator.as_raw_mut_GpuMat_Allocator(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_create_int_int_int(self.as_raw_mut_GpuMat(), rows, cols, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - pub fn get_std_allocator() -> Result> { + fn create_1(&mut self, size: core::Size, typ: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_getStdAllocator(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_create_Size_int(self.as_raw_mut_GpuMat(), &size, typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// decreases reference counter, deallocate the data when reference counter reaches 0 + #[inline] + fn release(&mut self) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_GpuMat_release(self.as_raw_mut_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { types::AbstractRefMut::<'static, core::GpuMat_Allocator>::opencv_from_extern(ret) }; Ok(ret) } - /// default constructor - /// - /// ## C++ default parameters - /// * allocator: GpuMat::defaultAllocator() + /// swaps with other smart pointer #[inline] - pub unsafe fn new(allocator: &mut impl core::GpuMat_AllocatorTrait) -> Result { + fn swap(&mut self, mat: &mut impl core::GpuMatTrait) -> Result<()> { return_send!(via ocvrs_return); - { sys::cv_cuda_GpuMat_GpuMat_AllocatorX(allocator.as_raw_mut_GpuMat_Allocator(), ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_cuda_GpuMat_swap_GpuMatR(self.as_raw_mut_GpuMat(), mat.as_raw_mut_GpuMat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// default constructor + /// Performs data upload to GpuMat (Blocking call) /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * allocator: GpuMat::defaultAllocator() + /// This function copies data from host memory to device memory. As being a blocking call, it is + /// guaranteed that the copy operation is finished when this function returns. #[inline] - pub fn new_def() -> Result { + fn upload(&mut self, arr: &impl ToInputArray) -> Result<()> { + input_array_arg!(arr); return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_GpuMat(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_upload_const__InputArrayR(self.as_raw_mut_GpuMat(), arr.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// constructs GpuMat of the specified size and type + /// Performs data upload to GpuMat (Non-Blocking call) /// - /// ## C++ default parameters - /// * allocator: GpuMat::defaultAllocator() + /// This function copies data from host memory to device memory. As being a non-blocking call, this + /// function may return even if the copy operation is not finished. + /// + /// The copy operation may be overlapped with operations in other non-default streams if \p stream is + /// not the default stream and \p dst is HostMem allocated with HostMem::PAGE_LOCKED option. #[inline] - pub unsafe fn new_rows_cols(rows: i32, cols: i32, typ: i32, allocator: &mut impl core::GpuMat_AllocatorTrait) -> Result { + fn upload_async(&mut self, arr: &impl ToInputArray, stream: &mut impl core::StreamTrait) -> Result<()> { + input_array_arg!(arr); return_send!(via ocvrs_return); - { sys::cv_cuda_GpuMat_GpuMat_int_int_int_AllocatorX(rows, cols, typ, allocator.as_raw_mut_GpuMat_Allocator(), ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_cuda_GpuMat_upload_const__InputArrayR_StreamR(self.as_raw_mut_GpuMat(), arr.as_raw__InputArray(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// constructs GpuMat of the specified size and type - /// - /// ## Note - /// This alternative version of [new_rows_cols] function uses the following default values for its arguments: - /// * allocator: GpuMat::defaultAllocator() + /// sets some of the GpuMat elements to s (Blocking call) #[inline] - pub fn new_rows_cols_def(rows: i32, cols: i32, typ: i32) -> Result { + fn set_to(&mut self, s: core::Scalar) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_GpuMat_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_setTo_Scalar(self.as_raw_mut_GpuMat(), &s, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// ## C++ default parameters - /// * allocator: GpuMat::defaultAllocator() + /// sets some of the GpuMat elements to s (Non-Blocking call) #[inline] - pub unsafe fn new_size(size: core::Size, typ: i32, allocator: &mut impl core::GpuMat_AllocatorTrait) -> Result { + fn set_to_1(&mut self, s: core::Scalar, stream: &mut impl core::StreamTrait) -> Result { return_send!(via ocvrs_return); - { sys::cv_cuda_GpuMat_GpuMat_Size_int_AllocatorX(&size, typ, allocator.as_raw_mut_GpuMat_Allocator(), ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_cuda_GpuMat_setTo_Scalar_StreamR(self.as_raw_mut_GpuMat(), &s, stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::GpuMat::opencv_from_extern(ret) }; + let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [new_size] function uses the following default values for its arguments: - /// * allocator: GpuMat::defaultAllocator() + /// sets some of the GpuMat elements to s, according to the mask (Blocking call) #[inline] - pub fn new_size_def(size: core::Size, typ: i32) -> Result { + fn set_to_2(&mut self, s: core::Scalar, mask: &impl ToInputArray) -> Result { + input_array_arg!(mask); return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_GpuMat_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_setTo_Scalar_const__InputArrayR(self.as_raw_mut_GpuMat(), &s, mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// constructs GpuMat and fills it with the specified value _s - /// - /// ## C++ default parameters - /// * allocator: GpuMat::defaultAllocator() + /// sets some of the GpuMat elements to s, according to the mask (Non-Blocking call) #[inline] - pub unsafe fn new_rows_cols_with_default(rows: i32, cols: i32, typ: i32, s: core::Scalar, allocator: &mut impl core::GpuMat_AllocatorTrait) -> Result { + fn set_to_3(&mut self, s: core::Scalar, mask: &impl ToInputArray, stream: &mut impl core::StreamTrait) -> Result { + input_array_arg!(mask); return_send!(via ocvrs_return); - { sys::cv_cuda_GpuMat_GpuMat_int_int_int_Scalar_AllocatorX(rows, cols, typ, &s, allocator.as_raw_mut_GpuMat_Allocator(), ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_cuda_GpuMat_setTo_Scalar_const__InputArrayR_StreamR(self.as_raw_mut_GpuMat(), &s, mask.as_raw__InputArray(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::GpuMat::opencv_from_extern(ret) }; + let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// constructs GpuMat and fills it with the specified value _s + /// returns pointer to y-th row /// - /// ## Note - /// This alternative version of [new_rows_cols_with_default] function uses the following default values for its arguments: - /// * allocator: GpuMat::defaultAllocator() + /// ## C++ default parameters + /// * y: 0 #[inline] - pub fn new_rows_cols_with_default_def(rows: i32, cols: i32, typ: i32, s: core::Scalar) -> Result { + fn ptr_mut(&mut self, y: i32) -> Result<*mut u8> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_GpuMat_int_int_int_Scalar(rows, cols, typ, &s, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_ptr_int(self.as_raw_mut_GpuMat(), y, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// ## C++ default parameters - /// * allocator: GpuMat::defaultAllocator() + /// returns pointer to y-th row + /// + /// ## Note + /// This alternative version of [GpuMatTrait::ptr_mut] function uses the following default values for its arguments: + /// * y: 0 #[inline] - pub unsafe fn new_size_with_default(size: core::Size, typ: i32, s: core::Scalar, allocator: &mut impl core::GpuMat_AllocatorTrait) -> Result { + fn ptr_mut_def(&mut self) -> Result<*mut u8> { return_send!(via ocvrs_return); - { sys::cv_cuda_GpuMat_GpuMat_Size_int_Scalar_AllocatorX(&size, typ, &s, allocator.as_raw_mut_GpuMat_Allocator(), ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_cuda_GpuMat_ptr(self.as_raw_mut_GpuMat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [new_size_with_default] function uses the following default values for its arguments: - /// * allocator: GpuMat::defaultAllocator() + /// returns a new GpuMat header for the specified row #[inline] - pub fn new_size_with_default_def(size: core::Size, typ: i32, s: core::Scalar) -> Result { + fn row_mut(&mut self, y: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_GpuMat_Size_int_Scalar(&size, typ, &s, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_row_int(self.as_raw_mut_GpuMat(), y, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// copy constructor + /// returns a new GpuMat header for the specified column #[inline] - pub fn copy(m: &impl core::GpuMatTraitConst) -> Result { + fn col_mut(&mut self, x: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_GpuMat_const_GpuMatR(m.as_raw_GpuMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_col_int(self.as_raw_mut_GpuMat(), x, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// constructor for GpuMat headers pointing to user-allocated data - /// - /// ## C++ default parameters - /// * step: Mat::AUTO_STEP + /// ... for the specified row span #[inline] - pub unsafe fn new_rows_cols_with_data(rows: i32, cols: i32, typ: i32, data: *mut c_void, step: size_t) -> Result { + fn row_bounds_mut(&mut self, startrow: i32, endrow: i32) -> Result> { return_send!(via ocvrs_return); - { sys::cv_cuda_GpuMat_GpuMat_int_int_int_voidX_size_t(rows, cols, typ, data, step, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_cuda_GpuMat_rowRange_int_int(self.as_raw_mut_GpuMat(), startrow, endrow, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::GpuMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// constructor for GpuMat headers pointing to user-allocated data - /// - /// ## Note - /// This alternative version of [new_rows_cols_with_data] function uses the following default values for its arguments: - /// * step: Mat::AUTO_STEP #[inline] - pub unsafe fn new_rows_cols_with_data_def(rows: i32, cols: i32, typ: i32, data: *mut c_void) -> Result { + fn row_range_mut(&mut self, mut r: impl core::RangeTrait) -> Result> { return_send!(via ocvrs_return); - { sys::cv_cuda_GpuMat_GpuMat_int_int_int_voidX(rows, cols, typ, data, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_cuda_GpuMat_rowRange_Range(self.as_raw_mut_GpuMat(), r.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::GpuMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// ## C++ default parameters - /// * step: Mat::AUTO_STEP + /// ... for the specified column span #[inline] - pub unsafe fn new_size_with_data(size: core::Size, typ: i32, data: *mut c_void, step: size_t) -> Result { + fn col_bounds_mut(&mut self, startcol: i32, endcol: i32) -> Result> { return_send!(via ocvrs_return); - { sys::cv_cuda_GpuMat_GpuMat_Size_int_voidX_size_t(&size, typ, data, step, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_cuda_GpuMat_colRange_int_int(self.as_raw_mut_GpuMat(), startcol, endcol, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::GpuMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [new_size_with_data] function uses the following default values for its arguments: - /// * step: Mat::AUTO_STEP #[inline] - pub unsafe fn new_size_with_data_def(size: core::Size, typ: i32, data: *mut c_void) -> Result { + fn col_range_mut(&mut self, mut r: impl core::RangeTrait) -> Result> { return_send!(via ocvrs_return); - { sys::cv_cuda_GpuMat_GpuMat_Size_int_voidX(&size, typ, data, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_cuda_GpuMat_colRange_Range(self.as_raw_mut_GpuMat(), r.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::GpuMat::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// creates a GpuMat header for a part of the bigger matrix + /// extracts a rectangular sub-GpuMat (this is a generalized form of row, rowRange etc.) #[inline] - pub fn rowscols(m: &impl core::GpuMatTraitConst, mut row_range: impl core::RangeTrait, mut col_range: impl core::RangeTrait) -> Result> { + fn rowscols_mut(&mut self, mut row_range: impl core::RangeTrait, mut col_range: impl core::RangeTrait) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_GpuMat_const_GpuMatR_Range_Range(m.as_raw_GpuMat(), row_range.as_raw_mut_Range(), col_range.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_operator___Range_Range(self.as_raw_mut_GpuMat(), row_range.as_raw_mut_Range(), col_range.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// creates a GpuMat header for a part of the bigger matrix #[inline] - pub fn rowscols_mut(m: &mut impl core::GpuMatTrait, mut row_range: impl core::RangeTrait, mut col_range: impl core::RangeTrait) -> Result> { + fn roi_mut(&mut self, roi: core::Rect) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_GpuMat_GpuMatR_Range_Range(m.as_raw_mut_GpuMat(), row_range.as_raw_mut_Range(), col_range.as_raw_mut_Range(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_operator___Rect(self.as_raw_mut_GpuMat(), &roi, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } + /// creates alternative GpuMat header for the same data, with different + /// number of channels and/or different number of rows + /// + /// ## Note + /// This alternative version of [GpuMatTraitConst::reshape] function uses the following default values for its arguments: + /// * rows: 0 #[inline] - pub fn roi(m: &impl core::GpuMatTraitConst, roi: core::Rect) -> Result> { + fn reshape_def_mut(&mut self, cn: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_GpuMat_const_GpuMatR_Rect(m.as_raw_GpuMat(), &roi, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_reshape_int(self.as_raw_mut_GpuMat(), cn, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { BoxedRef::::opencv_from_extern(ret) }; + let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } + /// creates alternative GpuMat header for the same data, with different + /// number of channels and/or different number of rows + /// + /// ## C++ default parameters + /// * rows: 0 #[inline] - pub fn roi_mut(m: &mut impl core::GpuMatTrait, roi: core::Rect) -> Result> { + fn reshape_mut(&mut self, cn: i32, rows: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_GpuMat_GpuMatR_Rect(m.as_raw_mut_GpuMat(), &roi, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_reshape_int_int(self.as_raw_mut_GpuMat(), cn, rows, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { BoxedRefMut::::opencv_from_extern(ret) }; Ok(ret) } - /// builds GpuMat from host memory (Blocking call) - /// - /// ## C++ default parameters - /// * allocator: GpuMat::defaultAllocator() + /// moves/resizes the current GpuMat ROI inside the parent GpuMat #[inline] - pub unsafe fn from_hostmem(arr: &impl ToInputArray, allocator: &mut impl core::GpuMat_AllocatorTrait) -> Result { - input_array_arg!(arr); + fn adjust_roi(&mut self, dtop: i32, dbottom: i32, dleft: i32, dright: i32) -> Result { return_send!(via ocvrs_return); - { sys::cv_cuda_GpuMat_GpuMat_const__InputArrayR_AllocatorX(arr.as_raw__InputArray(), allocator.as_raw_mut_GpuMat_Allocator(), ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_cuda_GpuMat_adjustROI_int_int_int_int(self.as_raw_mut_GpuMat(), dtop, dbottom, dleft, dright, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::GpuMat::opencv_from_extern(ret) }; + let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// builds GpuMat from host memory (Blocking call) - /// - /// ## Note - /// This alternative version of [from_hostmem] function uses the following default values for its arguments: - /// * allocator: GpuMat::defaultAllocator() + /// internal use method: updates the continuity flag #[inline] - pub fn from_hostmem_def(arr: &impl ToInputArray) -> Result { - input_array_arg!(arr); + fn update_continuity_flag(&mut self) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMat_GpuMat_const__InputArrayR(arr.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_GpuMat_updateContinuityFlag(self.as_raw_mut_GpuMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } @@ -32859,6 +32836,31 @@ pub mod core { } } + impl core::GpuMatTraitConst for GpuMat { + #[inline] fn as_raw_GpuMat(&self) -> *const c_void { self.as_raw() } + } + + impl core::GpuMatTrait for GpuMat { + #[inline] fn as_raw_mut_GpuMat(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { GpuMat, core::GpuMatTraitConst, as_raw_GpuMat, core::GpuMatTrait, as_raw_mut_GpuMat } + + pub struct GpuMat_Allocator { + ptr: *mut c_void, + } + + opencv_type_boxed! { GpuMat_Allocator } + + impl Drop for GpuMat_Allocator { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_GpuMat_Allocator_delete(self.as_raw_mut_GpuMat_Allocator()) }; + } + } + + unsafe impl Send for GpuMat_Allocator {} + /// Constant methods for [core::GpuMat_Allocator] pub trait GpuMat_AllocatorTraitConst { fn as_raw_GpuMat_Allocator(&self) -> *const c_void; @@ -32889,21 +32891,14 @@ pub mod core { } - pub struct GpuMat_Allocator { - ptr: *mut c_void, - } - - opencv_type_boxed! { GpuMat_Allocator } - - impl Drop for GpuMat_Allocator { + impl std::fmt::Debug for GpuMat_Allocator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_GpuMat_Allocator_delete(self.as_raw_mut_GpuMat_Allocator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GpuMat_Allocator") + .finish() } } - unsafe impl Send for GpuMat_Allocator {} - impl core::GpuMat_AllocatorTraitConst for GpuMat_Allocator { #[inline] fn as_raw_GpuMat_Allocator(&self) -> *const c_void { self.as_raw() } } @@ -32914,15 +32909,121 @@ pub mod core { boxed_ref! { GpuMat_Allocator, core::GpuMat_AllocatorTraitConst, as_raw_GpuMat_Allocator, core::GpuMat_AllocatorTrait, as_raw_mut_GpuMat_Allocator } - impl GpuMat_Allocator { + pub struct GpuMatND { + ptr: *mut c_void, } - impl std::fmt::Debug for GpuMat_Allocator { + opencv_type_boxed! { GpuMatND } + + impl Drop for GpuMatND { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GpuMat_Allocator") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cuda_GpuMatND_delete(self.as_raw_mut_GpuMatND()) }; + } + } + + unsafe impl Send for GpuMatND {} + + impl GpuMatND { + /// default constructor + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_GpuMatND_GpuMatND(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::GpuMatND::opencv_from_extern(ret) }; + Ok(ret) + } + + /// default constructor + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * size: Array of integers specifying an n-dimensional array shape. + /// * type: Array type. Use CV_8UC1, ..., CV_16FC4 to create 1-4 channel matrices, or + /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + #[inline] + pub fn new(mut size: core::GpuMatND_SizeArray, typ: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_GpuMatND_GpuMatND_SizeArray_int(size.as_raw_mut_VectorOfi32(), typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::GpuMatND::opencv_from_extern(ret) }; + Ok(ret) + } + + /// default constructor + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * size: Array of integers specifying an n-dimensional array shape. + /// * type: Array type. Use CV_8UC1, ..., CV_16FC4 to create 1-4 channel matrices, or + /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not + /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified + /// data, which means that no data is copied. This operation is very efficient and can be used to + /// process external data using OpenCV functions. The external data is not automatically deallocated, so + /// you should take care of it. + /// * step: Array of _size.size() or _size.size()-1 steps in case of a multi-dimensional array + /// (if specified, the last step must be equal to the element size, otherwise it will be added as such). + /// If not specified, the matrix is assumed to be continuous. + /// + /// ## C++ default parameters + /// * step: StepArray() + #[inline] + pub unsafe fn new_1(mut size: core::GpuMatND_SizeArray, typ: i32, data: *mut c_void, mut step: core::GpuMatND_StepArray) -> Result { + return_send!(via ocvrs_return); + { sys::cv_cuda_GpuMatND_GpuMatND_SizeArray_int_voidX_StepArray(size.as_raw_mut_VectorOfi32(), typ, data, step.as_raw_mut_VectorOfsize_t(), ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = { core::GpuMatND::opencv_from_extern(ret) }; + Ok(ret) + } + + /// @overload + /// ## Parameters + /// * size: Array of integers specifying an n-dimensional array shape. + /// * type: Array type. Use CV_8UC1, ..., CV_16FC4 to create 1-4 channel matrices, or + /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not + /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified + /// data, which means that no data is copied. This operation is very efficient and can be used to + /// process external data using OpenCV functions. The external data is not automatically deallocated, so + /// you should take care of it. + /// * step: Array of _size.size() or _size.size()-1 steps in case of a multi-dimensional array + /// (if specified, the last step must be equal to the element size, otherwise it will be added as such). + /// If not specified, the matrix is assumed to be continuous. + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * step: StepArray() + #[inline] + pub unsafe fn new_def(mut size: core::GpuMatND_SizeArray, typ: i32, data: *mut c_void) -> Result { + return_send!(via ocvrs_return); + { sys::cv_cuda_GpuMatND_GpuMatND_SizeArray_int_voidX(size.as_raw_mut_VectorOfi32(), typ, data, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = { core::GpuMatND::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn copy(unnamed: &impl core::GpuMatNDTraitConst) -> core::GpuMatND { + let ret = unsafe { sys::cv_cuda_GpuMatND_GpuMatND_const_GpuMatNDR(unnamed.as_raw_GpuMatND()) }; + let ret = unsafe { core::GpuMatND::opencv_from_extern(ret) }; + ret + } + + #[inline] + pub fn copy_mut(mut unnamed: core::GpuMatND) -> core::GpuMatND { + let ret = unsafe { sys::cv_cuda_GpuMatND_GpuMatND_GpuMatNDRR(unnamed.as_raw_mut_GpuMatND()) }; + let ret = unsafe { core::GpuMatND::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [core::GpuMatND] @@ -33368,21 +33469,26 @@ pub mod core { } - pub struct GpuMatND { - ptr: *mut c_void, + impl Clone for GpuMatND { + #[inline] + /// Calls try_clone() and panics if that fails + fn clone(&self) -> Self { + self.try_clone().expect("Cannot clone GpuMatND") + } } - opencv_type_boxed! { GpuMatND } - - impl Drop for GpuMatND { + impl std::fmt::Debug for GpuMatND { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_GpuMatND_delete(self.as_raw_mut_GpuMatND()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GpuMatND") + .field("flags", &core::GpuMatNDTraitConst::flags(self)) + .field("dims", &core::GpuMatNDTraitConst::dims(self)) + .field("size", &core::GpuMatNDTraitConst::size(self)) + .field("step", &core::GpuMatNDTraitConst::step(self)) + .finish() } } - unsafe impl Send for GpuMatND {} - impl core::GpuMatNDTraitConst for GpuMatND { #[inline] fn as_raw_GpuMatND(&self) -> *const c_void { self.as_raw() } } @@ -33393,126 +33499,153 @@ pub mod core { boxed_ref! { GpuMatND, core::GpuMatNDTraitConst, as_raw_GpuMatND, core::GpuMatNDTrait, as_raw_mut_GpuMatND } - impl GpuMatND { - /// default constructor + /// Class with reference counting wrapping special memory type allocation functions from CUDA. + /// + /// Its interface is also Mat-like but with additional memory type parameters. + /// + /// * **PAGE_LOCKED** sets a page locked memory type used commonly for fast and asynchronous + /// uploading/downloading data from/to GPU. + /// * **SHARED** specifies a zero copy memory allocation that enables mapping the host memory to GPU + /// address space, if supported. + /// * **WRITE_COMBINED** sets the write combined buffer that is not cached by CPU. Such buffers are + /// used to supply GPU with data when GPU only reads it. The advantage is a better CPU cache + /// utilization. + /// + /// + /// Note: Allocation size of such memory types is usually limited. For more details, see *CUDA 2.2 + /// Pinned Memory APIs* document or *CUDA C Programming Guide*. + pub struct HostMem { + ptr: *mut c_void, + } + + opencv_type_boxed! { HostMem } + + impl Drop for HostMem { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_HostMem_delete(self.as_raw_mut_HostMem()) }; + } + } + + unsafe impl Send for HostMem {} + + impl HostMem { + /// ## C++ default parameters + /// * alloc_type: HostMem::AllocType::PAGE_LOCKED + #[inline] + pub fn new(alloc_type: core::HostMem_AllocType) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_HostMem_HostMem_AllocType(alloc_type, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * alloc_type: HostMem::AllocType::PAGE_LOCKED + #[inline] + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_HostMem_HostMem(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn copy(m: &impl core::HostMemTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_HostMem_HostMem_const_HostMemR(m.as_raw_HostMem(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## C++ default parameters + /// * alloc_type: HostMem::AllocType::PAGE_LOCKED + #[inline] + pub fn new_1(rows: i32, cols: i32, typ: i32, alloc_type: core::HostMem_AllocType) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_HostMem_HostMem_int_int_int_AllocType(rows, cols, typ, alloc_type, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * alloc_type: HostMem::AllocType::PAGE_LOCKED + #[inline] + pub fn new_def_1(rows: i32, cols: i32, typ: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_HostMem_HostMem_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## C++ default parameters + /// * alloc_type: HostMem::AllocType::PAGE_LOCKED #[inline] - pub fn default() -> Result { + pub fn new_2(size: core::Size, typ: i32, alloc_type: core::HostMem_AllocType) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMatND_GpuMatND(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_HostMem_HostMem_Size_int_AllocType(&size, typ, alloc_type, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::GpuMatND::opencv_from_extern(ret) }; + let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; Ok(ret) } - /// default constructor - /// - /// ## Overloaded parameters - /// - /// ## Parameters - /// * size: Array of integers specifying an n-dimensional array shape. - /// * type: Array type. Use CV_8UC1, ..., CV_16FC4 to create 1-4 channel matrices, or - /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * alloc_type: HostMem::AllocType::PAGE_LOCKED #[inline] - pub fn new(mut size: core::GpuMatND_SizeArray, typ: i32) -> Result { + pub fn new_def_2(size: core::Size, typ: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_GpuMatND_GpuMatND_SizeArray_int(size.as_raw_mut_VectorOfi32(), typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_HostMem_HostMem_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::GpuMatND::opencv_from_extern(ret) }; + let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; Ok(ret) } - /// default constructor - /// - /// ## Overloaded parameters - /// - /// ## Parameters - /// * size: Array of integers specifying an n-dimensional array shape. - /// * type: Array type. Use CV_8UC1, ..., CV_16FC4 to create 1-4 channel matrices, or - /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. - /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not - /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified - /// data, which means that no data is copied. This operation is very efficient and can be used to - /// process external data using OpenCV functions. The external data is not automatically deallocated, so - /// you should take care of it. - /// * step: Array of _size.size() or _size.size()-1 steps in case of a multi-dimensional array - /// (if specified, the last step must be equal to the element size, otherwise it will be added as such). - /// If not specified, the matrix is assumed to be continuous. + /// creates from host memory with coping data /// /// ## C++ default parameters - /// * step: StepArray() + /// * alloc_type: HostMem::AllocType::PAGE_LOCKED #[inline] - pub unsafe fn new_1(mut size: core::GpuMatND_SizeArray, typ: i32, data: *mut c_void, mut step: core::GpuMatND_StepArray) -> Result { + pub fn new_3(arr: &impl ToInputArray, alloc_type: core::HostMem_AllocType) -> Result { + input_array_arg!(arr); return_send!(via ocvrs_return); - { sys::cv_cuda_GpuMatND_GpuMatND_SizeArray_int_voidX_StepArray(size.as_raw_mut_VectorOfi32(), typ, data, step.as_raw_mut_VectorOfsize_t(), ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_cuda_HostMem_HostMem_const__InputArrayR_AllocType(arr.as_raw__InputArray(), alloc_type, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::GpuMatND::opencv_from_extern(ret) }; + let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; Ok(ret) } - /// @overload - /// ## Parameters - /// * size: Array of integers specifying an n-dimensional array shape. - /// * type: Array type. Use CV_8UC1, ..., CV_16FC4 to create 1-4 channel matrices, or - /// CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. - /// * data: Pointer to the user data. Matrix constructors that take data and step parameters do not - /// allocate matrix data. Instead, they just initialize the matrix header that points to the specified - /// data, which means that no data is copied. This operation is very efficient and can be used to - /// process external data using OpenCV functions. The external data is not automatically deallocated, so - /// you should take care of it. - /// * step: Array of _size.size() or _size.size()-1 steps in case of a multi-dimensional array - /// (if specified, the last step must be equal to the element size, otherwise it will be added as such). - /// If not specified, the matrix is assumed to be continuous. + /// creates from host memory with coping data /// /// ## Note /// This alternative version of [new] function uses the following default values for its arguments: - /// * step: StepArray() + /// * alloc_type: HostMem::AllocType::PAGE_LOCKED #[inline] - pub unsafe fn new_def(mut size: core::GpuMatND_SizeArray, typ: i32, data: *mut c_void) -> Result { + pub fn new_def_3(arr: &impl ToInputArray) -> Result { + input_array_arg!(arr); return_send!(via ocvrs_return); - { sys::cv_cuda_GpuMatND_GpuMatND_SizeArray_int_voidX(size.as_raw_mut_VectorOfi32(), typ, data, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_cuda_HostMem_HostMem_const__InputArrayR(arr.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::GpuMatND::opencv_from_extern(ret) }; + let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; Ok(ret) } - #[inline] - pub fn copy(unnamed: &impl core::GpuMatNDTraitConst) -> core::GpuMatND { - let ret = unsafe { sys::cv_cuda_GpuMatND_GpuMatND_const_GpuMatNDR(unnamed.as_raw_GpuMatND()) }; - let ret = unsafe { core::GpuMatND::opencv_from_extern(ret) }; - ret - } - - #[inline] - pub fn copy_mut(mut unnamed: core::GpuMatND) -> core::GpuMatND { - let ret = unsafe { sys::cv_cuda_GpuMatND_GpuMatND_GpuMatNDRR(unnamed.as_raw_mut_GpuMatND()) }; - let ret = unsafe { core::GpuMatND::opencv_from_extern(ret) }; - ret - } - - } - - impl Clone for GpuMatND { - #[inline] - /// Calls try_clone() and panics if that fails - fn clone(&self) -> Self { - self.try_clone().expect("Cannot clone GpuMatND") - } - } - - impl std::fmt::Debug for GpuMatND { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GpuMatND") - .field("flags", &core::GpuMatNDTraitConst::flags(self)) - .field("dims", &core::GpuMatNDTraitConst::dims(self)) - .field("size", &core::GpuMatNDTraitConst::size(self)) - .field("step", &core::GpuMatNDTraitConst::step(self)) - .finish() - } } /// Constant methods for [core::HostMem] @@ -33818,189 +33951,30 @@ pub mod core { /// allocates new matrix data unless the matrix already has specified size and type. #[inline] - fn create(&mut self, rows: i32, cols: i32, typ: i32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_HostMem_create_int_int_int(self.as_raw_mut_HostMem(), rows, cols, typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn create_1(&mut self, size: core::Size, typ: i32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_HostMem_create_Size_int(self.as_raw_mut_HostMem(), &size, typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// decrements reference counter and released memory if needed. - #[inline] - fn release(&mut self) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_HostMem_release(self.as_raw_mut_HostMem(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - /// Class with reference counting wrapping special memory type allocation functions from CUDA. - /// - /// Its interface is also Mat-like but with additional memory type parameters. - /// - /// * **PAGE_LOCKED** sets a page locked memory type used commonly for fast and asynchronous - /// uploading/downloading data from/to GPU. - /// * **SHARED** specifies a zero copy memory allocation that enables mapping the host memory to GPU - /// address space, if supported. - /// * **WRITE_COMBINED** sets the write combined buffer that is not cached by CPU. Such buffers are - /// used to supply GPU with data when GPU only reads it. The advantage is a better CPU cache - /// utilization. - /// - /// - /// Note: Allocation size of such memory types is usually limited. For more details, see *CUDA 2.2 - /// Pinned Memory APIs* document or *CUDA C Programming Guide*. - pub struct HostMem { - ptr: *mut c_void, - } - - opencv_type_boxed! { HostMem } - - impl Drop for HostMem { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_HostMem_delete(self.as_raw_mut_HostMem()) }; - } - } - - unsafe impl Send for HostMem {} - - impl core::HostMemTraitConst for HostMem { - #[inline] fn as_raw_HostMem(&self) -> *const c_void { self.as_raw() } - } - - impl core::HostMemTrait for HostMem { - #[inline] fn as_raw_mut_HostMem(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { HostMem, core::HostMemTraitConst, as_raw_HostMem, core::HostMemTrait, as_raw_mut_HostMem } - - impl HostMem { - /// ## C++ default parameters - /// * alloc_type: HostMem::AllocType::PAGE_LOCKED - #[inline] - pub fn new(alloc_type: core::HostMem_AllocType) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_HostMem_HostMem_AllocType(alloc_type, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * alloc_type: HostMem::AllocType::PAGE_LOCKED - #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_HostMem_HostMem(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn copy(m: &impl core::HostMemTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_HostMem_HostMem_const_HostMemR(m.as_raw_HostMem(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## C++ default parameters - /// * alloc_type: HostMem::AllocType::PAGE_LOCKED - #[inline] - pub fn new_1(rows: i32, cols: i32, typ: i32, alloc_type: core::HostMem_AllocType) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_HostMem_HostMem_int_int_int_AllocType(rows, cols, typ, alloc_type, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * alloc_type: HostMem::AllocType::PAGE_LOCKED - #[inline] - pub fn new_def_1(rows: i32, cols: i32, typ: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_HostMem_HostMem_int_int_int(rows, cols, typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## C++ default parameters - /// * alloc_type: HostMem::AllocType::PAGE_LOCKED - #[inline] - pub fn new_2(size: core::Size, typ: i32, alloc_type: core::HostMem_AllocType) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_HostMem_HostMem_Size_int_AllocType(&size, typ, alloc_type, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * alloc_type: HostMem::AllocType::PAGE_LOCKED - #[inline] - pub fn new_def_2(size: core::Size, typ: i32) -> Result { + fn create(&mut self, rows: i32, cols: i32, typ: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_HostMem_HostMem_Size_int(&size, typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_HostMem_create_int_int_int(self.as_raw_mut_HostMem(), rows, cols, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; Ok(ret) } - /// creates from host memory with coping data - /// - /// ## C++ default parameters - /// * alloc_type: HostMem::AllocType::PAGE_LOCKED #[inline] - pub fn new_3(arr: &impl ToInputArray, alloc_type: core::HostMem_AllocType) -> Result { - input_array_arg!(arr); + fn create_1(&mut self, size: core::Size, typ: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_HostMem_HostMem_const__InputArrayR_AllocType(arr.as_raw__InputArray(), alloc_type, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_HostMem_create_Size_int(self.as_raw_mut_HostMem(), &size, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; Ok(ret) } - /// creates from host memory with coping data - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * alloc_type: HostMem::AllocType::PAGE_LOCKED + /// decrements reference counter and released memory if needed. #[inline] - pub fn new_def_3(arr: &impl ToInputArray) -> Result { - input_array_arg!(arr); + fn release(&mut self) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_HostMem_HostMem_const__InputArrayR(arr.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_HostMem_release(self.as_raw_mut_HostMem(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::HostMem::opencv_from_extern(ret) }; Ok(ret) } @@ -34031,77 +34005,16 @@ pub mod core { } } - /// Constant methods for [core::Stream] - pub trait StreamTraitConst { - fn as_raw_Stream(&self) -> *const c_void; - - /// Returns true if the current stream queue is finished. Otherwise, it returns false. - #[inline] - fn query_if_complete(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_Stream_queryIfComplete_const(self.as_raw_Stream(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// return Pointer to CUDA stream - #[inline] - fn cuda_ptr(&self) -> Result<*mut c_void> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_Stream_cudaPtr_const(self.as_raw_Stream(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - + impl core::HostMemTraitConst for HostMem { + #[inline] fn as_raw_HostMem(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [core::Stream] - pub trait StreamTrait: core::StreamTraitConst { - fn as_raw_mut_Stream(&mut self) -> *mut c_void; - - /// Blocks the current CPU thread until all operations in the stream are complete. - #[inline] - fn wait_for_completion(&mut self) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_Stream_waitForCompletion(self.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Makes a compute stream wait on an event. - #[inline] - fn wait_event(&mut self, event: &impl core::EventTraitConst) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_Stream_waitEvent_const_EventR(self.as_raw_mut_Stream(), event.as_raw_Event(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Adds a callback to be called on the host after all currently enqueued items in the stream have - /// completed. - /// - /// - /// Note: Callbacks must not make any CUDA API calls. Callbacks must not perform any synchronization - /// that may depend on outstanding device work or other callbacks that are not mandated to run earlier. - /// Callbacks without a mandated order (in independent streams) execute in undefined order and may be - /// serialized. - #[inline] - fn enqueue_host_callback(&mut self, callback: core::Stream_StreamCallback) -> Result<()> { - callback_arg!(callback_trampoline(status: i32, user_data: *mut c_void) -> () => user_data in callback(status: i32) -> ()); - userdata_arg!(user_data: *mut c_void => callback); - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_Stream_enqueueHostCallback_StreamCallback_voidX(self.as_raw_mut_Stream(), callback_trampoline, user_data, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - + impl core::HostMemTrait for HostMem { + #[inline] fn as_raw_mut_HostMem(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { HostMem, core::HostMemTraitConst, as_raw_HostMem, core::HostMemTrait, as_raw_mut_HostMem } + /// This class encapsulates a queue of asynchronous calls. /// /// @@ -34147,16 +34060,6 @@ pub mod core { unsafe impl Send for Stream {} - impl core::StreamTraitConst for Stream { - #[inline] fn as_raw_Stream(&self) -> *const c_void { self.as_raw() } - } - - impl core::StreamTrait for Stream { - #[inline] fn as_raw_mut_Stream(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Stream, core::StreamTraitConst, as_raw_Stream, core::StreamTrait, as_raw_mut_Stream } - impl Stream { /// creates a new asynchronous stream #[inline] @@ -34214,6 +34117,77 @@ pub mod core { } + /// Constant methods for [core::Stream] + pub trait StreamTraitConst { + fn as_raw_Stream(&self) -> *const c_void; + + /// Returns true if the current stream queue is finished. Otherwise, it returns false. + #[inline] + fn query_if_complete(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_Stream_queryIfComplete_const(self.as_raw_Stream(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// return Pointer to CUDA stream + #[inline] + fn cuda_ptr(&self) -> Result<*mut c_void> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_Stream_cudaPtr_const(self.as_raw_Stream(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + /// Mutable methods for [core::Stream] + pub trait StreamTrait: core::StreamTraitConst { + fn as_raw_mut_Stream(&mut self) -> *mut c_void; + + /// Blocks the current CPU thread until all operations in the stream are complete. + #[inline] + fn wait_for_completion(&mut self) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_Stream_waitForCompletion(self.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Makes a compute stream wait on an event. + #[inline] + fn wait_event(&mut self, event: &impl core::EventTraitConst) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_Stream_waitEvent_const_EventR(self.as_raw_mut_Stream(), event.as_raw_Event(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Adds a callback to be called on the host after all currently enqueued items in the stream have + /// completed. + /// + /// + /// Note: Callbacks must not make any CUDA API calls. Callbacks must not perform any synchronization + /// that may depend on outstanding device work or other callbacks that are not mandated to run earlier. + /// Callbacks without a mandated order (in independent streams) execute in undefined order and may be + /// serialized. + #[inline] + fn enqueue_host_callback(&mut self, callback: core::Stream_StreamCallback) -> Result<()> { + callback_arg!(callback_trampoline(status: i32, user_data: *mut c_void) -> () => user_data in callback(status: i32) -> ()); + userdata_arg!(user_data: *mut c_void => callback); + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_Stream_enqueueHostCallback_StreamCallback_voidX(self.as_raw_mut_Stream(), callback_trampoline, user_data, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + impl std::fmt::Debug for Stream { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -34222,18 +34196,16 @@ pub mod core { } } - /// Constant methods for [core::TargetArchs] - pub trait TargetArchsTraitConst { - fn as_raw_TargetArchs(&self) -> *const c_void; - + impl core::StreamTraitConst for Stream { + #[inline] fn as_raw_Stream(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [core::TargetArchs] - pub trait TargetArchsTrait: core::TargetArchsTraitConst { - fn as_raw_mut_TargetArchs(&mut self) -> *mut c_void; - + impl core::StreamTrait for Stream { + #[inline] fn as_raw_mut_Stream(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { Stream, core::StreamTraitConst, as_raw_Stream, core::StreamTrait, as_raw_mut_Stream } + /// Class providing a set of static methods to check what NVIDIA\* card architecture the CUDA module was /// built for. /// @@ -34254,21 +34226,13 @@ pub mod core { unsafe impl Send for TargetArchs {} - impl core::TargetArchsTraitConst for TargetArchs { - #[inline] fn as_raw_TargetArchs(&self) -> *const c_void { self.as_raw() } - } - - impl core::TargetArchsTrait for TargetArchs { - #[inline] fn as_raw_mut_TargetArchs(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TargetArchs, core::TargetArchsTraitConst, as_raw_TargetArchs, core::TargetArchsTrait, as_raw_mut_TargetArchs } - impl TargetArchs { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_cuda_TargetArchs_defaultNew_const()) } + pub fn default() -> core::TargetArchs { + let ret = unsafe { sys::cv_cuda_TargetArchs_defaultNew_const() }; + let ret = unsafe { core::TargetArchs::opencv_from_extern(ret) }; + ret } /// The following method checks whether the module was built with the support of the given feature: @@ -34355,6 +34319,26 @@ pub mod core { } + /// Constant methods for [core::TargetArchs] + pub trait TargetArchsTraitConst { + fn as_raw_TargetArchs(&self) -> *const c_void; + + } + + /// Mutable methods for [core::TargetArchs] + pub trait TargetArchsTrait: core::TargetArchsTraitConst { + fn as_raw_mut_TargetArchs(&mut self) -> *mut c_void; + + } + + impl Default for TargetArchs { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } + } + impl std::fmt::Debug for TargetArchs { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -34363,12 +34347,40 @@ pub mod core { } } - impl Default for TargetArchs { + impl core::TargetArchsTraitConst for TargetArchs { + #[inline] fn as_raw_TargetArchs(&self) -> *const c_void { self.as_raw() } + } + + impl core::TargetArchsTrait for TargetArchs { + #[inline] fn as_raw_mut_TargetArchs(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { TargetArchs, core::TargetArchsTraitConst, as_raw_TargetArchs, core::TargetArchsTrait, as_raw_mut_TargetArchs } + + pub struct Detail_CheckContext { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_CheckContext } + + impl Drop for Detail_CheckContext { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + fn drop(&mut self) { + unsafe { sys::cv_detail_CheckContext_delete(self.as_raw_mut_Detail_CheckContext()) }; + } + } + + unsafe impl Send for Detail_CheckContext {} + + impl Detail_CheckContext { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> core::Detail_CheckContext { + let ret = unsafe { sys::cv_detail_CheckContext_defaultNew_const() }; + let ret = unsafe { core::Detail_CheckContext::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [core::Detail_CheckContext] @@ -34444,38 +34456,12 @@ pub mod core { } - pub struct Detail_CheckContext { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_CheckContext } - - impl Drop for Detail_CheckContext { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_CheckContext_delete(self.as_raw_mut_Detail_CheckContext()) }; - } - } - - unsafe impl Send for Detail_CheckContext {} - - impl core::Detail_CheckContextTraitConst for Detail_CheckContext { - #[inline] fn as_raw_Detail_CheckContext(&self) -> *const c_void { self.as_raw() } - } - - impl core::Detail_CheckContextTrait for Detail_CheckContext { - #[inline] fn as_raw_mut_Detail_CheckContext(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Detail_CheckContext, core::Detail_CheckContextTraitConst, as_raw_Detail_CheckContext, core::Detail_CheckContextTrait, as_raw_mut_Detail_CheckContext } - - impl Detail_CheckContext { - /// Creates a default instance of the class by calling the default constructor + impl Default for Detail_CheckContext { #[inline] + /// Forwards to infallible Self::default() fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_CheckContext_defaultNew_const()) } + Self::default() } - } impl Clone for Detail_CheckContext { @@ -34500,14 +34486,16 @@ pub mod core { } } - impl Default for Detail_CheckContext { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } + impl core::Detail_CheckContextTraitConst for Detail_CheckContext { + #[inline] fn as_raw_Detail_CheckContext(&self) -> *const c_void { self.as_raw() } + } + + impl core::Detail_CheckContextTrait for Detail_CheckContext { + #[inline] fn as_raw_mut_Detail_CheckContext(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { Detail_CheckContext, core::Detail_CheckContextTraitConst, as_raw_Detail_CheckContext, core::Detail_CheckContextTrait, as_raw_mut_Detail_CheckContext } + #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] pub struct hfloat { @@ -34546,6 +34534,73 @@ pub mod core { } + pub struct NodeData { + ptr: *mut c_void, + } + + opencv_type_boxed! { NodeData } + + impl Drop for NodeData { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_instr_NodeData_delete(self.as_raw_mut_NodeData()) }; + } + } + + unsafe impl Send for NodeData {} + + impl NodeData { + /// ## C++ default parameters + /// * fun_name: 0 + /// * file_name: NULL + /// * line_num: 0 + /// * ret_address: NULL + /// * always_expand: false + /// * instr_type: TYPE_GENERAL + /// * impl_type: IMPL_PLAIN + #[inline] + pub unsafe fn new(fun_name: &str, file_name: &str, line_num: i32, ret_address: *mut c_void, always_expand: bool, instr_type: core::TYPE, impl_type: core::IMPL) -> Result { + extern_container_arg!(fun_name); + extern_container_arg!(file_name); + return_send!(via ocvrs_return); + { sys::cv_instr_NodeData_NodeData_const_charX_const_charX_int_voidX_bool_TYPE_IMPL(fun_name.opencv_as_extern(), file_name.opencv_as_extern(), line_num, ret_address, always_expand, instr_type, impl_type, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = { core::NodeData::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * fun_name: 0 + /// * file_name: NULL + /// * line_num: 0 + /// * ret_address: NULL + /// * always_expand: false + /// * instr_type: TYPE_GENERAL + /// * impl_type: IMPL_PLAIN + #[inline] + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_instr_NodeData_NodeData(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::NodeData::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn copy_mut(ref_: &mut impl core::NodeDataTrait) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_instr_NodeData_NodeData_NodeDataR(ref_.as_raw_mut_NodeData(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::NodeData::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [core::NodeData] pub trait NodeDataTraitConst { fn as_raw_NodeData(&self) -> *const c_void; @@ -34718,21 +34773,24 @@ pub mod core { } - pub struct NodeData { - ptr: *mut c_void, - } - - opencv_type_boxed! { NodeData } - - impl Drop for NodeData { + impl std::fmt::Debug for NodeData { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_instr_NodeData_delete(self.as_raw_mut_NodeData()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("NodeData") + .field("m_fun_name", &core::NodeDataTraitConst::m_fun_name(self)) + .field("m_instr_type", &core::NodeDataTraitConst::m_instr_type(self)) + .field("m_impl_type", &core::NodeDataTraitConst::m_impl_type(self)) + .field("m_file_name", &core::NodeDataTraitConst::m_file_name(self)) + .field("m_line_num", &core::NodeDataTraitConst::m_line_num(self)) + .field("m_always_expand", &core::NodeDataTraitConst::m_always_expand(self)) + .field("m_fun_error", &core::NodeDataTraitConst::m_fun_error(self)) + .field("m_counter", &core::NodeDataTraitConst::m_counter(self)) + .field("m_ticks_total", &core::NodeDataTraitConst::m_ticks_total(self)) + .field("m_threads", &core::NodeDataTraitConst::m_threads(self)) + .finish() } } - unsafe impl Send for NodeData {} - impl core::NodeDataTraitConst for NodeData { #[inline] fn as_raw_NodeData(&self) -> *const c_void { self.as_raw() } } @@ -34743,76 +34801,52 @@ pub mod core { boxed_ref! { NodeData, core::NodeDataTraitConst, as_raw_NodeData, core::NodeDataTrait, as_raw_mut_NodeData } - impl NodeData { - /// ## C++ default parameters - /// * fun_name: 0 - /// * file_name: NULL - /// * line_num: 0 - /// * ret_address: NULL - /// * always_expand: false - /// * instr_type: TYPE_GENERAL - /// * impl_type: IMPL_PLAIN + pub struct WriteStructContext { + ptr: *mut c_void, + } + + opencv_type_boxed! { WriteStructContext } + + impl Drop for WriteStructContext { #[inline] - pub unsafe fn new(fun_name: &str, file_name: &str, line_num: i32, ret_address: *mut c_void, always_expand: bool, instr_type: core::TYPE, impl_type: core::IMPL) -> Result { - extern_container_arg!(fun_name); - extern_container_arg!(file_name); - return_send!(via ocvrs_return); - { sys::cv_instr_NodeData_NodeData_const_charX_const_charX_int_voidX_bool_TYPE_IMPL(fun_name.opencv_as_extern(), file_name.opencv_as_extern(), line_num, ret_address, always_expand, instr_type, impl_type, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = { core::NodeData::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_internal_WriteStructContext_delete(self.as_raw_mut_WriteStructContext()) }; } + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * fun_name: 0 - /// * file_name: NULL - /// * line_num: 0 - /// * ret_address: NULL - /// * always_expand: false - /// * instr_type: TYPE_GENERAL - /// * impl_type: IMPL_PLAIN + unsafe impl Send for WriteStructContext {} + + impl WriteStructContext { + /// ## C++ default parameters + /// * type_name: String() #[inline] - pub fn new_def() -> Result { + pub fn new(_fs: &mut impl core::FileStorageTrait, name: &str, flags: i32, type_name: &str) -> Result { + extern_container_arg!(name); + extern_container_arg!(type_name); return_send!(via ocvrs_return); - unsafe { sys::cv_instr_NodeData_NodeData(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_internal_WriteStructContext_WriteStructContext_FileStorageR_const_StringR_int_const_StringR(_fs.as_raw_mut_FileStorage(), name.opencv_as_extern(), flags, type_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::NodeData::opencv_from_extern(ret) }; + let ret = unsafe { core::WriteStructContext::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * type_name: String() #[inline] - pub fn copy_mut(ref_: &mut impl core::NodeDataTrait) -> Result { + pub fn new_def(_fs: &mut impl core::FileStorageTrait, name: &str, flags: i32) -> Result { + extern_container_arg!(name); return_send!(via ocvrs_return); - unsafe { sys::cv_instr_NodeData_NodeData_NodeDataR(ref_.as_raw_mut_NodeData(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_internal_WriteStructContext_WriteStructContext_FileStorageR_const_StringR_int(_fs.as_raw_mut_FileStorage(), name.opencv_as_extern(), flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::NodeData::opencv_from_extern(ret) }; + let ret = unsafe { core::WriteStructContext::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for NodeData { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("NodeData") - .field("m_fun_name", &core::NodeDataTraitConst::m_fun_name(self)) - .field("m_instr_type", &core::NodeDataTraitConst::m_instr_type(self)) - .field("m_impl_type", &core::NodeDataTraitConst::m_impl_type(self)) - .field("m_file_name", &core::NodeDataTraitConst::m_file_name(self)) - .field("m_line_num", &core::NodeDataTraitConst::m_line_num(self)) - .field("m_always_expand", &core::NodeDataTraitConst::m_always_expand(self)) - .field("m_fun_error", &core::NodeDataTraitConst::m_fun_error(self)) - .field("m_counter", &core::NodeDataTraitConst::m_counter(self)) - .field("m_ticks_total", &core::NodeDataTraitConst::m_ticks_total(self)) - .field("m_threads", &core::NodeDataTraitConst::m_threads(self)) - .finish() - } - } - /// Constant methods for [core::WriteStructContext] pub trait WriteStructContextTraitConst { fn as_raw_WriteStructContext(&self) -> *const c_void; @@ -34825,68 +34859,132 @@ pub mod core { } - pub struct WriteStructContext { + impl std::fmt::Debug for WriteStructContext { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("WriteStructContext") + .finish() + } + } + + impl core::WriteStructContextTraitConst for WriteStructContext { + #[inline] fn as_raw_WriteStructContext(&self) -> *const c_void { self.as_raw() } + } + + impl core::WriteStructContextTrait for WriteStructContext { + #[inline] fn as_raw_mut_WriteStructContext(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { WriteStructContext, core::WriteStructContextTraitConst, as_raw_WriteStructContext, core::WriteStructContextTrait, as_raw_mut_WriteStructContext } + + pub struct Context { ptr: *mut c_void, } - opencv_type_boxed! { WriteStructContext } + opencv_type_boxed! { Context } + + impl Drop for Context { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_ocl_Context_delete(self.as_raw_mut_Context()) }; + } + } + + unsafe impl Send for Context {} + + impl Context { + #[inline] + pub fn default() -> core::Context { + let ret = unsafe { sys::cv_ocl_Context_Context() }; + let ret = unsafe { core::Context::opencv_from_extern(ret) }; + ret + } - impl Drop for WriteStructContext { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_internal_WriteStructContext_delete(self.as_raw_mut_WriteStructContext()) }; + pub fn new_with_type(dtype: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_Context_Context_int(dtype, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Context::opencv_from_extern(ret) }; + Ok(ret) } - } - - unsafe impl Send for WriteStructContext {} - - impl core::WriteStructContextTraitConst for WriteStructContext { - #[inline] fn as_raw_WriteStructContext(&self) -> *const c_void { self.as_raw() } - } - impl core::WriteStructContextTrait for WriteStructContext { - #[inline] fn as_raw_mut_WriteStructContext(&mut self) -> *mut c_void { self.as_raw_mut() } - } + #[inline] + pub fn copy(c: &impl core::ContextTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_Context_Context_const_ContextR(c.as_raw_Context(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Context::opencv_from_extern(ret) }; + Ok(ret) + } - boxed_ref! { WriteStructContext, core::WriteStructContextTraitConst, as_raw_WriteStructContext, core::WriteStructContextTrait, as_raw_mut_WriteStructContext } + #[inline] + pub fn copy_mut(mut c: core::Context) -> core::Context { + let ret = unsafe { sys::cv_ocl_Context_Context_ContextRR(c.as_raw_mut_Context()) }; + let ret = unsafe { core::Context::opencv_from_extern(ret) }; + ret + } - impl WriteStructContext { /// ## C++ default parameters - /// * type_name: String() + /// * initialize: true #[inline] - pub fn new(_fs: &mut impl core::FileStorageTrait, name: &str, flags: i32, type_name: &str) -> Result { - extern_container_arg!(name); - extern_container_arg!(type_name); + pub fn get_default(initialize: bool) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_internal_WriteStructContext_WriteStructContext_FileStorageR_const_StringR_int_const_StringR(_fs.as_raw_mut_FileStorage(), name.opencv_as_extern(), flags, type_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_Context_getDefault_bool(initialize, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::WriteStructContext::opencv_from_extern(ret) }; + let ret = unsafe { core::Context::opencv_from_extern(ret) }; Ok(ret) } /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * type_name: String() + /// This alternative version of [Context::get_default] function uses the following default values for its arguments: + /// * initialize: true #[inline] - pub fn new_def(_fs: &mut impl core::FileStorageTrait, name: &str, flags: i32) -> Result { - extern_container_arg!(name); + pub fn get_default_def() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_internal_WriteStructContext_WriteStructContext_FileStorageR_const_StringR_int(_fs.as_raw_mut_FileStorage(), name.opencv_as_extern(), flags, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_Context_getDefault(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::WriteStructContext::opencv_from_extern(ret) }; + let ret = unsafe { core::Context::opencv_from_extern(ret) }; Ok(ret) } - } + /// ## Parameters + /// * context: OpenCL handle (cl_context). clRetainContext() is called on success + #[inline] + pub unsafe fn from_handle(context: *mut c_void) -> Result { + return_send!(via ocvrs_return); + { sys::cv_ocl_Context_fromHandle_voidX(context, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = { core::Context::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for WriteStructContext { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("WriteStructContext") - .finish() + pub fn from_device(device: &impl core::DeviceTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_Context_fromDevice_const_DeviceR(device.as_raw_Device(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Context::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn create(configuration: &str) -> Result { + extern_container_arg!(configuration); + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_Context_create_const_stringR(configuration.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Context::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [core::Context] @@ -35038,21 +35136,22 @@ pub mod core { } - pub struct Context { - ptr: *mut c_void, + impl Default for Context { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Context } - - impl Drop for Context { + impl std::fmt::Debug for Context { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ocl_Context_delete(self.as_raw_mut_Context()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Context") + .finish() } } - unsafe impl Send for Context {} - impl core::ContextTraitConst for Context { #[inline] fn as_raw_Context(&self) -> *const c_void { self.as_raw() } } @@ -35063,177 +35162,147 @@ pub mod core { boxed_ref! { Context, core::ContextTraitConst, as_raw_Context, core::ContextTrait, as_raw_mut_Context } - impl Context { - #[inline] - pub fn default() -> core::Context { - let ret = unsafe { sys::cv_ocl_Context_Context() }; - let ret = unsafe { core::Context::opencv_from_extern(ret) }; - ret - } + pub struct Context_UserContext { + ptr: *mut c_void, + } - #[inline] - pub fn new_with_type(dtype: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Context_Context_int(dtype, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Context::opencv_from_extern(ret) }; - Ok(ret) - } + opencv_type_boxed! { Context_UserContext } + impl Drop for Context_UserContext { #[inline] - pub fn copy(c: &impl core::ContextTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Context_Context_const_ContextR(c.as_raw_Context(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Context::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_ocl_Context_UserContext_delete(self.as_raw_mut_Context_UserContext()) }; } + } + + unsafe impl Send for Context_UserContext {} + impl Context_UserContext { + /// Creates a default instance of the class by calling the default constructor #[inline] - pub fn copy_mut(mut c: core::Context) -> core::Context { - let ret = unsafe { sys::cv_ocl_Context_Context_ContextRR(c.as_raw_mut_Context()) }; - let ret = unsafe { core::Context::opencv_from_extern(ret) }; + pub fn default() -> core::Context_UserContext { + let ret = unsafe { sys::cv_ocl_Context_UserContext_defaultNew_const() }; + let ret = unsafe { core::Context_UserContext::opencv_from_extern(ret) }; ret } - /// ## C++ default parameters - /// * initialize: true - #[inline] - pub fn get_default(initialize: bool) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Context_getDefault_bool(initialize, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Context::opencv_from_extern(ret) }; - Ok(ret) - } + } - /// ## Note - /// This alternative version of [Context::get_default] function uses the following default values for its arguments: - /// * initialize: true - #[inline] - pub fn get_default_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Context_getDefault(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Context::opencv_from_extern(ret) }; - Ok(ret) - } + /// Constant methods for [core::Context_UserContext] + pub trait Context_UserContextTraitConst { + fn as_raw_Context_UserContext(&self) -> *const c_void; - /// ## Parameters - /// * context: OpenCL handle (cl_context). clRetainContext() is called on success - #[inline] - pub unsafe fn from_handle(context: *mut c_void) -> Result { - return_send!(via ocvrs_return); - { sys::cv_ocl_Context_fromHandle_voidX(context, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = { core::Context::opencv_from_extern(ret) }; - Ok(ret) - } + } - #[inline] - pub fn from_device(device: &impl core::DeviceTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Context_fromDevice_const_DeviceR(device.as_raw_Device(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Context::opencv_from_extern(ret) }; - Ok(ret) - } + /// Mutable methods for [core::Context_UserContext] + pub trait Context_UserContextTrait: core::Context_UserContextTraitConst { + fn as_raw_mut_Context_UserContext(&mut self) -> *mut c_void; + + } + impl Default for Context_UserContext { #[inline] - pub fn create(configuration: &str) -> Result { - extern_container_arg!(configuration); - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Context_create_const_stringR(configuration.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Context::opencv_from_extern(ret) }; - Ok(ret) + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() } - } - impl std::fmt::Debug for Context { + impl std::fmt::Debug for Context_UserContext { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Context") + f.debug_struct("Context_UserContext") .finish() } } - impl Default for Context { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } + impl core::Context_UserContextTraitConst for Context_UserContext { + #[inline] fn as_raw_Context_UserContext(&self) -> *const c_void { self.as_raw() } } - /// Constant methods for [core::Context_UserContext] - pub trait Context_UserContextTraitConst { - fn as_raw_Context_UserContext(&self) -> *const c_void; - + impl core::Context_UserContextTrait for Context_UserContext { + #[inline] fn as_raw_mut_Context_UserContext(&mut self) -> *mut c_void { self.as_raw_mut() } } - /// Mutable methods for [core::Context_UserContext] - pub trait Context_UserContextTrait: core::Context_UserContextTraitConst { - fn as_raw_mut_Context_UserContext(&mut self) -> *mut c_void; - - } + boxed_ref! { Context_UserContext, core::Context_UserContextTraitConst, as_raw_Context_UserContext, core::Context_UserContextTrait, as_raw_mut_Context_UserContext } - pub struct Context_UserContext { + pub struct Device { ptr: *mut c_void, } - opencv_type_boxed! { Context_UserContext } + opencv_type_boxed! { Device } - impl Drop for Context_UserContext { + impl Drop for Device { #[inline] fn drop(&mut self) { - unsafe { sys::cv_ocl_Context_UserContext_delete(self.as_raw_mut_Context_UserContext()) }; - } - } - - unsafe impl Send for Context_UserContext {} - - impl core::Context_UserContextTraitConst for Context_UserContext { - #[inline] fn as_raw_Context_UserContext(&self) -> *const c_void { self.as_raw() } + unsafe { sys::cv_ocl_Device_delete(self.as_raw_mut_Device()) }; + } } - impl core::Context_UserContextTrait for Context_UserContext { - #[inline] fn as_raw_mut_Context_UserContext(&mut self) -> *mut c_void { self.as_raw_mut() } - } + unsafe impl Send for Device {} - boxed_ref! { Context_UserContext, core::Context_UserContextTraitConst, as_raw_Context_UserContext, core::Context_UserContextTrait, as_raw_mut_Context_UserContext } + impl Device { + #[inline] + pub fn default() -> core::Device { + let ret = unsafe { sys::cv_ocl_Device_Device() }; + let ret = unsafe { core::Device::opencv_from_extern(ret) }; + ret + } - impl Context_UserContext { - /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_ocl_Context_UserContext_defaultNew_const()) } + pub unsafe fn new(d: *mut c_void) -> Result { + return_send!(via ocvrs_return); + { sys::cv_ocl_Device_Device_voidX(d, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = { core::Device::opencv_from_extern(ret) }; + Ok(ret) } - } + #[inline] + pub fn copy(d: &impl core::DeviceTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_Device_Device_const_DeviceR(d.as_raw_Device(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Device::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for Context_UserContext { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Context_UserContext") - .finish() + pub fn copy_mut(mut d: core::Device) -> core::Device { + let ret = unsafe { sys::cv_ocl_Device_Device_DeviceRR(d.as_raw_mut_Device()) }; + let ret = unsafe { core::Device::opencv_from_extern(ret) }; + ret } - } - impl Default for Context_UserContext { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn get_default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_Device_getDefault(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Device::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Parameters + /// * d: OpenCL handle (cl_device_id). clRetainDevice() is called on success. + /// + /// + /// Note: Ownership of the passed device is passed to OpenCV on success. + /// The caller should additionally call `clRetainDevice` on it if it intends + /// to continue using the device. + #[inline] + pub unsafe fn from_handle(d: *mut c_void) -> Result { + return_send!(via ocvrs_return); + { sys::cv_ocl_Device_fromHandle_voidX(d, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = { core::Device::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [core::Device] @@ -35976,20 +36045,28 @@ pub mod core { } - pub struct Device { - ptr: *mut c_void, + impl Default for Device { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Device } - - impl Drop for Device { + impl Clone for Device { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ocl_Device_delete(self.as_raw_mut_Device()) }; + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_ocl_Device_implicitClone_const(self.as_raw_Device())) } } } - unsafe impl Send for Device {} + impl std::fmt::Debug for Device { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Device") + .finish() + } + } impl core::DeviceTraitConst for Device { #[inline] fn as_raw_Device(&self) -> *const c_void { self.as_raw() } @@ -36001,91 +36078,106 @@ pub mod core { boxed_ref! { Device, core::DeviceTraitConst, as_raw_Device, core::DeviceTrait, as_raw_mut_Device } - impl Device { + pub struct Image2D { + ptr: *mut c_void, + } + + opencv_type_boxed! { Image2D } + + impl Drop for Image2D { #[inline] - pub fn default() -> core::Device { - let ret = unsafe { sys::cv_ocl_Device_Device() }; - let ret = unsafe { core::Device::opencv_from_extern(ret) }; - ret + fn drop(&mut self) { + unsafe { sys::cv_ocl_Image2D_delete(self.as_raw_mut_Image2D()) }; } + } + + unsafe impl Send for Image2D {} + impl Image2D { #[inline] - pub unsafe fn new(d: *mut c_void) -> Result { - return_send!(via ocvrs_return); - { sys::cv_ocl_Device_Device_voidX(d, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = { core::Device::opencv_from_extern(ret) }; - Ok(ret) + pub fn default() -> core::Image2D { + let ret = unsafe { sys::cv_ocl_Image2D_Image2D() }; + let ret = unsafe { core::Image2D::opencv_from_extern(ret) }; + ret } + /// ## Parameters + /// * src: UMat object from which to get image properties and data + /// * norm: flag to enable the use of normalized channel data types + /// * alias: flag indicating that the image should alias the src UMat. If true, changes to the + /// image or src will be reflected in both objects. + /// + /// ## C++ default parameters + /// * norm: false + /// * alias: false #[inline] - pub fn copy(d: &impl core::DeviceTraitConst) -> Result { + pub fn new(src: &impl core::UMatTraitConst, norm: bool, alias: bool) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Device_Device_const_DeviceR(d.as_raw_Device(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_Image2D_Image2D_const_UMatR_bool_bool(src.as_raw_UMat(), norm, alias, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Device::opencv_from_extern(ret) }; + let ret = unsafe { core::Image2D::opencv_from_extern(ret) }; Ok(ret) } + /// ## Parameters + /// * src: UMat object from which to get image properties and data + /// * norm: flag to enable the use of normalized channel data types + /// * alias: flag indicating that the image should alias the src UMat. If true, changes to the + /// image or src will be reflected in both objects. + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * norm: false + /// * alias: false #[inline] - pub fn copy_mut(mut d: core::Device) -> core::Device { - let ret = unsafe { sys::cv_ocl_Device_Device_DeviceRR(d.as_raw_mut_Device()) }; - let ret = unsafe { core::Device::opencv_from_extern(ret) }; - ret - } - - #[inline] - pub fn get_default() -> Result { + pub fn new_def(src: &impl core::UMatTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Device_getDefault(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_Image2D_Image2D_const_UMatR(src.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Device::opencv_from_extern(ret) }; + let ret = unsafe { core::Image2D::opencv_from_extern(ret) }; Ok(ret) } - /// ## Parameters - /// * d: OpenCL handle (cl_device_id). clRetainDevice() is called on success. - /// - /// - /// Note: Ownership of the passed device is passed to OpenCV on success. - /// The caller should additionally call `clRetainDevice` on it if it intends - /// to continue using the device. #[inline] - pub unsafe fn from_handle(d: *mut c_void) -> Result { + pub fn copy(i: &impl core::Image2DTraitConst) -> Result { return_send!(via ocvrs_return); - { sys::cv_ocl_Device_fromHandle_voidX(d, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_ocl_Image2D_Image2D_const_Image2DR(i.as_raw_Image2D(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::Device::opencv_from_extern(ret) }; + let ret = unsafe { core::Image2D::opencv_from_extern(ret) }; Ok(ret) } - } - - impl Clone for Device { #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_ocl_Device_implicitClone_const(self.as_raw_Device())) } + pub fn copy_mut(mut unnamed: core::Image2D) -> core::Image2D { + let ret = unsafe { sys::cv_ocl_Image2D_Image2D_Image2DRR(unnamed.as_raw_mut_Image2D()) }; + let ret = unsafe { core::Image2D::opencv_from_extern(ret) }; + ret } - } - impl std::fmt::Debug for Device { + /// Indicates if creating an aliased image should succeed. + /// Depends on the underlying platform and the dimensions of the UMat. #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Device") - .finish() + pub fn can_create_alias(u: &impl core::UMatTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_Image2D_canCreateAlias_const_UMatR(u.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } - } - impl Default for Device { + /// Indicates if the image format is supported. #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn is_format_supported(depth: i32, cn: i32, norm: bool) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_Image2D_isFormatSupported_int_int_bool(depth, cn, norm, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } + } /// Constant methods for [core::Image2D] @@ -36124,21 +36216,22 @@ pub mod core { } - pub struct Image2D { - ptr: *mut c_void, + impl Default for Image2D { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Image2D } - - impl Drop for Image2D { + impl std::fmt::Debug for Image2D { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ocl_Image2D_delete(self.as_raw_mut_Image2D()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Image2D") + .finish() } } - unsafe impl Send for Image2D {} - impl core::Image2DTraitConst for Image2D { #[inline] fn as_raw_Image2D(&self) -> *const c_void { self.as_raw() } } @@ -36149,107 +36242,89 @@ pub mod core { boxed_ref! { Image2D, core::Image2DTraitConst, as_raw_Image2D, core::Image2DTrait, as_raw_mut_Image2D } - impl Image2D { + pub struct Kernel { + ptr: *mut c_void, + } + + opencv_type_boxed! { Kernel } + + impl Drop for Kernel { #[inline] - pub fn default() -> core::Image2D { - let ret = unsafe { sys::cv_ocl_Image2D_Image2D() }; - let ret = unsafe { core::Image2D::opencv_from_extern(ret) }; - ret + fn drop(&mut self) { + unsafe { sys::cv_ocl_Kernel_delete(self.as_raw_mut_Kernel()) }; } + } - /// ## Parameters - /// * src: UMat object from which to get image properties and data - /// * norm: flag to enable the use of normalized channel data types - /// * alias: flag indicating that the image should alias the src UMat. If true, changes to the - /// image or src will be reflected in both objects. - /// - /// ## C++ default parameters - /// * norm: false - /// * alias: false + unsafe impl Send for Kernel {} + + impl Kernel { #[inline] - pub fn new(src: &impl core::UMatTraitConst, norm: bool, alias: bool) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Image2D_Image2D_const_UMatR_bool_bool(src.as_raw_UMat(), norm, alias, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Image2D::opencv_from_extern(ret) }; - Ok(ret) + pub fn default() -> core::Kernel { + let ret = unsafe { sys::cv_ocl_Kernel_Kernel() }; + let ret = unsafe { core::Kernel::opencv_from_extern(ret) }; + ret } - /// ## Parameters - /// * src: UMat object from which to get image properties and data - /// * norm: flag to enable the use of normalized channel data types - /// * alias: flag indicating that the image should alias the src UMat. If true, changes to the - /// image or src will be reflected in both objects. - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * norm: false - /// * alias: false #[inline] - pub fn new_def(src: &impl core::UMatTraitConst) -> Result { + pub fn new(kname: &str, prog: &impl core::ProgramTraitConst) -> Result { + extern_container_arg!(kname); return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Image2D_Image2D_const_UMatR(src.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_Kernel_Kernel_const_charX_const_ProgramR(kname.opencv_as_extern(), prog.as_raw_Program(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Image2D::opencv_from_extern(ret) }; + let ret = unsafe { core::Kernel::opencv_from_extern(ret) }; Ok(ret) } + /// ## C++ default parameters + /// * buildopts: String() + /// * errmsg: 0 #[inline] - pub fn copy(i: &impl core::Image2DTraitConst) -> Result { + pub fn new_1(kname: &str, prog: &impl core::ProgramSourceTraitConst, buildopts: &str, errmsg: &mut String) -> Result { + extern_container_arg!(kname); + extern_container_arg!(buildopts); + string_arg_output_send!(via errmsg_via); return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Image2D_Image2D_const_Image2DR(i.as_raw_Image2D(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_Kernel_Kernel_const_charX_const_ProgramSourceR_const_StringR_StringX(kname.opencv_as_extern(), prog.as_raw_ProgramSource(), buildopts.opencv_as_extern(), &mut errmsg_via, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Image2D::opencv_from_extern(ret) }; + let ret = unsafe { core::Kernel::opencv_from_extern(ret) }; + string_arg_output_receive!(errmsg_via => errmsg); Ok(ret) } + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * buildopts: String() + /// * errmsg: 0 #[inline] - pub fn copy_mut(mut unnamed: core::Image2D) -> core::Image2D { - let ret = unsafe { sys::cv_ocl_Image2D_Image2D_Image2DRR(unnamed.as_raw_mut_Image2D()) }; - let ret = unsafe { core::Image2D::opencv_from_extern(ret) }; - ret - } - - /// Indicates if creating an aliased image should succeed. - /// Depends on the underlying platform and the dimensions of the UMat. - #[inline] - pub fn can_create_alias(u: &impl core::UMatTraitConst) -> Result { + pub fn new_def(kname: &str, prog: &impl core::ProgramSourceTraitConst) -> Result { + extern_container_arg!(kname); return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Image2D_canCreateAlias_const_UMatR(u.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_Kernel_Kernel_const_charX_const_ProgramSourceR(kname.opencv_as_extern(), prog.as_raw_ProgramSource(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Kernel::opencv_from_extern(ret) }; Ok(ret) } - /// Indicates if the image format is supported. #[inline] - pub fn is_format_supported(depth: i32, cn: i32, norm: bool) -> Result { + pub fn copy(k: &impl core::KernelTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Image2D_isFormatSupported_int_int_bool(depth, cn, norm, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_Kernel_Kernel_const_KernelR(k.as_raw_Kernel(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Kernel::opencv_from_extern(ret) }; Ok(ret) } - } - - impl std::fmt::Debug for Image2D { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Image2D") - .finish() + pub fn copy_mut(mut k: core::Kernel) -> core::Kernel { + let ret = unsafe { sys::cv_ocl_Kernel_Kernel_KernelRR(k.as_raw_mut_Kernel()) }; + let ret = unsafe { core::Kernel::opencv_from_extern(ret) }; + ret } - } - impl Default for Image2D { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } } /// Constant methods for [core::Kernel] @@ -36560,196 +36635,32 @@ pub mod core { } - pub struct Kernel { - ptr: *mut c_void, - } - - opencv_type_boxed! { Kernel } - - impl Drop for Kernel { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ocl_Kernel_delete(self.as_raw_mut_Kernel()) }; - } - } - - unsafe impl Send for Kernel {} - - impl core::KernelTraitConst for Kernel { - #[inline] fn as_raw_Kernel(&self) -> *const c_void { self.as_raw() } - } - - impl core::KernelTrait for Kernel { - #[inline] fn as_raw_mut_Kernel(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Kernel, core::KernelTraitConst, as_raw_Kernel, core::KernelTrait, as_raw_mut_Kernel } - - impl Kernel { - #[inline] - pub fn default() -> core::Kernel { - let ret = unsafe { sys::cv_ocl_Kernel_Kernel() }; - let ret = unsafe { core::Kernel::opencv_from_extern(ret) }; - ret - } - - #[inline] - pub fn new(kname: &str, prog: &impl core::ProgramTraitConst) -> Result { - extern_container_arg!(kname); - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Kernel_Kernel_const_charX_const_ProgramR(kname.opencv_as_extern(), prog.as_raw_Program(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Kernel::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## C++ default parameters - /// * buildopts: String() - /// * errmsg: 0 - #[inline] - pub fn new_1(kname: &str, prog: &impl core::ProgramSourceTraitConst, buildopts: &str, errmsg: &mut String) -> Result { - extern_container_arg!(kname); - extern_container_arg!(buildopts); - string_arg_output_send!(via errmsg_via); - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Kernel_Kernel_const_charX_const_ProgramSourceR_const_StringR_StringX(kname.opencv_as_extern(), prog.as_raw_ProgramSource(), buildopts.opencv_as_extern(), &mut errmsg_via, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Kernel::opencv_from_extern(ret) }; - string_arg_output_receive!(errmsg_via => errmsg); - Ok(ret) - } - - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * buildopts: String() - /// * errmsg: 0 - #[inline] - pub fn new_def(kname: &str, prog: &impl core::ProgramSourceTraitConst) -> Result { - extern_container_arg!(kname); - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Kernel_Kernel_const_charX_const_ProgramSourceR(kname.opencv_as_extern(), prog.as_raw_ProgramSource(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Kernel::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn copy(k: &impl core::KernelTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Kernel_Kernel_const_KernelR(k.as_raw_Kernel(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Kernel::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn copy_mut(mut k: core::Kernel) -> core::Kernel { - let ret = unsafe { sys::cv_ocl_Kernel_Kernel_KernelRR(k.as_raw_mut_Kernel()) }; - let ret = unsafe { core::Kernel::opencv_from_extern(ret) }; - ret - } - - } - - impl std::fmt::Debug for Kernel { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Kernel") - .finish() - } - } - impl Default for Kernel { #[inline] /// Forwards to infallible Self::default() fn default() -> Self { - Self::default() - } - } - - /// Constant methods for [core::KernelArg] - pub trait KernelArgTraitConst { - fn as_raw_KernelArg(&self) -> *const c_void; - - #[inline] - fn flags(&self) -> i32 { - let ret = unsafe { sys::cv_ocl_KernelArg_propFlags_const(self.as_raw_KernelArg()) }; - ret - } - - #[inline] - fn obj(&self) -> *const c_void { - let ret = unsafe { sys::cv_ocl_KernelArg_propObj_const(self.as_raw_KernelArg()) }; - ret - } - - #[inline] - fn sz(&self) -> size_t { - let ret = unsafe { sys::cv_ocl_KernelArg_propSz_const(self.as_raw_KernelArg()) }; - ret - } - - #[inline] - fn wscale(&self) -> i32 { - let ret = unsafe { sys::cv_ocl_KernelArg_propWscale_const(self.as_raw_KernelArg()) }; - ret - } - - #[inline] - fn iwscale(&self) -> i32 { - let ret = unsafe { sys::cv_ocl_KernelArg_propIwscale_const(self.as_raw_KernelArg()) }; - ret - } - - } - - /// Mutable methods for [core::KernelArg] - pub trait KernelArgTrait: core::KernelArgTraitConst { - fn as_raw_mut_KernelArg(&mut self) -> *mut c_void; - - #[inline] - fn set_flags(&mut self, val: i32) { - let ret = unsafe { sys::cv_ocl_KernelArg_propFlags_const_int(self.as_raw_mut_KernelArg(), val) }; - ret - } - - #[inline] - fn m(&mut self) -> core::UMat { - let ret = unsafe { sys::cv_ocl_KernelArg_propM(self.as_raw_mut_KernelArg()) }; - let ret = unsafe { core::UMat::opencv_from_extern(ret) }; - ret - } - - #[inline] - fn set_m(&mut self, val: &impl core::UMatTraitConst) { - let ret = unsafe { sys::cv_ocl_KernelArg_propM_UMatX(self.as_raw_mut_KernelArg(), val.as_raw_UMat()) }; - ret - } - - #[inline] - fn set_sz(&mut self, val: size_t) { - let ret = unsafe { sys::cv_ocl_KernelArg_propSz_const_size_t(self.as_raw_mut_KernelArg(), val) }; - ret + Self::default() } + } + impl std::fmt::Debug for Kernel { #[inline] - fn set_wscale(&mut self, val: i32) { - let ret = unsafe { sys::cv_ocl_KernelArg_propWscale_const_int(self.as_raw_mut_KernelArg(), val) }; - ret + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Kernel") + .finish() } + } - #[inline] - fn set_iwscale(&mut self, val: i32) { - let ret = unsafe { sys::cv_ocl_KernelArg_propIwscale_const_int(self.as_raw_mut_KernelArg(), val) }; - ret - } + impl core::KernelTraitConst for Kernel { + #[inline] fn as_raw_Kernel(&self) -> *const c_void { self.as_raw() } + } + impl core::KernelTrait for Kernel { + #[inline] fn as_raw_mut_Kernel(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { Kernel, core::KernelTraitConst, as_raw_Kernel, core::KernelTrait, as_raw_mut_Kernel } + pub struct KernelArg { ptr: *mut c_void, } @@ -36765,16 +36676,6 @@ pub mod core { unsafe impl Send for KernelArg {} - impl core::KernelArgTraitConst for KernelArg { - #[inline] fn as_raw_KernelArg(&self) -> *const c_void { self.as_raw() } - } - - impl core::KernelArgTrait for KernelArg { - #[inline] fn as_raw_mut_KernelArg(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { KernelArg, core::KernelArgTraitConst, as_raw_KernelArg, core::KernelArgTrait, as_raw_mut_KernelArg } - impl KernelArg { /// ## C++ default parameters /// * wscale: 1 @@ -36993,62 +36894,276 @@ pub mod core { /// * wscale: 1 /// * iwscale: 1 #[inline] - pub fn write_only_no_size(m: &impl core::UMatTraitConst, wscale: i32, iwscale: i32) -> Result { + pub fn write_only_no_size(m: &impl core::UMatTraitConst, wscale: i32, iwscale: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_KernelArg_WriteOnlyNoSize_const_UMatR_int_int(m.as_raw_UMat(), wscale, iwscale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::KernelArg::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [KernelArg::write_only_no_size] function uses the following default values for its arguments: + /// * wscale: 1 + /// * iwscale: 1 + #[inline] + pub fn write_only_no_size_def(m: &impl core::UMatTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_KernelArg_WriteOnlyNoSize_const_UMatR(m.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::KernelArg::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn constant(m: &impl core::MatTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_KernelArg_Constant_const_MatR(m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::KernelArg::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [core::KernelArg] + pub trait KernelArgTraitConst { + fn as_raw_KernelArg(&self) -> *const c_void; + + #[inline] + fn flags(&self) -> i32 { + let ret = unsafe { sys::cv_ocl_KernelArg_propFlags_const(self.as_raw_KernelArg()) }; + ret + } + + #[inline] + fn obj(&self) -> *const c_void { + let ret = unsafe { sys::cv_ocl_KernelArg_propObj_const(self.as_raw_KernelArg()) }; + ret + } + + #[inline] + fn sz(&self) -> size_t { + let ret = unsafe { sys::cv_ocl_KernelArg_propSz_const(self.as_raw_KernelArg()) }; + ret + } + + #[inline] + fn wscale(&self) -> i32 { + let ret = unsafe { sys::cv_ocl_KernelArg_propWscale_const(self.as_raw_KernelArg()) }; + ret + } + + #[inline] + fn iwscale(&self) -> i32 { + let ret = unsafe { sys::cv_ocl_KernelArg_propIwscale_const(self.as_raw_KernelArg()) }; + ret + } + + } + + /// Mutable methods for [core::KernelArg] + pub trait KernelArgTrait: core::KernelArgTraitConst { + fn as_raw_mut_KernelArg(&mut self) -> *mut c_void; + + #[inline] + fn set_flags(&mut self, val: i32) { + let ret = unsafe { sys::cv_ocl_KernelArg_propFlags_const_int(self.as_raw_mut_KernelArg(), val) }; + ret + } + + #[inline] + fn m(&mut self) -> core::UMat { + let ret = unsafe { sys::cv_ocl_KernelArg_propM(self.as_raw_mut_KernelArg()) }; + let ret = unsafe { core::UMat::opencv_from_extern(ret) }; + ret + } + + #[inline] + fn set_m(&mut self, val: &impl core::UMatTraitConst) { + let ret = unsafe { sys::cv_ocl_KernelArg_propM_UMatX(self.as_raw_mut_KernelArg(), val.as_raw_UMat()) }; + ret + } + + #[inline] + fn set_sz(&mut self, val: size_t) { + let ret = unsafe { sys::cv_ocl_KernelArg_propSz_const_size_t(self.as_raw_mut_KernelArg(), val) }; + ret + } + + #[inline] + fn set_wscale(&mut self, val: i32) { + let ret = unsafe { sys::cv_ocl_KernelArg_propWscale_const_int(self.as_raw_mut_KernelArg(), val) }; + ret + } + + #[inline] + fn set_iwscale(&mut self, val: i32) { + let ret = unsafe { sys::cv_ocl_KernelArg_propIwscale_const_int(self.as_raw_mut_KernelArg(), val) }; + ret + } + + } + + impl Default for KernelArg { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } + } + + impl std::fmt::Debug for KernelArg { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("KernelArg") + .field("flags", &core::KernelArgTraitConst::flags(self)) + .field("obj", &core::KernelArgTraitConst::obj(self)) + .field("sz", &core::KernelArgTraitConst::sz(self)) + .field("wscale", &core::KernelArgTraitConst::wscale(self)) + .field("iwscale", &core::KernelArgTraitConst::iwscale(self)) + .finish() + } + } + + impl core::KernelArgTraitConst for KernelArg { + #[inline] fn as_raw_KernelArg(&self) -> *const c_void { self.as_raw() } + } + + impl core::KernelArgTrait for KernelArg { + #[inline] fn as_raw_mut_KernelArg(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { KernelArg, core::KernelArgTraitConst, as_raw_KernelArg, core::KernelArgTrait, as_raw_mut_KernelArg } + + pub struct OpenCLExecutionContext { + ptr: *mut c_void, + } + + opencv_type_boxed! { OpenCLExecutionContext } + + impl Drop for OpenCLExecutionContext { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_ocl_OpenCLExecutionContext_delete(self.as_raw_mut_OpenCLExecutionContext()) }; + } + } + + unsafe impl Send for OpenCLExecutionContext {} + + impl OpenCLExecutionContext { + #[inline] + pub fn default() -> core::OpenCLExecutionContext { + let ret = unsafe { sys::cv_ocl_OpenCLExecutionContext_OpenCLExecutionContext() }; + let ret = unsafe { core::OpenCLExecutionContext::opencv_from_extern(ret) }; + ret + } + + #[inline] + pub fn copy(unnamed: &impl core::OpenCLExecutionContextTraitConst) -> core::OpenCLExecutionContext { + let ret = unsafe { sys::cv_ocl_OpenCLExecutionContext_OpenCLExecutionContext_const_OpenCLExecutionContextR(unnamed.as_raw_OpenCLExecutionContext()) }; + let ret = unsafe { core::OpenCLExecutionContext::opencv_from_extern(ret) }; + ret + } + + #[inline] + pub fn copy_mut(mut unnamed: core::OpenCLExecutionContext) -> core::OpenCLExecutionContext { + let ret = unsafe { sys::cv_ocl_OpenCLExecutionContext_OpenCLExecutionContext_OpenCLExecutionContextRR(unnamed.as_raw_mut_OpenCLExecutionContext()) }; + let ret = unsafe { core::OpenCLExecutionContext::opencv_from_extern(ret) }; + ret + } + + /// Get OpenCL execution context of current thread. + /// + /// Initialize OpenCL execution context if it is empty + /// - create new + /// - reuse context of the main thread (threadID = 0) + #[inline] + pub fn get_current() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_OpenCLExecutionContext_getCurrent(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::OpenCLExecutionContext::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Get OpenCL execution context of current thread (can be empty) + #[inline] + pub fn get_current_ref() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_OpenCLExecutionContext_getCurrentRef(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::OpenCLExecutionContext::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Creates OpenCL execution context + /// OpenCV will check if available OpenCL platform has platformName name, + /// then assign context to OpenCV. + /// The deviceID device will be used as target device and a new command queue will be created. + /// + /// + /// Note: On success, ownership of one reference of the context and device is taken. + /// The caller should additionally call `clRetainContext` and/or `clRetainDevice` + /// to increase the reference count if it wishes to continue using them. + /// + /// ## Parameters + /// * platformName: name of OpenCL platform to attach, this string is used to check if platform is available to OpenCV at runtime + /// * platformID: ID of platform attached context was created for (cl_platform_id) + /// * context: OpenCL context to be attached to OpenCV (cl_context) + /// * deviceID: OpenCL device (cl_device_id) + #[inline] + pub unsafe fn create(platform_name: &str, platform_id: *mut c_void, context: *mut c_void, device_id: *mut c_void) -> Result { + extern_container_arg!(platform_name); return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_KernelArg_WriteOnlyNoSize_const_UMatR_int_int(m.as_raw_UMat(), wscale, iwscale, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_ocl_OpenCLExecutionContext_create_const_stringR_voidX_voidX_voidX(platform_name.opencv_as_extern(), platform_id, context, device_id, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::KernelArg::opencv_from_extern(ret) }; + let ret = { core::OpenCLExecutionContext::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [KernelArg::write_only_no_size] function uses the following default values for its arguments: - /// * wscale: 1 - /// * iwscale: 1 + /// Creates OpenCL execution context + /// + /// ## Parameters + /// * context: non-empty OpenCL context + /// * device: non-empty OpenCL device (must be a part of context) + /// * queue: non-empty OpenCL queue for provided context and device #[inline] - pub fn write_only_no_size_def(m: &impl core::UMatTraitConst) -> Result { + pub fn create_1(context: &impl core::ContextTraitConst, device: &impl core::DeviceTraitConst, queue: &impl core::QueueTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_KernelArg_WriteOnlyNoSize_const_UMatR(m.as_raw_UMat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_OpenCLExecutionContext_create_const_ContextR_const_DeviceR_const_QueueR(context.as_raw_Context(), device.as_raw_Device(), queue.as_raw_Queue(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::KernelArg::opencv_from_extern(ret) }; + let ret = unsafe { core::OpenCLExecutionContext::opencv_from_extern(ret) }; Ok(ret) } + /// Creates OpenCL execution context + /// + /// ## Parameters + /// * context: non-empty OpenCL context + /// * device: non-empty OpenCL device (must be a part of context) + /// * queue: non-empty OpenCL queue for provided context and device + /// + /// ## Overloaded parameters #[inline] - pub fn constant(m: &impl core::MatTraitConst) -> Result { + pub fn create_2(context: &impl core::ContextTraitConst, device: &impl core::DeviceTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_KernelArg_Constant_const_MatR(m.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_OpenCLExecutionContext_create_const_ContextR_const_DeviceR(context.as_raw_Context(), device.as_raw_Device(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::KernelArg::opencv_from_extern(ret) }; + let ret = unsafe { core::OpenCLExecutionContext::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for KernelArg { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("KernelArg") - .field("flags", &core::KernelArgTraitConst::flags(self)) - .field("obj", &core::KernelArgTraitConst::obj(self)) - .field("sz", &core::KernelArgTraitConst::sz(self)) - .field("wscale", &core::KernelArgTraitConst::wscale(self)) - .field("iwscale", &core::KernelArgTraitConst::iwscale(self)) - .finish() - } - } - - impl Default for KernelArg { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - /// Constant methods for [core::OpenCLExecutionContext] pub trait OpenCLExecutionContextTraitConst { fn as_raw_OpenCLExecutionContext(&self) -> *const c_void; @@ -37188,21 +37303,22 @@ pub mod core { } - pub struct OpenCLExecutionContext { - ptr: *mut c_void, + impl Default for OpenCLExecutionContext { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { OpenCLExecutionContext } - - impl Drop for OpenCLExecutionContext { + impl std::fmt::Debug for OpenCLExecutionContext { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ocl_OpenCLExecutionContext_delete(self.as_raw_mut_OpenCLExecutionContext()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("OpenCLExecutionContext") + .finish() } } - unsafe impl Send for OpenCLExecutionContext {} - impl core::OpenCLExecutionContextTraitConst for OpenCLExecutionContext { #[inline] fn as_raw_OpenCLExecutionContext(&self) -> *const c_void { self.as_raw() } } @@ -37213,132 +37329,60 @@ pub mod core { boxed_ref! { OpenCLExecutionContext, core::OpenCLExecutionContextTraitConst, as_raw_OpenCLExecutionContext, core::OpenCLExecutionContextTrait, as_raw_mut_OpenCLExecutionContext } - impl OpenCLExecutionContext { - #[inline] - pub fn default() -> core::OpenCLExecutionContext { - let ret = unsafe { sys::cv_ocl_OpenCLExecutionContext_OpenCLExecutionContext() }; - let ret = unsafe { core::OpenCLExecutionContext::opencv_from_extern(ret) }; - ret - } + /// @deprecated + pub struct Platform { + ptr: *mut c_void, + } - #[inline] - pub fn copy(unnamed: &impl core::OpenCLExecutionContextTraitConst) -> core::OpenCLExecutionContext { - let ret = unsafe { sys::cv_ocl_OpenCLExecutionContext_OpenCLExecutionContext_const_OpenCLExecutionContextR(unnamed.as_raw_OpenCLExecutionContext()) }; - let ret = unsafe { core::OpenCLExecutionContext::opencv_from_extern(ret) }; - ret - } + opencv_type_boxed! { Platform } + impl Drop for Platform { #[inline] - pub fn copy_mut(mut unnamed: core::OpenCLExecutionContext) -> core::OpenCLExecutionContext { - let ret = unsafe { sys::cv_ocl_OpenCLExecutionContext_OpenCLExecutionContext_OpenCLExecutionContextRR(unnamed.as_raw_mut_OpenCLExecutionContext()) }; - let ret = unsafe { core::OpenCLExecutionContext::opencv_from_extern(ret) }; - ret + fn drop(&mut self) { + unsafe { sys::cv_ocl_Platform_delete(self.as_raw_mut_Platform()) }; } + } - /// Get OpenCL execution context of current thread. - /// - /// Initialize OpenCL execution context if it is empty - /// - create new - /// - reuse context of the main thread (threadID = 0) - #[inline] - pub fn get_current() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_OpenCLExecutionContext_getCurrent(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::OpenCLExecutionContext::opencv_from_extern(ret) }; - Ok(ret) - } + unsafe impl Send for Platform {} - /// Get OpenCL execution context of current thread (can be empty) + impl Platform { #[inline] - pub fn get_current_ref() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_OpenCLExecutionContext_getCurrentRef(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::OpenCLExecutionContext::opencv_from_extern(ret) }; - Ok(ret) + pub fn default() -> core::Platform { + let ret = unsafe { sys::cv_ocl_Platform_Platform() }; + let ret = unsafe { core::Platform::opencv_from_extern(ret) }; + ret } - /// Creates OpenCL execution context - /// OpenCV will check if available OpenCL platform has platformName name, - /// then assign context to OpenCV. - /// The deviceID device will be used as target device and a new command queue will be created. - /// - /// - /// Note: On success, ownership of one reference of the context and device is taken. - /// The caller should additionally call `clRetainContext` and/or `clRetainDevice` - /// to increase the reference count if it wishes to continue using them. - /// - /// ## Parameters - /// * platformName: name of OpenCL platform to attach, this string is used to check if platform is available to OpenCV at runtime - /// * platformID: ID of platform attached context was created for (cl_platform_id) - /// * context: OpenCL context to be attached to OpenCV (cl_context) - /// * deviceID: OpenCL device (cl_device_id) #[inline] - pub unsafe fn create(platform_name: &str, platform_id: *mut c_void, context: *mut c_void, device_id: *mut c_void) -> Result { - extern_container_arg!(platform_name); + pub fn copy(p: &impl core::PlatformTraitConst) -> Result { return_send!(via ocvrs_return); - { sys::cv_ocl_OpenCLExecutionContext_create_const_stringR_voidX_voidX_voidX(platform_name.opencv_as_extern(), platform_id, context, device_id, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_ocl_Platform_Platform_const_PlatformR(p.as_raw_Platform(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::OpenCLExecutionContext::opencv_from_extern(ret) }; + let ret = unsafe { core::Platform::opencv_from_extern(ret) }; Ok(ret) } - /// Creates OpenCL execution context - /// - /// ## Parameters - /// * context: non-empty OpenCL context - /// * device: non-empty OpenCL device (must be a part of context) - /// * queue: non-empty OpenCL queue for provided context and device #[inline] - pub fn create_1(context: &impl core::ContextTraitConst, device: &impl core::DeviceTraitConst, queue: &impl core::QueueTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_OpenCLExecutionContext_create_const_ContextR_const_DeviceR_const_QueueR(context.as_raw_Context(), device.as_raw_Device(), queue.as_raw_Queue(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::OpenCLExecutionContext::opencv_from_extern(ret) }; - Ok(ret) + pub fn copy_mut(mut p: core::Platform) -> core::Platform { + let ret = unsafe { sys::cv_ocl_Platform_Platform_PlatformRR(p.as_raw_mut_Platform()) }; + let ret = unsafe { core::Platform::opencv_from_extern(ret) }; + ret } - /// Creates OpenCL execution context - /// - /// ## Parameters - /// * context: non-empty OpenCL context - /// * device: non-empty OpenCL device (must be a part of context) - /// * queue: non-empty OpenCL queue for provided context and device - /// - /// ## Overloaded parameters + /// @deprecated #[inline] - pub fn create_2(context: &impl core::ContextTraitConst, device: &impl core::DeviceTraitConst) -> Result { + pub fn get_default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_OpenCLExecutionContext_create_const_ContextR_const_DeviceR(context.as_raw_Context(), device.as_raw_Device(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_Platform_getDefault(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::OpenCLExecutionContext::opencv_from_extern(ret) }; + let ret = unsafe { core::Platform::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for OpenCLExecutionContext { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("OpenCLExecutionContext") - .finish() - } - } - - impl Default for OpenCLExecutionContext { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - /// Constant methods for [core::Platform] pub trait PlatformTraitConst { fn as_raw_Platform(&self) -> *const c_void; @@ -37384,22 +37428,22 @@ pub mod core { } - /// @deprecated - pub struct Platform { - ptr: *mut c_void, + impl Default for Platform { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Platform } - - impl Drop for Platform { + impl std::fmt::Debug for Platform { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ocl_Platform_delete(self.as_raw_mut_Platform()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Platform") + .finish() } } - unsafe impl Send for Platform {} - impl core::PlatformTraitConst for Platform { #[inline] fn as_raw_Platform(&self) -> *const c_void { self.as_raw() } } @@ -37410,58 +37454,58 @@ pub mod core { boxed_ref! { Platform, core::PlatformTraitConst, as_raw_Platform, core::PlatformTrait, as_raw_mut_Platform } - impl Platform { - #[inline] - pub fn default() -> core::Platform { - let ret = unsafe { sys::cv_ocl_Platform_Platform() }; - let ret = unsafe { core::Platform::opencv_from_extern(ret) }; - ret - } + pub struct PlatformInfo { + ptr: *mut c_void, + } + + opencv_type_boxed! { PlatformInfo } + impl Drop for PlatformInfo { #[inline] - pub fn copy(p: &impl core::PlatformTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Platform_Platform_const_PlatformR(p.as_raw_Platform(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Platform::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_ocl_PlatformInfo_delete(self.as_raw_mut_PlatformInfo()) }; } + } + unsafe impl Send for PlatformInfo {} + + impl PlatformInfo { #[inline] - pub fn copy_mut(mut p: core::Platform) -> core::Platform { - let ret = unsafe { sys::cv_ocl_Platform_Platform_PlatformRR(p.as_raw_mut_Platform()) }; - let ret = unsafe { core::Platform::opencv_from_extern(ret) }; + pub fn default() -> core::PlatformInfo { + let ret = unsafe { sys::cv_ocl_PlatformInfo_PlatformInfo() }; + let ret = unsafe { core::PlatformInfo::opencv_from_extern(ret) }; ret } - /// @deprecated + /// ## Parameters + /// * id: pointer cl_platform_id (cl_platform_id*) #[inline] - pub fn get_default() -> Result { + pub unsafe fn new(id: *mut c_void) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Platform_getDefault(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_ocl_PlatformInfo_PlatformInfo_voidX(id, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Platform::opencv_from_extern(ret) }; + let ret = { core::PlatformInfo::opencv_from_extern(ret) }; Ok(ret) } - } - - impl std::fmt::Debug for Platform { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Platform") - .finish() + pub fn copy(i: &impl core::PlatformInfoTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_PlatformInfo_PlatformInfo_const_PlatformInfoR(i.as_raw_PlatformInfo(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::PlatformInfo::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for Platform { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn copy_mut(mut i: core::PlatformInfo) -> core::PlatformInfo { + let ret = unsafe { sys::cv_ocl_PlatformInfo_PlatformInfo_PlatformInfoRR(i.as_raw_mut_PlatformInfo()) }; + let ret = unsafe { core::PlatformInfo::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [core::PlatformInfo] @@ -37567,21 +37611,22 @@ pub mod core { } - pub struct PlatformInfo { - ptr: *mut c_void, + impl Default for PlatformInfo { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { PlatformInfo } - - impl Drop for PlatformInfo { + impl std::fmt::Debug for PlatformInfo { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ocl_PlatformInfo_delete(self.as_raw_mut_PlatformInfo()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PlatformInfo") + .finish() } } - unsafe impl Send for PlatformInfo {} - impl core::PlatformInfoTraitConst for PlatformInfo { #[inline] fn as_raw_PlatformInfo(&self) -> *const c_void { self.as_raw() } } @@ -37592,59 +37637,70 @@ pub mod core { boxed_ref! { PlatformInfo, core::PlatformInfoTraitConst, as_raw_PlatformInfo, core::PlatformInfoTrait, as_raw_mut_PlatformInfo } - impl PlatformInfo { + pub struct Program { + ptr: *mut c_void, + } + + opencv_type_boxed! { Program } + + impl Drop for Program { #[inline] - pub fn default() -> core::PlatformInfo { - let ret = unsafe { sys::cv_ocl_PlatformInfo_PlatformInfo() }; - let ret = unsafe { core::PlatformInfo::opencv_from_extern(ret) }; + fn drop(&mut self) { + unsafe { sys::cv_ocl_Program_delete(self.as_raw_mut_Program()) }; + } + } + + unsafe impl Send for Program {} + + impl Program { + #[inline] + pub fn default() -> core::Program { + let ret = unsafe { sys::cv_ocl_Program_Program() }; + let ret = unsafe { core::Program::opencv_from_extern(ret) }; ret } - /// ## Parameters - /// * id: pointer cl_platform_id (cl_platform_id*) #[inline] - pub unsafe fn new(id: *mut c_void) -> Result { + pub fn new(src: &impl core::ProgramSourceTraitConst, buildflags: &str, errmsg: &mut String) -> Result { + extern_container_arg!(buildflags); + string_arg_output_send!(via errmsg_via); return_send!(via ocvrs_return); - { sys::cv_ocl_PlatformInfo_PlatformInfo_voidX(id, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); + unsafe { sys::cv_ocl_Program_Program_const_ProgramSourceR_const_StringR_StringR(src.as_raw_ProgramSource(), buildflags.opencv_as_extern(), &mut errmsg_via, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = { core::PlatformInfo::opencv_from_extern(ret) }; + let ret = unsafe { core::Program::opencv_from_extern(ret) }; + string_arg_output_receive!(errmsg_via => errmsg); Ok(ret) } #[inline] - pub fn copy(i: &impl core::PlatformInfoTraitConst) -> Result { + pub fn copy(prog: &impl core::ProgramTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_PlatformInfo_PlatformInfo_const_PlatformInfoR(i.as_raw_PlatformInfo(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_Program_Program_const_ProgramR(prog.as_raw_Program(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::PlatformInfo::opencv_from_extern(ret) }; + let ret = unsafe { core::Program::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn copy_mut(mut i: core::PlatformInfo) -> core::PlatformInfo { - let ret = unsafe { sys::cv_ocl_PlatformInfo_PlatformInfo_PlatformInfoRR(i.as_raw_mut_PlatformInfo()) }; - let ret = unsafe { core::PlatformInfo::opencv_from_extern(ret) }; + pub fn copy_mut(mut prog: core::Program) -> core::Program { + let ret = unsafe { sys::cv_ocl_Program_Program_ProgramRR(prog.as_raw_mut_Program()) }; + let ret = unsafe { core::Program::opencv_from_extern(ret) }; ret } - } - - impl std::fmt::Debug for PlatformInfo { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PlatformInfo") - .finish() + pub fn get_prefix_build_flags(buildflags: &str) -> Result { + extern_container_arg!(buildflags); + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_Program_getPrefix_const_StringR(buildflags.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { String::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for PlatformInfo { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } } /// Constant methods for [core::Program] @@ -37734,154 +37790,28 @@ pub mod core { #[inline] fn set_1(&mut self, mut prog: core::Program) { - let ret = unsafe { sys::cv_ocl_Program_operatorST_ProgramRR(self.as_raw_mut_Program(), prog.as_raw_mut_Program()) }; - ret - } - - #[inline] - fn create(&mut self, src: &impl core::ProgramSourceTraitConst, buildflags: &str, errmsg: &mut String) -> Result { - extern_container_arg!(buildflags); - string_arg_output_send!(via errmsg_via); - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Program_create_const_ProgramSourceR_const_StringR_StringR(self.as_raw_mut_Program(), src.as_raw_ProgramSource(), buildflags.opencv_as_extern(), &mut errmsg_via, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - string_arg_output_receive!(errmsg_via => errmsg); - Ok(ret) - } - - #[inline] - fn read(&mut self, buf: &str, buildflags: &str) -> Result { - extern_container_arg!(buf); - extern_container_arg!(buildflags); - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Program_read_const_StringR_const_StringR(self.as_raw_mut_Program(), buf.opencv_as_extern(), buildflags.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - pub struct Program { - ptr: *mut c_void, - } - - opencv_type_boxed! { Program } - - impl Drop for Program { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ocl_Program_delete(self.as_raw_mut_Program()) }; - } - } - - unsafe impl Send for Program {} - - impl core::ProgramTraitConst for Program { - #[inline] fn as_raw_Program(&self) -> *const c_void { self.as_raw() } - } - - impl core::ProgramTrait for Program { - #[inline] fn as_raw_mut_Program(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Program, core::ProgramTraitConst, as_raw_Program, core::ProgramTrait, as_raw_mut_Program } - - impl Program { - #[inline] - pub fn default() -> core::Program { - let ret = unsafe { sys::cv_ocl_Program_Program() }; - let ret = unsafe { core::Program::opencv_from_extern(ret) }; - ret - } - - #[inline] - pub fn new(src: &impl core::ProgramSourceTraitConst, buildflags: &str, errmsg: &mut String) -> Result { - extern_container_arg!(buildflags); - string_arg_output_send!(via errmsg_via); - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Program_Program_const_ProgramSourceR_const_StringR_StringR(src.as_raw_ProgramSource(), buildflags.opencv_as_extern(), &mut errmsg_via, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Program::opencv_from_extern(ret) }; - string_arg_output_receive!(errmsg_via => errmsg); - Ok(ret) - } - - #[inline] - pub fn copy(prog: &impl core::ProgramTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Program_Program_const_ProgramR(prog.as_raw_Program(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Program::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn copy_mut(mut prog: core::Program) -> core::Program { - let ret = unsafe { sys::cv_ocl_Program_Program_ProgramRR(prog.as_raw_mut_Program()) }; - let ret = unsafe { core::Program::opencv_from_extern(ret) }; - ret - } - - #[inline] - pub fn get_prefix_build_flags(buildflags: &str) -> Result { - extern_container_arg!(buildflags); - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Program_getPrefix_const_StringR(buildflags.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { String::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for Program { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Program") - .finish() - } - } - - impl Default for Program { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - - /// Constant methods for [core::ProgramSource] - pub trait ProgramSourceTraitConst { - fn as_raw_ProgramSource(&self) -> *const c_void; - - #[inline] - fn source(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_ProgramSource_source_const(self.as_raw_ProgramSource(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { String::opencv_from_extern(ret) }; - Ok(ret) + let ret = unsafe { sys::cv_ocl_Program_operatorST_ProgramRR(self.as_raw_mut_Program(), prog.as_raw_mut_Program()) }; + ret } #[inline] - fn hash(&self) -> Result { + fn create(&mut self, src: &impl core::ProgramSourceTraitConst, buildflags: &str, errmsg: &mut String) -> Result { + extern_container_arg!(buildflags); + string_arg_output_send!(via errmsg_via); return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_ProgramSource_hash_const(self.as_raw_ProgramSource(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_Program_create_const_ProgramSourceR_const_StringR_StringR(self.as_raw_mut_Program(), src.as_raw_ProgramSource(), buildflags.opencv_as_extern(), &mut errmsg_via, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + string_arg_output_receive!(errmsg_via => errmsg); Ok(ret) } #[inline] - fn empty(&self) -> Result { + fn read(&mut self, buf: &str, buildflags: &str) -> Result { + extern_container_arg!(buf); + extern_container_arg!(buildflags); return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_ProgramSource_empty_const(self.as_raw_ProgramSource(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_Program_read_const_StringR_const_StringR(self.as_raw_mut_Program(), buf.opencv_as_extern(), buildflags.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -37889,27 +37819,32 @@ pub mod core { } - /// Mutable methods for [core::ProgramSource] - pub trait ProgramSourceTrait: core::ProgramSourceTraitConst { - fn as_raw_mut_ProgramSource(&mut self) -> *mut c_void; - + impl Default for Program { #[inline] - fn set(&mut self, prog: &impl core::ProgramSourceTraitConst) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_ProgramSource_operatorST_const_ProgramSourceR(self.as_raw_mut_ProgramSource(), prog.as_raw_ProgramSource(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() } + } + impl std::fmt::Debug for Program { #[inline] - fn set_1(&mut self, mut prog: core::ProgramSource) { - let ret = unsafe { sys::cv_ocl_ProgramSource_operatorST_ProgramSourceRR(self.as_raw_mut_ProgramSource(), prog.as_raw_mut_ProgramSource()) }; - ret + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Program") + .finish() } + } + + impl core::ProgramTraitConst for Program { + #[inline] fn as_raw_Program(&self) -> *const c_void { self.as_raw() } + } + impl core::ProgramTrait for Program { + #[inline] fn as_raw_mut_Program(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { Program, core::ProgramTraitConst, as_raw_Program, core::ProgramTrait, as_raw_mut_Program } + pub struct ProgramSource { ptr: *mut c_void, } @@ -37925,16 +37860,6 @@ pub mod core { unsafe impl Send for ProgramSource {} - impl core::ProgramSourceTraitConst for ProgramSource { - #[inline] fn as_raw_ProgramSource(&self) -> *const c_void { self.as_raw() } - } - - impl core::ProgramSourceTrait for ProgramSource { - #[inline] fn as_raw_mut_ProgramSource(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { ProgramSource, core::ProgramSourceTraitConst, as_raw_ProgramSource, core::ProgramSourceTrait, as_raw_mut_ProgramSource } - impl ProgramSource { #[inline] pub fn default() -> core::ProgramSource { @@ -38125,50 +38050,33 @@ pub mod core { } - impl std::fmt::Debug for ProgramSource { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ProgramSource") - .finish() - } - } - - impl Default for ProgramSource { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - - /// Constant methods for [core::Queue] - pub trait QueueTraitConst { - fn as_raw_Queue(&self) -> *const c_void; + /// Constant methods for [core::ProgramSource] + pub trait ProgramSourceTraitConst { + fn as_raw_ProgramSource(&self) -> *const c_void; #[inline] - fn ptr(&self) -> Result<*mut c_void> { + fn source(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Queue_ptr_const(self.as_raw_Queue(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_ProgramSource_source_const(self.as_raw_ProgramSource(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { String::opencv_from_extern(ret) }; Ok(ret) } - /// Returns OpenCL command queue with enable profiling mode support #[inline] - fn get_profiling_queue(&self) -> Result { + fn hash(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Queue_getProfilingQueue_const(self.as_raw_Queue(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_ProgramSource_hash_const(self.as_raw_ProgramSource(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Queue::opencv_from_extern(ret) }; Ok(ret) } #[inline] fn empty(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Queue_empty_const(self.as_raw_Queue(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_ProgramSource_empty_const(self.as_raw_ProgramSource(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -38176,146 +38084,226 @@ pub mod core { } - /// Mutable methods for [core::Queue] - pub trait QueueTrait: core::QueueTraitConst { - fn as_raw_mut_Queue(&mut self) -> *mut c_void; + /// Mutable methods for [core::ProgramSource] + pub trait ProgramSourceTrait: core::ProgramSourceTraitConst { + fn as_raw_mut_ProgramSource(&mut self) -> *mut c_void; #[inline] - fn set(&mut self, q: &impl core::QueueTraitConst) -> Result<()> { + fn set(&mut self, prog: &impl core::ProgramSourceTraitConst) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Queue_operatorST_const_QueueR(self.as_raw_mut_Queue(), q.as_raw_Queue(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_ProgramSource_operatorST_const_ProgramSourceR(self.as_raw_mut_ProgramSource(), prog.as_raw_ProgramSource(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn set_1(&mut self, mut q: core::Queue) { - let ret = unsafe { sys::cv_ocl_Queue_operatorST_QueueRR(self.as_raw_mut_Queue(), q.as_raw_mut_Queue()) }; + fn set_1(&mut self, mut prog: core::ProgramSource) { + let ret = unsafe { sys::cv_ocl_ProgramSource_operatorST_ProgramSourceRR(self.as_raw_mut_ProgramSource(), prog.as_raw_mut_ProgramSource()) }; + ret + } + + } + + impl Default for ProgramSource { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } + } + + impl std::fmt::Debug for ProgramSource { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ProgramSource") + .finish() + } + } + + impl core::ProgramSourceTraitConst for ProgramSource { + #[inline] fn as_raw_ProgramSource(&self) -> *const c_void { self.as_raw() } + } + + impl core::ProgramSourceTrait for ProgramSource { + #[inline] fn as_raw_mut_ProgramSource(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { ProgramSource, core::ProgramSourceTraitConst, as_raw_ProgramSource, core::ProgramSourceTrait, as_raw_mut_ProgramSource } + + pub struct Queue { + ptr: *mut c_void, + } + + opencv_type_boxed! { Queue } + + impl Drop for Queue { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_ocl_Queue_delete(self.as_raw_mut_Queue()) }; + } + } + + unsafe impl Send for Queue {} + + impl Queue { + #[inline] + pub fn default() -> core::Queue { + let ret = unsafe { sys::cv_ocl_Queue_Queue() }; + let ret = unsafe { core::Queue::opencv_from_extern(ret) }; ret } /// ## C++ default parameters - /// * c: Context() /// * d: Device() #[inline] - fn create(&mut self, c: &impl core::ContextTraitConst, d: &impl core::DeviceTraitConst) -> Result { + pub fn new(c: &impl core::ContextTraitConst, d: &impl core::DeviceTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Queue_create_const_ContextR_const_DeviceR(self.as_raw_mut_Queue(), c.as_raw_Context(), d.as_raw_Device(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_Queue_Queue_const_ContextR_const_DeviceR(c.as_raw_Context(), d.as_raw_Device(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Queue::opencv_from_extern(ret) }; Ok(ret) } /// ## Note - /// This alternative version of [QueueTrait::create] function uses the following default values for its arguments: - /// * c: Context() + /// This alternative version of [new] function uses the following default values for its arguments: /// * d: Device() #[inline] - fn create_def(&mut self) -> Result { + pub fn new_def(c: &impl core::ContextTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Queue_create(self.as_raw_mut_Queue(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_Queue_Queue_const_ContextR(c.as_raw_Context(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Queue::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn finish(&mut self) -> Result<()> { + pub fn copy(q: &impl core::QueueTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Queue_finish(self.as_raw_mut_Queue(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_Queue_Queue_const_QueueR(q.as_raw_Queue(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Queue::opencv_from_extern(ret) }; Ok(ret) } - } + #[inline] + pub fn copy_mut(mut q: core::Queue) -> core::Queue { + let ret = unsafe { sys::cv_ocl_Queue_Queue_QueueRR(q.as_raw_mut_Queue()) }; + let ret = unsafe { core::Queue::opencv_from_extern(ret) }; + ret + } + + #[inline] + pub fn get_default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_Queue_getDefault(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Queue::opencv_from_extern(ret) }; + Ok(ret) + } - pub struct Queue { - ptr: *mut c_void, } - opencv_type_boxed! { Queue } + /// Constant methods for [core::Queue] + pub trait QueueTraitConst { + fn as_raw_Queue(&self) -> *const c_void; - impl Drop for Queue { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ocl_Queue_delete(self.as_raw_mut_Queue()) }; + fn ptr(&self) -> Result<*mut c_void> { + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_Queue_ptr_const(self.as_raw_Queue(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } - } - unsafe impl Send for Queue {} + /// Returns OpenCL command queue with enable profiling mode support + #[inline] + fn get_profiling_queue(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_Queue_getProfilingQueue_const(self.as_raw_Queue(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Queue::opencv_from_extern(ret) }; + Ok(ret) + } - impl core::QueueTraitConst for Queue { - #[inline] fn as_raw_Queue(&self) -> *const c_void { self.as_raw() } - } + #[inline] + fn empty(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_Queue_empty_const(self.as_raw_Queue(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - impl core::QueueTrait for Queue { - #[inline] fn as_raw_mut_Queue(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { Queue, core::QueueTraitConst, as_raw_Queue, core::QueueTrait, as_raw_mut_Queue } + /// Mutable methods for [core::Queue] + pub trait QueueTrait: core::QueueTraitConst { + fn as_raw_mut_Queue(&mut self) -> *mut c_void; - impl Queue { #[inline] - pub fn default() -> core::Queue { - let ret = unsafe { sys::cv_ocl_Queue_Queue() }; - let ret = unsafe { core::Queue::opencv_from_extern(ret) }; + fn set(&mut self, q: &impl core::QueueTraitConst) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_Queue_operatorST_const_QueueR(self.as_raw_mut_Queue(), q.as_raw_Queue(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn set_1(&mut self, mut q: core::Queue) { + let ret = unsafe { sys::cv_ocl_Queue_operatorST_QueueRR(self.as_raw_mut_Queue(), q.as_raw_mut_Queue()) }; ret } /// ## C++ default parameters + /// * c: Context() /// * d: Device() #[inline] - pub fn new(c: &impl core::ContextTraitConst, d: &impl core::DeviceTraitConst) -> Result { + fn create(&mut self, c: &impl core::ContextTraitConst, d: &impl core::DeviceTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Queue_Queue_const_ContextR_const_DeviceR(c.as_raw_Context(), d.as_raw_Device(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_Queue_create_const_ContextR_const_DeviceR(self.as_raw_mut_Queue(), c.as_raw_Context(), d.as_raw_Device(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Queue::opencv_from_extern(ret) }; Ok(ret) } /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: + /// This alternative version of [QueueTrait::create] function uses the following default values for its arguments: + /// * c: Context() /// * d: Device() #[inline] - pub fn new_def(c: &impl core::ContextTraitConst) -> Result { + fn create_def(&mut self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Queue_Queue_const_ContextR(c.as_raw_Context(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_Queue_create(self.as_raw_mut_Queue(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Queue::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn copy(q: &impl core::QueueTraitConst) -> Result { + fn finish(&mut self) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Queue_Queue_const_QueueR(q.as_raw_Queue(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ocl_Queue_finish(self.as_raw_mut_Queue(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Queue::opencv_from_extern(ret) }; Ok(ret) } - #[inline] - pub fn copy_mut(mut q: core::Queue) -> core::Queue { - let ret = unsafe { sys::cv_ocl_Queue_Queue_QueueRR(q.as_raw_mut_Queue()) }; - let ret = unsafe { core::Queue::opencv_from_extern(ret) }; - ret - } + } + impl Default for Queue { #[inline] - pub fn get_default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Queue_getDefault(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Queue::opencv_from_extern(ret) }; - Ok(ret) + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() } - } impl std::fmt::Debug for Queue { @@ -38326,12 +38314,42 @@ pub mod core { } } - impl Default for Queue { + impl core::QueueTraitConst for Queue { + #[inline] fn as_raw_Queue(&self) -> *const c_void { self.as_raw() } + } + + impl core::QueueTrait for Queue { + #[inline] fn as_raw_mut_Queue(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Queue, core::QueueTraitConst, as_raw_Queue, core::QueueTrait, as_raw_mut_Queue } + + pub struct Timer { + ptr: *mut c_void, + } + + opencv_type_boxed! { Timer } + + impl Drop for Timer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + fn drop(&mut self) { + unsafe { sys::cv_ocl_Timer_delete(self.as_raw_mut_Timer()) }; + } + } + + unsafe impl Send for Timer {} + + impl Timer { + #[inline] + pub fn new(q: &impl core::QueueTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ocl_Timer_Timer_const_QueueR(q.as_raw_Queue(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Timer::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [core::Timer] @@ -38373,21 +38391,14 @@ pub mod core { } - pub struct Timer { - ptr: *mut c_void, - } - - opencv_type_boxed! { Timer } - - impl Drop for Timer { + impl std::fmt::Debug for Timer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ocl_Timer_delete(self.as_raw_mut_Timer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Timer") + .finish() } } - unsafe impl Send for Timer {} - impl core::TimerTraitConst for Timer { #[inline] fn as_raw_Timer(&self) -> *const c_void { self.as_raw() } } @@ -38398,27 +38409,38 @@ pub mod core { boxed_ref! { Timer, core::TimerTraitConst, as_raw_Timer, core::TimerTrait, as_raw_mut_Timer } - impl Timer { + /// Wrapper for OpenGL Client-Side Vertex arrays. + /// + /// ogl::Arrays stores vertex data in ogl::Buffer objects. + pub struct Arrays { + ptr: *mut c_void, + } + + opencv_type_boxed! { Arrays } + + impl Drop for Arrays { #[inline] - pub fn new(q: &impl core::QueueTraitConst) -> Result { + fn drop(&mut self) { + unsafe { sys::cv_ogl_Arrays_delete(self.as_raw_mut_Arrays()) }; + } + } + + unsafe impl Send for Arrays {} + + impl Arrays { + /// Default constructor + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ocl_Timer_Timer_const_QueueR(q.as_raw_Queue(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Arrays_Arrays(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Timer::opencv_from_extern(ret) }; + let ret = unsafe { core::Arrays::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for Timer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Timer") - .finish() - } - } - /// Constant methods for [core::Arrays] pub trait ArraysTraitConst { fn as_raw_Arrays(&self) -> *const c_void; @@ -38574,24 +38596,14 @@ pub mod core { } - /// Wrapper for OpenGL Client-Side Vertex arrays. - /// - /// ogl::Arrays stores vertex data in ogl::Buffer objects. - pub struct Arrays { - ptr: *mut c_void, - } - - opencv_type_boxed! { Arrays } - - impl Drop for Arrays { + impl std::fmt::Debug for Arrays { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ogl_Arrays_delete(self.as_raw_mut_Arrays()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Arrays") + .finish() } } - unsafe impl Send for Arrays {} - impl core::ArraysTraitConst for Arrays { #[inline] fn as_raw_Arrays(&self) -> *const c_void { self.as_raw() } } @@ -38602,218 +38614,195 @@ pub mod core { boxed_ref! { Arrays, core::ArraysTraitConst, as_raw_Arrays, core::ArraysTrait, as_raw_mut_Arrays } - impl Arrays { - /// Default constructor - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Arrays_Arrays(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Arrays::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for Arrays { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Arrays") - .finish() - } - } - - /// Constant methods for [core::Buffer] - pub trait BufferTraitConst { - fn as_raw_Buffer(&self) -> *const c_void; - - /// Copies from OpenGL buffer to host/device memory or another OpenGL buffer object. - /// - /// ## Parameters - /// * arr: Destination array (host or device memory, can be Mat , cuda::GpuMat , std::vector or - /// ogl::Buffer ). - #[inline] - fn copy_to(&self, arr: &mut impl ToOutputArray) -> Result<()> { - output_array_arg!(arr); - return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_copyTo_const_const__OutputArrayR(self.as_raw_Buffer(), arr.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Copies from OpenGL buffer to host/device memory or another OpenGL buffer object. - /// - /// ## Parameters - /// * arr: Destination array (host or device memory, can be Mat , cuda::GpuMat , std::vector or - /// ogl::Buffer ). - /// - /// ## Overloaded parameters - #[inline] - fn copy_to_1(&self, arr: &mut impl ToOutputArray, stream: &mut impl core::StreamTrait) -> Result<()> { - output_array_arg!(arr); - return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_copyTo_const_const__OutputArrayR_StreamR(self.as_raw_Buffer(), arr.as_raw__OutputArray(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Creates a full copy of the buffer object and the underlying data. - /// - /// ## Parameters - /// * target: Buffer usage for destination buffer. - /// * autoRelease: Auto release mode for destination buffer. - /// - /// ## C++ default parameters - /// * target: ARRAY_BUFFER - /// * auto_release: false - #[inline] - fn clone(&self, target: core::Buffer_Target, auto_release: bool) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_clone_const_Target_bool(self.as_raw_Buffer(), target, auto_release, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Creates a full copy of the buffer object and the underlying data. - /// - /// ## Parameters - /// * target: Buffer usage for destination buffer. - /// * autoRelease: Auto release mode for destination buffer. - /// - /// ## Note - /// This alternative version of [BufferTraitConst::clone] function uses the following default values for its arguments: - /// * target: ARRAY_BUFFER - /// * auto_release: false - #[inline] - fn clone_def(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_clone_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Binds OpenGL buffer to the specified buffer binding point. - /// - /// ## Parameters - /// * target: Binding point. See cv::ogl::Buffer::Target . - #[inline] - fn bind(&self, target: core::Buffer_Target) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_bind_const_Target(self.as_raw_Buffer(), target, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } + /// Smart pointer for OpenGL buffer object with reference counting. + /// + /// Buffer Objects are OpenGL objects that store an array of unformatted memory allocated by the OpenGL + /// context. These can be used to store vertex data, pixel data retrieved from images or the + /// framebuffer, and a variety of other things. + /// + /// ogl::Buffer has interface similar with Mat interface and represents 2D array memory. + /// + /// ogl::Buffer supports memory transfers between host and device and also can be mapped to CUDA memory. + pub struct Buffer { + ptr: *mut c_void, + } - #[inline] - fn rows(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_rows_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } + opencv_type_boxed! { Buffer } + impl Drop for Buffer { #[inline] - fn cols(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_cols_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_ogl_Buffer_delete(self.as_raw_mut_Buffer()) }; } + } - #[inline] - fn size(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_size_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } + unsafe impl Send for Buffer {} + impl Buffer { + /// The constructors. + /// + /// Creates empty ogl::Buffer object, creates ogl::Buffer object from existed buffer ( abufId + /// parameter), allocates memory for ogl::Buffer object or copies from host/device memory. #[inline] - fn empty(&self) -> Result { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_empty_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_Buffer(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } + /// The constructors. + /// + /// Creates empty ogl::Buffer object, creates ogl::Buffer object from existed buffer ( abufId + /// parameter), allocates memory for ogl::Buffer object or copies from host/device memory. + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * arows: Number of rows in a 2D array. + /// * acols: Number of columns in a 2D array. + /// * atype: Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + /// * abufId: Buffer object name. + /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). + /// + /// ## C++ default parameters + /// * auto_release: false #[inline] - fn typ(&self) -> Result { + pub fn new(arows: i32, acols: i32, atype: i32, abuf_id: u32, auto_release: bool) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_type_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_Buffer_int_int_int_unsigned_int_bool(arows, acols, atype, abuf_id, auto_release, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } + /// @overload + /// ## Parameters + /// * arows: Number of rows in a 2D array. + /// * acols: Number of columns in a 2D array. + /// * atype: Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + /// * abufId: Buffer object name. + /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * auto_release: false #[inline] - fn depth(&self) -> Result { + pub fn new_def(arows: i32, acols: i32, atype: i32, abuf_id: u32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_depth_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_Buffer_int_int_int_unsigned_int(arows, acols, atype, abuf_id, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } + /// The constructors. + /// + /// Creates empty ogl::Buffer object, creates ogl::Buffer object from existed buffer ( abufId + /// parameter), allocates memory for ogl::Buffer object or copies from host/device memory. + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * asize: 2D array size. + /// * atype: Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + /// * abufId: Buffer object name. + /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). + /// + /// ## C++ default parameters + /// * auto_release: false #[inline] - fn channels(&self) -> Result { + pub fn new_1(asize: core::Size, atype: i32, abuf_id: u32, auto_release: bool) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_channels_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_Buffer_Size_int_unsigned_int_bool(&asize, atype, abuf_id, auto_release, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } + /// @overload + /// ## Parameters + /// * asize: 2D array size. + /// * atype: Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + /// * abufId: Buffer object name. + /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * auto_release: false #[inline] - fn elem_size(&self) -> Result { + pub fn new_def_1(asize: core::Size, atype: i32, abuf_id: u32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_elemSize_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_Buffer_Size_int_unsigned_int(&asize, atype, abuf_id, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } + /// The constructors. + /// + /// Creates empty ogl::Buffer object, creates ogl::Buffer object from existed buffer ( abufId + /// parameter), allocates memory for ogl::Buffer object or copies from host/device memory. + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * arows: Number of rows in a 2D array. + /// * acols: Number of columns in a 2D array. + /// * atype: Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + /// * target: Buffer usage. See cv::ogl::Buffer::Target . + /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). + /// + /// ## C++ default parameters + /// * target: ARRAY_BUFFER + /// * auto_release: false #[inline] - fn elem_size1(&self) -> Result { + pub fn new_2(arows: i32, acols: i32, atype: i32, target: core::Buffer_Target, auto_release: bool) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_elemSize1_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_Buffer_int_int_int_Target_bool(arows, acols, atype, target, auto_release, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } - /// get OpenGL opject id + /// @overload + /// ## Parameters + /// * arows: Number of rows in a 2D array. + /// * acols: Number of columns in a 2D array. + /// * atype: Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + /// * target: Buffer usage. See cv::ogl::Buffer::Target . + /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * target: ARRAY_BUFFER + /// * auto_release: false #[inline] - fn buf_id(&self) -> Result { + pub fn new_def_2(arows: i32, acols: i32, atype: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_bufId_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_Buffer_int_int_int(arows, acols, atype, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } - } - - /// Mutable methods for [core::Buffer] - pub trait BufferTrait: core::BufferTraitConst { - fn as_raw_mut_Buffer(&mut self) -> *mut c_void; - - /// Allocates memory for ogl::Buffer object. + /// The constructors. + /// + /// Creates empty ogl::Buffer object, creates ogl::Buffer object from existed buffer ( abufId + /// parameter), allocates memory for ogl::Buffer object or copies from host/device memory. + /// + /// ## Overloaded parameters /// /// ## Parameters - /// * arows: Number of rows in a 2D array. - /// * acols: Number of columns in a 2D array. + /// * asize: 2D array size. /// * atype: Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. /// * target: Buffer usage. See cv::ogl::Buffer::Target . /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). @@ -38822,49 +38811,45 @@ pub mod core { /// * target: ARRAY_BUFFER /// * auto_release: false #[inline] - fn create(&mut self, arows: i32, acols: i32, atype: i32, target: core::Buffer_Target, auto_release: bool) -> Result<()> { + pub fn new_3(asize: core::Size, atype: i32, target: core::Buffer_Target, auto_release: bool) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_create_int_int_int_Target_bool(self.as_raw_mut_Buffer(), arows, acols, atype, target, auto_release, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_Buffer_Size_int_Target_bool(&asize, atype, target, auto_release, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } - /// Allocates memory for ogl::Buffer object. - /// + /// @overload /// ## Parameters - /// * arows: Number of rows in a 2D array. - /// * acols: Number of columns in a 2D array. + /// * asize: 2D array size. /// * atype: Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. /// * target: Buffer usage. See cv::ogl::Buffer::Target . /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). /// /// ## Note - /// This alternative version of [BufferTrait::create] function uses the following default values for its arguments: + /// This alternative version of [new] function uses the following default values for its arguments: /// * target: ARRAY_BUFFER /// * auto_release: false #[inline] - fn create_def(&mut self, arows: i32, acols: i32, atype: i32) -> Result<()> { + pub fn new_def_3(asize: core::Size, atype: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_create_int_int_int(self.as_raw_mut_Buffer(), arows, acols, atype, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_Buffer_Size_int(&asize, atype, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } - /// Allocates memory for ogl::Buffer object. + /// The constructors. /// - /// ## Parameters - /// * arows: Number of rows in a 2D array. - /// * acols: Number of columns in a 2D array. - /// * atype: Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. - /// * target: Buffer usage. See cv::ogl::Buffer::Target . - /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). + /// Creates empty ogl::Buffer object, creates ogl::Buffer object from existed buffer ( abufId + /// parameter), allocates memory for ogl::Buffer object or copies from host/device memory. /// /// ## Overloaded parameters /// - /// * asize: 2D array size. - /// * atype: Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + /// ## Parameters + /// * arr: Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ). /// * target: Buffer usage. See cv::ogl::Buffer::Target . /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). /// @@ -38872,369 +38857,281 @@ pub mod core { /// * target: ARRAY_BUFFER /// * auto_release: false #[inline] - fn create_size(&mut self, asize: core::Size, atype: i32, target: core::Buffer_Target, auto_release: bool) -> Result<()> { + pub fn new_4(arr: &impl ToInputArray, target: core::Buffer_Target, auto_release: bool) -> Result { + input_array_arg!(arr); return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_create_Size_int_Target_bool(self.as_raw_mut_Buffer(), &asize, atype, target, auto_release, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_Buffer_const__InputArrayR_Target_bool(arr.as_raw__InputArray(), target, auto_release, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } /// @overload /// ## Parameters - /// * asize: 2D array size. - /// * atype: Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + /// * arr: Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ). /// * target: Buffer usage. See cv::ogl::Buffer::Target . /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). /// /// ## Note - /// This alternative version of [BufferTrait::create_size] function uses the following default values for its arguments: + /// This alternative version of [new] function uses the following default values for its arguments: /// * target: ARRAY_BUFFER /// * auto_release: false #[inline] - fn create_size_def(&mut self, asize: core::Size, atype: i32) -> Result<()> { + pub fn new_def_4(arr: &impl ToInputArray) -> Result { + input_array_arg!(arr); return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_create_Size_int(self.as_raw_mut_Buffer(), &asize, atype, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_Buffer_const__InputArrayR(arr.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } - /// Decrements the reference counter and destroys the buffer object if needed. + /// Unbind any buffers from the specified binding point. /// - /// The function will call setAutoRelease(true) . + /// ## Parameters + /// * target: Binding point. See cv::ogl::Buffer::Target . #[inline] - fn release(&mut self) -> Result<()> { + pub fn unbind(target: core::Buffer_Target) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_release(self.as_raw_mut_Buffer(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_unbind_Target(target, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// Sets auto release mode. + } + + /// Constant methods for [core::Buffer] + pub trait BufferTraitConst { + fn as_raw_Buffer(&self) -> *const c_void; + + /// Copies from OpenGL buffer to host/device memory or another OpenGL buffer object. + /// + /// ## Parameters + /// * arr: Destination array (host or device memory, can be Mat , cuda::GpuMat , std::vector or + /// ogl::Buffer ). + #[inline] + fn copy_to(&self, arr: &mut impl ToOutputArray) -> Result<()> { + output_array_arg!(arr); + return_send!(via ocvrs_return); + unsafe { sys::cv_ogl_Buffer_copyTo_const_const__OutputArrayR(self.as_raw_Buffer(), arr.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Copies from OpenGL buffer to host/device memory or another OpenGL buffer object. /// - /// The lifetime of the OpenGL object is tied to the lifetime of the context. If OpenGL context was - /// bound to a window it could be released at any time (user can close a window). If object's destructor - /// is called after destruction of the context it will cause an error. Thus ogl::Buffer doesn't destroy - /// OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL context). - /// This function can force ogl::Buffer destructor to destroy OpenGL object. /// ## Parameters - /// * flag: Auto release mode (if true, release will be called in object's destructor). + /// * arr: Destination array (host or device memory, can be Mat , cuda::GpuMat , std::vector or + /// ogl::Buffer ). + /// + /// ## Overloaded parameters #[inline] - fn set_auto_release(&mut self, flag: bool) -> Result<()> { + fn copy_to_1(&self, arr: &mut impl ToOutputArray, stream: &mut impl core::StreamTrait) -> Result<()> { + output_array_arg!(arr); return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_setAutoRelease_bool(self.as_raw_mut_Buffer(), flag, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_copyTo_const_const__OutputArrayR_StreamR(self.as_raw_Buffer(), arr.as_raw__OutputArray(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// Copies from host/device memory to OpenGL buffer. + /// Creates a full copy of the buffer object and the underlying data. + /// /// ## Parameters - /// * arr: Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ). - /// * target: Buffer usage. See cv::ogl::Buffer::Target . - /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). + /// * target: Buffer usage for destination buffer. + /// * autoRelease: Auto release mode for destination buffer. /// /// ## C++ default parameters /// * target: ARRAY_BUFFER /// * auto_release: false #[inline] - fn copy_from(&mut self, arr: &impl ToInputArray, target: core::Buffer_Target, auto_release: bool) -> Result<()> { - input_array_arg!(arr); + fn clone(&self, target: core::Buffer_Target, auto_release: bool) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_copyFrom_const__InputArrayR_Target_bool(self.as_raw_mut_Buffer(), arr.as_raw__InputArray(), target, auto_release, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_clone_const_Target_bool(self.as_raw_Buffer(), target, auto_release, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } - /// Copies from host/device memory to OpenGL buffer. + /// Creates a full copy of the buffer object and the underlying data. + /// /// ## Parameters - /// * arr: Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ). - /// * target: Buffer usage. See cv::ogl::Buffer::Target . - /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). + /// * target: Buffer usage for destination buffer. + /// * autoRelease: Auto release mode for destination buffer. /// /// ## Note - /// This alternative version of [BufferTrait::copy_from] function uses the following default values for its arguments: + /// This alternative version of [BufferTraitConst::clone] function uses the following default values for its arguments: /// * target: ARRAY_BUFFER /// * auto_release: false #[inline] - fn copy_from_def(&mut self, arr: &impl ToInputArray) -> Result<()> { - input_array_arg!(arr); + fn clone_def(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_copyFrom_const__InputArrayR(self.as_raw_mut_Buffer(), arr.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_clone_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } - /// Copies from host/device memory to OpenGL buffer. - /// ## Parameters - /// * arr: Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ). - /// * target: Buffer usage. See cv::ogl::Buffer::Target . - /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). - /// - /// ## Overloaded parameters + /// Binds OpenGL buffer to the specified buffer binding point. /// - /// ## C++ default parameters - /// * target: ARRAY_BUFFER - /// * auto_release: false + /// ## Parameters + /// * target: Binding point. See cv::ogl::Buffer::Target . #[inline] - fn copy_from_1(&mut self, arr: &impl ToInputArray, stream: &mut impl core::StreamTrait, target: core::Buffer_Target, auto_release: bool) -> Result<()> { - input_array_arg!(arr); + fn bind(&self, target: core::Buffer_Target) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_copyFrom_const__InputArrayR_StreamR_Target_bool(self.as_raw_mut_Buffer(), arr.as_raw__InputArray(), stream.as_raw_mut_Stream(), target, auto_release, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_bind_const_Target(self.as_raw_Buffer(), target, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// @overload - /// - /// ## Note - /// This alternative version of [BufferTrait::copy_from] function uses the following default values for its arguments: - /// * target: ARRAY_BUFFER - /// * auto_release: false #[inline] - fn copy_from_def_1(&mut self, arr: &impl ToInputArray, stream: &mut impl core::StreamTrait) -> Result<()> { - input_array_arg!(arr); + fn rows(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_copyFrom_const__InputArrayR_StreamR(self.as_raw_mut_Buffer(), arr.as_raw__InputArray(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_rows_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// Maps OpenGL buffer to host memory. - /// - /// mapHost maps to the client's address space the entire data store of the buffer object. The data can - /// then be directly read and/or written relative to the returned pointer, depending on the specified - /// access policy. - /// - /// A mapped data store must be unmapped with ogl::Buffer::unmapHost before its buffer object is used. - /// - /// This operation can lead to memory transfers between host and device. - /// - /// Only one buffer object can be mapped at a time. - /// ## Parameters - /// * access: Access policy, indicating whether it will be possible to read from, write to, or both - /// read from and write to the buffer object's mapped data store. The symbolic constant must be - /// ogl::Buffer::READ_ONLY , ogl::Buffer::WRITE_ONLY or ogl::Buffer::READ_WRITE . #[inline] - fn map_host(&mut self, access: core::Buffer_Access) -> Result { + fn cols(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_mapHost_Access(self.as_raw_mut_Buffer(), access, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_cols_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// Unmaps OpenGL buffer. #[inline] - fn unmap_host(&mut self) -> Result<()> { + fn size(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_unmapHost(self.as_raw_mut_Buffer(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_size_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// map to device memory (blocking) #[inline] - fn map_device(&mut self) -> Result { + fn empty(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_mapDevice(self.as_raw_mut_Buffer(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_empty_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn unmap_device(&mut self) -> Result<()> { + fn typ(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_unmapDevice(self.as_raw_mut_Buffer(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_type_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// Maps OpenGL buffer to CUDA device memory. - /// - /// This operation doesn't copy data. Several buffer objects can be mapped to CUDA memory at a time. - /// - /// A mapped data store must be unmapped with ogl::Buffer::unmapDevice before its buffer object is used. #[inline] - fn map_device_1(&mut self, stream: &mut impl core::StreamTrait) -> Result { + fn depth(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_mapDevice_StreamR(self.as_raw_mut_Buffer(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_depth_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// Unmaps OpenGL buffer. #[inline] - fn unmap_device_1(&mut self, stream: &mut impl core::StreamTrait) -> Result<()> { + fn channels(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_unmapDevice_StreamR(self.as_raw_mut_Buffer(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_channels_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - } - - /// Smart pointer for OpenGL buffer object with reference counting. - /// - /// Buffer Objects are OpenGL objects that store an array of unformatted memory allocated by the OpenGL - /// context. These can be used to store vertex data, pixel data retrieved from images or the - /// framebuffer, and a variety of other things. - /// - /// ogl::Buffer has interface similar with Mat interface and represents 2D array memory. - /// - /// ogl::Buffer supports memory transfers between host and device and also can be mapped to CUDA memory. - pub struct Buffer { - ptr: *mut c_void, - } - - opencv_type_boxed! { Buffer } - - impl Drop for Buffer { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ogl_Buffer_delete(self.as_raw_mut_Buffer()) }; - } - } - - unsafe impl Send for Buffer {} - - impl core::BufferTraitConst for Buffer { - #[inline] fn as_raw_Buffer(&self) -> *const c_void { self.as_raw() } - } - - impl core::BufferTrait for Buffer { - #[inline] fn as_raw_mut_Buffer(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Buffer, core::BufferTraitConst, as_raw_Buffer, core::BufferTrait, as_raw_mut_Buffer } - - impl Buffer { - /// The constructors. - /// - /// Creates empty ogl::Buffer object, creates ogl::Buffer object from existed buffer ( abufId - /// parameter), allocates memory for ogl::Buffer object or copies from host/device memory. #[inline] - pub fn default() -> Result { + fn elem_size(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_Buffer(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_elemSize_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } - /// The constructors. - /// - /// Creates empty ogl::Buffer object, creates ogl::Buffer object from existed buffer ( abufId - /// parameter), allocates memory for ogl::Buffer object or copies from host/device memory. - /// - /// ## Overloaded parameters - /// - /// ## Parameters - /// * arows: Number of rows in a 2D array. - /// * acols: Number of columns in a 2D array. - /// * atype: Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. - /// * abufId: Buffer object name. - /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). - /// - /// ## C++ default parameters - /// * auto_release: false #[inline] - pub fn new(arows: i32, acols: i32, atype: i32, abuf_id: u32, auto_release: bool) -> Result { + fn elem_size1(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_Buffer_int_int_int_unsigned_int_bool(arows, acols, atype, abuf_id, auto_release, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_elemSize1_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } - /// @overload - /// ## Parameters - /// * arows: Number of rows in a 2D array. - /// * acols: Number of columns in a 2D array. - /// * atype: Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. - /// * abufId: Buffer object name. - /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * auto_release: false + /// get OpenGL opject id #[inline] - pub fn new_def(arows: i32, acols: i32, atype: i32, abuf_id: u32) -> Result { + fn buf_id(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_Buffer_int_int_int_unsigned_int(arows, acols, atype, abuf_id, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_bufId_const(self.as_raw_Buffer(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } - /// The constructors. - /// - /// Creates empty ogl::Buffer object, creates ogl::Buffer object from existed buffer ( abufId - /// parameter), allocates memory for ogl::Buffer object or copies from host/device memory. - /// - /// ## Overloaded parameters + } + + /// Mutable methods for [core::Buffer] + pub trait BufferTrait: core::BufferTraitConst { + fn as_raw_mut_Buffer(&mut self) -> *mut c_void; + + /// Allocates memory for ogl::Buffer object. /// /// ## Parameters - /// * asize: 2D array size. + /// * arows: Number of rows in a 2D array. + /// * acols: Number of columns in a 2D array. /// * atype: Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. - /// * abufId: Buffer object name. + /// * target: Buffer usage. See cv::ogl::Buffer::Target . /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). /// /// ## C++ default parameters + /// * target: ARRAY_BUFFER /// * auto_release: false #[inline] - pub fn new_1(asize: core::Size, atype: i32, abuf_id: u32, auto_release: bool) -> Result { + fn create(&mut self, arows: i32, acols: i32, atype: i32, target: core::Buffer_Target, auto_release: bool) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_Buffer_Size_int_unsigned_int_bool(&asize, atype, abuf_id, auto_release, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_create_int_int_int_Target_bool(self.as_raw_mut_Buffer(), arows, acols, atype, target, auto_release, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } - /// @overload + /// Allocates memory for ogl::Buffer object. + /// /// ## Parameters - /// * asize: 2D array size. + /// * arows: Number of rows in a 2D array. + /// * acols: Number of columns in a 2D array. /// * atype: Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. - /// * abufId: Buffer object name. + /// * target: Buffer usage. See cv::ogl::Buffer::Target . /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). /// /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: + /// This alternative version of [BufferTrait::create] function uses the following default values for its arguments: + /// * target: ARRAY_BUFFER /// * auto_release: false #[inline] - pub fn new_def_1(asize: core::Size, atype: i32, abuf_id: u32) -> Result { + fn create_def(&mut self, arows: i32, acols: i32, atype: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_Buffer_Size_int_unsigned_int(&asize, atype, abuf_id, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_create_int_int_int(self.as_raw_mut_Buffer(), arows, acols, atype, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } - /// The constructors. - /// - /// Creates empty ogl::Buffer object, creates ogl::Buffer object from existed buffer ( abufId - /// parameter), allocates memory for ogl::Buffer object or copies from host/device memory. - /// - /// ## Overloaded parameters + /// Allocates memory for ogl::Buffer object. /// /// ## Parameters /// * arows: Number of rows in a 2D array. @@ -39243,51 +39140,78 @@ pub mod core { /// * target: Buffer usage. See cv::ogl::Buffer::Target . /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). /// + /// ## Overloaded parameters + /// + /// * asize: 2D array size. + /// * atype: Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + /// * target: Buffer usage. See cv::ogl::Buffer::Target . + /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). + /// /// ## C++ default parameters /// * target: ARRAY_BUFFER /// * auto_release: false #[inline] - pub fn new_2(arows: i32, acols: i32, atype: i32, target: core::Buffer_Target, auto_release: bool) -> Result { + fn create_size(&mut self, asize: core::Size, atype: i32, target: core::Buffer_Target, auto_release: bool) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_Buffer_int_int_int_Target_bool(arows, acols, atype, target, auto_release, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_create_Size_int_Target_bool(self.as_raw_mut_Buffer(), &asize, atype, target, auto_release, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } /// @overload /// ## Parameters - /// * arows: Number of rows in a 2D array. - /// * acols: Number of columns in a 2D array. + /// * asize: 2D array size. /// * atype: Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. /// * target: Buffer usage. See cv::ogl::Buffer::Target . /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). /// /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: + /// This alternative version of [BufferTrait::create_size] function uses the following default values for its arguments: /// * target: ARRAY_BUFFER /// * auto_release: false #[inline] - pub fn new_def_2(arows: i32, acols: i32, atype: i32) -> Result { + fn create_size_def(&mut self, asize: core::Size, atype: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_Buffer_int_int_int(arows, acols, atype, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_create_Size_int(self.as_raw_mut_Buffer(), &asize, atype, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } - /// The constructors. - /// - /// Creates empty ogl::Buffer object, creates ogl::Buffer object from existed buffer ( abufId - /// parameter), allocates memory for ogl::Buffer object or copies from host/device memory. + /// Decrements the reference counter and destroys the buffer object if needed. /// - /// ## Overloaded parameters + /// The function will call setAutoRelease(true) . + #[inline] + fn release(&mut self) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_ogl_Buffer_release(self.as_raw_mut_Buffer(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Sets auto release mode. /// + /// The lifetime of the OpenGL object is tied to the lifetime of the context. If OpenGL context was + /// bound to a window it could be released at any time (user can close a window). If object's destructor + /// is called after destruction of the context it will cause an error. Thus ogl::Buffer doesn't destroy + /// OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL context). + /// This function can force ogl::Buffer destructor to destroy OpenGL object. /// ## Parameters - /// * asize: 2D array size. - /// * atype: Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + /// * flag: Auto release mode (if true, release will be called in object's destructor). + #[inline] + fn set_auto_release(&mut self, flag: bool) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_ogl_Buffer_setAutoRelease_bool(self.as_raw_mut_Buffer(), flag, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Copies from host/device memory to OpenGL buffer. + /// ## Parameters + /// * arr: Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ). /// * target: Buffer usage. See cv::ogl::Buffer::Target . /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). /// @@ -39295,225 +39219,277 @@ pub mod core { /// * target: ARRAY_BUFFER /// * auto_release: false #[inline] - pub fn new_3(asize: core::Size, atype: i32, target: core::Buffer_Target, auto_release: bool) -> Result { + fn copy_from(&mut self, arr: &impl ToInputArray, target: core::Buffer_Target, auto_release: bool) -> Result<()> { + input_array_arg!(arr); return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_Buffer_Size_int_Target_bool(&asize, atype, target, auto_release, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_copyFrom_const__InputArrayR_Target_bool(self.as_raw_mut_Buffer(), arr.as_raw__InputArray(), target, auto_release, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } - /// @overload + /// Copies from host/device memory to OpenGL buffer. /// ## Parameters - /// * asize: 2D array size. - /// * atype: Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + /// * arr: Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ). /// * target: Buffer usage. See cv::ogl::Buffer::Target . /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). /// /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: + /// This alternative version of [BufferTrait::copy_from] function uses the following default values for its arguments: /// * target: ARRAY_BUFFER /// * auto_release: false #[inline] - pub fn new_def_3(asize: core::Size, atype: i32) -> Result { + fn copy_from_def(&mut self, arr: &impl ToInputArray) -> Result<()> { + input_array_arg!(arr); return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_Buffer_Size_int(&asize, atype, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_copyFrom_const__InputArrayR(self.as_raw_mut_Buffer(), arr.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } - /// The constructors. - /// - /// Creates empty ogl::Buffer object, creates ogl::Buffer object from existed buffer ( abufId - /// parameter), allocates memory for ogl::Buffer object or copies from host/device memory. - /// - /// ## Overloaded parameters - /// + /// Copies from host/device memory to OpenGL buffer. /// ## Parameters /// * arr: Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ). /// * target: Buffer usage. See cv::ogl::Buffer::Target . /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). /// + /// ## Overloaded parameters + /// /// ## C++ default parameters /// * target: ARRAY_BUFFER /// * auto_release: false #[inline] - pub fn new_4(arr: &impl ToInputArray, target: core::Buffer_Target, auto_release: bool) -> Result { + fn copy_from_1(&mut self, arr: &impl ToInputArray, stream: &mut impl core::StreamTrait, target: core::Buffer_Target, auto_release: bool) -> Result<()> { input_array_arg!(arr); return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_Buffer_const__InputArrayR_Target_bool(arr.as_raw__InputArray(), target, auto_release, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_copyFrom_const__InputArrayR_StreamR_Target_bool(self.as_raw_mut_Buffer(), arr.as_raw__InputArray(), stream.as_raw_mut_Stream(), target, auto_release, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } /// @overload - /// ## Parameters - /// * arr: Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ). - /// * target: Buffer usage. See cv::ogl::Buffer::Target . - /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). /// /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: + /// This alternative version of [BufferTrait::copy_from] function uses the following default values for its arguments: /// * target: ARRAY_BUFFER /// * auto_release: false #[inline] - pub fn new_def_4(arr: &impl ToInputArray) -> Result { + fn copy_from_def_1(&mut self, arr: &impl ToInputArray, stream: &mut impl core::StreamTrait) -> Result<()> { input_array_arg!(arr); return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_Buffer_const__InputArrayR(arr.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_copyFrom_const__InputArrayR_StreamR(self.as_raw_mut_Buffer(), arr.as_raw__InputArray(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Buffer::opencv_from_extern(ret) }; Ok(ret) } - /// Unbind any buffers from the specified binding point. + /// Maps OpenGL buffer to host memory. + /// + /// mapHost maps to the client's address space the entire data store of the buffer object. The data can + /// then be directly read and/or written relative to the returned pointer, depending on the specified + /// access policy. /// + /// A mapped data store must be unmapped with ogl::Buffer::unmapHost before its buffer object is used. + /// + /// This operation can lead to memory transfers between host and device. + /// + /// Only one buffer object can be mapped at a time. /// ## Parameters - /// * target: Binding point. See cv::ogl::Buffer::Target . + /// * access: Access policy, indicating whether it will be possible to read from, write to, or both + /// read from and write to the buffer object's mapped data store. The symbolic constant must be + /// ogl::Buffer::READ_ONLY , ogl::Buffer::WRITE_ONLY or ogl::Buffer::READ_WRITE . #[inline] - pub fn unbind(target: core::Buffer_Target) -> Result<()> { + fn map_host(&mut self, access: core::Buffer_Access) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Buffer_unbind_Target(target, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_mapHost_Access(self.as_raw_mut_Buffer(), access, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - } - - impl std::fmt::Debug for Buffer { + /// Unmaps OpenGL buffer. #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Buffer") - .finish() + fn unmap_host(&mut self) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_ogl_Buffer_unmapHost(self.as_raw_mut_Buffer(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } - } - - /// Constant methods for [core::Texture2D] - pub trait Texture2DTraitConst { - fn as_raw_Texture2D(&self) -> *const c_void; - /// Copies from OpenGL texture to host/device memory or another OpenGL texture object. - /// - /// ## Parameters - /// * arr: Destination array (host or device memory, can be Mat , cuda::GpuMat , ogl::Buffer or - /// ogl::Texture2D ). - /// * ddepth: Destination depth. - /// * autoRelease: Auto release mode for destination buffer (if arr is OpenGL buffer or texture). - /// - /// ## C++ default parameters - /// * ddepth: CV_32F - /// * auto_release: false + /// map to device memory (blocking) #[inline] - fn copy_to(&self, arr: &mut impl ToOutputArray, ddepth: i32, auto_release: bool) -> Result<()> { - output_array_arg!(arr); + fn map_device(&mut self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_copyTo_const_const__OutputArrayR_int_bool(self.as_raw_Texture2D(), arr.as_raw__OutputArray(), ddepth, auto_release, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_mapDevice(self.as_raw_mut_Buffer(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } - /// Copies from OpenGL texture to host/device memory or another OpenGL texture object. - /// - /// ## Parameters - /// * arr: Destination array (host or device memory, can be Mat , cuda::GpuMat , ogl::Buffer or - /// ogl::Texture2D ). - /// * ddepth: Destination depth. - /// * autoRelease: Auto release mode for destination buffer (if arr is OpenGL buffer or texture). - /// - /// ## Note - /// This alternative version of [Texture2DTraitConst::copy_to] function uses the following default values for its arguments: - /// * ddepth: CV_32F - /// * auto_release: false #[inline] - fn copy_to_def(&self, arr: &mut impl ToOutputArray) -> Result<()> { - output_array_arg!(arr); + fn unmap_device(&mut self) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_copyTo_const_const__OutputArrayR(self.as_raw_Texture2D(), arr.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_unmapDevice(self.as_raw_mut_Buffer(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// Binds texture to current active texture unit for GL_TEXTURE_2D target. + /// Maps OpenGL buffer to CUDA device memory. + /// + /// This operation doesn't copy data. Several buffer objects can be mapped to CUDA memory at a time. + /// + /// A mapped data store must be unmapped with ogl::Buffer::unmapDevice before its buffer object is used. #[inline] - fn bind(&self) -> Result<()> { + fn map_device_1(&mut self, stream: &mut impl core::StreamTrait) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_bind_const(self.as_raw_Texture2D(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_mapDevice_StreamR(self.as_raw_mut_Buffer(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::GpuMat::opencv_from_extern(ret) }; Ok(ret) } + /// Unmaps OpenGL buffer. #[inline] - fn rows(&self) -> Result { + fn unmap_device_1(&mut self, stream: &mut impl core::StreamTrait) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_rows_const(self.as_raw_Texture2D(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Buffer_unmapDevice_StreamR(self.as_raw_mut_Buffer(), stream.as_raw_mut_Stream(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } + } + + impl std::fmt::Debug for Buffer { #[inline] - fn cols(&self) -> Result { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Buffer") + .finish() + } + } + + impl core::BufferTraitConst for Buffer { + #[inline] fn as_raw_Buffer(&self) -> *const c_void { self.as_raw() } + } + + impl core::BufferTrait for Buffer { + #[inline] fn as_raw_mut_Buffer(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Buffer, core::BufferTraitConst, as_raw_Buffer, core::BufferTrait, as_raw_mut_Buffer } + + /// Smart pointer for OpenGL 2D texture memory with reference counting. + pub struct Texture2D { + ptr: *mut c_void, + } + + opencv_type_boxed! { Texture2D } + + impl Drop for Texture2D { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_ogl_Texture2D_delete(self.as_raw_mut_Texture2D()) }; + } + } + + unsafe impl Send for Texture2D {} + + impl Texture2D { + /// The constructors. + /// + /// Creates empty ogl::Texture2D object, allocates memory for ogl::Texture2D object or copies from + /// host/device memory. + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_cols_const(self.as_raw_Texture2D(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_Texture2D(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } + /// The constructors. + /// + /// Creates empty ogl::Texture2D object, allocates memory for ogl::Texture2D object or copies from + /// host/device memory. + /// + /// ## Overloaded parameters + /// + /// ## C++ default parameters + /// * auto_release: false #[inline] - fn size(&self) -> Result { + pub fn new(arows: i32, acols: i32, aformat: core::Texture2D_Format, atex_id: u32, auto_release: bool) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_size_const(self.as_raw_Texture2D(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_Texture2D_int_int_Format_unsigned_int_bool(arows, acols, aformat, atex_id, auto_release, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } + /// @overload + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * auto_release: false #[inline] - fn empty(&self) -> Result { + pub fn new_def(arows: i32, acols: i32, aformat: core::Texture2D_Format, atex_id: u32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_empty_const(self.as_raw_Texture2D(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_Texture2D_int_int_Format_unsigned_int(arows, acols, aformat, atex_id, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } + /// The constructors. + /// + /// Creates empty ogl::Texture2D object, allocates memory for ogl::Texture2D object or copies from + /// host/device memory. + /// + /// ## Overloaded parameters + /// + /// ## C++ default parameters + /// * auto_release: false #[inline] - fn format(&self) -> Result { + pub fn new_1(asize: core::Size, aformat: core::Texture2D_Format, atex_id: u32, auto_release: bool) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_format_const(self.as_raw_Texture2D(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_Texture2D_Size_Format_unsigned_int_bool(&asize, aformat, atex_id, auto_release, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } - /// get OpenGL opject id + /// @overload + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * auto_release: false #[inline] - fn tex_id(&self) -> Result { + pub fn new_def_1(asize: core::Size, aformat: core::Texture2D_Format, atex_id: u32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_texId_const(self.as_raw_Texture2D(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_Texture2D_Size_Format_unsigned_int(&asize, aformat, atex_id, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } - } - - /// Mutable methods for [core::Texture2D] - pub trait Texture2DTrait: core::Texture2DTraitConst { - fn as_raw_mut_Texture2D(&mut self) -> *mut c_void; - - /// Allocates memory for ogl::Texture2D object. + /// The constructors. + /// + /// Creates empty ogl::Texture2D object, allocates memory for ogl::Texture2D object or copies from + /// host/device memory. + /// + /// ## Overloaded parameters /// /// ## Parameters /// * arows: Number of rows. @@ -39524,16 +39500,16 @@ pub mod core { /// ## C++ default parameters /// * auto_release: false #[inline] - fn create(&mut self, arows: i32, acols: i32, aformat: core::Texture2D_Format, auto_release: bool) -> Result<()> { + pub fn new_2(arows: i32, acols: i32, aformat: core::Texture2D_Format, auto_release: bool) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_create_int_int_Format_bool(self.as_raw_mut_Texture2D(), arows, acols, aformat, auto_release, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_Texture2D_int_int_Format_bool(arows, acols, aformat, auto_release, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } - /// Allocates memory for ogl::Texture2D object. - /// + /// @overload /// ## Parameters /// * arows: Number of rows. /// * acols: Number of columns. @@ -39541,27 +39517,26 @@ pub mod core { /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). /// /// ## Note - /// This alternative version of [Texture2DTrait::create] function uses the following default values for its arguments: + /// This alternative version of [new] function uses the following default values for its arguments: /// * auto_release: false #[inline] - fn create_def(&mut self, arows: i32, acols: i32, aformat: core::Texture2D_Format) -> Result<()> { + pub fn new_def_2(arows: i32, acols: i32, aformat: core::Texture2D_Format) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_create_int_int_Format(self.as_raw_mut_Texture2D(), arows, acols, aformat, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_Texture2D_int_int_Format(arows, acols, aformat, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } - /// Allocates memory for ogl::Texture2D object. + /// The constructors. /// - /// ## Parameters - /// * arows: Number of rows. - /// * acols: Number of columns. - /// * aformat: Image format. See cv::ogl::Texture2D::Format . - /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). + /// Creates empty ogl::Texture2D object, allocates memory for ogl::Texture2D object or copies from + /// host/device memory. /// /// ## Overloaded parameters /// + /// ## Parameters /// * asize: 2D array size. /// * aformat: Image format. See cv::ogl::Texture2D::Format . /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). @@ -39569,11 +39544,12 @@ pub mod core { /// ## C++ default parameters /// * auto_release: false #[inline] - fn create_1(&mut self, asize: core::Size, aformat: core::Texture2D_Format, auto_release: bool) -> Result<()> { + pub fn new_3(asize: core::Size, aformat: core::Texture2D_Format, auto_release: bool) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_create_Size_Format_bool(self.as_raw_mut_Texture2D(), &asize, aformat, auto_release, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_Texture2D_Size_Format_bool(&asize, aformat, auto_release, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } @@ -39584,202 +39560,182 @@ pub mod core { /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). /// /// ## Note - /// This alternative version of [Texture2DTrait::create] function uses the following default values for its arguments: + /// This alternative version of [new] function uses the following default values for its arguments: /// * auto_release: false #[inline] - fn create_def_1(&mut self, asize: core::Size, aformat: core::Texture2D_Format) -> Result<()> { + pub fn new_def_3(asize: core::Size, aformat: core::Texture2D_Format) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_create_Size_Format(self.as_raw_mut_Texture2D(), &asize, aformat, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_Texture2D_Size_Format(&asize, aformat, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } - /// Decrements the reference counter and destroys the texture object if needed. + /// The constructors. /// - /// The function will call setAutoRelease(true) . + /// Creates empty ogl::Texture2D object, allocates memory for ogl::Texture2D object or copies from + /// host/device memory. + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * arr: Input array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ). + /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). + /// + /// ## C++ default parameters + /// * auto_release: false #[inline] - fn release(&mut self) -> Result<()> { + pub fn new_4(arr: &impl ToInputArray, auto_release: bool) -> Result { + input_array_arg!(arr); return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_release(self.as_raw_mut_Texture2D(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_Texture2D_const__InputArrayR_bool(arr.as_raw__InputArray(), auto_release, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } - /// Sets auto release mode. - /// + /// @overload /// ## Parameters - /// * flag: Auto release mode (if true, release will be called in object's destructor). + /// * arr: Input array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ). + /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). /// - /// The lifetime of the OpenGL object is tied to the lifetime of the context. If OpenGL context was - /// bound to a window it could be released at any time (user can close a window). If object's destructor - /// is called after destruction of the context it will cause an error. Thus ogl::Texture2D doesn't - /// destroy OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL - /// context). This function can force ogl::Texture2D destructor to destroy OpenGL object. + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * auto_release: false #[inline] - fn set_auto_release(&mut self, flag: bool) -> Result<()> { + pub fn new_def_4(arr: &impl ToInputArray) -> Result { + input_array_arg!(arr); return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_setAutoRelease_bool(self.as_raw_mut_Texture2D(), flag, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_Texture2D_const__InputArrayR(arr.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } - /// Copies from host/device memory to OpenGL texture. + } + + /// Constant methods for [core::Texture2D] + pub trait Texture2DTraitConst { + fn as_raw_Texture2D(&self) -> *const c_void; + + /// Copies from OpenGL texture to host/device memory or another OpenGL texture object. /// /// ## Parameters - /// * arr: Input array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ). - /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). + /// * arr: Destination array (host or device memory, can be Mat , cuda::GpuMat , ogl::Buffer or + /// ogl::Texture2D ). + /// * ddepth: Destination depth. + /// * autoRelease: Auto release mode for destination buffer (if arr is OpenGL buffer or texture). /// /// ## C++ default parameters + /// * ddepth: CV_32F /// * auto_release: false #[inline] - fn copy_from(&mut self, arr: &impl ToInputArray, auto_release: bool) -> Result<()> { - input_array_arg!(arr); + fn copy_to(&self, arr: &mut impl ToOutputArray, ddepth: i32, auto_release: bool) -> Result<()> { + output_array_arg!(arr); return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_copyFrom_const__InputArrayR_bool(self.as_raw_mut_Texture2D(), arr.as_raw__InputArray(), auto_release, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_copyTo_const_const__OutputArrayR_int_bool(self.as_raw_Texture2D(), arr.as_raw__OutputArray(), ddepth, auto_release, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// Copies from host/device memory to OpenGL texture. + /// Copies from OpenGL texture to host/device memory or another OpenGL texture object. /// /// ## Parameters - /// * arr: Input array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ). - /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). + /// * arr: Destination array (host or device memory, can be Mat , cuda::GpuMat , ogl::Buffer or + /// ogl::Texture2D ). + /// * ddepth: Destination depth. + /// * autoRelease: Auto release mode for destination buffer (if arr is OpenGL buffer or texture). /// /// ## Note - /// This alternative version of [Texture2DTrait::copy_from] function uses the following default values for its arguments: + /// This alternative version of [Texture2DTraitConst::copy_to] function uses the following default values for its arguments: + /// * ddepth: CV_32F /// * auto_release: false #[inline] - fn copy_from_def(&mut self, arr: &impl ToInputArray) -> Result<()> { - input_array_arg!(arr); + fn copy_to_def(&self, arr: &mut impl ToOutputArray) -> Result<()> { + output_array_arg!(arr); return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_copyFrom_const__InputArrayR(self.as_raw_mut_Texture2D(), arr.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_copyTo_const_const__OutputArrayR(self.as_raw_Texture2D(), arr.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - } - - /// Smart pointer for OpenGL 2D texture memory with reference counting. - pub struct Texture2D { - ptr: *mut c_void, - } - - opencv_type_boxed! { Texture2D } - - impl Drop for Texture2D { + /// Binds texture to current active texture unit for GL_TEXTURE_2D target. #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ogl_Texture2D_delete(self.as_raw_mut_Texture2D()) }; + fn bind(&self) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_ogl_Texture2D_bind_const(self.as_raw_Texture2D(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } - } - - unsafe impl Send for Texture2D {} - impl core::Texture2DTraitConst for Texture2D { - #[inline] fn as_raw_Texture2D(&self) -> *const c_void { self.as_raw() } - } - - impl core::Texture2DTrait for Texture2D { - #[inline] fn as_raw_mut_Texture2D(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Texture2D, core::Texture2DTraitConst, as_raw_Texture2D, core::Texture2DTrait, as_raw_mut_Texture2D } + #[inline] + fn rows(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ogl_Texture2D_rows_const(self.as_raw_Texture2D(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - impl Texture2D { - /// The constructors. - /// - /// Creates empty ogl::Texture2D object, allocates memory for ogl::Texture2D object or copies from - /// host/device memory. #[inline] - pub fn default() -> Result { + fn cols(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_Texture2D(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_cols_const(self.as_raw_Texture2D(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } - /// The constructors. - /// - /// Creates empty ogl::Texture2D object, allocates memory for ogl::Texture2D object or copies from - /// host/device memory. - /// - /// ## Overloaded parameters - /// - /// ## C++ default parameters - /// * auto_release: false #[inline] - pub fn new(arows: i32, acols: i32, aformat: core::Texture2D_Format, atex_id: u32, auto_release: bool) -> Result { + fn size(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_Texture2D_int_int_Format_unsigned_int_bool(arows, acols, aformat, atex_id, auto_release, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_size_const(self.as_raw_Texture2D(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } - /// @overload - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * auto_release: false #[inline] - pub fn new_def(arows: i32, acols: i32, aformat: core::Texture2D_Format, atex_id: u32) -> Result { + fn empty(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_Texture2D_int_int_Format_unsigned_int(arows, acols, aformat, atex_id, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_empty_const(self.as_raw_Texture2D(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } - /// The constructors. - /// - /// Creates empty ogl::Texture2D object, allocates memory for ogl::Texture2D object or copies from - /// host/device memory. - /// - /// ## Overloaded parameters - /// - /// ## C++ default parameters - /// * auto_release: false #[inline] - pub fn new_1(asize: core::Size, aformat: core::Texture2D_Format, atex_id: u32, auto_release: bool) -> Result { + fn format(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_Texture2D_Size_Format_unsigned_int_bool(&asize, aformat, atex_id, auto_release, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_format_const(self.as_raw_Texture2D(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } - /// @overload - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * auto_release: false + /// get OpenGL opject id #[inline] - pub fn new_def_1(asize: core::Size, aformat: core::Texture2D_Format, atex_id: u32) -> Result { + fn tex_id(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_Texture2D_Size_Format_unsigned_int(&asize, aformat, atex_id, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_texId_const(self.as_raw_Texture2D(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } - /// The constructors. - /// - /// Creates empty ogl::Texture2D object, allocates memory for ogl::Texture2D object or copies from - /// host/device memory. - /// - /// ## Overloaded parameters + } + + /// Mutable methods for [core::Texture2D] + pub trait Texture2DTrait: core::Texture2DTraitConst { + fn as_raw_mut_Texture2D(&mut self) -> *mut c_void; + + /// Allocates memory for ogl::Texture2D object. /// /// ## Parameters /// * arows: Number of rows. @@ -39790,16 +39746,16 @@ pub mod core { /// ## C++ default parameters /// * auto_release: false #[inline] - pub fn new_2(arows: i32, acols: i32, aformat: core::Texture2D_Format, auto_release: bool) -> Result { + fn create(&mut self, arows: i32, acols: i32, aformat: core::Texture2D_Format, auto_release: bool) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_Texture2D_int_int_Format_bool(arows, acols, aformat, auto_release, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_create_int_int_Format_bool(self.as_raw_mut_Texture2D(), arows, acols, aformat, auto_release, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } - /// @overload + /// Allocates memory for ogl::Texture2D object. + /// /// ## Parameters /// * arows: Number of rows. /// * acols: Number of columns. @@ -39807,26 +39763,27 @@ pub mod core { /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). /// /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: + /// This alternative version of [Texture2DTrait::create] function uses the following default values for its arguments: /// * auto_release: false #[inline] - pub fn new_def_2(arows: i32, acols: i32, aformat: core::Texture2D_Format) -> Result { + fn create_def(&mut self, arows: i32, acols: i32, aformat: core::Texture2D_Format) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_Texture2D_int_int_Format(arows, acols, aformat, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_create_int_int_Format(self.as_raw_mut_Texture2D(), arows, acols, aformat, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } - /// The constructors. + /// Allocates memory for ogl::Texture2D object. /// - /// Creates empty ogl::Texture2D object, allocates memory for ogl::Texture2D object or copies from - /// host/device memory. + /// ## Parameters + /// * arows: Number of rows. + /// * acols: Number of columns. + /// * aformat: Image format. See cv::ogl::Texture2D::Format . + /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). /// /// ## Overloaded parameters /// - /// ## Parameters /// * asize: 2D array size. /// * aformat: Image format. See cv::ogl::Texture2D::Format . /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). @@ -39834,12 +39791,11 @@ pub mod core { /// ## C++ default parameters /// * auto_release: false #[inline] - pub fn new_3(asize: core::Size, aformat: core::Texture2D_Format, auto_release: bool) -> Result { + fn create_1(&mut self, asize: core::Size, aformat: core::Texture2D_Format, auto_release: bool) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_Texture2D_Size_Format_bool(&asize, aformat, auto_release, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_create_Size_Format_bool(self.as_raw_mut_Texture2D(), &asize, aformat, auto_release, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } @@ -39850,24 +39806,49 @@ pub mod core { /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). /// /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: + /// This alternative version of [Texture2DTrait::create] function uses the following default values for its arguments: /// * auto_release: false #[inline] - pub fn new_def_3(asize: core::Size, aformat: core::Texture2D_Format) -> Result { + fn create_def_1(&mut self, asize: core::Size, aformat: core::Texture2D_Format) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_Texture2D_Size_Format(&asize, aformat, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_create_Size_Format(self.as_raw_mut_Texture2D(), &asize, aformat, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } - /// The constructors. + /// Decrements the reference counter and destroys the texture object if needed. /// - /// Creates empty ogl::Texture2D object, allocates memory for ogl::Texture2D object or copies from - /// host/device memory. + /// The function will call setAutoRelease(true) . + #[inline] + fn release(&mut self) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_ogl_Texture2D_release(self.as_raw_mut_Texture2D(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Sets auto release mode. /// - /// ## Overloaded parameters + /// ## Parameters + /// * flag: Auto release mode (if true, release will be called in object's destructor). + /// + /// The lifetime of the OpenGL object is tied to the lifetime of the context. If OpenGL context was + /// bound to a window it could be released at any time (user can close a window). If object's destructor + /// is called after destruction of the context it will cause an error. Thus ogl::Texture2D doesn't + /// destroy OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL + /// context). This function can force ogl::Texture2D destructor to destroy OpenGL object. + #[inline] + fn set_auto_release(&mut self, flag: bool) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_ogl_Texture2D_setAutoRelease_bool(self.as_raw_mut_Texture2D(), flag, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Copies from host/device memory to OpenGL texture. /// /// ## Parameters /// * arr: Input array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ). @@ -39876,32 +39857,31 @@ pub mod core { /// ## C++ default parameters /// * auto_release: false #[inline] - pub fn new_4(arr: &impl ToInputArray, auto_release: bool) -> Result { + fn copy_from(&mut self, arr: &impl ToInputArray, auto_release: bool) -> Result<()> { input_array_arg!(arr); return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_Texture2D_const__InputArrayR_bool(arr.as_raw__InputArray(), auto_release, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_copyFrom_const__InputArrayR_bool(self.as_raw_mut_Texture2D(), arr.as_raw__InputArray(), auto_release, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } - /// @overload + /// Copies from host/device memory to OpenGL texture. + /// /// ## Parameters /// * arr: Input array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ). /// * autoRelease: Auto release mode (if true, release will be called in object's destructor). /// /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: + /// This alternative version of [Texture2DTrait::copy_from] function uses the following default values for its arguments: /// * auto_release: false #[inline] - pub fn new_def_4(arr: &impl ToInputArray) -> Result { + fn copy_from_def(&mut self, arr: &impl ToInputArray) -> Result<()> { input_array_arg!(arr); return_send!(via ocvrs_return); - unsafe { sys::cv_ogl_Texture2D_Texture2D_const__InputArrayR(arr.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ogl_Texture2D_copyFrom_const__InputArrayR(self.as_raw_mut_Texture2D(), arr.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Texture2D::opencv_from_extern(ret) }; Ok(ret) } @@ -39915,6 +39895,16 @@ pub mod core { } } + impl core::Texture2DTraitConst for Texture2D { + #[inline] fn as_raw_Texture2D(&self) -> *const c_void { self.as_raw() } + } + + impl core::Texture2DTrait for Texture2D { + #[inline] fn as_raw_mut_Texture2D(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Texture2D, core::Texture2DTraitConst, as_raw_Texture2D, core::Texture2DTrait, as_raw_mut_Texture2D } + #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] pub struct ClassWithKeywordProperties { @@ -39980,6 +39970,35 @@ pub mod core { } + pub struct LogTag { + ptr: *mut c_void, + } + + opencv_type_boxed! { LogTag } + + impl Drop for LogTag { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_utils_logging_LogTag_delete(self.as_raw_mut_LogTag()) }; + } + } + + unsafe impl Send for LogTag {} + + impl LogTag { + #[inline] + pub fn new(_name: &str, _level: core::LogLevel) -> Result { + extern_container_arg!(_name); + return_send!(via ocvrs_return); + unsafe { sys::cv_utils_logging_LogTag_LogTag_const_charX_LogLevel(_name.opencv_as_extern(), _level, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::LogTag::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [core::LogTag] pub trait LogTagTraitConst { fn as_raw_LogTag(&self) -> *const c_void; @@ -40013,45 +40032,6 @@ pub mod core { } - pub struct LogTag { - ptr: *mut c_void, - } - - opencv_type_boxed! { LogTag } - - impl Drop for LogTag { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_utils_logging_LogTag_delete(self.as_raw_mut_LogTag()) }; - } - } - - unsafe impl Send for LogTag {} - - impl core::LogTagTraitConst for LogTag { - #[inline] fn as_raw_LogTag(&self) -> *const c_void { self.as_raw() } - } - - impl core::LogTagTrait for LogTag { - #[inline] fn as_raw_mut_LogTag(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { LogTag, core::LogTagTraitConst, as_raw_LogTag, core::LogTagTrait, as_raw_mut_LogTag } - - impl LogTag { - #[inline] - pub fn new(_name: &str, _level: core::LogLevel) -> Result { - extern_container_arg!(_name); - return_send!(via ocvrs_return); - unsafe { sys::cv_utils_logging_LogTag_LogTag_const_charX_LogLevel(_name.opencv_as_extern(), _level, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::LogTag::opencv_from_extern(ret) }; - Ok(ret) - } - - } - impl std::fmt::Debug for LogTag { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -40062,36 +40042,16 @@ pub mod core { } } - /// Constant methods for [core::OriginalClassName] - pub trait OriginalClassNameTraitConst { - fn as_raw_OriginalClassName(&self) -> *const c_void; - - #[inline] - fn get_int_param(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_utils_nested_OriginalClassName_getIntParam_const(self.as_raw_OriginalClassName(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_float_param(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_utils_nested_OriginalClassName_getFloatParam_const(self.as_raw_OriginalClassName(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - + impl core::LogTagTraitConst for LogTag { + #[inline] fn as_raw_LogTag(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [core::OriginalClassName] - pub trait OriginalClassNameTrait: core::OriginalClassNameTraitConst { - fn as_raw_mut_OriginalClassName(&mut self) -> *mut c_void; - + impl core::LogTagTrait for LogTag { + #[inline] fn as_raw_mut_LogTag(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { LogTag, core::LogTagTraitConst, as_raw_LogTag, core::LogTagTrait, as_raw_mut_LogTag } + pub struct OriginalClassName { ptr: *mut c_void, } @@ -40107,16 +40067,6 @@ pub mod core { unsafe impl Send for OriginalClassName {} - impl core::OriginalClassNameTraitConst for OriginalClassName { - #[inline] fn as_raw_OriginalClassName(&self) -> *const c_void { self.as_raw() } - } - - impl core::OriginalClassNameTrait for OriginalClassName { - #[inline] fn as_raw_mut_OriginalClassName(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { OriginalClassName, core::OriginalClassNameTraitConst, as_raw_OriginalClassName, core::OriginalClassNameTrait, as_raw_mut_OriginalClassName } - impl OriginalClassName { /// ## C++ default parameters /// * params: OriginalClassName::Params() @@ -40180,6 +40130,36 @@ pub mod core { } + /// Constant methods for [core::OriginalClassName] + pub trait OriginalClassNameTraitConst { + fn as_raw_OriginalClassName(&self) -> *const c_void; + + #[inline] + fn get_int_param(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_utils_nested_OriginalClassName_getIntParam_const(self.as_raw_OriginalClassName(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn get_float_param(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_utils_nested_OriginalClassName_getFloatParam_const(self.as_raw_OriginalClassName(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + /// Mutable methods for [core::OriginalClassName] + pub trait OriginalClassNameTrait: core::OriginalClassNameTraitConst { + fn as_raw_mut_OriginalClassName(&mut self) -> *mut c_void; + + } + impl std::fmt::Debug for OriginalClassName { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -40188,6 +40168,16 @@ pub mod core { } } + impl core::OriginalClassNameTraitConst for OriginalClassName { + #[inline] fn as_raw_OriginalClassName(&self) -> *const c_void { self.as_raw() } + } + + impl core::OriginalClassNameTrait for OriginalClassName { + #[inline] fn as_raw_mut_OriginalClassName(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { OriginalClassName, core::OriginalClassNameTraitConst, as_raw_OriginalClassName, core::OriginalClassNameTrait, as_raw_mut_OriginalClassName } + #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] pub struct OriginalClassName_Params { @@ -40224,5 +40214,6 @@ pub mod core { } } + pub use crate::manual::core::*; } diff --git a/docs/cudaarithm.rs b/docs/cudaarithm.rs index 40a6ef9aa..50cfb55ad 100644 --- a/docs/cudaarithm.rs +++ b/docs/cudaarithm.rs @@ -4310,6 +4310,22 @@ pub mod cudaarithm { Ok(ret) } + /// Base class for convolution (or cross-correlation) operator. : + pub struct Convolution { + ptr: *mut c_void, + } + + opencv_type_boxed! { Convolution } + + impl Drop for Convolution { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_Convolution_delete(self.as_raw_mut_Convolution()) }; + } + } + + unsafe impl Send for Convolution {} + /// Constant methods for [crate::cudaarithm::Convolution] pub trait ConvolutionTraitConst: core::AlgorithmTraitConst { fn as_raw_Convolution(&self) -> *const c_void; @@ -4375,21 +4391,15 @@ pub mod cudaarithm { } - /// Base class for convolution (or cross-correlation) operator. : - pub struct Convolution { - ptr: *mut c_void, - } - - opencv_type_boxed! { Convolution } - - impl Drop for Convolution { + impl std::fmt::Debug for Convolution { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_Convolution_delete(self.as_raw_mut_Convolution()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Convolution") + .finish() } } - unsafe impl Send for Convolution {} + boxed_cast_base! { Convolution, core::Algorithm, cv_cuda_Convolution_to_Algorithm } impl core::AlgorithmTraitConst for Convolution { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -4411,19 +4421,22 @@ pub mod cudaarithm { boxed_ref! { Convolution, crate::cudaarithm::ConvolutionTraitConst, as_raw_Convolution, crate::cudaarithm::ConvolutionTrait, as_raw_mut_Convolution } - impl Convolution { + /// Base class for DFT operator as a cv::Algorithm. : + pub struct DFT { + ptr: *mut c_void, } - boxed_cast_base! { Convolution, core::Algorithm, cv_cuda_Convolution_to_Algorithm } + opencv_type_boxed! { DFT } - impl std::fmt::Debug for Convolution { + impl Drop for DFT { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Convolution") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cuda_DFT_delete(self.as_raw_mut_DFT()) }; } } + unsafe impl Send for DFT {} + /// Constant methods for [crate::cudaarithm::DFT] pub trait DFTTraitConst: core::AlgorithmTraitConst { fn as_raw_DFT(&self) -> *const c_void; @@ -4477,21 +4490,15 @@ pub mod cudaarithm { } - /// Base class for DFT operator as a cv::Algorithm. : - pub struct DFT { - ptr: *mut c_void, - } - - opencv_type_boxed! { DFT } - - impl Drop for DFT { + impl std::fmt::Debug for DFT { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_DFT_delete(self.as_raw_mut_DFT()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DFT") + .finish() } } - unsafe impl Send for DFT {} + boxed_cast_base! { DFT, core::Algorithm, cv_cuda_DFT_to_Algorithm } impl core::AlgorithmTraitConst for DFT { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -4513,19 +4520,22 @@ pub mod cudaarithm { boxed_ref! { DFT, crate::cudaarithm::DFTTraitConst, as_raw_DFT, crate::cudaarithm::DFTTrait, as_raw_mut_DFT } - impl DFT { + /// Base class for transform using lookup table. + pub struct LookUpTable { + ptr: *mut c_void, } - boxed_cast_base! { DFT, core::Algorithm, cv_cuda_DFT_to_Algorithm } + opencv_type_boxed! { LookUpTable } - impl std::fmt::Debug for DFT { + impl Drop for LookUpTable { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DFT") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cuda_LookUpTable_delete(self.as_raw_mut_LookUpTable()) }; } } + unsafe impl Send for LookUpTable {} + /// Constant methods for [crate::cudaarithm::LookUpTable] pub trait LookUpTableTraitConst: core::AlgorithmTraitConst { fn as_raw_LookUpTable(&self) -> *const c_void; @@ -4581,21 +4591,15 @@ pub mod cudaarithm { } - /// Base class for transform using lookup table. - pub struct LookUpTable { - ptr: *mut c_void, - } - - opencv_type_boxed! { LookUpTable } - - impl Drop for LookUpTable { + impl std::fmt::Debug for LookUpTable { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_LookUpTable_delete(self.as_raw_mut_LookUpTable()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LookUpTable") + .finish() } } - unsafe impl Send for LookUpTable {} + boxed_cast_base! { LookUpTable, core::Algorithm, cv_cuda_LookUpTable_to_Algorithm } impl core::AlgorithmTraitConst for LookUpTable { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -4617,16 +4621,4 @@ pub mod cudaarithm { boxed_ref! { LookUpTable, crate::cudaarithm::LookUpTableTraitConst, as_raw_LookUpTable, crate::cudaarithm::LookUpTableTrait, as_raw_mut_LookUpTable } - impl LookUpTable { - } - - boxed_cast_base! { LookUpTable, core::Algorithm, cv_cuda_LookUpTable_to_Algorithm } - - impl std::fmt::Debug for LookUpTable { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LookUpTable") - .finish() - } - } } diff --git a/docs/cudabgsegm.rs b/docs/cudabgsegm.rs index 2ea6b3d99..d2a6b5556 100644 --- a/docs/cudabgsegm.rs +++ b/docs/cudabgsegm.rs @@ -104,6 +104,33 @@ pub mod cudabgsegm { Ok(ret) } + /// Gaussian Mixture-based Background/Foreground Segmentation Algorithm. + /// + /// The class discriminates between foreground and background pixels by building and maintaining a model + /// of the background. Any pixel which does not fit this model is then deemed to be foreground. The + /// class implements algorithm described in [MOG2001](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_MOG2001) . + /// ## See also + /// BackgroundSubtractorMOG + /// + /// + /// Note: + /// * An example on gaussian mixture based background/foreground segmantation can be found at + /// opencv_source_code/samples/gpu/bgfg_segm.cpp + pub struct CUDA_BackgroundSubtractorMOG { + ptr: *mut c_void, + } + + opencv_type_boxed! { CUDA_BackgroundSubtractorMOG } + + impl Drop for CUDA_BackgroundSubtractorMOG { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_BackgroundSubtractorMOG_delete(self.as_raw_mut_CUDA_BackgroundSubtractorMOG()) }; + } + } + + unsafe impl Send for CUDA_BackgroundSubtractorMOG {} + /// Constant methods for [crate::cudabgsegm::CUDA_BackgroundSubtractorMOG] pub trait CUDA_BackgroundSubtractorMOGTraitConst: crate::video::BackgroundSubtractorTraitConst { fn as_raw_CUDA_BackgroundSubtractorMOG(&self) -> *const c_void; @@ -218,32 +245,17 @@ pub mod cudabgsegm { } - /// Gaussian Mixture-based Background/Foreground Segmentation Algorithm. - /// - /// The class discriminates between foreground and background pixels by building and maintaining a model - /// of the background. Any pixel which does not fit this model is then deemed to be foreground. The - /// class implements algorithm described in [MOG2001](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_MOG2001) . - /// ## See also - /// BackgroundSubtractorMOG - /// - /// - /// Note: - /// * An example on gaussian mixture based background/foreground segmantation can be found at - /// opencv_source_code/samples/gpu/bgfg_segm.cpp - pub struct CUDA_BackgroundSubtractorMOG { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_BackgroundSubtractorMOG } - - impl Drop for CUDA_BackgroundSubtractorMOG { + impl std::fmt::Debug for CUDA_BackgroundSubtractorMOG { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_BackgroundSubtractorMOG_delete(self.as_raw_mut_CUDA_BackgroundSubtractorMOG()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_BackgroundSubtractorMOG") + .finish() } } - unsafe impl Send for CUDA_BackgroundSubtractorMOG {} + boxed_cast_base! { CUDA_BackgroundSubtractorMOG, core::Algorithm, cv_cuda_BackgroundSubtractorMOG_to_Algorithm } + + boxed_cast_base! { CUDA_BackgroundSubtractorMOG, crate::video::BackgroundSubtractor, cv_cuda_BackgroundSubtractorMOG_to_BackgroundSubtractor } impl core::AlgorithmTraitConst for CUDA_BackgroundSubtractorMOG { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -275,21 +287,28 @@ pub mod cudabgsegm { boxed_ref! { CUDA_BackgroundSubtractorMOG, crate::cudabgsegm::CUDA_BackgroundSubtractorMOGTraitConst, as_raw_CUDA_BackgroundSubtractorMOG, crate::cudabgsegm::CUDA_BackgroundSubtractorMOGTrait, as_raw_mut_CUDA_BackgroundSubtractorMOG } - impl CUDA_BackgroundSubtractorMOG { + /// Gaussian Mixture-based Background/Foreground Segmentation Algorithm. + /// + /// The class discriminates between foreground and background pixels by building and maintaining a model + /// of the background. Any pixel which does not fit this model is then deemed to be foreground. The + /// class implements algorithm described in [Zivkovic2004](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Zivkovic2004) . + /// ## See also + /// BackgroundSubtractorMOG2 + pub struct CUDA_BackgroundSubtractorMOG2 { + ptr: *mut c_void, } - boxed_cast_base! { CUDA_BackgroundSubtractorMOG, core::Algorithm, cv_cuda_BackgroundSubtractorMOG_to_Algorithm } - - boxed_cast_base! { CUDA_BackgroundSubtractorMOG, crate::video::BackgroundSubtractor, cv_cuda_BackgroundSubtractorMOG_to_BackgroundSubtractor } + opencv_type_boxed! { CUDA_BackgroundSubtractorMOG2 } - impl std::fmt::Debug for CUDA_BackgroundSubtractorMOG { + impl Drop for CUDA_BackgroundSubtractorMOG2 { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_BackgroundSubtractorMOG") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cuda_BackgroundSubtractorMOG2_delete(self.as_raw_mut_CUDA_BackgroundSubtractorMOG2()) }; } } + unsafe impl Send for CUDA_BackgroundSubtractorMOG2 {} + /// Constant methods for [crate::cudabgsegm::CUDA_BackgroundSubtractorMOG2] pub trait CUDA_BackgroundSubtractorMOG2TraitConst: crate::video::BackgroundSubtractorMOG2TraitConst { fn as_raw_CUDA_BackgroundSubtractorMOG2(&self) -> *const c_void; @@ -332,27 +351,19 @@ pub mod cudabgsegm { } - /// Gaussian Mixture-based Background/Foreground Segmentation Algorithm. - /// - /// The class discriminates between foreground and background pixels by building and maintaining a model - /// of the background. Any pixel which does not fit this model is then deemed to be foreground. The - /// class implements algorithm described in [Zivkovic2004](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Zivkovic2004) . - /// ## See also - /// BackgroundSubtractorMOG2 - pub struct CUDA_BackgroundSubtractorMOG2 { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_BackgroundSubtractorMOG2 } - - impl Drop for CUDA_BackgroundSubtractorMOG2 { + impl std::fmt::Debug for CUDA_BackgroundSubtractorMOG2 { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_BackgroundSubtractorMOG2_delete(self.as_raw_mut_CUDA_BackgroundSubtractorMOG2()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_BackgroundSubtractorMOG2") + .finish() } } - unsafe impl Send for CUDA_BackgroundSubtractorMOG2 {} + boxed_cast_base! { CUDA_BackgroundSubtractorMOG2, core::Algorithm, cv_cuda_BackgroundSubtractorMOG2_to_Algorithm } + + boxed_cast_base! { CUDA_BackgroundSubtractorMOG2, crate::video::BackgroundSubtractor, cv_cuda_BackgroundSubtractorMOG2_to_BackgroundSubtractor } + + boxed_cast_base! { CUDA_BackgroundSubtractorMOG2, crate::video::BackgroundSubtractorMOG2, cv_cuda_BackgroundSubtractorMOG2_to_BackgroundSubtractorMOG2 } impl core::AlgorithmTraitConst for CUDA_BackgroundSubtractorMOG2 { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -394,20 +405,4 @@ pub mod cudabgsegm { boxed_ref! { CUDA_BackgroundSubtractorMOG2, crate::cudabgsegm::CUDA_BackgroundSubtractorMOG2TraitConst, as_raw_CUDA_BackgroundSubtractorMOG2, crate::cudabgsegm::CUDA_BackgroundSubtractorMOG2Trait, as_raw_mut_CUDA_BackgroundSubtractorMOG2 } - impl CUDA_BackgroundSubtractorMOG2 { - } - - boxed_cast_base! { CUDA_BackgroundSubtractorMOG2, core::Algorithm, cv_cuda_BackgroundSubtractorMOG2_to_Algorithm } - - boxed_cast_base! { CUDA_BackgroundSubtractorMOG2, crate::video::BackgroundSubtractor, cv_cuda_BackgroundSubtractorMOG2_to_BackgroundSubtractor } - - boxed_cast_base! { CUDA_BackgroundSubtractorMOG2, crate::video::BackgroundSubtractorMOG2, cv_cuda_BackgroundSubtractorMOG2_to_BackgroundSubtractorMOG2 } - - impl std::fmt::Debug for CUDA_BackgroundSubtractorMOG2 { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_BackgroundSubtractorMOG2") - .finish() - } - } } diff --git a/docs/cudacodec.rs b/docs/cudacodec.rs index e712cf097..69707c6d4 100644 --- a/docs/cudacodec.rs +++ b/docs/cudacodec.rs @@ -953,9 +953,24 @@ pub mod cudacodec { opencv_type_simple! { crate::cudacodec::CUDA_EncodeQp } - impl CUDA_EncodeQp { + /// Interface for encoder callbacks. + /// + /// User can implement own multiplexing by implementing this interface. + pub struct CUDA_EncoderCallback { + ptr: *mut c_void, } + opencv_type_boxed! { CUDA_EncoderCallback } + + impl Drop for CUDA_EncoderCallback { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cudacodec_EncoderCallback_delete(self.as_raw_mut_CUDA_EncoderCallback()) }; + } + } + + unsafe impl Send for CUDA_EncoderCallback {} + /// Constant methods for [crate::cudacodec::CUDA_EncoderCallback] pub trait CUDA_EncoderCallbackTraitConst { fn as_raw_CUDA_EncoderCallback(&self) -> *const c_void; @@ -1005,24 +1020,14 @@ pub mod cudacodec { } - /// Interface for encoder callbacks. - /// - /// User can implement own multiplexing by implementing this interface. - pub struct CUDA_EncoderCallback { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_EncoderCallback } - - impl Drop for CUDA_EncoderCallback { + impl std::fmt::Debug for CUDA_EncoderCallback { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cudacodec_EncoderCallback_delete(self.as_raw_mut_CUDA_EncoderCallback()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_EncoderCallback") + .finish() } } - unsafe impl Send for CUDA_EncoderCallback {} - impl crate::cudacodec::CUDA_EncoderCallbackTraitConst for CUDA_EncoderCallback { #[inline] fn as_raw_CUDA_EncoderCallback(&self) -> *const c_void { self.as_raw() } } @@ -1033,17 +1038,6 @@ pub mod cudacodec { boxed_ref! { CUDA_EncoderCallback, crate::cudacodec::CUDA_EncoderCallbackTraitConst, as_raw_CUDA_EncoderCallback, crate::cudacodec::CUDA_EncoderCallbackTrait, as_raw_mut_CUDA_EncoderCallback } - impl CUDA_EncoderCallback { - } - - impl std::fmt::Debug for CUDA_EncoderCallback { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_EncoderCallback") - .finish() - } - } - /// Different parameters for CUDA video encoder. #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] @@ -1140,6 +1134,22 @@ pub mod cudacodec { } + /// Class for converting the raw YUV Surface output from VideoReader if output color format is set to ColorFormat::NV_YUV_SURFACE_FORMAT (VideoReader::set(ColorFormat::NV_YUV_SURFACE_FORMAT)) to the requested [ColorFormat]. + pub struct CUDA_NVSurfaceToColorConverter { + ptr: *mut c_void, + } + + opencv_type_boxed! { CUDA_NVSurfaceToColorConverter } + + impl Drop for CUDA_NVSurfaceToColorConverter { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cudacodec_NVSurfaceToColorConverter_delete(self.as_raw_mut_CUDA_NVSurfaceToColorConverter()) }; + } + } + + unsafe impl Send for CUDA_NVSurfaceToColorConverter {} + /// Constant methods for [crate::cudacodec::CUDA_NVSurfaceToColorConverter] pub trait CUDA_NVSurfaceToColorConverterTraitConst { fn as_raw_CUDA_NVSurfaceToColorConverter(&self) -> *const c_void; @@ -1207,22 +1217,14 @@ pub mod cudacodec { } - /// Class for converting the raw YUV Surface output from VideoReader if output color format is set to ColorFormat::NV_YUV_SURFACE_FORMAT (VideoReader::set(ColorFormat::NV_YUV_SURFACE_FORMAT)) to the requested [ColorFormat]. - pub struct CUDA_NVSurfaceToColorConverter { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_NVSurfaceToColorConverter } - - impl Drop for CUDA_NVSurfaceToColorConverter { + impl std::fmt::Debug for CUDA_NVSurfaceToColorConverter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cudacodec_NVSurfaceToColorConverter_delete(self.as_raw_mut_CUDA_NVSurfaceToColorConverter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_NVSurfaceToColorConverter") + .finish() } } - unsafe impl Send for CUDA_NVSurfaceToColorConverter {} - impl crate::cudacodec::CUDA_NVSurfaceToColorConverterTraitConst for CUDA_NVSurfaceToColorConverter { #[inline] fn as_raw_CUDA_NVSurfaceToColorConverter(&self) -> *const c_void { self.as_raw() } } @@ -1233,17 +1235,24 @@ pub mod cudacodec { boxed_ref! { CUDA_NVSurfaceToColorConverter, crate::cudacodec::CUDA_NVSurfaceToColorConverterTraitConst, as_raw_CUDA_NVSurfaceToColorConverter, crate::cudacodec::CUDA_NVSurfaceToColorConverterTrait, as_raw_mut_CUDA_NVSurfaceToColorConverter } - impl CUDA_NVSurfaceToColorConverter { + /// Interface for video demultiplexing. : + /// + /// User can implement own demultiplexing by implementing this interface. + pub struct CUDA_RawVideoSource { + ptr: *mut c_void, } - impl std::fmt::Debug for CUDA_NVSurfaceToColorConverter { + opencv_type_boxed! { CUDA_RawVideoSource } + + impl Drop for CUDA_RawVideoSource { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_NVSurfaceToColorConverter") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cudacodec_RawVideoSource_delete(self.as_raw_mut_CUDA_RawVideoSource()) }; } } + unsafe impl Send for CUDA_RawVideoSource {} + /// Constant methods for [crate::cudacodec::CUDA_RawVideoSource] pub trait CUDA_RawVideoSourceTraitConst { fn as_raw_CUDA_RawVideoSource(&self) -> *const c_void; @@ -1347,24 +1356,14 @@ pub mod cudacodec { } - /// Interface for video demultiplexing. : - /// - /// User can implement own demultiplexing by implementing this interface. - pub struct CUDA_RawVideoSource { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_RawVideoSource } - - impl Drop for CUDA_RawVideoSource { + impl std::fmt::Debug for CUDA_RawVideoSource { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cudacodec_RawVideoSource_delete(self.as_raw_mut_CUDA_RawVideoSource()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_RawVideoSource") + .finish() } } - unsafe impl Send for CUDA_RawVideoSource {} - impl crate::cudacodec::CUDA_RawVideoSourceTraitConst for CUDA_RawVideoSource { #[inline] fn as_raw_CUDA_RawVideoSource(&self) -> *const c_void { self.as_raw() } } @@ -1375,17 +1374,31 @@ pub mod cudacodec { boxed_ref! { CUDA_RawVideoSource, crate::cudacodec::CUDA_RawVideoSourceTraitConst, as_raw_CUDA_RawVideoSource, crate::cudacodec::CUDA_RawVideoSourceTrait, as_raw_mut_CUDA_RawVideoSource } - impl CUDA_RawVideoSource { + /// Video reader interface, see createVideoReader(). + /// + /// Available if Nvidia's Video Codec SDK is installed. + /// + /// Decoding support is dependent on the GPU, refer to the Nvidia Video Codec SDK Video Encode and Decode GPU Support Matrix for details. + /// + /// + /// Note: + /// * An example on how to use the VideoReader interface can be found at + /// opencv_source_code/samples/gpu/video_reader.cpp + pub struct CUDA_VideoReader { + ptr: *mut c_void, } - impl std::fmt::Debug for CUDA_RawVideoSource { + opencv_type_boxed! { CUDA_VideoReader } + + impl Drop for CUDA_VideoReader { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_RawVideoSource") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cudacodec_VideoReader_delete(self.as_raw_mut_CUDA_VideoReader()) }; } } + unsafe impl Send for CUDA_VideoReader {} + /// Constant methods for [crate::cudacodec::CUDA_VideoReader] pub trait CUDA_VideoReaderTraitConst { fn as_raw_CUDA_VideoReader(&self) -> *const c_void; @@ -1776,31 +1789,14 @@ pub mod cudacodec { } - /// Video reader interface, see createVideoReader(). - /// - /// Available if Nvidia's Video Codec SDK is installed. - /// - /// Decoding support is dependent on the GPU, refer to the Nvidia Video Codec SDK Video Encode and Decode GPU Support Matrix for details. - /// - /// - /// Note: - /// * An example on how to use the VideoReader interface can be found at - /// opencv_source_code/samples/gpu/video_reader.cpp - pub struct CUDA_VideoReader { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_VideoReader } - - impl Drop for CUDA_VideoReader { + impl std::fmt::Debug for CUDA_VideoReader { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cudacodec_VideoReader_delete(self.as_raw_mut_CUDA_VideoReader()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_VideoReader") + .finish() } } - unsafe impl Send for CUDA_VideoReader {} - impl crate::cudacodec::CUDA_VideoReaderTraitConst for CUDA_VideoReader { #[inline] fn as_raw_CUDA_VideoReader(&self) -> *const c_void { self.as_raw() } } @@ -1811,17 +1807,6 @@ pub mod cudacodec { boxed_ref! { CUDA_VideoReader, crate::cudacodec::CUDA_VideoReaderTraitConst, as_raw_CUDA_VideoReader, crate::cudacodec::CUDA_VideoReaderTrait, as_raw_mut_CUDA_VideoReader } - impl CUDA_VideoReader { - } - - impl std::fmt::Debug for CUDA_VideoReader { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_VideoReader") - .finish() - } - } - /// VideoReader initialization parameters /// ## Parameters /// * udpSource: Remove validation which can cause VideoReader() to throw exceptions when reading from a UDP source. @@ -1867,6 +1852,31 @@ pub mod cudacodec { } + /// Video writer interface, see createVideoWriter(). + /// + /// Available if Nvidia's Video Codec SDK is installed. + /// + /// Only Codec::H264 and Codec::HEVC are supported with encoding support dependent on the GPU, refer to the Nvidia Video Codec SDK Video Encode and Decode GPU Support Matrix for details. + /// + /// + /// Note: + /// * An example on how to use the VideoWriter class can be found at + /// opencv_source_code/samples/gpu/video_writer.cpp + pub struct CUDA_VideoWriter { + ptr: *mut c_void, + } + + opencv_type_boxed! { CUDA_VideoWriter } + + impl Drop for CUDA_VideoWriter { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cudacodec_VideoWriter_delete(self.as_raw_mut_CUDA_VideoWriter()) }; + } + } + + unsafe impl Send for CUDA_VideoWriter {} + /// Constant methods for [crate::cudacodec::CUDA_VideoWriter] pub trait CUDA_VideoWriterTraitConst { fn as_raw_CUDA_VideoWriter(&self) -> *const c_void; @@ -1916,31 +1926,14 @@ pub mod cudacodec { } - /// Video writer interface, see createVideoWriter(). - /// - /// Available if Nvidia's Video Codec SDK is installed. - /// - /// Only Codec::H264 and Codec::HEVC are supported with encoding support dependent on the GPU, refer to the Nvidia Video Codec SDK Video Encode and Decode GPU Support Matrix for details. - /// - /// - /// Note: - /// * An example on how to use the VideoWriter class can be found at - /// opencv_source_code/samples/gpu/video_writer.cpp - pub struct CUDA_VideoWriter { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_VideoWriter } - - impl Drop for CUDA_VideoWriter { + impl std::fmt::Debug for CUDA_VideoWriter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cudacodec_VideoWriter_delete(self.as_raw_mut_CUDA_VideoWriter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_VideoWriter") + .finish() } } - unsafe impl Send for CUDA_VideoWriter {} - impl crate::cudacodec::CUDA_VideoWriterTraitConst for CUDA_VideoWriter { #[inline] fn as_raw_CUDA_VideoWriter(&self) -> *const c_void { self.as_raw() } } @@ -1951,14 +1944,4 @@ pub mod cudacodec { boxed_ref! { CUDA_VideoWriter, crate::cudacodec::CUDA_VideoWriterTraitConst, as_raw_CUDA_VideoWriter, crate::cudacodec::CUDA_VideoWriterTrait, as_raw_mut_CUDA_VideoWriter } - impl CUDA_VideoWriter { - } - - impl std::fmt::Debug for CUDA_VideoWriter { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_VideoWriter") - .finish() - } - } } diff --git a/docs/cudafeatures2d.rs b/docs/cudafeatures2d.rs index b57e9406f..041bbb64b 100644 --- a/docs/cudafeatures2d.rs +++ b/docs/cudafeatures2d.rs @@ -6,6 +6,75 @@ pub mod cudafeatures2d { pub use super::{CUDA_DescriptorMatcherTrait, CUDA_DescriptorMatcherTraitConst, CUDA_FastFeatureDetectorTrait, CUDA_FastFeatureDetectorTraitConst, CUDA_Feature2DAsyncTrait, CUDA_Feature2DAsyncTraitConst, CUDA_ORBTrait, CUDA_ORBTraitConst}; } + /// Abstract base class for matching keypoint descriptors. + /// + /// It has two groups of match methods: for matching descriptors of an image with another image or with + /// an image set. + pub struct CUDA_DescriptorMatcher { + ptr: *mut c_void, + } + + opencv_type_boxed! { CUDA_DescriptorMatcher } + + impl Drop for CUDA_DescriptorMatcher { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_DescriptorMatcher_delete(self.as_raw_mut_CUDA_DescriptorMatcher()) }; + } + } + + unsafe impl Send for CUDA_DescriptorMatcher {} + + impl CUDA_DescriptorMatcher { + /// Brute-force descriptor matcher. + /// + /// For each descriptor in the first set, this matcher finds the closest descriptor in the second set + /// by trying each one. This descriptor matcher supports masking permissible matches of descriptor + /// sets. + /// + /// ## Parameters + /// * normType: One of NORM_L1, NORM_L2, NORM_HAMMING. L1 and L2 norms are + /// preferable choices for SIFT and SURF descriptors, NORM_HAMMING should be used with ORB, BRISK and + /// BRIEF). + /// + /// ## C++ default parameters + /// * norm_type: cv::NORM_L2 + #[inline] + pub fn create_bf_matcher(norm_type: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_DescriptorMatcher_createBFMatcher_int(norm_type, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Brute-force descriptor matcher. + /// + /// For each descriptor in the first set, this matcher finds the closest descriptor in the second set + /// by trying each one. This descriptor matcher supports masking permissible matches of descriptor + /// sets. + /// + /// ## Parameters + /// * normType: One of NORM_L1, NORM_L2, NORM_HAMMING. L1 and L2 norms are + /// preferable choices for SIFT and SURF descriptors, NORM_HAMMING should be used with ORB, BRISK and + /// BRIEF). + /// + /// ## Note + /// This alternative version of [CUDA_DescriptorMatcher::create_bf_matcher] function uses the following default values for its arguments: + /// * norm_type: cv::NORM_L2 + #[inline] + pub fn create_bf_matcher_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_DescriptorMatcher_createBFMatcher(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::cudafeatures2d::CUDA_DescriptorMatcher] pub trait CUDA_DescriptorMatcherTraitConst: core::AlgorithmTraitConst { fn as_raw_CUDA_DescriptorMatcher(&self) -> *const c_void; @@ -911,24 +980,15 @@ pub mod cudafeatures2d { } - /// Abstract base class for matching keypoint descriptors. - /// - /// It has two groups of match methods: for matching descriptors of an image with another image or with - /// an image set. - pub struct CUDA_DescriptorMatcher { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_DescriptorMatcher } - - impl Drop for CUDA_DescriptorMatcher { + impl std::fmt::Debug for CUDA_DescriptorMatcher { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_DescriptorMatcher_delete(self.as_raw_mut_CUDA_DescriptorMatcher()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_DescriptorMatcher") + .finish() } } - unsafe impl Send for CUDA_DescriptorMatcher {} + boxed_cast_base! { CUDA_DescriptorMatcher, core::Algorithm, cv_cuda_DescriptorMatcher_to_Algorithm } impl core::AlgorithmTraitConst for CUDA_DescriptorMatcher { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -950,66 +1010,60 @@ pub mod cudafeatures2d { boxed_ref! { CUDA_DescriptorMatcher, crate::cudafeatures2d::CUDA_DescriptorMatcherTraitConst, as_raw_CUDA_DescriptorMatcher, crate::cudafeatures2d::CUDA_DescriptorMatcherTrait, as_raw_mut_CUDA_DescriptorMatcher } - impl CUDA_DescriptorMatcher { - /// Brute-force descriptor matcher. - /// - /// For each descriptor in the first set, this matcher finds the closest descriptor in the second set - /// by trying each one. This descriptor matcher supports masking permissible matches of descriptor - /// sets. - /// - /// ## Parameters - /// * normType: One of NORM_L1, NORM_L2, NORM_HAMMING. L1 and L2 norms are - /// preferable choices for SIFT and SURF descriptors, NORM_HAMMING should be used with ORB, BRISK and - /// BRIEF). - /// + /// Wrapping class for feature detection using the FAST method. + pub struct CUDA_FastFeatureDetector { + ptr: *mut c_void, + } + + opencv_type_boxed! { CUDA_FastFeatureDetector } + + impl Drop for CUDA_FastFeatureDetector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_FastFeatureDetector_delete(self.as_raw_mut_CUDA_FastFeatureDetector()) }; + } + } + + unsafe impl Send for CUDA_FastFeatureDetector {} + + impl CUDA_FastFeatureDetector { + pub const LOCATION_ROW: i32 = 0; + pub const RESPONSE_ROW: i32 = 1; + pub const ROWS_COUNT: i32 = 2; + pub const FEATURE_SIZE: i32 = 7; /// ## C++ default parameters - /// * norm_type: cv::NORM_L2 + /// * threshold: 10 + /// * nonmax_suppression: true + /// * typ: cv::FastFeatureDetector::TYPE_9_16 + /// * max_npoints: 5000 #[inline] - pub fn create_bf_matcher(norm_type: i32) -> Result> { + pub fn create(threshold: i32, nonmax_suppression: bool, typ: i32, max_npoints: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_DescriptorMatcher_createBFMatcher_int(norm_type, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_FastFeatureDetector_create_int_bool_int_int(threshold, nonmax_suppression, typ, max_npoints, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Brute-force descriptor matcher. - /// - /// For each descriptor in the first set, this matcher finds the closest descriptor in the second set - /// by trying each one. This descriptor matcher supports masking permissible matches of descriptor - /// sets. - /// - /// ## Parameters - /// * normType: One of NORM_L1, NORM_L2, NORM_HAMMING. L1 and L2 norms are - /// preferable choices for SIFT and SURF descriptors, NORM_HAMMING should be used with ORB, BRISK and - /// BRIEF). - /// /// ## Note - /// This alternative version of [CUDA_DescriptorMatcher::create_bf_matcher] function uses the following default values for its arguments: - /// * norm_type: cv::NORM_L2 + /// This alternative version of [CUDA_FastFeatureDetector::create] function uses the following default values for its arguments: + /// * threshold: 10 + /// * nonmax_suppression: true + /// * typ: cv::FastFeatureDetector::TYPE_9_16 + /// * max_npoints: 5000 #[inline] - pub fn create_bf_matcher_def() -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_DescriptorMatcher_createBFMatcher(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_FastFeatureDetector_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { CUDA_DescriptorMatcher, core::Algorithm, cv_cuda_DescriptorMatcher_to_Algorithm } - - impl std::fmt::Debug for CUDA_DescriptorMatcher { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_DescriptorMatcher") - .finish() - } - } - /// Constant methods for [crate::cudafeatures2d::CUDA_FastFeatureDetector] pub trait CUDA_FastFeatureDetectorTraitConst: crate::cudafeatures2d::CUDA_Feature2DAsyncTraitConst { fn as_raw_CUDA_FastFeatureDetector(&self) -> *const c_void; @@ -1049,21 +1103,19 @@ pub mod cudafeatures2d { } - /// Wrapping class for feature detection using the FAST method. - pub struct CUDA_FastFeatureDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_FastFeatureDetector } - - impl Drop for CUDA_FastFeatureDetector { + impl std::fmt::Debug for CUDA_FastFeatureDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_FastFeatureDetector_delete(self.as_raw_mut_CUDA_FastFeatureDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_FastFeatureDetector") + .finish() } } - unsafe impl Send for CUDA_FastFeatureDetector {} + boxed_cast_base! { CUDA_FastFeatureDetector, core::Algorithm, cv_cuda_FastFeatureDetector_to_Algorithm } + + boxed_cast_base! { CUDA_FastFeatureDetector, crate::features2d::Feature2D, cv_cuda_FastFeatureDetector_to_Feature2D } + + boxed_cast_base! { CUDA_FastFeatureDetector, crate::cudafeatures2d::CUDA_Feature2DAsync, cv_cuda_FastFeatureDetector_to_CUDA_Feature2DAsync } impl core::AlgorithmTraitConst for CUDA_FastFeatureDetector { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1105,58 +1157,22 @@ pub mod cudafeatures2d { boxed_ref! { CUDA_FastFeatureDetector, crate::cudafeatures2d::CUDA_FastFeatureDetectorTraitConst, as_raw_CUDA_FastFeatureDetector, crate::cudafeatures2d::CUDA_FastFeatureDetectorTrait, as_raw_mut_CUDA_FastFeatureDetector } - impl CUDA_FastFeatureDetector { - pub const LOCATION_ROW: i32 = 0; - pub const RESPONSE_ROW: i32 = 1; - pub const ROWS_COUNT: i32 = 2; - pub const FEATURE_SIZE: i32 = 7; - /// ## C++ default parameters - /// * threshold: 10 - /// * nonmax_suppression: true - /// * typ: cv::FastFeatureDetector::TYPE_9_16 - /// * max_npoints: 5000 - #[inline] - pub fn create(threshold: i32, nonmax_suppression: bool, typ: i32, max_npoints: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_FastFeatureDetector_create_int_bool_int_int(threshold, nonmax_suppression, typ, max_npoints, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [CUDA_FastFeatureDetector::create] function uses the following default values for its arguments: - /// * threshold: 10 - /// * nonmax_suppression: true - /// * typ: cv::FastFeatureDetector::TYPE_9_16 - /// * max_npoints: 5000 - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_FastFeatureDetector_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + /// Abstract base class for CUDA asynchronous 2D image feature detectors and descriptor extractors. + pub struct CUDA_Feature2DAsync { + ptr: *mut c_void, } - boxed_cast_base! { CUDA_FastFeatureDetector, core::Algorithm, cv_cuda_FastFeatureDetector_to_Algorithm } - - boxed_cast_base! { CUDA_FastFeatureDetector, crate::features2d::Feature2D, cv_cuda_FastFeatureDetector_to_Feature2D } - - boxed_cast_base! { CUDA_FastFeatureDetector, crate::cudafeatures2d::CUDA_Feature2DAsync, cv_cuda_FastFeatureDetector_to_CUDA_Feature2DAsync } + opencv_type_boxed! { CUDA_Feature2DAsync } - impl std::fmt::Debug for CUDA_FastFeatureDetector { + impl Drop for CUDA_Feature2DAsync { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_FastFeatureDetector") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cuda_Feature2DAsync_delete(self.as_raw_mut_CUDA_Feature2DAsync()) }; } } + unsafe impl Send for CUDA_Feature2DAsync {} + /// Constant methods for [crate::cudafeatures2d::CUDA_Feature2DAsync] pub trait CUDA_Feature2DAsyncTraitConst: crate::features2d::Feature2DTraitConst { fn as_raw_CUDA_Feature2DAsync(&self) -> *const c_void; @@ -1310,21 +1326,21 @@ pub mod cudafeatures2d { } - /// Abstract base class for CUDA asynchronous 2D image feature detectors and descriptor extractors. - pub struct CUDA_Feature2DAsync { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_Feature2DAsync } - - impl Drop for CUDA_Feature2DAsync { + impl std::fmt::Debug for CUDA_Feature2DAsync { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_Feature2DAsync_delete(self.as_raw_mut_CUDA_Feature2DAsync()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_Feature2DAsync") + .finish() } } - unsafe impl Send for CUDA_Feature2DAsync {} + boxed_cast_base! { CUDA_Feature2DAsync, core::Algorithm, cv_cuda_Feature2DAsync_to_Algorithm } + + boxed_cast_base! { CUDA_Feature2DAsync, crate::features2d::Feature2D, cv_cuda_Feature2DAsync_to_Feature2D } + + boxed_cast_descendant! { CUDA_Feature2DAsync, crate::cudafeatures2d::CUDA_FastFeatureDetector, cv_cuda_Feature2DAsync_to_CUDA_FastFeatureDetector } + + boxed_cast_descendant! { CUDA_Feature2DAsync, crate::cudafeatures2d::CUDA_ORB, cv_cuda_Feature2DAsync_to_CUDA_ORB } impl core::AlgorithmTraitConst for CUDA_Feature2DAsync { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1356,23 +1372,75 @@ pub mod cudafeatures2d { boxed_ref! { CUDA_Feature2DAsync, crate::cudafeatures2d::CUDA_Feature2DAsyncTraitConst, as_raw_CUDA_Feature2DAsync, crate::cudafeatures2d::CUDA_Feature2DAsyncTrait, as_raw_mut_CUDA_Feature2DAsync } - impl CUDA_Feature2DAsync { + /// Class implementing the ORB (*oriented BRIEF*) keypoint detector and descriptor extractor + /// ## See also + /// cv::ORB + pub struct CUDA_ORB { + ptr: *mut c_void, } - boxed_cast_descendant! { CUDA_Feature2DAsync, crate::cudafeatures2d::CUDA_FastFeatureDetector, cv_cuda_Feature2DAsync_to_CUDA_FastFeatureDetector } + opencv_type_boxed! { CUDA_ORB } - boxed_cast_descendant! { CUDA_Feature2DAsync, crate::cudafeatures2d::CUDA_ORB, cv_cuda_Feature2DAsync_to_CUDA_ORB } + impl Drop for CUDA_ORB { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_ORB_delete(self.as_raw_mut_CUDA_ORB()) }; + } + } - boxed_cast_base! { CUDA_Feature2DAsync, core::Algorithm, cv_cuda_Feature2DAsync_to_Algorithm } + unsafe impl Send for CUDA_ORB {} - boxed_cast_base! { CUDA_Feature2DAsync, crate::features2d::Feature2D, cv_cuda_Feature2DAsync_to_Feature2D } + impl CUDA_ORB { + pub const X_ROW: i32 = 0; + pub const Y_ROW: i32 = 1; + pub const RESPONSE_ROW: i32 = 2; + pub const ANGLE_ROW: i32 = 3; + pub const OCTAVE_ROW: i32 = 4; + pub const SIZE_ROW: i32 = 5; + pub const ROWS_COUNT: i32 = 6; + /// ## C++ default parameters + /// * nfeatures: 500 + /// * scale_factor: 1.2f + /// * nlevels: 8 + /// * edge_threshold: 31 + /// * first_level: 0 + /// * wta_k: 2 + /// * score_type: cv::ORB::HARRIS_SCORE + /// * patch_size: 31 + /// * fast_threshold: 20 + /// * blur_for_descriptor: false + #[inline] + pub fn create(nfeatures: i32, scale_factor: f32, nlevels: i32, edge_threshold: i32, first_level: i32, wta_k: i32, score_type: i32, patch_size: i32, fast_threshold: i32, blur_for_descriptor: bool) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_ORB_create_int_float_int_int_int_int_int_int_int_bool(nfeatures, scale_factor, nlevels, edge_threshold, first_level, wta_k, score_type, patch_size, fast_threshold, blur_for_descriptor, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for CUDA_Feature2DAsync { + /// ## Note + /// This alternative version of [CUDA_ORB::create] function uses the following default values for its arguments: + /// * nfeatures: 500 + /// * scale_factor: 1.2f + /// * nlevels: 8 + /// * edge_threshold: 31 + /// * first_level: 0 + /// * wta_k: 2 + /// * score_type: cv::ORB::HARRIS_SCORE + /// * patch_size: 31 + /// * fast_threshold: 20 + /// * blur_for_descriptor: false #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_Feature2DAsync") - .finish() + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_ORB_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::cudafeatures2d::CUDA_ORB] @@ -1568,23 +1636,19 @@ pub mod cudafeatures2d { } - /// Class implementing the ORB (*oriented BRIEF*) keypoint detector and descriptor extractor - /// ## See also - /// cv::ORB - pub struct CUDA_ORB { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_ORB } - - impl Drop for CUDA_ORB { + impl std::fmt::Debug for CUDA_ORB { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_ORB_delete(self.as_raw_mut_CUDA_ORB()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_ORB") + .finish() } } - unsafe impl Send for CUDA_ORB {} + boxed_cast_base! { CUDA_ORB, core::Algorithm, cv_cuda_ORB_to_Algorithm } + + boxed_cast_base! { CUDA_ORB, crate::features2d::Feature2D, cv_cuda_ORB_to_Feature2D } + + boxed_cast_base! { CUDA_ORB, crate::cudafeatures2d::CUDA_Feature2DAsync, cv_cuda_ORB_to_CUDA_Feature2DAsync } impl core::AlgorithmTraitConst for CUDA_ORB { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1626,70 +1690,4 @@ pub mod cudafeatures2d { boxed_ref! { CUDA_ORB, crate::cudafeatures2d::CUDA_ORBTraitConst, as_raw_CUDA_ORB, crate::cudafeatures2d::CUDA_ORBTrait, as_raw_mut_CUDA_ORB } - impl CUDA_ORB { - pub const X_ROW: i32 = 0; - pub const Y_ROW: i32 = 1; - pub const RESPONSE_ROW: i32 = 2; - pub const ANGLE_ROW: i32 = 3; - pub const OCTAVE_ROW: i32 = 4; - pub const SIZE_ROW: i32 = 5; - pub const ROWS_COUNT: i32 = 6; - /// ## C++ default parameters - /// * nfeatures: 500 - /// * scale_factor: 1.2f - /// * nlevels: 8 - /// * edge_threshold: 31 - /// * first_level: 0 - /// * wta_k: 2 - /// * score_type: cv::ORB::HARRIS_SCORE - /// * patch_size: 31 - /// * fast_threshold: 20 - /// * blur_for_descriptor: false - #[inline] - pub fn create(nfeatures: i32, scale_factor: f32, nlevels: i32, edge_threshold: i32, first_level: i32, wta_k: i32, score_type: i32, patch_size: i32, fast_threshold: i32, blur_for_descriptor: bool) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_ORB_create_int_float_int_int_int_int_int_int_int_bool(nfeatures, scale_factor, nlevels, edge_threshold, first_level, wta_k, score_type, patch_size, fast_threshold, blur_for_descriptor, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [CUDA_ORB::create] function uses the following default values for its arguments: - /// * nfeatures: 500 - /// * scale_factor: 1.2f - /// * nlevels: 8 - /// * edge_threshold: 31 - /// * first_level: 0 - /// * wta_k: 2 - /// * score_type: cv::ORB::HARRIS_SCORE - /// * patch_size: 31 - /// * fast_threshold: 20 - /// * blur_for_descriptor: false - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_ORB_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { CUDA_ORB, core::Algorithm, cv_cuda_ORB_to_Algorithm } - - boxed_cast_base! { CUDA_ORB, crate::features2d::Feature2D, cv_cuda_ORB_to_Feature2D } - - boxed_cast_base! { CUDA_ORB, crate::cudafeatures2d::CUDA_Feature2DAsync, cv_cuda_ORB_to_CUDA_Feature2DAsync } - - impl std::fmt::Debug for CUDA_ORB { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_ORB") - .finish() - } - } } diff --git a/docs/cudafilters.rs b/docs/cudafilters.rs index db1ad35b4..f1175157b 100644 --- a/docs/cudafilters.rs +++ b/docs/cudafilters.rs @@ -806,6 +806,22 @@ pub mod cudafilters { Ok(ret) } + /// Common interface for all CUDA filters : + pub struct Filter { + ptr: *mut c_void, + } + + opencv_type_boxed! { Filter } + + impl Drop for Filter { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_Filter_delete(self.as_raw_mut_Filter()) }; + } + } + + unsafe impl Send for Filter {} + /// Constant methods for [crate::cudafilters::Filter] pub trait FilterTraitConst: core::AlgorithmTraitConst { fn as_raw_Filter(&self) -> *const c_void; @@ -859,21 +875,15 @@ pub mod cudafilters { } - /// Common interface for all CUDA filters : - pub struct Filter { - ptr: *mut c_void, - } - - opencv_type_boxed! { Filter } - - impl Drop for Filter { + impl std::fmt::Debug for Filter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_Filter_delete(self.as_raw_mut_Filter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Filter") + .finish() } } - unsafe impl Send for Filter {} + boxed_cast_base! { Filter, core::Algorithm, cv_cuda_Filter_to_Algorithm } impl core::AlgorithmTraitConst for Filter { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -895,16 +905,4 @@ pub mod cudafilters { boxed_ref! { Filter, crate::cudafilters::FilterTraitConst, as_raw_Filter, crate::cudafilters::FilterTrait, as_raw_mut_Filter } - impl Filter { - } - - boxed_cast_base! { Filter, core::Algorithm, cv_cuda_Filter_to_Algorithm } - - impl std::fmt::Debug for Filter { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Filter") - .finish() - } - } } diff --git a/docs/cudaimgproc.rs b/docs/cudaimgproc.rs index 53ae51d53..c70a6163d 100644 --- a/docs/cudaimgproc.rs +++ b/docs/cudaimgproc.rs @@ -1906,6 +1906,22 @@ pub mod cudaimgproc { Ok(ret) } + /// Base class for Contrast Limited Adaptive Histogram Equalization. : + pub struct CUDA_CLAHE { + ptr: *mut c_void, + } + + opencv_type_boxed! { CUDA_CLAHE } + + impl Drop for CUDA_CLAHE { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_CLAHE_delete(self.as_raw_mut_CUDA_CLAHE()) }; + } + } + + unsafe impl Send for CUDA_CLAHE {} + /// Constant methods for [crate::cudaimgproc::CUDA_CLAHE] pub trait CUDA_CLAHETraitConst: crate::imgproc::CLAHETraitConst { fn as_raw_CUDA_CLAHE(&self) -> *const c_void; @@ -1935,21 +1951,17 @@ pub mod cudaimgproc { } - /// Base class for Contrast Limited Adaptive Histogram Equalization. : - pub struct CUDA_CLAHE { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_CLAHE } - - impl Drop for CUDA_CLAHE { + impl std::fmt::Debug for CUDA_CLAHE { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_CLAHE_delete(self.as_raw_mut_CUDA_CLAHE()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_CLAHE") + .finish() } } - unsafe impl Send for CUDA_CLAHE {} + boxed_cast_base! { CUDA_CLAHE, core::Algorithm, cv_cuda_CLAHE_to_Algorithm } + + boxed_cast_base! { CUDA_CLAHE, crate::imgproc::CLAHE, cv_cuda_CLAHE_to_CLAHE } impl core::AlgorithmTraitConst for CUDA_CLAHE { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1981,21 +1993,22 @@ pub mod cudaimgproc { boxed_ref! { CUDA_CLAHE, crate::cudaimgproc::CUDA_CLAHETraitConst, as_raw_CUDA_CLAHE, crate::cudaimgproc::CUDA_CLAHETrait, as_raw_mut_CUDA_CLAHE } - impl CUDA_CLAHE { + /// Base class for Canny Edge Detector. : + pub struct CUDA_CannyEdgeDetector { + ptr: *mut c_void, } - boxed_cast_base! { CUDA_CLAHE, core::Algorithm, cv_cuda_CLAHE_to_Algorithm } - - boxed_cast_base! { CUDA_CLAHE, crate::imgproc::CLAHE, cv_cuda_CLAHE_to_CLAHE } + opencv_type_boxed! { CUDA_CannyEdgeDetector } - impl std::fmt::Debug for CUDA_CLAHE { + impl Drop for CUDA_CannyEdgeDetector { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_CLAHE") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cuda_CannyEdgeDetector_delete(self.as_raw_mut_CUDA_CannyEdgeDetector()) }; } } + unsafe impl Send for CUDA_CannyEdgeDetector {} + /// Constant methods for [crate::cudaimgproc::CUDA_CannyEdgeDetector] pub trait CUDA_CannyEdgeDetectorTraitConst: core::AlgorithmTraitConst { fn as_raw_CUDA_CannyEdgeDetector(&self) -> *const c_void; @@ -2171,21 +2184,15 @@ pub mod cudaimgproc { } - /// Base class for Canny Edge Detector. : - pub struct CUDA_CannyEdgeDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_CannyEdgeDetector } - - impl Drop for CUDA_CannyEdgeDetector { + impl std::fmt::Debug for CUDA_CannyEdgeDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_CannyEdgeDetector_delete(self.as_raw_mut_CUDA_CannyEdgeDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_CannyEdgeDetector") + .finish() } } - unsafe impl Send for CUDA_CannyEdgeDetector {} + boxed_cast_base! { CUDA_CannyEdgeDetector, core::Algorithm, cv_cuda_CannyEdgeDetector_to_Algorithm } impl core::AlgorithmTraitConst for CUDA_CannyEdgeDetector { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2207,19 +2214,22 @@ pub mod cudaimgproc { boxed_ref! { CUDA_CannyEdgeDetector, crate::cudaimgproc::CUDA_CannyEdgeDetectorTraitConst, as_raw_CUDA_CannyEdgeDetector, crate::cudaimgproc::CUDA_CannyEdgeDetectorTrait, as_raw_mut_CUDA_CannyEdgeDetector } - impl CUDA_CannyEdgeDetector { + /// Base class for Cornerness Criteria computation. : + pub struct CUDA_CornernessCriteria { + ptr: *mut c_void, } - boxed_cast_base! { CUDA_CannyEdgeDetector, core::Algorithm, cv_cuda_CannyEdgeDetector_to_Algorithm } + opencv_type_boxed! { CUDA_CornernessCriteria } - impl std::fmt::Debug for CUDA_CannyEdgeDetector { + impl Drop for CUDA_CornernessCriteria { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_CannyEdgeDetector") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cuda_CornernessCriteria_delete(self.as_raw_mut_CUDA_CornernessCriteria()) }; } } + unsafe impl Send for CUDA_CornernessCriteria {} + /// Constant methods for [crate::cudaimgproc::CUDA_CornernessCriteria] pub trait CUDA_CornernessCriteriaTraitConst: core::AlgorithmTraitConst { fn as_raw_CUDA_CornernessCriteria(&self) -> *const c_void; @@ -2275,21 +2285,15 @@ pub mod cudaimgproc { } - /// Base class for Cornerness Criteria computation. : - pub struct CUDA_CornernessCriteria { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_CornernessCriteria } - - impl Drop for CUDA_CornernessCriteria { + impl std::fmt::Debug for CUDA_CornernessCriteria { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_CornernessCriteria_delete(self.as_raw_mut_CUDA_CornernessCriteria()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_CornernessCriteria") + .finish() } } - unsafe impl Send for CUDA_CornernessCriteria {} + boxed_cast_base! { CUDA_CornernessCriteria, core::Algorithm, cv_cuda_CornernessCriteria_to_Algorithm } impl core::AlgorithmTraitConst for CUDA_CornernessCriteria { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2311,19 +2315,22 @@ pub mod cudaimgproc { boxed_ref! { CUDA_CornernessCriteria, crate::cudaimgproc::CUDA_CornernessCriteriaTraitConst, as_raw_CUDA_CornernessCriteria, crate::cudaimgproc::CUDA_CornernessCriteriaTrait, as_raw_mut_CUDA_CornernessCriteria } - impl CUDA_CornernessCriteria { + /// Base class for Corners Detector. : + pub struct CUDA_CornersDetector { + ptr: *mut c_void, } - boxed_cast_base! { CUDA_CornernessCriteria, core::Algorithm, cv_cuda_CornernessCriteria_to_Algorithm } + opencv_type_boxed! { CUDA_CornersDetector } - impl std::fmt::Debug for CUDA_CornernessCriteria { + impl Drop for CUDA_CornersDetector { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_CornernessCriteria") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cuda_CornersDetector_delete(self.as_raw_mut_CUDA_CornersDetector()) }; } } + unsafe impl Send for CUDA_CornersDetector {} + /// Constant methods for [crate::cudaimgproc::CUDA_CornersDetector] pub trait CUDA_CornersDetectorTraitConst: core::AlgorithmTraitConst { fn as_raw_CUDA_CornersDetector(&self) -> *const c_void; @@ -2404,21 +2411,15 @@ pub mod cudaimgproc { } - /// Base class for Corners Detector. : - pub struct CUDA_CornersDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_CornersDetector } - - impl Drop for CUDA_CornersDetector { + impl std::fmt::Debug for CUDA_CornersDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_CornersDetector_delete(self.as_raw_mut_CUDA_CornersDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_CornersDetector") + .finish() } } - unsafe impl Send for CUDA_CornersDetector {} + boxed_cast_base! { CUDA_CornersDetector, core::Algorithm, cv_cuda_CornersDetector_to_Algorithm } impl core::AlgorithmTraitConst for CUDA_CornersDetector { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2440,19 +2441,22 @@ pub mod cudaimgproc { boxed_ref! { CUDA_CornersDetector, crate::cudaimgproc::CUDA_CornersDetectorTraitConst, as_raw_CUDA_CornersDetector, crate::cudaimgproc::CUDA_CornersDetectorTrait, as_raw_mut_CUDA_CornersDetector } - impl CUDA_CornersDetector { + /// Base class for circles detector algorithm. : + pub struct CUDA_HoughCirclesDetector { + ptr: *mut c_void, } - boxed_cast_base! { CUDA_CornersDetector, core::Algorithm, cv_cuda_CornersDetector_to_Algorithm } + opencv_type_boxed! { CUDA_HoughCirclesDetector } - impl std::fmt::Debug for CUDA_CornersDetector { + impl Drop for CUDA_HoughCirclesDetector { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_CornersDetector") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cuda_HoughCirclesDetector_delete(self.as_raw_mut_CUDA_HoughCirclesDetector()) }; } } + unsafe impl Send for CUDA_HoughCirclesDetector {} + /// Constant methods for [crate::cudaimgproc::CUDA_HoughCirclesDetector] pub trait CUDA_HoughCirclesDetectorTraitConst: core::AlgorithmTraitConst { fn as_raw_CUDA_HoughCirclesDetector(&self) -> *const c_void; @@ -2638,21 +2642,15 @@ pub mod cudaimgproc { } - /// Base class for circles detector algorithm. : - pub struct CUDA_HoughCirclesDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_HoughCirclesDetector } - - impl Drop for CUDA_HoughCirclesDetector { + impl std::fmt::Debug for CUDA_HoughCirclesDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_HoughCirclesDetector_delete(self.as_raw_mut_CUDA_HoughCirclesDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_HoughCirclesDetector") + .finish() } } - unsafe impl Send for CUDA_HoughCirclesDetector {} + boxed_cast_base! { CUDA_HoughCirclesDetector, core::Algorithm, cv_cuda_HoughCirclesDetector_to_Algorithm } impl core::AlgorithmTraitConst for CUDA_HoughCirclesDetector { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2674,19 +2672,22 @@ pub mod cudaimgproc { boxed_ref! { CUDA_HoughCirclesDetector, crate::cudaimgproc::CUDA_HoughCirclesDetectorTraitConst, as_raw_CUDA_HoughCirclesDetector, crate::cudaimgproc::CUDA_HoughCirclesDetectorTrait, as_raw_mut_CUDA_HoughCirclesDetector } - impl CUDA_HoughCirclesDetector { + /// Base class for lines detector algorithm. : + pub struct CUDA_HoughLinesDetector { + ptr: *mut c_void, } - boxed_cast_base! { CUDA_HoughCirclesDetector, core::Algorithm, cv_cuda_HoughCirclesDetector_to_Algorithm } + opencv_type_boxed! { CUDA_HoughLinesDetector } - impl std::fmt::Debug for CUDA_HoughCirclesDetector { + impl Drop for CUDA_HoughLinesDetector { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_HoughCirclesDetector") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cuda_HoughLinesDetector_delete(self.as_raw_mut_CUDA_HoughLinesDetector()) }; } } + unsafe impl Send for CUDA_HoughLinesDetector {} + /// Constant methods for [crate::cudaimgproc::CUDA_HoughLinesDetector] pub trait CUDA_HoughLinesDetectorTraitConst: core::AlgorithmTraitConst { fn as_raw_CUDA_HoughLinesDetector(&self) -> *const c_void; @@ -2886,21 +2887,15 @@ pub mod cudaimgproc { } - /// Base class for lines detector algorithm. : - pub struct CUDA_HoughLinesDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_HoughLinesDetector } - - impl Drop for CUDA_HoughLinesDetector { + impl std::fmt::Debug for CUDA_HoughLinesDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_HoughLinesDetector_delete(self.as_raw_mut_CUDA_HoughLinesDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_HoughLinesDetector") + .finish() } } - unsafe impl Send for CUDA_HoughLinesDetector {} + boxed_cast_base! { CUDA_HoughLinesDetector, core::Algorithm, cv_cuda_HoughLinesDetector_to_Algorithm } impl core::AlgorithmTraitConst for CUDA_HoughLinesDetector { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2922,19 +2917,22 @@ pub mod cudaimgproc { boxed_ref! { CUDA_HoughLinesDetector, crate::cudaimgproc::CUDA_HoughLinesDetectorTraitConst, as_raw_CUDA_HoughLinesDetector, crate::cudaimgproc::CUDA_HoughLinesDetectorTrait, as_raw_mut_CUDA_HoughLinesDetector } - impl CUDA_HoughLinesDetector { + /// Base class for line segments detector algorithm. : + pub struct CUDA_HoughSegmentDetector { + ptr: *mut c_void, } - boxed_cast_base! { CUDA_HoughLinesDetector, core::Algorithm, cv_cuda_HoughLinesDetector_to_Algorithm } + opencv_type_boxed! { CUDA_HoughSegmentDetector } - impl std::fmt::Debug for CUDA_HoughLinesDetector { + impl Drop for CUDA_HoughSegmentDetector { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_HoughLinesDetector") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cuda_HoughSegmentDetector_delete(self.as_raw_mut_CUDA_HoughSegmentDetector()) }; } } + unsafe impl Send for CUDA_HoughSegmentDetector {} + /// Constant methods for [crate::cudaimgproc::CUDA_HoughSegmentDetector] pub trait CUDA_HoughSegmentDetectorTraitConst: core::AlgorithmTraitConst { fn as_raw_CUDA_HoughSegmentDetector(&self) -> *const c_void; @@ -3104,21 +3102,15 @@ pub mod cudaimgproc { } - /// Base class for line segments detector algorithm. : - pub struct CUDA_HoughSegmentDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_HoughSegmentDetector } - - impl Drop for CUDA_HoughSegmentDetector { + impl std::fmt::Debug for CUDA_HoughSegmentDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_HoughSegmentDetector_delete(self.as_raw_mut_CUDA_HoughSegmentDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_HoughSegmentDetector") + .finish() } } - unsafe impl Send for CUDA_HoughSegmentDetector {} + boxed_cast_base! { CUDA_HoughSegmentDetector, core::Algorithm, cv_cuda_HoughSegmentDetector_to_Algorithm } impl core::AlgorithmTraitConst for CUDA_HoughSegmentDetector { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3140,19 +3132,22 @@ pub mod cudaimgproc { boxed_ref! { CUDA_HoughSegmentDetector, crate::cudaimgproc::CUDA_HoughSegmentDetectorTraitConst, as_raw_CUDA_HoughSegmentDetector, crate::cudaimgproc::CUDA_HoughSegmentDetectorTrait, as_raw_mut_CUDA_HoughSegmentDetector } - impl CUDA_HoughSegmentDetector { + /// Base class for Template Matching. : + pub struct CUDA_TemplateMatching { + ptr: *mut c_void, } - boxed_cast_base! { CUDA_HoughSegmentDetector, core::Algorithm, cv_cuda_HoughSegmentDetector_to_Algorithm } + opencv_type_boxed! { CUDA_TemplateMatching } - impl std::fmt::Debug for CUDA_HoughSegmentDetector { + impl Drop for CUDA_TemplateMatching { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_HoughSegmentDetector") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cuda_TemplateMatching_delete(self.as_raw_mut_CUDA_TemplateMatching()) }; } } + unsafe impl Send for CUDA_TemplateMatching {} + /// Constant methods for [crate::cudaimgproc::CUDA_TemplateMatching] pub trait CUDA_TemplateMatchingTraitConst: core::AlgorithmTraitConst { fn as_raw_CUDA_TemplateMatching(&self) -> *const c_void; @@ -3212,21 +3207,15 @@ pub mod cudaimgproc { } - /// Base class for Template Matching. : - pub struct CUDA_TemplateMatching { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_TemplateMatching } - - impl Drop for CUDA_TemplateMatching { + impl std::fmt::Debug for CUDA_TemplateMatching { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_TemplateMatching_delete(self.as_raw_mut_CUDA_TemplateMatching()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_TemplateMatching") + .finish() } } - unsafe impl Send for CUDA_TemplateMatching {} + boxed_cast_base! { CUDA_TemplateMatching, core::Algorithm, cv_cuda_TemplateMatching_to_Algorithm } impl core::AlgorithmTraitConst for CUDA_TemplateMatching { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3248,16 +3237,4 @@ pub mod cudaimgproc { boxed_ref! { CUDA_TemplateMatching, crate::cudaimgproc::CUDA_TemplateMatchingTraitConst, as_raw_CUDA_TemplateMatching, crate::cudaimgproc::CUDA_TemplateMatchingTrait, as_raw_mut_CUDA_TemplateMatching } - impl CUDA_TemplateMatching { - } - - boxed_cast_base! { CUDA_TemplateMatching, core::Algorithm, cv_cuda_TemplateMatching_to_Algorithm } - - impl std::fmt::Debug for CUDA_TemplateMatching { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_TemplateMatching") - .finish() - } - } } diff --git a/docs/cudalegacy.rs b/docs/cudalegacy.rs index ff7822e3c..21b148e7a 100644 --- a/docs/cudalegacy.rs +++ b/docs/cudalegacy.rs @@ -423,6 +423,28 @@ pub mod cudalegacy { Ok(ret) } + /// The class discriminates between foreground and background pixels by building and maintaining a model + /// of the background. + /// + /// Any pixel which does not fit this model is then deemed to be foreground. The class implements + /// algorithm described in [FGD2003](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_FGD2003) . + /// ## See also + /// BackgroundSubtractor + pub struct CUDA_BackgroundSubtractorFGD { + ptr: *mut c_void, + } + + opencv_type_boxed! { CUDA_BackgroundSubtractorFGD } + + impl Drop for CUDA_BackgroundSubtractorFGD { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_BackgroundSubtractorFGD_delete(self.as_raw_mut_CUDA_BackgroundSubtractorFGD()) }; + } + } + + unsafe impl Send for CUDA_BackgroundSubtractorFGD {} + /// Constant methods for [crate::cudalegacy::CUDA_BackgroundSubtractorFGD] pub trait CUDA_BackgroundSubtractorFGDTraitConst: crate::video::BackgroundSubtractorTraitConst { fn as_raw_CUDA_BackgroundSubtractorFGD(&self) -> *const c_void; @@ -449,27 +471,17 @@ pub mod cudalegacy { } - /// The class discriminates between foreground and background pixels by building and maintaining a model - /// of the background. - /// - /// Any pixel which does not fit this model is then deemed to be foreground. The class implements - /// algorithm described in [FGD2003](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_FGD2003) . - /// ## See also - /// BackgroundSubtractor - pub struct CUDA_BackgroundSubtractorFGD { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_BackgroundSubtractorFGD } - - impl Drop for CUDA_BackgroundSubtractorFGD { + impl std::fmt::Debug for CUDA_BackgroundSubtractorFGD { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_BackgroundSubtractorFGD_delete(self.as_raw_mut_CUDA_BackgroundSubtractorFGD()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_BackgroundSubtractorFGD") + .finish() } } - unsafe impl Send for CUDA_BackgroundSubtractorFGD {} + boxed_cast_base! { CUDA_BackgroundSubtractorFGD, core::Algorithm, cv_cuda_BackgroundSubtractorFGD_to_Algorithm } + + boxed_cast_base! { CUDA_BackgroundSubtractorFGD, crate::video::BackgroundSubtractor, cv_cuda_BackgroundSubtractorFGD_to_BackgroundSubtractor } impl core::AlgorithmTraitConst for CUDA_BackgroundSubtractorFGD { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -501,21 +513,26 @@ pub mod cudalegacy { boxed_ref! { CUDA_BackgroundSubtractorFGD, crate::cudalegacy::CUDA_BackgroundSubtractorFGDTraitConst, as_raw_CUDA_BackgroundSubtractorFGD, crate::cudalegacy::CUDA_BackgroundSubtractorFGDTrait, as_raw_mut_CUDA_BackgroundSubtractorFGD } - impl CUDA_BackgroundSubtractorFGD { + /// Background/Foreground Segmentation Algorithm. + /// + /// The class discriminates between foreground and background pixels by building and maintaining a model + /// of the background. Any pixel which does not fit this model is then deemed to be foreground. The + /// class implements algorithm described in [Gold2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Gold2012) . + pub struct CUDA_BackgroundSubtractorGMG { + ptr: *mut c_void, } - boxed_cast_base! { CUDA_BackgroundSubtractorFGD, core::Algorithm, cv_cuda_BackgroundSubtractorFGD_to_Algorithm } - - boxed_cast_base! { CUDA_BackgroundSubtractorFGD, crate::video::BackgroundSubtractor, cv_cuda_BackgroundSubtractorFGD_to_BackgroundSubtractor } + opencv_type_boxed! { CUDA_BackgroundSubtractorGMG } - impl std::fmt::Debug for CUDA_BackgroundSubtractorFGD { + impl Drop for CUDA_BackgroundSubtractorGMG { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_BackgroundSubtractorFGD") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cuda_BackgroundSubtractorGMG_delete(self.as_raw_mut_CUDA_BackgroundSubtractorGMG()) }; } } + unsafe impl Send for CUDA_BackgroundSubtractorGMG {} + /// Constant methods for [crate::cudalegacy::CUDA_BackgroundSubtractorGMG] pub trait CUDA_BackgroundSubtractorGMGTraitConst: crate::video::BackgroundSubtractorTraitConst { fn as_raw_CUDA_BackgroundSubtractorGMG(&self) -> *const c_void; @@ -719,25 +736,17 @@ pub mod cudalegacy { } - /// Background/Foreground Segmentation Algorithm. - /// - /// The class discriminates between foreground and background pixels by building and maintaining a model - /// of the background. Any pixel which does not fit this model is then deemed to be foreground. The - /// class implements algorithm described in [Gold2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Gold2012) . - pub struct CUDA_BackgroundSubtractorGMG { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_BackgroundSubtractorGMG } - - impl Drop for CUDA_BackgroundSubtractorGMG { + impl std::fmt::Debug for CUDA_BackgroundSubtractorGMG { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_BackgroundSubtractorGMG_delete(self.as_raw_mut_CUDA_BackgroundSubtractorGMG()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_BackgroundSubtractorGMG") + .finish() } } - unsafe impl Send for CUDA_BackgroundSubtractorGMG {} + boxed_cast_base! { CUDA_BackgroundSubtractorGMG, core::Algorithm, cv_cuda_BackgroundSubtractorGMG_to_Algorithm } + + boxed_cast_base! { CUDA_BackgroundSubtractorGMG, crate::video::BackgroundSubtractor, cv_cuda_BackgroundSubtractorGMG_to_BackgroundSubtractor } impl core::AlgorithmTraitConst for CUDA_BackgroundSubtractorGMG { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -769,19 +778,33 @@ pub mod cudalegacy { boxed_ref! { CUDA_BackgroundSubtractorGMG, crate::cudalegacy::CUDA_BackgroundSubtractorGMGTraitConst, as_raw_CUDA_BackgroundSubtractorGMG, crate::cudalegacy::CUDA_BackgroundSubtractorGMGTrait, as_raw_mut_CUDA_BackgroundSubtractorGMG } - impl CUDA_BackgroundSubtractorGMG { + pub struct CUDA_FGDParams { + ptr: *mut c_void, } - boxed_cast_base! { CUDA_BackgroundSubtractorGMG, core::Algorithm, cv_cuda_BackgroundSubtractorGMG_to_Algorithm } + opencv_type_boxed! { CUDA_FGDParams } - boxed_cast_base! { CUDA_BackgroundSubtractorGMG, crate::video::BackgroundSubtractor, cv_cuda_BackgroundSubtractorGMG_to_BackgroundSubtractor } + impl Drop for CUDA_FGDParams { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_FGDParams_delete(self.as_raw_mut_CUDA_FGDParams()) }; + } + } - impl std::fmt::Debug for CUDA_BackgroundSubtractorGMG { + unsafe impl Send for CUDA_FGDParams {} + + impl CUDA_FGDParams { + /// default Params #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_BackgroundSubtractorGMG") - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_FGDParams_FGDParams(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::cudalegacy::CUDA_FGDParams::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::cudalegacy::CUDA_FGDParams] @@ -998,45 +1021,6 @@ pub mod cudalegacy { } - pub struct CUDA_FGDParams { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_FGDParams } - - impl Drop for CUDA_FGDParams { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_FGDParams_delete(self.as_raw_mut_CUDA_FGDParams()) }; - } - } - - unsafe impl Send for CUDA_FGDParams {} - - impl crate::cudalegacy::CUDA_FGDParamsTraitConst for CUDA_FGDParams { - #[inline] fn as_raw_CUDA_FGDParams(&self) -> *const c_void { self.as_raw() } - } - - impl crate::cudalegacy::CUDA_FGDParamsTrait for CUDA_FGDParams { - #[inline] fn as_raw_mut_CUDA_FGDParams(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { CUDA_FGDParams, crate::cudalegacy::CUDA_FGDParamsTraitConst, as_raw_CUDA_FGDParams, crate::cudalegacy::CUDA_FGDParamsTrait, as_raw_mut_CUDA_FGDParams } - - impl CUDA_FGDParams { - /// default Params - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_FGDParams_FGDParams(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::cudalegacy::CUDA_FGDParams::opencv_from_extern(ret) }; - Ok(ret) - } - - } - impl std::fmt::Debug for CUDA_FGDParams { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -1059,6 +1043,42 @@ pub mod cudalegacy { } } + impl crate::cudalegacy::CUDA_FGDParamsTraitConst for CUDA_FGDParams { + #[inline] fn as_raw_CUDA_FGDParams(&self) -> *const c_void { self.as_raw() } + } + + impl crate::cudalegacy::CUDA_FGDParamsTrait for CUDA_FGDParams { + #[inline] fn as_raw_mut_CUDA_FGDParams(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { CUDA_FGDParams, crate::cudalegacy::CUDA_FGDParamsTraitConst, as_raw_CUDA_FGDParams, crate::cudalegacy::CUDA_FGDParamsTrait, as_raw_mut_CUDA_FGDParams } + + pub struct CUDA_FastOpticalFlowBM { + ptr: *mut c_void, + } + + opencv_type_boxed! { CUDA_FastOpticalFlowBM } + + impl Drop for CUDA_FastOpticalFlowBM { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_FastOpticalFlowBM_delete(self.as_raw_mut_CUDA_FastOpticalFlowBM()) }; + } + } + + unsafe impl Send for CUDA_FastOpticalFlowBM {} + + impl CUDA_FastOpticalFlowBM { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::cudalegacy::CUDA_FastOpticalFlowBM { + let ret = unsafe { sys::cv_cuda_FastOpticalFlowBM_defaultNew_const() }; + let ret = unsafe { crate::cudalegacy::CUDA_FastOpticalFlowBM::opencv_from_extern(ret) }; + ret + } + + } + /// Constant methods for [crate::cudalegacy::CUDA_FastOpticalFlowBM] pub trait CUDA_FastOpticalFlowBMTraitConst { fn as_raw_CUDA_FastOpticalFlowBM(&self) -> *const c_void; @@ -1098,21 +1118,22 @@ pub mod cudalegacy { } - pub struct CUDA_FastOpticalFlowBM { - ptr: *mut c_void, + impl Default for CUDA_FastOpticalFlowBM { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { CUDA_FastOpticalFlowBM } - - impl Drop for CUDA_FastOpticalFlowBM { + impl std::fmt::Debug for CUDA_FastOpticalFlowBM { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_FastOpticalFlowBM_delete(self.as_raw_mut_CUDA_FastOpticalFlowBM()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_FastOpticalFlowBM") + .finish() } } - unsafe impl Send for CUDA_FastOpticalFlowBM {} - impl crate::cudalegacy::CUDA_FastOpticalFlowBMTraitConst for CUDA_FastOpticalFlowBM { #[inline] fn as_raw_CUDA_FastOpticalFlowBM(&self) -> *const c_void { self.as_raw() } } @@ -1123,31 +1144,21 @@ pub mod cudalegacy { boxed_ref! { CUDA_FastOpticalFlowBM, crate::cudalegacy::CUDA_FastOpticalFlowBMTraitConst, as_raw_CUDA_FastOpticalFlowBM, crate::cudalegacy::CUDA_FastOpticalFlowBMTrait, as_raw_mut_CUDA_FastOpticalFlowBM } - impl CUDA_FastOpticalFlowBM { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_cuda_FastOpticalFlowBM_defaultNew_const()) } - } - + pub struct CUDA_ImagePyramid { + ptr: *mut c_void, } - impl std::fmt::Debug for CUDA_FastOpticalFlowBM { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_FastOpticalFlowBM") - .finish() - } - } + opencv_type_boxed! { CUDA_ImagePyramid } - impl Default for CUDA_FastOpticalFlowBM { + impl Drop for CUDA_ImagePyramid { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + fn drop(&mut self) { + unsafe { sys::cv_cuda_ImagePyramid_delete(self.as_raw_mut_CUDA_ImagePyramid()) }; } } + unsafe impl Send for CUDA_ImagePyramid {} + /// Constant methods for [crate::cudalegacy::CUDA_ImagePyramid] pub trait CUDA_ImagePyramidTraitConst: core::AlgorithmTraitConst { fn as_raw_CUDA_ImagePyramid(&self) -> *const c_void; @@ -1185,20 +1196,15 @@ pub mod cudalegacy { } - pub struct CUDA_ImagePyramid { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_ImagePyramid } - - impl Drop for CUDA_ImagePyramid { + impl std::fmt::Debug for CUDA_ImagePyramid { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_ImagePyramid_delete(self.as_raw_mut_CUDA_ImagePyramid()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_ImagePyramid") + .finish() } } - unsafe impl Send for CUDA_ImagePyramid {} + boxed_cast_base! { CUDA_ImagePyramid, core::Algorithm, cv_cuda_ImagePyramid_to_Algorithm } impl core::AlgorithmTraitConst for CUDA_ImagePyramid { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1220,16 +1226,4 @@ pub mod cudalegacy { boxed_ref! { CUDA_ImagePyramid, crate::cudalegacy::CUDA_ImagePyramidTraitConst, as_raw_CUDA_ImagePyramid, crate::cudalegacy::CUDA_ImagePyramidTrait, as_raw_mut_CUDA_ImagePyramid } - impl CUDA_ImagePyramid { - } - - boxed_cast_base! { CUDA_ImagePyramid, core::Algorithm, cv_cuda_ImagePyramid_to_Algorithm } - - impl std::fmt::Debug for CUDA_ImagePyramid { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_ImagePyramid") - .finish() - } - } } diff --git a/docs/cudaobjdetect.rs b/docs/cudaobjdetect.rs index c3485622a..bcac297fd 100644 --- a/docs/cudaobjdetect.rs +++ b/docs/cudaobjdetect.rs @@ -6,6 +6,67 @@ pub mod cudaobjdetect { pub use super::{CUDA_CascadeClassifierTrait, CUDA_CascadeClassifierTraitConst, CUDA_HOGTrait, CUDA_HOGTraitConst}; } + /// Cascade classifier class used for object detection. Supports HAAR and LBP cascades. : + /// + /// + /// Note: + /// * A cascade classifier example can be found at + /// opencv_source_code/samples/gpu/cascadeclassifier.cpp + /// * A Nvidea API specific cascade classifier example can be found at + /// opencv_source_code/samples/gpu/cascadeclassifier_nvidia_api.cpp + pub struct CUDA_CascadeClassifier { + ptr: *mut c_void, + } + + opencv_type_boxed! { CUDA_CascadeClassifier } + + impl Drop for CUDA_CascadeClassifier { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_CascadeClassifier_delete(self.as_raw_mut_CUDA_CascadeClassifier()) }; + } + } + + unsafe impl Send for CUDA_CascadeClassifier {} + + impl CUDA_CascadeClassifier { + /// Loads the classifier from a file. Cascade type is detected automatically by constructor parameter. + /// + /// ## Parameters + /// * filename: Name of the file from which the classifier is loaded. Only the old haar classifier + /// (trained by the haar training application) and NVIDIA's nvbin are supported for HAAR and only new + /// type of OpenCV XML cascade supported for LBP. The working haar models can be found at opencv_folder/data/haarcascades_cuda/ + #[inline] + pub fn create(filename: &str) -> Result> { + extern_container_arg!(filename); + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_CascadeClassifier_create_const_StringR(filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Loads the classifier from a file. Cascade type is detected automatically by constructor parameter. + /// + /// ## Parameters + /// * filename: Name of the file from which the classifier is loaded. Only the old haar classifier + /// (trained by the haar training application) and NVIDIA's nvbin are supported for HAAR and only new + /// type of OpenCV XML cascade supported for LBP. The working haar models can be found at opencv_folder/data/haarcascades_cuda/ + /// + /// ## Overloaded parameters + #[inline] + pub fn create_1(file: &impl core::FileStorageTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_CascadeClassifier_create_const_FileStorageR(file.as_raw_FileStorage(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::cudaobjdetect::CUDA_CascadeClassifier] pub trait CUDA_CascadeClassifierTraitConst: core::AlgorithmTraitConst { fn as_raw_CUDA_CascadeClassifier(&self) -> *const c_void; @@ -241,28 +302,15 @@ pub mod cudaobjdetect { } - /// Cascade classifier class used for object detection. Supports HAAR and LBP cascades. : - /// - /// - /// Note: - /// * A cascade classifier example can be found at - /// opencv_source_code/samples/gpu/cascadeclassifier.cpp - /// * A Nvidea API specific cascade classifier example can be found at - /// opencv_source_code/samples/gpu/cascadeclassifier_nvidia_api.cpp - pub struct CUDA_CascadeClassifier { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_CascadeClassifier } - - impl Drop for CUDA_CascadeClassifier { + impl std::fmt::Debug for CUDA_CascadeClassifier { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_CascadeClassifier_delete(self.as_raw_mut_CUDA_CascadeClassifier()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_CascadeClassifier") + .finish() } } - unsafe impl Send for CUDA_CascadeClassifier {} + boxed_cast_base! { CUDA_CascadeClassifier, core::Algorithm, cv_cuda_CascadeClassifier_to_Algorithm } impl core::AlgorithmTraitConst for CUDA_CascadeClassifier { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -284,54 +332,85 @@ pub mod cudaobjdetect { boxed_ref! { CUDA_CascadeClassifier, crate::cudaobjdetect::CUDA_CascadeClassifierTraitConst, as_raw_CUDA_CascadeClassifier, crate::cudaobjdetect::CUDA_CascadeClassifierTrait, as_raw_mut_CUDA_CascadeClassifier } - impl CUDA_CascadeClassifier { - /// Loads the classifier from a file. Cascade type is detected automatically by constructor parameter. + /// The class implements Histogram of Oriented Gradients ([Dalal2005](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Dalal2005)) object detector. + /// + /// + /// Note: + /// * An example applying the HOG descriptor for people detection can be found at + /// opencv_source_code/samples/cpp/peopledetect.cpp + /// * A CUDA example applying the HOG descriptor for people detection can be found at + /// opencv_source_code/samples/gpu/hog.cpp + /// * (Python) An example applying the HOG descriptor for people detection can be found at + /// opencv_source_code/samples/python/peopledetect.py + pub struct CUDA_HOG { + ptr: *mut c_void, + } + + opencv_type_boxed! { CUDA_HOG } + + impl Drop for CUDA_HOG { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_HOG_delete(self.as_raw_mut_CUDA_HOG()) }; + } + } + + unsafe impl Send for CUDA_HOG {} + + impl CUDA_HOG { + /// Creates the HOG descriptor and detector. /// /// ## Parameters - /// * filename: Name of the file from which the classifier is loaded. Only the old haar classifier - /// (trained by the haar training application) and NVIDIA's nvbin are supported for HAAR and only new - /// type of OpenCV XML cascade supported for LBP. The working haar models can be found at opencv_folder/data/haarcascades_cuda/ + /// * win_size: Detection window size. Align to block size and block stride. + /// * block_size: Block size in pixels. Align to cell size. Only (16,16) is supported for now. + /// * block_stride: Block stride. It must be a multiple of cell size. + /// * cell_size: Cell size. Only (8, 8) is supported for now. + /// * nbins: Number of bins. Only 9 bins per cell are supported for now. + /// + /// ## C++ default parameters + /// * win_size: Size(64,128) + /// * block_size: Size(16,16) + /// * block_stride: Size(8,8) + /// * cell_size: Size(8,8) + /// * nbins: 9 #[inline] - pub fn create(filename: &str) -> Result> { - extern_container_arg!(filename); + pub fn create(win_size: core::Size, block_size: core::Size, block_stride: core::Size, cell_size: core::Size, nbins: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_CascadeClassifier_create_const_StringR(filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_HOG_create_Size_Size_Size_Size_int(&win_size, &block_size, &block_stride, &cell_size, nbins, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Loads the classifier from a file. Cascade type is detected automatically by constructor parameter. + /// Creates the HOG descriptor and detector. /// /// ## Parameters - /// * filename: Name of the file from which the classifier is loaded. Only the old haar classifier - /// (trained by the haar training application) and NVIDIA's nvbin are supported for HAAR and only new - /// type of OpenCV XML cascade supported for LBP. The working haar models can be found at opencv_folder/data/haarcascades_cuda/ + /// * win_size: Detection window size. Align to block size and block stride. + /// * block_size: Block size in pixels. Align to cell size. Only (16,16) is supported for now. + /// * block_stride: Block stride. It must be a multiple of cell size. + /// * cell_size: Cell size. Only (8, 8) is supported for now. + /// * nbins: Number of bins. Only 9 bins per cell are supported for now. /// - /// ## Overloaded parameters + /// ## Note + /// This alternative version of [CUDA_HOG::create] function uses the following default values for its arguments: + /// * win_size: Size(64,128) + /// * block_size: Size(16,16) + /// * block_stride: Size(8,8) + /// * cell_size: Size(8,8) + /// * nbins: 9 #[inline] - pub fn create_1(file: &impl core::FileStorageTraitConst) -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_CascadeClassifier_create_const_FileStorageR(file.as_raw_FileStorage(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_HOG_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { CUDA_CascadeClassifier, core::Algorithm, cv_cuda_CascadeClassifier_to_Algorithm } - - impl std::fmt::Debug for CUDA_CascadeClassifier { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_CascadeClassifier") - .finish() - } - } - /// Constant methods for [crate::cudaobjdetect::CUDA_HOG] pub trait CUDA_HOGTraitConst: core::AlgorithmTraitConst { fn as_raw_CUDA_HOG(&self) -> *const c_void; @@ -733,30 +812,15 @@ pub mod cudaobjdetect { } - /// The class implements Histogram of Oriented Gradients ([Dalal2005](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Dalal2005)) object detector. - /// - /// - /// Note: - /// * An example applying the HOG descriptor for people detection can be found at - /// opencv_source_code/samples/cpp/peopledetect.cpp - /// * A CUDA example applying the HOG descriptor for people detection can be found at - /// opencv_source_code/samples/gpu/hog.cpp - /// * (Python) An example applying the HOG descriptor for people detection can be found at - /// opencv_source_code/samples/python/peopledetect.py - pub struct CUDA_HOG { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_HOG } - - impl Drop for CUDA_HOG { + impl std::fmt::Debug for CUDA_HOG { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_HOG_delete(self.as_raw_mut_CUDA_HOG()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_HOG") + .finish() } } - unsafe impl Send for CUDA_HOG {} + boxed_cast_base! { CUDA_HOG, core::Algorithm, cv_cuda_HOG_to_Algorithm } impl core::AlgorithmTraitConst for CUDA_HOG { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -778,67 +842,4 @@ pub mod cudaobjdetect { boxed_ref! { CUDA_HOG, crate::cudaobjdetect::CUDA_HOGTraitConst, as_raw_CUDA_HOG, crate::cudaobjdetect::CUDA_HOGTrait, as_raw_mut_CUDA_HOG } - impl CUDA_HOG { - /// Creates the HOG descriptor and detector. - /// - /// ## Parameters - /// * win_size: Detection window size. Align to block size and block stride. - /// * block_size: Block size in pixels. Align to cell size. Only (16,16) is supported for now. - /// * block_stride: Block stride. It must be a multiple of cell size. - /// * cell_size: Cell size. Only (8, 8) is supported for now. - /// * nbins: Number of bins. Only 9 bins per cell are supported for now. - /// - /// ## C++ default parameters - /// * win_size: Size(64,128) - /// * block_size: Size(16,16) - /// * block_stride: Size(8,8) - /// * cell_size: Size(8,8) - /// * nbins: 9 - #[inline] - pub fn create(win_size: core::Size, block_size: core::Size, block_stride: core::Size, cell_size: core::Size, nbins: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_HOG_create_Size_Size_Size_Size_int(&win_size, &block_size, &block_stride, &cell_size, nbins, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Creates the HOG descriptor and detector. - /// - /// ## Parameters - /// * win_size: Detection window size. Align to block size and block stride. - /// * block_size: Block size in pixels. Align to cell size. Only (16,16) is supported for now. - /// * block_stride: Block stride. It must be a multiple of cell size. - /// * cell_size: Cell size. Only (8, 8) is supported for now. - /// * nbins: Number of bins. Only 9 bins per cell are supported for now. - /// - /// ## Note - /// This alternative version of [CUDA_HOG::create] function uses the following default values for its arguments: - /// * win_size: Size(64,128) - /// * block_size: Size(16,16) - /// * block_stride: Size(8,8) - /// * cell_size: Size(8,8) - /// * nbins: 9 - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_HOG_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { CUDA_HOG, core::Algorithm, cv_cuda_HOG_to_Algorithm } - - impl std::fmt::Debug for CUDA_HOG { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_HOG") - .finish() - } - } } diff --git a/docs/cudaoptflow.rs b/docs/cudaoptflow.rs index 556d71289..9167307fe 100644 --- a/docs/cudaoptflow.rs +++ b/docs/cudaoptflow.rs @@ -167,6 +167,60 @@ pub mod cudaoptflow { opencv_type_enum! { crate::cudaoptflow::CUDA_NvidiaOpticalFlow_2_0_NVIDIA_OF_PERF_LEVEL } + /// Class computing the optical flow for two images using Brox et al Optical Flow algorithm ([Brox2004](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Brox2004)). + pub struct CUDA_BroxOpticalFlow { + ptr: *mut c_void, + } + + opencv_type_boxed! { CUDA_BroxOpticalFlow } + + impl Drop for CUDA_BroxOpticalFlow { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_BroxOpticalFlow_delete(self.as_raw_mut_CUDA_BroxOpticalFlow()) }; + } + } + + unsafe impl Send for CUDA_BroxOpticalFlow {} + + impl CUDA_BroxOpticalFlow { + /// ## C++ default parameters + /// * alpha: 0.197 + /// * gamma: 50.0 + /// * scale_factor: 0.8 + /// * inner_iterations: 5 + /// * outer_iterations: 150 + /// * solver_iterations: 10 + #[inline] + pub fn create(alpha: f64, gamma: f64, scale_factor: f64, inner_iterations: i32, outer_iterations: i32, solver_iterations: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_BroxOpticalFlow_create_double_double_double_int_int_int(alpha, gamma, scale_factor, inner_iterations, outer_iterations, solver_iterations, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [CUDA_BroxOpticalFlow::create] function uses the following default values for its arguments: + /// * alpha: 0.197 + /// * gamma: 50.0 + /// * scale_factor: 0.8 + /// * inner_iterations: 5 + /// * outer_iterations: 150 + /// * solver_iterations: 10 + #[inline] + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_BroxOpticalFlow_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::cudaoptflow::CUDA_BroxOpticalFlow] pub trait CUDA_BroxOpticalFlowTraitConst: crate::cudaoptflow::CUDA_DenseOpticalFlowTraitConst { fn as_raw_CUDA_BroxOpticalFlow(&self) -> *const c_void; @@ -290,21 +344,17 @@ pub mod cudaoptflow { } - /// Class computing the optical flow for two images using Brox et al Optical Flow algorithm ([Brox2004](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Brox2004)). - pub struct CUDA_BroxOpticalFlow { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_BroxOpticalFlow } - - impl Drop for CUDA_BroxOpticalFlow { + impl std::fmt::Debug for CUDA_BroxOpticalFlow { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_BroxOpticalFlow_delete(self.as_raw_mut_CUDA_BroxOpticalFlow()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_BroxOpticalFlow") + .finish() } } - unsafe impl Send for CUDA_BroxOpticalFlow {} + boxed_cast_base! { CUDA_BroxOpticalFlow, core::Algorithm, cv_cuda_BroxOpticalFlow_to_Algorithm } + + boxed_cast_base! { CUDA_BroxOpticalFlow, crate::cudaoptflow::CUDA_DenseOpticalFlow, cv_cuda_BroxOpticalFlow_to_CUDA_DenseOpticalFlow } impl core::AlgorithmTraitConst for CUDA_BroxOpticalFlow { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -336,56 +386,22 @@ pub mod cudaoptflow { boxed_ref! { CUDA_BroxOpticalFlow, crate::cudaoptflow::CUDA_BroxOpticalFlowTraitConst, as_raw_CUDA_BroxOpticalFlow, crate::cudaoptflow::CUDA_BroxOpticalFlowTrait, as_raw_mut_CUDA_BroxOpticalFlow } - impl CUDA_BroxOpticalFlow { - /// ## C++ default parameters - /// * alpha: 0.197 - /// * gamma: 50.0 - /// * scale_factor: 0.8 - /// * inner_iterations: 5 - /// * outer_iterations: 150 - /// * solver_iterations: 10 - #[inline] - pub fn create(alpha: f64, gamma: f64, scale_factor: f64, inner_iterations: i32, outer_iterations: i32, solver_iterations: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_BroxOpticalFlow_create_double_double_double_int_int_int(alpha, gamma, scale_factor, inner_iterations, outer_iterations, solver_iterations, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [CUDA_BroxOpticalFlow::create] function uses the following default values for its arguments: - /// * alpha: 0.197 - /// * gamma: 50.0 - /// * scale_factor: 0.8 - /// * inner_iterations: 5 - /// * outer_iterations: 150 - /// * solver_iterations: 10 - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_BroxOpticalFlow_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + /// Base interface for dense optical flow algorithms. + pub struct CUDA_DenseOpticalFlow { + ptr: *mut c_void, } - boxed_cast_base! { CUDA_BroxOpticalFlow, core::Algorithm, cv_cuda_BroxOpticalFlow_to_Algorithm } - - boxed_cast_base! { CUDA_BroxOpticalFlow, crate::cudaoptflow::CUDA_DenseOpticalFlow, cv_cuda_BroxOpticalFlow_to_CUDA_DenseOpticalFlow } + opencv_type_boxed! { CUDA_DenseOpticalFlow } - impl std::fmt::Debug for CUDA_BroxOpticalFlow { + impl Drop for CUDA_DenseOpticalFlow { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_BroxOpticalFlow") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cuda_DenseOpticalFlow_delete(self.as_raw_mut_CUDA_DenseOpticalFlow()) }; } } + unsafe impl Send for CUDA_DenseOpticalFlow {} + /// Constant methods for [crate::cudaoptflow::CUDA_DenseOpticalFlow] pub trait CUDA_DenseOpticalFlowTraitConst: core::AlgorithmTraitConst { fn as_raw_CUDA_DenseOpticalFlow(&self) -> *const c_void; @@ -443,21 +459,23 @@ pub mod cudaoptflow { } - /// Base interface for dense optical flow algorithms. - pub struct CUDA_DenseOpticalFlow { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_DenseOpticalFlow } - - impl Drop for CUDA_DenseOpticalFlow { + impl std::fmt::Debug for CUDA_DenseOpticalFlow { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_DenseOpticalFlow_delete(self.as_raw_mut_CUDA_DenseOpticalFlow()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_DenseOpticalFlow") + .finish() } } - unsafe impl Send for CUDA_DenseOpticalFlow {} + boxed_cast_base! { CUDA_DenseOpticalFlow, core::Algorithm, cv_cuda_DenseOpticalFlow_to_Algorithm } + + boxed_cast_descendant! { CUDA_DenseOpticalFlow, crate::cudaoptflow::CUDA_BroxOpticalFlow, cv_cuda_DenseOpticalFlow_to_CUDA_BroxOpticalFlow } + + boxed_cast_descendant! { CUDA_DenseOpticalFlow, crate::cudaoptflow::CUDA_DensePyrLKOpticalFlow, cv_cuda_DenseOpticalFlow_to_CUDA_DensePyrLKOpticalFlow } + + boxed_cast_descendant! { CUDA_DenseOpticalFlow, crate::cudaoptflow::CUDA_FarnebackOpticalFlow, cv_cuda_DenseOpticalFlow_to_CUDA_FarnebackOpticalFlow } + + boxed_cast_descendant! { CUDA_DenseOpticalFlow, crate::cudaoptflow::CUDA_OpticalFlowDual_TVL1, cv_cuda_DenseOpticalFlow_to_CUDA_OpticalFlowDual_TVL1 } impl core::AlgorithmTraitConst for CUDA_DenseOpticalFlow { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -479,25 +497,57 @@ pub mod cudaoptflow { boxed_ref! { CUDA_DenseOpticalFlow, crate::cudaoptflow::CUDA_DenseOpticalFlowTraitConst, as_raw_CUDA_DenseOpticalFlow, crate::cudaoptflow::CUDA_DenseOpticalFlowTrait, as_raw_mut_CUDA_DenseOpticalFlow } - impl CUDA_DenseOpticalFlow { + /// Class used for calculating a dense optical flow. + /// + /// The class can calculate an optical flow for a dense optical flow using the + /// iterative Lucas-Kanade method with pyramids. + pub struct CUDA_DensePyrLKOpticalFlow { + ptr: *mut c_void, } - boxed_cast_descendant! { CUDA_DenseOpticalFlow, crate::cudaoptflow::CUDA_BroxOpticalFlow, cv_cuda_DenseOpticalFlow_to_CUDA_BroxOpticalFlow } - - boxed_cast_descendant! { CUDA_DenseOpticalFlow, crate::cudaoptflow::CUDA_DensePyrLKOpticalFlow, cv_cuda_DenseOpticalFlow_to_CUDA_DensePyrLKOpticalFlow } + opencv_type_boxed! { CUDA_DensePyrLKOpticalFlow } - boxed_cast_descendant! { CUDA_DenseOpticalFlow, crate::cudaoptflow::CUDA_FarnebackOpticalFlow, cv_cuda_DenseOpticalFlow_to_CUDA_FarnebackOpticalFlow } + impl Drop for CUDA_DensePyrLKOpticalFlow { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_DensePyrLKOpticalFlow_delete(self.as_raw_mut_CUDA_DensePyrLKOpticalFlow()) }; + } + } - boxed_cast_descendant! { CUDA_DenseOpticalFlow, crate::cudaoptflow::CUDA_OpticalFlowDual_TVL1, cv_cuda_DenseOpticalFlow_to_CUDA_OpticalFlowDual_TVL1 } + unsafe impl Send for CUDA_DensePyrLKOpticalFlow {} - boxed_cast_base! { CUDA_DenseOpticalFlow, core::Algorithm, cv_cuda_DenseOpticalFlow_to_Algorithm } + impl CUDA_DensePyrLKOpticalFlow { + /// ## C++ default parameters + /// * win_size: Size(13,13) + /// * max_level: 3 + /// * iters: 30 + /// * use_initial_flow: false + #[inline] + pub fn create(win_size: core::Size, max_level: i32, iters: i32, use_initial_flow: bool) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_DensePyrLKOpticalFlow_create_Size_int_int_bool(&win_size, max_level, iters, use_initial_flow, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for CUDA_DenseOpticalFlow { + /// ## Note + /// This alternative version of [CUDA_DensePyrLKOpticalFlow::create] function uses the following default values for its arguments: + /// * win_size: Size(13,13) + /// * max_level: 3 + /// * iters: 30 + /// * use_initial_flow: false #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_DenseOpticalFlow") - .finish() + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_DensePyrLKOpticalFlow_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::cudaoptflow::CUDA_DensePyrLKOpticalFlow] @@ -584,24 +634,17 @@ pub mod cudaoptflow { } - /// Class used for calculating a dense optical flow. - /// - /// The class can calculate an optical flow for a dense optical flow using the - /// iterative Lucas-Kanade method with pyramids. - pub struct CUDA_DensePyrLKOpticalFlow { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_DensePyrLKOpticalFlow } - - impl Drop for CUDA_DensePyrLKOpticalFlow { + impl std::fmt::Debug for CUDA_DensePyrLKOpticalFlow { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_DensePyrLKOpticalFlow_delete(self.as_raw_mut_CUDA_DensePyrLKOpticalFlow()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_DensePyrLKOpticalFlow") + .finish() } } - unsafe impl Send for CUDA_DensePyrLKOpticalFlow {} + boxed_cast_base! { CUDA_DensePyrLKOpticalFlow, core::Algorithm, cv_cuda_DensePyrLKOpticalFlow_to_Algorithm } + + boxed_cast_base! { CUDA_DensePyrLKOpticalFlow, crate::cudaoptflow::CUDA_DenseOpticalFlow, cv_cuda_DensePyrLKOpticalFlow_to_CUDA_DenseOpticalFlow } impl core::AlgorithmTraitConst for CUDA_DensePyrLKOpticalFlow { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -633,52 +676,64 @@ pub mod cudaoptflow { boxed_ref! { CUDA_DensePyrLKOpticalFlow, crate::cudaoptflow::CUDA_DensePyrLKOpticalFlowTraitConst, as_raw_CUDA_DensePyrLKOpticalFlow, crate::cudaoptflow::CUDA_DensePyrLKOpticalFlowTrait, as_raw_mut_CUDA_DensePyrLKOpticalFlow } - impl CUDA_DensePyrLKOpticalFlow { + /// Class computing a dense optical flow using the Gunnar Farneback's algorithm. + pub struct CUDA_FarnebackOpticalFlow { + ptr: *mut c_void, + } + + opencv_type_boxed! { CUDA_FarnebackOpticalFlow } + + impl Drop for CUDA_FarnebackOpticalFlow { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_FarnebackOpticalFlow_delete(self.as_raw_mut_CUDA_FarnebackOpticalFlow()) }; + } + } + + unsafe impl Send for CUDA_FarnebackOpticalFlow {} + + impl CUDA_FarnebackOpticalFlow { /// ## C++ default parameters - /// * win_size: Size(13,13) - /// * max_level: 3 - /// * iters: 30 - /// * use_initial_flow: false + /// * num_levels: 5 + /// * pyr_scale: 0.5 + /// * fast_pyramids: false + /// * win_size: 13 + /// * num_iters: 10 + /// * poly_n: 5 + /// * poly_sigma: 1.1 + /// * flags: 0 #[inline] - pub fn create(win_size: core::Size, max_level: i32, iters: i32, use_initial_flow: bool) -> Result> { + pub fn create(num_levels: i32, pyr_scale: f64, fast_pyramids: bool, win_size: i32, num_iters: i32, poly_n: i32, poly_sigma: f64, flags: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_DensePyrLKOpticalFlow_create_Size_int_int_bool(&win_size, max_level, iters, use_initial_flow, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_FarnebackOpticalFlow_create_int_double_bool_int_int_int_double_int(num_levels, pyr_scale, fast_pyramids, win_size, num_iters, poly_n, poly_sigma, flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } /// ## Note - /// This alternative version of [CUDA_DensePyrLKOpticalFlow::create] function uses the following default values for its arguments: - /// * win_size: Size(13,13) - /// * max_level: 3 - /// * iters: 30 - /// * use_initial_flow: false + /// This alternative version of [CUDA_FarnebackOpticalFlow::create] function uses the following default values for its arguments: + /// * num_levels: 5 + /// * pyr_scale: 0.5 + /// * fast_pyramids: false + /// * win_size: 13 + /// * num_iters: 10 + /// * poly_n: 5 + /// * poly_sigma: 1.1 + /// * flags: 0 #[inline] - pub fn create_def() -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_DensePyrLKOpticalFlow_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_FarnebackOpticalFlow_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { CUDA_DensePyrLKOpticalFlow, core::Algorithm, cv_cuda_DensePyrLKOpticalFlow_to_Algorithm } - - boxed_cast_base! { CUDA_DensePyrLKOpticalFlow, crate::cudaoptflow::CUDA_DenseOpticalFlow, cv_cuda_DensePyrLKOpticalFlow_to_CUDA_DenseOpticalFlow } - - impl std::fmt::Debug for CUDA_DensePyrLKOpticalFlow { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_DensePyrLKOpticalFlow") - .finish() - } - } - /// Constant methods for [crate::cudaoptflow::CUDA_FarnebackOpticalFlow] pub trait CUDA_FarnebackOpticalFlowTraitConst: crate::cudaoptflow::CUDA_DenseOpticalFlowTraitConst { fn as_raw_CUDA_FarnebackOpticalFlow(&self) -> *const c_void; @@ -835,21 +890,17 @@ pub mod cudaoptflow { } - /// Class computing a dense optical flow using the Gunnar Farneback's algorithm. - pub struct CUDA_FarnebackOpticalFlow { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_FarnebackOpticalFlow } - - impl Drop for CUDA_FarnebackOpticalFlow { + impl std::fmt::Debug for CUDA_FarnebackOpticalFlow { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_FarnebackOpticalFlow_delete(self.as_raw_mut_CUDA_FarnebackOpticalFlow()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_FarnebackOpticalFlow") + .finish() } } - unsafe impl Send for CUDA_FarnebackOpticalFlow {} + boxed_cast_base! { CUDA_FarnebackOpticalFlow, core::Algorithm, cv_cuda_FarnebackOpticalFlow_to_Algorithm } + + boxed_cast_base! { CUDA_FarnebackOpticalFlow, crate::cudaoptflow::CUDA_DenseOpticalFlow, cv_cuda_FarnebackOpticalFlow_to_CUDA_DenseOpticalFlow } impl core::AlgorithmTraitConst for CUDA_FarnebackOpticalFlow { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -881,60 +932,22 @@ pub mod cudaoptflow { boxed_ref! { CUDA_FarnebackOpticalFlow, crate::cudaoptflow::CUDA_FarnebackOpticalFlowTraitConst, as_raw_CUDA_FarnebackOpticalFlow, crate::cudaoptflow::CUDA_FarnebackOpticalFlowTrait, as_raw_mut_CUDA_FarnebackOpticalFlow } - impl CUDA_FarnebackOpticalFlow { - /// ## C++ default parameters - /// * num_levels: 5 - /// * pyr_scale: 0.5 - /// * fast_pyramids: false - /// * win_size: 13 - /// * num_iters: 10 - /// * poly_n: 5 - /// * poly_sigma: 1.1 - /// * flags: 0 - #[inline] - pub fn create(num_levels: i32, pyr_scale: f64, fast_pyramids: bool, win_size: i32, num_iters: i32, poly_n: i32, poly_sigma: f64, flags: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_FarnebackOpticalFlow_create_int_double_bool_int_int_int_double_int(num_levels, pyr_scale, fast_pyramids, win_size, num_iters, poly_n, poly_sigma, flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [CUDA_FarnebackOpticalFlow::create] function uses the following default values for its arguments: - /// * num_levels: 5 - /// * pyr_scale: 0.5 - /// * fast_pyramids: false - /// * win_size: 13 - /// * num_iters: 10 - /// * poly_n: 5 - /// * poly_sigma: 1.1 - /// * flags: 0 - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_FarnebackOpticalFlow_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + /// Base Interface for optical flow algorithms using NVIDIA Optical Flow SDK. + pub struct CUDA_NvidiaHWOpticalFlow { + ptr: *mut c_void, } - boxed_cast_base! { CUDA_FarnebackOpticalFlow, core::Algorithm, cv_cuda_FarnebackOpticalFlow_to_Algorithm } - - boxed_cast_base! { CUDA_FarnebackOpticalFlow, crate::cudaoptflow::CUDA_DenseOpticalFlow, cv_cuda_FarnebackOpticalFlow_to_CUDA_DenseOpticalFlow } + opencv_type_boxed! { CUDA_NvidiaHWOpticalFlow } - impl std::fmt::Debug for CUDA_FarnebackOpticalFlow { + impl Drop for CUDA_NvidiaHWOpticalFlow { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_FarnebackOpticalFlow") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cuda_NvidiaHWOpticalFlow_delete(self.as_raw_mut_CUDA_NvidiaHWOpticalFlow()) }; } } + unsafe impl Send for CUDA_NvidiaHWOpticalFlow {} + /// Constant methods for [crate::cudaoptflow::CUDA_NvidiaHWOpticalFlow] pub trait CUDA_NvidiaHWOpticalFlowTraitConst: core::AlgorithmTraitConst { fn as_raw_CUDA_NvidiaHWOpticalFlow(&self) -> *const c_void; @@ -1050,21 +1063,19 @@ pub mod cudaoptflow { } - /// Base Interface for optical flow algorithms using NVIDIA Optical Flow SDK. - pub struct CUDA_NvidiaHWOpticalFlow { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_NvidiaHWOpticalFlow } - - impl Drop for CUDA_NvidiaHWOpticalFlow { + impl std::fmt::Debug for CUDA_NvidiaHWOpticalFlow { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_NvidiaHWOpticalFlow_delete(self.as_raw_mut_CUDA_NvidiaHWOpticalFlow()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_NvidiaHWOpticalFlow") + .finish() } } - unsafe impl Send for CUDA_NvidiaHWOpticalFlow {} + boxed_cast_base! { CUDA_NvidiaHWOpticalFlow, core::Algorithm, cv_cuda_NvidiaHWOpticalFlow_to_Algorithm } + + boxed_cast_descendant! { CUDA_NvidiaHWOpticalFlow, crate::cudaoptflow::CUDA_NvidiaOpticalFlow_1_0, cv_cuda_NvidiaHWOpticalFlow_to_CUDA_NvidiaOpticalFlow_1_0 } + + boxed_cast_descendant! { CUDA_NvidiaHWOpticalFlow, crate::cudaoptflow::CUDA_NvidiaOpticalFlow_2_0, cv_cuda_NvidiaHWOpticalFlow_to_CUDA_NvidiaOpticalFlow_2_0 } impl core::AlgorithmTraitConst for CUDA_NvidiaHWOpticalFlow { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1086,55 +1097,6 @@ pub mod cudaoptflow { boxed_ref! { CUDA_NvidiaHWOpticalFlow, crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTraitConst, as_raw_CUDA_NvidiaHWOpticalFlow, crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTrait, as_raw_mut_CUDA_NvidiaHWOpticalFlow } - impl CUDA_NvidiaHWOpticalFlow { - } - - boxed_cast_descendant! { CUDA_NvidiaHWOpticalFlow, crate::cudaoptflow::CUDA_NvidiaOpticalFlow_1_0, cv_cuda_NvidiaHWOpticalFlow_to_CUDA_NvidiaOpticalFlow_1_0 } - - boxed_cast_descendant! { CUDA_NvidiaHWOpticalFlow, crate::cudaoptflow::CUDA_NvidiaOpticalFlow_2_0, cv_cuda_NvidiaHWOpticalFlow_to_CUDA_NvidiaOpticalFlow_2_0 } - - boxed_cast_base! { CUDA_NvidiaHWOpticalFlow, core::Algorithm, cv_cuda_NvidiaHWOpticalFlow_to_Algorithm } - - impl std::fmt::Debug for CUDA_NvidiaHWOpticalFlow { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_NvidiaHWOpticalFlow") - .finish() - } - } - - /// Constant methods for [crate::cudaoptflow::CUDA_NvidiaOpticalFlow_1_0] - pub trait CUDA_NvidiaOpticalFlow_1_0TraitConst: crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTraitConst { - fn as_raw_CUDA_NvidiaOpticalFlow_1_0(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::cudaoptflow::CUDA_NvidiaOpticalFlow_1_0] - pub trait CUDA_NvidiaOpticalFlow_1_0Trait: crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTrait + crate::cudaoptflow::CUDA_NvidiaOpticalFlow_1_0TraitConst { - fn as_raw_mut_CUDA_NvidiaOpticalFlow_1_0(&mut self) -> *mut c_void; - - /// The NVIDIA optical flow hardware generates flow vectors at granularity gridSize, which can be queried via function getGridSize(). - /// Upsampler() helper function converts the hardware-generated flow vectors to dense representation (1 flow vector for each pixel) - /// using nearest neighbour upsampling method. - /// - /// ## Parameters - /// * flow: Buffer of type CV_16FC2 containing flow vectors generated by calc(). - /// * imageSize: Size of the input image in pixels for which these flow vectors were generated. - /// * gridSize: Granularity of the optical flow vectors returned by calc() function. Can be queried using getGridSize(). - /// * upsampledFlow: Buffer of type CV_32FC2, containing upsampled flow vectors, each flow vector for 1 pixel, in the pitch-linear layout. - #[inline] - fn up_sampler(&mut self, flow: &impl ToInputArray, image_size: core::Size, grid_size: i32, upsampled_flow: &mut impl ToInputOutputArray) -> Result<()> { - input_array_arg!(flow); - input_output_array_arg!(upsampled_flow); - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_NvidiaOpticalFlow_1_0_upSampler_const__InputArrayR_Size_int_const__InputOutputArrayR(self.as_raw_mut_CUDA_NvidiaOpticalFlow_1_0(), flow.as_raw__InputArray(), &image_size, grid_size, upsampled_flow.as_raw__InputOutputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - /// Class for computing the optical flow vectors between two images using NVIDIA Optical Flow hardware and Optical Flow SDK 1.0. /// /// Note: @@ -1157,36 +1119,6 @@ pub mod cudaoptflow { unsafe impl Send for CUDA_NvidiaOpticalFlow_1_0 {} - impl core::AlgorithmTraitConst for CUDA_NvidiaOpticalFlow_1_0 { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for CUDA_NvidiaOpticalFlow_1_0 { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { CUDA_NvidiaOpticalFlow_1_0, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTraitConst for CUDA_NvidiaOpticalFlow_1_0 { - #[inline] fn as_raw_CUDA_NvidiaHWOpticalFlow(&self) -> *const c_void { self.as_raw() } - } - - impl crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTrait for CUDA_NvidiaOpticalFlow_1_0 { - #[inline] fn as_raw_mut_CUDA_NvidiaHWOpticalFlow(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { CUDA_NvidiaOpticalFlow_1_0, crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTraitConst, as_raw_CUDA_NvidiaHWOpticalFlow, crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTrait, as_raw_mut_CUDA_NvidiaHWOpticalFlow } - - impl crate::cudaoptflow::CUDA_NvidiaOpticalFlow_1_0TraitConst for CUDA_NvidiaOpticalFlow_1_0 { - #[inline] fn as_raw_CUDA_NvidiaOpticalFlow_1_0(&self) -> *const c_void { self.as_raw() } - } - - impl crate::cudaoptflow::CUDA_NvidiaOpticalFlow_1_0Trait for CUDA_NvidiaOpticalFlow_1_0 { - #[inline] fn as_raw_mut_CUDA_NvidiaOpticalFlow_1_0(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { CUDA_NvidiaOpticalFlow_1_0, crate::cudaoptflow::CUDA_NvidiaOpticalFlow_1_0TraitConst, as_raw_CUDA_NvidiaOpticalFlow_1_0, crate::cudaoptflow::CUDA_NvidiaOpticalFlow_1_0Trait, as_raw_mut_CUDA_NvidiaOpticalFlow_1_0 } - impl CUDA_NvidiaOpticalFlow_1_0 { /// Instantiate NVIDIA Optical Flow /// @@ -1265,40 +1197,31 @@ pub mod cudaoptflow { } - boxed_cast_base! { CUDA_NvidiaOpticalFlow_1_0, core::Algorithm, cv_cuda_NvidiaOpticalFlow_1_0_to_Algorithm } - - boxed_cast_base! { CUDA_NvidiaOpticalFlow_1_0, crate::cudaoptflow::CUDA_NvidiaHWOpticalFlow, cv_cuda_NvidiaOpticalFlow_1_0_to_CUDA_NvidiaHWOpticalFlow } - - impl std::fmt::Debug for CUDA_NvidiaOpticalFlow_1_0 { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_NvidiaOpticalFlow_1_0") - .finish() - } - } - - /// Constant methods for [crate::cudaoptflow::CUDA_NvidiaOpticalFlow_2_0] - pub trait CUDA_NvidiaOpticalFlow_2_0TraitConst: crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTraitConst { - fn as_raw_CUDA_NvidiaOpticalFlow_2_0(&self) -> *const c_void; + /// Constant methods for [crate::cudaoptflow::CUDA_NvidiaOpticalFlow_1_0] + pub trait CUDA_NvidiaOpticalFlow_1_0TraitConst: crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTraitConst { + fn as_raw_CUDA_NvidiaOpticalFlow_1_0(&self) -> *const c_void; } - /// Mutable methods for [crate::cudaoptflow::CUDA_NvidiaOpticalFlow_2_0] - pub trait CUDA_NvidiaOpticalFlow_2_0Trait: crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTrait + crate::cudaoptflow::CUDA_NvidiaOpticalFlow_2_0TraitConst { - fn as_raw_mut_CUDA_NvidiaOpticalFlow_2_0(&mut self) -> *mut c_void; + /// Mutable methods for [crate::cudaoptflow::CUDA_NvidiaOpticalFlow_1_0] + pub trait CUDA_NvidiaOpticalFlow_1_0Trait: crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTrait + crate::cudaoptflow::CUDA_NvidiaOpticalFlow_1_0TraitConst { + fn as_raw_mut_CUDA_NvidiaOpticalFlow_1_0(&mut self) -> *mut c_void; - /// convertToFloat() helper function converts the hardware-generated flow vectors to floating point representation (1 flow vector for gridSize). - /// gridSize can be queried via function getGridSize(). + /// The NVIDIA optical flow hardware generates flow vectors at granularity gridSize, which can be queried via function getGridSize(). + /// Upsampler() helper function converts the hardware-generated flow vectors to dense representation (1 flow vector for each pixel) + /// using nearest neighbour upsampling method. /// /// ## Parameters /// * flow: Buffer of type CV_16FC2 containing flow vectors generated by calc(). - /// * floatFlow: Buffer of type CV_32FC2, containing flow vectors in floating point representation, each flow vector for 1 pixel per gridSize, in the pitch-linear layout. + /// * imageSize: Size of the input image in pixels for which these flow vectors were generated. + /// * gridSize: Granularity of the optical flow vectors returned by calc() function. Can be queried using getGridSize(). + /// * upsampledFlow: Buffer of type CV_32FC2, containing upsampled flow vectors, each flow vector for 1 pixel, in the pitch-linear layout. #[inline] - fn convert_to_float(&mut self, flow: &impl ToInputArray, float_flow: &mut impl ToInputOutputArray) -> Result<()> { + fn up_sampler(&mut self, flow: &impl ToInputArray, image_size: core::Size, grid_size: i32, upsampled_flow: &mut impl ToInputOutputArray) -> Result<()> { input_array_arg!(flow); - input_output_array_arg!(float_flow); + input_output_array_arg!(upsampled_flow); return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_NvidiaOpticalFlow_2_0_convertToFloat_const__InputArrayR_const__InputOutputArrayR(self.as_raw_mut_CUDA_NvidiaOpticalFlow_2_0(), flow.as_raw__InputArray(), float_flow.as_raw__InputOutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_NvidiaOpticalFlow_1_0_upSampler_const__InputArrayR_Size_int_const__InputOutputArrayR(self.as_raw_mut_CUDA_NvidiaOpticalFlow_1_0(), flow.as_raw__InputArray(), &image_size, grid_size, upsampled_flow.as_raw__InputOutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -1306,57 +1229,69 @@ pub mod cudaoptflow { } - /// Class for computing the optical flow vectors between two images using NVIDIA Optical Flow hardware and Optical Flow SDK 2.0. - /// - /// Note: - /// - A sample application demonstrating the use of NVIDIA Optical Flow can be found at - /// opencv_contrib_source_code/modules/cudaoptflow/samples/nvidia_optical_flow.cpp - /// - An example application comparing accuracy and performance of NVIDIA Optical Flow with other optical flow algorithms in OpenCV can be found at - /// opencv_contrib_source_code/modules/cudaoptflow/samples/optical_flow.cpp - pub struct CUDA_NvidiaOpticalFlow_2_0 { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_NvidiaOpticalFlow_2_0 } - - impl Drop for CUDA_NvidiaOpticalFlow_2_0 { + impl std::fmt::Debug for CUDA_NvidiaOpticalFlow_1_0 { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_NvidiaOpticalFlow_2_0_delete(self.as_raw_mut_CUDA_NvidiaOpticalFlow_2_0()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_NvidiaOpticalFlow_1_0") + .finish() } } - unsafe impl Send for CUDA_NvidiaOpticalFlow_2_0 {} + boxed_cast_base! { CUDA_NvidiaOpticalFlow_1_0, core::Algorithm, cv_cuda_NvidiaOpticalFlow_1_0_to_Algorithm } - impl core::AlgorithmTraitConst for CUDA_NvidiaOpticalFlow_2_0 { + boxed_cast_base! { CUDA_NvidiaOpticalFlow_1_0, crate::cudaoptflow::CUDA_NvidiaHWOpticalFlow, cv_cuda_NvidiaOpticalFlow_1_0_to_CUDA_NvidiaHWOpticalFlow } + + impl core::AlgorithmTraitConst for CUDA_NvidiaOpticalFlow_1_0 { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } } - impl core::AlgorithmTrait for CUDA_NvidiaOpticalFlow_2_0 { + impl core::AlgorithmTrait for CUDA_NvidiaOpticalFlow_1_0 { #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { CUDA_NvidiaOpticalFlow_2_0, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + boxed_ref! { CUDA_NvidiaOpticalFlow_1_0, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - impl crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTraitConst for CUDA_NvidiaOpticalFlow_2_0 { + impl crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTraitConst for CUDA_NvidiaOpticalFlow_1_0 { #[inline] fn as_raw_CUDA_NvidiaHWOpticalFlow(&self) -> *const c_void { self.as_raw() } } - impl crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTrait for CUDA_NvidiaOpticalFlow_2_0 { + impl crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTrait for CUDA_NvidiaOpticalFlow_1_0 { #[inline] fn as_raw_mut_CUDA_NvidiaHWOpticalFlow(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { CUDA_NvidiaOpticalFlow_2_0, crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTraitConst, as_raw_CUDA_NvidiaHWOpticalFlow, crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTrait, as_raw_mut_CUDA_NvidiaHWOpticalFlow } + boxed_ref! { CUDA_NvidiaOpticalFlow_1_0, crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTraitConst, as_raw_CUDA_NvidiaHWOpticalFlow, crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTrait, as_raw_mut_CUDA_NvidiaHWOpticalFlow } - impl crate::cudaoptflow::CUDA_NvidiaOpticalFlow_2_0TraitConst for CUDA_NvidiaOpticalFlow_2_0 { - #[inline] fn as_raw_CUDA_NvidiaOpticalFlow_2_0(&self) -> *const c_void { self.as_raw() } + impl crate::cudaoptflow::CUDA_NvidiaOpticalFlow_1_0TraitConst for CUDA_NvidiaOpticalFlow_1_0 { + #[inline] fn as_raw_CUDA_NvidiaOpticalFlow_1_0(&self) -> *const c_void { self.as_raw() } } - impl crate::cudaoptflow::CUDA_NvidiaOpticalFlow_2_0Trait for CUDA_NvidiaOpticalFlow_2_0 { - #[inline] fn as_raw_mut_CUDA_NvidiaOpticalFlow_2_0(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::cudaoptflow::CUDA_NvidiaOpticalFlow_1_0Trait for CUDA_NvidiaOpticalFlow_1_0 { + #[inline] fn as_raw_mut_CUDA_NvidiaOpticalFlow_1_0(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { CUDA_NvidiaOpticalFlow_2_0, crate::cudaoptflow::CUDA_NvidiaOpticalFlow_2_0TraitConst, as_raw_CUDA_NvidiaOpticalFlow_2_0, crate::cudaoptflow::CUDA_NvidiaOpticalFlow_2_0Trait, as_raw_mut_CUDA_NvidiaOpticalFlow_2_0 } + boxed_ref! { CUDA_NvidiaOpticalFlow_1_0, crate::cudaoptflow::CUDA_NvidiaOpticalFlow_1_0TraitConst, as_raw_CUDA_NvidiaOpticalFlow_1_0, crate::cudaoptflow::CUDA_NvidiaOpticalFlow_1_0Trait, as_raw_mut_CUDA_NvidiaOpticalFlow_1_0 } + + /// Class for computing the optical flow vectors between two images using NVIDIA Optical Flow hardware and Optical Flow SDK 2.0. + /// + /// Note: + /// - A sample application demonstrating the use of NVIDIA Optical Flow can be found at + /// opencv_contrib_source_code/modules/cudaoptflow/samples/nvidia_optical_flow.cpp + /// - An example application comparing accuracy and performance of NVIDIA Optical Flow with other optical flow algorithms in OpenCV can be found at + /// opencv_contrib_source_code/modules/cudaoptflow/samples/optical_flow.cpp + pub struct CUDA_NvidiaOpticalFlow_2_0 { + ptr: *mut c_void, + } + + opencv_type_boxed! { CUDA_NvidiaOpticalFlow_2_0 } + + impl Drop for CUDA_NvidiaOpticalFlow_2_0 { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_NvidiaOpticalFlow_2_0_delete(self.as_raw_mut_CUDA_NvidiaOpticalFlow_2_0()) }; + } + } + + unsafe impl Send for CUDA_NvidiaOpticalFlow_2_0 {} impl CUDA_NvidiaOpticalFlow_2_0 { /// Instantiate NVIDIA Optical Flow @@ -1526,29 +1461,155 @@ pub mod cudaoptflow { /// * input_stream: Stream::Null() /// * output_stream: Stream::Null() #[inline] - pub fn create_def_1(image_size: core::Size, mut roi_data: core::Vector) -> Result> { + pub fn create_def_1(image_size: core::Size, mut roi_data: core::Vector) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_NvidiaOpticalFlow_2_0_create_Size_vectorLRectG(&image_size, roi_data.as_raw_mut_VectorOfRect(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::cudaoptflow::CUDA_NvidiaOpticalFlow_2_0] + pub trait CUDA_NvidiaOpticalFlow_2_0TraitConst: crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTraitConst { + fn as_raw_CUDA_NvidiaOpticalFlow_2_0(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::cudaoptflow::CUDA_NvidiaOpticalFlow_2_0] + pub trait CUDA_NvidiaOpticalFlow_2_0Trait: crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTrait + crate::cudaoptflow::CUDA_NvidiaOpticalFlow_2_0TraitConst { + fn as_raw_mut_CUDA_NvidiaOpticalFlow_2_0(&mut self) -> *mut c_void; + + /// convertToFloat() helper function converts the hardware-generated flow vectors to floating point representation (1 flow vector for gridSize). + /// gridSize can be queried via function getGridSize(). + /// + /// ## Parameters + /// * flow: Buffer of type CV_16FC2 containing flow vectors generated by calc(). + /// * floatFlow: Buffer of type CV_32FC2, containing flow vectors in floating point representation, each flow vector for 1 pixel per gridSize, in the pitch-linear layout. + #[inline] + fn convert_to_float(&mut self, flow: &impl ToInputArray, float_flow: &mut impl ToInputOutputArray) -> Result<()> { + input_array_arg!(flow); + input_output_array_arg!(float_flow); + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_NvidiaOpticalFlow_2_0_convertToFloat_const__InputArrayR_const__InputOutputArrayR(self.as_raw_mut_CUDA_NvidiaOpticalFlow_2_0(), flow.as_raw__InputArray(), float_flow.as_raw__InputOutputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + impl std::fmt::Debug for CUDA_NvidiaOpticalFlow_2_0 { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_NvidiaOpticalFlow_2_0") + .finish() + } + } + + boxed_cast_base! { CUDA_NvidiaOpticalFlow_2_0, core::Algorithm, cv_cuda_NvidiaOpticalFlow_2_0_to_Algorithm } + + boxed_cast_base! { CUDA_NvidiaOpticalFlow_2_0, crate::cudaoptflow::CUDA_NvidiaHWOpticalFlow, cv_cuda_NvidiaOpticalFlow_2_0_to_CUDA_NvidiaHWOpticalFlow } + + impl core::AlgorithmTraitConst for CUDA_NvidiaOpticalFlow_2_0 { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } + } + + impl core::AlgorithmTrait for CUDA_NvidiaOpticalFlow_2_0 { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { CUDA_NvidiaOpticalFlow_2_0, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + + impl crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTraitConst for CUDA_NvidiaOpticalFlow_2_0 { + #[inline] fn as_raw_CUDA_NvidiaHWOpticalFlow(&self) -> *const c_void { self.as_raw() } + } + + impl crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTrait for CUDA_NvidiaOpticalFlow_2_0 { + #[inline] fn as_raw_mut_CUDA_NvidiaHWOpticalFlow(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { CUDA_NvidiaOpticalFlow_2_0, crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTraitConst, as_raw_CUDA_NvidiaHWOpticalFlow, crate::cudaoptflow::CUDA_NvidiaHWOpticalFlowTrait, as_raw_mut_CUDA_NvidiaHWOpticalFlow } + + impl crate::cudaoptflow::CUDA_NvidiaOpticalFlow_2_0TraitConst for CUDA_NvidiaOpticalFlow_2_0 { + #[inline] fn as_raw_CUDA_NvidiaOpticalFlow_2_0(&self) -> *const c_void { self.as_raw() } + } + + impl crate::cudaoptflow::CUDA_NvidiaOpticalFlow_2_0Trait for CUDA_NvidiaOpticalFlow_2_0 { + #[inline] fn as_raw_mut_CUDA_NvidiaOpticalFlow_2_0(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { CUDA_NvidiaOpticalFlow_2_0, crate::cudaoptflow::CUDA_NvidiaOpticalFlow_2_0TraitConst, as_raw_CUDA_NvidiaOpticalFlow_2_0, crate::cudaoptflow::CUDA_NvidiaOpticalFlow_2_0Trait, as_raw_mut_CUDA_NvidiaOpticalFlow_2_0 } + + /// Implementation of the Zach, Pock and Bischof Dual TV-L1 Optical Flow method. + /// + /// + /// Note: C. Zach, T. Pock and H. Bischof, "A Duality Based Approach for Realtime TV-L1 Optical Flow". + /// + /// Note: Javier Sanchez, Enric Meinhardt-Llopis and Gabriele Facciolo. "TV-L1 Optical Flow Estimation". + pub struct CUDA_OpticalFlowDual_TVL1 { + ptr: *mut c_void, + } + + opencv_type_boxed! { CUDA_OpticalFlowDual_TVL1 } + + impl Drop for CUDA_OpticalFlowDual_TVL1 { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_OpticalFlowDual_TVL1_delete(self.as_raw_mut_CUDA_OpticalFlowDual_TVL1()) }; + } + } + + unsafe impl Send for CUDA_OpticalFlowDual_TVL1 {} + + impl CUDA_OpticalFlowDual_TVL1 { + /// ## C++ default parameters + /// * tau: 0.25 + /// * lambda: 0.15 + /// * theta: 0.3 + /// * nscales: 5 + /// * warps: 5 + /// * epsilon: 0.01 + /// * iterations: 300 + /// * scale_step: 0.8 + /// * gamma: 0.0 + /// * use_initial_flow: false + #[inline] + pub fn create(tau: f64, lambda: f64, theta: f64, nscales: i32, warps: i32, epsilon: f64, iterations: i32, scale_step: f64, gamma: f64, use_initial_flow: bool) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_OpticalFlowDual_TVL1_create_double_double_double_int_int_double_int_double_double_bool(tau, lambda, theta, nscales, warps, epsilon, iterations, scale_step, gamma, use_initial_flow, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [CUDA_OpticalFlowDual_TVL1::create] function uses the following default values for its arguments: + /// * tau: 0.25 + /// * lambda: 0.15 + /// * theta: 0.3 + /// * nscales: 5 + /// * warps: 5 + /// * epsilon: 0.01 + /// * iterations: 300 + /// * scale_step: 0.8 + /// * gamma: 0.0 + /// * use_initial_flow: false + #[inline] + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_NvidiaOpticalFlow_2_0_create_Size_vectorLRectG(&image_size, roi_data.as_raw_mut_VectorOfRect(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_cuda_OpticalFlowDual_TVL1_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { CUDA_NvidiaOpticalFlow_2_0, core::Algorithm, cv_cuda_NvidiaOpticalFlow_2_0_to_Algorithm } - - boxed_cast_base! { CUDA_NvidiaOpticalFlow_2_0, crate::cudaoptflow::CUDA_NvidiaHWOpticalFlow, cv_cuda_NvidiaOpticalFlow_2_0_to_CUDA_NvidiaHWOpticalFlow } - - impl std::fmt::Debug for CUDA_NvidiaOpticalFlow_2_0 { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_NvidiaOpticalFlow_2_0") - .finish() - } - } - /// Constant methods for [crate::cudaoptflow::CUDA_OpticalFlowDual_TVL1] pub trait CUDA_OpticalFlowDual_TVL1TraitConst: crate::cudaoptflow::CUDA_DenseOpticalFlowTraitConst { fn as_raw_CUDA_OpticalFlowDual_TVL1(&self) -> *const c_void; @@ -1762,26 +1823,17 @@ pub mod cudaoptflow { } - /// Implementation of the Zach, Pock and Bischof Dual TV-L1 Optical Flow method. - /// - /// - /// Note: C. Zach, T. Pock and H. Bischof, "A Duality Based Approach for Realtime TV-L1 Optical Flow". - /// - /// Note: Javier Sanchez, Enric Meinhardt-Llopis and Gabriele Facciolo. "TV-L1 Optical Flow Estimation". - pub struct CUDA_OpticalFlowDual_TVL1 { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_OpticalFlowDual_TVL1 } - - impl Drop for CUDA_OpticalFlowDual_TVL1 { + impl std::fmt::Debug for CUDA_OpticalFlowDual_TVL1 { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_OpticalFlowDual_TVL1_delete(self.as_raw_mut_CUDA_OpticalFlowDual_TVL1()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_OpticalFlowDual_TVL1") + .finish() } } - unsafe impl Send for CUDA_OpticalFlowDual_TVL1 {} + boxed_cast_base! { CUDA_OpticalFlowDual_TVL1, core::Algorithm, cv_cuda_OpticalFlowDual_TVL1_to_Algorithm } + + boxed_cast_base! { CUDA_OpticalFlowDual_TVL1, crate::cudaoptflow::CUDA_DenseOpticalFlow, cv_cuda_OpticalFlowDual_TVL1_to_CUDA_DenseOpticalFlow } impl core::AlgorithmTraitConst for CUDA_OpticalFlowDual_TVL1 { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1813,64 +1865,22 @@ pub mod cudaoptflow { boxed_ref! { CUDA_OpticalFlowDual_TVL1, crate::cudaoptflow::CUDA_OpticalFlowDual_TVL1TraitConst, as_raw_CUDA_OpticalFlowDual_TVL1, crate::cudaoptflow::CUDA_OpticalFlowDual_TVL1Trait, as_raw_mut_CUDA_OpticalFlowDual_TVL1 } - impl CUDA_OpticalFlowDual_TVL1 { - /// ## C++ default parameters - /// * tau: 0.25 - /// * lambda: 0.15 - /// * theta: 0.3 - /// * nscales: 5 - /// * warps: 5 - /// * epsilon: 0.01 - /// * iterations: 300 - /// * scale_step: 0.8 - /// * gamma: 0.0 - /// * use_initial_flow: false - #[inline] - pub fn create(tau: f64, lambda: f64, theta: f64, nscales: i32, warps: i32, epsilon: f64, iterations: i32, scale_step: f64, gamma: f64, use_initial_flow: bool) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_OpticalFlowDual_TVL1_create_double_double_double_int_int_double_int_double_double_bool(tau, lambda, theta, nscales, warps, epsilon, iterations, scale_step, gamma, use_initial_flow, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [CUDA_OpticalFlowDual_TVL1::create] function uses the following default values for its arguments: - /// * tau: 0.25 - /// * lambda: 0.15 - /// * theta: 0.3 - /// * nscales: 5 - /// * warps: 5 - /// * epsilon: 0.01 - /// * iterations: 300 - /// * scale_step: 0.8 - /// * gamma: 0.0 - /// * use_initial_flow: false - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_OpticalFlowDual_TVL1_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + /// Base interface for sparse optical flow algorithms. + pub struct CUDA_SparseOpticalFlow { + ptr: *mut c_void, } - boxed_cast_base! { CUDA_OpticalFlowDual_TVL1, core::Algorithm, cv_cuda_OpticalFlowDual_TVL1_to_Algorithm } - - boxed_cast_base! { CUDA_OpticalFlowDual_TVL1, crate::cudaoptflow::CUDA_DenseOpticalFlow, cv_cuda_OpticalFlowDual_TVL1_to_CUDA_DenseOpticalFlow } + opencv_type_boxed! { CUDA_SparseOpticalFlow } - impl std::fmt::Debug for CUDA_OpticalFlowDual_TVL1 { + impl Drop for CUDA_SparseOpticalFlow { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_OpticalFlowDual_TVL1") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cuda_SparseOpticalFlow_delete(self.as_raw_mut_CUDA_SparseOpticalFlow()) }; } } + unsafe impl Send for CUDA_SparseOpticalFlow {} + /// Constant methods for [crate::cudaoptflow::CUDA_SparseOpticalFlow] pub trait CUDA_SparseOpticalFlowTraitConst: core::AlgorithmTraitConst { fn as_raw_CUDA_SparseOpticalFlow(&self) -> *const c_void; @@ -1943,21 +1953,17 @@ pub mod cudaoptflow { } - /// Base interface for sparse optical flow algorithms. - pub struct CUDA_SparseOpticalFlow { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_SparseOpticalFlow } - - impl Drop for CUDA_SparseOpticalFlow { + impl std::fmt::Debug for CUDA_SparseOpticalFlow { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_SparseOpticalFlow_delete(self.as_raw_mut_CUDA_SparseOpticalFlow()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_SparseOpticalFlow") + .finish() } } - unsafe impl Send for CUDA_SparseOpticalFlow {} + boxed_cast_base! { CUDA_SparseOpticalFlow, core::Algorithm, cv_cuda_SparseOpticalFlow_to_Algorithm } + + boxed_cast_descendant! { CUDA_SparseOpticalFlow, crate::cudaoptflow::CUDA_SparsePyrLKOpticalFlow, cv_cuda_SparseOpticalFlow_to_CUDA_SparsePyrLKOpticalFlow } impl core::AlgorithmTraitConst for CUDA_SparseOpticalFlow { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1979,19 +1985,64 @@ pub mod cudaoptflow { boxed_ref! { CUDA_SparseOpticalFlow, crate::cudaoptflow::CUDA_SparseOpticalFlowTraitConst, as_raw_CUDA_SparseOpticalFlow, crate::cudaoptflow::CUDA_SparseOpticalFlowTrait, as_raw_mut_CUDA_SparseOpticalFlow } - impl CUDA_SparseOpticalFlow { + /// Class used for calculating a sparse optical flow. + /// + /// The class can calculate an optical flow for a sparse feature set using the + /// iterative Lucas-Kanade method with pyramids. + /// ## See also + /// calcOpticalFlowPyrLK + /// + /// + /// Note: + /// * An example of the Lucas Kanade optical flow algorithm can be found at + /// opencv_source_code/samples/gpu/pyrlk_optical_flow.cpp + pub struct CUDA_SparsePyrLKOpticalFlow { + ptr: *mut c_void, + } + + opencv_type_boxed! { CUDA_SparsePyrLKOpticalFlow } + + impl Drop for CUDA_SparsePyrLKOpticalFlow { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_SparsePyrLKOpticalFlow_delete(self.as_raw_mut_CUDA_SparsePyrLKOpticalFlow()) }; + } } - boxed_cast_descendant! { CUDA_SparseOpticalFlow, crate::cudaoptflow::CUDA_SparsePyrLKOpticalFlow, cv_cuda_SparseOpticalFlow_to_CUDA_SparsePyrLKOpticalFlow } + unsafe impl Send for CUDA_SparsePyrLKOpticalFlow {} - boxed_cast_base! { CUDA_SparseOpticalFlow, core::Algorithm, cv_cuda_SparseOpticalFlow_to_Algorithm } + impl CUDA_SparsePyrLKOpticalFlow { + /// ## C++ default parameters + /// * win_size: Size(21,21) + /// * max_level: 3 + /// * iters: 30 + /// * use_initial_flow: false + #[inline] + pub fn create(win_size: core::Size, max_level: i32, iters: i32, use_initial_flow: bool) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_SparsePyrLKOpticalFlow_create_Size_int_int_bool(&win_size, max_level, iters, use_initial_flow, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for CUDA_SparseOpticalFlow { + /// ## Note + /// This alternative version of [CUDA_SparsePyrLKOpticalFlow::create] function uses the following default values for its arguments: + /// * win_size: Size(21,21) + /// * max_level: 3 + /// * iters: 30 + /// * use_initial_flow: false #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_SparseOpticalFlow") - .finish() + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_SparsePyrLKOpticalFlow_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::cudaoptflow::CUDA_SparsePyrLKOpticalFlow] @@ -2078,31 +2129,17 @@ pub mod cudaoptflow { } - /// Class used for calculating a sparse optical flow. - /// - /// The class can calculate an optical flow for a sparse feature set using the - /// iterative Lucas-Kanade method with pyramids. - /// ## See also - /// calcOpticalFlowPyrLK - /// - /// - /// Note: - /// * An example of the Lucas Kanade optical flow algorithm can be found at - /// opencv_source_code/samples/gpu/pyrlk_optical_flow.cpp - pub struct CUDA_SparsePyrLKOpticalFlow { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_SparsePyrLKOpticalFlow } - - impl Drop for CUDA_SparsePyrLKOpticalFlow { + impl std::fmt::Debug for CUDA_SparsePyrLKOpticalFlow { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_SparsePyrLKOpticalFlow_delete(self.as_raw_mut_CUDA_SparsePyrLKOpticalFlow()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_SparsePyrLKOpticalFlow") + .finish() } } - unsafe impl Send for CUDA_SparsePyrLKOpticalFlow {} + boxed_cast_base! { CUDA_SparsePyrLKOpticalFlow, core::Algorithm, cv_cuda_SparsePyrLKOpticalFlow_to_Algorithm } + + boxed_cast_base! { CUDA_SparsePyrLKOpticalFlow, crate::cudaoptflow::CUDA_SparseOpticalFlow, cv_cuda_SparsePyrLKOpticalFlow_to_CUDA_SparseOpticalFlow } impl core::AlgorithmTraitConst for CUDA_SparsePyrLKOpticalFlow { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2134,49 +2171,4 @@ pub mod cudaoptflow { boxed_ref! { CUDA_SparsePyrLKOpticalFlow, crate::cudaoptflow::CUDA_SparsePyrLKOpticalFlowTraitConst, as_raw_CUDA_SparsePyrLKOpticalFlow, crate::cudaoptflow::CUDA_SparsePyrLKOpticalFlowTrait, as_raw_mut_CUDA_SparsePyrLKOpticalFlow } - impl CUDA_SparsePyrLKOpticalFlow { - /// ## C++ default parameters - /// * win_size: Size(21,21) - /// * max_level: 3 - /// * iters: 30 - /// * use_initial_flow: false - #[inline] - pub fn create(win_size: core::Size, max_level: i32, iters: i32, use_initial_flow: bool) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_SparsePyrLKOpticalFlow_create_Size_int_int_bool(&win_size, max_level, iters, use_initial_flow, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [CUDA_SparsePyrLKOpticalFlow::create] function uses the following default values for its arguments: - /// * win_size: Size(21,21) - /// * max_level: 3 - /// * iters: 30 - /// * use_initial_flow: false - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_SparsePyrLKOpticalFlow_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { CUDA_SparsePyrLKOpticalFlow, core::Algorithm, cv_cuda_SparsePyrLKOpticalFlow_to_Algorithm } - - boxed_cast_base! { CUDA_SparsePyrLKOpticalFlow, crate::cudaoptflow::CUDA_SparseOpticalFlow, cv_cuda_SparsePyrLKOpticalFlow_to_CUDA_SparseOpticalFlow } - - impl std::fmt::Debug for CUDA_SparsePyrLKOpticalFlow { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_SparsePyrLKOpticalFlow") - .finish() - } - } } diff --git a/docs/cudastereo.rs b/docs/cudastereo.rs index 1a454ad4e..16354de59 100644 --- a/docs/cudastereo.rs +++ b/docs/cudastereo.rs @@ -400,6 +400,24 @@ pub mod cudastereo { Ok(ret) } + /// Class refining a disparity map using joint bilateral filtering. : + /// + /// The class implements [Yang2010](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Yang2010) algorithm. + pub struct CUDA_DisparityBilateralFilter { + ptr: *mut c_void, + } + + opencv_type_boxed! { CUDA_DisparityBilateralFilter } + + impl Drop for CUDA_DisparityBilateralFilter { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_DisparityBilateralFilter_delete(self.as_raw_mut_CUDA_DisparityBilateralFilter()) }; + } + } + + unsafe impl Send for CUDA_DisparityBilateralFilter {} + /// Constant methods for [crate::cudastereo::CUDA_DisparityBilateralFilter] pub trait CUDA_DisparityBilateralFilterTraitConst: core::AlgorithmTraitConst { fn as_raw_CUDA_DisparityBilateralFilter(&self) -> *const c_void; @@ -568,23 +586,15 @@ pub mod cudastereo { } - /// Class refining a disparity map using joint bilateral filtering. : - /// - /// The class implements [Yang2010](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Yang2010) algorithm. - pub struct CUDA_DisparityBilateralFilter { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_DisparityBilateralFilter } - - impl Drop for CUDA_DisparityBilateralFilter { + impl std::fmt::Debug for CUDA_DisparityBilateralFilter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_DisparityBilateralFilter_delete(self.as_raw_mut_CUDA_DisparityBilateralFilter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_DisparityBilateralFilter") + .finish() } } - unsafe impl Send for CUDA_DisparityBilateralFilter {} + boxed_cast_base! { CUDA_DisparityBilateralFilter, core::Algorithm, cv_cuda_DisparityBilateralFilter_to_Algorithm } impl core::AlgorithmTraitConst for CUDA_DisparityBilateralFilter { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -606,19 +616,24 @@ pub mod cudastereo { boxed_ref! { CUDA_DisparityBilateralFilter, crate::cudastereo::CUDA_DisparityBilateralFilterTraitConst, as_raw_CUDA_DisparityBilateralFilter, crate::cudastereo::CUDA_DisparityBilateralFilterTrait, as_raw_mut_CUDA_DisparityBilateralFilter } - impl CUDA_DisparityBilateralFilter { + /// Class computing stereo correspondence (disparity map) using the block matching algorithm. : + /// ## See also + /// StereoBM + pub struct CUDA_StereoBM { + ptr: *mut c_void, } - boxed_cast_base! { CUDA_DisparityBilateralFilter, core::Algorithm, cv_cuda_DisparityBilateralFilter_to_Algorithm } + opencv_type_boxed! { CUDA_StereoBM } - impl std::fmt::Debug for CUDA_DisparityBilateralFilter { + impl Drop for CUDA_StereoBM { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_DisparityBilateralFilter") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cuda_StereoBM_delete(self.as_raw_mut_CUDA_StereoBM()) }; } } + unsafe impl Send for CUDA_StereoBM {} + /// Constant methods for [crate::cudastereo::CUDA_StereoBM] pub trait CUDA_StereoBMTraitConst: crate::calib3d::StereoBMTraitConst { fn as_raw_CUDA_StereoBM(&self) -> *const c_void; @@ -643,23 +658,19 @@ pub mod cudastereo { } - /// Class computing stereo correspondence (disparity map) using the block matching algorithm. : - /// ## See also - /// StereoBM - pub struct CUDA_StereoBM { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_StereoBM } - - impl Drop for CUDA_StereoBM { + impl std::fmt::Debug for CUDA_StereoBM { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_StereoBM_delete(self.as_raw_mut_CUDA_StereoBM()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_StereoBM") + .finish() } } - unsafe impl Send for CUDA_StereoBM {} + boxed_cast_base! { CUDA_StereoBM, core::Algorithm, cv_cuda_StereoBM_to_Algorithm } + + boxed_cast_base! { CUDA_StereoBM, crate::calib3d::StereoBM, cv_cuda_StereoBM_to_StereoBM } + + boxed_cast_base! { CUDA_StereoBM, crate::calib3d::StereoMatcher, cv_cuda_StereoBM_to_StereoMatcher } impl core::AlgorithmTraitConst for CUDA_StereoBM { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -701,21 +712,66 @@ pub mod cudastereo { boxed_ref! { CUDA_StereoBM, crate::cudastereo::CUDA_StereoBMTraitConst, as_raw_CUDA_StereoBM, crate::cudastereo::CUDA_StereoBMTrait, as_raw_mut_CUDA_StereoBM } - impl CUDA_StereoBM { + /// Class computing stereo correspondence using the belief propagation algorithm. : + /// + /// The class implements algorithm described in [Felzenszwalb2006](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Felzenszwalb2006) . It can compute own data cost + /// (using a truncated linear model) or use a user-provided data cost. + /// + /// + /// Note: + /// StereoBeliefPropagation requires a lot of memory for message storage: + /// + /// ![block formula](https://latex.codecogs.com/png.latex?width%20%5C%5F%20step%20%20%5Ccdot%20height%20%20%5Ccdot%20ndisp%20%20%5Ccdot%204%20%20%5Ccdot%20%281%20%2B%200%2E25%29) + /// + /// and for data cost storage: + /// + /// ![block formula](https://latex.codecogs.com/png.latex?width%5C%5Fstep%20%5Ccdot%20height%20%5Ccdot%20ndisp%20%5Ccdot%20%281%20%2B%200%2E25%20%2B%200%2E0625%20%2B%20%20%5Cdotsm%20%2B%20%5Cfrac%7B1%7D%7B4%5E%7Blevels%7D%7D%29) + /// + /// width_step is the number of bytes in a line including padding. + /// + /// StereoBeliefPropagation uses a truncated linear model for the data cost and discontinuity terms: + /// + /// ![block formula](https://latex.codecogs.com/png.latex?DataCost%20%3D%20data%20%5C%5F%20weight%20%20%5Ccdot%20%5Cmin%20%28%20%5Clvert%20Img%5FLeft%28x%2Cy%29%2DImg%5FRight%28x%2Dd%2Cy%29%20%20%5Crvert%20%2C%20max%20%5C%5F%20data%20%5C%5F%20term%29) + /// + /// ![block formula](https://latex.codecogs.com/png.latex?DiscTerm%20%3D%20%20%5Cmin%20%28disc%20%5C%5F%20single%20%5C%5F%20jump%20%20%5Ccdot%20%5Clvert%20f%5F1%2Df%5F2%20%20%5Crvert%20%2C%20max%20%5C%5F%20disc%20%5C%5F%20term%29) + /// + /// For more details, see [Felzenszwalb2006](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Felzenszwalb2006) . + /// + /// By default, StereoBeliefPropagation uses floating-point arithmetics and the CV_32FC1 type for + /// messages. But it can also use fixed-point arithmetics and the CV_16SC1 message type for better + /// performance. To avoid an overflow in this case, the parameters must satisfy the following + /// requirement: + /// + /// ![block formula](https://latex.codecogs.com/png.latex?10%20%20%5Ccdot%202%5E%7Blevels%2D1%7D%20%20%5Ccdot%20max%20%5C%5F%20data%20%5C%5F%20term%20%3C%20SHRT%20%5C%5F%20MAX) + /// ## See also + /// StereoMatcher + pub struct CUDA_StereoBeliefPropagation { + ptr: *mut c_void, } - boxed_cast_base! { CUDA_StereoBM, core::Algorithm, cv_cuda_StereoBM_to_Algorithm } + opencv_type_boxed! { CUDA_StereoBeliefPropagation } - boxed_cast_base! { CUDA_StereoBM, crate::calib3d::StereoBM, cv_cuda_StereoBM_to_StereoBM } + impl Drop for CUDA_StereoBeliefPropagation { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_StereoBeliefPropagation_delete(self.as_raw_mut_CUDA_StereoBeliefPropagation()) }; + } + } - boxed_cast_base! { CUDA_StereoBM, crate::calib3d::StereoMatcher, cv_cuda_StereoBM_to_StereoMatcher } + unsafe impl Send for CUDA_StereoBeliefPropagation {} - impl std::fmt::Debug for CUDA_StereoBM { + impl CUDA_StereoBeliefPropagation { + /// Uses a heuristic method to compute the recommended parameters ( ndisp, iters and levels ) for the + /// specified image size ( width and height ). #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_StereoBM") - .finish() + pub fn estimate_recommended_params(width: i32, height: i32, ndisp: &mut i32, iters: &mut i32, levels: &mut i32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_StereoBeliefPropagation_estimateRecommendedParams_int_int_intR_intR_intR(width, height, ndisp, iters, levels, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } + } /// Constant methods for [crate::cudastereo::CUDA_StereoBeliefPropagation] @@ -933,53 +989,19 @@ pub mod cudastereo { } - /// Class computing stereo correspondence using the belief propagation algorithm. : - /// - /// The class implements algorithm described in [Felzenszwalb2006](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Felzenszwalb2006) . It can compute own data cost - /// (using a truncated linear model) or use a user-provided data cost. - /// - /// - /// Note: - /// StereoBeliefPropagation requires a lot of memory for message storage: - /// - /// ![block formula](https://latex.codecogs.com/png.latex?width%20%5C%5F%20step%20%20%5Ccdot%20height%20%20%5Ccdot%20ndisp%20%20%5Ccdot%204%20%20%5Ccdot%20%281%20%2B%200%2E25%29) - /// - /// and for data cost storage: - /// - /// ![block formula](https://latex.codecogs.com/png.latex?width%5C%5Fstep%20%5Ccdot%20height%20%5Ccdot%20ndisp%20%5Ccdot%20%281%20%2B%200%2E25%20%2B%200%2E0625%20%2B%20%20%5Cdotsm%20%2B%20%5Cfrac%7B1%7D%7B4%5E%7Blevels%7D%7D%29) - /// - /// width_step is the number of bytes in a line including padding. - /// - /// StereoBeliefPropagation uses a truncated linear model for the data cost and discontinuity terms: - /// - /// ![block formula](https://latex.codecogs.com/png.latex?DataCost%20%3D%20data%20%5C%5F%20weight%20%20%5Ccdot%20%5Cmin%20%28%20%5Clvert%20Img%5FLeft%28x%2Cy%29%2DImg%5FRight%28x%2Dd%2Cy%29%20%20%5Crvert%20%2C%20max%20%5C%5F%20data%20%5C%5F%20term%29) - /// - /// ![block formula](https://latex.codecogs.com/png.latex?DiscTerm%20%3D%20%20%5Cmin%20%28disc%20%5C%5F%20single%20%5C%5F%20jump%20%20%5Ccdot%20%5Clvert%20f%5F1%2Df%5F2%20%20%5Crvert%20%2C%20max%20%5C%5F%20disc%20%5C%5F%20term%29) - /// - /// For more details, see [Felzenszwalb2006](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Felzenszwalb2006) . - /// - /// By default, StereoBeliefPropagation uses floating-point arithmetics and the CV_32FC1 type for - /// messages. But it can also use fixed-point arithmetics and the CV_16SC1 message type for better - /// performance. To avoid an overflow in this case, the parameters must satisfy the following - /// requirement: - /// - /// ![block formula](https://latex.codecogs.com/png.latex?10%20%20%5Ccdot%202%5E%7Blevels%2D1%7D%20%20%5Ccdot%20max%20%5C%5F%20data%20%5C%5F%20term%20%3C%20SHRT%20%5C%5F%20MAX) - /// ## See also - /// StereoMatcher - pub struct CUDA_StereoBeliefPropagation { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_StereoBeliefPropagation } - - impl Drop for CUDA_StereoBeliefPropagation { + impl std::fmt::Debug for CUDA_StereoBeliefPropagation { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_StereoBeliefPropagation_delete(self.as_raw_mut_CUDA_StereoBeliefPropagation()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_StereoBeliefPropagation") + .finish() } } - unsafe impl Send for CUDA_StereoBeliefPropagation {} + boxed_cast_base! { CUDA_StereoBeliefPropagation, core::Algorithm, cv_cuda_StereoBeliefPropagation_to_Algorithm } + + boxed_cast_base! { CUDA_StereoBeliefPropagation, crate::calib3d::StereoMatcher, cv_cuda_StereoBeliefPropagation_to_StereoMatcher } + + boxed_cast_descendant! { CUDA_StereoBeliefPropagation, crate::cudastereo::CUDA_StereoConstantSpaceBP, cv_cuda_StereoBeliefPropagation_to_CUDA_StereoConstantSpaceBP } impl core::AlgorithmTraitConst for CUDA_StereoBeliefPropagation { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1011,32 +1033,54 @@ pub mod cudastereo { boxed_ref! { CUDA_StereoBeliefPropagation, crate::cudastereo::CUDA_StereoBeliefPropagationTraitConst, as_raw_CUDA_StereoBeliefPropagation, crate::cudastereo::CUDA_StereoBeliefPropagationTrait, as_raw_mut_CUDA_StereoBeliefPropagation } - impl CUDA_StereoBeliefPropagation { - /// Uses a heuristic method to compute the recommended parameters ( ndisp, iters and levels ) for the - /// specified image size ( width and height ). - #[inline] - pub fn estimate_recommended_params(width: i32, height: i32, ndisp: &mut i32, iters: &mut i32, levels: &mut i32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_StereoBeliefPropagation_estimateRecommendedParams_int_int_intR_intR_intR(width, height, ndisp, iters, levels, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - + /// Class computing stereo correspondence using the constant space belief propagation algorithm. : + /// + /// The class implements algorithm described in [Yang2010](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Yang2010) . StereoConstantSpaceBP supports both local + /// minimum and global minimum data cost initialization algorithms. For more details, see the paper + /// mentioned above. By default, a local algorithm is used. To enable a global algorithm, set + /// use_local_init_data_cost to false . + /// + /// StereoConstantSpaceBP uses a truncated linear model for the data cost and discontinuity terms: + /// + /// ![block formula](https://latex.codecogs.com/png.latex?DataCost%20%3D%20data%20%5C%5F%20weight%20%20%5Ccdot%20%5Cmin%20%28%20%5Clvert%20I%5F2%2DI%5F1%20%20%5Crvert%20%2C%20max%20%5C%5F%20data%20%5C%5F%20term%29) + /// + /// ![block formula](https://latex.codecogs.com/png.latex?DiscTerm%20%3D%20%20%5Cmin%20%28disc%20%5C%5F%20single%20%5C%5F%20jump%20%20%5Ccdot%20%5Clvert%20f%5F1%2Df%5F2%20%20%5Crvert%20%2C%20max%20%5C%5F%20disc%20%5C%5F%20term%29) + /// + /// For more details, see [Yang2010](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Yang2010) . + /// + /// By default, StereoConstantSpaceBP uses floating-point arithmetics and the CV_32FC1 type for + /// messages. But it can also use fixed-point arithmetics and the CV_16SC1 message type for better + /// performance. To avoid an overflow in this case, the parameters must satisfy the following + /// requirement: + /// + /// ![block formula](https://latex.codecogs.com/png.latex?10%20%20%5Ccdot%202%5E%7Blevels%2D1%7D%20%20%5Ccdot%20max%20%5C%5F%20data%20%5C%5F%20term%20%3C%20SHRT%20%5C%5F%20MAX) + pub struct CUDA_StereoConstantSpaceBP { + ptr: *mut c_void, } - boxed_cast_descendant! { CUDA_StereoBeliefPropagation, crate::cudastereo::CUDA_StereoConstantSpaceBP, cv_cuda_StereoBeliefPropagation_to_CUDA_StereoConstantSpaceBP } + opencv_type_boxed! { CUDA_StereoConstantSpaceBP } - boxed_cast_base! { CUDA_StereoBeliefPropagation, core::Algorithm, cv_cuda_StereoBeliefPropagation_to_Algorithm } + impl Drop for CUDA_StereoConstantSpaceBP { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_StereoConstantSpaceBP_delete(self.as_raw_mut_CUDA_StereoConstantSpaceBP()) }; + } + } - boxed_cast_base! { CUDA_StereoBeliefPropagation, crate::calib3d::StereoMatcher, cv_cuda_StereoBeliefPropagation_to_StereoMatcher } + unsafe impl Send for CUDA_StereoConstantSpaceBP {} - impl std::fmt::Debug for CUDA_StereoBeliefPropagation { + impl CUDA_StereoConstantSpaceBP { + /// Uses a heuristic method to compute parameters (ndisp, iters, levelsand nrplane) for the specified + /// image size (widthand height). #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_StereoBeliefPropagation") - .finish() + pub fn estimate_recommended_params(width: i32, height: i32, ndisp: &mut i32, iters: &mut i32, levels: &mut i32, nr_plane: &mut i32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_StereoConstantSpaceBP_estimateRecommendedParams_int_int_intR_intR_intR_intR(width, height, ndisp, iters, levels, nr_plane, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } + } /// Constant methods for [crate::cudastereo::CUDA_StereoConstantSpaceBP] @@ -1088,41 +1132,19 @@ pub mod cudastereo { } - /// Class computing stereo correspondence using the constant space belief propagation algorithm. : - /// - /// The class implements algorithm described in [Yang2010](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Yang2010) . StereoConstantSpaceBP supports both local - /// minimum and global minimum data cost initialization algorithms. For more details, see the paper - /// mentioned above. By default, a local algorithm is used. To enable a global algorithm, set - /// use_local_init_data_cost to false . - /// - /// StereoConstantSpaceBP uses a truncated linear model for the data cost and discontinuity terms: - /// - /// ![block formula](https://latex.codecogs.com/png.latex?DataCost%20%3D%20data%20%5C%5F%20weight%20%20%5Ccdot%20%5Cmin%20%28%20%5Clvert%20I%5F2%2DI%5F1%20%20%5Crvert%20%2C%20max%20%5C%5F%20data%20%5C%5F%20term%29) - /// - /// ![block formula](https://latex.codecogs.com/png.latex?DiscTerm%20%3D%20%20%5Cmin%20%28disc%20%5C%5F%20single%20%5C%5F%20jump%20%20%5Ccdot%20%5Clvert%20f%5F1%2Df%5F2%20%20%5Crvert%20%2C%20max%20%5C%5F%20disc%20%5C%5F%20term%29) - /// - /// For more details, see [Yang2010](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Yang2010) . - /// - /// By default, StereoConstantSpaceBP uses floating-point arithmetics and the CV_32FC1 type for - /// messages. But it can also use fixed-point arithmetics and the CV_16SC1 message type for better - /// performance. To avoid an overflow in this case, the parameters must satisfy the following - /// requirement: - /// - /// ![block formula](https://latex.codecogs.com/png.latex?10%20%20%5Ccdot%202%5E%7Blevels%2D1%7D%20%20%5Ccdot%20max%20%5C%5F%20data%20%5C%5F%20term%20%3C%20SHRT%20%5C%5F%20MAX) - pub struct CUDA_StereoConstantSpaceBP { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_StereoConstantSpaceBP } - - impl Drop for CUDA_StereoConstantSpaceBP { + impl std::fmt::Debug for CUDA_StereoConstantSpaceBP { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_StereoConstantSpaceBP_delete(self.as_raw_mut_CUDA_StereoConstantSpaceBP()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_StereoConstantSpaceBP") + .finish() } } - unsafe impl Send for CUDA_StereoConstantSpaceBP {} + boxed_cast_base! { CUDA_StereoConstantSpaceBP, core::Algorithm, cv_cuda_StereoConstantSpaceBP_to_Algorithm } + + boxed_cast_base! { CUDA_StereoConstantSpaceBP, crate::cudastereo::CUDA_StereoBeliefPropagation, cv_cuda_StereoConstantSpaceBP_to_CUDA_StereoBeliefPropagation } + + boxed_cast_base! { CUDA_StereoConstantSpaceBP, crate::calib3d::StereoMatcher, cv_cuda_StereoConstantSpaceBP_to_StereoMatcher } impl core::AlgorithmTraitConst for CUDA_StereoConstantSpaceBP { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1164,34 +1186,31 @@ pub mod cudastereo { boxed_ref! { CUDA_StereoConstantSpaceBP, crate::cudastereo::CUDA_StereoConstantSpaceBPTraitConst, as_raw_CUDA_StereoConstantSpaceBP, crate::cudastereo::CUDA_StereoConstantSpaceBPTrait, as_raw_mut_CUDA_StereoConstantSpaceBP } - impl CUDA_StereoConstantSpaceBP { - /// Uses a heuristic method to compute parameters (ndisp, iters, levelsand nrplane) for the specified - /// image size (widthand height). - #[inline] - pub fn estimate_recommended_params(width: i32, height: i32, ndisp: &mut i32, iters: &mut i32, levels: &mut i32, nr_plane: &mut i32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_StereoConstantSpaceBP_estimateRecommendedParams_int_int_intR_intR_intR_intR(width, height, ndisp, iters, levels, nr_plane, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - + /// The class implements the modified H. Hirschmuller algorithm [HH08](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_HH08). + /// Limitation and difference are as follows: + /// + /// * By default, the algorithm uses only 4 directions which are horizontal and vertical path instead of 8. + /// Set mode=StereoSGM::MODE_HH in createStereoSGM to run the full variant of the algorithm. + /// * Mutual Information cost function is not implemented. + /// Instead, Center-Symmetric Census Transform with ![inline formula](https://latex.codecogs.com/png.latex?9%20%5Ctimes%207) window size from [Spangenberg2013](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Spangenberg2013) + /// is used for robustness. + /// ## See also + /// cv::StereoSGBM + pub struct CUDA_StereoSGM { + ptr: *mut c_void, } - boxed_cast_base! { CUDA_StereoConstantSpaceBP, core::Algorithm, cv_cuda_StereoConstantSpaceBP_to_Algorithm } - - boxed_cast_base! { CUDA_StereoConstantSpaceBP, crate::cudastereo::CUDA_StereoBeliefPropagation, cv_cuda_StereoConstantSpaceBP_to_CUDA_StereoBeliefPropagation } - - boxed_cast_base! { CUDA_StereoConstantSpaceBP, crate::calib3d::StereoMatcher, cv_cuda_StereoConstantSpaceBP_to_StereoMatcher } + opencv_type_boxed! { CUDA_StereoSGM } - impl std::fmt::Debug for CUDA_StereoConstantSpaceBP { + impl Drop for CUDA_StereoSGM { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_StereoConstantSpaceBP") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_cuda_StereoSGM_delete(self.as_raw_mut_CUDA_StereoSGM()) }; } } + unsafe impl Send for CUDA_StereoSGM {} + /// Constant methods for [crate::cudastereo::CUDA_StereoSGM] pub trait CUDA_StereoSGMTraitConst: crate::calib3d::StereoSGBMTraitConst { fn as_raw_CUDA_StereoSGM(&self) -> *const c_void; @@ -1238,30 +1257,19 @@ pub mod cudastereo { } - /// The class implements the modified H. Hirschmuller algorithm [HH08](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_HH08). - /// Limitation and difference are as follows: - /// - /// * By default, the algorithm uses only 4 directions which are horizontal and vertical path instead of 8. - /// Set mode=StereoSGM::MODE_HH in createStereoSGM to run the full variant of the algorithm. - /// * Mutual Information cost function is not implemented. - /// Instead, Center-Symmetric Census Transform with ![inline formula](https://latex.codecogs.com/png.latex?9%20%5Ctimes%207) window size from [Spangenberg2013](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Spangenberg2013) - /// is used for robustness. - /// ## See also - /// cv::StereoSGBM - pub struct CUDA_StereoSGM { - ptr: *mut c_void, - } - - opencv_type_boxed! { CUDA_StereoSGM } - - impl Drop for CUDA_StereoSGM { + impl std::fmt::Debug for CUDA_StereoSGM { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_StereoSGM_delete(self.as_raw_mut_CUDA_StereoSGM()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CUDA_StereoSGM") + .finish() } } - unsafe impl Send for CUDA_StereoSGM {} + boxed_cast_base! { CUDA_StereoSGM, core::Algorithm, cv_cuda_StereoSGM_to_Algorithm } + + boxed_cast_base! { CUDA_StereoSGM, crate::calib3d::StereoMatcher, cv_cuda_StereoSGM_to_StereoMatcher } + + boxed_cast_base! { CUDA_StereoSGM, crate::calib3d::StereoSGBM, cv_cuda_StereoSGM_to_StereoSGBM } impl core::AlgorithmTraitConst for CUDA_StereoSGM { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1303,20 +1311,4 @@ pub mod cudastereo { boxed_ref! { CUDA_StereoSGM, crate::cudastereo::CUDA_StereoSGMTraitConst, as_raw_CUDA_StereoSGM, crate::cudastereo::CUDA_StereoSGMTrait, as_raw_mut_CUDA_StereoSGM } - impl CUDA_StereoSGM { - } - - boxed_cast_base! { CUDA_StereoSGM, core::Algorithm, cv_cuda_StereoSGM_to_Algorithm } - - boxed_cast_base! { CUDA_StereoSGM, crate::calib3d::StereoMatcher, cv_cuda_StereoSGM_to_StereoMatcher } - - boxed_cast_base! { CUDA_StereoSGM, crate::calib3d::StereoSGBM, cv_cuda_StereoSGM_to_StereoSGBM } - - impl std::fmt::Debug for CUDA_StereoSGM { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CUDA_StereoSGM") - .finish() - } - } } diff --git a/docs/cudawarping.rs b/docs/cudawarping.rs index 30811e152..ef5841b20 100644 --- a/docs/cudawarping.rs +++ b/docs/cudawarping.rs @@ -789,4 +789,5 @@ pub mod cudawarping { let ret = ret.into_result()?; Ok(ret) } + } diff --git a/docs/cvv.rs b/docs/cvv.rs index bcb4da0cf..fa0fafef7 100644 --- a/docs/cvv.rs +++ b/docs/cvv.rs @@ -63,6 +63,51 @@ pub mod cvv { Ok(ret) } + /// Optional information about a location in Code. + pub struct CallMetaData { + ptr: *mut c_void, + } + + opencv_type_boxed! { CallMetaData } + + impl Drop for CallMetaData { + #[inline] + fn drop(&mut self) { + unsafe { sys::cvv_impl_CallMetaData_delete(self.as_raw_mut_CallMetaData()) }; + } + } + + unsafe impl Send for CallMetaData {} + + impl CallMetaData { + /// Creates an unknown location. + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cvv_impl_CallMetaData_CallMetaData(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::cvv::CallMetaData::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Creates the provided location. + /// + /// Argument should be self-explaining. + #[inline] + pub fn new(file: &str, line: size_t, function: &str) -> Result { + extern_container_arg!(file); + extern_container_arg!(function); + return_send!(via ocvrs_return); + unsafe { sys::cvv_impl_CallMetaData_CallMetaData_const_charX_size_t_const_charX(file.opencv_as_extern(), line, function.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::cvv::CallMetaData::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::cvv::CallMetaData] pub trait CallMetaDataTraitConst { fn as_raw_CallMetaData(&self) -> *const c_void; @@ -111,61 +156,6 @@ pub mod cvv { } - /// Optional information about a location in Code. - pub struct CallMetaData { - ptr: *mut c_void, - } - - opencv_type_boxed! { CallMetaData } - - impl Drop for CallMetaData { - #[inline] - fn drop(&mut self) { - unsafe { sys::cvv_impl_CallMetaData_delete(self.as_raw_mut_CallMetaData()) }; - } - } - - unsafe impl Send for CallMetaData {} - - impl crate::cvv::CallMetaDataTraitConst for CallMetaData { - #[inline] fn as_raw_CallMetaData(&self) -> *const c_void { self.as_raw() } - } - - impl crate::cvv::CallMetaDataTrait for CallMetaData { - #[inline] fn as_raw_mut_CallMetaData(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { CallMetaData, crate::cvv::CallMetaDataTraitConst, as_raw_CallMetaData, crate::cvv::CallMetaDataTrait, as_raw_mut_CallMetaData } - - impl CallMetaData { - /// Creates an unknown location. - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cvv_impl_CallMetaData_CallMetaData(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::cvv::CallMetaData::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Creates the provided location. - /// - /// Argument should be self-explaining. - #[inline] - pub fn new(file: &str, line: size_t, function: &str) -> Result { - extern_container_arg!(file); - extern_container_arg!(function); - return_send!(via ocvrs_return); - unsafe { sys::cvv_impl_CallMetaData_CallMetaData_const_charX_size_t_const_charX(file.opencv_as_extern(), line, function.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::cvv::CallMetaData::opencv_from_extern(ret) }; - Ok(ret) - } - - } - impl Clone for CallMetaData { #[inline] fn clone(&self) -> Self { @@ -184,4 +174,15 @@ pub mod cvv { .finish() } } + + impl crate::cvv::CallMetaDataTraitConst for CallMetaData { + #[inline] fn as_raw_CallMetaData(&self) -> *const c_void { self.as_raw() } + } + + impl crate::cvv::CallMetaDataTrait for CallMetaData { + #[inline] fn as_raw_mut_CallMetaData(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { CallMetaData, crate::cvv::CallMetaDataTraitConst, as_raw_CallMetaData, crate::cvv::CallMetaDataTrait, as_raw_mut_CallMetaData } + } diff --git a/docs/dnn.rs b/docs/dnn.rs index fd46a1d77..dd092aa23 100644 --- a/docs/dnn.rs +++ b/docs/dnn.rs @@ -2154,6 +2154,42 @@ pub mod dnn { Ok(ret) } + pub struct AbsLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { AbsLayer } + + impl Drop for AbsLayer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_AbsLayer_delete(self.as_raw_mut_AbsLayer()) }; + } + } + + unsafe impl Send for AbsLayer {} + + impl AbsLayer { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::dnn::AbsLayer { + let ret = unsafe { sys::cv_dnn_AbsLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::AbsLayer::opencv_from_extern(ret) }; + ret + } + + #[inline] + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_AbsLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::dnn::AbsLayer] pub trait AbsLayerTraitConst: crate::dnn::ActivationLayerTraitConst { fn as_raw_AbsLayer(&self) -> *const c_void; @@ -2166,20 +2202,31 @@ pub mod dnn { } - pub struct AbsLayer { - ptr: *mut c_void, + impl Default for AbsLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { AbsLayer } - - impl Drop for AbsLayer { + impl std::fmt::Debug for AbsLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_AbsLayer_delete(self.as_raw_mut_AbsLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AbsLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for AbsLayer {} + boxed_cast_base! { AbsLayer, crate::dnn::ActivationLayer, cv_dnn_AbsLayer_to_ActivationLayer } + + boxed_cast_base! { AbsLayer, core::Algorithm, cv_dnn_AbsLayer_to_Algorithm } + + boxed_cast_base! { AbsLayer, crate::dnn::Layer, cv_dnn_AbsLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for AbsLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -2221,49 +2268,40 @@ pub mod dnn { boxed_ref! { AbsLayer, crate::dnn::AbsLayerTraitConst, as_raw_AbsLayer, crate::dnn::AbsLayerTrait, as_raw_mut_AbsLayer } - impl AbsLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_AbsLayer_defaultNew_const()) } - } + pub struct AccumLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { AccumLayer } + + impl Drop for AccumLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_AbsLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_AccumLayer_delete(self.as_raw_mut_AccumLayer()) }; } - } - boxed_cast_base! { AbsLayer, crate::dnn::ActivationLayer, cv_dnn_AbsLayer_to_ActivationLayer } - - boxed_cast_base! { AbsLayer, core::Algorithm, cv_dnn_AbsLayer_to_Algorithm } - - boxed_cast_base! { AbsLayer, crate::dnn::Layer, cv_dnn_AbsLayer_to_Layer } + unsafe impl Send for AccumLayer {} - impl std::fmt::Debug for AbsLayer { + impl AccumLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AbsLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::AccumLayer { + let ret = unsafe { sys::cv_dnn_AccumLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::AccumLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for AbsLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_AccumLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::AccumLayer] @@ -2278,20 +2316,29 @@ pub mod dnn { } - pub struct AccumLayer { - ptr: *mut c_void, + impl Default for AccumLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { AccumLayer } - - impl Drop for AccumLayer { + impl std::fmt::Debug for AccumLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_AccumLayer_delete(self.as_raw_mut_AccumLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AccumLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for AccumLayer {} + boxed_cast_base! { AccumLayer, core::Algorithm, cv_dnn_AccumLayer_to_Algorithm } + + boxed_cast_base! { AccumLayer, crate::dnn::Layer, cv_dnn_AccumLayer_to_Layer } impl core::AlgorithmTraitConst for AccumLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2323,47 +2370,40 @@ pub mod dnn { boxed_ref! { AccumLayer, crate::dnn::AccumLayerTraitConst, as_raw_AccumLayer, crate::dnn::AccumLayerTrait, as_raw_mut_AccumLayer } - impl AccumLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_AccumLayer_defaultNew_const()) } - } + pub struct AcosLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { AcosLayer } + + impl Drop for AcosLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_AccumLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_AcosLayer_delete(self.as_raw_mut_AcosLayer()) }; } - } - boxed_cast_base! { AccumLayer, core::Algorithm, cv_dnn_AccumLayer_to_Algorithm } - - boxed_cast_base! { AccumLayer, crate::dnn::Layer, cv_dnn_AccumLayer_to_Layer } + unsafe impl Send for AcosLayer {} - impl std::fmt::Debug for AccumLayer { + impl AcosLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AccumLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::AcosLayer { + let ret = unsafe { sys::cv_dnn_AcosLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::AcosLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for AccumLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_AcosLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::AcosLayer] @@ -2378,20 +2418,31 @@ pub mod dnn { } - pub struct AcosLayer { - ptr: *mut c_void, + impl Default for AcosLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { AcosLayer } - - impl Drop for AcosLayer { + impl std::fmt::Debug for AcosLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_AcosLayer_delete(self.as_raw_mut_AcosLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AcosLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for AcosLayer {} + boxed_cast_base! { AcosLayer, crate::dnn::ActivationLayer, cv_dnn_AcosLayer_to_ActivationLayer } + + boxed_cast_base! { AcosLayer, core::Algorithm, cv_dnn_AcosLayer_to_Algorithm } + + boxed_cast_base! { AcosLayer, crate::dnn::Layer, cv_dnn_AcosLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for AcosLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -2433,44 +2484,55 @@ pub mod dnn { boxed_ref! { AcosLayer, crate::dnn::AcosLayerTraitConst, as_raw_AcosLayer, crate::dnn::AcosLayerTrait, as_raw_mut_AcosLayer } - impl AcosLayer { + pub struct AcoshLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { AcoshLayer } + + impl Drop for AcoshLayer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_AcoshLayer_delete(self.as_raw_mut_AcoshLayer()) }; + } + } + + unsafe impl Send for AcoshLayer {} + + impl AcoshLayer { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_AcosLayer_defaultNew_const()) } + pub fn default() -> crate::dnn::AcoshLayer { + let ret = unsafe { sys::cv_dnn_AcoshLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::AcoshLayer::opencv_from_extern(ret) }; + ret } #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_AcosLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_AcoshLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { AcosLayer, crate::dnn::ActivationLayer, cv_dnn_AcosLayer_to_ActivationLayer } + /// Constant methods for [crate::dnn::AcoshLayer] + pub trait AcoshLayerTraitConst: crate::dnn::ActivationLayerTraitConst { + fn as_raw_AcoshLayer(&self) -> *const c_void; - boxed_cast_base! { AcosLayer, core::Algorithm, cv_dnn_AcosLayer_to_Algorithm } + } - boxed_cast_base! { AcosLayer, crate::dnn::Layer, cv_dnn_AcosLayer_to_Layer } + /// Mutable methods for [crate::dnn::AcoshLayer] + pub trait AcoshLayerTrait: crate::dnn::AcoshLayerTraitConst + crate::dnn::ActivationLayerTrait { + fn as_raw_mut_AcoshLayer(&mut self) -> *mut c_void; - impl std::fmt::Debug for AcosLayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AcosLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for AcosLayer { + } + + impl Default for AcoshLayer { #[inline] /// Forwards to infallible Self::default() fn default() -> Self { @@ -2478,32 +2540,23 @@ pub mod dnn { } } - /// Constant methods for [crate::dnn::AcoshLayer] - pub trait AcoshLayerTraitConst: crate::dnn::ActivationLayerTraitConst { - fn as_raw_AcoshLayer(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::dnn::AcoshLayer] - pub trait AcoshLayerTrait: crate::dnn::AcoshLayerTraitConst + crate::dnn::ActivationLayerTrait { - fn as_raw_mut_AcoshLayer(&mut self) -> *mut c_void; - - } - - pub struct AcoshLayer { - ptr: *mut c_void, - } - - opencv_type_boxed! { AcoshLayer } - - impl Drop for AcoshLayer { + impl std::fmt::Debug for AcoshLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_AcoshLayer_delete(self.as_raw_mut_AcoshLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AcoshLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for AcoshLayer {} + boxed_cast_base! { AcoshLayer, crate::dnn::ActivationLayer, cv_dnn_AcoshLayer_to_ActivationLayer } + + boxed_cast_base! { AcoshLayer, core::Algorithm, cv_dnn_AcoshLayer_to_Algorithm } + + boxed_cast_base! { AcoshLayer, crate::dnn::Layer, cv_dnn_AcoshLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for AcoshLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -2545,49 +2598,30 @@ pub mod dnn { boxed_ref! { AcoshLayer, crate::dnn::AcoshLayerTraitConst, as_raw_AcoshLayer, crate::dnn::AcoshLayerTrait, as_raw_mut_AcoshLayer } - impl AcoshLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_AcoshLayer_defaultNew_const()) } - } - - #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_AcoshLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + pub struct ActivationLayer { + ptr: *mut c_void, } - boxed_cast_base! { AcoshLayer, crate::dnn::ActivationLayer, cv_dnn_AcoshLayer_to_ActivationLayer } - - boxed_cast_base! { AcoshLayer, core::Algorithm, cv_dnn_AcoshLayer_to_Algorithm } - - boxed_cast_base! { AcoshLayer, crate::dnn::Layer, cv_dnn_AcoshLayer_to_Layer } + opencv_type_boxed! { ActivationLayer } - impl std::fmt::Debug for AcoshLayer { + impl Drop for ActivationLayer { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AcoshLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_dnn_ActivationLayer_delete(self.as_raw_mut_ActivationLayer()) }; } } - impl Default for AcoshLayer { + unsafe impl Send for ActivationLayer {} + + impl ActivationLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::dnn::ActivationLayer { + let ret = unsafe { sys::cv_dnn_ActivationLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ActivationLayer::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::dnn::ActivationLayer] @@ -2620,60 +2654,30 @@ pub mod dnn { } - pub struct ActivationLayer { - ptr: *mut c_void, - } - - opencv_type_boxed! { ActivationLayer } - - impl Drop for ActivationLayer { + impl Default for ActivationLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ActivationLayer_delete(self.as_raw_mut_ActivationLayer()) }; + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() } } - unsafe impl Send for ActivationLayer {} - - impl core::AlgorithmTraitConst for ActivationLayer { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for ActivationLayer { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { ActivationLayer, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::dnn::LayerTraitConst for ActivationLayer { - #[inline] fn as_raw_Layer(&self) -> *const c_void { self.as_raw() } - } - - impl crate::dnn::LayerTrait for ActivationLayer { - #[inline] fn as_raw_mut_Layer(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { ActivationLayer, crate::dnn::LayerTraitConst, as_raw_Layer, crate::dnn::LayerTrait, as_raw_mut_Layer } - - impl crate::dnn::ActivationLayerTraitConst for ActivationLayer { - #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } - } - - impl crate::dnn::ActivationLayerTrait for ActivationLayer { - #[inline] fn as_raw_mut_ActivationLayer(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { ActivationLayer, crate::dnn::ActivationLayerTraitConst, as_raw_ActivationLayer, crate::dnn::ActivationLayerTrait, as_raw_mut_ActivationLayer } - - impl ActivationLayer { - /// Creates a default instance of the class by calling the default constructor + impl std::fmt::Debug for ActivationLayer { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ActivationLayer_defaultNew_const()) } + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ActivationLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } - } + boxed_cast_base! { ActivationLayer, core::Algorithm, cv_dnn_ActivationLayer_to_Algorithm } + + boxed_cast_base! { ActivationLayer, crate::dnn::Layer, cv_dnn_ActivationLayer_to_Layer } + boxed_cast_descendant! { ActivationLayer, crate::dnn::AbsLayer, cv_dnn_ActivationLayer_to_AbsLayer } boxed_cast_descendant! { ActivationLayer, crate::dnn::AcosLayer, cv_dnn_ActivationLayer_to_AcosLayer } @@ -2764,28 +2768,70 @@ pub mod dnn { boxed_cast_descendant! { ActivationLayer, crate::dnn::ThresholdedReluLayer, cv_dnn_ActivationLayer_to_ThresholdedReluLayer } - boxed_cast_base! { ActivationLayer, core::Algorithm, cv_dnn_ActivationLayer_to_Algorithm } + impl core::AlgorithmTraitConst for ActivationLayer { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } + } - boxed_cast_base! { ActivationLayer, crate::dnn::Layer, cv_dnn_ActivationLayer_to_Layer } + impl core::AlgorithmTrait for ActivationLayer { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } - impl std::fmt::Debug for ActivationLayer { + boxed_ref! { ActivationLayer, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + + impl crate::dnn::LayerTraitConst for ActivationLayer { + #[inline] fn as_raw_Layer(&self) -> *const c_void { self.as_raw() } + } + + impl crate::dnn::LayerTrait for ActivationLayer { + #[inline] fn as_raw_mut_Layer(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { ActivationLayer, crate::dnn::LayerTraitConst, as_raw_Layer, crate::dnn::LayerTrait, as_raw_mut_Layer } + + impl crate::dnn::ActivationLayerTraitConst for ActivationLayer { + #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } + } + + impl crate::dnn::ActivationLayerTrait for ActivationLayer { + #[inline] fn as_raw_mut_ActivationLayer(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { ActivationLayer, crate::dnn::ActivationLayerTraitConst, as_raw_ActivationLayer, crate::dnn::ActivationLayerTrait, as_raw_mut_ActivationLayer } + + pub struct ActivationLayerInt8 { + ptr: *mut c_void, + } + + opencv_type_boxed! { ActivationLayerInt8 } + + impl Drop for ActivationLayerInt8 { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ActivationLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_dnn_ActivationLayerInt8_delete(self.as_raw_mut_ActivationLayerInt8()) }; } } - impl Default for ActivationLayer { + unsafe impl Send for ActivationLayerInt8 {} + + impl ActivationLayerInt8 { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::dnn::ActivationLayerInt8 { + let ret = unsafe { sys::cv_dnn_ActivationLayerInt8_defaultNew_const() }; + let ret = unsafe { crate::dnn::ActivationLayerInt8::opencv_from_extern(ret) }; + ret + } + + #[inline] + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ActivationLayerInt8_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ActivationLayerInt8] @@ -2800,20 +2846,31 @@ pub mod dnn { } - pub struct ActivationLayerInt8 { - ptr: *mut c_void, + impl Default for ActivationLayerInt8 { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ActivationLayerInt8 } - - impl Drop for ActivationLayerInt8 { + impl std::fmt::Debug for ActivationLayerInt8 { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ActivationLayerInt8_delete(self.as_raw_mut_ActivationLayerInt8()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ActivationLayerInt8") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ActivationLayerInt8 {} + boxed_cast_base! { ActivationLayerInt8, crate::dnn::ActivationLayer, cv_dnn_ActivationLayerInt8_to_ActivationLayer } + + boxed_cast_base! { ActivationLayerInt8, core::Algorithm, cv_dnn_ActivationLayerInt8_to_Algorithm } + + boxed_cast_base! { ActivationLayerInt8, crate::dnn::Layer, cv_dnn_ActivationLayerInt8_to_Layer } impl crate::dnn::ActivationLayerTraitConst for ActivationLayerInt8 { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -2855,49 +2912,43 @@ pub mod dnn { boxed_ref! { ActivationLayerInt8, crate::dnn::ActivationLayerInt8TraitConst, as_raw_ActivationLayerInt8, crate::dnn::ActivationLayerInt8Trait, as_raw_mut_ActivationLayerInt8 } - impl ActivationLayerInt8 { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ActivationLayerInt8_defaultNew_const()) } - } + /// ArgMax/ArgMin layer + /// + /// Note: returns indices as floats, which means the supported range is [-2^24; 2^24] + pub struct ArgLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { ArgLayer } + impl Drop for ArgLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ActivationLayerInt8_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ArgLayer_delete(self.as_raw_mut_ArgLayer()) }; } - } - boxed_cast_base! { ActivationLayerInt8, crate::dnn::ActivationLayer, cv_dnn_ActivationLayerInt8_to_ActivationLayer } - - boxed_cast_base! { ActivationLayerInt8, core::Algorithm, cv_dnn_ActivationLayerInt8_to_Algorithm } - - boxed_cast_base! { ActivationLayerInt8, crate::dnn::Layer, cv_dnn_ActivationLayerInt8_to_Layer } + unsafe impl Send for ArgLayer {} - impl std::fmt::Debug for ActivationLayerInt8 { + impl ArgLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ActivationLayerInt8") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::ArgLayer { + let ret = unsafe { sys::cv_dnn_ArgLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ArgLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for ActivationLayerInt8 { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ArgLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ArgLayer] @@ -2912,23 +2963,29 @@ pub mod dnn { } - /// ArgMax/ArgMin layer - /// - /// Note: returns indices as floats, which means the supported range is [-2^24; 2^24] - pub struct ArgLayer { - ptr: *mut c_void, + impl Default for ArgLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ArgLayer } - - impl Drop for ArgLayer { + impl std::fmt::Debug for ArgLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ArgLayer_delete(self.as_raw_mut_ArgLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ArgLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ArgLayer {} + boxed_cast_base! { ArgLayer, core::Algorithm, cv_dnn_ArgLayer_to_Algorithm } + + boxed_cast_base! { ArgLayer, crate::dnn::Layer, cv_dnn_ArgLayer_to_Layer } impl core::AlgorithmTraitConst for ArgLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2960,47 +3017,40 @@ pub mod dnn { boxed_ref! { ArgLayer, crate::dnn::ArgLayerTraitConst, as_raw_ArgLayer, crate::dnn::ArgLayerTrait, as_raw_mut_ArgLayer } - impl ArgLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ArgLayer_defaultNew_const()) } - } + pub struct AsinLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { AsinLayer } + + impl Drop for AsinLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ArgLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_AsinLayer_delete(self.as_raw_mut_AsinLayer()) }; } - } - boxed_cast_base! { ArgLayer, core::Algorithm, cv_dnn_ArgLayer_to_Algorithm } - - boxed_cast_base! { ArgLayer, crate::dnn::Layer, cv_dnn_ArgLayer_to_Layer } + unsafe impl Send for AsinLayer {} - impl std::fmt::Debug for ArgLayer { + impl AsinLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ArgLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::AsinLayer { + let ret = unsafe { sys::cv_dnn_AsinLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::AsinLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for ArgLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_AsinLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::AsinLayer] @@ -3015,20 +3065,31 @@ pub mod dnn { } - pub struct AsinLayer { - ptr: *mut c_void, + impl Default for AsinLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { AsinLayer } - - impl Drop for AsinLayer { + impl std::fmt::Debug for AsinLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_AsinLayer_delete(self.as_raw_mut_AsinLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AsinLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for AsinLayer {} + boxed_cast_base! { AsinLayer, crate::dnn::ActivationLayer, cv_dnn_AsinLayer_to_ActivationLayer } + + boxed_cast_base! { AsinLayer, core::Algorithm, cv_dnn_AsinLayer_to_Algorithm } + + boxed_cast_base! { AsinLayer, crate::dnn::Layer, cv_dnn_AsinLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for AsinLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -3070,49 +3131,40 @@ pub mod dnn { boxed_ref! { AsinLayer, crate::dnn::AsinLayerTraitConst, as_raw_AsinLayer, crate::dnn::AsinLayerTrait, as_raw_mut_AsinLayer } - impl AsinLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_AsinLayer_defaultNew_const()) } - } + pub struct AsinhLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { AsinhLayer } + + impl Drop for AsinhLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_AsinLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_AsinhLayer_delete(self.as_raw_mut_AsinhLayer()) }; } - } - boxed_cast_base! { AsinLayer, crate::dnn::ActivationLayer, cv_dnn_AsinLayer_to_ActivationLayer } - - boxed_cast_base! { AsinLayer, core::Algorithm, cv_dnn_AsinLayer_to_Algorithm } - - boxed_cast_base! { AsinLayer, crate::dnn::Layer, cv_dnn_AsinLayer_to_Layer } + unsafe impl Send for AsinhLayer {} - impl std::fmt::Debug for AsinLayer { + impl AsinhLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AsinLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::AsinhLayer { + let ret = unsafe { sys::cv_dnn_AsinhLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::AsinhLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for AsinLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_AsinhLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::AsinhLayer] @@ -3127,20 +3179,31 @@ pub mod dnn { } - pub struct AsinhLayer { - ptr: *mut c_void, + impl Default for AsinhLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { AsinhLayer } - - impl Drop for AsinhLayer { + impl std::fmt::Debug for AsinhLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_AsinhLayer_delete(self.as_raw_mut_AsinhLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AsinhLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for AsinhLayer {} + boxed_cast_base! { AsinhLayer, crate::dnn::ActivationLayer, cv_dnn_AsinhLayer_to_ActivationLayer } + + boxed_cast_base! { AsinhLayer, core::Algorithm, cv_dnn_AsinhLayer_to_Algorithm } + + boxed_cast_base! { AsinhLayer, crate::dnn::Layer, cv_dnn_AsinhLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for AsinhLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -3182,44 +3245,55 @@ pub mod dnn { boxed_ref! { AsinhLayer, crate::dnn::AsinhLayerTraitConst, as_raw_AsinhLayer, crate::dnn::AsinhLayerTrait, as_raw_mut_AsinhLayer } - impl AsinhLayer { + pub struct AtanLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { AtanLayer } + + impl Drop for AtanLayer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_AtanLayer_delete(self.as_raw_mut_AtanLayer()) }; + } + } + + unsafe impl Send for AtanLayer {} + + impl AtanLayer { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_AsinhLayer_defaultNew_const()) } + pub fn default() -> crate::dnn::AtanLayer { + let ret = unsafe { sys::cv_dnn_AtanLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::AtanLayer::opencv_from_extern(ret) }; + ret } #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_AsinhLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_AtanLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { AsinhLayer, crate::dnn::ActivationLayer, cv_dnn_AsinhLayer_to_ActivationLayer } - - boxed_cast_base! { AsinhLayer, core::Algorithm, cv_dnn_AsinhLayer_to_Algorithm } + /// Constant methods for [crate::dnn::AtanLayer] + pub trait AtanLayerTraitConst: crate::dnn::ActivationLayerTraitConst { + fn as_raw_AtanLayer(&self) -> *const c_void; - boxed_cast_base! { AsinhLayer, crate::dnn::Layer, cv_dnn_AsinhLayer_to_Layer } + } + + /// Mutable methods for [crate::dnn::AtanLayer] + pub trait AtanLayerTrait: crate::dnn::ActivationLayerTrait + crate::dnn::AtanLayerTraitConst { + fn as_raw_mut_AtanLayer(&mut self) -> *mut c_void; - impl std::fmt::Debug for AsinhLayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AsinhLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } } - impl Default for AsinhLayer { + impl Default for AtanLayer { #[inline] /// Forwards to infallible Self::default() fn default() -> Self { @@ -3227,32 +3301,23 @@ pub mod dnn { } } - /// Constant methods for [crate::dnn::AtanLayer] - pub trait AtanLayerTraitConst: crate::dnn::ActivationLayerTraitConst { - fn as_raw_AtanLayer(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::dnn::AtanLayer] - pub trait AtanLayerTrait: crate::dnn::ActivationLayerTrait + crate::dnn::AtanLayerTraitConst { - fn as_raw_mut_AtanLayer(&mut self) -> *mut c_void; - - } - - pub struct AtanLayer { - ptr: *mut c_void, - } - - opencv_type_boxed! { AtanLayer } - - impl Drop for AtanLayer { + impl std::fmt::Debug for AtanLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_AtanLayer_delete(self.as_raw_mut_AtanLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AtanLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for AtanLayer {} + boxed_cast_base! { AtanLayer, crate::dnn::ActivationLayer, cv_dnn_AtanLayer_to_ActivationLayer } + + boxed_cast_base! { AtanLayer, core::Algorithm, cv_dnn_AtanLayer_to_Algorithm } + + boxed_cast_base! { AtanLayer, crate::dnn::Layer, cv_dnn_AtanLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for AtanLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -3294,49 +3359,40 @@ pub mod dnn { boxed_ref! { AtanLayer, crate::dnn::AtanLayerTraitConst, as_raw_AtanLayer, crate::dnn::AtanLayerTrait, as_raw_mut_AtanLayer } - impl AtanLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_AtanLayer_defaultNew_const()) } - } + pub struct AtanhLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { AtanhLayer } + impl Drop for AtanhLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_AtanLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_AtanhLayer_delete(self.as_raw_mut_AtanhLayer()) }; } - } - boxed_cast_base! { AtanLayer, crate::dnn::ActivationLayer, cv_dnn_AtanLayer_to_ActivationLayer } - - boxed_cast_base! { AtanLayer, core::Algorithm, cv_dnn_AtanLayer_to_Algorithm } - - boxed_cast_base! { AtanLayer, crate::dnn::Layer, cv_dnn_AtanLayer_to_Layer } + unsafe impl Send for AtanhLayer {} - impl std::fmt::Debug for AtanLayer { + impl AtanhLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AtanLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::AtanhLayer { + let ret = unsafe { sys::cv_dnn_AtanhLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::AtanhLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for AtanLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_AtanhLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::AtanhLayer] @@ -3351,20 +3407,31 @@ pub mod dnn { } - pub struct AtanhLayer { - ptr: *mut c_void, + impl Default for AtanhLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { AtanhLayer } - - impl Drop for AtanhLayer { + impl std::fmt::Debug for AtanhLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_AtanhLayer_delete(self.as_raw_mut_AtanhLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AtanhLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for AtanhLayer {} + boxed_cast_base! { AtanhLayer, crate::dnn::ActivationLayer, cv_dnn_AtanhLayer_to_ActivationLayer } + + boxed_cast_base! { AtanhLayer, core::Algorithm, cv_dnn_AtanhLayer_to_Algorithm } + + boxed_cast_base! { AtanhLayer, crate::dnn::Layer, cv_dnn_AtanhLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for AtanhLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -3406,49 +3473,40 @@ pub mod dnn { boxed_ref! { AtanhLayer, crate::dnn::AtanhLayerTraitConst, as_raw_AtanhLayer, crate::dnn::AtanhLayerTrait, as_raw_mut_AtanhLayer } - impl AtanhLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_AtanhLayer_defaultNew_const()) } - } + pub struct AttentionLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { AttentionLayer } + + impl Drop for AttentionLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_AtanhLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_AttentionLayer_delete(self.as_raw_mut_AttentionLayer()) }; } - } - boxed_cast_base! { AtanhLayer, crate::dnn::ActivationLayer, cv_dnn_AtanhLayer_to_ActivationLayer } - - boxed_cast_base! { AtanhLayer, core::Algorithm, cv_dnn_AtanhLayer_to_Algorithm } - - boxed_cast_base! { AtanhLayer, crate::dnn::Layer, cv_dnn_AtanhLayer_to_Layer } + unsafe impl Send for AttentionLayer {} - impl std::fmt::Debug for AtanhLayer { + impl AttentionLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AtanhLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::AttentionLayer { + let ret = unsafe { sys::cv_dnn_AttentionLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::AttentionLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for AtanhLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_AttentionLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::AttentionLayer] @@ -3463,20 +3521,29 @@ pub mod dnn { } - pub struct AttentionLayer { - ptr: *mut c_void, + impl Default for AttentionLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { AttentionLayer } - - impl Drop for AttentionLayer { + impl std::fmt::Debug for AttentionLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_AttentionLayer_delete(self.as_raw_mut_AttentionLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AttentionLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for AttentionLayer {} + boxed_cast_base! { AttentionLayer, core::Algorithm, cv_dnn_AttentionLayer_to_Algorithm } + + boxed_cast_base! { AttentionLayer, crate::dnn::Layer, cv_dnn_AttentionLayer_to_Layer } impl core::AlgorithmTraitConst for AttentionLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3508,47 +3575,40 @@ pub mod dnn { boxed_ref! { AttentionLayer, crate::dnn::AttentionLayerTraitConst, as_raw_AttentionLayer, crate::dnn::AttentionLayerTrait, as_raw_mut_AttentionLayer } - impl AttentionLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_AttentionLayer_defaultNew_const()) } - } + pub struct BNLLLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { BNLLLayer } + + impl Drop for BNLLLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_AttentionLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_BNLLLayer_delete(self.as_raw_mut_BNLLLayer()) }; } - } - boxed_cast_base! { AttentionLayer, core::Algorithm, cv_dnn_AttentionLayer_to_Algorithm } - - boxed_cast_base! { AttentionLayer, crate::dnn::Layer, cv_dnn_AttentionLayer_to_Layer } + unsafe impl Send for BNLLLayer {} - impl std::fmt::Debug for AttentionLayer { + impl BNLLLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AttentionLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::BNLLLayer { + let ret = unsafe { sys::cv_dnn_BNLLLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::BNLLLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for AttentionLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_BNLLLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::BNLLLayer] @@ -3563,20 +3623,31 @@ pub mod dnn { } - pub struct BNLLLayer { - ptr: *mut c_void, - } - - opencv_type_boxed! { BNLLLayer } + impl Default for BNLLLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } + } - impl Drop for BNLLLayer { + impl std::fmt::Debug for BNLLLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_BNLLLayer_delete(self.as_raw_mut_BNLLLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BNLLLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for BNLLLayer {} + boxed_cast_base! { BNLLLayer, crate::dnn::ActivationLayer, cv_dnn_BNLLLayer_to_ActivationLayer } + + boxed_cast_base! { BNLLLayer, core::Algorithm, cv_dnn_BNLLLayer_to_Algorithm } + + boxed_cast_base! { BNLLLayer, crate::dnn::Layer, cv_dnn_BNLLLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for BNLLLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -3618,50 +3689,21 @@ pub mod dnn { boxed_ref! { BNLLLayer, crate::dnn::BNLLLayerTraitConst, as_raw_BNLLLayer, crate::dnn::BNLLLayerTrait, as_raw_mut_BNLLLayer } - impl BNLLLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_BNLLLayer_defaultNew_const()) } - } - - #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_BNLLLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + /// Derivatives of this class encapsulates functions of certain backends. + pub struct BackendNode { + ptr: *mut c_void, } - boxed_cast_base! { BNLLLayer, crate::dnn::ActivationLayer, cv_dnn_BNLLLayer_to_ActivationLayer } - - boxed_cast_base! { BNLLLayer, core::Algorithm, cv_dnn_BNLLLayer_to_Algorithm } - - boxed_cast_base! { BNLLLayer, crate::dnn::Layer, cv_dnn_BNLLLayer_to_Layer } + opencv_type_boxed! { BackendNode } - impl std::fmt::Debug for BNLLLayer { + impl Drop for BackendNode { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BNLLLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_dnn_BackendNode_delete(self.as_raw_mut_BackendNode()) }; } } - impl Default for BNLLLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } + unsafe impl Send for BackendNode {} /// Constant methods for [crate::dnn::BackendNode] pub trait BackendNodeTraitConst { @@ -3689,22 +3731,15 @@ pub mod dnn { } - /// Derivatives of this class encapsulates functions of certain backends. - pub struct BackendNode { - ptr: *mut c_void, - } - - opencv_type_boxed! { BackendNode } - - impl Drop for BackendNode { + impl std::fmt::Debug for BackendNode { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_BackendNode_delete(self.as_raw_mut_BackendNode()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BackendNode") + .field("backend_id", &crate::dnn::BackendNodeTraitConst::backend_id(self)) + .finish() } } - unsafe impl Send for BackendNode {} - impl crate::dnn::BackendNodeTraitConst for BackendNode { #[inline] fn as_raw_BackendNode(&self) -> *const c_void { self.as_raw() } } @@ -3715,18 +3750,22 @@ pub mod dnn { boxed_ref! { BackendNode, crate::dnn::BackendNodeTraitConst, as_raw_BackendNode, crate::dnn::BackendNodeTrait, as_raw_mut_BackendNode } - impl BackendNode { + /// Derivatives of this class wraps cv::Mat for different backends and targets. + pub struct BackendWrapper { + ptr: *mut c_void, } - impl std::fmt::Debug for BackendNode { + opencv_type_boxed! { BackendWrapper } + + impl Drop for BackendWrapper { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BackendNode") - .field("backend_id", &crate::dnn::BackendNodeTraitConst::backend_id(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_dnn_BackendWrapper_delete(self.as_raw_mut_BackendWrapper()) }; } } + unsafe impl Send for BackendWrapper {} + /// Constant methods for [crate::dnn::BackendWrapper] pub trait BackendWrapperTraitConst { fn as_raw_BackendWrapper(&self) -> *const c_void; @@ -3787,22 +3826,16 @@ pub mod dnn { } - /// Derivatives of this class wraps cv::Mat for different backends and targets. - pub struct BackendWrapper { - ptr: *mut c_void, - } - - opencv_type_boxed! { BackendWrapper } - - impl Drop for BackendWrapper { + impl std::fmt::Debug for BackendWrapper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_BackendWrapper_delete(self.as_raw_mut_BackendWrapper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BackendWrapper") + .field("backend_id", &crate::dnn::BackendWrapperTraitConst::backend_id(self)) + .field("target_id", &crate::dnn::BackendWrapperTraitConst::target_id(self)) + .finish() } } - unsafe impl Send for BackendWrapper {} - impl crate::dnn::BackendWrapperTraitConst for BackendWrapper { #[inline] fn as_raw_BackendWrapper(&self) -> *const c_void { self.as_raw() } } @@ -3813,17 +3846,30 @@ pub mod dnn { boxed_ref! { BackendWrapper, crate::dnn::BackendWrapperTraitConst, as_raw_BackendWrapper, crate::dnn::BackendWrapperTrait, as_raw_mut_BackendWrapper } - impl BackendWrapper { + pub struct BaseConvolutionLayer { + ptr: *mut c_void, } - impl std::fmt::Debug for BackendWrapper { + opencv_type_boxed! { BaseConvolutionLayer } + + impl Drop for BaseConvolutionLayer { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BackendWrapper") - .field("backend_id", &crate::dnn::BackendWrapperTraitConst::backend_id(self)) - .field("target_id", &crate::dnn::BackendWrapperTraitConst::target_id(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_dnn_BaseConvolutionLayer_delete(self.as_raw_mut_BaseConvolutionLayer()) }; + } + } + + unsafe impl Send for BaseConvolutionLayer {} + + impl BaseConvolutionLayer { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::dnn::BaseConvolutionLayer { + let ret = unsafe { sys::cv_dnn_BaseConvolutionLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::BaseConvolutionLayer::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::dnn::BaseConvolutionLayer] @@ -4012,20 +4058,42 @@ pub mod dnn { } - pub struct BaseConvolutionLayer { - ptr: *mut c_void, + impl Default for BaseConvolutionLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { BaseConvolutionLayer } - - impl Drop for BaseConvolutionLayer { + impl std::fmt::Debug for BaseConvolutionLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_BaseConvolutionLayer_delete(self.as_raw_mut_BaseConvolutionLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BaseConvolutionLayer") + .field("kernel", &crate::dnn::BaseConvolutionLayerTraitConst::kernel(self)) + .field("stride", &crate::dnn::BaseConvolutionLayerTraitConst::stride(self)) + .field("pad", &crate::dnn::BaseConvolutionLayerTraitConst::pad(self)) + .field("dilation", &crate::dnn::BaseConvolutionLayerTraitConst::dilation(self)) + .field("adjust_pad", &crate::dnn::BaseConvolutionLayerTraitConst::adjust_pad(self)) + .field("adjust_pads", &crate::dnn::BaseConvolutionLayerTraitConst::adjust_pads(self)) + .field("kernel_size", &crate::dnn::BaseConvolutionLayerTraitConst::kernel_size(self)) + .field("strides", &crate::dnn::BaseConvolutionLayerTraitConst::strides(self)) + .field("dilations", &crate::dnn::BaseConvolutionLayerTraitConst::dilations(self)) + .field("pads_begin", &crate::dnn::BaseConvolutionLayerTraitConst::pads_begin(self)) + .field("pads_end", &crate::dnn::BaseConvolutionLayerTraitConst::pads_end(self)) + .field("pad_mode", &crate::dnn::BaseConvolutionLayerTraitConst::pad_mode(self)) + .field("num_output", &crate::dnn::BaseConvolutionLayerTraitConst::num_output(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for BaseConvolutionLayer {} + boxed_cast_base! { BaseConvolutionLayer, core::Algorithm, cv_dnn_BaseConvolutionLayer_to_Algorithm } + + boxed_cast_base! { BaseConvolutionLayer, crate::dnn::Layer, cv_dnn_BaseConvolutionLayer_to_Layer } impl core::AlgorithmTraitConst for BaseConvolutionLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -4057,50 +4125,40 @@ pub mod dnn { boxed_ref! { BaseConvolutionLayer, crate::dnn::BaseConvolutionLayerTraitConst, as_raw_BaseConvolutionLayer, crate::dnn::BaseConvolutionLayerTrait, as_raw_mut_BaseConvolutionLayer } - impl BaseConvolutionLayer { - /// Creates a default instance of the class by calling the default constructor + pub struct BatchNormLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { BatchNormLayer } + + impl Drop for BatchNormLayer { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_BaseConvolutionLayer_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_dnn_BatchNormLayer_delete(self.as_raw_mut_BatchNormLayer()) }; } - } - boxed_cast_base! { BaseConvolutionLayer, core::Algorithm, cv_dnn_BaseConvolutionLayer_to_Algorithm } - - boxed_cast_base! { BaseConvolutionLayer, crate::dnn::Layer, cv_dnn_BaseConvolutionLayer_to_Layer } + unsafe impl Send for BatchNormLayer {} - impl std::fmt::Debug for BaseConvolutionLayer { + impl BatchNormLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BaseConvolutionLayer") - .field("kernel", &crate::dnn::BaseConvolutionLayerTraitConst::kernel(self)) - .field("stride", &crate::dnn::BaseConvolutionLayerTraitConst::stride(self)) - .field("pad", &crate::dnn::BaseConvolutionLayerTraitConst::pad(self)) - .field("dilation", &crate::dnn::BaseConvolutionLayerTraitConst::dilation(self)) - .field("adjust_pad", &crate::dnn::BaseConvolutionLayerTraitConst::adjust_pad(self)) - .field("adjust_pads", &crate::dnn::BaseConvolutionLayerTraitConst::adjust_pads(self)) - .field("kernel_size", &crate::dnn::BaseConvolutionLayerTraitConst::kernel_size(self)) - .field("strides", &crate::dnn::BaseConvolutionLayerTraitConst::strides(self)) - .field("dilations", &crate::dnn::BaseConvolutionLayerTraitConst::dilations(self)) - .field("pads_begin", &crate::dnn::BaseConvolutionLayerTraitConst::pads_begin(self)) - .field("pads_end", &crate::dnn::BaseConvolutionLayerTraitConst::pads_end(self)) - .field("pad_mode", &crate::dnn::BaseConvolutionLayerTraitConst::pad_mode(self)) - .field("num_output", &crate::dnn::BaseConvolutionLayerTraitConst::num_output(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::BatchNormLayer { + let ret = unsafe { sys::cv_dnn_BatchNormLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::BatchNormLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for BaseConvolutionLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_BatchNormLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::BatchNormLayer] @@ -4151,27 +4209,41 @@ pub mod dnn { } - pub struct BatchNormLayer { - ptr: *mut c_void, - } - - opencv_type_boxed! { BatchNormLayer } - - impl Drop for BatchNormLayer { + impl Default for BatchNormLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_BatchNormLayer_delete(self.as_raw_mut_BatchNormLayer()) }; + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() } } - unsafe impl Send for BatchNormLayer {} - - impl crate::dnn::ActivationLayerTraitConst for BatchNormLayer { - #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } - } - - impl crate::dnn::ActivationLayerTrait for BatchNormLayer { - #[inline] fn as_raw_mut_ActivationLayer(&mut self) -> *mut c_void { self.as_raw_mut() } + impl std::fmt::Debug for BatchNormLayer { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BatchNormLayer") + .field("has_weights", &crate::dnn::BatchNormLayerTraitConst::has_weights(self)) + .field("has_bias", &crate::dnn::BatchNormLayerTraitConst::has_bias(self)) + .field("epsilon", &crate::dnn::BatchNormLayerTraitConst::epsilon(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() + } + } + + boxed_cast_base! { BatchNormLayer, crate::dnn::ActivationLayer, cv_dnn_BatchNormLayer_to_ActivationLayer } + + boxed_cast_base! { BatchNormLayer, core::Algorithm, cv_dnn_BatchNormLayer_to_Algorithm } + + boxed_cast_base! { BatchNormLayer, crate::dnn::Layer, cv_dnn_BatchNormLayer_to_Layer } + + impl crate::dnn::ActivationLayerTraitConst for BatchNormLayer { + #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } + } + + impl crate::dnn::ActivationLayerTrait for BatchNormLayer { + #[inline] fn as_raw_mut_ActivationLayer(&mut self) -> *mut c_void { self.as_raw_mut() } } boxed_ref! { BatchNormLayer, crate::dnn::ActivationLayerTraitConst, as_raw_ActivationLayer, crate::dnn::ActivationLayerTrait, as_raw_mut_ActivationLayer } @@ -4206,52 +4278,40 @@ pub mod dnn { boxed_ref! { BatchNormLayer, crate::dnn::BatchNormLayerTraitConst, as_raw_BatchNormLayer, crate::dnn::BatchNormLayerTrait, as_raw_mut_BatchNormLayer } - impl BatchNormLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_BatchNormLayer_defaultNew_const()) } - } + pub struct BatchNormLayerInt8 { + ptr: *mut c_void, + } + + opencv_type_boxed! { BatchNormLayerInt8 } + impl Drop for BatchNormLayerInt8 { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_BatchNormLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_BatchNormLayerInt8_delete(self.as_raw_mut_BatchNormLayerInt8()) }; } - } - boxed_cast_base! { BatchNormLayer, crate::dnn::ActivationLayer, cv_dnn_BatchNormLayer_to_ActivationLayer } - - boxed_cast_base! { BatchNormLayer, core::Algorithm, cv_dnn_BatchNormLayer_to_Algorithm } - - boxed_cast_base! { BatchNormLayer, crate::dnn::Layer, cv_dnn_BatchNormLayer_to_Layer } + unsafe impl Send for BatchNormLayerInt8 {} - impl std::fmt::Debug for BatchNormLayer { + impl BatchNormLayerInt8 { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BatchNormLayer") - .field("has_weights", &crate::dnn::BatchNormLayerTraitConst::has_weights(self)) - .field("has_bias", &crate::dnn::BatchNormLayerTraitConst::has_bias(self)) - .field("epsilon", &crate::dnn::BatchNormLayerTraitConst::epsilon(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::BatchNormLayerInt8 { + let ret = unsafe { sys::cv_dnn_BatchNormLayerInt8_defaultNew_const() }; + let ret = unsafe { crate::dnn::BatchNormLayerInt8::opencv_from_extern(ret) }; + ret } - } - impl Default for BatchNormLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_BatchNormLayerInt8_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::BatchNormLayerInt8] @@ -4314,20 +4374,40 @@ pub mod dnn { } - pub struct BatchNormLayerInt8 { - ptr: *mut c_void, + impl Default for BatchNormLayerInt8 { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { BatchNormLayerInt8 } - - impl Drop for BatchNormLayerInt8 { + impl std::fmt::Debug for BatchNormLayerInt8 { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_BatchNormLayerInt8_delete(self.as_raw_mut_BatchNormLayerInt8()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BatchNormLayerInt8") + .field("input_sc", &crate::dnn::BatchNormLayerInt8TraitConst::input_sc(self)) + .field("output_sc", &crate::dnn::BatchNormLayerInt8TraitConst::output_sc(self)) + .field("input_zp", &crate::dnn::BatchNormLayerInt8TraitConst::input_zp(self)) + .field("output_zp", &crate::dnn::BatchNormLayerInt8TraitConst::output_zp(self)) + .field("has_weights", &crate::dnn::BatchNormLayerTraitConst::has_weights(self)) + .field("has_bias", &crate::dnn::BatchNormLayerTraitConst::has_bias(self)) + .field("epsilon", &crate::dnn::BatchNormLayerTraitConst::epsilon(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for BatchNormLayerInt8 {} + boxed_cast_base! { BatchNormLayerInt8, crate::dnn::ActivationLayer, cv_dnn_BatchNormLayerInt8_to_ActivationLayer } + + boxed_cast_base! { BatchNormLayerInt8, core::Algorithm, cv_dnn_BatchNormLayerInt8_to_Algorithm } + + boxed_cast_base! { BatchNormLayerInt8, crate::dnn::BatchNormLayer, cv_dnn_BatchNormLayerInt8_to_BatchNormLayer } + + boxed_cast_base! { BatchNormLayerInt8, crate::dnn::Layer, cv_dnn_BatchNormLayerInt8_to_Layer } impl crate::dnn::ActivationLayerTraitConst for BatchNormLayerInt8 { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -4379,72 +4459,6 @@ pub mod dnn { boxed_ref! { BatchNormLayerInt8, crate::dnn::BatchNormLayerInt8TraitConst, as_raw_BatchNormLayerInt8, crate::dnn::BatchNormLayerInt8Trait, as_raw_mut_BatchNormLayerInt8 } - impl BatchNormLayerInt8 { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_BatchNormLayerInt8_defaultNew_const()) } - } - - #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_BatchNormLayerInt8_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { BatchNormLayerInt8, crate::dnn::ActivationLayer, cv_dnn_BatchNormLayerInt8_to_ActivationLayer } - - boxed_cast_base! { BatchNormLayerInt8, core::Algorithm, cv_dnn_BatchNormLayerInt8_to_Algorithm } - - boxed_cast_base! { BatchNormLayerInt8, crate::dnn::BatchNormLayer, cv_dnn_BatchNormLayerInt8_to_BatchNormLayer } - - boxed_cast_base! { BatchNormLayerInt8, crate::dnn::Layer, cv_dnn_BatchNormLayerInt8_to_Layer } - - impl std::fmt::Debug for BatchNormLayerInt8 { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BatchNormLayerInt8") - .field("input_sc", &crate::dnn::BatchNormLayerInt8TraitConst::input_sc(self)) - .field("output_sc", &crate::dnn::BatchNormLayerInt8TraitConst::output_sc(self)) - .field("input_zp", &crate::dnn::BatchNormLayerInt8TraitConst::input_zp(self)) - .field("output_zp", &crate::dnn::BatchNormLayerInt8TraitConst::output_zp(self)) - .field("has_weights", &crate::dnn::BatchNormLayerTraitConst::has_weights(self)) - .field("has_bias", &crate::dnn::BatchNormLayerTraitConst::has_bias(self)) - .field("epsilon", &crate::dnn::BatchNormLayerTraitConst::epsilon(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for BatchNormLayerInt8 { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - - /// Constant methods for [crate::dnn::BlankLayer] - pub trait BlankLayerTraitConst: crate::dnn::LayerTraitConst { - fn as_raw_BlankLayer(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::dnn::BlankLayer] - pub trait BlankLayerTrait: crate::dnn::BlankLayerTraitConst + crate::dnn::LayerTrait { - fn as_raw_mut_BlankLayer(&mut self) -> *mut c_void; - - } - /// # Partial List of Implemented Layers /// This subsection of dnn module contains information about built-in layers and their descriptions. /// @@ -4479,41 +4493,13 @@ pub mod dnn { unsafe impl Send for BlankLayer {} - impl core::AlgorithmTraitConst for BlankLayer { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for BlankLayer { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { BlankLayer, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::dnn::LayerTraitConst for BlankLayer { - #[inline] fn as_raw_Layer(&self) -> *const c_void { self.as_raw() } - } - - impl crate::dnn::LayerTrait for BlankLayer { - #[inline] fn as_raw_mut_Layer(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { BlankLayer, crate::dnn::LayerTraitConst, as_raw_Layer, crate::dnn::LayerTrait, as_raw_mut_Layer } - - impl crate::dnn::BlankLayerTraitConst for BlankLayer { - #[inline] fn as_raw_BlankLayer(&self) -> *const c_void { self.as_raw() } - } - - impl crate::dnn::BlankLayerTrait for BlankLayer { - #[inline] fn as_raw_mut_BlankLayer(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { BlankLayer, crate::dnn::BlankLayerTraitConst, as_raw_BlankLayer, crate::dnn::BlankLayerTrait, as_raw_mut_BlankLayer } - impl BlankLayer { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_BlankLayer_defaultNew_const()) } + pub fn default() -> crate::dnn::BlankLayer { + let ret = unsafe { sys::cv_dnn_BlankLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::BlankLayer::opencv_from_extern(ret) }; + ret } #[inline] @@ -4528,9 +4514,25 @@ pub mod dnn { } - boxed_cast_base! { BlankLayer, core::Algorithm, cv_dnn_BlankLayer_to_Algorithm } + /// Constant methods for [crate::dnn::BlankLayer] + pub trait BlankLayerTraitConst: crate::dnn::LayerTraitConst { + fn as_raw_BlankLayer(&self) -> *const c_void; - boxed_cast_base! { BlankLayer, crate::dnn::Layer, cv_dnn_BlankLayer_to_Layer } + } + + /// Mutable methods for [crate::dnn::BlankLayer] + pub trait BlankLayerTrait: crate::dnn::BlankLayerTraitConst + crate::dnn::LayerTrait { + fn as_raw_mut_BlankLayer(&mut self) -> *mut c_void; + + } + + impl Default for BlankLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } + } impl std::fmt::Debug for BlankLayer { #[inline] @@ -4544,28 +4546,42 @@ pub mod dnn { } } - impl Default for BlankLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } + boxed_cast_base! { BlankLayer, core::Algorithm, cv_dnn_BlankLayer_to_Algorithm } - /// Constant methods for [crate::dnn::CeilLayer] - pub trait CeilLayerTraitConst: crate::dnn::ActivationLayerTraitConst { - fn as_raw_CeilLayer(&self) -> *const c_void; + boxed_cast_base! { BlankLayer, crate::dnn::Layer, cv_dnn_BlankLayer_to_Layer } + impl core::AlgorithmTraitConst for BlankLayer { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::dnn::CeilLayer] - pub trait CeilLayerTrait: crate::dnn::ActivationLayerTrait + crate::dnn::CeilLayerTraitConst { - fn as_raw_mut_CeilLayer(&mut self) -> *mut c_void; - + impl core::AlgorithmTrait for BlankLayer { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } } - pub struct CeilLayer { - ptr: *mut c_void, + boxed_ref! { BlankLayer, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + + impl crate::dnn::LayerTraitConst for BlankLayer { + #[inline] fn as_raw_Layer(&self) -> *const c_void { self.as_raw() } + } + + impl crate::dnn::LayerTrait for BlankLayer { + #[inline] fn as_raw_mut_Layer(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { BlankLayer, crate::dnn::LayerTraitConst, as_raw_Layer, crate::dnn::LayerTrait, as_raw_mut_Layer } + + impl crate::dnn::BlankLayerTraitConst for BlankLayer { + #[inline] fn as_raw_BlankLayer(&self) -> *const c_void { self.as_raw() } + } + + impl crate::dnn::BlankLayerTrait for BlankLayer { + #[inline] fn as_raw_mut_BlankLayer(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { BlankLayer, crate::dnn::BlankLayerTraitConst, as_raw_BlankLayer, crate::dnn::BlankLayerTrait, as_raw_mut_BlankLayer } + + pub struct CeilLayer { + ptr: *mut c_void, } opencv_type_boxed! { CeilLayer } @@ -4579,6 +4595,65 @@ pub mod dnn { unsafe impl Send for CeilLayer {} + impl CeilLayer { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::dnn::CeilLayer { + let ret = unsafe { sys::cv_dnn_CeilLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::CeilLayer::opencv_from_extern(ret) }; + ret + } + + #[inline] + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_CeilLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::dnn::CeilLayer] + pub trait CeilLayerTraitConst: crate::dnn::ActivationLayerTraitConst { + fn as_raw_CeilLayer(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::dnn::CeilLayer] + pub trait CeilLayerTrait: crate::dnn::ActivationLayerTrait + crate::dnn::CeilLayerTraitConst { + fn as_raw_mut_CeilLayer(&mut self) -> *mut c_void; + + } + + impl Default for CeilLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } + } + + impl std::fmt::Debug for CeilLayer { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CeilLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() + } + } + + boxed_cast_base! { CeilLayer, crate::dnn::ActivationLayer, cv_dnn_CeilLayer_to_ActivationLayer } + + boxed_cast_base! { CeilLayer, core::Algorithm, cv_dnn_CeilLayer_to_Algorithm } + + boxed_cast_base! { CeilLayer, crate::dnn::Layer, cv_dnn_CeilLayer_to_Layer } + impl crate::dnn::ActivationLayerTraitConst for CeilLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } } @@ -4619,49 +4694,40 @@ pub mod dnn { boxed_ref! { CeilLayer, crate::dnn::CeilLayerTraitConst, as_raw_CeilLayer, crate::dnn::CeilLayerTrait, as_raw_mut_CeilLayer } - impl CeilLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_CeilLayer_defaultNew_const()) } - } + pub struct CeluLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { CeluLayer } + + impl Drop for CeluLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_CeilLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_CeluLayer_delete(self.as_raw_mut_CeluLayer()) }; } - } - boxed_cast_base! { CeilLayer, crate::dnn::ActivationLayer, cv_dnn_CeilLayer_to_ActivationLayer } - - boxed_cast_base! { CeilLayer, core::Algorithm, cv_dnn_CeilLayer_to_Algorithm } - - boxed_cast_base! { CeilLayer, crate::dnn::Layer, cv_dnn_CeilLayer_to_Layer } + unsafe impl Send for CeluLayer {} - impl std::fmt::Debug for CeilLayer { + impl CeluLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CeilLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::CeluLayer { + let ret = unsafe { sys::cv_dnn_CeluLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::CeluLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for CeilLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_CeluLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::CeluLayer] @@ -4688,20 +4754,32 @@ pub mod dnn { } - pub struct CeluLayer { - ptr: *mut c_void, + impl Default for CeluLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { CeluLayer } - - impl Drop for CeluLayer { + impl std::fmt::Debug for CeluLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_CeluLayer_delete(self.as_raw_mut_CeluLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CeluLayer") + .field("alpha", &crate::dnn::CeluLayerTraitConst::alpha(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for CeluLayer {} + boxed_cast_base! { CeluLayer, crate::dnn::ActivationLayer, cv_dnn_CeluLayer_to_ActivationLayer } + + boxed_cast_base! { CeluLayer, core::Algorithm, cv_dnn_CeluLayer_to_Algorithm } + + boxed_cast_base! { CeluLayer, crate::dnn::Layer, cv_dnn_CeluLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for CeluLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -4743,50 +4821,40 @@ pub mod dnn { boxed_ref! { CeluLayer, crate::dnn::CeluLayerTraitConst, as_raw_CeluLayer, crate::dnn::CeluLayerTrait, as_raw_mut_CeluLayer } - impl CeluLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_CeluLayer_defaultNew_const()) } - } + pub struct ChannelsPReLULayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { ChannelsPReLULayer } + impl Drop for ChannelsPReLULayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_CeluLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ChannelsPReLULayer_delete(self.as_raw_mut_ChannelsPReLULayer()) }; } - } - boxed_cast_base! { CeluLayer, crate::dnn::ActivationLayer, cv_dnn_CeluLayer_to_ActivationLayer } - - boxed_cast_base! { CeluLayer, core::Algorithm, cv_dnn_CeluLayer_to_Algorithm } - - boxed_cast_base! { CeluLayer, crate::dnn::Layer, cv_dnn_CeluLayer_to_Layer } + unsafe impl Send for ChannelsPReLULayer {} - impl std::fmt::Debug for CeluLayer { + impl ChannelsPReLULayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CeluLayer") - .field("alpha", &crate::dnn::CeluLayerTraitConst::alpha(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::ChannelsPReLULayer { + let ret = unsafe { sys::cv_dnn_ChannelsPReLULayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ChannelsPReLULayer::opencv_from_extern(ret) }; + ret } - } - impl Default for CeluLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ChannelsPReLULayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ChannelsPReLULayer] @@ -4801,20 +4869,31 @@ pub mod dnn { } - pub struct ChannelsPReLULayer { - ptr: *mut c_void, + impl Default for ChannelsPReLULayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ChannelsPReLULayer } - - impl Drop for ChannelsPReLULayer { + impl std::fmt::Debug for ChannelsPReLULayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ChannelsPReLULayer_delete(self.as_raw_mut_ChannelsPReLULayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ChannelsPReLULayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ChannelsPReLULayer {} + boxed_cast_base! { ChannelsPReLULayer, crate::dnn::ActivationLayer, cv_dnn_ChannelsPReLULayer_to_ActivationLayer } + + boxed_cast_base! { ChannelsPReLULayer, core::Algorithm, cv_dnn_ChannelsPReLULayer_to_Algorithm } + + boxed_cast_base! { ChannelsPReLULayer, crate::dnn::Layer, cv_dnn_ChannelsPReLULayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for ChannelsPReLULayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -4856,49 +4935,90 @@ pub mod dnn { boxed_ref! { ChannelsPReLULayer, crate::dnn::ChannelsPReLULayerTraitConst, as_raw_ChannelsPReLULayer, crate::dnn::ChannelsPReLULayerTrait, as_raw_mut_ChannelsPReLULayer } - impl ChannelsPReLULayer { - /// Creates a default instance of the class by calling the default constructor + /// This class represents high-level API for classification models. + /// + /// ClassificationModel allows to set params for preprocessing input image. + /// ClassificationModel creates net from file with trained weights and config, + /// sets preprocessing input, runs forward pass and return top-1 prediction. + pub struct ClassificationModel { + ptr: *mut c_void, + } + + opencv_type_boxed! { ClassificationModel } + + impl Drop for ClassificationModel { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ChannelsPReLULayer_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_dnn_ClassificationModel_delete(self.as_raw_mut_ClassificationModel()) }; } + } + unsafe impl Send for ClassificationModel {} + + impl ClassificationModel { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ChannelsPReLULayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_ClassificationModel_ClassificationModel(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::dnn::ClassificationModel::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { ChannelsPReLULayer, crate::dnn::ActivationLayer, cv_dnn_ChannelsPReLULayer_to_ActivationLayer } - - boxed_cast_base! { ChannelsPReLULayer, core::Algorithm, cv_dnn_ChannelsPReLULayer_to_Algorithm } - - boxed_cast_base! { ChannelsPReLULayer, crate::dnn::Layer, cv_dnn_ChannelsPReLULayer_to_Layer } + /// Create classification model from network represented in one of the supported formats. + /// An order of @p model and @p config arguments does not matter. + /// ## Parameters + /// * model: Binary file contains trained weights. + /// * config: Text file contains network configuration. + /// + /// ## C++ default parameters + /// * config: "" + #[inline] + pub fn new(model: &str, config: &str) -> Result { + extern_container_arg!(model); + extern_container_arg!(config); + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ClassificationModel_ClassificationModel_const_StringR_const_StringR(model.opencv_as_extern(), config.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::ClassificationModel::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for ChannelsPReLULayer { + /// Create classification model from network represented in one of the supported formats. + /// An order of @p model and @p config arguments does not matter. + /// ## Parameters + /// * model: Binary file contains trained weights. + /// * config: Text file contains network configuration. + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * config: "" #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ChannelsPReLULayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn new_def(model: &str) -> Result { + extern_container_arg!(model); + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ClassificationModel_ClassificationModel_const_StringR(model.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::ClassificationModel::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for ChannelsPReLULayer { + /// Create model from deep learning network. + /// ## Parameters + /// * network: Net object. #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new_1(network: &impl crate::dnn::NetTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ClassificationModel_ClassificationModel_const_NetR(network.as_raw_Net(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::ClassificationModel::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ClassificationModel] @@ -4972,25 +5092,22 @@ pub mod dnn { } - /// This class represents high-level API for classification models. - /// - /// ClassificationModel allows to set params for preprocessing input image. - /// ClassificationModel creates net from file with trained weights and config, - /// sets preprocessing input, runs forward pass and return top-1 prediction. - pub struct ClassificationModel { - ptr: *mut c_void, + impl Clone for ClassificationModel { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_dnn_ClassificationModel_implicitClone_const(self.as_raw_ClassificationModel())) } + } } - opencv_type_boxed! { ClassificationModel } - - impl Drop for ClassificationModel { + impl std::fmt::Debug for ClassificationModel { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ClassificationModel_delete(self.as_raw_mut_ClassificationModel()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ClassificationModel") + .finish() } } - unsafe impl Send for ClassificationModel {} + boxed_cast_base! { ClassificationModel, crate::dnn::Model, cv_dnn_ClassificationModel_to_Model } impl crate::dnn::ModelTraitConst for ClassificationModel { #[inline] fn as_raw_Model(&self) -> *const c_void { self.as_raw() } @@ -5012,89 +5129,42 @@ pub mod dnn { boxed_ref! { ClassificationModel, crate::dnn::ClassificationModelTraitConst, as_raw_ClassificationModel, crate::dnn::ClassificationModelTrait, as_raw_mut_ClassificationModel } - impl ClassificationModel { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ClassificationModel_ClassificationModel(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::ClassificationModel::opencv_from_extern(ret) }; - Ok(ret) - } + pub struct CompareLayer { + ptr: *mut c_void, + } - /// Create classification model from network represented in one of the supported formats. - /// An order of @p model and @p config arguments does not matter. - /// ## Parameters - /// * model: Binary file contains trained weights. - /// * config: Text file contains network configuration. - /// - /// ## C++ default parameters - /// * config: "" + opencv_type_boxed! { CompareLayer } + + impl Drop for CompareLayer { #[inline] - pub fn new(model: &str, config: &str) -> Result { - extern_container_arg!(model); - extern_container_arg!(config); - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ClassificationModel_ClassificationModel_const_StringR_const_StringR(model.opencv_as_extern(), config.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::ClassificationModel::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_CompareLayer_delete(self.as_raw_mut_CompareLayer()) }; } + } - /// Create classification model from network represented in one of the supported formats. - /// An order of @p model and @p config arguments does not matter. - /// ## Parameters - /// * model: Binary file contains trained weights. - /// * config: Text file contains network configuration. - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * config: "" + unsafe impl Send for CompareLayer {} + + impl CompareLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - pub fn new_def(model: &str) -> Result { - extern_container_arg!(model); - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ClassificationModel_ClassificationModel_const_StringR(model.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::ClassificationModel::opencv_from_extern(ret) }; - Ok(ret) + pub fn default() -> crate::dnn::CompareLayer { + let ret = unsafe { sys::cv_dnn_CompareLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::CompareLayer::opencv_from_extern(ret) }; + ret } - /// Create model from deep learning network. - /// ## Parameters - /// * network: Net object. #[inline] - pub fn new_1(network: &impl crate::dnn::NetTraitConst) -> Result { + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ClassificationModel_ClassificationModel_const_NetR(network.as_raw_Net(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_CompareLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::ClassificationModel::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - impl Clone for ClassificationModel { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ClassificationModel_implicitClone_const(self.as_raw_ClassificationModel())) } - } - } - - boxed_cast_base! { ClassificationModel, crate::dnn::Model, cv_dnn_ClassificationModel_to_Model } - - impl std::fmt::Debug for ClassificationModel { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ClassificationModel") - .finish() - } - } - /// Constant methods for [crate::dnn::CompareLayer] pub trait CompareLayerTraitConst: crate::dnn::LayerTraitConst { fn as_raw_CompareLayer(&self) -> *const c_void; @@ -5107,20 +5177,29 @@ pub mod dnn { } - pub struct CompareLayer { - ptr: *mut c_void, + impl Default for CompareLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { CompareLayer } - - impl Drop for CompareLayer { + impl std::fmt::Debug for CompareLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_CompareLayer_delete(self.as_raw_mut_CompareLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CompareLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for CompareLayer {} + boxed_cast_base! { CompareLayer, core::Algorithm, cv_dnn_CompareLayer_to_Algorithm } + + boxed_cast_base! { CompareLayer, crate::dnn::Layer, cv_dnn_CompareLayer_to_Layer } impl core::AlgorithmTraitConst for CompareLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5152,63 +5231,56 @@ pub mod dnn { boxed_ref! { CompareLayer, crate::dnn::CompareLayerTraitConst, as_raw_CompareLayer, crate::dnn::CompareLayerTrait, as_raw_mut_CompareLayer } - impl CompareLayer { + pub struct ConcatLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { ConcatLayer } + + impl Drop for ConcatLayer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_ConcatLayer_delete(self.as_raw_mut_ConcatLayer()) }; + } + } + + unsafe impl Send for ConcatLayer {} + + impl ConcatLayer { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_CompareLayer_defaultNew_const()) } + pub fn default() -> crate::dnn::ConcatLayer { + let ret = unsafe { sys::cv_dnn_ConcatLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ConcatLayer::opencv_from_extern(ret) }; + ret } #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_CompareLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_ConcatLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { CompareLayer, core::Algorithm, cv_dnn_CompareLayer_to_Algorithm } - - boxed_cast_base! { CompareLayer, crate::dnn::Layer, cv_dnn_CompareLayer_to_Layer } + /// Constant methods for [crate::dnn::ConcatLayer] + pub trait ConcatLayerTraitConst: crate::dnn::LayerTraitConst { + fn as_raw_ConcatLayer(&self) -> *const c_void; - impl std::fmt::Debug for CompareLayer { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CompareLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + fn axis(&self) -> i32 { + let ret = unsafe { sys::cv_dnn_ConcatLayer_propAxis_const(self.as_raw_ConcatLayer()) }; + ret } - } - impl Default for CompareLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - - /// Constant methods for [crate::dnn::ConcatLayer] - pub trait ConcatLayerTraitConst: crate::dnn::LayerTraitConst { - fn as_raw_ConcatLayer(&self) -> *const c_void; - - #[inline] - fn axis(&self) -> i32 { - let ret = unsafe { sys::cv_dnn_ConcatLayer_propAxis_const(self.as_raw_ConcatLayer()) }; - ret - } - - /// Add zero padding in case of concatenation of blobs with different - /// spatial sizes. - /// - /// Details: + /// Add zero padding in case of concatenation of blobs with different + /// spatial sizes. + /// + /// Details: #[inline] fn padding(&self) -> bool { let ret = unsafe { sys::cv_dnn_ConcatLayer_propPadding_const(self.as_raw_ConcatLayer()) }; @@ -5251,20 +5323,32 @@ pub mod dnn { } - pub struct ConcatLayer { - ptr: *mut c_void, + impl Default for ConcatLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ConcatLayer } - - impl Drop for ConcatLayer { + impl std::fmt::Debug for ConcatLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ConcatLayer_delete(self.as_raw_mut_ConcatLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ConcatLayer") + .field("axis", &crate::dnn::ConcatLayerTraitConst::axis(self)) + .field("padding", &crate::dnn::ConcatLayerTraitConst::padding(self)) + .field("padding_value", &crate::dnn::ConcatLayerTraitConst::padding_value(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ConcatLayer {} + boxed_cast_base! { ConcatLayer, core::Algorithm, cv_dnn_ConcatLayer_to_Algorithm } + + boxed_cast_base! { ConcatLayer, crate::dnn::Layer, cv_dnn_ConcatLayer_to_Layer } impl core::AlgorithmTraitConst for ConcatLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5296,50 +5380,41 @@ pub mod dnn { boxed_ref! { ConcatLayer, crate::dnn::ConcatLayerTraitConst, as_raw_ConcatLayer, crate::dnn::ConcatLayerTrait, as_raw_mut_ConcatLayer } - impl ConcatLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ConcatLayer_defaultNew_const()) } - } + /// Constant layer produces the same data blob at an every forward pass. + pub struct ConstLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { ConstLayer } + impl Drop for ConstLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ConcatLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ConstLayer_delete(self.as_raw_mut_ConstLayer()) }; } - } - boxed_cast_base! { ConcatLayer, core::Algorithm, cv_dnn_ConcatLayer_to_Algorithm } - - boxed_cast_base! { ConcatLayer, crate::dnn::Layer, cv_dnn_ConcatLayer_to_Layer } + unsafe impl Send for ConstLayer {} - impl std::fmt::Debug for ConcatLayer { + impl ConstLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ConcatLayer") - .field("axis", &crate::dnn::ConcatLayerTraitConst::axis(self)) - .field("padding", &crate::dnn::ConcatLayerTraitConst::padding(self)) - .field("padding_value", &crate::dnn::ConcatLayerTraitConst::padding_value(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::ConstLayer { + let ret = unsafe { sys::cv_dnn_ConstLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ConstLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for ConcatLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ConstLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ConstLayer] @@ -5354,21 +5429,29 @@ pub mod dnn { } - /// Constant layer produces the same data blob at an every forward pass. - pub struct ConstLayer { - ptr: *mut c_void, + impl Default for ConstLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ConstLayer } - - impl Drop for ConstLayer { + impl std::fmt::Debug for ConstLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ConstLayer_delete(self.as_raw_mut_ConstLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ConstLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ConstLayer {} + boxed_cast_base! { ConstLayer, core::Algorithm, cv_dnn_ConstLayer_to_Algorithm } + + boxed_cast_base! { ConstLayer, crate::dnn::Layer, cv_dnn_ConstLayer_to_Layer } impl core::AlgorithmTraitConst for ConstLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5400,47 +5483,40 @@ pub mod dnn { boxed_ref! { ConstLayer, crate::dnn::ConstLayerTraitConst, as_raw_ConstLayer, crate::dnn::ConstLayerTrait, as_raw_mut_ConstLayer } - impl ConstLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ConstLayer_defaultNew_const()) } - } + pub struct ConvolutionLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { ConvolutionLayer } + + impl Drop for ConvolutionLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ConstLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ConvolutionLayer_delete(self.as_raw_mut_ConvolutionLayer()) }; } - } - boxed_cast_base! { ConstLayer, core::Algorithm, cv_dnn_ConstLayer_to_Algorithm } - - boxed_cast_base! { ConstLayer, crate::dnn::Layer, cv_dnn_ConstLayer_to_Layer } + unsafe impl Send for ConvolutionLayer {} - impl std::fmt::Debug for ConstLayer { + impl ConvolutionLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ConstLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::ConvolutionLayer { + let ret = unsafe { sys::cv_dnn_ConvolutionLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ConvolutionLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for ConstLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ConvolutionLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ConvolutionLayer] @@ -5497,20 +5573,47 @@ pub mod dnn { } - pub struct ConvolutionLayer { - ptr: *mut c_void, + impl Default for ConvolutionLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ConvolutionLayer } - - impl Drop for ConvolutionLayer { + impl std::fmt::Debug for ConvolutionLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ConvolutionLayer_delete(self.as_raw_mut_ConvolutionLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ConvolutionLayer") + .field("fused_activation", &crate::dnn::ConvolutionLayerTraitConst::fused_activation(self)) + .field("fused_add", &crate::dnn::ConvolutionLayerTraitConst::fused_add(self)) + .field("use_winograd", &crate::dnn::ConvolutionLayerTraitConst::use_winograd(self)) + .field("kernel", &crate::dnn::BaseConvolutionLayerTraitConst::kernel(self)) + .field("stride", &crate::dnn::BaseConvolutionLayerTraitConst::stride(self)) + .field("pad", &crate::dnn::BaseConvolutionLayerTraitConst::pad(self)) + .field("dilation", &crate::dnn::BaseConvolutionLayerTraitConst::dilation(self)) + .field("adjust_pad", &crate::dnn::BaseConvolutionLayerTraitConst::adjust_pad(self)) + .field("adjust_pads", &crate::dnn::BaseConvolutionLayerTraitConst::adjust_pads(self)) + .field("kernel_size", &crate::dnn::BaseConvolutionLayerTraitConst::kernel_size(self)) + .field("strides", &crate::dnn::BaseConvolutionLayerTraitConst::strides(self)) + .field("dilations", &crate::dnn::BaseConvolutionLayerTraitConst::dilations(self)) + .field("pads_begin", &crate::dnn::BaseConvolutionLayerTraitConst::pads_begin(self)) + .field("pads_end", &crate::dnn::BaseConvolutionLayerTraitConst::pads_end(self)) + .field("pad_mode", &crate::dnn::BaseConvolutionLayerTraitConst::pad_mode(self)) + .field("num_output", &crate::dnn::BaseConvolutionLayerTraitConst::num_output(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ConvolutionLayer {} + boxed_cast_base! { ConvolutionLayer, core::Algorithm, cv_dnn_ConvolutionLayer_to_Algorithm } + + boxed_cast_base! { ConvolutionLayer, crate::dnn::BaseConvolutionLayer, cv_dnn_ConvolutionLayer_to_BaseConvolutionLayer } + + boxed_cast_base! { ConvolutionLayer, crate::dnn::Layer, cv_dnn_ConvolutionLayer_to_Layer } impl core::AlgorithmTraitConst for ConvolutionLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5552,17 +5655,34 @@ pub mod dnn { boxed_ref! { ConvolutionLayer, crate::dnn::ConvolutionLayerTraitConst, as_raw_ConvolutionLayer, crate::dnn::ConvolutionLayerTrait, as_raw_mut_ConvolutionLayer } - impl ConvolutionLayer { + pub struct ConvolutionLayerInt8 { + ptr: *mut c_void, + } + + opencv_type_boxed! { ConvolutionLayerInt8 } + + impl Drop for ConvolutionLayerInt8 { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_ConvolutionLayerInt8_delete(self.as_raw_mut_ConvolutionLayerInt8()) }; + } + } + + unsafe impl Send for ConvolutionLayerInt8 {} + + impl ConvolutionLayerInt8 { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ConvolutionLayer_defaultNew_const()) } + pub fn default() -> crate::dnn::ConvolutionLayerInt8 { + let ret = unsafe { sys::cv_dnn_ConvolutionLayerInt8_defaultNew_const() }; + let ret = unsafe { crate::dnn::ConvolutionLayerInt8::opencv_from_extern(ret) }; + ret } #[inline] pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ConvolutionLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_ConvolutionLayerInt8_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; @@ -5571,57 +5691,15 @@ pub mod dnn { } - boxed_cast_base! { ConvolutionLayer, core::Algorithm, cv_dnn_ConvolutionLayer_to_Algorithm } - - boxed_cast_base! { ConvolutionLayer, crate::dnn::BaseConvolutionLayer, cv_dnn_ConvolutionLayer_to_BaseConvolutionLayer } + /// Constant methods for [crate::dnn::ConvolutionLayerInt8] + pub trait ConvolutionLayerInt8TraitConst: crate::dnn::BaseConvolutionLayerTraitConst { + fn as_raw_ConvolutionLayerInt8(&self) -> *const c_void; - boxed_cast_base! { ConvolutionLayer, crate::dnn::Layer, cv_dnn_ConvolutionLayer_to_Layer } - - impl std::fmt::Debug for ConvolutionLayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ConvolutionLayer") - .field("fused_activation", &crate::dnn::ConvolutionLayerTraitConst::fused_activation(self)) - .field("fused_add", &crate::dnn::ConvolutionLayerTraitConst::fused_add(self)) - .field("use_winograd", &crate::dnn::ConvolutionLayerTraitConst::use_winograd(self)) - .field("kernel", &crate::dnn::BaseConvolutionLayerTraitConst::kernel(self)) - .field("stride", &crate::dnn::BaseConvolutionLayerTraitConst::stride(self)) - .field("pad", &crate::dnn::BaseConvolutionLayerTraitConst::pad(self)) - .field("dilation", &crate::dnn::BaseConvolutionLayerTraitConst::dilation(self)) - .field("adjust_pad", &crate::dnn::BaseConvolutionLayerTraitConst::adjust_pad(self)) - .field("adjust_pads", &crate::dnn::BaseConvolutionLayerTraitConst::adjust_pads(self)) - .field("kernel_size", &crate::dnn::BaseConvolutionLayerTraitConst::kernel_size(self)) - .field("strides", &crate::dnn::BaseConvolutionLayerTraitConst::strides(self)) - .field("dilations", &crate::dnn::BaseConvolutionLayerTraitConst::dilations(self)) - .field("pads_begin", &crate::dnn::BaseConvolutionLayerTraitConst::pads_begin(self)) - .field("pads_end", &crate::dnn::BaseConvolutionLayerTraitConst::pads_end(self)) - .field("pad_mode", &crate::dnn::BaseConvolutionLayerTraitConst::pad_mode(self)) - .field("num_output", &crate::dnn::BaseConvolutionLayerTraitConst::num_output(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for ConvolutionLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - - /// Constant methods for [crate::dnn::ConvolutionLayerInt8] - pub trait ConvolutionLayerInt8TraitConst: crate::dnn::BaseConvolutionLayerTraitConst { - fn as_raw_ConvolutionLayerInt8(&self) -> *const c_void; - - #[inline] - fn input_zp(&self) -> i32 { - let ret = unsafe { sys::cv_dnn_ConvolutionLayerInt8_propInput_zp_const(self.as_raw_ConvolutionLayerInt8()) }; - ret - } + #[inline] + fn input_zp(&self) -> i32 { + let ret = unsafe { sys::cv_dnn_ConvolutionLayerInt8_propInput_zp_const(self.as_raw_ConvolutionLayerInt8()) }; + ret + } #[inline] fn output_zp(&self) -> i32 { @@ -5699,20 +5777,50 @@ pub mod dnn { } - pub struct ConvolutionLayerInt8 { - ptr: *mut c_void, + impl Default for ConvolutionLayerInt8 { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ConvolutionLayerInt8 } - - impl Drop for ConvolutionLayerInt8 { + impl std::fmt::Debug for ConvolutionLayerInt8 { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ConvolutionLayerInt8_delete(self.as_raw_mut_ConvolutionLayerInt8()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ConvolutionLayerInt8") + .field("input_zp", &crate::dnn::ConvolutionLayerInt8TraitConst::input_zp(self)) + .field("output_zp", &crate::dnn::ConvolutionLayerInt8TraitConst::output_zp(self)) + .field("input_sc", &crate::dnn::ConvolutionLayerInt8TraitConst::input_sc(self)) + .field("output_sc", &crate::dnn::ConvolutionLayerInt8TraitConst::output_sc(self)) + .field("per_channel", &crate::dnn::ConvolutionLayerInt8TraitConst::per_channel(self)) + .field("use_winograd", &crate::dnn::ConvolutionLayerInt8TraitConst::use_winograd(self)) + .field("kernel", &crate::dnn::BaseConvolutionLayerTraitConst::kernel(self)) + .field("stride", &crate::dnn::BaseConvolutionLayerTraitConst::stride(self)) + .field("pad", &crate::dnn::BaseConvolutionLayerTraitConst::pad(self)) + .field("dilation", &crate::dnn::BaseConvolutionLayerTraitConst::dilation(self)) + .field("adjust_pad", &crate::dnn::BaseConvolutionLayerTraitConst::adjust_pad(self)) + .field("adjust_pads", &crate::dnn::BaseConvolutionLayerTraitConst::adjust_pads(self)) + .field("kernel_size", &crate::dnn::BaseConvolutionLayerTraitConst::kernel_size(self)) + .field("strides", &crate::dnn::BaseConvolutionLayerTraitConst::strides(self)) + .field("dilations", &crate::dnn::BaseConvolutionLayerTraitConst::dilations(self)) + .field("pads_begin", &crate::dnn::BaseConvolutionLayerTraitConst::pads_begin(self)) + .field("pads_end", &crate::dnn::BaseConvolutionLayerTraitConst::pads_end(self)) + .field("pad_mode", &crate::dnn::BaseConvolutionLayerTraitConst::pad_mode(self)) + .field("num_output", &crate::dnn::BaseConvolutionLayerTraitConst::num_output(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ConvolutionLayerInt8 {} + boxed_cast_base! { ConvolutionLayerInt8, core::Algorithm, cv_dnn_ConvolutionLayerInt8_to_Algorithm } + + boxed_cast_base! { ConvolutionLayerInt8, crate::dnn::BaseConvolutionLayer, cv_dnn_ConvolutionLayerInt8_to_BaseConvolutionLayer } + + boxed_cast_base! { ConvolutionLayerInt8, crate::dnn::Layer, cv_dnn_ConvolutionLayerInt8_to_Layer } impl core::AlgorithmTraitConst for ConvolutionLayerInt8 { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5754,68 +5862,40 @@ pub mod dnn { boxed_ref! { ConvolutionLayerInt8, crate::dnn::ConvolutionLayerInt8TraitConst, as_raw_ConvolutionLayerInt8, crate::dnn::ConvolutionLayerInt8Trait, as_raw_mut_ConvolutionLayerInt8 } - impl ConvolutionLayerInt8 { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ConvolutionLayerInt8_defaultNew_const()) } - } + pub struct CorrelationLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { CorrelationLayer } + impl Drop for CorrelationLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ConvolutionLayerInt8_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_CorrelationLayer_delete(self.as_raw_mut_CorrelationLayer()) }; } - } - boxed_cast_base! { ConvolutionLayerInt8, core::Algorithm, cv_dnn_ConvolutionLayerInt8_to_Algorithm } - - boxed_cast_base! { ConvolutionLayerInt8, crate::dnn::BaseConvolutionLayer, cv_dnn_ConvolutionLayerInt8_to_BaseConvolutionLayer } - - boxed_cast_base! { ConvolutionLayerInt8, crate::dnn::Layer, cv_dnn_ConvolutionLayerInt8_to_Layer } + unsafe impl Send for CorrelationLayer {} - impl std::fmt::Debug for ConvolutionLayerInt8 { + impl CorrelationLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ConvolutionLayerInt8") - .field("input_zp", &crate::dnn::ConvolutionLayerInt8TraitConst::input_zp(self)) - .field("output_zp", &crate::dnn::ConvolutionLayerInt8TraitConst::output_zp(self)) - .field("input_sc", &crate::dnn::ConvolutionLayerInt8TraitConst::input_sc(self)) - .field("output_sc", &crate::dnn::ConvolutionLayerInt8TraitConst::output_sc(self)) - .field("per_channel", &crate::dnn::ConvolutionLayerInt8TraitConst::per_channel(self)) - .field("use_winograd", &crate::dnn::ConvolutionLayerInt8TraitConst::use_winograd(self)) - .field("kernel", &crate::dnn::BaseConvolutionLayerTraitConst::kernel(self)) - .field("stride", &crate::dnn::BaseConvolutionLayerTraitConst::stride(self)) - .field("pad", &crate::dnn::BaseConvolutionLayerTraitConst::pad(self)) - .field("dilation", &crate::dnn::BaseConvolutionLayerTraitConst::dilation(self)) - .field("adjust_pad", &crate::dnn::BaseConvolutionLayerTraitConst::adjust_pad(self)) - .field("adjust_pads", &crate::dnn::BaseConvolutionLayerTraitConst::adjust_pads(self)) - .field("kernel_size", &crate::dnn::BaseConvolutionLayerTraitConst::kernel_size(self)) - .field("strides", &crate::dnn::BaseConvolutionLayerTraitConst::strides(self)) - .field("dilations", &crate::dnn::BaseConvolutionLayerTraitConst::dilations(self)) - .field("pads_begin", &crate::dnn::BaseConvolutionLayerTraitConst::pads_begin(self)) - .field("pads_end", &crate::dnn::BaseConvolutionLayerTraitConst::pads_end(self)) - .field("pad_mode", &crate::dnn::BaseConvolutionLayerTraitConst::pad_mode(self)) - .field("num_output", &crate::dnn::BaseConvolutionLayerTraitConst::num_output(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::CorrelationLayer { + let ret = unsafe { sys::cv_dnn_CorrelationLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::CorrelationLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for ConvolutionLayerInt8 { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_CorrelationLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::CorrelationLayer] @@ -5830,20 +5910,29 @@ pub mod dnn { } - pub struct CorrelationLayer { - ptr: *mut c_void, + impl Default for CorrelationLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { CorrelationLayer } - - impl Drop for CorrelationLayer { + impl std::fmt::Debug for CorrelationLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_CorrelationLayer_delete(self.as_raw_mut_CorrelationLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CorrelationLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for CorrelationLayer {} + boxed_cast_base! { CorrelationLayer, core::Algorithm, cv_dnn_CorrelationLayer_to_Algorithm } + + boxed_cast_base! { CorrelationLayer, crate::dnn::Layer, cv_dnn_CorrelationLayer_to_Layer } impl core::AlgorithmTraitConst for CorrelationLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5875,47 +5964,40 @@ pub mod dnn { boxed_ref! { CorrelationLayer, crate::dnn::CorrelationLayerTraitConst, as_raw_CorrelationLayer, crate::dnn::CorrelationLayerTrait, as_raw_mut_CorrelationLayer } - impl CorrelationLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_CorrelationLayer_defaultNew_const()) } - } + pub struct CosLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { CosLayer } + + impl Drop for CosLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_CorrelationLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_CosLayer_delete(self.as_raw_mut_CosLayer()) }; } - } - boxed_cast_base! { CorrelationLayer, core::Algorithm, cv_dnn_CorrelationLayer_to_Algorithm } - - boxed_cast_base! { CorrelationLayer, crate::dnn::Layer, cv_dnn_CorrelationLayer_to_Layer } + unsafe impl Send for CosLayer {} - impl std::fmt::Debug for CorrelationLayer { + impl CosLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CorrelationLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::CosLayer { + let ret = unsafe { sys::cv_dnn_CosLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::CosLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for CorrelationLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_CosLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::CosLayer] @@ -5930,20 +6012,31 @@ pub mod dnn { } - pub struct CosLayer { - ptr: *mut c_void, + impl Default for CosLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { CosLayer } - - impl Drop for CosLayer { + impl std::fmt::Debug for CosLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_CosLayer_delete(self.as_raw_mut_CosLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CosLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for CosLayer {} + boxed_cast_base! { CosLayer, crate::dnn::ActivationLayer, cv_dnn_CosLayer_to_ActivationLayer } + + boxed_cast_base! { CosLayer, core::Algorithm, cv_dnn_CosLayer_to_Algorithm } + + boxed_cast_base! { CosLayer, crate::dnn::Layer, cv_dnn_CosLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for CosLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -5985,49 +6078,40 @@ pub mod dnn { boxed_ref! { CosLayer, crate::dnn::CosLayerTraitConst, as_raw_CosLayer, crate::dnn::CosLayerTrait, as_raw_mut_CosLayer } - impl CosLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_CosLayer_defaultNew_const()) } - } + pub struct CoshLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { CoshLayer } + + impl Drop for CoshLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_CosLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_CoshLayer_delete(self.as_raw_mut_CoshLayer()) }; } - } - boxed_cast_base! { CosLayer, crate::dnn::ActivationLayer, cv_dnn_CosLayer_to_ActivationLayer } - - boxed_cast_base! { CosLayer, core::Algorithm, cv_dnn_CosLayer_to_Algorithm } - - boxed_cast_base! { CosLayer, crate::dnn::Layer, cv_dnn_CosLayer_to_Layer } + unsafe impl Send for CoshLayer {} - impl std::fmt::Debug for CosLayer { + impl CoshLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CosLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::CoshLayer { + let ret = unsafe { sys::cv_dnn_CoshLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::CoshLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for CosLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_CoshLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::CoshLayer] @@ -6042,20 +6126,31 @@ pub mod dnn { } - pub struct CoshLayer { - ptr: *mut c_void, + impl Default for CoshLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { CoshLayer } - - impl Drop for CoshLayer { + impl std::fmt::Debug for CoshLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_CoshLayer_delete(self.as_raw_mut_CoshLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CoshLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for CoshLayer {} + boxed_cast_base! { CoshLayer, crate::dnn::ActivationLayer, cv_dnn_CoshLayer_to_ActivationLayer } + + boxed_cast_base! { CoshLayer, core::Algorithm, cv_dnn_CoshLayer_to_Algorithm } + + boxed_cast_base! { CoshLayer, crate::dnn::Layer, cv_dnn_CoshLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for CoshLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -6097,49 +6192,40 @@ pub mod dnn { boxed_ref! { CoshLayer, crate::dnn::CoshLayerTraitConst, as_raw_CoshLayer, crate::dnn::CoshLayerTrait, as_raw_mut_CoshLayer } - impl CoshLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_CoshLayer_defaultNew_const()) } - } + pub struct CropAndResizeLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { CropAndResizeLayer } + impl Drop for CropAndResizeLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_CoshLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_CropAndResizeLayer_delete(self.as_raw_mut_CropAndResizeLayer()) }; } - } - boxed_cast_base! { CoshLayer, crate::dnn::ActivationLayer, cv_dnn_CoshLayer_to_ActivationLayer } - - boxed_cast_base! { CoshLayer, core::Algorithm, cv_dnn_CoshLayer_to_Algorithm } - - boxed_cast_base! { CoshLayer, crate::dnn::Layer, cv_dnn_CoshLayer_to_Layer } + unsafe impl Send for CropAndResizeLayer {} - impl std::fmt::Debug for CoshLayer { + impl CropAndResizeLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CoshLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::CropAndResizeLayer { + let ret = unsafe { sys::cv_dnn_CropAndResizeLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::CropAndResizeLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for CoshLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_CropAndResizeLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::CropAndResizeLayer] @@ -6154,20 +6240,29 @@ pub mod dnn { } - pub struct CropAndResizeLayer { - ptr: *mut c_void, + impl Default for CropAndResizeLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { CropAndResizeLayer } - - impl Drop for CropAndResizeLayer { + impl std::fmt::Debug for CropAndResizeLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_CropAndResizeLayer_delete(self.as_raw_mut_CropAndResizeLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CropAndResizeLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for CropAndResizeLayer {} + boxed_cast_base! { CropAndResizeLayer, core::Algorithm, cv_dnn_CropAndResizeLayer_to_Algorithm } + + boxed_cast_base! { CropAndResizeLayer, crate::dnn::Layer, cv_dnn_CropAndResizeLayer_to_Layer } impl core::AlgorithmTraitConst for CropAndResizeLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -6199,17 +6294,34 @@ pub mod dnn { boxed_ref! { CropAndResizeLayer, crate::dnn::CropAndResizeLayerTraitConst, as_raw_CropAndResizeLayer, crate::dnn::CropAndResizeLayerTrait, as_raw_mut_CropAndResizeLayer } - impl CropAndResizeLayer { + pub struct CropLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { CropLayer } + + impl Drop for CropLayer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_CropLayer_delete(self.as_raw_mut_CropLayer()) }; + } + } + + unsafe impl Send for CropLayer {} + + impl CropLayer { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_CropAndResizeLayer_defaultNew_const()) } + pub fn default() -> crate::dnn::CropLayer { + let ret = unsafe { sys::cv_dnn_CropLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::CropLayer::opencv_from_extern(ret) }; + ret } #[inline] pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_CropAndResizeLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_CropLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; @@ -6218,30 +6330,6 @@ pub mod dnn { } - boxed_cast_base! { CropAndResizeLayer, core::Algorithm, cv_dnn_CropAndResizeLayer_to_Algorithm } - - boxed_cast_base! { CropAndResizeLayer, crate::dnn::Layer, cv_dnn_CropAndResizeLayer_to_Layer } - - impl std::fmt::Debug for CropAndResizeLayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CropAndResizeLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for CropAndResizeLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - /// Constant methods for [crate::dnn::CropLayer] pub trait CropLayerTraitConst: crate::dnn::LayerTraitConst { fn as_raw_CropLayer(&self) -> *const c_void; @@ -6254,20 +6342,29 @@ pub mod dnn { } - pub struct CropLayer { - ptr: *mut c_void, + impl Default for CropLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { CropLayer } - - impl Drop for CropLayer { + impl std::fmt::Debug for CropLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_CropLayer_delete(self.as_raw_mut_CropLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CropLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for CropLayer {} + boxed_cast_base! { CropLayer, core::Algorithm, cv_dnn_CropLayer_to_Algorithm } + + boxed_cast_base! { CropLayer, crate::dnn::Layer, cv_dnn_CropLayer_to_Layer } impl core::AlgorithmTraitConst for CropLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -6299,49 +6396,42 @@ pub mod dnn { boxed_ref! { CropLayer, crate::dnn::CropLayerTraitConst, as_raw_CropLayer, crate::dnn::CropLayerTrait, as_raw_mut_CropLayer } - impl CropLayer { + pub struct CumSumLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { CumSumLayer } + + impl Drop for CumSumLayer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_CumSumLayer_delete(self.as_raw_mut_CumSumLayer()) }; + } + } + + unsafe impl Send for CumSumLayer {} + + impl CumSumLayer { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_CropLayer_defaultNew_const()) } + pub fn default() -> crate::dnn::CumSumLayer { + let ret = unsafe { sys::cv_dnn_CumSumLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::CumSumLayer::opencv_from_extern(ret) }; + ret } #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_CropLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_CumSumLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { CropLayer, core::Algorithm, cv_dnn_CropLayer_to_Algorithm } - - boxed_cast_base! { CropLayer, crate::dnn::Layer, cv_dnn_CropLayer_to_Layer } - - impl std::fmt::Debug for CropLayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CropLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for CropLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - /// Constant methods for [crate::dnn::CumSumLayer] pub trait CumSumLayerTraitConst: crate::dnn::LayerTraitConst { fn as_raw_CumSumLayer(&self) -> *const c_void; @@ -6378,20 +6468,31 @@ pub mod dnn { } - pub struct CumSumLayer { - ptr: *mut c_void, + impl Default for CumSumLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { CumSumLayer } - - impl Drop for CumSumLayer { + impl std::fmt::Debug for CumSumLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_CumSumLayer_delete(self.as_raw_mut_CumSumLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CumSumLayer") + .field("exclusive", &crate::dnn::CumSumLayerTraitConst::exclusive(self)) + .field("reverse", &crate::dnn::CumSumLayerTraitConst::reverse(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for CumSumLayer {} + boxed_cast_base! { CumSumLayer, core::Algorithm, cv_dnn_CumSumLayer_to_Algorithm } + + boxed_cast_base! { CumSumLayer, crate::dnn::Layer, cv_dnn_CumSumLayer_to_Layer } impl core::AlgorithmTraitConst for CumSumLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -6423,49 +6524,40 @@ pub mod dnn { boxed_ref! { CumSumLayer, crate::dnn::CumSumLayerTraitConst, as_raw_CumSumLayer, crate::dnn::CumSumLayerTrait, as_raw_mut_CumSumLayer } - impl CumSumLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_CumSumLayer_defaultNew_const()) } - } + pub struct DataAugmentationLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { DataAugmentationLayer } + + impl Drop for DataAugmentationLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_CumSumLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_DataAugmentationLayer_delete(self.as_raw_mut_DataAugmentationLayer()) }; } - } - boxed_cast_base! { CumSumLayer, core::Algorithm, cv_dnn_CumSumLayer_to_Algorithm } - - boxed_cast_base! { CumSumLayer, crate::dnn::Layer, cv_dnn_CumSumLayer_to_Layer } + unsafe impl Send for DataAugmentationLayer {} - impl std::fmt::Debug for CumSumLayer { + impl DataAugmentationLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CumSumLayer") - .field("exclusive", &crate::dnn::CumSumLayerTraitConst::exclusive(self)) - .field("reverse", &crate::dnn::CumSumLayerTraitConst::reverse(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::DataAugmentationLayer { + let ret = unsafe { sys::cv_dnn_DataAugmentationLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::DataAugmentationLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for CumSumLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_DataAugmentationLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::DataAugmentationLayer] @@ -6480,20 +6572,29 @@ pub mod dnn { } - pub struct DataAugmentationLayer { - ptr: *mut c_void, + impl Default for DataAugmentationLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { DataAugmentationLayer } - - impl Drop for DataAugmentationLayer { + impl std::fmt::Debug for DataAugmentationLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_DataAugmentationLayer_delete(self.as_raw_mut_DataAugmentationLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DataAugmentationLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for DataAugmentationLayer {} + boxed_cast_base! { DataAugmentationLayer, core::Algorithm, cv_dnn_DataAugmentationLayer_to_Algorithm } + + boxed_cast_base! { DataAugmentationLayer, crate::dnn::Layer, cv_dnn_DataAugmentationLayer_to_Layer } impl core::AlgorithmTraitConst for DataAugmentationLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -6525,47 +6626,40 @@ pub mod dnn { boxed_ref! { DataAugmentationLayer, crate::dnn::DataAugmentationLayerTraitConst, as_raw_DataAugmentationLayer, crate::dnn::DataAugmentationLayerTrait, as_raw_mut_DataAugmentationLayer } - impl DataAugmentationLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_DataAugmentationLayer_defaultNew_const()) } - } + pub struct DeconvolutionLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { DeconvolutionLayer } + + impl Drop for DeconvolutionLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DataAugmentationLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_DeconvolutionLayer_delete(self.as_raw_mut_DeconvolutionLayer()) }; } - } - boxed_cast_base! { DataAugmentationLayer, core::Algorithm, cv_dnn_DataAugmentationLayer_to_Algorithm } - - boxed_cast_base! { DataAugmentationLayer, crate::dnn::Layer, cv_dnn_DataAugmentationLayer_to_Layer } + unsafe impl Send for DeconvolutionLayer {} - impl std::fmt::Debug for DataAugmentationLayer { + impl DeconvolutionLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DataAugmentationLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::DeconvolutionLayer { + let ret = unsafe { sys::cv_dnn_DeconvolutionLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::DeconvolutionLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for DataAugmentationLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_DeconvolutionLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::DeconvolutionLayer] @@ -6580,20 +6674,44 @@ pub mod dnn { } - pub struct DeconvolutionLayer { - ptr: *mut c_void, + impl Default for DeconvolutionLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { DeconvolutionLayer } - - impl Drop for DeconvolutionLayer { + impl std::fmt::Debug for DeconvolutionLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_DeconvolutionLayer_delete(self.as_raw_mut_DeconvolutionLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DeconvolutionLayer") + .field("kernel", &crate::dnn::BaseConvolutionLayerTraitConst::kernel(self)) + .field("stride", &crate::dnn::BaseConvolutionLayerTraitConst::stride(self)) + .field("pad", &crate::dnn::BaseConvolutionLayerTraitConst::pad(self)) + .field("dilation", &crate::dnn::BaseConvolutionLayerTraitConst::dilation(self)) + .field("adjust_pad", &crate::dnn::BaseConvolutionLayerTraitConst::adjust_pad(self)) + .field("adjust_pads", &crate::dnn::BaseConvolutionLayerTraitConst::adjust_pads(self)) + .field("kernel_size", &crate::dnn::BaseConvolutionLayerTraitConst::kernel_size(self)) + .field("strides", &crate::dnn::BaseConvolutionLayerTraitConst::strides(self)) + .field("dilations", &crate::dnn::BaseConvolutionLayerTraitConst::dilations(self)) + .field("pads_begin", &crate::dnn::BaseConvolutionLayerTraitConst::pads_begin(self)) + .field("pads_end", &crate::dnn::BaseConvolutionLayerTraitConst::pads_end(self)) + .field("pad_mode", &crate::dnn::BaseConvolutionLayerTraitConst::pad_mode(self)) + .field("num_output", &crate::dnn::BaseConvolutionLayerTraitConst::num_output(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for DeconvolutionLayer {} + boxed_cast_base! { DeconvolutionLayer, core::Algorithm, cv_dnn_DeconvolutionLayer_to_Algorithm } + + boxed_cast_base! { DeconvolutionLayer, crate::dnn::BaseConvolutionLayer, cv_dnn_DeconvolutionLayer_to_BaseConvolutionLayer } + + boxed_cast_base! { DeconvolutionLayer, crate::dnn::Layer, cv_dnn_DeconvolutionLayer_to_Layer } impl core::AlgorithmTraitConst for DeconvolutionLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -6635,57 +6753,55 @@ pub mod dnn { boxed_ref! { DeconvolutionLayer, crate::dnn::DeconvolutionLayerTraitConst, as_raw_DeconvolutionLayer, crate::dnn::DeconvolutionLayerTrait, as_raw_mut_DeconvolutionLayer } - impl DeconvolutionLayer { + pub struct DepthToSpaceLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { DepthToSpaceLayer } + + impl Drop for DepthToSpaceLayer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_DepthToSpaceLayer_delete(self.as_raw_mut_DepthToSpaceLayer()) }; + } + } + + unsafe impl Send for DepthToSpaceLayer {} + + impl DepthToSpaceLayer { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_DeconvolutionLayer_defaultNew_const()) } + pub fn default() -> crate::dnn::DepthToSpaceLayer { + let ret = unsafe { sys::cv_dnn_DepthToSpaceLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::DepthToSpaceLayer::opencv_from_extern(ret) }; + ret } #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DeconvolutionLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_DepthToSpaceLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { DeconvolutionLayer, core::Algorithm, cv_dnn_DeconvolutionLayer_to_Algorithm } + /// Constant methods for [crate::dnn::DepthToSpaceLayer] + pub trait DepthToSpaceLayerTraitConst: crate::dnn::LayerTraitConst { + fn as_raw_DepthToSpaceLayer(&self) -> *const c_void; - boxed_cast_base! { DeconvolutionLayer, crate::dnn::BaseConvolutionLayer, cv_dnn_DeconvolutionLayer_to_BaseConvolutionLayer } + } - boxed_cast_base! { DeconvolutionLayer, crate::dnn::Layer, cv_dnn_DeconvolutionLayer_to_Layer } + /// Mutable methods for [crate::dnn::DepthToSpaceLayer] + pub trait DepthToSpaceLayerTrait: crate::dnn::DepthToSpaceLayerTraitConst + crate::dnn::LayerTrait { + fn as_raw_mut_DepthToSpaceLayer(&mut self) -> *mut c_void; - impl std::fmt::Debug for DeconvolutionLayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DeconvolutionLayer") - .field("kernel", &crate::dnn::BaseConvolutionLayerTraitConst::kernel(self)) - .field("stride", &crate::dnn::BaseConvolutionLayerTraitConst::stride(self)) - .field("pad", &crate::dnn::BaseConvolutionLayerTraitConst::pad(self)) - .field("dilation", &crate::dnn::BaseConvolutionLayerTraitConst::dilation(self)) - .field("adjust_pad", &crate::dnn::BaseConvolutionLayerTraitConst::adjust_pad(self)) - .field("adjust_pads", &crate::dnn::BaseConvolutionLayerTraitConst::adjust_pads(self)) - .field("kernel_size", &crate::dnn::BaseConvolutionLayerTraitConst::kernel_size(self)) - .field("strides", &crate::dnn::BaseConvolutionLayerTraitConst::strides(self)) - .field("dilations", &crate::dnn::BaseConvolutionLayerTraitConst::dilations(self)) - .field("pads_begin", &crate::dnn::BaseConvolutionLayerTraitConst::pads_begin(self)) - .field("pads_end", &crate::dnn::BaseConvolutionLayerTraitConst::pads_end(self)) - .field("pad_mode", &crate::dnn::BaseConvolutionLayerTraitConst::pad_mode(self)) - .field("num_output", &crate::dnn::BaseConvolutionLayerTraitConst::num_output(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for DeconvolutionLayer { + } + + impl Default for DepthToSpaceLayer { #[inline] /// Forwards to infallible Self::default() fn default() -> Self { @@ -6693,32 +6809,21 @@ pub mod dnn { } } - /// Constant methods for [crate::dnn::DepthToSpaceLayer] - pub trait DepthToSpaceLayerTraitConst: crate::dnn::LayerTraitConst { - fn as_raw_DepthToSpaceLayer(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::dnn::DepthToSpaceLayer] - pub trait DepthToSpaceLayerTrait: crate::dnn::DepthToSpaceLayerTraitConst + crate::dnn::LayerTrait { - fn as_raw_mut_DepthToSpaceLayer(&mut self) -> *mut c_void; - - } - - pub struct DepthToSpaceLayer { - ptr: *mut c_void, - } - - opencv_type_boxed! { DepthToSpaceLayer } - - impl Drop for DepthToSpaceLayer { + impl std::fmt::Debug for DepthToSpaceLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_DepthToSpaceLayer_delete(self.as_raw_mut_DepthToSpaceLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DepthToSpaceLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for DepthToSpaceLayer {} + boxed_cast_base! { DepthToSpaceLayer, core::Algorithm, cv_dnn_DepthToSpaceLayer_to_Algorithm } + + boxed_cast_base! { DepthToSpaceLayer, crate::dnn::Layer, cv_dnn_DepthToSpaceLayer_to_Layer } impl core::AlgorithmTraitConst for DepthToSpaceLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -6750,47 +6855,40 @@ pub mod dnn { boxed_ref! { DepthToSpaceLayer, crate::dnn::DepthToSpaceLayerTraitConst, as_raw_DepthToSpaceLayer, crate::dnn::DepthToSpaceLayerTrait, as_raw_mut_DepthToSpaceLayer } - impl DepthToSpaceLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_DepthToSpaceLayer_defaultNew_const()) } - } + pub struct DequantizeLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { DequantizeLayer } + impl Drop for DequantizeLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DepthToSpaceLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_DequantizeLayer_delete(self.as_raw_mut_DequantizeLayer()) }; } - } - boxed_cast_base! { DepthToSpaceLayer, core::Algorithm, cv_dnn_DepthToSpaceLayer_to_Algorithm } - - boxed_cast_base! { DepthToSpaceLayer, crate::dnn::Layer, cv_dnn_DepthToSpaceLayer_to_Layer } + unsafe impl Send for DequantizeLayer {} - impl std::fmt::Debug for DepthToSpaceLayer { + impl DequantizeLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DepthToSpaceLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::DequantizeLayer { + let ret = unsafe { sys::cv_dnn_DequantizeLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::DequantizeLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for DepthToSpaceLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_DequantizeLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::DequantizeLayer] @@ -6831,20 +6929,31 @@ pub mod dnn { } - pub struct DequantizeLayer { - ptr: *mut c_void, + impl Default for DequantizeLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { DequantizeLayer } - - impl Drop for DequantizeLayer { + impl std::fmt::Debug for DequantizeLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_DequantizeLayer_delete(self.as_raw_mut_DequantizeLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DequantizeLayer") + .field("scales", &crate::dnn::DequantizeLayerTraitConst::scales(self)) + .field("zeropoints", &crate::dnn::DequantizeLayerTraitConst::zeropoints(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for DequantizeLayer {} + boxed_cast_base! { DequantizeLayer, core::Algorithm, cv_dnn_DequantizeLayer_to_Algorithm } + + boxed_cast_base! { DequantizeLayer, crate::dnn::Layer, cv_dnn_DequantizeLayer_to_Layer } impl core::AlgorithmTraitConst for DequantizeLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -6876,49 +6985,91 @@ pub mod dnn { boxed_ref! { DequantizeLayer, crate::dnn::DequantizeLayerTraitConst, as_raw_DequantizeLayer, crate::dnn::DequantizeLayerTrait, as_raw_mut_DequantizeLayer } - impl DequantizeLayer { - /// Creates a default instance of the class by calling the default constructor + /// This class represents high-level API for object detection networks. + /// + /// DetectionModel allows to set params for preprocessing input image. + /// DetectionModel creates net from file with trained weights and config, + /// sets preprocessing input, runs forward pass and return result detections. + /// For DetectionModel SSD, Faster R-CNN, YOLO topologies are supported. + pub struct DetectionModel { + ptr: *mut c_void, + } + + opencv_type_boxed! { DetectionModel } + + impl Drop for DetectionModel { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_DequantizeLayer_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_dnn_DetectionModel_delete(self.as_raw_mut_DetectionModel()) }; } + } + + unsafe impl Send for DetectionModel {} + impl DetectionModel { + /// Create detection model from network represented in one of the supported formats. + /// An order of @p model and @p config arguments does not matter. + /// ## Parameters + /// * model: Binary file contains trained weights. + /// * config: Text file contains network configuration. + /// + /// ## C++ default parameters + /// * config: "" #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + pub fn new(model: &str, config: &str) -> Result { + extern_container_arg!(model); + extern_container_arg!(config); return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DequantizeLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_DetectionModel_DetectionModel_const_StringR_const_StringR(model.opencv_as_extern(), config.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::dnn::DetectionModel::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { DequantizeLayer, core::Algorithm, cv_dnn_DequantizeLayer_to_Algorithm } - - boxed_cast_base! { DequantizeLayer, crate::dnn::Layer, cv_dnn_DequantizeLayer_to_Layer } + /// Create detection model from network represented in one of the supported formats. + /// An order of @p model and @p config arguments does not matter. + /// ## Parameters + /// * model: Binary file contains trained weights. + /// * config: Text file contains network configuration. + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * config: "" + #[inline] + pub fn new_def(model: &str) -> Result { + extern_container_arg!(model); + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_DetectionModel_DetectionModel_const_StringR(model.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::DetectionModel::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for DequantizeLayer { + /// Create model from deep learning network. + /// ## Parameters + /// * network: Net object. #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DequantizeLayer") - .field("scales", &crate::dnn::DequantizeLayerTraitConst::scales(self)) - .field("zeropoints", &crate::dnn::DequantizeLayerTraitConst::zeropoints(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn new_1(network: &impl crate::dnn::NetTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_DetectionModel_DetectionModel_const_NetR(network.as_raw_Net(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::DetectionModel::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for DequantizeLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_DetectionModel_DetectionModel(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::DetectionModel::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::DetectionModel] @@ -7004,26 +7155,22 @@ pub mod dnn { } - /// This class represents high-level API for object detection networks. - /// - /// DetectionModel allows to set params for preprocessing input image. - /// DetectionModel creates net from file with trained weights and config, - /// sets preprocessing input, runs forward pass and return result detections. - /// For DetectionModel SSD, Faster R-CNN, YOLO topologies are supported. - pub struct DetectionModel { - ptr: *mut c_void, + impl Clone for DetectionModel { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_dnn_DetectionModel_implicitClone_const(self.as_raw_DetectionModel())) } + } } - opencv_type_boxed! { DetectionModel } - - impl Drop for DetectionModel { + impl std::fmt::Debug for DetectionModel { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_DetectionModel_delete(self.as_raw_mut_DetectionModel()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DetectionModel") + .finish() } } - unsafe impl Send for DetectionModel {} + boxed_cast_base! { DetectionModel, crate::dnn::Model, cv_dnn_DetectionModel_to_Model } impl crate::dnn::ModelTraitConst for DetectionModel { #[inline] fn as_raw_Model(&self) -> *const c_void { self.as_raw() } @@ -7045,89 +7192,48 @@ pub mod dnn { boxed_ref! { DetectionModel, crate::dnn::DetectionModelTraitConst, as_raw_DetectionModel, crate::dnn::DetectionModelTrait, as_raw_mut_DetectionModel } - impl DetectionModel { - /// Create detection model from network represented in one of the supported formats. - /// An order of @p model and @p config arguments does not matter. - /// ## Parameters - /// * model: Binary file contains trained weights. - /// * config: Text file contains network configuration. - /// - /// ## C++ default parameters - /// * config: "" - #[inline] - pub fn new(model: &str, config: &str) -> Result { - extern_container_arg!(model); - extern_container_arg!(config); - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DetectionModel_DetectionModel_const_StringR_const_StringR(model.opencv_as_extern(), config.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::DetectionModel::opencv_from_extern(ret) }; - Ok(ret) - } + /// Detection output layer. + /// + /// The layer size is: @f$ (1 \times 1 \times N \times 7) @f$ + /// where N is [keep_top_k] parameter multiplied by batch size. Each row is: + /// [image_id, label, confidence, xmin, ymin, xmax, ymax] + /// where image_id is the index of image input in the batch. + pub struct DetectionOutputLayer { + ptr: *mut c_void, + } - /// Create detection model from network represented in one of the supported formats. - /// An order of @p model and @p config arguments does not matter. - /// ## Parameters - /// * model: Binary file contains trained weights. - /// * config: Text file contains network configuration. - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * config: "" + opencv_type_boxed! { DetectionOutputLayer } + + impl Drop for DetectionOutputLayer { #[inline] - pub fn new_def(model: &str) -> Result { - extern_container_arg!(model); - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DetectionModel_DetectionModel_const_StringR(model.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::DetectionModel::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_DetectionOutputLayer_delete(self.as_raw_mut_DetectionOutputLayer()) }; } + } - /// Create model from deep learning network. - /// ## Parameters - /// * network: Net object. + unsafe impl Send for DetectionOutputLayer {} + + impl DetectionOutputLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - pub fn new_1(network: &impl crate::dnn::NetTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DetectionModel_DetectionModel_const_NetR(network.as_raw_Net(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::DetectionModel::opencv_from_extern(ret) }; - Ok(ret) + pub fn default() -> crate::dnn::DetectionOutputLayer { + let ret = unsafe { sys::cv_dnn_DetectionOutputLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::DetectionOutputLayer::opencv_from_extern(ret) }; + ret } #[inline] - pub fn default() -> Result { + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DetectionModel_DetectionModel(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_DetectionOutputLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::DetectionModel::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - impl Clone for DetectionModel { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_dnn_DetectionModel_implicitClone_const(self.as_raw_DetectionModel())) } - } - } - - boxed_cast_base! { DetectionModel, crate::dnn::Model, cv_dnn_DetectionModel_to_Model } - - impl std::fmt::Debug for DetectionModel { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DetectionModel") - .finish() - } - } - /// Constant methods for [crate::dnn::DetectionOutputLayer] pub trait DetectionOutputLayerTraitConst: crate::dnn::LayerTraitConst { fn as_raw_DetectionOutputLayer(&self) -> *const c_void; @@ -7140,26 +7246,29 @@ pub mod dnn { } - /// Detection output layer. - /// - /// The layer size is: @f$ (1 \times 1 \times N \times 7) @f$ - /// where N is [keep_top_k] parameter multiplied by batch size. Each row is: - /// [image_id, label, confidence, xmin, ymin, xmax, ymax] - /// where image_id is the index of image input in the batch. - pub struct DetectionOutputLayer { - ptr: *mut c_void, + impl Default for DetectionOutputLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { DetectionOutputLayer } - - impl Drop for DetectionOutputLayer { + impl std::fmt::Debug for DetectionOutputLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_DetectionOutputLayer_delete(self.as_raw_mut_DetectionOutputLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DetectionOutputLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for DetectionOutputLayer {} + boxed_cast_base! { DetectionOutputLayer, core::Algorithm, cv_dnn_DetectionOutputLayer_to_Algorithm } + + boxed_cast_base! { DetectionOutputLayer, crate::dnn::Layer, cv_dnn_DetectionOutputLayer_to_Layer } impl core::AlgorithmTraitConst for DetectionOutputLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -7191,47 +7300,31 @@ pub mod dnn { boxed_ref! { DetectionOutputLayer, crate::dnn::DetectionOutputLayerTraitConst, as_raw_DetectionOutputLayer, crate::dnn::DetectionOutputLayerTrait, as_raw_mut_DetectionOutputLayer } - impl DetectionOutputLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_DetectionOutputLayer_defaultNew_const()) } - } - - #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DetectionOutputLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + /// This class implements name-value dictionary, values are instances of DictValue. + pub struct Dict { + ptr: *mut c_void, } - boxed_cast_base! { DetectionOutputLayer, core::Algorithm, cv_dnn_DetectionOutputLayer_to_Algorithm } - - boxed_cast_base! { DetectionOutputLayer, crate::dnn::Layer, cv_dnn_DetectionOutputLayer_to_Layer } + opencv_type_boxed! { Dict } - impl std::fmt::Debug for DetectionOutputLayer { + impl Drop for Dict { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DetectionOutputLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_dnn_Dict_delete(self.as_raw_mut_Dict()) }; } } - impl Default for DetectionOutputLayer { + unsafe impl Send for Dict {} + + impl Dict { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::dnn::Dict { + let ret = unsafe { sys::cv_dnn_Dict_defaultNew_const() }; + let ret = unsafe { crate::dnn::Dict::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::dnn::Dict] @@ -7353,22 +7446,22 @@ pub mod dnn { } - /// This class implements name-value dictionary, values are instances of DictValue. - pub struct Dict { - ptr: *mut c_void, + impl Default for Dict { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Dict } - - impl Drop for Dict { + impl std::fmt::Debug for Dict { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_Dict_delete(self.as_raw_mut_Dict()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Dict") + .finish() } } - unsafe impl Send for Dict {} - impl crate::dnn::DictTraitConst for Dict { #[inline] fn as_raw_Dict(&self) -> *const c_void { self.as_raw() } } @@ -7379,101 +7472,182 @@ pub mod dnn { boxed_ref! { Dict, crate::dnn::DictTraitConst, as_raw_Dict, crate::dnn::DictTrait, as_raw_mut_Dict } - impl Dict { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_Dict_defaultNew_const()) } - } - + /// This struct stores the scalar value (or array) of one of the following type: double, cv::String or int64. + /// @todo Maybe int64 is useless because double type exactly stores at least 2^52 integers. + pub struct DictValue { + ptr: *mut c_void, } - impl std::fmt::Debug for Dict { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Dict") - .finish() - } - } + opencv_type_boxed! { DictValue } - impl Default for Dict { + impl Drop for DictValue { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + fn drop(&mut self) { + unsafe { sys::cv_dnn_DictValue_delete(self.as_raw_mut_DictValue()) }; } } - /// Constant methods for [crate::dnn::DictValue] - pub trait DictValueTraitConst { - fn as_raw_DictValue(&self) -> *const c_void; + unsafe impl Send for DictValue {} - /// ## C++ default parameters - /// * idx: -1 + impl DictValue { #[inline] - fn get_str(&self, idx: i32) -> Result { + pub fn copy(r: &impl crate::dnn::DictValueTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DictValue_get_cv_String_const_int(self.as_raw_DictValue(), idx, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_DictValue_DictValue_const_DictValueR(r.as_raw_DictValue(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { String::opencv_from_extern(ret) }; + let ret = unsafe { crate::dnn::DictValue::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [DictValueTraitConst::get_str] function uses the following default values for its arguments: - /// * idx: -1 #[inline] - fn get_str_def(&self) -> Result { + pub fn from_bool(i: bool) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DictValue_get_cv_String_const(self.as_raw_DictValue(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_DictValue_DictValue_bool(i, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { String::opencv_from_extern(ret) }; + let ret = unsafe { crate::dnn::DictValue::opencv_from_extern(ret) }; Ok(ret) } /// ## C++ default parameters - /// * idx: -1 + /// * i: 0 #[inline] - fn get_f64(&self, idx: i32) -> Result { + pub fn from_i64(i: i64) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DictValue_get_double_const_int(self.as_raw_DictValue(), idx, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_DictValue_DictValue_int64_t(i, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::DictValue::opencv_from_extern(ret) }; Ok(ret) } /// ## Note - /// This alternative version of [DictValueTraitConst::get_f64] function uses the following default values for its arguments: - /// * idx: -1 + /// This alternative version of [from_i64] function uses the following default values for its arguments: + /// * i: 0 #[inline] - fn get_f64_def(&self) -> Result { + pub fn from_i64_def() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DictValue_get_double_const(self.as_raw_DictValue(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_DictValue_DictValue(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::DictValue::opencv_from_extern(ret) }; Ok(ret) } - /// ## C++ default parameters - /// * idx: -1 #[inline] - fn get_i32(&self, idx: i32) -> Result { + pub fn from_i32(i: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DictValue_get_int_const_int(self.as_raw_DictValue(), idx, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_DictValue_DictValue_int(i, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::DictValue::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [DictValueTraitConst::get_i32] function uses the following default values for its arguments: - /// * idx: -1 #[inline] - fn get_i32_def(&self) -> Result { + pub fn from_u32(p: u32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DictValue_get_int_const(self.as_raw_DictValue(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_DictValue_DictValue_unsigned_int(p, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::DictValue::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn from_f64(p: f64) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_DictValue_DictValue_double(p, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::DictValue::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn from_str(s: &str) -> Result { + extern_container_arg!(s); + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_DictValue_DictValue_const_charX(s.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::DictValue::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::dnn::DictValue] + pub trait DictValueTraitConst { + fn as_raw_DictValue(&self) -> *const c_void; + + /// ## C++ default parameters + /// * idx: -1 + #[inline] + fn get_str(&self, idx: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_DictValue_get_cv_String_const_int(self.as_raw_DictValue(), idx, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { String::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [DictValueTraitConst::get_str] function uses the following default values for its arguments: + /// * idx: -1 + #[inline] + fn get_str_def(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_DictValue_get_cv_String_const(self.as_raw_DictValue(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { String::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## C++ default parameters + /// * idx: -1 + #[inline] + fn get_f64(&self, idx: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_DictValue_get_double_const_int(self.as_raw_DictValue(), idx, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// ## Note + /// This alternative version of [DictValueTraitConst::get_f64] function uses the following default values for its arguments: + /// * idx: -1 + #[inline] + fn get_f64_def(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_DictValue_get_double_const(self.as_raw_DictValue(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// ## C++ default parameters + /// * idx: -1 + #[inline] + fn get_i32(&self, idx: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_DictValue_get_int_const_int(self.as_raw_DictValue(), idx, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// ## Note + /// This alternative version of [DictValueTraitConst::get_i32] function uses the following default values for its arguments: + /// * idx: -1 + #[inline] + fn get_i32_def(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_DictValue_get_int_const(self.as_raw_DictValue(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -7626,23 +7800,6 @@ pub mod dnn { } - /// This struct stores the scalar value (or array) of one of the following type: double, cv::String or int64. - /// @todo Maybe int64 is useless because double type exactly stores at least 2^52 integers. - pub struct DictValue { - ptr: *mut c_void, - } - - opencv_type_boxed! { DictValue } - - impl Drop for DictValue { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_DictValue_delete(self.as_raw_mut_DictValue()) }; - } - } - - unsafe impl Send for DictValue {} - impl crate::dnn::DictValueTraitConst for DictValue { #[inline] fn as_raw_DictValue(&self) -> *const c_void { self.as_raw() } } @@ -7653,90 +7810,37 @@ pub mod dnn { boxed_ref! { DictValue, crate::dnn::DictValueTraitConst, as_raw_DictValue, crate::dnn::DictValueTrait, as_raw_mut_DictValue } - impl DictValue { - #[inline] - pub fn copy(r: &impl crate::dnn::DictValueTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DictValue_DictValue_const_DictValueR(r.as_raw_DictValue(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::DictValue::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn from_bool(i: bool) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DictValue_DictValue_bool(i, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::DictValue::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## C++ default parameters - /// * i: 0 - #[inline] - pub fn from_i64(i: i64) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DictValue_DictValue_int64_t(i, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::DictValue::opencv_from_extern(ret) }; - Ok(ret) - } + pub struct ELULayer { + ptr: *mut c_void, + } - /// ## Note - /// This alternative version of [from_i64] function uses the following default values for its arguments: - /// * i: 0 - #[inline] - pub fn from_i64_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DictValue_DictValue(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::DictValue::opencv_from_extern(ret) }; - Ok(ret) - } + opencv_type_boxed! { ELULayer } + impl Drop for ELULayer { #[inline] - pub fn from_i32(i: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DictValue_DictValue_int(i, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::DictValue::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ELULayer_delete(self.as_raw_mut_ELULayer()) }; } + } - #[inline] - pub fn from_u32(p: u32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DictValue_DictValue_unsigned_int(p, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::DictValue::opencv_from_extern(ret) }; - Ok(ret) - } + unsafe impl Send for ELULayer {} + impl ELULayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - pub fn from_f64(p: f64) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DictValue_DictValue_double(p, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::DictValue::opencv_from_extern(ret) }; - Ok(ret) + pub fn default() -> crate::dnn::ELULayer { + let ret = unsafe { sys::cv_dnn_ELULayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ELULayer::opencv_from_extern(ret) }; + ret } #[inline] - pub fn from_str(s: &str) -> Result { - extern_container_arg!(s); + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_DictValue_DictValue_const_charX(s.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_ELULayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::DictValue::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } @@ -7766,20 +7870,32 @@ pub mod dnn { } - pub struct ELULayer { - ptr: *mut c_void, + impl Default for ELULayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ELULayer } - - impl Drop for ELULayer { + impl std::fmt::Debug for ELULayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ELULayer_delete(self.as_raw_mut_ELULayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ELULayer") + .field("alpha", &crate::dnn::ELULayerTraitConst::alpha(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ELULayer {} + boxed_cast_base! { ELULayer, crate::dnn::ActivationLayer, cv_dnn_ELULayer_to_ActivationLayer } + + boxed_cast_base! { ELULayer, core::Algorithm, cv_dnn_ELULayer_to_Algorithm } + + boxed_cast_base! { ELULayer, crate::dnn::Layer, cv_dnn_ELULayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for ELULayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -7821,64 +7937,6 @@ pub mod dnn { boxed_ref! { ELULayer, crate::dnn::ELULayerTraitConst, as_raw_ELULayer, crate::dnn::ELULayerTrait, as_raw_mut_ELULayer } - impl ELULayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ELULayer_defaultNew_const()) } - } - - #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ELULayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { ELULayer, crate::dnn::ActivationLayer, cv_dnn_ELULayer_to_ActivationLayer } - - boxed_cast_base! { ELULayer, core::Algorithm, cv_dnn_ELULayer_to_Algorithm } - - boxed_cast_base! { ELULayer, crate::dnn::Layer, cv_dnn_ELULayer_to_Layer } - - impl std::fmt::Debug for ELULayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ELULayer") - .field("alpha", &crate::dnn::ELULayerTraitConst::alpha(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for ELULayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - - /// Constant methods for [crate::dnn::EinsumLayer] - pub trait EinsumLayerTraitConst: crate::dnn::LayerTraitConst { - fn as_raw_EinsumLayer(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::dnn::EinsumLayer] - pub trait EinsumLayerTrait: crate::dnn::EinsumLayerTraitConst + crate::dnn::LayerTrait { - fn as_raw_mut_EinsumLayer(&mut self) -> *mut c_void; - - } - /// This function performs array summation based /// on the Einstein summation convention. The function /// allows for concise expressions of various mathematical @@ -7920,6 +7978,63 @@ pub mod dnn { unsafe impl Send for EinsumLayer {} + impl EinsumLayer { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::dnn::EinsumLayer { + let ret = unsafe { sys::cv_dnn_EinsumLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::EinsumLayer::opencv_from_extern(ret) }; + ret + } + + #[inline] + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_EinsumLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::dnn::EinsumLayer] + pub trait EinsumLayerTraitConst: crate::dnn::LayerTraitConst { + fn as_raw_EinsumLayer(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::dnn::EinsumLayer] + pub trait EinsumLayerTrait: crate::dnn::EinsumLayerTraitConst + crate::dnn::LayerTrait { + fn as_raw_mut_EinsumLayer(&mut self) -> *mut c_void; + + } + + impl Default for EinsumLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } + } + + impl std::fmt::Debug for EinsumLayer { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("EinsumLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() + } + } + + boxed_cast_base! { EinsumLayer, core::Algorithm, cv_dnn_EinsumLayer_to_Algorithm } + + boxed_cast_base! { EinsumLayer, crate::dnn::Layer, cv_dnn_EinsumLayer_to_Layer } + impl core::AlgorithmTraitConst for EinsumLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } } @@ -7950,47 +8065,46 @@ pub mod dnn { boxed_ref! { EinsumLayer, crate::dnn::EinsumLayerTraitConst, as_raw_EinsumLayer, crate::dnn::EinsumLayerTrait, as_raw_mut_EinsumLayer } - impl EinsumLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_EinsumLayer_defaultNew_const()) } - } + /// Element wise operation on inputs + /// + /// Extra optional parameters: + /// - "operation" as string. Values are "sum" (default), "prod", "max", "div", "min" + /// - "coeff" as float array. Specify weights of inputs for SUM operation + /// - "output_channels_mode" as string. Values are "same" (default, all input must have the same layout), "input_0", "input_0_truncate", "max_input_channels" + pub struct EltwiseLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { EltwiseLayer } + impl Drop for EltwiseLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_EinsumLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_EltwiseLayer_delete(self.as_raw_mut_EltwiseLayer()) }; } - } - boxed_cast_base! { EinsumLayer, core::Algorithm, cv_dnn_EinsumLayer_to_Algorithm } - - boxed_cast_base! { EinsumLayer, crate::dnn::Layer, cv_dnn_EinsumLayer_to_Layer } + unsafe impl Send for EltwiseLayer {} - impl std::fmt::Debug for EinsumLayer { + impl EltwiseLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("EinsumLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::EltwiseLayer { + let ret = unsafe { sys::cv_dnn_EltwiseLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::EltwiseLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for EinsumLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_EltwiseLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::EltwiseLayer] @@ -8005,26 +8119,29 @@ pub mod dnn { } - /// Element wise operation on inputs - /// - /// Extra optional parameters: - /// - "operation" as string. Values are "sum" (default), "prod", "max", "div", "min" - /// - "coeff" as float array. Specify weights of inputs for SUM operation - /// - "output_channels_mode" as string. Values are "same" (default, all input must have the same layout), "input_0", "input_0_truncate", "max_input_channels" - pub struct EltwiseLayer { - ptr: *mut c_void, + impl Default for EltwiseLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { EltwiseLayer } - - impl Drop for EltwiseLayer { + impl std::fmt::Debug for EltwiseLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_EltwiseLayer_delete(self.as_raw_mut_EltwiseLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("EltwiseLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for EltwiseLayer {} + boxed_cast_base! { EltwiseLayer, core::Algorithm, cv_dnn_EltwiseLayer_to_Algorithm } + + boxed_cast_base! { EltwiseLayer, crate::dnn::Layer, cv_dnn_EltwiseLayer_to_Layer } impl core::AlgorithmTraitConst for EltwiseLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -8056,47 +8173,40 @@ pub mod dnn { boxed_ref! { EltwiseLayer, crate::dnn::EltwiseLayerTraitConst, as_raw_EltwiseLayer, crate::dnn::EltwiseLayerTrait, as_raw_mut_EltwiseLayer } - impl EltwiseLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_EltwiseLayer_defaultNew_const()) } - } + pub struct EltwiseLayerInt8 { + ptr: *mut c_void, + } + + opencv_type_boxed! { EltwiseLayerInt8 } + impl Drop for EltwiseLayerInt8 { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_EltwiseLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_EltwiseLayerInt8_delete(self.as_raw_mut_EltwiseLayerInt8()) }; } - } - boxed_cast_base! { EltwiseLayer, core::Algorithm, cv_dnn_EltwiseLayer_to_Algorithm } - - boxed_cast_base! { EltwiseLayer, crate::dnn::Layer, cv_dnn_EltwiseLayer_to_Layer } + unsafe impl Send for EltwiseLayerInt8 {} - impl std::fmt::Debug for EltwiseLayer { + impl EltwiseLayerInt8 { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("EltwiseLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::EltwiseLayerInt8 { + let ret = unsafe { sys::cv_dnn_EltwiseLayerInt8_defaultNew_const() }; + let ret = unsafe { crate::dnn::EltwiseLayerInt8::opencv_from_extern(ret) }; + ret } - } - impl Default for EltwiseLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_EltwiseLayerInt8_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::EltwiseLayerInt8] @@ -8111,20 +8221,29 @@ pub mod dnn { } - pub struct EltwiseLayerInt8 { - ptr: *mut c_void, + impl Default for EltwiseLayerInt8 { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { EltwiseLayerInt8 } - - impl Drop for EltwiseLayerInt8 { + impl std::fmt::Debug for EltwiseLayerInt8 { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_EltwiseLayerInt8_delete(self.as_raw_mut_EltwiseLayerInt8()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("EltwiseLayerInt8") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for EltwiseLayerInt8 {} + boxed_cast_base! { EltwiseLayerInt8, core::Algorithm, cv_dnn_EltwiseLayerInt8_to_Algorithm } + + boxed_cast_base! { EltwiseLayerInt8, crate::dnn::Layer, cv_dnn_EltwiseLayerInt8_to_Layer } impl core::AlgorithmTraitConst for EltwiseLayerInt8 { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -8156,47 +8275,40 @@ pub mod dnn { boxed_ref! { EltwiseLayerInt8, crate::dnn::EltwiseLayerInt8TraitConst, as_raw_EltwiseLayerInt8, crate::dnn::EltwiseLayerInt8Trait, as_raw_mut_EltwiseLayerInt8 } - impl EltwiseLayerInt8 { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_EltwiseLayerInt8_defaultNew_const()) } - } + pub struct ErfLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { ErfLayer } + + impl Drop for ErfLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_EltwiseLayerInt8_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ErfLayer_delete(self.as_raw_mut_ErfLayer()) }; } - } - boxed_cast_base! { EltwiseLayerInt8, core::Algorithm, cv_dnn_EltwiseLayerInt8_to_Algorithm } - - boxed_cast_base! { EltwiseLayerInt8, crate::dnn::Layer, cv_dnn_EltwiseLayerInt8_to_Layer } + unsafe impl Send for ErfLayer {} - impl std::fmt::Debug for EltwiseLayerInt8 { + impl ErfLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("EltwiseLayerInt8") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::ErfLayer { + let ret = unsafe { sys::cv_dnn_ErfLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ErfLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for EltwiseLayerInt8 { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ErfLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ErfLayer] @@ -8211,20 +8323,31 @@ pub mod dnn { } - pub struct ErfLayer { - ptr: *mut c_void, + impl Default for ErfLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ErfLayer } - - impl Drop for ErfLayer { + impl std::fmt::Debug for ErfLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ErfLayer_delete(self.as_raw_mut_ErfLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ErfLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ErfLayer {} + boxed_cast_base! { ErfLayer, crate::dnn::ActivationLayer, cv_dnn_ErfLayer_to_ActivationLayer } + + boxed_cast_base! { ErfLayer, core::Algorithm, cv_dnn_ErfLayer_to_Algorithm } + + boxed_cast_base! { ErfLayer, crate::dnn::Layer, cv_dnn_ErfLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for ErfLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -8266,49 +8389,40 @@ pub mod dnn { boxed_ref! { ErfLayer, crate::dnn::ErfLayerTraitConst, as_raw_ErfLayer, crate::dnn::ErfLayerTrait, as_raw_mut_ErfLayer } - impl ErfLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ErfLayer_defaultNew_const()) } - } + pub struct ExpLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { ExpLayer } + + impl Drop for ExpLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ErfLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ExpLayer_delete(self.as_raw_mut_ExpLayer()) }; } - } - boxed_cast_base! { ErfLayer, crate::dnn::ActivationLayer, cv_dnn_ErfLayer_to_ActivationLayer } - - boxed_cast_base! { ErfLayer, core::Algorithm, cv_dnn_ErfLayer_to_Algorithm } - - boxed_cast_base! { ErfLayer, crate::dnn::Layer, cv_dnn_ErfLayer_to_Layer } + unsafe impl Send for ExpLayer {} - impl std::fmt::Debug for ErfLayer { + impl ExpLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ErfLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::ExpLayer { + let ret = unsafe { sys::cv_dnn_ExpLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ExpLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for ErfLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ExpLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ExpLayer] @@ -8359,20 +8473,34 @@ pub mod dnn { } - pub struct ExpLayer { - ptr: *mut c_void, + impl Default for ExpLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ExpLayer } - - impl Drop for ExpLayer { + impl std::fmt::Debug for ExpLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ExpLayer_delete(self.as_raw_mut_ExpLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ExpLayer") + .field("base", &crate::dnn::ExpLayerTraitConst::base(self)) + .field("scale", &crate::dnn::ExpLayerTraitConst::scale(self)) + .field("shift", &crate::dnn::ExpLayerTraitConst::shift(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ExpLayer {} + boxed_cast_base! { ExpLayer, crate::dnn::ActivationLayer, cv_dnn_ExpLayer_to_ActivationLayer } + + boxed_cast_base! { ExpLayer, core::Algorithm, cv_dnn_ExpLayer_to_Algorithm } + + boxed_cast_base! { ExpLayer, crate::dnn::Layer, cv_dnn_ExpLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for ExpLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -8414,52 +8542,40 @@ pub mod dnn { boxed_ref! { ExpLayer, crate::dnn::ExpLayerTraitConst, as_raw_ExpLayer, crate::dnn::ExpLayerTrait, as_raw_mut_ExpLayer } - impl ExpLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ExpLayer_defaultNew_const()) } - } + pub struct ExpandLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { ExpandLayer } + impl Drop for ExpandLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ExpLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ExpandLayer_delete(self.as_raw_mut_ExpandLayer()) }; } - } - boxed_cast_base! { ExpLayer, crate::dnn::ActivationLayer, cv_dnn_ExpLayer_to_ActivationLayer } - - boxed_cast_base! { ExpLayer, core::Algorithm, cv_dnn_ExpLayer_to_Algorithm } - - boxed_cast_base! { ExpLayer, crate::dnn::Layer, cv_dnn_ExpLayer_to_Layer } + unsafe impl Send for ExpandLayer {} - impl std::fmt::Debug for ExpLayer { + impl ExpandLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ExpLayer") - .field("base", &crate::dnn::ExpLayerTraitConst::base(self)) - .field("scale", &crate::dnn::ExpLayerTraitConst::scale(self)) - .field("shift", &crate::dnn::ExpLayerTraitConst::shift(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::ExpandLayer { + let ret = unsafe { sys::cv_dnn_ExpandLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ExpandLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for ExpLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ExpandLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ExpandLayer] @@ -8474,20 +8590,29 @@ pub mod dnn { } - pub struct ExpandLayer { - ptr: *mut c_void, + impl Default for ExpandLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ExpandLayer } - - impl Drop for ExpandLayer { + impl std::fmt::Debug for ExpandLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ExpandLayer_delete(self.as_raw_mut_ExpandLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ExpandLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ExpandLayer {} + boxed_cast_base! { ExpandLayer, core::Algorithm, cv_dnn_ExpandLayer_to_Algorithm } + + boxed_cast_base! { ExpandLayer, crate::dnn::Layer, cv_dnn_ExpandLayer_to_Layer } impl core::AlgorithmTraitConst for ExpandLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -8519,42 +8644,55 @@ pub mod dnn { boxed_ref! { ExpandLayer, crate::dnn::ExpandLayerTraitConst, as_raw_ExpandLayer, crate::dnn::ExpandLayerTrait, as_raw_mut_ExpandLayer } - impl ExpandLayer { + pub struct FlattenLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { FlattenLayer } + + impl Drop for FlattenLayer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_FlattenLayer_delete(self.as_raw_mut_FlattenLayer()) }; + } + } + + unsafe impl Send for FlattenLayer {} + + impl FlattenLayer { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ExpandLayer_defaultNew_const()) } + pub fn default() -> crate::dnn::FlattenLayer { + let ret = unsafe { sys::cv_dnn_FlattenLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::FlattenLayer::opencv_from_extern(ret) }; + ret } #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ExpandLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_FlattenLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { ExpandLayer, core::Algorithm, cv_dnn_ExpandLayer_to_Algorithm } + /// Constant methods for [crate::dnn::FlattenLayer] + pub trait FlattenLayerTraitConst: crate::dnn::LayerTraitConst { + fn as_raw_FlattenLayer(&self) -> *const c_void; - boxed_cast_base! { ExpandLayer, crate::dnn::Layer, cv_dnn_ExpandLayer_to_Layer } + } + + /// Mutable methods for [crate::dnn::FlattenLayer] + pub trait FlattenLayerTrait: crate::dnn::FlattenLayerTraitConst + crate::dnn::LayerTrait { + fn as_raw_mut_FlattenLayer(&mut self) -> *mut c_void; - impl std::fmt::Debug for ExpandLayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ExpandLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } } - impl Default for ExpandLayer { + impl Default for FlattenLayer { #[inline] /// Forwards to infallible Self::default() fn default() -> Self { @@ -8562,32 +8700,21 @@ pub mod dnn { } } - /// Constant methods for [crate::dnn::FlattenLayer] - pub trait FlattenLayerTraitConst: crate::dnn::LayerTraitConst { - fn as_raw_FlattenLayer(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::dnn::FlattenLayer] - pub trait FlattenLayerTrait: crate::dnn::FlattenLayerTraitConst + crate::dnn::LayerTrait { - fn as_raw_mut_FlattenLayer(&mut self) -> *mut c_void; - - } - - pub struct FlattenLayer { - ptr: *mut c_void, - } - - opencv_type_boxed! { FlattenLayer } - - impl Drop for FlattenLayer { + impl std::fmt::Debug for FlattenLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_FlattenLayer_delete(self.as_raw_mut_FlattenLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FlattenLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for FlattenLayer {} + boxed_cast_base! { FlattenLayer, core::Algorithm, cv_dnn_FlattenLayer_to_Algorithm } + + boxed_cast_base! { FlattenLayer, crate::dnn::Layer, cv_dnn_FlattenLayer_to_Layer } impl core::AlgorithmTraitConst for FlattenLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -8619,47 +8746,40 @@ pub mod dnn { boxed_ref! { FlattenLayer, crate::dnn::FlattenLayerTraitConst, as_raw_FlattenLayer, crate::dnn::FlattenLayerTrait, as_raw_mut_FlattenLayer } - impl FlattenLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_FlattenLayer_defaultNew_const()) } - } + pub struct FloorLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { FloorLayer } + + impl Drop for FloorLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_FlattenLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_FloorLayer_delete(self.as_raw_mut_FloorLayer()) }; } - } - boxed_cast_base! { FlattenLayer, core::Algorithm, cv_dnn_FlattenLayer_to_Algorithm } - - boxed_cast_base! { FlattenLayer, crate::dnn::Layer, cv_dnn_FlattenLayer_to_Layer } + unsafe impl Send for FloorLayer {} - impl std::fmt::Debug for FlattenLayer { + impl FloorLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FlattenLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::FloorLayer { + let ret = unsafe { sys::cv_dnn_FloorLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::FloorLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for FlattenLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_FloorLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::FloorLayer] @@ -8674,20 +8794,31 @@ pub mod dnn { } - pub struct FloorLayer { - ptr: *mut c_void, + impl Default for FloorLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { FloorLayer } - - impl Drop for FloorLayer { + impl std::fmt::Debug for FloorLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_FloorLayer_delete(self.as_raw_mut_FloorLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FloorLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for FloorLayer {} + boxed_cast_base! { FloorLayer, crate::dnn::ActivationLayer, cv_dnn_FloorLayer_to_ActivationLayer } + + boxed_cast_base! { FloorLayer, core::Algorithm, cv_dnn_FloorLayer_to_Algorithm } + + boxed_cast_base! { FloorLayer, crate::dnn::Layer, cv_dnn_FloorLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for FloorLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -8729,49 +8860,40 @@ pub mod dnn { boxed_ref! { FloorLayer, crate::dnn::FloorLayerTraitConst, as_raw_FloorLayer, crate::dnn::FloorLayerTrait, as_raw_mut_FloorLayer } - impl FloorLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_FloorLayer_defaultNew_const()) } - } + pub struct FlowWarpLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { FlowWarpLayer } + + impl Drop for FlowWarpLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_FloorLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_FlowWarpLayer_delete(self.as_raw_mut_FlowWarpLayer()) }; } - } - boxed_cast_base! { FloorLayer, crate::dnn::ActivationLayer, cv_dnn_FloorLayer_to_ActivationLayer } - - boxed_cast_base! { FloorLayer, core::Algorithm, cv_dnn_FloorLayer_to_Algorithm } - - boxed_cast_base! { FloorLayer, crate::dnn::Layer, cv_dnn_FloorLayer_to_Layer } + unsafe impl Send for FlowWarpLayer {} - impl std::fmt::Debug for FloorLayer { + impl FlowWarpLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FloorLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::FlowWarpLayer { + let ret = unsafe { sys::cv_dnn_FlowWarpLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::FlowWarpLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for FloorLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_FlowWarpLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::FlowWarpLayer] @@ -8786,20 +8908,29 @@ pub mod dnn { } - pub struct FlowWarpLayer { - ptr: *mut c_void, + impl Default for FlowWarpLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { FlowWarpLayer } - - impl Drop for FlowWarpLayer { + impl std::fmt::Debug for FlowWarpLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_FlowWarpLayer_delete(self.as_raw_mut_FlowWarpLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FlowWarpLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for FlowWarpLayer {} + boxed_cast_base! { FlowWarpLayer, core::Algorithm, cv_dnn_FlowWarpLayer_to_Algorithm } + + boxed_cast_base! { FlowWarpLayer, crate::dnn::Layer, cv_dnn_FlowWarpLayer_to_Layer } impl core::AlgorithmTraitConst for FlowWarpLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -8831,61 +8962,6 @@ pub mod dnn { boxed_ref! { FlowWarpLayer, crate::dnn::FlowWarpLayerTraitConst, as_raw_FlowWarpLayer, crate::dnn::FlowWarpLayerTrait, as_raw_mut_FlowWarpLayer } - impl FlowWarpLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_FlowWarpLayer_defaultNew_const()) } - } - - #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_FlowWarpLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { FlowWarpLayer, core::Algorithm, cv_dnn_FlowWarpLayer_to_Algorithm } - - boxed_cast_base! { FlowWarpLayer, crate::dnn::Layer, cv_dnn_FlowWarpLayer_to_Layer } - - impl std::fmt::Debug for FlowWarpLayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FlowWarpLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for FlowWarpLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - - /// Constant methods for [crate::dnn::GRULayer] - pub trait GRULayerTraitConst: crate::dnn::LayerTraitConst { - fn as_raw_GRULayer(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::dnn::GRULayer] - pub trait GRULayerTrait: crate::dnn::GRULayerTraitConst + crate::dnn::LayerTrait { - fn as_raw_mut_GRULayer(&mut self) -> *mut c_void; - - } - /// GRU recurrent one-layer /// /// Accepts input sequence and computes the final hidden state for each element in the batch. @@ -8927,41 +9003,13 @@ pub mod dnn { unsafe impl Send for GRULayer {} - impl core::AlgorithmTraitConst for GRULayer { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for GRULayer { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { GRULayer, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::dnn::LayerTraitConst for GRULayer { - #[inline] fn as_raw_Layer(&self) -> *const c_void { self.as_raw() } - } - - impl crate::dnn::LayerTrait for GRULayer { - #[inline] fn as_raw_mut_Layer(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { GRULayer, crate::dnn::LayerTraitConst, as_raw_Layer, crate::dnn::LayerTrait, as_raw_mut_Layer } - - impl crate::dnn::GRULayerTraitConst for GRULayer { - #[inline] fn as_raw_GRULayer(&self) -> *const c_void { self.as_raw() } - } - - impl crate::dnn::GRULayerTrait for GRULayer { - #[inline] fn as_raw_mut_GRULayer(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { GRULayer, crate::dnn::GRULayerTraitConst, as_raw_GRULayer, crate::dnn::GRULayerTrait, as_raw_mut_GRULayer } - impl GRULayer { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_GRULayer_defaultNew_const()) } + pub fn default() -> crate::dnn::GRULayer { + let ret = unsafe { sys::cv_dnn_GRULayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::GRULayer::opencv_from_extern(ret) }; + ret } /// Creates instance of GRU layer @@ -8977,9 +9025,25 @@ pub mod dnn { } - boxed_cast_base! { GRULayer, core::Algorithm, cv_dnn_GRULayer_to_Algorithm } + /// Constant methods for [crate::dnn::GRULayer] + pub trait GRULayerTraitConst: crate::dnn::LayerTraitConst { + fn as_raw_GRULayer(&self) -> *const c_void; - boxed_cast_base! { GRULayer, crate::dnn::Layer, cv_dnn_GRULayer_to_Layer } + } + + /// Mutable methods for [crate::dnn::GRULayer] + pub trait GRULayerTrait: crate::dnn::GRULayerTraitConst + crate::dnn::LayerTrait { + fn as_raw_mut_GRULayer(&mut self) -> *mut c_void; + + } + + impl Default for GRULayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } + } impl std::fmt::Debug for GRULayer { #[inline] @@ -8993,26 +9057,40 @@ pub mod dnn { } } - impl Default for GRULayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } + boxed_cast_base! { GRULayer, core::Algorithm, cv_dnn_GRULayer_to_Algorithm } + + boxed_cast_base! { GRULayer, crate::dnn::Layer, cv_dnn_GRULayer_to_Layer } + + impl core::AlgorithmTraitConst for GRULayer { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } } - /// Constant methods for [crate::dnn::GatherElementsLayer] - pub trait GatherElementsLayerTraitConst: crate::dnn::LayerTraitConst { - fn as_raw_GatherElementsLayer(&self) -> *const c_void; + impl core::AlgorithmTrait for GRULayer { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { GRULayer, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + impl crate::dnn::LayerTraitConst for GRULayer { + #[inline] fn as_raw_Layer(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::dnn::GatherElementsLayer] - pub trait GatherElementsLayerTrait: crate::dnn::GatherElementsLayerTraitConst + crate::dnn::LayerTrait { - fn as_raw_mut_GatherElementsLayer(&mut self) -> *mut c_void; + impl crate::dnn::LayerTrait for GRULayer { + #[inline] fn as_raw_mut_Layer(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { GRULayer, crate::dnn::LayerTraitConst, as_raw_Layer, crate::dnn::LayerTrait, as_raw_mut_Layer } + impl crate::dnn::GRULayerTraitConst for GRULayer { + #[inline] fn as_raw_GRULayer(&self) -> *const c_void { self.as_raw() } } + impl crate::dnn::GRULayerTrait for GRULayer { + #[inline] fn as_raw_mut_GRULayer(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { GRULayer, crate::dnn::GRULayerTraitConst, as_raw_GRULayer, crate::dnn::GRULayerTrait, as_raw_mut_GRULayer } + /// GatherElements layer /// GatherElements takes two inputs data and indices of the same rank r >= 1 and an optional attribute axis and works such that: /// output[i][j][k] = data[index[i][j][k]][j][k] if axis = 0 and r = 3 @@ -9037,6 +9115,63 @@ pub mod dnn { unsafe impl Send for GatherElementsLayer {} + impl GatherElementsLayer { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::dnn::GatherElementsLayer { + let ret = unsafe { sys::cv_dnn_GatherElementsLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::GatherElementsLayer::opencv_from_extern(ret) }; + ret + } + + #[inline] + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_GatherElementsLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::dnn::GatherElementsLayer] + pub trait GatherElementsLayerTraitConst: crate::dnn::LayerTraitConst { + fn as_raw_GatherElementsLayer(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::dnn::GatherElementsLayer] + pub trait GatherElementsLayerTrait: crate::dnn::GatherElementsLayerTraitConst + crate::dnn::LayerTrait { + fn as_raw_mut_GatherElementsLayer(&mut self) -> *mut c_void; + + } + + impl Default for GatherElementsLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } + } + + impl std::fmt::Debug for GatherElementsLayer { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GatherElementsLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() + } + } + + boxed_cast_base! { GatherElementsLayer, core::Algorithm, cv_dnn_GatherElementsLayer_to_Algorithm } + + boxed_cast_base! { GatherElementsLayer, crate::dnn::Layer, cv_dnn_GatherElementsLayer_to_Layer } + impl core::AlgorithmTraitConst for GatherElementsLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } } @@ -9067,47 +9202,41 @@ pub mod dnn { boxed_ref! { GatherElementsLayer, crate::dnn::GatherElementsLayerTraitConst, as_raw_GatherElementsLayer, crate::dnn::GatherElementsLayerTrait, as_raw_mut_GatherElementsLayer } - impl GatherElementsLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_GatherElementsLayer_defaultNew_const()) } - } + /// Gather layer + pub struct GatherLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { GatherLayer } + impl Drop for GatherLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_GatherElementsLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_GatherLayer_delete(self.as_raw_mut_GatherLayer()) }; } - } - boxed_cast_base! { GatherElementsLayer, core::Algorithm, cv_dnn_GatherElementsLayer_to_Algorithm } - - boxed_cast_base! { GatherElementsLayer, crate::dnn::Layer, cv_dnn_GatherElementsLayer_to_Layer } + unsafe impl Send for GatherLayer {} - impl std::fmt::Debug for GatherElementsLayer { + impl GatherLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GatherElementsLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::GatherLayer { + let ret = unsafe { sys::cv_dnn_GatherLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::GatherLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for GatherElementsLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_GatherLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::GatherLayer] @@ -9122,21 +9251,29 @@ pub mod dnn { } - /// Gather layer - pub struct GatherLayer { - ptr: *mut c_void, + impl Default for GatherLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { GatherLayer } - - impl Drop for GatherLayer { + impl std::fmt::Debug for GatherLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_GatherLayer_delete(self.as_raw_mut_GatherLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GatherLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for GatherLayer {} + boxed_cast_base! { GatherLayer, core::Algorithm, cv_dnn_GatherLayer_to_Algorithm } + + boxed_cast_base! { GatherLayer, crate::dnn::Layer, cv_dnn_GatherLayer_to_Layer } impl core::AlgorithmTraitConst for GatherLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -9168,47 +9305,40 @@ pub mod dnn { boxed_ref! { GatherLayer, crate::dnn::GatherLayerTraitConst, as_raw_GatherLayer, crate::dnn::GatherLayerTrait, as_raw_mut_GatherLayer } - impl GatherLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_GatherLayer_defaultNew_const()) } - } + pub struct GeluApproximationLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { GeluApproximationLayer } + + impl Drop for GeluApproximationLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_GatherLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_GeluApproximationLayer_delete(self.as_raw_mut_GeluApproximationLayer()) }; } - } - boxed_cast_base! { GatherLayer, core::Algorithm, cv_dnn_GatherLayer_to_Algorithm } - - boxed_cast_base! { GatherLayer, crate::dnn::Layer, cv_dnn_GatherLayer_to_Layer } + unsafe impl Send for GeluApproximationLayer {} - impl std::fmt::Debug for GatherLayer { + impl GeluApproximationLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GatherLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::GeluApproximationLayer { + let ret = unsafe { sys::cv_dnn_GeluApproximationLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::GeluApproximationLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for GatherLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_GeluApproximationLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::GeluApproximationLayer] @@ -9223,20 +9353,31 @@ pub mod dnn { } - pub struct GeluApproximationLayer { - ptr: *mut c_void, + impl Default for GeluApproximationLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { GeluApproximationLayer } - - impl Drop for GeluApproximationLayer { + impl std::fmt::Debug for GeluApproximationLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_GeluApproximationLayer_delete(self.as_raw_mut_GeluApproximationLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GeluApproximationLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for GeluApproximationLayer {} + boxed_cast_base! { GeluApproximationLayer, crate::dnn::ActivationLayer, cv_dnn_GeluApproximationLayer_to_ActivationLayer } + + boxed_cast_base! { GeluApproximationLayer, core::Algorithm, cv_dnn_GeluApproximationLayer_to_Algorithm } + + boxed_cast_base! { GeluApproximationLayer, crate::dnn::Layer, cv_dnn_GeluApproximationLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for GeluApproximationLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -9278,49 +9419,40 @@ pub mod dnn { boxed_ref! { GeluApproximationLayer, crate::dnn::GeluApproximationLayerTraitConst, as_raw_GeluApproximationLayer, crate::dnn::GeluApproximationLayerTrait, as_raw_mut_GeluApproximationLayer } - impl GeluApproximationLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_GeluApproximationLayer_defaultNew_const()) } - } + pub struct GeluLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { GeluLayer } + + impl Drop for GeluLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_GeluApproximationLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_GeluLayer_delete(self.as_raw_mut_GeluLayer()) }; } - } - boxed_cast_base! { GeluApproximationLayer, crate::dnn::ActivationLayer, cv_dnn_GeluApproximationLayer_to_ActivationLayer } - - boxed_cast_base! { GeluApproximationLayer, core::Algorithm, cv_dnn_GeluApproximationLayer_to_Algorithm } - - boxed_cast_base! { GeluApproximationLayer, crate::dnn::Layer, cv_dnn_GeluApproximationLayer_to_Layer } + unsafe impl Send for GeluLayer {} - impl std::fmt::Debug for GeluApproximationLayer { + impl GeluLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GeluApproximationLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::GeluLayer { + let ret = unsafe { sys::cv_dnn_GeluLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::GeluLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for GeluApproximationLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_GeluLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::GeluLayer] @@ -9335,20 +9467,31 @@ pub mod dnn { } - pub struct GeluLayer { - ptr: *mut c_void, + impl Default for GeluLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { GeluLayer } - - impl Drop for GeluLayer { + impl std::fmt::Debug for GeluLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_GeluLayer_delete(self.as_raw_mut_GeluLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GeluLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for GeluLayer {} + boxed_cast_base! { GeluLayer, crate::dnn::ActivationLayer, cv_dnn_GeluLayer_to_ActivationLayer } + + boxed_cast_base! { GeluLayer, core::Algorithm, cv_dnn_GeluLayer_to_Algorithm } + + boxed_cast_base! { GeluLayer, crate::dnn::Layer, cv_dnn_GeluLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for GeluLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -9390,49 +9533,40 @@ pub mod dnn { boxed_ref! { GeluLayer, crate::dnn::GeluLayerTraitConst, as_raw_GeluLayer, crate::dnn::GeluLayerTrait, as_raw_mut_GeluLayer } - impl GeluLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_GeluLayer_defaultNew_const()) } - } + pub struct GemmLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { GemmLayer } + impl Drop for GemmLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_GeluLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_GemmLayer_delete(self.as_raw_mut_GemmLayer()) }; } - } - boxed_cast_base! { GeluLayer, crate::dnn::ActivationLayer, cv_dnn_GeluLayer_to_ActivationLayer } - - boxed_cast_base! { GeluLayer, core::Algorithm, cv_dnn_GeluLayer_to_Algorithm } - - boxed_cast_base! { GeluLayer, crate::dnn::Layer, cv_dnn_GeluLayer_to_Layer } + unsafe impl Send for GemmLayer {} - impl std::fmt::Debug for GeluLayer { + impl GemmLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GeluLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::GemmLayer { + let ret = unsafe { sys::cv_dnn_GemmLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::GemmLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for GeluLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_GemmLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::GemmLayer] @@ -9495,20 +9629,33 @@ pub mod dnn { } - pub struct GemmLayer { - ptr: *mut c_void, + impl Default for GemmLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { GemmLayer } - - impl Drop for GemmLayer { + impl std::fmt::Debug for GemmLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_GemmLayer_delete(self.as_raw_mut_GemmLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GemmLayer") + .field("trans_a", &crate::dnn::GemmLayerTraitConst::trans_a(self)) + .field("trans_b", &crate::dnn::GemmLayerTraitConst::trans_b(self)) + .field("alpha", &crate::dnn::GemmLayerTraitConst::alpha(self)) + .field("beta", &crate::dnn::GemmLayerTraitConst::beta(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for GemmLayer {} + boxed_cast_base! { GemmLayer, core::Algorithm, cv_dnn_GemmLayer_to_Algorithm } + + boxed_cast_base! { GemmLayer, crate::dnn::Layer, cv_dnn_GemmLayer_to_Layer } impl core::AlgorithmTraitConst for GemmLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -9540,51 +9687,40 @@ pub mod dnn { boxed_ref! { GemmLayer, crate::dnn::GemmLayerTraitConst, as_raw_GemmLayer, crate::dnn::GemmLayerTrait, as_raw_mut_GemmLayer } - impl GemmLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_GemmLayer_defaultNew_const()) } - } - - #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_GemmLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + pub struct GroupNormLayer { + ptr: *mut c_void, } - boxed_cast_base! { GemmLayer, core::Algorithm, cv_dnn_GemmLayer_to_Algorithm } - - boxed_cast_base! { GemmLayer, crate::dnn::Layer, cv_dnn_GemmLayer_to_Layer } + opencv_type_boxed! { GroupNormLayer } - impl std::fmt::Debug for GemmLayer { + impl Drop for GroupNormLayer { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GemmLayer") - .field("trans_a", &crate::dnn::GemmLayerTraitConst::trans_a(self)) - .field("trans_b", &crate::dnn::GemmLayerTraitConst::trans_b(self)) - .field("alpha", &crate::dnn::GemmLayerTraitConst::alpha(self)) - .field("beta", &crate::dnn::GemmLayerTraitConst::beta(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_dnn_GroupNormLayer_delete(self.as_raw_mut_GroupNormLayer()) }; } } - impl Default for GemmLayer { + unsafe impl Send for GroupNormLayer {} + + impl GroupNormLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::dnn::GroupNormLayer { + let ret = unsafe { sys::cv_dnn_GroupNormLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::GroupNormLayer::opencv_from_extern(ret) }; + ret + } + + #[inline] + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_GroupNormLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::GroupNormLayer] @@ -9599,20 +9735,29 @@ pub mod dnn { } - pub struct GroupNormLayer { - ptr: *mut c_void, + impl Default for GroupNormLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { GroupNormLayer } - - impl Drop for GroupNormLayer { + impl std::fmt::Debug for GroupNormLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_GroupNormLayer_delete(self.as_raw_mut_GroupNormLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GroupNormLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for GroupNormLayer {} + boxed_cast_base! { GroupNormLayer, core::Algorithm, cv_dnn_GroupNormLayer_to_Algorithm } + + boxed_cast_base! { GroupNormLayer, crate::dnn::Layer, cv_dnn_GroupNormLayer_to_Layer } impl core::AlgorithmTraitConst for GroupNormLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -9644,47 +9789,40 @@ pub mod dnn { boxed_ref! { GroupNormLayer, crate::dnn::GroupNormLayerTraitConst, as_raw_GroupNormLayer, crate::dnn::GroupNormLayerTrait, as_raw_mut_GroupNormLayer } - impl GroupNormLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_GroupNormLayer_defaultNew_const()) } - } + pub struct HardSigmoidLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { HardSigmoidLayer } + impl Drop for HardSigmoidLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_GroupNormLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_HardSigmoidLayer_delete(self.as_raw_mut_HardSigmoidLayer()) }; } - } - boxed_cast_base! { GroupNormLayer, core::Algorithm, cv_dnn_GroupNormLayer_to_Algorithm } - - boxed_cast_base! { GroupNormLayer, crate::dnn::Layer, cv_dnn_GroupNormLayer_to_Layer } + unsafe impl Send for HardSigmoidLayer {} - impl std::fmt::Debug for GroupNormLayer { + impl HardSigmoidLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GroupNormLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::HardSigmoidLayer { + let ret = unsafe { sys::cv_dnn_HardSigmoidLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::HardSigmoidLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for GroupNormLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_HardSigmoidLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::HardSigmoidLayer] @@ -9723,20 +9861,33 @@ pub mod dnn { } - pub struct HardSigmoidLayer { - ptr: *mut c_void, + impl Default for HardSigmoidLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { HardSigmoidLayer } - - impl Drop for HardSigmoidLayer { + impl std::fmt::Debug for HardSigmoidLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_HardSigmoidLayer_delete(self.as_raw_mut_HardSigmoidLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("HardSigmoidLayer") + .field("alpha", &crate::dnn::HardSigmoidLayerTraitConst::alpha(self)) + .field("beta", &crate::dnn::HardSigmoidLayerTraitConst::beta(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for HardSigmoidLayer {} + boxed_cast_base! { HardSigmoidLayer, crate::dnn::ActivationLayer, cv_dnn_HardSigmoidLayer_to_ActivationLayer } + + boxed_cast_base! { HardSigmoidLayer, core::Algorithm, cv_dnn_HardSigmoidLayer_to_Algorithm } + + boxed_cast_base! { HardSigmoidLayer, crate::dnn::Layer, cv_dnn_HardSigmoidLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for HardSigmoidLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -9778,51 +9929,40 @@ pub mod dnn { boxed_ref! { HardSigmoidLayer, crate::dnn::HardSigmoidLayerTraitConst, as_raw_HardSigmoidLayer, crate::dnn::HardSigmoidLayerTrait, as_raw_mut_HardSigmoidLayer } - impl HardSigmoidLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_HardSigmoidLayer_defaultNew_const()) } - } + pub struct HardSwishLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { HardSwishLayer } + impl Drop for HardSwishLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_HardSigmoidLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_HardSwishLayer_delete(self.as_raw_mut_HardSwishLayer()) }; } - } - boxed_cast_base! { HardSigmoidLayer, crate::dnn::ActivationLayer, cv_dnn_HardSigmoidLayer_to_ActivationLayer } - - boxed_cast_base! { HardSigmoidLayer, core::Algorithm, cv_dnn_HardSigmoidLayer_to_Algorithm } - - boxed_cast_base! { HardSigmoidLayer, crate::dnn::Layer, cv_dnn_HardSigmoidLayer_to_Layer } + unsafe impl Send for HardSwishLayer {} - impl std::fmt::Debug for HardSigmoidLayer { + impl HardSwishLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("HardSigmoidLayer") - .field("alpha", &crate::dnn::HardSigmoidLayerTraitConst::alpha(self)) - .field("beta", &crate::dnn::HardSigmoidLayerTraitConst::beta(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::HardSwishLayer { + let ret = unsafe { sys::cv_dnn_HardSwishLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::HardSwishLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for HardSigmoidLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_HardSwishLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::HardSwishLayer] @@ -9837,20 +9977,31 @@ pub mod dnn { } - pub struct HardSwishLayer { - ptr: *mut c_void, + impl Default for HardSwishLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { HardSwishLayer } - - impl Drop for HardSwishLayer { + impl std::fmt::Debug for HardSwishLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_HardSwishLayer_delete(self.as_raw_mut_HardSwishLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("HardSwishLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for HardSwishLayer {} + boxed_cast_base! { HardSwishLayer, crate::dnn::ActivationLayer, cv_dnn_HardSwishLayer_to_ActivationLayer } + + boxed_cast_base! { HardSwishLayer, core::Algorithm, cv_dnn_HardSwishLayer_to_Algorithm } + + boxed_cast_base! { HardSwishLayer, crate::dnn::Layer, cv_dnn_HardSwishLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for HardSwishLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -9883,60 +10034,15 @@ pub mod dnn { boxed_ref! { HardSwishLayer, crate::dnn::LayerTraitConst, as_raw_Layer, crate::dnn::LayerTrait, as_raw_mut_Layer } impl crate::dnn::HardSwishLayerTraitConst for HardSwishLayer { - #[inline] fn as_raw_HardSwishLayer(&self) -> *const c_void { self.as_raw() } - } - - impl crate::dnn::HardSwishLayerTrait for HardSwishLayer { - #[inline] fn as_raw_mut_HardSwishLayer(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { HardSwishLayer, crate::dnn::HardSwishLayerTraitConst, as_raw_HardSwishLayer, crate::dnn::HardSwishLayerTrait, as_raw_mut_HardSwishLayer } - - impl HardSwishLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_HardSwishLayer_defaultNew_const()) } - } - - #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_HardSwishLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { HardSwishLayer, crate::dnn::ActivationLayer, cv_dnn_HardSwishLayer_to_ActivationLayer } - - boxed_cast_base! { HardSwishLayer, core::Algorithm, cv_dnn_HardSwishLayer_to_Algorithm } - - boxed_cast_base! { HardSwishLayer, crate::dnn::Layer, cv_dnn_HardSwishLayer_to_Layer } - - impl std::fmt::Debug for HardSwishLayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("HardSwishLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for HardSwishLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } + #[inline] fn as_raw_HardSwishLayer(&self) -> *const c_void { self.as_raw() } + } + + impl crate::dnn::HardSwishLayerTrait for HardSwishLayer { + #[inline] fn as_raw_mut_HardSwishLayer(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { HardSwishLayer, crate::dnn::HardSwishLayerTraitConst, as_raw_HardSwishLayer, crate::dnn::HardSwishLayerTrait, as_raw_mut_HardSwishLayer } + /// Processing params of image to blob. /// /// It includes all possible image processing operations and corresponding parameters. @@ -10047,6 +10153,44 @@ pub mod dnn { } + /// `InnerProduct`, `MatMul` and `Gemm` operations are all implemented by Fully Connected Layer. + /// Parameter `is_matmul` is used to distinguish `MatMul` and `Gemm` from `InnerProduct`. + pub struct InnerProductLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { InnerProductLayer } + + impl Drop for InnerProductLayer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_InnerProductLayer_delete(self.as_raw_mut_InnerProductLayer()) }; + } + } + + unsafe impl Send for InnerProductLayer {} + + impl InnerProductLayer { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::dnn::InnerProductLayer { + let ret = unsafe { sys::cv_dnn_InnerProductLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::InnerProductLayer::opencv_from_extern(ret) }; + ret + } + + #[inline] + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_InnerProductLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::dnn::InnerProductLayer] pub trait InnerProductLayerTraitConst: crate::dnn::LayerTraitConst { fn as_raw_InnerProductLayer(&self) -> *const c_void; @@ -10071,22 +10215,30 @@ pub mod dnn { } - /// `InnerProduct`, `MatMul` and `Gemm` operations are all implemented by Fully Connected Layer. - /// Parameter `is_matmul` is used to distinguish `MatMul` and `Gemm` from `InnerProduct`. - pub struct InnerProductLayer { - ptr: *mut c_void, + impl Default for InnerProductLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { InnerProductLayer } - - impl Drop for InnerProductLayer { + impl std::fmt::Debug for InnerProductLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_InnerProductLayer_delete(self.as_raw_mut_InnerProductLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("InnerProductLayer") + .field("axis", &crate::dnn::InnerProductLayerTraitConst::axis(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for InnerProductLayer {} + boxed_cast_base! { InnerProductLayer, core::Algorithm, cv_dnn_InnerProductLayer_to_Algorithm } + + boxed_cast_base! { InnerProductLayer, crate::dnn::Layer, cv_dnn_InnerProductLayer_to_Layer } impl core::AlgorithmTraitConst for InnerProductLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -10118,48 +10270,40 @@ pub mod dnn { boxed_ref! { InnerProductLayer, crate::dnn::InnerProductLayerTraitConst, as_raw_InnerProductLayer, crate::dnn::InnerProductLayerTrait, as_raw_mut_InnerProductLayer } - impl InnerProductLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_InnerProductLayer_defaultNew_const()) } - } + pub struct InnerProductLayerInt8 { + ptr: *mut c_void, + } + + opencv_type_boxed! { InnerProductLayerInt8 } + impl Drop for InnerProductLayerInt8 { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_InnerProductLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_InnerProductLayerInt8_delete(self.as_raw_mut_InnerProductLayerInt8()) }; } - } - boxed_cast_base! { InnerProductLayer, core::Algorithm, cv_dnn_InnerProductLayer_to_Algorithm } - - boxed_cast_base! { InnerProductLayer, crate::dnn::Layer, cv_dnn_InnerProductLayer_to_Layer } + unsafe impl Send for InnerProductLayerInt8 {} - impl std::fmt::Debug for InnerProductLayer { + impl InnerProductLayerInt8 { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("InnerProductLayer") - .field("axis", &crate::dnn::InnerProductLayerTraitConst::axis(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::InnerProductLayerInt8 { + let ret = unsafe { sys::cv_dnn_InnerProductLayerInt8_defaultNew_const() }; + let ret = unsafe { crate::dnn::InnerProductLayerInt8::opencv_from_extern(ret) }; + ret } - } - impl Default for InnerProductLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_InnerProductLayerInt8_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::InnerProductLayerInt8] @@ -10234,20 +10378,37 @@ pub mod dnn { } - pub struct InnerProductLayerInt8 { - ptr: *mut c_void, + impl Default for InnerProductLayerInt8 { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { InnerProductLayerInt8 } - - impl Drop for InnerProductLayerInt8 { + impl std::fmt::Debug for InnerProductLayerInt8 { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_InnerProductLayerInt8_delete(self.as_raw_mut_InnerProductLayerInt8()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("InnerProductLayerInt8") + .field("input_zp", &crate::dnn::InnerProductLayerInt8TraitConst::input_zp(self)) + .field("output_zp", &crate::dnn::InnerProductLayerInt8TraitConst::output_zp(self)) + .field("input_sc", &crate::dnn::InnerProductLayerInt8TraitConst::input_sc(self)) + .field("output_sc", &crate::dnn::InnerProductLayerInt8TraitConst::output_sc(self)) + .field("per_channel", &crate::dnn::InnerProductLayerInt8TraitConst::per_channel(self)) + .field("axis", &crate::dnn::InnerProductLayerTraitConst::axis(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for InnerProductLayerInt8 {} + boxed_cast_base! { InnerProductLayerInt8, core::Algorithm, cv_dnn_InnerProductLayerInt8_to_Algorithm } + + boxed_cast_base! { InnerProductLayerInt8, crate::dnn::InnerProductLayer, cv_dnn_InnerProductLayerInt8_to_InnerProductLayer } + + boxed_cast_base! { InnerProductLayerInt8, crate::dnn::Layer, cv_dnn_InnerProductLayerInt8_to_Layer } impl core::AlgorithmTraitConst for InnerProductLayerInt8 { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -10289,55 +10450,40 @@ pub mod dnn { boxed_ref! { InnerProductLayerInt8, crate::dnn::InnerProductLayerInt8TraitConst, as_raw_InnerProductLayerInt8, crate::dnn::InnerProductLayerInt8Trait, as_raw_mut_InnerProductLayerInt8 } - impl InnerProductLayerInt8 { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_InnerProductLayerInt8_defaultNew_const()) } - } + pub struct InstanceNormLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { InstanceNormLayer } + impl Drop for InstanceNormLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_InnerProductLayerInt8_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_InstanceNormLayer_delete(self.as_raw_mut_InstanceNormLayer()) }; } - } - boxed_cast_base! { InnerProductLayerInt8, core::Algorithm, cv_dnn_InnerProductLayerInt8_to_Algorithm } - - boxed_cast_base! { InnerProductLayerInt8, crate::dnn::InnerProductLayer, cv_dnn_InnerProductLayerInt8_to_InnerProductLayer } - - boxed_cast_base! { InnerProductLayerInt8, crate::dnn::Layer, cv_dnn_InnerProductLayerInt8_to_Layer } + unsafe impl Send for InstanceNormLayer {} - impl std::fmt::Debug for InnerProductLayerInt8 { + impl InstanceNormLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("InnerProductLayerInt8") - .field("input_zp", &crate::dnn::InnerProductLayerInt8TraitConst::input_zp(self)) - .field("output_zp", &crate::dnn::InnerProductLayerInt8TraitConst::output_zp(self)) - .field("input_sc", &crate::dnn::InnerProductLayerInt8TraitConst::input_sc(self)) - .field("output_sc", &crate::dnn::InnerProductLayerInt8TraitConst::output_sc(self)) - .field("per_channel", &crate::dnn::InnerProductLayerInt8TraitConst::per_channel(self)) - .field("axis", &crate::dnn::InnerProductLayerTraitConst::axis(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::InstanceNormLayer { + let ret = unsafe { sys::cv_dnn_InstanceNormLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::InstanceNormLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for InnerProductLayerInt8 { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_InstanceNormLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::InstanceNormLayer] @@ -10364,20 +10510,30 @@ pub mod dnn { } - pub struct InstanceNormLayer { - ptr: *mut c_void, + impl Default for InstanceNormLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { InstanceNormLayer } - - impl Drop for InstanceNormLayer { + impl std::fmt::Debug for InstanceNormLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_InstanceNormLayer_delete(self.as_raw_mut_InstanceNormLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("InstanceNormLayer") + .field("epsilon", &crate::dnn::InstanceNormLayerTraitConst::epsilon(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for InstanceNormLayer {} + boxed_cast_base! { InstanceNormLayer, core::Algorithm, cv_dnn_InstanceNormLayer_to_Algorithm } + + boxed_cast_base! { InstanceNormLayer, crate::dnn::Layer, cv_dnn_InstanceNormLayer_to_Layer } impl core::AlgorithmTraitConst for InstanceNormLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -10409,50 +10565,45 @@ pub mod dnn { boxed_ref! { InstanceNormLayer, crate::dnn::InstanceNormLayerTraitConst, as_raw_InstanceNormLayer, crate::dnn::InstanceNormLayerTrait, as_raw_mut_InstanceNormLayer } - impl InstanceNormLayer { + /// Bilinear resize layer from + /// + /// It differs from [ResizeLayer] in output shape and resize scales computations. + pub struct InterpLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { InterpLayer } + + impl Drop for InterpLayer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_InterpLayer_delete(self.as_raw_mut_InterpLayer()) }; + } + } + + unsafe impl Send for InterpLayer {} + + impl InterpLayer { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_InstanceNormLayer_defaultNew_const()) } + pub fn default() -> crate::dnn::InterpLayer { + let ret = unsafe { sys::cv_dnn_InterpLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::InterpLayer::opencv_from_extern(ret) }; + ret } #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_InstanceNormLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_InterpLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { InstanceNormLayer, core::Algorithm, cv_dnn_InstanceNormLayer_to_Algorithm } - - boxed_cast_base! { InstanceNormLayer, crate::dnn::Layer, cv_dnn_InstanceNormLayer_to_Layer } - - impl std::fmt::Debug for InstanceNormLayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("InstanceNormLayer") - .field("epsilon", &crate::dnn::InstanceNormLayerTraitConst::epsilon(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for InstanceNormLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - /// Constant methods for [crate::dnn::InterpLayer] pub trait InterpLayerTraitConst: crate::dnn::LayerTraitConst { fn as_raw_InterpLayer(&self) -> *const c_void; @@ -10465,23 +10616,29 @@ pub mod dnn { } - /// Bilinear resize layer from - /// - /// It differs from [ResizeLayer] in output shape and resize scales computations. - pub struct InterpLayer { - ptr: *mut c_void, + impl Default for InterpLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { InterpLayer } - - impl Drop for InterpLayer { + impl std::fmt::Debug for InterpLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_InterpLayer_delete(self.as_raw_mut_InterpLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("InterpLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for InterpLayer {} + boxed_cast_base! { InterpLayer, core::Algorithm, cv_dnn_InterpLayer_to_Algorithm } + + boxed_cast_base! { InterpLayer, crate::dnn::Layer, cv_dnn_InterpLayer_to_Layer } impl core::AlgorithmTraitConst for InterpLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -10513,47 +10670,80 @@ pub mod dnn { boxed_ref! { InterpLayer, crate::dnn::InterpLayerTraitConst, as_raw_InterpLayer, crate::dnn::InterpLayerTrait, as_raw_mut_InterpLayer } - impl InterpLayer { - /// Creates a default instance of the class by calling the default constructor + /// This class represents high-level API for keypoints models + /// + /// KeypointsModel allows to set params for preprocessing input image. + /// KeypointsModel creates net from file with trained weights and config, + /// sets preprocessing input, runs forward pass and returns the x and y coordinates of each detected keypoint + pub struct KeypointsModel { + ptr: *mut c_void, + } + + opencv_type_boxed! { KeypointsModel } + + impl Drop for KeypointsModel { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_InterpLayer_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_dnn_KeypointsModel_delete(self.as_raw_mut_KeypointsModel()) }; } + } + + unsafe impl Send for KeypointsModel {} + impl KeypointsModel { + /// Create keypoints model from network represented in one of the supported formats. + /// An order of @p model and @p config arguments does not matter. + /// ## Parameters + /// * model: Binary file contains trained weights. + /// * config: Text file contains network configuration. + /// + /// ## C++ default parameters + /// * config: "" #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + pub fn new(model: &str, config: &str) -> Result { + extern_container_arg!(model); + extern_container_arg!(config); return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_InterpLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_KeypointsModel_KeypointsModel_const_StringR_const_StringR(model.opencv_as_extern(), config.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::dnn::KeypointsModel::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { InterpLayer, core::Algorithm, cv_dnn_InterpLayer_to_Algorithm } - - boxed_cast_base! { InterpLayer, crate::dnn::Layer, cv_dnn_InterpLayer_to_Layer } - - impl std::fmt::Debug for InterpLayer { + /// Create keypoints model from network represented in one of the supported formats. + /// An order of @p model and @p config arguments does not matter. + /// ## Parameters + /// * model: Binary file contains trained weights. + /// * config: Text file contains network configuration. + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * config: "" #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("InterpLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn new_def(model: &str) -> Result { + extern_container_arg!(model); + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_KeypointsModel_KeypointsModel_const_StringR(model.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::KeypointsModel::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for InterpLayer { + /// Create model from deep learning network. + /// ## Parameters + /// * network: Net object. #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new_1(network: &impl crate::dnn::NetTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_KeypointsModel_KeypointsModel_const_NetR(network.as_raw_Net(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::KeypointsModel::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::KeypointsModel] @@ -10609,25 +10799,22 @@ pub mod dnn { } - /// This class represents high-level API for keypoints models - /// - /// KeypointsModel allows to set params for preprocessing input image. - /// KeypointsModel creates net from file with trained weights and config, - /// sets preprocessing input, runs forward pass and returns the x and y coordinates of each detected keypoint - pub struct KeypointsModel { - ptr: *mut c_void, + impl Clone for KeypointsModel { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_dnn_KeypointsModel_implicitClone_const(self.as_raw_KeypointsModel())) } + } } - opencv_type_boxed! { KeypointsModel } - - impl Drop for KeypointsModel { + impl std::fmt::Debug for KeypointsModel { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_KeypointsModel_delete(self.as_raw_mut_KeypointsModel()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("KeypointsModel") + .finish() } } - unsafe impl Send for KeypointsModel {} + boxed_cast_base! { KeypointsModel, crate::dnn::Model, cv_dnn_KeypointsModel_to_Model } impl crate::dnn::ModelTraitConst for KeypointsModel { #[inline] fn as_raw_Model(&self) -> *const c_void { self.as_raw() } @@ -10649,79 +10836,42 @@ pub mod dnn { boxed_ref! { KeypointsModel, crate::dnn::KeypointsModelTraitConst, as_raw_KeypointsModel, crate::dnn::KeypointsModelTrait, as_raw_mut_KeypointsModel } - impl KeypointsModel { - /// Create keypoints model from network represented in one of the supported formats. - /// An order of @p model and @p config arguments does not matter. - /// ## Parameters - /// * model: Binary file contains trained weights. - /// * config: Text file contains network configuration. - /// - /// ## C++ default parameters - /// * config: "" + pub struct LRNLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { LRNLayer } + + impl Drop for LRNLayer { #[inline] - pub fn new(model: &str, config: &str) -> Result { - extern_container_arg!(model); - extern_container_arg!(config); - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_KeypointsModel_KeypointsModel_const_StringR_const_StringR(model.opencv_as_extern(), config.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::KeypointsModel::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_LRNLayer_delete(self.as_raw_mut_LRNLayer()) }; } + } - /// Create keypoints model from network represented in one of the supported formats. - /// An order of @p model and @p config arguments does not matter. - /// ## Parameters - /// * model: Binary file contains trained weights. - /// * config: Text file contains network configuration. - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * config: "" + unsafe impl Send for LRNLayer {} + + impl LRNLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - pub fn new_def(model: &str) -> Result { - extern_container_arg!(model); - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_KeypointsModel_KeypointsModel_const_StringR(model.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::KeypointsModel::opencv_from_extern(ret) }; - Ok(ret) + pub fn default() -> crate::dnn::LRNLayer { + let ret = unsafe { sys::cv_dnn_LRNLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::LRNLayer::opencv_from_extern(ret) }; + ret } - /// Create model from deep learning network. - /// ## Parameters - /// * network: Net object. #[inline] - pub fn new_1(network: &impl crate::dnn::NetTraitConst) -> Result { + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_KeypointsModel_KeypointsModel_const_NetR(network.as_raw_Net(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_LRNLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::KeypointsModel::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - impl Clone for KeypointsModel { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_dnn_KeypointsModel_implicitClone_const(self.as_raw_KeypointsModel())) } - } - } - - boxed_cast_base! { KeypointsModel, crate::dnn::Model, cv_dnn_KeypointsModel_to_Model } - - impl std::fmt::Debug for KeypointsModel { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("KeypointsModel") - .finish() - } - } - /// Constant methods for [crate::dnn::LRNLayer] pub trait LRNLayerTraitConst: crate::dnn::LayerTraitConst { fn as_raw_LRNLayer(&self) -> *const c_void; @@ -10806,20 +10956,35 @@ pub mod dnn { } - pub struct LRNLayer { - ptr: *mut c_void, + impl Default for LRNLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { LRNLayer } - - impl Drop for LRNLayer { + impl std::fmt::Debug for LRNLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_LRNLayer_delete(self.as_raw_mut_LRNLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LRNLayer") + .field("typ", &crate::dnn::LRNLayerTraitConst::typ(self)) + .field("size", &crate::dnn::LRNLayerTraitConst::size(self)) + .field("alpha", &crate::dnn::LRNLayerTraitConst::alpha(self)) + .field("beta", &crate::dnn::LRNLayerTraitConst::beta(self)) + .field("bias", &crate::dnn::LRNLayerTraitConst::bias(self)) + .field("norm_by_size", &crate::dnn::LRNLayerTraitConst::norm_by_size(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for LRNLayer {} + boxed_cast_base! { LRNLayer, core::Algorithm, cv_dnn_LRNLayer_to_Algorithm } + + boxed_cast_base! { LRNLayer, crate::dnn::Layer, cv_dnn_LRNLayer_to_Layer } impl core::AlgorithmTraitConst for LRNLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -10851,55 +11016,36 @@ pub mod dnn { boxed_ref! { LRNLayer, crate::dnn::LRNLayerTraitConst, as_raw_LRNLayer, crate::dnn::LRNLayerTrait, as_raw_mut_LRNLayer } - impl LRNLayer { - /// Creates a default instance of the class by calling the default constructor + /// LSTM recurrent layer + pub struct LSTMLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { LSTMLayer } + + impl Drop for LSTMLayer { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_LRNLayer_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_dnn_LSTMLayer_delete(self.as_raw_mut_LSTMLayer()) }; } + } + + unsafe impl Send for LSTMLayer {} + impl LSTMLayer { + /// Creates instance of LSTM layer #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_LRNLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_LSTMLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { LRNLayer, core::Algorithm, cv_dnn_LRNLayer_to_Algorithm } - - boxed_cast_base! { LRNLayer, crate::dnn::Layer, cv_dnn_LRNLayer_to_Layer } - - impl std::fmt::Debug for LRNLayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LRNLayer") - .field("typ", &crate::dnn::LRNLayerTraitConst::typ(self)) - .field("size", &crate::dnn::LRNLayerTraitConst::size(self)) - .field("alpha", &crate::dnn::LRNLayerTraitConst::alpha(self)) - .field("beta", &crate::dnn::LRNLayerTraitConst::beta(self)) - .field("bias", &crate::dnn::LRNLayerTraitConst::bias(self)) - .field("norm_by_size", &crate::dnn::LRNLayerTraitConst::norm_by_size(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for LRNLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - /// Constant methods for [crate::dnn::LSTMLayer] pub trait LSTMLayerTraitConst: crate::dnn::LayerTraitConst { fn as_raw_LSTMLayer(&self) -> *const c_void; @@ -11086,21 +11232,21 @@ pub mod dnn { } - /// LSTM recurrent layer - pub struct LSTMLayer { - ptr: *mut c_void, - } - - opencv_type_boxed! { LSTMLayer } - - impl Drop for LSTMLayer { + impl std::fmt::Debug for LSTMLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_LSTMLayer_delete(self.as_raw_mut_LSTMLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LSTMLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for LSTMLayer {} + boxed_cast_base! { LSTMLayer, core::Algorithm, cv_dnn_LSTMLayer_to_Algorithm } + + boxed_cast_base! { LSTMLayer, crate::dnn::Layer, cv_dnn_LSTMLayer_to_Layer } impl core::AlgorithmTraitConst for LSTMLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -11132,34 +11278,46 @@ pub mod dnn { boxed_ref! { LSTMLayer, crate::dnn::LSTMLayerTraitConst, as_raw_LSTMLayer, crate::dnn::LSTMLayerTrait, as_raw_mut_LSTMLayer } - impl LSTMLayer { - /// Creates instance of LSTM layer + /// This interface class allows to build new Layers - are building blocks of networks. + /// + /// Each class, derived from Layer, must implement forward() method to compute outputs. + /// Also before using the new layer into networks you must register your layer by using one of [dnnLayerFactory] "LayerFactory" macros. + pub struct Layer { + ptr: *mut c_void, + } + + opencv_type_boxed! { Layer } + + impl Drop for Layer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + fn drop(&mut self) { + unsafe { sys::cv_dnn_Layer_delete(self.as_raw_mut_Layer()) }; + } + } + + unsafe impl Send for Layer {} + + impl Layer { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_LSTMLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_Layer_Layer(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::dnn::Layer::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { LSTMLayer, core::Algorithm, cv_dnn_LSTMLayer_to_Algorithm } - - boxed_cast_base! { LSTMLayer, crate::dnn::Layer, cv_dnn_LSTMLayer_to_Layer } - - impl std::fmt::Debug for LSTMLayer { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LSTMLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn new(params: &impl crate::dnn::LayerParamsTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_Layer_Layer_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::Layer::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::Layer] @@ -11671,67 +11829,19 @@ pub mod dnn { } - /// This interface class allows to build new Layers - are building blocks of networks. - /// - /// Each class, derived from Layer, must implement forward() method to compute outputs. - /// Also before using the new layer into networks you must register your layer by using one of [dnnLayerFactory] "LayerFactory" macros. - pub struct Layer { - ptr: *mut c_void, - } - - opencv_type_boxed! { Layer } - - impl Drop for Layer { + impl std::fmt::Debug for Layer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_Layer_delete(self.as_raw_mut_Layer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Layer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for Layer {} - - impl core::AlgorithmTraitConst for Layer { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for Layer { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Layer, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::dnn::LayerTraitConst for Layer { - #[inline] fn as_raw_Layer(&self) -> *const c_void { self.as_raw() } - } - - impl crate::dnn::LayerTrait for Layer { - #[inline] fn as_raw_mut_Layer(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Layer, crate::dnn::LayerTraitConst, as_raw_Layer, crate::dnn::LayerTrait, as_raw_mut_Layer } - - impl Layer { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_Layer_Layer(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::Layer::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn new(params: &impl crate::dnn::LayerParamsTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_Layer_Layer_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::Layer::opencv_from_extern(ret) }; - Ok(ret) - } - - } + boxed_cast_base! { Layer, core::Algorithm, cv_dnn_Layer_to_Algorithm } boxed_cast_descendant! { Layer, crate::dnn::AbsLayer, cv_dnn_Layer_to_AbsLayer } @@ -11965,32 +12075,26 @@ pub mod dnn { boxed_cast_descendant! { Layer, crate::dnn::TopKLayer, cv_dnn_Layer_to_TopKLayer } - boxed_cast_base! { Layer, core::Algorithm, cv_dnn_Layer_to_Algorithm } + impl core::AlgorithmTraitConst for Layer { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } + } - impl std::fmt::Debug for Layer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Layer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } + impl core::AlgorithmTrait for Layer { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } } - /// Constant methods for [crate::dnn::LayerFactory] - pub trait LayerFactoryTraitConst { - fn as_raw_LayerFactory(&self) -> *const c_void; + boxed_ref! { Layer, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + impl crate::dnn::LayerTraitConst for Layer { + #[inline] fn as_raw_Layer(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::dnn::LayerFactory] - pub trait LayerFactoryTrait: crate::dnn::LayerFactoryTraitConst { - fn as_raw_mut_LayerFactory(&mut self) -> *mut c_void; - + impl crate::dnn::LayerTrait for Layer { + #[inline] fn as_raw_mut_Layer(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { Layer, crate::dnn::LayerTraitConst, as_raw_Layer, crate::dnn::LayerTrait, as_raw_mut_Layer } + /// %Layer factory allows to create instances of registered layers. pub struct LayerFactory { ptr: *mut c_void, @@ -11998,24 +12102,14 @@ pub mod dnn { opencv_type_boxed! { LayerFactory } - impl Drop for LayerFactory { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_LayerFactory_delete(self.as_raw_mut_LayerFactory()) }; - } - } - - unsafe impl Send for LayerFactory {} - - impl crate::dnn::LayerFactoryTraitConst for LayerFactory { - #[inline] fn as_raw_LayerFactory(&self) -> *const c_void { self.as_raw() } - } - - impl crate::dnn::LayerFactoryTrait for LayerFactory { - #[inline] fn as_raw_mut_LayerFactory(&mut self) -> *mut c_void { self.as_raw_mut() } + impl Drop for LayerFactory { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_LayerFactory_delete(self.as_raw_mut_LayerFactory()) }; + } } - boxed_ref! { LayerFactory, crate::dnn::LayerFactoryTraitConst, as_raw_LayerFactory, crate::dnn::LayerFactoryTrait, as_raw_mut_LayerFactory } + unsafe impl Send for LayerFactory {} impl LayerFactory { /// Registers the layer class with typename @p type and specified @p constructor. Thread-safe. @@ -12070,6 +12164,18 @@ pub mod dnn { } + /// Constant methods for [crate::dnn::LayerFactory] + pub trait LayerFactoryTraitConst { + fn as_raw_LayerFactory(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::dnn::LayerFactory] + pub trait LayerFactoryTrait: crate::dnn::LayerFactoryTraitConst { + fn as_raw_mut_LayerFactory(&mut self) -> *mut c_void; + + } + impl std::fmt::Debug for LayerFactory { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -12078,6 +12184,52 @@ pub mod dnn { } } + impl crate::dnn::LayerFactoryTraitConst for LayerFactory { + #[inline] fn as_raw_LayerFactory(&self) -> *const c_void { self.as_raw() } + } + + impl crate::dnn::LayerFactoryTrait for LayerFactory { + #[inline] fn as_raw_mut_LayerFactory(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { LayerFactory, crate::dnn::LayerFactoryTraitConst, as_raw_LayerFactory, crate::dnn::LayerFactoryTrait, as_raw_mut_LayerFactory } + + pub struct LayerNormLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { LayerNormLayer } + + impl Drop for LayerNormLayer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_LayerNormLayer_delete(self.as_raw_mut_LayerNormLayer()) }; + } + } + + unsafe impl Send for LayerNormLayer {} + + impl LayerNormLayer { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::dnn::LayerNormLayer { + let ret = unsafe { sys::cv_dnn_LayerNormLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::LayerNormLayer::opencv_from_extern(ret) }; + ret + } + + #[inline] + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_LayerNormLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::dnn::LayerNormLayer] pub trait LayerNormLayerTraitConst: crate::dnn::LayerTraitConst { fn as_raw_LayerNormLayer(&self) -> *const c_void; @@ -12126,20 +12278,32 @@ pub mod dnn { } - pub struct LayerNormLayer { - ptr: *mut c_void, + impl Default for LayerNormLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { LayerNormLayer } - - impl Drop for LayerNormLayer { + impl std::fmt::Debug for LayerNormLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_LayerNormLayer_delete(self.as_raw_mut_LayerNormLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LayerNormLayer") + .field("has_bias", &crate::dnn::LayerNormLayerTraitConst::has_bias(self)) + .field("axis", &crate::dnn::LayerNormLayerTraitConst::axis(self)) + .field("epsilon", &crate::dnn::LayerNormLayerTraitConst::epsilon(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for LayerNormLayer {} + boxed_cast_base! { LayerNormLayer, core::Algorithm, cv_dnn_LayerNormLayer_to_Algorithm } + + boxed_cast_base! { LayerNormLayer, crate::dnn::Layer, cv_dnn_LayerNormLayer_to_Layer } impl core::AlgorithmTraitConst for LayerNormLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -12171,50 +12335,34 @@ pub mod dnn { boxed_ref! { LayerNormLayer, crate::dnn::LayerNormLayerTraitConst, as_raw_LayerNormLayer, crate::dnn::LayerNormLayerTrait, as_raw_mut_LayerNormLayer } - impl LayerNormLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_LayerNormLayer_defaultNew_const()) } - } - - #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_LayerNormLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + /// This class provides all data needed to initialize layer. + /// + /// It includes dictionary with scalar params (which can be read by using Dict interface), + /// blob params [blobs] and optional meta information: [name] and [type] of layer instance. + pub struct LayerParams { + ptr: *mut c_void, } - boxed_cast_base! { LayerNormLayer, core::Algorithm, cv_dnn_LayerNormLayer_to_Algorithm } - - boxed_cast_base! { LayerNormLayer, crate::dnn::Layer, cv_dnn_LayerNormLayer_to_Layer } + opencv_type_boxed! { LayerParams } - impl std::fmt::Debug for LayerNormLayer { + impl Drop for LayerParams { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LayerNormLayer") - .field("has_bias", &crate::dnn::LayerNormLayerTraitConst::has_bias(self)) - .field("axis", &crate::dnn::LayerNormLayerTraitConst::axis(self)) - .field("epsilon", &crate::dnn::LayerNormLayerTraitConst::epsilon(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_dnn_LayerParams_delete(self.as_raw_mut_LayerParams()) }; } } - impl Default for LayerNormLayer { + unsafe impl Send for LayerParams {} + + impl LayerParams { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::dnn::LayerParams { + let ret = unsafe { sys::cv_dnn_LayerParams_defaultNew_const() }; + let ret = unsafe { crate::dnn::LayerParams::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::dnn::LayerParams] @@ -12276,24 +12424,26 @@ pub mod dnn { } - /// This class provides all data needed to initialize layer. - /// - /// It includes dictionary with scalar params (which can be read by using Dict interface), - /// blob params [blobs] and optional meta information: [name] and [type] of layer instance. - pub struct LayerParams { - ptr: *mut c_void, + impl Default for LayerParams { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { LayerParams } - - impl Drop for LayerParams { + impl std::fmt::Debug for LayerParams { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_LayerParams_delete(self.as_raw_mut_LayerParams()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LayerParams") + .field("blobs", &crate::dnn::LayerParamsTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerParamsTraitConst::name(self)) + .field("typ", &crate::dnn::LayerParamsTraitConst::typ(self)) + .finish() } } - unsafe impl Send for LayerParams {} + boxed_cast_base! { LayerParams, crate::dnn::Dict, cv_dnn_LayerParams_to_Dict } impl crate::dnn::DictTraitConst for LayerParams { #[inline] fn as_raw_Dict(&self) -> *const c_void { self.as_raw() } @@ -12315,34 +12465,40 @@ pub mod dnn { boxed_ref! { LayerParams, crate::dnn::LayerParamsTraitConst, as_raw_LayerParams, crate::dnn::LayerParamsTrait, as_raw_mut_LayerParams } - impl LayerParams { - /// Creates a default instance of the class by calling the default constructor + pub struct LogLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { LogLayer } + + impl Drop for LogLayer { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_LayerParams_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_dnn_LogLayer_delete(self.as_raw_mut_LogLayer()) }; } - } - boxed_cast_base! { LayerParams, crate::dnn::Dict, cv_dnn_LayerParams_to_Dict } + unsafe impl Send for LogLayer {} - impl std::fmt::Debug for LayerParams { + impl LogLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LayerParams") - .field("blobs", &crate::dnn::LayerParamsTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerParamsTraitConst::name(self)) - .field("typ", &crate::dnn::LayerParamsTraitConst::typ(self)) - .finish() + pub fn default() -> crate::dnn::LogLayer { + let ret = unsafe { sys::cv_dnn_LogLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::LogLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for LayerParams { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_LogLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::LogLayer] @@ -12357,20 +12513,31 @@ pub mod dnn { } - pub struct LogLayer { - ptr: *mut c_void, + impl Default for LogLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { LogLayer } - - impl Drop for LogLayer { + impl std::fmt::Debug for LogLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_LogLayer_delete(self.as_raw_mut_LogLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LogLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for LogLayer {} + boxed_cast_base! { LogLayer, crate::dnn::ActivationLayer, cv_dnn_LogLayer_to_ActivationLayer } + + boxed_cast_base! { LogLayer, core::Algorithm, cv_dnn_LogLayer_to_Algorithm } + + boxed_cast_base! { LogLayer, crate::dnn::Layer, cv_dnn_LogLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for LogLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -12412,49 +12579,40 @@ pub mod dnn { boxed_ref! { LogLayer, crate::dnn::LogLayerTraitConst, as_raw_LogLayer, crate::dnn::LogLayerTrait, as_raw_mut_LogLayer } - impl LogLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_LogLayer_defaultNew_const()) } - } - - #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_LogLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + pub struct MVNLayer { + ptr: *mut c_void, } - boxed_cast_base! { LogLayer, crate::dnn::ActivationLayer, cv_dnn_LogLayer_to_ActivationLayer } + opencv_type_boxed! { MVNLayer } - boxed_cast_base! { LogLayer, core::Algorithm, cv_dnn_LogLayer_to_Algorithm } + impl Drop for MVNLayer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_MVNLayer_delete(self.as_raw_mut_MVNLayer()) }; + } + } - boxed_cast_base! { LogLayer, crate::dnn::Layer, cv_dnn_LogLayer_to_Layer } + unsafe impl Send for MVNLayer {} - impl std::fmt::Debug for LogLayer { + impl MVNLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LogLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::MVNLayer { + let ret = unsafe { sys::cv_dnn_MVNLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::MVNLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for LogLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_MVNLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::MVNLayer] @@ -12505,20 +12663,32 @@ pub mod dnn { } - pub struct MVNLayer { - ptr: *mut c_void, + impl Default for MVNLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { MVNLayer } - - impl Drop for MVNLayer { + impl std::fmt::Debug for MVNLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_MVNLayer_delete(self.as_raw_mut_MVNLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MVNLayer") + .field("eps", &crate::dnn::MVNLayerTraitConst::eps(self)) + .field("norm_variance", &crate::dnn::MVNLayerTraitConst::norm_variance(self)) + .field("across_channels", &crate::dnn::MVNLayerTraitConst::across_channels(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for MVNLayer {} + boxed_cast_base! { MVNLayer, core::Algorithm, cv_dnn_MVNLayer_to_Algorithm } + + boxed_cast_base! { MVNLayer, crate::dnn::Layer, cv_dnn_MVNLayer_to_Layer } impl core::AlgorithmTraitConst for MVNLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -12550,50 +12720,40 @@ pub mod dnn { boxed_ref! { MVNLayer, crate::dnn::MVNLayerTraitConst, as_raw_MVNLayer, crate::dnn::MVNLayerTrait, as_raw_mut_MVNLayer } - impl MVNLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_MVNLayer_defaultNew_const()) } - } + pub struct MatMulLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { MatMulLayer } + + impl Drop for MatMulLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_MVNLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_MatMulLayer_delete(self.as_raw_mut_MatMulLayer()) }; } - } - boxed_cast_base! { MVNLayer, core::Algorithm, cv_dnn_MVNLayer_to_Algorithm } - - boxed_cast_base! { MVNLayer, crate::dnn::Layer, cv_dnn_MVNLayer_to_Layer } + unsafe impl Send for MatMulLayer {} - impl std::fmt::Debug for MVNLayer { + impl MatMulLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MVNLayer") - .field("eps", &crate::dnn::MVNLayerTraitConst::eps(self)) - .field("norm_variance", &crate::dnn::MVNLayerTraitConst::norm_variance(self)) - .field("across_channels", &crate::dnn::MVNLayerTraitConst::across_channels(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::MatMulLayer { + let ret = unsafe { sys::cv_dnn_MatMulLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::MatMulLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for MVNLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_MatMulLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::MatMulLayer] @@ -12608,20 +12768,29 @@ pub mod dnn { } - pub struct MatMulLayer { - ptr: *mut c_void, + impl Default for MatMulLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { MatMulLayer } - - impl Drop for MatMulLayer { + impl std::fmt::Debug for MatMulLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_MatMulLayer_delete(self.as_raw_mut_MatMulLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MatMulLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for MatMulLayer {} + boxed_cast_base! { MatMulLayer, core::Algorithm, cv_dnn_MatMulLayer_to_Algorithm } + + boxed_cast_base! { MatMulLayer, crate::dnn::Layer, cv_dnn_MatMulLayer_to_Layer } impl core::AlgorithmTraitConst for MatMulLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -12653,47 +12822,40 @@ pub mod dnn { boxed_ref! { MatMulLayer, crate::dnn::MatMulLayerTraitConst, as_raw_MatMulLayer, crate::dnn::MatMulLayerTrait, as_raw_mut_MatMulLayer } - impl MatMulLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_MatMulLayer_defaultNew_const()) } - } + pub struct MaxUnpoolLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { MaxUnpoolLayer } + impl Drop for MaxUnpoolLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_MatMulLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_MaxUnpoolLayer_delete(self.as_raw_mut_MaxUnpoolLayer()) }; } - } - boxed_cast_base! { MatMulLayer, core::Algorithm, cv_dnn_MatMulLayer_to_Algorithm } - - boxed_cast_base! { MatMulLayer, crate::dnn::Layer, cv_dnn_MatMulLayer_to_Layer } + unsafe impl Send for MaxUnpoolLayer {} - impl std::fmt::Debug for MatMulLayer { + impl MaxUnpoolLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MatMulLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::MaxUnpoolLayer { + let ret = unsafe { sys::cv_dnn_MaxUnpoolLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::MaxUnpoolLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for MatMulLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_MaxUnpoolLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::MaxUnpoolLayer] @@ -12750,20 +12912,32 @@ pub mod dnn { } - pub struct MaxUnpoolLayer { - ptr: *mut c_void, + impl Default for MaxUnpoolLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { MaxUnpoolLayer } - - impl Drop for MaxUnpoolLayer { + impl std::fmt::Debug for MaxUnpoolLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_MaxUnpoolLayer_delete(self.as_raw_mut_MaxUnpoolLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MaxUnpoolLayer") + .field("pool_kernel", &crate::dnn::MaxUnpoolLayerTraitConst::pool_kernel(self)) + .field("pool_pad", &crate::dnn::MaxUnpoolLayerTraitConst::pool_pad(self)) + .field("pool_stride", &crate::dnn::MaxUnpoolLayerTraitConst::pool_stride(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for MaxUnpoolLayer {} + boxed_cast_base! { MaxUnpoolLayer, core::Algorithm, cv_dnn_MaxUnpoolLayer_to_Algorithm } + + boxed_cast_base! { MaxUnpoolLayer, crate::dnn::Layer, cv_dnn_MaxUnpoolLayer_to_Layer } impl core::AlgorithmTraitConst for MaxUnpoolLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -12795,50 +12969,40 @@ pub mod dnn { boxed_ref! { MaxUnpoolLayer, crate::dnn::MaxUnpoolLayerTraitConst, as_raw_MaxUnpoolLayer, crate::dnn::MaxUnpoolLayerTrait, as_raw_mut_MaxUnpoolLayer } - impl MaxUnpoolLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_MaxUnpoolLayer_defaultNew_const()) } - } + pub struct MishLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { MishLayer } + impl Drop for MishLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_MaxUnpoolLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_MishLayer_delete(self.as_raw_mut_MishLayer()) }; } - } - boxed_cast_base! { MaxUnpoolLayer, core::Algorithm, cv_dnn_MaxUnpoolLayer_to_Algorithm } + unsafe impl Send for MishLayer {} - boxed_cast_base! { MaxUnpoolLayer, crate::dnn::Layer, cv_dnn_MaxUnpoolLayer_to_Layer } + impl MishLayer { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::dnn::MishLayer { + let ret = unsafe { sys::cv_dnn_MishLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::MishLayer::opencv_from_extern(ret) }; + ret + } - impl std::fmt::Debug for MaxUnpoolLayer { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MaxUnpoolLayer") - .field("pool_kernel", &crate::dnn::MaxUnpoolLayerTraitConst::pool_kernel(self)) - .field("pool_pad", &crate::dnn::MaxUnpoolLayerTraitConst::pool_pad(self)) - .field("pool_stride", &crate::dnn::MaxUnpoolLayerTraitConst::pool_stride(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_MishLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for MaxUnpoolLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } } /// Constant methods for [crate::dnn::MishLayer] @@ -12853,20 +13017,31 @@ pub mod dnn { } - pub struct MishLayer { - ptr: *mut c_void, + impl Default for MishLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { MishLayer } - - impl Drop for MishLayer { + impl std::fmt::Debug for MishLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_MishLayer_delete(self.as_raw_mut_MishLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MishLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for MishLayer {} + boxed_cast_base! { MishLayer, crate::dnn::ActivationLayer, cv_dnn_MishLayer_to_ActivationLayer } + + boxed_cast_base! { MishLayer, core::Algorithm, cv_dnn_MishLayer_to_Algorithm } + + boxed_cast_base! { MishLayer, crate::dnn::Layer, cv_dnn_MishLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for MishLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -12908,49 +13083,104 @@ pub mod dnn { boxed_ref! { MishLayer, crate::dnn::MishLayerTraitConst, as_raw_MishLayer, crate::dnn::MishLayerTrait, as_raw_mut_MishLayer } - impl MishLayer { - /// Creates a default instance of the class by calling the default constructor + /// This class is presented high-level API for neural networks. + /// + /// Model allows to set params for preprocessing input image. + /// Model creates net from file with trained weights and config, + /// sets preprocessing input and runs forward pass. + pub struct Model { + ptr: *mut c_void, + } + + opencv_type_boxed! { Model } + + impl Drop for Model { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_MishLayer_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_dnn_Model_delete(self.as_raw_mut_Model()) }; } + } + + unsafe impl Send for Model {} + impl Model { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_MishLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_Model_Model(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::dnn::Model::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { MishLayer, crate::dnn::ActivationLayer, cv_dnn_MishLayer_to_ActivationLayer } + #[inline] + pub fn copy(unnamed: &impl crate::dnn::ModelTraitConst) -> crate::dnn::Model { + let ret = unsafe { sys::cv_dnn_Model_Model_const_ModelR(unnamed.as_raw_Model()) }; + let ret = unsafe { crate::dnn::Model::opencv_from_extern(ret) }; + ret + } - boxed_cast_base! { MishLayer, core::Algorithm, cv_dnn_MishLayer_to_Algorithm } + #[inline] + pub fn copy_mut(mut unnamed: crate::dnn::Model) -> crate::dnn::Model { + let ret = unsafe { sys::cv_dnn_Model_Model_ModelRR(unnamed.as_raw_mut_Model()) }; + let ret = unsafe { crate::dnn::Model::opencv_from_extern(ret) }; + ret + } - boxed_cast_base! { MishLayer, crate::dnn::Layer, cv_dnn_MishLayer_to_Layer } + /// Create model from deep learning network represented in one of the supported formats. + /// An order of @p model and @p config arguments does not matter. + /// ## Parameters + /// * model: Binary file contains trained weights. + /// * config: Text file contains network configuration. + /// + /// ## C++ default parameters + /// * config: "" + #[inline] + pub fn new(model: &str, config: &str) -> Result { + extern_container_arg!(model); + extern_container_arg!(config); + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_Model_Model_const_StringR_const_StringR(model.opencv_as_extern(), config.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::Model::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for MishLayer { + /// Create model from deep learning network represented in one of the supported formats. + /// An order of @p model and @p config arguments does not matter. + /// ## Parameters + /// * model: Binary file contains trained weights. + /// * config: Text file contains network configuration. + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * config: "" #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MishLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn new_def(model: &str) -> Result { + extern_container_arg!(model); + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_Model_Model_const_StringR(model.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::Model::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for MishLayer { + /// Create model from deep learning network. + /// ## Parameters + /// * network: Net object. #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new_1(network: &impl crate::dnn::NetTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_Model_Model_const_NetR(network.as_raw_Net(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::Model::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::Model] @@ -13197,26 +13427,21 @@ pub mod dnn { } - /// This class is presented high-level API for neural networks. - /// - /// Model allows to set params for preprocessing input image. - /// Model creates net from file with trained weights and config, - /// sets preprocessing input and runs forward pass. - pub struct Model { - ptr: *mut c_void, + impl Clone for Model { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_dnn_Model_implicitClone_const(self.as_raw_Model())) } + } } - opencv_type_boxed! { Model } - - impl Drop for Model { + impl std::fmt::Debug for Model { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_Model_delete(self.as_raw_mut_Model()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Model") + .finish() } } - unsafe impl Send for Model {} - impl crate::dnn::ModelTraitConst for Model { #[inline] fn as_raw_Model(&self) -> *const c_void { self.as_raw() } } @@ -13227,99 +13452,40 @@ pub mod dnn { boxed_ref! { Model, crate::dnn::ModelTraitConst, as_raw_Model, crate::dnn::ModelTrait, as_raw_mut_Model } - impl Model { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_Model_Model(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::Model::opencv_from_extern(ret) }; - Ok(ret) - } + pub struct NaryEltwiseLayer { + ptr: *mut c_void, + } - #[inline] - pub fn copy(unnamed: &impl crate::dnn::ModelTraitConst) -> crate::dnn::Model { - let ret = unsafe { sys::cv_dnn_Model_Model_const_ModelR(unnamed.as_raw_Model()) }; - let ret = unsafe { crate::dnn::Model::opencv_from_extern(ret) }; - ret - } + opencv_type_boxed! { NaryEltwiseLayer } + impl Drop for NaryEltwiseLayer { #[inline] - pub fn copy_mut(mut unnamed: crate::dnn::Model) -> crate::dnn::Model { - let ret = unsafe { sys::cv_dnn_Model_Model_ModelRR(unnamed.as_raw_mut_Model()) }; - let ret = unsafe { crate::dnn::Model::opencv_from_extern(ret) }; - ret + fn drop(&mut self) { + unsafe { sys::cv_dnn_NaryEltwiseLayer_delete(self.as_raw_mut_NaryEltwiseLayer()) }; } + } - /// Create model from deep learning network represented in one of the supported formats. - /// An order of @p model and @p config arguments does not matter. - /// ## Parameters - /// * model: Binary file contains trained weights. - /// * config: Text file contains network configuration. - /// - /// ## C++ default parameters - /// * config: "" - #[inline] - pub fn new(model: &str, config: &str) -> Result { - extern_container_arg!(model); - extern_container_arg!(config); - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_Model_Model_const_StringR_const_StringR(model.opencv_as_extern(), config.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::Model::opencv_from_extern(ret) }; - Ok(ret) - } + unsafe impl Send for NaryEltwiseLayer {} - /// Create model from deep learning network represented in one of the supported formats. - /// An order of @p model and @p config arguments does not matter. - /// ## Parameters - /// * model: Binary file contains trained weights. - /// * config: Text file contains network configuration. - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * config: "" + impl NaryEltwiseLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - pub fn new_def(model: &str) -> Result { - extern_container_arg!(model); - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_Model_Model_const_StringR(model.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::Model::opencv_from_extern(ret) }; - Ok(ret) + pub fn default() -> crate::dnn::NaryEltwiseLayer { + let ret = unsafe { sys::cv_dnn_NaryEltwiseLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::NaryEltwiseLayer::opencv_from_extern(ret) }; + ret } - /// Create model from deep learning network. - /// ## Parameters - /// * network: Net object. #[inline] - pub fn new_1(network: &impl crate::dnn::NetTraitConst) -> Result { + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_Model_Model_const_NetR(network.as_raw_Net(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_NaryEltwiseLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::Model::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl Clone for Model { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_dnn_Model_implicitClone_const(self.as_raw_Model())) } - } - } - - impl std::fmt::Debug for Model { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Model") - .finish() + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::NaryEltwiseLayer] @@ -13334,20 +13500,29 @@ pub mod dnn { } - pub struct NaryEltwiseLayer { - ptr: *mut c_void, + impl Default for NaryEltwiseLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { NaryEltwiseLayer } - - impl Drop for NaryEltwiseLayer { + impl std::fmt::Debug for NaryEltwiseLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_NaryEltwiseLayer_delete(self.as_raw_mut_NaryEltwiseLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("NaryEltwiseLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for NaryEltwiseLayer {} + boxed_cast_base! { NaryEltwiseLayer, core::Algorithm, cv_dnn_NaryEltwiseLayer_to_Algorithm } + + boxed_cast_base! { NaryEltwiseLayer, crate::dnn::Layer, cv_dnn_NaryEltwiseLayer_to_Layer } impl core::AlgorithmTraitConst for NaryEltwiseLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -13379,47 +13554,93 @@ pub mod dnn { boxed_ref! { NaryEltwiseLayer, crate::dnn::NaryEltwiseLayerTraitConst, as_raw_NaryEltwiseLayer, crate::dnn::NaryEltwiseLayerTrait, as_raw_mut_NaryEltwiseLayer } - impl NaryEltwiseLayer { - /// Creates a default instance of the class by calling the default constructor + /// This class allows to create and manipulate comprehensive artificial neural networks. + /// + /// Neural network is presented as directed acyclic graph (DAG), where vertices are Layer instances, + /// and edges specify relationships between layers inputs and outputs. + /// + /// Each network layer has unique integer id and unique string name inside its network. + /// LayerId can store either layer name or layer id. + /// + /// This class supports reference counting of its instances, i. e. copies point to the same instance. + pub struct Net { + ptr: *mut c_void, + } + + opencv_type_boxed! { Net } + + impl Drop for Net { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_NaryEltwiseLayer_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_dnn_Net_delete(self.as_raw_mut_Net()) }; } + } + + unsafe impl Send for Net {} + impl Net { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_NaryEltwiseLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_Net_Net(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::dnn::Net::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { NaryEltwiseLayer, core::Algorithm, cv_dnn_NaryEltwiseLayer_to_Algorithm } - - boxed_cast_base! { NaryEltwiseLayer, crate::dnn::Layer, cv_dnn_NaryEltwiseLayer_to_Layer } + /// Create a network from Intel's Model Optimizer intermediate representation (IR). + /// ## Parameters + /// * xml: XML configuration file with network's topology. + /// * bin: Binary file with trained weights. + /// Networks imported from Intel's Model Optimizer are launched in Intel's Inference Engine + /// backend. + #[inline] + pub fn read_from_model_optimizer(xml: &str, bin: &str) -> Result { + extern_container_arg!(xml); + extern_container_arg!(bin); + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_Net_readFromModelOptimizer_const_StringR_const_StringR(xml.opencv_as_extern(), bin.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::Net::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for NaryEltwiseLayer { + /// Create a network from Intel's Model Optimizer in-memory buffers with intermediate representation (IR). + /// ## Parameters + /// * bufferModelConfig: buffer with model's configuration. + /// * bufferWeights: buffer with model's trained weights. + /// ## Returns + /// Net object. #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("NaryEltwiseLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn read_from_model_optimizer_1(buffer_model_config: &core::Vector, buffer_weights: &core::Vector) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_Net_readFromModelOptimizer_const_vectorLunsigned_charGR_const_vectorLunsigned_charGR(buffer_model_config.as_raw_VectorOfu8(), buffer_weights.as_raw_VectorOfu8(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::Net::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for NaryEltwiseLayer { + /// Create a network from Intel's Model Optimizer in-memory buffers with intermediate representation (IR). + /// ## Parameters + /// * bufferModelConfigPtr: buffer pointer of model's configuration. + /// * bufferModelConfigSize: buffer size of model's configuration. + /// * bufferWeightsPtr: buffer pointer of model's trained weights. + /// * bufferWeightsSize: buffer size of model's trained weights. + /// ## Returns + /// Net object. #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn read_from_model_optimizer_2(buffer_model_config_ptr: &[u8], buffer_weights_ptr: &[u8]) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_Net_readFromModelOptimizer_const_unsigned_charX_size_t_const_unsigned_charX_size_t(buffer_model_config_ptr.as_ptr(), buffer_model_config_ptr.len(), buffer_weights_ptr.as_ptr(), buffer_weights_ptr.len(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::Net::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::Net] @@ -14486,30 +14707,21 @@ pub mod dnn { } - /// This class allows to create and manipulate comprehensive artificial neural networks. - /// - /// Neural network is presented as directed acyclic graph (DAG), where vertices are Layer instances, - /// and edges specify relationships between layers inputs and outputs. - /// - /// Each network layer has unique integer id and unique string name inside its network. - /// LayerId can store either layer name or layer id. - /// - /// This class supports reference counting of its instances, i. e. copies point to the same instance. - pub struct Net { - ptr: *mut c_void, + impl Clone for Net { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_dnn_Net_implicitClone_const(self.as_raw_Net())) } + } } - opencv_type_boxed! { Net } - - impl Drop for Net { + impl std::fmt::Debug for Net { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_Net_delete(self.as_raw_mut_Net()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Net") + .finish() } } - unsafe impl Send for Net {} - impl crate::dnn::NetTraitConst for Net { #[inline] fn as_raw_Net(&self) -> *const c_void { self.as_raw() } } @@ -14520,84 +14732,64 @@ pub mod dnn { boxed_ref! { Net, crate::dnn::NetTraitConst, as_raw_Net, crate::dnn::NetTrait, as_raw_mut_Net } - impl Net { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_Net_Net(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::Net::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Create a network from Intel's Model Optimizer intermediate representation (IR). - /// ## Parameters - /// * xml: XML configuration file with network's topology. - /// * bin: Binary file with trained weights. - /// Networks imported from Intel's Model Optimizer are launched in Intel's Inference Engine - /// backend. - #[inline] - pub fn read_from_model_optimizer(xml: &str, bin: &str) -> Result { - extern_container_arg!(xml); - extern_container_arg!(bin); - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_Net_readFromModelOptimizer_const_StringR_const_StringR(xml.opencv_as_extern(), bin.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::Net::opencv_from_extern(ret) }; - Ok(ret) - } + /// ![inline formula](https://latex.codecogs.com/png.latex?%20L%5Fp%20) - normalization layer. + /// ## Parameters + /// * p: Normalization factor. The most common `p = 1` for ![inline formula](https://latex.codecogs.com/png.latex?%20L%5F1%20) - + /// normalization or `p = 2` for ![inline formula](https://latex.codecogs.com/png.latex?%20L%5F2%20) - normalization or a custom one. + /// * eps: Parameter ![inline formula](https://latex.codecogs.com/png.latex?%20%5Cepsilon%20) to prevent a division by zero. + /// * across_spatial: If true, normalize an input across all non-batch dimensions. + /// Otherwise normalize an every channel separately. + /// + /// Across spatial: + /// @f[ + /// norm = \sqrt[p]{\epsilon + \sum_{x, y, c} |src(x, y, c)|^p } \\ + /// dst(x, y, c) = \frac{ src(x, y, c) }{norm} + /// @f] + /// + /// Channel wise normalization: + /// @f[ + /// norm(c) = \sqrt[p]{\epsilon + \sum_{x, y} |src(x, y, c)|^p } \\ + /// dst(x, y, c) = \frac{ src(x, y, c) }{norm(c)} + /// @f] + /// + /// Where `x, y` - spatial coordinates, `c` - channel. + /// + /// An every sample in the batch is normalized separately. Optionally, + /// output is scaled by the trained parameters. + pub struct NormalizeBBoxLayer { + ptr: *mut c_void, + } - /// Create a network from Intel's Model Optimizer in-memory buffers with intermediate representation (IR). - /// ## Parameters - /// * bufferModelConfig: buffer with model's configuration. - /// * bufferWeights: buffer with model's trained weights. - /// ## Returns - /// Net object. - #[inline] - pub fn read_from_model_optimizer_1(buffer_model_config: &core::Vector, buffer_weights: &core::Vector) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_Net_readFromModelOptimizer_const_vectorLunsigned_charGR_const_vectorLunsigned_charGR(buffer_model_config.as_raw_VectorOfu8(), buffer_weights.as_raw_VectorOfu8(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::Net::opencv_from_extern(ret) }; - Ok(ret) - } + opencv_type_boxed! { NormalizeBBoxLayer } - /// Create a network from Intel's Model Optimizer in-memory buffers with intermediate representation (IR). - /// ## Parameters - /// * bufferModelConfigPtr: buffer pointer of model's configuration. - /// * bufferModelConfigSize: buffer size of model's configuration. - /// * bufferWeightsPtr: buffer pointer of model's trained weights. - /// * bufferWeightsSize: buffer size of model's trained weights. - /// ## Returns - /// Net object. + impl Drop for NormalizeBBoxLayer { #[inline] - pub fn read_from_model_optimizer_2(buffer_model_config_ptr: &[u8], buffer_weights_ptr: &[u8]) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_Net_readFromModelOptimizer_const_unsigned_charX_size_t_const_unsigned_charX_size_t(buffer_model_config_ptr.as_ptr(), buffer_model_config_ptr.len(), buffer_weights_ptr.as_ptr(), buffer_weights_ptr.len(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::Net::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_NormalizeBBoxLayer_delete(self.as_raw_mut_NormalizeBBoxLayer()) }; } - } - impl Clone for Net { + unsafe impl Send for NormalizeBBoxLayer {} + + impl NormalizeBBoxLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_dnn_Net_implicitClone_const(self.as_raw_Net())) } + pub fn default() -> crate::dnn::NormalizeBBoxLayer { + let ret = unsafe { sys::cv_dnn_NormalizeBBoxLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::NormalizeBBoxLayer::opencv_from_extern(ret) }; + ret } - } - impl std::fmt::Debug for Net { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Net") - .finish() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_NormalizeBBoxLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::NormalizeBBoxLayer] @@ -14648,44 +14840,32 @@ pub mod dnn { } - /// ![inline formula](https://latex.codecogs.com/png.latex?%20L%5Fp%20) - normalization layer. - /// ## Parameters - /// * p: Normalization factor. The most common `p = 1` for ![inline formula](https://latex.codecogs.com/png.latex?%20L%5F1%20) - - /// normalization or `p = 2` for ![inline formula](https://latex.codecogs.com/png.latex?%20L%5F2%20) - normalization or a custom one. - /// * eps: Parameter ![inline formula](https://latex.codecogs.com/png.latex?%20%5Cepsilon%20) to prevent a division by zero. - /// * across_spatial: If true, normalize an input across all non-batch dimensions. - /// Otherwise normalize an every channel separately. - /// - /// Across spatial: - /// @f[ - /// norm = \sqrt[p]{\epsilon + \sum_{x, y, c} |src(x, y, c)|^p } \\ - /// dst(x, y, c) = \frac{ src(x, y, c) }{norm} - /// @f] - /// - /// Channel wise normalization: - /// @f[ - /// norm(c) = \sqrt[p]{\epsilon + \sum_{x, y} |src(x, y, c)|^p } \\ - /// dst(x, y, c) = \frac{ src(x, y, c) }{norm(c)} - /// @f] - /// - /// Where `x, y` - spatial coordinates, `c` - channel. - /// - /// An every sample in the batch is normalized separately. Optionally, - /// output is scaled by the trained parameters. - pub struct NormalizeBBoxLayer { - ptr: *mut c_void, + impl Default for NormalizeBBoxLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { NormalizeBBoxLayer } - - impl Drop for NormalizeBBoxLayer { + impl std::fmt::Debug for NormalizeBBoxLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_NormalizeBBoxLayer_delete(self.as_raw_mut_NormalizeBBoxLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("NormalizeBBoxLayer") + .field("pnorm", &crate::dnn::NormalizeBBoxLayerTraitConst::pnorm(self)) + .field("epsilon", &crate::dnn::NormalizeBBoxLayerTraitConst::epsilon(self)) + .field("across_spatial", &crate::dnn::NormalizeBBoxLayerTraitConst::across_spatial(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for NormalizeBBoxLayer {} + boxed_cast_base! { NormalizeBBoxLayer, core::Algorithm, cv_dnn_NormalizeBBoxLayer_to_Algorithm } + + boxed_cast_base! { NormalizeBBoxLayer, crate::dnn::Layer, cv_dnn_NormalizeBBoxLayer_to_Layer } impl core::AlgorithmTraitConst for NormalizeBBoxLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -14717,50 +14897,40 @@ pub mod dnn { boxed_ref! { NormalizeBBoxLayer, crate::dnn::NormalizeBBoxLayerTraitConst, as_raw_NormalizeBBoxLayer, crate::dnn::NormalizeBBoxLayerTrait, as_raw_mut_NormalizeBBoxLayer } - impl NormalizeBBoxLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_NormalizeBBoxLayer_defaultNew_const()) } - } + pub struct NotLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { NotLayer } + impl Drop for NotLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_NormalizeBBoxLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_NotLayer_delete(self.as_raw_mut_NotLayer()) }; } - } - boxed_cast_base! { NormalizeBBoxLayer, core::Algorithm, cv_dnn_NormalizeBBoxLayer_to_Algorithm } - - boxed_cast_base! { NormalizeBBoxLayer, crate::dnn::Layer, cv_dnn_NormalizeBBoxLayer_to_Layer } + unsafe impl Send for NotLayer {} - impl std::fmt::Debug for NormalizeBBoxLayer { + impl NotLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("NormalizeBBoxLayer") - .field("pnorm", &crate::dnn::NormalizeBBoxLayerTraitConst::pnorm(self)) - .field("epsilon", &crate::dnn::NormalizeBBoxLayerTraitConst::epsilon(self)) - .field("across_spatial", &crate::dnn::NormalizeBBoxLayerTraitConst::across_spatial(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::NotLayer { + let ret = unsafe { sys::cv_dnn_NotLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::NotLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for NormalizeBBoxLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_NotLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::NotLayer] @@ -14775,20 +14945,31 @@ pub mod dnn { } - pub struct NotLayer { - ptr: *mut c_void, + impl Default for NotLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { NotLayer } - - impl Drop for NotLayer { + impl std::fmt::Debug for NotLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_NotLayer_delete(self.as_raw_mut_NotLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("NotLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for NotLayer {} + boxed_cast_base! { NotLayer, crate::dnn::ActivationLayer, cv_dnn_NotLayer_to_ActivationLayer } + + boxed_cast_base! { NotLayer, core::Algorithm, cv_dnn_NotLayer_to_Algorithm } + + boxed_cast_base! { NotLayer, crate::dnn::Layer, cv_dnn_NotLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for NotLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -14830,63 +15011,6 @@ pub mod dnn { boxed_ref! { NotLayer, crate::dnn::NotLayerTraitConst, as_raw_NotLayer, crate::dnn::NotLayerTrait, as_raw_mut_NotLayer } - impl NotLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_NotLayer_defaultNew_const()) } - } - - #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_NotLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { NotLayer, crate::dnn::ActivationLayer, cv_dnn_NotLayer_to_ActivationLayer } - - boxed_cast_base! { NotLayer, core::Algorithm, cv_dnn_NotLayer_to_Algorithm } - - boxed_cast_base! { NotLayer, crate::dnn::Layer, cv_dnn_NotLayer_to_Layer } - - impl std::fmt::Debug for NotLayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("NotLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for NotLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - - /// Constant methods for [crate::dnn::PaddingLayer] - pub trait PaddingLayerTraitConst: crate::dnn::LayerTraitConst { - fn as_raw_PaddingLayer(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::dnn::PaddingLayer] - pub trait PaddingLayerTrait: crate::dnn::LayerTrait + crate::dnn::PaddingLayerTraitConst { - fn as_raw_mut_PaddingLayer(&mut self) -> *mut c_void; - - } - /// Adds extra values for specific axes. /// ## Parameters /// * paddings: Vector of paddings in format @@ -14922,6 +15046,63 @@ pub mod dnn { unsafe impl Send for PaddingLayer {} + impl PaddingLayer { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::dnn::PaddingLayer { + let ret = unsafe { sys::cv_dnn_PaddingLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::PaddingLayer::opencv_from_extern(ret) }; + ret + } + + #[inline] + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_PaddingLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::dnn::PaddingLayer] + pub trait PaddingLayerTraitConst: crate::dnn::LayerTraitConst { + fn as_raw_PaddingLayer(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::dnn::PaddingLayer] + pub trait PaddingLayerTrait: crate::dnn::LayerTrait + crate::dnn::PaddingLayerTraitConst { + fn as_raw_mut_PaddingLayer(&mut self) -> *mut c_void; + + } + + impl Default for PaddingLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } + } + + impl std::fmt::Debug for PaddingLayer { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PaddingLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() + } + } + + boxed_cast_base! { PaddingLayer, core::Algorithm, cv_dnn_PaddingLayer_to_Algorithm } + + boxed_cast_base! { PaddingLayer, crate::dnn::Layer, cv_dnn_PaddingLayer_to_Layer } + impl core::AlgorithmTraitConst for PaddingLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } } @@ -14950,51 +15131,44 @@ pub mod dnn { #[inline] fn as_raw_mut_PaddingLayer(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { PaddingLayer, crate::dnn::PaddingLayerTraitConst, as_raw_PaddingLayer, crate::dnn::PaddingLayerTrait, as_raw_mut_PaddingLayer } + boxed_ref! { PaddingLayer, crate::dnn::PaddingLayerTraitConst, as_raw_PaddingLayer, crate::dnn::PaddingLayerTrait, as_raw_mut_PaddingLayer } + + pub struct PermuteLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { PermuteLayer } + + impl Drop for PermuteLayer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_PermuteLayer_delete(self.as_raw_mut_PermuteLayer()) }; + } + } + + unsafe impl Send for PermuteLayer {} - impl PaddingLayer { + impl PermuteLayer { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_PaddingLayer_defaultNew_const()) } + pub fn default() -> crate::dnn::PermuteLayer { + let ret = unsafe { sys::cv_dnn_PermuteLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::PermuteLayer::opencv_from_extern(ret) }; + ret } #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_PaddingLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_PermuteLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { PaddingLayer, core::Algorithm, cv_dnn_PaddingLayer_to_Algorithm } - - boxed_cast_base! { PaddingLayer, crate::dnn::Layer, cv_dnn_PaddingLayer_to_Layer } - - impl std::fmt::Debug for PaddingLayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PaddingLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for PaddingLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - /// Constant methods for [crate::dnn::PermuteLayer] pub trait PermuteLayerTraitConst: crate::dnn::LayerTraitConst { fn as_raw_PermuteLayer(&self) -> *const c_void; @@ -15007,20 +15181,29 @@ pub mod dnn { } - pub struct PermuteLayer { - ptr: *mut c_void, + impl Default for PermuteLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { PermuteLayer } - - impl Drop for PermuteLayer { + impl std::fmt::Debug for PermuteLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_PermuteLayer_delete(self.as_raw_mut_PermuteLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PermuteLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for PermuteLayer {} + boxed_cast_base! { PermuteLayer, core::Algorithm, cv_dnn_PermuteLayer_to_Algorithm } + + boxed_cast_base! { PermuteLayer, crate::dnn::Layer, cv_dnn_PermuteLayer_to_Layer } impl core::AlgorithmTraitConst for PermuteLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -15052,47 +15235,40 @@ pub mod dnn { boxed_ref! { PermuteLayer, crate::dnn::PermuteLayerTraitConst, as_raw_PermuteLayer, crate::dnn::PermuteLayerTrait, as_raw_mut_PermuteLayer } - impl PermuteLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_PermuteLayer_defaultNew_const()) } - } + pub struct PoolingLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { PoolingLayer } + impl Drop for PoolingLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_PermuteLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_PoolingLayer_delete(self.as_raw_mut_PoolingLayer()) }; } - } - boxed_cast_base! { PermuteLayer, core::Algorithm, cv_dnn_PermuteLayer_to_Algorithm } - - boxed_cast_base! { PermuteLayer, crate::dnn::Layer, cv_dnn_PermuteLayer_to_Layer } + unsafe impl Send for PoolingLayer {} - impl std::fmt::Debug for PermuteLayer { + impl PoolingLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PermuteLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::PoolingLayer { + let ret = unsafe { sys::cv_dnn_PoolingLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::PoolingLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for PermuteLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_PoolingLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::PoolingLayer] @@ -15286,20 +15462,43 @@ pub mod dnn { } - pub struct PoolingLayer { - ptr: *mut c_void, + impl Default for PoolingLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { PoolingLayer } - - impl Drop for PoolingLayer { + impl std::fmt::Debug for PoolingLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_PoolingLayer_delete(self.as_raw_mut_PoolingLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PoolingLayer") + .field("typ", &crate::dnn::PoolingLayerTraitConst::typ(self)) + .field("kernel_size", &crate::dnn::PoolingLayerTraitConst::kernel_size(self)) + .field("strides", &crate::dnn::PoolingLayerTraitConst::strides(self)) + .field("pads_begin", &crate::dnn::PoolingLayerTraitConst::pads_begin(self)) + .field("pads_end", &crate::dnn::PoolingLayerTraitConst::pads_end(self)) + .field("global_pooling", &crate::dnn::PoolingLayerTraitConst::global_pooling(self)) + .field("is_global_pooling", &crate::dnn::PoolingLayerTraitConst::is_global_pooling(self)) + .field("compute_max_idx", &crate::dnn::PoolingLayerTraitConst::compute_max_idx(self)) + .field("pad_mode", &crate::dnn::PoolingLayerTraitConst::pad_mode(self)) + .field("ceil_mode", &crate::dnn::PoolingLayerTraitConst::ceil_mode(self)) + .field("ave_pool_padded_area", &crate::dnn::PoolingLayerTraitConst::ave_pool_padded_area(self)) + .field("pooled_size", &crate::dnn::PoolingLayerTraitConst::pooled_size(self)) + .field("spatial_scale", &crate::dnn::PoolingLayerTraitConst::spatial_scale(self)) + .field("ps_roi_out_channels", &crate::dnn::PoolingLayerTraitConst::ps_roi_out_channels(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for PoolingLayer {} + boxed_cast_base! { PoolingLayer, core::Algorithm, cv_dnn_PoolingLayer_to_Algorithm } + + boxed_cast_base! { PoolingLayer, crate::dnn::Layer, cv_dnn_PoolingLayer_to_Layer } impl core::AlgorithmTraitConst for PoolingLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -15331,61 +15530,40 @@ pub mod dnn { boxed_ref! { PoolingLayer, crate::dnn::PoolingLayerTraitConst, as_raw_PoolingLayer, crate::dnn::PoolingLayerTrait, as_raw_mut_PoolingLayer } - impl PoolingLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_PoolingLayer_defaultNew_const()) } - } + pub struct PoolingLayerInt8 { + ptr: *mut c_void, + } + + opencv_type_boxed! { PoolingLayerInt8 } + impl Drop for PoolingLayerInt8 { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_PoolingLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_PoolingLayerInt8_delete(self.as_raw_mut_PoolingLayerInt8()) }; } - } - boxed_cast_base! { PoolingLayer, core::Algorithm, cv_dnn_PoolingLayer_to_Algorithm } - - boxed_cast_base! { PoolingLayer, crate::dnn::Layer, cv_dnn_PoolingLayer_to_Layer } + unsafe impl Send for PoolingLayerInt8 {} - impl std::fmt::Debug for PoolingLayer { + impl PoolingLayerInt8 { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PoolingLayer") - .field("typ", &crate::dnn::PoolingLayerTraitConst::typ(self)) - .field("kernel_size", &crate::dnn::PoolingLayerTraitConst::kernel_size(self)) - .field("strides", &crate::dnn::PoolingLayerTraitConst::strides(self)) - .field("pads_begin", &crate::dnn::PoolingLayerTraitConst::pads_begin(self)) - .field("pads_end", &crate::dnn::PoolingLayerTraitConst::pads_end(self)) - .field("global_pooling", &crate::dnn::PoolingLayerTraitConst::global_pooling(self)) - .field("is_global_pooling", &crate::dnn::PoolingLayerTraitConst::is_global_pooling(self)) - .field("compute_max_idx", &crate::dnn::PoolingLayerTraitConst::compute_max_idx(self)) - .field("pad_mode", &crate::dnn::PoolingLayerTraitConst::pad_mode(self)) - .field("ceil_mode", &crate::dnn::PoolingLayerTraitConst::ceil_mode(self)) - .field("ave_pool_padded_area", &crate::dnn::PoolingLayerTraitConst::ave_pool_padded_area(self)) - .field("pooled_size", &crate::dnn::PoolingLayerTraitConst::pooled_size(self)) - .field("spatial_scale", &crate::dnn::PoolingLayerTraitConst::spatial_scale(self)) - .field("ps_roi_out_channels", &crate::dnn::PoolingLayerTraitConst::ps_roi_out_channels(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::PoolingLayerInt8 { + let ret = unsafe { sys::cv_dnn_PoolingLayerInt8_defaultNew_const() }; + let ret = unsafe { crate::dnn::PoolingLayerInt8::opencv_from_extern(ret) }; + ret } - } - impl Default for PoolingLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_PoolingLayerInt8_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::PoolingLayerInt8] @@ -15448,20 +15626,49 @@ pub mod dnn { } - pub struct PoolingLayerInt8 { - ptr: *mut c_void, + impl Default for PoolingLayerInt8 { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { PoolingLayerInt8 } - - impl Drop for PoolingLayerInt8 { + impl std::fmt::Debug for PoolingLayerInt8 { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_PoolingLayerInt8_delete(self.as_raw_mut_PoolingLayerInt8()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PoolingLayerInt8") + .field("input_zp", &crate::dnn::PoolingLayerInt8TraitConst::input_zp(self)) + .field("output_zp", &crate::dnn::PoolingLayerInt8TraitConst::output_zp(self)) + .field("input_sc", &crate::dnn::PoolingLayerInt8TraitConst::input_sc(self)) + .field("output_sc", &crate::dnn::PoolingLayerInt8TraitConst::output_sc(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .field("typ", &crate::dnn::PoolingLayerTraitConst::typ(self)) + .field("kernel_size", &crate::dnn::PoolingLayerTraitConst::kernel_size(self)) + .field("strides", &crate::dnn::PoolingLayerTraitConst::strides(self)) + .field("pads_begin", &crate::dnn::PoolingLayerTraitConst::pads_begin(self)) + .field("pads_end", &crate::dnn::PoolingLayerTraitConst::pads_end(self)) + .field("global_pooling", &crate::dnn::PoolingLayerTraitConst::global_pooling(self)) + .field("is_global_pooling", &crate::dnn::PoolingLayerTraitConst::is_global_pooling(self)) + .field("compute_max_idx", &crate::dnn::PoolingLayerTraitConst::compute_max_idx(self)) + .field("pad_mode", &crate::dnn::PoolingLayerTraitConst::pad_mode(self)) + .field("ceil_mode", &crate::dnn::PoolingLayerTraitConst::ceil_mode(self)) + .field("ave_pool_padded_area", &crate::dnn::PoolingLayerTraitConst::ave_pool_padded_area(self)) + .field("pooled_size", &crate::dnn::PoolingLayerTraitConst::pooled_size(self)) + .field("spatial_scale", &crate::dnn::PoolingLayerTraitConst::spatial_scale(self)) + .field("ps_roi_out_channels", &crate::dnn::PoolingLayerTraitConst::ps_roi_out_channels(self)) + .finish() } } - unsafe impl Send for PoolingLayerInt8 {} + boxed_cast_base! { PoolingLayerInt8, core::Algorithm, cv_dnn_PoolingLayerInt8_to_Algorithm } + + boxed_cast_base! { PoolingLayerInt8, crate::dnn::Layer, cv_dnn_PoolingLayerInt8_to_Layer } + + boxed_cast_base! { PoolingLayerInt8, crate::dnn::PoolingLayer, cv_dnn_PoolingLayerInt8_to_PoolingLayer } impl core::AlgorithmTraitConst for PoolingLayerInt8 { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -15503,67 +15710,40 @@ pub mod dnn { boxed_ref! { PoolingLayerInt8, crate::dnn::PoolingLayerInt8TraitConst, as_raw_PoolingLayerInt8, crate::dnn::PoolingLayerInt8Trait, as_raw_mut_PoolingLayerInt8 } - impl PoolingLayerInt8 { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_PoolingLayerInt8_defaultNew_const()) } - } + pub struct PowerLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { PowerLayer } + impl Drop for PowerLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_PoolingLayerInt8_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_PowerLayer_delete(self.as_raw_mut_PowerLayer()) }; } - } - boxed_cast_base! { PoolingLayerInt8, core::Algorithm, cv_dnn_PoolingLayerInt8_to_Algorithm } - - boxed_cast_base! { PoolingLayerInt8, crate::dnn::Layer, cv_dnn_PoolingLayerInt8_to_Layer } - - boxed_cast_base! { PoolingLayerInt8, crate::dnn::PoolingLayer, cv_dnn_PoolingLayerInt8_to_PoolingLayer } + unsafe impl Send for PowerLayer {} - impl std::fmt::Debug for PoolingLayerInt8 { + impl PowerLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PoolingLayerInt8") - .field("input_zp", &crate::dnn::PoolingLayerInt8TraitConst::input_zp(self)) - .field("output_zp", &crate::dnn::PoolingLayerInt8TraitConst::output_zp(self)) - .field("input_sc", &crate::dnn::PoolingLayerInt8TraitConst::input_sc(self)) - .field("output_sc", &crate::dnn::PoolingLayerInt8TraitConst::output_sc(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .field("typ", &crate::dnn::PoolingLayerTraitConst::typ(self)) - .field("kernel_size", &crate::dnn::PoolingLayerTraitConst::kernel_size(self)) - .field("strides", &crate::dnn::PoolingLayerTraitConst::strides(self)) - .field("pads_begin", &crate::dnn::PoolingLayerTraitConst::pads_begin(self)) - .field("pads_end", &crate::dnn::PoolingLayerTraitConst::pads_end(self)) - .field("global_pooling", &crate::dnn::PoolingLayerTraitConst::global_pooling(self)) - .field("is_global_pooling", &crate::dnn::PoolingLayerTraitConst::is_global_pooling(self)) - .field("compute_max_idx", &crate::dnn::PoolingLayerTraitConst::compute_max_idx(self)) - .field("pad_mode", &crate::dnn::PoolingLayerTraitConst::pad_mode(self)) - .field("ceil_mode", &crate::dnn::PoolingLayerTraitConst::ceil_mode(self)) - .field("ave_pool_padded_area", &crate::dnn::PoolingLayerTraitConst::ave_pool_padded_area(self)) - .field("pooled_size", &crate::dnn::PoolingLayerTraitConst::pooled_size(self)) - .field("spatial_scale", &crate::dnn::PoolingLayerTraitConst::spatial_scale(self)) - .field("ps_roi_out_channels", &crate::dnn::PoolingLayerTraitConst::ps_roi_out_channels(self)) - .finish() + pub fn default() -> crate::dnn::PowerLayer { + let ret = unsafe { sys::cv_dnn_PowerLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::PowerLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for PoolingLayerInt8 { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_PowerLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::PowerLayer] @@ -15614,20 +15794,34 @@ pub mod dnn { } - pub struct PowerLayer { - ptr: *mut c_void, + impl Default for PowerLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { PowerLayer } - - impl Drop for PowerLayer { + impl std::fmt::Debug for PowerLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_PowerLayer_delete(self.as_raw_mut_PowerLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PowerLayer") + .field("power", &crate::dnn::PowerLayerTraitConst::power(self)) + .field("scale", &crate::dnn::PowerLayerTraitConst::scale(self)) + .field("shift", &crate::dnn::PowerLayerTraitConst::shift(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for PowerLayer {} + boxed_cast_base! { PowerLayer, crate::dnn::ActivationLayer, cv_dnn_PowerLayer_to_ActivationLayer } + + boxed_cast_base! { PowerLayer, core::Algorithm, cv_dnn_PowerLayer_to_Algorithm } + + boxed_cast_base! { PowerLayer, crate::dnn::Layer, cv_dnn_PowerLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for PowerLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -15669,52 +15863,40 @@ pub mod dnn { boxed_ref! { PowerLayer, crate::dnn::PowerLayerTraitConst, as_raw_PowerLayer, crate::dnn::PowerLayerTrait, as_raw_mut_PowerLayer } - impl PowerLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_PowerLayer_defaultNew_const()) } - } + pub struct PriorBoxLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { PriorBoxLayer } + impl Drop for PriorBoxLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_PowerLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_PriorBoxLayer_delete(self.as_raw_mut_PriorBoxLayer()) }; } - } - boxed_cast_base! { PowerLayer, crate::dnn::ActivationLayer, cv_dnn_PowerLayer_to_ActivationLayer } - - boxed_cast_base! { PowerLayer, core::Algorithm, cv_dnn_PowerLayer_to_Algorithm } - - boxed_cast_base! { PowerLayer, crate::dnn::Layer, cv_dnn_PowerLayer_to_Layer } + unsafe impl Send for PriorBoxLayer {} - impl std::fmt::Debug for PowerLayer { + impl PriorBoxLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PowerLayer") - .field("power", &crate::dnn::PowerLayerTraitConst::power(self)) - .field("scale", &crate::dnn::PowerLayerTraitConst::scale(self)) - .field("shift", &crate::dnn::PowerLayerTraitConst::shift(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::PriorBoxLayer { + let ret = unsafe { sys::cv_dnn_PriorBoxLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::PriorBoxLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for PowerLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_PriorBoxLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::PriorBoxLayer] @@ -15729,20 +15911,29 @@ pub mod dnn { } - pub struct PriorBoxLayer { - ptr: *mut c_void, + impl Default for PriorBoxLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { PriorBoxLayer } - - impl Drop for PriorBoxLayer { + impl std::fmt::Debug for PriorBoxLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_PriorBoxLayer_delete(self.as_raw_mut_PriorBoxLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PriorBoxLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for PriorBoxLayer {} + boxed_cast_base! { PriorBoxLayer, core::Algorithm, cv_dnn_PriorBoxLayer_to_Algorithm } + + boxed_cast_base! { PriorBoxLayer, crate::dnn::Layer, cv_dnn_PriorBoxLayer_to_Layer } impl core::AlgorithmTraitConst for PriorBoxLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -15774,47 +15965,40 @@ pub mod dnn { boxed_ref! { PriorBoxLayer, crate::dnn::PriorBoxLayerTraitConst, as_raw_PriorBoxLayer, crate::dnn::PriorBoxLayerTrait, as_raw_mut_PriorBoxLayer } - impl PriorBoxLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_PriorBoxLayer_defaultNew_const()) } - } + pub struct ProposalLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { ProposalLayer } + impl Drop for ProposalLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_PriorBoxLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ProposalLayer_delete(self.as_raw_mut_ProposalLayer()) }; } - } - boxed_cast_base! { PriorBoxLayer, core::Algorithm, cv_dnn_PriorBoxLayer_to_Algorithm } - - boxed_cast_base! { PriorBoxLayer, crate::dnn::Layer, cv_dnn_PriorBoxLayer_to_Layer } + unsafe impl Send for ProposalLayer {} - impl std::fmt::Debug for PriorBoxLayer { + impl ProposalLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PriorBoxLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::ProposalLayer { + let ret = unsafe { sys::cv_dnn_ProposalLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ProposalLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for PriorBoxLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ProposalLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ProposalLayer] @@ -15829,20 +16013,29 @@ pub mod dnn { } - pub struct ProposalLayer { - ptr: *mut c_void, + impl Default for ProposalLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ProposalLayer } - - impl Drop for ProposalLayer { + impl std::fmt::Debug for ProposalLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ProposalLayer_delete(self.as_raw_mut_ProposalLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ProposalLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ProposalLayer {} + boxed_cast_base! { ProposalLayer, core::Algorithm, cv_dnn_ProposalLayer_to_Algorithm } + + boxed_cast_base! { ProposalLayer, crate::dnn::Layer, cv_dnn_ProposalLayer_to_Layer } impl core::AlgorithmTraitConst for ProposalLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -15874,47 +16067,40 @@ pub mod dnn { boxed_ref! { ProposalLayer, crate::dnn::ProposalLayerTraitConst, as_raw_ProposalLayer, crate::dnn::ProposalLayerTrait, as_raw_mut_ProposalLayer } - impl ProposalLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ProposalLayer_defaultNew_const()) } - } + pub struct QuantizeLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { QuantizeLayer } + impl Drop for QuantizeLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ProposalLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_QuantizeLayer_delete(self.as_raw_mut_QuantizeLayer()) }; } - } - boxed_cast_base! { ProposalLayer, core::Algorithm, cv_dnn_ProposalLayer_to_Algorithm } - - boxed_cast_base! { ProposalLayer, crate::dnn::Layer, cv_dnn_ProposalLayer_to_Layer } + unsafe impl Send for QuantizeLayer {} - impl std::fmt::Debug for ProposalLayer { + impl QuantizeLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ProposalLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::QuantizeLayer { + let ret = unsafe { sys::cv_dnn_QuantizeLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::QuantizeLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for ProposalLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_QuantizeLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::QuantizeLayer] @@ -15955,20 +16141,31 @@ pub mod dnn { } - pub struct QuantizeLayer { - ptr: *mut c_void, + impl Default for QuantizeLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { QuantizeLayer } - - impl Drop for QuantizeLayer { + impl std::fmt::Debug for QuantizeLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_QuantizeLayer_delete(self.as_raw_mut_QuantizeLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("QuantizeLayer") + .field("scales", &crate::dnn::QuantizeLayerTraitConst::scales(self)) + .field("zeropoints", &crate::dnn::QuantizeLayerTraitConst::zeropoints(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for QuantizeLayer {} + boxed_cast_base! { QuantizeLayer, core::Algorithm, cv_dnn_QuantizeLayer_to_Algorithm } + + boxed_cast_base! { QuantizeLayer, crate::dnn::Layer, cv_dnn_QuantizeLayer_to_Layer } impl core::AlgorithmTraitConst for QuantizeLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -16000,51 +16197,47 @@ pub mod dnn { boxed_ref! { QuantizeLayer, crate::dnn::QuantizeLayerTraitConst, as_raw_QuantizeLayer, crate::dnn::QuantizeLayerTrait, as_raw_mut_QuantizeLayer } - impl QuantizeLayer { - /// Creates a default instance of the class by calling the default constructor + /// Classical recurrent layer + /// + /// Accepts two inputs @f$x_t@f$ and @f$h_{t-1}@f$ and compute two outputs @f$o_t@f$ and @f$h_t@f$. + /// + /// - input: should contain packed input @f$x_t@f$. + /// - output: should contain output @f$o_t@f$ (and @f$h_t@f$ if setProduceHiddenOutput() is set to true). + /// + /// input[0] should have shape [`T`, `N`, `data_dims`] where `T` and `N` is number of timestamps and number of independent samples of @f$x_t@f$ respectively. + /// + /// output[0] will have shape [`T`, `N`, @f$N_o@f$], where @f$N_o@f$ is number of rows in @f$ W_{xo} @f$ matrix. + /// + /// If setProduceHiddenOutput() is set to true then @p output[1] will contain a Mat with shape [`T`, `N`, @f$N_h@f$], where @f$N_h@f$ is number of rows in @f$ W_{hh} @f$ matrix. + pub struct RNNLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { RNNLayer } + + impl Drop for RNNLayer { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_QuantizeLayer_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_dnn_RNNLayer_delete(self.as_raw_mut_RNNLayer()) }; } + } + unsafe impl Send for RNNLayer {} + + impl RNNLayer { + /// Creates instance of RNNLayer #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_QuantizeLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_RNNLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { QuantizeLayer, core::Algorithm, cv_dnn_QuantizeLayer_to_Algorithm } - - boxed_cast_base! { QuantizeLayer, crate::dnn::Layer, cv_dnn_QuantizeLayer_to_Layer } - - impl std::fmt::Debug for QuantizeLayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("QuantizeLayer") - .field("scales", &crate::dnn::QuantizeLayerTraitConst::scales(self)) - .field("zeropoints", &crate::dnn::QuantizeLayerTraitConst::zeropoints(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for QuantizeLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - /// Constant methods for [crate::dnn::RNNLayer] pub trait RNNLayerTraitConst: crate::dnn::LayerTraitConst { fn as_raw_RNNLayer(&self) -> *const c_void; @@ -16109,32 +16302,21 @@ pub mod dnn { } - /// Classical recurrent layer - /// - /// Accepts two inputs @f$x_t@f$ and @f$h_{t-1}@f$ and compute two outputs @f$o_t@f$ and @f$h_t@f$. - /// - /// - input: should contain packed input @f$x_t@f$. - /// - output: should contain output @f$o_t@f$ (and @f$h_t@f$ if setProduceHiddenOutput() is set to true). - /// - /// input[0] should have shape [`T`, `N`, `data_dims`] where `T` and `N` is number of timestamps and number of independent samples of @f$x_t@f$ respectively. - /// - /// output[0] will have shape [`T`, `N`, @f$N_o@f$], where @f$N_o@f$ is number of rows in @f$ W_{xo} @f$ matrix. - /// - /// If setProduceHiddenOutput() is set to true then @p output[1] will contain a Mat with shape [`T`, `N`, @f$N_h@f$], where @f$N_h@f$ is number of rows in @f$ W_{hh} @f$ matrix. - pub struct RNNLayer { - ptr: *mut c_void, - } - - opencv_type_boxed! { RNNLayer } - - impl Drop for RNNLayer { + impl std::fmt::Debug for RNNLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_RNNLayer_delete(self.as_raw_mut_RNNLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RNNLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for RNNLayer {} + boxed_cast_base! { RNNLayer, core::Algorithm, cv_dnn_RNNLayer_to_Algorithm } + + boxed_cast_base! { RNNLayer, crate::dnn::Layer, cv_dnn_RNNLayer_to_Layer } impl core::AlgorithmTraitConst for RNNLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -16166,34 +16348,40 @@ pub mod dnn { boxed_ref! { RNNLayer, crate::dnn::RNNLayerTraitConst, as_raw_RNNLayer, crate::dnn::RNNLayerTrait, as_raw_mut_RNNLayer } - impl RNNLayer { - /// Creates instance of RNNLayer + pub struct ReLU6Layer { + ptr: *mut c_void, + } + + opencv_type_boxed! { ReLU6Layer } + + impl Drop for ReLU6Layer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_RNNLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ReLU6Layer_delete(self.as_raw_mut_ReLU6Layer()) }; } - } - boxed_cast_base! { RNNLayer, core::Algorithm, cv_dnn_RNNLayer_to_Algorithm } + unsafe impl Send for ReLU6Layer {} - boxed_cast_base! { RNNLayer, crate::dnn::Layer, cv_dnn_RNNLayer_to_Layer } + impl ReLU6Layer { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::dnn::ReLU6Layer { + let ret = unsafe { sys::cv_dnn_ReLU6Layer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ReLU6Layer::opencv_from_extern(ret) }; + ret + } - impl std::fmt::Debug for RNNLayer { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RNNLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ReLU6Layer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ReLU6Layer] @@ -16232,20 +16420,33 @@ pub mod dnn { } - pub struct ReLU6Layer { - ptr: *mut c_void, + impl Default for ReLU6Layer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ReLU6Layer } - - impl Drop for ReLU6Layer { + impl std::fmt::Debug for ReLU6Layer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ReLU6Layer_delete(self.as_raw_mut_ReLU6Layer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ReLU6Layer") + .field("min_value", &crate::dnn::ReLU6LayerTraitConst::min_value(self)) + .field("max_value", &crate::dnn::ReLU6LayerTraitConst::max_value(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ReLU6Layer {} + boxed_cast_base! { ReLU6Layer, crate::dnn::ActivationLayer, cv_dnn_ReLU6Layer_to_ActivationLayer } + + boxed_cast_base! { ReLU6Layer, core::Algorithm, cv_dnn_ReLU6Layer_to_Algorithm } + + boxed_cast_base! { ReLU6Layer, crate::dnn::Layer, cv_dnn_ReLU6Layer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for ReLU6Layer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -16281,59 +16482,48 @@ pub mod dnn { #[inline] fn as_raw_ReLU6Layer(&self) -> *const c_void { self.as_raw() } } - impl crate::dnn::ReLU6LayerTrait for ReLU6Layer { - #[inline] fn as_raw_mut_ReLU6Layer(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::dnn::ReLU6LayerTrait for ReLU6Layer { + #[inline] fn as_raw_mut_ReLU6Layer(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { ReLU6Layer, crate::dnn::ReLU6LayerTraitConst, as_raw_ReLU6Layer, crate::dnn::ReLU6LayerTrait, as_raw_mut_ReLU6Layer } + + pub struct ReLULayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { ReLULayer } + + impl Drop for ReLULayer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_ReLULayer_delete(self.as_raw_mut_ReLULayer()) }; + } } - boxed_ref! { ReLU6Layer, crate::dnn::ReLU6LayerTraitConst, as_raw_ReLU6Layer, crate::dnn::ReLU6LayerTrait, as_raw_mut_ReLU6Layer } + unsafe impl Send for ReLULayer {} - impl ReLU6Layer { + impl ReLULayer { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ReLU6Layer_defaultNew_const()) } + pub fn default() -> crate::dnn::ReLULayer { + let ret = unsafe { sys::cv_dnn_ReLULayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ReLULayer::opencv_from_extern(ret) }; + ret } #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ReLU6Layer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_ReLULayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { ReLU6Layer, crate::dnn::ActivationLayer, cv_dnn_ReLU6Layer_to_ActivationLayer } - - boxed_cast_base! { ReLU6Layer, core::Algorithm, cv_dnn_ReLU6Layer_to_Algorithm } - - boxed_cast_base! { ReLU6Layer, crate::dnn::Layer, cv_dnn_ReLU6Layer_to_Layer } - - impl std::fmt::Debug for ReLU6Layer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ReLU6Layer") - .field("min_value", &crate::dnn::ReLU6LayerTraitConst::min_value(self)) - .field("max_value", &crate::dnn::ReLU6LayerTraitConst::max_value(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for ReLU6Layer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - /// Constant methods for [crate::dnn::ReLULayer] pub trait ReLULayerTraitConst: crate::dnn::ActivationLayerTraitConst { fn as_raw_ReLULayer(&self) -> *const c_void; @@ -16358,20 +16548,32 @@ pub mod dnn { } - pub struct ReLULayer { - ptr: *mut c_void, + impl Default for ReLULayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ReLULayer } - - impl Drop for ReLULayer { + impl std::fmt::Debug for ReLULayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ReLULayer_delete(self.as_raw_mut_ReLULayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ReLULayer") + .field("negative_slope", &crate::dnn::ReLULayerTraitConst::negative_slope(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ReLULayer {} + boxed_cast_base! { ReLULayer, crate::dnn::ActivationLayer, cv_dnn_ReLULayer_to_ActivationLayer } + + boxed_cast_base! { ReLULayer, core::Algorithm, cv_dnn_ReLULayer_to_Algorithm } + + boxed_cast_base! { ReLULayer, crate::dnn::Layer, cv_dnn_ReLULayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for ReLULayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -16413,50 +16615,40 @@ pub mod dnn { boxed_ref! { ReLULayer, crate::dnn::ReLULayerTraitConst, as_raw_ReLULayer, crate::dnn::ReLULayerTrait, as_raw_mut_ReLULayer } - impl ReLULayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ReLULayer_defaultNew_const()) } - } + pub struct ReciprocalLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { ReciprocalLayer } + + impl Drop for ReciprocalLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ReLULayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ReciprocalLayer_delete(self.as_raw_mut_ReciprocalLayer()) }; } - } - boxed_cast_base! { ReLULayer, crate::dnn::ActivationLayer, cv_dnn_ReLULayer_to_ActivationLayer } - - boxed_cast_base! { ReLULayer, core::Algorithm, cv_dnn_ReLULayer_to_Algorithm } - - boxed_cast_base! { ReLULayer, crate::dnn::Layer, cv_dnn_ReLULayer_to_Layer } + unsafe impl Send for ReciprocalLayer {} - impl std::fmt::Debug for ReLULayer { + impl ReciprocalLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ReLULayer") - .field("negative_slope", &crate::dnn::ReLULayerTraitConst::negative_slope(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::ReciprocalLayer { + let ret = unsafe { sys::cv_dnn_ReciprocalLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ReciprocalLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for ReLULayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ReciprocalLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ReciprocalLayer] @@ -16471,20 +16663,31 @@ pub mod dnn { } - pub struct ReciprocalLayer { - ptr: *mut c_void, + impl Default for ReciprocalLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ReciprocalLayer } - - impl Drop for ReciprocalLayer { + impl std::fmt::Debug for ReciprocalLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ReciprocalLayer_delete(self.as_raw_mut_ReciprocalLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ReciprocalLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ReciprocalLayer {} + boxed_cast_base! { ReciprocalLayer, crate::dnn::ActivationLayer, cv_dnn_ReciprocalLayer_to_ActivationLayer } + + boxed_cast_base! { ReciprocalLayer, core::Algorithm, cv_dnn_ReciprocalLayer_to_Algorithm } + + boxed_cast_base! { ReciprocalLayer, crate::dnn::Layer, cv_dnn_ReciprocalLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for ReciprocalLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -16526,49 +16729,40 @@ pub mod dnn { boxed_ref! { ReciprocalLayer, crate::dnn::ReciprocalLayerTraitConst, as_raw_ReciprocalLayer, crate::dnn::ReciprocalLayerTrait, as_raw_mut_ReciprocalLayer } - impl ReciprocalLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ReciprocalLayer_defaultNew_const()) } - } + pub struct ReduceLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { ReduceLayer } + impl Drop for ReduceLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ReciprocalLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ReduceLayer_delete(self.as_raw_mut_ReduceLayer()) }; } - } - boxed_cast_base! { ReciprocalLayer, crate::dnn::ActivationLayer, cv_dnn_ReciprocalLayer_to_ActivationLayer } - - boxed_cast_base! { ReciprocalLayer, core::Algorithm, cv_dnn_ReciprocalLayer_to_Algorithm } - - boxed_cast_base! { ReciprocalLayer, crate::dnn::Layer, cv_dnn_ReciprocalLayer_to_Layer } + unsafe impl Send for ReduceLayer {} - impl std::fmt::Debug for ReciprocalLayer { + impl ReduceLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ReciprocalLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::ReduceLayer { + let ret = unsafe { sys::cv_dnn_ReduceLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ReduceLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for ReciprocalLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ReduceLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ReduceLayer] @@ -16583,20 +16777,29 @@ pub mod dnn { } - pub struct ReduceLayer { - ptr: *mut c_void, + impl Default for ReduceLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ReduceLayer } - - impl Drop for ReduceLayer { + impl std::fmt::Debug for ReduceLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ReduceLayer_delete(self.as_raw_mut_ReduceLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ReduceLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ReduceLayer {} + boxed_cast_base! { ReduceLayer, core::Algorithm, cv_dnn_ReduceLayer_to_Algorithm } + + boxed_cast_base! { ReduceLayer, crate::dnn::Layer, cv_dnn_ReduceLayer_to_Layer } impl core::AlgorithmTraitConst for ReduceLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -16628,47 +16831,40 @@ pub mod dnn { boxed_ref! { ReduceLayer, crate::dnn::ReduceLayerTraitConst, as_raw_ReduceLayer, crate::dnn::ReduceLayerTrait, as_raw_mut_ReduceLayer } - impl ReduceLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ReduceLayer_defaultNew_const()) } - } + pub struct RegionLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { RegionLayer } + impl Drop for RegionLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ReduceLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_RegionLayer_delete(self.as_raw_mut_RegionLayer()) }; } - } - boxed_cast_base! { ReduceLayer, core::Algorithm, cv_dnn_ReduceLayer_to_Algorithm } - - boxed_cast_base! { ReduceLayer, crate::dnn::Layer, cv_dnn_ReduceLayer_to_Layer } + unsafe impl Send for RegionLayer {} - impl std::fmt::Debug for ReduceLayer { + impl RegionLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ReduceLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::RegionLayer { + let ret = unsafe { sys::cv_dnn_RegionLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::RegionLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for ReduceLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_RegionLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::RegionLayer] @@ -16695,20 +16891,30 @@ pub mod dnn { } - pub struct RegionLayer { - ptr: *mut c_void, + impl Default for RegionLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { RegionLayer } - - impl Drop for RegionLayer { + impl std::fmt::Debug for RegionLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_RegionLayer_delete(self.as_raw_mut_RegionLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RegionLayer") + .field("nms_threshold", &crate::dnn::RegionLayerTraitConst::nms_threshold(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for RegionLayer {} + boxed_cast_base! { RegionLayer, core::Algorithm, cv_dnn_RegionLayer_to_Algorithm } + + boxed_cast_base! { RegionLayer, crate::dnn::Layer, cv_dnn_RegionLayer_to_Layer } impl core::AlgorithmTraitConst for RegionLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -16740,48 +16946,40 @@ pub mod dnn { boxed_ref! { RegionLayer, crate::dnn::RegionLayerTraitConst, as_raw_RegionLayer, crate::dnn::RegionLayerTrait, as_raw_mut_RegionLayer } - impl RegionLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_RegionLayer_defaultNew_const()) } - } + pub struct ReorgLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { ReorgLayer } + impl Drop for ReorgLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_RegionLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ReorgLayer_delete(self.as_raw_mut_ReorgLayer()) }; } - } - boxed_cast_base! { RegionLayer, core::Algorithm, cv_dnn_RegionLayer_to_Algorithm } - - boxed_cast_base! { RegionLayer, crate::dnn::Layer, cv_dnn_RegionLayer_to_Layer } + unsafe impl Send for ReorgLayer {} - impl std::fmt::Debug for RegionLayer { + impl ReorgLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RegionLayer") - .field("nms_threshold", &crate::dnn::RegionLayerTraitConst::nms_threshold(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::ReorgLayer { + let ret = unsafe { sys::cv_dnn_ReorgLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ReorgLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for RegionLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ReorgLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ReorgLayer] @@ -16796,20 +16994,29 @@ pub mod dnn { } - pub struct ReorgLayer { - ptr: *mut c_void, + impl Default for ReorgLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ReorgLayer } - - impl Drop for ReorgLayer { + impl std::fmt::Debug for ReorgLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ReorgLayer_delete(self.as_raw_mut_ReorgLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ReorgLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ReorgLayer {} + boxed_cast_base! { ReorgLayer, core::Algorithm, cv_dnn_ReorgLayer_to_Algorithm } + + boxed_cast_base! { ReorgLayer, crate::dnn::Layer, cv_dnn_ReorgLayer_to_Layer } impl core::AlgorithmTraitConst for ReorgLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -16841,47 +17048,40 @@ pub mod dnn { boxed_ref! { ReorgLayer, crate::dnn::ReorgLayerTraitConst, as_raw_ReorgLayer, crate::dnn::ReorgLayerTrait, as_raw_mut_ReorgLayer } - impl ReorgLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ReorgLayer_defaultNew_const()) } - } + pub struct RequantizeLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { RequantizeLayer } + impl Drop for RequantizeLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ReorgLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_RequantizeLayer_delete(self.as_raw_mut_RequantizeLayer()) }; } - } - boxed_cast_base! { ReorgLayer, core::Algorithm, cv_dnn_ReorgLayer_to_Algorithm } - - boxed_cast_base! { ReorgLayer, crate::dnn::Layer, cv_dnn_ReorgLayer_to_Layer } + unsafe impl Send for RequantizeLayer {} - impl std::fmt::Debug for ReorgLayer { + impl RequantizeLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ReorgLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::RequantizeLayer { + let ret = unsafe { sys::cv_dnn_RequantizeLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::RequantizeLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for ReorgLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_RequantizeLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::RequantizeLayer] @@ -16920,20 +17120,31 @@ pub mod dnn { } - pub struct RequantizeLayer { - ptr: *mut c_void, + impl Default for RequantizeLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { RequantizeLayer } - - impl Drop for RequantizeLayer { + impl std::fmt::Debug for RequantizeLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_RequantizeLayer_delete(self.as_raw_mut_RequantizeLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RequantizeLayer") + .field("scale", &crate::dnn::RequantizeLayerTraitConst::scale(self)) + .field("shift", &crate::dnn::RequantizeLayerTraitConst::shift(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for RequantizeLayer {} + boxed_cast_base! { RequantizeLayer, core::Algorithm, cv_dnn_RequantizeLayer_to_Algorithm } + + boxed_cast_base! { RequantizeLayer, crate::dnn::Layer, cv_dnn_RequantizeLayer_to_Layer } impl core::AlgorithmTraitConst for RequantizeLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -16965,49 +17176,40 @@ pub mod dnn { boxed_ref! { RequantizeLayer, crate::dnn::RequantizeLayerTraitConst, as_raw_RequantizeLayer, crate::dnn::RequantizeLayerTrait, as_raw_mut_RequantizeLayer } - impl RequantizeLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_RequantizeLayer_defaultNew_const()) } - } + pub struct ReshapeLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { ReshapeLayer } + impl Drop for ReshapeLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_RequantizeLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ReshapeLayer_delete(self.as_raw_mut_ReshapeLayer()) }; } - } - boxed_cast_base! { RequantizeLayer, core::Algorithm, cv_dnn_RequantizeLayer_to_Algorithm } - - boxed_cast_base! { RequantizeLayer, crate::dnn::Layer, cv_dnn_RequantizeLayer_to_Layer } + unsafe impl Send for ReshapeLayer {} - impl std::fmt::Debug for RequantizeLayer { + impl ReshapeLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RequantizeLayer") - .field("scale", &crate::dnn::RequantizeLayerTraitConst::scale(self)) - .field("shift", &crate::dnn::RequantizeLayerTraitConst::shift(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::ReshapeLayer { + let ret = unsafe { sys::cv_dnn_ReshapeLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ReshapeLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for RequantizeLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ReshapeLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ReshapeLayer] @@ -17048,20 +17250,31 @@ pub mod dnn { } - pub struct ReshapeLayer { - ptr: *mut c_void, - } - - opencv_type_boxed! { ReshapeLayer } + impl Default for ReshapeLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } + } - impl Drop for ReshapeLayer { + impl std::fmt::Debug for ReshapeLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ReshapeLayer_delete(self.as_raw_mut_ReshapeLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ReshapeLayer") + .field("new_shape_desc", &crate::dnn::ReshapeLayerTraitConst::new_shape_desc(self)) + .field("new_shape_range", &crate::dnn::ReshapeLayerTraitConst::new_shape_range(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ReshapeLayer {} + boxed_cast_base! { ReshapeLayer, core::Algorithm, cv_dnn_ReshapeLayer_to_Algorithm } + + boxed_cast_base! { ReshapeLayer, crate::dnn::Layer, cv_dnn_ReshapeLayer_to_Layer } impl core::AlgorithmTraitConst for ReshapeLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -17093,49 +17306,43 @@ pub mod dnn { boxed_ref! { ReshapeLayer, crate::dnn::ReshapeLayerTraitConst, as_raw_ReshapeLayer, crate::dnn::ReshapeLayerTrait, as_raw_mut_ReshapeLayer } - impl ReshapeLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ReshapeLayer_defaultNew_const()) } - } + /// Resize input 4-dimensional blob by nearest neighbor or bilinear strategy. + /// + /// Layer is used to support TensorFlow's resize_nearest_neighbor and resize_bilinear ops. + pub struct ResizeLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { ResizeLayer } + + impl Drop for ResizeLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ReshapeLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ResizeLayer_delete(self.as_raw_mut_ResizeLayer()) }; } - } - boxed_cast_base! { ReshapeLayer, core::Algorithm, cv_dnn_ReshapeLayer_to_Algorithm } - - boxed_cast_base! { ReshapeLayer, crate::dnn::Layer, cv_dnn_ReshapeLayer_to_Layer } + unsafe impl Send for ResizeLayer {} - impl std::fmt::Debug for ReshapeLayer { + impl ResizeLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ReshapeLayer") - .field("new_shape_desc", &crate::dnn::ReshapeLayerTraitConst::new_shape_desc(self)) - .field("new_shape_range", &crate::dnn::ReshapeLayerTraitConst::new_shape_range(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::ResizeLayer { + let ret = unsafe { sys::cv_dnn_ResizeLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ResizeLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for ReshapeLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ResizeLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ResizeLayer] @@ -17150,23 +17357,29 @@ pub mod dnn { } - /// Resize input 4-dimensional blob by nearest neighbor or bilinear strategy. - /// - /// Layer is used to support TensorFlow's resize_nearest_neighbor and resize_bilinear ops. - pub struct ResizeLayer { - ptr: *mut c_void, + impl Default for ResizeLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ResizeLayer } - - impl Drop for ResizeLayer { + impl std::fmt::Debug for ResizeLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ResizeLayer_delete(self.as_raw_mut_ResizeLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ResizeLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ResizeLayer {} + boxed_cast_base! { ResizeLayer, core::Algorithm, cv_dnn_ResizeLayer_to_Algorithm } + + boxed_cast_base! { ResizeLayer, crate::dnn::Layer, cv_dnn_ResizeLayer_to_Layer } impl core::AlgorithmTraitConst for ResizeLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -17198,47 +17411,40 @@ pub mod dnn { boxed_ref! { ResizeLayer, crate::dnn::ResizeLayerTraitConst, as_raw_ResizeLayer, crate::dnn::ResizeLayerTrait, as_raw_mut_ResizeLayer } - impl ResizeLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ResizeLayer_defaultNew_const()) } - } + pub struct RoundLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { RoundLayer } + impl Drop for RoundLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ResizeLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_RoundLayer_delete(self.as_raw_mut_RoundLayer()) }; } - } - boxed_cast_base! { ResizeLayer, core::Algorithm, cv_dnn_ResizeLayer_to_Algorithm } - - boxed_cast_base! { ResizeLayer, crate::dnn::Layer, cv_dnn_ResizeLayer_to_Layer } + unsafe impl Send for RoundLayer {} - impl std::fmt::Debug for ResizeLayer { + impl RoundLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ResizeLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::RoundLayer { + let ret = unsafe { sys::cv_dnn_RoundLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::RoundLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for ResizeLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_RoundLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::RoundLayer] @@ -17253,20 +17459,31 @@ pub mod dnn { } - pub struct RoundLayer { - ptr: *mut c_void, + impl Default for RoundLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { RoundLayer } - - impl Drop for RoundLayer { + impl std::fmt::Debug for RoundLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_RoundLayer_delete(self.as_raw_mut_RoundLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RoundLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for RoundLayer {} + boxed_cast_base! { RoundLayer, crate::dnn::ActivationLayer, cv_dnn_RoundLayer_to_ActivationLayer } + + boxed_cast_base! { RoundLayer, core::Algorithm, cv_dnn_RoundLayer_to_Algorithm } + + boxed_cast_base! { RoundLayer, crate::dnn::Layer, cv_dnn_RoundLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for RoundLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -17308,49 +17525,40 @@ pub mod dnn { boxed_ref! { RoundLayer, crate::dnn::RoundLayerTraitConst, as_raw_RoundLayer, crate::dnn::RoundLayerTrait, as_raw_mut_RoundLayer } - impl RoundLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_RoundLayer_defaultNew_const()) } - } + pub struct ScaleLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { ScaleLayer } + impl Drop for ScaleLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_RoundLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ScaleLayer_delete(self.as_raw_mut_ScaleLayer()) }; } - } - boxed_cast_base! { RoundLayer, crate::dnn::ActivationLayer, cv_dnn_RoundLayer_to_ActivationLayer } - - boxed_cast_base! { RoundLayer, core::Algorithm, cv_dnn_RoundLayer_to_Algorithm } - - boxed_cast_base! { RoundLayer, crate::dnn::Layer, cv_dnn_RoundLayer_to_Layer } + unsafe impl Send for ScaleLayer {} - impl std::fmt::Debug for RoundLayer { + impl ScaleLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RoundLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::ScaleLayer { + let ret = unsafe { sys::cv_dnn_ScaleLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ScaleLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for RoundLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ScaleLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ScaleLayer] @@ -17403,20 +17611,32 @@ pub mod dnn { } - pub struct ScaleLayer { - ptr: *mut c_void, + impl Default for ScaleLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ScaleLayer } - - impl Drop for ScaleLayer { + impl std::fmt::Debug for ScaleLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ScaleLayer_delete(self.as_raw_mut_ScaleLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ScaleLayer") + .field("has_bias", &crate::dnn::ScaleLayerTraitConst::has_bias(self)) + .field("axis", &crate::dnn::ScaleLayerTraitConst::axis(self)) + .field("mode", &crate::dnn::ScaleLayerTraitConst::mode(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ScaleLayer {} + boxed_cast_base! { ScaleLayer, core::Algorithm, cv_dnn_ScaleLayer_to_Algorithm } + + boxed_cast_base! { ScaleLayer, crate::dnn::Layer, cv_dnn_ScaleLayer_to_Layer } impl core::AlgorithmTraitConst for ScaleLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -17448,50 +17668,40 @@ pub mod dnn { boxed_ref! { ScaleLayer, crate::dnn::ScaleLayerTraitConst, as_raw_ScaleLayer, crate::dnn::ScaleLayerTrait, as_raw_mut_ScaleLayer } - impl ScaleLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ScaleLayer_defaultNew_const()) } - } + pub struct ScaleLayerInt8 { + ptr: *mut c_void, + } + + opencv_type_boxed! { ScaleLayerInt8 } + impl Drop for ScaleLayerInt8 { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ScaleLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ScaleLayerInt8_delete(self.as_raw_mut_ScaleLayerInt8()) }; } - } - boxed_cast_base! { ScaleLayer, core::Algorithm, cv_dnn_ScaleLayer_to_Algorithm } - - boxed_cast_base! { ScaleLayer, crate::dnn::Layer, cv_dnn_ScaleLayer_to_Layer } + unsafe impl Send for ScaleLayerInt8 {} - impl std::fmt::Debug for ScaleLayer { + impl ScaleLayerInt8 { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ScaleLayer") - .field("has_bias", &crate::dnn::ScaleLayerTraitConst::has_bias(self)) - .field("axis", &crate::dnn::ScaleLayerTraitConst::axis(self)) - .field("mode", &crate::dnn::ScaleLayerTraitConst::mode(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::ScaleLayerInt8 { + let ret = unsafe { sys::cv_dnn_ScaleLayerInt8_defaultNew_const() }; + let ret = unsafe { crate::dnn::ScaleLayerInt8::opencv_from_extern(ret) }; + ret } - } - impl Default for ScaleLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ScaleLayerInt8_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ScaleLayerInt8] @@ -17530,20 +17740,36 @@ pub mod dnn { } - pub struct ScaleLayerInt8 { - ptr: *mut c_void, + impl Default for ScaleLayerInt8 { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ScaleLayerInt8 } - - impl Drop for ScaleLayerInt8 { + impl std::fmt::Debug for ScaleLayerInt8 { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ScaleLayerInt8_delete(self.as_raw_mut_ScaleLayerInt8()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ScaleLayerInt8") + .field("output_sc", &crate::dnn::ScaleLayerInt8TraitConst::output_sc(self)) + .field("output_zp", &crate::dnn::ScaleLayerInt8TraitConst::output_zp(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .field("has_bias", &crate::dnn::ScaleLayerTraitConst::has_bias(self)) + .field("axis", &crate::dnn::ScaleLayerTraitConst::axis(self)) + .field("mode", &crate::dnn::ScaleLayerTraitConst::mode(self)) + .finish() } } - unsafe impl Send for ScaleLayerInt8 {} + boxed_cast_base! { ScaleLayerInt8, core::Algorithm, cv_dnn_ScaleLayerInt8_to_Algorithm } + + boxed_cast_base! { ScaleLayerInt8, crate::dnn::Layer, cv_dnn_ScaleLayerInt8_to_Layer } + + boxed_cast_base! { ScaleLayerInt8, crate::dnn::ScaleLayer, cv_dnn_ScaleLayerInt8_to_ScaleLayer } impl core::AlgorithmTraitConst for ScaleLayerInt8 { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -17585,54 +17811,40 @@ pub mod dnn { boxed_ref! { ScaleLayerInt8, crate::dnn::ScaleLayerInt8TraitConst, as_raw_ScaleLayerInt8, crate::dnn::ScaleLayerInt8Trait, as_raw_mut_ScaleLayerInt8 } - impl ScaleLayerInt8 { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ScaleLayerInt8_defaultNew_const()) } - } + pub struct ScatterLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { ScatterLayer } + impl Drop for ScatterLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ScaleLayerInt8_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ScatterLayer_delete(self.as_raw_mut_ScatterLayer()) }; } - } - boxed_cast_base! { ScaleLayerInt8, core::Algorithm, cv_dnn_ScaleLayerInt8_to_Algorithm } - - boxed_cast_base! { ScaleLayerInt8, crate::dnn::Layer, cv_dnn_ScaleLayerInt8_to_Layer } - - boxed_cast_base! { ScaleLayerInt8, crate::dnn::ScaleLayer, cv_dnn_ScaleLayerInt8_to_ScaleLayer } + unsafe impl Send for ScatterLayer {} - impl std::fmt::Debug for ScaleLayerInt8 { + impl ScatterLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ScaleLayerInt8") - .field("output_sc", &crate::dnn::ScaleLayerInt8TraitConst::output_sc(self)) - .field("output_zp", &crate::dnn::ScaleLayerInt8TraitConst::output_zp(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .field("has_bias", &crate::dnn::ScaleLayerTraitConst::has_bias(self)) - .field("axis", &crate::dnn::ScaleLayerTraitConst::axis(self)) - .field("mode", &crate::dnn::ScaleLayerTraitConst::mode(self)) - .finish() + pub fn default() -> crate::dnn::ScatterLayer { + let ret = unsafe { sys::cv_dnn_ScatterLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ScatterLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for ScaleLayerInt8 { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ScatterLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ScatterLayer] @@ -17647,20 +17859,29 @@ pub mod dnn { } - pub struct ScatterLayer { - ptr: *mut c_void, + impl Default for ScatterLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ScatterLayer } - - impl Drop for ScatterLayer { + impl std::fmt::Debug for ScatterLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ScatterLayer_delete(self.as_raw_mut_ScatterLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ScatterLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ScatterLayer {} + boxed_cast_base! { ScatterLayer, core::Algorithm, cv_dnn_ScatterLayer_to_Algorithm } + + boxed_cast_base! { ScatterLayer, crate::dnn::Layer, cv_dnn_ScatterLayer_to_Layer } impl core::AlgorithmTraitConst for ScatterLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -17692,61 +17913,6 @@ pub mod dnn { boxed_ref! { ScatterLayer, crate::dnn::ScatterLayerTraitConst, as_raw_ScatterLayer, crate::dnn::ScatterLayerTrait, as_raw_mut_ScatterLayer } - impl ScatterLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ScatterLayer_defaultNew_const()) } - } - - #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ScatterLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { ScatterLayer, core::Algorithm, cv_dnn_ScatterLayer_to_Algorithm } - - boxed_cast_base! { ScatterLayer, crate::dnn::Layer, cv_dnn_ScatterLayer_to_Layer } - - impl std::fmt::Debug for ScatterLayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ScatterLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for ScatterLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - - /// Constant methods for [crate::dnn::ScatterNDLayer] - pub trait ScatterNDLayerTraitConst: crate::dnn::LayerTraitConst { - fn as_raw_ScatterNDLayer(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::dnn::ScatterNDLayer] - pub trait ScatterNDLayerTrait: crate::dnn::LayerTrait + crate::dnn::ScatterNDLayerTraitConst { - fn as_raw_mut_ScatterNDLayer(&mut self) -> *mut c_void; - - } - pub struct ScatterNDLayer { ptr: *mut c_void, } @@ -17760,43 +17926,15 @@ pub mod dnn { } } - unsafe impl Send for ScatterNDLayer {} - - impl core::AlgorithmTraitConst for ScatterNDLayer { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for ScatterNDLayer { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { ScatterNDLayer, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::dnn::LayerTraitConst for ScatterNDLayer { - #[inline] fn as_raw_Layer(&self) -> *const c_void { self.as_raw() } - } - - impl crate::dnn::LayerTrait for ScatterNDLayer { - #[inline] fn as_raw_mut_Layer(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { ScatterNDLayer, crate::dnn::LayerTraitConst, as_raw_Layer, crate::dnn::LayerTrait, as_raw_mut_Layer } - - impl crate::dnn::ScatterNDLayerTraitConst for ScatterNDLayer { - #[inline] fn as_raw_ScatterNDLayer(&self) -> *const c_void { self.as_raw() } - } - - impl crate::dnn::ScatterNDLayerTrait for ScatterNDLayer { - #[inline] fn as_raw_mut_ScatterNDLayer(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { ScatterNDLayer, crate::dnn::ScatterNDLayerTraitConst, as_raw_ScatterNDLayer, crate::dnn::ScatterNDLayerTrait, as_raw_mut_ScatterNDLayer } + unsafe impl Send for ScatterNDLayer {} impl ScatterNDLayer { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ScatterNDLayer_defaultNew_const()) } + pub fn default() -> crate::dnn::ScatterNDLayer { + let ret = unsafe { sys::cv_dnn_ScatterNDLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ScatterNDLayer::opencv_from_extern(ret) }; + ret } #[inline] @@ -17811,9 +17949,25 @@ pub mod dnn { } - boxed_cast_base! { ScatterNDLayer, core::Algorithm, cv_dnn_ScatterNDLayer_to_Algorithm } + /// Constant methods for [crate::dnn::ScatterNDLayer] + pub trait ScatterNDLayerTraitConst: crate::dnn::LayerTraitConst { + fn as_raw_ScatterNDLayer(&self) -> *const c_void; - boxed_cast_base! { ScatterNDLayer, crate::dnn::Layer, cv_dnn_ScatterNDLayer_to_Layer } + } + + /// Mutable methods for [crate::dnn::ScatterNDLayer] + pub trait ScatterNDLayerTrait: crate::dnn::LayerTrait + crate::dnn::ScatterNDLayerTraitConst { + fn as_raw_mut_ScatterNDLayer(&mut self) -> *mut c_void; + + } + + impl Default for ScatterNDLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } + } impl std::fmt::Debug for ScatterNDLayer { #[inline] @@ -17827,41 +17981,40 @@ pub mod dnn { } } - impl Default for ScatterNDLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } + boxed_cast_base! { ScatterNDLayer, core::Algorithm, cv_dnn_ScatterNDLayer_to_Algorithm } + + boxed_cast_base! { ScatterNDLayer, crate::dnn::Layer, cv_dnn_ScatterNDLayer_to_Layer } + + impl core::AlgorithmTraitConst for ScatterNDLayer { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } } - /// Constant methods for [crate::dnn::SegmentationModel] - pub trait SegmentationModelTraitConst: crate::dnn::ModelTraitConst { - fn as_raw_SegmentationModel(&self) -> *const c_void; + impl core::AlgorithmTrait for ScatterNDLayer { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { ScatterNDLayer, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + impl crate::dnn::LayerTraitConst for ScatterNDLayer { + #[inline] fn as_raw_Layer(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::dnn::SegmentationModel] - pub trait SegmentationModelTrait: crate::dnn::ModelTrait + crate::dnn::SegmentationModelTraitConst { - fn as_raw_mut_SegmentationModel(&mut self) -> *mut c_void; + impl crate::dnn::LayerTrait for ScatterNDLayer { + #[inline] fn as_raw_mut_Layer(&mut self) -> *mut c_void { self.as_raw_mut() } + } - /// Given the @p input frame, create input blob, run net - /// ## Parameters - /// * frame: The input image. - /// * mask:[out] Allocated class prediction for each pixel - #[inline] - fn segment(&mut self, frame: &impl ToInputArray, mask: &mut impl ToOutputArray) -> Result<()> { - input_array_arg!(frame); - output_array_arg!(mask); - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_SegmentationModel_segment_const__InputArrayR_const__OutputArrayR(self.as_raw_mut_SegmentationModel(), frame.as_raw__InputArray(), mask.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } + boxed_ref! { ScatterNDLayer, crate::dnn::LayerTraitConst, as_raw_Layer, crate::dnn::LayerTrait, as_raw_mut_Layer } + + impl crate::dnn::ScatterNDLayerTraitConst for ScatterNDLayer { + #[inline] fn as_raw_ScatterNDLayer(&self) -> *const c_void { self.as_raw() } + } + impl crate::dnn::ScatterNDLayerTrait for ScatterNDLayer { + #[inline] fn as_raw_mut_ScatterNDLayer(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { ScatterNDLayer, crate::dnn::ScatterNDLayerTraitConst, as_raw_ScatterNDLayer, crate::dnn::ScatterNDLayerTrait, as_raw_mut_ScatterNDLayer } + /// This class represents high-level API for segmentation models /// /// SegmentationModel allows to set params for preprocessing input image. @@ -17882,26 +18035,6 @@ pub mod dnn { unsafe impl Send for SegmentationModel {} - impl crate::dnn::ModelTraitConst for SegmentationModel { - #[inline] fn as_raw_Model(&self) -> *const c_void { self.as_raw() } - } - - impl crate::dnn::ModelTrait for SegmentationModel { - #[inline] fn as_raw_mut_Model(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { SegmentationModel, crate::dnn::ModelTraitConst, as_raw_Model, crate::dnn::ModelTrait, as_raw_mut_Model } - - impl crate::dnn::SegmentationModelTraitConst for SegmentationModel { - #[inline] fn as_raw_SegmentationModel(&self) -> *const c_void { self.as_raw() } - } - - impl crate::dnn::SegmentationModelTrait for SegmentationModel { - #[inline] fn as_raw_mut_SegmentationModel(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { SegmentationModel, crate::dnn::SegmentationModelTraitConst, as_raw_SegmentationModel, crate::dnn::SegmentationModelTrait, as_raw_mut_SegmentationModel } - impl SegmentationModel { /// Create segmentation model from network represented in one of the supported formats. /// An order of @p model and @p config arguments does not matter. @@ -17958,6 +18091,33 @@ pub mod dnn { } + /// Constant methods for [crate::dnn::SegmentationModel] + pub trait SegmentationModelTraitConst: crate::dnn::ModelTraitConst { + fn as_raw_SegmentationModel(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::dnn::SegmentationModel] + pub trait SegmentationModelTrait: crate::dnn::ModelTrait + crate::dnn::SegmentationModelTraitConst { + fn as_raw_mut_SegmentationModel(&mut self) -> *mut c_void; + + /// Given the @p input frame, create input blob, run net + /// ## Parameters + /// * frame: The input image. + /// * mask:[out] Allocated class prediction for each pixel + #[inline] + fn segment(&mut self, frame: &impl ToInputArray, mask: &mut impl ToOutputArray) -> Result<()> { + input_array_arg!(frame); + output_array_arg!(mask); + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_SegmentationModel_segment_const__InputArrayR_const__OutputArrayR(self.as_raw_mut_SegmentationModel(), frame.as_raw__InputArray(), mask.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + impl Clone for SegmentationModel { #[inline] fn clone(&self) -> Self { @@ -17965,8 +18125,6 @@ pub mod dnn { } } - boxed_cast_base! { SegmentationModel, crate::dnn::Model, cv_dnn_SegmentationModel_to_Model } - impl std::fmt::Debug for SegmentationModel { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -17975,6 +18133,64 @@ pub mod dnn { } } + boxed_cast_base! { SegmentationModel, crate::dnn::Model, cv_dnn_SegmentationModel_to_Model } + + impl crate::dnn::ModelTraitConst for SegmentationModel { + #[inline] fn as_raw_Model(&self) -> *const c_void { self.as_raw() } + } + + impl crate::dnn::ModelTrait for SegmentationModel { + #[inline] fn as_raw_mut_Model(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { SegmentationModel, crate::dnn::ModelTraitConst, as_raw_Model, crate::dnn::ModelTrait, as_raw_mut_Model } + + impl crate::dnn::SegmentationModelTraitConst for SegmentationModel { + #[inline] fn as_raw_SegmentationModel(&self) -> *const c_void { self.as_raw() } + } + + impl crate::dnn::SegmentationModelTrait for SegmentationModel { + #[inline] fn as_raw_mut_SegmentationModel(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { SegmentationModel, crate::dnn::SegmentationModelTraitConst, as_raw_SegmentationModel, crate::dnn::SegmentationModelTrait, as_raw_mut_SegmentationModel } + + pub struct SeluLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { SeluLayer } + + impl Drop for SeluLayer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_SeluLayer_delete(self.as_raw_mut_SeluLayer()) }; + } + } + + unsafe impl Send for SeluLayer {} + + impl SeluLayer { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::dnn::SeluLayer { + let ret = unsafe { sys::cv_dnn_SeluLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::SeluLayer::opencv_from_extern(ret) }; + ret + } + + #[inline] + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_SeluLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::dnn::SeluLayer] pub trait SeluLayerTraitConst: crate::dnn::ActivationLayerTraitConst { fn as_raw_SeluLayer(&self) -> *const c_void; @@ -18011,20 +18227,33 @@ pub mod dnn { } - pub struct SeluLayer { - ptr: *mut c_void, + impl Default for SeluLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { SeluLayer } - - impl Drop for SeluLayer { + impl std::fmt::Debug for SeluLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_SeluLayer_delete(self.as_raw_mut_SeluLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SeluLayer") + .field("alpha", &crate::dnn::SeluLayerTraitConst::alpha(self)) + .field("gamma", &crate::dnn::SeluLayerTraitConst::gamma(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for SeluLayer {} + boxed_cast_base! { SeluLayer, crate::dnn::ActivationLayer, cv_dnn_SeluLayer_to_ActivationLayer } + + boxed_cast_base! { SeluLayer, core::Algorithm, cv_dnn_SeluLayer_to_Algorithm } + + boxed_cast_base! { SeluLayer, crate::dnn::Layer, cv_dnn_SeluLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for SeluLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -18066,51 +18295,40 @@ pub mod dnn { boxed_ref! { SeluLayer, crate::dnn::SeluLayerTraitConst, as_raw_SeluLayer, crate::dnn::SeluLayerTrait, as_raw_mut_SeluLayer } - impl SeluLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_SeluLayer_defaultNew_const()) } - } + pub struct ShiftLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { ShiftLayer } + impl Drop for ShiftLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_SeluLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ShiftLayer_delete(self.as_raw_mut_ShiftLayer()) }; } - } - boxed_cast_base! { SeluLayer, crate::dnn::ActivationLayer, cv_dnn_SeluLayer_to_ActivationLayer } - - boxed_cast_base! { SeluLayer, core::Algorithm, cv_dnn_SeluLayer_to_Algorithm } - - boxed_cast_base! { SeluLayer, crate::dnn::Layer, cv_dnn_SeluLayer_to_Layer } + unsafe impl Send for ShiftLayer {} - impl std::fmt::Debug for SeluLayer { + impl ShiftLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SeluLayer") - .field("alpha", &crate::dnn::SeluLayerTraitConst::alpha(self)) - .field("gamma", &crate::dnn::SeluLayerTraitConst::gamma(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::ShiftLayer { + let ret = unsafe { sys::cv_dnn_ShiftLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ShiftLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for SeluLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ShiftLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ShiftLayer] @@ -18125,20 +18343,29 @@ pub mod dnn { } - pub struct ShiftLayer { - ptr: *mut c_void, + impl Default for ShiftLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ShiftLayer } - - impl Drop for ShiftLayer { + impl std::fmt::Debug for ShiftLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ShiftLayer_delete(self.as_raw_mut_ShiftLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ShiftLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ShiftLayer {} + boxed_cast_base! { ShiftLayer, core::Algorithm, cv_dnn_ShiftLayer_to_Algorithm } + + boxed_cast_base! { ShiftLayer, crate::dnn::Layer, cv_dnn_ShiftLayer_to_Layer } impl core::AlgorithmTraitConst for ShiftLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -18170,17 +18397,34 @@ pub mod dnn { boxed_ref! { ShiftLayer, crate::dnn::ShiftLayerTraitConst, as_raw_ShiftLayer, crate::dnn::ShiftLayerTrait, as_raw_mut_ShiftLayer } - impl ShiftLayer { + pub struct ShiftLayerInt8 { + ptr: *mut c_void, + } + + opencv_type_boxed! { ShiftLayerInt8 } + + impl Drop for ShiftLayerInt8 { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_ShiftLayerInt8_delete(self.as_raw_mut_ShiftLayerInt8()) }; + } + } + + unsafe impl Send for ShiftLayerInt8 {} + + impl ShiftLayerInt8 { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ShiftLayer_defaultNew_const()) } + pub fn default() -> crate::dnn::ShiftLayerInt8 { + let ret = unsafe { sys::cv_dnn_ShiftLayerInt8_defaultNew_const() }; + let ret = unsafe { crate::dnn::ShiftLayerInt8::opencv_from_extern(ret) }; + ret } #[inline] pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ShiftLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_ShiftLayerInt8_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; @@ -18189,30 +18433,6 @@ pub mod dnn { } - boxed_cast_base! { ShiftLayer, core::Algorithm, cv_dnn_ShiftLayer_to_Algorithm } - - boxed_cast_base! { ShiftLayer, crate::dnn::Layer, cv_dnn_ShiftLayer_to_Layer } - - impl std::fmt::Debug for ShiftLayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ShiftLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for ShiftLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - /// Constant methods for [crate::dnn::ShiftLayerInt8] pub trait ShiftLayerInt8TraitConst: crate::dnn::LayerTraitConst { fn as_raw_ShiftLayerInt8(&self) -> *const c_void; @@ -18225,20 +18445,29 @@ pub mod dnn { } - pub struct ShiftLayerInt8 { - ptr: *mut c_void, + impl Default for ShiftLayerInt8 { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ShiftLayerInt8 } - - impl Drop for ShiftLayerInt8 { + impl std::fmt::Debug for ShiftLayerInt8 { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ShiftLayerInt8_delete(self.as_raw_mut_ShiftLayerInt8()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ShiftLayerInt8") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ShiftLayerInt8 {} + boxed_cast_base! { ShiftLayerInt8, core::Algorithm, cv_dnn_ShiftLayerInt8_to_Algorithm } + + boxed_cast_base! { ShiftLayerInt8, crate::dnn::Layer, cv_dnn_ShiftLayerInt8_to_Layer } impl core::AlgorithmTraitConst for ShiftLayerInt8 { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -18270,47 +18499,40 @@ pub mod dnn { boxed_ref! { ShiftLayerInt8, crate::dnn::ShiftLayerInt8TraitConst, as_raw_ShiftLayerInt8, crate::dnn::ShiftLayerInt8Trait, as_raw_mut_ShiftLayerInt8 } - impl ShiftLayerInt8 { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ShiftLayerInt8_defaultNew_const()) } - } + pub struct ShrinkLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { ShrinkLayer } + impl Drop for ShrinkLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ShiftLayerInt8_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ShrinkLayer_delete(self.as_raw_mut_ShrinkLayer()) }; } - } - boxed_cast_base! { ShiftLayerInt8, core::Algorithm, cv_dnn_ShiftLayerInt8_to_Algorithm } - - boxed_cast_base! { ShiftLayerInt8, crate::dnn::Layer, cv_dnn_ShiftLayerInt8_to_Layer } + unsafe impl Send for ShrinkLayer {} - impl std::fmt::Debug for ShiftLayerInt8 { + impl ShrinkLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ShiftLayerInt8") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::ShrinkLayer { + let ret = unsafe { sys::cv_dnn_ShrinkLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ShrinkLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for ShiftLayerInt8 { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ShrinkLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ShrinkLayer] @@ -18349,20 +18571,33 @@ pub mod dnn { } - pub struct ShrinkLayer { - ptr: *mut c_void, + impl Default for ShrinkLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ShrinkLayer } - - impl Drop for ShrinkLayer { + impl std::fmt::Debug for ShrinkLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ShrinkLayer_delete(self.as_raw_mut_ShrinkLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ShrinkLayer") + .field("bias", &crate::dnn::ShrinkLayerTraitConst::bias(self)) + .field("lambd", &crate::dnn::ShrinkLayerTraitConst::lambd(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ShrinkLayer {} + boxed_cast_base! { ShrinkLayer, crate::dnn::ActivationLayer, cv_dnn_ShrinkLayer_to_ActivationLayer } + + boxed_cast_base! { ShrinkLayer, core::Algorithm, cv_dnn_ShrinkLayer_to_Algorithm } + + boxed_cast_base! { ShrinkLayer, crate::dnn::Layer, cv_dnn_ShrinkLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for ShrinkLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -18404,51 +18639,48 @@ pub mod dnn { boxed_ref! { ShrinkLayer, crate::dnn::ShrinkLayerTraitConst, as_raw_ShrinkLayer, crate::dnn::ShrinkLayerTrait, as_raw_mut_ShrinkLayer } - impl ShrinkLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ShrinkLayer_defaultNew_const()) } - } + /// Permute channels of 4-dimensional input blob. + /// ## Parameters + /// * group: Number of groups to split input channels and pick in turns + /// into output blob. + /// + /// ![block formula](https://latex.codecogs.com/png.latex?%20groupSize%20%3D%20%5Cfrac%7Bnumber%5C%20of%5C%20channels%7D%7Bgroup%7D%20) + /// ![block formula](https://latex.codecogs.com/png.latex?%20output%28n%2C%20c%2C%20h%2C%20w%29%20%3D%20input%28n%2C%20groupSize%20%5Ctimes%20%28c%20%5C%25%20group%29%20%2B%20%5Clfloor%20%5Cfrac%7Bc%7D%7Bgroup%7D%20%5Crfloor%2C%20h%2C%20w%29%20) + /// Read more at + pub struct ShuffleChannelLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { ShuffleChannelLayer } + impl Drop for ShuffleChannelLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ShrinkLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ShuffleChannelLayer_delete(self.as_raw_mut_ShuffleChannelLayer()) }; } - } - boxed_cast_base! { ShrinkLayer, crate::dnn::ActivationLayer, cv_dnn_ShrinkLayer_to_ActivationLayer } - - boxed_cast_base! { ShrinkLayer, core::Algorithm, cv_dnn_ShrinkLayer_to_Algorithm } - - boxed_cast_base! { ShrinkLayer, crate::dnn::Layer, cv_dnn_ShrinkLayer_to_Layer } + unsafe impl Send for ShuffleChannelLayer {} - impl std::fmt::Debug for ShrinkLayer { + impl ShuffleChannelLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ShrinkLayer") - .field("bias", &crate::dnn::ShrinkLayerTraitConst::bias(self)) - .field("lambd", &crate::dnn::ShrinkLayerTraitConst::lambd(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::ShuffleChannelLayer { + let ret = unsafe { sys::cv_dnn_ShuffleChannelLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ShuffleChannelLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for ShrinkLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_ShuffleChannelLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::ShuffleChannelLayer] @@ -18467,36 +18699,38 @@ pub mod dnn { pub trait ShuffleChannelLayerTrait: crate::dnn::LayerTrait + crate::dnn::ShuffleChannelLayerTraitConst { fn as_raw_mut_ShuffleChannelLayer(&mut self) -> *mut c_void; - #[inline] - fn set_group(&mut self, val: i32) { - let ret = unsafe { sys::cv_dnn_ShuffleChannelLayer_propGroup_const_int(self.as_raw_mut_ShuffleChannelLayer(), val) }; - ret - } - - } - - /// Permute channels of 4-dimensional input blob. - /// ## Parameters - /// * group: Number of groups to split input channels and pick in turns - /// into output blob. - /// - /// ![block formula](https://latex.codecogs.com/png.latex?%20groupSize%20%3D%20%5Cfrac%7Bnumber%5C%20of%5C%20channels%7D%7Bgroup%7D%20) - /// ![block formula](https://latex.codecogs.com/png.latex?%20output%28n%2C%20c%2C%20h%2C%20w%29%20%3D%20input%28n%2C%20groupSize%20%5Ctimes%20%28c%20%5C%25%20group%29%20%2B%20%5Clfloor%20%5Cfrac%7Bc%7D%7Bgroup%7D%20%5Crfloor%2C%20h%2C%20w%29%20) - /// Read more at - pub struct ShuffleChannelLayer { - ptr: *mut c_void, + #[inline] + fn set_group(&mut self, val: i32) { + let ret = unsafe { sys::cv_dnn_ShuffleChannelLayer_propGroup_const_int(self.as_raw_mut_ShuffleChannelLayer(), val) }; + ret + } + } - opencv_type_boxed! { ShuffleChannelLayer } + impl Default for ShuffleChannelLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } + } - impl Drop for ShuffleChannelLayer { + impl std::fmt::Debug for ShuffleChannelLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ShuffleChannelLayer_delete(self.as_raw_mut_ShuffleChannelLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ShuffleChannelLayer") + .field("group", &crate::dnn::ShuffleChannelLayerTraitConst::group(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ShuffleChannelLayer {} + boxed_cast_base! { ShuffleChannelLayer, core::Algorithm, cv_dnn_ShuffleChannelLayer_to_Algorithm } + + boxed_cast_base! { ShuffleChannelLayer, crate::dnn::Layer, cv_dnn_ShuffleChannelLayer_to_Layer } impl core::AlgorithmTraitConst for ShuffleChannelLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -18528,48 +18762,40 @@ pub mod dnn { boxed_ref! { ShuffleChannelLayer, crate::dnn::ShuffleChannelLayerTraitConst, as_raw_ShuffleChannelLayer, crate::dnn::ShuffleChannelLayerTrait, as_raw_mut_ShuffleChannelLayer } - impl ShuffleChannelLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ShuffleChannelLayer_defaultNew_const()) } - } + pub struct SigmoidLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { SigmoidLayer } + impl Drop for SigmoidLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ShuffleChannelLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_SigmoidLayer_delete(self.as_raw_mut_SigmoidLayer()) }; } - } - boxed_cast_base! { ShuffleChannelLayer, core::Algorithm, cv_dnn_ShuffleChannelLayer_to_Algorithm } - - boxed_cast_base! { ShuffleChannelLayer, crate::dnn::Layer, cv_dnn_ShuffleChannelLayer_to_Layer } + unsafe impl Send for SigmoidLayer {} - impl std::fmt::Debug for ShuffleChannelLayer { + impl SigmoidLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ShuffleChannelLayer") - .field("group", &crate::dnn::ShuffleChannelLayerTraitConst::group(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::SigmoidLayer { + let ret = unsafe { sys::cv_dnn_SigmoidLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::SigmoidLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for ShuffleChannelLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_SigmoidLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::SigmoidLayer] @@ -18584,20 +18810,31 @@ pub mod dnn { } - pub struct SigmoidLayer { - ptr: *mut c_void, + impl Default for SigmoidLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { SigmoidLayer } - - impl Drop for SigmoidLayer { + impl std::fmt::Debug for SigmoidLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_SigmoidLayer_delete(self.as_raw_mut_SigmoidLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SigmoidLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for SigmoidLayer {} + boxed_cast_base! { SigmoidLayer, crate::dnn::ActivationLayer, cv_dnn_SigmoidLayer_to_ActivationLayer } + + boxed_cast_base! { SigmoidLayer, core::Algorithm, cv_dnn_SigmoidLayer_to_Algorithm } + + boxed_cast_base! { SigmoidLayer, crate::dnn::Layer, cv_dnn_SigmoidLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for SigmoidLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -18639,49 +18876,40 @@ pub mod dnn { boxed_ref! { SigmoidLayer, crate::dnn::SigmoidLayerTraitConst, as_raw_SigmoidLayer, crate::dnn::SigmoidLayerTrait, as_raw_mut_SigmoidLayer } - impl SigmoidLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_SigmoidLayer_defaultNew_const()) } - } + pub struct SignLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { SignLayer } + impl Drop for SignLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_SigmoidLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_SignLayer_delete(self.as_raw_mut_SignLayer()) }; } - } - boxed_cast_base! { SigmoidLayer, crate::dnn::ActivationLayer, cv_dnn_SigmoidLayer_to_ActivationLayer } - - boxed_cast_base! { SigmoidLayer, core::Algorithm, cv_dnn_SigmoidLayer_to_Algorithm } - - boxed_cast_base! { SigmoidLayer, crate::dnn::Layer, cv_dnn_SigmoidLayer_to_Layer } + unsafe impl Send for SignLayer {} - impl std::fmt::Debug for SigmoidLayer { + impl SignLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SigmoidLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::SignLayer { + let ret = unsafe { sys::cv_dnn_SignLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::SignLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for SigmoidLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_SignLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::SignLayer] @@ -18696,20 +18924,31 @@ pub mod dnn { } - pub struct SignLayer { - ptr: *mut c_void, + impl Default for SignLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { SignLayer } - - impl Drop for SignLayer { + impl std::fmt::Debug for SignLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_SignLayer_delete(self.as_raw_mut_SignLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SignLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for SignLayer {} + boxed_cast_base! { SignLayer, crate::dnn::ActivationLayer, cv_dnn_SignLayer_to_ActivationLayer } + + boxed_cast_base! { SignLayer, core::Algorithm, cv_dnn_SignLayer_to_Algorithm } + + boxed_cast_base! { SignLayer, crate::dnn::Layer, cv_dnn_SignLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for SignLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -18751,49 +18990,40 @@ pub mod dnn { boxed_ref! { SignLayer, crate::dnn::SignLayerTraitConst, as_raw_SignLayer, crate::dnn::SignLayerTrait, as_raw_mut_SignLayer } - impl SignLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_SignLayer_defaultNew_const()) } - } + pub struct SinLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { SinLayer } + impl Drop for SinLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_SignLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_SinLayer_delete(self.as_raw_mut_SinLayer()) }; } - } - boxed_cast_base! { SignLayer, crate::dnn::ActivationLayer, cv_dnn_SignLayer_to_ActivationLayer } - - boxed_cast_base! { SignLayer, core::Algorithm, cv_dnn_SignLayer_to_Algorithm } - - boxed_cast_base! { SignLayer, crate::dnn::Layer, cv_dnn_SignLayer_to_Layer } + unsafe impl Send for SinLayer {} - impl std::fmt::Debug for SignLayer { + impl SinLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SignLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::SinLayer { + let ret = unsafe { sys::cv_dnn_SinLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::SinLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for SignLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_SinLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::SinLayer] @@ -18808,20 +19038,31 @@ pub mod dnn { } - pub struct SinLayer { - ptr: *mut c_void, + impl Default for SinLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { SinLayer } - - impl Drop for SinLayer { + impl std::fmt::Debug for SinLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_SinLayer_delete(self.as_raw_mut_SinLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SinLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for SinLayer {} + boxed_cast_base! { SinLayer, crate::dnn::ActivationLayer, cv_dnn_SinLayer_to_ActivationLayer } + + boxed_cast_base! { SinLayer, core::Algorithm, cv_dnn_SinLayer_to_Algorithm } + + boxed_cast_base! { SinLayer, crate::dnn::Layer, cv_dnn_SinLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for SinLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -18863,49 +19104,40 @@ pub mod dnn { boxed_ref! { SinLayer, crate::dnn::SinLayerTraitConst, as_raw_SinLayer, crate::dnn::SinLayerTrait, as_raw_mut_SinLayer } - impl SinLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_SinLayer_defaultNew_const()) } - } + pub struct SinhLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { SinhLayer } + impl Drop for SinhLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_SinLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_SinhLayer_delete(self.as_raw_mut_SinhLayer()) }; } - } - boxed_cast_base! { SinLayer, crate::dnn::ActivationLayer, cv_dnn_SinLayer_to_ActivationLayer } - - boxed_cast_base! { SinLayer, core::Algorithm, cv_dnn_SinLayer_to_Algorithm } - - boxed_cast_base! { SinLayer, crate::dnn::Layer, cv_dnn_SinLayer_to_Layer } + unsafe impl Send for SinhLayer {} - impl std::fmt::Debug for SinLayer { + impl SinhLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SinLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::SinhLayer { + let ret = unsafe { sys::cv_dnn_SinhLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::SinhLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for SinLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_SinhLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::SinhLayer] @@ -18920,20 +19152,31 @@ pub mod dnn { } - pub struct SinhLayer { - ptr: *mut c_void, + impl Default for SinhLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { SinhLayer } - - impl Drop for SinhLayer { + impl std::fmt::Debug for SinhLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_SinhLayer_delete(self.as_raw_mut_SinhLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SinhLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for SinhLayer {} + boxed_cast_base! { SinhLayer, crate::dnn::ActivationLayer, cv_dnn_SinhLayer_to_ActivationLayer } + + boxed_cast_base! { SinhLayer, core::Algorithm, cv_dnn_SinhLayer_to_Algorithm } + + boxed_cast_base! { SinhLayer, crate::dnn::Layer, cv_dnn_SinhLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for SinhLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -18975,49 +19218,63 @@ pub mod dnn { boxed_ref! { SinhLayer, crate::dnn::SinhLayerTraitConst, as_raw_SinhLayer, crate::dnn::SinhLayerTrait, as_raw_mut_SinhLayer } - impl SinhLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_SinhLayer_defaultNew_const()) } - } + /// Slice layer has several modes: + /// 1. Caffe mode + /// ## Parameters + /// * axis: Axis of split operation + /// * slice_point: Array of split points + /// + /// Number of output blobs equals to number of split points plus one. The + /// first blob is a slice on input from 0 to @p slice_point[0] - 1 by @p axis, + /// the second output blob is a slice of input from @p slice_point[0] to + /// @p slice_point[1] - 1 by @p axis and the last output blob is a slice of + /// input from @p slice_point[-1] up to the end of @p axis size. + /// + /// 2. TensorFlow mode + /// * begin: Vector of start indices + /// * size: Vector of sizes + /// + /// More convenient numpy-like slice. One and only output blob + /// is a slice `input[begin[0]:begin[0]+size[0], begin[1]:begin[1]+size[1], ...]` + /// + /// 3. Torch mode + /// * axis: Axis of split operation + /// + /// Split input blob on the equal parts by @p axis. + pub struct SliceLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { SliceLayer } + + impl Drop for SliceLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_SinhLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_SliceLayer_delete(self.as_raw_mut_SliceLayer()) }; } - } - boxed_cast_base! { SinhLayer, crate::dnn::ActivationLayer, cv_dnn_SinhLayer_to_ActivationLayer } - - boxed_cast_base! { SinhLayer, core::Algorithm, cv_dnn_SinhLayer_to_Algorithm } - - boxed_cast_base! { SinhLayer, crate::dnn::Layer, cv_dnn_SinhLayer_to_Layer } + unsafe impl Send for SliceLayer {} - impl std::fmt::Debug for SinhLayer { + impl SliceLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SinhLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::SliceLayer { + let ret = unsafe { sys::cv_dnn_SliceLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::SliceLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for SinhLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_SliceLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::SliceLayer] @@ -19090,43 +19347,33 @@ pub mod dnn { } - /// Slice layer has several modes: - /// 1. Caffe mode - /// ## Parameters - /// * axis: Axis of split operation - /// * slice_point: Array of split points - /// - /// Number of output blobs equals to number of split points plus one. The - /// first blob is a slice on input from 0 to @p slice_point[0] - 1 by @p axis, - /// the second output blob is a slice of input from @p slice_point[0] to - /// @p slice_point[1] - 1 by @p axis and the last output blob is a slice of - /// input from @p slice_point[-1] up to the end of @p axis size. - /// - /// 2. TensorFlow mode - /// * begin: Vector of start indices - /// * size: Vector of sizes - /// - /// More convenient numpy-like slice. One and only output blob - /// is a slice `input[begin[0]:begin[0]+size[0], begin[1]:begin[1]+size[1], ...]` - /// - /// 3. Torch mode - /// * axis: Axis of split operation - /// - /// Split input blob on the equal parts by @p axis. - pub struct SliceLayer { - ptr: *mut c_void, + impl Default for SliceLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { SliceLayer } - - impl Drop for SliceLayer { + impl std::fmt::Debug for SliceLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_SliceLayer_delete(self.as_raw_mut_SliceLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SliceLayer") + .field("slice_ranges", &crate::dnn::SliceLayerTraitConst::slice_ranges(self)) + .field("slice_steps", &crate::dnn::SliceLayerTraitConst::slice_steps(self)) + .field("axis", &crate::dnn::SliceLayerTraitConst::axis(self)) + .field("num_split", &crate::dnn::SliceLayerTraitConst::num_split(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for SliceLayer {} + boxed_cast_base! { SliceLayer, core::Algorithm, cv_dnn_SliceLayer_to_Algorithm } + + boxed_cast_base! { SliceLayer, crate::dnn::Layer, cv_dnn_SliceLayer_to_Layer } impl core::AlgorithmTraitConst for SliceLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -19158,51 +19405,40 @@ pub mod dnn { boxed_ref! { SliceLayer, crate::dnn::SliceLayerTraitConst, as_raw_SliceLayer, crate::dnn::SliceLayerTrait, as_raw_mut_SliceLayer } - impl SliceLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_SliceLayer_defaultNew_const()) } - } + pub struct SoftmaxLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { SoftmaxLayer } + impl Drop for SoftmaxLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_SliceLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_SoftmaxLayer_delete(self.as_raw_mut_SoftmaxLayer()) }; } - } - boxed_cast_base! { SliceLayer, core::Algorithm, cv_dnn_SliceLayer_to_Algorithm } + unsafe impl Send for SoftmaxLayer {} - boxed_cast_base! { SliceLayer, crate::dnn::Layer, cv_dnn_SliceLayer_to_Layer } + impl SoftmaxLayer { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::dnn::SoftmaxLayer { + let ret = unsafe { sys::cv_dnn_SoftmaxLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::SoftmaxLayer::opencv_from_extern(ret) }; + ret + } - impl std::fmt::Debug for SliceLayer { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SliceLayer") - .field("slice_ranges", &crate::dnn::SliceLayerTraitConst::slice_ranges(self)) - .field("slice_steps", &crate::dnn::SliceLayerTraitConst::slice_steps(self)) - .field("axis", &crate::dnn::SliceLayerTraitConst::axis(self)) - .field("num_split", &crate::dnn::SliceLayerTraitConst::num_split(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_SoftmaxLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for SliceLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } } /// Constant methods for [crate::dnn::SoftmaxLayer] @@ -19229,20 +19465,30 @@ pub mod dnn { } - pub struct SoftmaxLayer { - ptr: *mut c_void, + impl Default for SoftmaxLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { SoftmaxLayer } - - impl Drop for SoftmaxLayer { + impl std::fmt::Debug for SoftmaxLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_SoftmaxLayer_delete(self.as_raw_mut_SoftmaxLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SoftmaxLayer") + .field("log_soft_max", &crate::dnn::SoftmaxLayerTraitConst::log_soft_max(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for SoftmaxLayer {} + boxed_cast_base! { SoftmaxLayer, core::Algorithm, cv_dnn_SoftmaxLayer_to_Algorithm } + + boxed_cast_base! { SoftmaxLayer, crate::dnn::Layer, cv_dnn_SoftmaxLayer_to_Layer } impl core::AlgorithmTraitConst for SoftmaxLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -19274,48 +19520,40 @@ pub mod dnn { boxed_ref! { SoftmaxLayer, crate::dnn::SoftmaxLayerTraitConst, as_raw_SoftmaxLayer, crate::dnn::SoftmaxLayerTrait, as_raw_mut_SoftmaxLayer } - impl SoftmaxLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_SoftmaxLayer_defaultNew_const()) } - } + pub struct SoftmaxLayerInt8 { + ptr: *mut c_void, + } + opencv_type_boxed! { SoftmaxLayerInt8 } + + impl Drop for SoftmaxLayerInt8 { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_SoftmaxLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_SoftmaxLayerInt8_delete(self.as_raw_mut_SoftmaxLayerInt8()) }; } - } - boxed_cast_base! { SoftmaxLayer, core::Algorithm, cv_dnn_SoftmaxLayer_to_Algorithm } - - boxed_cast_base! { SoftmaxLayer, crate::dnn::Layer, cv_dnn_SoftmaxLayer_to_Layer } + unsafe impl Send for SoftmaxLayerInt8 {} - impl std::fmt::Debug for SoftmaxLayer { + impl SoftmaxLayerInt8 { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SoftmaxLayer") - .field("log_soft_max", &crate::dnn::SoftmaxLayerTraitConst::log_soft_max(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::SoftmaxLayerInt8 { + let ret = unsafe { sys::cv_dnn_SoftmaxLayerInt8_defaultNew_const() }; + let ret = unsafe { crate::dnn::SoftmaxLayerInt8::opencv_from_extern(ret) }; + ret } - } - impl Default for SoftmaxLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_SoftmaxLayerInt8_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::SoftmaxLayerInt8] @@ -19354,20 +19592,34 @@ pub mod dnn { } - pub struct SoftmaxLayerInt8 { - ptr: *mut c_void, + impl Default for SoftmaxLayerInt8 { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { SoftmaxLayerInt8 } - - impl Drop for SoftmaxLayerInt8 { + impl std::fmt::Debug for SoftmaxLayerInt8 { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_SoftmaxLayerInt8_delete(self.as_raw_mut_SoftmaxLayerInt8()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SoftmaxLayerInt8") + .field("output_sc", &crate::dnn::SoftmaxLayerInt8TraitConst::output_sc(self)) + .field("output_zp", &crate::dnn::SoftmaxLayerInt8TraitConst::output_zp(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .field("log_soft_max", &crate::dnn::SoftmaxLayerTraitConst::log_soft_max(self)) + .finish() } } - unsafe impl Send for SoftmaxLayerInt8 {} + boxed_cast_base! { SoftmaxLayerInt8, core::Algorithm, cv_dnn_SoftmaxLayerInt8_to_Algorithm } + + boxed_cast_base! { SoftmaxLayerInt8, crate::dnn::Layer, cv_dnn_SoftmaxLayerInt8_to_Layer } + + boxed_cast_base! { SoftmaxLayerInt8, crate::dnn::SoftmaxLayer, cv_dnn_SoftmaxLayerInt8_to_SoftmaxLayer } impl core::AlgorithmTraitConst for SoftmaxLayerInt8 { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -19409,52 +19661,40 @@ pub mod dnn { boxed_ref! { SoftmaxLayerInt8, crate::dnn::SoftmaxLayerInt8TraitConst, as_raw_SoftmaxLayerInt8, crate::dnn::SoftmaxLayerInt8Trait, as_raw_mut_SoftmaxLayerInt8 } - impl SoftmaxLayerInt8 { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_SoftmaxLayerInt8_defaultNew_const()) } - } + pub struct SoftplusLayer { + ptr: *mut c_void, + } + opencv_type_boxed! { SoftplusLayer } + + impl Drop for SoftplusLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_SoftmaxLayerInt8_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_SoftplusLayer_delete(self.as_raw_mut_SoftplusLayer()) }; } - } - boxed_cast_base! { SoftmaxLayerInt8, core::Algorithm, cv_dnn_SoftmaxLayerInt8_to_Algorithm } - - boxed_cast_base! { SoftmaxLayerInt8, crate::dnn::Layer, cv_dnn_SoftmaxLayerInt8_to_Layer } - - boxed_cast_base! { SoftmaxLayerInt8, crate::dnn::SoftmaxLayer, cv_dnn_SoftmaxLayerInt8_to_SoftmaxLayer } + unsafe impl Send for SoftplusLayer {} - impl std::fmt::Debug for SoftmaxLayerInt8 { + impl SoftplusLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SoftmaxLayerInt8") - .field("output_sc", &crate::dnn::SoftmaxLayerInt8TraitConst::output_sc(self)) - .field("output_zp", &crate::dnn::SoftmaxLayerInt8TraitConst::output_zp(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .field("log_soft_max", &crate::dnn::SoftmaxLayerTraitConst::log_soft_max(self)) - .finish() + pub fn default() -> crate::dnn::SoftplusLayer { + let ret = unsafe { sys::cv_dnn_SoftplusLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::SoftplusLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for SoftmaxLayerInt8 { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_SoftplusLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::SoftplusLayer] @@ -19469,20 +19709,31 @@ pub mod dnn { } - pub struct SoftplusLayer { - ptr: *mut c_void, + impl Default for SoftplusLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { SoftplusLayer } - - impl Drop for SoftplusLayer { + impl std::fmt::Debug for SoftplusLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_SoftplusLayer_delete(self.as_raw_mut_SoftplusLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SoftplusLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for SoftplusLayer {} + boxed_cast_base! { SoftplusLayer, crate::dnn::ActivationLayer, cv_dnn_SoftplusLayer_to_ActivationLayer } + + boxed_cast_base! { SoftplusLayer, core::Algorithm, cv_dnn_SoftplusLayer_to_Algorithm } + + boxed_cast_base! { SoftplusLayer, crate::dnn::Layer, cv_dnn_SoftplusLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for SoftplusLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -19524,49 +19775,40 @@ pub mod dnn { boxed_ref! { SoftplusLayer, crate::dnn::SoftplusLayerTraitConst, as_raw_SoftplusLayer, crate::dnn::SoftplusLayerTrait, as_raw_mut_SoftplusLayer } - impl SoftplusLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_SoftplusLayer_defaultNew_const()) } - } + pub struct SoftsignLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { SoftsignLayer } + impl Drop for SoftsignLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_SoftplusLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_SoftsignLayer_delete(self.as_raw_mut_SoftsignLayer()) }; } - } - boxed_cast_base! { SoftplusLayer, crate::dnn::ActivationLayer, cv_dnn_SoftplusLayer_to_ActivationLayer } - - boxed_cast_base! { SoftplusLayer, core::Algorithm, cv_dnn_SoftplusLayer_to_Algorithm } - - boxed_cast_base! { SoftplusLayer, crate::dnn::Layer, cv_dnn_SoftplusLayer_to_Layer } + unsafe impl Send for SoftsignLayer {} - impl std::fmt::Debug for SoftplusLayer { + impl SoftsignLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SoftplusLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::SoftsignLayer { + let ret = unsafe { sys::cv_dnn_SoftsignLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::SoftsignLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for SoftplusLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_SoftsignLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::SoftsignLayer] @@ -19581,20 +19823,31 @@ pub mod dnn { } - pub struct SoftsignLayer { - ptr: *mut c_void, + impl Default for SoftsignLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { SoftsignLayer } - - impl Drop for SoftsignLayer { + impl std::fmt::Debug for SoftsignLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_SoftsignLayer_delete(self.as_raw_mut_SoftsignLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SoftsignLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for SoftsignLayer {} + boxed_cast_base! { SoftsignLayer, crate::dnn::ActivationLayer, cv_dnn_SoftsignLayer_to_ActivationLayer } + + boxed_cast_base! { SoftsignLayer, core::Algorithm, cv_dnn_SoftsignLayer_to_Algorithm } + + boxed_cast_base! { SoftsignLayer, crate::dnn::Layer, cv_dnn_SoftsignLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for SoftsignLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -19636,49 +19889,40 @@ pub mod dnn { boxed_ref! { SoftsignLayer, crate::dnn::SoftsignLayerTraitConst, as_raw_SoftsignLayer, crate::dnn::SoftsignLayerTrait, as_raw_mut_SoftsignLayer } - impl SoftsignLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_SoftsignLayer_defaultNew_const()) } - } + pub struct SpaceToDepthLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { SpaceToDepthLayer } + impl Drop for SpaceToDepthLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_SoftsignLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_SpaceToDepthLayer_delete(self.as_raw_mut_SpaceToDepthLayer()) }; } - } - boxed_cast_base! { SoftsignLayer, crate::dnn::ActivationLayer, cv_dnn_SoftsignLayer_to_ActivationLayer } - - boxed_cast_base! { SoftsignLayer, core::Algorithm, cv_dnn_SoftsignLayer_to_Algorithm } - - boxed_cast_base! { SoftsignLayer, crate::dnn::Layer, cv_dnn_SoftsignLayer_to_Layer } + unsafe impl Send for SpaceToDepthLayer {} - impl std::fmt::Debug for SoftsignLayer { + impl SpaceToDepthLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SoftsignLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::SpaceToDepthLayer { + let ret = unsafe { sys::cv_dnn_SpaceToDepthLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::SpaceToDepthLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for SoftsignLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_SpaceToDepthLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::SpaceToDepthLayer] @@ -19693,20 +19937,29 @@ pub mod dnn { } - pub struct SpaceToDepthLayer { - ptr: *mut c_void, + impl Default for SpaceToDepthLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { SpaceToDepthLayer } - - impl Drop for SpaceToDepthLayer { + impl std::fmt::Debug for SpaceToDepthLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_SpaceToDepthLayer_delete(self.as_raw_mut_SpaceToDepthLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SpaceToDepthLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for SpaceToDepthLayer {} + boxed_cast_base! { SpaceToDepthLayer, core::Algorithm, cv_dnn_SpaceToDepthLayer_to_Algorithm } + + boxed_cast_base! { SpaceToDepthLayer, crate::dnn::Layer, cv_dnn_SpaceToDepthLayer_to_Layer } impl core::AlgorithmTraitConst for SpaceToDepthLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -19738,47 +19991,40 @@ pub mod dnn { boxed_ref! { SpaceToDepthLayer, crate::dnn::SpaceToDepthLayerTraitConst, as_raw_SpaceToDepthLayer, crate::dnn::SpaceToDepthLayerTrait, as_raw_mut_SpaceToDepthLayer } - impl SpaceToDepthLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_SpaceToDepthLayer_defaultNew_const()) } - } + pub struct SplitLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { SplitLayer } + impl Drop for SplitLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_SpaceToDepthLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_SplitLayer_delete(self.as_raw_mut_SplitLayer()) }; } - } - boxed_cast_base! { SpaceToDepthLayer, core::Algorithm, cv_dnn_SpaceToDepthLayer_to_Algorithm } - - boxed_cast_base! { SpaceToDepthLayer, crate::dnn::Layer, cv_dnn_SpaceToDepthLayer_to_Layer } + unsafe impl Send for SplitLayer {} - impl std::fmt::Debug for SpaceToDepthLayer { + impl SplitLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SpaceToDepthLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::SplitLayer { + let ret = unsafe { sys::cv_dnn_SplitLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::SplitLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for SpaceToDepthLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_SplitLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::SplitLayer] @@ -19807,20 +20053,30 @@ pub mod dnn { } - pub struct SplitLayer { - ptr: *mut c_void, + impl Default for SplitLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { SplitLayer } - - impl Drop for SplitLayer { + impl std::fmt::Debug for SplitLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_SplitLayer_delete(self.as_raw_mut_SplitLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SplitLayer") + .field("outputs_count", &crate::dnn::SplitLayerTraitConst::outputs_count(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for SplitLayer {} + boxed_cast_base! { SplitLayer, core::Algorithm, cv_dnn_SplitLayer_to_Algorithm } + + boxed_cast_base! { SplitLayer, crate::dnn::Layer, cv_dnn_SplitLayer_to_Layer } impl core::AlgorithmTraitConst for SplitLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -19852,48 +20108,40 @@ pub mod dnn { boxed_ref! { SplitLayer, crate::dnn::SplitLayerTraitConst, as_raw_SplitLayer, crate::dnn::SplitLayerTrait, as_raw_mut_SplitLayer } - impl SplitLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_SplitLayer_defaultNew_const()) } - } + pub struct SqrtLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { SqrtLayer } + impl Drop for SqrtLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_SplitLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_SqrtLayer_delete(self.as_raw_mut_SqrtLayer()) }; } - } - boxed_cast_base! { SplitLayer, core::Algorithm, cv_dnn_SplitLayer_to_Algorithm } - - boxed_cast_base! { SplitLayer, crate::dnn::Layer, cv_dnn_SplitLayer_to_Layer } + unsafe impl Send for SqrtLayer {} - impl std::fmt::Debug for SplitLayer { + impl SqrtLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SplitLayer") - .field("outputs_count", &crate::dnn::SplitLayerTraitConst::outputs_count(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::SqrtLayer { + let ret = unsafe { sys::cv_dnn_SqrtLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::SqrtLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for SplitLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_SqrtLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::SqrtLayer] @@ -19908,20 +20156,31 @@ pub mod dnn { } - pub struct SqrtLayer { - ptr: *mut c_void, + impl Default for SqrtLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { SqrtLayer } - - impl Drop for SqrtLayer { + impl std::fmt::Debug for SqrtLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_SqrtLayer_delete(self.as_raw_mut_SqrtLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SqrtLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for SqrtLayer {} + boxed_cast_base! { SqrtLayer, crate::dnn::ActivationLayer, cv_dnn_SqrtLayer_to_ActivationLayer } + + boxed_cast_base! { SqrtLayer, core::Algorithm, cv_dnn_SqrtLayer_to_Algorithm } + + boxed_cast_base! { SqrtLayer, crate::dnn::Layer, cv_dnn_SqrtLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for SqrtLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -19957,57 +20216,48 @@ pub mod dnn { #[inline] fn as_raw_SqrtLayer(&self) -> *const c_void { self.as_raw() } } - impl crate::dnn::SqrtLayerTrait for SqrtLayer { - #[inline] fn as_raw_mut_SqrtLayer(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::dnn::SqrtLayerTrait for SqrtLayer { + #[inline] fn as_raw_mut_SqrtLayer(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { SqrtLayer, crate::dnn::SqrtLayerTraitConst, as_raw_SqrtLayer, crate::dnn::SqrtLayerTrait, as_raw_mut_SqrtLayer } + + pub struct SwishLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { SwishLayer } + + impl Drop for SwishLayer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_SwishLayer_delete(self.as_raw_mut_SwishLayer()) }; + } } - boxed_ref! { SqrtLayer, crate::dnn::SqrtLayerTraitConst, as_raw_SqrtLayer, crate::dnn::SqrtLayerTrait, as_raw_mut_SqrtLayer } + unsafe impl Send for SwishLayer {} - impl SqrtLayer { + impl SwishLayer { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_SqrtLayer_defaultNew_const()) } + pub fn default() -> crate::dnn::SwishLayer { + let ret = unsafe { sys::cv_dnn_SwishLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::SwishLayer::opencv_from_extern(ret) }; + ret } #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_SqrtLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_SwishLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { SqrtLayer, crate::dnn::ActivationLayer, cv_dnn_SqrtLayer_to_ActivationLayer } - - boxed_cast_base! { SqrtLayer, core::Algorithm, cv_dnn_SqrtLayer_to_Algorithm } - - boxed_cast_base! { SqrtLayer, crate::dnn::Layer, cv_dnn_SqrtLayer_to_Layer } - - impl std::fmt::Debug for SqrtLayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SqrtLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for SqrtLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - /// Constant methods for [crate::dnn::SwishLayer] pub trait SwishLayerTraitConst: crate::dnn::ActivationLayerTraitConst { fn as_raw_SwishLayer(&self) -> *const c_void; @@ -20020,20 +20270,31 @@ pub mod dnn { } - pub struct SwishLayer { - ptr: *mut c_void, + impl Default for SwishLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { SwishLayer } - - impl Drop for SwishLayer { + impl std::fmt::Debug for SwishLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_SwishLayer_delete(self.as_raw_mut_SwishLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SwishLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for SwishLayer {} + boxed_cast_base! { SwishLayer, crate::dnn::ActivationLayer, cv_dnn_SwishLayer_to_ActivationLayer } + + boxed_cast_base! { SwishLayer, core::Algorithm, cv_dnn_SwishLayer_to_Algorithm } + + boxed_cast_base! { SwishLayer, crate::dnn::Layer, cv_dnn_SwishLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for SwishLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -20075,49 +20336,40 @@ pub mod dnn { boxed_ref! { SwishLayer, crate::dnn::SwishLayerTraitConst, as_raw_SwishLayer, crate::dnn::SwishLayerTrait, as_raw_mut_SwishLayer } - impl SwishLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_SwishLayer_defaultNew_const()) } - } + pub struct TanHLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { TanHLayer } + impl Drop for TanHLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_SwishLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_TanHLayer_delete(self.as_raw_mut_TanHLayer()) }; } - } - boxed_cast_base! { SwishLayer, crate::dnn::ActivationLayer, cv_dnn_SwishLayer_to_ActivationLayer } - - boxed_cast_base! { SwishLayer, core::Algorithm, cv_dnn_SwishLayer_to_Algorithm } - - boxed_cast_base! { SwishLayer, crate::dnn::Layer, cv_dnn_SwishLayer_to_Layer } + unsafe impl Send for TanHLayer {} - impl std::fmt::Debug for SwishLayer { + impl TanHLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SwishLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::TanHLayer { + let ret = unsafe { sys::cv_dnn_TanHLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::TanHLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for SwishLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_TanHLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::TanHLayer] @@ -20132,20 +20384,31 @@ pub mod dnn { } - pub struct TanHLayer { - ptr: *mut c_void, + impl Default for TanHLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { TanHLayer } - - impl Drop for TanHLayer { + impl std::fmt::Debug for TanHLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_TanHLayer_delete(self.as_raw_mut_TanHLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TanHLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for TanHLayer {} + boxed_cast_base! { TanHLayer, crate::dnn::ActivationLayer, cv_dnn_TanHLayer_to_ActivationLayer } + + boxed_cast_base! { TanHLayer, core::Algorithm, cv_dnn_TanHLayer_to_Algorithm } + + boxed_cast_base! { TanHLayer, crate::dnn::Layer, cv_dnn_TanHLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for TanHLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -20187,49 +20450,40 @@ pub mod dnn { boxed_ref! { TanHLayer, crate::dnn::TanHLayerTraitConst, as_raw_TanHLayer, crate::dnn::TanHLayerTrait, as_raw_mut_TanHLayer } - impl TanHLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_TanHLayer_defaultNew_const()) } - } + pub struct TanLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { TanLayer } + impl Drop for TanLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_TanHLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_TanLayer_delete(self.as_raw_mut_TanLayer()) }; } - } - boxed_cast_base! { TanHLayer, crate::dnn::ActivationLayer, cv_dnn_TanHLayer_to_ActivationLayer } - - boxed_cast_base! { TanHLayer, core::Algorithm, cv_dnn_TanHLayer_to_Algorithm } - - boxed_cast_base! { TanHLayer, crate::dnn::Layer, cv_dnn_TanHLayer_to_Layer } + unsafe impl Send for TanLayer {} - impl std::fmt::Debug for TanHLayer { + impl TanLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TanHLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::TanLayer { + let ret = unsafe { sys::cv_dnn_TanLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::TanLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for TanHLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_TanLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::TanLayer] @@ -20244,20 +20498,31 @@ pub mod dnn { } - pub struct TanLayer { - ptr: *mut c_void, + impl Default for TanLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { TanLayer } - - impl Drop for TanLayer { + impl std::fmt::Debug for TanLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_TanLayer_delete(self.as_raw_mut_TanLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TanLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for TanLayer {} + boxed_cast_base! { TanLayer, crate::dnn::ActivationLayer, cv_dnn_TanLayer_to_ActivationLayer } + + boxed_cast_base! { TanLayer, core::Algorithm, cv_dnn_TanLayer_to_Algorithm } + + boxed_cast_base! { TanLayer, crate::dnn::Layer, cv_dnn_TanLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for TanLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -20289,60 +20554,31 @@ pub mod dnn { boxed_ref! { TanLayer, crate::dnn::LayerTraitConst, as_raw_Layer, crate::dnn::LayerTrait, as_raw_mut_Layer } - impl crate::dnn::TanLayerTraitConst for TanLayer { - #[inline] fn as_raw_TanLayer(&self) -> *const c_void { self.as_raw() } - } - - impl crate::dnn::TanLayerTrait for TanLayer { - #[inline] fn as_raw_mut_TanLayer(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TanLayer, crate::dnn::TanLayerTraitConst, as_raw_TanLayer, crate::dnn::TanLayerTrait, as_raw_mut_TanLayer } - - impl TanLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_TanLayer_defaultNew_const()) } - } - - #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_TanLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } + impl crate::dnn::TanLayerTraitConst for TanLayer { + #[inline] fn as_raw_TanLayer(&self) -> *const c_void { self.as_raw() } + } + impl crate::dnn::TanLayerTrait for TanLayer { + #[inline] fn as_raw_mut_TanLayer(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_cast_base! { TanLayer, crate::dnn::ActivationLayer, cv_dnn_TanLayer_to_ActivationLayer } + boxed_ref! { TanLayer, crate::dnn::TanLayerTraitConst, as_raw_TanLayer, crate::dnn::TanLayerTrait, as_raw_mut_TanLayer } - boxed_cast_base! { TanLayer, core::Algorithm, cv_dnn_TanLayer_to_Algorithm } + /// Base class for text detection networks + pub struct TextDetectionModel { + ptr: *mut c_void, + } - boxed_cast_base! { TanLayer, crate::dnn::Layer, cv_dnn_TanLayer_to_Layer } + opencv_type_boxed! { TextDetectionModel } - impl std::fmt::Debug for TanLayer { + impl Drop for TextDetectionModel { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TanLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_dnn_TextDetectionModel_delete(self.as_raw_mut_TextDetectionModel()) }; } } - impl Default for TanLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } + unsafe impl Send for TextDetectionModel {} /// Constant methods for [crate::dnn::TextDetectionModel] pub trait TextDetectionModelTraitConst: crate::dnn::ModelTraitConst { @@ -20464,21 +20700,15 @@ pub mod dnn { } - /// Base class for text detection networks - pub struct TextDetectionModel { - ptr: *mut c_void, - } - - opencv_type_boxed! { TextDetectionModel } - - impl Drop for TextDetectionModel { + impl std::fmt::Debug for TextDetectionModel { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_TextDetectionModel_delete(self.as_raw_mut_TextDetectionModel()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TextDetectionModel") + .finish() } } - unsafe impl Send for TextDetectionModel {} + boxed_cast_base! { TextDetectionModel, crate::dnn::Model, cv_dnn_TextDetectionModel_to_Model } impl crate::dnn::ModelTraitConst for TextDetectionModel { #[inline] fn as_raw_Model(&self) -> *const c_void { self.as_raw() } @@ -20500,17 +20730,96 @@ pub mod dnn { boxed_ref! { TextDetectionModel, crate::dnn::TextDetectionModelTraitConst, as_raw_TextDetectionModel, crate::dnn::TextDetectionModelTrait, as_raw_mut_TextDetectionModel } - impl TextDetectionModel { + /// This class represents high-level API for text detection DL networks compatible with DB model. + /// + /// Related publications: [liao2020real](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_liao2020real) + /// Paper: + /// For more information about the hyper-parameters setting, please refer to + /// + /// Configurable parameters: + /// - (float) binaryThreshold - The threshold of the binary map. It is usually set to 0.3. + /// - (float) polygonThreshold - The threshold of text polygons. It is usually set to 0.5, 0.6, and 0.7. Default is 0.5f + /// - (double) unclipRatio - The unclip ratio of the detected text region, which determines the output size. It is usually set to 2.0. + /// - (int) maxCandidates - The max number of the output results. + pub struct TextDetectionModel_DB { + ptr: *mut c_void, } - boxed_cast_base! { TextDetectionModel, crate::dnn::Model, cv_dnn_TextDetectionModel_to_Model } + opencv_type_boxed! { TextDetectionModel_DB } - impl std::fmt::Debug for TextDetectionModel { + impl Drop for TextDetectionModel_DB { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TextDetectionModel") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_dnn_TextDetectionModel_DB_delete(self.as_raw_mut_TextDetectionModel_DB()) }; + } + } + + unsafe impl Send for TextDetectionModel_DB {} + + impl TextDetectionModel_DB { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_TextDetectionModel_DB_TextDetectionModel_DB(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::TextDetectionModel_DB::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Create text detection algorithm from deep learning network. + /// ## Parameters + /// * network: Net object. + #[inline] + pub fn new(network: &impl crate::dnn::NetTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_TextDetectionModel_DB_TextDetectionModel_DB_const_NetR(network.as_raw_Net(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::TextDetectionModel_DB::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Create text detection model from network represented in one of the supported formats. + /// An order of @p model and @p config arguments does not matter. + /// ## Parameters + /// * model: Binary file contains trained weights. + /// * config: Text file contains network configuration. + /// + /// ## C++ default parameters + /// * config: "" + #[inline] + pub fn new_1(model: &str, config: &str) -> Result { + extern_container_arg!(model); + extern_container_arg!(config); + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_TextDetectionModel_DB_TextDetectionModel_DB_const_stringR_const_stringR(model.opencv_as_extern(), config.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::TextDetectionModel_DB::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Create text detection model from network represented in one of the supported formats. + /// An order of @p model and @p config arguments does not matter. + /// ## Parameters + /// * model: Binary file contains trained weights. + /// * config: Text file contains network configuration. + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * config: "" + #[inline] + pub fn new_def(model: &str) -> Result { + extern_container_arg!(model); + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_TextDetectionModel_DB_TextDetectionModel_DB_const_stringR(model.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::TextDetectionModel_DB::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::TextDetectionModel_DB] @@ -20601,31 +20910,24 @@ pub mod dnn { } - /// This class represents high-level API for text detection DL networks compatible with DB model. - /// - /// Related publications: [liao2020real](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_liao2020real) - /// Paper: - /// For more information about the hyper-parameters setting, please refer to - /// - /// Configurable parameters: - /// - (float) binaryThreshold - The threshold of the binary map. It is usually set to 0.3. - /// - (float) polygonThreshold - The threshold of text polygons. It is usually set to 0.5, 0.6, and 0.7. Default is 0.5f - /// - (double) unclipRatio - The unclip ratio of the detected text region, which determines the output size. It is usually set to 2.0. - /// - (int) maxCandidates - The max number of the output results. - pub struct TextDetectionModel_DB { - ptr: *mut c_void, + impl Clone for TextDetectionModel_DB { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_dnn_TextDetectionModel_DB_implicitClone_const(self.as_raw_TextDetectionModel_DB())) } + } } - opencv_type_boxed! { TextDetectionModel_DB } - - impl Drop for TextDetectionModel_DB { + impl std::fmt::Debug for TextDetectionModel_DB { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_TextDetectionModel_DB_delete(self.as_raw_mut_TextDetectionModel_DB()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TextDetectionModel_DB") + .finish() } } - unsafe impl Send for TextDetectionModel_DB {} + boxed_cast_base! { TextDetectionModel_DB, crate::dnn::Model, cv_dnn_TextDetectionModel_DB_to_Model } + + boxed_cast_base! { TextDetectionModel_DB, crate::dnn::TextDetectionModel, cv_dnn_TextDetectionModel_DB_to_TextDetectionModel } impl crate::dnn::ModelTraitConst for TextDetectionModel_DB { #[inline] fn as_raw_Model(&self) -> *const c_void { self.as_raw() } @@ -20657,27 +20959,47 @@ pub mod dnn { boxed_ref! { TextDetectionModel_DB, crate::dnn::TextDetectionModel_DBTraitConst, as_raw_TextDetectionModel_DB, crate::dnn::TextDetectionModel_DBTrait, as_raw_mut_TextDetectionModel_DB } - impl TextDetectionModel_DB { + /// This class represents high-level API for text detection DL networks compatible with EAST model. + /// + /// Configurable parameters: + /// - (float) confThreshold - used to filter boxes by confidences, default: 0.5f + /// - (float) nmsThreshold - used in non maximum suppression, default: 0.0f + pub struct TextDetectionModel_EAST { + ptr: *mut c_void, + } + + opencv_type_boxed! { TextDetectionModel_EAST } + + impl Drop for TextDetectionModel_EAST { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_dnn_TextDetectionModel_EAST_delete(self.as_raw_mut_TextDetectionModel_EAST()) }; + } + } + + unsafe impl Send for TextDetectionModel_EAST {} + + impl TextDetectionModel_EAST { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_TextDetectionModel_DB_TextDetectionModel_DB(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_TextDetectionModel_EAST_TextDetectionModel_EAST(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::TextDetectionModel_DB::opencv_from_extern(ret) }; + let ret = unsafe { crate::dnn::TextDetectionModel_EAST::opencv_from_extern(ret) }; Ok(ret) } - /// Create text detection algorithm from deep learning network. + /// Create text detection algorithm from deep learning network /// ## Parameters - /// * network: Net object. + /// * network: Net object #[inline] - pub fn new(network: &impl crate::dnn::NetTraitConst) -> Result { + pub fn new(network: &impl crate::dnn::NetTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_TextDetectionModel_DB_TextDetectionModel_DB_const_NetR(network.as_raw_Net(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_TextDetectionModel_EAST_TextDetectionModel_EAST_const_NetR(network.as_raw_Net(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::TextDetectionModel_DB::opencv_from_extern(ret) }; + let ret = unsafe { crate::dnn::TextDetectionModel_EAST::opencv_from_extern(ret) }; Ok(ret) } @@ -20690,14 +21012,14 @@ pub mod dnn { /// ## C++ default parameters /// * config: "" #[inline] - pub fn new_1(model: &str, config: &str) -> Result { + pub fn from_file(model: &str, config: &str) -> Result { extern_container_arg!(model); extern_container_arg!(config); return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_TextDetectionModel_DB_TextDetectionModel_DB_const_stringR_const_stringR(model.opencv_as_extern(), config.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_TextDetectionModel_EAST_TextDetectionModel_EAST_const_stringR_const_stringR(model.opencv_as_extern(), config.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::TextDetectionModel_DB::opencv_from_extern(ret) }; + let ret = unsafe { crate::dnn::TextDetectionModel_EAST::opencv_from_extern(ret) }; Ok(ret) } @@ -20708,40 +21030,21 @@ pub mod dnn { /// * config: Text file contains network configuration. /// /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: + /// This alternative version of [from_file] function uses the following default values for its arguments: /// * config: "" #[inline] - pub fn new_def(model: &str) -> Result { + pub fn from_file_def(model: &str) -> Result { extern_container_arg!(model); return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_TextDetectionModel_DB_TextDetectionModel_DB_const_stringR(model.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_TextDetectionModel_EAST_TextDetectionModel_EAST_const_stringR(model.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::TextDetectionModel_DB::opencv_from_extern(ret) }; + let ret = unsafe { crate::dnn::TextDetectionModel_EAST::opencv_from_extern(ret) }; Ok(ret) } } - impl Clone for TextDetectionModel_DB { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_dnn_TextDetectionModel_DB_implicitClone_const(self.as_raw_TextDetectionModel_DB())) } - } - } - - boxed_cast_base! { TextDetectionModel_DB, crate::dnn::Model, cv_dnn_TextDetectionModel_DB_to_Model } - - boxed_cast_base! { TextDetectionModel_DB, crate::dnn::TextDetectionModel, cv_dnn_TextDetectionModel_DB_to_TextDetectionModel } - - impl std::fmt::Debug for TextDetectionModel_DB { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TextDetectionModel_DB") - .finish() - } - } - /// Constant methods for [crate::dnn::TextDetectionModel_EAST] pub trait TextDetectionModel_EASTTraitConst: crate::dnn::TextDetectionModelTraitConst { fn as_raw_TextDetectionModel_EAST(&self) -> *const c_void; @@ -20792,33 +21095,32 @@ pub mod dnn { fn set_nms_threshold(&mut self, nms_threshold: f32) -> Result { return_send!(via ocvrs_return); unsafe { sys::cv_dnn_TextDetectionModel_EAST_setNMSThreshold_float(self.as_raw_mut_TextDetectionModel_EAST(), nms_threshold, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::TextDetectionModel_EAST::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - /// This class represents high-level API for text detection DL networks compatible with EAST model. - /// - /// Configurable parameters: - /// - (float) confThreshold - used to filter boxes by confidences, default: 0.5f - /// - (float) nmsThreshold - used in non maximum suppression, default: 0.0f - pub struct TextDetectionModel_EAST { - ptr: *mut c_void, + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn::TextDetectionModel_EAST::opencv_from_extern(ret) }; + Ok(ret) + } + } - opencv_type_boxed! { TextDetectionModel_EAST } + impl Clone for TextDetectionModel_EAST { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_dnn_TextDetectionModel_EAST_implicitClone_const(self.as_raw_TextDetectionModel_EAST())) } + } + } - impl Drop for TextDetectionModel_EAST { + impl std::fmt::Debug for TextDetectionModel_EAST { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_TextDetectionModel_EAST_delete(self.as_raw_mut_TextDetectionModel_EAST()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TextDetectionModel_EAST") + .finish() } } - unsafe impl Send for TextDetectionModel_EAST {} + boxed_cast_base! { TextDetectionModel_EAST, crate::dnn::Model, cv_dnn_TextDetectionModel_EAST_to_Model } + + boxed_cast_base! { TextDetectionModel_EAST, crate::dnn::TextDetectionModel, cv_dnn_TextDetectionModel_EAST_to_TextDetectionModel } impl crate::dnn::ModelTraitConst for TextDetectionModel_EAST { #[inline] fn as_raw_Model(&self) -> *const c_void { self.as_raw() } @@ -20850,91 +21152,94 @@ pub mod dnn { boxed_ref! { TextDetectionModel_EAST, crate::dnn::TextDetectionModel_EASTTraitConst, as_raw_TextDetectionModel_EAST, crate::dnn::TextDetectionModel_EASTTrait, as_raw_mut_TextDetectionModel_EAST } - impl TextDetectionModel_EAST { + /// This class represents high-level API for text recognition networks. + /// + /// TextRecognitionModel allows to set params for preprocessing input image. + /// TextRecognitionModel creates net from file with trained weights and config, + /// sets preprocessing input, runs forward pass and return recognition result. + /// For TextRecognitionModel, CRNN-CTC is supported. + pub struct TextRecognitionModel { + ptr: *mut c_void, + } + + opencv_type_boxed! { TextRecognitionModel } + + impl Drop for TextRecognitionModel { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_dnn_TextRecognitionModel_delete(self.as_raw_mut_TextRecognitionModel()) }; + } + } + + unsafe impl Send for TextRecognitionModel {} + + impl TextRecognitionModel { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_TextDetectionModel_EAST_TextDetectionModel_EAST(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_TextRecognitionModel_TextRecognitionModel(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::TextDetectionModel_EAST::opencv_from_extern(ret) }; + let ret = unsafe { crate::dnn::TextRecognitionModel::opencv_from_extern(ret) }; Ok(ret) } - /// Create text detection algorithm from deep learning network + /// Create Text Recognition model from deep learning network + /// Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method /// ## Parameters /// * network: Net object #[inline] - pub fn new(network: &impl crate::dnn::NetTraitConst) -> Result { + pub fn new(network: &impl crate::dnn::NetTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_TextDetectionModel_EAST_TextDetectionModel_EAST_const_NetR(network.as_raw_Net(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_TextRecognitionModel_TextRecognitionModel_const_NetR(network.as_raw_Net(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::TextDetectionModel_EAST::opencv_from_extern(ret) }; + let ret = unsafe { crate::dnn::TextRecognitionModel::opencv_from_extern(ret) }; Ok(ret) } - /// Create text detection model from network represented in one of the supported formats. - /// An order of @p model and @p config arguments does not matter. + /// Create text recognition model from network represented in one of the supported formats + /// Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method /// ## Parameters - /// * model: Binary file contains trained weights. - /// * config: Text file contains network configuration. + /// * model: Binary file contains trained weights + /// * config: Text file contains network configuration /// /// ## C++ default parameters /// * config: "" #[inline] - pub fn from_file(model: &str, config: &str) -> Result { + pub fn from_file(model: &str, config: &str) -> Result { extern_container_arg!(model); extern_container_arg!(config); return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_TextDetectionModel_EAST_TextDetectionModel_EAST_const_stringR_const_stringR(model.opencv_as_extern(), config.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_TextRecognitionModel_TextRecognitionModel_const_stringR_const_stringR(model.opencv_as_extern(), config.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::TextDetectionModel_EAST::opencv_from_extern(ret) }; + let ret = unsafe { crate::dnn::TextRecognitionModel::opencv_from_extern(ret) }; Ok(ret) } - /// Create text detection model from network represented in one of the supported formats. - /// An order of @p model and @p config arguments does not matter. + /// Create text recognition model from network represented in one of the supported formats + /// Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method /// ## Parameters - /// * model: Binary file contains trained weights. - /// * config: Text file contains network configuration. + /// * model: Binary file contains trained weights + /// * config: Text file contains network configuration /// /// ## Note /// This alternative version of [from_file] function uses the following default values for its arguments: /// * config: "" #[inline] - pub fn from_file_def(model: &str) -> Result { + pub fn from_file_def(model: &str) -> Result { extern_container_arg!(model); return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_TextDetectionModel_EAST_TextDetectionModel_EAST_const_stringR(model.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_TextRecognitionModel_TextRecognitionModel_const_stringR(model.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::TextDetectionModel_EAST::opencv_from_extern(ret) }; + let ret = unsafe { crate::dnn::TextRecognitionModel::opencv_from_extern(ret) }; Ok(ret) } } - impl Clone for TextDetectionModel_EAST { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_dnn_TextDetectionModel_EAST_implicitClone_const(self.as_raw_TextDetectionModel_EAST())) } - } - } - - boxed_cast_base! { TextDetectionModel_EAST, crate::dnn::Model, cv_dnn_TextDetectionModel_EAST_to_Model } - - boxed_cast_base! { TextDetectionModel_EAST, crate::dnn::TextDetectionModel, cv_dnn_TextDetectionModel_EAST_to_TextDetectionModel } - - impl std::fmt::Debug for TextDetectionModel_EAST { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TextDetectionModel_EAST") - .finish() - } - } - /// Constant methods for [crate::dnn::TextRecognitionModel] pub trait TextRecognitionModelTraitConst: crate::dnn::ModelTraitConst { fn as_raw_TextRecognitionModel(&self) -> *const c_void; @@ -21071,26 +21376,22 @@ pub mod dnn { } - /// This class represents high-level API for text recognition networks. - /// - /// TextRecognitionModel allows to set params for preprocessing input image. - /// TextRecognitionModel creates net from file with trained weights and config, - /// sets preprocessing input, runs forward pass and return recognition result. - /// For TextRecognitionModel, CRNN-CTC is supported. - pub struct TextRecognitionModel { - ptr: *mut c_void, + impl Clone for TextRecognitionModel { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_dnn_TextRecognitionModel_implicitClone_const(self.as_raw_TextRecognitionModel())) } + } } - opencv_type_boxed! { TextRecognitionModel } - - impl Drop for TextRecognitionModel { + impl std::fmt::Debug for TextRecognitionModel { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_TextRecognitionModel_delete(self.as_raw_mut_TextRecognitionModel()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TextRecognitionModel") + .finish() } } - unsafe impl Send for TextRecognitionModel {} + boxed_cast_base! { TextRecognitionModel, crate::dnn::Model, cv_dnn_TextRecognitionModel_to_Model } impl crate::dnn::ModelTraitConst for TextRecognitionModel { #[inline] fn as_raw_Model(&self) -> *const c_void { self.as_raw() } @@ -21112,90 +21413,42 @@ pub mod dnn { boxed_ref! { TextRecognitionModel, crate::dnn::TextRecognitionModelTraitConst, as_raw_TextRecognitionModel, crate::dnn::TextRecognitionModelTrait, as_raw_mut_TextRecognitionModel } - impl TextRecognitionModel { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_TextRecognitionModel_TextRecognitionModel(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::TextRecognitionModel::opencv_from_extern(ret) }; - Ok(ret) - } + pub struct ThresholdedReluLayer { + ptr: *mut c_void, + } - /// Create Text Recognition model from deep learning network - /// Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method - /// ## Parameters - /// * network: Net object + opencv_type_boxed! { ThresholdedReluLayer } + + impl Drop for ThresholdedReluLayer { #[inline] - pub fn new(network: &impl crate::dnn::NetTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_TextRecognitionModel_TextRecognitionModel_const_NetR(network.as_raw_Net(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::TextRecognitionModel::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_ThresholdedReluLayer_delete(self.as_raw_mut_ThresholdedReluLayer()) }; } + } - /// Create text recognition model from network represented in one of the supported formats - /// Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method - /// ## Parameters - /// * model: Binary file contains trained weights - /// * config: Text file contains network configuration - /// - /// ## C++ default parameters - /// * config: "" + unsafe impl Send for ThresholdedReluLayer {} + + impl ThresholdedReluLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - pub fn from_file(model: &str, config: &str) -> Result { - extern_container_arg!(model); - extern_container_arg!(config); - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_TextRecognitionModel_TextRecognitionModel_const_stringR_const_stringR(model.opencv_as_extern(), config.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::TextRecognitionModel::opencv_from_extern(ret) }; - Ok(ret) + pub fn default() -> crate::dnn::ThresholdedReluLayer { + let ret = unsafe { sys::cv_dnn_ThresholdedReluLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::ThresholdedReluLayer::opencv_from_extern(ret) }; + ret } - /// Create text recognition model from network represented in one of the supported formats - /// Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method - /// ## Parameters - /// * model: Binary file contains trained weights - /// * config: Text file contains network configuration - /// - /// ## Note - /// This alternative version of [from_file] function uses the following default values for its arguments: - /// * config: "" #[inline] - pub fn from_file_def(model: &str) -> Result { - extern_container_arg!(model); + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_TextRecognitionModel_TextRecognitionModel_const_stringR(model.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_ThresholdedReluLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::dnn::TextRecognitionModel::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - impl Clone for TextRecognitionModel { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_dnn_TextRecognitionModel_implicitClone_const(self.as_raw_TextRecognitionModel())) } - } - } - - boxed_cast_base! { TextRecognitionModel, crate::dnn::Model, cv_dnn_TextRecognitionModel_to_Model } - - impl std::fmt::Debug for TextRecognitionModel { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TextRecognitionModel") - .finish() - } - } - /// Constant methods for [crate::dnn::ThresholdedReluLayer] pub trait ThresholdedReluLayerTraitConst: crate::dnn::ActivationLayerTraitConst { fn as_raw_ThresholdedReluLayer(&self) -> *const c_void; @@ -21220,20 +21473,32 @@ pub mod dnn { } - pub struct ThresholdedReluLayer { - ptr: *mut c_void, + impl Default for ThresholdedReluLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ThresholdedReluLayer } - - impl Drop for ThresholdedReluLayer { + impl std::fmt::Debug for ThresholdedReluLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_ThresholdedReluLayer_delete(self.as_raw_mut_ThresholdedReluLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ThresholdedReluLayer") + .field("alpha", &crate::dnn::ThresholdedReluLayerTraitConst::alpha(self)) + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for ThresholdedReluLayer {} + boxed_cast_base! { ThresholdedReluLayer, crate::dnn::ActivationLayer, cv_dnn_ThresholdedReluLayer_to_ActivationLayer } + + boxed_cast_base! { ThresholdedReluLayer, core::Algorithm, cv_dnn_ThresholdedReluLayer_to_Algorithm } + + boxed_cast_base! { ThresholdedReluLayer, crate::dnn::Layer, cv_dnn_ThresholdedReluLayer_to_Layer } impl crate::dnn::ActivationLayerTraitConst for ThresholdedReluLayer { #[inline] fn as_raw_ActivationLayer(&self) -> *const c_void { self.as_raw() } @@ -21269,58 +21534,48 @@ pub mod dnn { #[inline] fn as_raw_ThresholdedReluLayer(&self) -> *const c_void { self.as_raw() } } - impl crate::dnn::ThresholdedReluLayerTrait for ThresholdedReluLayer { - #[inline] fn as_raw_mut_ThresholdedReluLayer(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::dnn::ThresholdedReluLayerTrait for ThresholdedReluLayer { + #[inline] fn as_raw_mut_ThresholdedReluLayer(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { ThresholdedReluLayer, crate::dnn::ThresholdedReluLayerTraitConst, as_raw_ThresholdedReluLayer, crate::dnn::ThresholdedReluLayerTrait, as_raw_mut_ThresholdedReluLayer } + + pub struct TileLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { TileLayer } + + impl Drop for TileLayer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_TileLayer_delete(self.as_raw_mut_TileLayer()) }; + } } - boxed_ref! { ThresholdedReluLayer, crate::dnn::ThresholdedReluLayerTraitConst, as_raw_ThresholdedReluLayer, crate::dnn::ThresholdedReluLayerTrait, as_raw_mut_ThresholdedReluLayer } + unsafe impl Send for TileLayer {} - impl ThresholdedReluLayer { + impl TileLayer { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_ThresholdedReluLayer_defaultNew_const()) } + pub fn default() -> crate::dnn::TileLayer { + let ret = unsafe { sys::cv_dnn_TileLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::TileLayer::opencv_from_extern(ret) }; + ret } #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_ThresholdedReluLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dnn_TileLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { ThresholdedReluLayer, crate::dnn::ActivationLayer, cv_dnn_ThresholdedReluLayer_to_ActivationLayer } - - boxed_cast_base! { ThresholdedReluLayer, core::Algorithm, cv_dnn_ThresholdedReluLayer_to_Algorithm } - - boxed_cast_base! { ThresholdedReluLayer, crate::dnn::Layer, cv_dnn_ThresholdedReluLayer_to_Layer } - - impl std::fmt::Debug for ThresholdedReluLayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ThresholdedReluLayer") - .field("alpha", &crate::dnn::ThresholdedReluLayerTraitConst::alpha(self)) - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for ThresholdedReluLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - /// Constant methods for [crate::dnn::TileLayer] pub trait TileLayerTraitConst: crate::dnn::LayerTraitConst { fn as_raw_TileLayer(&self) -> *const c_void; @@ -21333,20 +21588,29 @@ pub mod dnn { } - pub struct TileLayer { - ptr: *mut c_void, + impl Default for TileLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { TileLayer } - - impl Drop for TileLayer { + impl std::fmt::Debug for TileLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_TileLayer_delete(self.as_raw_mut_TileLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TileLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for TileLayer {} + boxed_cast_base! { TileLayer, core::Algorithm, cv_dnn_TileLayer_to_Algorithm } + + boxed_cast_base! { TileLayer, crate::dnn::Layer, cv_dnn_TileLayer_to_Layer } impl core::AlgorithmTraitConst for TileLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -21378,47 +21642,40 @@ pub mod dnn { boxed_ref! { TileLayer, crate::dnn::TileLayerTraitConst, as_raw_TileLayer, crate::dnn::TileLayerTrait, as_raw_mut_TileLayer } - impl TileLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_TileLayer_defaultNew_const()) } - } + pub struct TopKLayer { + ptr: *mut c_void, + } + + opencv_type_boxed! { TopKLayer } + impl Drop for TopKLayer { #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_TileLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_dnn_TopKLayer_delete(self.as_raw_mut_TopKLayer()) }; } - } - boxed_cast_base! { TileLayer, core::Algorithm, cv_dnn_TileLayer_to_Algorithm } - - boxed_cast_base! { TileLayer, crate::dnn::Layer, cv_dnn_TileLayer_to_Layer } + unsafe impl Send for TopKLayer {} - impl std::fmt::Debug for TileLayer { + impl TopKLayer { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TileLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() + pub fn default() -> crate::dnn::TopKLayer { + let ret = unsafe { sys::cv_dnn_TopKLayer_defaultNew_const() }; + let ret = unsafe { crate::dnn::TopKLayer::opencv_from_extern(ret) }; + ret } - } - impl Default for TileLayer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_TopKLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dnn::TopKLayer] @@ -21433,20 +21690,29 @@ pub mod dnn { } - pub struct TopKLayer { - ptr: *mut c_void, + impl Default for TopKLayer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { TopKLayer } - - impl Drop for TopKLayer { + impl std::fmt::Debug for TopKLayer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_TopKLayer_delete(self.as_raw_mut_TopKLayer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TopKLayer") + .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) + .field("name", &crate::dnn::LayerTraitConst::name(self)) + .field("typ", &crate::dnn::LayerTraitConst::typ(self)) + .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) + .finish() } } - unsafe impl Send for TopKLayer {} + boxed_cast_base! { TopKLayer, core::Algorithm, cv_dnn_TopKLayer_to_Algorithm } + + boxed_cast_base! { TopKLayer, crate::dnn::Layer, cv_dnn_TopKLayer_to_Layer } impl core::AlgorithmTraitConst for TopKLayer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -21478,61 +21744,6 @@ pub mod dnn { boxed_ref! { TopKLayer, crate::dnn::TopKLayerTraitConst, as_raw_TopKLayer, crate::dnn::TopKLayerTrait, as_raw_mut_TopKLayer } - impl TopKLayer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_dnn_TopKLayer_defaultNew_const()) } - } - - #[inline] - pub fn create(params: &impl crate::dnn::LayerParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_TopKLayer_create_const_LayerParamsR(params.as_raw_LayerParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { TopKLayer, core::Algorithm, cv_dnn_TopKLayer_to_Algorithm } - - boxed_cast_base! { TopKLayer, crate::dnn::Layer, cv_dnn_TopKLayer_to_Layer } - - impl std::fmt::Debug for TopKLayer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TopKLayer") - .field("blobs", &crate::dnn::LayerTraitConst::blobs(self)) - .field("name", &crate::dnn::LayerTraitConst::name(self)) - .field("typ", &crate::dnn::LayerTraitConst::typ(self)) - .field("preferable_target", &crate::dnn::LayerTraitConst::preferable_target(self)) - .finish() - } - } - - impl Default for TopKLayer { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - - /// Constant methods for [crate::dnn::_Range] - pub trait _RangeTraitConst: core::RangeTraitConst { - fn as_raw__Range(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::dnn::_Range] - pub trait _RangeTrait: core::RangeTrait + crate::dnn::_RangeTraitConst { - fn as_raw_mut__Range(&mut self) -> *mut c_void; - - } - pub struct _Range { ptr: *mut c_void, } @@ -21548,26 +21759,6 @@ pub mod dnn { unsafe impl Send for _Range {} - impl core::RangeTraitConst for _Range { - #[inline] fn as_raw_Range(&self) -> *const c_void { self.as_raw() } - } - - impl core::RangeTrait for _Range { - #[inline] fn as_raw_mut_Range(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { _Range, core::RangeTraitConst, as_raw_Range, core::RangeTrait, as_raw_mut_Range } - - impl crate::dnn::_RangeTraitConst for _Range { - #[inline] fn as_raw__Range(&self) -> *const c_void { self.as_raw() } - } - - impl crate::dnn::_RangeTrait for _Range { - #[inline] fn as_raw_mut__Range(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { _Range, crate::dnn::_RangeTraitConst, as_raw__Range, crate::dnn::_RangeTrait, as_raw_mut__Range } - impl _Range { #[inline] pub fn from_base(r: &impl core::RangeTraitConst) -> Result { @@ -21606,7 +21797,17 @@ pub mod dnn { } - boxed_cast_base! { _Range, core::Range, cv_dnn__Range_to_Range } + /// Constant methods for [crate::dnn::_Range] + pub trait _RangeTraitConst: core::RangeTraitConst { + fn as_raw__Range(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::dnn::_Range] + pub trait _RangeTrait: core::RangeTrait + crate::dnn::_RangeTraitConst { + fn as_raw_mut__Range(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for _Range { #[inline] @@ -21617,5 +21818,28 @@ pub mod dnn { .finish() } } + + boxed_cast_base! { _Range, core::Range, cv_dnn__Range_to_Range } + + impl core::RangeTraitConst for _Range { + #[inline] fn as_raw_Range(&self) -> *const c_void { self.as_raw() } + } + + impl core::RangeTrait for _Range { + #[inline] fn as_raw_mut_Range(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { _Range, core::RangeTraitConst, as_raw_Range, core::RangeTrait, as_raw_mut_Range } + + impl crate::dnn::_RangeTraitConst for _Range { + #[inline] fn as_raw__Range(&self) -> *const c_void { self.as_raw() } + } + + impl crate::dnn::_RangeTrait for _Range { + #[inline] fn as_raw_mut__Range(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { _Range, crate::dnn::_RangeTraitConst, as_raw__Range, crate::dnn::_RangeTrait, as_raw_mut__Range } + pub use crate::manual::dnn::*; } diff --git a/docs/dnn_superres.rs b/docs/dnn_superres.rs index 2e71c3c62..1f59ba8a7 100644 --- a/docs/dnn_superres.rs +++ b/docs/dnn_superres.rs @@ -14,6 +14,71 @@ pub mod dnn_superres { pub use super::{DnnSuperResImplTrait, DnnSuperResImplTraitConst}; } + /// A class to upscale images via convolutional neural networks. + /// The following four models are implemented: + /// + /// - edsr + /// - espcn + /// - fsrcnn + /// - lapsrn + pub struct DnnSuperResImpl { + ptr: *mut c_void, + } + + opencv_type_boxed! { DnnSuperResImpl } + + impl Drop for DnnSuperResImpl { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dnn_superres_DnnSuperResImpl_delete(self.as_raw_mut_DnnSuperResImpl()) }; + } + } + + unsafe impl Send for DnnSuperResImpl {} + + impl DnnSuperResImpl { + /// Empty constructor for python + #[inline] + pub fn create() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_superres_DnnSuperResImpl_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_superres_DnnSuperResImpl_DnnSuperResImpl(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn_superres::DnnSuperResImpl::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Constructor which immediately sets the desired model + /// ## Parameters + /// * algo: String containing one of the desired models: + /// - __edsr__ + /// - __espcn__ + /// - __fsrcnn__ + /// - __lapsrn__ + /// * scale: Integer specifying the upscale factor + #[inline] + pub fn new(algo: &str, scale: i32) -> Result { + extern_container_arg!(algo); + return_send!(via ocvrs_return); + unsafe { sys::cv_dnn_superres_DnnSuperResImpl_DnnSuperResImpl_const_StringR_int(algo.opencv_as_extern(), scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dnn_superres::DnnSuperResImpl::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::dnn_superres::DnnSuperResImpl] pub trait DnnSuperResImplTraitConst { fn as_raw_DnnSuperResImpl(&self) -> *const c_void; @@ -148,28 +213,14 @@ pub mod dnn_superres { } - /// A class to upscale images via convolutional neural networks. - /// The following four models are implemented: - /// - /// - edsr - /// - espcn - /// - fsrcnn - /// - lapsrn - pub struct DnnSuperResImpl { - ptr: *mut c_void, - } - - opencv_type_boxed! { DnnSuperResImpl } - - impl Drop for DnnSuperResImpl { + impl std::fmt::Debug for DnnSuperResImpl { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dnn_superres_DnnSuperResImpl_delete(self.as_raw_mut_DnnSuperResImpl()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DnnSuperResImpl") + .finish() } } - unsafe impl Send for DnnSuperResImpl {} - impl crate::dnn_superres::DnnSuperResImplTraitConst for DnnSuperResImpl { #[inline] fn as_raw_DnnSuperResImpl(&self) -> *const c_void { self.as_raw() } } @@ -180,54 +231,4 @@ pub mod dnn_superres { boxed_ref! { DnnSuperResImpl, crate::dnn_superres::DnnSuperResImplTraitConst, as_raw_DnnSuperResImpl, crate::dnn_superres::DnnSuperResImplTrait, as_raw_mut_DnnSuperResImpl } - impl DnnSuperResImpl { - /// Empty constructor for python - #[inline] - pub fn create() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_superres_DnnSuperResImpl_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_superres_DnnSuperResImpl_DnnSuperResImpl(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn_superres::DnnSuperResImpl::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Constructor which immediately sets the desired model - /// ## Parameters - /// * algo: String containing one of the desired models: - /// - __edsr__ - /// - __espcn__ - /// - __fsrcnn__ - /// - __lapsrn__ - /// * scale: Integer specifying the upscale factor - #[inline] - pub fn new(algo: &str, scale: i32) -> Result { - extern_container_arg!(algo); - return_send!(via ocvrs_return); - unsafe { sys::cv_dnn_superres_DnnSuperResImpl_DnnSuperResImpl_const_StringR_int(algo.opencv_as_extern(), scale, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dnn_superres::DnnSuperResImpl::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for DnnSuperResImpl { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DnnSuperResImpl") - .finish() - } - } } diff --git a/docs/dpm.rs b/docs/dpm.rs index b1a4f2397..3c2057f55 100644 --- a/docs/dpm.rs +++ b/docs/dpm.rs @@ -36,6 +36,66 @@ pub mod dpm { pub use super::{DPMDetectorTrait, DPMDetectorTraitConst, DPMDetector_ObjectDetectionTrait, DPMDetector_ObjectDetectionTraitConst}; } + /// This is a C++ abstract class, it provides external user API to work with DPM. + pub struct DPMDetector { + ptr: *mut c_void, + } + + opencv_type_boxed! { DPMDetector } + + impl Drop for DPMDetector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_dpm_DPMDetector_delete(self.as_raw_mut_DPMDetector()) }; + } + } + + unsafe impl Send for DPMDetector {} + + impl DPMDetector { + /// Load the trained models from given .xml files and return cv::Ptr\. + /// ## Parameters + /// * filenames: A set of filenames storing the trained detectors (models). Each file contains one + /// model. See examples of such files here `/opencv_extra/testdata/cv/dpm/VOC2007_Cascade/`. + /// * classNames: A set of trained models names. If it's empty then the name of each model will be + /// constructed from the name of file containing the model. E.g. the model stored in + /// "/home/user/cat.xml" will get the name "cat". + /// + /// ## C++ default parameters + /// * class_names: std::vector() + #[inline] + pub fn create(filenames: &core::Vector, class_names: &core::Vector) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dpm_DPMDetector_create_const_vectorLstringGR_const_vectorLstringGR(filenames.as_raw_VectorOfString(), class_names.as_raw_VectorOfString(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Load the trained models from given .xml files and return cv::Ptr\. + /// ## Parameters + /// * filenames: A set of filenames storing the trained detectors (models). Each file contains one + /// model. See examples of such files here `/opencv_extra/testdata/cv/dpm/VOC2007_Cascade/`. + /// * classNames: A set of trained models names. If it's empty then the name of each model will be + /// constructed from the name of file containing the model. E.g. the model stored in + /// "/home/user/cat.xml" will get the name "cat". + /// + /// ## Note + /// This alternative version of [DPMDetector::create] function uses the following default values for its arguments: + /// * class_names: std::vector() + #[inline] + pub fn create_def(filenames: &core::Vector) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_dpm_DPMDetector_create_const_vectorLstringGR(filenames.as_raw_VectorOfString(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::dpm::DPMDetector] pub trait DPMDetectorTraitConst { fn as_raw_DPMDetector(&self) -> *const c_void; @@ -93,22 +153,14 @@ pub mod dpm { } - /// This is a C++ abstract class, it provides external user API to work with DPM. - pub struct DPMDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { DPMDetector } - - impl Drop for DPMDetector { + impl std::fmt::Debug for DPMDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dpm_DPMDetector_delete(self.as_raw_mut_DPMDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DPMDetector") + .finish() } } - unsafe impl Send for DPMDetector {} - impl crate::dpm::DPMDetectorTraitConst for DPMDetector { #[inline] fn as_raw_DPMDetector(&self) -> *const c_void { self.as_raw() } } @@ -119,56 +171,57 @@ pub mod dpm { boxed_ref! { DPMDetector, crate::dpm::DPMDetectorTraitConst, as_raw_DPMDetector, crate::dpm::DPMDetectorTrait, as_raw_mut_DPMDetector } - impl DPMDetector { - /// Load the trained models from given .xml files and return cv::Ptr\. - /// ## Parameters - /// * filenames: A set of filenames storing the trained detectors (models). Each file contains one - /// model. See examples of such files here `/opencv_extra/testdata/cv/dpm/VOC2007_Cascade/`. - /// * classNames: A set of trained models names. If it's empty then the name of each model will be - /// constructed from the name of file containing the model. E.g. the model stored in - /// "/home/user/cat.xml" will get the name "cat". - /// - /// ## C++ default parameters - /// * class_names: std::vector() + pub struct DPMDetector_ObjectDetection { + ptr: *mut c_void, + } + + opencv_type_boxed! { DPMDetector_ObjectDetection } + + impl Drop for DPMDetector_ObjectDetection { #[inline] - pub fn create(filenames: &core::Vector, class_names: &core::Vector) -> Result> { + fn drop(&mut self) { + unsafe { sys::cv_dpm_DPMDetector_ObjectDetection_delete(self.as_raw_mut_DPMDetector_ObjectDetection()) }; + } + } + + unsafe impl Send for DPMDetector_ObjectDetection {} + + impl DPMDetector_ObjectDetection { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_dpm_DPMDetector_create_const_vectorLstringGR_const_vectorLstringGR(filenames.as_raw_VectorOfString(), class_names.as_raw_VectorOfString(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dpm_DPMDetector_ObjectDetection_ObjectDetection(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::dpm::DPMDetector_ObjectDetection::opencv_from_extern(ret) }; Ok(ret) } - /// Load the trained models from given .xml files and return cv::Ptr\. - /// ## Parameters - /// * filenames: A set of filenames storing the trained detectors (models). Each file contains one - /// model. See examples of such files here `/opencv_extra/testdata/cv/dpm/VOC2007_Cascade/`. - /// * classNames: A set of trained models names. If it's empty then the name of each model will be - /// constructed from the name of file containing the model. E.g. the model stored in - /// "/home/user/cat.xml" will get the name "cat". - /// - /// ## Note - /// This alternative version of [DPMDetector::create] function uses the following default values for its arguments: - /// * class_names: std::vector() + /// ## C++ default parameters + /// * class_id: -1 #[inline] - pub fn create_def(filenames: &core::Vector) -> Result> { + pub fn new(rect: core::Rect, score: f32, class_id: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_dpm_DPMDetector_create_const_vectorLstringGR(filenames.as_raw_VectorOfString(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dpm_DPMDetector_ObjectDetection_ObjectDetection_const_RectR_float_int(&rect, score, class_id, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::dpm::DPMDetector_ObjectDetection::opencv_from_extern(ret) }; Ok(ret) } - } - - impl std::fmt::Debug for DPMDetector { + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * class_id: -1 #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DPMDetector") - .finish() + pub fn new_def(rect: core::Rect, score: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_dpm_DPMDetector_ObjectDetection_ObjectDetection_const_RectR_float(&rect, score, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::dpm::DPMDetector_ObjectDetection::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::dpm::DPMDetector_ObjectDetection] @@ -221,21 +274,17 @@ pub mod dpm { } - pub struct DPMDetector_ObjectDetection { - ptr: *mut c_void, - } - - opencv_type_boxed! { DPMDetector_ObjectDetection } - - impl Drop for DPMDetector_ObjectDetection { + impl std::fmt::Debug for DPMDetector_ObjectDetection { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dpm_DPMDetector_ObjectDetection_delete(self.as_raw_mut_DPMDetector_ObjectDetection()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DPMDetector_ObjectDetection") + .field("rect", &crate::dpm::DPMDetector_ObjectDetectionTraitConst::rect(self)) + .field("score", &crate::dpm::DPMDetector_ObjectDetectionTraitConst::score(self)) + .field("class_id", &crate::dpm::DPMDetector_ObjectDetectionTraitConst::class_id(self)) + .finish() } } - unsafe impl Send for DPMDetector_ObjectDetection {} - impl crate::dpm::DPMDetector_ObjectDetectionTraitConst for DPMDetector_ObjectDetection { #[inline] fn as_raw_DPMDetector_ObjectDetection(&self) -> *const c_void { self.as_raw() } } @@ -246,52 +295,4 @@ pub mod dpm { boxed_ref! { DPMDetector_ObjectDetection, crate::dpm::DPMDetector_ObjectDetectionTraitConst, as_raw_DPMDetector_ObjectDetection, crate::dpm::DPMDetector_ObjectDetectionTrait, as_raw_mut_DPMDetector_ObjectDetection } - impl DPMDetector_ObjectDetection { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dpm_DPMDetector_ObjectDetection_ObjectDetection(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dpm::DPMDetector_ObjectDetection::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## C++ default parameters - /// * class_id: -1 - #[inline] - pub fn new(rect: core::Rect, score: f32, class_id: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dpm_DPMDetector_ObjectDetection_ObjectDetection_const_RectR_float_int(&rect, score, class_id, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dpm::DPMDetector_ObjectDetection::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * class_id: -1 - #[inline] - pub fn new_def(rect: core::Rect, score: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_dpm_DPMDetector_ObjectDetection_ObjectDetection_const_RectR_float(&rect, score, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::dpm::DPMDetector_ObjectDetection::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for DPMDetector_ObjectDetection { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DPMDetector_ObjectDetection") - .field("rect", &crate::dpm::DPMDetector_ObjectDetectionTraitConst::rect(self)) - .field("score", &crate::dpm::DPMDetector_ObjectDetectionTraitConst::score(self)) - .field("class_id", &crate::dpm::DPMDetector_ObjectDetectionTraitConst::class_id(self)) - .finish() - } - } } diff --git a/docs/face.rs b/docs/face.rs index 4617ec3cc..3bb4bb4bb 100644 --- a/docs/face.rs +++ b/docs/face.rs @@ -483,6 +483,66 @@ pub mod face { Ok(ret) } + /// Implementation of bio-inspired features (BIF) from the paper: + /// Guo, Guodong, et al. "Human age estimation using bio-inspired features." + /// Computer Vision and Pattern Recognition, 2009. CVPR 2009. + pub struct BIF { + ptr: *mut c_void, + } + + opencv_type_boxed! { BIF } + + impl Drop for BIF { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_face_BIF_delete(self.as_raw_mut_BIF()) }; + } + } + + unsafe impl Send for BIF {} + + impl BIF { + /// ## Parameters + /// * num_bands: The number of filter bands (<=8) used for computing BIF. + /// * num_rotations: The number of image rotations for computing BIF. + /// ## Returns + /// Object for computing BIF. + /// + /// ## C++ default parameters + /// * num_bands: 8 + /// * num_rotations: 12 + #[inline] + pub fn create(num_bands: i32, num_rotations: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_BIF_create_int_int(num_bands, num_rotations, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Parameters + /// * num_bands: The number of filter bands (<=8) used for computing BIF. + /// * num_rotations: The number of image rotations for computing BIF. + /// ## Returns + /// Object for computing BIF. + /// + /// ## Note + /// This alternative version of [BIF::create] function uses the following default values for its arguments: + /// * num_bands: 8 + /// * num_rotations: 12 + #[inline] + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_BIF_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::face::BIF] pub trait BIFTraitConst: core::AlgorithmTraitConst { fn as_raw_BIF(&self) -> *const c_void; @@ -532,23 +592,15 @@ pub mod face { } - /// Implementation of bio-inspired features (BIF) from the paper: - /// Guo, Guodong, et al. "Human age estimation using bio-inspired features." - /// Computer Vision and Pattern Recognition, 2009. CVPR 2009. - pub struct BIF { - ptr: *mut c_void, - } - - opencv_type_boxed! { BIF } - - impl Drop for BIF { + impl std::fmt::Debug for BIF { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_BIF_delete(self.as_raw_mut_BIF()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BIF") + .finish() } } - unsafe impl Send for BIF {} + boxed_cast_base! { BIF, core::Algorithm, cv_face_BIF_to_Algorithm } impl core::AlgorithmTraitConst for BIF { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -570,58 +622,21 @@ pub mod face { boxed_ref! { BIF, crate::face::BIFTraitConst, as_raw_BIF, crate::face::BIFTrait, as_raw_mut_BIF } - impl BIF { - /// ## Parameters - /// * num_bands: The number of filter bands (<=8) used for computing BIF. - /// * num_rotations: The number of image rotations for computing BIF. - /// ## Returns - /// Object for computing BIF. - /// - /// ## C++ default parameters - /// * num_bands: 8 - /// * num_rotations: 12 - #[inline] - pub fn create(num_bands: i32, num_rotations: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_face_BIF_create_int_int(num_bands, num_rotations, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Parameters - /// * num_bands: The number of filter bands (<=8) used for computing BIF. - /// * num_rotations: The number of image rotations for computing BIF. - /// ## Returns - /// Object for computing BIF. - /// - /// ## Note - /// This alternative version of [BIF::create] function uses the following default values for its arguments: - /// * num_bands: 8 - /// * num_rotations: 12 - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_face_BIF_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + pub struct BasicFaceRecognizer { + ptr: *mut c_void, } - boxed_cast_base! { BIF, core::Algorithm, cv_face_BIF_to_Algorithm } + opencv_type_boxed! { BasicFaceRecognizer } - impl std::fmt::Debug for BIF { + impl Drop for BasicFaceRecognizer { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BIF") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_face_BasicFaceRecognizer_delete(self.as_raw_mut_BasicFaceRecognizer()) }; } } + unsafe impl Send for BasicFaceRecognizer {} + /// Constant methods for [crate::face::BasicFaceRecognizer] pub trait BasicFaceRecognizerTraitConst: crate::face::FaceRecognizerTraitConst { fn as_raw_BasicFaceRecognizer(&self) -> *const c_void; @@ -755,20 +770,21 @@ pub mod face { } - pub struct BasicFaceRecognizer { - ptr: *mut c_void, - } - - opencv_type_boxed! { BasicFaceRecognizer } - - impl Drop for BasicFaceRecognizer { + impl std::fmt::Debug for BasicFaceRecognizer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_BasicFaceRecognizer_delete(self.as_raw_mut_BasicFaceRecognizer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BasicFaceRecognizer") + .finish() } } - unsafe impl Send for BasicFaceRecognizer {} + boxed_cast_base! { BasicFaceRecognizer, core::Algorithm, cv_face_BasicFaceRecognizer_to_Algorithm } + + boxed_cast_base! { BasicFaceRecognizer, crate::face::FaceRecognizer, cv_face_BasicFaceRecognizer_to_FaceRecognizer } + + boxed_cast_descendant! { BasicFaceRecognizer, crate::face::EigenFaceRecognizer, cv_face_BasicFaceRecognizer_to_EigenFaceRecognizer } + + boxed_cast_descendant! { BasicFaceRecognizer, crate::face::FisherFaceRecognizer, cv_face_BasicFaceRecognizer_to_FisherFaceRecognizer } impl core::AlgorithmTraitConst for BasicFaceRecognizer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -800,23 +816,55 @@ pub mod face { boxed_ref! { BasicFaceRecognizer, crate::face::BasicFaceRecognizerTraitConst, as_raw_BasicFaceRecognizer, crate::face::BasicFaceRecognizerTrait, as_raw_mut_BasicFaceRecognizer } - impl BasicFaceRecognizer { + pub struct CParams { + ptr: *mut c_void, } - boxed_cast_descendant! { BasicFaceRecognizer, crate::face::EigenFaceRecognizer, cv_face_BasicFaceRecognizer_to_EigenFaceRecognizer } + opencv_type_boxed! { CParams } - boxed_cast_descendant! { BasicFaceRecognizer, crate::face::FisherFaceRecognizer, cv_face_BasicFaceRecognizer_to_FisherFaceRecognizer } + impl Drop for CParams { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_face_CParams_delete(self.as_raw_mut_CParams()) }; + } + } - boxed_cast_base! { BasicFaceRecognizer, core::Algorithm, cv_face_BasicFaceRecognizer_to_Algorithm } + unsafe impl Send for CParams {} - boxed_cast_base! { BasicFaceRecognizer, crate::face::FaceRecognizer, cv_face_BasicFaceRecognizer_to_FaceRecognizer } + impl CParams { + /// ## C++ default parameters + /// * sf: 1.1 + /// * min_n: 3 + /// * min_sz: Size(30,30) + /// * max_sz: Size() + #[inline] + pub fn new(cascade_model: &str, sf: f64, min_n: i32, min_sz: core::Size, max_sz: core::Size) -> Result { + extern_container_arg!(cascade_model); + return_send!(via ocvrs_return); + unsafe { sys::cv_face_CParams_CParams_String_double_int_Size_Size(cascade_model.opencv_as_extern(), sf, min_n, &min_sz, &max_sz, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::face::CParams::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for BasicFaceRecognizer { + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * sf: 1.1 + /// * min_n: 3 + /// * min_sz: Size(30,30) + /// * max_sz: Size() #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BasicFaceRecognizer") - .finish() + pub fn new_def(cascade_model: &str) -> Result { + extern_container_arg!(cascade_model); + return_send!(via ocvrs_return); + unsafe { sys::cv_face_CParams_CParams_String(cascade_model.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::face::CParams::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::face::CParams] @@ -920,21 +968,20 @@ pub mod face { } - pub struct CParams { - ptr: *mut c_void, - } - - opencv_type_boxed! { CParams } - - impl Drop for CParams { + impl std::fmt::Debug for CParams { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_CParams_delete(self.as_raw_mut_CParams()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CParams") + .field("cascade", &crate::face::CParamsTraitConst::cascade(self)) + .field("scale_factor", &crate::face::CParamsTraitConst::scale_factor(self)) + .field("min_neighbors", &crate::face::CParamsTraitConst::min_neighbors(self)) + .field("min_size", &crate::face::CParamsTraitConst::min_size(self)) + .field("max_size", &crate::face::CParamsTraitConst::max_size(self)) + .field("face_cascade", &crate::face::CParamsTraitConst::face_cascade(self)) + .finish() } } - unsafe impl Send for CParams {} - impl crate::face::CParamsTraitConst for CParams { #[inline] fn as_raw_CParams(&self) -> *const c_void { self.as_raw() } } @@ -945,123 +992,21 @@ pub mod face { boxed_ref! { CParams, crate::face::CParamsTraitConst, as_raw_CParams, crate::face::CParamsTrait, as_raw_mut_CParams } - impl CParams { - /// ## C++ default parameters - /// * sf: 1.1 - /// * min_n: 3 - /// * min_sz: Size(30,30) - /// * max_sz: Size() + pub struct EigenFaceRecognizer { + ptr: *mut c_void, + } + + opencv_type_boxed! { EigenFaceRecognizer } + + impl Drop for EigenFaceRecognizer { #[inline] - pub fn new(cascade_model: &str, sf: f64, min_n: i32, min_sz: core::Size, max_sz: core::Size) -> Result { - extern_container_arg!(cascade_model); - return_send!(via ocvrs_return); - unsafe { sys::cv_face_CParams_CParams_String_double_int_Size_Size(cascade_model.opencv_as_extern(), sf, min_n, &min_sz, &max_sz, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::face::CParams::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_face_EigenFaceRecognizer_delete(self.as_raw_mut_EigenFaceRecognizer()) }; } - - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * sf: 1.1 - /// * min_n: 3 - /// * min_sz: Size(30,30) - /// * max_sz: Size() - #[inline] - pub fn new_def(cascade_model: &str) -> Result { - extern_container_arg!(cascade_model); - return_send!(via ocvrs_return); - unsafe { sys::cv_face_CParams_CParams_String(cascade_model.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::face::CParams::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for CParams { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CParams") - .field("cascade", &crate::face::CParamsTraitConst::cascade(self)) - .field("scale_factor", &crate::face::CParamsTraitConst::scale_factor(self)) - .field("min_neighbors", &crate::face::CParamsTraitConst::min_neighbors(self)) - .field("min_size", &crate::face::CParamsTraitConst::min_size(self)) - .field("max_size", &crate::face::CParamsTraitConst::max_size(self)) - .field("face_cascade", &crate::face::CParamsTraitConst::face_cascade(self)) - .finish() - } - } - - /// Constant methods for [crate::face::EigenFaceRecognizer] - pub trait EigenFaceRecognizerTraitConst: crate::face::BasicFaceRecognizerTraitConst { - fn as_raw_EigenFaceRecognizer(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::face::EigenFaceRecognizer] - pub trait EigenFaceRecognizerTrait: crate::face::BasicFaceRecognizerTrait + crate::face::EigenFaceRecognizerTraitConst { - fn as_raw_mut_EigenFaceRecognizer(&mut self) -> *mut c_void; - - } - - pub struct EigenFaceRecognizer { - ptr: *mut c_void, - } - - opencv_type_boxed! { EigenFaceRecognizer } - - impl Drop for EigenFaceRecognizer { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_EigenFaceRecognizer_delete(self.as_raw_mut_EigenFaceRecognizer()) }; - } - } + } unsafe impl Send for EigenFaceRecognizer {} - impl core::AlgorithmTraitConst for EigenFaceRecognizer { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for EigenFaceRecognizer { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { EigenFaceRecognizer, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::face::BasicFaceRecognizerTraitConst for EigenFaceRecognizer { - #[inline] fn as_raw_BasicFaceRecognizer(&self) -> *const c_void { self.as_raw() } - } - - impl crate::face::BasicFaceRecognizerTrait for EigenFaceRecognizer { - #[inline] fn as_raw_mut_BasicFaceRecognizer(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { EigenFaceRecognizer, crate::face::BasicFaceRecognizerTraitConst, as_raw_BasicFaceRecognizer, crate::face::BasicFaceRecognizerTrait, as_raw_mut_BasicFaceRecognizer } - - impl crate::face::FaceRecognizerTraitConst for EigenFaceRecognizer { - #[inline] fn as_raw_FaceRecognizer(&self) -> *const c_void { self.as_raw() } - } - - impl crate::face::FaceRecognizerTrait for EigenFaceRecognizer { - #[inline] fn as_raw_mut_FaceRecognizer(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { EigenFaceRecognizer, crate::face::FaceRecognizerTraitConst, as_raw_FaceRecognizer, crate::face::FaceRecognizerTrait, as_raw_mut_FaceRecognizer } - - impl crate::face::EigenFaceRecognizerTraitConst for EigenFaceRecognizer { - #[inline] fn as_raw_EigenFaceRecognizer(&self) -> *const c_void { self.as_raw() } - } - - impl crate::face::EigenFaceRecognizerTrait for EigenFaceRecognizer { - #[inline] fn as_raw_mut_EigenFaceRecognizer(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { EigenFaceRecognizer, crate::face::EigenFaceRecognizerTraitConst, as_raw_EigenFaceRecognizer, crate::face::EigenFaceRecognizerTrait, as_raw_mut_EigenFaceRecognizer } - impl EigenFaceRecognizer { /// ## Parameters /// * num_components: The number of components (read: Eigenfaces) kept for this Principal @@ -1150,11 +1095,17 @@ pub mod face { } - boxed_cast_base! { EigenFaceRecognizer, core::Algorithm, cv_face_EigenFaceRecognizer_to_Algorithm } + /// Constant methods for [crate::face::EigenFaceRecognizer] + pub trait EigenFaceRecognizerTraitConst: crate::face::BasicFaceRecognizerTraitConst { + fn as_raw_EigenFaceRecognizer(&self) -> *const c_void; - boxed_cast_base! { EigenFaceRecognizer, crate::face::BasicFaceRecognizer, cv_face_EigenFaceRecognizer_to_BasicFaceRecognizer } + } - boxed_cast_base! { EigenFaceRecognizer, crate::face::FaceRecognizer, cv_face_EigenFaceRecognizer_to_FaceRecognizer } + /// Mutable methods for [crate::face::EigenFaceRecognizer] + pub trait EigenFaceRecognizerTrait: crate::face::BasicFaceRecognizerTrait + crate::face::EigenFaceRecognizerTraitConst { + fn as_raw_mut_EigenFaceRecognizer(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for EigenFaceRecognizer { #[inline] @@ -1164,158 +1115,320 @@ pub mod face { } } - /// Constant methods for [crate::face::FaceRecognizer] - pub trait FaceRecognizerTraitConst: core::AlgorithmTraitConst { - fn as_raw_FaceRecognizer(&self) -> *const c_void; + boxed_cast_base! { EigenFaceRecognizer, core::Algorithm, cv_face_EigenFaceRecognizer_to_Algorithm } - /// Predicts a label and associated confidence (e.g. distance) for a given input image. - /// - /// ## Parameters - /// * src: Sample image to get a prediction from. - /// * label: The predicted label for the given image. - /// * confidence: Associated confidence (e.g. distance) for the predicted label. - /// - /// The suffix const means that prediction does not affect the internal model state, so the method can - /// be safely called from within different threads. - /// - /// The following example shows how to get a prediction from a trained model: - /// - /// ```C++ - /// using namespace cv; - /// // Do your initialization here (create the cv::FaceRecognizer model) ... - /// // ... - /// // Read in a sample image: - /// Mat img = imread("person1/3.jpg", IMREAD_GRAYSCALE); - /// // And get a prediction from the cv::FaceRecognizer: - /// int predicted = model->predict(img); - /// ``` - /// - /// - /// Or to get a prediction and the associated confidence (e.g. distance): - /// - /// ```C++ - /// using namespace cv; - /// // Do your initialization here (create the cv::FaceRecognizer model) ... - /// // ... - /// Mat img = imread("person1/3.jpg", IMREAD_GRAYSCALE); - /// // Some variables for the predicted label and associated confidence (e.g. distance): - /// int predicted_label = -1; - /// double predicted_confidence = 0.0; - /// // Get the prediction and associated confidence from the model - /// model->predict(img, predicted_label, predicted_confidence); - /// ``` - /// - /// - /// ## Overloaded parameters - #[inline] - fn predict_label(&self, src: &impl ToInputArray) -> Result { - input_array_arg!(src); - return_send!(via ocvrs_return); - unsafe { sys::cv_face_FaceRecognizer_predict_const_const__InputArrayR(self.as_raw_FaceRecognizer(), src.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } + boxed_cast_base! { EigenFaceRecognizer, crate::face::BasicFaceRecognizer, cv_face_EigenFaceRecognizer_to_BasicFaceRecognizer } - /// Predicts a label and associated confidence (e.g. distance) for a given input image. - /// - /// ## Parameters - /// * src: Sample image to get a prediction from. - /// * label: The predicted label for the given image. - /// * confidence: Associated confidence (e.g. distance) for the predicted label. - /// - /// The suffix const means that prediction does not affect the internal model state, so the method can - /// be safely called from within different threads. - /// - /// The following example shows how to get a prediction from a trained model: - /// - /// ```C++ - /// using namespace cv; - /// // Do your initialization here (create the cv::FaceRecognizer model) ... - /// // ... - /// // Read in a sample image: - /// Mat img = imread("person1/3.jpg", IMREAD_GRAYSCALE); - /// // And get a prediction from the cv::FaceRecognizer: - /// int predicted = model->predict(img); - /// ``` - /// - /// - /// Or to get a prediction and the associated confidence (e.g. distance): - /// - /// ```C++ - /// using namespace cv; - /// // Do your initialization here (create the cv::FaceRecognizer model) ... - /// // ... - /// Mat img = imread("person1/3.jpg", IMREAD_GRAYSCALE); - /// // Some variables for the predicted label and associated confidence (e.g. distance): - /// int predicted_label = -1; - /// double predicted_confidence = 0.0; - /// // Get the prediction and associated confidence from the model - /// model->predict(img, predicted_label, predicted_confidence); - /// ``` - /// - #[inline] - fn predict(&self, src: &impl ToInputArray, label: &mut i32, confidence: &mut f64) -> Result<()> { - input_array_arg!(src); - return_send!(via ocvrs_return); - unsafe { sys::cv_face_FaceRecognizer_predict_const_const__InputArrayR_intR_doubleR(self.as_raw_FaceRecognizer(), src.as_raw__InputArray(), label, confidence, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } + boxed_cast_base! { EigenFaceRecognizer, crate::face::FaceRecognizer, cv_face_EigenFaceRecognizer_to_FaceRecognizer } - /// - if implemented - send all result of prediction to collector that can be used for somehow custom result handling - /// ## Parameters - /// * src: Sample image to get a prediction from. - /// * collector: User-defined collector object that accepts all results - /// - /// To implement this method u just have to do same internal cycle as in predict(InputArray src, CV_OUT int &label, CV_OUT double &confidence) but - /// not try to get "best@ result, just resend it to caller side with given collector - #[inline] - fn predict_collect(&self, src: &impl ToInputArray, mut collector: core::Ptr) -> Result<()> { - input_array_arg!(src); - return_send!(via ocvrs_return); - unsafe { sys::cv_face_FaceRecognizer_predict_const_const__InputArrayR_PtrLPredictCollectorG(self.as_raw_FaceRecognizer(), src.as_raw__InputArray(), collector.as_raw_mut_PtrOfPredictCollector(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } + impl core::AlgorithmTraitConst for EigenFaceRecognizer { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } + } - /// Saves a FaceRecognizer and its model state. - /// - /// Saves this model to a given filename, either as XML or YAML. - /// ## Parameters - /// * filename: The filename to store this FaceRecognizer to (either XML/YAML). - /// - /// Every FaceRecognizer overwrites FaceRecognizer::save(FileStorage& fs) to save the internal model - /// state. FaceRecognizer::save(const String& filename) saves the state of a model to the given - /// filename. - /// - /// The suffix const means that prediction does not affect the internal model state, so the method can - /// be safely called from within different threads. - #[inline] - fn write(&self, filename: &str) -> Result<()> { - extern_container_arg!(filename); - return_send!(via ocvrs_return); - unsafe { sys::cv_face_FaceRecognizer_write_const_const_StringR(self.as_raw_FaceRecognizer(), filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } + impl core::AlgorithmTrait for EigenFaceRecognizer { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } - /// Saves a FaceRecognizer and its model state. - /// - /// Saves this model to a given filename, either as XML or YAML. - /// ## Parameters - /// * filename: The filename to store this FaceRecognizer to (either XML/YAML). - /// - /// Every FaceRecognizer overwrites FaceRecognizer::save(FileStorage& fs) to save the internal model - /// state. FaceRecognizer::save(const String& filename) saves the state of a model to the given - /// filename. - /// - /// The suffix const means that prediction does not affect the internal model state, so the method can - /// be safely called from within different threads. - /// + boxed_ref! { EigenFaceRecognizer, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + + impl crate::face::BasicFaceRecognizerTraitConst for EigenFaceRecognizer { + #[inline] fn as_raw_BasicFaceRecognizer(&self) -> *const c_void { self.as_raw() } + } + + impl crate::face::BasicFaceRecognizerTrait for EigenFaceRecognizer { + #[inline] fn as_raw_mut_BasicFaceRecognizer(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { EigenFaceRecognizer, crate::face::BasicFaceRecognizerTraitConst, as_raw_BasicFaceRecognizer, crate::face::BasicFaceRecognizerTrait, as_raw_mut_BasicFaceRecognizer } + + impl crate::face::FaceRecognizerTraitConst for EigenFaceRecognizer { + #[inline] fn as_raw_FaceRecognizer(&self) -> *const c_void { self.as_raw() } + } + + impl crate::face::FaceRecognizerTrait for EigenFaceRecognizer { + #[inline] fn as_raw_mut_FaceRecognizer(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { EigenFaceRecognizer, crate::face::FaceRecognizerTraitConst, as_raw_FaceRecognizer, crate::face::FaceRecognizerTrait, as_raw_mut_FaceRecognizer } + + impl crate::face::EigenFaceRecognizerTraitConst for EigenFaceRecognizer { + #[inline] fn as_raw_EigenFaceRecognizer(&self) -> *const c_void { self.as_raw() } + } + + impl crate::face::EigenFaceRecognizerTrait for EigenFaceRecognizer { + #[inline] fn as_raw_mut_EigenFaceRecognizer(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { EigenFaceRecognizer, crate::face::EigenFaceRecognizerTraitConst, as_raw_EigenFaceRecognizer, crate::face::EigenFaceRecognizerTrait, as_raw_mut_EigenFaceRecognizer } + + /// Abstract base class for all face recognition models + /// + /// All face recognition models in OpenCV are derived from the abstract base class FaceRecognizer, which + /// provides a unified access to all face recongition algorithms in OpenCV. + /// + /// ### Description + /// + /// I'll go a bit more into detail explaining FaceRecognizer, because it doesn't look like a powerful + /// interface at first sight. But: Every FaceRecognizer is an Algorithm, so you can easily get/set all + /// model internals (if allowed by the implementation). Algorithm is a relatively new OpenCV concept, + /// which is available since the 2.4 release. I suggest you take a look at its description. + /// + /// Algorithm provides the following features for all derived classes: + /// + /// * So called "virtual constructor". That is, each Algorithm derivative is registered at program + /// start and you can get the list of registered algorithms and create instance of a particular + /// algorithm by its name (see Algorithm::create). If you plan to add your own algorithms, it is + /// good practice to add a unique prefix to your algorithms to distinguish them from other + /// algorithms. + /// * Setting/Retrieving algorithm parameters by name. If you used video capturing functionality from + /// OpenCV highgui module, you are probably familar with cv::cvSetCaptureProperty, + /// ocvcvGetCaptureProperty, VideoCapture::set and VideoCapture::get. Algorithm provides similar + /// method where instead of integer id's you specify the parameter names as text Strings. See + /// Algorithm::set and Algorithm::get for details. + /// * Reading and writing parameters from/to XML or YAML files. Every Algorithm derivative can store + /// all its parameters and then read them back. There is no need to re-implement it each time. + /// + /// Moreover every FaceRecognizer supports the: + /// + /// * **Training** of a FaceRecognizer with FaceRecognizer::train on a given set of images (your face + /// database!). + /// * **Prediction** of a given sample image, that means a face. The image is given as a Mat. + /// * **Loading/Saving** the model state from/to a given XML or YAML. + /// * **Setting/Getting labels info**, that is stored as a string. String labels info is useful for + /// keeping names of the recognized people. + /// + /// + /// Note: When using the FaceRecognizer interface in combination with Python, please stick to Python 2. + /// Some underlying scripts like create_csv will not work in other versions, like Python 3. Setting the + /// Thresholds +++++++++++++++++++++++ + /// + /// Sometimes you run into the situation, when you want to apply a threshold on the prediction. A common + /// scenario in face recognition is to tell, whether a face belongs to the training dataset or if it is + /// unknown. You might wonder, why there's no public API in FaceRecognizer to set the threshold for the + /// prediction, but rest assured: It's supported. It just means there's no generic way in an abstract + /// class to provide an interface for setting/getting the thresholds of *every possible* FaceRecognizer + /// algorithm. The appropriate place to set the thresholds is in the constructor of the specific + /// FaceRecognizer and since every FaceRecognizer is a Algorithm (see above), you can get/set the + /// thresholds at runtime! + /// + /// Here is an example of setting a threshold for the Eigenfaces method, when creating the model: + /// + /// ```C++ + /// // Let's say we want to keep 10 Eigenfaces and have a threshold value of 10.0 + /// int num_components = 10; + /// double threshold = 10.0; + /// // Then if you want to have a cv::FaceRecognizer with a confidence threshold, + /// // create the concrete implementation with the appropriate parameters: + /// Ptr model = EigenFaceRecognizer::create(num_components, threshold); + /// ``` + /// + /// + /// Sometimes it's impossible to train the model, just to experiment with threshold values. Thanks to + /// Algorithm it's possible to set internal model thresholds during runtime. Let's see how we would + /// set/get the prediction for the Eigenface model, we've created above: + /// + /// ```C++ + /// // The following line reads the threshold from the Eigenfaces model: + /// double current_threshold = model->getDouble("threshold"); + /// // And this line sets the threshold to 0.0: + /// model->set("threshold", 0.0); + /// ``` + /// + /// + /// If you've set the threshold to 0.0 as we did above, then: + /// + /// ```C++ + /// // + /// Mat img = imread("person1/3.jpg", IMREAD_GRAYSCALE); + /// // Get a prediction from the model. Note: We've set a threshold of 0.0 above, + /// // since the distance is almost always larger than 0.0, you'll get -1 as + /// // label, which indicates, this face is unknown + /// int predicted_label = model->predict(img); + /// // ... + /// ``` + /// + /// + /// is going to yield -1 as predicted label, which states this face is unknown. + /// + /// ### Getting the name of a FaceRecognizer + /// + /// Since every FaceRecognizer is a Algorithm, you can use Algorithm::name to get the name of a + /// FaceRecognizer: + /// + /// ```C++ + /// // Create a FaceRecognizer: + /// Ptr model = EigenFaceRecognizer::create(); + /// // And here's how to get its name: + /// String name = model->name(); + /// ``` + /// + pub struct FaceRecognizer { + ptr: *mut c_void, + } + + opencv_type_boxed! { FaceRecognizer } + + impl Drop for FaceRecognizer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_face_FaceRecognizer_delete(self.as_raw_mut_FaceRecognizer()) }; + } + } + + unsafe impl Send for FaceRecognizer {} + + /// Constant methods for [crate::face::FaceRecognizer] + pub trait FaceRecognizerTraitConst: core::AlgorithmTraitConst { + fn as_raw_FaceRecognizer(&self) -> *const c_void; + + /// Predicts a label and associated confidence (e.g. distance) for a given input image. + /// + /// ## Parameters + /// * src: Sample image to get a prediction from. + /// * label: The predicted label for the given image. + /// * confidence: Associated confidence (e.g. distance) for the predicted label. + /// + /// The suffix const means that prediction does not affect the internal model state, so the method can + /// be safely called from within different threads. + /// + /// The following example shows how to get a prediction from a trained model: + /// + /// ```C++ + /// using namespace cv; + /// // Do your initialization here (create the cv::FaceRecognizer model) ... + /// // ... + /// // Read in a sample image: + /// Mat img = imread("person1/3.jpg", IMREAD_GRAYSCALE); + /// // And get a prediction from the cv::FaceRecognizer: + /// int predicted = model->predict(img); + /// ``` + /// + /// + /// Or to get a prediction and the associated confidence (e.g. distance): + /// + /// ```C++ + /// using namespace cv; + /// // Do your initialization here (create the cv::FaceRecognizer model) ... + /// // ... + /// Mat img = imread("person1/3.jpg", IMREAD_GRAYSCALE); + /// // Some variables for the predicted label and associated confidence (e.g. distance): + /// int predicted_label = -1; + /// double predicted_confidence = 0.0; + /// // Get the prediction and associated confidence from the model + /// model->predict(img, predicted_label, predicted_confidence); + /// ``` + /// + /// + /// ## Overloaded parameters + #[inline] + fn predict_label(&self, src: &impl ToInputArray) -> Result { + input_array_arg!(src); + return_send!(via ocvrs_return); + unsafe { sys::cv_face_FaceRecognizer_predict_const_const__InputArrayR(self.as_raw_FaceRecognizer(), src.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Predicts a label and associated confidence (e.g. distance) for a given input image. + /// + /// ## Parameters + /// * src: Sample image to get a prediction from. + /// * label: The predicted label for the given image. + /// * confidence: Associated confidence (e.g. distance) for the predicted label. + /// + /// The suffix const means that prediction does not affect the internal model state, so the method can + /// be safely called from within different threads. + /// + /// The following example shows how to get a prediction from a trained model: + /// + /// ```C++ + /// using namespace cv; + /// // Do your initialization here (create the cv::FaceRecognizer model) ... + /// // ... + /// // Read in a sample image: + /// Mat img = imread("person1/3.jpg", IMREAD_GRAYSCALE); + /// // And get a prediction from the cv::FaceRecognizer: + /// int predicted = model->predict(img); + /// ``` + /// + /// + /// Or to get a prediction and the associated confidence (e.g. distance): + /// + /// ```C++ + /// using namespace cv; + /// // Do your initialization here (create the cv::FaceRecognizer model) ... + /// // ... + /// Mat img = imread("person1/3.jpg", IMREAD_GRAYSCALE); + /// // Some variables for the predicted label and associated confidence (e.g. distance): + /// int predicted_label = -1; + /// double predicted_confidence = 0.0; + /// // Get the prediction and associated confidence from the model + /// model->predict(img, predicted_label, predicted_confidence); + /// ``` + /// + #[inline] + fn predict(&self, src: &impl ToInputArray, label: &mut i32, confidence: &mut f64) -> Result<()> { + input_array_arg!(src); + return_send!(via ocvrs_return); + unsafe { sys::cv_face_FaceRecognizer_predict_const_const__InputArrayR_intR_doubleR(self.as_raw_FaceRecognizer(), src.as_raw__InputArray(), label, confidence, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// - if implemented - send all result of prediction to collector that can be used for somehow custom result handling + /// ## Parameters + /// * src: Sample image to get a prediction from. + /// * collector: User-defined collector object that accepts all results + /// + /// To implement this method u just have to do same internal cycle as in predict(InputArray src, CV_OUT int &label, CV_OUT double &confidence) but + /// not try to get "best@ result, just resend it to caller side with given collector + #[inline] + fn predict_collect(&self, src: &impl ToInputArray, mut collector: core::Ptr) -> Result<()> { + input_array_arg!(src); + return_send!(via ocvrs_return); + unsafe { sys::cv_face_FaceRecognizer_predict_const_const__InputArrayR_PtrLPredictCollectorG(self.as_raw_FaceRecognizer(), src.as_raw__InputArray(), collector.as_raw_mut_PtrOfPredictCollector(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Saves a FaceRecognizer and its model state. + /// + /// Saves this model to a given filename, either as XML or YAML. + /// ## Parameters + /// * filename: The filename to store this FaceRecognizer to (either XML/YAML). + /// + /// Every FaceRecognizer overwrites FaceRecognizer::save(FileStorage& fs) to save the internal model + /// state. FaceRecognizer::save(const String& filename) saves the state of a model to the given + /// filename. + /// + /// The suffix const means that prediction does not affect the internal model state, so the method can + /// be safely called from within different threads. + #[inline] + fn write(&self, filename: &str) -> Result<()> { + extern_container_arg!(filename); + return_send!(via ocvrs_return); + unsafe { sys::cv_face_FaceRecognizer_write_const_const_StringR(self.as_raw_FaceRecognizer(), filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Saves a FaceRecognizer and its model state. + /// + /// Saves this model to a given filename, either as XML or YAML. + /// ## Parameters + /// * filename: The filename to store this FaceRecognizer to (either XML/YAML). + /// + /// Every FaceRecognizer overwrites FaceRecognizer::save(FileStorage& fs) to save the internal model + /// state. FaceRecognizer::save(const String& filename) saves the state of a model to the given + /// filename. + /// + /// The suffix const means that prediction does not affect the internal model state, so the method can + /// be safely called from within different threads. + /// /// ## Overloaded parameters /// /// Saves this model to a given FileStorage. @@ -1566,121 +1679,23 @@ pub mod face { } - /// Abstract base class for all face recognition models - /// - /// All face recognition models in OpenCV are derived from the abstract base class FaceRecognizer, which - /// provides a unified access to all face recongition algorithms in OpenCV. - /// - /// ### Description - /// - /// I'll go a bit more into detail explaining FaceRecognizer, because it doesn't look like a powerful - /// interface at first sight. But: Every FaceRecognizer is an Algorithm, so you can easily get/set all - /// model internals (if allowed by the implementation). Algorithm is a relatively new OpenCV concept, - /// which is available since the 2.4 release. I suggest you take a look at its description. - /// - /// Algorithm provides the following features for all derived classes: - /// - /// * So called "virtual constructor". That is, each Algorithm derivative is registered at program - /// start and you can get the list of registered algorithms and create instance of a particular - /// algorithm by its name (see Algorithm::create). If you plan to add your own algorithms, it is - /// good practice to add a unique prefix to your algorithms to distinguish them from other - /// algorithms. - /// * Setting/Retrieving algorithm parameters by name. If you used video capturing functionality from - /// OpenCV highgui module, you are probably familar with cv::cvSetCaptureProperty, - /// ocvcvGetCaptureProperty, VideoCapture::set and VideoCapture::get. Algorithm provides similar - /// method where instead of integer id's you specify the parameter names as text Strings. See - /// Algorithm::set and Algorithm::get for details. - /// * Reading and writing parameters from/to XML or YAML files. Every Algorithm derivative can store - /// all its parameters and then read them back. There is no need to re-implement it each time. - /// - /// Moreover every FaceRecognizer supports the: - /// - /// * **Training** of a FaceRecognizer with FaceRecognizer::train on a given set of images (your face - /// database!). - /// * **Prediction** of a given sample image, that means a face. The image is given as a Mat. - /// * **Loading/Saving** the model state from/to a given XML or YAML. - /// * **Setting/Getting labels info**, that is stored as a string. String labels info is useful for - /// keeping names of the recognized people. - /// - /// - /// Note: When using the FaceRecognizer interface in combination with Python, please stick to Python 2. - /// Some underlying scripts like create_csv will not work in other versions, like Python 3. Setting the - /// Thresholds +++++++++++++++++++++++ - /// - /// Sometimes you run into the situation, when you want to apply a threshold on the prediction. A common - /// scenario in face recognition is to tell, whether a face belongs to the training dataset or if it is - /// unknown. You might wonder, why there's no public API in FaceRecognizer to set the threshold for the - /// prediction, but rest assured: It's supported. It just means there's no generic way in an abstract - /// class to provide an interface for setting/getting the thresholds of *every possible* FaceRecognizer - /// algorithm. The appropriate place to set the thresholds is in the constructor of the specific - /// FaceRecognizer and since every FaceRecognizer is a Algorithm (see above), you can get/set the - /// thresholds at runtime! - /// - /// Here is an example of setting a threshold for the Eigenfaces method, when creating the model: - /// - /// ```C++ - /// // Let's say we want to keep 10 Eigenfaces and have a threshold value of 10.0 - /// int num_components = 10; - /// double threshold = 10.0; - /// // Then if you want to have a cv::FaceRecognizer with a confidence threshold, - /// // create the concrete implementation with the appropriate parameters: - /// Ptr model = EigenFaceRecognizer::create(num_components, threshold); - /// ``` - /// - /// - /// Sometimes it's impossible to train the model, just to experiment with threshold values. Thanks to - /// Algorithm it's possible to set internal model thresholds during runtime. Let's see how we would - /// set/get the prediction for the Eigenface model, we've created above: - /// - /// ```C++ - /// // The following line reads the threshold from the Eigenfaces model: - /// double current_threshold = model->getDouble("threshold"); - /// // And this line sets the threshold to 0.0: - /// model->set("threshold", 0.0); - /// ``` - /// - /// - /// If you've set the threshold to 0.0 as we did above, then: - /// - /// ```C++ - /// // - /// Mat img = imread("person1/3.jpg", IMREAD_GRAYSCALE); - /// // Get a prediction from the model. Note: We've set a threshold of 0.0 above, - /// // since the distance is almost always larger than 0.0, you'll get -1 as - /// // label, which indicates, this face is unknown - /// int predicted_label = model->predict(img); - /// // ... - /// ``` - /// - /// - /// is going to yield -1 as predicted label, which states this face is unknown. - /// - /// ### Getting the name of a FaceRecognizer - /// - /// Since every FaceRecognizer is a Algorithm, you can use Algorithm::name to get the name of a - /// FaceRecognizer: - /// - /// ```C++ - /// // Create a FaceRecognizer: - /// Ptr model = EigenFaceRecognizer::create(); - /// // And here's how to get its name: - /// String name = model->name(); - /// ``` - /// - pub struct FaceRecognizer { - ptr: *mut c_void, - } - - opencv_type_boxed! { FaceRecognizer } - - impl Drop for FaceRecognizer { + impl std::fmt::Debug for FaceRecognizer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_FaceRecognizer_delete(self.as_raw_mut_FaceRecognizer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FaceRecognizer") + .finish() } } - unsafe impl Send for FaceRecognizer {} + boxed_cast_base! { FaceRecognizer, core::Algorithm, cv_face_FaceRecognizer_to_Algorithm } + + boxed_cast_descendant! { FaceRecognizer, crate::face::BasicFaceRecognizer, cv_face_FaceRecognizer_to_BasicFaceRecognizer } + + boxed_cast_descendant! { FaceRecognizer, crate::face::EigenFaceRecognizer, cv_face_FaceRecognizer_to_EigenFaceRecognizer } + + boxed_cast_descendant! { FaceRecognizer, crate::face::FisherFaceRecognizer, cv_face_FaceRecognizer_to_FisherFaceRecognizer } + + boxed_cast_descendant! { FaceRecognizer, crate::face::LBPHFaceRecognizer, cv_face_FaceRecognizer_to_LBPHFaceRecognizer } impl core::AlgorithmTraitConst for FaceRecognizer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1702,27 +1717,39 @@ pub mod face { boxed_ref! { FaceRecognizer, crate::face::FaceRecognizerTraitConst, as_raw_FaceRecognizer, crate::face::FaceRecognizerTrait, as_raw_mut_FaceRecognizer } - impl FaceRecognizer { + /// Abstract base class for all facemark models + /// + /// To utilize this API in your program, please take a look at the [tutorial_table_of_content_facemark] + /// ### Description + /// + /// Facemark is a base class which provides universal access to any specific facemark algorithm. + /// Therefore, the users should declare a desired algorithm before they can use it in their application. + /// + /// Here is an example on how to declare a facemark algorithm: + /// ```C++ + /// // Using Facemark in your code: + /// Ptr facemark = createFacemarkLBF(); + /// ``` + /// + /// + /// The typical pipeline for facemark detection is as follows: + /// - Load the trained model using Facemark::loadModel. + /// - Perform the fitting on an image via Facemark::fit. + pub struct Facemark { + ptr: *mut c_void, } - boxed_cast_descendant! { FaceRecognizer, crate::face::BasicFaceRecognizer, cv_face_FaceRecognizer_to_BasicFaceRecognizer } - - boxed_cast_descendant! { FaceRecognizer, crate::face::EigenFaceRecognizer, cv_face_FaceRecognizer_to_EigenFaceRecognizer } - - boxed_cast_descendant! { FaceRecognizer, crate::face::FisherFaceRecognizer, cv_face_FaceRecognizer_to_FisherFaceRecognizer } - - boxed_cast_descendant! { FaceRecognizer, crate::face::LBPHFaceRecognizer, cv_face_FaceRecognizer_to_LBPHFaceRecognizer } - - boxed_cast_base! { FaceRecognizer, core::Algorithm, cv_face_FaceRecognizer_to_Algorithm } + opencv_type_boxed! { Facemark } - impl std::fmt::Debug for FaceRecognizer { + impl Drop for Facemark { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FaceRecognizer") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_face_Facemark_delete(self.as_raw_mut_Facemark()) }; } } + unsafe impl Send for Facemark {} + /// Constant methods for [crate::face::Facemark] pub trait FacemarkTraitConst: core::AlgorithmTraitConst { fn as_raw_Facemark(&self) -> *const c_void; @@ -1781,38 +1808,23 @@ pub mod face { } - /// Abstract base class for all facemark models - /// - /// To utilize this API in your program, please take a look at the [tutorial_table_of_content_facemark] - /// ### Description - /// - /// Facemark is a base class which provides universal access to any specific facemark algorithm. - /// Therefore, the users should declare a desired algorithm before they can use it in their application. - /// - /// Here is an example on how to declare a facemark algorithm: - /// ```C++ - /// // Using Facemark in your code: - /// Ptr facemark = createFacemarkLBF(); - /// ``` - /// - /// - /// The typical pipeline for facemark detection is as follows: - /// - Load the trained model using Facemark::loadModel. - /// - Perform the fitting on an image via Facemark::fit. - pub struct Facemark { - ptr: *mut c_void, - } - - opencv_type_boxed! { Facemark } - - impl Drop for Facemark { + impl std::fmt::Debug for Facemark { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_Facemark_delete(self.as_raw_mut_Facemark()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Facemark") + .finish() } } - unsafe impl Send for Facemark {} + boxed_cast_base! { Facemark, core::Algorithm, cv_face_Facemark_to_Algorithm } + + boxed_cast_descendant! { Facemark, crate::face::FacemarkAAM, cv_face_Facemark_to_FacemarkAAM } + + boxed_cast_descendant! { Facemark, crate::face::FacemarkKazemi, cv_face_Facemark_to_FacemarkKazemi } + + boxed_cast_descendant! { Facemark, crate::face::FacemarkLBF, cv_face_Facemark_to_FacemarkLBF } + + boxed_cast_descendant! { Facemark, crate::face::FacemarkTrain, cv_face_Facemark_to_FacemarkTrain } impl core::AlgorithmTraitConst for Facemark { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1834,25 +1846,51 @@ pub mod face { boxed_ref! { Facemark, crate::face::FacemarkTraitConst, as_raw_Facemark, crate::face::FacemarkTrait, as_raw_mut_Facemark } - impl Facemark { + pub struct FacemarkAAM { + ptr: *mut c_void, } - boxed_cast_descendant! { Facemark, crate::face::FacemarkAAM, cv_face_Facemark_to_FacemarkAAM } - - boxed_cast_descendant! { Facemark, crate::face::FacemarkKazemi, cv_face_Facemark_to_FacemarkKazemi } + opencv_type_boxed! { FacemarkAAM } - boxed_cast_descendant! { Facemark, crate::face::FacemarkLBF, cv_face_Facemark_to_FacemarkLBF } + impl Drop for FacemarkAAM { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_face_FacemarkAAM_delete(self.as_raw_mut_FacemarkAAM()) }; + } + } - boxed_cast_descendant! { Facemark, crate::face::FacemarkTrain, cv_face_Facemark_to_FacemarkTrain } + unsafe impl Send for FacemarkAAM {} - boxed_cast_base! { Facemark, core::Algorithm, cv_face_Facemark_to_Algorithm } + impl FacemarkAAM { + /// initializer + /// + /// ## C++ default parameters + /// * parameters: FacemarkAAM::Params() + #[inline] + pub fn create(parameters: &impl crate::face::FacemarkAAM_ParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_FacemarkAAM_create_const_ParamsR(parameters.as_raw_FacemarkAAM_Params(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for Facemark { + /// initializer + /// + /// ## Note + /// This alternative version of [FacemarkAAM::create] function uses the following default values for its arguments: + /// * parameters: FacemarkAAM::Params() #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Facemark") - .finish() + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_FacemarkAAM_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::face::FacemarkAAM] @@ -1880,20 +1918,19 @@ pub mod face { } - pub struct FacemarkAAM { - ptr: *mut c_void, - } - - opencv_type_boxed! { FacemarkAAM } - - impl Drop for FacemarkAAM { + impl std::fmt::Debug for FacemarkAAM { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_FacemarkAAM_delete(self.as_raw_mut_FacemarkAAM()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FacemarkAAM") + .finish() } } - unsafe impl Send for FacemarkAAM {} + boxed_cast_base! { FacemarkAAM, core::Algorithm, cv_face_FacemarkAAM_to_Algorithm } + + boxed_cast_base! { FacemarkAAM, crate::face::Facemark, cv_face_FacemarkAAM_to_Facemark } + + boxed_cast_base! { FacemarkAAM, crate::face::FacemarkTrain, cv_face_FacemarkAAM_to_FacemarkTrain } impl core::AlgorithmTraitConst for FacemarkAAM { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1935,52 +1972,56 @@ pub mod face { boxed_ref! { FacemarkAAM, crate::face::FacemarkAAMTraitConst, as_raw_FacemarkAAM, crate::face::FacemarkAAMTrait, as_raw_mut_FacemarkAAM } - impl FacemarkAAM { - /// initializer - /// + /// \brief Optional parameter for fitting process. + pub struct FacemarkAAM_Config { + ptr: *mut c_void, + } + + opencv_type_boxed! { FacemarkAAM_Config } + + impl Drop for FacemarkAAM_Config { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_face_FacemarkAAM_Config_delete(self.as_raw_mut_FacemarkAAM_Config()) }; + } + } + + unsafe impl Send for FacemarkAAM_Config {} + + impl FacemarkAAM_Config { /// ## C++ default parameters - /// * parameters: FacemarkAAM::Params() + /// * rot: Mat::eye(2,2,CV_32F) + /// * trans: Point2f(0.0f,0.0f) + /// * scaling: 1.0f + /// * scale_id: 0 #[inline] - pub fn create(parameters: &impl crate::face::FacemarkAAM_ParamsTraitConst) -> Result> { + pub fn new(mut rot: impl core::MatTrait, trans: core::Point2f, scaling: f32, scale_id: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_face_FacemarkAAM_create_const_ParamsR(parameters.as_raw_FacemarkAAM_Params(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_face_FacemarkAAM_Config_Config_Mat_Point2f_float_int(rot.as_raw_mut_Mat(), &trans, scaling, scale_id, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::face::FacemarkAAM_Config::opencv_from_extern(ret) }; Ok(ret) } - /// initializer - /// /// ## Note - /// This alternative version of [FacemarkAAM::create] function uses the following default values for its arguments: - /// * parameters: FacemarkAAM::Params() + /// This alternative version of [new] function uses the following default values for its arguments: + /// * rot: Mat::eye(2,2,CV_32F) + /// * trans: Point2f(0.0f,0.0f) + /// * scaling: 1.0f + /// * scale_id: 0 #[inline] - pub fn create_def() -> Result> { + pub fn new_def() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_face_FacemarkAAM_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_face_FacemarkAAM_Config_Config(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::face::FacemarkAAM_Config::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { FacemarkAAM, core::Algorithm, cv_face_FacemarkAAM_to_Algorithm } - - boxed_cast_base! { FacemarkAAM, crate::face::Facemark, cv_face_FacemarkAAM_to_Facemark } - - boxed_cast_base! { FacemarkAAM, crate::face::FacemarkTrain, cv_face_FacemarkAAM_to_FacemarkTrain } - - impl std::fmt::Debug for FacemarkAAM { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FacemarkAAM") - .finish() - } - } - /// Constant methods for [crate::face::FacemarkAAM_Config] pub trait FacemarkAAM_ConfigTraitConst { fn as_raw_FacemarkAAM_Config(&self) -> *const c_void; @@ -2044,22 +2085,18 @@ pub mod face { } - /// \brief Optional parameter for fitting process. - pub struct FacemarkAAM_Config { - ptr: *mut c_void, - } - - opencv_type_boxed! { FacemarkAAM_Config } - - impl Drop for FacemarkAAM_Config { + impl std::fmt::Debug for FacemarkAAM_Config { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_FacemarkAAM_Config_delete(self.as_raw_mut_FacemarkAAM_Config()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FacemarkAAM_Config") + .field("r", &crate::face::FacemarkAAM_ConfigTraitConst::r(self)) + .field("t", &crate::face::FacemarkAAM_ConfigTraitConst::t(self)) + .field("scale", &crate::face::FacemarkAAM_ConfigTraitConst::scale(self)) + .field("model_scale_idx", &crate::face::FacemarkAAM_ConfigTraitConst::model_scale_idx(self)) + .finish() } } - unsafe impl Send for FacemarkAAM_Config {} - impl crate::face::FacemarkAAM_ConfigTraitConst for FacemarkAAM_Config { #[inline] fn as_raw_FacemarkAAM_Config(&self) -> *const c_void { self.as_raw() } } @@ -2070,50 +2107,31 @@ pub mod face { boxed_ref! { FacemarkAAM_Config, crate::face::FacemarkAAM_ConfigTraitConst, as_raw_FacemarkAAM_Config, crate::face::FacemarkAAM_ConfigTrait, as_raw_mut_FacemarkAAM_Config } - impl FacemarkAAM_Config { - /// ## C++ default parameters - /// * rot: Mat::eye(2,2,CV_32F) - /// * trans: Point2f(0.0f,0.0f) - /// * scaling: 1.0f - /// * scale_id: 0 - #[inline] - pub fn new(mut rot: impl core::MatTrait, trans: core::Point2f, scaling: f32, scale_id: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_face_FacemarkAAM_Config_Config_Mat_Point2f_float_int(rot.as_raw_mut_Mat(), &trans, scaling, scale_id, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::face::FacemarkAAM_Config::opencv_from_extern(ret) }; - Ok(ret) - } + /// \brief Data container for the facemark::getData function + pub struct FacemarkAAM_Data { + ptr: *mut c_void, + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * rot: Mat::eye(2,2,CV_32F) - /// * trans: Point2f(0.0f,0.0f) - /// * scaling: 1.0f - /// * scale_id: 0 + opencv_type_boxed! { FacemarkAAM_Data } + + impl Drop for FacemarkAAM_Data { #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_face_FacemarkAAM_Config_Config(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::face::FacemarkAAM_Config::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_face_FacemarkAAM_Data_delete(self.as_raw_mut_FacemarkAAM_Data()) }; } - } - impl std::fmt::Debug for FacemarkAAM_Config { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FacemarkAAM_Config") - .field("r", &crate::face::FacemarkAAM_ConfigTraitConst::r(self)) - .field("t", &crate::face::FacemarkAAM_ConfigTraitConst::t(self)) - .field("scale", &crate::face::FacemarkAAM_ConfigTraitConst::scale(self)) - .field("model_scale_idx", &crate::face::FacemarkAAM_ConfigTraitConst::model_scale_idx(self)) - .finish() + unsafe impl Send for FacemarkAAM_Data {} + + impl FacemarkAAM_Data { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::face::FacemarkAAM_Data { + let ret = unsafe { sys::cv_face_FacemarkAAM_Data_defaultNew_const() }; + let ret = unsafe { crate::face::FacemarkAAM_Data::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::face::FacemarkAAM_Data] @@ -2141,22 +2159,23 @@ pub mod face { } - /// \brief Data container for the facemark::getData function - pub struct FacemarkAAM_Data { - ptr: *mut c_void, + impl Default for FacemarkAAM_Data { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { FacemarkAAM_Data } - - impl Drop for FacemarkAAM_Data { + impl std::fmt::Debug for FacemarkAAM_Data { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_FacemarkAAM_Data_delete(self.as_raw_mut_FacemarkAAM_Data()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FacemarkAAM_Data") + .field("s0", &crate::face::FacemarkAAM_DataTraitConst::s0(self)) + .finish() } } - unsafe impl Send for FacemarkAAM_Data {} - impl crate::face::FacemarkAAM_DataTraitConst for FacemarkAAM_Data { #[inline] fn as_raw_FacemarkAAM_Data(&self) -> *const c_void { self.as_raw() } } @@ -2167,30 +2186,31 @@ pub mod face { boxed_ref! { FacemarkAAM_Data, crate::face::FacemarkAAM_DataTraitConst, as_raw_FacemarkAAM_Data, crate::face::FacemarkAAM_DataTrait, as_raw_mut_FacemarkAAM_Data } - impl FacemarkAAM_Data { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_face_FacemarkAAM_Data_defaultNew_const()) } - } - + /// \brief The model of AAM Algorithm + pub struct FacemarkAAM_Model { + ptr: *mut c_void, } - impl std::fmt::Debug for FacemarkAAM_Data { + opencv_type_boxed! { FacemarkAAM_Model } + + impl Drop for FacemarkAAM_Model { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FacemarkAAM_Data") - .field("s0", &crate::face::FacemarkAAM_DataTraitConst::s0(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_face_FacemarkAAM_Model_delete(self.as_raw_mut_FacemarkAAM_Model()) }; } } - impl Default for FacemarkAAM_Data { + unsafe impl Send for FacemarkAAM_Model {} + + impl FacemarkAAM_Model { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::face::FacemarkAAM_Model { + let ret = unsafe { sys::cv_face_FacemarkAAM_Model_defaultNew_const() }; + let ret = unsafe { crate::face::FacemarkAAM_Model::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::face::FacemarkAAM_Model] @@ -2283,22 +2303,28 @@ pub mod face { } - /// \brief The model of AAM Algorithm - pub struct FacemarkAAM_Model { - ptr: *mut c_void, + impl Default for FacemarkAAM_Model { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { FacemarkAAM_Model } - - impl Drop for FacemarkAAM_Model { + impl std::fmt::Debug for FacemarkAAM_Model { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_FacemarkAAM_Model_delete(self.as_raw_mut_FacemarkAAM_Model()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FacemarkAAM_Model") + .field("scales", &crate::face::FacemarkAAM_ModelTraitConst::scales(self)) + .field("triangles", &crate::face::FacemarkAAM_ModelTraitConst::triangles(self)) + .field("textures", &crate::face::FacemarkAAM_ModelTraitConst::textures(self)) + .field("s0", &crate::face::FacemarkAAM_ModelTraitConst::s0(self)) + .field("s", &crate::face::FacemarkAAM_ModelTraitConst::s(self)) + .field("q", &crate::face::FacemarkAAM_ModelTraitConst::q(self)) + .finish() } } - unsafe impl Send for FacemarkAAM_Model {} - impl crate::face::FacemarkAAM_ModelTraitConst for FacemarkAAM_Model { #[inline] fn as_raw_FacemarkAAM_Model(&self) -> *const c_void { self.as_raw() } } @@ -2309,35 +2335,30 @@ pub mod face { boxed_ref! { FacemarkAAM_Model, crate::face::FacemarkAAM_ModelTraitConst, as_raw_FacemarkAAM_Model, crate::face::FacemarkAAM_ModelTrait, as_raw_mut_FacemarkAAM_Model } - impl FacemarkAAM_Model { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_face_FacemarkAAM_Model_defaultNew_const()) } - } - + pub struct FacemarkAAM_Model_Texture { + ptr: *mut c_void, } - impl std::fmt::Debug for FacemarkAAM_Model { + opencv_type_boxed! { FacemarkAAM_Model_Texture } + + impl Drop for FacemarkAAM_Model_Texture { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FacemarkAAM_Model") - .field("scales", &crate::face::FacemarkAAM_ModelTraitConst::scales(self)) - .field("triangles", &crate::face::FacemarkAAM_ModelTraitConst::triangles(self)) - .field("textures", &crate::face::FacemarkAAM_ModelTraitConst::textures(self)) - .field("s0", &crate::face::FacemarkAAM_ModelTraitConst::s0(self)) - .field("s", &crate::face::FacemarkAAM_ModelTraitConst::s(self)) - .field("q", &crate::face::FacemarkAAM_ModelTraitConst::q(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_face_FacemarkAAM_Model_Texture_delete(self.as_raw_mut_FacemarkAAM_Model_Texture()) }; } } - impl Default for FacemarkAAM_Model { + unsafe impl Send for FacemarkAAM_Model_Texture {} + + impl FacemarkAAM_Model_Texture { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::face::FacemarkAAM_Model_Texture { + let ret = unsafe { sys::cv_face_FacemarkAAM_Model_Texture_defaultNew_const() }; + let ret = unsafe { crate::face::FacemarkAAM_Model_Texture::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::face::FacemarkAAM_Model_Texture] @@ -2484,38 +2505,12 @@ pub mod face { } - pub struct FacemarkAAM_Model_Texture { - ptr: *mut c_void, - } - - opencv_type_boxed! { FacemarkAAM_Model_Texture } - - impl Drop for FacemarkAAM_Model_Texture { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_FacemarkAAM_Model_Texture_delete(self.as_raw_mut_FacemarkAAM_Model_Texture()) }; - } - } - - unsafe impl Send for FacemarkAAM_Model_Texture {} - - impl crate::face::FacemarkAAM_Model_TextureTraitConst for FacemarkAAM_Model_Texture { - #[inline] fn as_raw_FacemarkAAM_Model_Texture(&self) -> *const c_void { self.as_raw() } - } - - impl crate::face::FacemarkAAM_Model_TextureTrait for FacemarkAAM_Model_Texture { - #[inline] fn as_raw_mut_FacemarkAAM_Model_Texture(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { FacemarkAAM_Model_Texture, crate::face::FacemarkAAM_Model_TextureTraitConst, as_raw_FacemarkAAM_Model_Texture, crate::face::FacemarkAAM_Model_TextureTrait, as_raw_mut_FacemarkAAM_Model_Texture } - - impl FacemarkAAM_Model_Texture { - /// Creates a default instance of the class by calling the default constructor + impl Default for FacemarkAAM_Model_Texture { #[inline] + /// Forwards to infallible Self::default() fn default() -> Self { - unsafe { Self::from_raw(sys::cv_face_FacemarkAAM_Model_Texture_defaultNew_const()) } + Self::default() } - } impl std::fmt::Debug for FacemarkAAM_Model_Texture { @@ -2536,12 +2531,43 @@ pub mod face { } } - impl Default for FacemarkAAM_Model_Texture { + impl crate::face::FacemarkAAM_Model_TextureTraitConst for FacemarkAAM_Model_Texture { + #[inline] fn as_raw_FacemarkAAM_Model_Texture(&self) -> *const c_void { self.as_raw() } + } + + impl crate::face::FacemarkAAM_Model_TextureTrait for FacemarkAAM_Model_Texture { + #[inline] fn as_raw_mut_FacemarkAAM_Model_Texture(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { FacemarkAAM_Model_Texture, crate::face::FacemarkAAM_Model_TextureTraitConst, as_raw_FacemarkAAM_Model_Texture, crate::face::FacemarkAAM_Model_TextureTrait, as_raw_mut_FacemarkAAM_Model_Texture } + + pub struct FacemarkAAM_Params { + ptr: *mut c_void, + } + + opencv_type_boxed! { FacemarkAAM_Params } + + impl Drop for FacemarkAAM_Params { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + fn drop(&mut self) { + unsafe { sys::cv_face_FacemarkAAM_Params_delete(self.as_raw_mut_FacemarkAAM_Params()) }; + } + } + + unsafe impl Send for FacemarkAAM_Params {} + + impl FacemarkAAM_Params { + /// \brief Constructor + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_FacemarkAAM_Params_Params(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::face::FacemarkAAM_Params::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::face::FacemarkAAM_Params] @@ -2699,21 +2725,24 @@ pub mod face { } - pub struct FacemarkAAM_Params { - ptr: *mut c_void, - } - - opencv_type_boxed! { FacemarkAAM_Params } - - impl Drop for FacemarkAAM_Params { + impl std::fmt::Debug for FacemarkAAM_Params { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_FacemarkAAM_Params_delete(self.as_raw_mut_FacemarkAAM_Params()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FacemarkAAM_Params") + .field("model_filename", &crate::face::FacemarkAAM_ParamsTraitConst::model_filename(self)) + .field("m", &crate::face::FacemarkAAM_ParamsTraitConst::m(self)) + .field("n", &crate::face::FacemarkAAM_ParamsTraitConst::n(self)) + .field("n_iter", &crate::face::FacemarkAAM_ParamsTraitConst::n_iter(self)) + .field("verbose", &crate::face::FacemarkAAM_ParamsTraitConst::verbose(self)) + .field("save_model", &crate::face::FacemarkAAM_ParamsTraitConst::save_model(self)) + .field("max_m", &crate::face::FacemarkAAM_ParamsTraitConst::max_m(self)) + .field("max_n", &crate::face::FacemarkAAM_ParamsTraitConst::max_n(self)) + .field("texture_max_m", &crate::face::FacemarkAAM_ParamsTraitConst::texture_max_m(self)) + .field("scales", &crate::face::FacemarkAAM_ParamsTraitConst::scales(self)) + .finish() } } - unsafe impl Send for FacemarkAAM_Params {} - impl crate::face::FacemarkAAM_ParamsTraitConst for FacemarkAAM_Params { #[inline] fn as_raw_FacemarkAAM_Params(&self) -> *const c_void { self.as_raw() } } @@ -2724,36 +2753,47 @@ pub mod face { boxed_ref! { FacemarkAAM_Params, crate::face::FacemarkAAM_ParamsTraitConst, as_raw_FacemarkAAM_Params, crate::face::FacemarkAAM_ParamsTrait, as_raw_mut_FacemarkAAM_Params } - impl FacemarkAAM_Params { - /// \brief Constructor + pub struct FacemarkKazemi { + ptr: *mut c_void, + } + + opencv_type_boxed! { FacemarkKazemi } + + impl Drop for FacemarkKazemi { #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_face_FacemarkAAM_Params_Params(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::face::FacemarkAAM_Params::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_face_FacemarkKazemi_delete(self.as_raw_mut_FacemarkKazemi()) }; } - } - impl std::fmt::Debug for FacemarkAAM_Params { + unsafe impl Send for FacemarkKazemi {} + + impl FacemarkKazemi { + /// ## C++ default parameters + /// * parameters: FacemarkKazemi::Params() #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FacemarkAAM_Params") - .field("model_filename", &crate::face::FacemarkAAM_ParamsTraitConst::model_filename(self)) - .field("m", &crate::face::FacemarkAAM_ParamsTraitConst::m(self)) - .field("n", &crate::face::FacemarkAAM_ParamsTraitConst::n(self)) - .field("n_iter", &crate::face::FacemarkAAM_ParamsTraitConst::n_iter(self)) - .field("verbose", &crate::face::FacemarkAAM_ParamsTraitConst::verbose(self)) - .field("save_model", &crate::face::FacemarkAAM_ParamsTraitConst::save_model(self)) - .field("max_m", &crate::face::FacemarkAAM_ParamsTraitConst::max_m(self)) - .field("max_n", &crate::face::FacemarkAAM_ParamsTraitConst::max_n(self)) - .field("texture_max_m", &crate::face::FacemarkAAM_ParamsTraitConst::texture_max_m(self)) - .field("scales", &crate::face::FacemarkAAM_ParamsTraitConst::scales(self)) - .finish() + pub fn create(parameters: &impl crate::face::FacemarkKazemi_ParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_FacemarkKazemi_create_const_ParamsR(parameters.as_raw_FacemarkKazemi_Params(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + + /// ## Note + /// This alternative version of [FacemarkKazemi::create] function uses the following default values for its arguments: + /// * parameters: FacemarkKazemi::Params() + #[inline] + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_FacemarkKazemi_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + } /// Constant methods for [crate::face::FacemarkKazemi] @@ -2840,20 +2880,17 @@ pub mod face { } - pub struct FacemarkKazemi { - ptr: *mut c_void, - } - - opencv_type_boxed! { FacemarkKazemi } - - impl Drop for FacemarkKazemi { + impl std::fmt::Debug for FacemarkKazemi { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_FacemarkKazemi_delete(self.as_raw_mut_FacemarkKazemi()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FacemarkKazemi") + .finish() } } - unsafe impl Send for FacemarkKazemi {} + boxed_cast_base! { FacemarkKazemi, core::Algorithm, cv_face_FacemarkKazemi_to_Algorithm } + + boxed_cast_base! { FacemarkKazemi, crate::face::Facemark, cv_face_FacemarkKazemi_to_Facemark } impl core::AlgorithmTraitConst for FacemarkKazemi { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2885,46 +2922,35 @@ pub mod face { boxed_ref! { FacemarkKazemi, crate::face::FacemarkKazemiTraitConst, as_raw_FacemarkKazemi, crate::face::FacemarkKazemiTrait, as_raw_mut_FacemarkKazemi } - impl FacemarkKazemi { - /// ## C++ default parameters - /// * parameters: FacemarkKazemi::Params() + pub struct FacemarkKazemi_Params { + ptr: *mut c_void, + } + + opencv_type_boxed! { FacemarkKazemi_Params } + + impl Drop for FacemarkKazemi_Params { #[inline] - pub fn create(parameters: &impl crate::face::FacemarkKazemi_ParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_face_FacemarkKazemi_create_const_ParamsR(parameters.as_raw_FacemarkKazemi_Params(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_face_FacemarkKazemi_Params_delete(self.as_raw_mut_FacemarkKazemi_Params()) }; } + } - /// ## Note - /// This alternative version of [FacemarkKazemi::create] function uses the following default values for its arguments: - /// * parameters: FacemarkKazemi::Params() + unsafe impl Send for FacemarkKazemi_Params {} + + impl FacemarkKazemi_Params { + /// \brief Constructor #[inline] - pub fn create_def() -> Result> { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_face_FacemarkKazemi_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_face_FacemarkKazemi_Params_Params(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::face::FacemarkKazemi_Params::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { FacemarkKazemi, core::Algorithm, cv_face_FacemarkKazemi_to_Algorithm } - - boxed_cast_base! { FacemarkKazemi, crate::face::Facemark, cv_face_FacemarkKazemi_to_Facemark } - - impl std::fmt::Debug for FacemarkKazemi { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FacemarkKazemi") - .finish() - } - } - /// Constant methods for [crate::face::FacemarkKazemi_Params] pub trait FacemarkKazemi_ParamsTraitConst { fn as_raw_FacemarkKazemi_Params(&self) -> *const c_void; @@ -3065,21 +3091,23 @@ pub mod face { } - pub struct FacemarkKazemi_Params { - ptr: *mut c_void, - } - - opencv_type_boxed! { FacemarkKazemi_Params } - - impl Drop for FacemarkKazemi_Params { + impl std::fmt::Debug for FacemarkKazemi_Params { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_FacemarkKazemi_Params_delete(self.as_raw_mut_FacemarkKazemi_Params()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FacemarkKazemi_Params") + .field("cascade_depth", &crate::face::FacemarkKazemi_ParamsTraitConst::cascade_depth(self)) + .field("tree_depth", &crate::face::FacemarkKazemi_ParamsTraitConst::tree_depth(self)) + .field("num_trees_per_cascade_level", &crate::face::FacemarkKazemi_ParamsTraitConst::num_trees_per_cascade_level(self)) + .field("learning_rate", &crate::face::FacemarkKazemi_ParamsTraitConst::learning_rate(self)) + .field("oversampling_amount", &crate::face::FacemarkKazemi_ParamsTraitConst::oversampling_amount(self)) + .field("num_test_coordinates", &crate::face::FacemarkKazemi_ParamsTraitConst::num_test_coordinates(self)) + .field("lambda", &crate::face::FacemarkKazemi_ParamsTraitConst::lambda(self)) + .field("num_test_splits", &crate::face::FacemarkKazemi_ParamsTraitConst::num_test_splits(self)) + .field("configfile", &crate::face::FacemarkKazemi_ParamsTraitConst::configfile(self)) + .finish() } } - unsafe impl Send for FacemarkKazemi_Params {} - impl crate::face::FacemarkKazemi_ParamsTraitConst for FacemarkKazemi_Params { #[inline] fn as_raw_FacemarkKazemi_Params(&self) -> *const c_void { self.as_raw() } } @@ -3090,35 +3118,47 @@ pub mod face { boxed_ref! { FacemarkKazemi_Params, crate::face::FacemarkKazemi_ParamsTraitConst, as_raw_FacemarkKazemi_Params, crate::face::FacemarkKazemi_ParamsTrait, as_raw_mut_FacemarkKazemi_Params } - impl FacemarkKazemi_Params { - /// \brief Constructor + pub struct FacemarkLBF { + ptr: *mut c_void, + } + + opencv_type_boxed! { FacemarkLBF } + + impl Drop for FacemarkLBF { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_face_FacemarkLBF_delete(self.as_raw_mut_FacemarkLBF()) }; + } + } + + unsafe impl Send for FacemarkLBF {} + + impl FacemarkLBF { + /// ## C++ default parameters + /// * parameters: FacemarkLBF::Params() + #[inline] + pub fn create(parameters: &impl crate::face::FacemarkLBF_ParamsTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_face_FacemarkKazemi_Params_Params(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_face_FacemarkLBF_create_const_ParamsR(parameters.as_raw_FacemarkLBF_Params(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::face::FacemarkKazemi_Params::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - } - - impl std::fmt::Debug for FacemarkKazemi_Params { + /// ## Note + /// This alternative version of [FacemarkLBF::create] function uses the following default values for its arguments: + /// * parameters: FacemarkLBF::Params() #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FacemarkKazemi_Params") - .field("cascade_depth", &crate::face::FacemarkKazemi_ParamsTraitConst::cascade_depth(self)) - .field("tree_depth", &crate::face::FacemarkKazemi_ParamsTraitConst::tree_depth(self)) - .field("num_trees_per_cascade_level", &crate::face::FacemarkKazemi_ParamsTraitConst::num_trees_per_cascade_level(self)) - .field("learning_rate", &crate::face::FacemarkKazemi_ParamsTraitConst::learning_rate(self)) - .field("oversampling_amount", &crate::face::FacemarkKazemi_ParamsTraitConst::oversampling_amount(self)) - .field("num_test_coordinates", &crate::face::FacemarkKazemi_ParamsTraitConst::num_test_coordinates(self)) - .field("lambda", &crate::face::FacemarkKazemi_ParamsTraitConst::lambda(self)) - .field("num_test_splits", &crate::face::FacemarkKazemi_ParamsTraitConst::num_test_splits(self)) - .field("configfile", &crate::face::FacemarkKazemi_ParamsTraitConst::configfile(self)) - .finish() + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_FacemarkLBF_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::face::FacemarkLBF] @@ -3133,20 +3173,19 @@ pub mod face { } - pub struct FacemarkLBF { - ptr: *mut c_void, - } - - opencv_type_boxed! { FacemarkLBF } - - impl Drop for FacemarkLBF { + impl std::fmt::Debug for FacemarkLBF { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_FacemarkLBF_delete(self.as_raw_mut_FacemarkLBF()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FacemarkLBF") + .finish() } } - unsafe impl Send for FacemarkLBF {} + boxed_cast_base! { FacemarkLBF, core::Algorithm, cv_face_FacemarkLBF_to_Algorithm } + + boxed_cast_base! { FacemarkLBF, crate::face::Facemark, cv_face_FacemarkLBF_to_Facemark } + + boxed_cast_base! { FacemarkLBF, crate::face::FacemarkTrain, cv_face_FacemarkLBF_to_FacemarkTrain } impl core::AlgorithmTraitConst for FacemarkLBF { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3188,48 +3227,35 @@ pub mod face { boxed_ref! { FacemarkLBF, crate::face::FacemarkLBFTraitConst, as_raw_FacemarkLBF, crate::face::FacemarkLBFTrait, as_raw_mut_FacemarkLBF } - impl FacemarkLBF { - /// ## C++ default parameters - /// * parameters: FacemarkLBF::Params() + pub struct FacemarkLBF_Params { + ptr: *mut c_void, + } + + opencv_type_boxed! { FacemarkLBF_Params } + + impl Drop for FacemarkLBF_Params { #[inline] - pub fn create(parameters: &impl crate::face::FacemarkLBF_ParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_face_FacemarkLBF_create_const_ParamsR(parameters.as_raw_FacemarkLBF_Params(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_face_FacemarkLBF_Params_delete(self.as_raw_mut_FacemarkLBF_Params()) }; } + } - /// ## Note - /// This alternative version of [FacemarkLBF::create] function uses the following default values for its arguments: - /// * parameters: FacemarkLBF::Params() + unsafe impl Send for FacemarkLBF_Params {} + + impl FacemarkLBF_Params { + /// \brief Constructor #[inline] - pub fn create_def() -> Result> { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_face_FacemarkLBF_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_face_FacemarkLBF_Params_Params(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::face::FacemarkLBF_Params::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { FacemarkLBF, core::Algorithm, cv_face_FacemarkLBF_to_Algorithm } - - boxed_cast_base! { FacemarkLBF, crate::face::Facemark, cv_face_FacemarkLBF_to_Facemark } - - boxed_cast_base! { FacemarkLBF, crate::face::FacemarkTrain, cv_face_FacemarkLBF_to_FacemarkTrain } - - impl std::fmt::Debug for FacemarkLBF { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FacemarkLBF") - .finish() - } - } - /// Constant methods for [crate::face::FacemarkLBF_Params] pub trait FacemarkLBF_ParamsTraitConst { fn as_raw_FacemarkLBF_Params(&self) -> *const c_void; @@ -3438,54 +3464,15 @@ pub mod face { #[inline] fn set_detect_roi(&mut self, val: core::Rect) { let ret = unsafe { sys::cv_face_FacemarkLBF_Params_propDetectROI_const_Rect(self.as_raw_mut_FacemarkLBF_Params(), &val) }; - ret - } - - #[inline] - fn read(&mut self, unnamed: &impl core::FileNodeTraitConst) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_face_FacemarkLBF_Params_read_const_FileNodeR(self.as_raw_mut_FacemarkLBF_Params(), unnamed.as_raw_FileNode(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - pub struct FacemarkLBF_Params { - ptr: *mut c_void, - } - - opencv_type_boxed! { FacemarkLBF_Params } - - impl Drop for FacemarkLBF_Params { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_FacemarkLBF_Params_delete(self.as_raw_mut_FacemarkLBF_Params()) }; - } - } - - unsafe impl Send for FacemarkLBF_Params {} - - impl crate::face::FacemarkLBF_ParamsTraitConst for FacemarkLBF_Params { - #[inline] fn as_raw_FacemarkLBF_Params(&self) -> *const c_void { self.as_raw() } - } - - impl crate::face::FacemarkLBF_ParamsTrait for FacemarkLBF_Params { - #[inline] fn as_raw_mut_FacemarkLBF_Params(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { FacemarkLBF_Params, crate::face::FacemarkLBF_ParamsTraitConst, as_raw_FacemarkLBF_Params, crate::face::FacemarkLBF_ParamsTrait, as_raw_mut_FacemarkLBF_Params } + ret + } - impl FacemarkLBF_Params { - /// \brief Constructor #[inline] - pub fn default() -> Result { + fn read(&mut self, unnamed: &impl core::FileNodeTraitConst) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_face_FacemarkLBF_Params_Params(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_face_FacemarkLBF_Params_read_const_FileNodeR(self.as_raw_mut_FacemarkLBF_Params(), unnamed.as_raw_FileNode(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::face::FacemarkLBF_Params::opencv_from_extern(ret) }; Ok(ret) } @@ -3514,255 +3501,16 @@ pub mod face { } } - /// Constant methods for [crate::face::FacemarkTrain] - pub trait FacemarkTrainTraitConst: crate::face::FacemarkTraitConst { - fn as_raw_FacemarkTrain(&self) -> *const c_void; - + impl crate::face::FacemarkLBF_ParamsTraitConst for FacemarkLBF_Params { + #[inline] fn as_raw_FacemarkLBF_Params(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::face::FacemarkTrain] - pub trait FacemarkTrainTrait: crate::face::FacemarkTrainTraitConst + crate::face::FacemarkTrait { - fn as_raw_mut_FacemarkTrain(&mut self) -> *mut c_void; - - /// Add one training sample to the trainer. - /// - /// ## Parameters - /// * image: Input image. - /// * landmarks: The ground-truth of facial landmarks points corresponds to the image. - /// - /// Example of usage - /// ```C++ - /// String imageFiles = "../data/images_train.txt"; - /// String ptsFiles = "../data/points_train.txt"; - /// std::vector images_train; - /// std::vector landmarks_train; - /// - /// // load the list of dataset: image paths and landmark file paths - /// loadDatasetList(imageFiles,ptsFiles,images_train,landmarks_train); - /// - /// Mat image; - /// std::vector facial_points; - /// for(size_t i=0;iaddTrainingSample(image, facial_points); - /// } - /// ``` - /// - /// - /// The contents in the training files should follows the standard format. - /// Here are examples for the contents in these files. - /// example of content in the images_train.txt - /// ```C++ - /// /home/user/ibug/image_003_1.jpg - /// /home/user/ibug/image_004_1.jpg - /// /home/user/ibug/image_005_1.jpg - /// /home/user/ibug/image_006.jpg - /// ``` - /// - /// - /// example of content in the points_train.txt - /// ```C++ - /// /home/user/ibug/image_003_1.pts - /// /home/user/ibug/image_004_1.pts - /// /home/user/ibug/image_005_1.pts - /// /home/user/ibug/image_006.pts - /// ``` - /// - #[inline] - fn add_training_sample(&mut self, image: &impl ToInputArray, landmarks: &impl ToInputArray) -> Result { - input_array_arg!(image); - input_array_arg!(landmarks); - return_send!(via ocvrs_return); - unsafe { sys::cv_face_FacemarkTrain_addTrainingSample_const__InputArrayR_const__InputArrayR(self.as_raw_mut_FacemarkTrain(), image.as_raw__InputArray(), landmarks.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Trains a Facemark algorithm using the given dataset. - /// Before the training process, training samples should be added to the trainer - /// using face::addTrainingSample function. - /// - /// ## Parameters - /// * parameters: Optional extra parameters (algorithm dependent). - /// - /// Example of usage - /// ```C++ - /// FacemarkLBF::Params params; - /// params.model_filename = "ibug68.model"; // filename to save the trained model - /// Ptr facemark = FacemarkLBF::create(params); - /// - /// // add training samples (see Facemark::addTrainingSample) - /// - /// facemark->training(); - /// ``` - /// - /// - /// ## C++ default parameters - /// * parameters: 0 - #[inline] - unsafe fn training(&mut self, parameters: *mut c_void) -> Result<()> { - return_send!(via ocvrs_return); - { sys::cv_face_FacemarkTrain_training_voidX(self.as_raw_mut_FacemarkTrain(), parameters, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Trains a Facemark algorithm using the given dataset. - /// Before the training process, training samples should be added to the trainer - /// using face::addTrainingSample function. - /// - /// ## Parameters - /// * parameters: Optional extra parameters (algorithm dependent). - /// - /// Example of usage - /// ```C++ - /// FacemarkLBF::Params params; - /// params.model_filename = "ibug68.model"; // filename to save the trained model - /// Ptr facemark = FacemarkLBF::create(params); - /// - /// // add training samples (see Facemark::addTrainingSample) - /// - /// facemark->training(); - /// ``` - /// - /// - /// ## Note - /// This alternative version of [FacemarkTrainTrait::training] function uses the following default values for its arguments: - /// * parameters: 0 - #[inline] - fn training_def(&mut self) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_face_FacemarkTrain_training(self.as_raw_mut_FacemarkTrain(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Set a user defined face detector for the Facemark algorithm. - /// ## Parameters - /// * detector: The user defined face detector function - /// * userData: Detector parameters - /// - /// Example of usage - /// ```C++ - /// MyDetectorParameters detectorParameters(...); - /// facemark->setFaceDetector(myDetector, &detectorParameters); - /// ``` - /// - /// - /// Example of a user defined face detector - /// ```C++ - /// bool myDetector( InputArray image, OutputArray faces, void* userData) - /// { - /// MyDetectorParameters* params = (MyDetectorParameters*)userData; - /// // -------- do something -------- - /// } - /// ``` - /// - /// - /// TODO Lifetime of detector parameters is uncontrolled. Rework interface design to "Ptr". - #[inline] - fn set_face_detector(&mut self, detector: crate::face::FN_FaceDetector) -> Result { - callback_arg!(detector_trampoline(unnamed: *const c_void, unnamed_1: *const c_void, user_data: *mut c_void) -> bool => user_data in detector(unnamed: *const c_void, unnamed_1: *const c_void) -> bool); - userdata_arg!(user_data: *mut c_void => detector); - return_send!(via ocvrs_return); - unsafe { sys::cv_face_FacemarkTrain_setFaceDetector_FN_FaceDetector_voidX(self.as_raw_mut_FacemarkTrain(), detector_trampoline, user_data, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Detect faces from a given image using default or user defined face detector. - /// Some Algorithm might not provide a default face detector. - /// - /// ## Parameters - /// * image: Input image. - /// * faces: Output of the function which represent region of interest of the detected faces. Each face is stored in cv::Rect container. - /// - /// Example of usage - /// ```C++ - /// std::vector faces; - /// facemark->getFaces(img, faces); - /// for(int j=0;j Result { - input_array_arg!(image); - output_array_arg!(faces); - return_send!(via ocvrs_return); - unsafe { sys::cv_face_FacemarkTrain_getFaces_const__InputArrayR_const__OutputArrayR(self.as_raw_mut_FacemarkTrain(), image.as_raw__InputArray(), faces.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Get data from an algorithm - /// - /// ## Parameters - /// * items: The obtained data, algorithm dependent. - /// - /// Example of usage - /// ```C++ - /// Ptr facemark = FacemarkAAM::create(); - /// facemark->loadModel("AAM.yml"); - /// - /// FacemarkAAM::Data data; - /// facemark->getData(&data); - /// std::vector s0 = data.s0; - /// - /// cout< Result { - return_send!(via ocvrs_return); - { sys::cv_face_FacemarkTrain_getData_voidX(self.as_raw_mut_FacemarkTrain(), items, ocvrs_return.as_mut_ptr()) }; - return_receive!(ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Get data from an algorithm - /// - /// ## Parameters - /// * items: The obtained data, algorithm dependent. - /// - /// Example of usage - /// ```C++ - /// Ptr facemark = FacemarkAAM::create(); - /// facemark->loadModel("AAM.yml"); - /// - /// FacemarkAAM::Data data; - /// facemark->getData(&data); - /// std::vector s0 = data.s0; - /// - /// cout< Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_face_FacemarkTrain_getData(self.as_raw_mut_FacemarkTrain(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - + impl crate::face::FacemarkLBF_ParamsTrait for FacemarkLBF_Params { + #[inline] fn as_raw_mut_FacemarkLBF_Params(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { FacemarkLBF_Params, crate::face::FacemarkLBF_ParamsTraitConst, as_raw_FacemarkLBF_Params, crate::face::FacemarkLBF_ParamsTrait, as_raw_mut_FacemarkLBF_Params } + /// Abstract base class for trainable facemark models /// /// To utilize this API in your program, please take a look at the [tutorial_table_of_content_facemark] @@ -3805,412 +3553,486 @@ pub mod face { unsafe impl Send for FacemarkTrain {} - impl core::AlgorithmTraitConst for FacemarkTrain { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for FacemarkTrain { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { FacemarkTrain, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::face::FacemarkTraitConst for FacemarkTrain { - #[inline] fn as_raw_Facemark(&self) -> *const c_void { self.as_raw() } - } - - impl crate::face::FacemarkTrait for FacemarkTrain { - #[inline] fn as_raw_mut_Facemark(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { FacemarkTrain, crate::face::FacemarkTraitConst, as_raw_Facemark, crate::face::FacemarkTrait, as_raw_mut_Facemark } - - impl crate::face::FacemarkTrainTraitConst for FacemarkTrain { - #[inline] fn as_raw_FacemarkTrain(&self) -> *const c_void { self.as_raw() } - } - - impl crate::face::FacemarkTrainTrait for FacemarkTrain { - #[inline] fn as_raw_mut_FacemarkTrain(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { FacemarkTrain, crate::face::FacemarkTrainTraitConst, as_raw_FacemarkTrain, crate::face::FacemarkTrainTrait, as_raw_mut_FacemarkTrain } - - impl FacemarkTrain { - } - - boxed_cast_descendant! { FacemarkTrain, crate::face::FacemarkAAM, cv_face_FacemarkTrain_to_FacemarkAAM } - - boxed_cast_descendant! { FacemarkTrain, crate::face::FacemarkLBF, cv_face_FacemarkTrain_to_FacemarkLBF } - - boxed_cast_base! { FacemarkTrain, core::Algorithm, cv_face_FacemarkTrain_to_Algorithm } - - boxed_cast_base! { FacemarkTrain, crate::face::Facemark, cv_face_FacemarkTrain_to_Facemark } - - impl std::fmt::Debug for FacemarkTrain { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FacemarkTrain") - .finish() - } - } - - /// Constant methods for [crate::face::FisherFaceRecognizer] - pub trait FisherFaceRecognizerTraitConst: crate::face::BasicFaceRecognizerTraitConst { - fn as_raw_FisherFaceRecognizer(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::face::FisherFaceRecognizer] - pub trait FisherFaceRecognizerTrait: crate::face::BasicFaceRecognizerTrait + crate::face::FisherFaceRecognizerTraitConst { - fn as_raw_mut_FisherFaceRecognizer(&mut self) -> *mut c_void; - - } - - pub struct FisherFaceRecognizer { - ptr: *mut c_void, - } - - opencv_type_boxed! { FisherFaceRecognizer } - - impl Drop for FisherFaceRecognizer { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_FisherFaceRecognizer_delete(self.as_raw_mut_FisherFaceRecognizer()) }; - } - } - - unsafe impl Send for FisherFaceRecognizer {} - - impl core::AlgorithmTraitConst for FisherFaceRecognizer { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for FisherFaceRecognizer { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { FisherFaceRecognizer, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::face::BasicFaceRecognizerTraitConst for FisherFaceRecognizer { - #[inline] fn as_raw_BasicFaceRecognizer(&self) -> *const c_void { self.as_raw() } - } - - impl crate::face::BasicFaceRecognizerTrait for FisherFaceRecognizer { - #[inline] fn as_raw_mut_BasicFaceRecognizer(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { FisherFaceRecognizer, crate::face::BasicFaceRecognizerTraitConst, as_raw_BasicFaceRecognizer, crate::face::BasicFaceRecognizerTrait, as_raw_mut_BasicFaceRecognizer } - - impl crate::face::FaceRecognizerTraitConst for FisherFaceRecognizer { - #[inline] fn as_raw_FaceRecognizer(&self) -> *const c_void { self.as_raw() } - } - - impl crate::face::FaceRecognizerTrait for FisherFaceRecognizer { - #[inline] fn as_raw_mut_FaceRecognizer(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { FisherFaceRecognizer, crate::face::FaceRecognizerTraitConst, as_raw_FaceRecognizer, crate::face::FaceRecognizerTrait, as_raw_mut_FaceRecognizer } - - impl crate::face::FisherFaceRecognizerTraitConst for FisherFaceRecognizer { - #[inline] fn as_raw_FisherFaceRecognizer(&self) -> *const c_void { self.as_raw() } - } + /// Constant methods for [crate::face::FacemarkTrain] + pub trait FacemarkTrainTraitConst: crate::face::FacemarkTraitConst { + fn as_raw_FacemarkTrain(&self) -> *const c_void; - impl crate::face::FisherFaceRecognizerTrait for FisherFaceRecognizer { - #[inline] fn as_raw_mut_FisherFaceRecognizer(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { FisherFaceRecognizer, crate::face::FisherFaceRecognizerTraitConst, as_raw_FisherFaceRecognizer, crate::face::FisherFaceRecognizerTrait, as_raw_mut_FisherFaceRecognizer } + /// Mutable methods for [crate::face::FacemarkTrain] + pub trait FacemarkTrainTrait: crate::face::FacemarkTrainTraitConst + crate::face::FacemarkTrait { + fn as_raw_mut_FacemarkTrain(&mut self) -> *mut c_void; - impl FisherFaceRecognizer { - /// ## Parameters - /// * num_components: The number of components (read: Fisherfaces) kept for this Linear - /// Discriminant Analysis with the Fisherfaces criterion. It's useful to keep all components, that - /// means the number of your classes c (read: subjects, persons you want to recognize). If you leave - /// this at the default (0) or set it to a value less-equal 0 or greater (c-1), it will be set to the - /// correct number (c-1) automatically. - /// * threshold: The threshold applied in the prediction. If the distance to the nearest neighbor - /// is larger than the threshold, this method returns -1. - /// - /// ### Notes: - /// - /// * Training and prediction must be done on grayscale images, use cvtColor to convert between the - /// color spaces. - /// * **THE FISHERFACES METHOD MAKES THE ASSUMPTION, THAT THE TRAINING AND TEST IMAGES ARE OF EQUAL - /// SIZE.** (caps-lock, because I got so many mails asking for this). You have to make sure your - /// input data has the correct shape, else a meaningful exception is thrown. Use resize to resize - /// the images. - /// * This model does not support updating. + /// Add one training sample to the trainer. /// - /// ### Model internal data: + /// ## Parameters + /// * image: Input image. + /// * landmarks: The ground-truth of facial landmarks points corresponds to the image. /// - /// * num_components see FisherFaceRecognizer::create. - /// * threshold see FisherFaceRecognizer::create. - /// * eigenvalues The eigenvalues for this Linear Discriminant Analysis (ordered descending). - /// * eigenvectors The eigenvectors for this Linear Discriminant Analysis (ordered by their - /// eigenvalue). - /// * mean The sample mean calculated from the training data. - /// * projections The projections of the training data. - /// * labels The labels corresponding to the projections. + /// Example of usage + /// ```C++ + /// String imageFiles = "../data/images_train.txt"; + /// String ptsFiles = "../data/points_train.txt"; + /// std::vector images_train; + /// std::vector landmarks_train; /// - /// ## C++ default parameters - /// * num_components: 0 - /// * threshold: DBL_MAX - #[inline] - pub fn create(num_components: i32, threshold: f64) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_face_FisherFaceRecognizer_create_int_double(num_components, threshold, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Parameters - /// * num_components: The number of components (read: Fisherfaces) kept for this Linear - /// Discriminant Analysis with the Fisherfaces criterion. It's useful to keep all components, that - /// means the number of your classes c (read: subjects, persons you want to recognize). If you leave - /// this at the default (0) or set it to a value less-equal 0 or greater (c-1), it will be set to the - /// correct number (c-1) automatically. - /// * threshold: The threshold applied in the prediction. If the distance to the nearest neighbor - /// is larger than the threshold, this method returns -1. + /// // load the list of dataset: image paths and landmark file paths + /// loadDatasetList(imageFiles,ptsFiles,images_train,landmarks_train); /// - /// ### Notes: + /// Mat image; + /// std::vector facial_points; + /// for(size_t i=0;iaddTrainingSample(image, facial_points); + /// } + /// ``` /// - /// * Training and prediction must be done on grayscale images, use cvtColor to convert between the - /// color spaces. - /// * **THE FISHERFACES METHOD MAKES THE ASSUMPTION, THAT THE TRAINING AND TEST IMAGES ARE OF EQUAL - /// SIZE.** (caps-lock, because I got so many mails asking for this). You have to make sure your - /// input data has the correct shape, else a meaningful exception is thrown. Use resize to resize - /// the images. - /// * This model does not support updating. /// - /// ### Model internal data: + /// The contents in the training files should follows the standard format. + /// Here are examples for the contents in these files. + /// example of content in the images_train.txt + /// ```C++ + /// /home/user/ibug/image_003_1.jpg + /// /home/user/ibug/image_004_1.jpg + /// /home/user/ibug/image_005_1.jpg + /// /home/user/ibug/image_006.jpg + /// ``` /// - /// * num_components see FisherFaceRecognizer::create. - /// * threshold see FisherFaceRecognizer::create. - /// * eigenvalues The eigenvalues for this Linear Discriminant Analysis (ordered descending). - /// * eigenvectors The eigenvectors for this Linear Discriminant Analysis (ordered by their - /// eigenvalue). - /// * mean The sample mean calculated from the training data. - /// * projections The projections of the training data. - /// * labels The labels corresponding to the projections. /// - /// ## Note - /// This alternative version of [FisherFaceRecognizer::create] function uses the following default values for its arguments: - /// * num_components: 0 - /// * threshold: DBL_MAX - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_face_FisherFaceRecognizer_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { FisherFaceRecognizer, core::Algorithm, cv_face_FisherFaceRecognizer_to_Algorithm } - - boxed_cast_base! { FisherFaceRecognizer, crate::face::BasicFaceRecognizer, cv_face_FisherFaceRecognizer_to_BasicFaceRecognizer } - - boxed_cast_base! { FisherFaceRecognizer, crate::face::FaceRecognizer, cv_face_FisherFaceRecognizer_to_FaceRecognizer } - - impl std::fmt::Debug for FisherFaceRecognizer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FisherFaceRecognizer") - .finish() - } - } - - /// Constant methods for [crate::face::LBPHFaceRecognizer] - pub trait LBPHFaceRecognizerTraitConst: crate::face::FaceRecognizerTraitConst { - fn as_raw_LBPHFaceRecognizer(&self) -> *const c_void; - - /// ## See also - /// setGridX + /// example of content in the points_train.txt + /// ```C++ + /// /home/user/ibug/image_003_1.pts + /// /home/user/ibug/image_004_1.pts + /// /home/user/ibug/image_005_1.pts + /// /home/user/ibug/image_006.pts + /// ``` + /// #[inline] - fn get_grid_x(&self) -> Result { + fn add_training_sample(&mut self, image: &impl ToInputArray, landmarks: &impl ToInputArray) -> Result { + input_array_arg!(image); + input_array_arg!(landmarks); return_send!(via ocvrs_return); - unsafe { sys::cv_face_LBPHFaceRecognizer_getGridX_const(self.as_raw_LBPHFaceRecognizer(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_face_FacemarkTrain_addTrainingSample_const__InputArrayR_const__InputArrayR(self.as_raw_mut_FacemarkTrain(), image.as_raw__InputArray(), landmarks.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// ## See also - /// setGridY + /// Trains a Facemark algorithm using the given dataset. + /// Before the training process, training samples should be added to the trainer + /// using face::addTrainingSample function. + /// + /// ## Parameters + /// * parameters: Optional extra parameters (algorithm dependent). + /// + /// Example of usage + /// ```C++ + /// FacemarkLBF::Params params; + /// params.model_filename = "ibug68.model"; // filename to save the trained model + /// Ptr facemark = FacemarkLBF::create(params); + /// + /// // add training samples (see Facemark::addTrainingSample) + /// + /// facemark->training(); + /// ``` + /// + /// + /// ## C++ default parameters + /// * parameters: 0 #[inline] - fn get_grid_y(&self) -> Result { + unsafe fn training(&mut self, parameters: *mut c_void) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_face_LBPHFaceRecognizer_getGridY_const(self.as_raw_LBPHFaceRecognizer(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_face_FacemarkTrain_training_voidX(self.as_raw_mut_FacemarkTrain(), parameters, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// ## See also - /// setRadius + /// Trains a Facemark algorithm using the given dataset. + /// Before the training process, training samples should be added to the trainer + /// using face::addTrainingSample function. + /// + /// ## Parameters + /// * parameters: Optional extra parameters (algorithm dependent). + /// + /// Example of usage + /// ```C++ + /// FacemarkLBF::Params params; + /// params.model_filename = "ibug68.model"; // filename to save the trained model + /// Ptr facemark = FacemarkLBF::create(params); + /// + /// // add training samples (see Facemark::addTrainingSample) + /// + /// facemark->training(); + /// ``` + /// + /// + /// ## Note + /// This alternative version of [FacemarkTrainTrait::training] function uses the following default values for its arguments: + /// * parameters: 0 #[inline] - fn get_radius(&self) -> Result { + fn training_def(&mut self) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_face_LBPHFaceRecognizer_getRadius_const(self.as_raw_LBPHFaceRecognizer(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_face_FacemarkTrain_training(self.as_raw_mut_FacemarkTrain(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// ## See also - /// setNeighbors + /// Set a user defined face detector for the Facemark algorithm. + /// ## Parameters + /// * detector: The user defined face detector function + /// * userData: Detector parameters + /// + /// Example of usage + /// ```C++ + /// MyDetectorParameters detectorParameters(...); + /// facemark->setFaceDetector(myDetector, &detectorParameters); + /// ``` + /// + /// + /// Example of a user defined face detector + /// ```C++ + /// bool myDetector( InputArray image, OutputArray faces, void* userData) + /// { + /// MyDetectorParameters* params = (MyDetectorParameters*)userData; + /// // -------- do something -------- + /// } + /// ``` + /// + /// + /// TODO Lifetime of detector parameters is uncontrolled. Rework interface design to "Ptr". #[inline] - fn get_neighbors(&self) -> Result { + fn set_face_detector(&mut self, detector: crate::face::FN_FaceDetector) -> Result { + callback_arg!(detector_trampoline(unnamed: *const c_void, unnamed_1: *const c_void, user_data: *mut c_void) -> bool => user_data in detector(unnamed: *const c_void, unnamed_1: *const c_void) -> bool); + userdata_arg!(user_data: *mut c_void => detector); return_send!(via ocvrs_return); - unsafe { sys::cv_face_LBPHFaceRecognizer_getNeighbors_const(self.as_raw_LBPHFaceRecognizer(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_face_FacemarkTrain_setFaceDetector_FN_FaceDetector_voidX(self.as_raw_mut_FacemarkTrain(), detector_trampoline, user_data, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// ## See also - /// setThreshold + /// Detect faces from a given image using default or user defined face detector. + /// Some Algorithm might not provide a default face detector. + /// + /// ## Parameters + /// * image: Input image. + /// * faces: Output of the function which represent region of interest of the detected faces. Each face is stored in cv::Rect container. + /// + /// Example of usage + /// ```C++ + /// std::vector faces; + /// facemark->getFaces(img, faces); + /// for(int j=0;j Result { + fn get_faces(&mut self, image: &impl ToInputArray, faces: &mut impl ToOutputArray) -> Result { + input_array_arg!(image); + output_array_arg!(faces); return_send!(via ocvrs_return); - unsafe { sys::cv_face_LBPHFaceRecognizer_getThreshold_const(self.as_raw_LBPHFaceRecognizer(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_face_FacemarkTrain_getFaces_const__InputArrayR_const__OutputArrayR(self.as_raw_mut_FacemarkTrain(), image.as_raw__InputArray(), faces.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } + /// Get data from an algorithm + /// + /// ## Parameters + /// * items: The obtained data, algorithm dependent. + /// + /// Example of usage + /// ```C++ + /// Ptr facemark = FacemarkAAM::create(); + /// facemark->loadModel("AAM.yml"); + /// + /// FacemarkAAM::Data data; + /// facemark->getData(&data); + /// std::vector s0 = data.s0; + /// + /// cout< Result> { + unsafe fn get_data(&mut self, items: *mut c_void) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_face_LBPHFaceRecognizer_getHistograms_const(self.as_raw_LBPHFaceRecognizer(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + { sys::cv_face_FacemarkTrain_getData_voidX(self.as_raw_mut_FacemarkTrain(), items, ocvrs_return.as_mut_ptr()) }; + return_receive!(ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Vector::::opencv_from_extern(ret) }; Ok(ret) } + /// Get data from an algorithm + /// + /// ## Parameters + /// * items: The obtained data, algorithm dependent. + /// + /// Example of usage + /// ```C++ + /// Ptr facemark = FacemarkAAM::create(); + /// facemark->loadModel("AAM.yml"); + /// + /// FacemarkAAM::Data data; + /// facemark->getData(&data); + /// std::vector s0 = data.s0; + /// + /// cout< Result { + fn get_data_def(&mut self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_face_LBPHFaceRecognizer_getLabels_const(self.as_raw_LBPHFaceRecognizer(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_face_FacemarkTrain_getData(self.as_raw_mut_FacemarkTrain(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } } - /// Mutable methods for [crate::face::LBPHFaceRecognizer] - pub trait LBPHFaceRecognizerTrait: crate::face::FaceRecognizerTrait + crate::face::LBPHFaceRecognizerTraitConst { - fn as_raw_mut_LBPHFaceRecognizer(&mut self) -> *mut c_void; - - /// ## See also - /// setGridX getGridX + impl std::fmt::Debug for FacemarkTrain { #[inline] - fn set_grid_x(&mut self, val: i32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_face_LBPHFaceRecognizer_setGridX_int(self.as_raw_mut_LBPHFaceRecognizer(), val, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FacemarkTrain") + .finish() } + } - /// ## See also - /// setGridY getGridY - #[inline] - fn set_grid_y(&mut self, val: i32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_face_LBPHFaceRecognizer_setGridY_int(self.as_raw_mut_LBPHFaceRecognizer(), val, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } + boxed_cast_base! { FacemarkTrain, core::Algorithm, cv_face_FacemarkTrain_to_Algorithm } - /// ## See also - /// setRadius getRadius + boxed_cast_base! { FacemarkTrain, crate::face::Facemark, cv_face_FacemarkTrain_to_Facemark } + + boxed_cast_descendant! { FacemarkTrain, crate::face::FacemarkAAM, cv_face_FacemarkTrain_to_FacemarkAAM } + + boxed_cast_descendant! { FacemarkTrain, crate::face::FacemarkLBF, cv_face_FacemarkTrain_to_FacemarkLBF } + + impl core::AlgorithmTraitConst for FacemarkTrain { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } + } + + impl core::AlgorithmTrait for FacemarkTrain { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { FacemarkTrain, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + + impl crate::face::FacemarkTraitConst for FacemarkTrain { + #[inline] fn as_raw_Facemark(&self) -> *const c_void { self.as_raw() } + } + + impl crate::face::FacemarkTrait for FacemarkTrain { + #[inline] fn as_raw_mut_Facemark(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { FacemarkTrain, crate::face::FacemarkTraitConst, as_raw_Facemark, crate::face::FacemarkTrait, as_raw_mut_Facemark } + + impl crate::face::FacemarkTrainTraitConst for FacemarkTrain { + #[inline] fn as_raw_FacemarkTrain(&self) -> *const c_void { self.as_raw() } + } + + impl crate::face::FacemarkTrainTrait for FacemarkTrain { + #[inline] fn as_raw_mut_FacemarkTrain(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { FacemarkTrain, crate::face::FacemarkTrainTraitConst, as_raw_FacemarkTrain, crate::face::FacemarkTrainTrait, as_raw_mut_FacemarkTrain } + + pub struct FisherFaceRecognizer { + ptr: *mut c_void, + } + + opencv_type_boxed! { FisherFaceRecognizer } + + impl Drop for FisherFaceRecognizer { #[inline] - fn set_radius(&mut self, val: i32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_face_LBPHFaceRecognizer_setRadius_int(self.as_raw_mut_LBPHFaceRecognizer(), val, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_face_FisherFaceRecognizer_delete(self.as_raw_mut_FisherFaceRecognizer()) }; } + } - /// ## See also - /// setNeighbors getNeighbors + unsafe impl Send for FisherFaceRecognizer {} + + impl FisherFaceRecognizer { + /// ## Parameters + /// * num_components: The number of components (read: Fisherfaces) kept for this Linear + /// Discriminant Analysis with the Fisherfaces criterion. It's useful to keep all components, that + /// means the number of your classes c (read: subjects, persons you want to recognize). If you leave + /// this at the default (0) or set it to a value less-equal 0 or greater (c-1), it will be set to the + /// correct number (c-1) automatically. + /// * threshold: The threshold applied in the prediction. If the distance to the nearest neighbor + /// is larger than the threshold, this method returns -1. + /// + /// ### Notes: + /// + /// * Training and prediction must be done on grayscale images, use cvtColor to convert between the + /// color spaces. + /// * **THE FISHERFACES METHOD MAKES THE ASSUMPTION, THAT THE TRAINING AND TEST IMAGES ARE OF EQUAL + /// SIZE.** (caps-lock, because I got so many mails asking for this). You have to make sure your + /// input data has the correct shape, else a meaningful exception is thrown. Use resize to resize + /// the images. + /// * This model does not support updating. + /// + /// ### Model internal data: + /// + /// * num_components see FisherFaceRecognizer::create. + /// * threshold see FisherFaceRecognizer::create. + /// * eigenvalues The eigenvalues for this Linear Discriminant Analysis (ordered descending). + /// * eigenvectors The eigenvectors for this Linear Discriminant Analysis (ordered by their + /// eigenvalue). + /// * mean The sample mean calculated from the training data. + /// * projections The projections of the training data. + /// * labels The labels corresponding to the projections. + /// + /// ## C++ default parameters + /// * num_components: 0 + /// * threshold: DBL_MAX #[inline] - fn set_neighbors(&mut self, val: i32) -> Result<()> { + pub fn create(num_components: i32, threshold: f64) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_face_LBPHFaceRecognizer_setNeighbors_int(self.as_raw_mut_LBPHFaceRecognizer(), val, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_face_FisherFaceRecognizer_create_int_double(num_components, threshold, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// ## See also - /// setThreshold getThreshold + /// ## Parameters + /// * num_components: The number of components (read: Fisherfaces) kept for this Linear + /// Discriminant Analysis with the Fisherfaces criterion. It's useful to keep all components, that + /// means the number of your classes c (read: subjects, persons you want to recognize). If you leave + /// this at the default (0) or set it to a value less-equal 0 or greater (c-1), it will be set to the + /// correct number (c-1) automatically. + /// * threshold: The threshold applied in the prediction. If the distance to the nearest neighbor + /// is larger than the threshold, this method returns -1. + /// + /// ### Notes: + /// + /// * Training and prediction must be done on grayscale images, use cvtColor to convert between the + /// color spaces. + /// * **THE FISHERFACES METHOD MAKES THE ASSUMPTION, THAT THE TRAINING AND TEST IMAGES ARE OF EQUAL + /// SIZE.** (caps-lock, because I got so many mails asking for this). You have to make sure your + /// input data has the correct shape, else a meaningful exception is thrown. Use resize to resize + /// the images. + /// * This model does not support updating. + /// + /// ### Model internal data: + /// + /// * num_components see FisherFaceRecognizer::create. + /// * threshold see FisherFaceRecognizer::create. + /// * eigenvalues The eigenvalues for this Linear Discriminant Analysis (ordered descending). + /// * eigenvectors The eigenvectors for this Linear Discriminant Analysis (ordered by their + /// eigenvalue). + /// * mean The sample mean calculated from the training data. + /// * projections The projections of the training data. + /// * labels The labels corresponding to the projections. + /// + /// ## Note + /// This alternative version of [FisherFaceRecognizer::create] function uses the following default values for its arguments: + /// * num_components: 0 + /// * threshold: DBL_MAX #[inline] - fn set_threshold(&mut self, val: f64) -> Result<()> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_face_LBPHFaceRecognizer_setThreshold_double(self.as_raw_mut_LBPHFaceRecognizer(), val, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_face_FisherFaceRecognizer_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - pub struct LBPHFaceRecognizer { - ptr: *mut c_void, + /// Constant methods for [crate::face::FisherFaceRecognizer] + pub trait FisherFaceRecognizerTraitConst: crate::face::BasicFaceRecognizerTraitConst { + fn as_raw_FisherFaceRecognizer(&self) -> *const c_void; + } - opencv_type_boxed! { LBPHFaceRecognizer } + /// Mutable methods for [crate::face::FisherFaceRecognizer] + pub trait FisherFaceRecognizerTrait: crate::face::BasicFaceRecognizerTrait + crate::face::FisherFaceRecognizerTraitConst { + fn as_raw_mut_FisherFaceRecognizer(&mut self) -> *mut c_void; - impl Drop for LBPHFaceRecognizer { + } + + impl std::fmt::Debug for FisherFaceRecognizer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_LBPHFaceRecognizer_delete(self.as_raw_mut_LBPHFaceRecognizer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FisherFaceRecognizer") + .finish() } } - unsafe impl Send for LBPHFaceRecognizer {} + boxed_cast_base! { FisherFaceRecognizer, core::Algorithm, cv_face_FisherFaceRecognizer_to_Algorithm } - impl core::AlgorithmTraitConst for LBPHFaceRecognizer { + boxed_cast_base! { FisherFaceRecognizer, crate::face::BasicFaceRecognizer, cv_face_FisherFaceRecognizer_to_BasicFaceRecognizer } + + boxed_cast_base! { FisherFaceRecognizer, crate::face::FaceRecognizer, cv_face_FisherFaceRecognizer_to_FaceRecognizer } + + impl core::AlgorithmTraitConst for FisherFaceRecognizer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } } - impl core::AlgorithmTrait for LBPHFaceRecognizer { + impl core::AlgorithmTrait for FisherFaceRecognizer { #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { LBPHFaceRecognizer, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + boxed_ref! { FisherFaceRecognizer, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - impl crate::face::FaceRecognizerTraitConst for LBPHFaceRecognizer { + impl crate::face::BasicFaceRecognizerTraitConst for FisherFaceRecognizer { + #[inline] fn as_raw_BasicFaceRecognizer(&self) -> *const c_void { self.as_raw() } + } + + impl crate::face::BasicFaceRecognizerTrait for FisherFaceRecognizer { + #[inline] fn as_raw_mut_BasicFaceRecognizer(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { FisherFaceRecognizer, crate::face::BasicFaceRecognizerTraitConst, as_raw_BasicFaceRecognizer, crate::face::BasicFaceRecognizerTrait, as_raw_mut_BasicFaceRecognizer } + + impl crate::face::FaceRecognizerTraitConst for FisherFaceRecognizer { #[inline] fn as_raw_FaceRecognizer(&self) -> *const c_void { self.as_raw() } } - impl crate::face::FaceRecognizerTrait for LBPHFaceRecognizer { + impl crate::face::FaceRecognizerTrait for FisherFaceRecognizer { #[inline] fn as_raw_mut_FaceRecognizer(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { LBPHFaceRecognizer, crate::face::FaceRecognizerTraitConst, as_raw_FaceRecognizer, crate::face::FaceRecognizerTrait, as_raw_mut_FaceRecognizer } + boxed_ref! { FisherFaceRecognizer, crate::face::FaceRecognizerTraitConst, as_raw_FaceRecognizer, crate::face::FaceRecognizerTrait, as_raw_mut_FaceRecognizer } - impl crate::face::LBPHFaceRecognizerTraitConst for LBPHFaceRecognizer { - #[inline] fn as_raw_LBPHFaceRecognizer(&self) -> *const c_void { self.as_raw() } + impl crate::face::FisherFaceRecognizerTraitConst for FisherFaceRecognizer { + #[inline] fn as_raw_FisherFaceRecognizer(&self) -> *const c_void { self.as_raw() } } - impl crate::face::LBPHFaceRecognizerTrait for LBPHFaceRecognizer { - #[inline] fn as_raw_mut_LBPHFaceRecognizer(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::face::FisherFaceRecognizerTrait for FisherFaceRecognizer { + #[inline] fn as_raw_mut_FisherFaceRecognizer(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { LBPHFaceRecognizer, crate::face::LBPHFaceRecognizerTraitConst, as_raw_LBPHFaceRecognizer, crate::face::LBPHFaceRecognizerTrait, as_raw_mut_LBPHFaceRecognizer } + boxed_ref! { FisherFaceRecognizer, crate::face::FisherFaceRecognizerTraitConst, as_raw_FisherFaceRecognizer, crate::face::FisherFaceRecognizerTrait, as_raw_mut_FisherFaceRecognizer } + + pub struct LBPHFaceRecognizer { + ptr: *mut c_void, + } + + opencv_type_boxed! { LBPHFaceRecognizer } + + impl Drop for LBPHFaceRecognizer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_face_LBPHFaceRecognizer_delete(self.as_raw_mut_LBPHFaceRecognizer()) }; + } + } + + unsafe impl Send for LBPHFaceRecognizer {} impl LBPHFaceRecognizer { /// ## Parameters @@ -4254,122 +4076,199 @@ pub mod face { #[inline] pub fn create(radius: i32, neighbors: i32, grid_x: i32, grid_y: i32, threshold: f64) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_face_LBPHFaceRecognizer_create_int_int_int_int_double(radius, neighbors, grid_x, grid_y, threshold, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_face_LBPHFaceRecognizer_create_int_int_int_int_double(radius, neighbors, grid_x, grid_y, threshold, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Parameters + /// * radius: The radius used for building the Circular Local Binary Pattern. The greater the + /// radius, the smoother the image but more spatial information you can get. + /// * neighbors: The number of sample points to build a Circular Local Binary Pattern from. An + /// appropriate value is to use `8` sample points. Keep in mind: the more sample points you include, + /// the higher the computational cost. + /// * grid_x: The number of cells in the horizontal direction, 8 is a common value used in + /// publications. The more cells, the finer the grid, the higher the dimensionality of the resulting + /// feature vector. + /// * grid_y: The number of cells in the vertical direction, 8 is a common value used in + /// publications. The more cells, the finer the grid, the higher the dimensionality of the resulting + /// feature vector. + /// * threshold: The threshold applied in the prediction. If the distance to the nearest neighbor + /// is larger than the threshold, this method returns -1. + /// + /// ### Notes: + /// + /// * The Circular Local Binary Patterns (used in training and prediction) expect the data given as + /// grayscale images, use cvtColor to convert between the color spaces. + /// * This model supports updating. + /// + /// ### Model internal data: + /// + /// * radius see LBPHFaceRecognizer::create. + /// * neighbors see LBPHFaceRecognizer::create. + /// * grid_x see LLBPHFaceRecognizer::create. + /// * grid_y see LBPHFaceRecognizer::create. + /// * threshold see LBPHFaceRecognizer::create. + /// * histograms Local Binary Patterns Histograms calculated from the given training data (empty if + /// none was given). + /// * labels Labels corresponding to the calculated Local Binary Patterns Histograms. + /// + /// ## Note + /// This alternative version of [LBPHFaceRecognizer::create] function uses the following default values for its arguments: + /// * radius: 1 + /// * neighbors: 8 + /// * grid_x: 8 + /// * grid_y: 8 + /// * threshold: DBL_MAX + #[inline] + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_LBPHFaceRecognizer_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::face::LBPHFaceRecognizer] + pub trait LBPHFaceRecognizerTraitConst: crate::face::FaceRecognizerTraitConst { + fn as_raw_LBPHFaceRecognizer(&self) -> *const c_void; + + /// ## See also + /// setGridX + #[inline] + fn get_grid_x(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_LBPHFaceRecognizer_getGridX_const(self.as_raw_LBPHFaceRecognizer(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// ## See also + /// setGridY + #[inline] + fn get_grid_y(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_LBPHFaceRecognizer_getGridY_const(self.as_raw_LBPHFaceRecognizer(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// ## See also + /// setRadius + #[inline] + fn get_radius(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_LBPHFaceRecognizer_getRadius_const(self.as_raw_LBPHFaceRecognizer(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// ## See also + /// setNeighbors + #[inline] + fn get_neighbors(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_LBPHFaceRecognizer_getNeighbors_const(self.as_raw_LBPHFaceRecognizer(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// ## Parameters - /// * radius: The radius used for building the Circular Local Binary Pattern. The greater the - /// radius, the smoother the image but more spatial information you can get. - /// * neighbors: The number of sample points to build a Circular Local Binary Pattern from. An - /// appropriate value is to use `8` sample points. Keep in mind: the more sample points you include, - /// the higher the computational cost. - /// * grid_x: The number of cells in the horizontal direction, 8 is a common value used in - /// publications. The more cells, the finer the grid, the higher the dimensionality of the resulting - /// feature vector. - /// * grid_y: The number of cells in the vertical direction, 8 is a common value used in - /// publications. The more cells, the finer the grid, the higher the dimensionality of the resulting - /// feature vector. - /// * threshold: The threshold applied in the prediction. If the distance to the nearest neighbor - /// is larger than the threshold, this method returns -1. - /// - /// ### Notes: - /// - /// * The Circular Local Binary Patterns (used in training and prediction) expect the data given as - /// grayscale images, use cvtColor to convert between the color spaces. - /// * This model supports updating. - /// - /// ### Model internal data: - /// - /// * radius see LBPHFaceRecognizer::create. - /// * neighbors see LBPHFaceRecognizer::create. - /// * grid_x see LLBPHFaceRecognizer::create. - /// * grid_y see LBPHFaceRecognizer::create. - /// * threshold see LBPHFaceRecognizer::create. - /// * histograms Local Binary Patterns Histograms calculated from the given training data (empty if - /// none was given). - /// * labels Labels corresponding to the calculated Local Binary Patterns Histograms. - /// - /// ## Note - /// This alternative version of [LBPHFaceRecognizer::create] function uses the following default values for its arguments: - /// * radius: 1 - /// * neighbors: 8 - /// * grid_x: 8 - /// * grid_y: 8 - /// * threshold: DBL_MAX + /// ## See also + /// setThreshold #[inline] - pub fn create_def() -> Result> { + fn get_threshold(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_face_LBPHFaceRecognizer_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_face_LBPHFaceRecognizer_getThreshold_const(self.as_raw_LBPHFaceRecognizer(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { LBPHFaceRecognizer, core::Algorithm, cv_face_LBPHFaceRecognizer_to_Algorithm } - - boxed_cast_base! { LBPHFaceRecognizer, crate::face::FaceRecognizer, cv_face_LBPHFaceRecognizer_to_FaceRecognizer } + #[inline] + fn get_histograms(&self) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_LBPHFaceRecognizer_getHistograms_const(self.as_raw_LBPHFaceRecognizer(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Vector::::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for LBPHFaceRecognizer { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LBPHFaceRecognizer") - .finish() + fn get_labels(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_LBPHFaceRecognizer_getLabels_const(self.as_raw_LBPHFaceRecognizer(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + Ok(ret) } + } - /// Constant methods for [crate::face::MACE] - pub trait MACETraitConst: core::AlgorithmTraitConst { - fn as_raw_MACE(&self) -> *const c_void; + /// Mutable methods for [crate::face::LBPHFaceRecognizer] + pub trait LBPHFaceRecognizerTrait: crate::face::FaceRecognizerTrait + crate::face::LBPHFaceRecognizerTraitConst { + fn as_raw_mut_LBPHFaceRecognizer(&mut self) -> *mut c_void; - /// correlate query img and threshold to min class value - /// ## Parameters - /// * query: a Mat with query image + /// ## See also + /// setGridX getGridX #[inline] - fn same(&self, query: &impl ToInputArray) -> Result { - input_array_arg!(query); + fn set_grid_x(&mut self, val: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_face_MACE_same_const_const__InputArrayR(self.as_raw_MACE(), query.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_face_LBPHFaceRecognizer_setGridX_int(self.as_raw_mut_LBPHFaceRecognizer(), val, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - } + /// ## See also + /// setGridY getGridY + #[inline] + fn set_grid_y(&mut self, val: i32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_LBPHFaceRecognizer_setGridY_int(self.as_raw_mut_LBPHFaceRecognizer(), val, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - /// Mutable methods for [crate::face::MACE] - pub trait MACETrait: core::AlgorithmTrait + crate::face::MACETraitConst { - fn as_raw_mut_MACE(&mut self) -> *mut c_void; + /// ## See also + /// setRadius getRadius + #[inline] + fn set_radius(&mut self, val: i32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_LBPHFaceRecognizer_setRadius_int(self.as_raw_mut_LBPHFaceRecognizer(), val, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - /// optionally encrypt images with random convolution - /// ## Parameters - /// * passphrase: a crc64 random seed will get generated from this + /// ## See also + /// setNeighbors getNeighbors #[inline] - fn salt(&mut self, passphrase: &str) -> Result<()> { - extern_container_arg!(passphrase); + fn set_neighbors(&mut self, val: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_face_MACE_salt_const_StringR(self.as_raw_mut_MACE(), passphrase.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_face_LBPHFaceRecognizer_setNeighbors_int(self.as_raw_mut_LBPHFaceRecognizer(), val, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// train it on positive features - /// compute the mace filter: `h = D(-1) * X * (X(+) * D(-1) * X)(-1) * C` - /// also calculate a minimal threshold for this class, the smallest self-similarity from the train images - /// ## Parameters - /// * images: a vector with the train images + /// ## See also + /// setThreshold getThreshold #[inline] - fn train(&mut self, images: &impl ToInputArray) -> Result<()> { - input_array_arg!(images); + fn set_threshold(&mut self, val: f64) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_face_MACE_train_const__InputArrayR(self.as_raw_mut_MACE(), images.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_face_LBPHFaceRecognizer_setThreshold_double(self.as_raw_mut_LBPHFaceRecognizer(), val, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -4377,6 +4276,48 @@ pub mod face { } + impl std::fmt::Debug for LBPHFaceRecognizer { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LBPHFaceRecognizer") + .finish() + } + } + + boxed_cast_base! { LBPHFaceRecognizer, core::Algorithm, cv_face_LBPHFaceRecognizer_to_Algorithm } + + boxed_cast_base! { LBPHFaceRecognizer, crate::face::FaceRecognizer, cv_face_LBPHFaceRecognizer_to_FaceRecognizer } + + impl core::AlgorithmTraitConst for LBPHFaceRecognizer { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } + } + + impl core::AlgorithmTrait for LBPHFaceRecognizer { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { LBPHFaceRecognizer, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + + impl crate::face::FaceRecognizerTraitConst for LBPHFaceRecognizer { + #[inline] fn as_raw_FaceRecognizer(&self) -> *const c_void { self.as_raw() } + } + + impl crate::face::FaceRecognizerTrait for LBPHFaceRecognizer { + #[inline] fn as_raw_mut_FaceRecognizer(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { LBPHFaceRecognizer, crate::face::FaceRecognizerTraitConst, as_raw_FaceRecognizer, crate::face::FaceRecognizerTrait, as_raw_mut_FaceRecognizer } + + impl crate::face::LBPHFaceRecognizerTraitConst for LBPHFaceRecognizer { + #[inline] fn as_raw_LBPHFaceRecognizer(&self) -> *const c_void { self.as_raw() } + } + + impl crate::face::LBPHFaceRecognizerTrait for LBPHFaceRecognizer { + #[inline] fn as_raw_mut_LBPHFaceRecognizer(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { LBPHFaceRecognizer, crate::face::LBPHFaceRecognizerTraitConst, as_raw_LBPHFaceRecognizer, crate::face::LBPHFaceRecognizerTrait, as_raw_mut_LBPHFaceRecognizer } + /// Minimum Average Correlation Energy Filter /// useful for authentication with (cancellable) biometrical features. /// (does not need many positives to train (10-50), and no negatives at all, also robust to noise/salting) @@ -4444,26 +4385,6 @@ pub mod face { unsafe impl Send for MACE {} - impl core::AlgorithmTraitConst for MACE { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for MACE { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { MACE, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::face::MACETraitConst for MACE { - #[inline] fn as_raw_MACE(&self) -> *const c_void { self.as_raw() } - } - - impl crate::face::MACETrait for MACE { - #[inline] fn as_raw_mut_MACE(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { MACE, crate::face::MACETraitConst, as_raw_MACE, crate::face::MACETrait, as_raw_mut_MACE } - impl MACE { /// constructor /// ## Parameters @@ -4515,31 +4436,82 @@ pub mod face { unsafe { sys::cv_face_MACE_create_int(imgsize, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// constructor + /// ## Parameters + /// * IMGSIZE: images will get resized to this (should be an even number) + /// + /// ## Note + /// This alternative version of [MACE::create] function uses the following default values for its arguments: + /// * imgsize: 64 + #[inline] + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_MACE_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::face::MACE] + pub trait MACETraitConst: core::AlgorithmTraitConst { + fn as_raw_MACE(&self) -> *const c_void; + + /// correlate query img and threshold to min class value + /// ## Parameters + /// * query: a Mat with query image + #[inline] + fn same(&self, query: &impl ToInputArray) -> Result { + input_array_arg!(query); + return_send!(via ocvrs_return); + unsafe { sys::cv_face_MACE_same_const_const__InputArrayR(self.as_raw_MACE(), query.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + /// Mutable methods for [crate::face::MACE] + pub trait MACETrait: core::AlgorithmTrait + crate::face::MACETraitConst { + fn as_raw_mut_MACE(&mut self) -> *mut c_void; + + /// optionally encrypt images with random convolution + /// ## Parameters + /// * passphrase: a crc64 random seed will get generated from this + #[inline] + fn salt(&mut self, passphrase: &str) -> Result<()> { + extern_container_arg!(passphrase); + return_send!(via ocvrs_return); + unsafe { sys::cv_face_MACE_salt_const_StringR(self.as_raw_mut_MACE(), passphrase.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; Ok(ret) } - /// constructor + /// train it on positive features + /// compute the mace filter: `h = D(-1) * X * (X(+) * D(-1) * X)(-1) * C` + /// also calculate a minimal threshold for this class, the smallest self-similarity from the train images /// ## Parameters - /// * IMGSIZE: images will get resized to this (should be an even number) - /// - /// ## Note - /// This alternative version of [MACE::create] function uses the following default values for its arguments: - /// * imgsize: 64 + /// * images: a vector with the train images #[inline] - pub fn create_def() -> Result> { + fn train(&mut self, images: &impl ToInputArray) -> Result<()> { + input_array_arg!(images); return_send!(via ocvrs_return); - unsafe { sys::cv_face_MACE_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_face_MACE_train_const__InputArrayR(self.as_raw_mut_MACE(), images.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { MACE, core::Algorithm, cv_face_MACE_to_Algorithm } - impl std::fmt::Debug for MACE { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -4548,6 +4520,44 @@ pub mod face { } } + boxed_cast_base! { MACE, core::Algorithm, cv_face_MACE_to_Algorithm } + + impl core::AlgorithmTraitConst for MACE { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } + } + + impl core::AlgorithmTrait for MACE { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { MACE, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + + impl crate::face::MACETraitConst for MACE { + #[inline] fn as_raw_MACE(&self) -> *const c_void { self.as_raw() } + } + + impl crate::face::MACETrait for MACE { + #[inline] fn as_raw_mut_MACE(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { MACE, crate::face::MACETraitConst, as_raw_MACE, crate::face::MACETrait, as_raw_mut_MACE } + + /// Abstract base class for all strategies of prediction result handling + pub struct PredictCollector { + ptr: *mut c_void, + } + + opencv_type_boxed! { PredictCollector } + + impl Drop for PredictCollector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_face_PredictCollector_delete(self.as_raw_mut_PredictCollector()) }; + } + } + + unsafe impl Send for PredictCollector {} + /// Constant methods for [crate::face::PredictCollector] pub trait PredictCollectorTraitConst { fn as_raw_PredictCollector(&self) -> *const c_void; @@ -4585,21 +4595,15 @@ pub mod face { } - /// Abstract base class for all strategies of prediction result handling - pub struct PredictCollector { - ptr: *mut c_void, - } - - opencv_type_boxed! { PredictCollector } - - impl Drop for PredictCollector { + impl std::fmt::Debug for PredictCollector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_PredictCollector_delete(self.as_raw_mut_PredictCollector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PredictCollector") + .finish() } } - unsafe impl Send for PredictCollector {} + boxed_cast_descendant! { PredictCollector, crate::face::StandardCollector, cv_face_PredictCollector_to_StandardCollector } impl crate::face::PredictCollectorTraitConst for PredictCollector { #[inline] fn as_raw_PredictCollector(&self) -> *const c_void { self.as_raw() } @@ -4611,17 +4615,91 @@ pub mod face { boxed_ref! { PredictCollector, crate::face::PredictCollectorTraitConst, as_raw_PredictCollector, crate::face::PredictCollectorTrait, as_raw_mut_PredictCollector } - impl PredictCollector { + /// Default predict collector + /// + /// Trace minimal distance with treshhold checking (that is default behavior for most predict logic) + pub struct StandardCollector { + ptr: *mut c_void, } - boxed_cast_descendant! { PredictCollector, crate::face::StandardCollector, cv_face_PredictCollector_to_StandardCollector } + opencv_type_boxed! { StandardCollector } - impl std::fmt::Debug for PredictCollector { + impl Drop for StandardCollector { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PredictCollector") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_face_StandardCollector_delete(self.as_raw_mut_StandardCollector()) }; + } + } + + unsafe impl Send for StandardCollector {} + + impl StandardCollector { + /// Constructor + /// ## Parameters + /// * threshold_: set threshold + /// + /// ## C++ default parameters + /// * threshold_: DBL_MAX + #[inline] + pub fn new(threshold_: f64) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_StandardCollector_StandardCollector_double(threshold_, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::face::StandardCollector::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Constructor + /// ## Parameters + /// * threshold_: set threshold + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * threshold_: DBL_MAX + #[inline] + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_StandardCollector_StandardCollector(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::face::StandardCollector::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Static constructor + /// ## Parameters + /// * threshold: set threshold + /// + /// ## C++ default parameters + /// * threshold: DBL_MAX + #[inline] + pub fn create(threshold: f64) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_StandardCollector_create_double(threshold, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Static constructor + /// ## Parameters + /// * threshold: set threshold + /// + /// ## Note + /// This alternative version of [StandardCollector::create] function uses the following default values for its arguments: + /// * threshold: DBL_MAX + #[inline] + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_face_StandardCollector_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::face::StandardCollector] @@ -4711,23 +4789,15 @@ pub mod face { } - /// Default predict collector - /// - /// Trace minimal distance with treshhold checking (that is default behavior for most predict logic) - pub struct StandardCollector { - ptr: *mut c_void, - } - - opencv_type_boxed! { StandardCollector } - - impl Drop for StandardCollector { + impl std::fmt::Debug for StandardCollector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_face_StandardCollector_delete(self.as_raw_mut_StandardCollector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("StandardCollector") + .finish() } } - unsafe impl Send for StandardCollector {} + boxed_cast_base! { StandardCollector, crate::face::PredictCollector, cv_face_StandardCollector_to_PredictCollector } impl crate::face::PredictCollectorTraitConst for StandardCollector { #[inline] fn as_raw_PredictCollector(&self) -> *const c_void { self.as_raw() } @@ -4749,85 +4819,6 @@ pub mod face { boxed_ref! { StandardCollector, crate::face::StandardCollectorTraitConst, as_raw_StandardCollector, crate::face::StandardCollectorTrait, as_raw_mut_StandardCollector } - impl StandardCollector { - /// Constructor - /// ## Parameters - /// * threshold_: set threshold - /// - /// ## C++ default parameters - /// * threshold_: DBL_MAX - #[inline] - pub fn new(threshold_: f64) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_face_StandardCollector_StandardCollector_double(threshold_, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::face::StandardCollector::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Constructor - /// ## Parameters - /// * threshold_: set threshold - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * threshold_: DBL_MAX - #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_face_StandardCollector_StandardCollector(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::face::StandardCollector::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Static constructor - /// ## Parameters - /// * threshold: set threshold - /// - /// ## C++ default parameters - /// * threshold: DBL_MAX - #[inline] - pub fn create(threshold: f64) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_face_StandardCollector_create_double(threshold, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Static constructor - /// ## Parameters - /// * threshold: set threshold - /// - /// ## Note - /// This alternative version of [StandardCollector::create] function uses the following default values for its arguments: - /// * threshold: DBL_MAX - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_face_StandardCollector_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { StandardCollector, crate::face::PredictCollector, cv_face_StandardCollector_to_PredictCollector } - - impl std::fmt::Debug for StandardCollector { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("StandardCollector") - .finish() - } - } - #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] pub struct StandardCollector_PredictResult { @@ -4864,4 +4855,5 @@ pub mod face { } } + } diff --git a/docs/features2d.rs b/docs/features2d.rs index c9f72af3b..ddac39554 100644 --- a/docs/features2d.rs +++ b/docs/features2d.rs @@ -706,6 +706,112 @@ pub mod features2d { Ok(ret) } + /// Class implementing the AKAZE keypoint detector and descriptor extractor, described in [ANB13](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_ANB13). + /// + /// @details AKAZE descriptors can only be used with KAZE or AKAZE keypoints. This class is thread-safe. + /// + /// + /// Note: When you need descriptors use Feature2D::detectAndCompute, which + /// provides better performance. When using Feature2D::detect followed by + /// Feature2D::compute scale space pyramid is computed twice. + /// + /// + /// Note: AKAZE implements T-API. When image is passed as UMat some parts of the algorithm + /// will use OpenCL. + /// + /// + /// Note: [ANB13] Fast Explicit Diffusion for Accelerated Features in Nonlinear + /// Scale Spaces. Pablo F. Alcantarilla, Jesús Nuevo and Adrien Bartoli. In + /// British Machine Vision Conference (BMVC), Bristol, UK, September 2013. + pub struct AKAZE { + ptr: *mut c_void, + } + + opencv_type_boxed! { AKAZE } + + impl Drop for AKAZE { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_AKAZE_delete(self.as_raw_mut_AKAZE()) }; + } + } + + unsafe impl Send for AKAZE {} + + impl AKAZE { + /// The AKAZE constructor + /// + /// ## Parameters + /// * descriptor_type: Type of the extracted descriptor: DESCRIPTOR_KAZE, + /// DESCRIPTOR_KAZE_UPRIGHT, DESCRIPTOR_MLDB or DESCRIPTOR_MLDB_UPRIGHT. + /// * descriptor_size: Size of the descriptor in bits. 0 -\> Full size + /// * descriptor_channels: Number of channels in the descriptor (1, 2, 3) + /// * threshold: Detector response threshold to accept point + /// * nOctaves: Maximum octave evolution of the image + /// * nOctaveLayers: Default number of sublevels per scale level + /// * diffusivity: Diffusivity type. DIFF_PM_G1, DIFF_PM_G2, DIFF_WEICKERT or + /// DIFF_CHARBONNIER + /// * max_points: Maximum amount of returned points. In case if image contains + /// more features, then the features with highest response are returned. + /// Negative value means no limitation. + /// + /// ## C++ default parameters + /// * descriptor_type: AKAZE::DESCRIPTOR_MLDB + /// * descriptor_size: 0 + /// * descriptor_channels: 3 + /// * threshold: 0.001f + /// * n_octaves: 4 + /// * n_octave_layers: 4 + /// * diffusivity: KAZE::DIFF_PM_G2 + /// * max_points: -1 + #[inline] + pub fn create(descriptor_type: crate::features2d::AKAZE_DescriptorType, descriptor_size: i32, descriptor_channels: i32, threshold: f32, n_octaves: i32, n_octave_layers: i32, diffusivity: crate::features2d::KAZE_DiffusivityType, max_points: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_AKAZE_create_DescriptorType_int_int_float_int_int_DiffusivityType_int(descriptor_type, descriptor_size, descriptor_channels, threshold, n_octaves, n_octave_layers, diffusivity, max_points, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// The AKAZE constructor + /// + /// ## Parameters + /// * descriptor_type: Type of the extracted descriptor: DESCRIPTOR_KAZE, + /// DESCRIPTOR_KAZE_UPRIGHT, DESCRIPTOR_MLDB or DESCRIPTOR_MLDB_UPRIGHT. + /// * descriptor_size: Size of the descriptor in bits. 0 -\> Full size + /// * descriptor_channels: Number of channels in the descriptor (1, 2, 3) + /// * threshold: Detector response threshold to accept point + /// * nOctaves: Maximum octave evolution of the image + /// * nOctaveLayers: Default number of sublevels per scale level + /// * diffusivity: Diffusivity type. DIFF_PM_G1, DIFF_PM_G2, DIFF_WEICKERT or + /// DIFF_CHARBONNIER + /// * max_points: Maximum amount of returned points. In case if image contains + /// more features, then the features with highest response are returned. + /// Negative value means no limitation. + /// + /// ## Note + /// This alternative version of [AKAZE::create] function uses the following default values for its arguments: + /// * descriptor_type: AKAZE::DESCRIPTOR_MLDB + /// * descriptor_size: 0 + /// * descriptor_channels: 3 + /// * threshold: 0.001f + /// * n_octaves: 4 + /// * n_octave_layers: 4 + /// * diffusivity: KAZE::DIFF_PM_G2 + /// * max_points: -1 + #[inline] + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_AKAZE_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::features2d::AKAZE] pub trait AKAZETraitConst: crate::features2d::Feature2DTraitConst { fn as_raw_AKAZE(&self) -> *const c_void; @@ -872,37 +978,17 @@ pub mod features2d { } - /// Class implementing the AKAZE keypoint detector and descriptor extractor, described in [ANB13](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_ANB13). - /// - /// @details AKAZE descriptors can only be used with KAZE or AKAZE keypoints. This class is thread-safe. - /// - /// - /// Note: When you need descriptors use Feature2D::detectAndCompute, which - /// provides better performance. When using Feature2D::detect followed by - /// Feature2D::compute scale space pyramid is computed twice. - /// - /// - /// Note: AKAZE implements T-API. When image is passed as UMat some parts of the algorithm - /// will use OpenCL. - /// - /// - /// Note: [ANB13] Fast Explicit Diffusion for Accelerated Features in Nonlinear - /// Scale Spaces. Pablo F. Alcantarilla, Jesús Nuevo and Adrien Bartoli. In - /// British Machine Vision Conference (BMVC), Bristol, UK, September 2013. - pub struct AKAZE { - ptr: *mut c_void, - } - - opencv_type_boxed! { AKAZE } - - impl Drop for AKAZE { + impl std::fmt::Debug for AKAZE { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_AKAZE_delete(self.as_raw_mut_AKAZE()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AKAZE") + .finish() } } - unsafe impl Send for AKAZE {} + boxed_cast_base! { AKAZE, core::Algorithm, cv_AKAZE_to_Algorithm } + + boxed_cast_base! { AKAZE, crate::features2d::Feature2D, cv_AKAZE_to_Feature2D } impl core::AlgorithmTraitConst for AKAZE { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -934,92 +1020,71 @@ pub mod features2d { boxed_ref! { AKAZE, crate::features2d::AKAZETraitConst, as_raw_AKAZE, crate::features2d::AKAZETrait, as_raw_mut_AKAZE } - impl AKAZE { - /// The AKAZE constructor - /// + /// Class for implementing the wrapper which makes detectors and extractors to be affine invariant, + /// described as ASIFT in [YM11](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_YM11) . + pub struct AffineFeature { + ptr: *mut c_void, + } + + opencv_type_boxed! { AffineFeature } + + impl Drop for AffineFeature { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_AffineFeature_delete(self.as_raw_mut_AffineFeature()) }; + } + } + + unsafe impl Send for AffineFeature {} + + impl AffineFeature { /// ## Parameters - /// * descriptor_type: Type of the extracted descriptor: DESCRIPTOR_KAZE, - /// DESCRIPTOR_KAZE_UPRIGHT, DESCRIPTOR_MLDB or DESCRIPTOR_MLDB_UPRIGHT. - /// * descriptor_size: Size of the descriptor in bits. 0 -\> Full size - /// * descriptor_channels: Number of channels in the descriptor (1, 2, 3) - /// * threshold: Detector response threshold to accept point - /// * nOctaves: Maximum octave evolution of the image - /// * nOctaveLayers: Default number of sublevels per scale level - /// * diffusivity: Diffusivity type. DIFF_PM_G1, DIFF_PM_G2, DIFF_WEICKERT or - /// DIFF_CHARBONNIER - /// * max_points: Maximum amount of returned points. In case if image contains - /// more features, then the features with highest response are returned. - /// Negative value means no limitation. + /// * backend: The detector/extractor you want to use as backend. + /// * maxTilt: The highest power index of tilt factor. 5 is used in the paper as tilt sampling range n. + /// * minTilt: The lowest power index of tilt factor. 0 is used in the paper. + /// * tiltStep: Tilt sampling step ![inline formula](https://latex.codecogs.com/png.latex?%5Cdelta%5Ft) in Algorithm 1 in the paper. + /// * rotateStepBase: Rotation sampling step factor b in Algorithm 1 in the paper. /// /// ## C++ default parameters - /// * descriptor_type: AKAZE::DESCRIPTOR_MLDB - /// * descriptor_size: 0 - /// * descriptor_channels: 3 - /// * threshold: 0.001f - /// * n_octaves: 4 - /// * n_octave_layers: 4 - /// * diffusivity: KAZE::DIFF_PM_G2 - /// * max_points: -1 + /// * max_tilt: 5 + /// * min_tilt: 0 + /// * tilt_step: 1.4142135623730951f + /// * rotate_step_base: 72 #[inline] - pub fn create(descriptor_type: crate::features2d::AKAZE_DescriptorType, descriptor_size: i32, descriptor_channels: i32, threshold: f32, n_octaves: i32, n_octave_layers: i32, diffusivity: crate::features2d::KAZE_DiffusivityType, max_points: i32) -> Result> { + pub fn create(backend: &core::Ptr, max_tilt: i32, min_tilt: i32, tilt_step: f32, rotate_step_base: f32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_AKAZE_create_DescriptorType_int_int_float_int_int_DiffusivityType_int(descriptor_type, descriptor_size, descriptor_channels, threshold, n_octaves, n_octave_layers, diffusivity, max_points, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_AffineFeature_create_const_PtrLFeature2DGR_int_int_float_float(backend.as_raw_PtrOfFeature2D(), max_tilt, min_tilt, tilt_step, rotate_step_base, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// The AKAZE constructor - /// /// ## Parameters - /// * descriptor_type: Type of the extracted descriptor: DESCRIPTOR_KAZE, - /// DESCRIPTOR_KAZE_UPRIGHT, DESCRIPTOR_MLDB or DESCRIPTOR_MLDB_UPRIGHT. - /// * descriptor_size: Size of the descriptor in bits. 0 -\> Full size - /// * descriptor_channels: Number of channels in the descriptor (1, 2, 3) - /// * threshold: Detector response threshold to accept point - /// * nOctaves: Maximum octave evolution of the image - /// * nOctaveLayers: Default number of sublevels per scale level - /// * diffusivity: Diffusivity type. DIFF_PM_G1, DIFF_PM_G2, DIFF_WEICKERT or - /// DIFF_CHARBONNIER - /// * max_points: Maximum amount of returned points. In case if image contains - /// more features, then the features with highest response are returned. - /// Negative value means no limitation. + /// * backend: The detector/extractor you want to use as backend. + /// * maxTilt: The highest power index of tilt factor. 5 is used in the paper as tilt sampling range n. + /// * minTilt: The lowest power index of tilt factor. 0 is used in the paper. + /// * tiltStep: Tilt sampling step ![inline formula](https://latex.codecogs.com/png.latex?%5Cdelta%5Ft) in Algorithm 1 in the paper. + /// * rotateStepBase: Rotation sampling step factor b in Algorithm 1 in the paper. /// /// ## Note - /// This alternative version of [AKAZE::create] function uses the following default values for its arguments: - /// * descriptor_type: AKAZE::DESCRIPTOR_MLDB - /// * descriptor_size: 0 - /// * descriptor_channels: 3 - /// * threshold: 0.001f - /// * n_octaves: 4 - /// * n_octave_layers: 4 - /// * diffusivity: KAZE::DIFF_PM_G2 - /// * max_points: -1 + /// This alternative version of [AffineFeature::create] function uses the following default values for its arguments: + /// * max_tilt: 5 + /// * min_tilt: 0 + /// * tilt_step: 1.4142135623730951f + /// * rotate_step_base: 72 #[inline] - pub fn create_def() -> Result> { + pub fn create_def(backend: &core::Ptr) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_AKAZE_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_AffineFeature_create_const_PtrLFeature2DGR(backend.as_raw_PtrOfFeature2D(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { AKAZE, core::Algorithm, cv_AKAZE_to_Algorithm } - - boxed_cast_base! { AKAZE, crate::features2d::Feature2D, cv_AKAZE_to_Feature2D } - - impl std::fmt::Debug for AKAZE { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AKAZE") - .finish() - } - } - /// Constant methods for [crate::features2d::AffineFeature] pub trait AffineFeatureTraitConst: crate::features2d::Feature2DTraitConst { fn as_raw_AffineFeature(&self) -> *const c_void; @@ -1060,22 +1125,17 @@ pub mod features2d { } - /// Class for implementing the wrapper which makes detectors and extractors to be affine invariant, - /// described as ASIFT in [YM11](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_YM11) . - pub struct AffineFeature { - ptr: *mut c_void, - } - - opencv_type_boxed! { AffineFeature } - - impl Drop for AffineFeature { + impl std::fmt::Debug for AffineFeature { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_AffineFeature_delete(self.as_raw_mut_AffineFeature()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AffineFeature") + .finish() } } - unsafe impl Send for AffineFeature {} + boxed_cast_base! { AffineFeature, core::Algorithm, cv_AffineFeature_to_Algorithm } + + boxed_cast_base! { AffineFeature, crate::features2d::Feature2D, cv_AffineFeature_to_Feature2D } impl core::AlgorithmTraitConst for AffineFeature { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1107,66 +1167,54 @@ pub mod features2d { boxed_ref! { AffineFeature, crate::features2d::AffineFeatureTraitConst, as_raw_AffineFeature, crate::features2d::AffineFeatureTrait, as_raw_mut_AffineFeature } - impl AffineFeature { - /// ## Parameters - /// * backend: The detector/extractor you want to use as backend. - /// * maxTilt: The highest power index of tilt factor. 5 is used in the paper as tilt sampling range n. - /// * minTilt: The lowest power index of tilt factor. 0 is used in the paper. - /// * tiltStep: Tilt sampling step ![inline formula](https://latex.codecogs.com/png.latex?%5Cdelta%5Ft) in Algorithm 1 in the paper. - /// * rotateStepBase: Rotation sampling step factor b in Algorithm 1 in the paper. - /// + /// Wrapping class for feature detection using the AGAST method. : + pub struct AgastFeatureDetector { + ptr: *mut c_void, + } + + opencv_type_boxed! { AgastFeatureDetector } + + impl Drop for AgastFeatureDetector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_AgastFeatureDetector_delete(self.as_raw_mut_AgastFeatureDetector()) }; + } + } + + unsafe impl Send for AgastFeatureDetector {} + + impl AgastFeatureDetector { /// ## C++ default parameters - /// * max_tilt: 5 - /// * min_tilt: 0 - /// * tilt_step: 1.4142135623730951f - /// * rotate_step_base: 72 + /// * threshold: 10 + /// * nonmax_suppression: true + /// * typ: AgastFeatureDetector::OAST_9_16 #[inline] - pub fn create(backend: &core::Ptr, max_tilt: i32, min_tilt: i32, tilt_step: f32, rotate_step_base: f32) -> Result> { + pub fn create(threshold: i32, nonmax_suppression: bool, typ: crate::features2d::AgastFeatureDetector_DetectorType) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_AffineFeature_create_const_PtrLFeature2DGR_int_int_float_float(backend.as_raw_PtrOfFeature2D(), max_tilt, min_tilt, tilt_step, rotate_step_base, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_AgastFeatureDetector_create_int_bool_DetectorType(threshold, nonmax_suppression, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// ## Parameters - /// * backend: The detector/extractor you want to use as backend. - /// * maxTilt: The highest power index of tilt factor. 5 is used in the paper as tilt sampling range n. - /// * minTilt: The lowest power index of tilt factor. 0 is used in the paper. - /// * tiltStep: Tilt sampling step ![inline formula](https://latex.codecogs.com/png.latex?%5Cdelta%5Ft) in Algorithm 1 in the paper. - /// * rotateStepBase: Rotation sampling step factor b in Algorithm 1 in the paper. - /// /// ## Note - /// This alternative version of [AffineFeature::create] function uses the following default values for its arguments: - /// * max_tilt: 5 - /// * min_tilt: 0 - /// * tilt_step: 1.4142135623730951f - /// * rotate_step_base: 72 + /// This alternative version of [AgastFeatureDetector::create] function uses the following default values for its arguments: + /// * threshold: 10 + /// * nonmax_suppression: true + /// * typ: AgastFeatureDetector::OAST_9_16 #[inline] - pub fn create_def(backend: &core::Ptr) -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_AffineFeature_create_const_PtrLFeature2DGR(backend.as_raw_PtrOfFeature2D(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_AgastFeatureDetector_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { AffineFeature, core::Algorithm, cv_AffineFeature_to_Algorithm } - - boxed_cast_base! { AffineFeature, crate::features2d::Feature2D, cv_AffineFeature_to_Feature2D } - - impl std::fmt::Debug for AffineFeature { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AffineFeature") - .finish() - } - } - /// Constant methods for [crate::features2d::AgastFeatureDetector] pub trait AgastFeatureDetectorTraitConst: crate::features2d::Feature2DTraitConst { fn as_raw_AgastFeatureDetector(&self) -> *const c_void; @@ -1243,21 +1291,17 @@ pub mod features2d { } - /// Wrapping class for feature detection using the AGAST method. : - pub struct AgastFeatureDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { AgastFeatureDetector } - - impl Drop for AgastFeatureDetector { + impl std::fmt::Debug for AgastFeatureDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_AgastFeatureDetector_delete(self.as_raw_mut_AgastFeatureDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AgastFeatureDetector") + .finish() } } - unsafe impl Send for AgastFeatureDetector {} + boxed_cast_base! { AgastFeatureDetector, core::Algorithm, cv_AgastFeatureDetector_to_Algorithm } + + boxed_cast_base! { AgastFeatureDetector, crate::features2d::Feature2D, cv_AgastFeatureDetector_to_Feature2D } impl core::AlgorithmTraitConst for AgastFeatureDetector { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1289,97 +1333,6 @@ pub mod features2d { boxed_ref! { AgastFeatureDetector, crate::features2d::AgastFeatureDetectorTraitConst, as_raw_AgastFeatureDetector, crate::features2d::AgastFeatureDetectorTrait, as_raw_mut_AgastFeatureDetector } - impl AgastFeatureDetector { - /// ## C++ default parameters - /// * threshold: 10 - /// * nonmax_suppression: true - /// * typ: AgastFeatureDetector::OAST_9_16 - #[inline] - pub fn create(threshold: i32, nonmax_suppression: bool, typ: crate::features2d::AgastFeatureDetector_DetectorType) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_AgastFeatureDetector_create_int_bool_DetectorType(threshold, nonmax_suppression, typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [AgastFeatureDetector::create] function uses the following default values for its arguments: - /// * threshold: 10 - /// * nonmax_suppression: true - /// * typ: AgastFeatureDetector::OAST_9_16 - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_AgastFeatureDetector_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { AgastFeatureDetector, core::Algorithm, cv_AgastFeatureDetector_to_Algorithm } - - boxed_cast_base! { AgastFeatureDetector, crate::features2d::Feature2D, cv_AgastFeatureDetector_to_Feature2D } - - impl std::fmt::Debug for AgastFeatureDetector { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AgastFeatureDetector") - .finish() - } - } - - /// Constant methods for [crate::features2d::BFMatcher] - pub trait BFMatcherTraitConst: crate::features2d::DescriptorMatcherTraitConst { - fn as_raw_BFMatcher(&self) -> *const c_void; - - #[inline] - fn is_mask_supported(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_BFMatcher_isMaskSupported_const(self.as_raw_BFMatcher(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// ## C++ default parameters - /// * empty_train_data: false - #[inline] - #[must_use] - fn clone(&self, empty_train_data: bool) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_BFMatcher_clone_const_bool(self.as_raw_BFMatcher(), empty_train_data, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [BFMatcherTraitConst::clone] function uses the following default values for its arguments: - /// * empty_train_data: false - #[inline] - fn clone_def(&self) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_BFMatcher_clone_const(self.as_raw_BFMatcher(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - /// Mutable methods for [crate::features2d::BFMatcher] - pub trait BFMatcherTrait: crate::features2d::BFMatcherTraitConst + crate::features2d::DescriptorMatcherTrait { - fn as_raw_mut_BFMatcher(&mut self) -> *mut c_void; - - } - /// Brute-force descriptor matcher. /// /// For each descriptor in the first set, this matcher finds the closest descriptor in the second set @@ -1400,36 +1353,6 @@ pub mod features2d { unsafe impl Send for BFMatcher {} - impl core::AlgorithmTraitConst for BFMatcher { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for BFMatcher { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { BFMatcher, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::features2d::DescriptorMatcherTraitConst for BFMatcher { - #[inline] fn as_raw_DescriptorMatcher(&self) -> *const c_void { self.as_raw() } - } - - impl crate::features2d::DescriptorMatcherTrait for BFMatcher { - #[inline] fn as_raw_mut_DescriptorMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { BFMatcher, crate::features2d::DescriptorMatcherTraitConst, as_raw_DescriptorMatcher, crate::features2d::DescriptorMatcherTrait, as_raw_mut_DescriptorMatcher } - - impl crate::features2d::BFMatcherTraitConst for BFMatcher { - #[inline] fn as_raw_BFMatcher(&self) -> *const c_void { self.as_raw() } - } - - impl crate::features2d::BFMatcherTrait for BFMatcher { - #[inline] fn as_raw_mut_BFMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { BFMatcher, crate::features2d::BFMatcherTraitConst, as_raw_BFMatcher, crate::features2d::BFMatcherTrait, as_raw_mut_BFMatcher } - impl BFMatcher { /// Brute-force matcher constructor (obsolete). Please use BFMatcher.create() /// @@ -1517,45 +1440,185 @@ pub mod features2d { } - boxed_cast_base! { BFMatcher, core::Algorithm, cv_BFMatcher_to_Algorithm } - - boxed_cast_base! { BFMatcher, crate::features2d::DescriptorMatcher, cv_BFMatcher_to_DescriptorMatcher } - - impl std::fmt::Debug for BFMatcher { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BFMatcher") - .finish() - } - } - - /// Constant methods for [crate::features2d::BOWImgDescriptorExtractor] - pub trait BOWImgDescriptorExtractorTraitConst { - fn as_raw_BOWImgDescriptorExtractor(&self) -> *const c_void; + /// Constant methods for [crate::features2d::BFMatcher] + pub trait BFMatcherTraitConst: crate::features2d::DescriptorMatcherTraitConst { + fn as_raw_BFMatcher(&self) -> *const c_void; - /// Returns the set vocabulary. #[inline] - fn get_vocabulary(&self) -> Result { + fn is_mask_supported(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_BOWImgDescriptorExtractor_getVocabulary_const(self.as_raw_BOWImgDescriptorExtractor(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_BFMatcher_isMaskSupported_const(self.as_raw_BFMatcher(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// Returns an image descriptor size if the vocabulary is set. Otherwise, it returns 0. + /// ## C++ default parameters + /// * empty_train_data: false #[inline] - fn descriptor_size(&self) -> Result { + #[must_use] + fn clone(&self, empty_train_data: bool) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_BOWImgDescriptorExtractor_descriptorSize_const(self.as_raw_BOWImgDescriptorExtractor(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_BFMatcher_clone_const_bool(self.as_raw_BFMatcher(), empty_train_data, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Returns an image descriptor type. - #[inline] + /// ## Note + /// This alternative version of [BFMatcherTraitConst::clone] function uses the following default values for its arguments: + /// * empty_train_data: false + #[inline] + fn clone_def(&self) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_BFMatcher_clone_const(self.as_raw_BFMatcher(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Mutable methods for [crate::features2d::BFMatcher] + pub trait BFMatcherTrait: crate::features2d::BFMatcherTraitConst + crate::features2d::DescriptorMatcherTrait { + fn as_raw_mut_BFMatcher(&mut self) -> *mut c_void; + + } + + impl std::fmt::Debug for BFMatcher { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BFMatcher") + .finish() + } + } + + boxed_cast_base! { BFMatcher, core::Algorithm, cv_BFMatcher_to_Algorithm } + + boxed_cast_base! { BFMatcher, crate::features2d::DescriptorMatcher, cv_BFMatcher_to_DescriptorMatcher } + + impl core::AlgorithmTraitConst for BFMatcher { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } + } + + impl core::AlgorithmTrait for BFMatcher { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { BFMatcher, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + + impl crate::features2d::DescriptorMatcherTraitConst for BFMatcher { + #[inline] fn as_raw_DescriptorMatcher(&self) -> *const c_void { self.as_raw() } + } + + impl crate::features2d::DescriptorMatcherTrait for BFMatcher { + #[inline] fn as_raw_mut_DescriptorMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { BFMatcher, crate::features2d::DescriptorMatcherTraitConst, as_raw_DescriptorMatcher, crate::features2d::DescriptorMatcherTrait, as_raw_mut_DescriptorMatcher } + + impl crate::features2d::BFMatcherTraitConst for BFMatcher { + #[inline] fn as_raw_BFMatcher(&self) -> *const c_void { self.as_raw() } + } + + impl crate::features2d::BFMatcherTrait for BFMatcher { + #[inline] fn as_raw_mut_BFMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { BFMatcher, crate::features2d::BFMatcherTraitConst, as_raw_BFMatcher, crate::features2d::BFMatcherTrait, as_raw_mut_BFMatcher } + + /// Class to compute an image descriptor using the *bag of visual words*. + /// + /// Such a computation consists of the following steps: + /// + /// 1. Compute descriptors for a given image and its keypoints set. + /// 2. Find the nearest visual words from the vocabulary for each keypoint descriptor. + /// 3. Compute the bag-of-words image descriptor as is a normalized histogram of vocabulary words + /// encountered in the image. The i-th bin of the histogram is a frequency of i-th word of the + /// vocabulary in the given image. + pub struct BOWImgDescriptorExtractor { + ptr: *mut c_void, + } + + opencv_type_boxed! { BOWImgDescriptorExtractor } + + impl Drop for BOWImgDescriptorExtractor { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_BOWImgDescriptorExtractor_delete(self.as_raw_mut_BOWImgDescriptorExtractor()) }; + } + } + + unsafe impl Send for BOWImgDescriptorExtractor {} + + impl BOWImgDescriptorExtractor { + /// The constructor. + /// + /// ## Parameters + /// * dextractor: Descriptor extractor that is used to compute descriptors for an input image and + /// its keypoints. + /// * dmatcher: Descriptor matcher that is used to find the nearest word of the trained vocabulary + /// for each keypoint descriptor of the image. + #[inline] + pub fn new_with_extractor(dextractor: &core::Ptr, dmatcher: &core::Ptr) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_BOWImgDescriptorExtractor_BOWImgDescriptorExtractor_const_PtrLFeature2DGR_const_PtrLDescriptorMatcherGR(dextractor.as_raw_PtrOfFeature2D(), dmatcher.as_raw_PtrOfDescriptorMatcher(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::features2d::BOWImgDescriptorExtractor::opencv_from_extern(ret) }; + Ok(ret) + } + + /// The constructor. + /// + /// ## Parameters + /// * dextractor: Descriptor extractor that is used to compute descriptors for an input image and + /// its keypoints. + /// * dmatcher: Descriptor matcher that is used to find the nearest word of the trained vocabulary + /// for each keypoint descriptor of the image. + /// + /// ## Overloaded parameters + #[inline] + pub fn new(dmatcher: &core::Ptr) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_BOWImgDescriptorExtractor_BOWImgDescriptorExtractor_const_PtrLDescriptorMatcherGR(dmatcher.as_raw_PtrOfDescriptorMatcher(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::features2d::BOWImgDescriptorExtractor::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::features2d::BOWImgDescriptorExtractor] + pub trait BOWImgDescriptorExtractorTraitConst { + fn as_raw_BOWImgDescriptorExtractor(&self) -> *const c_void; + + /// Returns the set vocabulary. + #[inline] + fn get_vocabulary(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_BOWImgDescriptorExtractor_getVocabulary_const(self.as_raw_BOWImgDescriptorExtractor(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Returns an image descriptor size if the vocabulary is set. Otherwise, it returns 0. + #[inline] + fn descriptor_size(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_BOWImgDescriptorExtractor_descriptorSize_const(self.as_raw_BOWImgDescriptorExtractor(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Returns an image descriptor type. + #[inline] fn descriptor_type(&self) -> Result { return_send!(via ocvrs_return); unsafe { sys::cv_BOWImgDescriptorExtractor_descriptorType_const(self.as_raw_BOWImgDescriptorExtractor(), ocvrs_return.as_mut_ptr()) }; @@ -1700,30 +1763,14 @@ pub mod features2d { } - /// Class to compute an image descriptor using the *bag of visual words*. - /// - /// Such a computation consists of the following steps: - /// - /// 1. Compute descriptors for a given image and its keypoints set. - /// 2. Find the nearest visual words from the vocabulary for each keypoint descriptor. - /// 3. Compute the bag-of-words image descriptor as is a normalized histogram of vocabulary words - /// encountered in the image. The i-th bin of the histogram is a frequency of i-th word of the - /// vocabulary in the given image. - pub struct BOWImgDescriptorExtractor { - ptr: *mut c_void, - } - - opencv_type_boxed! { BOWImgDescriptorExtractor } - - impl Drop for BOWImgDescriptorExtractor { + impl std::fmt::Debug for BOWImgDescriptorExtractor { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_BOWImgDescriptorExtractor_delete(self.as_raw_mut_BOWImgDescriptorExtractor()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BOWImgDescriptorExtractor") + .finish() } } - unsafe impl Send for BOWImgDescriptorExtractor {} - impl crate::features2d::BOWImgDescriptorExtractorTraitConst for BOWImgDescriptorExtractor { #[inline] fn as_raw_BOWImgDescriptorExtractor(&self) -> *const c_void { self.as_raw() } } @@ -1734,53 +1781,62 @@ pub mod features2d { boxed_ref! { BOWImgDescriptorExtractor, crate::features2d::BOWImgDescriptorExtractorTraitConst, as_raw_BOWImgDescriptorExtractor, crate::features2d::BOWImgDescriptorExtractorTrait, as_raw_mut_BOWImgDescriptorExtractor } - impl BOWImgDescriptorExtractor { + /// kmeans -based class to train visual vocabulary using the *bag of visual words* approach. : + pub struct BOWKMeansTrainer { + ptr: *mut c_void, + } + + opencv_type_boxed! { BOWKMeansTrainer } + + impl Drop for BOWKMeansTrainer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_BOWKMeansTrainer_delete(self.as_raw_mut_BOWKMeansTrainer()) }; + } + } + + unsafe impl Send for BOWKMeansTrainer {} + + impl BOWKMeansTrainer { /// The constructor. + /// ## See also + /// cv::kmeans /// - /// ## Parameters - /// * dextractor: Descriptor extractor that is used to compute descriptors for an input image and - /// its keypoints. - /// * dmatcher: Descriptor matcher that is used to find the nearest word of the trained vocabulary - /// for each keypoint descriptor of the image. + /// ## C++ default parameters + /// * termcrit: TermCriteria() + /// * attempts: 3 + /// * flags: KMEANS_PP_CENTERS #[inline] - pub fn new_with_extractor(dextractor: &core::Ptr, dmatcher: &core::Ptr) -> Result { + pub fn new(cluster_count: i32, termcrit: core::TermCriteria, attempts: i32, flags: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_BOWImgDescriptorExtractor_BOWImgDescriptorExtractor_const_PtrLFeature2DGR_const_PtrLDescriptorMatcherGR(dextractor.as_raw_PtrOfFeature2D(), dmatcher.as_raw_PtrOfDescriptorMatcher(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_BOWKMeansTrainer_BOWKMeansTrainer_int_const_TermCriteriaR_int_int(cluster_count, &termcrit, attempts, flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::features2d::BOWImgDescriptorExtractor::opencv_from_extern(ret) }; + let ret = unsafe { crate::features2d::BOWKMeansTrainer::opencv_from_extern(ret) }; Ok(ret) } /// The constructor. + /// ## See also + /// cv::kmeans /// - /// ## Parameters - /// * dextractor: Descriptor extractor that is used to compute descriptors for an input image and - /// its keypoints. - /// * dmatcher: Descriptor matcher that is used to find the nearest word of the trained vocabulary - /// for each keypoint descriptor of the image. - /// - /// ## Overloaded parameters + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * termcrit: TermCriteria() + /// * attempts: 3 + /// * flags: KMEANS_PP_CENTERS #[inline] - pub fn new(dmatcher: &core::Ptr) -> Result { + pub fn new_def(cluster_count: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_BOWImgDescriptorExtractor_BOWImgDescriptorExtractor_const_PtrLDescriptorMatcherGR(dmatcher.as_raw_PtrOfDescriptorMatcher(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_BOWKMeansTrainer_BOWKMeansTrainer_int(cluster_count, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::features2d::BOWImgDescriptorExtractor::opencv_from_extern(ret) }; + let ret = unsafe { crate::features2d::BOWKMeansTrainer::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for BOWImgDescriptorExtractor { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BOWImgDescriptorExtractor") - .finish() - } - } - /// Constant methods for [crate::features2d::BOWKMeansTrainer] pub trait BOWKMeansTrainerTraitConst: crate::features2d::BOWTrainerTraitConst { fn as_raw_BOWKMeansTrainer(&self) -> *const c_void; @@ -1813,21 +1869,15 @@ pub mod features2d { } - /// kmeans -based class to train visual vocabulary using the *bag of visual words* approach. : - pub struct BOWKMeansTrainer { - ptr: *mut c_void, - } - - opencv_type_boxed! { BOWKMeansTrainer } - - impl Drop for BOWKMeansTrainer { + impl std::fmt::Debug for BOWKMeansTrainer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_BOWKMeansTrainer_delete(self.as_raw_mut_BOWKMeansTrainer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BOWKMeansTrainer") + .finish() } } - unsafe impl Send for BOWKMeansTrainer {} + boxed_cast_base! { BOWKMeansTrainer, crate::features2d::BOWTrainer, cv_BOWKMeansTrainer_to_BOWTrainer } impl crate::features2d::BOWTrainerTraitConst for BOWKMeansTrainer { #[inline] fn as_raw_BOWTrainer(&self) -> *const c_void { self.as_raw() } @@ -1849,56 +1899,25 @@ pub mod features2d { boxed_ref! { BOWKMeansTrainer, crate::features2d::BOWKMeansTrainerTraitConst, as_raw_BOWKMeansTrainer, crate::features2d::BOWKMeansTrainerTrait, as_raw_mut_BOWKMeansTrainer } - impl BOWKMeansTrainer { - /// The constructor. - /// ## See also - /// cv::kmeans - /// - /// ## C++ default parameters - /// * termcrit: TermCriteria() - /// * attempts: 3 - /// * flags: KMEANS_PP_CENTERS - #[inline] - pub fn new(cluster_count: i32, termcrit: core::TermCriteria, attempts: i32, flags: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_BOWKMeansTrainer_BOWKMeansTrainer_int_const_TermCriteriaR_int_int(cluster_count, &termcrit, attempts, flags, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::features2d::BOWKMeansTrainer::opencv_from_extern(ret) }; - Ok(ret) - } - - /// The constructor. - /// ## See also - /// cv::kmeans - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * termcrit: TermCriteria() - /// * attempts: 3 - /// * flags: KMEANS_PP_CENTERS - #[inline] - pub fn new_def(cluster_count: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_BOWKMeansTrainer_BOWKMeansTrainer_int(cluster_count, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::features2d::BOWKMeansTrainer::opencv_from_extern(ret) }; - Ok(ret) - } - + /// Abstract base class for training the *bag of visual words* vocabulary from a set of descriptors. + /// + /// For details, see, for example, *Visual Categorization with Bags of Keypoints* by Gabriella Csurka, + /// Christopher R. Dance, Lixin Fan, Jutta Willamowski, Cedric Bray, 2004. : + pub struct BOWTrainer { + ptr: *mut c_void, } - boxed_cast_base! { BOWKMeansTrainer, crate::features2d::BOWTrainer, cv_BOWKMeansTrainer_to_BOWTrainer } + opencv_type_boxed! { BOWTrainer } - impl std::fmt::Debug for BOWKMeansTrainer { + impl Drop for BOWTrainer { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BOWKMeansTrainer") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_BOWTrainer_delete(self.as_raw_mut_BOWTrainer()) }; } } + unsafe impl Send for BOWTrainer {} + /// Constant methods for [crate::features2d::BOWTrainer] pub trait BOWTrainerTraitConst { fn as_raw_BOWTrainer(&self) -> *const c_void; @@ -1997,24 +2016,15 @@ pub mod features2d { } - /// Abstract base class for training the *bag of visual words* vocabulary from a set of descriptors. - /// - /// For details, see, for example, *Visual Categorization with Bags of Keypoints* by Gabriella Csurka, - /// Christopher R. Dance, Lixin Fan, Jutta Willamowski, Cedric Bray, 2004. : - pub struct BOWTrainer { - ptr: *mut c_void, - } - - opencv_type_boxed! { BOWTrainer } - - impl Drop for BOWTrainer { + impl std::fmt::Debug for BOWTrainer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_BOWTrainer_delete(self.as_raw_mut_BOWTrainer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BOWTrainer") + .finish() } } - unsafe impl Send for BOWTrainer {} + boxed_cast_descendant! { BOWTrainer, crate::features2d::BOWKMeansTrainer, cv_BOWTrainer_to_BOWKMeansTrainer } impl crate::features2d::BOWTrainerTraitConst for BOWTrainer { #[inline] fn as_raw_BOWTrainer(&self) -> *const c_void { self.as_raw() } @@ -2026,105 +2036,6 @@ pub mod features2d { boxed_ref! { BOWTrainer, crate::features2d::BOWTrainerTraitConst, as_raw_BOWTrainer, crate::features2d::BOWTrainerTrait, as_raw_mut_BOWTrainer } - impl BOWTrainer { - } - - boxed_cast_descendant! { BOWTrainer, crate::features2d::BOWKMeansTrainer, cv_BOWTrainer_to_BOWKMeansTrainer } - - impl std::fmt::Debug for BOWTrainer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BOWTrainer") - .finish() - } - } - - /// Constant methods for [crate::features2d::BRISK] - pub trait BRISKTraitConst: crate::features2d::Feature2DTraitConst { - fn as_raw_BRISK(&self) -> *const c_void; - - #[inline] - fn get_default_name(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_BRISK_getDefaultName_const(self.as_raw_BRISK(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { String::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - fn get_threshold(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_BRISK_getThreshold_const(self.as_raw_BRISK(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_octaves(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_BRISK_getOctaves_const(self.as_raw_BRISK(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_pattern_scale(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_BRISK_getPatternScale_const(self.as_raw_BRISK(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - /// Mutable methods for [crate::features2d::BRISK] - pub trait BRISKTrait: crate::features2d::BRISKTraitConst + crate::features2d::Feature2DTrait { - fn as_raw_mut_BRISK(&mut self) -> *mut c_void; - - /// Set detection threshold. - /// ## Parameters - /// * threshold: AGAST detection threshold score. - #[inline] - fn set_threshold(&mut self, threshold: i32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_BRISK_setThreshold_int(self.as_raw_mut_BRISK(), threshold, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Set detection octaves. - /// ## Parameters - /// * octaves: detection octaves. Use 0 to do single scale. - #[inline] - fn set_octaves(&mut self, octaves: i32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_BRISK_setOctaves_int(self.as_raw_mut_BRISK(), octaves, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Set detection patternScale. - /// ## Parameters - /// * patternScale: apply this scale to the pattern used for sampling the neighbourhood of a - /// keypoint. - #[inline] - fn set_pattern_scale(&mut self, pattern_scale: f32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_BRISK_setPatternScale_float(self.as_raw_mut_BRISK(), pattern_scale, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - /// Class implementing the BRISK keypoint detector and descriptor extractor, described in [LCS11](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_LCS11) . pub struct BRISK { ptr: *mut c_void, @@ -2141,36 +2052,6 @@ pub mod features2d { unsafe impl Send for BRISK {} - impl core::AlgorithmTraitConst for BRISK { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for BRISK { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { BRISK, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::features2d::Feature2DTraitConst for BRISK { - #[inline] fn as_raw_Feature2D(&self) -> *const c_void { self.as_raw() } - } - - impl crate::features2d::Feature2DTrait for BRISK { - #[inline] fn as_raw_mut_Feature2D(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { BRISK, crate::features2d::Feature2DTraitConst, as_raw_Feature2D, crate::features2d::Feature2DTrait, as_raw_mut_Feature2D } - - impl crate::features2d::BRISKTraitConst for BRISK { - #[inline] fn as_raw_BRISK(&self) -> *const c_void { self.as_raw() } - } - - impl crate::features2d::BRISKTrait for BRISK { - #[inline] fn as_raw_mut_BRISK(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { BRISK, crate::features2d::BRISKTraitConst, as_raw_BRISK, crate::features2d::BRISKTrait, as_raw_mut_BRISK } - impl BRISK { /// The BRISK constructor /// @@ -2333,63 +2214,233 @@ pub mod features2d { } - boxed_cast_base! { BRISK, core::Algorithm, cv_BRISK_to_Algorithm } - - boxed_cast_base! { BRISK, crate::features2d::Feature2D, cv_BRISK_to_Feature2D } + /// Constant methods for [crate::features2d::BRISK] + pub trait BRISKTraitConst: crate::features2d::Feature2DTraitConst { + fn as_raw_BRISK(&self) -> *const c_void; - impl std::fmt::Debug for BRISK { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BRISK") - .finish() + fn get_default_name(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_BRISK_getDefaultName_const(self.as_raw_BRISK(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { String::opencv_from_extern(ret) }; + Ok(ret) } - } - - /// Constant methods for [crate::features2d::DescriptorMatcher] - pub trait DescriptorMatcherTraitConst: core::AlgorithmTraitConst { - fn as_raw_DescriptorMatcher(&self) -> *const c_void; - /// Returns a constant link to the train descriptor collection trainDescCollection . #[inline] - fn get_train_descriptors(&self) -> Result> { + fn get_threshold(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_DescriptorMatcher_getTrainDescriptors_const(self.as_raw_DescriptorMatcher(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_BRISK_getThreshold_const(self.as_raw_BRISK(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Vector::::opencv_from_extern(ret) }; Ok(ret) } - /// Returns true if there are no train descriptors in the both collections. #[inline] - fn empty(&self) -> Result { + fn get_octaves(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_DescriptorMatcher_empty_const(self.as_raw_DescriptorMatcher(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_BRISK_getOctaves_const(self.as_raw_BRISK(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// Returns true if the descriptor matcher supports masking permissible matches. #[inline] - fn is_mask_supported(&self) -> Result { + fn get_pattern_scale(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_DescriptorMatcher_isMaskSupported_const(self.as_raw_DescriptorMatcher(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_BRISK_getPatternScale_const(self.as_raw_BRISK(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// Finds the best match for each descriptor from a query set. - /// + } + + /// Mutable methods for [crate::features2d::BRISK] + pub trait BRISKTrait: crate::features2d::BRISKTraitConst + crate::features2d::Feature2DTrait { + fn as_raw_mut_BRISK(&mut self) -> *mut c_void; + + /// Set detection threshold. /// ## Parameters - /// * queryDescriptors: Query set of descriptors. - /// * trainDescriptors: Train set of descriptors. This set is not added to the train descriptors - /// collection stored in the class object. - /// * matches: Matches. If a query descriptor is masked out in mask , no match is added for this - /// descriptor. So, matches size may be smaller than the query descriptors count. - /// * mask: Mask specifying permissible matches between an input query and train matrices of - /// descriptors. + /// * threshold: AGAST detection threshold score. + #[inline] + fn set_threshold(&mut self, threshold: i32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_BRISK_setThreshold_int(self.as_raw_mut_BRISK(), threshold, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Set detection octaves. + /// ## Parameters + /// * octaves: detection octaves. Use 0 to do single scale. + #[inline] + fn set_octaves(&mut self, octaves: i32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_BRISK_setOctaves_int(self.as_raw_mut_BRISK(), octaves, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Set detection patternScale. + /// ## Parameters + /// * patternScale: apply this scale to the pattern used for sampling the neighbourhood of a + /// keypoint. + #[inline] + fn set_pattern_scale(&mut self, pattern_scale: f32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_BRISK_setPatternScale_float(self.as_raw_mut_BRISK(), pattern_scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + impl std::fmt::Debug for BRISK { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BRISK") + .finish() + } + } + + boxed_cast_base! { BRISK, core::Algorithm, cv_BRISK_to_Algorithm } + + boxed_cast_base! { BRISK, crate::features2d::Feature2D, cv_BRISK_to_Feature2D } + + impl core::AlgorithmTraitConst for BRISK { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } + } + + impl core::AlgorithmTrait for BRISK { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { BRISK, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + + impl crate::features2d::Feature2DTraitConst for BRISK { + #[inline] fn as_raw_Feature2D(&self) -> *const c_void { self.as_raw() } + } + + impl crate::features2d::Feature2DTrait for BRISK { + #[inline] fn as_raw_mut_Feature2D(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { BRISK, crate::features2d::Feature2DTraitConst, as_raw_Feature2D, crate::features2d::Feature2DTrait, as_raw_mut_Feature2D } + + impl crate::features2d::BRISKTraitConst for BRISK { + #[inline] fn as_raw_BRISK(&self) -> *const c_void { self.as_raw() } + } + + impl crate::features2d::BRISKTrait for BRISK { + #[inline] fn as_raw_mut_BRISK(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { BRISK, crate::features2d::BRISKTraitConst, as_raw_BRISK, crate::features2d::BRISKTrait, as_raw_mut_BRISK } + + /// Abstract base class for matching keypoint descriptors. + /// + /// It has two groups of match methods: for matching descriptors of an image with another image or with + /// an image set. + pub struct DescriptorMatcher { + ptr: *mut c_void, + } + + opencv_type_boxed! { DescriptorMatcher } + + impl Drop for DescriptorMatcher { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_DescriptorMatcher_delete(self.as_raw_mut_DescriptorMatcher()) }; + } + } + + unsafe impl Send for DescriptorMatcher {} + + impl DescriptorMatcher { + /// Creates a descriptor matcher of a given type with the default parameters (using default + /// constructor). + /// + /// ## Parameters + /// * descriptorMatcherType: Descriptor matcher type. Now the following matcher types are + /// supported: + /// * `BruteForce` (it uses L2 ) + /// * `BruteForce-L1` + /// * `BruteForce-Hamming` + /// * `BruteForce-Hamming(2)` + /// * `FlannBased` + #[inline] + pub fn create(descriptor_matcher_type: &str) -> Result> { + extern_container_arg!(descriptor_matcher_type); + return_send!(via ocvrs_return); + unsafe { sys::cv_DescriptorMatcher_create_const_StringR(descriptor_matcher_type.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn create_with_matcher_type(matcher_type: crate::features2d::DescriptorMatcher_MatcherType) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_DescriptorMatcher_create_const_MatcherTypeR(matcher_type, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::features2d::DescriptorMatcher] + pub trait DescriptorMatcherTraitConst: core::AlgorithmTraitConst { + fn as_raw_DescriptorMatcher(&self) -> *const c_void; + + /// Returns a constant link to the train descriptor collection trainDescCollection . + #[inline] + fn get_train_descriptors(&self) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_DescriptorMatcher_getTrainDescriptors_const(self.as_raw_DescriptorMatcher(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Vector::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Returns true if there are no train descriptors in the both collections. + #[inline] + fn empty(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_DescriptorMatcher_empty_const(self.as_raw_DescriptorMatcher(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Returns true if the descriptor matcher supports masking permissible matches. + #[inline] + fn is_mask_supported(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_DescriptorMatcher_isMaskSupported_const(self.as_raw_DescriptorMatcher(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Finds the best match for each descriptor from a query set. + /// + /// ## Parameters + /// * queryDescriptors: Query set of descriptors. + /// * trainDescriptors: Train set of descriptors. This set is not added to the train descriptors + /// collection stored in the class object. + /// * matches: Matches. If a query descriptor is masked out in mask , no match is added for this + /// descriptor. So, matches size may be smaller than the query descriptors count. + /// * mask: Mask specifying permissible matches between an input query and train matrices of + /// descriptors. /// /// In the first variant of this method, the train descriptors are passed as an input argument. In the /// second variant of the method, train descriptors collection that was set by DescriptorMatcher::add is @@ -2933,24 +2984,19 @@ pub mod features2d { } - /// Abstract base class for matching keypoint descriptors. - /// - /// It has two groups of match methods: for matching descriptors of an image with another image or with - /// an image set. - pub struct DescriptorMatcher { - ptr: *mut c_void, - } - - opencv_type_boxed! { DescriptorMatcher } - - impl Drop for DescriptorMatcher { + impl std::fmt::Debug for DescriptorMatcher { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_DescriptorMatcher_delete(self.as_raw_mut_DescriptorMatcher()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DescriptorMatcher") + .finish() } } - unsafe impl Send for DescriptorMatcher {} + boxed_cast_base! { DescriptorMatcher, core::Algorithm, cv_DescriptorMatcher_to_Algorithm } + + boxed_cast_descendant! { DescriptorMatcher, crate::features2d::BFMatcher, cv_DescriptorMatcher_to_BFMatcher } + + boxed_cast_descendant! { DescriptorMatcher, crate::features2d::FlannBasedMatcher, cv_DescriptorMatcher_to_FlannBasedMatcher } impl core::AlgorithmTraitConst for DescriptorMatcher { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2972,58 +3018,57 @@ pub mod features2d { boxed_ref! { DescriptorMatcher, crate::features2d::DescriptorMatcherTraitConst, as_raw_DescriptorMatcher, crate::features2d::DescriptorMatcherTrait, as_raw_mut_DescriptorMatcher } - impl DescriptorMatcher { - /// Creates a descriptor matcher of a given type with the default parameters (using default - /// constructor). - /// - /// ## Parameters - /// * descriptorMatcherType: Descriptor matcher type. Now the following matcher types are - /// supported: - /// * `BruteForce` (it uses L2 ) - /// * `BruteForce-L1` - /// * `BruteForce-Hamming` - /// * `BruteForce-Hamming(2)` - /// * `FlannBased` + /// Wrapping class for feature detection using the FAST method. : + pub struct FastFeatureDetector { + ptr: *mut c_void, + } + + opencv_type_boxed! { FastFeatureDetector } + + impl Drop for FastFeatureDetector { #[inline] - pub fn create(descriptor_matcher_type: &str) -> Result> { - extern_container_arg!(descriptor_matcher_type); + fn drop(&mut self) { + unsafe { sys::cv_FastFeatureDetector_delete(self.as_raw_mut_FastFeatureDetector()) }; + } + } + + unsafe impl Send for FastFeatureDetector {} + + impl FastFeatureDetector { + /// ## C++ default parameters + /// * threshold: 10 + /// * nonmax_suppression: true + /// * typ: FastFeatureDetector::TYPE_9_16 + #[inline] + pub fn create(threshold: i32, nonmax_suppression: bool, typ: crate::features2d::FastFeatureDetector_DetectorType) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_DescriptorMatcher_create_const_StringR(descriptor_matcher_type.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_FastFeatureDetector_create_int_bool_DetectorType(threshold, nonmax_suppression, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [FastFeatureDetector::create] function uses the following default values for its arguments: + /// * threshold: 10 + /// * nonmax_suppression: true + /// * typ: FastFeatureDetector::TYPE_9_16 #[inline] - pub fn create_with_matcher_type(matcher_type: crate::features2d::DescriptorMatcher_MatcherType) -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_DescriptorMatcher_create_const_MatcherTypeR(matcher_type, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_FastFeatureDetector_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_descendant! { DescriptorMatcher, crate::features2d::BFMatcher, cv_DescriptorMatcher_to_BFMatcher } - - boxed_cast_descendant! { DescriptorMatcher, crate::features2d::FlannBasedMatcher, cv_DescriptorMatcher_to_FlannBasedMatcher } - - boxed_cast_base! { DescriptorMatcher, core::Algorithm, cv_DescriptorMatcher_to_Algorithm } - - impl std::fmt::Debug for DescriptorMatcher { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DescriptorMatcher") - .finish() - } - } - - /// Constant methods for [crate::features2d::FastFeatureDetector] - pub trait FastFeatureDetectorTraitConst: crate::features2d::Feature2DTraitConst { - fn as_raw_FastFeatureDetector(&self) -> *const c_void; + /// Constant methods for [crate::features2d::FastFeatureDetector] + pub trait FastFeatureDetectorTraitConst: crate::features2d::Feature2DTraitConst { + fn as_raw_FastFeatureDetector(&self) -> *const c_void; #[inline] fn get_threshold(&self) -> Result { @@ -3097,21 +3142,17 @@ pub mod features2d { } - /// Wrapping class for feature detection using the FAST method. : - pub struct FastFeatureDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { FastFeatureDetector } - - impl Drop for FastFeatureDetector { + impl std::fmt::Debug for FastFeatureDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_FastFeatureDetector_delete(self.as_raw_mut_FastFeatureDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FastFeatureDetector") + .finish() } } - unsafe impl Send for FastFeatureDetector {} + boxed_cast_base! { FastFeatureDetector, core::Algorithm, cv_FastFeatureDetector_to_Algorithm } + + boxed_cast_base! { FastFeatureDetector, crate::features2d::Feature2D, cv_FastFeatureDetector_to_Feature2D } impl core::AlgorithmTraitConst for FastFeatureDetector { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3143,48 +3184,30 @@ pub mod features2d { boxed_ref! { FastFeatureDetector, crate::features2d::FastFeatureDetectorTraitConst, as_raw_FastFeatureDetector, crate::features2d::FastFeatureDetectorTrait, as_raw_mut_FastFeatureDetector } - impl FastFeatureDetector { - /// ## C++ default parameters - /// * threshold: 10 - /// * nonmax_suppression: true - /// * typ: FastFeatureDetector::TYPE_9_16 - #[inline] - pub fn create(threshold: i32, nonmax_suppression: bool, typ: crate::features2d::FastFeatureDetector_DetectorType) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_FastFeatureDetector_create_int_bool_DetectorType(threshold, nonmax_suppression, typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } + pub struct Feature2D { + ptr: *mut c_void, + } - /// ## Note - /// This alternative version of [FastFeatureDetector::create] function uses the following default values for its arguments: - /// * threshold: 10 - /// * nonmax_suppression: true - /// * typ: FastFeatureDetector::TYPE_9_16 + opencv_type_boxed! { Feature2D } + + impl Drop for Feature2D { #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_FastFeatureDetector_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_Feature2D_delete(self.as_raw_mut_Feature2D()) }; } - } - boxed_cast_base! { FastFeatureDetector, core::Algorithm, cv_FastFeatureDetector_to_Algorithm } - - boxed_cast_base! { FastFeatureDetector, crate::features2d::Feature2D, cv_FastFeatureDetector_to_Feature2D } + unsafe impl Send for Feature2D {} - impl std::fmt::Debug for FastFeatureDetector { + impl Feature2D { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FastFeatureDetector") - .finish() + pub fn default() -> crate::features2d::Feature2D { + let ret = unsafe { sys::cv_Feature2D_defaultNew_const() }; + let ret = unsafe { crate::features2d::Feature2D::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::features2d::Feature2D] @@ -3487,20 +3510,45 @@ pub mod features2d { } - pub struct Feature2D { - ptr: *mut c_void, + impl Default for Feature2D { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Feature2D } - - impl Drop for Feature2D { + impl std::fmt::Debug for Feature2D { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_Feature2D_delete(self.as_raw_mut_Feature2D()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Feature2D") + .finish() } } - unsafe impl Send for Feature2D {} + boxed_cast_base! { Feature2D, core::Algorithm, cv_Feature2D_to_Algorithm } + + boxed_cast_descendant! { Feature2D, crate::features2d::AKAZE, cv_Feature2D_to_AKAZE } + + boxed_cast_descendant! { Feature2D, crate::features2d::AffineFeature, cv_Feature2D_to_AffineFeature } + + boxed_cast_descendant! { Feature2D, crate::features2d::AgastFeatureDetector, cv_Feature2D_to_AgastFeatureDetector } + + boxed_cast_descendant! { Feature2D, crate::features2d::BRISK, cv_Feature2D_to_BRISK } + + boxed_cast_descendant! { Feature2D, crate::features2d::FastFeatureDetector, cv_Feature2D_to_FastFeatureDetector } + + boxed_cast_descendant! { Feature2D, crate::features2d::GFTTDetector, cv_Feature2D_to_GFTTDetector } + + boxed_cast_descendant! { Feature2D, crate::features2d::KAZE, cv_Feature2D_to_KAZE } + + boxed_cast_descendant! { Feature2D, crate::features2d::MSER, cv_Feature2D_to_MSER } + + boxed_cast_descendant! { Feature2D, crate::features2d::ORB, cv_Feature2D_to_ORB } + + boxed_cast_descendant! { Feature2D, crate::features2d::SIFT, cv_Feature2D_to_SIFT } + + boxed_cast_descendant! { Feature2D, crate::features2d::SimpleBlobDetector, cv_Feature2D_to_SimpleBlobDetector } impl core::AlgorithmTraitConst for Feature2D { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3522,53 +3570,65 @@ pub mod features2d { boxed_ref! { Feature2D, crate::features2d::Feature2DTraitConst, as_raw_Feature2D, crate::features2d::Feature2DTrait, as_raw_mut_Feature2D } - impl Feature2D { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_Feature2D_defaultNew_const()) } - } - + /// Flann-based descriptor matcher. + /// + /// This matcher trains cv::flann::Index on a train descriptor collection and calls its nearest search + /// methods to find the best matches. So, this matcher may be faster when matching a large train + /// collection than the brute force matcher. FlannBasedMatcher does not support masking permissible + /// matches of descriptor sets because flann::Index does not support this. : + pub struct FlannBasedMatcher { + ptr: *mut c_void, } - boxed_cast_descendant! { Feature2D, crate::features2d::AKAZE, cv_Feature2D_to_AKAZE } - - boxed_cast_descendant! { Feature2D, crate::features2d::AffineFeature, cv_Feature2D_to_AffineFeature } - - boxed_cast_descendant! { Feature2D, crate::features2d::AgastFeatureDetector, cv_Feature2D_to_AgastFeatureDetector } - - boxed_cast_descendant! { Feature2D, crate::features2d::BRISK, cv_Feature2D_to_BRISK } - - boxed_cast_descendant! { Feature2D, crate::features2d::FastFeatureDetector, cv_Feature2D_to_FastFeatureDetector } - - boxed_cast_descendant! { Feature2D, crate::features2d::GFTTDetector, cv_Feature2D_to_GFTTDetector } - - boxed_cast_descendant! { Feature2D, crate::features2d::KAZE, cv_Feature2D_to_KAZE } - - boxed_cast_descendant! { Feature2D, crate::features2d::MSER, cv_Feature2D_to_MSER } - - boxed_cast_descendant! { Feature2D, crate::features2d::ORB, cv_Feature2D_to_ORB } + opencv_type_boxed! { FlannBasedMatcher } - boxed_cast_descendant! { Feature2D, crate::features2d::SIFT, cv_Feature2D_to_SIFT } + impl Drop for FlannBasedMatcher { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_FlannBasedMatcher_delete(self.as_raw_mut_FlannBasedMatcher()) }; + } + } - boxed_cast_descendant! { Feature2D, crate::features2d::SimpleBlobDetector, cv_Feature2D_to_SimpleBlobDetector } + unsafe impl Send for FlannBasedMatcher {} - boxed_cast_base! { Feature2D, core::Algorithm, cv_Feature2D_to_Algorithm } + impl FlannBasedMatcher { + /// ## C++ default parameters + /// * index_params: makePtr() + /// * search_params: makePtr() + #[inline] + pub fn new(index_params: &core::Ptr, search_params: &core::Ptr) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_FlannBasedMatcher_FlannBasedMatcher_const_PtrLIndexParamsGR_const_PtrLSearchParamsGR(index_params.as_raw_PtrOfIndexParams(), search_params.as_raw_PtrOfSearchParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::features2d::FlannBasedMatcher::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for Feature2D { + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * index_params: makePtr() + /// * search_params: makePtr() #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Feature2D") - .finish() + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_FlannBasedMatcher_FlannBasedMatcher(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::features2d::FlannBasedMatcher::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for Feature2D { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_FlannBasedMatcher_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::features2d::FlannBasedMatcher] @@ -3664,26 +3724,17 @@ pub mod features2d { } - /// Flann-based descriptor matcher. - /// - /// This matcher trains cv::flann::Index on a train descriptor collection and calls its nearest search - /// methods to find the best matches. So, this matcher may be faster when matching a large train - /// collection than the brute force matcher. FlannBasedMatcher does not support masking permissible - /// matches of descriptor sets because flann::Index does not support this. : - pub struct FlannBasedMatcher { - ptr: *mut c_void, - } - - opencv_type_boxed! { FlannBasedMatcher } - - impl Drop for FlannBasedMatcher { + impl std::fmt::Debug for FlannBasedMatcher { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_FlannBasedMatcher_delete(self.as_raw_mut_FlannBasedMatcher()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FlannBasedMatcher") + .finish() } } - unsafe impl Send for FlannBasedMatcher {} + boxed_cast_base! { FlannBasedMatcher, core::Algorithm, cv_FlannBasedMatcher_to_Algorithm } + + boxed_cast_base! { FlannBasedMatcher, crate::features2d::DescriptorMatcher, cv_FlannBasedMatcher_to_DescriptorMatcher } impl core::AlgorithmTraitConst for FlannBasedMatcher { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3715,56 +3766,85 @@ pub mod features2d { boxed_ref! { FlannBasedMatcher, crate::features2d::FlannBasedMatcherTraitConst, as_raw_FlannBasedMatcher, crate::features2d::FlannBasedMatcherTrait, as_raw_mut_FlannBasedMatcher } - impl FlannBasedMatcher { - /// ## C++ default parameters - /// * index_params: makePtr() - /// * search_params: makePtr() + /// Wrapping class for feature detection using the goodFeaturesToTrack function. : + pub struct GFTTDetector { + ptr: *mut c_void, + } + + opencv_type_boxed! { GFTTDetector } + + impl Drop for GFTTDetector { #[inline] - pub fn new(index_params: &core::Ptr, search_params: &core::Ptr) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_FlannBasedMatcher_FlannBasedMatcher_const_PtrLIndexParamsGR_const_PtrLSearchParamsGR(index_params.as_raw_PtrOfIndexParams(), search_params.as_raw_PtrOfSearchParams(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::features2d::FlannBasedMatcher::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_GFTTDetector_delete(self.as_raw_mut_GFTTDetector()) }; } + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * index_params: makePtr() - /// * search_params: makePtr() - #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_FlannBasedMatcher_FlannBasedMatcher(ocvrs_return.as_mut_ptr()) }; + unsafe impl Send for GFTTDetector {} + + impl GFTTDetector { + /// ## C++ default parameters + /// * max_corners: 1000 + /// * quality_level: 0.01 + /// * min_distance: 1 + /// * block_size: 3 + /// * use_harris_detector: false + /// * k: 0.04 + #[inline] + pub fn create(max_corners: i32, quality_level: f64, min_distance: f64, block_size: i32, use_harris_detector: bool, k: f64) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_GFTTDetector_create_int_double_double_int_bool_double(max_corners, quality_level, min_distance, block_size, use_harris_detector, k, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::features2d::FlannBasedMatcher::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [GFTTDetector::create] function uses the following default values for its arguments: + /// * max_corners: 1000 + /// * quality_level: 0.01 + /// * min_distance: 1 + /// * block_size: 3 + /// * use_harris_detector: false + /// * k: 0.04 #[inline] - pub fn create() -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_FlannBasedMatcher_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_GFTTDetector_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { FlannBasedMatcher, core::Algorithm, cv_FlannBasedMatcher_to_Algorithm } - - boxed_cast_base! { FlannBasedMatcher, crate::features2d::DescriptorMatcher, cv_FlannBasedMatcher_to_DescriptorMatcher } + /// ## C++ default parameters + /// * use_harris_detector: false + /// * k: 0.04 + #[inline] + pub fn create_with_gradient(max_corners: i32, quality_level: f64, min_distance: f64, block_size: i32, gradiant_size: i32, use_harris_detector: bool, k: f64) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_GFTTDetector_create_int_double_double_int_int_bool_double(max_corners, quality_level, min_distance, block_size, gradiant_size, use_harris_detector, k, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for FlannBasedMatcher { + /// ## Note + /// This alternative version of [GFTTDetector::create_with_gradient] function uses the following default values for its arguments: + /// * use_harris_detector: false + /// * k: 0.04 #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FlannBasedMatcher") - .finish() + pub fn create_with_gradient_def(max_corners: i32, quality_level: f64, min_distance: f64, block_size: i32, gradiant_size: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_GFTTDetector_create_int_double_double_int_int(max_corners, quality_level, min_distance, block_size, gradiant_size, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::features2d::GFTTDetector] @@ -3915,21 +3995,17 @@ pub mod features2d { } - /// Wrapping class for feature detection using the goodFeaturesToTrack function. : - pub struct GFTTDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { GFTTDetector } - - impl Drop for GFTTDetector { + impl std::fmt::Debug for GFTTDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GFTTDetector_delete(self.as_raw_mut_GFTTDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GFTTDetector") + .finish() } } - unsafe impl Send for GFTTDetector {} + boxed_cast_base! { GFTTDetector, core::Algorithm, cv_GFTTDetector_to_Algorithm } + + boxed_cast_base! { GFTTDetector, crate::features2d::Feature2D, cv_GFTTDetector_to_Feature2D } impl core::AlgorithmTraitConst for GFTTDetector { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3961,83 +4037,87 @@ pub mod features2d { boxed_ref! { GFTTDetector, crate::features2d::GFTTDetectorTraitConst, as_raw_GFTTDetector, crate::features2d::GFTTDetectorTrait, as_raw_mut_GFTTDetector } - impl GFTTDetector { - /// ## C++ default parameters - /// * max_corners: 1000 - /// * quality_level: 0.01 - /// * min_distance: 1 - /// * block_size: 3 - /// * use_harris_detector: false - /// * k: 0.04 - #[inline] - pub fn create(max_corners: i32, quality_level: f64, min_distance: f64, block_size: i32, use_harris_detector: bool, k: f64) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_GFTTDetector_create_int_double_double_int_bool_double(max_corners, quality_level, min_distance, block_size, use_harris_detector, k, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } + /// Class implementing the KAZE keypoint detector and descriptor extractor, described in [ABD12](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_ABD12) . + /// + /// + /// Note: AKAZE descriptor can only be used with KAZE or AKAZE keypoints .. [ABD12] KAZE Features. Pablo + /// F. Alcantarilla, Adrien Bartoli and Andrew J. Davison. In European Conference on Computer Vision + /// (ECCV), Fiorenze, Italy, October 2012. + pub struct KAZE { + ptr: *mut c_void, + } - /// ## Note - /// This alternative version of [GFTTDetector::create] function uses the following default values for its arguments: - /// * max_corners: 1000 - /// * quality_level: 0.01 - /// * min_distance: 1 - /// * block_size: 3 - /// * use_harris_detector: false - /// * k: 0.04 + opencv_type_boxed! { KAZE } + + impl Drop for KAZE { #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_GFTTDetector_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_KAZE_delete(self.as_raw_mut_KAZE()) }; } + } + + unsafe impl Send for KAZE {} + impl KAZE { + /// The KAZE constructor + /// + /// ## Parameters + /// * extended: Set to enable extraction of extended (128-byte) descriptor. + /// * upright: Set to enable use of upright descriptors (non rotation-invariant). + /// * threshold: Detector response threshold to accept point + /// * nOctaves: Maximum octave evolution of the image + /// * nOctaveLayers: Default number of sublevels per scale level + /// * diffusivity: Diffusivity type. DIFF_PM_G1, DIFF_PM_G2, DIFF_WEICKERT or + /// DIFF_CHARBONNIER + /// /// ## C++ default parameters - /// * use_harris_detector: false - /// * k: 0.04 + /// * extended: false + /// * upright: false + /// * threshold: 0.001f + /// * n_octaves: 4 + /// * n_octave_layers: 4 + /// * diffusivity: KAZE::DIFF_PM_G2 #[inline] - pub fn create_with_gradient(max_corners: i32, quality_level: f64, min_distance: f64, block_size: i32, gradiant_size: i32, use_harris_detector: bool, k: f64) -> Result> { + pub fn create(extended: bool, upright: bool, threshold: f32, n_octaves: i32, n_octave_layers: i32, diffusivity: crate::features2d::KAZE_DiffusivityType) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_GFTTDetector_create_int_double_double_int_int_bool_double(max_corners, quality_level, min_distance, block_size, gradiant_size, use_harris_detector, k, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_KAZE_create_bool_bool_float_int_int_DiffusivityType(extended, upright, threshold, n_octaves, n_octave_layers, diffusivity, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } + /// The KAZE constructor + /// + /// ## Parameters + /// * extended: Set to enable extraction of extended (128-byte) descriptor. + /// * upright: Set to enable use of upright descriptors (non rotation-invariant). + /// * threshold: Detector response threshold to accept point + /// * nOctaves: Maximum octave evolution of the image + /// * nOctaveLayers: Default number of sublevels per scale level + /// * diffusivity: Diffusivity type. DIFF_PM_G1, DIFF_PM_G2, DIFF_WEICKERT or + /// DIFF_CHARBONNIER + /// /// ## Note - /// This alternative version of [GFTTDetector::create_with_gradient] function uses the following default values for its arguments: - /// * use_harris_detector: false - /// * k: 0.04 + /// This alternative version of [KAZE::create] function uses the following default values for its arguments: + /// * extended: false + /// * upright: false + /// * threshold: 0.001f + /// * n_octaves: 4 + /// * n_octave_layers: 4 + /// * diffusivity: KAZE::DIFF_PM_G2 #[inline] - pub fn create_with_gradient_def(max_corners: i32, quality_level: f64, min_distance: f64, block_size: i32, gradiant_size: i32) -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_GFTTDetector_create_int_double_double_int_int(max_corners, quality_level, min_distance, block_size, gradiant_size, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_KAZE_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { GFTTDetector, core::Algorithm, cv_GFTTDetector_to_Algorithm } - - boxed_cast_base! { GFTTDetector, crate::features2d::Feature2D, cv_GFTTDetector_to_Feature2D } - - impl std::fmt::Debug for GFTTDetector { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GFTTDetector") - .finish() - } - } - /// Constant methods for [crate::features2d::KAZE] pub trait KAZETraitConst: crate::features2d::Feature2DTraitConst { fn as_raw_KAZE(&self) -> *const c_void; @@ -4168,26 +4248,17 @@ pub mod features2d { } - /// Class implementing the KAZE keypoint detector and descriptor extractor, described in [ABD12](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_ABD12) . - /// - /// - /// Note: AKAZE descriptor can only be used with KAZE or AKAZE keypoints .. [ABD12] KAZE Features. Pablo - /// F. Alcantarilla, Adrien Bartoli and Andrew J. Davison. In European Conference on Computer Vision - /// (ECCV), Fiorenze, Italy, October 2012. - pub struct KAZE { - ptr: *mut c_void, - } - - opencv_type_boxed! { KAZE } - - impl Drop for KAZE { + impl std::fmt::Debug for KAZE { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_KAZE_delete(self.as_raw_mut_KAZE()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("KAZE") + .finish() } } - unsafe impl Send for KAZE {} + boxed_cast_base! { KAZE, core::Algorithm, cv_KAZE_to_Algorithm } + + boxed_cast_base! { KAZE, crate::features2d::Feature2D, cv_KAZE_to_Feature2D } impl core::AlgorithmTraitConst for KAZE { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -4219,435 +4290,145 @@ pub mod features2d { boxed_ref! { KAZE, crate::features2d::KAZETraitConst, as_raw_KAZE, crate::features2d::KAZETrait, as_raw_mut_KAZE } - impl KAZE { - /// The KAZE constructor - /// - /// ## Parameters - /// * extended: Set to enable extraction of extended (128-byte) descriptor. - /// * upright: Set to enable use of upright descriptors (non rotation-invariant). - /// * threshold: Detector response threshold to accept point - /// * nOctaves: Maximum octave evolution of the image - /// * nOctaveLayers: Default number of sublevels per scale level - /// * diffusivity: Diffusivity type. DIFF_PM_G1, DIFF_PM_G2, DIFF_WEICKERT or - /// DIFF_CHARBONNIER - /// - /// ## C++ default parameters - /// * extended: false - /// * upright: false - /// * threshold: 0.001f - /// * n_octaves: 4 - /// * n_octave_layers: 4 - /// * diffusivity: KAZE::DIFF_PM_G2 - #[inline] - pub fn create(extended: bool, upright: bool, threshold: f32, n_octaves: i32, n_octave_layers: i32, diffusivity: crate::features2d::KAZE_DiffusivityType) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_KAZE_create_bool_bool_float_int_int_DiffusivityType(extended, upright, threshold, n_octaves, n_octave_layers, diffusivity, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// The KAZE constructor - /// - /// ## Parameters - /// * extended: Set to enable extraction of extended (128-byte) descriptor. - /// * upright: Set to enable use of upright descriptors (non rotation-invariant). - /// * threshold: Detector response threshold to accept point - /// * nOctaves: Maximum octave evolution of the image - /// * nOctaveLayers: Default number of sublevels per scale level - /// * diffusivity: Diffusivity type. DIFF_PM_G1, DIFF_PM_G2, DIFF_WEICKERT or - /// DIFF_CHARBONNIER - /// - /// ## Note - /// This alternative version of [KAZE::create] function uses the following default values for its arguments: - /// * extended: false - /// * upright: false - /// * threshold: 0.001f - /// * n_octaves: 4 - /// * n_octave_layers: 4 - /// * diffusivity: KAZE::DIFF_PM_G2 - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_KAZE_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { KAZE, core::Algorithm, cv_KAZE_to_Algorithm } - - boxed_cast_base! { KAZE, crate::features2d::Feature2D, cv_KAZE_to_Feature2D } - - impl std::fmt::Debug for KAZE { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("KAZE") - .finish() - } - } - - /// Constant methods for [crate::features2d::KeyPointsFilter] - pub trait KeyPointsFilterTraitConst { - fn as_raw_KeyPointsFilter(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::features2d::KeyPointsFilter] - pub trait KeyPointsFilterTrait: crate::features2d::KeyPointsFilterTraitConst { - fn as_raw_mut_KeyPointsFilter(&mut self) -> *mut c_void; - - } - - /// A class filters a vector of keypoints. - /// - /// Because now it is difficult to provide a convenient interface for all usage scenarios of the - /// keypoints filter class, it has only several needed by now static methods. - pub struct KeyPointsFilter { - ptr: *mut c_void, - } - - opencv_type_boxed! { KeyPointsFilter } - - impl Drop for KeyPointsFilter { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_KeyPointsFilter_delete(self.as_raw_mut_KeyPointsFilter()) }; - } - } - - unsafe impl Send for KeyPointsFilter {} - - impl crate::features2d::KeyPointsFilterTraitConst for KeyPointsFilter { - #[inline] fn as_raw_KeyPointsFilter(&self) -> *const c_void { self.as_raw() } - } - - impl crate::features2d::KeyPointsFilterTrait for KeyPointsFilter { - #[inline] fn as_raw_mut_KeyPointsFilter(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { KeyPointsFilter, crate::features2d::KeyPointsFilterTraitConst, as_raw_KeyPointsFilter, crate::features2d::KeyPointsFilterTrait, as_raw_mut_KeyPointsFilter } - - impl KeyPointsFilter { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_KeyPointsFilter_KeyPointsFilter(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::features2d::KeyPointsFilter::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn run_by_image_border(keypoints: &mut core::Vector, image_size: core::Size, border_size: i32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_KeyPointsFilter_runByImageBorder_vectorLKeyPointGR_Size_int(keypoints.as_raw_mut_VectorOfKeyPoint(), &image_size, border_size, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// ## C++ default parameters - /// * max_size: FLT_MAX - #[inline] - pub fn run_by_keypoint_size(keypoints: &mut core::Vector, min_size: f32, max_size: f32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_KeyPointsFilter_runByKeypointSize_vectorLKeyPointGR_float_float(keypoints.as_raw_mut_VectorOfKeyPoint(), min_size, max_size, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// ## Note - /// This alternative version of [KeyPointsFilter::run_by_keypoint_size] function uses the following default values for its arguments: - /// * max_size: FLT_MAX - #[inline] - pub fn run_by_keypoint_size_def(keypoints: &mut core::Vector, min_size: f32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_KeyPointsFilter_runByKeypointSize_vectorLKeyPointGR_float(keypoints.as_raw_mut_VectorOfKeyPoint(), min_size, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - pub fn run_by_pixels_mask(keypoints: &mut core::Vector, mask: &impl core::MatTraitConst) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_KeyPointsFilter_runByPixelsMask_vectorLKeyPointGR_const_MatR(keypoints.as_raw_mut_VectorOfKeyPoint(), mask.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - pub fn run_by_pixels_mask2_vector_point(keypoints: &mut core::Vector, remove_from: &mut core::Vector>, mask: &impl core::MatTraitConst) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_KeyPointsFilter_runByPixelsMask2VectorPoint_vectorLKeyPointGR_vectorLvectorLPointGGR_const_MatR(keypoints.as_raw_mut_VectorOfKeyPoint(), remove_from.as_raw_mut_VectorOfVectorOfPoint(), mask.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - pub fn remove_duplicated(keypoints: &mut core::Vector) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_KeyPointsFilter_removeDuplicated_vectorLKeyPointGR(keypoints.as_raw_mut_VectorOfKeyPoint(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - pub fn remove_duplicated_sorted(keypoints: &mut core::Vector) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_KeyPointsFilter_removeDuplicatedSorted_vectorLKeyPointGR(keypoints.as_raw_mut_VectorOfKeyPoint(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - pub fn retain_best(keypoints: &mut core::Vector, npoints: i32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_KeyPointsFilter_retainBest_vectorLKeyPointGR_int(keypoints.as_raw_mut_VectorOfKeyPoint(), npoints, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - impl std::fmt::Debug for KeyPointsFilter { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("KeyPointsFilter") - .finish() - } - } - - /// Constant methods for [crate::features2d::MSER] - pub trait MSERTraitConst: crate::features2d::Feature2DTraitConst { - fn as_raw_MSER(&self) -> *const c_void; - - #[inline] - fn get_delta(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_getDelta_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_min_area(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_getMinArea_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_max_area(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_getMaxArea_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_max_variation(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_getMaxVariation_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_min_diversity(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_getMinDiversity_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_max_evolution(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_getMaxEvolution_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_area_threshold(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_getAreaThreshold_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_min_margin(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_getMinMargin_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_edge_blur_size(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_getEdgeBlurSize_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_pass2_only(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_getPass2Only_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_default_name(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_getDefaultName_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { String::opencv_from_extern(ret) }; - Ok(ret) - } - + /// A class filters a vector of keypoints. + /// + /// Because now it is difficult to provide a convenient interface for all usage scenarios of the + /// keypoints filter class, it has only several needed by now static methods. + pub struct KeyPointsFilter { + ptr: *mut c_void, } - /// Mutable methods for [crate::features2d::MSER] - pub trait MSERTrait: crate::features2d::Feature2DTrait + crate::features2d::MSERTraitConst { - fn as_raw_mut_MSER(&mut self) -> *mut c_void; + opencv_type_boxed! { KeyPointsFilter } - /// Detect %MSER regions - /// - /// ## Parameters - /// * image: input image (8UC1, 8UC3 or 8UC4, must be greater or equal than 3x3) - /// * msers: resulting list of point sets - /// * bboxes: resulting bounding boxes + impl Drop for KeyPointsFilter { #[inline] - fn detect_regions(&mut self, image: &impl ToInputArray, msers: &mut core::Vector>, bboxes: &mut core::Vector) -> Result<()> { - input_array_arg!(image); - return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_detectRegions_const__InputArrayR_vectorLvectorLPointGGR_vectorLRectGR(self.as_raw_mut_MSER(), image.as_raw__InputArray(), msers.as_raw_mut_VectorOfVectorOfPoint(), bboxes.as_raw_mut_VectorOfRect(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_KeyPointsFilter_delete(self.as_raw_mut_KeyPointsFilter()) }; } + } + + unsafe impl Send for KeyPointsFilter {} + impl KeyPointsFilter { #[inline] - fn set_delta(&mut self, delta: i32) -> Result<()> { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_setDelta_int(self.as_raw_mut_MSER(), delta, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_KeyPointsFilter_KeyPointsFilter(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { crate::features2d::KeyPointsFilter::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn set_min_area(&mut self, min_area: i32) -> Result<()> { + pub fn run_by_image_border(keypoints: &mut core::Vector, image_size: core::Size, border_size: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_setMinArea_int(self.as_raw_mut_MSER(), min_area, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_KeyPointsFilter_runByImageBorder_vectorLKeyPointGR_Size_int(keypoints.as_raw_mut_VectorOfKeyPoint(), &image_size, border_size, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } + /// ## C++ default parameters + /// * max_size: FLT_MAX #[inline] - fn set_max_area(&mut self, max_area: i32) -> Result<()> { + pub fn run_by_keypoint_size(keypoints: &mut core::Vector, min_size: f32, max_size: f32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_setMaxArea_int(self.as_raw_mut_MSER(), max_area, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_KeyPointsFilter_runByKeypointSize_vectorLKeyPointGR_float_float(keypoints.as_raw_mut_VectorOfKeyPoint(), min_size, max_size, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } + /// ## Note + /// This alternative version of [KeyPointsFilter::run_by_keypoint_size] function uses the following default values for its arguments: + /// * max_size: FLT_MAX #[inline] - fn set_max_variation(&mut self, max_variation: f64) -> Result<()> { + pub fn run_by_keypoint_size_def(keypoints: &mut core::Vector, min_size: f32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_setMaxVariation_double(self.as_raw_mut_MSER(), max_variation, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_KeyPointsFilter_runByKeypointSize_vectorLKeyPointGR_float(keypoints.as_raw_mut_VectorOfKeyPoint(), min_size, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn set_min_diversity(&mut self, min_diversity: f64) -> Result<()> { + pub fn run_by_pixels_mask(keypoints: &mut core::Vector, mask: &impl core::MatTraitConst) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_setMinDiversity_double(self.as_raw_mut_MSER(), min_diversity, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_KeyPointsFilter_runByPixelsMask_vectorLKeyPointGR_const_MatR(keypoints.as_raw_mut_VectorOfKeyPoint(), mask.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn set_max_evolution(&mut self, max_evolution: i32) -> Result<()> { + pub fn run_by_pixels_mask2_vector_point(keypoints: &mut core::Vector, remove_from: &mut core::Vector>, mask: &impl core::MatTraitConst) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_setMaxEvolution_int(self.as_raw_mut_MSER(), max_evolution, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_KeyPointsFilter_runByPixelsMask2VectorPoint_vectorLKeyPointGR_vectorLvectorLPointGGR_const_MatR(keypoints.as_raw_mut_VectorOfKeyPoint(), remove_from.as_raw_mut_VectorOfVectorOfPoint(), mask.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn set_area_threshold(&mut self, area_threshold: f64) -> Result<()> { + pub fn remove_duplicated(keypoints: &mut core::Vector) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_setAreaThreshold_double(self.as_raw_mut_MSER(), area_threshold, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_KeyPointsFilter_removeDuplicated_vectorLKeyPointGR(keypoints.as_raw_mut_VectorOfKeyPoint(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn set_min_margin(&mut self, min_margin: f64) -> Result<()> { + pub fn remove_duplicated_sorted(keypoints: &mut core::Vector) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_setMinMargin_double(self.as_raw_mut_MSER(), min_margin, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_KeyPointsFilter_removeDuplicatedSorted_vectorLKeyPointGR(keypoints.as_raw_mut_VectorOfKeyPoint(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn set_edge_blur_size(&mut self, edge_blur_size: i32) -> Result<()> { + pub fn retain_best(keypoints: &mut core::Vector, npoints: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_setEdgeBlurSize_int(self.as_raw_mut_MSER(), edge_blur_size, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_KeyPointsFilter_retainBest_vectorLKeyPointGR_int(keypoints.as_raw_mut_VectorOfKeyPoint(), npoints, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } + } + + /// Constant methods for [crate::features2d::KeyPointsFilter] + pub trait KeyPointsFilterTraitConst { + fn as_raw_KeyPointsFilter(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::features2d::KeyPointsFilter] + pub trait KeyPointsFilterTrait: crate::features2d::KeyPointsFilterTraitConst { + fn as_raw_mut_KeyPointsFilter(&mut self) -> *mut c_void; + + } + + impl std::fmt::Debug for KeyPointsFilter { #[inline] - fn set_pass2_only(&mut self, f: bool) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_MSER_setPass2Only_bool(self.as_raw_mut_MSER(), f, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("KeyPointsFilter") + .finish() } + } + + impl crate::features2d::KeyPointsFilterTraitConst for KeyPointsFilter { + #[inline] fn as_raw_KeyPointsFilter(&self) -> *const c_void { self.as_raw() } + } + impl crate::features2d::KeyPointsFilterTrait for KeyPointsFilter { + #[inline] fn as_raw_mut_KeyPointsFilter(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { KeyPointsFilter, crate::features2d::KeyPointsFilterTraitConst, as_raw_KeyPointsFilter, crate::features2d::KeyPointsFilterTrait, as_raw_mut_KeyPointsFilter } + /// Maximally stable extremal region extractor /// /// The class encapsulates all the parameters of the %MSER extraction algorithm (see [wiki @@ -4677,36 +4458,6 @@ pub mod features2d { unsafe impl Send for MSER {} - impl core::AlgorithmTraitConst for MSER { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for MSER { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { MSER, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::features2d::Feature2DTraitConst for MSER { - #[inline] fn as_raw_Feature2D(&self) -> *const c_void { self.as_raw() } - } - - impl crate::features2d::Feature2DTrait for MSER { - #[inline] fn as_raw_mut_Feature2D(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { MSER, crate::features2d::Feature2DTraitConst, as_raw_Feature2D, crate::features2d::Feature2DTrait, as_raw_mut_Feature2D } - - impl crate::features2d::MSERTraitConst for MSER { - #[inline] fn as_raw_MSER(&self) -> *const c_void { self.as_raw() } - } - - impl crate::features2d::MSERTrait for MSER { - #[inline] fn as_raw_mut_MSER(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { MSER, crate::features2d::MSERTraitConst, as_raw_MSER, crate::features2d::MSERTrait, as_raw_mut_MSER } - impl MSER { /// Full constructor for %MSER detector /// @@ -4777,98 +4528,95 @@ pub mod features2d { } - boxed_cast_base! { MSER, core::Algorithm, cv_MSER_to_Algorithm } - - boxed_cast_base! { MSER, crate::features2d::Feature2D, cv_MSER_to_Feature2D } + /// Constant methods for [crate::features2d::MSER] + pub trait MSERTraitConst: crate::features2d::Feature2DTraitConst { + fn as_raw_MSER(&self) -> *const c_void; - impl std::fmt::Debug for MSER { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MSER") - .finish() + fn get_delta(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_MSER_getDelta_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } - } - - /// Constant methods for [crate::features2d::ORB] - pub trait ORBTraitConst: crate::features2d::Feature2DTraitConst { - fn as_raw_ORB(&self) -> *const c_void; #[inline] - fn get_max_features(&self) -> Result { + fn get_min_area(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ORB_getMaxFeatures_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MSER_getMinArea_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn get_scale_factor(&self) -> Result { + fn get_max_area(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ORB_getScaleFactor_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MSER_getMaxArea_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn get_n_levels(&self) -> Result { + fn get_max_variation(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ORB_getNLevels_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MSER_getMaxVariation_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn get_edge_threshold(&self) -> Result { + fn get_min_diversity(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ORB_getEdgeThreshold_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MSER_getMinDiversity_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn get_first_level(&self) -> Result { + fn get_max_evolution(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ORB_getFirstLevel_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MSER_getMaxEvolution_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn get_wta_k(&self) -> Result { + fn get_area_threshold(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ORB_getWTA_K_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MSER_getAreaThreshold_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn get_score_type(&self) -> Result { + fn get_min_margin(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ORB_getScoreType_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MSER_getMinMargin_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn get_patch_size(&self) -> Result { + fn get_edge_blur_size(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ORB_getPatchSize_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MSER_getEdgeBlurSize_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn get_fast_threshold(&self) -> Result { + fn get_pass2_only(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ORB_getFastThreshold_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MSER_getPass2Only_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -4877,7 +4625,7 @@ pub mod features2d { #[inline] fn get_default_name(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ORB_getDefaultName_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MSER_getDefaultName_const(self.as_raw_MSER(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { String::opencv_from_extern(ret) }; @@ -4886,86 +4634,111 @@ pub mod features2d { } - /// Mutable methods for [crate::features2d::ORB] - pub trait ORBTrait: crate::features2d::Feature2DTrait + crate::features2d::ORBTraitConst { - fn as_raw_mut_ORB(&mut self) -> *mut c_void; + /// Mutable methods for [crate::features2d::MSER] + pub trait MSERTrait: crate::features2d::Feature2DTrait + crate::features2d::MSERTraitConst { + fn as_raw_mut_MSER(&mut self) -> *mut c_void; + /// Detect %MSER regions + /// + /// ## Parameters + /// * image: input image (8UC1, 8UC3 or 8UC4, must be greater or equal than 3x3) + /// * msers: resulting list of point sets + /// * bboxes: resulting bounding boxes #[inline] - fn set_max_features(&mut self, max_features: i32) -> Result<()> { + fn detect_regions(&mut self, image: &impl ToInputArray, msers: &mut core::Vector>, bboxes: &mut core::Vector) -> Result<()> { + input_array_arg!(image); return_send!(via ocvrs_return); - unsafe { sys::cv_ORB_setMaxFeatures_int(self.as_raw_mut_ORB(), max_features, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MSER_detectRegions_const__InputArrayR_vectorLvectorLPointGGR_vectorLRectGR(self.as_raw_mut_MSER(), image.as_raw__InputArray(), msers.as_raw_mut_VectorOfVectorOfPoint(), bboxes.as_raw_mut_VectorOfRect(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn set_scale_factor(&mut self, scale_factor: f64) -> Result<()> { + fn set_delta(&mut self, delta: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ORB_setScaleFactor_double(self.as_raw_mut_ORB(), scale_factor, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MSER_setDelta_int(self.as_raw_mut_MSER(), delta, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn set_n_levels(&mut self, nlevels: i32) -> Result<()> { + fn set_min_area(&mut self, min_area: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ORB_setNLevels_int(self.as_raw_mut_ORB(), nlevels, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MSER_setMinArea_int(self.as_raw_mut_MSER(), min_area, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn set_edge_threshold(&mut self, edge_threshold: i32) -> Result<()> { + fn set_max_area(&mut self, max_area: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ORB_setEdgeThreshold_int(self.as_raw_mut_ORB(), edge_threshold, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MSER_setMaxArea_int(self.as_raw_mut_MSER(), max_area, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn set_first_level(&mut self, first_level: i32) -> Result<()> { + fn set_max_variation(&mut self, max_variation: f64) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ORB_setFirstLevel_int(self.as_raw_mut_ORB(), first_level, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MSER_setMaxVariation_double(self.as_raw_mut_MSER(), max_variation, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn set_wta_k(&mut self, wta_k: i32) -> Result<()> { + fn set_min_diversity(&mut self, min_diversity: f64) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ORB_setWTA_K_int(self.as_raw_mut_ORB(), wta_k, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MSER_setMinDiversity_double(self.as_raw_mut_MSER(), min_diversity, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn set_score_type(&mut self, score_type: crate::features2d::ORB_ScoreType) -> Result<()> { + fn set_max_evolution(&mut self, max_evolution: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ORB_setScoreType_ScoreType(self.as_raw_mut_ORB(), score_type, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MSER_setMaxEvolution_int(self.as_raw_mut_MSER(), max_evolution, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn set_patch_size(&mut self, patch_size: i32) -> Result<()> { + fn set_area_threshold(&mut self, area_threshold: f64) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ORB_setPatchSize_int(self.as_raw_mut_ORB(), patch_size, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MSER_setAreaThreshold_double(self.as_raw_mut_MSER(), area_threshold, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn set_min_margin(&mut self, min_margin: f64) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_MSER_setMinMargin_double(self.as_raw_mut_MSER(), min_margin, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn set_edge_blur_size(&mut self, edge_blur_size: i32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_MSER_setEdgeBlurSize_int(self.as_raw_mut_MSER(), edge_blur_size, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn set_fast_threshold(&mut self, fast_threshold: i32) -> Result<()> { + fn set_pass2_only(&mut self, f: bool) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_ORB_setFastThreshold_int(self.as_raw_mut_ORB(), fast_threshold, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MSER_setPass2Only_bool(self.as_raw_mut_MSER(), f, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -4973,56 +4746,68 @@ pub mod features2d { } - /// Class implementing the ORB (*oriented BRIEF*) keypoint detector and descriptor extractor - /// - /// described in [RRKB11](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_RRKB11) . The algorithm uses FAST in pyramids to detect stable keypoints, selects - /// the strongest features using FAST or Harris response, finds their orientation using first-order - /// moments and computes the descriptors using BRIEF (where the coordinates of random point pairs (or - /// k-tuples) are rotated according to the measured orientation). - pub struct ORB { - ptr: *mut c_void, - } - - opencv_type_boxed! { ORB } - - impl Drop for ORB { + impl std::fmt::Debug for MSER { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ORB_delete(self.as_raw_mut_ORB()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MSER") + .finish() } } - unsafe impl Send for ORB {} + boxed_cast_base! { MSER, core::Algorithm, cv_MSER_to_Algorithm } - impl core::AlgorithmTraitConst for ORB { + boxed_cast_base! { MSER, crate::features2d::Feature2D, cv_MSER_to_Feature2D } + + impl core::AlgorithmTraitConst for MSER { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } } - impl core::AlgorithmTrait for ORB { + impl core::AlgorithmTrait for MSER { #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { ORB, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + boxed_ref! { MSER, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - impl crate::features2d::Feature2DTraitConst for ORB { + impl crate::features2d::Feature2DTraitConst for MSER { #[inline] fn as_raw_Feature2D(&self) -> *const c_void { self.as_raw() } } - impl crate::features2d::Feature2DTrait for ORB { + impl crate::features2d::Feature2DTrait for MSER { #[inline] fn as_raw_mut_Feature2D(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { ORB, crate::features2d::Feature2DTraitConst, as_raw_Feature2D, crate::features2d::Feature2DTrait, as_raw_mut_Feature2D } + boxed_ref! { MSER, crate::features2d::Feature2DTraitConst, as_raw_Feature2D, crate::features2d::Feature2DTrait, as_raw_mut_Feature2D } - impl crate::features2d::ORBTraitConst for ORB { - #[inline] fn as_raw_ORB(&self) -> *const c_void { self.as_raw() } + impl crate::features2d::MSERTraitConst for MSER { + #[inline] fn as_raw_MSER(&self) -> *const c_void { self.as_raw() } } - impl crate::features2d::ORBTrait for ORB { - #[inline] fn as_raw_mut_ORB(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::features2d::MSERTrait for MSER { + #[inline] fn as_raw_mut_MSER(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { ORB, crate::features2d::ORBTraitConst, as_raw_ORB, crate::features2d::ORBTrait, as_raw_mut_ORB } + boxed_ref! { MSER, crate::features2d::MSERTraitConst, as_raw_MSER, crate::features2d::MSERTrait, as_raw_mut_MSER } + + /// Class implementing the ORB (*oriented BRIEF*) keypoint detector and descriptor extractor + /// + /// described in [RRKB11](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_RRKB11) . The algorithm uses FAST in pyramids to detect stable keypoints, selects + /// the strongest features using FAST or Harris response, finds their orientation using first-order + /// moments and computes the descriptors using BRIEF (where the coordinates of random point pairs (or + /// k-tuples) are rotated according to the measured orientation). + pub struct ORB { + ptr: *mut c_void, + } + + opencv_type_boxed! { ORB } + + impl Drop for ORB { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_ORB_delete(self.as_raw_mut_ORB()) }; + } + } + + unsafe impl Send for ORB {} impl ORB { pub const kBytes: i32 = 32; @@ -5133,176 +4918,248 @@ pub mod features2d { } - boxed_cast_base! { ORB, core::Algorithm, cv_ORB_to_Algorithm } + /// Constant methods for [crate::features2d::ORB] + pub trait ORBTraitConst: crate::features2d::Feature2DTraitConst { + fn as_raw_ORB(&self) -> *const c_void; - boxed_cast_base! { ORB, crate::features2d::Feature2D, cv_ORB_to_Feature2D } + #[inline] + fn get_max_features(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ORB_getMaxFeatures_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - impl std::fmt::Debug for ORB { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ORB") - .finish() + fn get_scale_factor(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ORB_getScaleFactor_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } - } - /// Constant methods for [crate::features2d::SIFT] - pub trait SIFTTraitConst: crate::features2d::Feature2DTraitConst { - fn as_raw_SIFT(&self) -> *const c_void; + #[inline] + fn get_n_levels(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ORB_getNLevels_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } #[inline] - fn get_default_name(&self) -> Result { + fn get_edge_threshold(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_SIFT_getDefaultName_const(self.as_raw_SIFT(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ORB_getEdgeThreshold_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { String::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn get_n_features(&self) -> Result { + fn get_first_level(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_SIFT_getNFeatures_const(self.as_raw_SIFT(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ORB_getFirstLevel_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn get_n_octave_layers(&self) -> Result { + fn get_wta_k(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_SIFT_getNOctaveLayers_const(self.as_raw_SIFT(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ORB_getWTA_K_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn get_contrast_threshold(&self) -> Result { + fn get_score_type(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_SIFT_getContrastThreshold_const(self.as_raw_SIFT(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ORB_getScoreType_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn get_edge_threshold(&self) -> Result { + fn get_patch_size(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_SIFT_getEdgeThreshold_const(self.as_raw_SIFT(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ORB_getPatchSize_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn get_sigma(&self) -> Result { + fn get_fast_threshold(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_SIFT_getSigma_const(self.as_raw_SIFT(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ORB_getFastThreshold_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn get_default_name(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ORB_getDefaultName_const(self.as_raw_ORB(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { String::opencv_from_extern(ret) }; Ok(ret) } } - /// Mutable methods for [crate::features2d::SIFT] - pub trait SIFTTrait: crate::features2d::Feature2DTrait + crate::features2d::SIFTTraitConst { - fn as_raw_mut_SIFT(&mut self) -> *mut c_void; + /// Mutable methods for [crate::features2d::ORB] + pub trait ORBTrait: crate::features2d::Feature2DTrait + crate::features2d::ORBTraitConst { + fn as_raw_mut_ORB(&mut self) -> *mut c_void; #[inline] - fn set_n_features(&mut self, max_features: i32) -> Result<()> { + fn set_max_features(&mut self, max_features: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_SIFT_setNFeatures_int(self.as_raw_mut_SIFT(), max_features, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ORB_setMaxFeatures_int(self.as_raw_mut_ORB(), max_features, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn set_n_octave_layers(&mut self, n_octave_layers: i32) -> Result<()> { + fn set_scale_factor(&mut self, scale_factor: f64) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_SIFT_setNOctaveLayers_int(self.as_raw_mut_SIFT(), n_octave_layers, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ORB_setScaleFactor_double(self.as_raw_mut_ORB(), scale_factor, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn set_contrast_threshold(&mut self, contrast_threshold: f64) -> Result<()> { + fn set_n_levels(&mut self, nlevels: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_SIFT_setContrastThreshold_double(self.as_raw_mut_SIFT(), contrast_threshold, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ORB_setNLevels_int(self.as_raw_mut_ORB(), nlevels, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn set_edge_threshold(&mut self, edge_threshold: f64) -> Result<()> { + fn set_edge_threshold(&mut self, edge_threshold: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_SIFT_setEdgeThreshold_double(self.as_raw_mut_SIFT(), edge_threshold, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ORB_setEdgeThreshold_int(self.as_raw_mut_ORB(), edge_threshold, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn set_sigma(&mut self, sigma: f64) -> Result<()> { + fn set_first_level(&mut self, first_level: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_SIFT_setSigma_double(self.as_raw_mut_SIFT(), sigma, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ORB_setFirstLevel_int(self.as_raw_mut_ORB(), first_level, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - } + #[inline] + fn set_wta_k(&mut self, wta_k: i32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_ORB_setWTA_K_int(self.as_raw_mut_ORB(), wta_k, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - /// Class for extracting keypoints and computing descriptors using the Scale Invariant Feature Transform - /// (SIFT) algorithm by D. Lowe [Lowe04](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Lowe04) . - pub struct SIFT { - ptr: *mut c_void, - } + #[inline] + fn set_score_type(&mut self, score_type: crate::features2d::ORB_ScoreType) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_ORB_setScoreType_ScoreType(self.as_raw_mut_ORB(), score_type, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - opencv_type_boxed! { SIFT } + #[inline] + fn set_patch_size(&mut self, patch_size: i32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_ORB_setPatchSize_int(self.as_raw_mut_ORB(), patch_size, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - impl Drop for SIFT { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_SIFT_delete(self.as_raw_mut_SIFT()) }; + fn set_fast_threshold(&mut self, fast_threshold: i32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_ORB_setFastThreshold_int(self.as_raw_mut_ORB(), fast_threshold, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + impl std::fmt::Debug for ORB { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ORB") + .finish() } } - unsafe impl Send for SIFT {} + boxed_cast_base! { ORB, core::Algorithm, cv_ORB_to_Algorithm } - impl core::AlgorithmTraitConst for SIFT { + boxed_cast_base! { ORB, crate::features2d::Feature2D, cv_ORB_to_Feature2D } + + impl core::AlgorithmTraitConst for ORB { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } } - impl core::AlgorithmTrait for SIFT { + impl core::AlgorithmTrait for ORB { #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { SIFT, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + boxed_ref! { ORB, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - impl crate::features2d::Feature2DTraitConst for SIFT { + impl crate::features2d::Feature2DTraitConst for ORB { #[inline] fn as_raw_Feature2D(&self) -> *const c_void { self.as_raw() } } - impl crate::features2d::Feature2DTrait for SIFT { + impl crate::features2d::Feature2DTrait for ORB { #[inline] fn as_raw_mut_Feature2D(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { SIFT, crate::features2d::Feature2DTraitConst, as_raw_Feature2D, crate::features2d::Feature2DTrait, as_raw_mut_Feature2D } + boxed_ref! { ORB, crate::features2d::Feature2DTraitConst, as_raw_Feature2D, crate::features2d::Feature2DTrait, as_raw_mut_Feature2D } - impl crate::features2d::SIFTTraitConst for SIFT { - #[inline] fn as_raw_SIFT(&self) -> *const c_void { self.as_raw() } + impl crate::features2d::ORBTraitConst for ORB { + #[inline] fn as_raw_ORB(&self) -> *const c_void { self.as_raw() } } - impl crate::features2d::SIFTTrait for SIFT { - #[inline] fn as_raw_mut_SIFT(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::features2d::ORBTrait for ORB { + #[inline] fn as_raw_mut_ORB(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { ORB, crate::features2d::ORBTraitConst, as_raw_ORB, crate::features2d::ORBTrait, as_raw_mut_ORB } + + /// Class for extracting keypoints and computing descriptors using the Scale Invariant Feature Transform + /// (SIFT) algorithm by D. Lowe [Lowe04](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Lowe04) . + pub struct SIFT { + ptr: *mut c_void, + } + + opencv_type_boxed! { SIFT } + + impl Drop for SIFT { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_SIFT_delete(self.as_raw_mut_SIFT()) }; + } } - boxed_ref! { SIFT, crate::features2d::SIFTTraitConst, as_raw_SIFT, crate::features2d::SIFTTrait, as_raw_mut_SIFT } + unsafe impl Send for SIFT {} impl SIFT { /// ## Parameters @@ -5477,61 +5334,111 @@ pub mod features2d { } - boxed_cast_base! { SIFT, core::Algorithm, cv_SIFT_to_Algorithm } + /// Constant methods for [crate::features2d::SIFT] + pub trait SIFTTraitConst: crate::features2d::Feature2DTraitConst { + fn as_raw_SIFT(&self) -> *const c_void; - boxed_cast_base! { SIFT, crate::features2d::Feature2D, cv_SIFT_to_Feature2D } + #[inline] + fn get_default_name(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_SIFT_getDefaultName_const(self.as_raw_SIFT(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { String::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for SIFT { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SIFT") - .finish() + fn get_n_features(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_SIFT_getNFeatures_const(self.as_raw_SIFT(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } - } - /// Constant methods for [crate::features2d::SimpleBlobDetector] - pub trait SimpleBlobDetectorTraitConst: crate::features2d::Feature2DTraitConst { - fn as_raw_SimpleBlobDetector(&self) -> *const c_void; + #[inline] + fn get_n_octave_layers(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_SIFT_getNOctaveLayers_const(self.as_raw_SIFT(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } #[inline] - fn get_params(&self) -> Result { + fn get_contrast_threshold(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_SimpleBlobDetector_getParams_const(self.as_raw_SimpleBlobDetector(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_SIFT_getContrastThreshold_const(self.as_raw_SIFT(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn get_default_name(&self) -> Result { + fn get_edge_threshold(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_SimpleBlobDetector_getDefaultName_const(self.as_raw_SimpleBlobDetector(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_SIFT_getEdgeThreshold_const(self.as_raw_SIFT(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { String::opencv_from_extern(ret) }; Ok(ret) } #[inline] - fn get_blob_contours(&self) -> Result>> { + fn get_sigma(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_SimpleBlobDetector_getBlobContours_const(self.as_raw_SimpleBlobDetector(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_SIFT_getSigma_const(self.as_raw_SIFT(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Vector::>::opencv_from_extern(ret) }; Ok(ret) } } - /// Mutable methods for [crate::features2d::SimpleBlobDetector] - pub trait SimpleBlobDetectorTrait: crate::features2d::Feature2DTrait + crate::features2d::SimpleBlobDetectorTraitConst { - fn as_raw_mut_SimpleBlobDetector(&mut self) -> *mut c_void; + /// Mutable methods for [crate::features2d::SIFT] + pub trait SIFTTrait: crate::features2d::Feature2DTrait + crate::features2d::SIFTTraitConst { + fn as_raw_mut_SIFT(&mut self) -> *mut c_void; #[inline] - fn set_params(&mut self, params: crate::features2d::SimpleBlobDetector_Params) -> Result<()> { + fn set_n_features(&mut self, max_features: i32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_SimpleBlobDetector_setParams_const_ParamsR(self.as_raw_mut_SimpleBlobDetector(), ¶ms, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_SIFT_setNFeatures_int(self.as_raw_mut_SIFT(), max_features, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn set_n_octave_layers(&mut self, n_octave_layers: i32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_SIFT_setNOctaveLayers_int(self.as_raw_mut_SIFT(), n_octave_layers, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn set_contrast_threshold(&mut self, contrast_threshold: f64) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_SIFT_setContrastThreshold_double(self.as_raw_mut_SIFT(), contrast_threshold, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn set_edge_threshold(&mut self, edge_threshold: f64) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_SIFT_setEdgeThreshold_double(self.as_raw_mut_SIFT(), edge_threshold, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn set_sigma(&mut self, sigma: f64) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_SIFT_setSigma_double(self.as_raw_mut_SIFT(), sigma, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -5539,6 +5446,48 @@ pub mod features2d { } + impl std::fmt::Debug for SIFT { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SIFT") + .finish() + } + } + + boxed_cast_base! { SIFT, core::Algorithm, cv_SIFT_to_Algorithm } + + boxed_cast_base! { SIFT, crate::features2d::Feature2D, cv_SIFT_to_Feature2D } + + impl core::AlgorithmTraitConst for SIFT { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } + } + + impl core::AlgorithmTrait for SIFT { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { SIFT, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + + impl crate::features2d::Feature2DTraitConst for SIFT { + #[inline] fn as_raw_Feature2D(&self) -> *const c_void { self.as_raw() } + } + + impl crate::features2d::Feature2DTrait for SIFT { + #[inline] fn as_raw_mut_Feature2D(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { SIFT, crate::features2d::Feature2DTraitConst, as_raw_Feature2D, crate::features2d::Feature2DTrait, as_raw_mut_Feature2D } + + impl crate::features2d::SIFTTraitConst for SIFT { + #[inline] fn as_raw_SIFT(&self) -> *const c_void { self.as_raw() } + } + + impl crate::features2d::SIFTTrait for SIFT { + #[inline] fn as_raw_mut_SIFT(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { SIFT, crate::features2d::SIFTTraitConst, as_raw_SIFT, crate::features2d::SIFTTrait, as_raw_mut_SIFT } + /// Class for extracting blobs from an image. : /// /// The class implements a simple algorithm for extracting blobs from an image: @@ -5584,36 +5533,6 @@ pub mod features2d { unsafe impl Send for SimpleBlobDetector {} - impl core::AlgorithmTraitConst for SimpleBlobDetector { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for SimpleBlobDetector { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { SimpleBlobDetector, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::features2d::Feature2DTraitConst for SimpleBlobDetector { - #[inline] fn as_raw_Feature2D(&self) -> *const c_void { self.as_raw() } - } - - impl crate::features2d::Feature2DTrait for SimpleBlobDetector { - #[inline] fn as_raw_mut_Feature2D(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { SimpleBlobDetector, crate::features2d::Feature2DTraitConst, as_raw_Feature2D, crate::features2d::Feature2DTrait, as_raw_mut_Feature2D } - - impl crate::features2d::SimpleBlobDetectorTraitConst for SimpleBlobDetector { - #[inline] fn as_raw_SimpleBlobDetector(&self) -> *const c_void { self.as_raw() } - } - - impl crate::features2d::SimpleBlobDetectorTrait for SimpleBlobDetector { - #[inline] fn as_raw_mut_SimpleBlobDetector(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { SimpleBlobDetector, crate::features2d::SimpleBlobDetectorTraitConst, as_raw_SimpleBlobDetector, crate::features2d::SimpleBlobDetectorTrait, as_raw_mut_SimpleBlobDetector } - impl SimpleBlobDetector { /// ## C++ default parameters /// * parameters: SimpleBlobDetector::Params() @@ -5642,9 +5561,55 @@ pub mod features2d { } - boxed_cast_base! { SimpleBlobDetector, core::Algorithm, cv_SimpleBlobDetector_to_Algorithm } + /// Constant methods for [crate::features2d::SimpleBlobDetector] + pub trait SimpleBlobDetectorTraitConst: crate::features2d::Feature2DTraitConst { + fn as_raw_SimpleBlobDetector(&self) -> *const c_void; - boxed_cast_base! { SimpleBlobDetector, crate::features2d::Feature2D, cv_SimpleBlobDetector_to_Feature2D } + #[inline] + fn get_params(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_SimpleBlobDetector_getParams_const(self.as_raw_SimpleBlobDetector(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn get_default_name(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_SimpleBlobDetector_getDefaultName_const(self.as_raw_SimpleBlobDetector(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { String::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + fn get_blob_contours(&self) -> Result>> { + return_send!(via ocvrs_return); + unsafe { sys::cv_SimpleBlobDetector_getBlobContours_const(self.as_raw_SimpleBlobDetector(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Vector::>::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Mutable methods for [crate::features2d::SimpleBlobDetector] + pub trait SimpleBlobDetectorTrait: crate::features2d::Feature2DTrait + crate::features2d::SimpleBlobDetectorTraitConst { + fn as_raw_mut_SimpleBlobDetector(&mut self) -> *mut c_void; + + #[inline] + fn set_params(&mut self, params: crate::features2d::SimpleBlobDetector_Params) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_SimpleBlobDetector_setParams_const_ParamsR(self.as_raw_mut_SimpleBlobDetector(), ¶ms, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } impl std::fmt::Debug for SimpleBlobDetector { #[inline] @@ -5654,6 +5619,40 @@ pub mod features2d { } } + boxed_cast_base! { SimpleBlobDetector, core::Algorithm, cv_SimpleBlobDetector_to_Algorithm } + + boxed_cast_base! { SimpleBlobDetector, crate::features2d::Feature2D, cv_SimpleBlobDetector_to_Feature2D } + + impl core::AlgorithmTraitConst for SimpleBlobDetector { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } + } + + impl core::AlgorithmTrait for SimpleBlobDetector { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { SimpleBlobDetector, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + + impl crate::features2d::Feature2DTraitConst for SimpleBlobDetector { + #[inline] fn as_raw_Feature2D(&self) -> *const c_void { self.as_raw() } + } + + impl crate::features2d::Feature2DTrait for SimpleBlobDetector { + #[inline] fn as_raw_mut_Feature2D(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { SimpleBlobDetector, crate::features2d::Feature2DTraitConst, as_raw_Feature2D, crate::features2d::Feature2DTrait, as_raw_mut_Feature2D } + + impl crate::features2d::SimpleBlobDetectorTraitConst for SimpleBlobDetector { + #[inline] fn as_raw_SimpleBlobDetector(&self) -> *const c_void { self.as_raw() } + } + + impl crate::features2d::SimpleBlobDetectorTrait for SimpleBlobDetector { + #[inline] fn as_raw_mut_SimpleBlobDetector(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { SimpleBlobDetector, crate::features2d::SimpleBlobDetectorTraitConst, as_raw_SimpleBlobDetector, crate::features2d::SimpleBlobDetectorTrait, as_raw_mut_SimpleBlobDetector } + #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] pub struct SimpleBlobDetector_Params { @@ -5710,4 +5709,5 @@ pub mod features2d { } } + } diff --git a/docs/flann.rs b/docs/flann.rs index e4ee1c2ba..88723abb0 100644 --- a/docs/flann.rs +++ b/docs/flann.rs @@ -422,18 +422,6 @@ pub mod flann { Ok(ret) } - /// Constant methods for [crate::flann::AutotunedIndexParams] - pub trait AutotunedIndexParamsTraitConst: crate::flann::IndexParamsTraitConst { - fn as_raw_AutotunedIndexParams(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::flann::AutotunedIndexParams] - pub trait AutotunedIndexParamsTrait: crate::flann::AutotunedIndexParamsTraitConst + crate::flann::IndexParamsTrait { - fn as_raw_mut_AutotunedIndexParams(&mut self) -> *mut c_void; - - } - pub struct AutotunedIndexParams { ptr: *mut c_void, } @@ -449,26 +437,6 @@ pub mod flann { unsafe impl Send for AutotunedIndexParams {} - impl crate::flann::IndexParamsTraitConst for AutotunedIndexParams { - #[inline] fn as_raw_IndexParams(&self) -> *const c_void { self.as_raw() } - } - - impl crate::flann::IndexParamsTrait for AutotunedIndexParams { - #[inline] fn as_raw_mut_IndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { AutotunedIndexParams, crate::flann::IndexParamsTraitConst, as_raw_IndexParams, crate::flann::IndexParamsTrait, as_raw_mut_IndexParams } - - impl crate::flann::AutotunedIndexParamsTraitConst for AutotunedIndexParams { - #[inline] fn as_raw_AutotunedIndexParams(&self) -> *const c_void { self.as_raw() } - } - - impl crate::flann::AutotunedIndexParamsTrait for AutotunedIndexParams { - #[inline] fn as_raw_mut_AutotunedIndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { AutotunedIndexParams, crate::flann::AutotunedIndexParamsTraitConst, as_raw_AutotunedIndexParams, crate::flann::AutotunedIndexParamsTrait, as_raw_mut_AutotunedIndexParams } - impl AutotunedIndexParams { /// ## C++ default parameters /// * target_precision: 0.8f @@ -503,7 +471,17 @@ pub mod flann { } - boxed_cast_base! { AutotunedIndexParams, crate::flann::IndexParams, cv_flann_AutotunedIndexParams_to_IndexParams } + /// Constant methods for [crate::flann::AutotunedIndexParams] + pub trait AutotunedIndexParamsTraitConst: crate::flann::IndexParamsTraitConst { + fn as_raw_AutotunedIndexParams(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::flann::AutotunedIndexParams] + pub trait AutotunedIndexParamsTrait: crate::flann::AutotunedIndexParamsTraitConst + crate::flann::IndexParamsTrait { + fn as_raw_mut_AutotunedIndexParams(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for AutotunedIndexParams { #[inline] @@ -513,18 +491,28 @@ pub mod flann { } } - /// Constant methods for [crate::flann::CompositeIndexParams] - pub trait CompositeIndexParamsTraitConst: crate::flann::IndexParamsTraitConst { - fn as_raw_CompositeIndexParams(&self) -> *const c_void; + boxed_cast_base! { AutotunedIndexParams, crate::flann::IndexParams, cv_flann_AutotunedIndexParams_to_IndexParams } + impl crate::flann::IndexParamsTraitConst for AutotunedIndexParams { + #[inline] fn as_raw_IndexParams(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::flann::CompositeIndexParams] - pub trait CompositeIndexParamsTrait: crate::flann::CompositeIndexParamsTraitConst + crate::flann::IndexParamsTrait { - fn as_raw_mut_CompositeIndexParams(&mut self) -> *mut c_void; + impl crate::flann::IndexParamsTrait for AutotunedIndexParams { + #[inline] fn as_raw_mut_IndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } + } + boxed_ref! { AutotunedIndexParams, crate::flann::IndexParamsTraitConst, as_raw_IndexParams, crate::flann::IndexParamsTrait, as_raw_mut_IndexParams } + + impl crate::flann::AutotunedIndexParamsTraitConst for AutotunedIndexParams { + #[inline] fn as_raw_AutotunedIndexParams(&self) -> *const c_void { self.as_raw() } + } + + impl crate::flann::AutotunedIndexParamsTrait for AutotunedIndexParams { + #[inline] fn as_raw_mut_AutotunedIndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { AutotunedIndexParams, crate::flann::AutotunedIndexParamsTraitConst, as_raw_AutotunedIndexParams, crate::flann::AutotunedIndexParamsTrait, as_raw_mut_AutotunedIndexParams } + pub struct CompositeIndexParams { ptr: *mut c_void, } @@ -540,26 +528,6 @@ pub mod flann { unsafe impl Send for CompositeIndexParams {} - impl crate::flann::IndexParamsTraitConst for CompositeIndexParams { - #[inline] fn as_raw_IndexParams(&self) -> *const c_void { self.as_raw() } - } - - impl crate::flann::IndexParamsTrait for CompositeIndexParams { - #[inline] fn as_raw_mut_IndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { CompositeIndexParams, crate::flann::IndexParamsTraitConst, as_raw_IndexParams, crate::flann::IndexParamsTrait, as_raw_mut_IndexParams } - - impl crate::flann::CompositeIndexParamsTraitConst for CompositeIndexParams { - #[inline] fn as_raw_CompositeIndexParams(&self) -> *const c_void { self.as_raw() } - } - - impl crate::flann::CompositeIndexParamsTrait for CompositeIndexParams { - #[inline] fn as_raw_mut_CompositeIndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { CompositeIndexParams, crate::flann::CompositeIndexParamsTraitConst, as_raw_CompositeIndexParams, crate::flann::CompositeIndexParamsTrait, as_raw_mut_CompositeIndexParams } - impl CompositeIndexParams { /// ## C++ default parameters /// * trees: 4 @@ -596,7 +564,17 @@ pub mod flann { } - boxed_cast_base! { CompositeIndexParams, crate::flann::IndexParams, cv_flann_CompositeIndexParams_to_IndexParams } + /// Constant methods for [crate::flann::CompositeIndexParams] + pub trait CompositeIndexParamsTraitConst: crate::flann::IndexParamsTraitConst { + fn as_raw_CompositeIndexParams(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::flann::CompositeIndexParams] + pub trait CompositeIndexParamsTrait: crate::flann::CompositeIndexParamsTraitConst + crate::flann::IndexParamsTrait { + fn as_raw_mut_CompositeIndexParams(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for CompositeIndexParams { #[inline] @@ -606,18 +584,28 @@ pub mod flann { } } - /// Constant methods for [crate::flann::HierarchicalClusteringIndexParams] - pub trait HierarchicalClusteringIndexParamsTraitConst: crate::flann::IndexParamsTraitConst { - fn as_raw_HierarchicalClusteringIndexParams(&self) -> *const c_void; + boxed_cast_base! { CompositeIndexParams, crate::flann::IndexParams, cv_flann_CompositeIndexParams_to_IndexParams } + + impl crate::flann::IndexParamsTraitConst for CompositeIndexParams { + #[inline] fn as_raw_IndexParams(&self) -> *const c_void { self.as_raw() } + } + impl crate::flann::IndexParamsTrait for CompositeIndexParams { + #[inline] fn as_raw_mut_IndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } } - /// Mutable methods for [crate::flann::HierarchicalClusteringIndexParams] - pub trait HierarchicalClusteringIndexParamsTrait: crate::flann::HierarchicalClusteringIndexParamsTraitConst + crate::flann::IndexParamsTrait { - fn as_raw_mut_HierarchicalClusteringIndexParams(&mut self) -> *mut c_void; + boxed_ref! { CompositeIndexParams, crate::flann::IndexParamsTraitConst, as_raw_IndexParams, crate::flann::IndexParamsTrait, as_raw_mut_IndexParams } + impl crate::flann::CompositeIndexParamsTraitConst for CompositeIndexParams { + #[inline] fn as_raw_CompositeIndexParams(&self) -> *const c_void { self.as_raw() } + } + + impl crate::flann::CompositeIndexParamsTrait for CompositeIndexParams { + #[inline] fn as_raw_mut_CompositeIndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { CompositeIndexParams, crate::flann::CompositeIndexParamsTraitConst, as_raw_CompositeIndexParams, crate::flann::CompositeIndexParamsTrait, as_raw_mut_CompositeIndexParams } + pub struct HierarchicalClusteringIndexParams { ptr: *mut c_void, } @@ -633,26 +621,6 @@ pub mod flann { unsafe impl Send for HierarchicalClusteringIndexParams {} - impl crate::flann::IndexParamsTraitConst for HierarchicalClusteringIndexParams { - #[inline] fn as_raw_IndexParams(&self) -> *const c_void { self.as_raw() } - } - - impl crate::flann::IndexParamsTrait for HierarchicalClusteringIndexParams { - #[inline] fn as_raw_mut_IndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { HierarchicalClusteringIndexParams, crate::flann::IndexParamsTraitConst, as_raw_IndexParams, crate::flann::IndexParamsTrait, as_raw_mut_IndexParams } - - impl crate::flann::HierarchicalClusteringIndexParamsTraitConst for HierarchicalClusteringIndexParams { - #[inline] fn as_raw_HierarchicalClusteringIndexParams(&self) -> *const c_void { self.as_raw() } - } - - impl crate::flann::HierarchicalClusteringIndexParamsTrait for HierarchicalClusteringIndexParams { - #[inline] fn as_raw_mut_HierarchicalClusteringIndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { HierarchicalClusteringIndexParams, crate::flann::HierarchicalClusteringIndexParamsTraitConst, as_raw_HierarchicalClusteringIndexParams, crate::flann::HierarchicalClusteringIndexParamsTrait, as_raw_mut_HierarchicalClusteringIndexParams } - impl HierarchicalClusteringIndexParams { /// ## C++ default parameters /// * branching: 32 @@ -687,7 +655,17 @@ pub mod flann { } - boxed_cast_base! { HierarchicalClusteringIndexParams, crate::flann::IndexParams, cv_flann_HierarchicalClusteringIndexParams_to_IndexParams } + /// Constant methods for [crate::flann::HierarchicalClusteringIndexParams] + pub trait HierarchicalClusteringIndexParamsTraitConst: crate::flann::IndexParamsTraitConst { + fn as_raw_HierarchicalClusteringIndexParams(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::flann::HierarchicalClusteringIndexParams] + pub trait HierarchicalClusteringIndexParamsTrait: crate::flann::HierarchicalClusteringIndexParamsTraitConst + crate::flann::IndexParamsTrait { + fn as_raw_mut_HierarchicalClusteringIndexParams(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for HierarchicalClusteringIndexParams { #[inline] @@ -697,6 +675,83 @@ pub mod flann { } } + boxed_cast_base! { HierarchicalClusteringIndexParams, crate::flann::IndexParams, cv_flann_HierarchicalClusteringIndexParams_to_IndexParams } + + impl crate::flann::IndexParamsTraitConst for HierarchicalClusteringIndexParams { + #[inline] fn as_raw_IndexParams(&self) -> *const c_void { self.as_raw() } + } + + impl crate::flann::IndexParamsTrait for HierarchicalClusteringIndexParams { + #[inline] fn as_raw_mut_IndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { HierarchicalClusteringIndexParams, crate::flann::IndexParamsTraitConst, as_raw_IndexParams, crate::flann::IndexParamsTrait, as_raw_mut_IndexParams } + + impl crate::flann::HierarchicalClusteringIndexParamsTraitConst for HierarchicalClusteringIndexParams { + #[inline] fn as_raw_HierarchicalClusteringIndexParams(&self) -> *const c_void { self.as_raw() } + } + + impl crate::flann::HierarchicalClusteringIndexParamsTrait for HierarchicalClusteringIndexParams { + #[inline] fn as_raw_mut_HierarchicalClusteringIndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { HierarchicalClusteringIndexParams, crate::flann::HierarchicalClusteringIndexParamsTraitConst, as_raw_HierarchicalClusteringIndexParams, crate::flann::HierarchicalClusteringIndexParamsTrait, as_raw_mut_HierarchicalClusteringIndexParams } + + pub struct Index { + ptr: *mut c_void, + } + + opencv_type_boxed! { Index } + + impl Drop for Index { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_flann_Index_delete(self.as_raw_mut_Index()) }; + } + } + + unsafe impl Send for Index {} + + impl Index { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_flann_Index_Index(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::flann::Index::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## C++ default parameters + /// * dist_type: cvflann::FLANN_DIST_L2 + #[inline] + pub fn new(features: &impl ToInputArray, params: &impl crate::flann::IndexParamsTraitConst, dist_type: crate::flann::flann_distance_t) -> Result { + input_array_arg!(features); + return_send!(via ocvrs_return); + unsafe { sys::cv_flann_Index_Index_const__InputArrayR_const_IndexParamsR_flann_distance_t(features.as_raw__InputArray(), params.as_raw_IndexParams(), dist_type, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::flann::Index::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * dist_type: cvflann::FLANN_DIST_L2 + #[inline] + pub fn new_def(features: &impl ToInputArray, params: &impl crate::flann::IndexParamsTraitConst) -> Result { + input_array_arg!(features); + return_send!(via ocvrs_return); + unsafe { sys::cv_flann_Index_Index_const__InputArrayR_const_IndexParamsR(features.as_raw__InputArray(), params.as_raw_IndexParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::flann::Index::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::flann::Index] pub trait IndexTraitConst { fn as_raw_Index(&self) -> *const c_void; @@ -840,21 +895,14 @@ pub mod flann { } - pub struct Index { - ptr: *mut c_void, - } - - opencv_type_boxed! { Index } - - impl Drop for Index { + impl std::fmt::Debug for Index { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_flann_Index_delete(self.as_raw_mut_Index()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Index") + .finish() } } - unsafe impl Send for Index {} - impl crate::flann::IndexTraitConst for Index { #[inline] fn as_raw_Index(&self) -> *const c_void { self.as_raw() } } @@ -865,54 +913,34 @@ pub mod flann { boxed_ref! { Index, crate::flann::IndexTraitConst, as_raw_Index, crate::flann::IndexTrait, as_raw_mut_Index } - impl Index { + pub struct IndexParams { + ptr: *mut c_void, + } + + opencv_type_boxed! { IndexParams } + + impl Drop for IndexParams { #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_flann_Index_Index(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::flann::Index::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_flann_IndexParams_delete(self.as_raw_mut_IndexParams()) }; } + } - /// ## C++ default parameters - /// * dist_type: cvflann::FLANN_DIST_L2 - #[inline] - pub fn new(features: &impl ToInputArray, params: &impl crate::flann::IndexParamsTraitConst, dist_type: crate::flann::flann_distance_t) -> Result { - input_array_arg!(features); - return_send!(via ocvrs_return); - unsafe { sys::cv_flann_Index_Index_const__InputArrayR_const_IndexParamsR_flann_distance_t(features.as_raw__InputArray(), params.as_raw_IndexParams(), dist_type, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::flann::Index::opencv_from_extern(ret) }; - Ok(ret) - } + unsafe impl Send for IndexParams {} - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * dist_type: cvflann::FLANN_DIST_L2 + impl IndexParams { #[inline] - pub fn new_def(features: &impl ToInputArray, params: &impl crate::flann::IndexParamsTraitConst) -> Result { - input_array_arg!(features); + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_flann_Index_Index_const__InputArrayR_const_IndexParamsR(features.as_raw__InputArray(), params.as_raw_IndexParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_flann_IndexParams_IndexParams(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::flann::Index::opencv_from_extern(ret) }; + let ret = unsafe { crate::flann::IndexParams::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for Index { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Index") - .finish() - } - } - /// Constant methods for [crate::flann::IndexParams] pub trait IndexParamsTraitConst { fn as_raw_IndexParams(&self) -> *const c_void; @@ -1084,21 +1112,14 @@ pub mod flann { } - pub struct IndexParams { - ptr: *mut c_void, - } - - opencv_type_boxed! { IndexParams } - - impl Drop for IndexParams { + impl std::fmt::Debug for IndexParams { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_flann_IndexParams_delete(self.as_raw_mut_IndexParams()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("IndexParams") + .finish() } } - unsafe impl Send for IndexParams {} - impl crate::flann::IndexParamsTraitConst for IndexParams { #[inline] fn as_raw_IndexParams(&self) -> *const c_void { self.as_raw() } } @@ -1109,39 +1130,6 @@ pub mod flann { boxed_ref! { IndexParams, crate::flann::IndexParamsTraitConst, as_raw_IndexParams, crate::flann::IndexParamsTrait, as_raw_mut_IndexParams } - impl IndexParams { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_flann_IndexParams_IndexParams(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::flann::IndexParams::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for IndexParams { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("IndexParams") - .finish() - } - } - - /// Constant methods for [crate::flann::KDTreeIndexParams] - pub trait KDTreeIndexParamsTraitConst: crate::flann::IndexParamsTraitConst { - fn as_raw_KDTreeIndexParams(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::flann::KDTreeIndexParams] - pub trait KDTreeIndexParamsTrait: crate::flann::IndexParamsTrait + crate::flann::KDTreeIndexParamsTraitConst { - fn as_raw_mut_KDTreeIndexParams(&mut self) -> *mut c_void; - - } - pub struct KDTreeIndexParams { ptr: *mut c_void, } @@ -1157,26 +1145,6 @@ pub mod flann { unsafe impl Send for KDTreeIndexParams {} - impl crate::flann::IndexParamsTraitConst for KDTreeIndexParams { - #[inline] fn as_raw_IndexParams(&self) -> *const c_void { self.as_raw() } - } - - impl crate::flann::IndexParamsTrait for KDTreeIndexParams { - #[inline] fn as_raw_mut_IndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { KDTreeIndexParams, crate::flann::IndexParamsTraitConst, as_raw_IndexParams, crate::flann::IndexParamsTrait, as_raw_mut_IndexParams } - - impl crate::flann::KDTreeIndexParamsTraitConst for KDTreeIndexParams { - #[inline] fn as_raw_KDTreeIndexParams(&self) -> *const c_void { self.as_raw() } - } - - impl crate::flann::KDTreeIndexParamsTrait for KDTreeIndexParams { - #[inline] fn as_raw_mut_KDTreeIndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { KDTreeIndexParams, crate::flann::KDTreeIndexParamsTraitConst, as_raw_KDTreeIndexParams, crate::flann::KDTreeIndexParamsTrait, as_raw_mut_KDTreeIndexParams } - impl KDTreeIndexParams { /// ## C++ default parameters /// * trees: 4 @@ -1205,7 +1173,17 @@ pub mod flann { } - boxed_cast_base! { KDTreeIndexParams, crate::flann::IndexParams, cv_flann_KDTreeIndexParams_to_IndexParams } + /// Constant methods for [crate::flann::KDTreeIndexParams] + pub trait KDTreeIndexParamsTraitConst: crate::flann::IndexParamsTraitConst { + fn as_raw_KDTreeIndexParams(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::flann::KDTreeIndexParams] + pub trait KDTreeIndexParamsTrait: crate::flann::IndexParamsTrait + crate::flann::KDTreeIndexParamsTraitConst { + fn as_raw_mut_KDTreeIndexParams(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for KDTreeIndexParams { #[inline] @@ -1215,18 +1193,28 @@ pub mod flann { } } - /// Constant methods for [crate::flann::KMeansIndexParams] - pub trait KMeansIndexParamsTraitConst: crate::flann::IndexParamsTraitConst { - fn as_raw_KMeansIndexParams(&self) -> *const c_void; + boxed_cast_base! { KDTreeIndexParams, crate::flann::IndexParams, cv_flann_KDTreeIndexParams_to_IndexParams } + impl crate::flann::IndexParamsTraitConst for KDTreeIndexParams { + #[inline] fn as_raw_IndexParams(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::flann::KMeansIndexParams] - pub trait KMeansIndexParamsTrait: crate::flann::IndexParamsTrait + crate::flann::KMeansIndexParamsTraitConst { - fn as_raw_mut_KMeansIndexParams(&mut self) -> *mut c_void; + impl crate::flann::IndexParamsTrait for KDTreeIndexParams { + #[inline] fn as_raw_mut_IndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { KDTreeIndexParams, crate::flann::IndexParamsTraitConst, as_raw_IndexParams, crate::flann::IndexParamsTrait, as_raw_mut_IndexParams } + impl crate::flann::KDTreeIndexParamsTraitConst for KDTreeIndexParams { + #[inline] fn as_raw_KDTreeIndexParams(&self) -> *const c_void { self.as_raw() } } + impl crate::flann::KDTreeIndexParamsTrait for KDTreeIndexParams { + #[inline] fn as_raw_mut_KDTreeIndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { KDTreeIndexParams, crate::flann::KDTreeIndexParamsTraitConst, as_raw_KDTreeIndexParams, crate::flann::KDTreeIndexParamsTrait, as_raw_mut_KDTreeIndexParams } + pub struct KMeansIndexParams { ptr: *mut c_void, } @@ -1242,26 +1230,6 @@ pub mod flann { unsafe impl Send for KMeansIndexParams {} - impl crate::flann::IndexParamsTraitConst for KMeansIndexParams { - #[inline] fn as_raw_IndexParams(&self) -> *const c_void { self.as_raw() } - } - - impl crate::flann::IndexParamsTrait for KMeansIndexParams { - #[inline] fn as_raw_mut_IndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { KMeansIndexParams, crate::flann::IndexParamsTraitConst, as_raw_IndexParams, crate::flann::IndexParamsTrait, as_raw_mut_IndexParams } - - impl crate::flann::KMeansIndexParamsTraitConst for KMeansIndexParams { - #[inline] fn as_raw_KMeansIndexParams(&self) -> *const c_void { self.as_raw() } - } - - impl crate::flann::KMeansIndexParamsTrait for KMeansIndexParams { - #[inline] fn as_raw_mut_KMeansIndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { KMeansIndexParams, crate::flann::KMeansIndexParamsTraitConst, as_raw_KMeansIndexParams, crate::flann::KMeansIndexParamsTrait, as_raw_mut_KMeansIndexParams } - impl KMeansIndexParams { /// ## C++ default parameters /// * branching: 32 @@ -1296,7 +1264,17 @@ pub mod flann { } - boxed_cast_base! { KMeansIndexParams, crate::flann::IndexParams, cv_flann_KMeansIndexParams_to_IndexParams } + /// Constant methods for [crate::flann::KMeansIndexParams] + pub trait KMeansIndexParamsTraitConst: crate::flann::IndexParamsTraitConst { + fn as_raw_KMeansIndexParams(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::flann::KMeansIndexParams] + pub trait KMeansIndexParamsTrait: crate::flann::IndexParamsTrait + crate::flann::KMeansIndexParamsTraitConst { + fn as_raw_mut_KMeansIndexParams(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for KMeansIndexParams { #[inline] @@ -1306,18 +1284,28 @@ pub mod flann { } } - /// Constant methods for [crate::flann::LinearIndexParams] - pub trait LinearIndexParamsTraitConst: crate::flann::IndexParamsTraitConst { - fn as_raw_LinearIndexParams(&self) -> *const c_void; + boxed_cast_base! { KMeansIndexParams, crate::flann::IndexParams, cv_flann_KMeansIndexParams_to_IndexParams } + impl crate::flann::IndexParamsTraitConst for KMeansIndexParams { + #[inline] fn as_raw_IndexParams(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::flann::LinearIndexParams] - pub trait LinearIndexParamsTrait: crate::flann::IndexParamsTrait + crate::flann::LinearIndexParamsTraitConst { - fn as_raw_mut_LinearIndexParams(&mut self) -> *mut c_void; + impl crate::flann::IndexParamsTrait for KMeansIndexParams { + #[inline] fn as_raw_mut_IndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } + } + boxed_ref! { KMeansIndexParams, crate::flann::IndexParamsTraitConst, as_raw_IndexParams, crate::flann::IndexParamsTrait, as_raw_mut_IndexParams } + + impl crate::flann::KMeansIndexParamsTraitConst for KMeansIndexParams { + #[inline] fn as_raw_KMeansIndexParams(&self) -> *const c_void { self.as_raw() } } + impl crate::flann::KMeansIndexParamsTrait for KMeansIndexParams { + #[inline] fn as_raw_mut_KMeansIndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { KMeansIndexParams, crate::flann::KMeansIndexParamsTraitConst, as_raw_KMeansIndexParams, crate::flann::KMeansIndexParamsTrait, as_raw_mut_KMeansIndexParams } + pub struct LinearIndexParams { ptr: *mut c_void, } @@ -1333,26 +1321,6 @@ pub mod flann { unsafe impl Send for LinearIndexParams {} - impl crate::flann::IndexParamsTraitConst for LinearIndexParams { - #[inline] fn as_raw_IndexParams(&self) -> *const c_void { self.as_raw() } - } - - impl crate::flann::IndexParamsTrait for LinearIndexParams { - #[inline] fn as_raw_mut_IndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { LinearIndexParams, crate::flann::IndexParamsTraitConst, as_raw_IndexParams, crate::flann::IndexParamsTrait, as_raw_mut_IndexParams } - - impl crate::flann::LinearIndexParamsTraitConst for LinearIndexParams { - #[inline] fn as_raw_LinearIndexParams(&self) -> *const c_void { self.as_raw() } - } - - impl crate::flann::LinearIndexParamsTrait for LinearIndexParams { - #[inline] fn as_raw_mut_LinearIndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { LinearIndexParams, crate::flann::LinearIndexParamsTraitConst, as_raw_LinearIndexParams, crate::flann::LinearIndexParamsTrait, as_raw_mut_LinearIndexParams } - impl LinearIndexParams { #[inline] pub fn default() -> Result { @@ -1366,7 +1334,17 @@ pub mod flann { } - boxed_cast_base! { LinearIndexParams, crate::flann::IndexParams, cv_flann_LinearIndexParams_to_IndexParams } + /// Constant methods for [crate::flann::LinearIndexParams] + pub trait LinearIndexParamsTraitConst: crate::flann::IndexParamsTraitConst { + fn as_raw_LinearIndexParams(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::flann::LinearIndexParams] + pub trait LinearIndexParamsTrait: crate::flann::IndexParamsTrait + crate::flann::LinearIndexParamsTraitConst { + fn as_raw_mut_LinearIndexParams(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for LinearIndexParams { #[inline] @@ -1376,18 +1354,28 @@ pub mod flann { } } - /// Constant methods for [crate::flann::LshIndexParams] - pub trait LshIndexParamsTraitConst: crate::flann::IndexParamsTraitConst { - fn as_raw_LshIndexParams(&self) -> *const c_void; + boxed_cast_base! { LinearIndexParams, crate::flann::IndexParams, cv_flann_LinearIndexParams_to_IndexParams } + + impl crate::flann::IndexParamsTraitConst for LinearIndexParams { + #[inline] fn as_raw_IndexParams(&self) -> *const c_void { self.as_raw() } + } + impl crate::flann::IndexParamsTrait for LinearIndexParams { + #[inline] fn as_raw_mut_IndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } } - /// Mutable methods for [crate::flann::LshIndexParams] - pub trait LshIndexParamsTrait: crate::flann::IndexParamsTrait + crate::flann::LshIndexParamsTraitConst { - fn as_raw_mut_LshIndexParams(&mut self) -> *mut c_void; + boxed_ref! { LinearIndexParams, crate::flann::IndexParamsTraitConst, as_raw_IndexParams, crate::flann::IndexParamsTrait, as_raw_mut_IndexParams } + + impl crate::flann::LinearIndexParamsTraitConst for LinearIndexParams { + #[inline] fn as_raw_LinearIndexParams(&self) -> *const c_void { self.as_raw() } + } + impl crate::flann::LinearIndexParamsTrait for LinearIndexParams { + #[inline] fn as_raw_mut_LinearIndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { LinearIndexParams, crate::flann::LinearIndexParamsTraitConst, as_raw_LinearIndexParams, crate::flann::LinearIndexParamsTrait, as_raw_mut_LinearIndexParams } + pub struct LshIndexParams { ptr: *mut c_void, } @@ -1403,26 +1391,6 @@ pub mod flann { unsafe impl Send for LshIndexParams {} - impl crate::flann::IndexParamsTraitConst for LshIndexParams { - #[inline] fn as_raw_IndexParams(&self) -> *const c_void { self.as_raw() } - } - - impl crate::flann::IndexParamsTrait for LshIndexParams { - #[inline] fn as_raw_mut_IndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { LshIndexParams, crate::flann::IndexParamsTraitConst, as_raw_IndexParams, crate::flann::IndexParamsTrait, as_raw_mut_IndexParams } - - impl crate::flann::LshIndexParamsTraitConst for LshIndexParams { - #[inline] fn as_raw_LshIndexParams(&self) -> *const c_void { self.as_raw() } - } - - impl crate::flann::LshIndexParamsTrait for LshIndexParams { - #[inline] fn as_raw_mut_LshIndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { LshIndexParams, crate::flann::LshIndexParamsTraitConst, as_raw_LshIndexParams, crate::flann::LshIndexParamsTrait, as_raw_mut_LshIndexParams } - impl LshIndexParams { #[inline] pub fn new(table_number: i32, key_size: i32, multi_probe_level: i32) -> Result { @@ -1436,7 +1404,17 @@ pub mod flann { } - boxed_cast_base! { LshIndexParams, crate::flann::IndexParams, cv_flann_LshIndexParams_to_IndexParams } + /// Constant methods for [crate::flann::LshIndexParams] + pub trait LshIndexParamsTraitConst: crate::flann::IndexParamsTraitConst { + fn as_raw_LshIndexParams(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::flann::LshIndexParams] + pub trait LshIndexParamsTrait: crate::flann::IndexParamsTrait + crate::flann::LshIndexParamsTraitConst { + fn as_raw_mut_LshIndexParams(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for LshIndexParams { #[inline] @@ -1446,18 +1424,28 @@ pub mod flann { } } - /// Constant methods for [crate::flann::SavedIndexParams] - pub trait SavedIndexParamsTraitConst: crate::flann::IndexParamsTraitConst { - fn as_raw_SavedIndexParams(&self) -> *const c_void; + boxed_cast_base! { LshIndexParams, crate::flann::IndexParams, cv_flann_LshIndexParams_to_IndexParams } + impl crate::flann::IndexParamsTraitConst for LshIndexParams { + #[inline] fn as_raw_IndexParams(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::flann::SavedIndexParams] - pub trait SavedIndexParamsTrait: crate::flann::IndexParamsTrait + crate::flann::SavedIndexParamsTraitConst { - fn as_raw_mut_SavedIndexParams(&mut self) -> *mut c_void; + impl crate::flann::IndexParamsTrait for LshIndexParams { + #[inline] fn as_raw_mut_IndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { LshIndexParams, crate::flann::IndexParamsTraitConst, as_raw_IndexParams, crate::flann::IndexParamsTrait, as_raw_mut_IndexParams } + impl crate::flann::LshIndexParamsTraitConst for LshIndexParams { + #[inline] fn as_raw_LshIndexParams(&self) -> *const c_void { self.as_raw() } } + impl crate::flann::LshIndexParamsTrait for LshIndexParams { + #[inline] fn as_raw_mut_LshIndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { LshIndexParams, crate::flann::LshIndexParamsTraitConst, as_raw_LshIndexParams, crate::flann::LshIndexParamsTrait, as_raw_mut_LshIndexParams } + pub struct SavedIndexParams { ptr: *mut c_void, } @@ -1473,26 +1461,6 @@ pub mod flann { unsafe impl Send for SavedIndexParams {} - impl crate::flann::IndexParamsTraitConst for SavedIndexParams { - #[inline] fn as_raw_IndexParams(&self) -> *const c_void { self.as_raw() } - } - - impl crate::flann::IndexParamsTrait for SavedIndexParams { - #[inline] fn as_raw_mut_IndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { SavedIndexParams, crate::flann::IndexParamsTraitConst, as_raw_IndexParams, crate::flann::IndexParamsTrait, as_raw_mut_IndexParams } - - impl crate::flann::SavedIndexParamsTraitConst for SavedIndexParams { - #[inline] fn as_raw_SavedIndexParams(&self) -> *const c_void { self.as_raw() } - } - - impl crate::flann::SavedIndexParamsTrait for SavedIndexParams { - #[inline] fn as_raw_mut_SavedIndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { SavedIndexParams, crate::flann::SavedIndexParamsTraitConst, as_raw_SavedIndexParams, crate::flann::SavedIndexParamsTrait, as_raw_mut_SavedIndexParams } - impl SavedIndexParams { #[inline] pub fn new(filename: &str) -> Result { @@ -1507,7 +1475,17 @@ pub mod flann { } - boxed_cast_base! { SavedIndexParams, crate::flann::IndexParams, cv_flann_SavedIndexParams_to_IndexParams } + /// Constant methods for [crate::flann::SavedIndexParams] + pub trait SavedIndexParamsTraitConst: crate::flann::IndexParamsTraitConst { + fn as_raw_SavedIndexParams(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::flann::SavedIndexParams] + pub trait SavedIndexParamsTrait: crate::flann::IndexParamsTrait + crate::flann::SavedIndexParamsTraitConst { + fn as_raw_mut_SavedIndexParams(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for SavedIndexParams { #[inline] @@ -1517,18 +1495,28 @@ pub mod flann { } } - /// Constant methods for [crate::flann::SearchParams] - pub trait SearchParamsTraitConst: crate::flann::IndexParamsTraitConst { - fn as_raw_SearchParams(&self) -> *const c_void; + boxed_cast_base! { SavedIndexParams, crate::flann::IndexParams, cv_flann_SavedIndexParams_to_IndexParams } + impl crate::flann::IndexParamsTraitConst for SavedIndexParams { + #[inline] fn as_raw_IndexParams(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::flann::SearchParams] - pub trait SearchParamsTrait: crate::flann::IndexParamsTrait + crate::flann::SearchParamsTraitConst { - fn as_raw_mut_SearchParams(&mut self) -> *mut c_void; + impl crate::flann::IndexParamsTrait for SavedIndexParams { + #[inline] fn as_raw_mut_IndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { SavedIndexParams, crate::flann::IndexParamsTraitConst, as_raw_IndexParams, crate::flann::IndexParamsTrait, as_raw_mut_IndexParams } + impl crate::flann::SavedIndexParamsTraitConst for SavedIndexParams { + #[inline] fn as_raw_SavedIndexParams(&self) -> *const c_void { self.as_raw() } + } + + impl crate::flann::SavedIndexParamsTrait for SavedIndexParams { + #[inline] fn as_raw_mut_SavedIndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { SavedIndexParams, crate::flann::SavedIndexParamsTraitConst, as_raw_SavedIndexParams, crate::flann::SavedIndexParamsTrait, as_raw_mut_SavedIndexParams } + pub struct SearchParams { ptr: *mut c_void, } @@ -1544,26 +1532,6 @@ pub mod flann { unsafe impl Send for SearchParams {} - impl crate::flann::IndexParamsTraitConst for SearchParams { - #[inline] fn as_raw_IndexParams(&self) -> *const c_void { self.as_raw() } - } - - impl crate::flann::IndexParamsTrait for SearchParams { - #[inline] fn as_raw_mut_IndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { SearchParams, crate::flann::IndexParamsTraitConst, as_raw_IndexParams, crate::flann::IndexParamsTrait, as_raw_mut_IndexParams } - - impl crate::flann::SearchParamsTraitConst for SearchParams { - #[inline] fn as_raw_SearchParams(&self) -> *const c_void { self.as_raw() } - } - - impl crate::flann::SearchParamsTrait for SearchParams { - #[inline] fn as_raw_mut_SearchParams(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { SearchParams, crate::flann::SearchParamsTraitConst, as_raw_SearchParams, crate::flann::SearchParamsTrait, as_raw_mut_SearchParams } - impl SearchParams { #[inline] pub fn new(checks: i32, eps: f32, sorted: bool, explore_all_trees: bool) -> Result { @@ -1606,7 +1574,17 @@ pub mod flann { } - boxed_cast_base! { SearchParams, crate::flann::IndexParams, cv_flann_SearchParams_to_IndexParams } + /// Constant methods for [crate::flann::SearchParams] + pub trait SearchParamsTraitConst: crate::flann::IndexParamsTraitConst { + fn as_raw_SearchParams(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::flann::SearchParams] + pub trait SearchParamsTrait: crate::flann::IndexParamsTrait + crate::flann::SearchParamsTraitConst { + fn as_raw_mut_SearchParams(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for SearchParams { #[inline] @@ -1615,4 +1593,27 @@ pub mod flann { .finish() } } + + boxed_cast_base! { SearchParams, crate::flann::IndexParams, cv_flann_SearchParams_to_IndexParams } + + impl crate::flann::IndexParamsTraitConst for SearchParams { + #[inline] fn as_raw_IndexParams(&self) -> *const c_void { self.as_raw() } + } + + impl crate::flann::IndexParamsTrait for SearchParams { + #[inline] fn as_raw_mut_IndexParams(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { SearchParams, crate::flann::IndexParamsTraitConst, as_raw_IndexParams, crate::flann::IndexParamsTrait, as_raw_mut_IndexParams } + + impl crate::flann::SearchParamsTraitConst for SearchParams { + #[inline] fn as_raw_SearchParams(&self) -> *const c_void { self.as_raw() } + } + + impl crate::flann::SearchParamsTrait for SearchParams { + #[inline] fn as_raw_mut_SearchParams(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { SearchParams, crate::flann::SearchParamsTraitConst, as_raw_SearchParams, crate::flann::SearchParamsTrait, as_raw_mut_SearchParams } + } diff --git a/docs/freetype.rs b/docs/freetype.rs index c570500d3..875e89ae9 100644 --- a/docs/freetype.rs +++ b/docs/freetype.rs @@ -30,6 +30,21 @@ pub mod freetype { Ok(ret) } + pub struct FreeType2 { + ptr: *mut c_void, + } + + opencv_type_boxed! { FreeType2 } + + impl Drop for FreeType2 { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_freetype_FreeType2_delete(self.as_raw_mut_FreeType2()) }; + } + } + + unsafe impl Send for FreeType2 {} + /// Constant methods for [crate::freetype::FreeType2] pub trait FreeType2TraitConst: core::AlgorithmTraitConst { fn as_raw_FreeType2(&self) -> *const c_void; @@ -186,20 +201,15 @@ pub mod freetype { } - pub struct FreeType2 { - ptr: *mut c_void, - } - - opencv_type_boxed! { FreeType2 } - - impl Drop for FreeType2 { + impl std::fmt::Debug for FreeType2 { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_freetype_FreeType2_delete(self.as_raw_mut_FreeType2()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FreeType2") + .finish() } } - unsafe impl Send for FreeType2 {} + boxed_cast_base! { FreeType2, core::Algorithm, cv_freetype_FreeType2_to_Algorithm } impl core::AlgorithmTraitConst for FreeType2 { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -221,16 +231,4 @@ pub mod freetype { boxed_ref! { FreeType2, crate::freetype::FreeType2TraitConst, as_raw_FreeType2, crate::freetype::FreeType2Trait, as_raw_mut_FreeType2 } - impl FreeType2 { - } - - boxed_cast_base! { FreeType2, core::Algorithm, cv_freetype_FreeType2_to_Algorithm } - - impl std::fmt::Debug for FreeType2 { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FreeType2") - .finish() - } - } } diff --git a/docs/fuzzy.rs b/docs/fuzzy.rs index 3822e6c1e..f2b7a3f94 100644 --- a/docs/fuzzy.rs +++ b/docs/fuzzy.rs @@ -482,4 +482,5 @@ pub mod fuzzy { let ret = ret.into_result()?; Ok(ret) } + } diff --git a/docs/gapi.rs b/docs/gapi.rs index ad0b064b1..fc4b7bd64 100644 --- a/docs/gapi.rs +++ b/docs/gapi.rs @@ -6106,6 +6106,34 @@ pub mod gapi { Ok(ret) } + pub struct GArg { + ptr: *mut c_void, + } + + opencv_type_boxed! { GArg } + + impl Drop for GArg { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_GArg_delete(self.as_raw_mut_GArg()) }; + } + } + + unsafe impl Send for GArg {} + + impl GArg { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_GArg_GArg(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::GArg::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::gapi::GArg] pub trait GArgTraitConst { fn as_raw_GArg(&self) -> *const c_void; @@ -6150,21 +6178,16 @@ pub mod gapi { } - pub struct GArg { - ptr: *mut c_void, - } - - opencv_type_boxed! { GArg } - - impl Drop for GArg { + impl std::fmt::Debug for GArg { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GArg_delete(self.as_raw_mut_GArg()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GArg") + .field("kind", &crate::gapi::GArgTraitConst::kind(self)) + .field("opaque_kind", &crate::gapi::GArgTraitConst::opaque_kind(self)) + .finish() } } - unsafe impl Send for GArg {} - impl crate::gapi::GArgTraitConst for GArg { #[inline] fn as_raw_GArg(&self) -> *const c_void { self.as_raw() } } @@ -6175,27 +6198,31 @@ pub mod gapi { boxed_ref! { GArg, crate::gapi::GArgTraitConst, as_raw_GArg, crate::gapi::GArgTrait, as_raw_mut_GArg } - impl GArg { + /// \addtogroup gapi_meta_args + pub struct GArrayDesc { + ptr: *mut c_void, + } + + opencv_type_boxed! { GArrayDesc } + + impl Drop for GArrayDesc { #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_GArg_GArg(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::GArg::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_GArrayDesc_delete(self.as_raw_mut_GArrayDesc()) }; } - } - impl std::fmt::Debug for GArg { + unsafe impl Send for GArrayDesc {} + + impl GArrayDesc { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GArg") - .field("kind", &crate::gapi::GArgTraitConst::kind(self)) - .field("opaque_kind", &crate::gapi::GArgTraitConst::opaque_kind(self)) - .finish() + pub fn default() -> crate::gapi::GArrayDesc { + let ret = unsafe { sys::cv_GArrayDesc_defaultNew_const() }; + let ret = unsafe { crate::gapi::GArrayDesc::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::gapi::GArrayDesc] @@ -6219,21 +6246,28 @@ pub mod gapi { } - /// \addtogroup gapi_meta_args - pub struct GArrayDesc { - ptr: *mut c_void, + impl Default for GArrayDesc { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { GArrayDesc } - - impl Drop for GArrayDesc { + impl Clone for GArrayDesc { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GArrayDesc_delete(self.as_raw_mut_GArrayDesc()) }; + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_GArrayDesc_implicitClone_const(self.as_raw_GArrayDesc())) } } } - unsafe impl Send for GArrayDesc {} + impl std::fmt::Debug for GArrayDesc { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GArrayDesc") + .finish() + } + } impl crate::gapi::GArrayDescTraitConst for GArrayDesc { #[inline] fn as_raw_GArrayDesc(&self) -> *const c_void { self.as_raw() } @@ -6245,36 +6279,32 @@ pub mod gapi { boxed_ref! { GArrayDesc, crate::gapi::GArrayDescTraitConst, as_raw_GArrayDesc, crate::gapi::GArrayDescTrait, as_raw_mut_GArrayDesc } - impl GArrayDesc { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_GArrayDesc_defaultNew_const()) } - } - + pub struct GCall { + ptr: *mut c_void, } - impl Clone for GArrayDesc { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_GArrayDesc_implicitClone_const(self.as_raw_GArrayDesc())) } - } - } + opencv_type_boxed! { GCall } - impl std::fmt::Debug for GArrayDesc { + impl Drop for GCall { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GArrayDesc") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_GCall_delete(self.as_raw_mut_GCall()) }; } } - impl Default for GArrayDesc { + unsafe impl Send for GCall {} + + impl GCall { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new(k: &impl crate::gapi::GKernelTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_GCall_GCall_const_GKernelR(k.as_raw_GKernel(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::GCall::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::gapi::GCall] @@ -6418,21 +6448,14 @@ pub mod gapi { } - pub struct GCall { - ptr: *mut c_void, - } - - opencv_type_boxed! { GCall } - - impl Drop for GCall { + impl std::fmt::Debug for GCall { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GCall_delete(self.as_raw_mut_GCall()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GCall") + .finish() } } - unsafe impl Send for GCall {} - impl crate::gapi::GCallTraitConst for GCall { #[inline] fn as_raw_GCall(&self) -> *const c_void { self.as_raw() } } @@ -6443,25 +6466,38 @@ pub mod gapi { boxed_ref! { GCall, crate::gapi::GCallTraitConst, as_raw_GCall, crate::gapi::GCallTrait, as_raw_mut_GCall } - impl GCall { + /// Represents an arbitrary compilation argument. + /// + /// Any value can be wrapped into cv::GCompileArg, but only known ones + /// (to G-API or its backends) can be interpreted correctly. + /// + /// Normally objects of this class shouldn't be created manually, use + /// cv::compile_args() function which automatically wraps everything + /// passed in (a variadic template parameter pack) into a vector of + /// cv::GCompileArg objects. + pub struct GCompileArg { + ptr: *mut c_void, + } + + opencv_type_boxed! { GCompileArg } + + impl Drop for GCompileArg { #[inline] - pub fn new(k: &impl crate::gapi::GKernelTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_GCall_GCall_const_GKernelR(k.as_raw_GKernel(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::GCall::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_GCompileArg_delete(self.as_raw_mut_GCompileArg()) }; } - } - impl std::fmt::Debug for GCall { + unsafe impl Send for GCompileArg {} + + impl GCompileArg { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GCall") - .finish() + pub fn default() -> crate::gapi::GCompileArg { + let ret = unsafe { sys::cv_GCompileArg_GCompileArg() }; + let ret = unsafe { crate::gapi::GCompileArg::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::gapi::GCompileArg] @@ -6490,48 +6526,12 @@ pub mod gapi { } - /// Represents an arbitrary compilation argument. - /// - /// Any value can be wrapped into cv::GCompileArg, but only known ones - /// (to G-API or its backends) can be interpreted correctly. - /// - /// Normally objects of this class shouldn't be created manually, use - /// cv::compile_args() function which automatically wraps everything - /// passed in (a variadic template parameter pack) into a vector of - /// cv::GCompileArg objects. - pub struct GCompileArg { - ptr: *mut c_void, - } - - opencv_type_boxed! { GCompileArg } - - impl Drop for GCompileArg { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GCompileArg_delete(self.as_raw_mut_GCompileArg()) }; - } - } - - unsafe impl Send for GCompileArg {} - - impl crate::gapi::GCompileArgTraitConst for GCompileArg { - #[inline] fn as_raw_GCompileArg(&self) -> *const c_void { self.as_raw() } - } - - impl crate::gapi::GCompileArgTrait for GCompileArg { - #[inline] fn as_raw_mut_GCompileArg(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { GCompileArg, crate::gapi::GCompileArgTraitConst, as_raw_GCompileArg, crate::gapi::GCompileArgTrait, as_raw_mut_GCompileArg } - - impl GCompileArg { + impl Default for GCompileArg { #[inline] - pub fn default() -> crate::gapi::GCompileArg { - let ret = unsafe { sys::cv_GCompileArg_GCompileArg() }; - let ret = unsafe { crate::gapi::GCompileArg::opencv_from_extern(ret) }; - ret + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() } - } impl std::fmt::Debug for GCompileArg { @@ -6543,24 +6543,86 @@ pub mod gapi { } } - impl Default for GCompileArg { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } + impl crate::gapi::GCompileArgTraitConst for GCompileArg { + #[inline] fn as_raw_GCompileArg(&self) -> *const c_void { self.as_raw() } } - /// Constant methods for [crate::gapi::GCompiled] - pub trait GCompiledTraitConst { - fn as_raw_GCompiled(&self) -> *const c_void; + impl crate::gapi::GCompileArgTrait for GCompileArg { + #[inline] fn as_raw_mut_GCompileArg(&mut self) -> *mut c_void { self.as_raw_mut() } + } - /// Check if compiled object is valid (non-empty) - /// - /// ## Returns - /// true if the object is runnable (valid), false otherwise - #[inline] - fn to_bool(&self) -> Result { + boxed_ref! { GCompileArg, crate::gapi::GCompileArgTraitConst, as_raw_GCompileArg, crate::gapi::GCompileArgTrait, as_raw_mut_GCompileArg } + + /// \addtogroup gapi_main_classes + /// / + /// + /// Represents a compiled computation (graph). Can only be used + /// with image / data formats & resolutions it was compiled for, with + /// some exceptions. + /// + /// This class represents a product of graph compilation (calling + /// cv::GComputation::compile()). Objects of this class actually do + /// data processing, and graph execution is incapsulated into objects + /// of this class. Execution model itself depends on kernels and + /// backends which were using during the compilation, see [gapi_compile_args] for details. + /// + /// In a general case, GCompiled objects can be applied to data only in + /// that formats/resolutions they were compiled for (see [gapi_meta_args]). However, if the underlying backends allow, a + /// compiled object can be _reshaped_ to handle data (images) of + /// different resolution, though formats and types must remain the same. + /// + /// GCompiled is very similar to `std::function<>` in its semantics -- + /// running it looks like a function call in the user code. + /// + /// At the moment, GCompiled objects are not reentrant -- generally, + /// the objects are stateful since graph execution itself is a stateful + /// process and this state is now maintained in GCompiled's own memory + /// (not on the process stack). + /// + /// At the same time, two different GCompiled objects produced from the + /// single cv::GComputation are completely independent and can be used + /// concurrently. + /// ## See also + /// GStreamingCompiled + pub struct GCompiled { + ptr: *mut c_void, + } + + opencv_type_boxed! { GCompiled } + + impl Drop for GCompiled { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_GCompiled_delete(self.as_raw_mut_GCompiled()) }; + } + } + + unsafe impl Send for GCompiled {} + + impl GCompiled { + /// Constructs an empty object + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_GCompiled_GCompiled(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::GCompiled::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::gapi::GCompiled] + pub trait GCompiledTraitConst { + fn as_raw_GCompiled(&self) -> *const c_void; + + /// Check if compiled object is valid (non-empty) + /// + /// ## Returns + /// true if the object is runnable (valid), false otherwise + #[inline] + fn to_bool(&self) -> Result { return_send!(via ocvrs_return); unsafe { sys::cv_GCompiled_operator_bool_const(self.as_raw_GCompiled(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); @@ -6794,52 +6856,14 @@ pub mod gapi { } - /// \addtogroup gapi_main_classes - /// / - /// - /// Represents a compiled computation (graph). Can only be used - /// with image / data formats & resolutions it was compiled for, with - /// some exceptions. - /// - /// This class represents a product of graph compilation (calling - /// cv::GComputation::compile()). Objects of this class actually do - /// data processing, and graph execution is incapsulated into objects - /// of this class. Execution model itself depends on kernels and - /// backends which were using during the compilation, see [gapi_compile_args] for details. - /// - /// In a general case, GCompiled objects can be applied to data only in - /// that formats/resolutions they were compiled for (see [gapi_meta_args]). However, if the underlying backends allow, a - /// compiled object can be _reshaped_ to handle data (images) of - /// different resolution, though formats and types must remain the same. - /// - /// GCompiled is very similar to `std::function<>` in its semantics -- - /// running it looks like a function call in the user code. - /// - /// At the moment, GCompiled objects are not reentrant -- generally, - /// the objects are stateful since graph execution itself is a stateful - /// process and this state is now maintained in GCompiled's own memory - /// (not on the process stack). - /// - /// At the same time, two different GCompiled objects produced from the - /// single cv::GComputation are completely independent and can be used - /// concurrently. - /// ## See also - /// GStreamingCompiled - pub struct GCompiled { - ptr: *mut c_void, - } - - opencv_type_boxed! { GCompiled } - - impl Drop for GCompiled { + impl std::fmt::Debug for GCompiled { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GCompiled_delete(self.as_raw_mut_GCompiled()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GCompiled") + .finish() } } - unsafe impl Send for GCompiled {} - impl crate::gapi::GCompiledTraitConst for GCompiled { #[inline] fn as_raw_GCompiled(&self) -> *const c_void { self.as_raw() } } @@ -6850,61 +6874,293 @@ pub mod gapi { boxed_ref! { GCompiled, crate::gapi::GCompiledTraitConst, as_raw_GCompiled, crate::gapi::GCompiledTrait, as_raw_mut_GCompiled } - impl GCompiled { - /// Constructs an empty object - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_GCompiled_GCompiled(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::GCompiled::opencv_from_extern(ret) }; - Ok(ret) - } - + /// GComputation class represents a captured computation + /// graph. GComputation objects form boundaries for expression code + /// user writes with G-API, allowing to compile and execute it. + /// + /// G-API computations are defined with input/output data + /// objects. G-API will track automatically which operations connect + /// specified outputs to the inputs, forming up a call graph to be + /// executed. The below example expresses calculation of Sobel operator + /// for edge detection (![inline formula](https://latex.codecogs.com/png.latex?G%20%3D%20%5Csqrt%7BG%5Fx%5E2%20%2B%20G%5Fy%5E2%7D)): + /// + /// [graph_def](https://github.com/opencv/opencv_contrib/blob/4.11.0/modules/hdf/samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp#L1) + /// + /// Full pipeline can be now captured with this object declaration: + /// + /// [graph_cap_full](https://github.com/opencv/opencv_contrib/blob/4.11.0/modules/hdf/samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp#L1) + /// + /// Input/output data objects on which a call graph should be + /// reconstructed are passed using special wrappers cv::GIn and + /// cv::GOut. G-API will track automatically which operations form a + /// path from inputs to outputs and build the execution graph appropriately. + /// + /// Note that cv::GComputation doesn't take ownership on data objects + /// it is defined. Moreover, multiple GComputation objects may be + /// defined on the same expressions, e.g. a smaller pipeline which + /// expects that image gradients are already pre-calculated may be + /// defined like this: + /// + /// [graph_cap_sub](https://github.com/opencv/opencv_contrib/blob/4.11.0/modules/hdf/samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp#L1) + /// + /// The resulting graph would expect two inputs and produce one + /// output. In this case, it doesn't matter if gx/gy data objects are + /// results of cv::gapi::Sobel operators -- G-API will stop unrolling + /// expressions and building the underlying graph one reaching this + /// data objects. + /// + /// The way how GComputation is defined is important as its definition + /// specifies graph _protocol_ -- the way how the graph should be + /// used. Protocol is defined by number of inputs, number of outputs, + /// and shapes of inputs and outputs. + /// + /// In the above example, sobelEdge expects one Mat on input and + /// produces one Mat; while sobelEdgeSub expects two Mats on input and + /// produces one Mat. GComputation's protocol defines how other + /// computation methods should be used -- cv::GComputation::compile() and + /// cv::GComputation::apply(). For example, if a graph is defined on + /// two GMat inputs, two cv::Mat objects have to be passed to apply() + /// for execution. GComputation checks protocol correctness in runtime + /// so passing a different number of objects in apply() or passing + /// cv::Scalar instead of cv::Mat there would compile well as a C++ + /// source but raise an exception in run-time. G-API also comes with a + /// typed wrapper cv::GComputationT<> which introduces this type-checking in + /// compile-time. + /// + /// cv::GComputation itself is a thin object which just captures what + /// the graph is. The compiled graph (which actually process data) is + /// represented by class GCompiled. Use compile() method to generate a + /// compiled graph with given compile options. cv::GComputation can + /// also be used to process data with implicit graph compilation + /// on-the-fly, see apply() for details. + /// + /// GComputation is a reference-counted object -- once defined, all its + /// copies will refer to the same instance. + /// ## See also + /// GCompiled + pub struct GComputation { + ptr: *mut c_void, } - impl std::fmt::Debug for GCompiled { + opencv_type_boxed! { GComputation } + + impl Drop for GComputation { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GCompiled") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_GComputation_delete(self.as_raw_mut_GComputation()) }; } } - /// Constant methods for [crate::gapi::GComputation] - pub trait GComputationTraitConst { - fn as_raw_GComputation(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::gapi::GComputation] - pub trait GComputationTrait: crate::gapi::GComputationTraitConst { - fn as_raw_mut_GComputation(&mut self) -> *mut c_void; + unsafe impl Send for GComputation {} - /// @private -- Exclude this function from OpenCV documentation + impl GComputation { + /// Defines an unary (one input -- one output) computation /// - /// ## C++ default parameters - /// * args: {} + /// Generic GComputation constructor. + /// + /// Constructs a new graph with a given protocol, specified as a + /// flow of operations connecting input/output objects. Throws if + /// the passed boundaries are invalid, e.g. if there's no + /// functional dependency (path) between given outputs and inputs. + /// + /// ## Parameters + /// * ins: Input data vector. + /// * outs: Output data vector. + /// + /// + /// Note: Don't construct GProtoInputArgs/GProtoOutputArgs objects + /// directly, use cv::GIn()/cv::GOut() wrapper functions instead. + /// ## See also + /// [gapi_data_objects] + /// + /// ## Overloaded parameters + /// + /// * in: input GMat of the defined unary computation + /// * out: output GMat of the defined unary computation #[inline] - fn apply(&mut self, callback: &impl crate::gapi::Detail_ExtractArgsCallbackTraitConst, mut args: crate::gapi::GCompileArgs) -> Result { + pub fn new(mut in_: impl crate::gapi::GMatTrait, mut out: impl crate::gapi::GMatTrait) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_GComputation_apply_const_ExtractArgsCallbackR_GCompileArgsRR(self.as_raw_mut_GComputation(), callback.as_raw_Detail_ExtractArgsCallback(), args.as_raw_mut_VectorOfGCompileArg(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_GComputation_GComputation_GMat_GMat(in_.as_raw_mut_GMat(), out.as_raw_mut_GMat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::GRunArgs::opencv_from_extern(ret) }; + let ret = unsafe { crate::gapi::GComputation::opencv_from_extern(ret) }; Ok(ret) } - /// @private -- Exclude this function from OpenCV documentation + /// Defines an unary (one input -- one output) computation /// - /// ## Note - /// This alternative version of [GComputationTrait::apply] function uses the following default values for its arguments: - /// * args: {} - #[inline] - fn apply_def(&mut self, callback: &impl crate::gapi::Detail_ExtractArgsCallbackTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_GComputation_apply_const_ExtractArgsCallbackR(self.as_raw_mut_GComputation(), callback.as_raw_Detail_ExtractArgsCallback(), ocvrs_return.as_mut_ptr()) }; + /// Generic GComputation constructor. + /// + /// Constructs a new graph with a given protocol, specified as a + /// flow of operations connecting input/output objects. Throws if + /// the passed boundaries are invalid, e.g. if there's no + /// functional dependency (path) between given outputs and inputs. + /// + /// ## Parameters + /// * ins: Input data vector. + /// * outs: Output data vector. + /// + /// + /// Note: Don't construct GProtoInputArgs/GProtoOutputArgs objects + /// directly, use cv::GIn()/cv::GOut() wrapper functions instead. + /// ## See also + /// [gapi_data_objects] + /// + /// ## Overloaded parameters + /// + /// * in: input GMat of the defined unary computation + /// * out: output GScalar of the defined unary computation + #[inline] + pub fn new_1(mut in_: impl crate::gapi::GMatTrait, mut out: impl crate::gapi::GScalarTrait) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_GComputation_GComputation_GMat_GScalar(in_.as_raw_mut_GMat(), out.as_raw_mut_GScalar(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::GComputation::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Defines a binary (two inputs -- one output) computation + /// + /// Generic GComputation constructor. + /// + /// Constructs a new graph with a given protocol, specified as a + /// flow of operations connecting input/output objects. Throws if + /// the passed boundaries are invalid, e.g. if there's no + /// functional dependency (path) between given outputs and inputs. + /// + /// ## Parameters + /// * ins: Input data vector. + /// * outs: Output data vector. + /// + /// + /// Note: Don't construct GProtoInputArgs/GProtoOutputArgs objects + /// directly, use cv::GIn()/cv::GOut() wrapper functions instead. + /// ## See also + /// [gapi_data_objects] + /// + /// ## Overloaded parameters + /// + /// * in1: first input GMat of the defined binary computation + /// * in2: second input GMat of the defined binary computation + /// * out: output GMat of the defined binary computation + #[inline] + pub fn new_2(mut in1: impl crate::gapi::GMatTrait, mut in2: impl crate::gapi::GMatTrait, mut out: impl crate::gapi::GMatTrait) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_GComputation_GComputation_GMat_GMat_GMat(in1.as_raw_mut_GMat(), in2.as_raw_mut_GMat(), out.as_raw_mut_GMat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::GComputation::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Defines a binary (two inputs -- one output) computation + /// + /// Generic GComputation constructor. + /// + /// Constructs a new graph with a given protocol, specified as a + /// flow of operations connecting input/output objects. Throws if + /// the passed boundaries are invalid, e.g. if there's no + /// functional dependency (path) between given outputs and inputs. + /// + /// ## Parameters + /// * ins: Input data vector. + /// * outs: Output data vector. + /// + /// + /// Note: Don't construct GProtoInputArgs/GProtoOutputArgs objects + /// directly, use cv::GIn()/cv::GOut() wrapper functions instead. + /// ## See also + /// [gapi_data_objects] + /// + /// ## Overloaded parameters + /// + /// * in1: first input GMat of the defined binary computation + /// * in2: second input GMat of the defined binary computation + /// * out: output GScalar of the defined binary computation + #[inline] + pub fn new_3(mut in1: impl crate::gapi::GMatTrait, mut in2: impl crate::gapi::GMatTrait, mut out: impl crate::gapi::GScalarTrait) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_GComputation_GComputation_GMat_GMat_GScalar(in1.as_raw_mut_GMat(), in2.as_raw_mut_GMat(), out.as_raw_mut_GScalar(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::GComputation::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Defines a computation with arbitrary input/output number. + /// + /// Generic GComputation constructor. + /// + /// Constructs a new graph with a given protocol, specified as a + /// flow of operations connecting input/output objects. Throws if + /// the passed boundaries are invalid, e.g. if there's no + /// functional dependency (path) between given outputs and inputs. + /// + /// ## Parameters + /// * ins: Input data vector. + /// * outs: Output data vector. + /// + /// + /// Note: Don't construct GProtoInputArgs/GProtoOutputArgs objects + /// directly, use cv::GIn()/cv::GOut() wrapper functions instead. + /// ## See also + /// [gapi_data_objects] + /// + /// ## Overloaded parameters + /// + /// * ins: vector of inputs GMats for this computation + /// * outs: vector of outputs GMats for this computation + /// + /// Use this overload for cases when number of computation + /// inputs/outputs is not known in compile-time -- e.g. when graph + /// is programmatically generated to build an image pyramid with + /// the given number of levels, etc. + #[inline] + pub fn new_4(ins: &core::Vector, outs: &core::Vector) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_GComputation_GComputation_const_vectorLGMatGR_const_vectorLGMatGR(ins.as_raw_VectorOfGMat(), outs.as_raw_VectorOfGMat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::GComputation::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::gapi::GComputation] + pub trait GComputationTraitConst { + fn as_raw_GComputation(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::gapi::GComputation] + pub trait GComputationTrait: crate::gapi::GComputationTraitConst { + fn as_raw_mut_GComputation(&mut self) -> *mut c_void; + + /// @private -- Exclude this function from OpenCV documentation + /// + /// ## C++ default parameters + /// * args: {} + #[inline] + fn apply(&mut self, callback: &impl crate::gapi::Detail_ExtractArgsCallbackTraitConst, mut args: crate::gapi::GCompileArgs) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_GComputation_apply_const_ExtractArgsCallbackR_GCompileArgsRR(self.as_raw_mut_GComputation(), callback.as_raw_Detail_ExtractArgsCallback(), args.as_raw_mut_VectorOfGCompileArg(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::GRunArgs::opencv_from_extern(ret) }; + Ok(ret) + } + + /// @private -- Exclude this function from OpenCV documentation + /// + /// ## Note + /// This alternative version of [GComputationTrait::apply] function uses the following default values for its arguments: + /// * args: {} + #[inline] + fn apply_def(&mut self, callback: &impl crate::gapi::Detail_ExtractArgsCallbackTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_GComputation_apply_const_ExtractArgsCallbackR(self.as_raw_mut_GComputation(), callback.as_raw_Detail_ExtractArgsCallback(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { crate::gapi::GRunArgs::opencv_from_extern(ret) }; @@ -7270,85 +7526,14 @@ pub mod gapi { } - /// GComputation class represents a captured computation - /// graph. GComputation objects form boundaries for expression code - /// user writes with G-API, allowing to compile and execute it. - /// - /// G-API computations are defined with input/output data - /// objects. G-API will track automatically which operations connect - /// specified outputs to the inputs, forming up a call graph to be - /// executed. The below example expresses calculation of Sobel operator - /// for edge detection (![inline formula](https://latex.codecogs.com/png.latex?G%20%3D%20%5Csqrt%7BG%5Fx%5E2%20%2B%20G%5Fy%5E2%7D)): - /// - /// [graph_def](https://github.com/opencv/opencv_contrib/blob/4.11.0/modules/hdf/samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp#L1) - /// - /// Full pipeline can be now captured with this object declaration: - /// - /// [graph_cap_full](https://github.com/opencv/opencv_contrib/blob/4.11.0/modules/hdf/samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp#L1) - /// - /// Input/output data objects on which a call graph should be - /// reconstructed are passed using special wrappers cv::GIn and - /// cv::GOut. G-API will track automatically which operations form a - /// path from inputs to outputs and build the execution graph appropriately. - /// - /// Note that cv::GComputation doesn't take ownership on data objects - /// it is defined. Moreover, multiple GComputation objects may be - /// defined on the same expressions, e.g. a smaller pipeline which - /// expects that image gradients are already pre-calculated may be - /// defined like this: - /// - /// [graph_cap_sub](https://github.com/opencv/opencv_contrib/blob/4.11.0/modules/hdf/samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp#L1) - /// - /// The resulting graph would expect two inputs and produce one - /// output. In this case, it doesn't matter if gx/gy data objects are - /// results of cv::gapi::Sobel operators -- G-API will stop unrolling - /// expressions and building the underlying graph one reaching this - /// data objects. - /// - /// The way how GComputation is defined is important as its definition - /// specifies graph _protocol_ -- the way how the graph should be - /// used. Protocol is defined by number of inputs, number of outputs, - /// and shapes of inputs and outputs. - /// - /// In the above example, sobelEdge expects one Mat on input and - /// produces one Mat; while sobelEdgeSub expects two Mats on input and - /// produces one Mat. GComputation's protocol defines how other - /// computation methods should be used -- cv::GComputation::compile() and - /// cv::GComputation::apply(). For example, if a graph is defined on - /// two GMat inputs, two cv::Mat objects have to be passed to apply() - /// for execution. GComputation checks protocol correctness in runtime - /// so passing a different number of objects in apply() or passing - /// cv::Scalar instead of cv::Mat there would compile well as a C++ - /// source but raise an exception in run-time. G-API also comes with a - /// typed wrapper cv::GComputationT<> which introduces this type-checking in - /// compile-time. - /// - /// cv::GComputation itself is a thin object which just captures what - /// the graph is. The compiled graph (which actually process data) is - /// represented by class GCompiled. Use compile() method to generate a - /// compiled graph with given compile options. cv::GComputation can - /// also be used to process data with implicit graph compilation - /// on-the-fly, see apply() for details. - /// - /// GComputation is a reference-counted object -- once defined, all its - /// copies will refer to the same instance. - /// ## See also - /// GCompiled - pub struct GComputation { - ptr: *mut c_void, - } - - opencv_type_boxed! { GComputation } - - impl Drop for GComputation { + impl std::fmt::Debug for GComputation { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GComputation_delete(self.as_raw_mut_GComputation()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GComputation") + .finish() } } - unsafe impl Send for GComputation {} - impl crate::gapi::GComputationTraitConst for GComputation { #[inline] fn as_raw_GComputation(&self) -> *const c_void { self.as_raw() } } @@ -7359,201 +7544,6 @@ pub mod gapi { boxed_ref! { GComputation, crate::gapi::GComputationTraitConst, as_raw_GComputation, crate::gapi::GComputationTrait, as_raw_mut_GComputation } - impl GComputation { - /// Defines an unary (one input -- one output) computation - /// - /// Generic GComputation constructor. - /// - /// Constructs a new graph with a given protocol, specified as a - /// flow of operations connecting input/output objects. Throws if - /// the passed boundaries are invalid, e.g. if there's no - /// functional dependency (path) between given outputs and inputs. - /// - /// ## Parameters - /// * ins: Input data vector. - /// * outs: Output data vector. - /// - /// - /// Note: Don't construct GProtoInputArgs/GProtoOutputArgs objects - /// directly, use cv::GIn()/cv::GOut() wrapper functions instead. - /// ## See also - /// [gapi_data_objects] - /// - /// ## Overloaded parameters - /// - /// * in: input GMat of the defined unary computation - /// * out: output GMat of the defined unary computation - #[inline] - pub fn new(mut in_: impl crate::gapi::GMatTrait, mut out: impl crate::gapi::GMatTrait) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_GComputation_GComputation_GMat_GMat(in_.as_raw_mut_GMat(), out.as_raw_mut_GMat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::GComputation::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Defines an unary (one input -- one output) computation - /// - /// Generic GComputation constructor. - /// - /// Constructs a new graph with a given protocol, specified as a - /// flow of operations connecting input/output objects. Throws if - /// the passed boundaries are invalid, e.g. if there's no - /// functional dependency (path) between given outputs and inputs. - /// - /// ## Parameters - /// * ins: Input data vector. - /// * outs: Output data vector. - /// - /// - /// Note: Don't construct GProtoInputArgs/GProtoOutputArgs objects - /// directly, use cv::GIn()/cv::GOut() wrapper functions instead. - /// ## See also - /// [gapi_data_objects] - /// - /// ## Overloaded parameters - /// - /// * in: input GMat of the defined unary computation - /// * out: output GScalar of the defined unary computation - #[inline] - pub fn new_1(mut in_: impl crate::gapi::GMatTrait, mut out: impl crate::gapi::GScalarTrait) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_GComputation_GComputation_GMat_GScalar(in_.as_raw_mut_GMat(), out.as_raw_mut_GScalar(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::GComputation::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Defines a binary (two inputs -- one output) computation - /// - /// Generic GComputation constructor. - /// - /// Constructs a new graph with a given protocol, specified as a - /// flow of operations connecting input/output objects. Throws if - /// the passed boundaries are invalid, e.g. if there's no - /// functional dependency (path) between given outputs and inputs. - /// - /// ## Parameters - /// * ins: Input data vector. - /// * outs: Output data vector. - /// - /// - /// Note: Don't construct GProtoInputArgs/GProtoOutputArgs objects - /// directly, use cv::GIn()/cv::GOut() wrapper functions instead. - /// ## See also - /// [gapi_data_objects] - /// - /// ## Overloaded parameters - /// - /// * in1: first input GMat of the defined binary computation - /// * in2: second input GMat of the defined binary computation - /// * out: output GMat of the defined binary computation - #[inline] - pub fn new_2(mut in1: impl crate::gapi::GMatTrait, mut in2: impl crate::gapi::GMatTrait, mut out: impl crate::gapi::GMatTrait) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_GComputation_GComputation_GMat_GMat_GMat(in1.as_raw_mut_GMat(), in2.as_raw_mut_GMat(), out.as_raw_mut_GMat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::GComputation::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Defines a binary (two inputs -- one output) computation - /// - /// Generic GComputation constructor. - /// - /// Constructs a new graph with a given protocol, specified as a - /// flow of operations connecting input/output objects. Throws if - /// the passed boundaries are invalid, e.g. if there's no - /// functional dependency (path) between given outputs and inputs. - /// - /// ## Parameters - /// * ins: Input data vector. - /// * outs: Output data vector. - /// - /// - /// Note: Don't construct GProtoInputArgs/GProtoOutputArgs objects - /// directly, use cv::GIn()/cv::GOut() wrapper functions instead. - /// ## See also - /// [gapi_data_objects] - /// - /// ## Overloaded parameters - /// - /// * in1: first input GMat of the defined binary computation - /// * in2: second input GMat of the defined binary computation - /// * out: output GScalar of the defined binary computation - #[inline] - pub fn new_3(mut in1: impl crate::gapi::GMatTrait, mut in2: impl crate::gapi::GMatTrait, mut out: impl crate::gapi::GScalarTrait) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_GComputation_GComputation_GMat_GMat_GScalar(in1.as_raw_mut_GMat(), in2.as_raw_mut_GMat(), out.as_raw_mut_GScalar(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::GComputation::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Defines a computation with arbitrary input/output number. - /// - /// Generic GComputation constructor. - /// - /// Constructs a new graph with a given protocol, specified as a - /// flow of operations connecting input/output objects. Throws if - /// the passed boundaries are invalid, e.g. if there's no - /// functional dependency (path) between given outputs and inputs. - /// - /// ## Parameters - /// * ins: Input data vector. - /// * outs: Output data vector. - /// - /// - /// Note: Don't construct GProtoInputArgs/GProtoOutputArgs objects - /// directly, use cv::GIn()/cv::GOut() wrapper functions instead. - /// ## See also - /// [gapi_data_objects] - /// - /// ## Overloaded parameters - /// - /// * ins: vector of inputs GMats for this computation - /// * outs: vector of outputs GMats for this computation - /// - /// Use this overload for cases when number of computation - /// inputs/outputs is not known in compile-time -- e.g. when graph - /// is programmatically generated to build an image pyramid with - /// the given number of levels, etc. - #[inline] - pub fn new_4(ins: &core::Vector, outs: &core::Vector) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_GComputation_GComputation_const_vectorLGMatGR_const_vectorLGMatGR(ins.as_raw_VectorOfGMat(), outs.as_raw_VectorOfGMat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::GComputation::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for GComputation { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GComputation") - .finish() - } - } - - /// Constant methods for [crate::gapi::GFrame] - pub trait GFrameTraitConst { - fn as_raw_GFrame(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::gapi::GFrame] - pub trait GFrameTrait: crate::gapi::GFrameTraitConst { - fn as_raw_mut_GFrame(&mut self) -> *mut c_void; - - } - /// \addtogroup gapi_data_objects /// / /// @@ -7599,16 +7589,6 @@ pub mod gapi { unsafe impl Send for GFrame {} - impl crate::gapi::GFrameTraitConst for GFrame { - #[inline] fn as_raw_GFrame(&self) -> *const c_void { self.as_raw() } - } - - impl crate::gapi::GFrameTrait for GFrame { - #[inline] fn as_raw_mut_GFrame(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { GFrame, crate::gapi::GFrameTraitConst, as_raw_GFrame, crate::gapi::GFrameTrait, as_raw_mut_GFrame } - impl GFrame { /// Constructs an empty GFrame /// @@ -7628,6 +7608,18 @@ pub mod gapi { } + /// Constant methods for [crate::gapi::GFrame] + pub trait GFrameTraitConst { + fn as_raw_GFrame(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::gapi::GFrame] + pub trait GFrameTrait: crate::gapi::GFrameTraitConst { + fn as_raw_mut_GFrame(&mut self) -> *mut c_void; + + } + impl Clone for GFrame { #[inline] fn clone(&self) -> Self { @@ -7643,6 +7635,43 @@ pub mod gapi { } } + impl crate::gapi::GFrameTraitConst for GFrame { + #[inline] fn as_raw_GFrame(&self) -> *const c_void { self.as_raw() } + } + + impl crate::gapi::GFrameTrait for GFrame { + #[inline] fn as_raw_mut_GFrame(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { GFrame, crate::gapi::GFrameTraitConst, as_raw_GFrame, crate::gapi::GFrameTrait, as_raw_mut_GFrame } + + /// \addtogroup gapi_meta_args + pub struct GFrameDesc { + ptr: *mut c_void, + } + + opencv_type_boxed! { GFrameDesc } + + impl Drop for GFrameDesc { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_GFrameDesc_delete(self.as_raw_mut_GFrameDesc()) }; + } + } + + unsafe impl Send for GFrameDesc {} + + impl GFrameDesc { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::gapi::GFrameDesc { + let ret = unsafe { sys::cv_GFrameDesc_defaultNew_const() }; + let ret = unsafe { crate::gapi::GFrameDesc::opencv_from_extern(ret) }; + ret + } + + } + /// Constant methods for [crate::gapi::GFrameDesc] pub trait GFrameDescTraitConst { fn as_raw_GFrameDesc(&self) -> *const c_void; @@ -7692,22 +7721,24 @@ pub mod gapi { } - /// \addtogroup gapi_meta_args - pub struct GFrameDesc { - ptr: *mut c_void, + impl Default for GFrameDesc { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { GFrameDesc } - - impl Drop for GFrameDesc { + impl std::fmt::Debug for GFrameDesc { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GFrameDesc_delete(self.as_raw_mut_GFrameDesc()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GFrameDesc") + .field("fmt", &crate::gapi::GFrameDescTraitConst::fmt(self)) + .field("size", &crate::gapi::GFrameDescTraitConst::size(self)) + .finish() } } - unsafe impl Send for GFrameDesc {} - impl crate::gapi::GFrameDescTraitConst for GFrameDesc { #[inline] fn as_raw_GFrameDesc(&self) -> *const c_void { self.as_raw() } } @@ -7718,31 +7749,30 @@ pub mod gapi { boxed_ref! { GFrameDesc, crate::gapi::GFrameDescTraitConst, as_raw_GFrameDesc, crate::gapi::GFrameDescTrait, as_raw_mut_GFrameDesc } - impl GFrameDesc { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_GFrameDesc_defaultNew_const()) } - } - + pub struct GKernel { + ptr: *mut c_void, } - impl std::fmt::Debug for GFrameDesc { + opencv_type_boxed! { GKernel } + + impl Drop for GKernel { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GFrameDesc") - .field("fmt", &crate::gapi::GFrameDescTraitConst::fmt(self)) - .field("size", &crate::gapi::GFrameDescTraitConst::size(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_GKernel_delete(self.as_raw_mut_GKernel()) }; } } - impl Default for GFrameDesc { + unsafe impl Send for GKernel {} + + impl GKernel { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::gapi::GKernel { + let ret = unsafe { sys::cv_GKernel_defaultNew_const() }; + let ret = unsafe { crate::gapi::GKernel::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::gapi::GKernel] @@ -7824,21 +7854,27 @@ pub mod gapi { } - pub struct GKernel { - ptr: *mut c_void, + impl Default for GKernel { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { GKernel } - - impl Drop for GKernel { + impl std::fmt::Debug for GKernel { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GKernel_delete(self.as_raw_mut_GKernel()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GKernel") + .field("name", &crate::gapi::GKernelTraitConst::name(self)) + .field("tag", &crate::gapi::GKernelTraitConst::tag(self)) + .field("out_shapes", &crate::gapi::GKernelTraitConst::out_shapes(self)) + .field("in_kinds", &crate::gapi::GKernelTraitConst::in_kinds(self)) + .field("out_kinds", &crate::gapi::GKernelTraitConst::out_kinds(self)) + .finish() } } - unsafe impl Send for GKernel {} - impl crate::gapi::GKernelTraitConst for GKernel { #[inline] fn as_raw_GKernel(&self) -> *const c_void { self.as_raw() } } @@ -7849,34 +7885,30 @@ pub mod gapi { boxed_ref! { GKernel, crate::gapi::GKernelTraitConst, as_raw_GKernel, crate::gapi::GKernelTrait, as_raw_mut_GKernel } - impl GKernel { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_GKernel_defaultNew_const()) } - } - + pub struct GKernelImpl { + ptr: *mut c_void, } - impl std::fmt::Debug for GKernel { + opencv_type_boxed! { GKernelImpl } + + impl Drop for GKernelImpl { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GKernel") - .field("name", &crate::gapi::GKernelTraitConst::name(self)) - .field("tag", &crate::gapi::GKernelTraitConst::tag(self)) - .field("out_shapes", &crate::gapi::GKernelTraitConst::out_shapes(self)) - .field("in_kinds", &crate::gapi::GKernelTraitConst::in_kinds(self)) - .field("out_kinds", &crate::gapi::GKernelTraitConst::out_kinds(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_GKernelImpl_delete(self.as_raw_mut_GKernelImpl()) }; } } - impl Default for GKernel { + unsafe impl Send for GKernelImpl {} + + impl GKernelImpl { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::gapi::GKernelImpl { + let ret = unsafe { sys::cv_GKernelImpl_defaultNew_const() }; + let ret = unsafe { crate::gapi::GKernelImpl::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::gapi::GKernelImpl] @@ -7904,21 +7936,23 @@ pub mod gapi { } - pub struct GKernelImpl { - ptr: *mut c_void, + impl Default for GKernelImpl { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { GKernelImpl } - - impl Drop for GKernelImpl { + impl std::fmt::Debug for GKernelImpl { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GKernelImpl_delete(self.as_raw_mut_GKernelImpl()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GKernelImpl") + .field("opaque", &crate::gapi::GKernelImplTraitConst::opaque(self)) + .finish() } } - unsafe impl Send for GKernelImpl {} - impl crate::gapi::GKernelImplTraitConst for GKernelImpl { #[inline] fn as_raw_GKernelImpl(&self) -> *const c_void { self.as_raw() } } @@ -7929,30 +7963,54 @@ pub mod gapi { boxed_ref! { GKernelImpl, crate::gapi::GKernelImplTraitConst, as_raw_GKernelImpl, crate::gapi::GKernelImplTrait, as_raw_mut_GKernelImpl } - impl GKernelImpl { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_GKernelImpl_defaultNew_const()) } - } - + /// A container class for heterogeneous kernel + /// implementation collections and graph transformations. + /// + /// GKernelPackage is a special container class which stores kernel + /// _implementations_ and graph _transformations_. Objects of this class + /// are created and passed to cv::GComputation::compile() to specify + /// which kernels to use and which transformations to apply in the + /// compiled graph. GKernelPackage may contain kernels of + /// different backends, e.g. be heterogeneous. + /// + /// The most easy way to create a kernel package is to use function + /// cv::gapi::kernels(). This template functions takes kernel + /// implementations in form of type list (variadic template) and + /// generates a kernel package atop of that. + /// + /// Kernel packages can be also generated programmatically, starting + /// with an empty package (created with the default constructor) + /// and then by populating it with kernels via call to + /// GKernelPackage::include(). Note this method is also a template + /// one since G-API kernel and transformation implementations are _types_, + /// not objects. + /// + /// Finally, two kernel packages can be combined into a new one + /// with function cv::gapi::combine(). + pub struct GKernelPackage { + ptr: *mut c_void, } - impl std::fmt::Debug for GKernelImpl { + opencv_type_boxed! { GKernelPackage } + + impl Drop for GKernelPackage { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GKernelImpl") - .field("opaque", &crate::gapi::GKernelImplTraitConst::opaque(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_GKernelPackage_delete(self.as_raw_mut_GKernelPackage()) }; } } - impl Default for GKernelImpl { + unsafe impl Send for GKernelPackage {} + + impl GKernelPackage { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::gapi::GKernelPackage { + let ret = unsafe { sys::cv_GKernelPackage_defaultNew_const() }; + let ret = unsafe { crate::gapi::GKernelPackage::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::gapi::GKernelPackage] @@ -8034,100 +8092,50 @@ pub mod gapi { fn include(&mut self, functor: &impl crate::gapi::GFunctorTraitConst) -> Result<()> { return_send!(via ocvrs_return); unsafe { sys::cv_GKernelPackage_include_const_GFunctorR(self.as_raw_mut_GKernelPackage(), functor.as_raw_GFunctor(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Remove all kernels associated with the given backend - /// from the package. - /// - /// Does nothing if there's no kernels of this backend in the package. - /// - /// ## Parameters - /// * backend: backend which kernels to remove - #[inline] - fn remove(&mut self, backend: &impl crate::gapi::GBackendTraitConst) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_GKernelPackage_remove_const_GBackendR(self.as_raw_mut_GKernelPackage(), backend.as_raw_GBackend(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Adds a new kernel based on it's backend and id into the kernel package - /// - /// ## Parameters - /// * backend: backend associated with the kernel - /// * kernel_id: a name/id of the kernel - #[inline] - fn include_1(&mut self, backend: &impl crate::gapi::GBackendTraitConst, kernel_id: &str) -> Result<()> { - extern_container_arg!(kernel_id); - return_send!(via ocvrs_return); - unsafe { sys::cv_GKernelPackage_include_const_GBackendR_const_stringR(self.as_raw_mut_GKernelPackage(), backend.as_raw_GBackend(), kernel_id.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - /// A container class for heterogeneous kernel - /// implementation collections and graph transformations. - /// - /// GKernelPackage is a special container class which stores kernel - /// _implementations_ and graph _transformations_. Objects of this class - /// are created and passed to cv::GComputation::compile() to specify - /// which kernels to use and which transformations to apply in the - /// compiled graph. GKernelPackage may contain kernels of - /// different backends, e.g. be heterogeneous. - /// - /// The most easy way to create a kernel package is to use function - /// cv::gapi::kernels(). This template functions takes kernel - /// implementations in form of type list (variadic template) and - /// generates a kernel package atop of that. - /// - /// Kernel packages can be also generated programmatically, starting - /// with an empty package (created with the default constructor) - /// and then by populating it with kernels via call to - /// GKernelPackage::include(). Note this method is also a template - /// one since G-API kernel and transformation implementations are _types_, - /// not objects. - /// - /// Finally, two kernel packages can be combined into a new one - /// with function cv::gapi::combine(). - pub struct GKernelPackage { - ptr: *mut c_void, - } - - opencv_type_boxed! { GKernelPackage } + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - impl Drop for GKernelPackage { + /// Remove all kernels associated with the given backend + /// from the package. + /// + /// Does nothing if there's no kernels of this backend in the package. + /// + /// ## Parameters + /// * backend: backend which kernels to remove #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GKernelPackage_delete(self.as_raw_mut_GKernelPackage()) }; + fn remove(&mut self, backend: &impl crate::gapi::GBackendTraitConst) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_GKernelPackage_remove_const_GBackendR(self.as_raw_mut_GKernelPackage(), backend.as_raw_GBackend(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } - } - - unsafe impl Send for GKernelPackage {} - impl crate::gapi::GKernelPackageTraitConst for GKernelPackage { - #[inline] fn as_raw_GKernelPackage(&self) -> *const c_void { self.as_raw() } - } + /// Adds a new kernel based on it's backend and id into the kernel package + /// + /// ## Parameters + /// * backend: backend associated with the kernel + /// * kernel_id: a name/id of the kernel + #[inline] + fn include_1(&mut self, backend: &impl crate::gapi::GBackendTraitConst, kernel_id: &str) -> Result<()> { + extern_container_arg!(kernel_id); + return_send!(via ocvrs_return); + unsafe { sys::cv_GKernelPackage_include_const_GBackendR_const_stringR(self.as_raw_mut_GKernelPackage(), backend.as_raw_GBackend(), kernel_id.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - impl crate::gapi::GKernelPackageTrait for GKernelPackage { - #[inline] fn as_raw_mut_GKernelPackage(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { GKernelPackage, crate::gapi::GKernelPackageTraitConst, as_raw_GKernelPackage, crate::gapi::GKernelPackageTrait, as_raw_mut_GKernelPackage } - - impl GKernelPackage { - /// Creates a default instance of the class by calling the default constructor + impl Default for GKernelPackage { #[inline] + /// Forwards to infallible Self::default() fn default() -> Self { - unsafe { Self::from_raw(sys::cv_GKernelPackage_defaultNew_const()) } + Self::default() } - } impl Clone for GKernelPackage { @@ -8145,25 +8153,15 @@ pub mod gapi { } } - impl Default for GKernelPackage { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } + impl crate::gapi::GKernelPackageTraitConst for GKernelPackage { + #[inline] fn as_raw_GKernelPackage(&self) -> *const c_void { self.as_raw() } } - /// Constant methods for [crate::gapi::GMat] - pub trait GMatTraitConst { - fn as_raw_GMat(&self) -> *const c_void; - + impl crate::gapi::GKernelPackageTrait for GKernelPackage { + #[inline] fn as_raw_mut_GKernelPackage(&mut self) -> *mut c_void { self.as_raw_mut() } } - /// Mutable methods for [crate::gapi::GMat] - pub trait GMatTrait: crate::gapi::GMatTraitConst { - fn as_raw_mut_GMat(&mut self) -> *mut c_void; - - } + boxed_ref! { GKernelPackage, crate::gapi::GKernelPackageTraitConst, as_raw_GKernelPackage, crate::gapi::GKernelPackageTrait, as_raw_mut_GKernelPackage } /// GMat class represents image or tensor data in the /// graph. @@ -8193,16 +8191,6 @@ pub mod gapi { unsafe impl Send for GMat {} - impl crate::gapi::GMatTraitConst for GMat { - #[inline] fn as_raw_GMat(&self) -> *const c_void { self.as_raw() } - } - - impl crate::gapi::GMatTrait for GMat { - #[inline] fn as_raw_mut_GMat(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { GMat, crate::gapi::GMatTraitConst, as_raw_GMat, crate::gapi::GMatTrait, as_raw_mut_GMat } - impl GMat { /// Constructs an empty GMat /// @@ -8241,6 +8229,18 @@ pub mod gapi { } + /// Constant methods for [crate::gapi::GMat] + pub trait GMatTraitConst { + fn as_raw_GMat(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::gapi::GMat] + pub trait GMatTrait: crate::gapi::GMatTraitConst { + fn as_raw_mut_GMat(&mut self) -> *mut c_void; + + } + impl Clone for GMat { #[inline] fn clone(&self) -> Self { @@ -8256,6 +8256,90 @@ pub mod gapi { } } + impl crate::gapi::GMatTraitConst for GMat { + #[inline] fn as_raw_GMat(&self) -> *const c_void { self.as_raw() } + } + + impl crate::gapi::GMatTrait for GMat { + #[inline] fn as_raw_mut_GMat(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { GMat, crate::gapi::GMatTraitConst, as_raw_GMat, crate::gapi::GMatTrait, as_raw_mut_GMat } + + /// \addtogroup gapi_meta_args + pub struct GMatDesc { + ptr: *mut c_void, + } + + opencv_type_boxed! { GMatDesc } + + impl Drop for GMatDesc { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_GMatDesc_delete(self.as_raw_mut_GMatDesc()) }; + } + } + + unsafe impl Send for GMatDesc {} + + impl GMatDesc { + /// ## C++ default parameters + /// * p: false + #[inline] + pub fn new(d: i32, c: i32, s: core::Size, p: bool) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_GMatDesc_GMatDesc_int_int_Size_bool(d, c, &s, p, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::GMatDesc::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * p: false + #[inline] + pub fn new_def(d: i32, c: i32, s: core::Size) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_GMatDesc_GMatDesc_int_int_Size(d, c, &s, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::GMatDesc::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn new_1(d: i32, dd: &core::Vector) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_GMatDesc_GMatDesc_int_const_vectorLintGR(d, dd.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::GMatDesc::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn new_2(d: i32, mut dd: core::Vector) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_GMatDesc_GMatDesc_int_vectorLintGRR(d, dd.as_raw_mut_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::GMatDesc::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_GMatDesc_GMatDesc(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::GMatDesc::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::gapi::GMatDesc] pub trait GMatDescTraitConst { fn as_raw_GMatDesc(&self) -> *const c_void; @@ -8449,93 +8533,9 @@ pub mod gapi { } #[inline] - fn set_dims(&mut self, val: core::Vector) { - let ret = unsafe { sys::cv_GMatDesc_propDims_const_vectorLintG(self.as_raw_mut_GMatDesc(), val.as_raw_VectorOfi32()) }; - ret - } - - } - - /// \addtogroup gapi_meta_args - pub struct GMatDesc { - ptr: *mut c_void, - } - - opencv_type_boxed! { GMatDesc } - - impl Drop for GMatDesc { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GMatDesc_delete(self.as_raw_mut_GMatDesc()) }; - } - } - - unsafe impl Send for GMatDesc {} - - impl crate::gapi::GMatDescTraitConst for GMatDesc { - #[inline] fn as_raw_GMatDesc(&self) -> *const c_void { self.as_raw() } - } - - impl crate::gapi::GMatDescTrait for GMatDesc { - #[inline] fn as_raw_mut_GMatDesc(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { GMatDesc, crate::gapi::GMatDescTraitConst, as_raw_GMatDesc, crate::gapi::GMatDescTrait, as_raw_mut_GMatDesc } - - impl GMatDesc { - /// ## C++ default parameters - /// * p: false - #[inline] - pub fn new(d: i32, c: i32, s: core::Size, p: bool) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_GMatDesc_GMatDesc_int_int_Size_bool(d, c, &s, p, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::GMatDesc::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * p: false - #[inline] - pub fn new_def(d: i32, c: i32, s: core::Size) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_GMatDesc_GMatDesc_int_int_Size(d, c, &s, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::GMatDesc::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn new_1(d: i32, dd: &core::Vector) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_GMatDesc_GMatDesc_int_const_vectorLintGR(d, dd.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::GMatDesc::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn new_2(d: i32, mut dd: core::Vector) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_GMatDesc_GMatDesc_int_vectorLintGRR(d, dd.as_raw_mut_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::GMatDesc::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_GMatDesc_GMatDesc(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::GMatDesc::opencv_from_extern(ret) }; - Ok(ret) + fn set_dims(&mut self, val: core::Vector) { + let ret = unsafe { sys::cv_GMatDesc_propDims_const_vectorLintG(self.as_raw_mut_GMatDesc(), val.as_raw_VectorOfi32()) }; + ret } } @@ -8560,18 +8560,16 @@ pub mod gapi { } } - /// Constant methods for [crate::gapi::GMatP] - pub trait GMatPTraitConst: crate::gapi::GMatTraitConst { - fn as_raw_GMatP(&self) -> *const c_void; - + impl crate::gapi::GMatDescTraitConst for GMatDesc { + #[inline] fn as_raw_GMatDesc(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::gapi::GMatP] - pub trait GMatPTrait: crate::gapi::GMatPTraitConst + crate::gapi::GMatTrait { - fn as_raw_mut_GMatP(&mut self) -> *mut c_void; - + impl crate::gapi::GMatDescTrait for GMatDesc { + #[inline] fn as_raw_mut_GMatDesc(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { GMatDesc, crate::gapi::GMatDescTraitConst, as_raw_GMatDesc, crate::gapi::GMatDescTrait, as_raw_mut_GMatDesc } + pub struct GMatP { ptr: *mut c_void, } @@ -8587,6 +8585,47 @@ pub mod gapi { unsafe impl Send for GMatP {} + impl GMatP { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::gapi::GMatP { + let ret = unsafe { sys::cv_GMatP_defaultNew_const() }; + let ret = unsafe { crate::gapi::GMatP::opencv_from_extern(ret) }; + ret + } + + } + + /// Constant methods for [crate::gapi::GMatP] + pub trait GMatPTraitConst: crate::gapi::GMatTraitConst { + fn as_raw_GMatP(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::gapi::GMatP] + pub trait GMatPTrait: crate::gapi::GMatPTraitConst + crate::gapi::GMatTrait { + fn as_raw_mut_GMatP(&mut self) -> *mut c_void; + + } + + impl Default for GMatP { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } + } + + impl std::fmt::Debug for GMatP { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GMatP") + .finish() + } + } + + boxed_cast_base! { GMatP, crate::gapi::GMat, cv_GMatP_to_GMat } + impl crate::gapi::GMatTraitConst for GMatP { #[inline] fn as_raw_GMat(&self) -> *const c_void { self.as_raw() } } @@ -8607,31 +8646,31 @@ pub mod gapi { boxed_ref! { GMatP, crate::gapi::GMatPTraitConst, as_raw_GMatP, crate::gapi::GMatPTrait, as_raw_mut_GMatP } - impl GMatP { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_GMatP_defaultNew_const()) } - } - + /// \addtogroup gapi_meta_args + pub struct GOpaqueDesc { + ptr: *mut c_void, } - boxed_cast_base! { GMatP, crate::gapi::GMat, cv_GMatP_to_GMat } + opencv_type_boxed! { GOpaqueDesc } - impl std::fmt::Debug for GMatP { + impl Drop for GOpaqueDesc { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GMatP") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_GOpaqueDesc_delete(self.as_raw_mut_GOpaqueDesc()) }; } } - impl Default for GMatP { + unsafe impl Send for GOpaqueDesc {} + + impl GOpaqueDesc { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::gapi::GOpaqueDesc { + let ret = unsafe { sys::cv_GOpaqueDesc_defaultNew_const() }; + let ret = unsafe { crate::gapi::GOpaqueDesc::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::gapi::GOpaqueDesc] @@ -8655,39 +8694,12 @@ pub mod gapi { } - /// \addtogroup gapi_meta_args - pub struct GOpaqueDesc { - ptr: *mut c_void, - } - - opencv_type_boxed! { GOpaqueDesc } - - impl Drop for GOpaqueDesc { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GOpaqueDesc_delete(self.as_raw_mut_GOpaqueDesc()) }; - } - } - - unsafe impl Send for GOpaqueDesc {} - - impl crate::gapi::GOpaqueDescTraitConst for GOpaqueDesc { - #[inline] fn as_raw_GOpaqueDesc(&self) -> *const c_void { self.as_raw() } - } - - impl crate::gapi::GOpaqueDescTrait for GOpaqueDesc { - #[inline] fn as_raw_mut_GOpaqueDesc(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { GOpaqueDesc, crate::gapi::GOpaqueDescTraitConst, as_raw_GOpaqueDesc, crate::gapi::GOpaqueDescTrait, as_raw_mut_GOpaqueDesc } - - impl GOpaqueDesc { - /// Creates a default instance of the class by calling the default constructor + impl Default for GOpaqueDesc { #[inline] + /// Forwards to infallible Self::default() fn default() -> Self { - unsafe { Self::from_raw(sys::cv_GOpaqueDesc_defaultNew_const()) } + Self::default() } - } impl Clone for GOpaqueDesc { @@ -8705,43 +8717,15 @@ pub mod gapi { } } - impl Default for GOpaqueDesc { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } + impl crate::gapi::GOpaqueDescTraitConst for GOpaqueDesc { + #[inline] fn as_raw_GOpaqueDesc(&self) -> *const c_void { self.as_raw() } } - /// Constant methods for [crate::gapi::GRunArg] - pub trait GRunArgTraitConst { - fn as_raw_GRunArg(&self) -> *const c_void; - + impl crate::gapi::GOpaqueDescTrait for GOpaqueDesc { + #[inline] fn as_raw_mut_GOpaqueDesc(&mut self) -> *mut c_void { self.as_raw_mut() } } - /// Mutable methods for [crate::gapi::GRunArg] - pub trait GRunArgTrait: crate::gapi::GRunArgTraitConst { - fn as_raw_mut_GRunArg(&mut self) -> *mut c_void; - - #[inline] - fn set(&mut self, arg: &impl crate::gapi::GRunArgTraitConst) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_GRunArg_operatorST_const_GRunArgR(self.as_raw_mut_GRunArg(), arg.as_raw_GRunArg(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn set_1(&mut self, mut arg: crate::gapi::GRunArg) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_GRunArg_operatorST_GRunArgRR(self.as_raw_mut_GRunArg(), arg.as_raw_mut_GRunArg(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } + boxed_ref! { GOpaqueDesc, crate::gapi::GOpaqueDescTraitConst, as_raw_GOpaqueDesc, crate::gapi::GOpaqueDescTrait, as_raw_mut_GOpaqueDesc } pub struct GRunArg { ptr: *mut c_void, @@ -8758,16 +8742,6 @@ pub mod gapi { unsafe impl Send for GRunArg {} - impl crate::gapi::GRunArgTraitConst for GRunArg { - #[inline] fn as_raw_GRunArg(&self) -> *const c_void { self.as_raw() } - } - - impl crate::gapi::GRunArgTrait for GRunArg { - #[inline] fn as_raw_mut_GRunArg(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { GRunArg, crate::gapi::GRunArgTraitConst, as_raw_GRunArg, crate::gapi::GRunArgTrait, as_raw_mut_GRunArg } - impl GRunArg { #[inline] pub fn default() -> Result { @@ -8801,6 +8775,36 @@ pub mod gapi { } + /// Constant methods for [crate::gapi::GRunArg] + pub trait GRunArgTraitConst { + fn as_raw_GRunArg(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::gapi::GRunArg] + pub trait GRunArgTrait: crate::gapi::GRunArgTraitConst { + fn as_raw_mut_GRunArg(&mut self) -> *mut c_void; + + #[inline] + fn set(&mut self, arg: &impl crate::gapi::GRunArgTraitConst) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_GRunArg_operatorST_const_GRunArgR(self.as_raw_mut_GRunArg(), arg.as_raw_GRunArg(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn set_1(&mut self, mut arg: crate::gapi::GRunArg) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_GRunArg_operatorST_GRunArgRR(self.as_raw_mut_GRunArg(), arg.as_raw_mut_GRunArg(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + impl std::fmt::Debug for GRunArg { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -8809,18 +8813,16 @@ pub mod gapi { } } - /// Constant methods for [crate::gapi::GScalar] - pub trait GScalarTraitConst { - fn as_raw_GScalar(&self) -> *const c_void; - + impl crate::gapi::GRunArgTraitConst for GRunArg { + #[inline] fn as_raw_GRunArg(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::gapi::GScalar] - pub trait GScalarTrait: crate::gapi::GScalarTraitConst { - fn as_raw_mut_GScalar(&mut self) -> *mut c_void; - + impl crate::gapi::GRunArgTrait for GRunArg { + #[inline] fn as_raw_mut_GRunArg(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { GRunArg, crate::gapi::GRunArgTraitConst, as_raw_GRunArg, crate::gapi::GRunArgTrait, as_raw_mut_GRunArg } + /// \addtogroup gapi_data_objects /// / /// @@ -8850,16 +8852,6 @@ pub mod gapi { unsafe impl Send for GScalar {} - impl crate::gapi::GScalarTraitConst for GScalar { - #[inline] fn as_raw_GScalar(&self) -> *const c_void { self.as_raw() } - } - - impl crate::gapi::GScalarTrait for GScalar { - #[inline] fn as_raw_mut_GScalar(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { GScalar, crate::gapi::GScalarTraitConst, as_raw_GScalar, crate::gapi::GScalarTrait, as_raw_mut_GScalar } - impl GScalar { /// Constructs an empty GScalar /// @@ -8978,19 +8970,68 @@ pub mod gapi { } - impl Clone for GScalar { + /// Constant methods for [crate::gapi::GScalar] + pub trait GScalarTraitConst { + fn as_raw_GScalar(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::gapi::GScalar] + pub trait GScalarTrait: crate::gapi::GScalarTraitConst { + fn as_raw_mut_GScalar(&mut self) -> *mut c_void; + + } + + impl Clone for GScalar { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_GScalar_implicitClone_const(self.as_raw_GScalar())) } + } + } + + impl std::fmt::Debug for GScalar { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GScalar") + .finish() + } + } + + impl crate::gapi::GScalarTraitConst for GScalar { + #[inline] fn as_raw_GScalar(&self) -> *const c_void { self.as_raw() } + } + + impl crate::gapi::GScalarTrait for GScalar { + #[inline] fn as_raw_mut_GScalar(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { GScalar, crate::gapi::GScalarTraitConst, as_raw_GScalar, crate::gapi::GScalarTrait, as_raw_mut_GScalar } + + /// \addtogroup gapi_meta_args + pub struct GScalarDesc { + ptr: *mut c_void, + } + + opencv_type_boxed! { GScalarDesc } + + impl Drop for GScalarDesc { #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_GScalar_implicitClone_const(self.as_raw_GScalar())) } + fn drop(&mut self) { + unsafe { sys::cv_GScalarDesc_delete(self.as_raw_mut_GScalarDesc()) }; } } - impl std::fmt::Debug for GScalar { + unsafe impl Send for GScalarDesc {} + + impl GScalarDesc { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GScalar") - .finish() + pub fn default() -> crate::gapi::GScalarDesc { + let ret = unsafe { sys::cv_GScalarDesc_defaultNew_const() }; + let ret = unsafe { crate::gapi::GScalarDesc::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::gapi::GScalarDesc] @@ -9023,21 +9064,28 @@ pub mod gapi { } - /// \addtogroup gapi_meta_args - pub struct GScalarDesc { - ptr: *mut c_void, + impl Default for GScalarDesc { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { GScalarDesc } - - impl Drop for GScalarDesc { + impl Clone for GScalarDesc { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GScalarDesc_delete(self.as_raw_mut_GScalarDesc()) }; + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_GScalarDesc_implicitClone_const(self.as_raw_GScalarDesc())) } } } - unsafe impl Send for GScalarDesc {} + impl std::fmt::Debug for GScalarDesc { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GScalarDesc") + .finish() + } + } impl crate::gapi::GScalarDescTraitConst for GScalarDesc { #[inline] fn as_raw_GScalarDesc(&self) -> *const c_void { self.as_raw() } @@ -9049,36 +9097,61 @@ pub mod gapi { boxed_ref! { GScalarDesc, crate::gapi::GScalarDescTraitConst, as_raw_GScalarDesc, crate::gapi::GScalarDescTrait, as_raw_mut_GScalarDesc } - impl GScalarDesc { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_GScalarDesc_defaultNew_const()) } - } - + /// \addtogroup gapi_main_classes + /// / + /// + /// Represents a computation (graph) compiled for streaming. + /// + /// This class represents a product of graph compilation (calling + /// cv::GComputation::compileStreaming()). Objects of this class + /// actually do stream processing, and the whole pipeline execution + /// complexity is incapsulated into objects of this class. Execution + /// model has two levels: at the very top, the execution of a + /// heterogeneous graph is aggressively pipelined; at the very bottom + /// the execution of every internal block is determined by its + /// associated backend. Backends are selected based on kernel packages + /// passed via compilation arguments ( see [gapi_compile_args], + /// GNetworkPackage, GKernelPackage for details). + /// + /// GStreamingCompiled objects have a "player" semantics -- there are + /// methods like start() and stop(). GStreamingCompiled has a full + /// control over a videostream and so is stateful. You need to specify the + /// input stream data using setSource() and then call start() to + /// actually start processing. After that, use pull() or try_pull() to + /// obtain next processed data frame from the graph in a blocking or + /// non-blocking way, respectively. + /// + /// Currently a single GStreamingCompiled can process only one video + /// streat at time. Produce multiple GStreamingCompiled objects to run the + /// same graph on multiple video streams. + /// ## See also + /// GCompiled + pub struct GStreamingCompiled { + ptr: *mut c_void, } - impl Clone for GScalarDesc { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_GScalarDesc_implicitClone_const(self.as_raw_GScalarDesc())) } - } - } + opencv_type_boxed! { GStreamingCompiled } - impl std::fmt::Debug for GScalarDesc { + impl Drop for GStreamingCompiled { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GScalarDesc") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_GStreamingCompiled_delete(self.as_raw_mut_GStreamingCompiled()) }; } } - impl Default for GScalarDesc { + unsafe impl Send for GStreamingCompiled {} + + impl GStreamingCompiled { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_GStreamingCompiled_GStreamingCompiled(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::GStreamingCompiled::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::gapi::GStreamingCompiled] @@ -9223,50 +9296,21 @@ pub mod gapi { } - /// \addtogroup gapi_main_classes - /// / - /// - /// Represents a computation (graph) compiled for streaming. - /// - /// This class represents a product of graph compilation (calling - /// cv::GComputation::compileStreaming()). Objects of this class - /// actually do stream processing, and the whole pipeline execution - /// complexity is incapsulated into objects of this class. Execution - /// model has two levels: at the very top, the execution of a - /// heterogeneous graph is aggressively pipelined; at the very bottom - /// the execution of every internal block is determined by its - /// associated backend. Backends are selected based on kernel packages - /// passed via compilation arguments ( see [gapi_compile_args], - /// GNetworkPackage, GKernelPackage for details). - /// - /// GStreamingCompiled objects have a "player" semantics -- there are - /// methods like start() and stop(). GStreamingCompiled has a full - /// control over a videostream and so is stateful. You need to specify the - /// input stream data using setSource() and then call start() to - /// actually start processing. After that, use pull() or try_pull() to - /// obtain next processed data frame from the graph in a blocking or - /// non-blocking way, respectively. - /// - /// Currently a single GStreamingCompiled can process only one video - /// streat at time. Produce multiple GStreamingCompiled objects to run the - /// same graph on multiple video streams. - /// ## See also - /// GCompiled - pub struct GStreamingCompiled { - ptr: *mut c_void, + impl Clone for GStreamingCompiled { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_GStreamingCompiled_implicitClone_const(self.as_raw_GStreamingCompiled())) } + } } - opencv_type_boxed! { GStreamingCompiled } - - impl Drop for GStreamingCompiled { + impl std::fmt::Debug for GStreamingCompiled { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GStreamingCompiled_delete(self.as_raw_mut_GStreamingCompiled()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GStreamingCompiled") + .finish() } } - unsafe impl Send for GStreamingCompiled {} - impl crate::gapi::GStreamingCompiledTraitConst for GStreamingCompiled { #[inline] fn as_raw_GStreamingCompiled(&self) -> *const c_void { self.as_raw() } } @@ -9277,34 +9321,21 @@ pub mod gapi { boxed_ref! { GStreamingCompiled, crate::gapi::GStreamingCompiledTraitConst, as_raw_GStreamingCompiled, crate::gapi::GStreamingCompiledTrait, as_raw_mut_GStreamingCompiled } - impl GStreamingCompiled { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_GStreamingCompiled_GStreamingCompiled(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::GStreamingCompiled::opencv_from_extern(ret) }; - Ok(ret) - } - + pub struct GTransform { + ptr: *mut c_void, } - impl Clone for GStreamingCompiled { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_GStreamingCompiled_implicitClone_const(self.as_raw_GStreamingCompiled())) } - } - } + opencv_type_boxed! { GTransform } - impl std::fmt::Debug for GStreamingCompiled { + impl Drop for GTransform { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GStreamingCompiled") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_GTransform_delete(self.as_raw_mut_GTransform()) }; } } + unsafe impl Send for GTransform {} + /// Constant methods for [crate::gapi::GTransform] pub trait GTransformTraitConst { fn as_raw_GTransform(&self) -> *const c_void; @@ -9331,21 +9362,15 @@ pub mod gapi { } - pub struct GTransform { - ptr: *mut c_void, - } - - opencv_type_boxed! { GTransform } - - impl Drop for GTransform { + impl std::fmt::Debug for GTransform { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GTransform_delete(self.as_raw_mut_GTransform()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GTransform") + .field("description", &crate::gapi::GTransformTraitConst::description(self)) + .finish() } } - unsafe impl Send for GTransform {} - impl crate::gapi::GTransformTraitConst for GTransform { #[inline] fn as_raw_GTransform(&self) -> *const c_void { self.as_raw() } } @@ -9356,18 +9381,32 @@ pub mod gapi { boxed_ref! { GTransform, crate::gapi::GTransformTraitConst, as_raw_GTransform, crate::gapi::GTransformTrait, as_raw_mut_GTransform } - impl GTransform { + pub struct GTypeInfo { + ptr: *mut c_void, } - impl std::fmt::Debug for GTransform { + opencv_type_boxed! { GTypeInfo } + + impl Drop for GTypeInfo { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GTransform") - .field("description", &crate::gapi::GTransformTraitConst::description(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_GTypeInfo_delete(self.as_raw_mut_GTypeInfo()) }; } } + unsafe impl Send for GTypeInfo {} + + impl GTypeInfo { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::gapi::GTypeInfo { + let ret = unsafe { sys::cv_GTypeInfo_defaultNew_const() }; + let ret = unsafe { crate::gapi::GTypeInfo::opencv_from_extern(ret) }; + ret + } + + } + /// Constant methods for [crate::gapi::GTypeInfo] pub trait GTypeInfoTraitConst { fn as_raw_GTypeInfo(&self) -> *const c_void; @@ -9404,42 +9443,16 @@ pub mod gapi { fn set_kind(&mut self, val: crate::gapi::Detail_OpaqueKind) { let ret = unsafe { sys::cv_GTypeInfo_propKind_const_OpaqueKind(self.as_raw_mut_GTypeInfo(), val) }; ret - } - - } - - pub struct GTypeInfo { - ptr: *mut c_void, - } - - opencv_type_boxed! { GTypeInfo } - - impl Drop for GTypeInfo { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GTypeInfo_delete(self.as_raw_mut_GTypeInfo()) }; - } - } - - unsafe impl Send for GTypeInfo {} - - impl crate::gapi::GTypeInfoTraitConst for GTypeInfo { - #[inline] fn as_raw_GTypeInfo(&self) -> *const c_void { self.as_raw() } - } + } - impl crate::gapi::GTypeInfoTrait for GTypeInfo { - #[inline] fn as_raw_mut_GTypeInfo(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { GTypeInfo, crate::gapi::GTypeInfoTraitConst, as_raw_GTypeInfo, crate::gapi::GTypeInfoTrait, as_raw_mut_GTypeInfo } - - impl GTypeInfo { - /// Creates a default instance of the class by calling the default constructor + impl Default for GTypeInfo { #[inline] + /// Forwards to infallible Self::default() fn default() -> Self { - unsafe { Self::from_raw(sys::cv_GTypeInfo_defaultNew_const()) } + Self::default() } - } impl Clone for GTypeInfo { @@ -9459,50 +9472,15 @@ pub mod gapi { } } - impl Default for GTypeInfo { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } + impl crate::gapi::GTypeInfoTraitConst for GTypeInfo { + #[inline] fn as_raw_GTypeInfo(&self) -> *const c_void { self.as_raw() } } - /// Constant methods for [crate::gapi::MediaFrame] - pub trait MediaFrameTraitConst { - fn as_raw_MediaFrame(&self) -> *const c_void; - - /// Returns a media frame descriptor -- the information - /// about the media format, dimensions, etc. - /// ## Returns - /// a cv::GFrameDesc - #[inline] - fn desc(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_MediaFrame_desc_const(self.as_raw_MediaFrame(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::GFrameDesc::opencv_from_extern(ret) }; - Ok(ret) - } - - /// @private -- exclude from the OpenCV documentation for now. - #[inline] - fn blob_params(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_MediaFrame_blobParams_const(self.as_raw_MediaFrame(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::any::opencv_from_extern(ret) }; - Ok(ret) - } - + impl crate::gapi::GTypeInfoTrait for GTypeInfo { + #[inline] fn as_raw_mut_GTypeInfo(&mut self) -> *mut c_void { self.as_raw_mut() } } - /// Mutable methods for [crate::gapi::MediaFrame] - pub trait MediaFrameTrait: crate::gapi::MediaFrameTraitConst { - fn as_raw_mut_MediaFrame(&mut self) -> *mut c_void; - - } + boxed_ref! { GTypeInfo, crate::gapi::GTypeInfoTraitConst, as_raw_GTypeInfo, crate::gapi::GTypeInfoTrait, as_raw_mut_GTypeInfo } /// cv::MediaFrame class represents an image/media frame /// obtained from an external source. @@ -9533,16 +9511,6 @@ pub mod gapi { unsafe impl Send for MediaFrame {} - impl crate::gapi::MediaFrameTraitConst for MediaFrame { - #[inline] fn as_raw_MediaFrame(&self) -> *const c_void { self.as_raw() } - } - - impl crate::gapi::MediaFrameTrait for MediaFrame { - #[inline] fn as_raw_mut_MediaFrame(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { MediaFrame, crate::gapi::MediaFrameTraitConst, as_raw_MediaFrame, crate::gapi::MediaFrameTrait, as_raw_mut_MediaFrame } - impl MediaFrame { /// Constructs an empty MediaFrame /// @@ -9559,32 +9527,29 @@ pub mod gapi { } - impl std::fmt::Debug for MediaFrame { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MediaFrame") - .finish() - } - } - - /// Constant methods for [crate::gapi::MediaFrame_IAdapter] - pub trait MediaFrame_IAdapterTraitConst { - fn as_raw_MediaFrame_IAdapter(&self) -> *const c_void; + /// Constant methods for [crate::gapi::MediaFrame] + pub trait MediaFrameTraitConst { + fn as_raw_MediaFrame(&self) -> *const c_void; + /// Returns a media frame descriptor -- the information + /// about the media format, dimensions, etc. + /// ## Returns + /// a cv::GFrameDesc #[inline] - fn meta(&self) -> Result { + fn desc(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_MediaFrame_IAdapter_meta_const(self.as_raw_MediaFrame_IAdapter(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MediaFrame_desc_const(self.as_raw_MediaFrame(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { crate::gapi::GFrameDesc::opencv_from_extern(ret) }; Ok(ret) } + /// @private -- exclude from the OpenCV documentation for now. #[inline] fn blob_params(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_MediaFrame_IAdapter_blobParams_const(self.as_raw_MediaFrame_IAdapter(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_MediaFrame_blobParams_const(self.as_raw_MediaFrame(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { crate::gapi::any::opencv_from_extern(ret) }; @@ -9593,12 +9558,30 @@ pub mod gapi { } - /// Mutable methods for [crate::gapi::MediaFrame_IAdapter] - pub trait MediaFrame_IAdapterTrait: crate::gapi::MediaFrame_IAdapterTraitConst { - fn as_raw_mut_MediaFrame_IAdapter(&mut self) -> *mut c_void; + /// Mutable methods for [crate::gapi::MediaFrame] + pub trait MediaFrameTrait: crate::gapi::MediaFrameTraitConst { + fn as_raw_mut_MediaFrame(&mut self) -> *mut c_void; + + } + + impl std::fmt::Debug for MediaFrame { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MediaFrame") + .finish() + } + } + + impl crate::gapi::MediaFrameTraitConst for MediaFrame { + #[inline] fn as_raw_MediaFrame(&self) -> *const c_void { self.as_raw() } + } + impl crate::gapi::MediaFrameTrait for MediaFrame { + #[inline] fn as_raw_mut_MediaFrame(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { MediaFrame, crate::gapi::MediaFrameTraitConst, as_raw_MediaFrame, crate::gapi::MediaFrameTrait, as_raw_mut_MediaFrame } + /// An interface class for MediaFrame data adapters. /// /// Implement this interface to wrap media data in the MediaFrame. It @@ -9623,17 +9606,36 @@ pub mod gapi { unsafe impl Send for MediaFrame_IAdapter {} - impl crate::gapi::MediaFrame_IAdapterTraitConst for MediaFrame_IAdapter { - #[inline] fn as_raw_MediaFrame_IAdapter(&self) -> *const c_void { self.as_raw() } - } + /// Constant methods for [crate::gapi::MediaFrame_IAdapter] + pub trait MediaFrame_IAdapterTraitConst { + fn as_raw_MediaFrame_IAdapter(&self) -> *const c_void; + + #[inline] + fn meta(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_MediaFrame_IAdapter_meta_const(self.as_raw_MediaFrame_IAdapter(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::GFrameDesc::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + fn blob_params(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_MediaFrame_IAdapter_blobParams_const(self.as_raw_MediaFrame_IAdapter(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::any::opencv_from_extern(ret) }; + Ok(ret) + } - impl crate::gapi::MediaFrame_IAdapterTrait for MediaFrame_IAdapter { - #[inline] fn as_raw_mut_MediaFrame_IAdapter(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { MediaFrame_IAdapter, crate::gapi::MediaFrame_IAdapterTraitConst, as_raw_MediaFrame_IAdapter, crate::gapi::MediaFrame_IAdapterTrait, as_raw_mut_MediaFrame_IAdapter } + /// Mutable methods for [crate::gapi::MediaFrame_IAdapter] + pub trait MediaFrame_IAdapterTrait: crate::gapi::MediaFrame_IAdapterTraitConst { + fn as_raw_mut_MediaFrame_IAdapter(&mut self) -> *mut c_void; - impl MediaFrame_IAdapter { } impl std::fmt::Debug for MediaFrame_IAdapter { @@ -9644,18 +9646,16 @@ pub mod gapi { } } - /// Constant methods for [crate::gapi::MediaFrame_View] - pub trait MediaFrame_ViewTraitConst { - fn as_raw_MediaFrame_View(&self) -> *const c_void; - + impl crate::gapi::MediaFrame_IAdapterTraitConst for MediaFrame_IAdapter { + #[inline] fn as_raw_MediaFrame_IAdapter(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::gapi::MediaFrame_View] - pub trait MediaFrame_ViewTrait: crate::gapi::MediaFrame_ViewTraitConst { - fn as_raw_mut_MediaFrame_View(&mut self) -> *mut c_void; - + impl crate::gapi::MediaFrame_IAdapterTrait for MediaFrame_IAdapter { + #[inline] fn as_raw_mut_MediaFrame_IAdapter(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { MediaFrame_IAdapter, crate::gapi::MediaFrame_IAdapterTraitConst, as_raw_MediaFrame_IAdapter, crate::gapi::MediaFrame_IAdapterTrait, as_raw_mut_MediaFrame_IAdapter } + /// Provides access to the MediaFrame's underlying data. /// /// This object contains the necessary information to access the pixel @@ -9706,16 +9706,6 @@ pub mod gapi { unsafe impl Send for MediaFrame_View {} - impl crate::gapi::MediaFrame_ViewTraitConst for MediaFrame_View { - #[inline] fn as_raw_MediaFrame_View(&self) -> *const c_void { self.as_raw() } - } - - impl crate::gapi::MediaFrame_ViewTrait for MediaFrame_View { - #[inline] fn as_raw_mut_MediaFrame_View(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { MediaFrame_View, crate::gapi::MediaFrame_ViewTraitConst, as_raw_MediaFrame_View, crate::gapi::MediaFrame_ViewTrait, as_raw_mut_MediaFrame_View } - impl MediaFrame_View { pub const MAX_PLANES: u32 = 4; /// @private @@ -9728,6 +9718,18 @@ pub mod gapi { } + /// Constant methods for [crate::gapi::MediaFrame_View] + pub trait MediaFrame_ViewTraitConst { + fn as_raw_MediaFrame_View(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::gapi::MediaFrame_View] + pub trait MediaFrame_ViewTrait: crate::gapi::MediaFrame_ViewTraitConst { + fn as_raw_mut_MediaFrame_View(&mut self) -> *mut c_void; + + } + impl std::fmt::Debug for MediaFrame_View { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -9736,28 +9738,16 @@ pub mod gapi { } } - /// Constant methods for [crate::gapi::RMat] - pub trait RMatTraitConst { - fn as_raw_RMat(&self) -> *const c_void; - - #[inline] - fn desc(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_RMat_desc_const(self.as_raw_RMat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::GMatDesc::opencv_from_extern(ret) }; - Ok(ret) - } - + impl crate::gapi::MediaFrame_ViewTraitConst for MediaFrame_View { + #[inline] fn as_raw_MediaFrame_View(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::gapi::RMat] - pub trait RMatTrait: crate::gapi::RMatTraitConst { - fn as_raw_mut_RMat(&mut self) -> *mut c_void; - + impl crate::gapi::MediaFrame_ViewTrait for MediaFrame_View { + #[inline] fn as_raw_mut_MediaFrame_View(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { MediaFrame_View, crate::gapi::MediaFrame_ViewTraitConst, as_raw_MediaFrame_View, crate::gapi::MediaFrame_ViewTrait, as_raw_mut_MediaFrame_View } + /// \addtogroup gapi_data_structures pub struct RMat { ptr: *mut c_void, @@ -9774,16 +9764,6 @@ pub mod gapi { unsafe impl Send for RMat {} - impl crate::gapi::RMatTraitConst for RMat { - #[inline] fn as_raw_RMat(&self) -> *const c_void { self.as_raw() } - } - - impl crate::gapi::RMatTrait for RMat { - #[inline] fn as_raw_mut_RMat(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { RMat, crate::gapi::RMatTraitConst, as_raw_RMat, crate::gapi::RMatTrait, as_raw_mut_RMat } - impl RMat { #[inline] pub fn default() -> crate::gapi::RMat { @@ -9794,6 +9774,36 @@ pub mod gapi { } + /// Constant methods for [crate::gapi::RMat] + pub trait RMatTraitConst { + fn as_raw_RMat(&self) -> *const c_void; + + #[inline] + fn desc(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_RMat_desc_const(self.as_raw_RMat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::GMatDesc::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Mutable methods for [crate::gapi::RMat] + pub trait RMatTrait: crate::gapi::RMatTraitConst { + fn as_raw_mut_RMat(&mut self) -> *mut c_void; + + } + + impl Default for RMat { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } + } + impl std::fmt::Debug for RMat { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -9802,14 +9812,31 @@ pub mod gapi { } } - impl Default for RMat { + impl crate::gapi::RMatTraitConst for RMat { + #[inline] fn as_raw_RMat(&self) -> *const c_void { self.as_raw() } + } + + impl crate::gapi::RMatTrait for RMat { + #[inline] fn as_raw_mut_RMat(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { RMat, crate::gapi::RMatTraitConst, as_raw_RMat, crate::gapi::RMatTrait, as_raw_mut_RMat } + + pub struct RMat_IAdapter { + ptr: *mut c_void, + } + + opencv_type_boxed! { RMat_IAdapter } + + impl Drop for RMat_IAdapter { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + fn drop(&mut self) { + unsafe { sys::cv_RMat_IAdapter_delete(self.as_raw_mut_RMat_IAdapter()) }; } } + unsafe impl Send for RMat_IAdapter {} + /// Constant methods for [crate::gapi::RMat_IAdapter] pub trait RMat_IAdapterTraitConst { fn as_raw_RMat_IAdapter(&self) -> *const c_void; @@ -9832,21 +9859,14 @@ pub mod gapi { } - pub struct RMat_IAdapter { - ptr: *mut c_void, - } - - opencv_type_boxed! { RMat_IAdapter } - - impl Drop for RMat_IAdapter { + impl std::fmt::Debug for RMat_IAdapter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_RMat_IAdapter_delete(self.as_raw_mut_RMat_IAdapter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RMat_IAdapter") + .finish() } } - unsafe impl Send for RMat_IAdapter {} - impl crate::gapi::RMat_IAdapterTraitConst for RMat_IAdapter { #[inline] fn as_raw_RMat_IAdapter(&self) -> *const c_void { self.as_raw() } } @@ -9857,15 +9877,36 @@ pub mod gapi { boxed_ref! { RMat_IAdapter, crate::gapi::RMat_IAdapterTraitConst, as_raw_RMat_IAdapter, crate::gapi::RMat_IAdapterTrait, as_raw_mut_RMat_IAdapter } - impl RMat_IAdapter { + pub struct RMat_View { + ptr: *mut c_void, + } + + opencv_type_boxed! { RMat_View } + + impl Drop for RMat_View { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_RMat_View_delete(self.as_raw_mut_RMat_View()) }; + } } - impl std::fmt::Debug for RMat_IAdapter { + unsafe impl Send for RMat_View {} + + impl RMat_View { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RMat_IAdapter") - .finish() + pub fn default() -> crate::gapi::RMat_View { + let ret = unsafe { sys::cv_RMat_View_View() }; + let ret = unsafe { crate::gapi::RMat_View::opencv_from_extern(ret) }; + ret + } + + #[inline] + pub fn copy_mut(mut unnamed: crate::gapi::RMat_View) -> crate::gapi::RMat_View { + let ret = unsafe { sys::cv_RMat_View_View_ViewRR(unnamed.as_raw_mut_RMat_View()) }; + let ret = unsafe { crate::gapi::RMat_View::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::gapi::RMat_View] @@ -9995,21 +10036,22 @@ pub mod gapi { } - pub struct RMat_View { - ptr: *mut c_void, + impl Default for RMat_View { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { RMat_View } - - impl Drop for RMat_View { + impl std::fmt::Debug for RMat_View { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_RMat_View_delete(self.as_raw_mut_RMat_View()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RMat_View") + .finish() } } - unsafe impl Send for RMat_View {} - impl crate::gapi::RMat_ViewTraitConst for RMat_View { #[inline] fn as_raw_RMat_View(&self) -> *const c_void { self.as_raw() } } @@ -10020,37 +10062,30 @@ pub mod gapi { boxed_ref! { RMat_View, crate::gapi::RMat_ViewTraitConst, as_raw_RMat_View, crate::gapi::RMat_ViewTrait, as_raw_mut_RMat_View } - impl RMat_View { - #[inline] - pub fn default() -> crate::gapi::RMat_View { - let ret = unsafe { sys::cv_RMat_View_View() }; - let ret = unsafe { crate::gapi::RMat_View::opencv_from_extern(ret) }; - ret - } - - #[inline] - pub fn copy_mut(mut unnamed: crate::gapi::RMat_View) -> crate::gapi::RMat_View { - let ret = unsafe { sys::cv_RMat_View_View_ViewRR(unnamed.as_raw_mut_RMat_View()) }; - let ret = unsafe { crate::gapi::RMat_View::opencv_from_extern(ret) }; - ret - } - + pub struct Detail_ExtractArgsCallback { + ptr: *mut c_void, } - impl std::fmt::Debug for RMat_View { + opencv_type_boxed! { Detail_ExtractArgsCallback } + + impl Drop for Detail_ExtractArgsCallback { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RMat_View") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_detail_ExtractArgsCallback_delete(self.as_raw_mut_Detail_ExtractArgsCallback()) }; } } - impl Default for RMat_View { + unsafe impl Send for Detail_ExtractArgsCallback {} + + impl Detail_ExtractArgsCallback { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::gapi::Detail_ExtractArgsCallback { + let ret = unsafe { sys::cv_detail_ExtractArgsCallback_defaultNew_const() }; + let ret = unsafe { crate::gapi::Detail_ExtractArgsCallback::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::gapi::Detail_ExtractArgsCallback] @@ -10075,21 +10110,22 @@ pub mod gapi { } - pub struct Detail_ExtractArgsCallback { - ptr: *mut c_void, + impl Default for Detail_ExtractArgsCallback { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_ExtractArgsCallback } - - impl Drop for Detail_ExtractArgsCallback { + impl std::fmt::Debug for Detail_ExtractArgsCallback { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_ExtractArgsCallback_delete(self.as_raw_mut_Detail_ExtractArgsCallback()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_ExtractArgsCallback") + .finish() } } - unsafe impl Send for Detail_ExtractArgsCallback {} - impl crate::gapi::Detail_ExtractArgsCallbackTraitConst for Detail_ExtractArgsCallback { #[inline] fn as_raw_Detail_ExtractArgsCallback(&self) -> *const c_void { self.as_raw() } } @@ -10100,29 +10136,30 @@ pub mod gapi { boxed_ref! { Detail_ExtractArgsCallback, crate::gapi::Detail_ExtractArgsCallbackTraitConst, as_raw_Detail_ExtractArgsCallback, crate::gapi::Detail_ExtractArgsCallbackTrait, as_raw_mut_Detail_ExtractArgsCallback } - impl Detail_ExtractArgsCallback { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_ExtractArgsCallback_defaultNew_const()) } - } - + pub struct Detail_ExtractMetaCallback { + ptr: *mut c_void, } - impl std::fmt::Debug for Detail_ExtractArgsCallback { + opencv_type_boxed! { Detail_ExtractMetaCallback } + + impl Drop for Detail_ExtractMetaCallback { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_ExtractArgsCallback") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_detail_ExtractMetaCallback_delete(self.as_raw_mut_Detail_ExtractMetaCallback()) }; } } - impl Default for Detail_ExtractArgsCallback { + unsafe impl Send for Detail_ExtractMetaCallback {} + + impl Detail_ExtractMetaCallback { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::gapi::Detail_ExtractMetaCallback { + let ret = unsafe { sys::cv_detail_ExtractMetaCallback_defaultNew_const() }; + let ret = unsafe { crate::gapi::Detail_ExtractMetaCallback::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::gapi::Detail_ExtractMetaCallback] @@ -10137,21 +10174,22 @@ pub mod gapi { } - pub struct Detail_ExtractMetaCallback { - ptr: *mut c_void, + impl Default for Detail_ExtractMetaCallback { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_ExtractMetaCallback } - - impl Drop for Detail_ExtractMetaCallback { + impl std::fmt::Debug for Detail_ExtractMetaCallback { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_ExtractMetaCallback_delete(self.as_raw_mut_Detail_ExtractMetaCallback()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_ExtractMetaCallback") + .finish() } } - unsafe impl Send for Detail_ExtractMetaCallback {} - impl crate::gapi::Detail_ExtractMetaCallbackTraitConst for Detail_ExtractMetaCallback { #[inline] fn as_raw_Detail_ExtractMetaCallback(&self) -> *const c_void { self.as_raw() } } @@ -10162,31 +10200,21 @@ pub mod gapi { boxed_ref! { Detail_ExtractMetaCallback, crate::gapi::Detail_ExtractMetaCallbackTraitConst, as_raw_Detail_ExtractMetaCallback, crate::gapi::Detail_ExtractMetaCallbackTrait, as_raw_mut_Detail_ExtractMetaCallback } - impl Detail_ExtractMetaCallback { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_ExtractMetaCallback_defaultNew_const()) } - } - + pub struct Detail_GArrayU { + ptr: *mut c_void, } - impl std::fmt::Debug for Detail_ExtractMetaCallback { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_ExtractMetaCallback") - .finish() - } - } + opencv_type_boxed! { Detail_GArrayU } - impl Default for Detail_ExtractMetaCallback { + impl Drop for Detail_GArrayU { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + fn drop(&mut self) { + unsafe { sys::cv_detail_GArrayU_delete(self.as_raw_mut_Detail_GArrayU()) }; } } + unsafe impl Send for Detail_GArrayU {} + /// Constant methods for [crate::gapi::Detail_GArrayU] pub trait Detail_GArrayUTraitConst { fn as_raw_Detail_GArrayU(&self) -> *const c_void; @@ -10199,21 +10227,14 @@ pub mod gapi { } - pub struct Detail_GArrayU { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_GArrayU } - - impl Drop for Detail_GArrayU { + impl std::fmt::Debug for Detail_GArrayU { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_GArrayU_delete(self.as_raw_mut_Detail_GArrayU()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_GArrayU") + .finish() } } - unsafe impl Send for Detail_GArrayU {} - impl crate::gapi::Detail_GArrayUTraitConst for Detail_GArrayU { #[inline] fn as_raw_Detail_GArrayU(&self) -> *const c_void { self.as_raw() } } @@ -10224,17 +10245,21 @@ pub mod gapi { boxed_ref! { Detail_GArrayU, crate::gapi::Detail_GArrayUTraitConst, as_raw_Detail_GArrayU, crate::gapi::Detail_GArrayUTrait, as_raw_mut_Detail_GArrayU } - impl Detail_GArrayU { + pub struct Detail_GOpaqueU { + ptr: *mut c_void, } - impl std::fmt::Debug for Detail_GArrayU { + opencv_type_boxed! { Detail_GOpaqueU } + + impl Drop for Detail_GOpaqueU { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_GArrayU") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_detail_GOpaqueU_delete(self.as_raw_mut_Detail_GOpaqueU()) }; } } + unsafe impl Send for Detail_GOpaqueU {} + /// Constant methods for [crate::gapi::Detail_GOpaqueU] pub trait Detail_GOpaqueUTraitConst { fn as_raw_Detail_GOpaqueU(&self) -> *const c_void; @@ -10247,21 +10272,14 @@ pub mod gapi { } - pub struct Detail_GOpaqueU { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_GOpaqueU } - - impl Drop for Detail_GOpaqueU { + impl std::fmt::Debug for Detail_GOpaqueU { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_GOpaqueU_delete(self.as_raw_mut_Detail_GOpaqueU()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_GOpaqueU") + .finish() } } - unsafe impl Send for Detail_GOpaqueU {} - impl crate::gapi::Detail_GOpaqueUTraitConst for Detail_GOpaqueU { #[inline] fn as_raw_Detail_GOpaqueU(&self) -> *const c_void { self.as_raw() } } @@ -10270,17 +10288,35 @@ pub mod gapi { #[inline] fn as_raw_mut_Detail_GOpaqueU(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { Detail_GOpaqueU, crate::gapi::Detail_GOpaqueUTraitConst, as_raw_Detail_GOpaqueU, crate::gapi::Detail_GOpaqueUTrait, as_raw_mut_Detail_GOpaqueU } + boxed_ref! { Detail_GOpaqueU, crate::gapi::Detail_GOpaqueUTraitConst, as_raw_Detail_GOpaqueU, crate::gapi::Detail_GOpaqueUTrait, as_raw_mut_Detail_GOpaqueU } + + /// @private + pub struct GBackend { + ptr: *mut c_void, + } + + opencv_type_boxed! { GBackend } - impl Detail_GOpaqueU { + impl Drop for GBackend { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_gapi_GBackend_delete(self.as_raw_mut_GBackend()) }; + } } - impl std::fmt::Debug for Detail_GOpaqueU { + unsafe impl Send for GBackend {} + + impl GBackend { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_GOpaqueU") - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_gapi_GBackend_GBackend(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::GBackend::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::gapi::GBackend] @@ -10304,22 +10340,14 @@ pub mod gapi { } - /// @private - pub struct GBackend { - ptr: *mut c_void, - } - - opencv_type_boxed! { GBackend } - - impl Drop for GBackend { + impl std::fmt::Debug for GBackend { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_gapi_GBackend_delete(self.as_raw_mut_GBackend()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GBackend") + .finish() } } - unsafe impl Send for GBackend {} - impl crate::gapi::GBackendTraitConst for GBackend { #[inline] fn as_raw_GBackend(&self) -> *const c_void { self.as_raw() } } @@ -10330,27 +10358,22 @@ pub mod gapi { boxed_ref! { GBackend, crate::gapi::GBackendTraitConst, as_raw_GBackend, crate::gapi::GBackendTrait, as_raw_mut_GBackend } - impl GBackend { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_gapi_GBackend_GBackend(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::GBackend::opencv_from_extern(ret) }; - Ok(ret) - } - + /// @private + pub struct GFunctor { + ptr: *mut c_void, } - impl std::fmt::Debug for GBackend { + opencv_type_boxed! { GFunctor } + + impl Drop for GFunctor { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GBackend") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_gapi_GFunctor_delete(self.as_raw_mut_GFunctor()) }; } } + unsafe impl Send for GFunctor {} + /// Constant methods for [crate::gapi::GFunctor] pub trait GFunctorTraitConst { fn as_raw_GFunctor(&self) -> *const c_void; @@ -10393,22 +10416,14 @@ pub mod gapi { } - /// @private - pub struct GFunctor { - ptr: *mut c_void, - } - - opencv_type_boxed! { GFunctor } - - impl Drop for GFunctor { + impl std::fmt::Debug for GFunctor { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_gapi_GFunctor_delete(self.as_raw_mut_GFunctor()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GFunctor") + .finish() } } - unsafe impl Send for GFunctor {} - impl crate::gapi::GFunctorTraitConst for GFunctor { #[inline] fn as_raw_GFunctor(&self) -> *const c_void { self.as_raw() } } @@ -10419,61 +10434,6 @@ pub mod gapi { boxed_ref! { GFunctor, crate::gapi::GFunctorTraitConst, as_raw_GFunctor, crate::gapi::GFunctorTrait, as_raw_mut_GFunctor } - impl GFunctor { - } - - impl std::fmt::Debug for GFunctor { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GFunctor") - .finish() - } - } - - /// Constant methods for [crate::gapi::Scalar] - pub trait ScalarTraitConst { - fn as_raw_Scalar(&self) -> *const c_void; - - #[inline] - fn val(&self) -> &[f64; 4] { - let ret = unsafe { sys::cv_gapi_own_Scalar_propVal_const(self.as_raw_Scalar()) }; - let ret = unsafe { ret.as_ref() }.expect("Function returned null pointer"); - ret - } - - #[inline] - fn get(&self, i: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_gapi_own_Scalar_operator___const_int(self.as_raw_Scalar(), i, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - /// Mutable methods for [crate::gapi::Scalar] - pub trait ScalarTrait: crate::gapi::ScalarTraitConst { - fn as_raw_mut_Scalar(&mut self) -> *mut c_void; - - #[inline] - fn val_mut(&mut self) -> &mut [f64; 4] { - let ret = unsafe { sys::cv_gapi_own_Scalar_propVal(self.as_raw_mut_Scalar()) }; - let ret = unsafe { ret.as_mut() }.expect("Function returned null pointer"); - ret - } - - #[inline] - fn get_mut(&mut self, i: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_gapi_own_Scalar_operator___int(self.as_raw_mut_Scalar(), i, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - pub struct Scalar { ptr: *mut c_void, } @@ -10489,16 +10449,6 @@ pub mod gapi { unsafe impl Send for Scalar {} - impl crate::gapi::ScalarTraitConst for Scalar { - #[inline] fn as_raw_Scalar(&self) -> *const c_void { self.as_raw() } - } - - impl crate::gapi::ScalarTrait for Scalar { - #[inline] fn as_raw_mut_Scalar(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Scalar, crate::gapi::ScalarTraitConst, as_raw_Scalar, crate::gapi::ScalarTrait, as_raw_mut_Scalar } - impl Scalar { #[inline] pub fn default() -> crate::gapi::Scalar { @@ -10556,13 +10506,48 @@ pub mod gapi { } - impl std::fmt::Debug for Scalar { + /// Constant methods for [crate::gapi::Scalar] + pub trait ScalarTraitConst { + fn as_raw_Scalar(&self) -> *const c_void; + #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Scalar") - .field("val", &crate::gapi::ScalarTraitConst::val(self)) - .finish() + fn val(&self) -> &[f64; 4] { + let ret = unsafe { sys::cv_gapi_own_Scalar_propVal_const(self.as_raw_Scalar()) }; + let ret = unsafe { ret.as_ref() }.expect("Function returned null pointer"); + ret + } + + #[inline] + fn get(&self, i: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_gapi_own_Scalar_operator___const_int(self.as_raw_Scalar(), i, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + /// Mutable methods for [crate::gapi::Scalar] + pub trait ScalarTrait: crate::gapi::ScalarTraitConst { + fn as_raw_mut_Scalar(&mut self) -> *mut c_void; + + #[inline] + fn val_mut(&mut self) -> &mut [f64; 4] { + let ret = unsafe { sys::cv_gapi_own_Scalar_propVal(self.as_raw_mut_Scalar()) }; + let ret = unsafe { ret.as_mut() }.expect("Function returned null pointer"); + ret + } + + #[inline] + fn get_mut(&mut self, i: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_gapi_own_Scalar_operator___int(self.as_raw_mut_Scalar(), i, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } + } impl Default for Scalar { @@ -10573,6 +10558,25 @@ pub mod gapi { } } + impl std::fmt::Debug for Scalar { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Scalar") + .field("val", &crate::gapi::ScalarTraitConst::val(self)) + .finish() + } + } + + impl crate::gapi::ScalarTraitConst for Scalar { + #[inline] fn as_raw_Scalar(&self) -> *const c_void { self.as_raw() } + } + + impl crate::gapi::ScalarTrait for Scalar { + #[inline] fn as_raw_mut_Scalar(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Scalar, crate::gapi::ScalarTraitConst, as_raw_Scalar, crate::gapi::ScalarTrait, as_raw_mut_Scalar } + /// Specify queue capacity for streaming execution. /// /// In the streaming mode the pipeline steps are connected with queues @@ -10611,31 +10615,6 @@ pub mod gapi { } - /// Constant methods for [crate::gapi::use_only] - pub trait use_onlyTraitConst { - fn as_raw_use_only(&self) -> *const c_void; - - #[inline] - fn pkg(&self) -> crate::gapi::GKernelPackage { - let ret = unsafe { sys::cv_gapi_use_only_propPkg_const(self.as_raw_use_only()) }; - let ret = unsafe { crate::gapi::GKernelPackage::opencv_from_extern(ret) }; - ret - } - - } - - /// Mutable methods for [crate::gapi::use_only] - pub trait use_onlyTrait: crate::gapi::use_onlyTraitConst { - fn as_raw_mut_use_only(&mut self) -> *mut c_void; - - #[inline] - fn set_pkg(&mut self, val: crate::gapi::GKernelPackage) { - let ret = unsafe { sys::cv_gapi_use_only_propPkg_const_GKernelPackage(self.as_raw_mut_use_only(), val.as_raw_GKernelPackage()) }; - ret - } - - } - /// \addtogroup gapi_compile_args /// / /// @@ -10657,23 +10636,48 @@ pub mod gapi { unsafe impl Send for use_only {} - impl crate::gapi::use_onlyTraitConst for use_only { - #[inline] fn as_raw_use_only(&self) -> *const c_void { self.as_raw() } - } + impl use_only { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::gapi::use_only { + let ret = unsafe { sys::cv_gapi_use_only_defaultNew_const() }; + let ret = unsafe { crate::gapi::use_only::opencv_from_extern(ret) }; + ret + } + + } + + /// Constant methods for [crate::gapi::use_only] + pub trait use_onlyTraitConst { + fn as_raw_use_only(&self) -> *const c_void; + + #[inline] + fn pkg(&self) -> crate::gapi::GKernelPackage { + let ret = unsafe { sys::cv_gapi_use_only_propPkg_const(self.as_raw_use_only()) }; + let ret = unsafe { crate::gapi::GKernelPackage::opencv_from_extern(ret) }; + ret + } + + } + + /// Mutable methods for [crate::gapi::use_only] + pub trait use_onlyTrait: crate::gapi::use_onlyTraitConst { + fn as_raw_mut_use_only(&mut self) -> *mut c_void; + + #[inline] + fn set_pkg(&mut self, val: crate::gapi::GKernelPackage) { + let ret = unsafe { sys::cv_gapi_use_only_propPkg_const_GKernelPackage(self.as_raw_mut_use_only(), val.as_raw_GKernelPackage()) }; + ret + } - impl crate::gapi::use_onlyTrait for use_only { - #[inline] fn as_raw_mut_use_only(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { use_only, crate::gapi::use_onlyTraitConst, as_raw_use_only, crate::gapi::use_onlyTrait, as_raw_mut_use_only } - - impl use_only { - /// Creates a default instance of the class by calling the default constructor + impl Default for use_only { #[inline] + /// Forwards to infallible Self::default() fn default() -> Self { - unsafe { Self::from_raw(sys::cv_gapi_use_only_defaultNew_const()) } + Self::default() } - } impl std::fmt::Debug for use_only { @@ -10685,25 +10689,15 @@ pub mod gapi { } } - impl Default for use_only { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } + impl crate::gapi::use_onlyTraitConst for use_only { + #[inline] fn as_raw_use_only(&self) -> *const c_void { self.as_raw() } } - /// Constant methods for [crate::gapi::Data] - pub trait DataTraitConst: crate::gapi::GRunArgTraitConst { - fn as_raw_Data(&self) -> *const c_void; - + impl crate::gapi::use_onlyTrait for use_only { + #[inline] fn as_raw_mut_use_only(&mut self) -> *mut c_void { self.as_raw_mut() } } - /// Mutable methods for [crate::gapi::Data] - pub trait DataTrait: crate::gapi::DataTraitConst + crate::gapi::GRunArgTrait { - fn as_raw_mut_Data(&mut self) -> *mut c_void; - - } + boxed_ref! { use_only, crate::gapi::use_onlyTraitConst, as_raw_use_only, crate::gapi::use_onlyTrait, as_raw_mut_use_only } /// This aggregate type represents all types which G-API can /// handle (via variant). @@ -10725,37 +10719,37 @@ pub mod gapi { unsafe impl Send for Data {} - impl crate::gapi::GRunArgTraitConst for Data { - #[inline] fn as_raw_GRunArg(&self) -> *const c_void { self.as_raw() } - } + impl Data { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::gapi::Data { + let ret = unsafe { sys::cv_gapi_wip_Data_defaultNew_const() }; + let ret = unsafe { crate::gapi::Data::opencv_from_extern(ret) }; + ret + } - impl crate::gapi::GRunArgTrait for Data { - #[inline] fn as_raw_mut_GRunArg(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { Data, crate::gapi::GRunArgTraitConst, as_raw_GRunArg, crate::gapi::GRunArgTrait, as_raw_mut_GRunArg } + /// Constant methods for [crate::gapi::Data] + pub trait DataTraitConst: crate::gapi::GRunArgTraitConst { + fn as_raw_Data(&self) -> *const c_void; - impl crate::gapi::DataTraitConst for Data { - #[inline] fn as_raw_Data(&self) -> *const c_void { self.as_raw() } } - impl crate::gapi::DataTrait for Data { - #[inline] fn as_raw_mut_Data(&mut self) -> *mut c_void { self.as_raw_mut() } - } + /// Mutable methods for [crate::gapi::Data] + pub trait DataTrait: crate::gapi::DataTraitConst + crate::gapi::GRunArgTrait { + fn as_raw_mut_Data(&mut self) -> *mut c_void; - boxed_ref! { Data, crate::gapi::DataTraitConst, as_raw_Data, crate::gapi::DataTrait, as_raw_mut_Data } + } - impl Data { - /// Creates a default instance of the class by calling the default constructor + impl Default for Data { #[inline] + /// Forwards to infallible Self::default() fn default() -> Self { - unsafe { Self::from_raw(sys::cv_gapi_wip_Data_defaultNew_const()) } + Self::default() } - } - boxed_cast_base! { Data, crate::gapi::GRunArg, cv_gapi_wip_Data_to_GRunArg } - impl std::fmt::Debug for Data { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -10764,14 +10758,28 @@ pub mod gapi { } } - impl Default for Data { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } + boxed_cast_base! { Data, crate::gapi::GRunArg, cv_gapi_wip_Data_to_GRunArg } + + impl crate::gapi::GRunArgTraitConst for Data { + #[inline] fn as_raw_GRunArg(&self) -> *const c_void { self.as_raw() } + } + + impl crate::gapi::GRunArgTrait for Data { + #[inline] fn as_raw_mut_GRunArg(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Data, crate::gapi::GRunArgTraitConst, as_raw_GRunArg, crate::gapi::GRunArgTrait, as_raw_mut_GRunArg } + + impl crate::gapi::DataTraitConst for Data { + #[inline] fn as_raw_Data(&self) -> *const c_void { self.as_raw() } + } + + impl crate::gapi::DataTrait for Data { + #[inline] fn as_raw_mut_Data(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { Data, crate::gapi::DataTraitConst, as_raw_Data, crate::gapi::DataTrait, as_raw_mut_Data } + /// This structure represents a circle to draw. /// /// Parameters match cv::circle(). @@ -10860,6 +10868,50 @@ pub mod gapi { } } + /// This structure represents an image to draw. + /// + /// Image is blended on a frame using the specified mask. + pub struct Image { + ptr: *mut c_void, + } + + opencv_type_boxed! { Image } + + impl Drop for Image { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_gapi_wip_draw_Image_delete(self.as_raw_mut_Image()) }; + } + } + + unsafe impl Send for Image {} + + impl Image { + /// Mosaic constructor + /// + /// ## Parameters + /// * org_: The bottom-left corner of the image + /// * img_: Image to draw + /// * alpha_: Alpha channel for image to draw (same size and number of channels) + #[inline] + pub fn new(org_: core::Point, img_: &impl core::MatTraitConst, alpha_: &impl core::MatTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_gapi_wip_draw_Image_Image_const_PointR_const_MatR_const_MatR(&org_, img_.as_raw_Mat(), alpha_.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::Image::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn default() -> crate::gapi::Image { + let ret = unsafe { sys::cv_gapi_wip_draw_Image_Image() }; + let ret = unsafe { crate::gapi::Image::opencv_from_extern(ret) }; + ret + } + + } + /// Constant methods for [crate::gapi::Image] pub trait ImageTraitConst { fn as_raw_Image(&self) -> *const c_void; @@ -10918,58 +10970,12 @@ pub mod gapi { } - /// This structure represents an image to draw. - /// - /// Image is blended on a frame using the specified mask. - pub struct Image { - ptr: *mut c_void, - } - - opencv_type_boxed! { Image } - - impl Drop for Image { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_gapi_wip_draw_Image_delete(self.as_raw_mut_Image()) }; - } - } - - unsafe impl Send for Image {} - - impl crate::gapi::ImageTraitConst for Image { - #[inline] fn as_raw_Image(&self) -> *const c_void { self.as_raw() } - } - - impl crate::gapi::ImageTrait for Image { - #[inline] fn as_raw_mut_Image(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Image, crate::gapi::ImageTraitConst, as_raw_Image, crate::gapi::ImageTrait, as_raw_mut_Image } - - impl Image { - /// Mosaic constructor - /// - /// ## Parameters - /// * org_: The bottom-left corner of the image - /// * img_: Image to draw - /// * alpha_: Alpha channel for image to draw (same size and number of channels) - #[inline] - pub fn new(org_: core::Point, img_: &impl core::MatTraitConst, alpha_: &impl core::MatTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_gapi_wip_draw_Image_Image_const_PointR_const_MatR_const_MatR(&org_, img_.as_raw_Mat(), alpha_.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::Image::opencv_from_extern(ret) }; - Ok(ret) - } - + impl Default for Image { #[inline] - pub fn default() -> crate::gapi::Image { - let ret = unsafe { sys::cv_gapi_wip_draw_Image_Image() }; - let ret = unsafe { crate::gapi::Image::opencv_from_extern(ret) }; - ret + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() } - } impl Clone for Image { @@ -10990,14 +10996,16 @@ pub mod gapi { } } - impl Default for Image { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } + impl crate::gapi::ImageTraitConst for Image { + #[inline] fn as_raw_Image(&self) -> *const c_void { self.as_raw() } + } + + impl crate::gapi::ImageTrait for Image { + #[inline] fn as_raw_mut_Image(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { Image, crate::gapi::ImageTraitConst, as_raw_Image, crate::gapi::ImageTrait, as_raw_mut_Image } + /// This structure represents a line to draw. /// /// Parameters match cv::line(). @@ -11086,47 +11094,120 @@ pub mod gapi { } } - /// This structure represents a mosaicing operation. - /// - /// Mosaicing is a very basic method to obfuscate regions in the image. - #[repr(C)] - #[derive(Copy, Clone, Debug, PartialEq)] - pub struct Mosaic { - /// Coordinates of the mosaic - pub mos: core::Rect, - /// Cell size (same for X, Y) - pub cell_sz: i32, - /// Decimation (0 stands for no decimation) - pub decim: i32, + /// This structure represents a mosaicing operation. + /// + /// Mosaicing is a very basic method to obfuscate regions in the image. + #[repr(C)] + #[derive(Copy, Clone, Debug, PartialEq)] + pub struct Mosaic { + /// Coordinates of the mosaic + pub mos: core::Rect, + /// Cell size (same for X, Y) + pub cell_sz: i32, + /// Decimation (0 stands for no decimation) + pub decim: i32, + } + + opencv_type_simple! { crate::gapi::Mosaic } + + impl Mosaic { + /// Mosaic constructor + /// + /// ## Parameters + /// * mos_: Coordinates of the mosaic + /// * cellSz_: Cell size (same for X, Y) + /// * decim_: Decimation (0 stands for no decimation) + #[inline] + pub fn new(mos_: core::Rect, cell_sz_: i32, decim_: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_gapi_wip_draw_Mosaic_Mosaic_const_RectR_int_int(&mos_, cell_sz_, decim_, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_gapi_wip_draw_Mosaic_Mosaic(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + /// This structure represents a polygon to draw. + pub struct Poly { + ptr: *mut c_void, + } + + opencv_type_boxed! { Poly } + + impl Drop for Poly { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_gapi_wip_draw_Poly_delete(self.as_raw_mut_Poly()) }; + } } - opencv_type_simple! { crate::gapi::Mosaic } + unsafe impl Send for Poly {} - impl Mosaic { + impl Poly { /// Mosaic constructor /// /// ## Parameters - /// * mos_: Coordinates of the mosaic - /// * cellSz_: Cell size (same for X, Y) - /// * decim_: Decimation (0 stands for no decimation) + /// * points_: Points to connect + /// * color_: The line color + /// * thick_: The thickness of line + /// * lt_: The Type of the line. See [line_types] + /// * shift_: The number of fractional bits in the point coordinate + /// + /// ## C++ default parameters + /// * thick_: 1 + /// * lt_: 8 + /// * shift_: 0 #[inline] - pub fn new(mos_: core::Rect, cell_sz_: i32, decim_: i32) -> Result { + pub fn new(points_: &core::Vector, color_: core::Scalar, thick_: i32, lt_: i32, shift_: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_gapi_wip_draw_Mosaic_Mosaic_const_RectR_int_int(&mos_, cell_sz_, decim_, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_gapi_wip_draw_Poly_Poly_const_vectorLPointGR_const_ScalarR_int_int_int(points_.as_raw_VectorOfPoint(), &color_, thick_, lt_, shift_, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::Poly::opencv_from_extern(ret) }; Ok(ret) } + /// Mosaic constructor + /// + /// ## Parameters + /// * points_: Points to connect + /// * color_: The line color + /// * thick_: The thickness of line + /// * lt_: The Type of the line. See [line_types] + /// * shift_: The number of fractional bits in the point coordinate + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * thick_: 1 + /// * lt_: 8 + /// * shift_: 0 #[inline] - pub fn default() -> Result { + pub fn new_def(points_: &core::Vector, color_: core::Scalar) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_gapi_wip_draw_Mosaic_Mosaic(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_gapi_wip_draw_Poly_Poly_const_vectorLPointGR_const_ScalarR(points_.as_raw_VectorOfPoint(), &color_, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::Poly::opencv_from_extern(ret) }; Ok(ret) } + #[inline] + pub fn default() -> crate::gapi::Poly { + let ret = unsafe { sys::cv_gapi_wip_draw_Poly_Poly() }; + let ret = unsafe { crate::gapi::Poly::opencv_from_extern(ret) }; + ret + } + } /// Constant methods for [crate::gapi::Poly] @@ -11214,87 +11295,12 @@ pub mod gapi { } - /// This structure represents a polygon to draw. - pub struct Poly { - ptr: *mut c_void, - } - - opencv_type_boxed! { Poly } - - impl Drop for Poly { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_gapi_wip_draw_Poly_delete(self.as_raw_mut_Poly()) }; - } - } - - unsafe impl Send for Poly {} - - impl crate::gapi::PolyTraitConst for Poly { - #[inline] fn as_raw_Poly(&self) -> *const c_void { self.as_raw() } - } - - impl crate::gapi::PolyTrait for Poly { - #[inline] fn as_raw_mut_Poly(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Poly, crate::gapi::PolyTraitConst, as_raw_Poly, crate::gapi::PolyTrait, as_raw_mut_Poly } - - impl Poly { - /// Mosaic constructor - /// - /// ## Parameters - /// * points_: Points to connect - /// * color_: The line color - /// * thick_: The thickness of line - /// * lt_: The Type of the line. See [line_types] - /// * shift_: The number of fractional bits in the point coordinate - /// - /// ## C++ default parameters - /// * thick_: 1 - /// * lt_: 8 - /// * shift_: 0 - #[inline] - pub fn new(points_: &core::Vector, color_: core::Scalar, thick_: i32, lt_: i32, shift_: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_gapi_wip_draw_Poly_Poly_const_vectorLPointGR_const_ScalarR_int_int_int(points_.as_raw_VectorOfPoint(), &color_, thick_, lt_, shift_, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::Poly::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Mosaic constructor - /// - /// ## Parameters - /// * points_: Points to connect - /// * color_: The line color - /// * thick_: The thickness of line - /// * lt_: The Type of the line. See [line_types] - /// * shift_: The number of fractional bits in the point coordinate - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * thick_: 1 - /// * lt_: 8 - /// * shift_: 0 - #[inline] - pub fn new_def(points_: &core::Vector, color_: core::Scalar) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_gapi_wip_draw_Poly_Poly_const_vectorLPointGR_const_ScalarR(points_.as_raw_VectorOfPoint(), &color_, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::Poly::opencv_from_extern(ret) }; - Ok(ret) - } - + impl Default for Poly { #[inline] - pub fn default() -> crate::gapi::Poly { - let ret = unsafe { sys::cv_gapi_wip_draw_Poly_Poly() }; - let ret = unsafe { crate::gapi::Poly::opencv_from_extern(ret) }; - ret + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() } - } impl Clone for Poly { @@ -11317,14 +11323,16 @@ pub mod gapi { } } - impl Default for Poly { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } + impl crate::gapi::PolyTraitConst for Poly { + #[inline] fn as_raw_Poly(&self) -> *const c_void { self.as_raw() } + } + + impl crate::gapi::PolyTrait for Poly { + #[inline] fn as_raw_mut_Poly(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { Poly, crate::gapi::PolyTraitConst, as_raw_Poly, crate::gapi::PolyTrait, as_raw_mut_Poly } + /// This structure represents a rectangle to draw. /// /// Parameters match cv::rectangle(). @@ -11392,23 +11400,106 @@ pub mod gapi { } #[inline] - pub fn default() -> crate::gapi::Rect { - return_send!(via ocvrs_return); - unsafe { sys::cv_gapi_wip_draw_Rect_Rect(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); + pub fn default() -> crate::gapi::Rect { + return_send!(via ocvrs_return); + unsafe { sys::cv_gapi_wip_draw_Rect_Rect(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + ret + } + + } + + impl Default for Rect { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } + } + + /// * This structure represents a text string to draw. + /// * + /// * Parameters match cv::putText(). + pub struct Text { + ptr: *mut c_void, + } + + opencv_type_boxed! { Text } + + impl Drop for Text { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_gapi_wip_draw_Text_delete(self.as_raw_mut_Text()) }; + } + } + + unsafe impl Send for Text {} + + impl Text { + /// Text constructor + /// + /// ## Parameters + /// * text_: The text string to be drawn + /// * org_: The bottom-left corner of the text string in the image + /// * ff_: The font type, see [hershey_fonts] + /// * fs_: The font scale factor that is multiplied by the font-specific base size + /// * color_: The text color + /// * thick_: The thickness of the lines used to draw a text + /// * lt_: The line type. See [line_types] + /// * bottom_left_origin_: When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner + /// + /// ## C++ default parameters + /// * thick_: 1 + /// * lt_: 8 + /// * bottom_left_origin_: false + #[inline] + pub fn new(text_: &str, org_: core::Point, ff_: i32, fs_: f64, color_: core::Scalar, thick_: i32, lt_: i32, bottom_left_origin_: bool) -> Result { + extern_container_arg!(text_); + return_send!(via ocvrs_return); + unsafe { sys::cv_gapi_wip_draw_Text_Text_const_stringR_const_PointR_int_double_const_ScalarR_int_int_bool(text_.opencv_as_extern(), &org_, ff_, fs_, &color_, thick_, lt_, bottom_left_origin_, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::Text::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Text constructor + /// + /// ## Parameters + /// * text_: The text string to be drawn + /// * org_: The bottom-left corner of the text string in the image + /// * ff_: The font type, see [hershey_fonts] + /// * fs_: The font scale factor that is multiplied by the font-specific base size + /// * color_: The text color + /// * thick_: The thickness of the lines used to draw a text + /// * lt_: The line type. See [line_types] + /// * bottom_left_origin_: When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * thick_: 1 + /// * lt_: 8 + /// * bottom_left_origin_: false + #[inline] + pub fn new_def(text_: &str, org_: core::Point, ff_: i32, fs_: f64, color_: core::Scalar) -> Result { + extern_container_arg!(text_); + return_send!(via ocvrs_return); + unsafe { sys::cv_gapi_wip_draw_Text_Text_const_stringR_const_PointR_int_double_const_ScalarR(text_.opencv_as_extern(), &org_, ff_, fs_, &color_, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::gapi::Text::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn default() -> crate::gapi::Text { + let ret = unsafe { sys::cv_gapi_wip_draw_Text_Text() }; + let ret = unsafe { crate::gapi::Text::opencv_from_extern(ret) }; ret } } - impl Default for Rect { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - /// Constant methods for [crate::gapi::Text] pub trait TextTraitConst { fn as_raw_Text(&self) -> *const c_void; @@ -11539,97 +11630,12 @@ pub mod gapi { } - /// * This structure represents a text string to draw. - /// * - /// * Parameters match cv::putText(). - pub struct Text { - ptr: *mut c_void, - } - - opencv_type_boxed! { Text } - - impl Drop for Text { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_gapi_wip_draw_Text_delete(self.as_raw_mut_Text()) }; - } - } - - unsafe impl Send for Text {} - - impl crate::gapi::TextTraitConst for Text { - #[inline] fn as_raw_Text(&self) -> *const c_void { self.as_raw() } - } - - impl crate::gapi::TextTrait for Text { - #[inline] fn as_raw_mut_Text(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Text, crate::gapi::TextTraitConst, as_raw_Text, crate::gapi::TextTrait, as_raw_mut_Text } - - impl Text { - /// Text constructor - /// - /// ## Parameters - /// * text_: The text string to be drawn - /// * org_: The bottom-left corner of the text string in the image - /// * ff_: The font type, see [hershey_fonts] - /// * fs_: The font scale factor that is multiplied by the font-specific base size - /// * color_: The text color - /// * thick_: The thickness of the lines used to draw a text - /// * lt_: The line type. See [line_types] - /// * bottom_left_origin_: When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner - /// - /// ## C++ default parameters - /// * thick_: 1 - /// * lt_: 8 - /// * bottom_left_origin_: false - #[inline] - pub fn new(text_: &str, org_: core::Point, ff_: i32, fs_: f64, color_: core::Scalar, thick_: i32, lt_: i32, bottom_left_origin_: bool) -> Result { - extern_container_arg!(text_); - return_send!(via ocvrs_return); - unsafe { sys::cv_gapi_wip_draw_Text_Text_const_stringR_const_PointR_int_double_const_ScalarR_int_int_bool(text_.opencv_as_extern(), &org_, ff_, fs_, &color_, thick_, lt_, bottom_left_origin_, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::Text::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Text constructor - /// - /// ## Parameters - /// * text_: The text string to be drawn - /// * org_: The bottom-left corner of the text string in the image - /// * ff_: The font type, see [hershey_fonts] - /// * fs_: The font scale factor that is multiplied by the font-specific base size - /// * color_: The text color - /// * thick_: The thickness of the lines used to draw a text - /// * lt_: The line type. See [line_types] - /// * bottom_left_origin_: When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * thick_: 1 - /// * lt_: 8 - /// * bottom_left_origin_: false - #[inline] - pub fn new_def(text_: &str, org_: core::Point, ff_: i32, fs_: f64, color_: core::Scalar) -> Result { - extern_container_arg!(text_); - return_send!(via ocvrs_return); - unsafe { sys::cv_gapi_wip_draw_Text_Text_const_stringR_const_PointR_int_double_const_ScalarR(text_.opencv_as_extern(), &org_, ff_, fs_, &color_, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::gapi::Text::opencv_from_extern(ret) }; - Ok(ret) - } - + impl Default for Text { #[inline] - pub fn default() -> crate::gapi::Text { - let ret = unsafe { sys::cv_gapi_wip_draw_Text_Text() }; - let ret = unsafe { crate::gapi::Text::opencv_from_extern(ret) }; - ret + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() } - } impl Clone for Text { @@ -11655,37 +11661,15 @@ pub mod gapi { } } - impl Default for Text { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } + impl crate::gapi::TextTraitConst for Text { + #[inline] fn as_raw_Text(&self) -> *const c_void { self.as_raw() } } - /// Constant methods for [crate::gapi::use_threaded_executor] - pub trait use_threaded_executorTraitConst { - fn as_raw_use_threaded_executor(&self) -> *const c_void; - - #[inline] - fn num_threads(&self) -> u32 { - let ret = unsafe { sys::cv_use_threaded_executor_propNum_threads_const(self.as_raw_use_threaded_executor()) }; - ret - } - + impl crate::gapi::TextTrait for Text { + #[inline] fn as_raw_mut_Text(&mut self) -> *mut c_void { self.as_raw_mut() } } - /// Mutable methods for [crate::gapi::use_threaded_executor] - pub trait use_threaded_executorTrait: crate::gapi::use_threaded_executorTraitConst { - fn as_raw_mut_use_threaded_executor(&mut self) -> *mut c_void; - - #[inline] - fn set_num_threads(&mut self, val: u32) { - let ret = unsafe { sys::cv_use_threaded_executor_propNum_threads_const_uint32_t(self.as_raw_mut_use_threaded_executor(), val) }; - ret - } - - } + boxed_ref! { Text, crate::gapi::TextTraitConst, as_raw_Text, crate::gapi::TextTrait, as_raw_mut_Text } /// Ask G-API to use threaded executor when cv::GComputation /// is compiled via cv::GComputation::compile method. @@ -11706,16 +11690,6 @@ pub mod gapi { unsafe impl Send for use_threaded_executor {} - impl crate::gapi::use_threaded_executorTraitConst for use_threaded_executor { - #[inline] fn as_raw_use_threaded_executor(&self) -> *const c_void { self.as_raw() } - } - - impl crate::gapi::use_threaded_executorTrait for use_threaded_executor { - #[inline] fn as_raw_mut_use_threaded_executor(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { use_threaded_executor, crate::gapi::use_threaded_executorTraitConst, as_raw_use_threaded_executor, crate::gapi::use_threaded_executorTrait, as_raw_mut_use_threaded_executor } - impl use_threaded_executor { #[inline] pub fn default() -> Result { @@ -11739,42 +11713,49 @@ pub mod gapi { } - impl std::fmt::Debug for use_threaded_executor { + /// Constant methods for [crate::gapi::use_threaded_executor] + pub trait use_threaded_executorTraitConst { + fn as_raw_use_threaded_executor(&self) -> *const c_void; + #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("use_threaded_executor") - .field("num_threads", &crate::gapi::use_threaded_executorTraitConst::num_threads(self)) - .finish() + fn num_threads(&self) -> u32 { + let ret = unsafe { sys::cv_use_threaded_executor_propNum_threads_const(self.as_raw_use_threaded_executor()) }; + ret } - } - - /// Constant methods for [crate::gapi::any] - pub trait anyTraitConst { - fn as_raw_any(&self) -> *const c_void; } - /// Mutable methods for [crate::gapi::any] - pub trait anyTrait: crate::gapi::anyTraitConst { - fn as_raw_mut_any(&mut self) -> *mut c_void; + /// Mutable methods for [crate::gapi::use_threaded_executor] + pub trait use_threaded_executorTrait: crate::gapi::use_threaded_executorTraitConst { + fn as_raw_mut_use_threaded_executor(&mut self) -> *mut c_void; #[inline] - fn set(&mut self, mut unnamed: crate::gapi::any) { - let ret = unsafe { sys::cv_util_any_operatorST_anyRR(self.as_raw_mut_any(), unnamed.as_raw_mut_any()) }; + fn set_num_threads(&mut self, val: u32) { + let ret = unsafe { sys::cv_use_threaded_executor_propNum_threads_const_uint32_t(self.as_raw_mut_use_threaded_executor(), val) }; ret } + } + + impl std::fmt::Debug for use_threaded_executor { #[inline] - fn set_1(&mut self, src: &impl crate::gapi::anyTraitConst) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_util_any_operatorST_const_anyR(self.as_raw_mut_any(), src.as_raw_any(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("use_threaded_executor") + .field("num_threads", &crate::gapi::use_threaded_executorTraitConst::num_threads(self)) + .finish() } + } + impl crate::gapi::use_threaded_executorTraitConst for use_threaded_executor { + #[inline] fn as_raw_use_threaded_executor(&self) -> *const c_void { self.as_raw() } + } + + impl crate::gapi::use_threaded_executorTrait for use_threaded_executor { + #[inline] fn as_raw_mut_use_threaded_executor(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { use_threaded_executor, crate::gapi::use_threaded_executorTraitConst, as_raw_use_threaded_executor, crate::gapi::use_threaded_executorTrait, as_raw_mut_use_threaded_executor } + pub struct any { ptr: *mut c_void, } @@ -11790,16 +11771,6 @@ pub mod gapi { unsafe impl Send for any {} - impl crate::gapi::anyTraitConst for any { - #[inline] fn as_raw_any(&self) -> *const c_void { self.as_raw() } - } - - impl crate::gapi::anyTrait for any { - #[inline] fn as_raw_mut_any(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { any, crate::gapi::anyTraitConst, as_raw_any, crate::gapi::anyTrait, as_raw_mut_any } - impl any { #[inline] pub fn copy(src: &impl crate::gapi::anyTraitConst) -> Result { @@ -11837,12 +11808,31 @@ pub mod gapi { } - impl std::fmt::Debug for any { + /// Constant methods for [crate::gapi::any] + pub trait anyTraitConst { + fn as_raw_any(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::gapi::any] + pub trait anyTrait: crate::gapi::anyTraitConst { + fn as_raw_mut_any(&mut self) -> *mut c_void; + #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("any") - .finish() + fn set(&mut self, mut unnamed: crate::gapi::any) { + let ret = unsafe { sys::cv_util_any_operatorST_anyRR(self.as_raw_mut_any(), unnamed.as_raw_mut_any()) }; + ret + } + + #[inline] + fn set_1(&mut self, src: &impl crate::gapi::anyTraitConst) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_util_any_operatorST_const_anyR(self.as_raw_mut_any(), src.as_raw_any(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } + } impl Default for any { @@ -11852,4 +11842,23 @@ pub mod gapi { Self::default() } } + + impl std::fmt::Debug for any { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("any") + .finish() + } + } + + impl crate::gapi::anyTraitConst for any { + #[inline] fn as_raw_any(&self) -> *const c_void { self.as_raw() } + } + + impl crate::gapi::anyTrait for any { + #[inline] fn as_raw_mut_any(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { any, crate::gapi::anyTraitConst, as_raw_any, crate::gapi::anyTrait, as_raw_mut_any } + } diff --git a/docs/hdf.rs b/docs/hdf.rs index b8180ad58..2ed2666f7 100644 --- a/docs/hdf.rs +++ b/docs/hdf.rs @@ -82,6 +82,24 @@ pub mod hdf { Ok(ret) } + /// Hierarchical Data Format version 5 interface. + /// + /// Notice that this module is compiled only when hdf5 is correctly installed. + pub struct HDF5 { + ptr: *mut c_void, + } + + opencv_type_boxed! { HDF5 } + + impl Drop for HDF5 { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_hdf_HDF5_delete(self.as_raw_mut_HDF5()) }; + } + } + + unsafe impl Send for HDF5 {} + /// Constant methods for [crate::hdf::HDF5] pub trait HDF5TraitConst { fn as_raw_HDF5(&self) -> *const c_void; @@ -1487,24 +1505,14 @@ pub mod hdf { } - /// Hierarchical Data Format version 5 interface. - /// - /// Notice that this module is compiled only when hdf5 is correctly installed. - pub struct HDF5 { - ptr: *mut c_void, - } - - opencv_type_boxed! { HDF5 } - - impl Drop for HDF5 { + impl std::fmt::Debug for HDF5 { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_hdf_HDF5_delete(self.as_raw_mut_HDF5()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("HDF5") + .finish() } } - unsafe impl Send for HDF5 {} - impl crate::hdf::HDF5TraitConst for HDF5 { #[inline] fn as_raw_HDF5(&self) -> *const c_void { self.as_raw() } } @@ -1515,14 +1523,4 @@ pub mod hdf { boxed_ref! { HDF5, crate::hdf::HDF5TraitConst, as_raw_HDF5, crate::hdf::HDF5Trait, as_raw_mut_HDF5 } - impl HDF5 { - } - - impl std::fmt::Debug for HDF5 { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("HDF5") - .finish() - } - } } diff --git a/docs/hfs.rs b/docs/hfs.rs index 5fd373a36..1c4fb4b8b 100644 --- a/docs/hfs.rs +++ b/docs/hfs.rs @@ -36,6 +36,85 @@ pub mod hfs { pub use super::{HfsSegmentTrait, HfsSegmentTraitConst}; } + pub struct HfsSegment { + ptr: *mut c_void, + } + + opencv_type_boxed! { HfsSegment } + + impl Drop for HfsSegment { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_hfs_HfsSegment_delete(self.as_raw_mut_HfsSegment()) }; + } + } + + unsafe impl Send for HfsSegment {} + + impl HfsSegment { + /// create a hfs object + /// ## Parameters + /// * height: : the height of the input image + /// * width: : the width of the input image + /// * segEgbThresholdI: : parameter segEgbThresholdI + /// * minRegionSizeI: : parameter minRegionSizeI + /// * segEgbThresholdII: : parameter segEgbThresholdII + /// * minRegionSizeII: : parameter minRegionSizeII + /// * spatialWeight: : parameter spatialWeight + /// * slicSpixelSize: : parameter slicSpixelSize + /// * numSlicIter: : parameter numSlicIter + /// + /// ## C++ default parameters + /// * seg_egb_threshold_i: 0.08f + /// * min_region_size_i: 100 + /// * seg_egb_threshold_ii: 0.28f + /// * min_region_size_ii: 200 + /// * spatial_weight: 0.6f + /// * slic_spixel_size: 8 + /// * num_slic_iter: 5 + #[inline] + pub fn create(height: i32, width: i32, seg_egb_threshold_i: f32, min_region_size_i: i32, seg_egb_threshold_ii: f32, min_region_size_ii: i32, spatial_weight: f32, slic_spixel_size: i32, num_slic_iter: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_hfs_HfsSegment_create_int_int_float_int_float_int_float_int_int(height, width, seg_egb_threshold_i, min_region_size_i, seg_egb_threshold_ii, min_region_size_ii, spatial_weight, slic_spixel_size, num_slic_iter, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// create a hfs object + /// ## Parameters + /// * height: : the height of the input image + /// * width: : the width of the input image + /// * segEgbThresholdI: : parameter segEgbThresholdI + /// * minRegionSizeI: : parameter minRegionSizeI + /// * segEgbThresholdII: : parameter segEgbThresholdII + /// * minRegionSizeII: : parameter minRegionSizeII + /// * spatialWeight: : parameter spatialWeight + /// * slicSpixelSize: : parameter slicSpixelSize + /// * numSlicIter: : parameter numSlicIter + /// + /// ## Note + /// This alternative version of [HfsSegment::create] function uses the following default values for its arguments: + /// * seg_egb_threshold_i: 0.08f + /// * min_region_size_i: 100 + /// * seg_egb_threshold_ii: 0.28f + /// * min_region_size_ii: 200 + /// * spatial_weight: 0.6f + /// * slic_spixel_size: 8 + /// * num_slic_iter: 5 + #[inline] + pub fn create_def(height: i32, width: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_hfs_HfsSegment_create_int_int(height, width, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::hfs::HfsSegment] pub trait HfsSegmentTraitConst: core::AlgorithmTraitConst { fn as_raw_HfsSegment(&self) -> *const c_void; @@ -290,20 +369,15 @@ pub mod hfs { } - pub struct HfsSegment { - ptr: *mut c_void, - } - - opencv_type_boxed! { HfsSegment } - - impl Drop for HfsSegment { + impl std::fmt::Debug for HfsSegment { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_hfs_HfsSegment_delete(self.as_raw_mut_HfsSegment()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("HfsSegment") + .finish() } } - unsafe impl Send for HfsSegment {} + boxed_cast_base! { HfsSegment, core::Algorithm, cv_hfs_HfsSegment_to_Algorithm } impl core::AlgorithmTraitConst for HfsSegment { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -325,77 +399,4 @@ pub mod hfs { boxed_ref! { HfsSegment, crate::hfs::HfsSegmentTraitConst, as_raw_HfsSegment, crate::hfs::HfsSegmentTrait, as_raw_mut_HfsSegment } - impl HfsSegment { - /// create a hfs object - /// ## Parameters - /// * height: : the height of the input image - /// * width: : the width of the input image - /// * segEgbThresholdI: : parameter segEgbThresholdI - /// * minRegionSizeI: : parameter minRegionSizeI - /// * segEgbThresholdII: : parameter segEgbThresholdII - /// * minRegionSizeII: : parameter minRegionSizeII - /// * spatialWeight: : parameter spatialWeight - /// * slicSpixelSize: : parameter slicSpixelSize - /// * numSlicIter: : parameter numSlicIter - /// - /// ## C++ default parameters - /// * seg_egb_threshold_i: 0.08f - /// * min_region_size_i: 100 - /// * seg_egb_threshold_ii: 0.28f - /// * min_region_size_ii: 200 - /// * spatial_weight: 0.6f - /// * slic_spixel_size: 8 - /// * num_slic_iter: 5 - #[inline] - pub fn create(height: i32, width: i32, seg_egb_threshold_i: f32, min_region_size_i: i32, seg_egb_threshold_ii: f32, min_region_size_ii: i32, spatial_weight: f32, slic_spixel_size: i32, num_slic_iter: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_hfs_HfsSegment_create_int_int_float_int_float_int_float_int_int(height, width, seg_egb_threshold_i, min_region_size_i, seg_egb_threshold_ii, min_region_size_ii, spatial_weight, slic_spixel_size, num_slic_iter, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// create a hfs object - /// ## Parameters - /// * height: : the height of the input image - /// * width: : the width of the input image - /// * segEgbThresholdI: : parameter segEgbThresholdI - /// * minRegionSizeI: : parameter minRegionSizeI - /// * segEgbThresholdII: : parameter segEgbThresholdII - /// * minRegionSizeII: : parameter minRegionSizeII - /// * spatialWeight: : parameter spatialWeight - /// * slicSpixelSize: : parameter slicSpixelSize - /// * numSlicIter: : parameter numSlicIter - /// - /// ## Note - /// This alternative version of [HfsSegment::create] function uses the following default values for its arguments: - /// * seg_egb_threshold_i: 0.08f - /// * min_region_size_i: 100 - /// * seg_egb_threshold_ii: 0.28f - /// * min_region_size_ii: 200 - /// * spatial_weight: 0.6f - /// * slic_spixel_size: 8 - /// * num_slic_iter: 5 - #[inline] - pub fn create_def(height: i32, width: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_hfs_HfsSegment_create_int_int(height, width, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { HfsSegment, core::Algorithm, cv_hfs_HfsSegment_to_Algorithm } - - impl std::fmt::Debug for HfsSegment { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("HfsSegment") - .finish() - } - } } diff --git a/docs/highgui.rs b/docs/highgui.rs index bc94aeda6..7cd264b7b 100644 --- a/docs/highgui.rs +++ b/docs/highgui.rs @@ -1762,6 +1762,33 @@ pub mod highgui { Ok(ret) } + /// QtFont available only for Qt. See cv::fontQt + pub struct QtFont { + ptr: *mut c_void, + } + + opencv_type_boxed! { QtFont } + + impl Drop for QtFont { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_QtFont_delete(self.as_raw_mut_QtFont()) }; + } + } + + unsafe impl Send for QtFont {} + + impl QtFont { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::highgui::QtFont { + let ret = unsafe { sys::cv_QtFont_defaultNew_const() }; + let ret = unsafe { crate::highgui::QtFont::opencv_from_extern(ret) }; + ret + } + + } + /// Constant methods for [crate::highgui::QtFont] pub trait QtFontTraitConst { fn as_raw_QtFont(&self) -> *const c_void; @@ -1911,39 +1938,12 @@ pub mod highgui { } - /// QtFont available only for Qt. See cv::fontQt - pub struct QtFont { - ptr: *mut c_void, - } - - opencv_type_boxed! { QtFont } - - impl Drop for QtFont { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_QtFont_delete(self.as_raw_mut_QtFont()) }; - } - } - - unsafe impl Send for QtFont {} - - impl crate::highgui::QtFontTraitConst for QtFont { - #[inline] fn as_raw_QtFont(&self) -> *const c_void { self.as_raw() } - } - - impl crate::highgui::QtFontTrait for QtFont { - #[inline] fn as_raw_mut_QtFont(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { QtFont, crate::highgui::QtFontTraitConst, as_raw_QtFont, crate::highgui::QtFontTrait, as_raw_mut_QtFont } - - impl QtFont { - /// Creates a default instance of the class by calling the default constructor + impl Default for QtFont { #[inline] + /// Forwards to infallible Self::default() fn default() -> Self { - unsafe { Self::from_raw(sys::cv_QtFont_defaultNew_const()) } + Self::default() } - } impl std::fmt::Debug for QtFont { @@ -1966,11 +1966,14 @@ pub mod highgui { } } - impl Default for QtFont { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } + impl crate::highgui::QtFontTraitConst for QtFont { + #[inline] fn as_raw_QtFont(&self) -> *const c_void { self.as_raw() } + } + + impl crate::highgui::QtFontTrait for QtFont { + #[inline] fn as_raw_mut_QtFont(&mut self) -> *mut c_void { self.as_raw_mut() } } + + boxed_ref! { QtFont, crate::highgui::QtFontTraitConst, as_raw_QtFont, crate::highgui::QtFontTrait, as_raw_mut_QtFont } + } diff --git a/docs/img_hash.rs b/docs/img_hash.rs index b174c6903..8321fd72c 100644 --- a/docs/img_hash.rs +++ b/docs/img_hash.rs @@ -271,18 +271,6 @@ pub mod img_hash { Ok(ret) } - /// Constant methods for [crate::img_hash::AverageHash] - pub trait AverageHashTraitConst: crate::img_hash::ImgHashBaseTraitConst { - fn as_raw_AverageHash(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::img_hash::AverageHash] - pub trait AverageHashTrait: crate::img_hash::AverageHashTraitConst + crate::img_hash::ImgHashBaseTrait { - fn as_raw_mut_AverageHash(&mut self) -> *mut c_void; - - } - /// Computes average hash value of the input image /// /// This is a fast image hashing algorithm, but only work on simple case. For more details, please @@ -302,6 +290,43 @@ pub mod img_hash { unsafe impl Send for AverageHash {} + impl AverageHash { + #[inline] + pub fn create() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_img_hash_AverageHash_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::img_hash::AverageHash] + pub trait AverageHashTraitConst: crate::img_hash::ImgHashBaseTraitConst { + fn as_raw_AverageHash(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::img_hash::AverageHash] + pub trait AverageHashTrait: crate::img_hash::AverageHashTraitConst + crate::img_hash::ImgHashBaseTrait { + fn as_raw_mut_AverageHash(&mut self) -> *mut c_void; + + } + + impl std::fmt::Debug for AverageHash { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AverageHash") + .finish() + } + } + + boxed_cast_base! { AverageHash, core::Algorithm, cv_img_hash_AverageHash_to_Algorithm } + + boxed_cast_base! { AverageHash, crate::img_hash::ImgHashBase, cv_img_hash_AverageHash_to_ImgHashBase } + impl core::AlgorithmTraitConst for AverageHash { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } } @@ -332,29 +357,50 @@ pub mod img_hash { boxed_ref! { AverageHash, crate::img_hash::AverageHashTraitConst, as_raw_AverageHash, crate::img_hash::AverageHashTrait, as_raw_mut_AverageHash } - impl AverageHash { + /// Image hash based on block mean. + /// + /// See [zauner2010implementation](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_zauner2010implementation) for details. + pub struct BlockMeanHash { + ptr: *mut c_void, + } + + opencv_type_boxed! { BlockMeanHash } + + impl Drop for BlockMeanHash { #[inline] - pub fn create() -> Result> { + fn drop(&mut self) { + unsafe { sys::cv_img_hash_BlockMeanHash_delete(self.as_raw_mut_BlockMeanHash()) }; + } + } + + unsafe impl Send for BlockMeanHash {} + + impl BlockMeanHash { + /// ## C++ default parameters + /// * mode: BLOCK_MEAN_HASH_MODE_0 + #[inline] + pub fn create(mode: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_img_hash_AverageHash_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_img_hash_BlockMeanHash_create_int(mode, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { AverageHash, core::Algorithm, cv_img_hash_AverageHash_to_Algorithm } - - boxed_cast_base! { AverageHash, crate::img_hash::ImgHashBase, cv_img_hash_AverageHash_to_ImgHashBase } - - impl std::fmt::Debug for AverageHash { + /// ## Note + /// This alternative version of [BlockMeanHash::create] function uses the following default values for its arguments: + /// * mode: BLOCK_MEAN_HASH_MODE_0 #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AverageHash") - .finish() + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_img_hash_BlockMeanHash_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::img_hash::BlockMeanHash] @@ -391,23 +437,17 @@ pub mod img_hash { } - /// Image hash based on block mean. - /// - /// See [zauner2010implementation](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_zauner2010implementation) for details. - pub struct BlockMeanHash { - ptr: *mut c_void, - } - - opencv_type_boxed! { BlockMeanHash } - - impl Drop for BlockMeanHash { + impl std::fmt::Debug for BlockMeanHash { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_img_hash_BlockMeanHash_delete(self.as_raw_mut_BlockMeanHash()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BlockMeanHash") + .finish() } } - unsafe impl Send for BlockMeanHash {} + boxed_cast_base! { BlockMeanHash, core::Algorithm, cv_img_hash_BlockMeanHash_to_Algorithm } + + boxed_cast_base! { BlockMeanHash, crate::img_hash::ImgHashBase, cv_img_hash_BlockMeanHash_to_ImgHashBase } impl core::AlgorithmTraitConst for BlockMeanHash { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -439,46 +479,37 @@ pub mod img_hash { boxed_ref! { BlockMeanHash, crate::img_hash::BlockMeanHashTraitConst, as_raw_BlockMeanHash, crate::img_hash::BlockMeanHashTrait, as_raw_mut_BlockMeanHash } - impl BlockMeanHash { - /// ## C++ default parameters - /// * mode: BLOCK_MEAN_HASH_MODE_0 + /// Image hash based on color moments. + /// + /// See [tang2012perceptual](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_tang2012perceptual) for details. + pub struct ColorMomentHash { + ptr: *mut c_void, + } + + opencv_type_boxed! { ColorMomentHash } + + impl Drop for ColorMomentHash { #[inline] - pub fn create(mode: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_img_hash_BlockMeanHash_create_int(mode, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_img_hash_ColorMomentHash_delete(self.as_raw_mut_ColorMomentHash()) }; } + } - /// ## Note - /// This alternative version of [BlockMeanHash::create] function uses the following default values for its arguments: - /// * mode: BLOCK_MEAN_HASH_MODE_0 + unsafe impl Send for ColorMomentHash {} + + impl ColorMomentHash { #[inline] - pub fn create_def() -> Result> { + pub fn create() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_img_hash_BlockMeanHash_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_img_hash_ColorMomentHash_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { BlockMeanHash, core::Algorithm, cv_img_hash_BlockMeanHash_to_Algorithm } - - boxed_cast_base! { BlockMeanHash, crate::img_hash::ImgHashBase, cv_img_hash_BlockMeanHash_to_ImgHashBase } - - impl std::fmt::Debug for BlockMeanHash { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BlockMeanHash") - .finish() - } - } - /// Constant methods for [crate::img_hash::ColorMomentHash] pub trait ColorMomentHashTraitConst: crate::img_hash::ImgHashBaseTraitConst { fn as_raw_ColorMomentHash(&self) -> *const c_void; @@ -491,23 +522,17 @@ pub mod img_hash { } - /// Image hash based on color moments. - /// - /// See [tang2012perceptual](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_tang2012perceptual) for details. - pub struct ColorMomentHash { - ptr: *mut c_void, - } - - opencv_type_boxed! { ColorMomentHash } - - impl Drop for ColorMomentHash { + impl std::fmt::Debug for ColorMomentHash { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_img_hash_ColorMomentHash_delete(self.as_raw_mut_ColorMomentHash()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ColorMomentHash") + .finish() } } - unsafe impl Send for ColorMomentHash {} + boxed_cast_base! { ColorMomentHash, core::Algorithm, cv_img_hash_ColorMomentHash_to_Algorithm } + + boxed_cast_base! { ColorMomentHash, crate::img_hash::ImgHashBase, cv_img_hash_ColorMomentHash_to_ImgHashBase } impl core::AlgorithmTraitConst for ColorMomentHash { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -539,31 +564,22 @@ pub mod img_hash { boxed_ref! { ColorMomentHash, crate::img_hash::ColorMomentHashTraitConst, as_raw_ColorMomentHash, crate::img_hash::ColorMomentHashTrait, as_raw_mut_ColorMomentHash } - impl ColorMomentHash { - #[inline] - pub fn create() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_img_hash_ColorMomentHash_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + /// The base class for image hash algorithms + pub struct ImgHashBase { + ptr: *mut c_void, } - boxed_cast_base! { ColorMomentHash, core::Algorithm, cv_img_hash_ColorMomentHash_to_Algorithm } - - boxed_cast_base! { ColorMomentHash, crate::img_hash::ImgHashBase, cv_img_hash_ColorMomentHash_to_ImgHashBase } + opencv_type_boxed! { ImgHashBase } - impl std::fmt::Debug for ColorMomentHash { + impl Drop for ImgHashBase { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ColorMomentHash") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_img_hash_ImgHashBase_delete(self.as_raw_mut_ImgHashBase()) }; } } + unsafe impl Send for ImgHashBase {} + /// Constant methods for [crate::img_hash::ImgHashBase] pub trait ImgHashBaseTraitConst: core::AlgorithmTraitConst { fn as_raw_ImgHashBase(&self) -> *const c_void; @@ -609,21 +625,15 @@ pub mod img_hash { } - /// The base class for image hash algorithms - pub struct ImgHashBase { - ptr: *mut c_void, - } - - opencv_type_boxed! { ImgHashBase } - - impl Drop for ImgHashBase { + impl std::fmt::Debug for ImgHashBase { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_img_hash_ImgHashBase_delete(self.as_raw_mut_ImgHashBase()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ImgHashBase") + .finish() } } - unsafe impl Send for ImgHashBase {} + boxed_cast_base! { ImgHashBase, core::Algorithm, cv_img_hash_ImgHashBase_to_Algorithm } impl core::AlgorithmTraitConst for ImgHashBase { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -645,19 +655,62 @@ pub mod img_hash { boxed_ref! { ImgHashBase, crate::img_hash::ImgHashBaseTraitConst, as_raw_ImgHashBase, crate::img_hash::ImgHashBaseTrait, as_raw_mut_ImgHashBase } - impl ImgHashBase { + /// Marr-Hildreth Operator Based Hash, slowest but more discriminative. + /// + /// See [zauner2010implementation](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_zauner2010implementation) for details. + pub struct MarrHildrethHash { + ptr: *mut c_void, } - boxed_cast_base! { ImgHashBase, core::Algorithm, cv_img_hash_ImgHashBase_to_Algorithm } + opencv_type_boxed! { MarrHildrethHash } - impl std::fmt::Debug for ImgHashBase { + impl Drop for MarrHildrethHash { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ImgHashBase") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_img_hash_MarrHildrethHash_delete(self.as_raw_mut_MarrHildrethHash()) }; } } + unsafe impl Send for MarrHildrethHash {} + + impl MarrHildrethHash { + /// ## Parameters + /// * alpha: int scale factor for marr wavelet (default=2). + /// * scale: int level of scale factor (default = 1) + /// + /// ## C++ default parameters + /// * alpha: 2.0f + /// * scale: 1.0f + #[inline] + pub fn create(alpha: f32, scale: f32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_img_hash_MarrHildrethHash_create_float_float(alpha, scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Parameters + /// * alpha: int scale factor for marr wavelet (default=2). + /// * scale: int level of scale factor (default = 1) + /// + /// ## Note + /// This alternative version of [MarrHildrethHash::create] function uses the following default values for its arguments: + /// * alpha: 2.0f + /// * scale: 1.0f + #[inline] + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_img_hash_MarrHildrethHash_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::img_hash::MarrHildrethHash] pub trait MarrHildrethHashTraitConst: crate::img_hash::ImgHashBaseTraitConst { fn as_raw_MarrHildrethHash(&self) -> *const c_void; @@ -703,23 +756,17 @@ pub mod img_hash { } - /// Marr-Hildreth Operator Based Hash, slowest but more discriminative. - /// - /// See [zauner2010implementation](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_zauner2010implementation) for details. - pub struct MarrHildrethHash { - ptr: *mut c_void, - } - - opencv_type_boxed! { MarrHildrethHash } - - impl Drop for MarrHildrethHash { + impl std::fmt::Debug for MarrHildrethHash { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_img_hash_MarrHildrethHash_delete(self.as_raw_mut_MarrHildrethHash()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MarrHildrethHash") + .finish() } } - unsafe impl Send for MarrHildrethHash {} + boxed_cast_base! { MarrHildrethHash, core::Algorithm, cv_img_hash_MarrHildrethHash_to_Algorithm } + + boxed_cast_base! { MarrHildrethHash, crate::img_hash::ImgHashBase, cv_img_hash_MarrHildrethHash_to_ImgHashBase } impl core::AlgorithmTraitConst for MarrHildrethHash { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -751,56 +798,39 @@ pub mod img_hash { boxed_ref! { MarrHildrethHash, crate::img_hash::MarrHildrethHashTraitConst, as_raw_MarrHildrethHash, crate::img_hash::MarrHildrethHashTrait, as_raw_mut_MarrHildrethHash } - impl MarrHildrethHash { - /// ## Parameters - /// * alpha: int scale factor for marr wavelet (default=2). - /// * scale: int level of scale factor (default = 1) - /// - /// ## C++ default parameters - /// * alpha: 2.0f - /// * scale: 1.0f + /// pHash + /// + /// Slower than average_hash, but tolerant of minor modifications + /// + /// This algorithm can combat more variation than averageHash, for more details please refer to [lookslikeit](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_lookslikeit) + pub struct PHash { + ptr: *mut c_void, + } + + opencv_type_boxed! { PHash } + + impl Drop for PHash { #[inline] - pub fn create(alpha: f32, scale: f32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_img_hash_MarrHildrethHash_create_float_float(alpha, scale, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_img_hash_PHash_delete(self.as_raw_mut_PHash()) }; } + } - /// ## Parameters - /// * alpha: int scale factor for marr wavelet (default=2). - /// * scale: int level of scale factor (default = 1) - /// - /// ## Note - /// This alternative version of [MarrHildrethHash::create] function uses the following default values for its arguments: - /// * alpha: 2.0f - /// * scale: 1.0f + unsafe impl Send for PHash {} + + impl PHash { #[inline] - pub fn create_def() -> Result> { + pub fn create() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_img_hash_MarrHildrethHash_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_img_hash_PHash_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { MarrHildrethHash, core::Algorithm, cv_img_hash_MarrHildrethHash_to_Algorithm } - - boxed_cast_base! { MarrHildrethHash, crate::img_hash::ImgHashBase, cv_img_hash_MarrHildrethHash_to_ImgHashBase } - - impl std::fmt::Debug for MarrHildrethHash { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MarrHildrethHash") - .finish() - } - } - /// Constant methods for [crate::img_hash::PHash] pub trait PHashTraitConst: crate::img_hash::ImgHashBaseTraitConst { fn as_raw_PHash(&self) -> *const c_void; @@ -813,25 +843,17 @@ pub mod img_hash { } - /// pHash - /// - /// Slower than average_hash, but tolerant of minor modifications - /// - /// This algorithm can combat more variation than averageHash, for more details please refer to [lookslikeit](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_lookslikeit) - pub struct PHash { - ptr: *mut c_void, - } - - opencv_type_boxed! { PHash } - - impl Drop for PHash { + impl std::fmt::Debug for PHash { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_img_hash_PHash_delete(self.as_raw_mut_PHash()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PHash") + .finish() } } - unsafe impl Send for PHash {} + boxed_cast_base! { PHash, core::Algorithm, cv_img_hash_PHash_to_Algorithm } + + boxed_cast_base! { PHash, crate::img_hash::ImgHashBase, cv_img_hash_PHash_to_ImgHashBase } impl core::AlgorithmTraitConst for PHash { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -863,29 +885,52 @@ pub mod img_hash { boxed_ref! { PHash, crate::img_hash::PHashTraitConst, as_raw_PHash, crate::img_hash::PHashTrait, as_raw_mut_PHash } - impl PHash { + /// Image hash based on Radon transform. + /// + /// See [tang2012perceptual](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_tang2012perceptual) for details. + pub struct RadialVarianceHash { + ptr: *mut c_void, + } + + opencv_type_boxed! { RadialVarianceHash } + + impl Drop for RadialVarianceHash { #[inline] - pub fn create() -> Result> { + fn drop(&mut self) { + unsafe { sys::cv_img_hash_RadialVarianceHash_delete(self.as_raw_mut_RadialVarianceHash()) }; + } + } + + unsafe impl Send for RadialVarianceHash {} + + impl RadialVarianceHash { + /// ## C++ default parameters + /// * sigma: 1 + /// * num_of_angle_line: 180 + #[inline] + pub fn create(sigma: f64, num_of_angle_line: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_img_hash_PHash_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_img_hash_RadialVarianceHash_create_double_int(sigma, num_of_angle_line, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { PHash, core::Algorithm, cv_img_hash_PHash_to_Algorithm } - - boxed_cast_base! { PHash, crate::img_hash::ImgHashBase, cv_img_hash_PHash_to_ImgHashBase } - - impl std::fmt::Debug for PHash { + /// ## Note + /// This alternative version of [RadialVarianceHash::create] function uses the following default values for its arguments: + /// * sigma: 1 + /// * num_of_angle_line: 180 #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PHash") - .finish() + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_img_hash_RadialVarianceHash_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::img_hash::RadialVarianceHash] @@ -976,23 +1021,17 @@ pub mod img_hash { } - /// Image hash based on Radon transform. - /// - /// See [tang2012perceptual](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_tang2012perceptual) for details. - pub struct RadialVarianceHash { - ptr: *mut c_void, - } - - opencv_type_boxed! { RadialVarianceHash } - - impl Drop for RadialVarianceHash { + impl std::fmt::Debug for RadialVarianceHash { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_img_hash_RadialVarianceHash_delete(self.as_raw_mut_RadialVarianceHash()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RadialVarianceHash") + .finish() } } - unsafe impl Send for RadialVarianceHash {} + boxed_cast_base! { RadialVarianceHash, core::Algorithm, cv_img_hash_RadialVarianceHash_to_Algorithm } + + boxed_cast_base! { RadialVarianceHash, crate::img_hash::ImgHashBase, cv_img_hash_RadialVarianceHash_to_ImgHashBase } impl core::AlgorithmTraitConst for RadialVarianceHash { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1024,45 +1063,4 @@ pub mod img_hash { boxed_ref! { RadialVarianceHash, crate::img_hash::RadialVarianceHashTraitConst, as_raw_RadialVarianceHash, crate::img_hash::RadialVarianceHashTrait, as_raw_mut_RadialVarianceHash } - impl RadialVarianceHash { - /// ## C++ default parameters - /// * sigma: 1 - /// * num_of_angle_line: 180 - #[inline] - pub fn create(sigma: f64, num_of_angle_line: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_img_hash_RadialVarianceHash_create_double_int(sigma, num_of_angle_line, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [RadialVarianceHash::create] function uses the following default values for its arguments: - /// * sigma: 1 - /// * num_of_angle_line: 180 - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_img_hash_RadialVarianceHash_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { RadialVarianceHash, core::Algorithm, cv_img_hash_RadialVarianceHash_to_Algorithm } - - boxed_cast_base! { RadialVarianceHash, crate::img_hash::ImgHashBase, cv_img_hash_RadialVarianceHash_to_ImgHashBase } - - impl std::fmt::Debug for RadialVarianceHash { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RadialVarianceHash") - .finish() - } - } } diff --git a/docs/imgcodecs.rs b/docs/imgcodecs.rs index db34a0a21..e85f468fd 100644 --- a/docs/imgcodecs.rs +++ b/docs/imgcodecs.rs @@ -1644,6 +1644,80 @@ pub mod imgcodecs { Ok(ret) } + /// Represents an animation with multiple frames. + /// The `Animation` struct is designed to store and manage data for animated sequences such as those from animated formats (e.g., GIF, AVIF, APNG, WebP). + /// It provides support for looping, background color settings, frame timing, and frame storage. + pub struct Animation { + ptr: *mut c_void, + } + + opencv_type_boxed! { Animation } + + impl Drop for Animation { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_Animation_delete(self.as_raw_mut_Animation()) }; + } + } + + unsafe impl Send for Animation {} + + impl Animation { + /// Constructs an Animation object with optional loop count and background color. + /// + /// ## Parameters + /// * loopCount: An integer representing the number of times the animation should loop: + /// - `0` (default) indicates infinite looping, meaning the animation will replay continuously. + /// - Positive values denote finite repeat counts, allowing the animation to play a limited number of times. + /// - If a negative value or a value beyond the maximum of `0xffff` (65535) is provided, it is reset to `0` + /// (infinite looping) to maintain valid bounds. + /// + /// * bgColor: A `Scalar` object representing the background color in BGRA format: + /// - Defaults to `Scalar()`, indicating an empty color (usually transparent if supported). + /// - This background color provides a solid fill behind frames that have transparency, ensuring a consistent display appearance. + /// + /// ## C++ default parameters + /// * loop_count: 0 + /// * bg_color: Scalar() + #[inline] + pub fn new(loop_count: i32, bg_color: core::Scalar) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_Animation_Animation_int_Scalar(loop_count, &bg_color, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::imgcodecs::Animation::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Constructs an Animation object with optional loop count and background color. + /// + /// ## Parameters + /// * loopCount: An integer representing the number of times the animation should loop: + /// - `0` (default) indicates infinite looping, meaning the animation will replay continuously. + /// - Positive values denote finite repeat counts, allowing the animation to play a limited number of times. + /// - If a negative value or a value beyond the maximum of `0xffff` (65535) is provided, it is reset to `0` + /// (infinite looping) to maintain valid bounds. + /// + /// * bgColor: A `Scalar` object representing the background color in BGRA format: + /// - Defaults to `Scalar()`, indicating an empty color (usually transparent if supported). + /// - This background color provides a solid fill behind frames that have transparency, ensuring a consistent display appearance. + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * loop_count: 0 + /// * bg_color: Scalar() + #[inline] + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_Animation_Animation(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::imgcodecs::Animation::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::imgcodecs::Animation] pub trait AnimationTraitConst { fn as_raw_Animation(&self) -> *const c_void; @@ -1716,24 +1790,25 @@ pub mod imgcodecs { } - /// Represents an animation with multiple frames. - /// The `Animation` struct is designed to store and manage data for animated sequences such as those from animated formats (e.g., GIF, AVIF, APNG, WebP). - /// It provides support for looping, background color settings, frame timing, and frame storage. - pub struct Animation { - ptr: *mut c_void, + impl Clone for Animation { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_Animation_implicitClone_const(self.as_raw_Animation())) } + } } - opencv_type_boxed! { Animation } - - impl Drop for Animation { + impl std::fmt::Debug for Animation { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_Animation_delete(self.as_raw_mut_Animation()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Animation") + .field("loop_count", &crate::imgcodecs::AnimationTraitConst::loop_count(self)) + .field("bgcolor", &crate::imgcodecs::AnimationTraitConst::bgcolor(self)) + .field("durations", &crate::imgcodecs::AnimationTraitConst::durations(self)) + .field("frames", &crate::imgcodecs::AnimationTraitConst::frames(self)) + .finish() } } - unsafe impl Send for Animation {} - impl crate::imgcodecs::AnimationTraitConst for Animation { #[inline] fn as_raw_Animation(&self) -> *const c_void { self.as_raw() } } @@ -1744,81 +1819,57 @@ pub mod imgcodecs { boxed_ref! { Animation, crate::imgcodecs::AnimationTraitConst, as_raw_Animation, crate::imgcodecs::AnimationTrait, as_raw_mut_Animation } - impl Animation { - /// Constructs an Animation object with optional loop count and background color. - /// - /// ## Parameters - /// * loopCount: An integer representing the number of times the animation should loop: - /// - `0` (default) indicates infinite looping, meaning the animation will replay continuously. - /// - Positive values denote finite repeat counts, allowing the animation to play a limited number of times. - /// - If a negative value or a value beyond the maximum of `0xffff` (65535) is provided, it is reset to `0` - /// (infinite looping) to maintain valid bounds. - /// - /// * bgColor: A `Scalar` object representing the background color in BGRA format: - /// - Defaults to `Scalar()`, indicating an empty color (usually transparent if supported). - /// - This background color provides a solid fill behind frames that have transparency, ensuring a consistent display appearance. - /// - /// ## C++ default parameters - /// * loop_count: 0 - /// * bg_color: Scalar() + /// To read multi-page images on demand + /// + /// The ImageCollection class provides iterator API to read multi-page images on demand. Create iterator + /// to the collection of the images and iterate over the collection. Decode the necessary page with operator*. + /// + /// The performance of page decoding is O(1) if collection is increment sequentially. If the user wants to access random page, + /// then the time Complexity is O(n) because the collection has to be reinitialized every time in order to go to the correct page. + /// However, the intermediate pages are not decoded during the process, so typically it's quite fast. + /// This is required because multi-page codecs does not support going backwards. + /// After decoding the one page, it is stored inside the collection cache. Hence, trying to get Mat object from already decoded page is O(1). + /// If you need memory, you can use .releaseCache() method to release cached index. + /// The space complexity is O(n) if all pages are decoded into memory. The user is able to decode and release images on demand. + pub struct ImageCollection { + ptr: *mut c_void, + } + + opencv_type_boxed! { ImageCollection } + + impl Drop for ImageCollection { #[inline] - pub fn new(loop_count: i32, bg_color: core::Scalar) -> Result { + fn drop(&mut self) { + unsafe { sys::cv_ImageCollection_delete(self.as_raw_mut_ImageCollection()) }; + } + } + + unsafe impl Send for ImageCollection {} + + impl ImageCollection { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Animation_Animation_int_Scalar(loop_count, &bg_color, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ImageCollection_ImageCollection(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::imgcodecs::Animation::opencv_from_extern(ret) }; + let ret = unsafe { crate::imgcodecs::ImageCollection::opencv_from_extern(ret) }; Ok(ret) } - /// Constructs an Animation object with optional loop count and background color. - /// - /// ## Parameters - /// * loopCount: An integer representing the number of times the animation should loop: - /// - `0` (default) indicates infinite looping, meaning the animation will replay continuously. - /// - Positive values denote finite repeat counts, allowing the animation to play a limited number of times. - /// - If a negative value or a value beyond the maximum of `0xffff` (65535) is provided, it is reset to `0` - /// (infinite looping) to maintain valid bounds. - /// - /// * bgColor: A `Scalar` object representing the background color in BGRA format: - /// - Defaults to `Scalar()`, indicating an empty color (usually transparent if supported). - /// - This background color provides a solid fill behind frames that have transparency, ensuring a consistent display appearance. - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * loop_count: 0 - /// * bg_color: Scalar() #[inline] - pub fn new_def() -> Result { + pub fn new(filename: &str, flags: i32) -> Result { + extern_container_arg!(filename); return_send!(via ocvrs_return); - unsafe { sys::cv_Animation_Animation(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ImageCollection_ImageCollection_const_StringR_int(filename.opencv_as_extern(), flags, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::imgcodecs::Animation::opencv_from_extern(ret) }; + let ret = unsafe { crate::imgcodecs::ImageCollection::opencv_from_extern(ret) }; Ok(ret) } } - impl Clone for Animation { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_Animation_implicitClone_const(self.as_raw_Animation())) } - } - } - - impl std::fmt::Debug for Animation { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Animation") - .field("loop_count", &crate::imgcodecs::AnimationTraitConst::loop_count(self)) - .field("bgcolor", &crate::imgcodecs::AnimationTraitConst::bgcolor(self)) - .field("durations", &crate::imgcodecs::AnimationTraitConst::durations(self)) - .field("frames", &crate::imgcodecs::AnimationTraitConst::frames(self)) - .finish() - } - } - /// Constant methods for [crate::imgcodecs::ImageCollection] pub trait ImageCollectionTraitConst { fn as_raw_ImageCollection(&self) -> *const c_void; @@ -1899,33 +1950,14 @@ pub mod imgcodecs { } - /// To read multi-page images on demand - /// - /// The ImageCollection class provides iterator API to read multi-page images on demand. Create iterator - /// to the collection of the images and iterate over the collection. Decode the necessary page with operator*. - /// - /// The performance of page decoding is O(1) if collection is increment sequentially. If the user wants to access random page, - /// then the time Complexity is O(n) because the collection has to be reinitialized every time in order to go to the correct page. - /// However, the intermediate pages are not decoded during the process, so typically it's quite fast. - /// This is required because multi-page codecs does not support going backwards. - /// After decoding the one page, it is stored inside the collection cache. Hence, trying to get Mat object from already decoded page is O(1). - /// If you need memory, you can use .releaseCache() method to release cached index. - /// The space complexity is O(n) if all pages are decoded into memory. The user is able to decode and release images on demand. - pub struct ImageCollection { - ptr: *mut c_void, - } - - opencv_type_boxed! { ImageCollection } - - impl Drop for ImageCollection { + impl std::fmt::Debug for ImageCollection { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ImageCollection_delete(self.as_raw_mut_ImageCollection()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ImageCollection") + .finish() } } - unsafe impl Send for ImageCollection {} - impl crate::imgcodecs::ImageCollectionTraitConst for ImageCollection { #[inline] fn as_raw_ImageCollection(&self) -> *const c_void { self.as_raw() } } @@ -1936,38 +1968,44 @@ pub mod imgcodecs { boxed_ref! { ImageCollection, crate::imgcodecs::ImageCollectionTraitConst, as_raw_ImageCollection, crate::imgcodecs::ImageCollectionTrait, as_raw_mut_ImageCollection } - impl ImageCollection { + pub struct ImageCollection_iterator { + ptr: *mut c_void, + } + + opencv_type_boxed! { ImageCollection_iterator } + + impl Drop for ImageCollection_iterator { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_ImageCollection_iterator_delete(self.as_raw_mut_ImageCollection_iterator()) }; + } + } + + unsafe impl Send for ImageCollection_iterator {} + + impl ImageCollection_iterator { + #[inline] + pub fn new(col: &mut impl crate::imgcodecs::ImageCollectionTrait) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ImageCollection_ImageCollection(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ImageCollection_iterator_iterator_ImageCollectionX(col.as_raw_mut_ImageCollection(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::imgcodecs::ImageCollection::opencv_from_extern(ret) }; + let ret = unsafe { crate::imgcodecs::ImageCollection_iterator::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn new(filename: &str, flags: i32) -> Result { - extern_container_arg!(filename); + pub fn new_1(col: &mut impl crate::imgcodecs::ImageCollectionTrait, end: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ImageCollection_ImageCollection_const_StringR_int(filename.opencv_as_extern(), flags, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ImageCollection_iterator_iterator_ImageCollectionX_int(col.as_raw_mut_ImageCollection(), end, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::imgcodecs::ImageCollection::opencv_from_extern(ret) }; + let ret = unsafe { crate::imgcodecs::ImageCollection_iterator::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for ImageCollection { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ImageCollection") - .finish() - } - } - /// Constant methods for [crate::imgcodecs::ImageCollection_iterator] pub trait ImageCollection_iteratorTraitConst { fn as_raw_ImageCollection_iterator(&self) -> *const c_void; @@ -2000,21 +2038,14 @@ pub mod imgcodecs { } - pub struct ImageCollection_iterator { - ptr: *mut c_void, - } - - opencv_type_boxed! { ImageCollection_iterator } - - impl Drop for ImageCollection_iterator { + impl std::fmt::Debug for ImageCollection_iterator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ImageCollection_iterator_delete(self.as_raw_mut_ImageCollection_iterator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ImageCollection_iterator") + .finish() } } - unsafe impl Send for ImageCollection_iterator {} - impl crate::imgcodecs::ImageCollection_iteratorTraitConst for ImageCollection_iterator { #[inline] fn as_raw_ImageCollection_iterator(&self) -> *const c_void { self.as_raw() } } @@ -2025,34 +2056,4 @@ pub mod imgcodecs { boxed_ref! { ImageCollection_iterator, crate::imgcodecs::ImageCollection_iteratorTraitConst, as_raw_ImageCollection_iterator, crate::imgcodecs::ImageCollection_iteratorTrait, as_raw_mut_ImageCollection_iterator } - impl ImageCollection_iterator { - #[inline] - pub fn new(col: &mut impl crate::imgcodecs::ImageCollectionTrait) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ImageCollection_iterator_iterator_ImageCollectionX(col.as_raw_mut_ImageCollection(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::imgcodecs::ImageCollection_iterator::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn new_1(col: &mut impl crate::imgcodecs::ImageCollectionTrait, end: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ImageCollection_iterator_iterator_ImageCollectionX_int(col.as_raw_mut_ImageCollection(), end, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::imgcodecs::ImageCollection_iterator::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for ImageCollection_iterator { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ImageCollection_iterator") - .finish() - } - } } diff --git a/docs/imgproc.rs b/docs/imgproc.rs index b586ada28..e4fbd2e39 100644 --- a/docs/imgproc.rs +++ b/docs/imgproc.rs @@ -11285,6 +11285,22 @@ pub mod imgproc { Ok(ret) } + /// Base class for Contrast Limited Adaptive Histogram Equalization. + pub struct CLAHE { + ptr: *mut c_void, + } + + opencv_type_boxed! { CLAHE } + + impl Drop for CLAHE { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_CLAHE_delete(self.as_raw_mut_CLAHE()) }; + } + } + + unsafe impl Send for CLAHE {} + /// Constant methods for [crate::imgproc::CLAHE] pub trait CLAHETraitConst: core::AlgorithmTraitConst { fn as_raw_CLAHE(&self) -> *const c_void; @@ -11369,21 +11385,15 @@ pub mod imgproc { } - /// Base class for Contrast Limited Adaptive Histogram Equalization. - pub struct CLAHE { - ptr: *mut c_void, - } - - opencv_type_boxed! { CLAHE } - - impl Drop for CLAHE { + impl std::fmt::Debug for CLAHE { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_CLAHE_delete(self.as_raw_mut_CLAHE()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CLAHE") + .finish() } } - unsafe impl Send for CLAHE {} + boxed_cast_base! { CLAHE, core::Algorithm, cv_CLAHE_to_Algorithm } impl core::AlgorithmTraitConst for CLAHE { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -11405,19 +11415,22 @@ pub mod imgproc { boxed_ref! { CLAHE, crate::imgproc::CLAHETraitConst, as_raw_CLAHE, crate::imgproc::CLAHETrait, as_raw_mut_CLAHE } - impl CLAHE { + /// finds arbitrary template in the grayscale image using Generalized Hough Transform + pub struct GeneralizedHough { + ptr: *mut c_void, } - boxed_cast_base! { CLAHE, core::Algorithm, cv_CLAHE_to_Algorithm } + opencv_type_boxed! { GeneralizedHough } - impl std::fmt::Debug for CLAHE { + impl Drop for GeneralizedHough { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CLAHE") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_GeneralizedHough_delete(self.as_raw_mut_GeneralizedHough()) }; } } + unsafe impl Send for GeneralizedHough {} + /// Constant methods for [crate::imgproc::GeneralizedHough] pub trait GeneralizedHoughTraitConst: core::AlgorithmTraitConst { fn as_raw_GeneralizedHough(&self) -> *const c_void; @@ -11647,21 +11660,19 @@ pub mod imgproc { } - /// finds arbitrary template in the grayscale image using Generalized Hough Transform - pub struct GeneralizedHough { - ptr: *mut c_void, - } - - opencv_type_boxed! { GeneralizedHough } - - impl Drop for GeneralizedHough { + impl std::fmt::Debug for GeneralizedHough { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GeneralizedHough_delete(self.as_raw_mut_GeneralizedHough()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GeneralizedHough") + .finish() } } - unsafe impl Send for GeneralizedHough {} + boxed_cast_base! { GeneralizedHough, core::Algorithm, cv_GeneralizedHough_to_Algorithm } + + boxed_cast_descendant! { GeneralizedHough, crate::imgproc::GeneralizedHoughBallard, cv_GeneralizedHough_to_GeneralizedHoughBallard } + + boxed_cast_descendant! { GeneralizedHough, crate::imgproc::GeneralizedHoughGuil, cv_GeneralizedHough_to_GeneralizedHoughGuil } impl core::AlgorithmTraitConst for GeneralizedHough { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -11683,23 +11694,24 @@ pub mod imgproc { boxed_ref! { GeneralizedHough, crate::imgproc::GeneralizedHoughTraitConst, as_raw_GeneralizedHough, crate::imgproc::GeneralizedHoughTrait, as_raw_mut_GeneralizedHough } - impl GeneralizedHough { + /// finds arbitrary template in the grayscale image using Generalized Hough Transform + /// + /// Detects position only without translation and rotation [Ballard1981](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Ballard1981) . + pub struct GeneralizedHoughBallard { + ptr: *mut c_void, } - boxed_cast_descendant! { GeneralizedHough, crate::imgproc::GeneralizedHoughBallard, cv_GeneralizedHough_to_GeneralizedHoughBallard } - - boxed_cast_descendant! { GeneralizedHough, crate::imgproc::GeneralizedHoughGuil, cv_GeneralizedHough_to_GeneralizedHoughGuil } - - boxed_cast_base! { GeneralizedHough, core::Algorithm, cv_GeneralizedHough_to_Algorithm } + opencv_type_boxed! { GeneralizedHoughBallard } - impl std::fmt::Debug for GeneralizedHough { + impl Drop for GeneralizedHoughBallard { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GeneralizedHough") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_GeneralizedHoughBallard_delete(self.as_raw_mut_GeneralizedHoughBallard()) }; } } + unsafe impl Send for GeneralizedHoughBallard {} + /// Constant methods for [crate::imgproc::GeneralizedHoughBallard] pub trait GeneralizedHoughBallardTraitConst: crate::imgproc::GeneralizedHoughTraitConst { fn as_raw_GeneralizedHoughBallard(&self) -> *const c_void; @@ -11750,23 +11762,17 @@ pub mod imgproc { } - /// finds arbitrary template in the grayscale image using Generalized Hough Transform - /// - /// Detects position only without translation and rotation [Ballard1981](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Ballard1981) . - pub struct GeneralizedHoughBallard { - ptr: *mut c_void, - } - - opencv_type_boxed! { GeneralizedHoughBallard } - - impl Drop for GeneralizedHoughBallard { + impl std::fmt::Debug for GeneralizedHoughBallard { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GeneralizedHoughBallard_delete(self.as_raw_mut_GeneralizedHoughBallard()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GeneralizedHoughBallard") + .finish() } } - unsafe impl Send for GeneralizedHoughBallard {} + boxed_cast_base! { GeneralizedHoughBallard, core::Algorithm, cv_GeneralizedHoughBallard_to_Algorithm } + + boxed_cast_base! { GeneralizedHoughBallard, crate::imgproc::GeneralizedHough, cv_GeneralizedHoughBallard_to_GeneralizedHough } impl core::AlgorithmTraitConst for GeneralizedHoughBallard { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -11798,21 +11804,24 @@ pub mod imgproc { boxed_ref! { GeneralizedHoughBallard, crate::imgproc::GeneralizedHoughBallardTraitConst, as_raw_GeneralizedHoughBallard, crate::imgproc::GeneralizedHoughBallardTrait, as_raw_mut_GeneralizedHoughBallard } - impl GeneralizedHoughBallard { + /// finds arbitrary template in the grayscale image using Generalized Hough Transform + /// + /// Detects position, translation and rotation [Guil1999](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Guil1999) . + pub struct GeneralizedHoughGuil { + ptr: *mut c_void, } - boxed_cast_base! { GeneralizedHoughBallard, core::Algorithm, cv_GeneralizedHoughBallard_to_Algorithm } - - boxed_cast_base! { GeneralizedHoughBallard, crate::imgproc::GeneralizedHough, cv_GeneralizedHoughBallard_to_GeneralizedHough } + opencv_type_boxed! { GeneralizedHoughGuil } - impl std::fmt::Debug for GeneralizedHoughBallard { + impl Drop for GeneralizedHoughGuil { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GeneralizedHoughBallard") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_GeneralizedHoughGuil_delete(self.as_raw_mut_GeneralizedHoughGuil()) }; } } + unsafe impl Send for GeneralizedHoughGuil {} + /// Constant methods for [crate::imgproc::GeneralizedHoughGuil] pub trait GeneralizedHoughGuilTraitConst: crate::imgproc::GeneralizedHoughTraitConst { fn as_raw_GeneralizedHoughGuil(&self) -> *const c_void; @@ -12053,23 +12062,17 @@ pub mod imgproc { } - /// finds arbitrary template in the grayscale image using Generalized Hough Transform - /// - /// Detects position, translation and rotation [Guil1999](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Guil1999) . - pub struct GeneralizedHoughGuil { - ptr: *mut c_void, - } - - opencv_type_boxed! { GeneralizedHoughGuil } - - impl Drop for GeneralizedHoughGuil { + impl std::fmt::Debug for GeneralizedHoughGuil { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GeneralizedHoughGuil_delete(self.as_raw_mut_GeneralizedHoughGuil()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GeneralizedHoughGuil") + .finish() } } - unsafe impl Send for GeneralizedHoughGuil {} + boxed_cast_base! { GeneralizedHoughGuil, core::Algorithm, cv_GeneralizedHoughGuil_to_Algorithm } + + boxed_cast_base! { GeneralizedHoughGuil, crate::imgproc::GeneralizedHough, cv_GeneralizedHoughGuil_to_GeneralizedHough } impl core::AlgorithmTraitConst for GeneralizedHoughGuil { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -12101,42 +12104,213 @@ pub mod imgproc { boxed_ref! { GeneralizedHoughGuil, crate::imgproc::GeneralizedHoughGuilTraitConst, as_raw_GeneralizedHoughGuil, crate::imgproc::GeneralizedHoughGuilTrait, as_raw_mut_GeneralizedHoughGuil } - impl GeneralizedHoughGuil { + /// Class for iterating over all pixels on a raster line segment. + /// + /// The class LineIterator is used to get each pixel of a raster line connecting + /// two specified points. + /// It can be treated as a versatile implementation of the Bresenham algorithm + /// where you can stop at each pixel and do some extra processing, for + /// example, grab pixel values along the line or draw a line with an effect + /// (for example, with XOR operation). + /// + /// The number of pixels along the line is stored in LineIterator::count. + /// The method LineIterator::pos returns the current position in the image: + /// + /// ```C++ + /// // grabs pixels along the line (pt1, pt2) + /// // from 8-bit 3-channel image to the buffer + /// LineIterator it(img, pt1, pt2, 8); + /// LineIterator it2 = it; + /// vector buf(it.count); + /// + /// for(int i = 0; i < it.count; i++, ++it) + /// buf[i] = *(const Vec3b*)*it; + /// + /// // alternative way of iterating through the line + /// for(int i = 0; i < it2.count; i++, ++it2) + /// { + /// Vec3b val = img.at(it2.pos()); + /// CV_Assert(buf[i] == val); + /// } + /// ``` + /// + pub struct LineIterator { + ptr: *mut c_void, } - boxed_cast_base! { GeneralizedHoughGuil, core::Algorithm, cv_GeneralizedHoughGuil_to_Algorithm } - - boxed_cast_base! { GeneralizedHoughGuil, crate::imgproc::GeneralizedHough, cv_GeneralizedHoughGuil_to_GeneralizedHough } + opencv_type_boxed! { LineIterator } - impl std::fmt::Debug for GeneralizedHoughGuil { + impl Drop for LineIterator { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GeneralizedHoughGuil") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_LineIterator_delete(self.as_raw_mut_LineIterator()) }; } } - /// Constant methods for [crate::imgproc::LineIterator] - pub trait LineIteratorTraitConst { - fn as_raw_LineIterator(&self) -> *const c_void; + unsafe impl Send for LineIterator {} + impl LineIterator { + /// Initializes iterator object for the given line and image. + /// + /// The returned iterator can be used to traverse all pixels on a line that + /// connects the given two points. + /// The line will be clipped on the image boundaries. + /// + /// ## Parameters + /// * img: Underlying image. + /// * pt1: First endpoint of the line. + /// * pt2: The other endpoint of the line. + /// * connectivity: Pixel connectivity of the iterator. Valid values are 4 (iterator can move + /// up, down, left and right) and 8 (iterator can also move diagonally). + /// * leftToRight: If true, the line is traversed from the leftmost endpoint to the rightmost + /// endpoint. Otherwise, the line is traversed from \p pt1 to \p pt2. + /// + /// ## C++ default parameters + /// * connectivity: 8 + /// * left_to_right: false #[inline] - fn ptr(&self) -> *const u8 { - let ret = unsafe { sys::cv_LineIterator_propPtr_const(self.as_raw_LineIterator()) }; - ret + pub fn new(img: &impl core::MatTraitConst, pt1: core::Point, pt2: core::Point, connectivity: i32, left_to_right: bool) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_LineIterator_LineIterator_const_MatR_Point_Point_int_bool(img.as_raw_Mat(), &pt1, &pt2, connectivity, left_to_right, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::imgproc::LineIterator::opencv_from_extern(ret) }; + Ok(ret) } + /// Initializes iterator object for the given line and image. + /// + /// The returned iterator can be used to traverse all pixels on a line that + /// connects the given two points. + /// The line will be clipped on the image boundaries. + /// + /// ## Parameters + /// * img: Underlying image. + /// * pt1: First endpoint of the line. + /// * pt2: The other endpoint of the line. + /// * connectivity: Pixel connectivity of the iterator. Valid values are 4 (iterator can move + /// up, down, left and right) and 8 (iterator can also move diagonally). + /// * leftToRight: If true, the line is traversed from the leftmost endpoint to the rightmost + /// endpoint. Otherwise, the line is traversed from \p pt1 to \p pt2. + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * connectivity: 8 + /// * left_to_right: false #[inline] - fn ptr0(&self) -> *const u8 { - let ret = unsafe { sys::cv_LineIterator_propPtr0_const(self.as_raw_LineIterator()) }; - ret + pub fn new_def(img: &impl core::MatTraitConst, pt1: core::Point, pt2: core::Point) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_LineIterator_LineIterator_const_MatR_Point_Point(img.as_raw_Mat(), &pt1, &pt2, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::imgproc::LineIterator::opencv_from_extern(ret) }; + Ok(ret) } + /// ## C++ default parameters + /// * connectivity: 8 + /// * left_to_right: false #[inline] - fn step(&self) -> i32 { - let ret = unsafe { sys::cv_LineIterator_propStep_const(self.as_raw_LineIterator()) }; - ret - } + pub fn new_1(pt1: core::Point, pt2: core::Point, connectivity: i32, left_to_right: bool) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_LineIterator_LineIterator_Point_Point_int_bool(&pt1, &pt2, connectivity, left_to_right, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::imgproc::LineIterator::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * connectivity: 8 + /// * left_to_right: false + #[inline] + pub fn new_def_1(pt1: core::Point, pt2: core::Point) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_LineIterator_LineIterator_Point_Point(&pt1, &pt2, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::imgproc::LineIterator::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## C++ default parameters + /// * connectivity: 8 + /// * left_to_right: false + #[inline] + pub fn new_2(bounding_area_size: core::Size, pt1: core::Point, pt2: core::Point, connectivity: i32, left_to_right: bool) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_LineIterator_LineIterator_Size_Point_Point_int_bool(&bounding_area_size, &pt1, &pt2, connectivity, left_to_right, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::imgproc::LineIterator::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * connectivity: 8 + /// * left_to_right: false + #[inline] + pub fn new_def_2(bounding_area_size: core::Size, pt1: core::Point, pt2: core::Point) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_LineIterator_LineIterator_Size_Point_Point(&bounding_area_size, &pt1, &pt2, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::imgproc::LineIterator::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## C++ default parameters + /// * connectivity: 8 + /// * left_to_right: false + #[inline] + pub fn new_3(bounding_area_rect: core::Rect, pt1: core::Point, pt2: core::Point, connectivity: i32, left_to_right: bool) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_LineIterator_LineIterator_Rect_Point_Point_int_bool(&bounding_area_rect, &pt1, &pt2, connectivity, left_to_right, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::imgproc::LineIterator::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * connectivity: 8 + /// * left_to_right: false + #[inline] + pub fn new_def_3(bounding_area_rect: core::Rect, pt1: core::Point, pt2: core::Point) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_LineIterator_LineIterator_Rect_Point_Point(&bounding_area_rect, &pt1, &pt2, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::imgproc::LineIterator::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::imgproc::LineIterator] + pub trait LineIteratorTraitConst { + fn as_raw_LineIterator(&self) -> *const c_void; + + #[inline] + fn ptr(&self) -> *const u8 { + let ret = unsafe { sys::cv_LineIterator_propPtr_const(self.as_raw_LineIterator()) }; + ret + } + + #[inline] + fn ptr0(&self) -> *const u8 { + let ret = unsafe { sys::cv_LineIterator_propPtr0_const(self.as_raw_LineIterator()) }; + ret + } + + #[inline] + fn step(&self) -> i32 { + let ret = unsafe { sys::cv_LineIterator_propStep_const(self.as_raw_LineIterator()) }; + ret + } #[inline] fn elem_size(&self) -> i32 { @@ -12315,219 +12489,23 @@ pub mod imgproc { Ok(ret) } - /// Returns pointer to the current pixel. - #[inline] - fn try_deref_mut(&mut self) -> Result<*mut u8> { - return_send!(via ocvrs_return); - unsafe { sys::cv_LineIterator_operatorX(self.as_raw_mut_LineIterator(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Moves iterator to the next pixel on the line. - /// - /// This is the prefix version (++it). - #[inline] - fn incr(&mut self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_LineIterator_operatorAA(self.as_raw_mut_LineIterator(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::imgproc::LineIterator::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - /// Class for iterating over all pixels on a raster line segment. - /// - /// The class LineIterator is used to get each pixel of a raster line connecting - /// two specified points. - /// It can be treated as a versatile implementation of the Bresenham algorithm - /// where you can stop at each pixel and do some extra processing, for - /// example, grab pixel values along the line or draw a line with an effect - /// (for example, with XOR operation). - /// - /// The number of pixels along the line is stored in LineIterator::count. - /// The method LineIterator::pos returns the current position in the image: - /// - /// ```C++ - /// // grabs pixels along the line (pt1, pt2) - /// // from 8-bit 3-channel image to the buffer - /// LineIterator it(img, pt1, pt2, 8); - /// LineIterator it2 = it; - /// vector buf(it.count); - /// - /// for(int i = 0; i < it.count; i++, ++it) - /// buf[i] = *(const Vec3b*)*it; - /// - /// // alternative way of iterating through the line - /// for(int i = 0; i < it2.count; i++, ++it2) - /// { - /// Vec3b val = img.at(it2.pos()); - /// CV_Assert(buf[i] == val); - /// } - /// ``` - /// - pub struct LineIterator { - ptr: *mut c_void, - } - - opencv_type_boxed! { LineIterator } - - impl Drop for LineIterator { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_LineIterator_delete(self.as_raw_mut_LineIterator()) }; - } - } - - unsafe impl Send for LineIterator {} - - impl crate::imgproc::LineIteratorTraitConst for LineIterator { - #[inline] fn as_raw_LineIterator(&self) -> *const c_void { self.as_raw() } - } - - impl crate::imgproc::LineIteratorTrait for LineIterator { - #[inline] fn as_raw_mut_LineIterator(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { LineIterator, crate::imgproc::LineIteratorTraitConst, as_raw_LineIterator, crate::imgproc::LineIteratorTrait, as_raw_mut_LineIterator } - - impl LineIterator { - /// Initializes iterator object for the given line and image. - /// - /// The returned iterator can be used to traverse all pixels on a line that - /// connects the given two points. - /// The line will be clipped on the image boundaries. - /// - /// ## Parameters - /// * img: Underlying image. - /// * pt1: First endpoint of the line. - /// * pt2: The other endpoint of the line. - /// * connectivity: Pixel connectivity of the iterator. Valid values are 4 (iterator can move - /// up, down, left and right) and 8 (iterator can also move diagonally). - /// * leftToRight: If true, the line is traversed from the leftmost endpoint to the rightmost - /// endpoint. Otherwise, the line is traversed from \p pt1 to \p pt2. - /// - /// ## C++ default parameters - /// * connectivity: 8 - /// * left_to_right: false - #[inline] - pub fn new(img: &impl core::MatTraitConst, pt1: core::Point, pt2: core::Point, connectivity: i32, left_to_right: bool) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_LineIterator_LineIterator_const_MatR_Point_Point_int_bool(img.as_raw_Mat(), &pt1, &pt2, connectivity, left_to_right, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::imgproc::LineIterator::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Initializes iterator object for the given line and image. - /// - /// The returned iterator can be used to traverse all pixels on a line that - /// connects the given two points. - /// The line will be clipped on the image boundaries. - /// - /// ## Parameters - /// * img: Underlying image. - /// * pt1: First endpoint of the line. - /// * pt2: The other endpoint of the line. - /// * connectivity: Pixel connectivity of the iterator. Valid values are 4 (iterator can move - /// up, down, left and right) and 8 (iterator can also move diagonally). - /// * leftToRight: If true, the line is traversed from the leftmost endpoint to the rightmost - /// endpoint. Otherwise, the line is traversed from \p pt1 to \p pt2. - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * connectivity: 8 - /// * left_to_right: false - #[inline] - pub fn new_def(img: &impl core::MatTraitConst, pt1: core::Point, pt2: core::Point) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_LineIterator_LineIterator_const_MatR_Point_Point(img.as_raw_Mat(), &pt1, &pt2, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::imgproc::LineIterator::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## C++ default parameters - /// * connectivity: 8 - /// * left_to_right: false - #[inline] - pub fn new_1(pt1: core::Point, pt2: core::Point, connectivity: i32, left_to_right: bool) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_LineIterator_LineIterator_Point_Point_int_bool(&pt1, &pt2, connectivity, left_to_right, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::imgproc::LineIterator::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * connectivity: 8 - /// * left_to_right: false - #[inline] - pub fn new_def_1(pt1: core::Point, pt2: core::Point) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_LineIterator_LineIterator_Point_Point(&pt1, &pt2, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::imgproc::LineIterator::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## C++ default parameters - /// * connectivity: 8 - /// * left_to_right: false - #[inline] - pub fn new_2(bounding_area_size: core::Size, pt1: core::Point, pt2: core::Point, connectivity: i32, left_to_right: bool) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_LineIterator_LineIterator_Size_Point_Point_int_bool(&bounding_area_size, &pt1, &pt2, connectivity, left_to_right, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::imgproc::LineIterator::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * connectivity: 8 - /// * left_to_right: false - #[inline] - pub fn new_def_2(bounding_area_size: core::Size, pt1: core::Point, pt2: core::Point) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_LineIterator_LineIterator_Size_Point_Point(&bounding_area_size, &pt1, &pt2, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::imgproc::LineIterator::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## C++ default parameters - /// * connectivity: 8 - /// * left_to_right: false + /// Returns pointer to the current pixel. #[inline] - pub fn new_3(bounding_area_rect: core::Rect, pt1: core::Point, pt2: core::Point, connectivity: i32, left_to_right: bool) -> Result { + fn try_deref_mut(&mut self) -> Result<*mut u8> { return_send!(via ocvrs_return); - unsafe { sys::cv_LineIterator_LineIterator_Rect_Point_Point_int_bool(&bounding_area_rect, &pt1, &pt2, connectivity, left_to_right, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_LineIterator_operatorX(self.as_raw_mut_LineIterator(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::imgproc::LineIterator::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * connectivity: 8 - /// * left_to_right: false + /// Moves iterator to the next pixel on the line. + /// + /// This is the prefix version (++it). #[inline] - pub fn new_def_3(bounding_area_rect: core::Rect, pt1: core::Point, pt2: core::Point) -> Result { + fn incr(&mut self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_LineIterator_LineIterator_Rect_Point_Point(&bounding_area_rect, &pt1, &pt2, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_LineIterator_operatorAA(self.as_raw_mut_LineIterator(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { crate::imgproc::LineIterator::opencv_from_extern(ret) }; @@ -12558,6 +12536,38 @@ pub mod imgproc { } } + impl crate::imgproc::LineIteratorTraitConst for LineIterator { + #[inline] fn as_raw_LineIterator(&self) -> *const c_void { self.as_raw() } + } + + impl crate::imgproc::LineIteratorTrait for LineIterator { + #[inline] fn as_raw_mut_LineIterator(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { LineIterator, crate::imgproc::LineIteratorTraitConst, as_raw_LineIterator, crate::imgproc::LineIteratorTrait, as_raw_mut_LineIterator } + + /// Line segment detector class + /// + /// following the algorithm described at [Rafael12](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Rafael12) . + /// + /// + /// Note: Implementation has been removed from OpenCV version 3.4.6 to 3.4.15 and version 4.1.0 to 4.5.3 due original code license conflict. + /// restored again after [Computation of a NFA](https://github.com/rafael-grompone-von-gioi/binomial_nfa) code published under the MIT license. + pub struct LineSegmentDetector { + ptr: *mut c_void, + } + + opencv_type_boxed! { LineSegmentDetector } + + impl Drop for LineSegmentDetector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_LineSegmentDetector_delete(self.as_raw_mut_LineSegmentDetector()) }; + } + } + + unsafe impl Send for LineSegmentDetector {} + /// Constant methods for [crate::imgproc::LineSegmentDetector] pub trait LineSegmentDetectorTraitConst: core::AlgorithmTraitConst { fn as_raw_LineSegmentDetector(&self) -> *const c_void; @@ -12708,27 +12718,15 @@ pub mod imgproc { } - /// Line segment detector class - /// - /// following the algorithm described at [Rafael12](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Rafael12) . - /// - /// - /// Note: Implementation has been removed from OpenCV version 3.4.6 to 3.4.15 and version 4.1.0 to 4.5.3 due original code license conflict. - /// restored again after [Computation of a NFA](https://github.com/rafael-grompone-von-gioi/binomial_nfa) code published under the MIT license. - pub struct LineSegmentDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { LineSegmentDetector } - - impl Drop for LineSegmentDetector { + impl std::fmt::Debug for LineSegmentDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_LineSegmentDetector_delete(self.as_raw_mut_LineSegmentDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LineSegmentDetector") + .finish() } } - unsafe impl Send for LineSegmentDetector {} + boxed_cast_base! { LineSegmentDetector, core::Algorithm, cv_LineSegmentDetector_to_Algorithm } impl core::AlgorithmTraitConst for LineSegmentDetector { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -12750,17 +12748,56 @@ pub mod imgproc { boxed_ref! { LineSegmentDetector, crate::imgproc::LineSegmentDetectorTraitConst, as_raw_LineSegmentDetector, crate::imgproc::LineSegmentDetectorTrait, as_raw_mut_LineSegmentDetector } - impl LineSegmentDetector { + pub struct Subdiv2D { + ptr: *mut c_void, } - boxed_cast_base! { LineSegmentDetector, core::Algorithm, cv_LineSegmentDetector_to_Algorithm } + opencv_type_boxed! { Subdiv2D } - impl std::fmt::Debug for LineSegmentDetector { + impl Drop for Subdiv2D { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LineSegmentDetector") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_Subdiv2D_delete(self.as_raw_mut_Subdiv2D()) }; + } + } + + unsafe impl Send for Subdiv2D {} + + impl Subdiv2D { + /// creates an empty Subdiv2D object. + /// To create a new empty Delaunay subdivision you need to use the [init_delaunay] function. + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_Subdiv2D_Subdiv2D(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::imgproc::Subdiv2D::opencv_from_extern(ret) }; + Ok(ret) + } + + /// creates an empty Subdiv2D object. + /// To create a new empty Delaunay subdivision you need to use the [init_delaunay] function. + /// + /// ## Overloaded parameters + /// + /// + /// ## Parameters + /// * rect: Rectangle that includes all of the 2D points that are to be added to the subdivision. + /// + /// The function creates an empty Delaunay subdivision where 2D points can be added using the function + /// insert() . All of the points to be added must be within the specified rectangle, otherwise a runtime + /// error is raised. + #[inline] + pub fn new(rect: core::Rect) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_Subdiv2D_Subdiv2D_Rect(&rect, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::imgproc::Subdiv2D::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::imgproc::Subdiv2D] @@ -13165,21 +13202,14 @@ pub mod imgproc { } - pub struct Subdiv2D { - ptr: *mut c_void, - } - - opencv_type_boxed! { Subdiv2D } - - impl Drop for Subdiv2D { + impl std::fmt::Debug for Subdiv2D { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_Subdiv2D_delete(self.as_raw_mut_Subdiv2D()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Subdiv2D") + .finish() } } - unsafe impl Send for Subdiv2D {} - impl crate::imgproc::Subdiv2DTraitConst for Subdiv2D { #[inline] fn as_raw_Subdiv2D(&self) -> *const c_void { self.as_raw() } } @@ -13190,51 +13220,45 @@ pub mod imgproc { boxed_ref! { Subdiv2D, crate::imgproc::Subdiv2DTraitConst, as_raw_Subdiv2D, crate::imgproc::Subdiv2DTrait, as_raw_mut_Subdiv2D } - impl Subdiv2D { - /// creates an empty Subdiv2D object. - /// To create a new empty Delaunay subdivision you need to use the [init_delaunay] function. + /// Intelligent Scissors image segmentation + /// + /// This class is used to find the path (contour) between two points + /// which can be used for image segmentation. + /// + /// Usage example: + /// [usage_example_intelligent_scissors](https://github.com/opencv/opencv/blob/4.11.0/samples/cpp/tutorial_code/snippets/imgproc_segmentation.cpp#L1) + /// + /// Reference: "Intelligent Scissors for Image Composition" + /// algorithm designed by Eric N. Mortensen and William A. Barrett, Brigham Young University + /// [Mortensen95intelligentscissors](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Mortensen95intelligentscissors) + pub struct IntelligentScissorsMB { + ptr: *mut c_void, + } + + opencv_type_boxed! { IntelligentScissorsMB } + + impl Drop for IntelligentScissorsMB { #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_Subdiv2D_Subdiv2D(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::imgproc::Subdiv2D::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_segmentation_IntelligentScissorsMB_delete(self.as_raw_mut_IntelligentScissorsMB()) }; } + } - /// creates an empty Subdiv2D object. - /// To create a new empty Delaunay subdivision you need to use the [init_delaunay] function. - /// - /// ## Overloaded parameters - /// - /// - /// ## Parameters - /// * rect: Rectangle that includes all of the 2D points that are to be added to the subdivision. - /// - /// The function creates an empty Delaunay subdivision where 2D points can be added using the function - /// insert() . All of the points to be added must be within the specified rectangle, otherwise a runtime - /// error is raised. + unsafe impl Send for IntelligentScissorsMB {} + + impl IntelligentScissorsMB { #[inline] - pub fn new(rect: core::Rect) -> Result { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_Subdiv2D_Subdiv2D_Rect(&rect, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_segmentation_IntelligentScissorsMB_IntelligentScissorsMB(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::imgproc::Subdiv2D::opencv_from_extern(ret) }; + let ret = unsafe { crate::imgproc::IntelligentScissorsMB::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for Subdiv2D { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Subdiv2D") - .finish() - } - } - /// Constant methods for [crate::imgproc::IntelligentScissorsMB] pub trait IntelligentScissorsMBTraitConst { fn as_raw_IntelligentScissorsMB(&self) -> *const c_void; @@ -13539,32 +13563,21 @@ pub mod imgproc { } - /// Intelligent Scissors image segmentation - /// - /// This class is used to find the path (contour) between two points - /// which can be used for image segmentation. - /// - /// Usage example: - /// [usage_example_intelligent_scissors](https://github.com/opencv/opencv/blob/4.11.0/samples/cpp/tutorial_code/snippets/imgproc_segmentation.cpp#L1) - /// - /// Reference: "Intelligent Scissors for Image Composition" - /// algorithm designed by Eric N. Mortensen and William A. Barrett, Brigham Young University - /// [Mortensen95intelligentscissors](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Mortensen95intelligentscissors) - pub struct IntelligentScissorsMB { - ptr: *mut c_void, + impl Clone for IntelligentScissorsMB { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_segmentation_IntelligentScissorsMB_implicitClone_const(self.as_raw_IntelligentScissorsMB())) } + } } - opencv_type_boxed! { IntelligentScissorsMB } - - impl Drop for IntelligentScissorsMB { + impl std::fmt::Debug for IntelligentScissorsMB { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_segmentation_IntelligentScissorsMB_delete(self.as_raw_mut_IntelligentScissorsMB()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("IntelligentScissorsMB") + .finish() } } - unsafe impl Send for IntelligentScissorsMB {} - impl crate::imgproc::IntelligentScissorsMBTraitConst for IntelligentScissorsMB { #[inline] fn as_raw_IntelligentScissorsMB(&self) -> *const c_void { self.as_raw() } } @@ -13575,31 +13588,4 @@ pub mod imgproc { boxed_ref! { IntelligentScissorsMB, crate::imgproc::IntelligentScissorsMBTraitConst, as_raw_IntelligentScissorsMB, crate::imgproc::IntelligentScissorsMBTrait, as_raw_mut_IntelligentScissorsMB } - impl IntelligentScissorsMB { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_segmentation_IntelligentScissorsMB_IntelligentScissorsMB(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::imgproc::IntelligentScissorsMB::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl Clone for IntelligentScissorsMB { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_segmentation_IntelligentScissorsMB_implicitClone_const(self.as_raw_IntelligentScissorsMB())) } - } - } - - impl std::fmt::Debug for IntelligentScissorsMB { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("IntelligentScissorsMB") - .finish() - } - } } diff --git a/docs/intensity_transform.rs b/docs/intensity_transform.rs index b3b02f98b..1ffe710f5 100644 --- a/docs/intensity_transform.rs +++ b/docs/intensity_transform.rs @@ -166,4 +166,5 @@ pub mod intensity_transform { let ret = ret.into_result()?; Ok(ret) } + } diff --git a/docs/line_descriptor.rs b/docs/line_descriptor.rs index 36631d23a..9a5c1dce5 100644 --- a/docs/line_descriptor.rs +++ b/docs/line_descriptor.rs @@ -231,6 +231,93 @@ pub mod line_descriptor { Ok(ret) } + /// Class implements both functionalities for detection of lines and computation of their + /// binary descriptor. + /// + /// Class' interface is mainly based on the ones of classical detectors and extractors, such as + /// Feature2d's [features2d_main] and [features2d_match]. Retrieved information about lines is + /// stored in line_descriptor::KeyLine objects. + pub struct BinaryDescriptor { + ptr: *mut c_void, + } + + opencv_type_boxed! { BinaryDescriptor } + + impl Drop for BinaryDescriptor { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_line_descriptor_BinaryDescriptor_delete(self.as_raw_mut_BinaryDescriptor()) }; + } + } + + unsafe impl Send for BinaryDescriptor {} + + impl BinaryDescriptor { + /// Constructor + /// + /// ## Parameters + /// * parameters: configuration parameters BinaryDescriptor::Params + /// + /// If no argument is provided, constructor sets default values (see comments in the code snippet in + /// previous section). Default values are strongly recommended. + /// + /// ## C++ default parameters + /// * parameters: BinaryDescriptor::Params() + #[inline] + pub fn new(parameters: &impl crate::line_descriptor::BinaryDescriptor_ParamsTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_line_descriptor_BinaryDescriptor_BinaryDescriptor_const_ParamsR(parameters.as_raw_BinaryDescriptor_Params(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::line_descriptor::BinaryDescriptor::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Constructor + /// + /// ## Parameters + /// * parameters: configuration parameters BinaryDescriptor::Params + /// + /// If no argument is provided, constructor sets default values (see comments in the code snippet in + /// previous section). Default values are strongly recommended. + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * parameters: BinaryDescriptor::Params() + #[inline] + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_line_descriptor_BinaryDescriptor_BinaryDescriptor(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::line_descriptor::BinaryDescriptor::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Create a BinaryDescriptor object with default parameters (or with the ones provided) + /// and return a smart pointer to it + #[inline] + pub fn create_binary_descriptor() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_line_descriptor_BinaryDescriptor_createBinaryDescriptor(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn create_binary_descriptor_1(mut parameters: impl crate::line_descriptor::BinaryDescriptor_ParamsTrait) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_line_descriptor_BinaryDescriptor_createBinaryDescriptor_Params(parameters.as_raw_mut_BinaryDescriptor_Params(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::line_descriptor::BinaryDescriptor] pub trait BinaryDescriptorTraitConst: core::AlgorithmTraitConst { fn as_raw_BinaryDescriptor(&self) -> *const c_void; @@ -589,26 +676,15 @@ pub mod line_descriptor { } - /// Class implements both functionalities for detection of lines and computation of their - /// binary descriptor. - /// - /// Class' interface is mainly based on the ones of classical detectors and extractors, such as - /// Feature2d's [features2d_main] and [features2d_match]. Retrieved information about lines is - /// stored in line_descriptor::KeyLine objects. - pub struct BinaryDescriptor { - ptr: *mut c_void, - } - - opencv_type_boxed! { BinaryDescriptor } - - impl Drop for BinaryDescriptor { + impl std::fmt::Debug for BinaryDescriptor { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_line_descriptor_BinaryDescriptor_delete(self.as_raw_mut_BinaryDescriptor()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BinaryDescriptor") + .finish() } } - unsafe impl Send for BinaryDescriptor {} + boxed_cast_base! { BinaryDescriptor, core::Algorithm, cv_line_descriptor_BinaryDescriptor_to_Algorithm } impl core::AlgorithmTraitConst for BinaryDescriptor { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -630,82 +706,35 @@ pub mod line_descriptor { boxed_ref! { BinaryDescriptor, crate::line_descriptor::BinaryDescriptorTraitConst, as_raw_BinaryDescriptor, crate::line_descriptor::BinaryDescriptorTrait, as_raw_mut_BinaryDescriptor } - impl BinaryDescriptor { - /// Constructor - /// - /// ## Parameters - /// * parameters: configuration parameters BinaryDescriptor::Params - /// - /// If no argument is provided, constructor sets default values (see comments in the code snippet in - /// previous section). Default values are strongly recommended. - /// - /// ## C++ default parameters - /// * parameters: BinaryDescriptor::Params() - #[inline] - pub fn new(parameters: &impl crate::line_descriptor::BinaryDescriptor_ParamsTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_line_descriptor_BinaryDescriptor_BinaryDescriptor_const_ParamsR(parameters.as_raw_BinaryDescriptor_Params(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::line_descriptor::BinaryDescriptor::opencv_from_extern(ret) }; - Ok(ret) - } + /// List of BinaryDescriptor parameters: + pub struct BinaryDescriptor_Params { + ptr: *mut c_void, + } - /// Constructor - /// - /// ## Parameters - /// * parameters: configuration parameters BinaryDescriptor::Params - /// - /// If no argument is provided, constructor sets default values (see comments in the code snippet in - /// previous section). Default values are strongly recommended. - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * parameters: BinaryDescriptor::Params() - #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_line_descriptor_BinaryDescriptor_BinaryDescriptor(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::line_descriptor::BinaryDescriptor::opencv_from_extern(ret) }; - Ok(ret) - } + opencv_type_boxed! { BinaryDescriptor_Params } - /// Create a BinaryDescriptor object with default parameters (or with the ones provided) - /// and return a smart pointer to it + impl Drop for BinaryDescriptor_Params { #[inline] - pub fn create_binary_descriptor() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_line_descriptor_BinaryDescriptor_createBinaryDescriptor(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_line_descriptor_BinaryDescriptor_Params_delete(self.as_raw_mut_BinaryDescriptor_Params()) }; } + } + + unsafe impl Send for BinaryDescriptor_Params {} + impl BinaryDescriptor_Params { #[inline] - pub fn create_binary_descriptor_1(mut parameters: impl crate::line_descriptor::BinaryDescriptor_ParamsTrait) -> Result> { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_line_descriptor_BinaryDescriptor_createBinaryDescriptor_Params(parameters.as_raw_mut_BinaryDescriptor_Params(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_line_descriptor_BinaryDescriptor_Params_Params(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::line_descriptor::BinaryDescriptor_Params::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { BinaryDescriptor, core::Algorithm, cv_line_descriptor_BinaryDescriptor_to_Algorithm } - - impl std::fmt::Debug for BinaryDescriptor { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BinaryDescriptor") - .finish() - } - } - /// Constant methods for [crate::line_descriptor::BinaryDescriptor_Params] pub trait BinaryDescriptor_ParamsTraitConst { fn as_raw_BinaryDescriptor_Params(&self) -> *const c_void; @@ -792,22 +821,18 @@ pub mod line_descriptor { } - /// List of BinaryDescriptor parameters: - pub struct BinaryDescriptor_Params { - ptr: *mut c_void, - } - - opencv_type_boxed! { BinaryDescriptor_Params } - - impl Drop for BinaryDescriptor_Params { + impl std::fmt::Debug for BinaryDescriptor_Params { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_line_descriptor_BinaryDescriptor_Params_delete(self.as_raw_mut_BinaryDescriptor_Params()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BinaryDescriptor_Params") + .field("num_of_octave_", &crate::line_descriptor::BinaryDescriptor_ParamsTraitConst::num_of_octave_(self)) + .field("width_of_band_", &crate::line_descriptor::BinaryDescriptor_ParamsTraitConst::width_of_band_(self)) + .field("reduction_ratio", &crate::line_descriptor::BinaryDescriptor_ParamsTraitConst::reduction_ratio(self)) + .field("ksize_", &crate::line_descriptor::BinaryDescriptor_ParamsTraitConst::ksize_(self)) + .finish() } } - unsafe impl Send for BinaryDescriptor_Params {} - impl crate::line_descriptor::BinaryDescriptor_ParamsTraitConst for BinaryDescriptor_Params { #[inline] fn as_raw_BinaryDescriptor_Params(&self) -> *const c_void { self.as_raw() } } @@ -818,29 +843,83 @@ pub mod line_descriptor { boxed_ref! { BinaryDescriptor_Params, crate::line_descriptor::BinaryDescriptor_ParamsTraitConst, as_raw_BinaryDescriptor_Params, crate::line_descriptor::BinaryDescriptor_ParamsTrait, as_raw_mut_BinaryDescriptor_Params } - impl BinaryDescriptor_Params { + /// furnishes all functionalities for querying a dataset provided by user or internal to + /// class (that user must, anyway, populate) on the model of [features2d_match] + /// + /// + /// Once descriptors have been extracted from an image (both they represent lines and points), it + /// becomes interesting to be able to match a descriptor with another one extracted from a different + /// image and representing the same line or point, seen from a differente perspective or on a different + /// scale. In reaching such goal, the main headache is designing an efficient search algorithm to + /// associate a query descriptor to one extracted from a dataset. In the following, a matching modality + /// based on *Multi-Index Hashing (MiHashing)* will be described. + /// + /// Multi-Index Hashing + /// ------------------- + /// + /// The theory described in this section is based on [MIH](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_MIH) . Given a dataset populated with binary + /// codes, each code is indexed *m* times into *m* different hash tables, according to *m* substrings it + /// has been divided into. Thus, given a query code, all the entries close to it at least in one + /// substring are returned by search as *neighbor candidates*. Returned entries are then checked for + /// validity by verifying that their full codes are not distant (in Hamming space) more than *r* bits + /// from query code. In details, each binary code **h** composed of *b* bits is divided into *m* + /// disjoint substrings ![inline formula](https://latex.codecogs.com/png.latex?%5Cmathbf%7Bh%7D%5E%7B%281%29%7D%2C%20%2E%2E%2E%2C%20%5Cmathbf%7Bh%7D%5E%7B%28m%29%7D), each with length + /// ![inline formula](https://latex.codecogs.com/png.latex?%5Clfloor%20b%2Fm%20%5Crfloor) or ![inline formula](https://latex.codecogs.com/png.latex?%5Clceil%20b%2Fm%20%5Crceil) bits. Formally, when two codes **h** and **g** differ + /// by at the most *r* bits, in at the least one of their *m* substrings they differ by at the most + /// ![inline formula](https://latex.codecogs.com/png.latex?%5Clfloor%20r%2Fm%20%5Crfloor) bits. In particular, when ![inline formula](https://latex.codecogs.com/png.latex?%7C%7C%5Cmathbf%7Bh%7D%2D%5Cmathbf%7Bg%7D%7C%7C%5FH%20%5Cle%20r) (where ![inline formula](https://latex.codecogs.com/png.latex?%7C%7C%2E%7C%7C%5FH) + /// is the Hamming norm), there must exist a substring *k* (with ![inline formula](https://latex.codecogs.com/png.latex?1%20%5Cle%20k%20%5Cle%20m)) such that + /// + /// ![block formula](https://latex.codecogs.com/png.latex?%7C%7C%5Cmathbf%7Bh%7D%5E%7B%28k%29%7D%20%2D%20%5Cmathbf%7Bg%7D%5E%7B%28k%29%7D%7C%7C%5FH%20%5Cle%20%5Cleft%5Clfloor%20%5Cfrac%7Br%7D%7Bm%7D%20%5Cright%5Crfloor%20%2E) + /// + /// That means that if Hamming distance between each of the *m* substring is strictly greater than + /// ![inline formula](https://latex.codecogs.com/png.latex?%5Clfloor%20r%2Fm%20%5Crfloor), then ![inline formula](https://latex.codecogs.com/png.latex?%7C%7C%5Cmathbf%7Bh%7D%2D%5Cmathbf%7Bg%7D%7C%7C%5FH) must be larger that *r* and that is a + /// contradiction. If the codes in dataset are divided into *m* substrings, then *m* tables will be + /// built. Given a query **q** with substrings ![inline formula](https://latex.codecogs.com/png.latex?%5C%7B%5Cmathbf%7Bq%7D%5E%7B%28i%29%7D%5C%7D%5Em%5F%7Bi%3D1%7D), *i*-th hash table is + /// searched for entries distant at the most ![inline formula](https://latex.codecogs.com/png.latex?%5Clfloor%20r%2Fm%20%5Crfloor) from ![inline formula](https://latex.codecogs.com/png.latex?%5Cmathbf%7Bq%7D%5E%7B%28i%29%7D) and a set of + /// candidates ![inline formula](https://latex.codecogs.com/png.latex?%5Cmathcal%7BN%7D%5Fi%28%5Cmathbf%7Bq%7D%29) is obtained. The union of sets + /// ![inline formula](https://latex.codecogs.com/png.latex?%5Cmathcal%7BN%7D%28%5Cmathbf%7Bq%7D%29%20%3D%20%5Cbigcup%5Fi%20%5Cmathcal%7BN%7D%5Fi%28%5Cmathbf%7Bq%7D%29) is a superset of the *r*-neighbors + /// of **q**. Then, last step of algorithm is computing the Hamming distance between **q** and each + /// element in ![inline formula](https://latex.codecogs.com/png.latex?%5Cmathcal%7BN%7D%28%5Cmathbf%7Bq%7D%29), deleting the codes that are distant more that *r* from **q**. + pub struct BinaryDescriptorMatcher { + ptr: *mut c_void, + } + + opencv_type_boxed! { BinaryDescriptorMatcher } + + impl Drop for BinaryDescriptorMatcher { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_line_descriptor_BinaryDescriptorMatcher_delete(self.as_raw_mut_BinaryDescriptorMatcher()) }; + } + } + + unsafe impl Send for BinaryDescriptorMatcher {} + + impl BinaryDescriptorMatcher { + /// Create a BinaryDescriptorMatcher object and return a smart pointer to it. + #[inline] + pub fn create_binary_descriptor_matcher() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_line_descriptor_BinaryDescriptor_Params_Params(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_line_descriptor_BinaryDescriptorMatcher_createBinaryDescriptorMatcher(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::line_descriptor::BinaryDescriptor_Params::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - } - - impl std::fmt::Debug for BinaryDescriptor_Params { + /// Constructor. + /// + /// The BinaryDescriptorMatcher constructed is able to store and manage 256-bits long entries. #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BinaryDescriptor_Params") - .field("num_of_octave_", &crate::line_descriptor::BinaryDescriptor_ParamsTraitConst::num_of_octave_(self)) - .field("width_of_band_", &crate::line_descriptor::BinaryDescriptor_ParamsTraitConst::width_of_band_(self)) - .field("reduction_ratio", &crate::line_descriptor::BinaryDescriptor_ParamsTraitConst::reduction_ratio(self)) - .field("ksize_", &crate::line_descriptor::BinaryDescriptor_ParamsTraitConst::ksize_(self)) - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_line_descriptor_BinaryDescriptorMatcher_BinaryDescriptorMatcher(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::line_descriptor::BinaryDescriptorMatcher::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::line_descriptor::BinaryDescriptorMatcher] @@ -1201,57 +1280,15 @@ pub mod line_descriptor { } - /// furnishes all functionalities for querying a dataset provided by user or internal to - /// class (that user must, anyway, populate) on the model of [features2d_match] - /// - /// - /// Once descriptors have been extracted from an image (both they represent lines and points), it - /// becomes interesting to be able to match a descriptor with another one extracted from a different - /// image and representing the same line or point, seen from a differente perspective or on a different - /// scale. In reaching such goal, the main headache is designing an efficient search algorithm to - /// associate a query descriptor to one extracted from a dataset. In the following, a matching modality - /// based on *Multi-Index Hashing (MiHashing)* will be described. - /// - /// Multi-Index Hashing - /// ------------------- - /// - /// The theory described in this section is based on [MIH](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_MIH) . Given a dataset populated with binary - /// codes, each code is indexed *m* times into *m* different hash tables, according to *m* substrings it - /// has been divided into. Thus, given a query code, all the entries close to it at least in one - /// substring are returned by search as *neighbor candidates*. Returned entries are then checked for - /// validity by verifying that their full codes are not distant (in Hamming space) more than *r* bits - /// from query code. In details, each binary code **h** composed of *b* bits is divided into *m* - /// disjoint substrings ![inline formula](https://latex.codecogs.com/png.latex?%5Cmathbf%7Bh%7D%5E%7B%281%29%7D%2C%20%2E%2E%2E%2C%20%5Cmathbf%7Bh%7D%5E%7B%28m%29%7D), each with length - /// ![inline formula](https://latex.codecogs.com/png.latex?%5Clfloor%20b%2Fm%20%5Crfloor) or ![inline formula](https://latex.codecogs.com/png.latex?%5Clceil%20b%2Fm%20%5Crceil) bits. Formally, when two codes **h** and **g** differ - /// by at the most *r* bits, in at the least one of their *m* substrings they differ by at the most - /// ![inline formula](https://latex.codecogs.com/png.latex?%5Clfloor%20r%2Fm%20%5Crfloor) bits. In particular, when ![inline formula](https://latex.codecogs.com/png.latex?%7C%7C%5Cmathbf%7Bh%7D%2D%5Cmathbf%7Bg%7D%7C%7C%5FH%20%5Cle%20r) (where ![inline formula](https://latex.codecogs.com/png.latex?%7C%7C%2E%7C%7C%5FH) - /// is the Hamming norm), there must exist a substring *k* (with ![inline formula](https://latex.codecogs.com/png.latex?1%20%5Cle%20k%20%5Cle%20m)) such that - /// - /// ![block formula](https://latex.codecogs.com/png.latex?%7C%7C%5Cmathbf%7Bh%7D%5E%7B%28k%29%7D%20%2D%20%5Cmathbf%7Bg%7D%5E%7B%28k%29%7D%7C%7C%5FH%20%5Cle%20%5Cleft%5Clfloor%20%5Cfrac%7Br%7D%7Bm%7D%20%5Cright%5Crfloor%20%2E) - /// - /// That means that if Hamming distance between each of the *m* substring is strictly greater than - /// ![inline formula](https://latex.codecogs.com/png.latex?%5Clfloor%20r%2Fm%20%5Crfloor), then ![inline formula](https://latex.codecogs.com/png.latex?%7C%7C%5Cmathbf%7Bh%7D%2D%5Cmathbf%7Bg%7D%7C%7C%5FH) must be larger that *r* and that is a - /// contradiction. If the codes in dataset are divided into *m* substrings, then *m* tables will be - /// built. Given a query **q** with substrings ![inline formula](https://latex.codecogs.com/png.latex?%5C%7B%5Cmathbf%7Bq%7D%5E%7B%28i%29%7D%5C%7D%5Em%5F%7Bi%3D1%7D), *i*-th hash table is - /// searched for entries distant at the most ![inline formula](https://latex.codecogs.com/png.latex?%5Clfloor%20r%2Fm%20%5Crfloor) from ![inline formula](https://latex.codecogs.com/png.latex?%5Cmathbf%7Bq%7D%5E%7B%28i%29%7D) and a set of - /// candidates ![inline formula](https://latex.codecogs.com/png.latex?%5Cmathcal%7BN%7D%5Fi%28%5Cmathbf%7Bq%7D%29) is obtained. The union of sets - /// ![inline formula](https://latex.codecogs.com/png.latex?%5Cmathcal%7BN%7D%28%5Cmathbf%7Bq%7D%29%20%3D%20%5Cbigcup%5Fi%20%5Cmathcal%7BN%7D%5Fi%28%5Cmathbf%7Bq%7D%29) is a superset of the *r*-neighbors - /// of **q**. Then, last step of algorithm is computing the Hamming distance between **q** and each - /// element in ![inline formula](https://latex.codecogs.com/png.latex?%5Cmathcal%7BN%7D%28%5Cmathbf%7Bq%7D%29), deleting the codes that are distant more that *r* from **q**. - pub struct BinaryDescriptorMatcher { - ptr: *mut c_void, - } - - opencv_type_boxed! { BinaryDescriptorMatcher } - - impl Drop for BinaryDescriptorMatcher { + impl std::fmt::Debug for BinaryDescriptorMatcher { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_line_descriptor_BinaryDescriptorMatcher_delete(self.as_raw_mut_BinaryDescriptorMatcher()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BinaryDescriptorMatcher") + .finish() } } - unsafe impl Send for BinaryDescriptorMatcher {} + boxed_cast_base! { BinaryDescriptorMatcher, core::Algorithm, cv_line_descriptor_BinaryDescriptorMatcher_to_Algorithm } impl core::AlgorithmTraitConst for BinaryDescriptorMatcher { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1273,43 +1310,6 @@ pub mod line_descriptor { boxed_ref! { BinaryDescriptorMatcher, crate::line_descriptor::BinaryDescriptorMatcherTraitConst, as_raw_BinaryDescriptorMatcher, crate::line_descriptor::BinaryDescriptorMatcherTrait, as_raw_mut_BinaryDescriptorMatcher } - impl BinaryDescriptorMatcher { - /// Create a BinaryDescriptorMatcher object and return a smart pointer to it. - #[inline] - pub fn create_binary_descriptor_matcher() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_line_descriptor_BinaryDescriptorMatcher_createBinaryDescriptorMatcher(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Constructor. - /// - /// The BinaryDescriptorMatcher constructed is able to store and manage 256-bits long entries. - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_line_descriptor_BinaryDescriptorMatcher_BinaryDescriptorMatcher(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::line_descriptor::BinaryDescriptorMatcher::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { BinaryDescriptorMatcher, core::Algorithm, cv_line_descriptor_BinaryDescriptorMatcher_to_Algorithm } - - impl std::fmt::Debug for BinaryDescriptorMatcher { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BinaryDescriptorMatcher") - .finish() - } - } - /// A class to represent a line /// /// As aformentioned, it is been necessary to design a class that fully stores the information needed to @@ -1419,6 +1419,65 @@ pub mod line_descriptor { } + pub struct LSDDetector { + ptr: *mut c_void, + } + + opencv_type_boxed! { LSDDetector } + + impl Drop for LSDDetector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_line_descriptor_LSDDetector_delete(self.as_raw_mut_LSDDetector()) }; + } + } + + unsafe impl Send for LSDDetector {} + + impl LSDDetector { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_line_descriptor_LSDDetector_LSDDetector(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::line_descriptor::LSDDetector::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn new(_params: crate::line_descriptor::LSDParam) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_line_descriptor_LSDDetector_LSDDetector_LSDParam(&_params, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::line_descriptor::LSDDetector::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Creates ad LSDDetector object, using smart pointers. + #[inline] + pub fn create_lsd_detector() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_line_descriptor_LSDDetector_createLSDDetector(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn create_lsd_detector_with_params(params: crate::line_descriptor::LSDParam) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_line_descriptor_LSDDetector_createLSDDetector_LSDParam(¶ms, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::line_descriptor::LSDDetector] pub trait LSDDetectorTraitConst: core::AlgorithmTraitConst { fn as_raw_LSDDetector(&self) -> *const c_void; @@ -1520,20 +1579,15 @@ pub mod line_descriptor { } - pub struct LSDDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { LSDDetector } - - impl Drop for LSDDetector { + impl std::fmt::Debug for LSDDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_line_descriptor_LSDDetector_delete(self.as_raw_mut_LSDDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LSDDetector") + .finish() } } - unsafe impl Send for LSDDetector {} + boxed_cast_base! { LSDDetector, core::Algorithm, cv_line_descriptor_LSDDetector_to_Algorithm } impl core::AlgorithmTraitConst for LSDDetector { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1555,60 +1609,6 @@ pub mod line_descriptor { boxed_ref! { LSDDetector, crate::line_descriptor::LSDDetectorTraitConst, as_raw_LSDDetector, crate::line_descriptor::LSDDetectorTrait, as_raw_mut_LSDDetector } - impl LSDDetector { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_line_descriptor_LSDDetector_LSDDetector(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::line_descriptor::LSDDetector::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn new(_params: crate::line_descriptor::LSDParam) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_line_descriptor_LSDDetector_LSDDetector_LSDParam(&_params, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::line_descriptor::LSDDetector::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Creates ad LSDDetector object, using smart pointers. - #[inline] - pub fn create_lsd_detector() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_line_descriptor_LSDDetector_createLSDDetector(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn create_lsd_detector_with_params(params: crate::line_descriptor::LSDParam) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_line_descriptor_LSDDetector_createLSDDetector_LSDParam(¶ms, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { LSDDetector, core::Algorithm, cv_line_descriptor_LSDDetector_to_Algorithm } - - impl std::fmt::Debug for LSDDetector { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LSDDetector") - .finish() - } - } - /// Lines extraction methodology /// ---------------------------- /// @@ -1649,4 +1649,5 @@ pub mod line_descriptor { } } + } diff --git a/docs/mcc.rs b/docs/mcc.rs index d71b43007..dd18d12e2 100644 --- a/docs/mcc.rs +++ b/docs/mcc.rs @@ -589,6 +589,88 @@ pub mod mcc { opencv_type_enum! { crate::mcc::MCC_TYPECHART } + /// Core class of ccm model + /// + /// Produce a ColorCorrectionModel instance for inference + pub struct ColorCorrectionModel { + ptr: *mut c_void, + } + + opencv_type_boxed! { ColorCorrectionModel } + + impl Drop for ColorCorrectionModel { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_ccm_ColorCorrectionModel_delete(self.as_raw_mut_ColorCorrectionModel()) }; + } + } + + unsafe impl Send for ColorCorrectionModel {} + + impl ColorCorrectionModel { + /// Color Correction Model + /// + /// Supported list of color cards: + /// - [COLORCHECKER_Macbeth], the Macbeth ColorChecker + /// - [COLORCHECKER_Vinyl], the DKK ColorChecker + /// - [COLORCHECKER_DigitalSG], the DigitalSG ColorChecker with 140 squares + /// + /// ## Parameters + /// * src: detected colors of ColorChecker patches; + /// + /// the color type is RGB not BGR, and the color values are in [0, 1]; + /// * constcolor: the Built-in color card + #[inline] + pub fn new(src: &impl core::MatTraitConst, constcolor: crate::mcc::CONST_COLOR) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ccm_ColorCorrectionModel_ColorCorrectionModel_const_MatR_CONST_COLOR(src.as_raw_Mat(), constcolor, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::mcc::ColorCorrectionModel::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Color Correction Model + /// ## Parameters + /// * src: detected colors of ColorChecker patches; + /// + /// the color type is RGB not BGR, and the color values are in [0, 1]; + /// * colors: the reference color values, the color values are in [0, 1]. + /// + /// * ref_cs: the corresponding color space + /// If the color type is some RGB, the format is RGB not BGR; + /// + #[inline] + pub fn new_1(src: &impl core::MatTraitConst, mut colors: impl core::MatTrait, ref_cs: crate::mcc::COLOR_SPACE) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ccm_ColorCorrectionModel_ColorCorrectionModel_const_MatR_Mat_COLOR_SPACE(src.as_raw_Mat(), colors.as_raw_mut_Mat(), ref_cs, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::mcc::ColorCorrectionModel::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Color Correction Model + /// ## Parameters + /// * src: detected colors of ColorChecker patches; + /// + /// the color type is RGB not BGR, and the color values are in [0, 1]; + /// * colors: the reference color values, the color values are in [0, 1]. + /// * ref_cs: the corresponding color space + /// If the color type is some RGB, the format is RGB not BGR; + /// * colored: mask of colored color + #[inline] + pub fn new_2(src: &impl core::MatTraitConst, mut colors: impl core::MatTrait, ref_cs: crate::mcc::COLOR_SPACE, mut colored: impl core::MatTrait) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ccm_ColorCorrectionModel_ColorCorrectionModel_const_MatR_Mat_COLOR_SPACE_Mat(src.as_raw_Mat(), colors.as_raw_mut_Mat(), ref_cs, colored.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::mcc::ColorCorrectionModel::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::mcc::ColorCorrectionModel] pub trait ColorCorrectionModelTraitConst { fn as_raw_ColorCorrectionModel(&self) -> *const c_void; @@ -909,24 +991,14 @@ pub mod mcc { } - /// Core class of ccm model - /// - /// Produce a ColorCorrectionModel instance for inference - pub struct ColorCorrectionModel { - ptr: *mut c_void, - } - - opencv_type_boxed! { ColorCorrectionModel } - - impl Drop for ColorCorrectionModel { + impl std::fmt::Debug for ColorCorrectionModel { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ccm_ColorCorrectionModel_delete(self.as_raw_mut_ColorCorrectionModel()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ColorCorrectionModel") + .finish() } } - unsafe impl Send for ColorCorrectionModel {} - impl crate::mcc::ColorCorrectionModelTraitConst for ColorCorrectionModel { #[inline] fn as_raw_ColorCorrectionModel(&self) -> *const c_void { self.as_raw() } } @@ -937,78 +1009,43 @@ pub mod mcc { boxed_ref! { ColorCorrectionModel, crate::mcc::ColorCorrectionModelTraitConst, as_raw_ColorCorrectionModel, crate::mcc::ColorCorrectionModelTrait, as_raw_mut_ColorCorrectionModel } - impl ColorCorrectionModel { - /// Color Correction Model - /// - /// Supported list of color cards: - /// - [COLORCHECKER_Macbeth], the Macbeth ColorChecker - /// - [COLORCHECKER_Vinyl], the DKK ColorChecker - /// - [COLORCHECKER_DigitalSG], the DigitalSG ColorChecker with 140 squares - /// - /// ## Parameters - /// * src: detected colors of ColorChecker patches; - /// - /// the color type is RGB not BGR, and the color values are in [0, 1]; - /// * constcolor: the Built-in color card - #[inline] - pub fn new(src: &impl core::MatTraitConst, constcolor: crate::mcc::CONST_COLOR) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ccm_ColorCorrectionModel_ColorCorrectionModel_const_MatR_CONST_COLOR(src.as_raw_Mat(), constcolor, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::mcc::ColorCorrectionModel::opencv_from_extern(ret) }; - Ok(ret) - } + /// CChecker + /// + /// \brief checker object + /// + /// This class contains the information about the detected checkers,i.e, their + /// type, the corners of the chart, the color profile, the cost, centers chart, + /// etc. + pub struct MCC_CChecker { + ptr: *mut c_void, + } - /// Color Correction Model - /// ## Parameters - /// * src: detected colors of ColorChecker patches; - /// - /// the color type is RGB not BGR, and the color values are in [0, 1]; - /// * colors: the reference color values, the color values are in [0, 1]. - /// - /// * ref_cs: the corresponding color space - /// If the color type is some RGB, the format is RGB not BGR; - /// + opencv_type_boxed! { MCC_CChecker } + + impl Drop for MCC_CChecker { #[inline] - pub fn new_1(src: &impl core::MatTraitConst, mut colors: impl core::MatTrait, ref_cs: crate::mcc::COLOR_SPACE) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ccm_ColorCorrectionModel_ColorCorrectionModel_const_MatR_Mat_COLOR_SPACE(src.as_raw_Mat(), colors.as_raw_mut_Mat(), ref_cs, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::mcc::ColorCorrectionModel::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_mcc_CChecker_delete(self.as_raw_mut_MCC_CChecker()) }; } + } - /// Color Correction Model - /// ## Parameters - /// * src: detected colors of ColorChecker patches; - /// - /// the color type is RGB not BGR, and the color values are in [0, 1]; - /// * colors: the reference color values, the color values are in [0, 1]. - /// * ref_cs: the corresponding color space - /// If the color type is some RGB, the format is RGB not BGR; - /// * colored: mask of colored color + unsafe impl Send for MCC_CChecker {} + + impl MCC_CChecker { + /// \brief Create a new CChecker object. + /// \return A pointer to the implementation of the CChecker #[inline] - pub fn new_2(src: &impl core::MatTraitConst, mut colors: impl core::MatTrait, ref_cs: crate::mcc::COLOR_SPACE, mut colored: impl core::MatTrait) -> Result { + pub fn create() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_ccm_ColorCorrectionModel_ColorCorrectionModel_const_MatR_Mat_COLOR_SPACE_Mat(src.as_raw_Mat(), colors.as_raw_mut_Mat(), ref_cs, colored.as_raw_mut_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_mcc_CChecker_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::mcc::ColorCorrectionModel::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for ColorCorrectionModel { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ColorCorrectionModel") - .finish() - } - } - /// Constant methods for [crate::mcc::MCC_CChecker] pub trait MCC_CCheckerTraitConst { fn as_raw_MCC_CChecker(&self) -> *const c_void; @@ -1147,28 +1184,14 @@ pub mod mcc { } - /// CChecker - /// - /// \brief checker object - /// - /// This class contains the information about the detected checkers,i.e, their - /// type, the corners of the chart, the color profile, the cost, centers chart, - /// etc. - pub struct MCC_CChecker { - ptr: *mut c_void, - } - - opencv_type_boxed! { MCC_CChecker } - - impl Drop for MCC_CChecker { + impl std::fmt::Debug for MCC_CChecker { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_mcc_CChecker_delete(self.as_raw_mut_MCC_CChecker()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MCC_CChecker") + .finish() } } - unsafe impl Send for MCC_CChecker {} - impl crate::mcc::MCC_CCheckerTraitConst for MCC_CChecker { #[inline] fn as_raw_MCC_CChecker(&self) -> *const c_void { self.as_raw() } } @@ -1179,29 +1202,36 @@ pub mod mcc { boxed_ref! { MCC_CChecker, crate::mcc::MCC_CCheckerTraitConst, as_raw_MCC_CChecker, crate::mcc::MCC_CCheckerTrait, as_raw_mut_MCC_CChecker } - impl MCC_CChecker { - /// \brief Create a new CChecker object. - /// \return A pointer to the implementation of the CChecker + /// A class to find the positions of the ColorCharts in the image. + pub struct MCC_CCheckerDetector { + ptr: *mut c_void, + } + + opencv_type_boxed! { MCC_CCheckerDetector } + + impl Drop for MCC_CCheckerDetector { #[inline] - pub fn create() -> Result> { + fn drop(&mut self) { + unsafe { sys::cv_mcc_CCheckerDetector_delete(self.as_raw_mut_MCC_CCheckerDetector()) }; + } + } + + unsafe impl Send for MCC_CCheckerDetector {} + + impl MCC_CCheckerDetector { + /// \brief Returns the implementation of the CCheckerDetector. + #[inline] + pub fn create() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_mcc_CChecker_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_mcc_CCheckerDetector_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for MCC_CChecker { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MCC_CChecker") - .finish() - } - } - /// Constant methods for [crate::mcc::MCC_CCheckerDetector] pub trait MCC_CCheckerDetectorTraitConst: core::AlgorithmTraitConst { fn as_raw_MCC_CCheckerDetector(&self) -> *const c_void; @@ -1395,21 +1425,15 @@ pub mod mcc { } - /// A class to find the positions of the ColorCharts in the image. - pub struct MCC_CCheckerDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { MCC_CCheckerDetector } - - impl Drop for MCC_CCheckerDetector { + impl std::fmt::Debug for MCC_CCheckerDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_mcc_CCheckerDetector_delete(self.as_raw_mut_MCC_CCheckerDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MCC_CCheckerDetector") + .finish() } } - unsafe impl Send for MCC_CCheckerDetector {} + boxed_cast_base! { MCC_CCheckerDetector, core::Algorithm, cv_mcc_CCheckerDetector_to_Algorithm } impl core::AlgorithmTraitConst for MCC_CCheckerDetector { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1431,54 +1455,6 @@ pub mod mcc { boxed_ref! { MCC_CCheckerDetector, crate::mcc::MCC_CCheckerDetectorTraitConst, as_raw_MCC_CCheckerDetector, crate::mcc::MCC_CCheckerDetectorTrait, as_raw_mut_MCC_CCheckerDetector } - impl MCC_CCheckerDetector { - /// \brief Returns the implementation of the CCheckerDetector. - #[inline] - pub fn create() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_mcc_CCheckerDetector_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { MCC_CCheckerDetector, core::Algorithm, cv_mcc_CCheckerDetector_to_Algorithm } - - impl std::fmt::Debug for MCC_CCheckerDetector { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MCC_CCheckerDetector") - .finish() - } - } - - /// Constant methods for [crate::mcc::MCC_CCheckerDraw] - pub trait MCC_CCheckerDrawTraitConst { - fn as_raw_MCC_CCheckerDraw(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::mcc::MCC_CCheckerDraw] - pub trait MCC_CCheckerDrawTrait: crate::mcc::MCC_CCheckerDrawTraitConst { - fn as_raw_mut_MCC_CCheckerDraw(&mut self) -> *mut c_void; - - /// \brief Draws the checker to the given image. - /// \param img image in color space BGR - #[inline] - fn draw(&mut self, img: &mut impl ToInputOutputArray) -> Result<()> { - input_output_array_arg!(img); - return_send!(via ocvrs_return); - unsafe { sys::cv_mcc_CCheckerDraw_draw_const__InputOutputArrayR(self.as_raw_mut_MCC_CCheckerDraw(), img.as_raw__InputOutputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - /// \brief checker draw /// /// This class contains the functions for drawing a detected chart. This class @@ -1507,16 +1483,6 @@ pub mod mcc { unsafe impl Send for MCC_CCheckerDraw {} - impl crate::mcc::MCC_CCheckerDrawTraitConst for MCC_CCheckerDraw { - #[inline] fn as_raw_MCC_CCheckerDraw(&self) -> *const c_void { self.as_raw() } - } - - impl crate::mcc::MCC_CCheckerDrawTrait for MCC_CCheckerDraw { - #[inline] fn as_raw_mut_MCC_CCheckerDraw(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { MCC_CCheckerDraw, crate::mcc::MCC_CCheckerDrawTraitConst, as_raw_MCC_CCheckerDraw, crate::mcc::MCC_CCheckerDrawTrait, as_raw_mut_MCC_CCheckerDraw } - impl MCC_CCheckerDraw { /// \brief Create a new CCheckerDraw object. /// \param pChecker The checker which will be drawn by this object. @@ -1563,6 +1529,30 @@ pub mod mcc { } + /// Constant methods for [crate::mcc::MCC_CCheckerDraw] + pub trait MCC_CCheckerDrawTraitConst { + fn as_raw_MCC_CCheckerDraw(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::mcc::MCC_CCheckerDraw] + pub trait MCC_CCheckerDrawTrait: crate::mcc::MCC_CCheckerDrawTraitConst { + fn as_raw_mut_MCC_CCheckerDraw(&mut self) -> *mut c_void; + + /// \brief Draws the checker to the given image. + /// \param img image in color space BGR + #[inline] + fn draw(&mut self, img: &mut impl ToInputOutputArray) -> Result<()> { + input_output_array_arg!(img); + return_send!(via ocvrs_return); + unsafe { sys::cv_mcc_CCheckerDraw_draw_const__InputOutputArrayR(self.as_raw_mut_MCC_CCheckerDraw(), img.as_raw__InputOutputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + impl std::fmt::Debug for MCC_CCheckerDraw { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -1571,6 +1561,101 @@ pub mod mcc { } } + impl crate::mcc::MCC_CCheckerDrawTraitConst for MCC_CCheckerDraw { + #[inline] fn as_raw_MCC_CCheckerDraw(&self) -> *const c_void { self.as_raw() } + } + + impl crate::mcc::MCC_CCheckerDrawTrait for MCC_CCheckerDraw { + #[inline] fn as_raw_mut_MCC_CCheckerDraw(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { MCC_CCheckerDraw, crate::mcc::MCC_CCheckerDrawTraitConst, as_raw_MCC_CCheckerDraw, crate::mcc::MCC_CCheckerDrawTrait, as_raw_mut_MCC_CCheckerDraw } + + /// Parameters for the detectMarker process: + /// - int adaptiveThreshWinSizeMin : minimum window size for adaptive + /// thresholding before finding contours + /// (default 23). + /// - int adaptiveThreshWinSizeMax : maximum window size for adaptive + /// thresholding before finding contours + /// (default 153). + /// - int adaptiveThreshWinSizeStep : increments from adaptiveThreshWinSizeMin to + /// adaptiveThreshWinSizeMax during the + /// thresholding (default 16). + /// - double adaptiveThreshConstant : constant for adaptive thresholding before + /// finding contours (default 7) + /// - double minContoursAreaRate : determine minimum area for marker contour to + /// be detected. This is defined as a rate respect + /// to the area of the input image. Used only if + /// neural network is used (default 0.003). + /// - double minContoursArea : determine minimum area for marker contour to be + /// detected. This is defined as the actual area. Used + /// only if neural network is not used (default 100). + /// - double confidenceThreshold : minimum confidence for a bounding box detected + /// by neural network to classify as + /// detection.(default 0.5) + /// (0<=confidenceThreshold<=1) + /// - double minContourSolidity : minimum solidity of a contour for it be + /// detected as a square in the chart. (default + /// 0.9). + /// - double findCandidatesApproxPolyDPEpsMultiplier : multipler to be used in + /// cv::ApproxPolyDP function + /// (default 0.05) + /// - int borderWidth : width of the padding used to pass the inital neural + /// network detection in the succeeding system.(default 0) + /// - float B0factor : distance between two neighbours squares of the same chart. + /// Defined as the ratio between distance and large dimension + /// of square (default 1.25) + /// - float maxError : maximum allowed error in the detection of a chart. + /// default(0.1) + /// - int minContourPointsAllowed : minium points in a detected contour. + /// default(4) + /// - int minContourLengthAllowed : minimum length of a countour. default(100) + /// - int minInterContourDistance : minimum distance between two contours. + /// default(100) + /// - int minInterCheckerDistance : minimum distance between two checkers. + /// default(10000) + /// - int minImageSize : minimum size of the smaller dimension of the image. + /// default(1000) + /// - unsigned minGroupSize : minimum number of a squared of a chart that must be + /// detected. default(4) + pub struct MCC_DetectorParameters { + ptr: *mut c_void, + } + + opencv_type_boxed! { MCC_DetectorParameters } + + impl Drop for MCC_DetectorParameters { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_mcc_DetectorParameters_delete(self.as_raw_mut_MCC_DetectorParameters()) }; + } + } + + unsafe impl Send for MCC_DetectorParameters {} + + impl MCC_DetectorParameters { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_mcc_DetectorParameters_DetectorParameters(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::mcc::MCC_DetectorParameters::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn create() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_mcc_DetectorParameters_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::mcc::MCC_DetectorParameters] pub trait MCC_DetectorParametersTraitConst { fn as_raw_MCC_DetectorParameters(&self) -> *const c_void; @@ -1799,101 +1884,6 @@ pub mod mcc { } - /// Parameters for the detectMarker process: - /// - int adaptiveThreshWinSizeMin : minimum window size for adaptive - /// thresholding before finding contours - /// (default 23). - /// - int adaptiveThreshWinSizeMax : maximum window size for adaptive - /// thresholding before finding contours - /// (default 153). - /// - int adaptiveThreshWinSizeStep : increments from adaptiveThreshWinSizeMin to - /// adaptiveThreshWinSizeMax during the - /// thresholding (default 16). - /// - double adaptiveThreshConstant : constant for adaptive thresholding before - /// finding contours (default 7) - /// - double minContoursAreaRate : determine minimum area for marker contour to - /// be detected. This is defined as a rate respect - /// to the area of the input image. Used only if - /// neural network is used (default 0.003). - /// - double minContoursArea : determine minimum area for marker contour to be - /// detected. This is defined as the actual area. Used - /// only if neural network is not used (default 100). - /// - double confidenceThreshold : minimum confidence for a bounding box detected - /// by neural network to classify as - /// detection.(default 0.5) - /// (0<=confidenceThreshold<=1) - /// - double minContourSolidity : minimum solidity of a contour for it be - /// detected as a square in the chart. (default - /// 0.9). - /// - double findCandidatesApproxPolyDPEpsMultiplier : multipler to be used in - /// cv::ApproxPolyDP function - /// (default 0.05) - /// - int borderWidth : width of the padding used to pass the inital neural - /// network detection in the succeeding system.(default 0) - /// - float B0factor : distance between two neighbours squares of the same chart. - /// Defined as the ratio between distance and large dimension - /// of square (default 1.25) - /// - float maxError : maximum allowed error in the detection of a chart. - /// default(0.1) - /// - int minContourPointsAllowed : minium points in a detected contour. - /// default(4) - /// - int minContourLengthAllowed : minimum length of a countour. default(100) - /// - int minInterContourDistance : minimum distance between two contours. - /// default(100) - /// - int minInterCheckerDistance : minimum distance between two checkers. - /// default(10000) - /// - int minImageSize : minimum size of the smaller dimension of the image. - /// default(1000) - /// - unsigned minGroupSize : minimum number of a squared of a chart that must be - /// detected. default(4) - pub struct MCC_DetectorParameters { - ptr: *mut c_void, - } - - opencv_type_boxed! { MCC_DetectorParameters } - - impl Drop for MCC_DetectorParameters { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_mcc_DetectorParameters_delete(self.as_raw_mut_MCC_DetectorParameters()) }; - } - } - - unsafe impl Send for MCC_DetectorParameters {} - - impl crate::mcc::MCC_DetectorParametersTraitConst for MCC_DetectorParameters { - #[inline] fn as_raw_MCC_DetectorParameters(&self) -> *const c_void { self.as_raw() } - } - - impl crate::mcc::MCC_DetectorParametersTrait for MCC_DetectorParameters { - #[inline] fn as_raw_mut_MCC_DetectorParameters(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { MCC_DetectorParameters, crate::mcc::MCC_DetectorParametersTraitConst, as_raw_MCC_DetectorParameters, crate::mcc::MCC_DetectorParametersTrait, as_raw_mut_MCC_DetectorParameters } - - impl MCC_DetectorParameters { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_mcc_DetectorParameters_DetectorParameters(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::mcc::MCC_DetectorParameters::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn create() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_mcc_DetectorParameters_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - impl std::fmt::Debug for MCC_DetectorParameters { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -1919,4 +1909,15 @@ pub mod mcc { .finish() } } + + impl crate::mcc::MCC_DetectorParametersTraitConst for MCC_DetectorParameters { + #[inline] fn as_raw_MCC_DetectorParameters(&self) -> *const c_void { self.as_raw() } + } + + impl crate::mcc::MCC_DetectorParametersTrait for MCC_DetectorParameters { + #[inline] fn as_raw_mut_MCC_DetectorParameters(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { MCC_DetectorParameters, crate::mcc::MCC_DetectorParametersTraitConst, as_raw_MCC_DetectorParameters, crate::mcc::MCC_DetectorParametersTrait, as_raw_mut_MCC_DetectorParameters } + } diff --git a/docs/ml.rs b/docs/ml.rs index dfd5da0ed..36472f2d8 100644 --- a/docs/ml.rs +++ b/docs/ml.rs @@ -748,6 +748,67 @@ pub mod ml { Ok(ret) } + /// Artificial Neural Networks - Multi-Layer Perceptrons. + /// + /// Unlike many other models in ML that are constructed and trained at once, in the MLP model these + /// steps are separated. First, a network with the specified topology is created using the non-default + /// constructor or the method ANN_MLP::create. All the weights are set to zeros. Then, the network is + /// trained using a set of input and output vectors. The training procedure can be repeated more than + /// once, that is, the weights can be adjusted based on the new training data. + /// + /// Additional flags for StatModel::train are available: ANN_MLP::TrainFlags. + /// ## See also + /// [ml_intro_ann] + pub struct ANN_MLP { + ptr: *mut c_void, + } + + opencv_type_boxed! { ANN_MLP } + + impl Drop for ANN_MLP { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_ml_ANN_MLP_delete(self.as_raw_mut_ANN_MLP()) }; + } + } + + unsafe impl Send for ANN_MLP {} + + impl ANN_MLP { + /// Creates empty model + /// + /// Use StatModel::train to train the model, Algorithm::load\(filename) to load the pre-trained model. + /// Note that the train method has optional flags: ANN_MLP::TrainFlags. + #[inline] + pub fn create() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_ml_ANN_MLP_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Loads and creates a serialized ANN from a file + /// + /// Use ANN::save to serialize and store an ANN to disk. + /// Load the ANN from this file again, by calling this function with the path to the file. + /// + /// ## Parameters + /// * filepath: path to serialized ANN + #[inline] + pub fn load(filepath: &str) -> Result> { + extern_container_arg!(filepath); + return_send!(via ocvrs_return); + unsafe { sys::cv_ml_ANN_MLP_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::ml::ANN_MLP] pub trait ANN_MLPTraitConst: crate::ml::StatModelTraitConst { fn as_raw_ANN_MLP(&self) -> *const c_void; @@ -1216,31 +1277,17 @@ pub mod ml { } - /// Artificial Neural Networks - Multi-Layer Perceptrons. - /// - /// Unlike many other models in ML that are constructed and trained at once, in the MLP model these - /// steps are separated. First, a network with the specified topology is created using the non-default - /// constructor or the method ANN_MLP::create. All the weights are set to zeros. Then, the network is - /// trained using a set of input and output vectors. The training procedure can be repeated more than - /// once, that is, the weights can be adjusted based on the new training data. - /// - /// Additional flags for StatModel::train are available: ANN_MLP::TrainFlags. - /// ## See also - /// [ml_intro_ann] - pub struct ANN_MLP { - ptr: *mut c_void, - } - - opencv_type_boxed! { ANN_MLP } - - impl Drop for ANN_MLP { + impl std::fmt::Debug for ANN_MLP { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ml_ANN_MLP_delete(self.as_raw_mut_ANN_MLP()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ANN_MLP") + .finish() } } - unsafe impl Send for ANN_MLP {} + boxed_cast_base! { ANN_MLP, core::Algorithm, cv_ml_ANN_MLP_to_Algorithm } + + boxed_cast_base! { ANN_MLP, crate::ml::StatModel, cv_ml_ANN_MLP_to_StatModel } impl core::AlgorithmTraitConst for ANN_MLP { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1272,51 +1319,85 @@ pub mod ml { boxed_ref! { ANN_MLP, crate::ml::ANN_MLPTraitConst, as_raw_ANN_MLP, crate::ml::ANN_MLPTrait, as_raw_mut_ANN_MLP } - impl ANN_MLP { - /// Creates empty model - /// - /// Use StatModel::train to train the model, Algorithm::load\(filename) to load the pre-trained model. - /// Note that the train method has optional flags: ANN_MLP::TrainFlags. + /// Boosted tree classifier derived from DTrees + /// ## See also + /// [ml_intro_boost] + pub struct Boost { + ptr: *mut c_void, + } + + opencv_type_boxed! { Boost } + + impl Drop for Boost { #[inline] - pub fn create() -> Result> { + fn drop(&mut self) { + unsafe { sys::cv_ml_Boost_delete(self.as_raw_mut_Boost()) }; + } + } + + unsafe impl Send for Boost {} + + impl Boost { + /// Creates the empty model. + /// Use StatModel::train to train the model, Algorithm::load\(filename) to load the pre-trained model. + #[inline] + pub fn create() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_ml_ANN_MLP_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_Boost_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Loads and creates a serialized ANN from a file + /// Loads and creates a serialized Boost from a file /// - /// Use ANN::save to serialize and store an ANN to disk. - /// Load the ANN from this file again, by calling this function with the path to the file. + /// Use Boost::save to serialize and store an RTree to disk. + /// Load the Boost from this file again, by calling this function with the path to the file. + /// Optionally specify the node for the file containing the classifier /// /// ## Parameters - /// * filepath: path to serialized ANN + /// * filepath: path to serialized Boost + /// * nodeName: name of node containing the classifier + /// + /// ## C++ default parameters + /// * node_name: String() #[inline] - pub fn load(filepath: &str) -> Result> { + pub fn load(filepath: &str, node_name: &str) -> Result> { extern_container_arg!(filepath); + extern_container_arg!(node_name); return_send!(via ocvrs_return); - unsafe { sys::cv_ml_ANN_MLP_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_Boost_load_const_StringR_const_StringR(filepath.opencv_as_extern(), node_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { ANN_MLP, core::Algorithm, cv_ml_ANN_MLP_to_Algorithm } - - boxed_cast_base! { ANN_MLP, crate::ml::StatModel, cv_ml_ANN_MLP_to_StatModel } - - impl std::fmt::Debug for ANN_MLP { + /// Loads and creates a serialized Boost from a file + /// + /// Use Boost::save to serialize and store an RTree to disk. + /// Load the Boost from this file again, by calling this function with the path to the file. + /// Optionally specify the node for the file containing the classifier + /// + /// ## Parameters + /// * filepath: path to serialized Boost + /// * nodeName: name of node containing the classifier + /// + /// ## Note + /// This alternative version of [Boost::load] function uses the following default values for its arguments: + /// * node_name: String() #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ANN_MLP") - .finish() + pub fn load_def(filepath: &str) -> Result> { + extern_container_arg!(filepath); + return_send!(via ocvrs_return); + unsafe { sys::cv_ml_Boost_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::ml::Boost] @@ -1411,23 +1492,19 @@ pub mod ml { } - /// Boosted tree classifier derived from DTrees - /// ## See also - /// [ml_intro_boost] - pub struct Boost { - ptr: *mut c_void, - } - - opencv_type_boxed! { Boost } - - impl Drop for Boost { + impl std::fmt::Debug for Boost { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ml_Boost_delete(self.as_raw_mut_Boost()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Boost") + .finish() } } - unsafe impl Send for Boost {} + boxed_cast_base! { Boost, core::Algorithm, cv_ml_Boost_to_Algorithm } + + boxed_cast_base! { Boost, crate::ml::DTrees, cv_ml_Boost_to_DTrees } + + boxed_cast_base! { Boost, crate::ml::StatModel, cv_ml_Boost_to_StatModel } impl core::AlgorithmTraitConst for Boost { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1469,83 +1546,95 @@ pub mod ml { boxed_ref! { Boost, crate::ml::BoostTraitConst, as_raw_Boost, crate::ml::BoostTrait, as_raw_mut_Boost } - impl Boost { - /// Creates the empty model. - /// Use StatModel::train to train the model, Algorithm::load\(filename) to load the pre-trained model. + /// The class represents a single decision tree or a collection of decision trees. + /// + /// The current public interface of the class allows user to train only a single decision tree, however + /// the class is capable of storing multiple decision trees and using them for prediction (by summing + /// responses or using a voting schemes), and the derived from DTrees classes (such as RTrees and Boost) + /// use this capability to implement decision tree ensembles. + /// ## See also + /// [ml_intro_trees] + pub struct DTrees { + ptr: *mut c_void, + } + + opencv_type_boxed! { DTrees } + + impl Drop for DTrees { #[inline] - pub fn create() -> Result> { + fn drop(&mut self) { + unsafe { sys::cv_ml_DTrees_delete(self.as_raw_mut_DTrees()) }; + } + } + + unsafe impl Send for DTrees {} + + impl DTrees { + /// Creates the empty model + /// + /// The static method creates empty decision tree with the specified parameters. It should be then + /// trained using train method (see StatModel::train). Alternatively, you can load the model from + /// file using Algorithm::load\(filename). + #[inline] + pub fn create() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_ml_Boost_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_DTrees_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Loads and creates a serialized Boost from a file + /// Loads and creates a serialized DTrees from a file /// - /// Use Boost::save to serialize and store an RTree to disk. - /// Load the Boost from this file again, by calling this function with the path to the file. + /// Use DTree::save to serialize and store an DTree to disk. + /// Load the DTree from this file again, by calling this function with the path to the file. /// Optionally specify the node for the file containing the classifier /// /// ## Parameters - /// * filepath: path to serialized Boost + /// * filepath: path to serialized DTree /// * nodeName: name of node containing the classifier /// /// ## C++ default parameters /// * node_name: String() #[inline] - pub fn load(filepath: &str, node_name: &str) -> Result> { + pub fn load(filepath: &str, node_name: &str) -> Result> { extern_container_arg!(filepath); extern_container_arg!(node_name); return_send!(via ocvrs_return); - unsafe { sys::cv_ml_Boost_load_const_StringR_const_StringR(filepath.opencv_as_extern(), node_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_DTrees_load_const_StringR_const_StringR(filepath.opencv_as_extern(), node_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Loads and creates a serialized Boost from a file + /// Loads and creates a serialized DTrees from a file /// - /// Use Boost::save to serialize and store an RTree to disk. - /// Load the Boost from this file again, by calling this function with the path to the file. + /// Use DTree::save to serialize and store an DTree to disk. + /// Load the DTree from this file again, by calling this function with the path to the file. /// Optionally specify the node for the file containing the classifier /// /// ## Parameters - /// * filepath: path to serialized Boost + /// * filepath: path to serialized DTree /// * nodeName: name of node containing the classifier /// /// ## Note - /// This alternative version of [Boost::load] function uses the following default values for its arguments: + /// This alternative version of [DTrees::load] function uses the following default values for its arguments: /// * node_name: String() #[inline] - pub fn load_def(filepath: &str) -> Result> { + pub fn load_def(filepath: &str) -> Result> { extern_container_arg!(filepath); return_send!(via ocvrs_return); - unsafe { sys::cv_ml_Boost_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_DTrees_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { Boost, core::Algorithm, cv_ml_Boost_to_Algorithm } - - boxed_cast_base! { Boost, crate::ml::DTrees, cv_ml_Boost_to_DTrees } - - boxed_cast_base! { Boost, crate::ml::StatModel, cv_ml_Boost_to_StatModel } - - impl std::fmt::Debug for Boost { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Boost") - .finish() - } - } - /// Constant methods for [crate::ml::DTrees] pub trait DTreesTraitConst: crate::ml::StatModelTraitConst { fn as_raw_DTrees(&self) -> *const c_void; @@ -1911,28 +2000,21 @@ pub mod ml { } - /// The class represents a single decision tree or a collection of decision trees. - /// - /// The current public interface of the class allows user to train only a single decision tree, however - /// the class is capable of storing multiple decision trees and using them for prediction (by summing - /// responses or using a voting schemes), and the derived from DTrees classes (such as RTrees and Boost) - /// use this capability to implement decision tree ensembles. - /// ## See also - /// [ml_intro_trees] - pub struct DTrees { - ptr: *mut c_void, - } - - opencv_type_boxed! { DTrees } - - impl Drop for DTrees { + impl std::fmt::Debug for DTrees { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ml_DTrees_delete(self.as_raw_mut_DTrees()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DTrees") + .finish() } } - unsafe impl Send for DTrees {} + boxed_cast_base! { DTrees, core::Algorithm, cv_ml_DTrees_to_Algorithm } + + boxed_cast_base! { DTrees, crate::ml::StatModel, cv_ml_DTrees_to_StatModel } + + boxed_cast_descendant! { DTrees, crate::ml::Boost, cv_ml_DTrees_to_Boost } + + boxed_cast_descendant! { DTrees, crate::ml::RTrees, cv_ml_DTrees_to_RTrees } impl core::AlgorithmTraitConst for DTrees { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1964,88 +2046,35 @@ pub mod ml { boxed_ref! { DTrees, crate::ml::DTreesTraitConst, as_raw_DTrees, crate::ml::DTreesTrait, as_raw_mut_DTrees } - impl DTrees { - /// Creates the empty model - /// - /// The static method creates empty decision tree with the specified parameters. It should be then - /// trained using train method (see StatModel::train). Alternatively, you can load the model from - /// file using Algorithm::load\(filename). - #[inline] - pub fn create() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_ml_DTrees_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } + /// The class represents a decision tree node. + pub struct DTrees_Node { + ptr: *mut c_void, + } - /// Loads and creates a serialized DTrees from a file - /// - /// Use DTree::save to serialize and store an DTree to disk. - /// Load the DTree from this file again, by calling this function with the path to the file. - /// Optionally specify the node for the file containing the classifier - /// - /// ## Parameters - /// * filepath: path to serialized DTree - /// * nodeName: name of node containing the classifier - /// - /// ## C++ default parameters - /// * node_name: String() + opencv_type_boxed! { DTrees_Node } + + impl Drop for DTrees_Node { #[inline] - pub fn load(filepath: &str, node_name: &str) -> Result> { - extern_container_arg!(filepath); - extern_container_arg!(node_name); - return_send!(via ocvrs_return); - unsafe { sys::cv_ml_DTrees_load_const_StringR_const_StringR(filepath.opencv_as_extern(), node_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_ml_DTrees_Node_delete(self.as_raw_mut_DTrees_Node()) }; } + } - /// Loads and creates a serialized DTrees from a file - /// - /// Use DTree::save to serialize and store an DTree to disk. - /// Load the DTree from this file again, by calling this function with the path to the file. - /// Optionally specify the node for the file containing the classifier - /// - /// ## Parameters - /// * filepath: path to serialized DTree - /// * nodeName: name of node containing the classifier - /// - /// ## Note - /// This alternative version of [DTrees::load] function uses the following default values for its arguments: - /// * node_name: String() + unsafe impl Send for DTrees_Node {} + + impl DTrees_Node { #[inline] - pub fn load_def(filepath: &str) -> Result> { - extern_container_arg!(filepath); + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ml_DTrees_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_DTrees_Node_Node(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::ml::DTrees_Node::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_descendant! { DTrees, crate::ml::Boost, cv_ml_DTrees_to_Boost } - - boxed_cast_descendant! { DTrees, crate::ml::RTrees, cv_ml_DTrees_to_RTrees } - - boxed_cast_base! { DTrees, core::Algorithm, cv_ml_DTrees_to_Algorithm } - - boxed_cast_base! { DTrees, crate::ml::StatModel, cv_ml_DTrees_to_StatModel } - - impl std::fmt::Debug for DTrees { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DTrees") - .finish() - } - } - /// Constant methods for [crate::ml::DTrees_Node] pub trait DTrees_NodeTraitConst { fn as_raw_DTrees_Node(&self) -> *const c_void; @@ -2162,22 +2191,21 @@ pub mod ml { } - /// The class represents a decision tree node. - pub struct DTrees_Node { - ptr: *mut c_void, - } - - opencv_type_boxed! { DTrees_Node } - - impl Drop for DTrees_Node { + impl std::fmt::Debug for DTrees_Node { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ml_DTrees_Node_delete(self.as_raw_mut_DTrees_Node()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DTrees_Node") + .field("value", &crate::ml::DTrees_NodeTraitConst::value(self)) + .field("class_idx", &crate::ml::DTrees_NodeTraitConst::class_idx(self)) + .field("parent", &crate::ml::DTrees_NodeTraitConst::parent(self)) + .field("left", &crate::ml::DTrees_NodeTraitConst::left(self)) + .field("right", &crate::ml::DTrees_NodeTraitConst::right(self)) + .field("default_dir", &crate::ml::DTrees_NodeTraitConst::default_dir(self)) + .field("split", &crate::ml::DTrees_NodeTraitConst::split(self)) + .finish() } } - unsafe impl Send for DTrees_Node {} - impl crate::ml::DTrees_NodeTraitConst for DTrees_Node { #[inline] fn as_raw_DTrees_Node(&self) -> *const c_void { self.as_raw() } } @@ -2188,34 +2216,35 @@ pub mod ml { boxed_ref! { DTrees_Node, crate::ml::DTrees_NodeTraitConst, as_raw_DTrees_Node, crate::ml::DTrees_NodeTrait, as_raw_mut_DTrees_Node } - impl DTrees_Node { + /// The class represents split in a decision tree. + pub struct DTrees_Split { + ptr: *mut c_void, + } + + opencv_type_boxed! { DTrees_Split } + + impl Drop for DTrees_Split { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_ml_DTrees_Split_delete(self.as_raw_mut_DTrees_Split()) }; + } + } + + unsafe impl Send for DTrees_Split {} + + impl DTrees_Split { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ml_DTrees_Node_Node(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_DTrees_Split_Split(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::ml::DTrees_Node::opencv_from_extern(ret) }; + let ret = unsafe { crate::ml::DTrees_Split::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for DTrees_Node { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DTrees_Node") - .field("value", &crate::ml::DTrees_NodeTraitConst::value(self)) - .field("class_idx", &crate::ml::DTrees_NodeTraitConst::class_idx(self)) - .field("parent", &crate::ml::DTrees_NodeTraitConst::parent(self)) - .field("left", &crate::ml::DTrees_NodeTraitConst::left(self)) - .field("right", &crate::ml::DTrees_NodeTraitConst::right(self)) - .field("default_dir", &crate::ml::DTrees_NodeTraitConst::default_dir(self)) - .field("split", &crate::ml::DTrees_NodeTraitConst::split(self)) - .finish() - } - } - /// Constant methods for [crate::ml::DTrees_Split] pub trait DTrees_SplitTraitConst { fn as_raw_DTrees_Split(&self) -> *const c_void; @@ -2342,22 +2371,20 @@ pub mod ml { } - /// The class represents split in a decision tree. - pub struct DTrees_Split { - ptr: *mut c_void, - } - - opencv_type_boxed! { DTrees_Split } - - impl Drop for DTrees_Split { + impl std::fmt::Debug for DTrees_Split { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ml_DTrees_Split_delete(self.as_raw_mut_DTrees_Split()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DTrees_Split") + .field("var_idx", &crate::ml::DTrees_SplitTraitConst::var_idx(self)) + .field("inversed", &crate::ml::DTrees_SplitTraitConst::inversed(self)) + .field("quality", &crate::ml::DTrees_SplitTraitConst::quality(self)) + .field("next", &crate::ml::DTrees_SplitTraitConst::next(self)) + .field("c", &crate::ml::DTrees_SplitTraitConst::c(self)) + .field("subset_ofs", &crate::ml::DTrees_SplitTraitConst::subset_ofs(self)) + .finish() } } - unsafe impl Send for DTrees_Split {} - impl crate::ml::DTrees_SplitTraitConst for DTrees_Split { #[inline] fn as_raw_DTrees_Split(&self) -> *const c_void { self.as_raw() } } @@ -2368,39 +2395,94 @@ pub mod ml { boxed_ref! { DTrees_Split, crate::ml::DTrees_SplitTraitConst, as_raw_DTrees_Split, crate::ml::DTrees_SplitTrait, as_raw_mut_DTrees_Split } - impl DTrees_Split { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ml_DTrees_Split_Split(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::ml::DTrees_Split::opencv_from_extern(ret) }; - Ok(ret) - } - + /// The class implements the Expectation Maximization algorithm. + /// ## See also + /// [ml_intro_em] + pub struct EM { + ptr: *mut c_void, } - impl std::fmt::Debug for DTrees_Split { + opencv_type_boxed! { EM } + + impl Drop for EM { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DTrees_Split") - .field("var_idx", &crate::ml::DTrees_SplitTraitConst::var_idx(self)) - .field("inversed", &crate::ml::DTrees_SplitTraitConst::inversed(self)) - .field("quality", &crate::ml::DTrees_SplitTraitConst::quality(self)) - .field("next", &crate::ml::DTrees_SplitTraitConst::next(self)) - .field("c", &crate::ml::DTrees_SplitTraitConst::c(self)) - .field("subset_ofs", &crate::ml::DTrees_SplitTraitConst::subset_ofs(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ml_EM_delete(self.as_raw_mut_EM()) }; } } - /// Constant methods for [crate::ml::EM] - pub trait EMTraitConst: crate::ml::StatModelTraitConst { - fn as_raw_EM(&self) -> *const c_void; + unsafe impl Send for EM {} - /// The number of mixture components in the Gaussian mixture model. - /// Default value of the parameter is EM::DEFAULT_NCLUSTERS=5. Some of %EM implementation could + impl EM { + /// Creates empty %EM model. + /// The model should be trained then using StatModel::train(traindata, flags) method. Alternatively, you + /// can use one of the EM::train\* methods or load it from file using Algorithm::load\(filename). + #[inline] + pub fn create() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_ml_EM_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Loads and creates a serialized EM from a file + /// + /// Use EM::save to serialize and store an EM to disk. + /// Load the EM from this file again, by calling this function with the path to the file. + /// Optionally specify the node for the file containing the classifier + /// + /// ## Parameters + /// * filepath: path to serialized EM + /// * nodeName: name of node containing the classifier + /// + /// ## C++ default parameters + /// * node_name: String() + #[inline] + pub fn load(filepath: &str, node_name: &str) -> Result> { + extern_container_arg!(filepath); + extern_container_arg!(node_name); + return_send!(via ocvrs_return); + unsafe { sys::cv_ml_EM_load_const_StringR_const_StringR(filepath.opencv_as_extern(), node_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Loads and creates a serialized EM from a file + /// + /// Use EM::save to serialize and store an EM to disk. + /// Load the EM from this file again, by calling this function with the path to the file. + /// Optionally specify the node for the file containing the classifier + /// + /// ## Parameters + /// * filepath: path to serialized EM + /// * nodeName: name of node containing the classifier + /// + /// ## Note + /// This alternative version of [EM::load] function uses the following default values for its arguments: + /// * node_name: String() + #[inline] + pub fn load_def(filepath: &str) -> Result> { + extern_container_arg!(filepath); + return_send!(via ocvrs_return); + unsafe { sys::cv_ml_EM_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::ml::EM] + pub trait EMTraitConst: crate::ml::StatModelTraitConst { + fn as_raw_EM(&self) -> *const c_void; + + /// The number of mixture components in the Gaussian mixture model. + /// Default value of the parameter is EM::DEFAULT_NCLUSTERS=5. Some of %EM implementation could /// determine the optimal number of mixtures within a specified value range, but that is not the /// case in ML yet. /// ## See also @@ -2858,23 +2940,17 @@ pub mod ml { } - /// The class implements the Expectation Maximization algorithm. - /// ## See also - /// [ml_intro_em] - pub struct EM { - ptr: *mut c_void, - } - - opencv_type_boxed! { EM } - - impl Drop for EM { + impl std::fmt::Debug for EM { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ml_EM_delete(self.as_raw_mut_EM()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("EM") + .finish() } } - unsafe impl Send for EM {} + boxed_cast_base! { EM, core::Algorithm, cv_ml_EM_to_Algorithm } + + boxed_cast_base! { EM, crate::ml::StatModel, cv_ml_EM_to_StatModel } impl core::AlgorithmTraitConst for EM { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2906,82 +2982,58 @@ pub mod ml { boxed_ref! { EM, crate::ml::EMTraitConst, as_raw_EM, crate::ml::EMTrait, as_raw_mut_EM } - impl EM { - /// Creates empty %EM model. - /// The model should be trained then using StatModel::train(traindata, flags) method. Alternatively, you - /// can use one of the EM::train\* methods or load it from file using Algorithm::load\(filename). + /// The class implements K-Nearest Neighbors model + /// ## See also + /// [ml_intro_knn] + pub struct KNearest { + ptr: *mut c_void, + } + + opencv_type_boxed! { KNearest } + + impl Drop for KNearest { #[inline] - pub fn create() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_ml_EM_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_ml_KNearest_delete(self.as_raw_mut_KNearest()) }; } + } - /// Loads and creates a serialized EM from a file - /// - /// Use EM::save to serialize and store an EM to disk. - /// Load the EM from this file again, by calling this function with the path to the file. - /// Optionally specify the node for the file containing the classifier - /// - /// ## Parameters - /// * filepath: path to serialized EM - /// * nodeName: name of node containing the classifier + unsafe impl Send for KNearest {} + + impl KNearest { + /// Creates the empty model /// - /// ## C++ default parameters - /// * node_name: String() + /// The static method creates empty %KNearest classifier. It should be then trained using StatModel::train method. #[inline] - pub fn load(filepath: &str, node_name: &str) -> Result> { - extern_container_arg!(filepath); - extern_container_arg!(node_name); + pub fn create() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_ml_EM_load_const_StringR_const_StringR(filepath.opencv_as_extern(), node_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_KNearest_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Loads and creates a serialized EM from a file + /// Loads and creates a serialized knearest from a file /// - /// Use EM::save to serialize and store an EM to disk. - /// Load the EM from this file again, by calling this function with the path to the file. - /// Optionally specify the node for the file containing the classifier + /// Use KNearest::save to serialize and store an KNearest to disk. + /// Load the KNearest from this file again, by calling this function with the path to the file. /// /// ## Parameters - /// * filepath: path to serialized EM - /// * nodeName: name of node containing the classifier - /// - /// ## Note - /// This alternative version of [EM::load] function uses the following default values for its arguments: - /// * node_name: String() + /// * filepath: path to serialized KNearest #[inline] - pub fn load_def(filepath: &str) -> Result> { + pub fn load(filepath: &str) -> Result> { extern_container_arg!(filepath); return_send!(via ocvrs_return); - unsafe { sys::cv_ml_EM_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_KNearest_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { EM, core::Algorithm, cv_ml_EM_to_Algorithm } - - boxed_cast_base! { EM, crate::ml::StatModel, cv_ml_EM_to_StatModel } - - impl std::fmt::Debug for EM { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("EM") - .finish() - } - } - /// Constant methods for [crate::ml::KNearest] pub trait KNearestTraitConst: crate::ml::StatModelTraitConst { fn as_raw_KNearest(&self) -> *const c_void; @@ -3175,23 +3227,17 @@ pub mod ml { } - /// The class implements K-Nearest Neighbors model - /// ## See also - /// [ml_intro_knn] - pub struct KNearest { - ptr: *mut c_void, - } - - opencv_type_boxed! { KNearest } - - impl Drop for KNearest { + impl std::fmt::Debug for KNearest { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ml_KNearest_delete(self.as_raw_mut_KNearest()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("KNearest") + .finish() } } - unsafe impl Send for KNearest {} + boxed_cast_base! { KNearest, core::Algorithm, cv_ml_KNearest_to_Algorithm } + + boxed_cast_base! { KNearest, crate::ml::StatModel, cv_ml_KNearest_to_StatModel } impl core::AlgorithmTraitConst for KNearest { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3223,54 +3269,90 @@ pub mod ml { boxed_ref! { KNearest, crate::ml::KNearestTraitConst, as_raw_KNearest, crate::ml::KNearestTrait, as_raw_mut_KNearest } - impl KNearest { - /// Creates the empty model + /// Implements Logistic Regression classifier. + /// ## See also + /// [ml_intro_lr] + pub struct LogisticRegression { + ptr: *mut c_void, + } + + opencv_type_boxed! { LogisticRegression } + + impl Drop for LogisticRegression { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_ml_LogisticRegression_delete(self.as_raw_mut_LogisticRegression()) }; + } + } + + unsafe impl Send for LogisticRegression {} + + impl LogisticRegression { + /// Creates empty model. /// - /// The static method creates empty %KNearest classifier. It should be then trained using StatModel::train method. + /// Creates Logistic Regression model with parameters given. #[inline] - pub fn create() -> Result> { + pub fn create() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_ml_KNearest_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_LogisticRegression_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Loads and creates a serialized knearest from a file + /// Loads and creates a serialized LogisticRegression from a file /// - /// Use KNearest::save to serialize and store an KNearest to disk. - /// Load the KNearest from this file again, by calling this function with the path to the file. + /// Use LogisticRegression::save to serialize and store an LogisticRegression to disk. + /// Load the LogisticRegression from this file again, by calling this function with the path to the file. + /// Optionally specify the node for the file containing the classifier /// /// ## Parameters - /// * filepath: path to serialized KNearest + /// * filepath: path to serialized LogisticRegression + /// * nodeName: name of node containing the classifier + /// + /// ## C++ default parameters + /// * node_name: String() #[inline] - pub fn load(filepath: &str) -> Result> { + pub fn load(filepath: &str, node_name: &str) -> Result> { extern_container_arg!(filepath); + extern_container_arg!(node_name); return_send!(via ocvrs_return); - unsafe { sys::cv_ml_KNearest_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_LogisticRegression_load_const_StringR_const_StringR(filepath.opencv_as_extern(), node_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { KNearest, core::Algorithm, cv_ml_KNearest_to_Algorithm } - - boxed_cast_base! { KNearest, crate::ml::StatModel, cv_ml_KNearest_to_StatModel } - - impl std::fmt::Debug for KNearest { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("KNearest") - .finish() - } - } - - /// Constant methods for [crate::ml::LogisticRegression] - pub trait LogisticRegressionTraitConst: crate::ml::StatModelTraitConst { + /// Loads and creates a serialized LogisticRegression from a file + /// + /// Use LogisticRegression::save to serialize and store an LogisticRegression to disk. + /// Load the LogisticRegression from this file again, by calling this function with the path to the file. + /// Optionally specify the node for the file containing the classifier + /// + /// ## Parameters + /// * filepath: path to serialized LogisticRegression + /// * nodeName: name of node containing the classifier + /// + /// ## Note + /// This alternative version of [LogisticRegression::load] function uses the following default values for its arguments: + /// * node_name: String() + #[inline] + pub fn load_def(filepath: &str) -> Result> { + extern_container_arg!(filepath); + return_send!(via ocvrs_return); + unsafe { sys::cv_ml_LogisticRegression_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::ml::LogisticRegression] + pub trait LogisticRegressionTraitConst: crate::ml::StatModelTraitConst { fn as_raw_LogisticRegression(&self) -> *const c_void; /// Learning rate. @@ -3487,23 +3569,17 @@ pub mod ml { } - /// Implements Logistic Regression classifier. - /// ## See also - /// [ml_intro_lr] - pub struct LogisticRegression { - ptr: *mut c_void, - } - - opencv_type_boxed! { LogisticRegression } - - impl Drop for LogisticRegression { + impl std::fmt::Debug for LogisticRegression { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ml_LogisticRegression_delete(self.as_raw_mut_LogisticRegression()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LogisticRegression") + .finish() } } - unsafe impl Send for LogisticRegression {} + boxed_cast_base! { LogisticRegression, core::Algorithm, cv_ml_LogisticRegression_to_Algorithm } + + boxed_cast_base! { LogisticRegression, crate::ml::StatModel, cv_ml_LogisticRegression_to_StatModel } impl core::AlgorithmTraitConst for LogisticRegression { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3535,82 +3611,87 @@ pub mod ml { boxed_ref! { LogisticRegression, crate::ml::LogisticRegressionTraitConst, as_raw_LogisticRegression, crate::ml::LogisticRegressionTrait, as_raw_mut_LogisticRegression } - impl LogisticRegression { - /// Creates empty model. - /// - /// Creates Logistic Regression model with parameters given. + /// Bayes classifier for normally distributed data. + /// ## See also + /// [ml_intro_bayes] + pub struct NormalBayesClassifier { + ptr: *mut c_void, + } + + opencv_type_boxed! { NormalBayesClassifier } + + impl Drop for NormalBayesClassifier { #[inline] - pub fn create() -> Result> { + fn drop(&mut self) { + unsafe { sys::cv_ml_NormalBayesClassifier_delete(self.as_raw_mut_NormalBayesClassifier()) }; + } + } + + unsafe impl Send for NormalBayesClassifier {} + + impl NormalBayesClassifier { + /// Creates empty model + /// Use StatModel::train to train the model after creation. + #[inline] + pub fn create() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_ml_LogisticRegression_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_NormalBayesClassifier_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Loads and creates a serialized LogisticRegression from a file + /// Loads and creates a serialized NormalBayesClassifier from a file /// - /// Use LogisticRegression::save to serialize and store an LogisticRegression to disk. - /// Load the LogisticRegression from this file again, by calling this function with the path to the file. + /// Use NormalBayesClassifier::save to serialize and store an NormalBayesClassifier to disk. + /// Load the NormalBayesClassifier from this file again, by calling this function with the path to the file. /// Optionally specify the node for the file containing the classifier /// /// ## Parameters - /// * filepath: path to serialized LogisticRegression + /// * filepath: path to serialized NormalBayesClassifier /// * nodeName: name of node containing the classifier /// /// ## C++ default parameters /// * node_name: String() #[inline] - pub fn load(filepath: &str, node_name: &str) -> Result> { + pub fn load(filepath: &str, node_name: &str) -> Result> { extern_container_arg!(filepath); extern_container_arg!(node_name); return_send!(via ocvrs_return); - unsafe { sys::cv_ml_LogisticRegression_load_const_StringR_const_StringR(filepath.opencv_as_extern(), node_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_NormalBayesClassifier_load_const_StringR_const_StringR(filepath.opencv_as_extern(), node_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Loads and creates a serialized LogisticRegression from a file + /// Loads and creates a serialized NormalBayesClassifier from a file /// - /// Use LogisticRegression::save to serialize and store an LogisticRegression to disk. - /// Load the LogisticRegression from this file again, by calling this function with the path to the file. + /// Use NormalBayesClassifier::save to serialize and store an NormalBayesClassifier to disk. + /// Load the NormalBayesClassifier from this file again, by calling this function with the path to the file. /// Optionally specify the node for the file containing the classifier /// /// ## Parameters - /// * filepath: path to serialized LogisticRegression + /// * filepath: path to serialized NormalBayesClassifier /// * nodeName: name of node containing the classifier /// /// ## Note - /// This alternative version of [LogisticRegression::load] function uses the following default values for its arguments: + /// This alternative version of [NormalBayesClassifier::load] function uses the following default values for its arguments: /// * node_name: String() #[inline] - pub fn load_def(filepath: &str) -> Result> { + pub fn load_def(filepath: &str) -> Result> { extern_container_arg!(filepath); return_send!(via ocvrs_return); - unsafe { sys::cv_ml_LogisticRegression_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_NormalBayesClassifier_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { LogisticRegression, core::Algorithm, cv_ml_LogisticRegression_to_Algorithm } - - boxed_cast_base! { LogisticRegression, crate::ml::StatModel, cv_ml_LogisticRegression_to_StatModel } - - impl std::fmt::Debug for LogisticRegression { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LogisticRegression") - .finish() - } - } - /// Constant methods for [crate::ml::NormalBayesClassifier] pub trait NormalBayesClassifierTraitConst: crate::ml::StatModelTraitConst { fn as_raw_NormalBayesClassifier(&self) -> *const c_void; @@ -3668,23 +3749,17 @@ pub mod ml { } - /// Bayes classifier for normally distributed data. - /// ## See also - /// [ml_intro_bayes] - pub struct NormalBayesClassifier { - ptr: *mut c_void, - } - - opencv_type_boxed! { NormalBayesClassifier } - - impl Drop for NormalBayesClassifier { + impl std::fmt::Debug for NormalBayesClassifier { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ml_NormalBayesClassifier_delete(self.as_raw_mut_NormalBayesClassifier()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("NormalBayesClassifier") + .finish() } } - unsafe impl Send for NormalBayesClassifier {} + boxed_cast_base! { NormalBayesClassifier, core::Algorithm, cv_ml_NormalBayesClassifier_to_Algorithm } + + boxed_cast_base! { NormalBayesClassifier, crate::ml::StatModel, cv_ml_NormalBayesClassifier_to_StatModel } impl core::AlgorithmTraitConst for NormalBayesClassifier { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3716,81 +3791,93 @@ pub mod ml { boxed_ref! { NormalBayesClassifier, crate::ml::NormalBayesClassifierTraitConst, as_raw_NormalBayesClassifier, crate::ml::NormalBayesClassifierTrait, as_raw_mut_NormalBayesClassifier } - impl NormalBayesClassifier { - /// Creates empty model - /// Use StatModel::train to train the model after creation. + /// The structure represents the logarithmic grid range of statmodel parameters. + /// + /// It is used for optimizing statmodel accuracy by varying model parameters, the accuracy estimate + /// being computed by cross-validation. + pub struct ParamGrid { + ptr: *mut c_void, + } + + opencv_type_boxed! { ParamGrid } + + impl Drop for ParamGrid { #[inline] - pub fn create() -> Result> { + fn drop(&mut self) { + unsafe { sys::cv_ml_ParamGrid_delete(self.as_raw_mut_ParamGrid()) }; + } + } + + unsafe impl Send for ParamGrid {} + + impl ParamGrid { + /// Default constructor + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ml_NormalBayesClassifier_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_ParamGrid_ParamGrid(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::ml::ParamGrid::opencv_from_extern(ret) }; Ok(ret) } - /// Loads and creates a serialized NormalBayesClassifier from a file - /// - /// Use NormalBayesClassifier::save to serialize and store an NormalBayesClassifier to disk. - /// Load the NormalBayesClassifier from this file again, by calling this function with the path to the file. - /// Optionally specify the node for the file containing the classifier + /// Constructor with parameters + #[inline] + pub fn for_range(_min_val: f64, _max_val: f64, _log_step: f64) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ml_ParamGrid_ParamGrid_double_double_double(_min_val, _max_val, _log_step, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::ml::ParamGrid::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Creates a ParamGrid Ptr that can be given to the %SVM::trainAuto method /// /// ## Parameters - /// * filepath: path to serialized NormalBayesClassifier - /// * nodeName: name of node containing the classifier + /// * minVal: minimum value of the parameter grid + /// * maxVal: maximum value of the parameter grid + /// * logstep: Logarithmic step for iterating the statmodel parameter /// /// ## C++ default parameters - /// * node_name: String() + /// * min_val: 0. + /// * max_val: 0. + /// * logstep: 1. #[inline] - pub fn load(filepath: &str, node_name: &str) -> Result> { - extern_container_arg!(filepath); - extern_container_arg!(node_name); + pub fn create(min_val: f64, max_val: f64, logstep: f64) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_ml_NormalBayesClassifier_load_const_StringR_const_StringR(filepath.opencv_as_extern(), node_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_ParamGrid_create_double_double_double(min_val, max_val, logstep, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Loads and creates a serialized NormalBayesClassifier from a file - /// - /// Use NormalBayesClassifier::save to serialize and store an NormalBayesClassifier to disk. - /// Load the NormalBayesClassifier from this file again, by calling this function with the path to the file. - /// Optionally specify the node for the file containing the classifier + /// Creates a ParamGrid Ptr that can be given to the %SVM::trainAuto method /// /// ## Parameters - /// * filepath: path to serialized NormalBayesClassifier - /// * nodeName: name of node containing the classifier + /// * minVal: minimum value of the parameter grid + /// * maxVal: maximum value of the parameter grid + /// * logstep: Logarithmic step for iterating the statmodel parameter /// /// ## Note - /// This alternative version of [NormalBayesClassifier::load] function uses the following default values for its arguments: - /// * node_name: String() + /// This alternative version of [ParamGrid::create] function uses the following default values for its arguments: + /// * min_val: 0. + /// * max_val: 0. + /// * logstep: 1. #[inline] - pub fn load_def(filepath: &str) -> Result> { - extern_container_arg!(filepath); + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_ml_NormalBayesClassifier_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_ParamGrid_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { NormalBayesClassifier, core::Algorithm, cv_ml_NormalBayesClassifier_to_Algorithm } - - boxed_cast_base! { NormalBayesClassifier, crate::ml::StatModel, cv_ml_NormalBayesClassifier_to_StatModel } - - impl std::fmt::Debug for NormalBayesClassifier { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("NormalBayesClassifier") - .finish() - } - } - /// Constant methods for [crate::ml::ParamGrid] pub trait ParamGridTraitConst { fn as_raw_ParamGrid(&self) -> *const c_void; @@ -3857,25 +3944,17 @@ pub mod ml { } - /// The structure represents the logarithmic grid range of statmodel parameters. - /// - /// It is used for optimizing statmodel accuracy by varying model parameters, the accuracy estimate - /// being computed by cross-validation. - pub struct ParamGrid { - ptr: *mut c_void, + impl std::fmt::Debug for ParamGrid { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ParamGrid") + .field("min_val", &crate::ml::ParamGridTraitConst::min_val(self)) + .field("max_val", &crate::ml::ParamGridTraitConst::max_val(self)) + .field("log_step", &crate::ml::ParamGridTraitConst::log_step(self)) + .finish() + } } - opencv_type_boxed! { ParamGrid } - - impl Drop for ParamGrid { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ml_ParamGrid_delete(self.as_raw_mut_ParamGrid()) }; - } - } - - unsafe impl Send for ParamGrid {} - impl crate::ml::ParamGridTraitConst for ParamGrid { #[inline] fn as_raw_ParamGrid(&self) -> *const c_void { self.as_raw() } } @@ -3886,85 +3965,88 @@ pub mod ml { boxed_ref! { ParamGrid, crate::ml::ParamGridTraitConst, as_raw_ParamGrid, crate::ml::ParamGridTrait, as_raw_mut_ParamGrid } - impl ParamGrid { - /// Default constructor + /// The class implements the random forest predictor. + /// ## See also + /// [ml_intro_rtrees] + pub struct RTrees { + ptr: *mut c_void, + } + + opencv_type_boxed! { RTrees } + + impl Drop for RTrees { #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ml_ParamGrid_ParamGrid(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::ml::ParamGrid::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_ml_RTrees_delete(self.as_raw_mut_RTrees()) }; } + } - /// Constructor with parameters + unsafe impl Send for RTrees {} + + impl RTrees { + /// Creates the empty model. + /// Use StatModel::train to train the model, StatModel::train to create and train the model, + /// Algorithm::load to load the pre-trained model. #[inline] - pub fn for_range(_min_val: f64, _max_val: f64, _log_step: f64) -> Result { + pub fn create() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_ml_ParamGrid_ParamGrid_double_double_double(_min_val, _max_val, _log_step, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_RTrees_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::ml::ParamGrid::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Creates a ParamGrid Ptr that can be given to the %SVM::trainAuto method + /// Loads and creates a serialized RTree from a file + /// + /// Use RTree::save to serialize and store an RTree to disk. + /// Load the RTree from this file again, by calling this function with the path to the file. + /// Optionally specify the node for the file containing the classifier /// /// ## Parameters - /// * minVal: minimum value of the parameter grid - /// * maxVal: maximum value of the parameter grid - /// * logstep: Logarithmic step for iterating the statmodel parameter + /// * filepath: path to serialized RTree + /// * nodeName: name of node containing the classifier /// /// ## C++ default parameters - /// * min_val: 0. - /// * max_val: 0. - /// * logstep: 1. + /// * node_name: String() #[inline] - pub fn create(min_val: f64, max_val: f64, logstep: f64) -> Result> { + pub fn load(filepath: &str, node_name: &str) -> Result> { + extern_container_arg!(filepath); + extern_container_arg!(node_name); return_send!(via ocvrs_return); - unsafe { sys::cv_ml_ParamGrid_create_double_double_double(min_val, max_val, logstep, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_RTrees_load_const_StringR_const_StringR(filepath.opencv_as_extern(), node_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Creates a ParamGrid Ptr that can be given to the %SVM::trainAuto method + /// Loads and creates a serialized RTree from a file + /// + /// Use RTree::save to serialize and store an RTree to disk. + /// Load the RTree from this file again, by calling this function with the path to the file. + /// Optionally specify the node for the file containing the classifier /// /// ## Parameters - /// * minVal: minimum value of the parameter grid - /// * maxVal: maximum value of the parameter grid - /// * logstep: Logarithmic step for iterating the statmodel parameter + /// * filepath: path to serialized RTree + /// * nodeName: name of node containing the classifier /// /// ## Note - /// This alternative version of [ParamGrid::create] function uses the following default values for its arguments: - /// * min_val: 0. - /// * max_val: 0. - /// * logstep: 1. + /// This alternative version of [RTrees::load] function uses the following default values for its arguments: + /// * node_name: String() #[inline] - pub fn create_def() -> Result> { + pub fn load_def(filepath: &str) -> Result> { + extern_container_arg!(filepath); return_send!(via ocvrs_return); - unsafe { sys::cv_ml_ParamGrid_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_RTrees_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for ParamGrid { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ParamGrid") - .field("min_val", &crate::ml::ParamGridTraitConst::min_val(self)) - .field("max_val", &crate::ml::ParamGridTraitConst::max_val(self)) - .field("log_step", &crate::ml::ParamGridTraitConst::log_step(self)) - .finish() - } - } - /// Constant methods for [crate::ml::RTrees] pub trait RTreesTraitConst: crate::ml::DTreesTraitConst { fn as_raw_RTrees(&self) -> *const c_void; @@ -4112,23 +4194,19 @@ pub mod ml { } - /// The class implements the random forest predictor. - /// ## See also - /// [ml_intro_rtrees] - pub struct RTrees { - ptr: *mut c_void, - } - - opencv_type_boxed! { RTrees } - - impl Drop for RTrees { + impl std::fmt::Debug for RTrees { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ml_RTrees_delete(self.as_raw_mut_RTrees()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RTrees") + .finish() } } - unsafe impl Send for RTrees {} + boxed_cast_base! { RTrees, core::Algorithm, cv_ml_RTrees_to_Algorithm } + + boxed_cast_base! { RTrees, crate::ml::DTrees, cv_ml_RTrees_to_DTrees } + + boxed_cast_base! { RTrees, crate::ml::StatModel, cv_ml_RTrees_to_StatModel } impl core::AlgorithmTraitConst for RTrees { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -4170,84 +4248,94 @@ pub mod ml { boxed_ref! { RTrees, crate::ml::RTreesTraitConst, as_raw_RTrees, crate::ml::RTreesTrait, as_raw_mut_RTrees } - impl RTrees { - /// Creates the empty model. - /// Use StatModel::train to train the model, StatModel::train to create and train the model, - /// Algorithm::load to load the pre-trained model. + /// Support Vector Machines. + /// ## See also + /// [ml_intro_svm] + pub struct SVM { + ptr: *mut c_void, + } + + opencv_type_boxed! { SVM } + + impl Drop for SVM { #[inline] - pub fn create() -> Result> { + fn drop(&mut self) { + unsafe { sys::cv_ml_SVM_delete(self.as_raw_mut_SVM()) }; + } + } + + unsafe impl Send for SVM {} + + impl SVM { + /// Generates a grid for %SVM parameters. + /// + /// ## Parameters + /// * param_id: %SVM parameters IDs that must be one of the SVM::ParamTypes. The grid is + /// generated for the parameter with this ID. + /// + /// The function generates a grid for the specified parameter of the %SVM algorithm. The grid may be + /// passed to the function SVM::trainAuto. + #[inline] + pub fn get_default_grid(param_id: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ml_RTrees_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_SVM_getDefaultGrid_int(param_id, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::ml::ParamGrid::opencv_from_extern(ret) }; Ok(ret) } - /// Loads and creates a serialized RTree from a file - /// - /// Use RTree::save to serialize and store an RTree to disk. - /// Load the RTree from this file again, by calling this function with the path to the file. - /// Optionally specify the node for the file containing the classifier + /// Generates a grid for %SVM parameters. /// /// ## Parameters - /// * filepath: path to serialized RTree - /// * nodeName: name of node containing the classifier + /// * param_id: %SVM parameters IDs that must be one of the SVM::ParamTypes. The grid is + /// generated for the parameter with this ID. /// - /// ## C++ default parameters - /// * node_name: String() + /// The function generates a grid pointer for the specified parameter of the %SVM algorithm. + /// The grid may be passed to the function SVM::trainAuto. #[inline] - pub fn load(filepath: &str, node_name: &str) -> Result> { - extern_container_arg!(filepath); - extern_container_arg!(node_name); + pub fn get_default_grid_ptr(param_id: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_ml_RTrees_load_const_StringR_const_StringR(filepath.opencv_as_extern(), node_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_SVM_getDefaultGridPtr_int(param_id, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Loads and creates a serialized RTree from a file + /// Creates empty model. + /// Use StatModel::train to train the model. Since %SVM has several parameters, you may want to + /// find the best parameters for your problem, it can be done with SVM::trainAuto. + #[inline] + pub fn create() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_ml_SVM_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Loads and creates a serialized svm from a file /// - /// Use RTree::save to serialize and store an RTree to disk. - /// Load the RTree from this file again, by calling this function with the path to the file. - /// Optionally specify the node for the file containing the classifier + /// Use SVM::save to serialize and store an SVM to disk. + /// Load the SVM from this file again, by calling this function with the path to the file. /// /// ## Parameters - /// * filepath: path to serialized RTree - /// * nodeName: name of node containing the classifier - /// - /// ## Note - /// This alternative version of [RTrees::load] function uses the following default values for its arguments: - /// * node_name: String() + /// * filepath: path to serialized svm #[inline] - pub fn load_def(filepath: &str) -> Result> { + pub fn load(filepath: &str) -> Result> { extern_container_arg!(filepath); return_send!(via ocvrs_return); - unsafe { sys::cv_ml_RTrees_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ml_SVM_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { RTrees, core::Algorithm, cv_ml_RTrees_to_Algorithm } - - boxed_cast_base! { RTrees, crate::ml::DTrees, cv_ml_RTrees_to_DTrees } - - boxed_cast_base! { RTrees, crate::ml::StatModel, cv_ml_RTrees_to_StatModel } - - impl std::fmt::Debug for RTrees { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RTrees") - .finish() - } - } - /// Constant methods for [crate::ml::SVM] pub trait SVMTraitConst: crate::ml::StatModelTraitConst { fn as_raw_SVM(&self) -> *const c_void; @@ -4799,23 +4887,17 @@ pub mod ml { } - /// Support Vector Machines. - /// ## See also - /// [ml_intro_svm] - pub struct SVM { - ptr: *mut c_void, - } - - opencv_type_boxed! { SVM } - - impl Drop for SVM { + impl std::fmt::Debug for SVM { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ml_SVM_delete(self.as_raw_mut_SVM()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SVM") + .finish() } } - unsafe impl Send for SVM {} + boxed_cast_base! { SVM, core::Algorithm, cv_ml_SVM_to_Algorithm } + + boxed_cast_base! { SVM, crate::ml::StatModel, cv_ml_SVM_to_StatModel } impl core::AlgorithmTraitConst for SVM { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -4847,88 +4929,21 @@ pub mod ml { boxed_ref! { SVM, crate::ml::SVMTraitConst, as_raw_SVM, crate::ml::SVMTrait, as_raw_mut_SVM } - impl SVM { - /// Generates a grid for %SVM parameters. - /// - /// ## Parameters - /// * param_id: %SVM parameters IDs that must be one of the SVM::ParamTypes. The grid is - /// generated for the parameter with this ID. - /// - /// The function generates a grid for the specified parameter of the %SVM algorithm. The grid may be - /// passed to the function SVM::trainAuto. - #[inline] - pub fn get_default_grid(param_id: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ml_SVM_getDefaultGrid_int(param_id, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::ml::ParamGrid::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Generates a grid for %SVM parameters. - /// - /// ## Parameters - /// * param_id: %SVM parameters IDs that must be one of the SVM::ParamTypes. The grid is - /// generated for the parameter with this ID. - /// - /// The function generates a grid pointer for the specified parameter of the %SVM algorithm. - /// The grid may be passed to the function SVM::trainAuto. - #[inline] - pub fn get_default_grid_ptr(param_id: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_ml_SVM_getDefaultGridPtr_int(param_id, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Creates empty model. - /// Use StatModel::train to train the model. Since %SVM has several parameters, you may want to - /// find the best parameters for your problem, it can be done with SVM::trainAuto. - #[inline] - pub fn create() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_ml_SVM_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Loads and creates a serialized svm from a file - /// - /// Use SVM::save to serialize and store an SVM to disk. - /// Load the SVM from this file again, by calling this function with the path to the file. - /// - /// ## Parameters - /// * filepath: path to serialized svm - #[inline] - pub fn load(filepath: &str) -> Result> { - extern_container_arg!(filepath); - return_send!(via ocvrs_return); - unsafe { sys::cv_ml_SVM_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + pub struct SVM_Kernel { + ptr: *mut c_void, } - boxed_cast_base! { SVM, core::Algorithm, cv_ml_SVM_to_Algorithm } - - boxed_cast_base! { SVM, crate::ml::StatModel, cv_ml_SVM_to_StatModel } + opencv_type_boxed! { SVM_Kernel } - impl std::fmt::Debug for SVM { + impl Drop for SVM_Kernel { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SVM") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ml_SVM_Kernel_delete(self.as_raw_mut_SVM_Kernel()) }; } } + unsafe impl Send for SVM_Kernel {} + /// Constant methods for [crate::ml::SVM_Kernel] pub trait SVM_KernelTraitConst: core::AlgorithmTraitConst { fn as_raw_SVM_Kernel(&self) -> *const c_void; @@ -4959,20 +4974,15 @@ pub mod ml { } - pub struct SVM_Kernel { - ptr: *mut c_void, - } - - opencv_type_boxed! { SVM_Kernel } - - impl Drop for SVM_Kernel { + impl std::fmt::Debug for SVM_Kernel { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ml_SVM_Kernel_delete(self.as_raw_mut_SVM_Kernel()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SVM_Kernel") + .finish() } } - unsafe impl Send for SVM_Kernel {} + boxed_cast_base! { SVM_Kernel, core::Algorithm, cv_ml_SVM_Kernel_to_Algorithm } impl core::AlgorithmTraitConst for SVM_Kernel { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -4994,17 +5004,154 @@ pub mod ml { boxed_ref! { SVM_Kernel, crate::ml::SVM_KernelTraitConst, as_raw_SVM_Kernel, crate::ml::SVM_KernelTrait, as_raw_mut_SVM_Kernel } - impl SVM_Kernel { + /// ! + /// Stochastic Gradient Descent SVM classifier + /// + /// SVMSGD provides a fast and easy-to-use implementation of the SVM classifier using the Stochastic Gradient Descent approach, + /// as presented in [bottou2010large](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_bottou2010large). + /// + /// The classifier has following parameters: + /// - model type, + /// - margin type, + /// - margin regularization (![inline formula](https://latex.codecogs.com/png.latex?%5Clambda)), + /// - initial step size (![inline formula](https://latex.codecogs.com/png.latex?%5Cgamma%5F0)), + /// - step decreasing power (![inline formula](https://latex.codecogs.com/png.latex?c)), + /// - and termination criteria. + /// + /// The model type may have one of the following values: \ref SGD and \ref ASGD. + /// + /// - \ref SGD is the classic version of SVMSGD classifier: every next step is calculated by the formula + /// ![block formula](https://latex.codecogs.com/png.latex?w%5F%7Bt%2B1%7D%20%3D%20w%5Ft%20%2D%20%5Cgamma%28t%29%20%5Cfrac%7BdQ%5Fi%7D%7Bdw%7D%20%7C%5F%7Bw%20%3D%20w%5Ft%7D) + /// where + /// - ![inline formula](https://latex.codecogs.com/png.latex?w%5Ft) is the weights vector for decision function at step ![inline formula](https://latex.codecogs.com/png.latex?t), + /// - ![inline formula](https://latex.codecogs.com/png.latex?%5Cgamma%28t%29) is the step size of model parameters at the iteration ![inline formula](https://latex.codecogs.com/png.latex?t), it is decreased on each step by the formula + /// ![inline formula](https://latex.codecogs.com/png.latex?%5Cgamma%28t%29%20%3D%20%5Cgamma%5F0%20%20%281%20%2B%20%5Clambda%20%20%5Cgamma%5F0%20t%29%20%5E%20%7B%2Dc%7D) + /// - ![inline formula](https://latex.codecogs.com/png.latex?Q%5Fi) is the target functional from SVM task for sample with number ![inline formula](https://latex.codecogs.com/png.latex?i), this sample is chosen stochastically on each step of the algorithm. + /// + /// - \ref ASGD is Average Stochastic Gradient Descent SVM Classifier. ASGD classifier averages weights vector on each step of algorithm by the formula + /// ![inline formula](https://latex.codecogs.com/png.latex?%5Cwidehat%7Bw%7D%5F%7Bt%2B1%7D%20%3D%20%5Cfrac%7Bt%7D%7B1%2Bt%7D%5Cwidehat%7Bw%7D%5F%7Bt%7D%20%2B%20%5Cfrac%7B1%7D%7B1%2Bt%7Dw%5F%7Bt%2B1%7D) + /// + /// The recommended model type is ASGD (following [bottou2010large](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_bottou2010large)). + /// + /// The margin type may have one of the following values: \ref SOFT_MARGIN or \ref HARD_MARGIN. + /// + /// - You should use \ref HARD_MARGIN type, if you have linearly separable sets. + /// - You should use \ref SOFT_MARGIN type, if you have non-linearly separable sets or sets with outliers. + /// - In the general case (if you know nothing about linear separability of your sets), use SOFT_MARGIN. + /// + /// The other parameters may be described as follows: + /// - Margin regularization parameter is responsible for weights decreasing at each step and for the strength of restrictions on outliers + /// (the less the parameter, the less probability that an outlier will be ignored). + /// Recommended value for SGD model is 0.0001, for ASGD model is 0.00001. + /// + /// - Initial step size parameter is the initial value for the step size ![inline formula](https://latex.codecogs.com/png.latex?%5Cgamma%28t%29). + /// You will have to find the best initial step for your problem. + /// + /// - Step decreasing power is the power parameter for ![inline formula](https://latex.codecogs.com/png.latex?%5Cgamma%28t%29) decreasing by the formula, mentioned above. + /// Recommended value for SGD model is 1, for ASGD model is 0.75. + /// + /// - Termination criteria can be TermCriteria::COUNT, TermCriteria::EPS or TermCriteria::COUNT + TermCriteria::EPS. + /// You will have to find the best termination criteria for your problem. + /// + /// Note that the parameters margin regularization, initial step size, and step decreasing power should be positive. + /// + /// To use SVMSGD algorithm do as follows: + /// + /// - first, create the SVMSGD object. The algorithm will set optimal parameters by default, but you can set your own parameters via functions setSvmsgdType(), + /// setMarginType(), setMarginRegularization(), setInitialStepSize(), and setStepDecreasingPower(). + /// + /// - then the SVM model can be trained using the train features and the correspondent labels by the method train(). + /// + /// - after that, the label of a new feature vector can be predicted using the method predict(). + /// + /// ```C++ + /// // Create empty object + /// cv::Ptr svmsgd = SVMSGD::create(); + /// + /// // Train the Stochastic Gradient Descent SVM + /// svmsgd->train(trainData); + /// + /// // Predict labels for the new samples + /// svmsgd->predict(samples, responses); + /// ``` + /// + pub struct SVMSGD { + ptr: *mut c_void, + } + + opencv_type_boxed! { SVMSGD } + + impl Drop for SVMSGD { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_ml_SVMSGD_delete(self.as_raw_mut_SVMSGD()) }; + } } - boxed_cast_base! { SVM_Kernel, core::Algorithm, cv_ml_SVM_Kernel_to_Algorithm } + unsafe impl Send for SVMSGD {} - impl std::fmt::Debug for SVM_Kernel { + impl SVMSGD { + /// Creates empty model. + /// Use StatModel::train to train the model. Since %SVMSGD has several parameters, you may want to + /// find the best parameters for your problem or use setOptimalParameters() to set some default parameters. #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SVM_Kernel") - .finish() + pub fn create() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_ml_SVMSGD_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Loads and creates a serialized SVMSGD from a file + /// + /// Use SVMSGD::save to serialize and store an SVMSGD to disk. + /// Load the SVMSGD from this file again, by calling this function with the path to the file. + /// Optionally specify the node for the file containing the classifier + /// + /// ## Parameters + /// * filepath: path to serialized SVMSGD + /// * nodeName: name of node containing the classifier + /// + /// ## C++ default parameters + /// * node_name: String() + #[inline] + pub fn load(filepath: &str, node_name: &str) -> Result> { + extern_container_arg!(filepath); + extern_container_arg!(node_name); + return_send!(via ocvrs_return); + unsafe { sys::cv_ml_SVMSGD_load_const_StringR_const_StringR(filepath.opencv_as_extern(), node_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Loads and creates a serialized SVMSGD from a file + /// + /// Use SVMSGD::save to serialize and store an SVMSGD to disk. + /// Load the SVMSGD from this file again, by calling this function with the path to the file. + /// Optionally specify the node for the file containing the classifier + /// + /// ## Parameters + /// * filepath: path to serialized SVMSGD + /// * nodeName: name of node containing the classifier + /// + /// ## Note + /// This alternative version of [SVMSGD::load] function uses the following default values for its arguments: + /// * node_name: String() + #[inline] + pub fn load_def(filepath: &str) -> Result> { + extern_container_arg!(filepath); + return_send!(via ocvrs_return); + unsafe { sys::cv_ml_SVMSGD_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::ml::SVMSGD] @@ -5225,91 +5372,17 @@ pub mod ml { } - /// ! - /// Stochastic Gradient Descent SVM classifier - /// - /// SVMSGD provides a fast and easy-to-use implementation of the SVM classifier using the Stochastic Gradient Descent approach, - /// as presented in [bottou2010large](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_bottou2010large). - /// - /// The classifier has following parameters: - /// - model type, - /// - margin type, - /// - margin regularization (![inline formula](https://latex.codecogs.com/png.latex?%5Clambda)), - /// - initial step size (![inline formula](https://latex.codecogs.com/png.latex?%5Cgamma%5F0)), - /// - step decreasing power (![inline formula](https://latex.codecogs.com/png.latex?c)), - /// - and termination criteria. - /// - /// The model type may have one of the following values: \ref SGD and \ref ASGD. - /// - /// - \ref SGD is the classic version of SVMSGD classifier: every next step is calculated by the formula - /// ![block formula](https://latex.codecogs.com/png.latex?w%5F%7Bt%2B1%7D%20%3D%20w%5Ft%20%2D%20%5Cgamma%28t%29%20%5Cfrac%7BdQ%5Fi%7D%7Bdw%7D%20%7C%5F%7Bw%20%3D%20w%5Ft%7D) - /// where - /// - ![inline formula](https://latex.codecogs.com/png.latex?w%5Ft) is the weights vector for decision function at step ![inline formula](https://latex.codecogs.com/png.latex?t), - /// - ![inline formula](https://latex.codecogs.com/png.latex?%5Cgamma%28t%29) is the step size of model parameters at the iteration ![inline formula](https://latex.codecogs.com/png.latex?t), it is decreased on each step by the formula - /// ![inline formula](https://latex.codecogs.com/png.latex?%5Cgamma%28t%29%20%3D%20%5Cgamma%5F0%20%20%281%20%2B%20%5Clambda%20%20%5Cgamma%5F0%20t%29%20%5E%20%7B%2Dc%7D) - /// - ![inline formula](https://latex.codecogs.com/png.latex?Q%5Fi) is the target functional from SVM task for sample with number ![inline formula](https://latex.codecogs.com/png.latex?i), this sample is chosen stochastically on each step of the algorithm. - /// - /// - \ref ASGD is Average Stochastic Gradient Descent SVM Classifier. ASGD classifier averages weights vector on each step of algorithm by the formula - /// ![inline formula](https://latex.codecogs.com/png.latex?%5Cwidehat%7Bw%7D%5F%7Bt%2B1%7D%20%3D%20%5Cfrac%7Bt%7D%7B1%2Bt%7D%5Cwidehat%7Bw%7D%5F%7Bt%7D%20%2B%20%5Cfrac%7B1%7D%7B1%2Bt%7Dw%5F%7Bt%2B1%7D) - /// - /// The recommended model type is ASGD (following [bottou2010large](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_bottou2010large)). - /// - /// The margin type may have one of the following values: \ref SOFT_MARGIN or \ref HARD_MARGIN. - /// - /// - You should use \ref HARD_MARGIN type, if you have linearly separable sets. - /// - You should use \ref SOFT_MARGIN type, if you have non-linearly separable sets or sets with outliers. - /// - In the general case (if you know nothing about linear separability of your sets), use SOFT_MARGIN. - /// - /// The other parameters may be described as follows: - /// - Margin regularization parameter is responsible for weights decreasing at each step and for the strength of restrictions on outliers - /// (the less the parameter, the less probability that an outlier will be ignored). - /// Recommended value for SGD model is 0.0001, for ASGD model is 0.00001. - /// - /// - Initial step size parameter is the initial value for the step size ![inline formula](https://latex.codecogs.com/png.latex?%5Cgamma%28t%29). - /// You will have to find the best initial step for your problem. - /// - /// - Step decreasing power is the power parameter for ![inline formula](https://latex.codecogs.com/png.latex?%5Cgamma%28t%29) decreasing by the formula, mentioned above. - /// Recommended value for SGD model is 1, for ASGD model is 0.75. - /// - /// - Termination criteria can be TermCriteria::COUNT, TermCriteria::EPS or TermCriteria::COUNT + TermCriteria::EPS. - /// You will have to find the best termination criteria for your problem. - /// - /// Note that the parameters margin regularization, initial step size, and step decreasing power should be positive. - /// - /// To use SVMSGD algorithm do as follows: - /// - /// - first, create the SVMSGD object. The algorithm will set optimal parameters by default, but you can set your own parameters via functions setSvmsgdType(), - /// setMarginType(), setMarginRegularization(), setInitialStepSize(), and setStepDecreasingPower(). - /// - /// - then the SVM model can be trained using the train features and the correspondent labels by the method train(). - /// - /// - after that, the label of a new feature vector can be predicted using the method predict(). - /// - /// ```C++ - /// // Create empty object - /// cv::Ptr svmsgd = SVMSGD::create(); - /// - /// // Train the Stochastic Gradient Descent SVM - /// svmsgd->train(trainData); - /// - /// // Predict labels for the new samples - /// svmsgd->predict(samples, responses); - /// ``` - /// - pub struct SVMSGD { - ptr: *mut c_void, - } - - opencv_type_boxed! { SVMSGD } - - impl Drop for SVMSGD { + impl std::fmt::Debug for SVMSGD { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ml_SVMSGD_delete(self.as_raw_mut_SVMSGD()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SVMSGD") + .finish() } } - unsafe impl Send for SVMSGD {} + boxed_cast_base! { SVMSGD, core::Algorithm, cv_ml_SVMSGD_to_Algorithm } + + boxed_cast_base! { SVMSGD, crate::ml::StatModel, cv_ml_SVMSGD_to_StatModel } impl core::AlgorithmTraitConst for SVMSGD { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5341,82 +5414,22 @@ pub mod ml { boxed_ref! { SVMSGD, crate::ml::SVMSGDTraitConst, as_raw_SVMSGD, crate::ml::SVMSGDTrait, as_raw_mut_SVMSGD } - impl SVMSGD { - /// Creates empty model. - /// Use StatModel::train to train the model. Since %SVMSGD has several parameters, you may want to - /// find the best parameters for your problem or use setOptimalParameters() to set some default parameters. - #[inline] - pub fn create() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_ml_SVMSGD_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Loads and creates a serialized SVMSGD from a file - /// - /// Use SVMSGD::save to serialize and store an SVMSGD to disk. - /// Load the SVMSGD from this file again, by calling this function with the path to the file. - /// Optionally specify the node for the file containing the classifier - /// - /// ## Parameters - /// * filepath: path to serialized SVMSGD - /// * nodeName: name of node containing the classifier - /// - /// ## C++ default parameters - /// * node_name: String() - #[inline] - pub fn load(filepath: &str, node_name: &str) -> Result> { - extern_container_arg!(filepath); - extern_container_arg!(node_name); - return_send!(via ocvrs_return); - unsafe { sys::cv_ml_SVMSGD_load_const_StringR_const_StringR(filepath.opencv_as_extern(), node_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Loads and creates a serialized SVMSGD from a file - /// - /// Use SVMSGD::save to serialize and store an SVMSGD to disk. - /// Load the SVMSGD from this file again, by calling this function with the path to the file. - /// Optionally specify the node for the file containing the classifier - /// - /// ## Parameters - /// * filepath: path to serialized SVMSGD - /// * nodeName: name of node containing the classifier - /// - /// ## Note - /// This alternative version of [SVMSGD::load] function uses the following default values for its arguments: - /// * node_name: String() - #[inline] - pub fn load_def(filepath: &str) -> Result> { - extern_container_arg!(filepath); - return_send!(via ocvrs_return); - unsafe { sys::cv_ml_SVMSGD_load_const_StringR(filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + /// Base class for statistical models in OpenCV ML. + pub struct StatModel { + ptr: *mut c_void, } - boxed_cast_base! { SVMSGD, core::Algorithm, cv_ml_SVMSGD_to_Algorithm } - - boxed_cast_base! { SVMSGD, crate::ml::StatModel, cv_ml_SVMSGD_to_StatModel } + opencv_type_boxed! { StatModel } - impl std::fmt::Debug for SVMSGD { + impl Drop for StatModel { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SVMSGD") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ml_StatModel_delete(self.as_raw_mut_StatModel()) }; } } + unsafe impl Send for StatModel {} + /// Constant methods for [crate::ml::StatModel] pub trait StatModelTraitConst: core::AlgorithmTraitConst { fn as_raw_StatModel(&self) -> *const c_void; @@ -5589,21 +5602,35 @@ pub mod ml { } - /// Base class for statistical models in OpenCV ML. - pub struct StatModel { - ptr: *mut c_void, - } - - opencv_type_boxed! { StatModel } - - impl Drop for StatModel { + impl std::fmt::Debug for StatModel { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ml_StatModel_delete(self.as_raw_mut_StatModel()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("StatModel") + .finish() } } - unsafe impl Send for StatModel {} + boxed_cast_base! { StatModel, core::Algorithm, cv_ml_StatModel_to_Algorithm } + + boxed_cast_descendant! { StatModel, crate::ml::ANN_MLP, cv_ml_StatModel_to_ANN_MLP } + + boxed_cast_descendant! { StatModel, crate::ml::Boost, cv_ml_StatModel_to_Boost } + + boxed_cast_descendant! { StatModel, crate::ml::DTrees, cv_ml_StatModel_to_DTrees } + + boxed_cast_descendant! { StatModel, crate::ml::EM, cv_ml_StatModel_to_EM } + + boxed_cast_descendant! { StatModel, crate::ml::KNearest, cv_ml_StatModel_to_KNearest } + + boxed_cast_descendant! { StatModel, crate::ml::LogisticRegression, cv_ml_StatModel_to_LogisticRegression } + + boxed_cast_descendant! { StatModel, crate::ml::NormalBayesClassifier, cv_ml_StatModel_to_NormalBayesClassifier } + + boxed_cast_descendant! { StatModel, crate::ml::RTrees, cv_ml_StatModel_to_RTrees } + + boxed_cast_descendant! { StatModel, crate::ml::SVM, cv_ml_StatModel_to_SVM } + + boxed_cast_descendant! { StatModel, crate::ml::SVMSGD, cv_ml_StatModel_to_SVMSGD } impl core::AlgorithmTraitConst for StatModel { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5625,37 +5652,245 @@ pub mod ml { boxed_ref! { StatModel, crate::ml::StatModelTraitConst, as_raw_StatModel, crate::ml::StatModelTrait, as_raw_mut_StatModel } - impl StatModel { + /// Class encapsulating training data. + /// + /// Please note that the class only specifies the interface of training data, but not implementation. + /// All the statistical model classes in _ml_ module accepts Ptr\ as parameter. In other + /// words, you can create your own class derived from TrainData and pass smart pointer to the instance + /// of this class into StatModel::train. + /// ## See also + /// [ml_intro_data] + pub struct TrainData { + ptr: *mut c_void, } - boxed_cast_descendant! { StatModel, crate::ml::ANN_MLP, cv_ml_StatModel_to_ANN_MLP } - - boxed_cast_descendant! { StatModel, crate::ml::Boost, cv_ml_StatModel_to_Boost } - - boxed_cast_descendant! { StatModel, crate::ml::DTrees, cv_ml_StatModel_to_DTrees } + opencv_type_boxed! { TrainData } - boxed_cast_descendant! { StatModel, crate::ml::EM, cv_ml_StatModel_to_EM } + impl Drop for TrainData { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_ml_TrainData_delete(self.as_raw_mut_TrainData()) }; + } + } - boxed_cast_descendant! { StatModel, crate::ml::KNearest, cv_ml_StatModel_to_KNearest } + unsafe impl Send for TrainData {} - boxed_cast_descendant! { StatModel, crate::ml::LogisticRegression, cv_ml_StatModel_to_LogisticRegression } + impl TrainData { + #[inline] + pub fn missing_value() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ml_TrainData_missingValue(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - boxed_cast_descendant! { StatModel, crate::ml::NormalBayesClassifier, cv_ml_StatModel_to_NormalBayesClassifier } + /// Extract from 1D vector elements specified by passed indexes. + /// ## Parameters + /// * vec: input vector (supported types: CV_32S, CV_32F, CV_64F) + /// * idx: 1D index vector + #[inline] + pub fn get_sub_vector(vec: &impl core::MatTraitConst, idx: &impl core::MatTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ml_TrainData_getSubVector_const_MatR_const_MatR(vec.as_raw_Mat(), idx.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + Ok(ret) + } - boxed_cast_descendant! { StatModel, crate::ml::RTrees, cv_ml_StatModel_to_RTrees } + /// Extract from matrix rows/cols specified by passed indexes. + /// ## Parameters + /// * matrix: input matrix (supported types: CV_32S, CV_32F, CV_64F) + /// * idx: 1D index vector + /// * layout: specifies to extract rows (cv::ml::ROW_SAMPLES) or to extract columns (cv::ml::COL_SAMPLES) + #[inline] + pub fn get_sub_matrix(matrix: &impl core::MatTraitConst, idx: &impl core::MatTraitConst, layout: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ml_TrainData_getSubMatrix_const_MatR_const_MatR_int(matrix.as_raw_Mat(), idx.as_raw_Mat(), layout, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + Ok(ret) + } - boxed_cast_descendant! { StatModel, crate::ml::SVM, cv_ml_StatModel_to_SVM } + /// Reads the dataset from a .csv file and returns the ready-to-use training data. + /// + /// ## Parameters + /// * filename: The input file name + /// * headerLineCount: The number of lines in the beginning to skip; besides the header, the + /// function also skips empty lines and lines staring with `#` + /// * responseStartIdx: Index of the first output variable. If -1, the function considers the + /// last variable as the response + /// * responseEndIdx: Index of the last output variable + 1. If -1, then there is single + /// response variable at responseStartIdx. + /// * varTypeSpec: The optional text string that specifies the variables' types. It has the + /// format `ord[n1-n2,n3,n4-n5,...]cat[n6,n7-n8,...]`. That is, variables from `n1 to n2` + /// (inclusive range), `n3`, `n4 to n5` ... are considered ordered and `n6`, `n7 to n8` ... are + /// considered as categorical. The range `[n1..n2] + [n3] + [n4..n5] + ... + [n6] + [n7..n8]` + /// should cover all the variables. If varTypeSpec is not specified, then algorithm uses the + /// following rules: + /// - all input variables are considered ordered by default. If some column contains has non- + /// numerical values, e.g. 'apple', 'pear', 'apple', 'apple', 'mango', the corresponding + /// variable is considered categorical. + /// - if there are several output variables, they are all considered as ordered. Error is + /// reported when non-numerical values are used. + /// - if there is a single output variable, then if its values are non-numerical or are all + /// integers, then it's considered categorical. Otherwise, it's considered ordered. + /// * delimiter: The character used to separate values in each line. + /// * missch: The character used to specify missing measurements. It should not be a digit. + /// Although it's a non-numerical value, it surely does not affect the decision of whether the + /// variable ordered or categorical. + /// + /// Note: If the dataset only contains input variables and no responses, use responseStartIdx = -2 + /// and responseEndIdx = 0. The output variables vector will just contain zeros. + /// + /// ## C++ default parameters + /// * response_start_idx: -1 + /// * response_end_idx: -1 + /// * var_type_spec: String() + /// * delimiter: ',' + /// * missch: '?' + #[inline] + pub fn load_from_csv(filename: &str, header_line_count: i32, response_start_idx: i32, response_end_idx: i32, var_type_spec: &str, delimiter: char, missch: char) -> Result> { + extern_container_arg!(filename); + extern_container_arg!(var_type_spec); + return_send!(via ocvrs_return); + unsafe { sys::cv_ml_TrainData_loadFromCSV_const_StringR_int_int_int_const_StringR_char_char(filename.opencv_as_extern(), header_line_count, response_start_idx, response_end_idx, var_type_spec.opencv_as_extern(), u8::try_from(delimiter)? as c_char, u8::try_from(missch)? as c_char, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } - boxed_cast_descendant! { StatModel, crate::ml::SVMSGD, cv_ml_StatModel_to_SVMSGD } + /// Reads the dataset from a .csv file and returns the ready-to-use training data. + /// + /// ## Parameters + /// * filename: The input file name + /// * headerLineCount: The number of lines in the beginning to skip; besides the header, the + /// function also skips empty lines and lines staring with `#` + /// * responseStartIdx: Index of the first output variable. If -1, the function considers the + /// last variable as the response + /// * responseEndIdx: Index of the last output variable + 1. If -1, then there is single + /// response variable at responseStartIdx. + /// * varTypeSpec: The optional text string that specifies the variables' types. It has the + /// format `ord[n1-n2,n3,n4-n5,...]cat[n6,n7-n8,...]`. That is, variables from `n1 to n2` + /// (inclusive range), `n3`, `n4 to n5` ... are considered ordered and `n6`, `n7 to n8` ... are + /// considered as categorical. The range `[n1..n2] + [n3] + [n4..n5] + ... + [n6] + [n7..n8]` + /// should cover all the variables. If varTypeSpec is not specified, then algorithm uses the + /// following rules: + /// - all input variables are considered ordered by default. If some column contains has non- + /// numerical values, e.g. 'apple', 'pear', 'apple', 'apple', 'mango', the corresponding + /// variable is considered categorical. + /// - if there are several output variables, they are all considered as ordered. Error is + /// reported when non-numerical values are used. + /// - if there is a single output variable, then if its values are non-numerical or are all + /// integers, then it's considered categorical. Otherwise, it's considered ordered. + /// * delimiter: The character used to separate values in each line. + /// * missch: The character used to specify missing measurements. It should not be a digit. + /// Although it's a non-numerical value, it surely does not affect the decision of whether the + /// variable ordered or categorical. + /// + /// Note: If the dataset only contains input variables and no responses, use responseStartIdx = -2 + /// and responseEndIdx = 0. The output variables vector will just contain zeros. + /// + /// ## Note + /// This alternative version of [TrainData::load_from_csv] function uses the following default values for its arguments: + /// * response_start_idx: -1 + /// * response_end_idx: -1 + /// * var_type_spec: String() + /// * delimiter: ',' + /// * missch: '?' + #[inline] + pub fn load_from_csv_def(filename: &str, header_line_count: i32) -> Result> { + extern_container_arg!(filename); + return_send!(via ocvrs_return); + unsafe { sys::cv_ml_TrainData_loadFromCSV_const_StringR_int(filename.opencv_as_extern(), header_line_count, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } - boxed_cast_base! { StatModel, core::Algorithm, cv_ml_StatModel_to_Algorithm } + /// Creates training data from in-memory arrays. + /// + /// ## Parameters + /// * samples: matrix of samples. It should have CV_32F type. + /// * layout: see ml::SampleTypes. + /// * responses: matrix of responses. If the responses are scalar, they should be stored as a + /// single row or as a single column. The matrix should have type CV_32F or CV_32S (in the + /// former case the responses are considered as ordered by default; in the latter case - as + /// categorical) + /// * varIdx: vector specifying which variables to use for training. It can be an integer vector + /// (CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of + /// active variables. + /// * sampleIdx: vector specifying which samples to use for training. It can be an integer + /// vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask + /// of training samples. + /// * sampleWeights: optional vector with weights for each sample. It should have CV_32F type. + /// * varType: optional vector of type CV_8U and size ` + + /// `, containing types of each input and output variable. See + /// ml::VariableTypes. + /// + /// ## C++ default parameters + /// * var_idx: noArray() + /// * sample_idx: noArray() + /// * sample_weights: noArray() + /// * var_type: noArray() + #[inline] + pub fn create(samples: &impl ToInputArray, layout: i32, responses: &impl ToInputArray, var_idx: &impl ToInputArray, sample_idx: &impl ToInputArray, sample_weights: &impl ToInputArray, var_type: &impl ToInputArray) -> Result> { + input_array_arg!(samples); + input_array_arg!(responses); + input_array_arg!(var_idx); + input_array_arg!(sample_idx); + input_array_arg!(sample_weights); + input_array_arg!(var_type); + return_send!(via ocvrs_return); + unsafe { sys::cv_ml_TrainData_create_const__InputArrayR_int_const__InputArrayR_const__InputArrayR_const__InputArrayR_const__InputArrayR_const__InputArrayR(samples.as_raw__InputArray(), layout, responses.as_raw__InputArray(), var_idx.as_raw__InputArray(), sample_idx.as_raw__InputArray(), sample_weights.as_raw__InputArray(), var_type.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for StatModel { + /// Creates training data from in-memory arrays. + /// + /// ## Parameters + /// * samples: matrix of samples. It should have CV_32F type. + /// * layout: see ml::SampleTypes. + /// * responses: matrix of responses. If the responses are scalar, they should be stored as a + /// single row or as a single column. The matrix should have type CV_32F or CV_32S (in the + /// former case the responses are considered as ordered by default; in the latter case - as + /// categorical) + /// * varIdx: vector specifying which variables to use for training. It can be an integer vector + /// (CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of + /// active variables. + /// * sampleIdx: vector specifying which samples to use for training. It can be an integer + /// vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask + /// of training samples. + /// * sampleWeights: optional vector with weights for each sample. It should have CV_32F type. + /// * varType: optional vector of type CV_8U and size ` + + /// `, containing types of each input and output variable. See + /// ml::VariableTypes. + /// + /// ## Note + /// This alternative version of [TrainData::create] function uses the following default values for its arguments: + /// * var_idx: noArray() + /// * sample_idx: noArray() + /// * sample_weights: noArray() + /// * var_type: noArray() #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("StatModel") - .finish() + pub fn create_def(samples: &impl ToInputArray, layout: i32, responses: &impl ToInputArray) -> Result> { + input_array_arg!(samples); + input_array_arg!(responses); + return_send!(via ocvrs_return); + unsafe { sys::cv_ml_TrainData_create_const__InputArrayR_int_const__InputArrayR(samples.as_raw__InputArray(), layout, responses.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::ml::TrainData] @@ -6141,29 +6376,14 @@ pub mod ml { } - /// Class encapsulating training data. - /// - /// Please note that the class only specifies the interface of training data, but not implementation. - /// All the statistical model classes in _ml_ module accepts Ptr\ as parameter. In other - /// words, you can create your own class derived from TrainData and pass smart pointer to the instance - /// of this class into StatModel::train. - /// ## See also - /// [ml_intro_data] - pub struct TrainData { - ptr: *mut c_void, - } - - opencv_type_boxed! { TrainData } - - impl Drop for TrainData { + impl std::fmt::Debug for TrainData { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ml_TrainData_delete(self.as_raw_mut_TrainData()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TrainData") + .finish() } } - unsafe impl Send for TrainData {} - impl crate::ml::TrainDataTraitConst for TrainData { #[inline] fn as_raw_TrainData(&self) -> *const c_void { self.as_raw() } } @@ -6174,229 +6394,4 @@ pub mod ml { boxed_ref! { TrainData, crate::ml::TrainDataTraitConst, as_raw_TrainData, crate::ml::TrainDataTrait, as_raw_mut_TrainData } - impl TrainData { - #[inline] - pub fn missing_value() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ml_TrainData_missingValue(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Extract from 1D vector elements specified by passed indexes. - /// ## Parameters - /// * vec: input vector (supported types: CV_32S, CV_32F, CV_64F) - /// * idx: 1D index vector - #[inline] - pub fn get_sub_vector(vec: &impl core::MatTraitConst, idx: &impl core::MatTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ml_TrainData_getSubVector_const_MatR_const_MatR(vec.as_raw_Mat(), idx.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Extract from matrix rows/cols specified by passed indexes. - /// ## Parameters - /// * matrix: input matrix (supported types: CV_32S, CV_32F, CV_64F) - /// * idx: 1D index vector - /// * layout: specifies to extract rows (cv::ml::ROW_SAMPLES) or to extract columns (cv::ml::COL_SAMPLES) - #[inline] - pub fn get_sub_matrix(matrix: &impl core::MatTraitConst, idx: &impl core::MatTraitConst, layout: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ml_TrainData_getSubMatrix_const_MatR_const_MatR_int(matrix.as_raw_Mat(), idx.as_raw_Mat(), layout, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Reads the dataset from a .csv file and returns the ready-to-use training data. - /// - /// ## Parameters - /// * filename: The input file name - /// * headerLineCount: The number of lines in the beginning to skip; besides the header, the - /// function also skips empty lines and lines staring with `#` - /// * responseStartIdx: Index of the first output variable. If -1, the function considers the - /// last variable as the response - /// * responseEndIdx: Index of the last output variable + 1. If -1, then there is single - /// response variable at responseStartIdx. - /// * varTypeSpec: The optional text string that specifies the variables' types. It has the - /// format `ord[n1-n2,n3,n4-n5,...]cat[n6,n7-n8,...]`. That is, variables from `n1 to n2` - /// (inclusive range), `n3`, `n4 to n5` ... are considered ordered and `n6`, `n7 to n8` ... are - /// considered as categorical. The range `[n1..n2] + [n3] + [n4..n5] + ... + [n6] + [n7..n8]` - /// should cover all the variables. If varTypeSpec is not specified, then algorithm uses the - /// following rules: - /// - all input variables are considered ordered by default. If some column contains has non- - /// numerical values, e.g. 'apple', 'pear', 'apple', 'apple', 'mango', the corresponding - /// variable is considered categorical. - /// - if there are several output variables, they are all considered as ordered. Error is - /// reported when non-numerical values are used. - /// - if there is a single output variable, then if its values are non-numerical or are all - /// integers, then it's considered categorical. Otherwise, it's considered ordered. - /// * delimiter: The character used to separate values in each line. - /// * missch: The character used to specify missing measurements. It should not be a digit. - /// Although it's a non-numerical value, it surely does not affect the decision of whether the - /// variable ordered or categorical. - /// - /// Note: If the dataset only contains input variables and no responses, use responseStartIdx = -2 - /// and responseEndIdx = 0. The output variables vector will just contain zeros. - /// - /// ## C++ default parameters - /// * response_start_idx: -1 - /// * response_end_idx: -1 - /// * var_type_spec: String() - /// * delimiter: ',' - /// * missch: '?' - #[inline] - pub fn load_from_csv(filename: &str, header_line_count: i32, response_start_idx: i32, response_end_idx: i32, var_type_spec: &str, delimiter: char, missch: char) -> Result> { - extern_container_arg!(filename); - extern_container_arg!(var_type_spec); - return_send!(via ocvrs_return); - unsafe { sys::cv_ml_TrainData_loadFromCSV_const_StringR_int_int_int_const_StringR_char_char(filename.opencv_as_extern(), header_line_count, response_start_idx, response_end_idx, var_type_spec.opencv_as_extern(), u8::try_from(delimiter)? as c_char, u8::try_from(missch)? as c_char, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Reads the dataset from a .csv file and returns the ready-to-use training data. - /// - /// ## Parameters - /// * filename: The input file name - /// * headerLineCount: The number of lines in the beginning to skip; besides the header, the - /// function also skips empty lines and lines staring with `#` - /// * responseStartIdx: Index of the first output variable. If -1, the function considers the - /// last variable as the response - /// * responseEndIdx: Index of the last output variable + 1. If -1, then there is single - /// response variable at responseStartIdx. - /// * varTypeSpec: The optional text string that specifies the variables' types. It has the - /// format `ord[n1-n2,n3,n4-n5,...]cat[n6,n7-n8,...]`. That is, variables from `n1 to n2` - /// (inclusive range), `n3`, `n4 to n5` ... are considered ordered and `n6`, `n7 to n8` ... are - /// considered as categorical. The range `[n1..n2] + [n3] + [n4..n5] + ... + [n6] + [n7..n8]` - /// should cover all the variables. If varTypeSpec is not specified, then algorithm uses the - /// following rules: - /// - all input variables are considered ordered by default. If some column contains has non- - /// numerical values, e.g. 'apple', 'pear', 'apple', 'apple', 'mango', the corresponding - /// variable is considered categorical. - /// - if there are several output variables, they are all considered as ordered. Error is - /// reported when non-numerical values are used. - /// - if there is a single output variable, then if its values are non-numerical or are all - /// integers, then it's considered categorical. Otherwise, it's considered ordered. - /// * delimiter: The character used to separate values in each line. - /// * missch: The character used to specify missing measurements. It should not be a digit. - /// Although it's a non-numerical value, it surely does not affect the decision of whether the - /// variable ordered or categorical. - /// - /// Note: If the dataset only contains input variables and no responses, use responseStartIdx = -2 - /// and responseEndIdx = 0. The output variables vector will just contain zeros. - /// - /// ## Note - /// This alternative version of [TrainData::load_from_csv] function uses the following default values for its arguments: - /// * response_start_idx: -1 - /// * response_end_idx: -1 - /// * var_type_spec: String() - /// * delimiter: ',' - /// * missch: '?' - #[inline] - pub fn load_from_csv_def(filename: &str, header_line_count: i32) -> Result> { - extern_container_arg!(filename); - return_send!(via ocvrs_return); - unsafe { sys::cv_ml_TrainData_loadFromCSV_const_StringR_int(filename.opencv_as_extern(), header_line_count, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Creates training data from in-memory arrays. - /// - /// ## Parameters - /// * samples: matrix of samples. It should have CV_32F type. - /// * layout: see ml::SampleTypes. - /// * responses: matrix of responses. If the responses are scalar, they should be stored as a - /// single row or as a single column. The matrix should have type CV_32F or CV_32S (in the - /// former case the responses are considered as ordered by default; in the latter case - as - /// categorical) - /// * varIdx: vector specifying which variables to use for training. It can be an integer vector - /// (CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of - /// active variables. - /// * sampleIdx: vector specifying which samples to use for training. It can be an integer - /// vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask - /// of training samples. - /// * sampleWeights: optional vector with weights for each sample. It should have CV_32F type. - /// * varType: optional vector of type CV_8U and size ` + - /// `, containing types of each input and output variable. See - /// ml::VariableTypes. - /// - /// ## C++ default parameters - /// * var_idx: noArray() - /// * sample_idx: noArray() - /// * sample_weights: noArray() - /// * var_type: noArray() - #[inline] - pub fn create(samples: &impl ToInputArray, layout: i32, responses: &impl ToInputArray, var_idx: &impl ToInputArray, sample_idx: &impl ToInputArray, sample_weights: &impl ToInputArray, var_type: &impl ToInputArray) -> Result> { - input_array_arg!(samples); - input_array_arg!(responses); - input_array_arg!(var_idx); - input_array_arg!(sample_idx); - input_array_arg!(sample_weights); - input_array_arg!(var_type); - return_send!(via ocvrs_return); - unsafe { sys::cv_ml_TrainData_create_const__InputArrayR_int_const__InputArrayR_const__InputArrayR_const__InputArrayR_const__InputArrayR_const__InputArrayR(samples.as_raw__InputArray(), layout, responses.as_raw__InputArray(), var_idx.as_raw__InputArray(), sample_idx.as_raw__InputArray(), sample_weights.as_raw__InputArray(), var_type.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Creates training data from in-memory arrays. - /// - /// ## Parameters - /// * samples: matrix of samples. It should have CV_32F type. - /// * layout: see ml::SampleTypes. - /// * responses: matrix of responses. If the responses are scalar, they should be stored as a - /// single row or as a single column. The matrix should have type CV_32F or CV_32S (in the - /// former case the responses are considered as ordered by default; in the latter case - as - /// categorical) - /// * varIdx: vector specifying which variables to use for training. It can be an integer vector - /// (CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of - /// active variables. - /// * sampleIdx: vector specifying which samples to use for training. It can be an integer - /// vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask - /// of training samples. - /// * sampleWeights: optional vector with weights for each sample. It should have CV_32F type. - /// * varType: optional vector of type CV_8U and size ` + - /// `, containing types of each input and output variable. See - /// ml::VariableTypes. - /// - /// ## Note - /// This alternative version of [TrainData::create] function uses the following default values for its arguments: - /// * var_idx: noArray() - /// * sample_idx: noArray() - /// * sample_weights: noArray() - /// * var_type: noArray() - #[inline] - pub fn create_def(samples: &impl ToInputArray, layout: i32, responses: &impl ToInputArray) -> Result> { - input_array_arg!(samples); - input_array_arg!(responses); - return_send!(via ocvrs_return); - unsafe { sys::cv_ml_TrainData_create_const__InputArrayR_int_const__InputArrayR(samples.as_raw__InputArray(), layout, responses.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for TrainData { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TrainData") - .finish() - } - } } diff --git a/docs/objdetect.rs b/docs/objdetect.rs index 4938d1c6a..e1837b003 100644 --- a/docs/objdetect.rs +++ b/docs/objdetect.rs @@ -951,6 +951,21 @@ pub mod objdetect { Ok(ret) } + pub struct BaseCascadeClassifier { + ptr: *mut c_void, + } + + opencv_type_boxed! { BaseCascadeClassifier } + + impl Drop for BaseCascadeClassifier { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_BaseCascadeClassifier_delete(self.as_raw_mut_BaseCascadeClassifier()) }; + } + } + + unsafe impl Send for BaseCascadeClassifier {} + /// Constant methods for [crate::objdetect::BaseCascadeClassifier] pub trait BaseCascadeClassifierTraitConst: core::AlgorithmTraitConst { fn as_raw_BaseCascadeClassifier(&self) -> *const c_void; @@ -1067,20 +1082,15 @@ pub mod objdetect { } - pub struct BaseCascadeClassifier { - ptr: *mut c_void, - } - - opencv_type_boxed! { BaseCascadeClassifier } - - impl Drop for BaseCascadeClassifier { + impl std::fmt::Debug for BaseCascadeClassifier { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_BaseCascadeClassifier_delete(self.as_raw_mut_BaseCascadeClassifier()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BaseCascadeClassifier") + .finish() } } - unsafe impl Send for BaseCascadeClassifier {} + boxed_cast_base! { BaseCascadeClassifier, core::Algorithm, cv_BaseCascadeClassifier_to_Algorithm } impl core::AlgorithmTraitConst for BaseCascadeClassifier { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1102,19 +1112,21 @@ pub mod objdetect { boxed_ref! { BaseCascadeClassifier, crate::objdetect::BaseCascadeClassifierTraitConst, as_raw_BaseCascadeClassifier, crate::objdetect::BaseCascadeClassifierTrait, as_raw_mut_BaseCascadeClassifier } - impl BaseCascadeClassifier { + pub struct BaseCascadeClassifier_MaskGenerator { + ptr: *mut c_void, } - boxed_cast_base! { BaseCascadeClassifier, core::Algorithm, cv_BaseCascadeClassifier_to_Algorithm } + opencv_type_boxed! { BaseCascadeClassifier_MaskGenerator } - impl std::fmt::Debug for BaseCascadeClassifier { + impl Drop for BaseCascadeClassifier_MaskGenerator { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BaseCascadeClassifier") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_BaseCascadeClassifier_MaskGenerator_delete(self.as_raw_mut_BaseCascadeClassifier_MaskGenerator()) }; } } + unsafe impl Send for BaseCascadeClassifier_MaskGenerator {} + /// Constant methods for [crate::objdetect::BaseCascadeClassifier_MaskGenerator] pub trait BaseCascadeClassifier_MaskGeneratorTraitConst { fn as_raw_BaseCascadeClassifier_MaskGenerator(&self) -> *const c_void; @@ -1146,21 +1158,14 @@ pub mod objdetect { } - pub struct BaseCascadeClassifier_MaskGenerator { - ptr: *mut c_void, - } - - opencv_type_boxed! { BaseCascadeClassifier_MaskGenerator } - - impl Drop for BaseCascadeClassifier_MaskGenerator { + impl std::fmt::Debug for BaseCascadeClassifier_MaskGenerator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_BaseCascadeClassifier_MaskGenerator_delete(self.as_raw_mut_BaseCascadeClassifier_MaskGenerator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BaseCascadeClassifier_MaskGenerator") + .finish() } } - unsafe impl Send for BaseCascadeClassifier_MaskGenerator {} - impl crate::objdetect::BaseCascadeClassifier_MaskGeneratorTraitConst for BaseCascadeClassifier_MaskGenerator { #[inline] fn as_raw_BaseCascadeClassifier_MaskGenerator(&self) -> *const c_void { self.as_raw() } } @@ -1171,15 +1176,63 @@ pub mod objdetect { boxed_ref! { BaseCascadeClassifier_MaskGenerator, crate::objdetect::BaseCascadeClassifier_MaskGeneratorTraitConst, as_raw_BaseCascadeClassifier_MaskGenerator, crate::objdetect::BaseCascadeClassifier_MaskGeneratorTrait, as_raw_mut_BaseCascadeClassifier_MaskGenerator } - impl BaseCascadeClassifier_MaskGenerator { + /// @example samples/cpp/facedetect.cpp + /// This program demonstrates usage of the Cascade classifier class + /// \image html Cascade_Classifier_Tutorial_Result_Haar.jpg "Sample screenshot" width=321 height=254 + /// + /// Cascade classifier class for object detection. + pub struct CascadeClassifier { + ptr: *mut c_void, + } + + opencv_type_boxed! { CascadeClassifier } + + impl Drop for CascadeClassifier { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_CascadeClassifier_delete(self.as_raw_mut_CascadeClassifier()) }; + } } - impl std::fmt::Debug for BaseCascadeClassifier_MaskGenerator { + unsafe impl Send for CascadeClassifier {} + + impl CascadeClassifier { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BaseCascadeClassifier_MaskGenerator") - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_CascadeClassifier_CascadeClassifier(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::CascadeClassifier::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Loads a classifier from a file. + /// + /// ## Parameters + /// * filename: Name of the file from which the classifier is loaded. + #[inline] + pub fn new(filename: &str) -> Result { + extern_container_arg!(filename); + return_send!(via ocvrs_return); + unsafe { sys::cv_CascadeClassifier_CascadeClassifier_const_StringR(filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::CascadeClassifier::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn convert(oldcascade: &str, newcascade: &str) -> Result { + extern_container_arg!(oldcascade); + extern_container_arg!(newcascade); + return_send!(via ocvrs_return); + unsafe { sys::cv_CascadeClassifier_convert_const_StringR_const_StringR(oldcascade.opencv_as_extern(), newcascade.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } + } /// Constant methods for [crate::objdetect::CascadeClassifier] @@ -1531,26 +1584,14 @@ pub mod objdetect { } - /// @example samples/cpp/facedetect.cpp - /// This program demonstrates usage of the Cascade classifier class - /// \image html Cascade_Classifier_Tutorial_Result_Haar.jpg "Sample screenshot" width=321 height=254 - /// - /// Cascade classifier class for object detection. - pub struct CascadeClassifier { - ptr: *mut c_void, - } - - opencv_type_boxed! { CascadeClassifier } - - impl Drop for CascadeClassifier { + impl std::fmt::Debug for CascadeClassifier { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_CascadeClassifier_delete(self.as_raw_mut_CascadeClassifier()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CascadeClassifier") + .finish() } } - unsafe impl Send for CascadeClassifier {} - impl crate::objdetect::CascadeClassifierTraitConst for CascadeClassifier { #[inline] fn as_raw_CascadeClassifier(&self) -> *const c_void { self.as_raw() } } @@ -1561,53 +1602,34 @@ pub mod objdetect { boxed_ref! { CascadeClassifier, crate::objdetect::CascadeClassifierTraitConst, as_raw_CascadeClassifier, crate::objdetect::CascadeClassifierTrait, as_raw_mut_CascadeClassifier } - impl CascadeClassifier { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_CascadeClassifier_CascadeClassifier(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::CascadeClassifier::opencv_from_extern(ret) }; - Ok(ret) - } + pub struct DetectionBasedTracker { + ptr: *mut c_void, + } - /// Loads a classifier from a file. - /// - /// ## Parameters - /// * filename: Name of the file from which the classifier is loaded. + opencv_type_boxed! { DetectionBasedTracker } + + impl Drop for DetectionBasedTracker { #[inline] - pub fn new(filename: &str) -> Result { - extern_container_arg!(filename); - return_send!(via ocvrs_return); - unsafe { sys::cv_CascadeClassifier_CascadeClassifier_const_StringR(filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::CascadeClassifier::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_DetectionBasedTracker_delete(self.as_raw_mut_DetectionBasedTracker()) }; } + } + + unsafe impl Send for DetectionBasedTracker {} + impl DetectionBasedTracker { #[inline] - pub fn convert(oldcascade: &str, newcascade: &str) -> Result { - extern_container_arg!(oldcascade); - extern_container_arg!(newcascade); + pub fn new(mut main_detector: core::Ptr, mut tracking_detector: core::Ptr, params: &impl crate::objdetect::DetectionBasedTracker_ParametersTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_CascadeClassifier_convert_const_StringR_const_StringR(oldcascade.opencv_as_extern(), newcascade.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_DetectionBasedTracker_DetectionBasedTracker_PtrLIDetectorG_PtrLIDetectorG_const_ParametersR(main_detector.as_raw_mut_PtrOfDetectionBasedTracker_IDetector(), tracking_detector.as_raw_mut_PtrOfDetectionBasedTracker_IDetector(), params.as_raw_DetectionBasedTracker_Parameters(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::DetectionBasedTracker::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for CascadeClassifier { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CascadeClassifier") - .finish() - } - } - /// Constant methods for [crate::objdetect::DetectionBasedTracker] pub trait DetectionBasedTrackerTraitConst { fn as_raw_DetectionBasedTracker(&self) -> *const c_void; @@ -1711,21 +1733,14 @@ pub mod objdetect { } - pub struct DetectionBasedTracker { - ptr: *mut c_void, - } - - opencv_type_boxed! { DetectionBasedTracker } - - impl Drop for DetectionBasedTracker { + impl std::fmt::Debug for DetectionBasedTracker { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_DetectionBasedTracker_delete(self.as_raw_mut_DetectionBasedTracker()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DetectionBasedTracker") + .finish() } } - unsafe impl Send for DetectionBasedTracker {} - impl crate::objdetect::DetectionBasedTrackerTraitConst for DetectionBasedTracker { #[inline] fn as_raw_DetectionBasedTracker(&self) -> *const c_void { self.as_raw() } } @@ -1736,27 +1751,34 @@ pub mod objdetect { boxed_ref! { DetectionBasedTracker, crate::objdetect::DetectionBasedTrackerTraitConst, as_raw_DetectionBasedTracker, crate::objdetect::DetectionBasedTrackerTrait, as_raw_mut_DetectionBasedTracker } - impl DetectionBasedTracker { + pub struct DetectionBasedTracker_ExtObject { + ptr: *mut c_void, + } + + opencv_type_boxed! { DetectionBasedTracker_ExtObject } + + impl Drop for DetectionBasedTracker_ExtObject { #[inline] - pub fn new(mut main_detector: core::Ptr, mut tracking_detector: core::Ptr, params: &impl crate::objdetect::DetectionBasedTracker_ParametersTraitConst) -> Result { + fn drop(&mut self) { + unsafe { sys::cv_DetectionBasedTracker_ExtObject_delete(self.as_raw_mut_DetectionBasedTracker_ExtObject()) }; + } + } + + unsafe impl Send for DetectionBasedTracker_ExtObject {} + + impl DetectionBasedTracker_ExtObject { + #[inline] + pub fn new(_id: i32, _location: core::Rect, _status: crate::objdetect::DetectionBasedTracker_ObjectStatus) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_DetectionBasedTracker_DetectionBasedTracker_PtrLIDetectorG_PtrLIDetectorG_const_ParametersR(main_detector.as_raw_mut_PtrOfDetectionBasedTracker_IDetector(), tracking_detector.as_raw_mut_PtrOfDetectionBasedTracker_IDetector(), params.as_raw_DetectionBasedTracker_Parameters(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_DetectionBasedTracker_ExtObject_ExtObject_int_Rect_ObjectStatus(_id, &_location, _status, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::DetectionBasedTracker::opencv_from_extern(ret) }; + let ret = unsafe { crate::objdetect::DetectionBasedTracker_ExtObject::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for DetectionBasedTracker { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DetectionBasedTracker") - .finish() - } - } - /// Constant methods for [crate::objdetect::DetectionBasedTracker_ExtObject] pub trait DetectionBasedTracker_ExtObjectTraitConst { fn as_raw_DetectionBasedTracker_ExtObject(&self) -> *const c_void; @@ -1809,21 +1831,24 @@ pub mod objdetect { } - pub struct DetectionBasedTracker_ExtObject { - ptr: *mut c_void, + impl Clone for DetectionBasedTracker_ExtObject { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_DetectionBasedTracker_ExtObject_implicitClone_const(self.as_raw_DetectionBasedTracker_ExtObject())) } + } } - opencv_type_boxed! { DetectionBasedTracker_ExtObject } - - impl Drop for DetectionBasedTracker_ExtObject { + impl std::fmt::Debug for DetectionBasedTracker_ExtObject { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_DetectionBasedTracker_ExtObject_delete(self.as_raw_mut_DetectionBasedTracker_ExtObject()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DetectionBasedTracker_ExtObject") + .field("id", &crate::objdetect::DetectionBasedTracker_ExtObjectTraitConst::id(self)) + .field("location", &crate::objdetect::DetectionBasedTracker_ExtObjectTraitConst::location(self)) + .field("status", &crate::objdetect::DetectionBasedTracker_ExtObjectTraitConst::status(self)) + .finish() } } - unsafe impl Send for DetectionBasedTracker_ExtObject {} - impl crate::objdetect::DetectionBasedTracker_ExtObjectTraitConst for DetectionBasedTracker_ExtObject { #[inline] fn as_raw_DetectionBasedTracker_ExtObject(&self) -> *const c_void { self.as_raw() } } @@ -1834,37 +1859,21 @@ pub mod objdetect { boxed_ref! { DetectionBasedTracker_ExtObject, crate::objdetect::DetectionBasedTracker_ExtObjectTraitConst, as_raw_DetectionBasedTracker_ExtObject, crate::objdetect::DetectionBasedTracker_ExtObjectTrait, as_raw_mut_DetectionBasedTracker_ExtObject } - impl DetectionBasedTracker_ExtObject { - #[inline] - pub fn new(_id: i32, _location: core::Rect, _status: crate::objdetect::DetectionBasedTracker_ObjectStatus) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_DetectionBasedTracker_ExtObject_ExtObject_int_Rect_ObjectStatus(_id, &_location, _status, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::DetectionBasedTracker_ExtObject::opencv_from_extern(ret) }; - Ok(ret) - } - + pub struct DetectionBasedTracker_IDetector { + ptr: *mut c_void, } - impl Clone for DetectionBasedTracker_ExtObject { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_DetectionBasedTracker_ExtObject_implicitClone_const(self.as_raw_DetectionBasedTracker_ExtObject())) } - } - } + opencv_type_boxed! { DetectionBasedTracker_IDetector } - impl std::fmt::Debug for DetectionBasedTracker_ExtObject { + impl Drop for DetectionBasedTracker_IDetector { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DetectionBasedTracker_ExtObject") - .field("id", &crate::objdetect::DetectionBasedTracker_ExtObjectTraitConst::id(self)) - .field("location", &crate::objdetect::DetectionBasedTracker_ExtObjectTraitConst::location(self)) - .field("status", &crate::objdetect::DetectionBasedTracker_ExtObjectTraitConst::status(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_DetectionBasedTracker_IDetector_delete(self.as_raw_mut_DetectionBasedTracker_IDetector()) }; } } + unsafe impl Send for DetectionBasedTracker_IDetector {} + /// Constant methods for [crate::objdetect::DetectionBasedTracker_IDetector] pub trait DetectionBasedTracker_IDetectorTraitConst { fn as_raw_DetectionBasedTracker_IDetector(&self) -> *const c_void; @@ -1958,21 +1967,14 @@ pub mod objdetect { } - pub struct DetectionBasedTracker_IDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { DetectionBasedTracker_IDetector } - - impl Drop for DetectionBasedTracker_IDetector { + impl std::fmt::Debug for DetectionBasedTracker_IDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_DetectionBasedTracker_IDetector_delete(self.as_raw_mut_DetectionBasedTracker_IDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DetectionBasedTracker_IDetector") + .finish() } } - unsafe impl Send for DetectionBasedTracker_IDetector {} - impl crate::objdetect::DetectionBasedTracker_IDetectorTraitConst for DetectionBasedTracker_IDetector { #[inline] fn as_raw_DetectionBasedTracker_IDetector(&self) -> *const c_void { self.as_raw() } } @@ -1983,15 +1985,32 @@ pub mod objdetect { boxed_ref! { DetectionBasedTracker_IDetector, crate::objdetect::DetectionBasedTracker_IDetectorTraitConst, as_raw_DetectionBasedTracker_IDetector, crate::objdetect::DetectionBasedTracker_IDetectorTrait, as_raw_mut_DetectionBasedTracker_IDetector } - impl DetectionBasedTracker_IDetector { + pub struct DetectionBasedTracker_Parameters { + ptr: *mut c_void, } - impl std::fmt::Debug for DetectionBasedTracker_IDetector { + opencv_type_boxed! { DetectionBasedTracker_Parameters } + + impl Drop for DetectionBasedTracker_Parameters { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DetectionBasedTracker_IDetector") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_DetectionBasedTracker_Parameters_delete(self.as_raw_mut_DetectionBasedTracker_Parameters()) }; + } + } + + unsafe impl Send for DetectionBasedTracker_Parameters {} + + impl DetectionBasedTracker_Parameters { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_DetectionBasedTracker_Parameters_Parameters(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::DetectionBasedTracker_Parameters::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::objdetect::DetectionBasedTracker_Parameters] @@ -2030,21 +2049,16 @@ pub mod objdetect { } - pub struct DetectionBasedTracker_Parameters { - ptr: *mut c_void, - } - - opencv_type_boxed! { DetectionBasedTracker_Parameters } - - impl Drop for DetectionBasedTracker_Parameters { + impl std::fmt::Debug for DetectionBasedTracker_Parameters { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_DetectionBasedTracker_Parameters_delete(self.as_raw_mut_DetectionBasedTracker_Parameters()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DetectionBasedTracker_Parameters") + .field("max_track_lifetime", &crate::objdetect::DetectionBasedTracker_ParametersTraitConst::max_track_lifetime(self)) + .field("min_detection_period", &crate::objdetect::DetectionBasedTracker_ParametersTraitConst::min_detection_period(self)) + .finish() } } - unsafe impl Send for DetectionBasedTracker_Parameters {} - impl crate::objdetect::DetectionBasedTracker_ParametersTraitConst for DetectionBasedTracker_Parameters { #[inline] fn as_raw_DetectionBasedTracker_Parameters(&self) -> *const c_void { self.as_raw() } } @@ -2055,27 +2069,31 @@ pub mod objdetect { boxed_ref! { DetectionBasedTracker_Parameters, crate::objdetect::DetectionBasedTracker_ParametersTraitConst, as_raw_DetectionBasedTracker_Parameters, crate::objdetect::DetectionBasedTracker_ParametersTrait, as_raw_mut_DetectionBasedTracker_Parameters } - impl DetectionBasedTracker_Parameters { + /// struct for detection region of interest (ROI) + pub struct DetectionROI { + ptr: *mut c_void, + } + + opencv_type_boxed! { DetectionROI } + + impl Drop for DetectionROI { #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_DetectionBasedTracker_Parameters_Parameters(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::DetectionBasedTracker_Parameters::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_DetectionROI_delete(self.as_raw_mut_DetectionROI()) }; } - } - impl std::fmt::Debug for DetectionBasedTracker_Parameters { + unsafe impl Send for DetectionROI {} + + impl DetectionROI { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DetectionBasedTracker_Parameters") - .field("max_track_lifetime", &crate::objdetect::DetectionBasedTracker_ParametersTraitConst::max_track_lifetime(self)) - .field("min_detection_period", &crate::objdetect::DetectionBasedTracker_ParametersTraitConst::min_detection_period(self)) - .finish() + pub fn default() -> crate::objdetect::DetectionROI { + let ret = unsafe { sys::cv_DetectionROI_defaultNew_const() }; + let ret = unsafe { crate::objdetect::DetectionROI::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::objdetect::DetectionROI] @@ -2134,22 +2152,25 @@ pub mod objdetect { } - /// struct for detection region of interest (ROI) - pub struct DetectionROI { - ptr: *mut c_void, + impl Default for DetectionROI { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { DetectionROI } - - impl Drop for DetectionROI { + impl std::fmt::Debug for DetectionROI { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_DetectionROI_delete(self.as_raw_mut_DetectionROI()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DetectionROI") + .field("scale", &crate::objdetect::DetectionROITraitConst::scale(self)) + .field("locations", &crate::objdetect::DetectionROITraitConst::locations(self)) + .field("confidences", &crate::objdetect::DetectionROITraitConst::confidences(self)) + .finish() } } - unsafe impl Send for DetectionROI {} - impl crate::objdetect::DetectionROITraitConst for DetectionROI { #[inline] fn as_raw_DetectionROI(&self) -> *const c_void { self.as_raw() } } @@ -2160,251 +2181,87 @@ pub mod objdetect { boxed_ref! { DetectionROI, crate::objdetect::DetectionROITraitConst, as_raw_DetectionROI, crate::objdetect::DetectionROITrait, as_raw_mut_DetectionROI } - impl DetectionROI { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_DetectionROI_defaultNew_const()) } - } - + /// DNN-based face detector + /// + /// model download link: + pub struct FaceDetectorYN { + ptr: *mut c_void, } - impl std::fmt::Debug for DetectionROI { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DetectionROI") - .field("scale", &crate::objdetect::DetectionROITraitConst::scale(self)) - .field("locations", &crate::objdetect::DetectionROITraitConst::locations(self)) - .field("confidences", &crate::objdetect::DetectionROITraitConst::confidences(self)) - .finish() - } - } + opencv_type_boxed! { FaceDetectorYN } - impl Default for DetectionROI { + impl Drop for FaceDetectorYN { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + fn drop(&mut self) { + unsafe { sys::cv_FaceDetectorYN_delete(self.as_raw_mut_FaceDetectorYN()) }; } } - /// Constant methods for [crate::objdetect::FaceDetectorYN] - pub trait FaceDetectorYNTraitConst { - fn as_raw_FaceDetectorYN(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::objdetect::FaceDetectorYN] - pub trait FaceDetectorYNTrait: crate::objdetect::FaceDetectorYNTraitConst { - fn as_raw_mut_FaceDetectorYN(&mut self) -> *mut c_void; + unsafe impl Send for FaceDetectorYN {} - /// Set the size for the network input, which overwrites the input size of creating model. Call this method when the size of input image does not match the input size when creating model + impl FaceDetectorYN { + /// Creates an instance of face detector class with given parameters /// /// ## Parameters + /// * model: the path to the requested model + /// * config: the path to the config file for compability, which is not requested for ONNX models /// * input_size: the size of the input image + /// * score_threshold: the threshold to filter out bounding boxes of score smaller than the given value + /// * nms_threshold: the threshold to suppress bounding boxes of IoU bigger than the given value + /// * top_k: keep top K bboxes before NMS + /// * backend_id: the id of backend + /// * target_id: the id of target device + /// + /// ## C++ default parameters + /// * score_threshold: 0.9f + /// * nms_threshold: 0.3f + /// * top_k: 5000 + /// * backend_id: 0 + /// * target_id: 0 #[inline] - fn set_input_size(&mut self, input_size: core::Size) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_FaceDetectorYN_setInputSize_const_SizeR(self.as_raw_mut_FaceDetectorYN(), &input_size, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_input_size(&mut self) -> Result { + pub fn create(model: &str, config: &str, input_size: core::Size, score_threshold: f32, nms_threshold: f32, top_k: i32, backend_id: i32, target_id: i32) -> Result> { + extern_container_arg!(model); + extern_container_arg!(config); return_send!(via ocvrs_return); - unsafe { sys::cv_FaceDetectorYN_getInputSize(self.as_raw_mut_FaceDetectorYN(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_FaceDetectorYN_create_const_StringR_const_StringR_const_SizeR_float_float_int_int_int(model.opencv_as_extern(), config.opencv_as_extern(), &input_size, score_threshold, nms_threshold, top_k, backend_id, target_id, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Set the score threshold to filter out bounding boxes of score less than the given value + /// Creates an instance of face detector class with given parameters /// /// ## Parameters - /// * score_threshold: threshold for filtering out bounding boxes - #[inline] - fn set_score_threshold(&mut self, score_threshold: f32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_FaceDetectorYN_setScoreThreshold_float(self.as_raw_mut_FaceDetectorYN(), score_threshold, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - + /// * model: the path to the requested model + /// * config: the path to the config file for compability, which is not requested for ONNX models + /// * input_size: the size of the input image + /// * score_threshold: the threshold to filter out bounding boxes of score smaller than the given value + /// * nms_threshold: the threshold to suppress bounding boxes of IoU bigger than the given value + /// * top_k: keep top K bboxes before NMS + /// * backend_id: the id of backend + /// * target_id: the id of target device + /// + /// ## Note + /// This alternative version of [FaceDetectorYN::create] function uses the following default values for its arguments: + /// * score_threshold: 0.9f + /// * nms_threshold: 0.3f + /// * top_k: 5000 + /// * backend_id: 0 + /// * target_id: 0 #[inline] - fn get_score_threshold(&mut self) -> Result { + pub fn create_def(model: &str, config: &str, input_size: core::Size) -> Result> { + extern_container_arg!(model); + extern_container_arg!(config); return_send!(via ocvrs_return); - unsafe { sys::cv_FaceDetectorYN_getScoreThreshold(self.as_raw_mut_FaceDetectorYN(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_FaceDetectorYN_create_const_StringR_const_StringR_const_SizeR(model.opencv_as_extern(), config.opencv_as_extern(), &input_size, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Set the Non-maximum-suppression threshold to suppress bounding boxes that have IoU greater than the given value - /// - /// ## Parameters - /// * nms_threshold: threshold for NMS operation - #[inline] - fn set_nms_threshold(&mut self, nms_threshold: f32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_FaceDetectorYN_setNMSThreshold_float(self.as_raw_mut_FaceDetectorYN(), nms_threshold, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_nms_threshold(&mut self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_FaceDetectorYN_getNMSThreshold(self.as_raw_mut_FaceDetectorYN(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Set the number of bounding boxes preserved before NMS - /// - /// ## Parameters - /// * top_k: the number of bounding boxes to preserve from top rank based on score - #[inline] - fn set_top_k(&mut self, top_k: i32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_FaceDetectorYN_setTopK_int(self.as_raw_mut_FaceDetectorYN(), top_k, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_top_k(&mut self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_FaceDetectorYN_getTopK(self.as_raw_mut_FaceDetectorYN(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Detects faces in the input image. Following is an example output. - /// - /// * ![image](https://docs.opencv.org/4.11.0/lena-face-detection.jpg) - /// - /// ## Parameters - /// * image: an image to detect - /// * faces: detection results stored in a 2D cv::Mat of shape [num_faces, 15] - /// * - 0-1: x, y of bbox top left corner - /// * - 2-3: width, height of bbox - /// * - 4-5: x, y of right eye (blue point in the example image) - /// * - 6-7: x, y of left eye (red point in the example image) - /// * - 8-9: x, y of nose tip (green point in the example image) - /// * - 10-11: x, y of right corner of mouth (pink point in the example image) - /// * - 12-13: x, y of left corner of mouth (yellow point in the example image) - /// * - 14: face score - #[inline] - fn detect(&mut self, image: &impl ToInputArray, faces: &mut impl ToOutputArray) -> Result { - input_array_arg!(image); - output_array_arg!(faces); - return_send!(via ocvrs_return); - unsafe { sys::cv_FaceDetectorYN_detect_const__InputArrayR_const__OutputArrayR(self.as_raw_mut_FaceDetectorYN(), image.as_raw__InputArray(), faces.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - /// DNN-based face detector - /// - /// model download link: - pub struct FaceDetectorYN { - ptr: *mut c_void, - } - - opencv_type_boxed! { FaceDetectorYN } - - impl Drop for FaceDetectorYN { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_FaceDetectorYN_delete(self.as_raw_mut_FaceDetectorYN()) }; - } - } - - unsafe impl Send for FaceDetectorYN {} - - impl crate::objdetect::FaceDetectorYNTraitConst for FaceDetectorYN { - #[inline] fn as_raw_FaceDetectorYN(&self) -> *const c_void { self.as_raw() } - } - - impl crate::objdetect::FaceDetectorYNTrait for FaceDetectorYN { - #[inline] fn as_raw_mut_FaceDetectorYN(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { FaceDetectorYN, crate::objdetect::FaceDetectorYNTraitConst, as_raw_FaceDetectorYN, crate::objdetect::FaceDetectorYNTrait, as_raw_mut_FaceDetectorYN } - - impl FaceDetectorYN { - /// Creates an instance of face detector class with given parameters - /// - /// ## Parameters - /// * model: the path to the requested model - /// * config: the path to the config file for compability, which is not requested for ONNX models - /// * input_size: the size of the input image - /// * score_threshold: the threshold to filter out bounding boxes of score smaller than the given value - /// * nms_threshold: the threshold to suppress bounding boxes of IoU bigger than the given value - /// * top_k: keep top K bboxes before NMS - /// * backend_id: the id of backend - /// * target_id: the id of target device - /// - /// ## C++ default parameters - /// * score_threshold: 0.9f - /// * nms_threshold: 0.3f - /// * top_k: 5000 - /// * backend_id: 0 - /// * target_id: 0 - #[inline] - pub fn create(model: &str, config: &str, input_size: core::Size, score_threshold: f32, nms_threshold: f32, top_k: i32, backend_id: i32, target_id: i32) -> Result> { - extern_container_arg!(model); - extern_container_arg!(config); - return_send!(via ocvrs_return); - unsafe { sys::cv_FaceDetectorYN_create_const_StringR_const_StringR_const_SizeR_float_float_int_int_int(model.opencv_as_extern(), config.opencv_as_extern(), &input_size, score_threshold, nms_threshold, top_k, backend_id, target_id, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Creates an instance of face detector class with given parameters - /// - /// ## Parameters - /// * model: the path to the requested model - /// * config: the path to the config file for compability, which is not requested for ONNX models - /// * input_size: the size of the input image - /// * score_threshold: the threshold to filter out bounding boxes of score smaller than the given value - /// * nms_threshold: the threshold to suppress bounding boxes of IoU bigger than the given value - /// * top_k: keep top K bboxes before NMS - /// * backend_id: the id of backend - /// * target_id: the id of target device - /// - /// ## Note - /// This alternative version of [FaceDetectorYN::create] function uses the following default values for its arguments: - /// * score_threshold: 0.9f - /// * nms_threshold: 0.3f - /// * top_k: 5000 - /// * backend_id: 0 - /// * target_id: 0 - #[inline] - pub fn create_def(model: &str, config: &str, input_size: core::Size) -> Result> { - extern_container_arg!(model); - extern_container_arg!(config); - return_send!(via ocvrs_return); - unsafe { sys::cv_FaceDetectorYN_create_const_StringR_const_StringR_const_SizeR(model.opencv_as_extern(), config.opencv_as_extern(), &input_size, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Creates an instance of face detector class with given parameters + /// Creates an instance of face detector class with given parameters /// /// ## Parameters /// * model: the path to the requested model @@ -2479,90 +2336,125 @@ pub mod objdetect { } - impl std::fmt::Debug for FaceDetectorYN { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FaceDetectorYN") - .finish() - } + /// Constant methods for [crate::objdetect::FaceDetectorYN] + pub trait FaceDetectorYNTraitConst { + fn as_raw_FaceDetectorYN(&self) -> *const c_void; + } - /// Constant methods for [crate::objdetect::FaceRecognizerSF] - pub trait FaceRecognizerSFTraitConst { - fn as_raw_FaceRecognizerSF(&self) -> *const c_void; + /// Mutable methods for [crate::objdetect::FaceDetectorYN] + pub trait FaceDetectorYNTrait: crate::objdetect::FaceDetectorYNTraitConst { + fn as_raw_mut_FaceDetectorYN(&mut self) -> *mut c_void; - /// Aligns detected face with the source input image and crops it + /// Set the size for the network input, which overwrites the input size of creating model. Call this method when the size of input image does not match the input size when creating model + /// /// ## Parameters - /// * src_img: input image - /// * face_box: the detected face result from the input image - /// * aligned_img: output aligned image + /// * input_size: the size of the input image #[inline] - fn align_crop(&self, src_img: &impl ToInputArray, face_box: &impl ToInputArray, aligned_img: &mut impl ToOutputArray) -> Result<()> { - input_array_arg!(src_img); - input_array_arg!(face_box); - output_array_arg!(aligned_img); + fn set_input_size(&mut self, input_size: core::Size) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_FaceRecognizerSF_alignCrop_const_const__InputArrayR_const__InputArrayR_const__OutputArrayR(self.as_raw_FaceRecognizerSF(), src_img.as_raw__InputArray(), face_box.as_raw__InputArray(), aligned_img.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_FaceDetectorYN_setInputSize_const_SizeR(self.as_raw_mut_FaceDetectorYN(), &input_size, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// Calculates the distance between two face features - /// ## Parameters - /// * face_feature1: the first input feature - /// * face_feature2: the second input feature of the same size and the same type as face_feature1 - /// * dis_type: defines how to calculate the distance between two face features with optional values "FR_COSINE" or "FR_NORM_L2" - /// - /// ## C++ default parameters - /// * dis_type: FaceRecognizerSF::FR_COSINE #[inline] - fn match_(&self, face_feature1: &impl ToInputArray, face_feature2: &impl ToInputArray, dis_type: i32) -> Result { - input_array_arg!(face_feature1); - input_array_arg!(face_feature2); + fn get_input_size(&mut self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_FaceRecognizerSF_match_const_const__InputArrayR_const__InputArrayR_int(self.as_raw_FaceRecognizerSF(), face_feature1.as_raw__InputArray(), face_feature2.as_raw__InputArray(), dis_type, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_FaceDetectorYN_getInputSize(self.as_raw_mut_FaceDetectorYN(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// Calculates the distance between two face features + /// Set the score threshold to filter out bounding boxes of score less than the given value + /// /// ## Parameters - /// * face_feature1: the first input feature - /// * face_feature2: the second input feature of the same size and the same type as face_feature1 - /// * dis_type: defines how to calculate the distance between two face features with optional values "FR_COSINE" or "FR_NORM_L2" + /// * score_threshold: threshold for filtering out bounding boxes + #[inline] + fn set_score_threshold(&mut self, score_threshold: f32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_FaceDetectorYN_setScoreThreshold_float(self.as_raw_mut_FaceDetectorYN(), score_threshold, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn get_score_threshold(&mut self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_FaceDetectorYN_getScoreThreshold(self.as_raw_mut_FaceDetectorYN(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Set the Non-maximum-suppression threshold to suppress bounding boxes that have IoU greater than the given value /// - /// ## Note - /// This alternative version of [FaceRecognizerSFTraitConst::match_] function uses the following default values for its arguments: - /// * dis_type: FaceRecognizerSF::FR_COSINE + /// ## Parameters + /// * nms_threshold: threshold for NMS operation #[inline] - fn match__def(&self, face_feature1: &impl ToInputArray, face_feature2: &impl ToInputArray) -> Result { - input_array_arg!(face_feature1); - input_array_arg!(face_feature2); + fn set_nms_threshold(&mut self, nms_threshold: f32) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_FaceRecognizerSF_match_const_const__InputArrayR_const__InputArrayR(self.as_raw_FaceRecognizerSF(), face_feature1.as_raw__InputArray(), face_feature2.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_FaceDetectorYN_setNMSThreshold_float(self.as_raw_mut_FaceDetectorYN(), nms_threshold, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - } + #[inline] + fn get_nms_threshold(&mut self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_FaceDetectorYN_getNMSThreshold(self.as_raw_mut_FaceDetectorYN(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - /// Mutable methods for [crate::objdetect::FaceRecognizerSF] - pub trait FaceRecognizerSFTrait: crate::objdetect::FaceRecognizerSFTraitConst { - fn as_raw_mut_FaceRecognizerSF(&mut self) -> *mut c_void; + /// Set the number of bounding boxes preserved before NMS + /// + /// ## Parameters + /// * top_k: the number of bounding boxes to preserve from top rank based on score + #[inline] + fn set_top_k(&mut self, top_k: i32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_FaceDetectorYN_setTopK_int(self.as_raw_mut_FaceDetectorYN(), top_k, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - /// Extracts face feature from aligned image + #[inline] + fn get_top_k(&mut self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_FaceDetectorYN_getTopK(self.as_raw_mut_FaceDetectorYN(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Detects faces in the input image. Following is an example output. + /// + /// * ![image](https://docs.opencv.org/4.11.0/lena-face-detection.jpg) + /// /// ## Parameters - /// * aligned_img: input aligned image - /// * face_feature: output face feature + /// * image: an image to detect + /// * faces: detection results stored in a 2D cv::Mat of shape [num_faces, 15] + /// * - 0-1: x, y of bbox top left corner + /// * - 2-3: width, height of bbox + /// * - 4-5: x, y of right eye (blue point in the example image) + /// * - 6-7: x, y of left eye (red point in the example image) + /// * - 8-9: x, y of nose tip (green point in the example image) + /// * - 10-11: x, y of right corner of mouth (pink point in the example image) + /// * - 12-13: x, y of left corner of mouth (yellow point in the example image) + /// * - 14: face score #[inline] - fn feature(&mut self, aligned_img: &impl ToInputArray, face_feature: &mut impl ToOutputArray) -> Result<()> { - input_array_arg!(aligned_img); - output_array_arg!(face_feature); + fn detect(&mut self, image: &impl ToInputArray, faces: &mut impl ToOutputArray) -> Result { + input_array_arg!(image); + output_array_arg!(faces); return_send!(via ocvrs_return); - unsafe { sys::cv_FaceRecognizerSF_feature_const__InputArrayR_const__OutputArrayR(self.as_raw_mut_FaceRecognizerSF(), aligned_img.as_raw__InputArray(), face_feature.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_FaceDetectorYN_detect_const__InputArrayR_const__OutputArrayR(self.as_raw_mut_FaceDetectorYN(), image.as_raw__InputArray(), faces.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -2570,6 +2462,24 @@ pub mod objdetect { } + impl std::fmt::Debug for FaceDetectorYN { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FaceDetectorYN") + .finish() + } + } + + impl crate::objdetect::FaceDetectorYNTraitConst for FaceDetectorYN { + #[inline] fn as_raw_FaceDetectorYN(&self) -> *const c_void { self.as_raw() } + } + + impl crate::objdetect::FaceDetectorYNTrait for FaceDetectorYN { + #[inline] fn as_raw_mut_FaceDetectorYN(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { FaceDetectorYN, crate::objdetect::FaceDetectorYNTraitConst, as_raw_FaceDetectorYN, crate::objdetect::FaceDetectorYNTrait, as_raw_mut_FaceDetectorYN } + /// DNN-based face recognizer /// /// model download link: @@ -2588,16 +2498,6 @@ pub mod objdetect { unsafe impl Send for FaceRecognizerSF {} - impl crate::objdetect::FaceRecognizerSFTraitConst for FaceRecognizerSF { - #[inline] fn as_raw_FaceRecognizerSF(&self) -> *const c_void { self.as_raw() } - } - - impl crate::objdetect::FaceRecognizerSFTrait for FaceRecognizerSF { - #[inline] fn as_raw_mut_FaceRecognizerSF(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { FaceRecognizerSF, crate::objdetect::FaceRecognizerSFTraitConst, as_raw_FaceRecognizerSF, crate::objdetect::FaceRecognizerSFTrait, as_raw_mut_FaceRecognizerSF } - impl FaceRecognizerSF { /// Creates an instance of this class with given parameters /// ## Parameters @@ -2659,39 +2559,122 @@ pub mod objdetect { /// * backend_id: 0 /// * target_id: 0 #[inline] - pub fn create_1(framework: &str, buffer_model: &core::Vector, buffer_config: &core::Vector, backend_id: i32, target_id: i32) -> Result> { - extern_container_arg!(framework); + pub fn create_1(framework: &str, buffer_model: &core::Vector, buffer_config: &core::Vector, backend_id: i32, target_id: i32) -> Result> { + extern_container_arg!(framework); + return_send!(via ocvrs_return); + unsafe { sys::cv_FaceRecognizerSF_create_const_StringR_const_vectorLunsigned_charGR_const_vectorLunsigned_charGR_int_int(framework.opencv_as_extern(), buffer_model.as_raw_VectorOfu8(), buffer_config.as_raw_VectorOfu8(), backend_id, target_id, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Creates an instance of this class from a buffer containing the model weights and configuration. + /// ## Parameters + /// * framework: Name of the framework (ONNX, etc.) + /// * bufferModel: A buffer containing the binary model weights. + /// * bufferConfig: A buffer containing the network configuration. + /// * backend_id: The id of the backend. + /// * target_id: The id of the target device. + /// + /// ## Returns + /// A pointer to the created instance of FaceRecognizerSF. + /// + /// ## Note + /// This alternative version of [FaceRecognizerSF::create] function uses the following default values for its arguments: + /// * backend_id: 0 + /// * target_id: 0 + #[inline] + pub fn create_def_1(framework: &str, buffer_model: &core::Vector, buffer_config: &core::Vector) -> Result> { + extern_container_arg!(framework); + return_send!(via ocvrs_return); + unsafe { sys::cv_FaceRecognizerSF_create_const_StringR_const_vectorLunsigned_charGR_const_vectorLunsigned_charGR(framework.opencv_as_extern(), buffer_model.as_raw_VectorOfu8(), buffer_config.as_raw_VectorOfu8(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::objdetect::FaceRecognizerSF] + pub trait FaceRecognizerSFTraitConst { + fn as_raw_FaceRecognizerSF(&self) -> *const c_void; + + /// Aligns detected face with the source input image and crops it + /// ## Parameters + /// * src_img: input image + /// * face_box: the detected face result from the input image + /// * aligned_img: output aligned image + #[inline] + fn align_crop(&self, src_img: &impl ToInputArray, face_box: &impl ToInputArray, aligned_img: &mut impl ToOutputArray) -> Result<()> { + input_array_arg!(src_img); + input_array_arg!(face_box); + output_array_arg!(aligned_img); + return_send!(via ocvrs_return); + unsafe { sys::cv_FaceRecognizerSF_alignCrop_const_const__InputArrayR_const__InputArrayR_const__OutputArrayR(self.as_raw_FaceRecognizerSF(), src_img.as_raw__InputArray(), face_box.as_raw__InputArray(), aligned_img.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Calculates the distance between two face features + /// ## Parameters + /// * face_feature1: the first input feature + /// * face_feature2: the second input feature of the same size and the same type as face_feature1 + /// * dis_type: defines how to calculate the distance between two face features with optional values "FR_COSINE" or "FR_NORM_L2" + /// + /// ## C++ default parameters + /// * dis_type: FaceRecognizerSF::FR_COSINE + #[inline] + fn match_(&self, face_feature1: &impl ToInputArray, face_feature2: &impl ToInputArray, dis_type: i32) -> Result { + input_array_arg!(face_feature1); + input_array_arg!(face_feature2); + return_send!(via ocvrs_return); + unsafe { sys::cv_FaceRecognizerSF_match_const_const__InputArrayR_const__InputArrayR_int(self.as_raw_FaceRecognizerSF(), face_feature1.as_raw__InputArray(), face_feature2.as_raw__InputArray(), dis_type, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Calculates the distance between two face features + /// ## Parameters + /// * face_feature1: the first input feature + /// * face_feature2: the second input feature of the same size and the same type as face_feature1 + /// * dis_type: defines how to calculate the distance between two face features with optional values "FR_COSINE" or "FR_NORM_L2" + /// + /// ## Note + /// This alternative version of [FaceRecognizerSFTraitConst::match_] function uses the following default values for its arguments: + /// * dis_type: FaceRecognizerSF::FR_COSINE + #[inline] + fn match__def(&self, face_feature1: &impl ToInputArray, face_feature2: &impl ToInputArray) -> Result { + input_array_arg!(face_feature1); + input_array_arg!(face_feature2); return_send!(via ocvrs_return); - unsafe { sys::cv_FaceRecognizerSF_create_const_StringR_const_vectorLunsigned_charGR_const_vectorLunsigned_charGR_int_int(framework.opencv_as_extern(), buffer_model.as_raw_VectorOfu8(), buffer_config.as_raw_VectorOfu8(), backend_id, target_id, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_FaceRecognizerSF_match_const_const__InputArrayR_const__InputArrayR(self.as_raw_FaceRecognizerSF(), face_feature1.as_raw__InputArray(), face_feature2.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Creates an instance of this class from a buffer containing the model weights and configuration. + } + + /// Mutable methods for [crate::objdetect::FaceRecognizerSF] + pub trait FaceRecognizerSFTrait: crate::objdetect::FaceRecognizerSFTraitConst { + fn as_raw_mut_FaceRecognizerSF(&mut self) -> *mut c_void; + + /// Extracts face feature from aligned image /// ## Parameters - /// * framework: Name of the framework (ONNX, etc.) - /// * bufferModel: A buffer containing the binary model weights. - /// * bufferConfig: A buffer containing the network configuration. - /// * backend_id: The id of the backend. - /// * target_id: The id of the target device. - /// - /// ## Returns - /// A pointer to the created instance of FaceRecognizerSF. - /// - /// ## Note - /// This alternative version of [FaceRecognizerSF::create] function uses the following default values for its arguments: - /// * backend_id: 0 - /// * target_id: 0 + /// * aligned_img: input aligned image + /// * face_feature: output face feature #[inline] - pub fn create_def_1(framework: &str, buffer_model: &core::Vector, buffer_config: &core::Vector) -> Result> { - extern_container_arg!(framework); + fn feature(&mut self, aligned_img: &impl ToInputArray, face_feature: &mut impl ToOutputArray) -> Result<()> { + input_array_arg!(aligned_img); + output_array_arg!(face_feature); return_send!(via ocvrs_return); - unsafe { sys::cv_FaceRecognizerSF_create_const_StringR_const_vectorLunsigned_charGR_const_vectorLunsigned_charGR(framework.opencv_as_extern(), buffer_model.as_raw_VectorOfu8(), buffer_config.as_raw_VectorOfu8(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_FaceRecognizerSF_feature_const__InputArrayR_const__OutputArrayR(self.as_raw_mut_FaceRecognizerSF(), aligned_img.as_raw__InputArray(), face_feature.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } @@ -2705,6 +2688,58 @@ pub mod objdetect { } } + impl crate::objdetect::FaceRecognizerSFTraitConst for FaceRecognizerSF { + #[inline] fn as_raw_FaceRecognizerSF(&self) -> *const c_void { self.as_raw() } + } + + impl crate::objdetect::FaceRecognizerSFTrait for FaceRecognizerSF { + #[inline] fn as_raw_mut_FaceRecognizerSF(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { FaceRecognizerSF, crate::objdetect::FaceRecognizerSFTraitConst, as_raw_FaceRecognizerSF, crate::objdetect::FaceRecognizerSFTrait, as_raw_mut_FaceRecognizerSF } + + pub struct GraphicalCodeDetector { + ptr: *mut c_void, + } + + opencv_type_boxed! { GraphicalCodeDetector } + + impl Drop for GraphicalCodeDetector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_GraphicalCodeDetector_delete(self.as_raw_mut_GraphicalCodeDetector()) }; + } + } + + unsafe impl Send for GraphicalCodeDetector {} + + impl GraphicalCodeDetector { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_GraphicalCodeDetector_GraphicalCodeDetector(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::GraphicalCodeDetector::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn copy(unnamed: &impl crate::objdetect::GraphicalCodeDetectorTraitConst) -> crate::objdetect::GraphicalCodeDetector { + let ret = unsafe { sys::cv_GraphicalCodeDetector_GraphicalCodeDetector_const_GraphicalCodeDetectorR(unnamed.as_raw_GraphicalCodeDetector()) }; + let ret = unsafe { crate::objdetect::GraphicalCodeDetector::opencv_from_extern(ret) }; + ret + } + + #[inline] + pub fn copy_mut(mut unnamed: crate::objdetect::GraphicalCodeDetector) -> crate::objdetect::GraphicalCodeDetector { + let ret = unsafe { sys::cv_GraphicalCodeDetector_GraphicalCodeDetector_GraphicalCodeDetectorRR(unnamed.as_raw_mut_GraphicalCodeDetector()) }; + let ret = unsafe { crate::objdetect::GraphicalCodeDetector::opencv_from_extern(ret) }; + ret + } + + } + /// Constant methods for [crate::objdetect::GraphicalCodeDetector] pub trait GraphicalCodeDetectorTraitConst { fn as_raw_GraphicalCodeDetector(&self) -> *const c_void; @@ -2943,21 +2978,21 @@ pub mod objdetect { } - pub struct GraphicalCodeDetector { - ptr: *mut c_void, + impl Clone for GraphicalCodeDetector { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_GraphicalCodeDetector_implicitClone_const(self.as_raw_GraphicalCodeDetector())) } + } } - opencv_type_boxed! { GraphicalCodeDetector } - - impl Drop for GraphicalCodeDetector { + impl std::fmt::Debug for GraphicalCodeDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_GraphicalCodeDetector_delete(self.as_raw_mut_GraphicalCodeDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GraphicalCodeDetector") + .finish() } } - unsafe impl Send for GraphicalCodeDetector {} - impl crate::objdetect::GraphicalCodeDetectorTraitConst for GraphicalCodeDetector { #[inline] fn as_raw_GraphicalCodeDetector(&self) -> *const c_void { self.as_raw() } } @@ -2968,46 +3003,185 @@ pub mod objdetect { boxed_ref! { GraphicalCodeDetector, crate::objdetect::GraphicalCodeDetectorTraitConst, as_raw_GraphicalCodeDetector, crate::objdetect::GraphicalCodeDetectorTrait, as_raw_mut_GraphicalCodeDetector } - impl GraphicalCodeDetector { + /// Implementation of HOG (Histogram of Oriented Gradients) descriptor and object detector. + /// + /// the HOG descriptor algorithm introduced by Navneet Dalal and Bill Triggs [Dalal2005](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Dalal2005) . + /// + /// useful links: + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + pub struct HOGDescriptor { + ptr: *mut c_void, + } + + opencv_type_boxed! { HOGDescriptor } + + impl Drop for HOGDescriptor { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_HOGDescriptor_delete(self.as_raw_mut_HOGDescriptor()) }; + } + } + + unsafe impl Send for HOGDescriptor {} + + impl HOGDescriptor { + /// Creates the HOG descriptor and detector with default parameters. + /// + /// aqual to HOGDescriptor(Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9 ) + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_HOGDescriptor_HOGDescriptor(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::HOGDescriptor::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Creates the HOG descriptor and detector with default parameters. + /// + /// aqual to HOGDescriptor(Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9 ) + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * _winSize: sets winSize with given value. + /// * _blockSize: sets blockSize with given value. + /// * _blockStride: sets blockStride with given value. + /// * _cellSize: sets cellSize with given value. + /// * _nbins: sets nbins with given value. + /// * _derivAperture: sets derivAperture with given value. + /// * _winSigma: sets winSigma with given value. + /// * _histogramNormType: sets histogramNormType with given value. + /// * _L2HysThreshold: sets L2HysThreshold with given value. + /// * _gammaCorrection: sets gammaCorrection with given value. + /// * _nlevels: sets nlevels with given value. + /// * _signedGradient: sets signedGradient with given value. + /// + /// ## C++ default parameters + /// * _deriv_aperture: 1 + /// * _win_sigma: -1 + /// * _histogram_norm_type: HOGDescriptor::L2Hys + /// * _l2_hys_threshold: 0.2 + /// * _gamma_correction: false + /// * _nlevels: HOGDescriptor::DEFAULT_NLEVELS + /// * _signed_gradient: false + #[inline] + pub fn new(_win_size: core::Size, _block_size: core::Size, _block_stride: core::Size, _cell_size: core::Size, _nbins: i32, _deriv_aperture: i32, _win_sigma: f64, _histogram_norm_type: crate::objdetect::HOGDescriptor_HistogramNormType, _l2_hys_threshold: f64, _gamma_correction: bool, _nlevels: i32, _signed_gradient: bool) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_HOGDescriptor_HOGDescriptor_Size_Size_Size_Size_int_int_double_HistogramNormType_double_bool_int_bool(&_win_size, &_block_size, &_block_stride, &_cell_size, _nbins, _deriv_aperture, _win_sigma, _histogram_norm_type, _l2_hys_threshold, _gamma_correction, _nlevels, _signed_gradient, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::HOGDescriptor::opencv_from_extern(ret) }; + Ok(ret) + } + + /// @overload + /// ## Parameters + /// * _winSize: sets winSize with given value. + /// * _blockSize: sets blockSize with given value. + /// * _blockStride: sets blockStride with given value. + /// * _cellSize: sets cellSize with given value. + /// * _nbins: sets nbins with given value. + /// * _derivAperture: sets derivAperture with given value. + /// * _winSigma: sets winSigma with given value. + /// * _histogramNormType: sets histogramNormType with given value. + /// * _L2HysThreshold: sets L2HysThreshold with given value. + /// * _gammaCorrection: sets gammaCorrection with given value. + /// * _nlevels: sets nlevels with given value. + /// * _signedGradient: sets signedGradient with given value. + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * _deriv_aperture: 1 + /// * _win_sigma: -1 + /// * _histogram_norm_type: HOGDescriptor::L2Hys + /// * _l2_hys_threshold: 0.2 + /// * _gamma_correction: false + /// * _nlevels: HOGDescriptor::DEFAULT_NLEVELS + /// * _signed_gradient: false + #[inline] + pub fn new_def(_win_size: core::Size, _block_size: core::Size, _block_stride: core::Size, _cell_size: core::Size, _nbins: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_HOGDescriptor_HOGDescriptor_Size_Size_Size_Size_int(&_win_size, &_block_size, &_block_stride, &_cell_size, _nbins, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::HOGDescriptor::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Creates the HOG descriptor and detector with default parameters. + /// + /// aqual to HOGDescriptor(Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9 ) + /// + /// ## Overloaded parameters + /// + /// + /// Creates the HOG descriptor and detector and loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file. + /// ## Parameters + /// * filename: The file name containing HOGDescriptor properties and coefficients for the linear SVM classifier. + #[inline] + pub fn new_from_file(filename: &str) -> Result { + extern_container_arg!(filename); + return_send!(via ocvrs_return); + unsafe { sys::cv_HOGDescriptor_HOGDescriptor_const_StringR(filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::HOGDescriptor::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Creates the HOG descriptor and detector with default parameters. + /// + /// aqual to HOGDescriptor(Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9 ) + /// + /// ## Overloaded parameters + /// + /// ## Parameters + /// * d: the HOGDescriptor which cloned to create a new one. + #[inline] + pub fn copy(d: &impl crate::objdetect::HOGDescriptorTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_GraphicalCodeDetector_GraphicalCodeDetector(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_HOGDescriptor_HOGDescriptor_const_HOGDescriptorR(d.as_raw_HOGDescriptor(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::GraphicalCodeDetector::opencv_from_extern(ret) }; + let ret = unsafe { crate::objdetect::HOGDescriptor::opencv_from_extern(ret) }; Ok(ret) } + /// Returns coefficients of the classifier trained for people detection (for 64x128 windows). #[inline] - pub fn copy(unnamed: &impl crate::objdetect::GraphicalCodeDetectorTraitConst) -> crate::objdetect::GraphicalCodeDetector { - let ret = unsafe { sys::cv_GraphicalCodeDetector_GraphicalCodeDetector_const_GraphicalCodeDetectorR(unnamed.as_raw_GraphicalCodeDetector()) }; - let ret = unsafe { crate::objdetect::GraphicalCodeDetector::opencv_from_extern(ret) }; - ret - } - - #[inline] - pub fn copy_mut(mut unnamed: crate::objdetect::GraphicalCodeDetector) -> crate::objdetect::GraphicalCodeDetector { - let ret = unsafe { sys::cv_GraphicalCodeDetector_GraphicalCodeDetector_GraphicalCodeDetectorRR(unnamed.as_raw_mut_GraphicalCodeDetector()) }; - let ret = unsafe { crate::objdetect::GraphicalCodeDetector::opencv_from_extern(ret) }; - ret + pub fn get_default_people_detector() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_HOGDescriptor_getDefaultPeopleDetector(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Vector::::opencv_from_extern(ret) }; + Ok(ret) } - } - - impl Clone for GraphicalCodeDetector { + /// @example samples/tapi/hog.cpp + /// / + /// Returns coefficients of the classifier trained for people detection (for 48x96 windows). #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_GraphicalCodeDetector_implicitClone_const(self.as_raw_GraphicalCodeDetector())) } + pub fn get_daimler_people_detector() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_HOGDescriptor_getDaimlerPeopleDetector(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Vector::::opencv_from_extern(ret) }; + Ok(ret) } - } - impl std::fmt::Debug for GraphicalCodeDetector { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GraphicalCodeDetector") - .finish() - } } /// Constant methods for [crate::objdetect::HOGDescriptor] @@ -3754,286 +3928,95 @@ pub mod objdetect { let ret = unsafe { sys::cv_HOGDescriptor_propSvmDetector_const_vectorLfloatG(self.as_raw_mut_HOGDescriptor(), val.as_raw_VectorOff32()) }; ret } - - /// coefficients for the linear SVM classifier used when OpenCL is enabled - #[inline] - fn set_ocl_svm_detector(&mut self, val: core::UMat) { - let ret = unsafe { sys::cv_HOGDescriptor_propOclSvmDetector_const_UMat(self.as_raw_mut_HOGDescriptor(), val.as_raw_UMat()) }; - ret - } - - /// not documented - #[inline] - fn set_free_coef(&mut self, val: f32) { - let ret = unsafe { sys::cv_HOGDescriptor_propFree_coef_const_float(self.as_raw_mut_HOGDescriptor(), val) }; - ret - } - - /// Maximum number of detection window increases. Default value is 64 - #[inline] - fn set_nlevels(&mut self, val: i32) { - let ret = unsafe { sys::cv_HOGDescriptor_propNlevels_const_int(self.as_raw_mut_HOGDescriptor(), val) }; - ret - } - - /// Indicates signed gradient will be used or not - #[inline] - fn set_signed_gradient(&mut self, val: bool) { - let ret = unsafe { sys::cv_HOGDescriptor_propSignedGradient_const_bool(self.as_raw_mut_HOGDescriptor(), val) }; - ret - } - - /// @example samples/cpp/peopledetect.cpp - /// / - /// Sets coefficients for the linear SVM classifier. - /// ## Parameters - /// * svmdetector: coefficients for the linear SVM classifier. - #[inline] - fn set_svm_detector_input_array(&mut self, svmdetector: &impl ToInputArray) -> Result<()> { - input_array_arg!(svmdetector); - return_send!(via ocvrs_return); - unsafe { sys::cv_HOGDescriptor_setSVMDetector_const__InputArrayR(self.as_raw_mut_HOGDescriptor(), svmdetector.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Reads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file node. - /// ## Parameters - /// * fn: File node - #[inline] - fn read(&mut self, fn_: &mut impl core::FileNodeTrait) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_HOGDescriptor_read_FileNodeR(self.as_raw_mut_HOGDescriptor(), fn_.as_raw_mut_FileNode(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file - /// ## Parameters - /// * filename: Name of the file to read. - /// * objname: The optional name of the node to read (if empty, the first top-level node will be used). - /// - /// ## C++ default parameters - /// * objname: String() - #[inline] - fn load(&mut self, filename: &str, objname: &str) -> Result { - extern_container_arg!(filename); - extern_container_arg!(objname); - return_send!(via ocvrs_return); - unsafe { sys::cv_HOGDescriptor_load_const_StringR_const_StringR(self.as_raw_mut_HOGDescriptor(), filename.opencv_as_extern(), objname.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file - /// ## Parameters - /// * filename: Name of the file to read. - /// * objname: The optional name of the node to read (if empty, the first top-level node will be used). - /// - /// ## Note - /// This alternative version of [HOGDescriptorTrait::load] function uses the following default values for its arguments: - /// * objname: String() - #[inline] - fn load_def(&mut self, filename: &str) -> Result { - extern_container_arg!(filename); - return_send!(via ocvrs_return); - unsafe { sys::cv_HOGDescriptor_load_const_StringR(self.as_raw_mut_HOGDescriptor(), filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - /// Implementation of HOG (Histogram of Oriented Gradients) descriptor and object detector. - /// - /// the HOG descriptor algorithm introduced by Navneet Dalal and Bill Triggs [Dalal2005](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Dalal2005) . - /// - /// useful links: - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - pub struct HOGDescriptor { - ptr: *mut c_void, - } - - opencv_type_boxed! { HOGDescriptor } - - impl Drop for HOGDescriptor { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_HOGDescriptor_delete(self.as_raw_mut_HOGDescriptor()) }; - } - } - - unsafe impl Send for HOGDescriptor {} - - impl crate::objdetect::HOGDescriptorTraitConst for HOGDescriptor { - #[inline] fn as_raw_HOGDescriptor(&self) -> *const c_void { self.as_raw() } - } - - impl crate::objdetect::HOGDescriptorTrait for HOGDescriptor { - #[inline] fn as_raw_mut_HOGDescriptor(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { HOGDescriptor, crate::objdetect::HOGDescriptorTraitConst, as_raw_HOGDescriptor, crate::objdetect::HOGDescriptorTrait, as_raw_mut_HOGDescriptor } - - impl HOGDescriptor { - /// Creates the HOG descriptor and detector with default parameters. - /// - /// aqual to HOGDescriptor(Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9 ) - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_HOGDescriptor_HOGDescriptor(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::HOGDescriptor::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Creates the HOG descriptor and detector with default parameters. - /// - /// aqual to HOGDescriptor(Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9 ) - /// - /// ## Overloaded parameters - /// - /// ## Parameters - /// * _winSize: sets winSize with given value. - /// * _blockSize: sets blockSize with given value. - /// * _blockStride: sets blockStride with given value. - /// * _cellSize: sets cellSize with given value. - /// * _nbins: sets nbins with given value. - /// * _derivAperture: sets derivAperture with given value. - /// * _winSigma: sets winSigma with given value. - /// * _histogramNormType: sets histogramNormType with given value. - /// * _L2HysThreshold: sets L2HysThreshold with given value. - /// * _gammaCorrection: sets gammaCorrection with given value. - /// * _nlevels: sets nlevels with given value. - /// * _signedGradient: sets signedGradient with given value. - /// - /// ## C++ default parameters - /// * _deriv_aperture: 1 - /// * _win_sigma: -1 - /// * _histogram_norm_type: HOGDescriptor::L2Hys - /// * _l2_hys_threshold: 0.2 - /// * _gamma_correction: false - /// * _nlevels: HOGDescriptor::DEFAULT_NLEVELS - /// * _signed_gradient: false - #[inline] - pub fn new(_win_size: core::Size, _block_size: core::Size, _block_stride: core::Size, _cell_size: core::Size, _nbins: i32, _deriv_aperture: i32, _win_sigma: f64, _histogram_norm_type: crate::objdetect::HOGDescriptor_HistogramNormType, _l2_hys_threshold: f64, _gamma_correction: bool, _nlevels: i32, _signed_gradient: bool) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_HOGDescriptor_HOGDescriptor_Size_Size_Size_Size_int_int_double_HistogramNormType_double_bool_int_bool(&_win_size, &_block_size, &_block_stride, &_cell_size, _nbins, _deriv_aperture, _win_sigma, _histogram_norm_type, _l2_hys_threshold, _gamma_correction, _nlevels, _signed_gradient, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::HOGDescriptor::opencv_from_extern(ret) }; - Ok(ret) - } - - /// @overload - /// ## Parameters - /// * _winSize: sets winSize with given value. - /// * _blockSize: sets blockSize with given value. - /// * _blockStride: sets blockStride with given value. - /// * _cellSize: sets cellSize with given value. - /// * _nbins: sets nbins with given value. - /// * _derivAperture: sets derivAperture with given value. - /// * _winSigma: sets winSigma with given value. - /// * _histogramNormType: sets histogramNormType with given value. - /// * _L2HysThreshold: sets L2HysThreshold with given value. - /// * _gammaCorrection: sets gammaCorrection with given value. - /// * _nlevels: sets nlevels with given value. - /// * _signedGradient: sets signedGradient with given value. - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * _deriv_aperture: 1 - /// * _win_sigma: -1 - /// * _histogram_norm_type: HOGDescriptor::L2Hys - /// * _l2_hys_threshold: 0.2 - /// * _gamma_correction: false - /// * _nlevels: HOGDescriptor::DEFAULT_NLEVELS - /// * _signed_gradient: false + + /// coefficients for the linear SVM classifier used when OpenCL is enabled #[inline] - pub fn new_def(_win_size: core::Size, _block_size: core::Size, _block_stride: core::Size, _cell_size: core::Size, _nbins: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_HOGDescriptor_HOGDescriptor_Size_Size_Size_Size_int(&_win_size, &_block_size, &_block_stride, &_cell_size, _nbins, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::HOGDescriptor::opencv_from_extern(ret) }; - Ok(ret) + fn set_ocl_svm_detector(&mut self, val: core::UMat) { + let ret = unsafe { sys::cv_HOGDescriptor_propOclSvmDetector_const_UMat(self.as_raw_mut_HOGDescriptor(), val.as_raw_UMat()) }; + ret } - /// Creates the HOG descriptor and detector with default parameters. - /// - /// aqual to HOGDescriptor(Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9 ) - /// - /// ## Overloaded parameters - /// - /// - /// Creates the HOG descriptor and detector and loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file. + /// not documented + #[inline] + fn set_free_coef(&mut self, val: f32) { + let ret = unsafe { sys::cv_HOGDescriptor_propFree_coef_const_float(self.as_raw_mut_HOGDescriptor(), val) }; + ret + } + + /// Maximum number of detection window increases. Default value is 64 + #[inline] + fn set_nlevels(&mut self, val: i32) { + let ret = unsafe { sys::cv_HOGDescriptor_propNlevels_const_int(self.as_raw_mut_HOGDescriptor(), val) }; + ret + } + + /// Indicates signed gradient will be used or not + #[inline] + fn set_signed_gradient(&mut self, val: bool) { + let ret = unsafe { sys::cv_HOGDescriptor_propSignedGradient_const_bool(self.as_raw_mut_HOGDescriptor(), val) }; + ret + } + + /// @example samples/cpp/peopledetect.cpp + /// / + /// Sets coefficients for the linear SVM classifier. /// ## Parameters - /// * filename: The file name containing HOGDescriptor properties and coefficients for the linear SVM classifier. + /// * svmdetector: coefficients for the linear SVM classifier. #[inline] - pub fn new_from_file(filename: &str) -> Result { - extern_container_arg!(filename); + fn set_svm_detector_input_array(&mut self, svmdetector: &impl ToInputArray) -> Result<()> { + input_array_arg!(svmdetector); return_send!(via ocvrs_return); - unsafe { sys::cv_HOGDescriptor_HOGDescriptor_const_StringR(filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_HOGDescriptor_setSVMDetector_const__InputArrayR(self.as_raw_mut_HOGDescriptor(), svmdetector.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::HOGDescriptor::opencv_from_extern(ret) }; Ok(ret) } - /// Creates the HOG descriptor and detector with default parameters. - /// - /// aqual to HOGDescriptor(Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9 ) - /// - /// ## Overloaded parameters - /// + /// Reads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file node. /// ## Parameters - /// * d: the HOGDescriptor which cloned to create a new one. + /// * fn: File node #[inline] - pub fn copy(d: &impl crate::objdetect::HOGDescriptorTraitConst) -> Result { + fn read(&mut self, fn_: &mut impl core::FileNodeTrait) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_HOGDescriptor_HOGDescriptor_const_HOGDescriptorR(d.as_raw_HOGDescriptor(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_HOGDescriptor_read_FileNodeR(self.as_raw_mut_HOGDescriptor(), fn_.as_raw_mut_FileNode(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::HOGDescriptor::opencv_from_extern(ret) }; Ok(ret) } - /// Returns coefficients of the classifier trained for people detection (for 64x128 windows). + /// loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file + /// ## Parameters + /// * filename: Name of the file to read. + /// * objname: The optional name of the node to read (if empty, the first top-level node will be used). + /// + /// ## C++ default parameters + /// * objname: String() #[inline] - pub fn get_default_people_detector() -> Result> { + fn load(&mut self, filename: &str, objname: &str) -> Result { + extern_container_arg!(filename); + extern_container_arg!(objname); return_send!(via ocvrs_return); - unsafe { sys::cv_HOGDescriptor_getDefaultPeopleDetector(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_HOGDescriptor_load_const_StringR_const_StringR(self.as_raw_mut_HOGDescriptor(), filename.opencv_as_extern(), objname.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Vector::::opencv_from_extern(ret) }; Ok(ret) } - /// @example samples/tapi/hog.cpp - /// / - /// Returns coefficients of the classifier trained for people detection (for 48x96 windows). + /// loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file + /// ## Parameters + /// * filename: Name of the file to read. + /// * objname: The optional name of the node to read (if empty, the first top-level node will be used). + /// + /// ## Note + /// This alternative version of [HOGDescriptorTrait::load] function uses the following default values for its arguments: + /// * objname: String() #[inline] - pub fn get_daimler_people_detector() -> Result> { + fn load_def(&mut self, filename: &str) -> Result { + extern_container_arg!(filename); return_send!(via ocvrs_return); - unsafe { sys::cv_HOGDescriptor_getDaimlerPeopleDetector(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_HOGDescriptor_load_const_StringR(self.as_raw_mut_HOGDescriptor(), filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Vector::::opencv_from_extern(ret) }; Ok(ret) } @@ -4062,6 +4045,44 @@ pub mod objdetect { } } + impl crate::objdetect::HOGDescriptorTraitConst for HOGDescriptor { + #[inline] fn as_raw_HOGDescriptor(&self) -> *const c_void { self.as_raw() } + } + + impl crate::objdetect::HOGDescriptorTrait for HOGDescriptor { + #[inline] fn as_raw_mut_HOGDescriptor(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { HOGDescriptor, crate::objdetect::HOGDescriptorTraitConst, as_raw_HOGDescriptor, crate::objdetect::HOGDescriptorTrait, as_raw_mut_HOGDescriptor } + + pub struct QRCodeDetector { + ptr: *mut c_void, + } + + opencv_type_boxed! { QRCodeDetector } + + impl Drop for QRCodeDetector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_QRCodeDetector_delete(self.as_raw_mut_QRCodeDetector()) }; + } + } + + unsafe impl Send for QRCodeDetector {} + + impl QRCodeDetector { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_QRCodeDetector_QRCodeDetector(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::QRCodeDetector::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::objdetect::QRCodeDetector] pub trait QRCodeDetectorTraitConst: crate::objdetect::GraphicalCodeDetectorTraitConst { fn as_raw_QRCodeDetector(&self) -> *const c_void; @@ -4206,20 +4227,22 @@ pub mod objdetect { } - pub struct QRCodeDetector { - ptr: *mut c_void, + impl Clone for QRCodeDetector { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_QRCodeDetector_implicitClone_const(self.as_raw_QRCodeDetector())) } + } } - opencv_type_boxed! { QRCodeDetector } - - impl Drop for QRCodeDetector { + impl std::fmt::Debug for QRCodeDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_QRCodeDetector_delete(self.as_raw_mut_QRCodeDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("QRCodeDetector") + .finish() } } - unsafe impl Send for QRCodeDetector {} + boxed_cast_base! { QRCodeDetector, crate::objdetect::GraphicalCodeDetector, cv_QRCodeDetector_to_GraphicalCodeDetector } impl crate::objdetect::GraphicalCodeDetectorTraitConst for QRCodeDetector { #[inline] fn as_raw_GraphicalCodeDetector(&self) -> *const c_void { self.as_raw() } @@ -4241,144 +4264,94 @@ pub mod objdetect { boxed_ref! { QRCodeDetector, crate::objdetect::QRCodeDetectorTraitConst, as_raw_QRCodeDetector, crate::objdetect::QRCodeDetectorTrait, as_raw_mut_QRCodeDetector } - impl QRCodeDetector { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_QRCodeDetector_QRCodeDetector(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::QRCodeDetector::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl Clone for QRCodeDetector { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_QRCodeDetector_implicitClone_const(self.as_raw_QRCodeDetector())) } - } + pub struct QRCodeDetectorAruco { + ptr: *mut c_void, } - boxed_cast_base! { QRCodeDetector, crate::objdetect::GraphicalCodeDetector, cv_QRCodeDetector_to_GraphicalCodeDetector } + opencv_type_boxed! { QRCodeDetectorAruco } - impl std::fmt::Debug for QRCodeDetector { + impl Drop for QRCodeDetectorAruco { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("QRCodeDetector") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_QRCodeDetectorAruco_delete(self.as_raw_mut_QRCodeDetectorAruco()) }; } } - /// Constant methods for [crate::objdetect::QRCodeDetectorAruco] - pub trait QRCodeDetectorArucoTraitConst: crate::objdetect::GraphicalCodeDetectorTraitConst { - fn as_raw_QRCodeDetectorAruco(&self) -> *const c_void; + unsafe impl Send for QRCodeDetectorAruco {} - /// Detector parameters getter. See cv::QRCodeDetectorAruco::Params + impl QRCodeDetectorAruco { #[inline] - fn get_detector_parameters(&self) -> Result { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_QRCodeDetectorAruco_getDetectorParameters_const(self.as_raw_QRCodeDetectorAruco(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_QRCodeDetectorAruco_QRCodeDetectorAruco(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::QRCodeDetectorAruco::opencv_from_extern(ret) }; Ok(ret) } - /// Aruco detector parameters are used to search for the finder patterns. + /// QR code detector constructor for Aruco-based algorithm. See cv::QRCodeDetectorAruco::Params #[inline] - fn get_aruco_parameters(&self) -> Result { + pub fn new(params: crate::objdetect::QRCodeDetectorAruco_Params) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_QRCodeDetectorAruco_getArucoParameters_const(self.as_raw_QRCodeDetectorAruco(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_QRCodeDetectorAruco_QRCodeDetectorAruco_const_ParamsR(¶ms, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::DetectorParameters::opencv_from_extern(ret) }; + let ret = unsafe { crate::objdetect::QRCodeDetectorAruco::opencv_from_extern(ret) }; Ok(ret) } } - /// Mutable methods for [crate::objdetect::QRCodeDetectorAruco] - pub trait QRCodeDetectorArucoTrait: crate::objdetect::GraphicalCodeDetectorTrait + crate::objdetect::QRCodeDetectorArucoTraitConst { - fn as_raw_mut_QRCodeDetectorAruco(&mut self) -> *mut c_void; + /// Constant methods for [crate::objdetect::QRCodeDetectorAruco] + pub trait QRCodeDetectorArucoTraitConst: crate::objdetect::GraphicalCodeDetectorTraitConst { + fn as_raw_QRCodeDetectorAruco(&self) -> *const c_void; - /// Detector parameters setter. See cv::QRCodeDetectorAruco::Params + /// Detector parameters getter. See cv::QRCodeDetectorAruco::Params #[inline] - fn set_detector_parameters(&mut self, params: crate::objdetect::QRCodeDetectorAruco_Params) -> Result { + fn get_detector_parameters(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_QRCodeDetectorAruco_setDetectorParameters_const_ParamsR(self.as_raw_mut_QRCodeDetectorAruco(), ¶ms, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_QRCodeDetectorAruco_getDetectorParameters_const(self.as_raw_QRCodeDetectorAruco(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::QRCodeDetectorAruco::opencv_from_extern(ret) }; Ok(ret) } /// Aruco detector parameters are used to search for the finder patterns. #[inline] - fn set_aruco_parameters(&mut self, params: &impl crate::objdetect::DetectorParametersTraitConst) -> Result<()> { + fn get_aruco_parameters(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_QRCodeDetectorAruco_setArucoParameters_const_DetectorParametersR(self.as_raw_mut_QRCodeDetectorAruco(), params.as_raw_DetectorParameters(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_QRCodeDetectorAruco_getArucoParameters_const(self.as_raw_QRCodeDetectorAruco(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::DetectorParameters::opencv_from_extern(ret) }; Ok(ret) } } - pub struct QRCodeDetectorAruco { - ptr: *mut c_void, - } - - opencv_type_boxed! { QRCodeDetectorAruco } - - impl Drop for QRCodeDetectorAruco { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_QRCodeDetectorAruco_delete(self.as_raw_mut_QRCodeDetectorAruco()) }; - } - } - - unsafe impl Send for QRCodeDetectorAruco {} - - impl crate::objdetect::GraphicalCodeDetectorTraitConst for QRCodeDetectorAruco { - #[inline] fn as_raw_GraphicalCodeDetector(&self) -> *const c_void { self.as_raw() } - } - - impl crate::objdetect::GraphicalCodeDetectorTrait for QRCodeDetectorAruco { - #[inline] fn as_raw_mut_GraphicalCodeDetector(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { QRCodeDetectorAruco, crate::objdetect::GraphicalCodeDetectorTraitConst, as_raw_GraphicalCodeDetector, crate::objdetect::GraphicalCodeDetectorTrait, as_raw_mut_GraphicalCodeDetector } - - impl crate::objdetect::QRCodeDetectorArucoTraitConst for QRCodeDetectorAruco { - #[inline] fn as_raw_QRCodeDetectorAruco(&self) -> *const c_void { self.as_raw() } - } - - impl crate::objdetect::QRCodeDetectorArucoTrait for QRCodeDetectorAruco { - #[inline] fn as_raw_mut_QRCodeDetectorAruco(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { QRCodeDetectorAruco, crate::objdetect::QRCodeDetectorArucoTraitConst, as_raw_QRCodeDetectorAruco, crate::objdetect::QRCodeDetectorArucoTrait, as_raw_mut_QRCodeDetectorAruco } + /// Mutable methods for [crate::objdetect::QRCodeDetectorAruco] + pub trait QRCodeDetectorArucoTrait: crate::objdetect::GraphicalCodeDetectorTrait + crate::objdetect::QRCodeDetectorArucoTraitConst { + fn as_raw_mut_QRCodeDetectorAruco(&mut self) -> *mut c_void; - impl QRCodeDetectorAruco { + /// Detector parameters setter. See cv::QRCodeDetectorAruco::Params #[inline] - pub fn default() -> Result { + fn set_detector_parameters(&mut self, params: crate::objdetect::QRCodeDetectorAruco_Params) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_QRCodeDetectorAruco_QRCodeDetectorAruco(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_QRCodeDetectorAruco_setDetectorParameters_const_ParamsR(self.as_raw_mut_QRCodeDetectorAruco(), ¶ms, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { crate::objdetect::QRCodeDetectorAruco::opencv_from_extern(ret) }; Ok(ret) } - /// QR code detector constructor for Aruco-based algorithm. See cv::QRCodeDetectorAruco::Params + /// Aruco detector parameters are used to search for the finder patterns. #[inline] - pub fn new(params: crate::objdetect::QRCodeDetectorAruco_Params) -> Result { + fn set_aruco_parameters(&mut self, params: &impl crate::objdetect::DetectorParametersTraitConst) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_QRCodeDetectorAruco_QRCodeDetectorAruco_const_ParamsR(¶ms, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_QRCodeDetectorAruco_setArucoParameters_const_DetectorParametersR(self.as_raw_mut_QRCodeDetectorAruco(), params.as_raw_DetectorParameters(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::QRCodeDetectorAruco::opencv_from_extern(ret) }; Ok(ret) } @@ -4391,8 +4364,6 @@ pub mod objdetect { } } - boxed_cast_base! { QRCodeDetectorAruco, crate::objdetect::GraphicalCodeDetector, cv_QRCodeDetectorAruco_to_GraphicalCodeDetector } - impl std::fmt::Debug for QRCodeDetectorAruco { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -4401,6 +4372,28 @@ pub mod objdetect { } } + boxed_cast_base! { QRCodeDetectorAruco, crate::objdetect::GraphicalCodeDetector, cv_QRCodeDetectorAruco_to_GraphicalCodeDetector } + + impl crate::objdetect::GraphicalCodeDetectorTraitConst for QRCodeDetectorAruco { + #[inline] fn as_raw_GraphicalCodeDetector(&self) -> *const c_void { self.as_raw() } + } + + impl crate::objdetect::GraphicalCodeDetectorTrait for QRCodeDetectorAruco { + #[inline] fn as_raw_mut_GraphicalCodeDetector(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { QRCodeDetectorAruco, crate::objdetect::GraphicalCodeDetectorTraitConst, as_raw_GraphicalCodeDetector, crate::objdetect::GraphicalCodeDetectorTrait, as_raw_mut_GraphicalCodeDetector } + + impl crate::objdetect::QRCodeDetectorArucoTraitConst for QRCodeDetectorAruco { + #[inline] fn as_raw_QRCodeDetectorAruco(&self) -> *const c_void { self.as_raw() } + } + + impl crate::objdetect::QRCodeDetectorArucoTrait for QRCodeDetectorAruco { + #[inline] fn as_raw_mut_QRCodeDetectorAruco(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { QRCodeDetectorAruco, crate::objdetect::QRCodeDetectorArucoTraitConst, as_raw_QRCodeDetectorAruco, crate::objdetect::QRCodeDetectorArucoTrait, as_raw_mut_QRCodeDetectorAruco } + #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] pub struct QRCodeDetectorAruco_Params { @@ -4441,48 +4434,6 @@ pub mod objdetect { } - /// Constant methods for [crate::objdetect::QRCodeEncoder] - pub trait QRCodeEncoderTraitConst { - fn as_raw_QRCodeEncoder(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::objdetect::QRCodeEncoder] - pub trait QRCodeEncoderTrait: crate::objdetect::QRCodeEncoderTraitConst { - fn as_raw_mut_QRCodeEncoder(&mut self) -> *mut c_void; - - /// Generates QR code from input string. - /// ## Parameters - /// * encoded_info: Input string to encode. - /// * qrcode: Generated QR code. - #[inline] - fn encode(&mut self, encoded_info: &str, qrcode: &mut impl ToOutputArray) -> Result<()> { - extern_container_arg!(encoded_info); - output_array_arg!(qrcode); - return_send!(via ocvrs_return); - unsafe { sys::cv_QRCodeEncoder_encode_const_StringR_const__OutputArrayR(self.as_raw_mut_QRCodeEncoder(), encoded_info.opencv_as_extern(), qrcode.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Generates QR code from input string in Structured Append mode. The encoded message is splitting over a number of QR codes. - /// ## Parameters - /// * encoded_info: Input string to encode. - /// * qrcodes: Vector of generated QR codes. - #[inline] - fn encode_structured_append(&mut self, encoded_info: &str, qrcodes: &mut impl ToOutputArray) -> Result<()> { - extern_container_arg!(encoded_info); - output_array_arg!(qrcodes); - return_send!(via ocvrs_return); - unsafe { sys::cv_QRCodeEncoder_encodeStructuredAppend_const_StringR_const__OutputArrayR(self.as_raw_mut_QRCodeEncoder(), encoded_info.opencv_as_extern(), qrcodes.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - pub struct QRCodeEncoder { ptr: *mut c_void, } @@ -4498,16 +4449,6 @@ pub mod objdetect { unsafe impl Send for QRCodeEncoder {} - impl crate::objdetect::QRCodeEncoderTraitConst for QRCodeEncoder { - #[inline] fn as_raw_QRCodeEncoder(&self) -> *const c_void { self.as_raw() } - } - - impl crate::objdetect::QRCodeEncoderTrait for QRCodeEncoder { - #[inline] fn as_raw_mut_QRCodeEncoder(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { QRCodeEncoder, crate::objdetect::QRCodeEncoderTraitConst, as_raw_QRCodeEncoder, crate::objdetect::QRCodeEncoderTrait, as_raw_mut_QRCodeEncoder } - impl QRCodeEncoder { /// Constructor /// ## Parameters @@ -4544,6 +4485,48 @@ pub mod objdetect { } + /// Constant methods for [crate::objdetect::QRCodeEncoder] + pub trait QRCodeEncoderTraitConst { + fn as_raw_QRCodeEncoder(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::objdetect::QRCodeEncoder] + pub trait QRCodeEncoderTrait: crate::objdetect::QRCodeEncoderTraitConst { + fn as_raw_mut_QRCodeEncoder(&mut self) -> *mut c_void; + + /// Generates QR code from input string. + /// ## Parameters + /// * encoded_info: Input string to encode. + /// * qrcode: Generated QR code. + #[inline] + fn encode(&mut self, encoded_info: &str, qrcode: &mut impl ToOutputArray) -> Result<()> { + extern_container_arg!(encoded_info); + output_array_arg!(qrcode); + return_send!(via ocvrs_return); + unsafe { sys::cv_QRCodeEncoder_encode_const_StringR_const__OutputArrayR(self.as_raw_mut_QRCodeEncoder(), encoded_info.opencv_as_extern(), qrcode.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Generates QR code from input string in Structured Append mode. The encoded message is splitting over a number of QR codes. + /// ## Parameters + /// * encoded_info: Input string to encode. + /// * qrcodes: Vector of generated QR codes. + #[inline] + fn encode_structured_append(&mut self, encoded_info: &str, qrcodes: &mut impl ToOutputArray) -> Result<()> { + extern_container_arg!(encoded_info); + output_array_arg!(qrcodes); + return_send!(via ocvrs_return); + unsafe { sys::cv_QRCodeEncoder_encodeStructuredAppend_const_StringR_const__OutputArrayR(self.as_raw_mut_QRCodeEncoder(), encoded_info.opencv_as_extern(), qrcodes.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + impl std::fmt::Debug for QRCodeEncoder { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -4552,6 +4535,16 @@ pub mod objdetect { } } + impl crate::objdetect::QRCodeEncoderTraitConst for QRCodeEncoder { + #[inline] fn as_raw_QRCodeEncoder(&self) -> *const c_void { self.as_raw() } + } + + impl crate::objdetect::QRCodeEncoderTrait for QRCodeEncoder { + #[inline] fn as_raw_mut_QRCodeEncoder(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { QRCodeEncoder, crate::objdetect::QRCodeEncoderTraitConst, as_raw_QRCodeEncoder, crate::objdetect::QRCodeEncoderTrait, as_raw_mut_QRCodeEncoder } + /// QR code encoder parameters. #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] @@ -4580,6 +4573,37 @@ pub mod objdetect { } + /// This class is used for grouping object candidates detected by Cascade Classifier, HOG etc. + /// + /// instance of the class is to be passed to cv::partition + pub struct SimilarRects { + ptr: *mut c_void, + } + + opencv_type_boxed! { SimilarRects } + + impl Drop for SimilarRects { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_SimilarRects_delete(self.as_raw_mut_SimilarRects()) }; + } + } + + unsafe impl Send for SimilarRects {} + + impl SimilarRects { + #[inline] + pub fn new(_eps: f64) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_SimilarRects_SimilarRects_double(_eps, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::SimilarRects::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::objdetect::SimilarRects] pub trait SimilarRectsTraitConst { fn as_raw_SimilarRects(&self) -> *const c_void; @@ -4613,24 +4637,15 @@ pub mod objdetect { } - /// This class is used for grouping object candidates detected by Cascade Classifier, HOG etc. - /// - /// instance of the class is to be passed to cv::partition - pub struct SimilarRects { - ptr: *mut c_void, - } - - opencv_type_boxed! { SimilarRects } - - impl Drop for SimilarRects { + impl std::fmt::Debug for SimilarRects { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_SimilarRects_delete(self.as_raw_mut_SimilarRects()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SimilarRects") + .field("eps", &crate::objdetect::SimilarRectsTraitConst::eps(self)) + .finish() } } - unsafe impl Send for SimilarRects {} - impl crate::objdetect::SimilarRectsTraitConst for SimilarRects { #[inline] fn as_raw_SimilarRects(&self) -> *const c_void { self.as_raw() } } @@ -4641,26 +4656,71 @@ pub mod objdetect { boxed_ref! { SimilarRects, crate::objdetect::SimilarRectsTraitConst, as_raw_SimilarRects, crate::objdetect::SimilarRectsTrait, as_raw_mut_SimilarRects } - impl SimilarRects { + /// The main functionality of ArucoDetector class is detection of markers in an image with detectMarkers() method. + /// + /// After detecting some markers in the image, you can try to find undetected markers from this dictionary with + /// refineDetectedMarkers() method. + /// ## See also + /// DetectorParameters, RefineParameters + pub struct ArucoDetector { + ptr: *mut c_void, + } + + opencv_type_boxed! { ArucoDetector } + + impl Drop for ArucoDetector { #[inline] - pub fn new(_eps: f64) -> Result { + fn drop(&mut self) { + unsafe { sys::cv_aruco_ArucoDetector_delete(self.as_raw_mut_ArucoDetector()) }; + } + } + + unsafe impl Send for ArucoDetector {} + + impl ArucoDetector { + /// Basic ArucoDetector constructor + /// + /// ## Parameters + /// * dictionary: indicates the type of markers that will be searched + /// * detectorParams: marker detection parameters + /// * refineParams: marker refine detection parameters + /// + /// ## C++ default parameters + /// * dictionary: getPredefinedDictionary(cv::aruco::DICT_4X4_50) + /// * detector_params: DetectorParameters() + /// * refine_params: RefineParameters() + #[inline] + pub fn new(dictionary: &impl crate::objdetect::DictionaryTraitConst, detector_params: &impl crate::objdetect::DetectorParametersTraitConst, refine_params: crate::objdetect::RefineParameters) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_SimilarRects_SimilarRects_double(_eps, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_aruco_ArucoDetector_ArucoDetector_const_DictionaryR_const_DetectorParametersR_const_RefineParametersR(dictionary.as_raw_Dictionary(), detector_params.as_raw_DetectorParameters(), &refine_params, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::SimilarRects::opencv_from_extern(ret) }; + let ret = unsafe { crate::objdetect::ArucoDetector::opencv_from_extern(ret) }; Ok(ret) } - } - - impl std::fmt::Debug for SimilarRects { + /// Basic ArucoDetector constructor + /// + /// ## Parameters + /// * dictionary: indicates the type of markers that will be searched + /// * detectorParams: marker detection parameters + /// * refineParams: marker refine detection parameters + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * dictionary: getPredefinedDictionary(cv::aruco::DICT_4X4_50) + /// * detector_params: DetectorParameters() + /// * refine_params: RefineParameters() #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SimilarRects") - .field("eps", &crate::objdetect::SimilarRectsTraitConst::eps(self)) - .finish() + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_aruco_ArucoDetector_ArucoDetector(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::ArucoDetector::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::objdetect::ArucoDetector] @@ -4922,26 +4982,15 @@ pub mod objdetect { } - /// The main functionality of ArucoDetector class is detection of markers in an image with detectMarkers() method. - /// - /// After detecting some markers in the image, you can try to find undetected markers from this dictionary with - /// refineDetectedMarkers() method. - /// ## See also - /// DetectorParameters, RefineParameters - pub struct ArucoDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { ArucoDetector } - - impl Drop for ArucoDetector { + impl std::fmt::Debug for ArucoDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_aruco_ArucoDetector_delete(self.as_raw_mut_ArucoDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ArucoDetector") + .finish() } } - unsafe impl Send for ArucoDetector {} + boxed_cast_base! { ArucoDetector, core::Algorithm, cv_aruco_ArucoDetector_to_Algorithm } impl core::AlgorithmTraitConst for ArucoDetector { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -4963,62 +5012,60 @@ pub mod objdetect { boxed_ref! { ArucoDetector, crate::objdetect::ArucoDetectorTraitConst, as_raw_ArucoDetector, crate::objdetect::ArucoDetectorTrait, as_raw_mut_ArucoDetector } - impl ArucoDetector { - /// Basic ArucoDetector constructor + /// Board of ArUco markers + /// + /// A board is a set of markers in the 3D space with a common coordinate system. + /// The common form of a board of marker is a planar (2D) board, however any 3D layout can be used. + /// A Board object is composed by: + /// - The object points of the marker corners, i.e. their coordinates respect to the board system. + /// - The dictionary which indicates the type of markers of the board + /// - The identifier of all the markers in the board. + pub struct Board { + ptr: *mut c_void, + } + + opencv_type_boxed! { Board } + + impl Drop for Board { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_aruco_Board_delete(self.as_raw_mut_Board()) }; + } + } + + unsafe impl Send for Board {} + + impl Board { + /// Common Board constructor /// /// ## Parameters - /// * dictionary: indicates the type of markers that will be searched - /// * detectorParams: marker detection parameters - /// * refineParams: marker refine detection parameters - /// - /// ## C++ default parameters - /// * dictionary: getPredefinedDictionary(cv::aruco::DICT_4X4_50) - /// * detector_params: DetectorParameters() - /// * refine_params: RefineParameters() + /// * objPoints: array of object points of all the marker corners in the board + /// * dictionary: the dictionary of markers employed for this board + /// * ids: vector of the identifiers of the markers in the board #[inline] - pub fn new(dictionary: &impl crate::objdetect::DictionaryTraitConst, detector_params: &impl crate::objdetect::DetectorParametersTraitConst, refine_params: crate::objdetect::RefineParameters) -> Result { + pub fn new(obj_points: &impl ToInputArray, dictionary: &impl crate::objdetect::DictionaryTraitConst, ids: &impl ToInputArray) -> Result { + input_array_arg!(obj_points); + input_array_arg!(ids); return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_ArucoDetector_ArucoDetector_const_DictionaryR_const_DetectorParametersR_const_RefineParametersR(dictionary.as_raw_Dictionary(), detector_params.as_raw_DetectorParameters(), &refine_params, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_aruco_Board_Board_const__InputArrayR_const_DictionaryR_const__InputArrayR(obj_points.as_raw__InputArray(), dictionary.as_raw_Dictionary(), ids.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::ArucoDetector::opencv_from_extern(ret) }; + let ret = unsafe { crate::objdetect::Board::opencv_from_extern(ret) }; Ok(ret) } - /// Basic ArucoDetector constructor - /// - /// ## Parameters - /// * dictionary: indicates the type of markers that will be searched - /// * detectorParams: marker detection parameters - /// * refineParams: marker refine detection parameters - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * dictionary: getPredefinedDictionary(cv::aruco::DICT_4X4_50) - /// * detector_params: DetectorParameters() - /// * refine_params: RefineParameters() #[inline] - pub fn new_def() -> Result { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_ArucoDetector_ArucoDetector(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_aruco_Board_Board(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::ArucoDetector::opencv_from_extern(ret) }; + let ret = unsafe { crate::objdetect::Board::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { ArucoDetector, core::Algorithm, cv_aruco_ArucoDetector_to_Algorithm } - - impl std::fmt::Debug for ArucoDetector { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ArucoDetector") - .finish() - } - } - /// Constant methods for [crate::objdetect::Board] pub trait BoardTraitConst { fn as_raw_Board(&self) -> *const c_void; @@ -5164,29 +5211,21 @@ pub mod objdetect { } - /// Board of ArUco markers - /// - /// A board is a set of markers in the 3D space with a common coordinate system. - /// The common form of a board of marker is a planar (2D) board, however any 3D layout can be used. - /// A Board object is composed by: - /// - The object points of the marker corners, i.e. their coordinates respect to the board system. - /// - The dictionary which indicates the type of markers of the board - /// - The identifier of all the markers in the board. - pub struct Board { - ptr: *mut c_void, + impl Clone for Board { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_aruco_Board_implicitClone_const(self.as_raw_Board())) } + } } - opencv_type_boxed! { Board } - - impl Drop for Board { + impl std::fmt::Debug for Board { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_aruco_Board_delete(self.as_raw_mut_Board()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Board") + .finish() } } - unsafe impl Send for Board {} - impl crate::objdetect::BoardTraitConst for Board { #[inline] fn as_raw_Board(&self) -> *const c_void { self.as_raw() } } @@ -5197,50 +5236,82 @@ pub mod objdetect { boxed_ref! { Board, crate::objdetect::BoardTraitConst, as_raw_Board, crate::objdetect::BoardTrait, as_raw_mut_Board } - impl Board { - /// Common Board constructor + /// ChArUco board is a planar chessboard where the markers are placed inside the white squares of a chessboard. + /// + /// The benefits of ChArUco boards is that they provide both, ArUco markers versatility and chessboard corner precision, + /// which is important for calibration and pose estimation. The board image can be drawn using generateImage() method. + pub struct CharucoBoard { + ptr: *mut c_void, + } + + opencv_type_boxed! { CharucoBoard } + + impl Drop for CharucoBoard { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_aruco_CharucoBoard_delete(self.as_raw_mut_CharucoBoard()) }; + } + } + + unsafe impl Send for CharucoBoard {} + + impl CharucoBoard { + /// CharucoBoard constructor /// /// ## Parameters - /// * objPoints: array of object points of all the marker corners in the board - /// * dictionary: the dictionary of markers employed for this board - /// * ids: vector of the identifiers of the markers in the board + /// * size: number of chessboard squares in x and y directions + /// * squareLength: squareLength chessboard square side length (normally in meters) + /// * markerLength: marker side length (same unit than squareLength) + /// * dictionary: dictionary of markers indicating the type of markers + /// * ids: array of id used markers + /// The first markers in the dictionary are used to fill the white chessboard squares. + /// + /// ## C++ default parameters + /// * ids: noArray() #[inline] - pub fn new(obj_points: &impl ToInputArray, dictionary: &impl crate::objdetect::DictionaryTraitConst, ids: &impl ToInputArray) -> Result { - input_array_arg!(obj_points); + pub fn new(size: core::Size, square_length: f32, marker_length: f32, dictionary: &impl crate::objdetect::DictionaryTraitConst, ids: &impl ToInputArray) -> Result { input_array_arg!(ids); return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_Board_Board_const__InputArrayR_const_DictionaryR_const__InputArrayR(obj_points.as_raw__InputArray(), dictionary.as_raw_Dictionary(), ids.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_aruco_CharucoBoard_CharucoBoard_const_SizeR_float_float_const_DictionaryR_const__InputArrayR(&size, square_length, marker_length, dictionary.as_raw_Dictionary(), ids.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::Board::opencv_from_extern(ret) }; + let ret = unsafe { crate::objdetect::CharucoBoard::opencv_from_extern(ret) }; Ok(ret) } + /// CharucoBoard constructor + /// + /// ## Parameters + /// * size: number of chessboard squares in x and y directions + /// * squareLength: squareLength chessboard square side length (normally in meters) + /// * markerLength: marker side length (same unit than squareLength) + /// * dictionary: dictionary of markers indicating the type of markers + /// * ids: array of id used markers + /// The first markers in the dictionary are used to fill the white chessboard squares. + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * ids: noArray() #[inline] - pub fn default() -> Result { + pub fn new_def(size: core::Size, square_length: f32, marker_length: f32, dictionary: &impl crate::objdetect::DictionaryTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_Board_Board(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_aruco_CharucoBoard_CharucoBoard_const_SizeR_float_float_const_DictionaryR(&size, square_length, marker_length, dictionary.as_raw_Dictionary(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::Board::opencv_from_extern(ret) }; + let ret = unsafe { crate::objdetect::CharucoBoard::opencv_from_extern(ret) }; Ok(ret) } - } - - impl Clone for Board { #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_aruco_Board_implicitClone_const(self.as_raw_Board())) } + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_aruco_CharucoBoard_CharucoBoard(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::CharucoBoard::opencv_from_extern(ret) }; + Ok(ret) } - } - impl std::fmt::Debug for Board { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Board") - .finish() - } } /// Constant methods for [crate::objdetect::CharucoBoard] @@ -5363,24 +5434,22 @@ pub mod objdetect { } - /// ChArUco board is a planar chessboard where the markers are placed inside the white squares of a chessboard. - /// - /// The benefits of ChArUco boards is that they provide both, ArUco markers versatility and chessboard corner precision, - /// which is important for calibration and pose estimation. The board image can be drawn using generateImage() method. - pub struct CharucoBoard { - ptr: *mut c_void, + impl Clone for CharucoBoard { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_aruco_CharucoBoard_implicitClone_const(self.as_raw_CharucoBoard())) } + } } - opencv_type_boxed! { CharucoBoard } - - impl Drop for CharucoBoard { + impl std::fmt::Debug for CharucoBoard { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_aruco_CharucoBoard_delete(self.as_raw_mut_CharucoBoard()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CharucoBoard") + .finish() } } - unsafe impl Send for CharucoBoard {} + boxed_cast_base! { CharucoBoard, crate::objdetect::Board, cv_aruco_CharucoBoard_to_Board } impl crate::objdetect::BoardTraitConst for CharucoBoard { #[inline] fn as_raw_Board(&self) -> *const c_void { self.as_raw() } @@ -5402,82 +5471,69 @@ pub mod objdetect { boxed_ref! { CharucoBoard, crate::objdetect::CharucoBoardTraitConst, as_raw_CharucoBoard, crate::objdetect::CharucoBoardTrait, as_raw_mut_CharucoBoard } - impl CharucoBoard { - /// CharucoBoard constructor + pub struct CharucoDetector { + ptr: *mut c_void, + } + + opencv_type_boxed! { CharucoDetector } + + impl Drop for CharucoDetector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_aruco_CharucoDetector_delete(self.as_raw_mut_CharucoDetector()) }; + } + } + + unsafe impl Send for CharucoDetector {} + + impl CharucoDetector { + /// Basic CharucoDetector constructor /// /// ## Parameters - /// * size: number of chessboard squares in x and y directions - /// * squareLength: squareLength chessboard square side length (normally in meters) - /// * markerLength: marker side length (same unit than squareLength) - /// * dictionary: dictionary of markers indicating the type of markers - /// * ids: array of id used markers - /// The first markers in the dictionary are used to fill the white chessboard squares. + /// * board: ChAruco board + /// * charucoParams: charuco detection parameters + /// * detectorParams: marker detection parameters + /// * refineParams: marker refine detection parameters /// /// ## C++ default parameters - /// * ids: noArray() + /// * charuco_params: CharucoParameters() + /// * detector_params: DetectorParameters() + /// * refine_params: RefineParameters() #[inline] - pub fn new(size: core::Size, square_length: f32, marker_length: f32, dictionary: &impl crate::objdetect::DictionaryTraitConst, ids: &impl ToInputArray) -> Result { - input_array_arg!(ids); + pub fn new(board: &impl crate::objdetect::CharucoBoardTraitConst, charuco_params: &impl crate::objdetect::CharucoParametersTraitConst, detector_params: &impl crate::objdetect::DetectorParametersTraitConst, refine_params: crate::objdetect::RefineParameters) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_CharucoBoard_CharucoBoard_const_SizeR_float_float_const_DictionaryR_const__InputArrayR(&size, square_length, marker_length, dictionary.as_raw_Dictionary(), ids.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_aruco_CharucoDetector_CharucoDetector_const_CharucoBoardR_const_CharucoParametersR_const_DetectorParametersR_const_RefineParametersR(board.as_raw_CharucoBoard(), charuco_params.as_raw_CharucoParameters(), detector_params.as_raw_DetectorParameters(), &refine_params, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::CharucoBoard::opencv_from_extern(ret) }; + let ret = unsafe { crate::objdetect::CharucoDetector::opencv_from_extern(ret) }; Ok(ret) } - /// CharucoBoard constructor + /// Basic CharucoDetector constructor /// /// ## Parameters - /// * size: number of chessboard squares in x and y directions - /// * squareLength: squareLength chessboard square side length (normally in meters) - /// * markerLength: marker side length (same unit than squareLength) - /// * dictionary: dictionary of markers indicating the type of markers - /// * ids: array of id used markers - /// The first markers in the dictionary are used to fill the white chessboard squares. + /// * board: ChAruco board + /// * charucoParams: charuco detection parameters + /// * detectorParams: marker detection parameters + /// * refineParams: marker refine detection parameters /// /// ## Note /// This alternative version of [new] function uses the following default values for its arguments: - /// * ids: noArray() - #[inline] - pub fn new_def(size: core::Size, square_length: f32, marker_length: f32, dictionary: &impl crate::objdetect::DictionaryTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_CharucoBoard_CharucoBoard_const_SizeR_float_float_const_DictionaryR(&size, square_length, marker_length, dictionary.as_raw_Dictionary(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::CharucoBoard::opencv_from_extern(ret) }; - Ok(ret) - } - + /// * charuco_params: CharucoParameters() + /// * detector_params: DetectorParameters() + /// * refine_params: RefineParameters() #[inline] - pub fn default() -> Result { + pub fn new_def(board: &impl crate::objdetect::CharucoBoardTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_CharucoBoard_CharucoBoard(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_aruco_CharucoDetector_CharucoDetector_const_CharucoBoardR(board.as_raw_CharucoBoard(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::CharucoBoard::opencv_from_extern(ret) }; + let ret = unsafe { crate::objdetect::CharucoDetector::opencv_from_extern(ret) }; Ok(ret) } } - impl Clone for CharucoBoard { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_aruco_CharucoBoard_implicitClone_const(self.as_raw_CharucoBoard())) } - } - } - - boxed_cast_base! { CharucoBoard, crate::objdetect::Board, cv_aruco_CharucoBoard_to_Board } - - impl std::fmt::Debug for CharucoBoard { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CharucoBoard") - .finish() - } - } - /// Constant methods for [crate::objdetect::CharucoDetector] pub trait CharucoDetectorTraitConst: core::AlgorithmTraitConst { fn as_raw_CharucoDetector(&self) -> *const c_void; @@ -5725,20 +5781,15 @@ pub mod objdetect { } - pub struct CharucoDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { CharucoDetector } - - impl Drop for CharucoDetector { + impl std::fmt::Debug for CharucoDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_aruco_CharucoDetector_delete(self.as_raw_mut_CharucoDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CharucoDetector") + .finish() } } - unsafe impl Send for CharucoDetector {} + boxed_cast_base! { CharucoDetector, core::Algorithm, cv_aruco_CharucoDetector_to_Algorithm } impl core::AlgorithmTraitConst for CharucoDetector { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5760,64 +5811,34 @@ pub mod objdetect { boxed_ref! { CharucoDetector, crate::objdetect::CharucoDetectorTraitConst, as_raw_CharucoDetector, crate::objdetect::CharucoDetectorTrait, as_raw_mut_CharucoDetector } - impl CharucoDetector { - /// Basic CharucoDetector constructor - /// - /// ## Parameters - /// * board: ChAruco board - /// * charucoParams: charuco detection parameters - /// * detectorParams: marker detection parameters - /// * refineParams: marker refine detection parameters - /// - /// ## C++ default parameters - /// * charuco_params: CharucoParameters() - /// * detector_params: DetectorParameters() - /// * refine_params: RefineParameters() + pub struct CharucoParameters { + ptr: *mut c_void, + } + + opencv_type_boxed! { CharucoParameters } + + impl Drop for CharucoParameters { #[inline] - pub fn new(board: &impl crate::objdetect::CharucoBoardTraitConst, charuco_params: &impl crate::objdetect::CharucoParametersTraitConst, detector_params: &impl crate::objdetect::DetectorParametersTraitConst, refine_params: crate::objdetect::RefineParameters) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_CharucoDetector_CharucoDetector_const_CharucoBoardR_const_CharucoParametersR_const_DetectorParametersR_const_RefineParametersR(board.as_raw_CharucoBoard(), charuco_params.as_raw_CharucoParameters(), detector_params.as_raw_DetectorParameters(), &refine_params, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::CharucoDetector::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_aruco_CharucoParameters_delete(self.as_raw_mut_CharucoParameters()) }; } + } - /// Basic CharucoDetector constructor - /// - /// ## Parameters - /// * board: ChAruco board - /// * charucoParams: charuco detection parameters - /// * detectorParams: marker detection parameters - /// * refineParams: marker refine detection parameters - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * charuco_params: CharucoParameters() - /// * detector_params: DetectorParameters() - /// * refine_params: RefineParameters() + unsafe impl Send for CharucoParameters {} + + impl CharucoParameters { #[inline] - pub fn new_def(board: &impl crate::objdetect::CharucoBoardTraitConst) -> Result { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_CharucoDetector_CharucoDetector_const_CharucoBoardR(board.as_raw_CharucoBoard(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_aruco_CharucoParameters_CharucoParameters(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::CharucoDetector::opencv_from_extern(ret) }; + let ret = unsafe { crate::objdetect::CharucoParameters::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { CharucoDetector, core::Algorithm, cv_aruco_CharucoDetector_to_Algorithm } - - impl std::fmt::Debug for CharucoDetector { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CharucoDetector") - .finish() - } - } - /// Constant methods for [crate::objdetect::CharucoParameters] pub trait CharucoParametersTraitConst { fn as_raw_CharucoParameters(&self) -> *const c_void; @@ -5888,21 +5909,25 @@ pub mod objdetect { } - pub struct CharucoParameters { - ptr: *mut c_void, + impl Clone for CharucoParameters { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_aruco_CharucoParameters_implicitClone_const(self.as_raw_CharucoParameters())) } + } } - opencv_type_boxed! { CharucoParameters } - - impl Drop for CharucoParameters { + impl std::fmt::Debug for CharucoParameters { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_aruco_CharucoParameters_delete(self.as_raw_mut_CharucoParameters()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CharucoParameters") + .field("camera_matrix", &crate::objdetect::CharucoParametersTraitConst::camera_matrix(self)) + .field("dist_coeffs", &crate::objdetect::CharucoParametersTraitConst::dist_coeffs(self)) + .field("min_markers", &crate::objdetect::CharucoParametersTraitConst::min_markers(self)) + .field("try_refine_markers", &crate::objdetect::CharucoParametersTraitConst::try_refine_markers(self)) + .finish() } } - unsafe impl Send for CharucoParameters {} - impl crate::objdetect::CharucoParametersTraitConst for CharucoParameters { #[inline] fn as_raw_CharucoParameters(&self) -> *const c_void { self.as_raw() } } @@ -5913,36 +5938,33 @@ pub mod objdetect { boxed_ref! { CharucoParameters, crate::objdetect::CharucoParametersTraitConst, as_raw_CharucoParameters, crate::objdetect::CharucoParametersTrait, as_raw_mut_CharucoParameters } - impl CharucoParameters { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_CharucoParameters_CharucoParameters(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::CharucoParameters::opencv_from_extern(ret) }; - Ok(ret) - } - + /// struct DetectorParameters is used by ArucoDetector + pub struct DetectorParameters { + ptr: *mut c_void, } - impl Clone for CharucoParameters { + opencv_type_boxed! { DetectorParameters } + + impl Drop for DetectorParameters { #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_aruco_CharucoParameters_implicitClone_const(self.as_raw_CharucoParameters())) } + fn drop(&mut self) { + unsafe { sys::cv_aruco_DetectorParameters_delete(self.as_raw_mut_DetectorParameters()) }; } } - impl std::fmt::Debug for CharucoParameters { + unsafe impl Send for DetectorParameters {} + + impl DetectorParameters { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CharucoParameters") - .field("camera_matrix", &crate::objdetect::CharucoParametersTraitConst::camera_matrix(self)) - .field("dist_coeffs", &crate::objdetect::CharucoParametersTraitConst::dist_coeffs(self)) - .field("min_markers", &crate::objdetect::CharucoParametersTraitConst::min_markers(self)) - .field("try_refine_markers", &crate::objdetect::CharucoParametersTraitConst::try_refine_markers(self)) - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_aruco_DetectorParameters_DetectorParameters(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::DetectorParameters::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::objdetect::DetectorParameters] @@ -6541,73 +6563,34 @@ pub mod objdetect { unsafe { sys::cv_aruco_DetectorParameters_readDetectorParameters_const_FileNodeR(self.as_raw_mut_DetectorParameters(), fn_.as_raw_FileNode(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - Ok(ret) - } - - /// Write a set of DetectorParameters to FileStorage - /// - /// ## C++ default parameters - /// * name: String() - #[inline] - fn write_detector_parameters(&mut self, fs: &mut impl core::FileStorageTrait, name: &str) -> Result { - extern_container_arg!(name); - return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_DetectorParameters_writeDetectorParameters_FileStorageR_const_StringR(self.as_raw_mut_DetectorParameters(), fs.as_raw_mut_FileStorage(), name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Write a set of DetectorParameters to FileStorage - /// - /// ## Note - /// This alternative version of [DetectorParametersTrait::write_detector_parameters] function uses the following default values for its arguments: - /// * name: String() - #[inline] - fn write_detector_parameters_def(&mut self, fs: &mut impl core::FileStorageTrait) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_DetectorParameters_writeDetectorParameters_FileStorageR(self.as_raw_mut_DetectorParameters(), fs.as_raw_mut_FileStorage(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - /// struct DetectorParameters is used by ArucoDetector - pub struct DetectorParameters { - ptr: *mut c_void, - } - - opencv_type_boxed! { DetectorParameters } - - impl Drop for DetectorParameters { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_aruco_DetectorParameters_delete(self.as_raw_mut_DetectorParameters()) }; - } - } - - unsafe impl Send for DetectorParameters {} - - impl crate::objdetect::DetectorParametersTraitConst for DetectorParameters { - #[inline] fn as_raw_DetectorParameters(&self) -> *const c_void { self.as_raw() } - } - - impl crate::objdetect::DetectorParametersTrait for DetectorParameters { - #[inline] fn as_raw_mut_DetectorParameters(&mut self) -> *mut c_void { self.as_raw_mut() } - } + Ok(ret) + } - boxed_ref! { DetectorParameters, crate::objdetect::DetectorParametersTraitConst, as_raw_DetectorParameters, crate::objdetect::DetectorParametersTrait, as_raw_mut_DetectorParameters } + /// Write a set of DetectorParameters to FileStorage + /// + /// ## C++ default parameters + /// * name: String() + #[inline] + fn write_detector_parameters(&mut self, fs: &mut impl core::FileStorageTrait, name: &str) -> Result { + extern_container_arg!(name); + return_send!(via ocvrs_return); + unsafe { sys::cv_aruco_DetectorParameters_writeDetectorParameters_FileStorageR_const_StringR(self.as_raw_mut_DetectorParameters(), fs.as_raw_mut_FileStorage(), name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - impl DetectorParameters { + /// Write a set of DetectorParameters to FileStorage + /// + /// ## Note + /// This alternative version of [DetectorParametersTrait::write_detector_parameters] function uses the following default values for its arguments: + /// * name: String() #[inline] - pub fn default() -> Result { + fn write_detector_parameters_def(&mut self, fs: &mut impl core::FileStorageTrait) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_DetectorParameters_DetectorParameters(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_aruco_DetectorParameters_writeDetectorParameters_FileStorageR(self.as_raw_mut_DetectorParameters(), fs.as_raw_mut_FileStorage(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::DetectorParameters::opencv_from_extern(ret) }; Ok(ret) } @@ -6662,6 +6645,118 @@ pub mod objdetect { } } + impl crate::objdetect::DetectorParametersTraitConst for DetectorParameters { + #[inline] fn as_raw_DetectorParameters(&self) -> *const c_void { self.as_raw() } + } + + impl crate::objdetect::DetectorParametersTrait for DetectorParameters { + #[inline] fn as_raw_mut_DetectorParameters(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { DetectorParameters, crate::objdetect::DetectorParametersTraitConst, as_raw_DetectorParameters, crate::objdetect::DetectorParametersTrait, as_raw_mut_DetectorParameters } + + /// Dictionary is a set of unique ArUco markers of the same size + /// + /// `bytesList` storing as 2-dimensions Mat with 4-th channels (CV_8UC4 type was used) and contains the marker codewords where: + /// - bytesList.rows is the dictionary size + /// - each marker is encoded using `nbytes = ceil(markerSize*markerSize/8.)` bytes + /// - each row contains all 4 rotations of the marker, so its length is `4*nbytes` + /// - the byte order in the bytesList[i] row: + /// `//bytes without rotation/bytes with rotation 1/bytes with rotation 2/bytes with rotation 3//` + /// So `bytesList.ptr(i)[k*nbytes + j]` is the j-th byte of i-th marker, in its k-th rotation. + /// + /// Note: Python bindings generate matrix with shape of bytesList `dictionary_size x nbytes x 4`, + /// but it should be indexed like C++ version. Python example for j-th byte of i-th marker, in its k-th rotation: + /// `aruco_dict.bytesList[id].ravel()[k*nbytes + j]` + pub struct Dictionary { + ptr: *mut c_void, + } + + opencv_type_boxed! { Dictionary } + + impl Drop for Dictionary { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_aruco_Dictionary_delete(self.as_raw_mut_Dictionary()) }; + } + } + + unsafe impl Send for Dictionary {} + + impl Dictionary { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_aruco_Dictionary_Dictionary(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::Dictionary::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Basic ArUco dictionary constructor + /// + /// ## Parameters + /// * bytesList: bits for all ArUco markers in dictionary see memory layout in the class description + /// * _markerSize: ArUco marker size in units + /// * maxcorr: maximum number of bits that can be corrected + /// + /// ## C++ default parameters + /// * maxcorr: 0 + #[inline] + pub fn new(bytes_list: &impl core::MatTraitConst, _marker_size: i32, maxcorr: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_aruco_Dictionary_Dictionary_const_MatR_int_int(bytes_list.as_raw_Mat(), _marker_size, maxcorr, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::Dictionary::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Basic ArUco dictionary constructor + /// + /// ## Parameters + /// * bytesList: bits for all ArUco markers in dictionary see memory layout in the class description + /// * _markerSize: ArUco marker size in units + /// * maxcorr: maximum number of bits that can be corrected + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * maxcorr: 0 + #[inline] + pub fn new_def(bytes_list: &impl core::MatTraitConst, _marker_size: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_aruco_Dictionary_Dictionary_const_MatR_int(bytes_list.as_raw_Mat(), _marker_size, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::Dictionary::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Transform matrix of bits to list of bytes with 4 marker rotations + #[inline] + pub fn get_byte_list_from_bits(bits: &impl core::MatTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_aruco_Dictionary_getByteListFromBits_const_MatR(bits.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Transform list of bytes to matrix of bits + #[inline] + pub fn get_bits_from_byte_list(byte_list: &impl core::MatTraitConst, marker_size: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_aruco_Dictionary_getBitsFromByteList_const_MatR_int(byte_list.as_raw_Mat(), marker_size, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Mat::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::objdetect::Dictionary] pub trait DictionaryTraitConst { fn as_raw_Dictionary(&self) -> *const c_void; @@ -6815,141 +6910,29 @@ pub mod objdetect { /// Write a dictionary to FileStorage, format is the same as in readDictionary(). /// - /// ## C++ default parameters - /// * name: String() - #[inline] - fn write_dictionary(&mut self, fs: &mut impl core::FileStorageTrait, name: &str) -> Result<()> { - extern_container_arg!(name); - return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_Dictionary_writeDictionary_FileStorageR_const_StringR(self.as_raw_mut_Dictionary(), fs.as_raw_mut_FileStorage(), name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Write a dictionary to FileStorage, format is the same as in readDictionary(). - /// - /// ## Note - /// This alternative version of [DictionaryTrait::write_dictionary] function uses the following default values for its arguments: - /// * name: String() - #[inline] - fn write_dictionary_def(&mut self, fs: &mut impl core::FileStorageTrait) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_Dictionary_writeDictionary_FileStorageR(self.as_raw_mut_Dictionary(), fs.as_raw_mut_FileStorage(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - /// Dictionary is a set of unique ArUco markers of the same size - /// - /// `bytesList` storing as 2-dimensions Mat with 4-th channels (CV_8UC4 type was used) and contains the marker codewords where: - /// - bytesList.rows is the dictionary size - /// - each marker is encoded using `nbytes = ceil(markerSize*markerSize/8.)` bytes - /// - each row contains all 4 rotations of the marker, so its length is `4*nbytes` - /// - the byte order in the bytesList[i] row: - /// `//bytes without rotation/bytes with rotation 1/bytes with rotation 2/bytes with rotation 3//` - /// So `bytesList.ptr(i)[k*nbytes + j]` is the j-th byte of i-th marker, in its k-th rotation. - /// - /// Note: Python bindings generate matrix with shape of bytesList `dictionary_size x nbytes x 4`, - /// but it should be indexed like C++ version. Python example for j-th byte of i-th marker, in its k-th rotation: - /// `aruco_dict.bytesList[id].ravel()[k*nbytes + j]` - pub struct Dictionary { - ptr: *mut c_void, - } - - opencv_type_boxed! { Dictionary } - - impl Drop for Dictionary { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_aruco_Dictionary_delete(self.as_raw_mut_Dictionary()) }; - } - } - - unsafe impl Send for Dictionary {} - - impl crate::objdetect::DictionaryTraitConst for Dictionary { - #[inline] fn as_raw_Dictionary(&self) -> *const c_void { self.as_raw() } - } - - impl crate::objdetect::DictionaryTrait for Dictionary { - #[inline] fn as_raw_mut_Dictionary(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Dictionary, crate::objdetect::DictionaryTraitConst, as_raw_Dictionary, crate::objdetect::DictionaryTrait, as_raw_mut_Dictionary } - - impl Dictionary { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_Dictionary_Dictionary(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::Dictionary::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Basic ArUco dictionary constructor - /// - /// ## Parameters - /// * bytesList: bits for all ArUco markers in dictionary see memory layout in the class description - /// * _markerSize: ArUco marker size in units - /// * maxcorr: maximum number of bits that can be corrected - /// - /// ## C++ default parameters - /// * maxcorr: 0 - #[inline] - pub fn new(bytes_list: &impl core::MatTraitConst, _marker_size: i32, maxcorr: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_Dictionary_Dictionary_const_MatR_int_int(bytes_list.as_raw_Mat(), _marker_size, maxcorr, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::Dictionary::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Basic ArUco dictionary constructor - /// - /// ## Parameters - /// * bytesList: bits for all ArUco markers in dictionary see memory layout in the class description - /// * _markerSize: ArUco marker size in units - /// * maxcorr: maximum number of bits that can be corrected - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * maxcorr: 0 - #[inline] - pub fn new_def(bytes_list: &impl core::MatTraitConst, _marker_size: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_Dictionary_Dictionary_const_MatR_int(bytes_list.as_raw_Mat(), _marker_size, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::Dictionary::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Transform matrix of bits to list of bytes with 4 marker rotations + /// ## C++ default parameters + /// * name: String() #[inline] - pub fn get_byte_list_from_bits(bits: &impl core::MatTraitConst) -> Result { + fn write_dictionary(&mut self, fs: &mut impl core::FileStorageTrait, name: &str) -> Result<()> { + extern_container_arg!(name); return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_Dictionary_getByteListFromBits_const_MatR(bits.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_aruco_Dictionary_writeDictionary_FileStorageR_const_StringR(self.as_raw_mut_Dictionary(), fs.as_raw_mut_FileStorage(), name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } - /// Transform list of bytes to matrix of bits + /// Write a dictionary to FileStorage, format is the same as in readDictionary(). + /// + /// ## Note + /// This alternative version of [DictionaryTrait::write_dictionary] function uses the following default values for its arguments: + /// * name: String() #[inline] - pub fn get_bits_from_byte_list(byte_list: &impl core::MatTraitConst, marker_size: i32) -> Result { + fn write_dictionary_def(&mut self, fs: &mut impl core::FileStorageTrait) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_Dictionary_getBitsFromByteList_const_MatR_int(byte_list.as_raw_Mat(), marker_size, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_aruco_Dictionary_writeDictionary_FileStorageR(self.as_raw_mut_Dictionary(), fs.as_raw_mut_FileStorage(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Mat::opencv_from_extern(ret) }; Ok(ret) } @@ -6973,45 +6956,16 @@ pub mod objdetect { } } - /// Constant methods for [crate::objdetect::GridBoard] - pub trait GridBoardTraitConst: crate::objdetect::BoardTraitConst { - fn as_raw_GridBoard(&self) -> *const c_void; - - #[inline] - fn get_grid_size(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_GridBoard_getGridSize_const(self.as_raw_GridBoard(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_marker_length(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_GridBoard_getMarkerLength_const(self.as_raw_GridBoard(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_marker_separation(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_aruco_GridBoard_getMarkerSeparation_const(self.as_raw_GridBoard(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - + impl crate::objdetect::DictionaryTraitConst for Dictionary { + #[inline] fn as_raw_Dictionary(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::objdetect::GridBoard] - pub trait GridBoardTrait: crate::objdetect::BoardTrait + crate::objdetect::GridBoardTraitConst { - fn as_raw_mut_GridBoard(&mut self) -> *mut c_void; - + impl crate::objdetect::DictionaryTrait for Dictionary { + #[inline] fn as_raw_mut_Dictionary(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { Dictionary, crate::objdetect::DictionaryTraitConst, as_raw_Dictionary, crate::objdetect::DictionaryTrait, as_raw_mut_Dictionary } + /// Planar board with grid arrangement of markers /// /// More common type of board. All markers are placed in the same plane in a grid arrangement. @@ -7031,26 +6985,6 @@ pub mod objdetect { unsafe impl Send for GridBoard {} - impl crate::objdetect::BoardTraitConst for GridBoard { - #[inline] fn as_raw_Board(&self) -> *const c_void { self.as_raw() } - } - - impl crate::objdetect::BoardTrait for GridBoard { - #[inline] fn as_raw_mut_Board(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { GridBoard, crate::objdetect::BoardTraitConst, as_raw_Board, crate::objdetect::BoardTrait, as_raw_mut_Board } - - impl crate::objdetect::GridBoardTraitConst for GridBoard { - #[inline] fn as_raw_GridBoard(&self) -> *const c_void { self.as_raw() } - } - - impl crate::objdetect::GridBoardTrait for GridBoard { - #[inline] fn as_raw_mut_GridBoard(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { GridBoard, crate::objdetect::GridBoardTraitConst, as_raw_GridBoard, crate::objdetect::GridBoardTrait, as_raw_mut_GridBoard } - impl GridBoard { /// GridBoard constructor /// @@ -7108,6 +7042,45 @@ pub mod objdetect { } + /// Constant methods for [crate::objdetect::GridBoard] + pub trait GridBoardTraitConst: crate::objdetect::BoardTraitConst { + fn as_raw_GridBoard(&self) -> *const c_void; + + #[inline] + fn get_grid_size(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_aruco_GridBoard_getGridSize_const(self.as_raw_GridBoard(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn get_marker_length(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_aruco_GridBoard_getMarkerLength_const(self.as_raw_GridBoard(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn get_marker_separation(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_aruco_GridBoard_getMarkerSeparation_const(self.as_raw_GridBoard(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + /// Mutable methods for [crate::objdetect::GridBoard] + pub trait GridBoardTrait: crate::objdetect::BoardTrait + crate::objdetect::GridBoardTraitConst { + fn as_raw_mut_GridBoard(&mut self) -> *mut c_void; + + } + impl Clone for GridBoard { #[inline] fn clone(&self) -> Self { @@ -7115,8 +7088,6 @@ pub mod objdetect { } } - boxed_cast_base! { GridBoard, crate::objdetect::Board, cv_aruco_GridBoard_to_Board } - impl std::fmt::Debug for GridBoard { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -7125,6 +7096,28 @@ pub mod objdetect { } } + boxed_cast_base! { GridBoard, crate::objdetect::Board, cv_aruco_GridBoard_to_Board } + + impl crate::objdetect::BoardTraitConst for GridBoard { + #[inline] fn as_raw_Board(&self) -> *const c_void { self.as_raw() } + } + + impl crate::objdetect::BoardTrait for GridBoard { + #[inline] fn as_raw_mut_Board(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { GridBoard, crate::objdetect::BoardTraitConst, as_raw_Board, crate::objdetect::BoardTrait, as_raw_mut_Board } + + impl crate::objdetect::GridBoardTraitConst for GridBoard { + #[inline] fn as_raw_GridBoard(&self) -> *const c_void { self.as_raw() } + } + + impl crate::objdetect::GridBoardTrait for GridBoard { + #[inline] fn as_raw_mut_GridBoard(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { GridBoard, crate::objdetect::GridBoardTraitConst, as_raw_GridBoard, crate::objdetect::GridBoardTrait, as_raw_mut_GridBoard } + /// struct RefineParameters is used by ArucoDetector #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] @@ -7212,6 +7205,53 @@ pub mod objdetect { } + pub struct BarcodeDetector { + ptr: *mut c_void, + } + + opencv_type_boxed! { BarcodeDetector } + + impl Drop for BarcodeDetector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_barcode_BarcodeDetector_delete(self.as_raw_mut_BarcodeDetector()) }; + } + } + + unsafe impl Send for BarcodeDetector {} + + impl BarcodeDetector { + /// Initialize the BarcodeDetector. + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_barcode_BarcodeDetector_BarcodeDetector(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::BarcodeDetector::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Initialize the BarcodeDetector. + /// + /// Parameters allow to load _optional_ Super Resolution DNN model for better quality. + /// ## Parameters + /// * prototxt_path: prototxt file path for the super resolution model + /// * model_path: model file path for the super resolution model + #[inline] + pub fn new(prototxt_path: &str, model_path: &str) -> Result { + extern_container_arg!(prototxt_path); + extern_container_arg!(model_path); + return_send!(via ocvrs_return); + unsafe { sys::cv_barcode_BarcodeDetector_BarcodeDetector_const_stringR_const_stringR(prototxt_path.opencv_as_extern(), model_path.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::objdetect::BarcodeDetector::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::objdetect::BarcodeDetector] pub trait BarcodeDetectorTraitConst: crate::objdetect::GraphicalCodeDetectorTraitConst { fn as_raw_BarcodeDetector(&self) -> *const c_void; @@ -7384,20 +7424,22 @@ pub mod objdetect { } - pub struct BarcodeDetector { - ptr: *mut c_void, + impl Clone for BarcodeDetector { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_barcode_BarcodeDetector_implicitClone_const(self.as_raw_BarcodeDetector())) } + } } - opencv_type_boxed! { BarcodeDetector } - - impl Drop for BarcodeDetector { + impl std::fmt::Debug for BarcodeDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_barcode_BarcodeDetector_delete(self.as_raw_mut_BarcodeDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BarcodeDetector") + .finish() } } - unsafe impl Send for BarcodeDetector {} + boxed_cast_base! { BarcodeDetector, crate::objdetect::GraphicalCodeDetector, cv_barcode_BarcodeDetector_to_GraphicalCodeDetector } impl crate::objdetect::GraphicalCodeDetectorTraitConst for BarcodeDetector { #[inline] fn as_raw_GraphicalCodeDetector(&self) -> *const c_void { self.as_raw() } @@ -7419,52 +7461,4 @@ pub mod objdetect { boxed_ref! { BarcodeDetector, crate::objdetect::BarcodeDetectorTraitConst, as_raw_BarcodeDetector, crate::objdetect::BarcodeDetectorTrait, as_raw_mut_BarcodeDetector } - impl BarcodeDetector { - /// Initialize the BarcodeDetector. - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_barcode_BarcodeDetector_BarcodeDetector(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::BarcodeDetector::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Initialize the BarcodeDetector. - /// - /// Parameters allow to load _optional_ Super Resolution DNN model for better quality. - /// ## Parameters - /// * prototxt_path: prototxt file path for the super resolution model - /// * model_path: model file path for the super resolution model - #[inline] - pub fn new(prototxt_path: &str, model_path: &str) -> Result { - extern_container_arg!(prototxt_path); - extern_container_arg!(model_path); - return_send!(via ocvrs_return); - unsafe { sys::cv_barcode_BarcodeDetector_BarcodeDetector_const_stringR_const_stringR(prototxt_path.opencv_as_extern(), model_path.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::objdetect::BarcodeDetector::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl Clone for BarcodeDetector { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_barcode_BarcodeDetector_implicitClone_const(self.as_raw_BarcodeDetector())) } - } - } - - boxed_cast_base! { BarcodeDetector, crate::objdetect::GraphicalCodeDetector, cv_barcode_BarcodeDetector_to_GraphicalCodeDetector } - - impl std::fmt::Debug for BarcodeDetector { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BarcodeDetector") - .finish() - } - } } diff --git a/docs/optflow.rs b/docs/optflow.rs index 600b84af8..0b31cd2a2 100644 --- a/docs/optflow.rs +++ b/docs/optflow.rs @@ -866,6 +866,134 @@ pub mod optflow { Ok(ret) } + /// Fast dense optical flow computation based on robust local optical flow (RLOF) algorithms and sparse-to-dense interpolation + /// scheme. + /// + /// The RLOF is a fast local optical flow approach described in [Senst2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2012) [Senst2013](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2013) [Senst2014](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2014) + /// and [Senst2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2016) similar to the pyramidal iterative Lucas-Kanade method as + /// proposed by [Bouguet00](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Bouguet00). More details and experiments can be found in the following thesis [Senst2019](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2019). + /// The implementation is derived from optflow::calcOpticalFlowPyrLK(). + /// + /// The sparse-to-dense interpolation scheme allows for fast computation of dense optical flow using RLOF (see [Geistert2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Geistert2016)). + /// For this scheme the following steps are applied: + /// -# motion vector seeded at a regular sampled grid are computed. The sparsity of this grid can be configured with setGridStep + /// -# (optinally) errornous motion vectors are filter based on the forward backward confidence. The threshold can be configured + /// with setForwardBackward. The filter is only applied if the threshold >0 but than the runtime is doubled due to the estimation + /// of the backward flow. + /// -# Vector field interpolation is applied to the motion vector set to obtain a dense vector field. + /// + /// For the RLOF configuration see optflow::RLOFOpticalFlowParameter for further details. + /// Parameters have been described in [Senst2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2012) [Senst2013](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2013) [Senst2014](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2014) and [Senst2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2016). + /// + /// + /// Note: If the grid size is set to (1,1) and the forward backward threshold <= 0 than pixelwise dense optical flow field is + /// computed by RLOF without using interpolation. + /// + /// + /// Note: Note that in output, if no correspondences are found between \a I0 and \a I1, the \a flow is set to 0. + /// ## See also + /// optflow::calcOpticalFlowDenseRLOF(), optflow::RLOFOpticalFlowParameter + pub struct DenseRLOFOpticalFlow { + ptr: *mut c_void, + } + + opencv_type_boxed! { DenseRLOFOpticalFlow } + + impl Drop for DenseRLOFOpticalFlow { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_optflow_DenseRLOFOpticalFlow_delete(self.as_raw_mut_DenseRLOFOpticalFlow()) }; + } + } + + unsafe impl Send for DenseRLOFOpticalFlow {} + + impl DenseRLOFOpticalFlow { + /// Creates instance of optflow::DenseRLOFOpticalFlow + /// + /// ## Parameters + /// * rlofParam: see optflow::RLOFOpticalFlowParameter + /// * forwardBackwardThreshold: see setForwardBackward + /// * gridStep: see setGridStep + /// * interp_type: see setInterpolation + /// * epicK: see setEPICK + /// * epicSigma: see setEPICSigma + /// * epicLambda: see setEPICLambda + /// * ricSPSize: see setRICSPSize + /// * ricSLICType: see setRICSLICType + /// * use_post_proc: see setUsePostProc + /// * fgsLambda: see setFgsLambda + /// * fgsSigma: see setFgsSigma + /// * use_variational_refinement: see setUseVariationalRefinement + /// + /// ## C++ default parameters + /// * rlof_param: Ptr() + /// * forward_backward_threshold: 1.f + /// * grid_step: Size(6,6) + /// * interp_type: InterpolationType::INTERP_EPIC + /// * epic_k: 128 + /// * epic_sigma: 0.05f + /// * epic_lambda: 999.0f + /// * ric_sp_size: 15 + /// * ric_slic_type: 100 + /// * use_post_proc: true + /// * fgs_lambda: 500.0f + /// * fgs_sigma: 1.5f + /// * use_variational_refinement: false + #[inline] + pub fn create(mut rlof_param: core::Ptr, forward_backward_threshold: f32, grid_step: core::Size, interp_type: crate::optflow::InterpolationType, epic_k: i32, epic_sigma: f32, epic_lambda: f32, ric_sp_size: i32, ric_slic_type: i32, use_post_proc: bool, fgs_lambda: f32, fgs_sigma: f32, use_variational_refinement: bool) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_optflow_DenseRLOFOpticalFlow_create_PtrLRLOFOpticalFlowParameterG_float_Size_InterpolationType_int_float_float_int_int_bool_float_float_bool(rlof_param.as_raw_mut_PtrOfRLOFOpticalFlowParameter(), forward_backward_threshold, &grid_step, interp_type, epic_k, epic_sigma, epic_lambda, ric_sp_size, ric_slic_type, use_post_proc, fgs_lambda, fgs_sigma, use_variational_refinement, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Creates instance of optflow::DenseRLOFOpticalFlow + /// + /// ## Parameters + /// * rlofParam: see optflow::RLOFOpticalFlowParameter + /// * forwardBackwardThreshold: see setForwardBackward + /// * gridStep: see setGridStep + /// * interp_type: see setInterpolation + /// * epicK: see setEPICK + /// * epicSigma: see setEPICSigma + /// * epicLambda: see setEPICLambda + /// * ricSPSize: see setRICSPSize + /// * ricSLICType: see setRICSLICType + /// * use_post_proc: see setUsePostProc + /// * fgsLambda: see setFgsLambda + /// * fgsSigma: see setFgsSigma + /// * use_variational_refinement: see setUseVariationalRefinement + /// + /// ## Note + /// This alternative version of [DenseRLOFOpticalFlow::create] function uses the following default values for its arguments: + /// * rlof_param: Ptr() + /// * forward_backward_threshold: 1.f + /// * grid_step: Size(6,6) + /// * interp_type: InterpolationType::INTERP_EPIC + /// * epic_k: 128 + /// * epic_sigma: 0.05f + /// * epic_lambda: 999.0f + /// * ric_sp_size: 15 + /// * ric_slic_type: 100 + /// * use_post_proc: true + /// * fgs_lambda: 500.0f + /// * fgs_sigma: 1.5f + /// * use_variational_refinement: false + #[inline] + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_optflow_DenseRLOFOpticalFlow_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::optflow::DenseRLOFOpticalFlow] pub trait DenseRLOFOpticalFlowTraitConst: crate::video::DenseOpticalFlowTraitConst { fn as_raw_DenseRLOFOpticalFlow(&self) -> *const c_void; @@ -1243,47 +1371,17 @@ pub mod optflow { } - /// Fast dense optical flow computation based on robust local optical flow (RLOF) algorithms and sparse-to-dense interpolation - /// scheme. - /// - /// The RLOF is a fast local optical flow approach described in [Senst2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2012) [Senst2013](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2013) [Senst2014](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2014) - /// and [Senst2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2016) similar to the pyramidal iterative Lucas-Kanade method as - /// proposed by [Bouguet00](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Bouguet00). More details and experiments can be found in the following thesis [Senst2019](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2019). - /// The implementation is derived from optflow::calcOpticalFlowPyrLK(). - /// - /// The sparse-to-dense interpolation scheme allows for fast computation of dense optical flow using RLOF (see [Geistert2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Geistert2016)). - /// For this scheme the following steps are applied: - /// -# motion vector seeded at a regular sampled grid are computed. The sparsity of this grid can be configured with setGridStep - /// -# (optinally) errornous motion vectors are filter based on the forward backward confidence. The threshold can be configured - /// with setForwardBackward. The filter is only applied if the threshold >0 but than the runtime is doubled due to the estimation - /// of the backward flow. - /// -# Vector field interpolation is applied to the motion vector set to obtain a dense vector field. - /// - /// For the RLOF configuration see optflow::RLOFOpticalFlowParameter for further details. - /// Parameters have been described in [Senst2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2012) [Senst2013](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2013) [Senst2014](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2014) and [Senst2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2016). - /// - /// - /// Note: If the grid size is set to (1,1) and the forward backward threshold <= 0 than pixelwise dense optical flow field is - /// computed by RLOF without using interpolation. - /// - /// - /// Note: Note that in output, if no correspondences are found between \a I0 and \a I1, the \a flow is set to 0. - /// ## See also - /// optflow::calcOpticalFlowDenseRLOF(), optflow::RLOFOpticalFlowParameter - pub struct DenseRLOFOpticalFlow { - ptr: *mut c_void, - } - - opencv_type_boxed! { DenseRLOFOpticalFlow } - - impl Drop for DenseRLOFOpticalFlow { + impl std::fmt::Debug for DenseRLOFOpticalFlow { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_optflow_DenseRLOFOpticalFlow_delete(self.as_raw_mut_DenseRLOFOpticalFlow()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DenseRLOFOpticalFlow") + .finish() } } - unsafe impl Send for DenseRLOFOpticalFlow {} + boxed_cast_base! { DenseRLOFOpticalFlow, core::Algorithm, cv_optflow_DenseRLOFOpticalFlow_to_Algorithm } + + boxed_cast_base! { DenseRLOFOpticalFlow, crate::video::DenseOpticalFlow, cv_optflow_DenseRLOFOpticalFlow_to_DenseOpticalFlow } impl core::AlgorithmTraitConst for DenseRLOFOpticalFlow { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1315,104 +1413,116 @@ pub mod optflow { boxed_ref! { DenseRLOFOpticalFlow, crate::optflow::DenseRLOFOpticalFlowTraitConst, as_raw_DenseRLOFOpticalFlow, crate::optflow::DenseRLOFOpticalFlowTrait, as_raw_mut_DenseRLOFOpticalFlow } - impl DenseRLOFOpticalFlow { - /// Creates instance of optflow::DenseRLOFOpticalFlow - /// - /// ## Parameters - /// * rlofParam: see optflow::RLOFOpticalFlowParameter - /// * forwardBackwardThreshold: see setForwardBackward - /// * gridStep: see setGridStep - /// * interp_type: see setInterpolation - /// * epicK: see setEPICK - /// * epicSigma: see setEPICSigma - /// * epicLambda: see setEPICLambda - /// * ricSPSize: see setRICSPSize - /// * ricSLICType: see setRICSLICType - /// * use_post_proc: see setUsePostProc - /// * fgsLambda: see setFgsLambda - /// * fgsSigma: see setFgsSigma - /// * use_variational_refinement: see setUseVariationalRefinement + /// "Dual TV L1" Optical Flow Algorithm. + /// + /// The class implements the "Dual TV L1" optical flow algorithm described in [Zach2007](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Zach2007) and + /// [Javier2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Javier2012) . + /// Here are important members of the class that control the algorithm, which you can set after + /// constructing the class instance: + /// + /// * member double tau + /// Time step of the numerical scheme. + /// + /// * member double lambda + /// Weight parameter for the data term, attachment parameter. This is the most relevant + /// parameter, which determines the smoothness of the output. The smaller this parameter is, + /// the smoother the solutions we obtain. It depends on the range of motions of the images, so + /// its value should be adapted to each image sequence. + /// + /// * member double theta + /// Weight parameter for (u - v)\^2, tightness parameter. It serves as a link between the + /// attachment and the regularization terms. In theory, it should have a small value in order + /// to maintain both parts in correspondence. The method is stable for a large range of values + /// of this parameter. + /// + /// * member int nscales + /// Number of scales used to create the pyramid of images. + /// + /// * member int warps + /// Number of warpings per scale. Represents the number of times that I1(x+u0) and grad( + /// I1(x+u0) ) are computed per scale. This is a parameter that assures the stability of the + /// method. It also affects the running time, so it is a compromise between speed and + /// accuracy. + /// + /// * member double epsilon + /// Stopping criterion threshold used in the numerical scheme, which is a trade-off between + /// precision and running time. A small value will yield more accurate solutions at the + /// expense of a slower convergence. + /// + /// * member int iterations + /// Stopping criterion iterations number used in the numerical scheme. + /// + /// C. Zach, T. Pock and H. Bischof, "A Duality Based Approach for Realtime TV-L1 Optical Flow". + /// Javier Sanchez, Enric Meinhardt-Llopis and Gabriele Facciolo. "TV-L1 Optical Flow Estimation". + pub struct DualTVL1OpticalFlow { + ptr: *mut c_void, + } + + opencv_type_boxed! { DualTVL1OpticalFlow } + + impl Drop for DualTVL1OpticalFlow { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_optflow_DualTVL1OpticalFlow_delete(self.as_raw_mut_DualTVL1OpticalFlow()) }; + } + } + + unsafe impl Send for DualTVL1OpticalFlow {} + + impl DualTVL1OpticalFlow { + /// Creates instance of cv::DualTVL1OpticalFlow /// /// ## C++ default parameters - /// * rlof_param: Ptr() - /// * forward_backward_threshold: 1.f - /// * grid_step: Size(6,6) - /// * interp_type: InterpolationType::INTERP_EPIC - /// * epic_k: 128 - /// * epic_sigma: 0.05f - /// * epic_lambda: 999.0f - /// * ric_sp_size: 15 - /// * ric_slic_type: 100 - /// * use_post_proc: true - /// * fgs_lambda: 500.0f - /// * fgs_sigma: 1.5f - /// * use_variational_refinement: false + /// * tau: 0.25 + /// * lambda: 0.15 + /// * theta: 0.3 + /// * nscales: 5 + /// * warps: 5 + /// * epsilon: 0.01 + /// * innner_iterations: 30 + /// * outer_iterations: 10 + /// * scale_step: 0.8 + /// * gamma: 0.0 + /// * median_filtering: 5 + /// * use_initial_flow: false #[inline] - pub fn create(mut rlof_param: core::Ptr, forward_backward_threshold: f32, grid_step: core::Size, interp_type: crate::optflow::InterpolationType, epic_k: i32, epic_sigma: f32, epic_lambda: f32, ric_sp_size: i32, ric_slic_type: i32, use_post_proc: bool, fgs_lambda: f32, fgs_sigma: f32, use_variational_refinement: bool) -> Result> { + pub fn create(tau: f64, lambda: f64, theta: f64, nscales: i32, warps: i32, epsilon: f64, innner_iterations: i32, outer_iterations: i32, scale_step: f64, gamma: f64, median_filtering: i32, use_initial_flow: bool) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_optflow_DenseRLOFOpticalFlow_create_PtrLRLOFOpticalFlowParameterG_float_Size_InterpolationType_int_float_float_int_int_bool_float_float_bool(rlof_param.as_raw_mut_PtrOfRLOFOpticalFlowParameter(), forward_backward_threshold, &grid_step, interp_type, epic_k, epic_sigma, epic_lambda, ric_sp_size, ric_slic_type, use_post_proc, fgs_lambda, fgs_sigma, use_variational_refinement, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_optflow_DualTVL1OpticalFlow_create_double_double_double_int_int_double_int_int_double_double_int_bool(tau, lambda, theta, nscales, warps, epsilon, innner_iterations, outer_iterations, scale_step, gamma, median_filtering, use_initial_flow, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Creates instance of optflow::DenseRLOFOpticalFlow - /// - /// ## Parameters - /// * rlofParam: see optflow::RLOFOpticalFlowParameter - /// * forwardBackwardThreshold: see setForwardBackward - /// * gridStep: see setGridStep - /// * interp_type: see setInterpolation - /// * epicK: see setEPICK - /// * epicSigma: see setEPICSigma - /// * epicLambda: see setEPICLambda - /// * ricSPSize: see setRICSPSize - /// * ricSLICType: see setRICSLICType - /// * use_post_proc: see setUsePostProc - /// * fgsLambda: see setFgsLambda - /// * fgsSigma: see setFgsSigma - /// * use_variational_refinement: see setUseVariationalRefinement + /// Creates instance of cv::DualTVL1OpticalFlow /// /// ## Note - /// This alternative version of [DenseRLOFOpticalFlow::create] function uses the following default values for its arguments: - /// * rlof_param: Ptr() - /// * forward_backward_threshold: 1.f - /// * grid_step: Size(6,6) - /// * interp_type: InterpolationType::INTERP_EPIC - /// * epic_k: 128 - /// * epic_sigma: 0.05f - /// * epic_lambda: 999.0f - /// * ric_sp_size: 15 - /// * ric_slic_type: 100 - /// * use_post_proc: true - /// * fgs_lambda: 500.0f - /// * fgs_sigma: 1.5f - /// * use_variational_refinement: false + /// This alternative version of [DualTVL1OpticalFlow::create] function uses the following default values for its arguments: + /// * tau: 0.25 + /// * lambda: 0.15 + /// * theta: 0.3 + /// * nscales: 5 + /// * warps: 5 + /// * epsilon: 0.01 + /// * innner_iterations: 30 + /// * outer_iterations: 10 + /// * scale_step: 0.8 + /// * gamma: 0.0 + /// * median_filtering: 5 + /// * use_initial_flow: false #[inline] - pub fn create_def() -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_optflow_DenseRLOFOpticalFlow_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_optflow_DualTVL1OpticalFlow_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { DenseRLOFOpticalFlow, core::Algorithm, cv_optflow_DenseRLOFOpticalFlow_to_Algorithm } - - boxed_cast_base! { DenseRLOFOpticalFlow, crate::video::DenseOpticalFlow, cv_optflow_DenseRLOFOpticalFlow_to_DenseOpticalFlow } - - impl std::fmt::Debug for DenseRLOFOpticalFlow { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DenseRLOFOpticalFlow") - .finish() - } - } - /// Constant methods for [crate::optflow::DualTVL1OpticalFlow] pub trait DualTVL1OpticalFlowTraitConst: crate::video::DenseOpticalFlowTraitConst { fn as_raw_DualTVL1OpticalFlow(&self) -> *const c_void; @@ -1713,61 +1823,17 @@ pub mod optflow { } - /// "Dual TV L1" Optical Flow Algorithm. - /// - /// The class implements the "Dual TV L1" optical flow algorithm described in [Zach2007](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Zach2007) and - /// [Javier2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Javier2012) . - /// Here are important members of the class that control the algorithm, which you can set after - /// constructing the class instance: - /// - /// * member double tau - /// Time step of the numerical scheme. - /// - /// * member double lambda - /// Weight parameter for the data term, attachment parameter. This is the most relevant - /// parameter, which determines the smoothness of the output. The smaller this parameter is, - /// the smoother the solutions we obtain. It depends on the range of motions of the images, so - /// its value should be adapted to each image sequence. - /// - /// * member double theta - /// Weight parameter for (u - v)\^2, tightness parameter. It serves as a link between the - /// attachment and the regularization terms. In theory, it should have a small value in order - /// to maintain both parts in correspondence. The method is stable for a large range of values - /// of this parameter. - /// - /// * member int nscales - /// Number of scales used to create the pyramid of images. - /// - /// * member int warps - /// Number of warpings per scale. Represents the number of times that I1(x+u0) and grad( - /// I1(x+u0) ) are computed per scale. This is a parameter that assures the stability of the - /// method. It also affects the running time, so it is a compromise between speed and - /// accuracy. - /// - /// * member double epsilon - /// Stopping criterion threshold used in the numerical scheme, which is a trade-off between - /// precision and running time. A small value will yield more accurate solutions at the - /// expense of a slower convergence. - /// - /// * member int iterations - /// Stopping criterion iterations number used in the numerical scheme. - /// - /// C. Zach, T. Pock and H. Bischof, "A Duality Based Approach for Realtime TV-L1 Optical Flow". - /// Javier Sanchez, Enric Meinhardt-Llopis and Gabriele Facciolo. "TV-L1 Optical Flow Estimation". - pub struct DualTVL1OpticalFlow { - ptr: *mut c_void, - } - - opencv_type_boxed! { DualTVL1OpticalFlow } - - impl Drop for DualTVL1OpticalFlow { + impl std::fmt::Debug for DualTVL1OpticalFlow { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_optflow_DualTVL1OpticalFlow_delete(self.as_raw_mut_DualTVL1OpticalFlow()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DualTVL1OpticalFlow") + .finish() } } - unsafe impl Send for DualTVL1OpticalFlow {} + boxed_cast_base! { DualTVL1OpticalFlow, core::Algorithm, cv_optflow_DualTVL1OpticalFlow_to_Algorithm } + + boxed_cast_base! { DualTVL1OpticalFlow, crate::video::DenseOpticalFlow, cv_optflow_DualTVL1OpticalFlow_to_DenseOpticalFlow } impl core::AlgorithmTraitConst for DualTVL1OpticalFlow { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1799,84 +1865,6 @@ pub mod optflow { boxed_ref! { DualTVL1OpticalFlow, crate::optflow::DualTVL1OpticalFlowTraitConst, as_raw_DualTVL1OpticalFlow, crate::optflow::DualTVL1OpticalFlowTrait, as_raw_mut_DualTVL1OpticalFlow } - impl DualTVL1OpticalFlow { - /// Creates instance of cv::DualTVL1OpticalFlow - /// - /// ## C++ default parameters - /// * tau: 0.25 - /// * lambda: 0.15 - /// * theta: 0.3 - /// * nscales: 5 - /// * warps: 5 - /// * epsilon: 0.01 - /// * innner_iterations: 30 - /// * outer_iterations: 10 - /// * scale_step: 0.8 - /// * gamma: 0.0 - /// * median_filtering: 5 - /// * use_initial_flow: false - #[inline] - pub fn create(tau: f64, lambda: f64, theta: f64, nscales: i32, warps: i32, epsilon: f64, innner_iterations: i32, outer_iterations: i32, scale_step: f64, gamma: f64, median_filtering: i32, use_initial_flow: bool) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_optflow_DualTVL1OpticalFlow_create_double_double_double_int_int_double_int_int_double_double_int_bool(tau, lambda, theta, nscales, warps, epsilon, innner_iterations, outer_iterations, scale_step, gamma, median_filtering, use_initial_flow, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Creates instance of cv::DualTVL1OpticalFlow - /// - /// ## Note - /// This alternative version of [DualTVL1OpticalFlow::create] function uses the following default values for its arguments: - /// * tau: 0.25 - /// * lambda: 0.15 - /// * theta: 0.3 - /// * nscales: 5 - /// * warps: 5 - /// * epsilon: 0.01 - /// * innner_iterations: 30 - /// * outer_iterations: 10 - /// * scale_step: 0.8 - /// * gamma: 0.0 - /// * median_filtering: 5 - /// * use_initial_flow: false - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_optflow_DualTVL1OpticalFlow_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { DualTVL1OpticalFlow, core::Algorithm, cv_optflow_DualTVL1OpticalFlow_to_Algorithm } - - boxed_cast_base! { DualTVL1OpticalFlow, crate::video::DenseOpticalFlow, cv_optflow_DualTVL1OpticalFlow_to_DenseOpticalFlow } - - impl std::fmt::Debug for DualTVL1OpticalFlow { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DualTVL1OpticalFlow") - .finish() - } - } - - /// Constant methods for [crate::optflow::GPCDetails] - pub trait GPCDetailsTraitConst { - fn as_raw_GPCDetails(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::optflow::GPCDetails] - pub trait GPCDetailsTrait: crate::optflow::GPCDetailsTraitConst { - fn as_raw_mut_GPCDetails(&mut self) -> *mut c_void; - - } - pub struct GPCDetails { ptr: *mut c_void, } @@ -1892,21 +1880,13 @@ pub mod optflow { unsafe impl Send for GPCDetails {} - impl crate::optflow::GPCDetailsTraitConst for GPCDetails { - #[inline] fn as_raw_GPCDetails(&self) -> *const c_void { self.as_raw() } - } - - impl crate::optflow::GPCDetailsTrait for GPCDetails { - #[inline] fn as_raw_mut_GPCDetails(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { GPCDetails, crate::optflow::GPCDetailsTraitConst, as_raw_GPCDetails, crate::optflow::GPCDetailsTrait, as_raw_mut_GPCDetails } - impl GPCDetails { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_optflow_GPCDetails_defaultNew_const()) } + pub fn default() -> crate::optflow::GPCDetails { + let ret = unsafe { sys::cv_optflow_GPCDetails_defaultNew_const() }; + let ret = unsafe { crate::optflow::GPCDetails::opencv_from_extern(ret) }; + ret } #[inline] @@ -1938,12 +1918,16 @@ pub mod optflow { } - impl std::fmt::Debug for GPCDetails { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GPCDetails") - .finish() - } + /// Constant methods for [crate::optflow::GPCDetails] + pub trait GPCDetailsTraitConst { + fn as_raw_GPCDetails(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::optflow::GPCDetails] + pub trait GPCDetailsTrait: crate::optflow::GPCDetailsTraitConst { + fn as_raw_mut_GPCDetails(&mut self) -> *mut c_void; + } impl Default for GPCDetails { @@ -1954,14 +1938,32 @@ pub mod optflow { } } - /// Class encapsulating matching parameters. - #[repr(C)] - #[derive(Copy, Clone, Debug, PartialEq)] - pub struct GPCMatchingParams { - /// Whether to use OpenCL to speed up the matching. - pub use_opencl: bool, - } - + impl std::fmt::Debug for GPCDetails { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GPCDetails") + .finish() + } + } + + impl crate::optflow::GPCDetailsTraitConst for GPCDetails { + #[inline] fn as_raw_GPCDetails(&self) -> *const c_void { self.as_raw() } + } + + impl crate::optflow::GPCDetailsTrait for GPCDetails { + #[inline] fn as_raw_mut_GPCDetails(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { GPCDetails, crate::optflow::GPCDetailsTraitConst, as_raw_GPCDetails, crate::optflow::GPCDetailsTrait, as_raw_mut_GPCDetails } + + /// Class encapsulating matching parameters. + #[repr(C)] + #[derive(Copy, Clone, Debug, PartialEq)] + pub struct GPCMatchingParams { + /// Whether to use OpenCL to speed up the matching. + pub use_opencl: bool, + } + opencv_type_simple! { crate::optflow::GPCMatchingParams } impl GPCMatchingParams { @@ -1999,6 +2001,34 @@ pub mod optflow { } + pub struct GPCPatchDescriptor { + ptr: *mut c_void, + } + + opencv_type_boxed! { GPCPatchDescriptor } + + impl Drop for GPCPatchDescriptor { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_optflow_GPCPatchDescriptor_delete(self.as_raw_mut_GPCPatchDescriptor()) }; + } + } + + unsafe impl Send for GPCPatchDescriptor {} + + impl GPCPatchDescriptor { + /// number of features in a patch descriptor + pub const nFeatures: u32 = 18; + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::optflow::GPCPatchDescriptor { + let ret = unsafe { sys::cv_optflow_GPCPatchDescriptor_defaultNew_const() }; + let ret = unsafe { crate::optflow::GPCPatchDescriptor::opencv_from_extern(ret) }; + ret + } + + } + /// Constant methods for [crate::optflow::GPCPatchDescriptor] pub trait GPCPatchDescriptorTraitConst { fn as_raw_GPCPatchDescriptor(&self) -> *const c_void; @@ -2052,21 +2082,23 @@ pub mod optflow { } - pub struct GPCPatchDescriptor { - ptr: *mut c_void, + impl Default for GPCPatchDescriptor { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { GPCPatchDescriptor } - - impl Drop for GPCPatchDescriptor { + impl std::fmt::Debug for GPCPatchDescriptor { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_optflow_GPCPatchDescriptor_delete(self.as_raw_mut_GPCPatchDescriptor()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GPCPatchDescriptor") + .field("feature", &crate::optflow::GPCPatchDescriptorTraitConst::feature(self)) + .finish() } } - unsafe impl Send for GPCPatchDescriptor {} - impl crate::optflow::GPCPatchDescriptorTraitConst for GPCPatchDescriptor { #[inline] fn as_raw_GPCPatchDescriptor(&self) -> *const c_void { self.as_raw() } } @@ -2077,32 +2109,30 @@ pub mod optflow { boxed_ref! { GPCPatchDescriptor, crate::optflow::GPCPatchDescriptorTraitConst, as_raw_GPCPatchDescriptor, crate::optflow::GPCPatchDescriptorTrait, as_raw_mut_GPCPatchDescriptor } - impl GPCPatchDescriptor { - /// number of features in a patch descriptor - pub const nFeatures: u32 = 18; - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_optflow_GPCPatchDescriptor_defaultNew_const()) } - } - + pub struct GPCPatchSample { + ptr: *mut c_void, } - impl std::fmt::Debug for GPCPatchDescriptor { + opencv_type_boxed! { GPCPatchSample } + + impl Drop for GPCPatchSample { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GPCPatchDescriptor") - .field("feature", &crate::optflow::GPCPatchDescriptorTraitConst::feature(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_optflow_GPCPatchSample_delete(self.as_raw_mut_GPCPatchSample()) }; } } - impl Default for GPCPatchDescriptor { + unsafe impl Send for GPCPatchSample {} + + impl GPCPatchSample { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::optflow::GPCPatchSample { + let ret = unsafe { sys::cv_optflow_GPCPatchSample_defaultNew_const() }; + let ret = unsafe { crate::optflow::GPCPatchSample::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::optflow::GPCPatchSample] @@ -2165,38 +2195,12 @@ pub mod optflow { } - pub struct GPCPatchSample { - ptr: *mut c_void, - } - - opencv_type_boxed! { GPCPatchSample } - - impl Drop for GPCPatchSample { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_optflow_GPCPatchSample_delete(self.as_raw_mut_GPCPatchSample()) }; - } - } - - unsafe impl Send for GPCPatchSample {} - - impl crate::optflow::GPCPatchSampleTraitConst for GPCPatchSample { - #[inline] fn as_raw_GPCPatchSample(&self) -> *const c_void { self.as_raw() } - } - - impl crate::optflow::GPCPatchSampleTrait for GPCPatchSample { - #[inline] fn as_raw_mut_GPCPatchSample(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { GPCPatchSample, crate::optflow::GPCPatchSampleTraitConst, as_raw_GPCPatchSample, crate::optflow::GPCPatchSampleTrait, as_raw_mut_GPCPatchSample } - - impl GPCPatchSample { - /// Creates a default instance of the class by calling the default constructor + impl Default for GPCPatchSample { #[inline] + /// Forwards to infallible Self::default() fn default() -> Self { - unsafe { Self::from_raw(sys::cv_optflow_GPCPatchSample_defaultNew_const()) } + Self::default() } - } impl std::fmt::Debug for GPCPatchSample { @@ -2210,14 +2214,16 @@ pub mod optflow { } } - impl Default for GPCPatchSample { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } + impl crate::optflow::GPCPatchSampleTraitConst for GPCPatchSample { + #[inline] fn as_raw_GPCPatchSample(&self) -> *const c_void { self.as_raw() } + } + + impl crate::optflow::GPCPatchSampleTrait for GPCPatchSample { + #[inline] fn as_raw_mut_GPCPatchSample(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { GPCPatchSample, crate::optflow::GPCPatchSampleTraitConst, as_raw_GPCPatchSample, crate::optflow::GPCPatchSampleTrait, as_raw_mut_GPCPatchSample } + /// Class encapsulating training parameters. #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] @@ -2275,36 +2281,6 @@ pub mod optflow { } - /// Constant methods for [crate::optflow::GPCTrainingSamples] - pub trait GPCTrainingSamplesTraitConst { - fn as_raw_GPCTrainingSamples(&self) -> *const c_void; - - #[inline] - fn size(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_optflow_GPCTrainingSamples_size_const(self.as_raw_GPCTrainingSamples(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn typ(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_optflow_GPCTrainingSamples_type_const(self.as_raw_GPCTrainingSamples(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - /// Mutable methods for [crate::optflow::GPCTrainingSamples] - pub trait GPCTrainingSamplesTrait: crate::optflow::GPCTrainingSamplesTraitConst { - fn as_raw_mut_GPCTrainingSamples(&mut self) -> *mut c_void; - - } - /// Class encapsulating training samples. pub struct GPCTrainingSamples { ptr: *mut c_void, @@ -2321,21 +2297,13 @@ pub mod optflow { unsafe impl Send for GPCTrainingSamples {} - impl crate::optflow::GPCTrainingSamplesTraitConst for GPCTrainingSamples { - #[inline] fn as_raw_GPCTrainingSamples(&self) -> *const c_void { self.as_raw() } - } - - impl crate::optflow::GPCTrainingSamplesTrait for GPCTrainingSamples { - #[inline] fn as_raw_mut_GPCTrainingSamples(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { GPCTrainingSamples, crate::optflow::GPCTrainingSamplesTraitConst, as_raw_GPCTrainingSamples, crate::optflow::GPCTrainingSamplesTrait, as_raw_mut_GPCTrainingSamples } - impl GPCTrainingSamples { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_optflow_GPCTrainingSamples_defaultNew_const()) } + pub fn default() -> crate::optflow::GPCTrainingSamples { + let ret = unsafe { sys::cv_optflow_GPCTrainingSamples_defaultNew_const() }; + let ret = unsafe { crate::optflow::GPCTrainingSamples::opencv_from_extern(ret) }; + ret } /// This function can be used to extract samples from a pair of images and a ground truth flow. @@ -2365,69 +2333,146 @@ pub mod optflow { } - impl std::fmt::Debug for GPCTrainingSamples { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GPCTrainingSamples") - .finish() - } - } - - impl Default for GPCTrainingSamples { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - - /// Constant methods for [crate::optflow::GPCTree] - pub trait GPCTreeTraitConst: core::AlgorithmTraitConst { - fn as_raw_GPCTree(&self) -> *const c_void; + /// Constant methods for [crate::optflow::GPCTrainingSamples] + pub trait GPCTrainingSamplesTraitConst { + fn as_raw_GPCTrainingSamples(&self) -> *const c_void; #[inline] - fn write(&self, fs: &mut impl core::FileStorageTrait) -> Result<()> { + fn size(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_optflow_GPCTree_write_const_FileStorageR(self.as_raw_GPCTree(), fs.as_raw_mut_FileStorage(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_optflow_GPCTrainingSamples_size_const(self.as_raw_GPCTrainingSamples(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } #[inline] - fn find_leaf_for_patch(&self, descr: &impl crate::optflow::GPCPatchDescriptorTraitConst) -> Result { + fn typ(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_optflow_GPCTree_findLeafForPatch_const_const_GPCPatchDescriptorR(self.as_raw_GPCTree(), descr.as_raw_GPCPatchDescriptor(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_optflow_GPCTrainingSamples_type_const(self.as_raw_GPCTrainingSamples(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } + } + + /// Mutable methods for [crate::optflow::GPCTrainingSamples] + pub trait GPCTrainingSamplesTrait: crate::optflow::GPCTrainingSamplesTraitConst { + fn as_raw_mut_GPCTrainingSamples(&mut self) -> *mut c_void; + + } + + impl Default for GPCTrainingSamples { #[inline] - fn equals(&self, t: &impl crate::optflow::GPCTreeTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_optflow_GPCTree_operatorEQ_const_const_GPCTreeR(self.as_raw_GPCTree(), t.as_raw_GPCTree(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() } + } + impl std::fmt::Debug for GPCTrainingSamples { #[inline] - fn get_descriptor_type(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_optflow_GPCTree_getDescriptorType_const(self.as_raw_GPCTree(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GPCTrainingSamples") + .finish() } - } - /// Mutable methods for [crate::optflow::GPCTree] - pub trait GPCTreeTrait: core::AlgorithmTrait + crate::optflow::GPCTreeTraitConst { - fn as_raw_mut_GPCTree(&mut self) -> *mut c_void; + impl crate::optflow::GPCTrainingSamplesTraitConst for GPCTrainingSamples { + #[inline] fn as_raw_GPCTrainingSamples(&self) -> *const c_void { self.as_raw() } + } - /// ## C++ default parameters + impl crate::optflow::GPCTrainingSamplesTrait for GPCTrainingSamples { + #[inline] fn as_raw_mut_GPCTrainingSamples(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { GPCTrainingSamples, crate::optflow::GPCTrainingSamplesTraitConst, as_raw_GPCTrainingSamples, crate::optflow::GPCTrainingSamplesTrait, as_raw_mut_GPCTrainingSamples } + + /// Class for individual tree. + pub struct GPCTree { + ptr: *mut c_void, + } + + opencv_type_boxed! { GPCTree } + + impl Drop for GPCTree { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_optflow_GPCTree_delete(self.as_raw_mut_GPCTree()) }; + } + } + + unsafe impl Send for GPCTree {} + + impl GPCTree { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::optflow::GPCTree { + let ret = unsafe { sys::cv_optflow_GPCTree_defaultNew_const() }; + let ret = unsafe { crate::optflow::GPCTree::opencv_from_extern(ret) }; + ret + } + + #[inline] + pub fn create() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_optflow_GPCTree_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::optflow::GPCTree] + pub trait GPCTreeTraitConst: core::AlgorithmTraitConst { + fn as_raw_GPCTree(&self) -> *const c_void; + + #[inline] + fn write(&self, fs: &mut impl core::FileStorageTrait) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_optflow_GPCTree_write_const_FileStorageR(self.as_raw_GPCTree(), fs.as_raw_mut_FileStorage(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn find_leaf_for_patch(&self, descr: &impl crate::optflow::GPCPatchDescriptorTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_optflow_GPCTree_findLeafForPatch_const_const_GPCPatchDescriptorR(self.as_raw_GPCTree(), descr.as_raw_GPCPatchDescriptor(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn equals(&self, t: &impl crate::optflow::GPCTreeTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_optflow_GPCTree_operatorEQ_const_const_GPCTreeR(self.as_raw_GPCTree(), t.as_raw_GPCTree(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn get_descriptor_type(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_optflow_GPCTree_getDescriptorType_const(self.as_raw_GPCTree(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + /// Mutable methods for [crate::optflow::GPCTree] + pub trait GPCTreeTrait: core::AlgorithmTrait + crate::optflow::GPCTreeTraitConst { + fn as_raw_mut_GPCTree(&mut self) -> *mut c_void; + + /// ## C++ default parameters /// * params: GPCTrainingParams() #[inline] fn train(&mut self, samples: &mut impl crate::optflow::GPCTrainingSamplesTrait, params: crate::optflow::GPCTrainingParams) -> Result<()> { @@ -2461,21 +2506,23 @@ pub mod optflow { } - /// Class for individual tree. - pub struct GPCTree { - ptr: *mut c_void, + impl Default for GPCTree { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { GPCTree } - - impl Drop for GPCTree { + impl std::fmt::Debug for GPCTree { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_optflow_GPCTree_delete(self.as_raw_mut_GPCTree()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GPCTree") + .finish() } } - unsafe impl Send for GPCTree {} + boxed_cast_base! { GPCTree, core::Algorithm, cv_optflow_GPCTree_to_Algorithm } impl core::AlgorithmTraitConst for GPCTree { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2497,43 +2544,6 @@ pub mod optflow { boxed_ref! { GPCTree, crate::optflow::GPCTreeTraitConst, as_raw_GPCTree, crate::optflow::GPCTreeTrait, as_raw_mut_GPCTree } - impl GPCTree { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_optflow_GPCTree_defaultNew_const()) } - } - - #[inline] - pub fn create() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_optflow_GPCTree_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { GPCTree, core::Algorithm, cv_optflow_GPCTree_to_Algorithm } - - impl std::fmt::Debug for GPCTree { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GPCTree") - .finish() - } - } - - impl Default for GPCTree { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] pub struct GPCTree_Node { @@ -2559,39 +2569,6 @@ pub mod optflow { } - /// Constant methods for [crate::optflow::OpticalFlowPCAFlow] - pub trait OpticalFlowPCAFlowTraitConst: crate::video::DenseOpticalFlowTraitConst { - fn as_raw_OpticalFlowPCAFlow(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::optflow::OpticalFlowPCAFlow] - pub trait OpticalFlowPCAFlowTrait: crate::optflow::OpticalFlowPCAFlowTraitConst + crate::video::DenseOpticalFlowTrait { - fn as_raw_mut_OpticalFlowPCAFlow(&mut self) -> *mut c_void; - - #[inline] - fn calc(&mut self, i0: &impl ToInputArray, i1: &impl ToInputArray, flow: &mut impl ToInputOutputArray) -> Result<()> { - input_array_arg!(i0); - input_array_arg!(i1); - input_output_array_arg!(flow); - return_send!(via ocvrs_return); - unsafe { sys::cv_optflow_OpticalFlowPCAFlow_calc_const__InputArrayR_const__InputArrayR_const__InputOutputArrayR(self.as_raw_mut_OpticalFlowPCAFlow(), i0.as_raw__InputArray(), i1.as_raw__InputArray(), flow.as_raw__InputOutputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn collect_garbage(&mut self) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_optflow_OpticalFlowPCAFlow_collectGarbage(self.as_raw_mut_OpticalFlowPCAFlow(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - /// PCAFlow algorithm. pub struct OpticalFlowPCAFlow { ptr: *mut c_void, @@ -2608,36 +2585,6 @@ pub mod optflow { unsafe impl Send for OpticalFlowPCAFlow {} - impl core::AlgorithmTraitConst for OpticalFlowPCAFlow { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for OpticalFlowPCAFlow { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { OpticalFlowPCAFlow, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::video::DenseOpticalFlowTraitConst for OpticalFlowPCAFlow { - #[inline] fn as_raw_DenseOpticalFlow(&self) -> *const c_void { self.as_raw() } - } - - impl crate::video::DenseOpticalFlowTrait for OpticalFlowPCAFlow { - #[inline] fn as_raw_mut_DenseOpticalFlow(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { OpticalFlowPCAFlow, crate::video::DenseOpticalFlowTraitConst, as_raw_DenseOpticalFlow, crate::video::DenseOpticalFlowTrait, as_raw_mut_DenseOpticalFlow } - - impl crate::optflow::OpticalFlowPCAFlowTraitConst for OpticalFlowPCAFlow { - #[inline] fn as_raw_OpticalFlowPCAFlow(&self) -> *const c_void { self.as_raw() } - } - - impl crate::optflow::OpticalFlowPCAFlowTrait for OpticalFlowPCAFlow { - #[inline] fn as_raw_mut_OpticalFlowPCAFlow(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { OpticalFlowPCAFlow, crate::optflow::OpticalFlowPCAFlowTraitConst, as_raw_OpticalFlowPCAFlow, crate::optflow::OpticalFlowPCAFlowTrait, as_raw_mut_OpticalFlowPCAFlow } - impl OpticalFlowPCAFlow { /// Creates an instance of PCAFlow algorithm. /// ## Parameters @@ -2698,9 +2645,38 @@ pub mod optflow { } - boxed_cast_base! { OpticalFlowPCAFlow, core::Algorithm, cv_optflow_OpticalFlowPCAFlow_to_Algorithm } + /// Constant methods for [crate::optflow::OpticalFlowPCAFlow] + pub trait OpticalFlowPCAFlowTraitConst: crate::video::DenseOpticalFlowTraitConst { + fn as_raw_OpticalFlowPCAFlow(&self) -> *const c_void; - boxed_cast_base! { OpticalFlowPCAFlow, crate::video::DenseOpticalFlow, cv_optflow_OpticalFlowPCAFlow_to_DenseOpticalFlow } + } + + /// Mutable methods for [crate::optflow::OpticalFlowPCAFlow] + pub trait OpticalFlowPCAFlowTrait: crate::optflow::OpticalFlowPCAFlowTraitConst + crate::video::DenseOpticalFlowTrait { + fn as_raw_mut_OpticalFlowPCAFlow(&mut self) -> *mut c_void; + + #[inline] + fn calc(&mut self, i0: &impl ToInputArray, i1: &impl ToInputArray, flow: &mut impl ToInputOutputArray) -> Result<()> { + input_array_arg!(i0); + input_array_arg!(i1); + input_output_array_arg!(flow); + return_send!(via ocvrs_return); + unsafe { sys::cv_optflow_OpticalFlowPCAFlow_calc_const__InputArrayR_const__InputArrayR_const__InputOutputArrayR(self.as_raw_mut_OpticalFlowPCAFlow(), i0.as_raw__InputArray(), i1.as_raw__InputArray(), flow.as_raw__InputOutputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn collect_garbage(&mut self) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_optflow_OpticalFlowPCAFlow_collectGarbage(self.as_raw_mut_OpticalFlowPCAFlow(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } impl std::fmt::Debug for OpticalFlowPCAFlow { #[inline] @@ -2710,6 +2686,73 @@ pub mod optflow { } } + boxed_cast_base! { OpticalFlowPCAFlow, core::Algorithm, cv_optflow_OpticalFlowPCAFlow_to_Algorithm } + + boxed_cast_base! { OpticalFlowPCAFlow, crate::video::DenseOpticalFlow, cv_optflow_OpticalFlowPCAFlow_to_DenseOpticalFlow } + + impl core::AlgorithmTraitConst for OpticalFlowPCAFlow { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } + } + + impl core::AlgorithmTrait for OpticalFlowPCAFlow { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { OpticalFlowPCAFlow, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + + impl crate::video::DenseOpticalFlowTraitConst for OpticalFlowPCAFlow { + #[inline] fn as_raw_DenseOpticalFlow(&self) -> *const c_void { self.as_raw() } + } + + impl crate::video::DenseOpticalFlowTrait for OpticalFlowPCAFlow { + #[inline] fn as_raw_mut_DenseOpticalFlow(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { OpticalFlowPCAFlow, crate::video::DenseOpticalFlowTraitConst, as_raw_DenseOpticalFlow, crate::video::DenseOpticalFlowTrait, as_raw_mut_DenseOpticalFlow } + + impl crate::optflow::OpticalFlowPCAFlowTraitConst for OpticalFlowPCAFlow { + #[inline] fn as_raw_OpticalFlowPCAFlow(&self) -> *const c_void { self.as_raw() } + } + + impl crate::optflow::OpticalFlowPCAFlowTrait for OpticalFlowPCAFlow { + #[inline] fn as_raw_mut_OpticalFlowPCAFlow(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { OpticalFlowPCAFlow, crate::optflow::OpticalFlowPCAFlowTraitConst, as_raw_OpticalFlowPCAFlow, crate::optflow::OpticalFlowPCAFlowTrait, as_raw_mut_OpticalFlowPCAFlow } + + /// + /// This class can be used for imposing a learned prior on the resulting optical flow. + /// Solution will be regularized according to this prior. + /// You need to generate appropriate prior file with "learn_prior.py" script beforehand. + pub struct PCAPrior { + ptr: *mut c_void, + } + + opencv_type_boxed! { PCAPrior } + + impl Drop for PCAPrior { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_optflow_PCAPrior_delete(self.as_raw_mut_PCAPrior()) }; + } + } + + unsafe impl Send for PCAPrior {} + + impl PCAPrior { + #[inline] + pub fn new(path_to_prior: &str) -> Result { + extern_container_arg!(path_to_prior); + return_send!(via ocvrs_return); + unsafe { sys::cv_optflow_PCAPrior_PCAPrior_const_charX(path_to_prior.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::optflow::PCAPrior::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::optflow::PCAPrior] pub trait PCAPriorTraitConst { fn as_raw_PCAPrior(&self) -> *const c_void; @@ -2749,55 +2792,87 @@ pub mod optflow { } + impl std::fmt::Debug for PCAPrior { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PCAPrior") + .finish() + } + } + + impl crate::optflow::PCAPriorTraitConst for PCAPrior { + #[inline] fn as_raw_PCAPrior(&self) -> *const c_void { self.as_raw() } + } + + impl crate::optflow::PCAPriorTrait for PCAPrior { + #[inline] fn as_raw_mut_PCAPrior(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { PCAPrior, crate::optflow::PCAPriorTraitConst, as_raw_PCAPrior, crate::optflow::PCAPriorTrait, as_raw_mut_PCAPrior } + + /// This is used store and set up the parameters of the robust local optical flow (RLOF) algoritm. /// - /// This class can be used for imposing a learned prior on the resulting optical flow. - /// Solution will be regularized according to this prior. - /// You need to generate appropriate prior file with "learn_prior.py" script beforehand. - pub struct PCAPrior { + /// The RLOF is a fast local optical flow approach described in [Senst2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2012) [Senst2013](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2013) [Senst2014](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2014) + /// and [Senst2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2016) similar to the pyramidal iterative Lucas-Kanade method as + /// proposed by [Bouguet00](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Bouguet00). More details and experiments can be found in the following thesis [Senst2019](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2019). + /// The implementation is derived from optflow::calcOpticalFlowPyrLK(). + /// This RLOF implementation can be seen as an improved pyramidal iterative Lucas-Kanade and includes + /// a set of improving modules. The main improvements in respect to the pyramidal iterative Lucas-Kanade + /// are: + /// - A more robust redecending M-estimator framework (see [Senst2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2012)) to improve the accuracy at + /// motion boundaries and appearing and disappearing pixels. + /// - an adaptive support region strategies to improve the accuracy at motion boundaries to reduce the + /// corona effect, i.e oversmoothing of the PLK at motion/object boundaries. The cross-based segementation + /// strategy (SR_CROSS) proposed in [Senst2014](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2014) uses a simple segmenation approach to obtain the optimal + /// shape of the support region. + /// - To deal with illumination changes (outdoor sequences and shadow) the intensity constancy assumption + /// based optical flow equation has been adopt with the Gennert and Negahdaripour illumination model + /// (see [Senst2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2016)). This model can be switched on/off with the useIlluminationModel variable. + /// - By using a global motion prior initialization (see [Senst2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2016)) of the iterative refinement + /// the accuracy could be significantly improved for large displacements. This initialization can be + /// switched on and of with useGlobalMotionPrior variable. + /// + /// The RLOF can be computed with the SparseOpticalFlow class or function interface to track a set of features + /// or with the DenseOpticalFlow class or function interface to compute dense optical flow. + /// ## See also + /// optflow::DenseRLOFOpticalFlow, optflow::calcOpticalFlowDenseRLOF(), optflow::SparseRLOFOpticalFlow, optflow::calcOpticalFlowSparseRLOF() + pub struct RLOFOpticalFlowParameter { ptr: *mut c_void, } - opencv_type_boxed! { PCAPrior } + opencv_type_boxed! { RLOFOpticalFlowParameter } - impl Drop for PCAPrior { + impl Drop for RLOFOpticalFlowParameter { #[inline] fn drop(&mut self) { - unsafe { sys::cv_optflow_PCAPrior_delete(self.as_raw_mut_PCAPrior()) }; + unsafe { sys::cv_optflow_RLOFOpticalFlowParameter_delete(self.as_raw_mut_RLOFOpticalFlowParameter()) }; } } - unsafe impl Send for PCAPrior {} - - impl crate::optflow::PCAPriorTraitConst for PCAPrior { - #[inline] fn as_raw_PCAPrior(&self) -> *const c_void { self.as_raw() } - } - - impl crate::optflow::PCAPriorTrait for PCAPrior { - #[inline] fn as_raw_mut_PCAPrior(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { PCAPrior, crate::optflow::PCAPriorTraitConst, as_raw_PCAPrior, crate::optflow::PCAPriorTrait, as_raw_mut_PCAPrior } + unsafe impl Send for RLOFOpticalFlowParameter {} - impl PCAPrior { + impl RLOFOpticalFlowParameter { #[inline] - pub fn new(path_to_prior: &str) -> Result { - extern_container_arg!(path_to_prior); + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_optflow_PCAPrior_PCAPrior_const_charX(path_to_prior.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_optflow_RLOFOpticalFlowParameter_RLOFOpticalFlowParameter(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::optflow::PCAPrior::opencv_from_extern(ret) }; + let ret = unsafe { crate::optflow::RLOFOpticalFlowParameter::opencv_from_extern(ret) }; Ok(ret) } - } - - impl std::fmt::Debug for PCAPrior { + /// Creates instance of optflow::RLOFOpticalFlowParameter #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PCAPrior") - .finish() + pub fn create() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_optflow_RLOFOpticalFlowParameter_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::optflow::RLOFOpticalFlowParameter] @@ -3251,103 +3326,109 @@ pub mod optflow { } - /// This is used store and set up the parameters of the robust local optical flow (RLOF) algoritm. + impl std::fmt::Debug for RLOFOpticalFlowParameter { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RLOFOpticalFlowParameter") + .field("solver_type", &crate::optflow::RLOFOpticalFlowParameterTraitConst::solver_type(self)) + .field("support_region_type", &crate::optflow::RLOFOpticalFlowParameterTraitConst::support_region_type(self)) + .field("norm_sigma0", &crate::optflow::RLOFOpticalFlowParameterTraitConst::norm_sigma0(self)) + .field("norm_sigma1", &crate::optflow::RLOFOpticalFlowParameterTraitConst::norm_sigma1(self)) + .field("small_win_size", &crate::optflow::RLOFOpticalFlowParameterTraitConst::small_win_size(self)) + .field("large_win_size", &crate::optflow::RLOFOpticalFlowParameterTraitConst::large_win_size(self)) + .field("cross_segmentation_threshold", &crate::optflow::RLOFOpticalFlowParameterTraitConst::cross_segmentation_threshold(self)) + .field("max_level", &crate::optflow::RLOFOpticalFlowParameterTraitConst::max_level(self)) + .field("use_initial_flow", &crate::optflow::RLOFOpticalFlowParameterTraitConst::use_initial_flow(self)) + .field("use_illumination_model", &crate::optflow::RLOFOpticalFlowParameterTraitConst::use_illumination_model(self)) + .field("use_global_motion_prior", &crate::optflow::RLOFOpticalFlowParameterTraitConst::use_global_motion_prior(self)) + .field("max_iteration", &crate::optflow::RLOFOpticalFlowParameterTraitConst::max_iteration(self)) + .field("min_eigen_value", &crate::optflow::RLOFOpticalFlowParameterTraitConst::min_eigen_value(self)) + .field("global_motion_ransac_threshold", &crate::optflow::RLOFOpticalFlowParameterTraitConst::global_motion_ransac_threshold(self)) + .finish() + } + } + + impl crate::optflow::RLOFOpticalFlowParameterTraitConst for RLOFOpticalFlowParameter { + #[inline] fn as_raw_RLOFOpticalFlowParameter(&self) -> *const c_void { self.as_raw() } + } + + impl crate::optflow::RLOFOpticalFlowParameterTrait for RLOFOpticalFlowParameter { + #[inline] fn as_raw_mut_RLOFOpticalFlowParameter(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { RLOFOpticalFlowParameter, crate::optflow::RLOFOpticalFlowParameterTraitConst, as_raw_RLOFOpticalFlowParameter, crate::optflow::RLOFOpticalFlowParameterTrait, as_raw_mut_RLOFOpticalFlowParameter } + + /// Class used for calculation sparse optical flow and feature tracking with robust local optical flow (RLOF) algorithms. /// /// The RLOF is a fast local optical flow approach described in [Senst2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2012) [Senst2013](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2013) [Senst2014](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2014) /// and [Senst2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2016) similar to the pyramidal iterative Lucas-Kanade method as /// proposed by [Bouguet00](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Bouguet00). More details and experiments can be found in the following thesis [Senst2019](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2019). /// The implementation is derived from optflow::calcOpticalFlowPyrLK(). - /// This RLOF implementation can be seen as an improved pyramidal iterative Lucas-Kanade and includes - /// a set of improving modules. The main improvements in respect to the pyramidal iterative Lucas-Kanade - /// are: - /// - A more robust redecending M-estimator framework (see [Senst2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2012)) to improve the accuracy at - /// motion boundaries and appearing and disappearing pixels. - /// - an adaptive support region strategies to improve the accuracy at motion boundaries to reduce the - /// corona effect, i.e oversmoothing of the PLK at motion/object boundaries. The cross-based segementation - /// strategy (SR_CROSS) proposed in [Senst2014](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2014) uses a simple segmenation approach to obtain the optimal - /// shape of the support region. - /// - To deal with illumination changes (outdoor sequences and shadow) the intensity constancy assumption - /// based optical flow equation has been adopt with the Gennert and Negahdaripour illumination model - /// (see [Senst2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2016)). This model can be switched on/off with the useIlluminationModel variable. - /// - By using a global motion prior initialization (see [Senst2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2016)) of the iterative refinement - /// the accuracy could be significantly improved for large displacements. This initialization can be - /// switched on and of with useGlobalMotionPrior variable. /// - /// The RLOF can be computed with the SparseOpticalFlow class or function interface to track a set of features - /// or with the DenseOpticalFlow class or function interface to compute dense optical flow. + /// For the RLOF configuration see optflow::RLOFOpticalFlowParameter for further details. + /// Parameters have been described in [Senst2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2012), [Senst2013](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2013), [Senst2014](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2014) and [Senst2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2016). + /// + /// + /// Note: SIMD parallelization is only available when compiling with SSE4.1. /// ## See also - /// optflow::DenseRLOFOpticalFlow, optflow::calcOpticalFlowDenseRLOF(), optflow::SparseRLOFOpticalFlow, optflow::calcOpticalFlowSparseRLOF() - pub struct RLOFOpticalFlowParameter { + /// optflow::calcOpticalFlowSparseRLOF(), optflow::RLOFOpticalFlowParameter + pub struct SparseRLOFOpticalFlow { ptr: *mut c_void, } - opencv_type_boxed! { RLOFOpticalFlowParameter } + opencv_type_boxed! { SparseRLOFOpticalFlow } - impl Drop for RLOFOpticalFlowParameter { + impl Drop for SparseRLOFOpticalFlow { #[inline] fn drop(&mut self) { - unsafe { sys::cv_optflow_RLOFOpticalFlowParameter_delete(self.as_raw_mut_RLOFOpticalFlowParameter()) }; + unsafe { sys::cv_optflow_SparseRLOFOpticalFlow_delete(self.as_raw_mut_SparseRLOFOpticalFlow()) }; } } - unsafe impl Send for RLOFOpticalFlowParameter {} - - impl crate::optflow::RLOFOpticalFlowParameterTraitConst for RLOFOpticalFlowParameter { - #[inline] fn as_raw_RLOFOpticalFlowParameter(&self) -> *const c_void { self.as_raw() } - } - - impl crate::optflow::RLOFOpticalFlowParameterTrait for RLOFOpticalFlowParameter { - #[inline] fn as_raw_mut_RLOFOpticalFlowParameter(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { RLOFOpticalFlowParameter, crate::optflow::RLOFOpticalFlowParameterTraitConst, as_raw_RLOFOpticalFlowParameter, crate::optflow::RLOFOpticalFlowParameterTrait, as_raw_mut_RLOFOpticalFlowParameter } + unsafe impl Send for SparseRLOFOpticalFlow {} - impl RLOFOpticalFlowParameter { + impl SparseRLOFOpticalFlow { + /// Creates instance of SparseRLOFOpticalFlow + /// + /// ## Parameters + /// * rlofParam: see setRLOFOpticalFlowParameter + /// * forwardBackwardThreshold: see setForwardBackward + /// + /// ## C++ default parameters + /// * rlof_param: Ptr() + /// * forward_backward_threshold: 1.f #[inline] - pub fn default() -> Result { + pub fn create(mut rlof_param: core::Ptr, forward_backward_threshold: f32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_optflow_RLOFOpticalFlowParameter_RLOFOpticalFlowParameter(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_optflow_SparseRLOFOpticalFlow_create_PtrLRLOFOpticalFlowParameterG_float(rlof_param.as_raw_mut_PtrOfRLOFOpticalFlowParameter(), forward_backward_threshold, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::optflow::RLOFOpticalFlowParameter::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Creates instance of optflow::RLOFOpticalFlowParameter + /// Creates instance of SparseRLOFOpticalFlow + /// + /// ## Parameters + /// * rlofParam: see setRLOFOpticalFlowParameter + /// * forwardBackwardThreshold: see setForwardBackward + /// + /// ## Note + /// This alternative version of [SparseRLOFOpticalFlow::create] function uses the following default values for its arguments: + /// * rlof_param: Ptr() + /// * forward_backward_threshold: 1.f #[inline] - pub fn create() -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_optflow_RLOFOpticalFlowParameter_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_optflow_SparseRLOFOpticalFlow_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for RLOFOpticalFlowParameter { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RLOFOpticalFlowParameter") - .field("solver_type", &crate::optflow::RLOFOpticalFlowParameterTraitConst::solver_type(self)) - .field("support_region_type", &crate::optflow::RLOFOpticalFlowParameterTraitConst::support_region_type(self)) - .field("norm_sigma0", &crate::optflow::RLOFOpticalFlowParameterTraitConst::norm_sigma0(self)) - .field("norm_sigma1", &crate::optflow::RLOFOpticalFlowParameterTraitConst::norm_sigma1(self)) - .field("small_win_size", &crate::optflow::RLOFOpticalFlowParameterTraitConst::small_win_size(self)) - .field("large_win_size", &crate::optflow::RLOFOpticalFlowParameterTraitConst::large_win_size(self)) - .field("cross_segmentation_threshold", &crate::optflow::RLOFOpticalFlowParameterTraitConst::cross_segmentation_threshold(self)) - .field("max_level", &crate::optflow::RLOFOpticalFlowParameterTraitConst::max_level(self)) - .field("use_initial_flow", &crate::optflow::RLOFOpticalFlowParameterTraitConst::use_initial_flow(self)) - .field("use_illumination_model", &crate::optflow::RLOFOpticalFlowParameterTraitConst::use_illumination_model(self)) - .field("use_global_motion_prior", &crate::optflow::RLOFOpticalFlowParameterTraitConst::use_global_motion_prior(self)) - .field("max_iteration", &crate::optflow::RLOFOpticalFlowParameterTraitConst::max_iteration(self)) - .field("min_eigen_value", &crate::optflow::RLOFOpticalFlowParameterTraitConst::min_eigen_value(self)) - .field("global_motion_ransac_threshold", &crate::optflow::RLOFOpticalFlowParameterTraitConst::global_motion_ransac_threshold(self)) - .finish() - } - } - /// Constant methods for [crate::optflow::SparseRLOFOpticalFlow] pub trait SparseRLOFOpticalFlowTraitConst: crate::video::SparseOpticalFlowTraitConst { fn as_raw_SparseRLOFOpticalFlow(&self) -> *const c_void; @@ -3417,34 +3498,17 @@ pub mod optflow { } - /// Class used for calculation sparse optical flow and feature tracking with robust local optical flow (RLOF) algorithms. - /// - /// The RLOF is a fast local optical flow approach described in [Senst2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2012) [Senst2013](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2013) [Senst2014](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2014) - /// and [Senst2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2016) similar to the pyramidal iterative Lucas-Kanade method as - /// proposed by [Bouguet00](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Bouguet00). More details and experiments can be found in the following thesis [Senst2019](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2019). - /// The implementation is derived from optflow::calcOpticalFlowPyrLK(). - /// - /// For the RLOF configuration see optflow::RLOFOpticalFlowParameter for further details. - /// Parameters have been described in [Senst2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2012), [Senst2013](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2013), [Senst2014](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2014) and [Senst2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Senst2016). - /// - /// - /// Note: SIMD parallelization is only available when compiling with SSE4.1. - /// ## See also - /// optflow::calcOpticalFlowSparseRLOF(), optflow::RLOFOpticalFlowParameter - pub struct SparseRLOFOpticalFlow { - ptr: *mut c_void, - } - - opencv_type_boxed! { SparseRLOFOpticalFlow } - - impl Drop for SparseRLOFOpticalFlow { + impl std::fmt::Debug for SparseRLOFOpticalFlow { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_optflow_SparseRLOFOpticalFlow_delete(self.as_raw_mut_SparseRLOFOpticalFlow()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SparseRLOFOpticalFlow") + .finish() } } - unsafe impl Send for SparseRLOFOpticalFlow {} + boxed_cast_base! { SparseRLOFOpticalFlow, core::Algorithm, cv_optflow_SparseRLOFOpticalFlow_to_Algorithm } + + boxed_cast_base! { SparseRLOFOpticalFlow, crate::video::SparseOpticalFlow, cv_optflow_SparseRLOFOpticalFlow_to_SparseOpticalFlow } impl core::AlgorithmTraitConst for SparseRLOFOpticalFlow { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3476,57 +3540,4 @@ pub mod optflow { boxed_ref! { SparseRLOFOpticalFlow, crate::optflow::SparseRLOFOpticalFlowTraitConst, as_raw_SparseRLOFOpticalFlow, crate::optflow::SparseRLOFOpticalFlowTrait, as_raw_mut_SparseRLOFOpticalFlow } - impl SparseRLOFOpticalFlow { - /// Creates instance of SparseRLOFOpticalFlow - /// - /// ## Parameters - /// * rlofParam: see setRLOFOpticalFlowParameter - /// * forwardBackwardThreshold: see setForwardBackward - /// - /// ## C++ default parameters - /// * rlof_param: Ptr() - /// * forward_backward_threshold: 1.f - #[inline] - pub fn create(mut rlof_param: core::Ptr, forward_backward_threshold: f32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_optflow_SparseRLOFOpticalFlow_create_PtrLRLOFOpticalFlowParameterG_float(rlof_param.as_raw_mut_PtrOfRLOFOpticalFlowParameter(), forward_backward_threshold, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Creates instance of SparseRLOFOpticalFlow - /// - /// ## Parameters - /// * rlofParam: see setRLOFOpticalFlowParameter - /// * forwardBackwardThreshold: see setForwardBackward - /// - /// ## Note - /// This alternative version of [SparseRLOFOpticalFlow::create] function uses the following default values for its arguments: - /// * rlof_param: Ptr() - /// * forward_backward_threshold: 1.f - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_optflow_SparseRLOFOpticalFlow_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { SparseRLOFOpticalFlow, core::Algorithm, cv_optflow_SparseRLOFOpticalFlow_to_Algorithm } - - boxed_cast_base! { SparseRLOFOpticalFlow, crate::video::SparseOpticalFlow, cv_optflow_SparseRLOFOpticalFlow_to_SparseOpticalFlow } - - impl std::fmt::Debug for SparseRLOFOpticalFlow { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SparseRLOFOpticalFlow") - .finish() - } - } } diff --git a/docs/ovis.rs b/docs/ovis.rs index 93305dac0..0f5dfa4f5 100644 --- a/docs/ovis.rs +++ b/docs/ovis.rs @@ -518,6 +518,22 @@ pub mod ovis { Ok(ret) } + /// A 3D viewport and the associated scene + pub struct WindowScene { + ptr: *mut c_void, + } + + opencv_type_boxed! { WindowScene } + + impl Drop for WindowScene { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_ovis_WindowScene_delete(self.as_raw_mut_WindowScene()) }; + } + } + + unsafe impl Send for WindowScene {} + /// Constant methods for [crate::ovis::WindowScene] pub trait WindowSceneTraitConst { fn as_raw_WindowScene(&self) -> *const c_void; @@ -1350,22 +1366,14 @@ pub mod ovis { } - /// A 3D viewport and the associated scene - pub struct WindowScene { - ptr: *mut c_void, - } - - opencv_type_boxed! { WindowScene } - - impl Drop for WindowScene { + impl std::fmt::Debug for WindowScene { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ovis_WindowScene_delete(self.as_raw_mut_WindowScene()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("WindowScene") + .finish() } } - unsafe impl Send for WindowScene {} - impl crate::ovis::WindowSceneTraitConst for WindowScene { #[inline] fn as_raw_WindowScene(&self) -> *const c_void { self.as_raw() } } @@ -1376,14 +1384,4 @@ pub mod ovis { boxed_ref! { WindowScene, crate::ovis::WindowSceneTraitConst, as_raw_WindowScene, crate::ovis::WindowSceneTrait, as_raw_mut_WindowScene } - impl WindowScene { - } - - impl std::fmt::Debug for WindowScene { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("WindowScene") - .finish() - } - } } diff --git a/docs/phase_unwrapping.rs b/docs/phase_unwrapping.rs index 40ef6526c..a5682c0fb 100644 --- a/docs/phase_unwrapping.rs +++ b/docs/phase_unwrapping.rs @@ -20,32 +20,6 @@ pub mod phase_unwrapping { pub use super::{HistogramPhaseUnwrappingTrait, HistogramPhaseUnwrappingTraitConst, PhaseUnwrappingTrait, PhaseUnwrappingTraitConst}; } - /// Constant methods for [crate::phase_unwrapping::HistogramPhaseUnwrapping] - pub trait HistogramPhaseUnwrappingTraitConst: crate::phase_unwrapping::PhaseUnwrappingTraitConst { - fn as_raw_HistogramPhaseUnwrapping(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::phase_unwrapping::HistogramPhaseUnwrapping] - pub trait HistogramPhaseUnwrappingTrait: crate::phase_unwrapping::HistogramPhaseUnwrappingTraitConst + crate::phase_unwrapping::PhaseUnwrappingTrait { - fn as_raw_mut_HistogramPhaseUnwrapping(&mut self) -> *mut c_void; - - /// Get the reliability map computed from the wrapped phase map. - /// - /// ## Parameters - /// * reliabilityMap: Image where the reliability map is stored. - #[inline] - fn get_inverse_reliability_map(&mut self, reliability_map: &mut impl ToOutputArray) -> Result<()> { - output_array_arg!(reliability_map); - return_send!(via ocvrs_return); - unsafe { sys::cv_phase_unwrapping_HistogramPhaseUnwrapping_getInverseReliabilityMap_const__OutputArrayR(self.as_raw_mut_HistogramPhaseUnwrapping(), reliability_map.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - /// Class implementing two-dimensional phase unwrapping based on [histogramUnwrapping](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_histogramUnwrapping) /// This algorithm belongs to the quality-guided phase unwrapping methods. /// First, it computes a reliability map from second differences between a pixel and its eight neighbours. @@ -71,36 +45,6 @@ pub mod phase_unwrapping { unsafe impl Send for HistogramPhaseUnwrapping {} - impl core::AlgorithmTraitConst for HistogramPhaseUnwrapping { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for HistogramPhaseUnwrapping { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { HistogramPhaseUnwrapping, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::phase_unwrapping::PhaseUnwrappingTraitConst for HistogramPhaseUnwrapping { - #[inline] fn as_raw_PhaseUnwrapping(&self) -> *const c_void { self.as_raw() } - } - - impl crate::phase_unwrapping::PhaseUnwrappingTrait for HistogramPhaseUnwrapping { - #[inline] fn as_raw_mut_PhaseUnwrapping(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { HistogramPhaseUnwrapping, crate::phase_unwrapping::PhaseUnwrappingTraitConst, as_raw_PhaseUnwrapping, crate::phase_unwrapping::PhaseUnwrappingTrait, as_raw_mut_PhaseUnwrapping } - - impl crate::phase_unwrapping::HistogramPhaseUnwrappingTraitConst for HistogramPhaseUnwrapping { - #[inline] fn as_raw_HistogramPhaseUnwrapping(&self) -> *const c_void { self.as_raw() } - } - - impl crate::phase_unwrapping::HistogramPhaseUnwrappingTrait for HistogramPhaseUnwrapping { - #[inline] fn as_raw_mut_HistogramPhaseUnwrapping(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { HistogramPhaseUnwrapping, crate::phase_unwrapping::HistogramPhaseUnwrappingTraitConst, as_raw_HistogramPhaseUnwrapping, crate::phase_unwrapping::HistogramPhaseUnwrappingTrait, as_raw_mut_HistogramPhaseUnwrapping } - impl HistogramPhaseUnwrapping { /// Constructor /// @@ -139,9 +83,31 @@ pub mod phase_unwrapping { } - boxed_cast_base! { HistogramPhaseUnwrapping, core::Algorithm, cv_phase_unwrapping_HistogramPhaseUnwrapping_to_Algorithm } + /// Constant methods for [crate::phase_unwrapping::HistogramPhaseUnwrapping] + pub trait HistogramPhaseUnwrappingTraitConst: crate::phase_unwrapping::PhaseUnwrappingTraitConst { + fn as_raw_HistogramPhaseUnwrapping(&self) -> *const c_void; - boxed_cast_base! { HistogramPhaseUnwrapping, crate::phase_unwrapping::PhaseUnwrapping, cv_phase_unwrapping_HistogramPhaseUnwrapping_to_PhaseUnwrapping } + } + + /// Mutable methods for [crate::phase_unwrapping::HistogramPhaseUnwrapping] + pub trait HistogramPhaseUnwrappingTrait: crate::phase_unwrapping::HistogramPhaseUnwrappingTraitConst + crate::phase_unwrapping::PhaseUnwrappingTrait { + fn as_raw_mut_HistogramPhaseUnwrapping(&mut self) -> *mut c_void; + + /// Get the reliability map computed from the wrapped phase map. + /// + /// ## Parameters + /// * reliabilityMap: Image where the reliability map is stored. + #[inline] + fn get_inverse_reliability_map(&mut self, reliability_map: &mut impl ToOutputArray) -> Result<()> { + output_array_arg!(reliability_map); + return_send!(via ocvrs_return); + unsafe { sys::cv_phase_unwrapping_HistogramPhaseUnwrapping_getInverseReliabilityMap_const__OutputArrayR(self.as_raw_mut_HistogramPhaseUnwrapping(), reliability_map.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } impl std::fmt::Debug for HistogramPhaseUnwrapping { #[inline] @@ -151,6 +117,40 @@ pub mod phase_unwrapping { } } + boxed_cast_base! { HistogramPhaseUnwrapping, core::Algorithm, cv_phase_unwrapping_HistogramPhaseUnwrapping_to_Algorithm } + + boxed_cast_base! { HistogramPhaseUnwrapping, crate::phase_unwrapping::PhaseUnwrapping, cv_phase_unwrapping_HistogramPhaseUnwrapping_to_PhaseUnwrapping } + + impl core::AlgorithmTraitConst for HistogramPhaseUnwrapping { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } + } + + impl core::AlgorithmTrait for HistogramPhaseUnwrapping { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { HistogramPhaseUnwrapping, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + + impl crate::phase_unwrapping::PhaseUnwrappingTraitConst for HistogramPhaseUnwrapping { + #[inline] fn as_raw_PhaseUnwrapping(&self) -> *const c_void { self.as_raw() } + } + + impl crate::phase_unwrapping::PhaseUnwrappingTrait for HistogramPhaseUnwrapping { + #[inline] fn as_raw_mut_PhaseUnwrapping(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { HistogramPhaseUnwrapping, crate::phase_unwrapping::PhaseUnwrappingTraitConst, as_raw_PhaseUnwrapping, crate::phase_unwrapping::PhaseUnwrappingTrait, as_raw_mut_PhaseUnwrapping } + + impl crate::phase_unwrapping::HistogramPhaseUnwrappingTraitConst for HistogramPhaseUnwrapping { + #[inline] fn as_raw_HistogramPhaseUnwrapping(&self) -> *const c_void { self.as_raw() } + } + + impl crate::phase_unwrapping::HistogramPhaseUnwrappingTrait for HistogramPhaseUnwrapping { + #[inline] fn as_raw_mut_HistogramPhaseUnwrapping(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { HistogramPhaseUnwrapping, crate::phase_unwrapping::HistogramPhaseUnwrappingTraitConst, as_raw_HistogramPhaseUnwrapping, crate::phase_unwrapping::HistogramPhaseUnwrappingTrait, as_raw_mut_HistogramPhaseUnwrapping } + /// Parameters of phaseUnwrapping constructor. /// /// ## Parameters @@ -183,6 +183,22 @@ pub mod phase_unwrapping { } + /// Abstract base class for phase unwrapping. + pub struct PhaseUnwrapping { + ptr: *mut c_void, + } + + opencv_type_boxed! { PhaseUnwrapping } + + impl Drop for PhaseUnwrapping { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_phase_unwrapping_PhaseUnwrapping_delete(self.as_raw_mut_PhaseUnwrapping()) }; + } + } + + unsafe impl Send for PhaseUnwrapping {} + /// Constant methods for [crate::phase_unwrapping::PhaseUnwrapping] pub trait PhaseUnwrappingTraitConst: core::AlgorithmTraitConst { fn as_raw_PhaseUnwrapping(&self) -> *const c_void; @@ -237,21 +253,17 @@ pub mod phase_unwrapping { } - /// Abstract base class for phase unwrapping. - pub struct PhaseUnwrapping { - ptr: *mut c_void, - } - - opencv_type_boxed! { PhaseUnwrapping } - - impl Drop for PhaseUnwrapping { + impl std::fmt::Debug for PhaseUnwrapping { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_phase_unwrapping_PhaseUnwrapping_delete(self.as_raw_mut_PhaseUnwrapping()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PhaseUnwrapping") + .finish() } } - unsafe impl Send for PhaseUnwrapping {} + boxed_cast_base! { PhaseUnwrapping, core::Algorithm, cv_phase_unwrapping_PhaseUnwrapping_to_Algorithm } + + boxed_cast_descendant! { PhaseUnwrapping, crate::phase_unwrapping::HistogramPhaseUnwrapping, cv_phase_unwrapping_PhaseUnwrapping_to_HistogramPhaseUnwrapping } impl core::AlgorithmTraitConst for PhaseUnwrapping { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -273,18 +285,4 @@ pub mod phase_unwrapping { boxed_ref! { PhaseUnwrapping, crate::phase_unwrapping::PhaseUnwrappingTraitConst, as_raw_PhaseUnwrapping, crate::phase_unwrapping::PhaseUnwrappingTrait, as_raw_mut_PhaseUnwrapping } - impl PhaseUnwrapping { - } - - boxed_cast_descendant! { PhaseUnwrapping, crate::phase_unwrapping::HistogramPhaseUnwrapping, cv_phase_unwrapping_PhaseUnwrapping_to_HistogramPhaseUnwrapping } - - boxed_cast_base! { PhaseUnwrapping, core::Algorithm, cv_phase_unwrapping_PhaseUnwrapping_to_Algorithm } - - impl std::fmt::Debug for PhaseUnwrapping { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PhaseUnwrapping") - .finish() - } - } } diff --git a/docs/photo.rs b/docs/photo.rs index a2d063266..19de54dc4 100644 --- a/docs/photo.rs +++ b/docs/photo.rs @@ -1834,6 +1834,22 @@ pub mod photo { Ok(ret) } + /// The base class for algorithms that align images of the same scene with different exposures + pub struct AlignExposures { + ptr: *mut c_void, + } + + opencv_type_boxed! { AlignExposures } + + impl Drop for AlignExposures { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_AlignExposures_delete(self.as_raw_mut_AlignExposures()) }; + } + } + + unsafe impl Send for AlignExposures {} + /// Constant methods for [crate::photo::AlignExposures] pub trait AlignExposuresTraitConst: core::AlgorithmTraitConst { fn as_raw_AlignExposures(&self) -> *const c_void; @@ -1866,21 +1882,17 @@ pub mod photo { } - /// The base class for algorithms that align images of the same scene with different exposures - pub struct AlignExposures { - ptr: *mut c_void, - } - - opencv_type_boxed! { AlignExposures } - - impl Drop for AlignExposures { + impl std::fmt::Debug for AlignExposures { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_AlignExposures_delete(self.as_raw_mut_AlignExposures()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AlignExposures") + .finish() } } - unsafe impl Send for AlignExposures {} + boxed_cast_base! { AlignExposures, core::Algorithm, cv_AlignExposures_to_Algorithm } + + boxed_cast_descendant! { AlignExposures, crate::photo::AlignMTB, cv_AlignExposures_to_AlignMTB } impl core::AlgorithmTraitConst for AlignExposures { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1902,21 +1914,29 @@ pub mod photo { boxed_ref! { AlignExposures, crate::photo::AlignExposuresTraitConst, as_raw_AlignExposures, crate::photo::AlignExposuresTrait, as_raw_mut_AlignExposures } - impl AlignExposures { + /// This algorithm converts images to median threshold bitmaps (1 for pixels brighter than median + /// luminance and 0 otherwise) and than aligns the resulting bitmaps using bit operations. + /// + /// It is invariant to exposure, so exposure values and camera response are not necessary. + /// + /// In this implementation new image regions are filled with zeros. + /// + /// For more information see [GW03](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_GW03) . + pub struct AlignMTB { + ptr: *mut c_void, } - boxed_cast_descendant! { AlignExposures, crate::photo::AlignMTB, cv_AlignExposures_to_AlignMTB } - - boxed_cast_base! { AlignExposures, core::Algorithm, cv_AlignExposures_to_Algorithm } + opencv_type_boxed! { AlignMTB } - impl std::fmt::Debug for AlignExposures { + impl Drop for AlignMTB { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AlignExposures") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_AlignMTB_delete(self.as_raw_mut_AlignMTB()) }; } } + unsafe impl Send for AlignMTB {} + /// Constant methods for [crate::photo::AlignMTB] pub trait AlignMTBTraitConst: crate::photo::AlignExposuresTraitConst { fn as_raw_AlignMTB(&self) -> *const c_void; @@ -2062,28 +2082,17 @@ pub mod photo { } - /// This algorithm converts images to median threshold bitmaps (1 for pixels brighter than median - /// luminance and 0 otherwise) and than aligns the resulting bitmaps using bit operations. - /// - /// It is invariant to exposure, so exposure values and camera response are not necessary. - /// - /// In this implementation new image regions are filled with zeros. - /// - /// For more information see [GW03](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_GW03) . - pub struct AlignMTB { - ptr: *mut c_void, - } - - opencv_type_boxed! { AlignMTB } - - impl Drop for AlignMTB { + impl std::fmt::Debug for AlignMTB { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_AlignMTB_delete(self.as_raw_mut_AlignMTB()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AlignMTB") + .finish() } } - unsafe impl Send for AlignMTB {} + boxed_cast_base! { AlignMTB, core::Algorithm, cv_AlignMTB_to_Algorithm } + + boxed_cast_base! { AlignMTB, crate::photo::AlignExposures, cv_AlignMTB_to_AlignExposures } impl core::AlgorithmTraitConst for AlignMTB { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2115,21 +2124,22 @@ pub mod photo { boxed_ref! { AlignMTB, crate::photo::AlignMTBTraitConst, as_raw_AlignMTB, crate::photo::AlignMTBTrait, as_raw_mut_AlignMTB } - impl AlignMTB { + /// The base class for camera response calibration algorithms. + pub struct CalibrateCRF { + ptr: *mut c_void, } - boxed_cast_base! { AlignMTB, core::Algorithm, cv_AlignMTB_to_Algorithm } - - boxed_cast_base! { AlignMTB, crate::photo::AlignExposures, cv_AlignMTB_to_AlignExposures } + opencv_type_boxed! { CalibrateCRF } - impl std::fmt::Debug for AlignMTB { + impl Drop for CalibrateCRF { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AlignMTB") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_CalibrateCRF_delete(self.as_raw_mut_CalibrateCRF()) }; } } + unsafe impl Send for CalibrateCRF {} + /// Constant methods for [crate::photo::CalibrateCRF] pub trait CalibrateCRFTraitConst: core::AlgorithmTraitConst { fn as_raw_CalibrateCRF(&self) -> *const c_void; @@ -2160,21 +2170,19 @@ pub mod photo { } - /// The base class for camera response calibration algorithms. - pub struct CalibrateCRF { - ptr: *mut c_void, - } - - opencv_type_boxed! { CalibrateCRF } - - impl Drop for CalibrateCRF { + impl std::fmt::Debug for CalibrateCRF { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_CalibrateCRF_delete(self.as_raw_mut_CalibrateCRF()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CalibrateCRF") + .finish() } } - unsafe impl Send for CalibrateCRF {} + boxed_cast_base! { CalibrateCRF, core::Algorithm, cv_CalibrateCRF_to_Algorithm } + + boxed_cast_descendant! { CalibrateCRF, crate::photo::CalibrateDebevec, cv_CalibrateCRF_to_CalibrateDebevec } + + boxed_cast_descendant! { CalibrateCRF, crate::photo::CalibrateRobertson, cv_CalibrateCRF_to_CalibrateRobertson } impl core::AlgorithmTraitConst for CalibrateCRF { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2196,23 +2204,26 @@ pub mod photo { boxed_ref! { CalibrateCRF, crate::photo::CalibrateCRFTraitConst, as_raw_CalibrateCRF, crate::photo::CalibrateCRFTrait, as_raw_mut_CalibrateCRF } - impl CalibrateCRF { + /// Inverse camera response function is extracted for each brightness value by minimizing an objective + /// function as linear system. Objective function is constructed using pixel values on the same position + /// in all images, extra term is added to make the result smoother. + /// + /// For more information see [DM97](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_DM97) . + pub struct CalibrateDebevec { + ptr: *mut c_void, } - boxed_cast_descendant! { CalibrateCRF, crate::photo::CalibrateDebevec, cv_CalibrateCRF_to_CalibrateDebevec } - - boxed_cast_descendant! { CalibrateCRF, crate::photo::CalibrateRobertson, cv_CalibrateCRF_to_CalibrateRobertson } - - boxed_cast_base! { CalibrateCRF, core::Algorithm, cv_CalibrateCRF_to_Algorithm } + opencv_type_boxed! { CalibrateDebevec } - impl std::fmt::Debug for CalibrateCRF { + impl Drop for CalibrateDebevec { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CalibrateCRF") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_CalibrateDebevec_delete(self.as_raw_mut_CalibrateDebevec()) }; } } + unsafe impl Send for CalibrateDebevec {} + /// Constant methods for [crate::photo::CalibrateDebevec] pub trait CalibrateDebevecTraitConst: crate::photo::CalibrateCRFTraitConst { fn as_raw_CalibrateDebevec(&self) -> *const c_void; @@ -2279,25 +2290,17 @@ pub mod photo { } - /// Inverse camera response function is extracted for each brightness value by minimizing an objective - /// function as linear system. Objective function is constructed using pixel values on the same position - /// in all images, extra term is added to make the result smoother. - /// - /// For more information see [DM97](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_DM97) . - pub struct CalibrateDebevec { - ptr: *mut c_void, - } - - opencv_type_boxed! { CalibrateDebevec } - - impl Drop for CalibrateDebevec { + impl std::fmt::Debug for CalibrateDebevec { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_CalibrateDebevec_delete(self.as_raw_mut_CalibrateDebevec()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CalibrateDebevec") + .finish() } } - unsafe impl Send for CalibrateDebevec {} + boxed_cast_base! { CalibrateDebevec, core::Algorithm, cv_CalibrateDebevec_to_Algorithm } + + boxed_cast_base! { CalibrateDebevec, crate::photo::CalibrateCRF, cv_CalibrateDebevec_to_CalibrateCRF } impl core::AlgorithmTraitConst for CalibrateDebevec { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2329,21 +2332,25 @@ pub mod photo { boxed_ref! { CalibrateDebevec, crate::photo::CalibrateDebevecTraitConst, as_raw_CalibrateDebevec, crate::photo::CalibrateDebevecTrait, as_raw_mut_CalibrateDebevec } - impl CalibrateDebevec { + /// Inverse camera response function is extracted for each brightness value by minimizing an objective + /// function as linear system. This algorithm uses all image pixels. + /// + /// For more information see [RB99](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_RB99) . + pub struct CalibrateRobertson { + ptr: *mut c_void, } - boxed_cast_base! { CalibrateDebevec, core::Algorithm, cv_CalibrateDebevec_to_Algorithm } - - boxed_cast_base! { CalibrateDebevec, crate::photo::CalibrateCRF, cv_CalibrateDebevec_to_CalibrateCRF } + opencv_type_boxed! { CalibrateRobertson } - impl std::fmt::Debug for CalibrateDebevec { + impl Drop for CalibrateRobertson { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CalibrateDebevec") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_CalibrateRobertson_delete(self.as_raw_mut_CalibrateRobertson()) }; } } + unsafe impl Send for CalibrateRobertson {} + /// Constant methods for [crate::photo::CalibrateRobertson] pub trait CalibrateRobertsonTraitConst: crate::photo::CalibrateCRFTraitConst { fn as_raw_CalibrateRobertson(&self) -> *const c_void; @@ -2402,24 +2409,17 @@ pub mod photo { } - /// Inverse camera response function is extracted for each brightness value by minimizing an objective - /// function as linear system. This algorithm uses all image pixels. - /// - /// For more information see [RB99](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_RB99) . - pub struct CalibrateRobertson { - ptr: *mut c_void, - } - - opencv_type_boxed! { CalibrateRobertson } - - impl Drop for CalibrateRobertson { + impl std::fmt::Debug for CalibrateRobertson { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_CalibrateRobertson_delete(self.as_raw_mut_CalibrateRobertson()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CalibrateRobertson") + .finish() } } - unsafe impl Send for CalibrateRobertson {} + boxed_cast_base! { CalibrateRobertson, core::Algorithm, cv_CalibrateRobertson_to_Algorithm } + + boxed_cast_base! { CalibrateRobertson, crate::photo::CalibrateCRF, cv_CalibrateRobertson_to_CalibrateCRF } impl core::AlgorithmTraitConst for CalibrateRobertson { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2451,21 +2451,25 @@ pub mod photo { boxed_ref! { CalibrateRobertson, crate::photo::CalibrateRobertsonTraitConst, as_raw_CalibrateRobertson, crate::photo::CalibrateRobertsonTrait, as_raw_mut_CalibrateRobertson } - impl CalibrateRobertson { + /// The resulting HDR image is calculated as weighted average of the exposures considering exposure + /// values and camera response. + /// + /// For more information see [DM97](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_DM97) . + pub struct MergeDebevec { + ptr: *mut c_void, } - boxed_cast_base! { CalibrateRobertson, core::Algorithm, cv_CalibrateRobertson_to_Algorithm } - - boxed_cast_base! { CalibrateRobertson, crate::photo::CalibrateCRF, cv_CalibrateRobertson_to_CalibrateCRF } + opencv_type_boxed! { MergeDebevec } - impl std::fmt::Debug for CalibrateRobertson { + impl Drop for MergeDebevec { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CalibrateRobertson") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_MergeDebevec_delete(self.as_raw_mut_MergeDebevec()) }; } } + unsafe impl Send for MergeDebevec {} + /// Constant methods for [crate::photo::MergeDebevec] pub trait MergeDebevecTraitConst: crate::photo::MergeExposuresTraitConst { fn as_raw_MergeDebevec(&self) -> *const c_void; @@ -2503,24 +2507,17 @@ pub mod photo { } - /// The resulting HDR image is calculated as weighted average of the exposures considering exposure - /// values and camera response. - /// - /// For more information see [DM97](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_DM97) . - pub struct MergeDebevec { - ptr: *mut c_void, - } - - opencv_type_boxed! { MergeDebevec } - - impl Drop for MergeDebevec { + impl std::fmt::Debug for MergeDebevec { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_MergeDebevec_delete(self.as_raw_mut_MergeDebevec()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MergeDebevec") + .finish() } } - unsafe impl Send for MergeDebevec {} + boxed_cast_base! { MergeDebevec, core::Algorithm, cv_MergeDebevec_to_Algorithm } + + boxed_cast_base! { MergeDebevec, crate::photo::MergeExposures, cv_MergeDebevec_to_MergeExposures } impl core::AlgorithmTraitConst for MergeDebevec { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2552,21 +2549,22 @@ pub mod photo { boxed_ref! { MergeDebevec, crate::photo::MergeDebevecTraitConst, as_raw_MergeDebevec, crate::photo::MergeDebevecTrait, as_raw_mut_MergeDebevec } - impl MergeDebevec { + /// The base class algorithms that can merge exposure sequence to a single image. + pub struct MergeExposures { + ptr: *mut c_void, } - boxed_cast_base! { MergeDebevec, core::Algorithm, cv_MergeDebevec_to_Algorithm } - - boxed_cast_base! { MergeDebevec, crate::photo::MergeExposures, cv_MergeDebevec_to_MergeExposures } + opencv_type_boxed! { MergeExposures } - impl std::fmt::Debug for MergeDebevec { + impl Drop for MergeExposures { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MergeDebevec") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_MergeExposures_delete(self.as_raw_mut_MergeExposures()) }; } } + unsafe impl Send for MergeExposures {} + /// Constant methods for [crate::photo::MergeExposures] pub trait MergeExposuresTraitConst: core::AlgorithmTraitConst { fn as_raw_MergeExposures(&self) -> *const c_void; @@ -2600,21 +2598,21 @@ pub mod photo { } - /// The base class algorithms that can merge exposure sequence to a single image. - pub struct MergeExposures { - ptr: *mut c_void, - } - - opencv_type_boxed! { MergeExposures } - - impl Drop for MergeExposures { + impl std::fmt::Debug for MergeExposures { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_MergeExposures_delete(self.as_raw_mut_MergeExposures()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MergeExposures") + .finish() } } - unsafe impl Send for MergeExposures {} + boxed_cast_base! { MergeExposures, core::Algorithm, cv_MergeExposures_to_Algorithm } + + boxed_cast_descendant! { MergeExposures, crate::photo::MergeDebevec, cv_MergeExposures_to_MergeDebevec } + + boxed_cast_descendant! { MergeExposures, crate::photo::MergeMertens, cv_MergeExposures_to_MergeMertens } + + boxed_cast_descendant! { MergeExposures, crate::photo::MergeRobertson, cv_MergeExposures_to_MergeRobertson } impl core::AlgorithmTraitConst for MergeExposures { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2636,25 +2634,31 @@ pub mod photo { boxed_ref! { MergeExposures, crate::photo::MergeExposuresTraitConst, as_raw_MergeExposures, crate::photo::MergeExposuresTrait, as_raw_mut_MergeExposures } - impl MergeExposures { + /// Pixels are weighted using contrast, saturation and well-exposedness measures, than images are + /// combined using laplacian pyramids. + /// + /// The resulting image weight is constructed as weighted average of contrast, saturation and + /// well-exposedness measures. + /// + /// The resulting image doesn't require tonemapping and can be converted to 8-bit image by multiplying + /// by 255, but it's recommended to apply gamma correction and/or linear tonemapping. + /// + /// For more information see [MK07](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_MK07) . + pub struct MergeMertens { + ptr: *mut c_void, } - boxed_cast_descendant! { MergeExposures, crate::photo::MergeDebevec, cv_MergeExposures_to_MergeDebevec } - - boxed_cast_descendant! { MergeExposures, crate::photo::MergeMertens, cv_MergeExposures_to_MergeMertens } - - boxed_cast_descendant! { MergeExposures, crate::photo::MergeRobertson, cv_MergeExposures_to_MergeRobertson } - - boxed_cast_base! { MergeExposures, core::Algorithm, cv_MergeExposures_to_Algorithm } + opencv_type_boxed! { MergeMertens } - impl std::fmt::Debug for MergeExposures { + impl Drop for MergeMertens { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MergeExposures") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_MergeMertens_delete(self.as_raw_mut_MergeMertens()) }; } } + unsafe impl Send for MergeMertens {} + /// Constant methods for [crate::photo::MergeMertens] pub trait MergeMertensTraitConst: crate::photo::MergeExposuresTraitConst { fn as_raw_MergeMertens(&self) -> *const c_void; @@ -2750,30 +2754,17 @@ pub mod photo { } - /// Pixels are weighted using contrast, saturation and well-exposedness measures, than images are - /// combined using laplacian pyramids. - /// - /// The resulting image weight is constructed as weighted average of contrast, saturation and - /// well-exposedness measures. - /// - /// The resulting image doesn't require tonemapping and can be converted to 8-bit image by multiplying - /// by 255, but it's recommended to apply gamma correction and/or linear tonemapping. - /// - /// For more information see [MK07](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_MK07) . - pub struct MergeMertens { - ptr: *mut c_void, - } - - opencv_type_boxed! { MergeMertens } - - impl Drop for MergeMertens { + impl std::fmt::Debug for MergeMertens { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_MergeMertens_delete(self.as_raw_mut_MergeMertens()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MergeMertens") + .finish() } } - unsafe impl Send for MergeMertens {} + boxed_cast_base! { MergeMertens, core::Algorithm, cv_MergeMertens_to_Algorithm } + + boxed_cast_base! { MergeMertens, crate::photo::MergeExposures, cv_MergeMertens_to_MergeExposures } impl core::AlgorithmTraitConst for MergeMertens { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2805,21 +2796,25 @@ pub mod photo { boxed_ref! { MergeMertens, crate::photo::MergeMertensTraitConst, as_raw_MergeMertens, crate::photo::MergeMertensTrait, as_raw_mut_MergeMertens } - impl MergeMertens { + /// The resulting HDR image is calculated as weighted average of the exposures considering exposure + /// values and camera response. + /// + /// For more information see [RB99](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_RB99) . + pub struct MergeRobertson { + ptr: *mut c_void, } - boxed_cast_base! { MergeMertens, core::Algorithm, cv_MergeMertens_to_Algorithm } - - boxed_cast_base! { MergeMertens, crate::photo::MergeExposures, cv_MergeMertens_to_MergeExposures } + opencv_type_boxed! { MergeRobertson } - impl std::fmt::Debug for MergeMertens { + impl Drop for MergeRobertson { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MergeMertens") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_MergeRobertson_delete(self.as_raw_mut_MergeRobertson()) }; } } + unsafe impl Send for MergeRobertson {} + /// Constant methods for [crate::photo::MergeRobertson] pub trait MergeRobertsonTraitConst: crate::photo::MergeExposuresTraitConst { fn as_raw_MergeRobertson(&self) -> *const c_void; @@ -2857,24 +2852,17 @@ pub mod photo { } - /// The resulting HDR image is calculated as weighted average of the exposures considering exposure - /// values and camera response. - /// - /// For more information see [RB99](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_RB99) . - pub struct MergeRobertson { - ptr: *mut c_void, - } - - opencv_type_boxed! { MergeRobertson } - - impl Drop for MergeRobertson { + impl std::fmt::Debug for MergeRobertson { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_MergeRobertson_delete(self.as_raw_mut_MergeRobertson()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MergeRobertson") + .finish() } } - unsafe impl Send for MergeRobertson {} + boxed_cast_base! { MergeRobertson, core::Algorithm, cv_MergeRobertson_to_Algorithm } + + boxed_cast_base! { MergeRobertson, crate::photo::MergeExposures, cv_MergeRobertson_to_MergeExposures } impl core::AlgorithmTraitConst for MergeRobertson { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2906,21 +2894,22 @@ pub mod photo { boxed_ref! { MergeRobertson, crate::photo::MergeRobertsonTraitConst, as_raw_MergeRobertson, crate::photo::MergeRobertsonTrait, as_raw_mut_MergeRobertson } - impl MergeRobertson { + /// Base class for tonemapping algorithms - tools that are used to map HDR image to 8-bit range. + pub struct Tonemap { + ptr: *mut c_void, } - boxed_cast_base! { MergeRobertson, core::Algorithm, cv_MergeRobertson_to_Algorithm } - - boxed_cast_base! { MergeRobertson, crate::photo::MergeExposures, cv_MergeRobertson_to_MergeExposures } + opencv_type_boxed! { Tonemap } - impl std::fmt::Debug for MergeRobertson { + impl Drop for Tonemap { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MergeRobertson") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_Tonemap_delete(self.as_raw_mut_Tonemap()) }; } } + unsafe impl Send for Tonemap {} + /// Constant methods for [crate::photo::Tonemap] pub trait TonemapTraitConst: core::AlgorithmTraitConst { fn as_raw_Tonemap(&self) -> *const c_void; @@ -2967,21 +2956,21 @@ pub mod photo { } - /// Base class for tonemapping algorithms - tools that are used to map HDR image to 8-bit range. - pub struct Tonemap { - ptr: *mut c_void, - } - - opencv_type_boxed! { Tonemap } - - impl Drop for Tonemap { + impl std::fmt::Debug for Tonemap { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_Tonemap_delete(self.as_raw_mut_Tonemap()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Tonemap") + .finish() } } - unsafe impl Send for Tonemap {} + boxed_cast_base! { Tonemap, core::Algorithm, cv_Tonemap_to_Algorithm } + + boxed_cast_descendant! { Tonemap, crate::photo::TonemapDrago, cv_Tonemap_to_TonemapDrago } + + boxed_cast_descendant! { Tonemap, crate::photo::TonemapMantiuk, cv_Tonemap_to_TonemapMantiuk } + + boxed_cast_descendant! { Tonemap, crate::photo::TonemapReinhard, cv_Tonemap_to_TonemapReinhard } impl core::AlgorithmTraitConst for Tonemap { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3003,25 +2992,30 @@ pub mod photo { boxed_ref! { Tonemap, crate::photo::TonemapTraitConst, as_raw_Tonemap, crate::photo::TonemapTrait, as_raw_mut_Tonemap } - impl Tonemap { + /// Adaptive logarithmic mapping is a fast global tonemapping algorithm that scales the image in + /// logarithmic domain. + /// + /// Since it's a global operator the same function is applied to all the pixels, it is controlled by the + /// bias parameter. + /// + /// Optional saturation enhancement is possible as described in [FL02](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_FL02) . + /// + /// For more information see [DM03](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_DM03) . + pub struct TonemapDrago { + ptr: *mut c_void, } - boxed_cast_descendant! { Tonemap, crate::photo::TonemapDrago, cv_Tonemap_to_TonemapDrago } - - boxed_cast_descendant! { Tonemap, crate::photo::TonemapMantiuk, cv_Tonemap_to_TonemapMantiuk } - - boxed_cast_descendant! { Tonemap, crate::photo::TonemapReinhard, cv_Tonemap_to_TonemapReinhard } - - boxed_cast_base! { Tonemap, core::Algorithm, cv_Tonemap_to_Algorithm } + opencv_type_boxed! { TonemapDrago } - impl std::fmt::Debug for Tonemap { + impl Drop for TonemapDrago { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Tonemap") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_TonemapDrago_delete(self.as_raw_mut_TonemapDrago()) }; } } + unsafe impl Send for TonemapDrago {} + /// Constant methods for [crate::photo::TonemapDrago] pub trait TonemapDragoTraitConst: crate::photo::TonemapTraitConst { fn as_raw_TonemapDrago(&self) -> *const c_void; @@ -3070,29 +3064,17 @@ pub mod photo { } - /// Adaptive logarithmic mapping is a fast global tonemapping algorithm that scales the image in - /// logarithmic domain. - /// - /// Since it's a global operator the same function is applied to all the pixels, it is controlled by the - /// bias parameter. - /// - /// Optional saturation enhancement is possible as described in [FL02](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_FL02) . - /// - /// For more information see [DM03](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_DM03) . - pub struct TonemapDrago { - ptr: *mut c_void, - } - - opencv_type_boxed! { TonemapDrago } - - impl Drop for TonemapDrago { + impl std::fmt::Debug for TonemapDrago { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_TonemapDrago_delete(self.as_raw_mut_TonemapDrago()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TonemapDrago") + .finish() } } - unsafe impl Send for TonemapDrago {} + boxed_cast_base! { TonemapDrago, core::Algorithm, cv_TonemapDrago_to_Algorithm } + + boxed_cast_base! { TonemapDrago, crate::photo::Tonemap, cv_TonemapDrago_to_Tonemap } impl core::AlgorithmTraitConst for TonemapDrago { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3124,21 +3106,26 @@ pub mod photo { boxed_ref! { TonemapDrago, crate::photo::TonemapDragoTraitConst, as_raw_TonemapDrago, crate::photo::TonemapDragoTrait, as_raw_mut_TonemapDrago } - impl TonemapDrago { + /// This algorithm transforms image to contrast using gradients on all levels of gaussian pyramid, + /// transforms contrast values to HVS response and scales the response. After this the image is + /// reconstructed from new contrast values. + /// + /// For more information see [MM06](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_MM06) . + pub struct TonemapMantiuk { + ptr: *mut c_void, } - boxed_cast_base! { TonemapDrago, core::Algorithm, cv_TonemapDrago_to_Algorithm } - - boxed_cast_base! { TonemapDrago, crate::photo::Tonemap, cv_TonemapDrago_to_Tonemap } + opencv_type_boxed! { TonemapMantiuk } - impl std::fmt::Debug for TonemapDrago { + impl Drop for TonemapMantiuk { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TonemapDrago") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_TonemapMantiuk_delete(self.as_raw_mut_TonemapMantiuk()) }; } } + unsafe impl Send for TonemapMantiuk {} + /// Constant methods for [crate::photo::TonemapMantiuk] pub trait TonemapMantiukTraitConst: crate::photo::TonemapTraitConst { fn as_raw_TonemapMantiuk(&self) -> *const c_void; @@ -3187,25 +3174,17 @@ pub mod photo { } - /// This algorithm transforms image to contrast using gradients on all levels of gaussian pyramid, - /// transforms contrast values to HVS response and scales the response. After this the image is - /// reconstructed from new contrast values. - /// - /// For more information see [MM06](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_MM06) . - pub struct TonemapMantiuk { - ptr: *mut c_void, - } - - opencv_type_boxed! { TonemapMantiuk } - - impl Drop for TonemapMantiuk { + impl std::fmt::Debug for TonemapMantiuk { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_TonemapMantiuk_delete(self.as_raw_mut_TonemapMantiuk()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TonemapMantiuk") + .finish() } } - unsafe impl Send for TonemapMantiuk {} + boxed_cast_base! { TonemapMantiuk, core::Algorithm, cv_TonemapMantiuk_to_Algorithm } + + boxed_cast_base! { TonemapMantiuk, crate::photo::Tonemap, cv_TonemapMantiuk_to_Tonemap } impl core::AlgorithmTraitConst for TonemapMantiuk { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3237,21 +3216,27 @@ pub mod photo { boxed_ref! { TonemapMantiuk, crate::photo::TonemapMantiukTraitConst, as_raw_TonemapMantiuk, crate::photo::TonemapMantiukTrait, as_raw_mut_TonemapMantiuk } - impl TonemapMantiuk { + /// This is a global tonemapping operator that models human visual system. + /// + /// Mapping function is controlled by adaptation parameter, that is computed using light adaptation and + /// color adaptation. + /// + /// For more information see [RD05](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_RD05) . + pub struct TonemapReinhard { + ptr: *mut c_void, } - boxed_cast_base! { TonemapMantiuk, core::Algorithm, cv_TonemapMantiuk_to_Algorithm } - - boxed_cast_base! { TonemapMantiuk, crate::photo::Tonemap, cv_TonemapMantiuk_to_Tonemap } + opencv_type_boxed! { TonemapReinhard } - impl std::fmt::Debug for TonemapMantiuk { + impl Drop for TonemapReinhard { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TonemapMantiuk") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_TonemapReinhard_delete(self.as_raw_mut_TonemapReinhard()) }; } } + unsafe impl Send for TonemapReinhard {} + /// Constant methods for [crate::photo::TonemapReinhard] pub trait TonemapReinhardTraitConst: crate::photo::TonemapTraitConst { fn as_raw_TonemapReinhard(&self) -> *const c_void; @@ -3318,26 +3303,17 @@ pub mod photo { } - /// This is a global tonemapping operator that models human visual system. - /// - /// Mapping function is controlled by adaptation parameter, that is computed using light adaptation and - /// color adaptation. - /// - /// For more information see [RD05](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_RD05) . - pub struct TonemapReinhard { - ptr: *mut c_void, - } - - opencv_type_boxed! { TonemapReinhard } - - impl Drop for TonemapReinhard { + impl std::fmt::Debug for TonemapReinhard { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_TonemapReinhard_delete(self.as_raw_mut_TonemapReinhard()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TonemapReinhard") + .finish() } } - unsafe impl Send for TonemapReinhard {} + boxed_cast_base! { TonemapReinhard, core::Algorithm, cv_TonemapReinhard_to_Algorithm } + + boxed_cast_base! { TonemapReinhard, crate::photo::Tonemap, cv_TonemapReinhard_to_Tonemap } impl core::AlgorithmTraitConst for TonemapReinhard { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3369,18 +3345,4 @@ pub mod photo { boxed_ref! { TonemapReinhard, crate::photo::TonemapReinhardTraitConst, as_raw_TonemapReinhard, crate::photo::TonemapReinhardTrait, as_raw_mut_TonemapReinhard } - impl TonemapReinhard { - } - - boxed_cast_base! { TonemapReinhard, core::Algorithm, cv_TonemapReinhard_to_Algorithm } - - boxed_cast_base! { TonemapReinhard, crate::photo::Tonemap, cv_TonemapReinhard_to_Tonemap } - - impl std::fmt::Debug for TonemapReinhard { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TonemapReinhard") - .finish() - } - } } diff --git a/docs/plot.rs b/docs/plot.rs index f71d2f0a2..1a53135e1 100644 --- a/docs/plot.rs +++ b/docs/plot.rs @@ -6,6 +6,57 @@ pub mod plot { pub use super::{Plot2dTrait, Plot2dTraitConst}; } + pub struct Plot2d { + ptr: *mut c_void, + } + + opencv_type_boxed! { Plot2d } + + impl Drop for Plot2d { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_plot_Plot2d_delete(self.as_raw_mut_Plot2d()) }; + } + } + + unsafe impl Send for Plot2d {} + + impl Plot2d { + /// Creates Plot2d object + /// + /// ## Parameters + /// * data: ![inline formula](https://latex.codecogs.com/png.latex?1xN) or ![inline formula](https://latex.codecogs.com/png.latex?Nx1) matrix containing ![inline formula](https://latex.codecogs.com/png.latex?Y) values of points to plot. ![inline formula](https://latex.codecogs.com/png.latex?X) values + /// will be equal to indexes of correspondind elements in data matrix. + #[inline] + pub fn create(data: &impl ToInputArray) -> Result> { + input_array_arg!(data); + return_send!(via ocvrs_return); + unsafe { sys::cv_plot_Plot2d_create_const__InputArrayR(data.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Creates Plot2d object + /// + /// ## Parameters + /// * dataX: ![inline formula](https://latex.codecogs.com/png.latex?1xN) or ![inline formula](https://latex.codecogs.com/png.latex?Nx1) matrix ![inline formula](https://latex.codecogs.com/png.latex?X) values of points to plot. + /// * dataY: ![inline formula](https://latex.codecogs.com/png.latex?1xN) or ![inline formula](https://latex.codecogs.com/png.latex?Nx1) matrix containing ![inline formula](https://latex.codecogs.com/png.latex?Y) values of points to plot. + #[inline] + pub fn create_1(data_x: &impl ToInputArray, data_y: &impl ToInputArray) -> Result> { + input_array_arg!(data_x); + input_array_arg!(data_y); + return_send!(via ocvrs_return); + unsafe { sys::cv_plot_Plot2d_create_const__InputArrayR_const__InputArrayR(data_x.as_raw__InputArray(), data_y.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::plot::Plot2d] pub trait Plot2dTraitConst: core::AlgorithmTraitConst { fn as_raw_Plot2d(&self) -> *const c_void; @@ -190,20 +241,15 @@ pub mod plot { } - pub struct Plot2d { - ptr: *mut c_void, - } - - opencv_type_boxed! { Plot2d } - - impl Drop for Plot2d { + impl std::fmt::Debug for Plot2d { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_plot_Plot2d_delete(self.as_raw_mut_Plot2d()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Plot2d") + .finish() } } - unsafe impl Send for Plot2d {} + boxed_cast_base! { Plot2d, core::Algorithm, cv_plot_Plot2d_to_Algorithm } impl core::AlgorithmTraitConst for Plot2d { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -225,49 +271,4 @@ pub mod plot { boxed_ref! { Plot2d, crate::plot::Plot2dTraitConst, as_raw_Plot2d, crate::plot::Plot2dTrait, as_raw_mut_Plot2d } - impl Plot2d { - /// Creates Plot2d object - /// - /// ## Parameters - /// * data: ![inline formula](https://latex.codecogs.com/png.latex?1xN) or ![inline formula](https://latex.codecogs.com/png.latex?Nx1) matrix containing ![inline formula](https://latex.codecogs.com/png.latex?Y) values of points to plot. ![inline formula](https://latex.codecogs.com/png.latex?X) values - /// will be equal to indexes of correspondind elements in data matrix. - #[inline] - pub fn create(data: &impl ToInputArray) -> Result> { - input_array_arg!(data); - return_send!(via ocvrs_return); - unsafe { sys::cv_plot_Plot2d_create_const__InputArrayR(data.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Creates Plot2d object - /// - /// ## Parameters - /// * dataX: ![inline formula](https://latex.codecogs.com/png.latex?1xN) or ![inline formula](https://latex.codecogs.com/png.latex?Nx1) matrix ![inline formula](https://latex.codecogs.com/png.latex?X) values of points to plot. - /// * dataY: ![inline formula](https://latex.codecogs.com/png.latex?1xN) or ![inline formula](https://latex.codecogs.com/png.latex?Nx1) matrix containing ![inline formula](https://latex.codecogs.com/png.latex?Y) values of points to plot. - #[inline] - pub fn create_1(data_x: &impl ToInputArray, data_y: &impl ToInputArray) -> Result> { - input_array_arg!(data_x); - input_array_arg!(data_y); - return_send!(via ocvrs_return); - unsafe { sys::cv_plot_Plot2d_create_const__InputArrayR_const__InputArrayR(data_x.as_raw__InputArray(), data_y.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { Plot2d, core::Algorithm, cv_plot_Plot2d_to_Algorithm } - - impl std::fmt::Debug for Plot2d { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Plot2d") - .finish() - } - } } diff --git a/docs/quality.rs b/docs/quality.rs index 54eb2968a..e04f08a3e 100644 --- a/docs/quality.rs +++ b/docs/quality.rs @@ -5,33 +5,6 @@ pub mod quality { pub use super::{QualityBRISQUETrait, QualityBRISQUETraitConst, QualityBaseTrait, QualityBaseTraitConst, QualityGMSDTrait, QualityGMSDTraitConst, QualityMSETrait, QualityMSETraitConst, QualityPSNRTrait, QualityPSNRTraitConst, QualitySSIMTrait, QualitySSIMTraitConst}; } - /// Constant methods for [crate::quality::QualityBRISQUE] - pub trait QualityBRISQUETraitConst: crate::quality::QualityBaseTraitConst { - fn as_raw_QualityBRISQUE(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::quality::QualityBRISQUE] - pub trait QualityBRISQUETrait: crate::quality::QualityBRISQUETraitConst + crate::quality::QualityBaseTrait { - fn as_raw_mut_QualityBRISQUE(&mut self) -> *mut c_void; - - /// Computes BRISQUE quality score for input image - /// ## Parameters - /// * img: Image for which to compute quality - /// ## Returns - /// cv::Scalar with the score in the first element. The score ranges from 0 (best quality) to 100 (worst quality) - #[inline] - fn compute(&mut self, img: &impl ToInputArray) -> Result { - input_array_arg!(img); - return_send!(via ocvrs_return); - unsafe { sys::cv_quality_QualityBRISQUE_compute_const__InputArrayR(self.as_raw_mut_QualityBRISQUE(), img.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - /// BRISQUE (Blind/Referenceless Image Spatial Quality Evaluator) is a No Reference Image Quality Assessment (NR-IQA) algorithm. /// /// BRISQUE computes a score based on extracting Natural Scene Statistics () @@ -55,36 +28,6 @@ pub mod quality { unsafe impl Send for QualityBRISQUE {} - impl core::AlgorithmTraitConst for QualityBRISQUE { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for QualityBRISQUE { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { QualityBRISQUE, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::quality::QualityBaseTraitConst for QualityBRISQUE { - #[inline] fn as_raw_QualityBase(&self) -> *const c_void { self.as_raw() } - } - - impl crate::quality::QualityBaseTrait for QualityBRISQUE { - #[inline] fn as_raw_mut_QualityBase(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { QualityBRISQUE, crate::quality::QualityBaseTraitConst, as_raw_QualityBase, crate::quality::QualityBaseTrait, as_raw_mut_QualityBase } - - impl crate::quality::QualityBRISQUETraitConst for QualityBRISQUE { - #[inline] fn as_raw_QualityBRISQUE(&self) -> *const c_void { self.as_raw() } - } - - impl crate::quality::QualityBRISQUETrait for QualityBRISQUE { - #[inline] fn as_raw_mut_QualityBRISQUE(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { QualityBRISQUE, crate::quality::QualityBRISQUETraitConst, as_raw_QualityBRISQUE, crate::quality::QualityBRISQUETrait, as_raw_mut_QualityBRISQUE } - impl QualityBRISQUE { /// Create an object which calculates quality /// ## Parameters @@ -152,9 +95,32 @@ pub mod quality { } - boxed_cast_base! { QualityBRISQUE, core::Algorithm, cv_quality_QualityBRISQUE_to_Algorithm } + /// Constant methods for [crate::quality::QualityBRISQUE] + pub trait QualityBRISQUETraitConst: crate::quality::QualityBaseTraitConst { + fn as_raw_QualityBRISQUE(&self) -> *const c_void; - boxed_cast_base! { QualityBRISQUE, crate::quality::QualityBase, cv_quality_QualityBRISQUE_to_QualityBase } + } + + /// Mutable methods for [crate::quality::QualityBRISQUE] + pub trait QualityBRISQUETrait: crate::quality::QualityBRISQUETraitConst + crate::quality::QualityBaseTrait { + fn as_raw_mut_QualityBRISQUE(&mut self) -> *mut c_void; + + /// Computes BRISQUE quality score for input image + /// ## Parameters + /// * img: Image for which to compute quality + /// ## Returns + /// cv::Scalar with the score in the first element. The score ranges from 0 (best quality) to 100 (worst quality) + #[inline] + fn compute(&mut self, img: &impl ToInputArray) -> Result { + input_array_arg!(img); + return_send!(via ocvrs_return); + unsafe { sys::cv_quality_QualityBRISQUE_compute_const__InputArrayR(self.as_raw_mut_QualityBRISQUE(), img.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } impl std::fmt::Debug for QualityBRISQUE { #[inline] @@ -164,6 +130,56 @@ pub mod quality { } } + boxed_cast_base! { QualityBRISQUE, core::Algorithm, cv_quality_QualityBRISQUE_to_Algorithm } + + boxed_cast_base! { QualityBRISQUE, crate::quality::QualityBase, cv_quality_QualityBRISQUE_to_QualityBase } + + impl core::AlgorithmTraitConst for QualityBRISQUE { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } + } + + impl core::AlgorithmTrait for QualityBRISQUE { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { QualityBRISQUE, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + + impl crate::quality::QualityBaseTraitConst for QualityBRISQUE { + #[inline] fn as_raw_QualityBase(&self) -> *const c_void { self.as_raw() } + } + + impl crate::quality::QualityBaseTrait for QualityBRISQUE { + #[inline] fn as_raw_mut_QualityBase(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { QualityBRISQUE, crate::quality::QualityBaseTraitConst, as_raw_QualityBase, crate::quality::QualityBaseTrait, as_raw_mut_QualityBase } + + impl crate::quality::QualityBRISQUETraitConst for QualityBRISQUE { + #[inline] fn as_raw_QualityBRISQUE(&self) -> *const c_void { self.as_raw() } + } + + impl crate::quality::QualityBRISQUETrait for QualityBRISQUE { + #[inline] fn as_raw_mut_QualityBRISQUE(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { QualityBRISQUE, crate::quality::QualityBRISQUETraitConst, as_raw_QualityBRISQUE, crate::quality::QualityBRISQUETrait, as_raw_mut_QualityBRISQUE } + + /// ********************************* Quality Base Class *********************************** + pub struct QualityBase { + ptr: *mut c_void, + } + + opencv_type_boxed! { QualityBase } + + impl Drop for QualityBase { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_quality_QualityBase_delete(self.as_raw_mut_QualityBase()) }; + } + } + + unsafe impl Send for QualityBase {} + /// Constant methods for [crate::quality::QualityBase] pub trait QualityBaseTraitConst: core::AlgorithmTraitConst { fn as_raw_QualityBase(&self) -> *const c_void; @@ -220,21 +236,25 @@ pub mod quality { } - /// ********************************* Quality Base Class *********************************** - pub struct QualityBase { - ptr: *mut c_void, - } - - opencv_type_boxed! { QualityBase } - - impl Drop for QualityBase { + impl std::fmt::Debug for QualityBase { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_quality_QualityBase_delete(self.as_raw_mut_QualityBase()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("QualityBase") + .finish() } } - unsafe impl Send for QualityBase {} + boxed_cast_base! { QualityBase, core::Algorithm, cv_quality_QualityBase_to_Algorithm } + + boxed_cast_descendant! { QualityBase, crate::quality::QualityBRISQUE, cv_quality_QualityBase_to_QualityBRISQUE } + + boxed_cast_descendant! { QualityBase, crate::quality::QualityGMSD, cv_quality_QualityBase_to_QualityGMSD } + + boxed_cast_descendant! { QualityBase, crate::quality::QualityMSE, cv_quality_QualityBase_to_QualityMSE } + + boxed_cast_descendant! { QualityBase, crate::quality::QualityPSNR, cv_quality_QualityBase_to_QualityPSNR } + + boxed_cast_descendant! { QualityBase, crate::quality::QualitySSIM, cv_quality_QualityBase_to_QualitySSIM } impl core::AlgorithmTraitConst for QualityBase { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -256,27 +276,57 @@ pub mod quality { boxed_ref! { QualityBase, crate::quality::QualityBaseTraitConst, as_raw_QualityBase, crate::quality::QualityBaseTrait, as_raw_mut_QualityBase } - impl QualityBase { + /// Full reference GMSD algorithm + /// + pub struct QualityGMSD { + ptr: *mut c_void, } - boxed_cast_descendant! { QualityBase, crate::quality::QualityBRISQUE, cv_quality_QualityBase_to_QualityBRISQUE } - - boxed_cast_descendant! { QualityBase, crate::quality::QualityGMSD, cv_quality_QualityBase_to_QualityGMSD } - - boxed_cast_descendant! { QualityBase, crate::quality::QualityMSE, cv_quality_QualityBase_to_QualityMSE } + opencv_type_boxed! { QualityGMSD } - boxed_cast_descendant! { QualityBase, crate::quality::QualityPSNR, cv_quality_QualityBase_to_QualityPSNR } + impl Drop for QualityGMSD { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_quality_QualityGMSD_delete(self.as_raw_mut_QualityGMSD()) }; + } + } - boxed_cast_descendant! { QualityBase, crate::quality::QualitySSIM, cv_quality_QualityBase_to_QualitySSIM } + unsafe impl Send for QualityGMSD {} - boxed_cast_base! { QualityBase, core::Algorithm, cv_quality_QualityBase_to_Algorithm } + impl QualityGMSD { + /// Create an object which calculates image quality + /// ## Parameters + /// * ref: reference image + #[inline] + pub fn create(ref_: &impl ToInputArray) -> Result> { + input_array_arg!(ref_); + return_send!(via ocvrs_return); + unsafe { sys::cv_quality_QualityGMSD_create_const__InputArrayR(ref_.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for QualityBase { + /// static method for computing quality + /// ## Parameters + /// * ref: reference image + /// * cmp: comparison image + /// * qualityMap: output quality map, or cv::noArray() + /// ## Returns + /// cv::Scalar with per-channel quality value. Values range from 0 (worst) to 1 (best) #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("QualityBase") - .finish() + pub fn compute(ref_: &impl ToInputArray, cmp: &impl ToInputArray, quality_map: &mut impl ToOutputArray) -> Result { + input_array_arg!(ref_); + input_array_arg!(cmp); + output_array_arg!(quality_map); + return_send!(via ocvrs_return); + unsafe { sys::cv_quality_QualityGMSD_compute_const__InputArrayR_const__InputArrayR_const__OutputArrayR(ref_.as_raw__InputArray(), cmp.as_raw__InputArray(), quality_map.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } + } /// Constant methods for [crate::quality::QualityGMSD] @@ -326,22 +376,17 @@ pub mod quality { } - /// Full reference GMSD algorithm - /// - pub struct QualityGMSD { - ptr: *mut c_void, - } - - opencv_type_boxed! { QualityGMSD } - - impl Drop for QualityGMSD { + impl std::fmt::Debug for QualityGMSD { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_quality_QualityGMSD_delete(self.as_raw_mut_QualityGMSD()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("QualityGMSD") + .finish() } } - unsafe impl Send for QualityGMSD {} + boxed_cast_base! { QualityGMSD, core::Algorithm, cv_quality_QualityGMSD_to_Algorithm } + + boxed_cast_base! { QualityGMSD, crate::quality::QualityBase, cv_quality_QualityGMSD_to_QualityBase } impl core::AlgorithmTraitConst for QualityGMSD { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -373,35 +418,51 @@ pub mod quality { boxed_ref! { QualityGMSD, crate::quality::QualityGMSDTraitConst, as_raw_QualityGMSD, crate::quality::QualityGMSDTrait, as_raw_mut_QualityGMSD } - impl QualityGMSD { - /// Create an object which calculates image quality - /// ## Parameters - /// * ref: reference image + /// Full reference mean square error algorithm + pub struct QualityMSE { + ptr: *mut c_void, + } + + opencv_type_boxed! { QualityMSE } + + impl Drop for QualityMSE { #[inline] - pub fn create(ref_: &impl ToInputArray) -> Result> { - input_array_arg!(ref_); - return_send!(via ocvrs_return); - unsafe { sys::cv_quality_QualityGMSD_create_const__InputArrayR(ref_.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_quality_QualityMSE_delete(self.as_raw_mut_QualityMSE()) }; + } + } + + unsafe impl Send for QualityMSE {} + + impl QualityMSE { + /// Create an object which calculates quality + /// ## Parameters + /// * ref: input image to use as the reference for comparison + #[inline] + pub fn create(ref_: &impl ToInputArray) -> Result> { + input_array_arg!(ref_); + return_send!(via ocvrs_return); + unsafe { sys::cv_quality_QualityMSE_create_const__InputArrayR(ref_.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } /// static method for computing quality /// ## Parameters /// * ref: reference image - /// * cmp: comparison image + /// * cmp: comparison image= /// * qualityMap: output quality map, or cv::noArray() /// ## Returns - /// cv::Scalar with per-channel quality value. Values range from 0 (worst) to 1 (best) + /// cv::Scalar with per-channel quality values. Values range from 0 (best) to max float (worst) #[inline] pub fn compute(ref_: &impl ToInputArray, cmp: &impl ToInputArray, quality_map: &mut impl ToOutputArray) -> Result { input_array_arg!(ref_); input_array_arg!(cmp); output_array_arg!(quality_map); return_send!(via ocvrs_return); - unsafe { sys::cv_quality_QualityGMSD_compute_const__InputArrayR_const__InputArrayR_const__OutputArrayR(ref_.as_raw__InputArray(), cmp.as_raw__InputArray(), quality_map.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_quality_QualityMSE_compute_const__InputArrayR_const__InputArrayR_const__OutputArrayR(ref_.as_raw__InputArray(), cmp.as_raw__InputArray(), quality_map.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -409,18 +470,6 @@ pub mod quality { } - boxed_cast_base! { QualityGMSD, core::Algorithm, cv_quality_QualityGMSD_to_Algorithm } - - boxed_cast_base! { QualityGMSD, crate::quality::QualityBase, cv_quality_QualityGMSD_to_QualityBase } - - impl std::fmt::Debug for QualityGMSD { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("QualityGMSD") - .finish() - } - } - /// Constant methods for [crate::quality::QualityMSE] pub trait QualityMSETraitConst: crate::quality::QualityBaseTraitConst { fn as_raw_QualityMSE(&self) -> *const c_void; @@ -468,21 +517,17 @@ pub mod quality { } - /// Full reference mean square error algorithm - pub struct QualityMSE { - ptr: *mut c_void, - } - - opencv_type_boxed! { QualityMSE } - - impl Drop for QualityMSE { + impl std::fmt::Debug for QualityMSE { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_quality_QualityMSE_delete(self.as_raw_mut_QualityMSE()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("QualityMSE") + .finish() } } - unsafe impl Send for QualityMSE {} + boxed_cast_base! { QualityMSE, core::Algorithm, cv_quality_QualityMSE_to_Algorithm } + + boxed_cast_base! { QualityMSE, crate::quality::QualityBase, cv_quality_QualityMSE_to_QualityBase } impl core::AlgorithmTraitConst for QualityMSE { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -514,52 +559,108 @@ pub mod quality { boxed_ref! { QualityMSE, crate::quality::QualityMSETraitConst, as_raw_QualityMSE, crate::quality::QualityMSETrait, as_raw_mut_QualityMSE } - impl QualityMSE { + /// Full reference peak signal to noise ratio (PSNR) algorithm + pub struct QualityPSNR { + ptr: *mut c_void, + } + + opencv_type_boxed! { QualityPSNR } + + impl Drop for QualityPSNR { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_quality_QualityPSNR_delete(self.as_raw_mut_QualityPSNR()) }; + } + } + + unsafe impl Send for QualityPSNR {} + + impl QualityPSNR { + pub const MAX_PIXEL_VALUE_DEFAULT: f64 = 255.; /// Create an object which calculates quality /// ## Parameters - /// * ref: input image to use as the reference for comparison + /// * ref: input image to use as the source for comparison + /// * maxPixelValue: maximum per-channel value for any individual pixel; eg 255 for uint8 image + /// + /// ## C++ default parameters + /// * max_pixel_value: QualityPSNR::MAX_PIXEL_VALUE_DEFAULT #[inline] - pub fn create(ref_: &impl ToInputArray) -> Result> { + pub fn create(ref_: &impl ToInputArray, max_pixel_value: f64) -> Result> { input_array_arg!(ref_); return_send!(via ocvrs_return); - unsafe { sys::cv_quality_QualityMSE_create_const__InputArrayR(ref_.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_quality_QualityPSNR_create_const__InputArrayR_double(ref_.as_raw__InputArray(), max_pixel_value, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Create an object which calculates quality + /// ## Parameters + /// * ref: input image to use as the source for comparison + /// * maxPixelValue: maximum per-channel value for any individual pixel; eg 255 for uint8 image + /// + /// ## Note + /// This alternative version of [QualityPSNR::create] function uses the following default values for its arguments: + /// * max_pixel_value: QualityPSNR::MAX_PIXEL_VALUE_DEFAULT + #[inline] + pub fn create_def(ref_: &impl ToInputArray) -> Result> { + input_array_arg!(ref_); + return_send!(via ocvrs_return); + unsafe { sys::cv_quality_QualityPSNR_create_const__InputArrayR(ref_.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } /// static method for computing quality /// ## Parameters /// * ref: reference image - /// * cmp: comparison image= + /// * cmp: comparison image /// * qualityMap: output quality map, or cv::noArray() + /// * maxPixelValue: maximum per-channel value for any individual pixel; eg 255 for uint8 image /// ## Returns - /// cv::Scalar with per-channel quality values. Values range from 0 (best) to max float (worst) + /// PSNR value, or std::numeric_limits::infinity() if the MSE between the two images == 0 + /// + /// ## C++ default parameters + /// * max_pixel_value: QualityPSNR::MAX_PIXEL_VALUE_DEFAULT #[inline] - pub fn compute(ref_: &impl ToInputArray, cmp: &impl ToInputArray, quality_map: &mut impl ToOutputArray) -> Result { + pub fn compute(ref_: &impl ToInputArray, cmp: &impl ToInputArray, quality_map: &mut impl ToOutputArray, max_pixel_value: f64) -> Result { input_array_arg!(ref_); input_array_arg!(cmp); output_array_arg!(quality_map); return_send!(via ocvrs_return); - unsafe { sys::cv_quality_QualityMSE_compute_const__InputArrayR_const__InputArrayR_const__OutputArrayR(ref_.as_raw__InputArray(), cmp.as_raw__InputArray(), quality_map.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_quality_QualityPSNR_compute_const__InputArrayR_const__InputArrayR_const__OutputArrayR_double(ref_.as_raw__InputArray(), cmp.as_raw__InputArray(), quality_map.as_raw__OutputArray(), max_pixel_value, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - } - - boxed_cast_base! { QualityMSE, core::Algorithm, cv_quality_QualityMSE_to_Algorithm } - - boxed_cast_base! { QualityMSE, crate::quality::QualityBase, cv_quality_QualityMSE_to_QualityBase } - - impl std::fmt::Debug for QualityMSE { + /// static method for computing quality + /// ## Parameters + /// * ref: reference image + /// * cmp: comparison image + /// * qualityMap: output quality map, or cv::noArray() + /// * maxPixelValue: maximum per-channel value for any individual pixel; eg 255 for uint8 image + /// ## Returns + /// PSNR value, or std::numeric_limits::infinity() if the MSE between the two images == 0 + /// + /// ## Note + /// This alternative version of [QualityPSNR::compute] function uses the following default values for its arguments: + /// * max_pixel_value: QualityPSNR::MAX_PIXEL_VALUE_DEFAULT #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("QualityMSE") - .finish() + pub fn compute_def(ref_: &impl ToInputArray, cmp: &impl ToInputArray, quality_map: &mut impl ToOutputArray) -> Result { + input_array_arg!(ref_); + input_array_arg!(cmp); + output_array_arg!(quality_map); + return_send!(via ocvrs_return); + unsafe { sys::cv_quality_QualityPSNR_compute_const__InputArrayR_const__InputArrayR_const__OutputArrayR(ref_.as_raw__InputArray(), cmp.as_raw__InputArray(), quality_map.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } + } /// Constant methods for [crate::quality::QualityPSNR] @@ -631,21 +732,17 @@ pub mod quality { } - /// Full reference peak signal to noise ratio (PSNR) algorithm - pub struct QualityPSNR { - ptr: *mut c_void, - } - - opencv_type_boxed! { QualityPSNR } - - impl Drop for QualityPSNR { + impl std::fmt::Debug for QualityPSNR { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_quality_QualityPSNR_delete(self.as_raw_mut_QualityPSNR()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("QualityPSNR") + .finish() } } - unsafe impl Send for QualityPSNR {} + boxed_cast_base! { QualityPSNR, core::Algorithm, cv_quality_QualityPSNR_to_Algorithm } + + boxed_cast_base! { QualityPSNR, crate::quality::QualityBase, cv_quality_QualityPSNR_to_QualityBase } impl core::AlgorithmTraitConst for QualityPSNR { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -677,65 +774,34 @@ pub mod quality { boxed_ref! { QualityPSNR, crate::quality::QualityPSNRTraitConst, as_raw_QualityPSNR, crate::quality::QualityPSNRTrait, as_raw_mut_QualityPSNR } - impl QualityPSNR { - pub const MAX_PIXEL_VALUE_DEFAULT: f64 = 255.; - /// Create an object which calculates quality - /// ## Parameters - /// * ref: input image to use as the source for comparison - /// * maxPixelValue: maximum per-channel value for any individual pixel; eg 255 for uint8 image - /// - /// ## C++ default parameters - /// * max_pixel_value: QualityPSNR::MAX_PIXEL_VALUE_DEFAULT - #[inline] - pub fn create(ref_: &impl ToInputArray, max_pixel_value: f64) -> Result> { - input_array_arg!(ref_); - return_send!(via ocvrs_return); - unsafe { sys::cv_quality_QualityPSNR_create_const__InputArrayR_double(ref_.as_raw__InputArray(), max_pixel_value, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } + /// Full reference structural similarity algorithm + pub struct QualitySSIM { + ptr: *mut c_void, + } - /// Create an object which calculates quality - /// ## Parameters - /// * ref: input image to use as the source for comparison - /// * maxPixelValue: maximum per-channel value for any individual pixel; eg 255 for uint8 image - /// - /// ## Note - /// This alternative version of [QualityPSNR::create] function uses the following default values for its arguments: - /// * max_pixel_value: QualityPSNR::MAX_PIXEL_VALUE_DEFAULT + opencv_type_boxed! { QualitySSIM } + + impl Drop for QualitySSIM { #[inline] - pub fn create_def(ref_: &impl ToInputArray) -> Result> { - input_array_arg!(ref_); - return_send!(via ocvrs_return); - unsafe { sys::cv_quality_QualityPSNR_create_const__InputArrayR(ref_.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_quality_QualitySSIM_delete(self.as_raw_mut_QualitySSIM()) }; } + } - /// static method for computing quality + unsafe impl Send for QualitySSIM {} + + impl QualitySSIM { + /// Create an object which calculates quality /// ## Parameters - /// * ref: reference image - /// * cmp: comparison image - /// * qualityMap: output quality map, or cv::noArray() - /// * maxPixelValue: maximum per-channel value for any individual pixel; eg 255 for uint8 image - /// ## Returns - /// PSNR value, or std::numeric_limits::infinity() if the MSE between the two images == 0 - /// - /// ## C++ default parameters - /// * max_pixel_value: QualityPSNR::MAX_PIXEL_VALUE_DEFAULT + /// * ref: input image to use as the reference image for comparison #[inline] - pub fn compute(ref_: &impl ToInputArray, cmp: &impl ToInputArray, quality_map: &mut impl ToOutputArray, max_pixel_value: f64) -> Result { + pub fn create(ref_: &impl ToInputArray) -> Result> { input_array_arg!(ref_); - input_array_arg!(cmp); - output_array_arg!(quality_map); return_send!(via ocvrs_return); - unsafe { sys::cv_quality_QualityPSNR_compute_const__InputArrayR_const__InputArrayR_const__OutputArrayR_double(ref_.as_raw__InputArray(), cmp.as_raw__InputArray(), quality_map.as_raw__OutputArray(), max_pixel_value, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_quality_QualitySSIM_create_const__InputArrayR(ref_.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } @@ -744,20 +810,15 @@ pub mod quality { /// * ref: reference image /// * cmp: comparison image /// * qualityMap: output quality map, or cv::noArray() - /// * maxPixelValue: maximum per-channel value for any individual pixel; eg 255 for uint8 image /// ## Returns - /// PSNR value, or std::numeric_limits::infinity() if the MSE between the two images == 0 - /// - /// ## Note - /// This alternative version of [QualityPSNR::compute] function uses the following default values for its arguments: - /// * max_pixel_value: QualityPSNR::MAX_PIXEL_VALUE_DEFAULT + /// cv::Scalar with per-channel quality values. Values range from 0 (worst) to 1 (best) #[inline] - pub fn compute_def(ref_: &impl ToInputArray, cmp: &impl ToInputArray, quality_map: &mut impl ToOutputArray) -> Result { + pub fn compute(ref_: &impl ToInputArray, cmp: &impl ToInputArray, quality_map: &mut impl ToOutputArray) -> Result { input_array_arg!(ref_); input_array_arg!(cmp); output_array_arg!(quality_map); return_send!(via ocvrs_return); - unsafe { sys::cv_quality_QualityPSNR_compute_const__InputArrayR_const__InputArrayR_const__OutputArrayR(ref_.as_raw__InputArray(), cmp.as_raw__InputArray(), quality_map.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_quality_QualitySSIM_compute_const__InputArrayR_const__InputArrayR_const__OutputArrayR(ref_.as_raw__InputArray(), cmp.as_raw__InputArray(), quality_map.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -765,18 +826,6 @@ pub mod quality { } - boxed_cast_base! { QualityPSNR, core::Algorithm, cv_quality_QualityPSNR_to_Algorithm } - - boxed_cast_base! { QualityPSNR, crate::quality::QualityBase, cv_quality_QualityPSNR_to_QualityBase } - - impl std::fmt::Debug for QualityPSNR { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("QualityPSNR") - .finish() - } - } - /// Constant methods for [crate::quality::QualitySSIM] pub trait QualitySSIMTraitConst: crate::quality::QualityBaseTraitConst { fn as_raw_QualitySSIM(&self) -> *const c_void; @@ -824,21 +873,17 @@ pub mod quality { } - /// Full reference structural similarity algorithm - pub struct QualitySSIM { - ptr: *mut c_void, - } - - opencv_type_boxed! { QualitySSIM } - - impl Drop for QualitySSIM { + impl std::fmt::Debug for QualitySSIM { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_quality_QualitySSIM_delete(self.as_raw_mut_QualitySSIM()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("QualitySSIM") + .finish() } } - unsafe impl Send for QualitySSIM {} + boxed_cast_base! { QualitySSIM, core::Algorithm, cv_quality_QualitySSIM_to_Algorithm } + + boxed_cast_base! { QualitySSIM, crate::quality::QualityBase, cv_quality_QualitySSIM_to_QualityBase } impl core::AlgorithmTraitConst for QualitySSIM { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -870,51 +915,4 @@ pub mod quality { boxed_ref! { QualitySSIM, crate::quality::QualitySSIMTraitConst, as_raw_QualitySSIM, crate::quality::QualitySSIMTrait, as_raw_mut_QualitySSIM } - impl QualitySSIM { - /// Create an object which calculates quality - /// ## Parameters - /// * ref: input image to use as the reference image for comparison - #[inline] - pub fn create(ref_: &impl ToInputArray) -> Result> { - input_array_arg!(ref_); - return_send!(via ocvrs_return); - unsafe { sys::cv_quality_QualitySSIM_create_const__InputArrayR(ref_.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// static method for computing quality - /// ## Parameters - /// * ref: reference image - /// * cmp: comparison image - /// * qualityMap: output quality map, or cv::noArray() - /// ## Returns - /// cv::Scalar with per-channel quality values. Values range from 0 (worst) to 1 (best) - #[inline] - pub fn compute(ref_: &impl ToInputArray, cmp: &impl ToInputArray, quality_map: &mut impl ToOutputArray) -> Result { - input_array_arg!(ref_); - input_array_arg!(cmp); - output_array_arg!(quality_map); - return_send!(via ocvrs_return); - unsafe { sys::cv_quality_QualitySSIM_compute_const__InputArrayR_const__InputArrayR_const__OutputArrayR(ref_.as_raw__InputArray(), cmp.as_raw__InputArray(), quality_map.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - boxed_cast_base! { QualitySSIM, core::Algorithm, cv_quality_QualitySSIM_to_Algorithm } - - boxed_cast_base! { QualitySSIM, crate::quality::QualityBase, cv_quality_QualitySSIM_to_QualityBase } - - impl std::fmt::Debug for QualitySSIM { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("QualitySSIM") - .finish() - } - } } diff --git a/docs/rapid.rs b/docs/rapid.rs index a1aa9e2bd..1c3ebaba8 100644 --- a/docs/rapid.rs +++ b/docs/rapid.rs @@ -332,6 +332,56 @@ pub mod rapid { Ok(ret) } + /// implements "Global optimal searching for textureless 3D object tracking" [wang2015global](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_wang2015global) + pub struct Rapid_GOSTracker { + ptr: *mut c_void, + } + + opencv_type_boxed! { Rapid_GOSTracker } + + impl Drop for Rapid_GOSTracker { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_rapid_GOSTracker_delete(self.as_raw_mut_Rapid_GOSTracker()) }; + } + } + + unsafe impl Send for Rapid_GOSTracker {} + + impl Rapid_GOSTracker { + /// ## C++ default parameters + /// * hist_bins: 4 + /// * sobel_thesh: 10 + #[inline] + pub fn create(pts3d: &impl ToInputArray, tris: &impl ToInputArray, hist_bins: i32, sobel_thesh: u8) -> Result> { + input_array_arg!(pts3d); + input_array_arg!(tris); + return_send!(via ocvrs_return); + unsafe { sys::cv_rapid_GOSTracker_create_const__InputArrayR_const__InputArrayR_int_unsigned_char(pts3d.as_raw__InputArray(), tris.as_raw__InputArray(), hist_bins, sobel_thesh, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [Rapid_GOSTracker::create] function uses the following default values for its arguments: + /// * hist_bins: 4 + /// * sobel_thesh: 10 + #[inline] + pub fn create_def(pts3d: &impl ToInputArray, tris: &impl ToInputArray) -> Result> { + input_array_arg!(pts3d); + input_array_arg!(tris); + return_send!(via ocvrs_return); + unsafe { sys::cv_rapid_GOSTracker_create_const__InputArrayR_const__InputArrayR(pts3d.as_raw__InputArray(), tris.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::rapid::Rapid_GOSTracker] pub trait Rapid_GOSTrackerTraitConst: crate::rapid::Rapid_TrackerTraitConst { fn as_raw_Rapid_GOSTracker(&self) -> *const c_void; @@ -344,21 +394,17 @@ pub mod rapid { } - /// implements "Global optimal searching for textureless 3D object tracking" [wang2015global](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_wang2015global) - pub struct Rapid_GOSTracker { - ptr: *mut c_void, - } - - opencv_type_boxed! { Rapid_GOSTracker } - - impl Drop for Rapid_GOSTracker { + impl std::fmt::Debug for Rapid_GOSTracker { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_rapid_GOSTracker_delete(self.as_raw_mut_Rapid_GOSTracker()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Rapid_GOSTracker") + .finish() } } - unsafe impl Send for Rapid_GOSTracker {} + boxed_cast_base! { Rapid_GOSTracker, core::Algorithm, cv_rapid_GOSTracker_to_Algorithm } + + boxed_cast_base! { Rapid_GOSTracker, crate::rapid::Rapid_Tracker, cv_rapid_GOSTracker_to_Rapid_Tracker } impl core::AlgorithmTraitConst for Rapid_GOSTracker { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -390,16 +436,33 @@ pub mod rapid { boxed_ref! { Rapid_GOSTracker, crate::rapid::Rapid_GOSTrackerTraitConst, as_raw_Rapid_GOSTracker, crate::rapid::Rapid_GOSTrackerTrait, as_raw_mut_Rapid_GOSTracker } - impl Rapid_GOSTracker { + /// implements "Optimal local searching for fast and robust textureless 3D object tracking in highly + /// cluttered backgrounds" [seo2013optimal](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_seo2013optimal) + pub struct Rapid_OLSTracker { + ptr: *mut c_void, + } + + opencv_type_boxed! { Rapid_OLSTracker } + + impl Drop for Rapid_OLSTracker { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_rapid_OLSTracker_delete(self.as_raw_mut_Rapid_OLSTracker()) }; + } + } + + unsafe impl Send for Rapid_OLSTracker {} + + impl Rapid_OLSTracker { /// ## C++ default parameters - /// * hist_bins: 4 + /// * hist_bins: 8 /// * sobel_thesh: 10 #[inline] pub fn create(pts3d: &impl ToInputArray, tris: &impl ToInputArray, hist_bins: i32, sobel_thesh: u8) -> Result> { input_array_arg!(pts3d); input_array_arg!(tris); return_send!(via ocvrs_return); - unsafe { sys::cv_rapid_GOSTracker_create_const__InputArrayR_const__InputArrayR_int_unsigned_char(pts3d.as_raw__InputArray(), tris.as_raw__InputArray(), hist_bins, sobel_thesh, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rapid_OLSTracker_create_const__InputArrayR_const__InputArrayR_int_unsigned_char(pts3d.as_raw__InputArray(), tris.as_raw__InputArray(), hist_bins, sobel_thesh, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; @@ -407,15 +470,15 @@ pub mod rapid { } /// ## Note - /// This alternative version of [Rapid_GOSTracker::create] function uses the following default values for its arguments: - /// * hist_bins: 4 + /// This alternative version of [Rapid_OLSTracker::create] function uses the following default values for its arguments: + /// * hist_bins: 8 /// * sobel_thesh: 10 #[inline] pub fn create_def(pts3d: &impl ToInputArray, tris: &impl ToInputArray) -> Result> { input_array_arg!(pts3d); input_array_arg!(tris); return_send!(via ocvrs_return); - unsafe { sys::cv_rapid_GOSTracker_create_const__InputArrayR_const__InputArrayR(pts3d.as_raw__InputArray(), tris.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rapid_OLSTracker_create_const__InputArrayR_const__InputArrayR(pts3d.as_raw__InputArray(), tris.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; @@ -424,18 +487,6 @@ pub mod rapid { } - boxed_cast_base! { Rapid_GOSTracker, core::Algorithm, cv_rapid_GOSTracker_to_Algorithm } - - boxed_cast_base! { Rapid_GOSTracker, crate::rapid::Rapid_Tracker, cv_rapid_GOSTracker_to_Rapid_Tracker } - - impl std::fmt::Debug for Rapid_GOSTracker { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Rapid_GOSTracker") - .finish() - } - } - /// Constant methods for [crate::rapid::Rapid_OLSTracker] pub trait Rapid_OLSTrackerTraitConst: crate::rapid::Rapid_TrackerTraitConst { fn as_raw_Rapid_OLSTracker(&self) -> *const c_void; @@ -448,22 +499,17 @@ pub mod rapid { } - /// implements "Optimal local searching for fast and robust textureless 3D object tracking in highly - /// cluttered backgrounds" [seo2013optimal](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_seo2013optimal) - pub struct Rapid_OLSTracker { - ptr: *mut c_void, - } - - opencv_type_boxed! { Rapid_OLSTracker } - - impl Drop for Rapid_OLSTracker { + impl std::fmt::Debug for Rapid_OLSTracker { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_rapid_OLSTracker_delete(self.as_raw_mut_Rapid_OLSTracker()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Rapid_OLSTracker") + .finish() } } - unsafe impl Send for Rapid_OLSTracker {} + boxed_cast_base! { Rapid_OLSTracker, core::Algorithm, cv_rapid_OLSTracker_to_Algorithm } + + boxed_cast_base! { Rapid_OLSTracker, crate::rapid::Rapid_Tracker, cv_rapid_OLSTracker_to_Rapid_Tracker } impl core::AlgorithmTraitConst for Rapid_OLSTracker { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -495,52 +541,37 @@ pub mod rapid { boxed_ref! { Rapid_OLSTracker, crate::rapid::Rapid_OLSTrackerTraitConst, as_raw_Rapid_OLSTracker, crate::rapid::Rapid_OLSTrackerTrait, as_raw_mut_Rapid_OLSTracker } - impl Rapid_OLSTracker { - /// ## C++ default parameters - /// * hist_bins: 8 - /// * sobel_thesh: 10 + /// wrapper around [rapid] function for uniform access + pub struct Rapid_Rapid { + ptr: *mut c_void, + } + + opencv_type_boxed! { Rapid_Rapid } + + impl Drop for Rapid_Rapid { #[inline] - pub fn create(pts3d: &impl ToInputArray, tris: &impl ToInputArray, hist_bins: i32, sobel_thesh: u8) -> Result> { - input_array_arg!(pts3d); - input_array_arg!(tris); - return_send!(via ocvrs_return); - unsafe { sys::cv_rapid_OLSTracker_create_const__InputArrayR_const__InputArrayR_int_unsigned_char(pts3d.as_raw__InputArray(), tris.as_raw__InputArray(), hist_bins, sobel_thesh, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_rapid_Rapid_delete(self.as_raw_mut_Rapid_Rapid()) }; } + } - /// ## Note - /// This alternative version of [Rapid_OLSTracker::create] function uses the following default values for its arguments: - /// * hist_bins: 8 - /// * sobel_thesh: 10 + unsafe impl Send for Rapid_Rapid {} + + impl Rapid_Rapid { #[inline] - pub fn create_def(pts3d: &impl ToInputArray, tris: &impl ToInputArray) -> Result> { + pub fn create(pts3d: &impl ToInputArray, tris: &impl ToInputArray) -> Result> { input_array_arg!(pts3d); input_array_arg!(tris); return_send!(via ocvrs_return); - unsafe { sys::cv_rapid_OLSTracker_create_const__InputArrayR_const__InputArrayR(pts3d.as_raw__InputArray(), tris.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rapid_Rapid_create_const__InputArrayR_const__InputArrayR(pts3d.as_raw__InputArray(), tris.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { Rapid_OLSTracker, core::Algorithm, cv_rapid_OLSTracker_to_Algorithm } - - boxed_cast_base! { Rapid_OLSTracker, crate::rapid::Rapid_Tracker, cv_rapid_OLSTracker_to_Rapid_Tracker } - - impl std::fmt::Debug for Rapid_OLSTracker { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Rapid_OLSTracker") - .finish() - } - } - /// Constant methods for [crate::rapid::Rapid_Rapid] pub trait Rapid_RapidTraitConst: crate::rapid::Rapid_TrackerTraitConst { fn as_raw_Rapid_Rapid(&self) -> *const c_void; @@ -553,21 +584,17 @@ pub mod rapid { } - /// wrapper around [rapid] function for uniform access - pub struct Rapid_Rapid { - ptr: *mut c_void, - } - - opencv_type_boxed! { Rapid_Rapid } - - impl Drop for Rapid_Rapid { + impl std::fmt::Debug for Rapid_Rapid { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_rapid_Rapid_delete(self.as_raw_mut_Rapid_Rapid()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Rapid_Rapid") + .finish() } } - unsafe impl Send for Rapid_Rapid {} + boxed_cast_base! { Rapid_Rapid, core::Algorithm, cv_rapid_Rapid_to_Algorithm } + + boxed_cast_base! { Rapid_Rapid, crate::rapid::Rapid_Tracker, cv_rapid_Rapid_to_Rapid_Tracker } impl core::AlgorithmTraitConst for Rapid_Rapid { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -599,33 +626,22 @@ pub mod rapid { boxed_ref! { Rapid_Rapid, crate::rapid::Rapid_RapidTraitConst, as_raw_Rapid_Rapid, crate::rapid::Rapid_RapidTrait, as_raw_mut_Rapid_Rapid } - impl Rapid_Rapid { - #[inline] - pub fn create(pts3d: &impl ToInputArray, tris: &impl ToInputArray) -> Result> { - input_array_arg!(pts3d); - input_array_arg!(tris); - return_send!(via ocvrs_return); - unsafe { sys::cv_rapid_Rapid_create_const__InputArrayR_const__InputArrayR(pts3d.as_raw__InputArray(), tris.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + /// Abstract base class for stateful silhouette trackers + pub struct Rapid_Tracker { + ptr: *mut c_void, } - boxed_cast_base! { Rapid_Rapid, core::Algorithm, cv_rapid_Rapid_to_Algorithm } - - boxed_cast_base! { Rapid_Rapid, crate::rapid::Rapid_Tracker, cv_rapid_Rapid_to_Rapid_Tracker } + opencv_type_boxed! { Rapid_Tracker } - impl std::fmt::Debug for Rapid_Rapid { + impl Drop for Rapid_Tracker { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Rapid_Rapid") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_rapid_Tracker_delete(self.as_raw_mut_Rapid_Tracker()) }; } } + unsafe impl Send for Rapid_Tracker {} + /// Constant methods for [crate::rapid::Rapid_Tracker] pub trait Rapid_TrackerTraitConst: core::AlgorithmTraitConst { fn as_raw_Rapid_Tracker(&self) -> *const c_void; @@ -678,21 +694,21 @@ pub mod rapid { } - /// Abstract base class for stateful silhouette trackers - pub struct Rapid_Tracker { - ptr: *mut c_void, - } - - opencv_type_boxed! { Rapid_Tracker } - - impl Drop for Rapid_Tracker { + impl std::fmt::Debug for Rapid_Tracker { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_rapid_Tracker_delete(self.as_raw_mut_Rapid_Tracker()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Rapid_Tracker") + .finish() } } - unsafe impl Send for Rapid_Tracker {} + boxed_cast_base! { Rapid_Tracker, core::Algorithm, cv_rapid_Tracker_to_Algorithm } + + boxed_cast_descendant! { Rapid_Tracker, crate::rapid::Rapid_GOSTracker, cv_rapid_Tracker_to_Rapid_GOSTracker } + + boxed_cast_descendant! { Rapid_Tracker, crate::rapid::Rapid_OLSTracker, cv_rapid_Tracker_to_Rapid_OLSTracker } + + boxed_cast_descendant! { Rapid_Tracker, crate::rapid::Rapid_Rapid, cv_rapid_Tracker_to_Rapid_Rapid } impl core::AlgorithmTraitConst for Rapid_Tracker { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -714,22 +730,4 @@ pub mod rapid { boxed_ref! { Rapid_Tracker, crate::rapid::Rapid_TrackerTraitConst, as_raw_Rapid_Tracker, crate::rapid::Rapid_TrackerTrait, as_raw_mut_Rapid_Tracker } - impl Rapid_Tracker { - } - - boxed_cast_descendant! { Rapid_Tracker, crate::rapid::Rapid_GOSTracker, cv_rapid_Tracker_to_Rapid_GOSTracker } - - boxed_cast_descendant! { Rapid_Tracker, crate::rapid::Rapid_OLSTracker, cv_rapid_Tracker_to_Rapid_OLSTracker } - - boxed_cast_descendant! { Rapid_Tracker, crate::rapid::Rapid_Rapid, cv_rapid_Tracker_to_Rapid_Rapid } - - boxed_cast_base! { Rapid_Tracker, core::Algorithm, cv_rapid_Tracker_to_Algorithm } - - impl std::fmt::Debug for Rapid_Tracker { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Rapid_Tracker") - .finish() - } - } } diff --git a/docs/rgbd.rs b/docs/rgbd.rs index 2a9b7c780..dfb85577d 100644 --- a/docs/rgbd.rs +++ b/docs/rgbd.rs @@ -500,6 +500,57 @@ pub mod rgbd { Ok(ret) } + /// KinectFusion implementation + /// + /// This class implements a 3d reconstruction algorithm described in + /// [kinectfusion](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_kinectfusion) paper. + /// + /// It takes a sequence of depth images taken from depth sensor + /// (or any depth images source such as stereo camera matching algorithm or even raymarching renderer). + /// The output can be obtained as a vector of points and their normals + /// or can be Phong-rendered from given camera pose. + /// + /// An internal representation of a model is a voxel cuboid that keeps TSDF values + /// which are a sort of distances to the surface (for details read the [kinectfusion](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_kinectfusion) article about TSDF). + /// There is no interface to that representation yet. + /// + /// KinFu uses OpenCL acceleration automatically if available. + /// To enable or disable it explicitly use cv::setUseOptimized() or cv::ocl::setUseOpenCL(). + /// + /// This implementation is based on [kinfu-remake](https://github.com/Nerei/kinfu_remake). + /// + /// Note that the KinectFusion algorithm was patented and its use may be restricted by + /// the list of patents mentioned in README.md file in this module directory. + /// + /// That's why you need to set the OPENCV_ENABLE_NONFREE option in CMake to use KinectFusion. + pub struct ColoredKinfu_ColoredKinFu { + ptr: *mut c_void, + } + + opencv_type_boxed! { ColoredKinfu_ColoredKinFu } + + impl Drop for ColoredKinfu_ColoredKinFu { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_colored_kinfu_ColoredKinFu_delete(self.as_raw_mut_ColoredKinfu_ColoredKinFu()) }; + } + } + + unsafe impl Send for ColoredKinfu_ColoredKinFu {} + + impl ColoredKinfu_ColoredKinFu { + #[inline] + pub fn create(_params: &core::Ptr) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_colored_kinfu_ColoredKinFu_create_const_PtrLParamsGR(_params.as_raw_PtrOfColoredKinfu_Params(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::rgbd::ColoredKinfu_ColoredKinFu] pub trait ColoredKinfu_ColoredKinFuTraitConst { fn as_raw_ColoredKinfu_ColoredKinFu(&self) -> *const c_void; @@ -678,44 +729,14 @@ pub mod rgbd { } - /// KinectFusion implementation - /// - /// This class implements a 3d reconstruction algorithm described in - /// [kinectfusion](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_kinectfusion) paper. - /// - /// It takes a sequence of depth images taken from depth sensor - /// (or any depth images source such as stereo camera matching algorithm or even raymarching renderer). - /// The output can be obtained as a vector of points and their normals - /// or can be Phong-rendered from given camera pose. - /// - /// An internal representation of a model is a voxel cuboid that keeps TSDF values - /// which are a sort of distances to the surface (for details read the [kinectfusion](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_kinectfusion) article about TSDF). - /// There is no interface to that representation yet. - /// - /// KinFu uses OpenCL acceleration automatically if available. - /// To enable or disable it explicitly use cv::setUseOptimized() or cv::ocl::setUseOpenCL(). - /// - /// This implementation is based on [kinfu-remake](https://github.com/Nerei/kinfu_remake). - /// - /// Note that the KinectFusion algorithm was patented and its use may be restricted by - /// the list of patents mentioned in README.md file in this module directory. - /// - /// That's why you need to set the OPENCV_ENABLE_NONFREE option in CMake to use KinectFusion. - pub struct ColoredKinfu_ColoredKinFu { - ptr: *mut c_void, - } - - opencv_type_boxed! { ColoredKinfu_ColoredKinFu } - - impl Drop for ColoredKinfu_ColoredKinFu { + impl std::fmt::Debug for ColoredKinfu_ColoredKinFu { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_colored_kinfu_ColoredKinFu_delete(self.as_raw_mut_ColoredKinfu_ColoredKinFu()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ColoredKinfu_ColoredKinFu") + .finish() } } - unsafe impl Send for ColoredKinfu_ColoredKinFu {} - impl crate::rgbd::ColoredKinfu_ColoredKinFuTraitConst for ColoredKinfu_ColoredKinFu { #[inline] fn as_raw_ColoredKinfu_ColoredKinFu(&self) -> *const c_void { self.as_raw() } } @@ -726,25 +747,110 @@ pub mod rgbd { boxed_ref! { ColoredKinfu_ColoredKinFu, crate::rgbd::ColoredKinfu_ColoredKinFuTraitConst, as_raw_ColoredKinfu_ColoredKinFu, crate::rgbd::ColoredKinfu_ColoredKinFuTrait, as_raw_mut_ColoredKinfu_ColoredKinFu } - impl ColoredKinfu_ColoredKinFu { + pub struct ColoredKinfu_Params { + ptr: *mut c_void, + } + + opencv_type_boxed! { ColoredKinfu_Params } + + impl Drop for ColoredKinfu_Params { #[inline] - pub fn create(_params: &core::Ptr) -> Result> { + fn drop(&mut self) { + unsafe { sys::cv_colored_kinfu_Params_delete(self.as_raw_mut_ColoredKinfu_Params()) }; + } + } + + unsafe impl Send for ColoredKinfu_Params {} + + impl ColoredKinfu_Params { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_colored_kinfu_ColoredKinFu_create_const_PtrLParamsGR(_params.as_raw_PtrOfColoredKinfu_Params(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_colored_kinfu_Params_Params(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::ColoredKinfu_Params::opencv_from_extern(ret) }; Ok(ret) } - } + /// Constructor for Params + /// Sets the initial pose of the TSDF volume. + /// ## Parameters + /// * volumeInitialPoseRot: rotation matrix + /// * volumeInitialPoseTransl: translation vector + #[inline] + pub fn new(volume_initial_pose_rot: core::Matx33f, volume_initial_pose_transl: core::Vec3f) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_colored_kinfu_Params_Params_Matx33f_Vec3f(&volume_initial_pose_rot, &volume_initial_pose_transl, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::rgbd::ColoredKinfu_Params::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for ColoredKinfu_ColoredKinFu { + /// Constructor for Params + /// Sets the initial pose of the TSDF volume. + /// ## Parameters + /// * volumeInitialPose: 4 by 4 Homogeneous Transform matrix to set the intial pose of TSDF volume #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ColoredKinfu_ColoredKinFu") - .finish() + pub fn new_1(volume_initial_pose: core::Matx44f) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_colored_kinfu_Params_Params_Matx44f(&volume_initial_pose, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::rgbd::ColoredKinfu_Params::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Default parameters + /// A set of parameters which provides better model quality, can be very slow. + #[inline] + pub fn default_params() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_colored_kinfu_Params_defaultParams(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Coarse parameters + /// A set of parameters which provides better speed, can fail to match frames + /// in case of rapid sensor motion. + #[inline] + pub fn coarse_params() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_colored_kinfu_Params_coarseParams(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// HashTSDF parameters + /// A set of parameters suitable for use with HashTSDFVolume + #[inline] + pub fn hash_tsdf_params(is_coarse: bool) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_colored_kinfu_Params_hashTSDFParams_bool(is_coarse, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ColoredTSDF parameters + /// A set of parameters suitable for use with HashTSDFVolume + #[inline] + pub fn colored_tsdf_params(is_coarse: bool) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_colored_kinfu_Params_coloredTSDFParams_bool(is_coarse, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::rgbd::ColoredKinfu_Params] @@ -1143,21 +1249,36 @@ pub mod rgbd { } - pub struct ColoredKinfu_Params { - ptr: *mut c_void, - } - - opencv_type_boxed! { ColoredKinfu_Params } - - impl Drop for ColoredKinfu_Params { + impl std::fmt::Debug for ColoredKinfu_Params { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_colored_kinfu_Params_delete(self.as_raw_mut_ColoredKinfu_Params()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ColoredKinfu_Params") + .field("frame_size", &crate::rgbd::ColoredKinfu_ParamsTraitConst::frame_size(self)) + .field("rgb_frame_size", &crate::rgbd::ColoredKinfu_ParamsTraitConst::rgb_frame_size(self)) + .field("volume_type", &crate::rgbd::ColoredKinfu_ParamsTraitConst::volume_type(self)) + .field("intr", &crate::rgbd::ColoredKinfu_ParamsTraitConst::intr(self)) + .field("rgb_intr", &crate::rgbd::ColoredKinfu_ParamsTraitConst::rgb_intr(self)) + .field("depth_factor", &crate::rgbd::ColoredKinfu_ParamsTraitConst::depth_factor(self)) + .field("bilateral_sigma_depth", &crate::rgbd::ColoredKinfu_ParamsTraitConst::bilateral_sigma_depth(self)) + .field("bilateral_sigma_spatial", &crate::rgbd::ColoredKinfu_ParamsTraitConst::bilateral_sigma_spatial(self)) + .field("bilateral_kernel_size", &crate::rgbd::ColoredKinfu_ParamsTraitConst::bilateral_kernel_size(self)) + .field("pyramid_levels", &crate::rgbd::ColoredKinfu_ParamsTraitConst::pyramid_levels(self)) + .field("volume_dims", &crate::rgbd::ColoredKinfu_ParamsTraitConst::volume_dims(self)) + .field("voxel_size", &crate::rgbd::ColoredKinfu_ParamsTraitConst::voxel_size(self)) + .field("tsdf_min_camera_movement", &crate::rgbd::ColoredKinfu_ParamsTraitConst::tsdf_min_camera_movement(self)) + .field("volume_pose", &crate::rgbd::ColoredKinfu_ParamsTraitConst::volume_pose(self)) + .field("tsdf_trunc_dist", &crate::rgbd::ColoredKinfu_ParamsTraitConst::tsdf_trunc_dist(self)) + .field("tsdf_max_weight", &crate::rgbd::ColoredKinfu_ParamsTraitConst::tsdf_max_weight(self)) + .field("raycast_step_factor", &crate::rgbd::ColoredKinfu_ParamsTraitConst::raycast_step_factor(self)) + .field("light_pose", &crate::rgbd::ColoredKinfu_ParamsTraitConst::light_pose(self)) + .field("icp_dist_thresh", &crate::rgbd::ColoredKinfu_ParamsTraitConst::icp_dist_thresh(self)) + .field("icp_angle_thresh", &crate::rgbd::ColoredKinfu_ParamsTraitConst::icp_angle_thresh(self)) + .field("icp_iterations", &crate::rgbd::ColoredKinfu_ParamsTraitConst::icp_iterations(self)) + .field("truncate_threshold", &crate::rgbd::ColoredKinfu_ParamsTraitConst::truncate_threshold(self)) + .finish() } } - unsafe impl Send for ColoredKinfu_Params {} - impl crate::rgbd::ColoredKinfu_ParamsTraitConst for ColoredKinfu_Params { #[inline] fn as_raw_ColoredKinfu_Params(&self) -> *const c_void { self.as_raw() } } @@ -1168,125 +1289,32 @@ pub mod rgbd { boxed_ref! { ColoredKinfu_Params, crate::rgbd::ColoredKinfu_ParamsTraitConst, as_raw_ColoredKinfu_Params, crate::rgbd::ColoredKinfu_ParamsTrait, as_raw_mut_ColoredKinfu_Params } - impl ColoredKinfu_Params { + pub struct Dynafu_DynaFu { + ptr: *mut c_void, + } + + opencv_type_boxed! { Dynafu_DynaFu } + + impl Drop for Dynafu_DynaFu { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_dynafu_DynaFu_delete(self.as_raw_mut_Dynafu_DynaFu()) }; + } + } + + unsafe impl Send for Dynafu_DynaFu {} + + impl Dynafu_DynaFu { + #[inline] + pub fn create(_params: &core::Ptr) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_colored_kinfu_Params_Params(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_dynafu_DynaFu_create_const_PtrLParamsGR(_params.as_raw_PtrOfKinfu_Params(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::ColoredKinfu_Params::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Constructor for Params - /// Sets the initial pose of the TSDF volume. - /// ## Parameters - /// * volumeInitialPoseRot: rotation matrix - /// * volumeInitialPoseTransl: translation vector - #[inline] - pub fn new(volume_initial_pose_rot: core::Matx33f, volume_initial_pose_transl: core::Vec3f) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_colored_kinfu_Params_Params_Matx33f_Vec3f(&volume_initial_pose_rot, &volume_initial_pose_transl, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::ColoredKinfu_Params::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Constructor for Params - /// Sets the initial pose of the TSDF volume. - /// ## Parameters - /// * volumeInitialPose: 4 by 4 Homogeneous Transform matrix to set the intial pose of TSDF volume - #[inline] - pub fn new_1(volume_initial_pose: core::Matx44f) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_colored_kinfu_Params_Params_Matx44f(&volume_initial_pose, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::ColoredKinfu_Params::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Default parameters - /// A set of parameters which provides better model quality, can be very slow. - #[inline] - pub fn default_params() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_colored_kinfu_Params_defaultParams(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Coarse parameters - /// A set of parameters which provides better speed, can fail to match frames - /// in case of rapid sensor motion. - #[inline] - pub fn coarse_params() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_colored_kinfu_Params_coarseParams(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// HashTSDF parameters - /// A set of parameters suitable for use with HashTSDFVolume - #[inline] - pub fn hash_tsdf_params(is_coarse: bool) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_colored_kinfu_Params_hashTSDFParams_bool(is_coarse, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ColoredTSDF parameters - /// A set of parameters suitable for use with HashTSDFVolume - #[inline] - pub fn colored_tsdf_params(is_coarse: bool) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_colored_kinfu_Params_coloredTSDFParams_bool(is_coarse, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for ColoredKinfu_Params { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ColoredKinfu_Params") - .field("frame_size", &crate::rgbd::ColoredKinfu_ParamsTraitConst::frame_size(self)) - .field("rgb_frame_size", &crate::rgbd::ColoredKinfu_ParamsTraitConst::rgb_frame_size(self)) - .field("volume_type", &crate::rgbd::ColoredKinfu_ParamsTraitConst::volume_type(self)) - .field("intr", &crate::rgbd::ColoredKinfu_ParamsTraitConst::intr(self)) - .field("rgb_intr", &crate::rgbd::ColoredKinfu_ParamsTraitConst::rgb_intr(self)) - .field("depth_factor", &crate::rgbd::ColoredKinfu_ParamsTraitConst::depth_factor(self)) - .field("bilateral_sigma_depth", &crate::rgbd::ColoredKinfu_ParamsTraitConst::bilateral_sigma_depth(self)) - .field("bilateral_sigma_spatial", &crate::rgbd::ColoredKinfu_ParamsTraitConst::bilateral_sigma_spatial(self)) - .field("bilateral_kernel_size", &crate::rgbd::ColoredKinfu_ParamsTraitConst::bilateral_kernel_size(self)) - .field("pyramid_levels", &crate::rgbd::ColoredKinfu_ParamsTraitConst::pyramid_levels(self)) - .field("volume_dims", &crate::rgbd::ColoredKinfu_ParamsTraitConst::volume_dims(self)) - .field("voxel_size", &crate::rgbd::ColoredKinfu_ParamsTraitConst::voxel_size(self)) - .field("tsdf_min_camera_movement", &crate::rgbd::ColoredKinfu_ParamsTraitConst::tsdf_min_camera_movement(self)) - .field("volume_pose", &crate::rgbd::ColoredKinfu_ParamsTraitConst::volume_pose(self)) - .field("tsdf_trunc_dist", &crate::rgbd::ColoredKinfu_ParamsTraitConst::tsdf_trunc_dist(self)) - .field("tsdf_max_weight", &crate::rgbd::ColoredKinfu_ParamsTraitConst::tsdf_max_weight(self)) - .field("raycast_step_factor", &crate::rgbd::ColoredKinfu_ParamsTraitConst::raycast_step_factor(self)) - .field("light_pose", &crate::rgbd::ColoredKinfu_ParamsTraitConst::light_pose(self)) - .field("icp_dist_thresh", &crate::rgbd::ColoredKinfu_ParamsTraitConst::icp_dist_thresh(self)) - .field("icp_angle_thresh", &crate::rgbd::ColoredKinfu_ParamsTraitConst::icp_angle_thresh(self)) - .field("icp_iterations", &crate::rgbd::ColoredKinfu_ParamsTraitConst::icp_iterations(self)) - .field("truncate_threshold", &crate::rgbd::ColoredKinfu_ParamsTraitConst::truncate_threshold(self)) - .finish() - } } /// Constant methods for [crate::rgbd::Dynafu_DynaFu] @@ -1498,21 +1526,14 @@ pub mod rgbd { } - pub struct Dynafu_DynaFu { - ptr: *mut c_void, - } - - opencv_type_boxed! { Dynafu_DynaFu } - - impl Drop for Dynafu_DynaFu { + impl std::fmt::Debug for Dynafu_DynaFu { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_dynafu_DynaFu_delete(self.as_raw_mut_Dynafu_DynaFu()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Dynafu_DynaFu") + .finish() } } - unsafe impl Send for Dynafu_DynaFu {} - impl crate::rgbd::Dynafu_DynaFuTraitConst for Dynafu_DynaFu { #[inline] fn as_raw_Dynafu_DynaFu(&self) -> *const c_void { self.as_raw() } } @@ -1523,27 +1544,6 @@ pub mod rgbd { boxed_ref! { Dynafu_DynaFu, crate::rgbd::Dynafu_DynaFuTraitConst, as_raw_Dynafu_DynaFu, crate::rgbd::Dynafu_DynaFuTrait, as_raw_mut_Dynafu_DynaFu } - impl Dynafu_DynaFu { - #[inline] - pub fn create(_params: &core::Ptr) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_dynafu_DynaFu_create_const_PtrLParamsGR(_params.as_raw_PtrOfKinfu_Params(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for Dynafu_DynaFu { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Dynafu_DynaFu") - .finish() - } - } - #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] pub struct Kinfu_Intr { @@ -1679,6 +1679,57 @@ pub mod rgbd { } + /// KinectFusion implementation + /// + /// This class implements a 3d reconstruction algorithm described in + /// [kinectfusion](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_kinectfusion) paper. + /// + /// It takes a sequence of depth images taken from depth sensor + /// (or any depth images source such as stereo camera matching algorithm or even raymarching renderer). + /// The output can be obtained as a vector of points and their normals + /// or can be Phong-rendered from given camera pose. + /// + /// An internal representation of a model is a voxel cuboid that keeps TSDF values + /// which are a sort of distances to the surface (for details read the [kinectfusion](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_kinectfusion) article about TSDF). + /// There is no interface to that representation yet. + /// + /// KinFu uses OpenCL acceleration automatically if available. + /// To enable or disable it explicitly use cv::setUseOptimized() or cv::ocl::setUseOpenCL(). + /// + /// This implementation is based on [kinfu-remake](https://github.com/Nerei/kinfu_remake). + /// + /// Note that the KinectFusion algorithm was patented and its use may be restricted by + /// the list of patents mentioned in README.md file in this module directory. + /// + /// That's why you need to set the OPENCV_ENABLE_NONFREE option in CMake to use KinectFusion. + pub struct Kinfu_KinFu { + ptr: *mut c_void, + } + + opencv_type_boxed! { Kinfu_KinFu } + + impl Drop for Kinfu_KinFu { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_kinfu_KinFu_delete(self.as_raw_mut_Kinfu_KinFu()) }; + } + } + + unsafe impl Send for Kinfu_KinFu {} + + impl Kinfu_KinFu { + #[inline] + pub fn create(_params: &core::Ptr) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_kinfu_KinFu_create_const_PtrLParamsGR(_params.as_raw_PtrOfKinfu_Params(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::rgbd::Kinfu_KinFu] pub trait Kinfu_KinFuTraitConst { fn as_raw_Kinfu_KinFu(&self) -> *const c_void; @@ -1829,44 +1880,14 @@ pub mod rgbd { } - /// KinectFusion implementation - /// - /// This class implements a 3d reconstruction algorithm described in - /// [kinectfusion](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_kinectfusion) paper. - /// - /// It takes a sequence of depth images taken from depth sensor - /// (or any depth images source such as stereo camera matching algorithm or even raymarching renderer). - /// The output can be obtained as a vector of points and their normals - /// or can be Phong-rendered from given camera pose. - /// - /// An internal representation of a model is a voxel cuboid that keeps TSDF values - /// which are a sort of distances to the surface (for details read the [kinectfusion](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_kinectfusion) article about TSDF). - /// There is no interface to that representation yet. - /// - /// KinFu uses OpenCL acceleration automatically if available. - /// To enable or disable it explicitly use cv::setUseOptimized() or cv::ocl::setUseOpenCL(). - /// - /// This implementation is based on [kinfu-remake](https://github.com/Nerei/kinfu_remake). - /// - /// Note that the KinectFusion algorithm was patented and its use may be restricted by - /// the list of patents mentioned in README.md file in this module directory. - /// - /// That's why you need to set the OPENCV_ENABLE_NONFREE option in CMake to use KinectFusion. - pub struct Kinfu_KinFu { - ptr: *mut c_void, - } - - opencv_type_boxed! { Kinfu_KinFu } - - impl Drop for Kinfu_KinFu { + impl std::fmt::Debug for Kinfu_KinFu { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_kinfu_KinFu_delete(self.as_raw_mut_Kinfu_KinFu()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Kinfu_KinFu") + .finish() } } - unsafe impl Send for Kinfu_KinFu {} - impl crate::rgbd::Kinfu_KinFuTraitConst for Kinfu_KinFu { #[inline] fn as_raw_Kinfu_KinFu(&self) -> *const c_void { self.as_raw() } } @@ -1877,32 +1898,117 @@ pub mod rgbd { boxed_ref! { Kinfu_KinFu, crate::rgbd::Kinfu_KinFuTraitConst, as_raw_Kinfu_KinFu, crate::rgbd::Kinfu_KinFuTrait, as_raw_mut_Kinfu_KinFu } - impl Kinfu_KinFu { - #[inline] - pub fn create(_params: &core::Ptr) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_kinfu_KinFu_create_const_PtrLParamsGR(_params.as_raw_PtrOfKinfu_Params(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + pub struct Kinfu_Params { + ptr: *mut c_void, } - impl std::fmt::Debug for Kinfu_KinFu { + opencv_type_boxed! { Kinfu_Params } + + impl Drop for Kinfu_Params { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Kinfu_KinFu") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_kinfu_Params_delete(self.as_raw_mut_Kinfu_Params()) }; } } - /// Constant methods for [crate::rgbd::Kinfu_Params] - pub trait Kinfu_ParamsTraitConst { - fn as_raw_Kinfu_Params(&self) -> *const c_void; + unsafe impl Send for Kinfu_Params {} - /// frame size in pixels + impl Kinfu_Params { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_kinfu_Params_Params(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::rgbd::Kinfu_Params::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Constructor for Params + /// Sets the initial pose of the TSDF volume. + /// ## Parameters + /// * volumeInitialPoseRot: rotation matrix + /// * volumeInitialPoseTransl: translation vector + #[inline] + pub fn new(volume_initial_pose_rot: core::Matx33f, volume_initial_pose_transl: core::Vec3f) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_kinfu_Params_Params_Matx33f_Vec3f(&volume_initial_pose_rot, &volume_initial_pose_transl, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::rgbd::Kinfu_Params::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Constructor for Params + /// Sets the initial pose of the TSDF volume. + /// ## Parameters + /// * volumeInitialPose: 4 by 4 Homogeneous Transform matrix to set the intial pose of TSDF volume + #[inline] + pub fn new_1(volume_initial_pose: core::Matx44f) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_kinfu_Params_Params_Matx44f(&volume_initial_pose, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::rgbd::Kinfu_Params::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Default parameters + /// A set of parameters which provides better model quality, can be very slow. + #[inline] + pub fn default_params() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_kinfu_Params_defaultParams(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Coarse parameters + /// A set of parameters which provides better speed, can fail to match frames + /// in case of rapid sensor motion. + #[inline] + pub fn coarse_params() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_kinfu_Params_coarseParams(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// HashTSDF parameters + /// A set of parameters suitable for use with HashTSDFVolume + #[inline] + pub fn hash_tsdf_params(is_coarse: bool) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_kinfu_Params_hashTSDFParams_bool(is_coarse, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ColoredTSDF parameters + /// A set of parameters suitable for use with ColoredTSDFVolume + #[inline] + pub fn colored_tsdf_params(is_coarse: bool) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_kinfu_Params_coloredTSDFParams_bool(is_coarse, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::rgbd::Kinfu_Params] + pub trait Kinfu_ParamsTraitConst { + fn as_raw_Kinfu_Params(&self) -> *const c_void; + + /// frame size in pixels #[inline] fn frame_size(&self) -> core::Size { return_send!(via ocvrs_return); @@ -2280,122 +2386,6 @@ pub mod rgbd { } - pub struct Kinfu_Params { - ptr: *mut c_void, - } - - opencv_type_boxed! { Kinfu_Params } - - impl Drop for Kinfu_Params { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_kinfu_Params_delete(self.as_raw_mut_Kinfu_Params()) }; - } - } - - unsafe impl Send for Kinfu_Params {} - - impl crate::rgbd::Kinfu_ParamsTraitConst for Kinfu_Params { - #[inline] fn as_raw_Kinfu_Params(&self) -> *const c_void { self.as_raw() } - } - - impl crate::rgbd::Kinfu_ParamsTrait for Kinfu_Params { - #[inline] fn as_raw_mut_Kinfu_Params(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Kinfu_Params, crate::rgbd::Kinfu_ParamsTraitConst, as_raw_Kinfu_Params, crate::rgbd::Kinfu_ParamsTrait, as_raw_mut_Kinfu_Params } - - impl Kinfu_Params { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_kinfu_Params_Params(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::Kinfu_Params::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Constructor for Params - /// Sets the initial pose of the TSDF volume. - /// ## Parameters - /// * volumeInitialPoseRot: rotation matrix - /// * volumeInitialPoseTransl: translation vector - #[inline] - pub fn new(volume_initial_pose_rot: core::Matx33f, volume_initial_pose_transl: core::Vec3f) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_kinfu_Params_Params_Matx33f_Vec3f(&volume_initial_pose_rot, &volume_initial_pose_transl, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::Kinfu_Params::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Constructor for Params - /// Sets the initial pose of the TSDF volume. - /// ## Parameters - /// * volumeInitialPose: 4 by 4 Homogeneous Transform matrix to set the intial pose of TSDF volume - #[inline] - pub fn new_1(volume_initial_pose: core::Matx44f) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_kinfu_Params_Params_Matx44f(&volume_initial_pose, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::Kinfu_Params::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Default parameters - /// A set of parameters which provides better model quality, can be very slow. - #[inline] - pub fn default_params() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_kinfu_Params_defaultParams(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Coarse parameters - /// A set of parameters which provides better speed, can fail to match frames - /// in case of rapid sensor motion. - #[inline] - pub fn coarse_params() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_kinfu_Params_coarseParams(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// HashTSDF parameters - /// A set of parameters suitable for use with HashTSDFVolume - #[inline] - pub fn hash_tsdf_params(is_coarse: bool) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_kinfu_Params_hashTSDFParams_bool(is_coarse, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ColoredTSDF parameters - /// A set of parameters suitable for use with ColoredTSDFVolume - #[inline] - pub fn colored_tsdf_params(is_coarse: bool) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_kinfu_Params_coloredTSDFParams_bool(is_coarse, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - impl std::fmt::Debug for Kinfu_Params { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -2425,6 +2415,31 @@ pub mod rgbd { } } + impl crate::rgbd::Kinfu_ParamsTraitConst for Kinfu_Params { + #[inline] fn as_raw_Kinfu_Params(&self) -> *const c_void { self.as_raw() } + } + + impl crate::rgbd::Kinfu_ParamsTrait for Kinfu_Params { + #[inline] fn as_raw_mut_Kinfu_Params(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Kinfu_Params, crate::rgbd::Kinfu_ParamsTraitConst, as_raw_Kinfu_Params, crate::rgbd::Kinfu_ParamsTrait, as_raw_mut_Kinfu_Params } + + pub struct Kinfu_Volume { + ptr: *mut c_void, + } + + opencv_type_boxed! { Kinfu_Volume } + + impl Drop for Kinfu_Volume { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_kinfu_Volume_delete(self.as_raw_mut_Kinfu_Volume()) }; + } + } + + unsafe impl Send for Kinfu_Volume {} + /// Constant methods for [crate::rgbd::Kinfu_Volume] pub trait Kinfu_VolumeTraitConst { fn as_raw_Kinfu_Volume(&self) -> *const c_void; @@ -2581,21 +2596,18 @@ pub mod rgbd { } - pub struct Kinfu_Volume { - ptr: *mut c_void, - } - - opencv_type_boxed! { Kinfu_Volume } - - impl Drop for Kinfu_Volume { + impl std::fmt::Debug for Kinfu_Volume { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_kinfu_Volume_delete(self.as_raw_mut_Kinfu_Volume()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Kinfu_Volume") + .field("voxel_size", &crate::rgbd::Kinfu_VolumeTraitConst::voxel_size(self)) + .field("voxel_size_inv", &crate::rgbd::Kinfu_VolumeTraitConst::voxel_size_inv(self)) + .field("pose", &crate::rgbd::Kinfu_VolumeTraitConst::pose(self)) + .field("raycast_step_factor", &crate::rgbd::Kinfu_VolumeTraitConst::raycast_step_factor(self)) + .finish() } } - unsafe impl Send for Kinfu_Volume {} - impl crate::rgbd::Kinfu_VolumeTraitConst for Kinfu_Volume { #[inline] fn as_raw_Kinfu_Volume(&self) -> *const c_void { self.as_raw() } } @@ -2606,19 +2618,54 @@ pub mod rgbd { boxed_ref! { Kinfu_Volume, crate::rgbd::Kinfu_VolumeTraitConst, as_raw_Kinfu_Volume, crate::rgbd::Kinfu_VolumeTrait, as_raw_mut_Kinfu_Volume } - impl Kinfu_Volume { + pub struct Kinfu_VolumeParams { + ptr: *mut c_void, } - impl std::fmt::Debug for Kinfu_Volume { + opencv_type_boxed! { Kinfu_VolumeParams } + + impl Drop for Kinfu_VolumeParams { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Kinfu_Volume") - .field("voxel_size", &crate::rgbd::Kinfu_VolumeTraitConst::voxel_size(self)) - .field("voxel_size_inv", &crate::rgbd::Kinfu_VolumeTraitConst::voxel_size_inv(self)) - .field("pose", &crate::rgbd::Kinfu_VolumeTraitConst::pose(self)) - .field("raycast_step_factor", &crate::rgbd::Kinfu_VolumeTraitConst::raycast_step_factor(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_kinfu_VolumeParams_delete(self.as_raw_mut_Kinfu_VolumeParams()) }; + } + } + + unsafe impl Send for Kinfu_VolumeParams {} + + impl Kinfu_VolumeParams { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::rgbd::Kinfu_VolumeParams { + let ret = unsafe { sys::cv_kinfu_VolumeParams_defaultNew_const() }; + let ret = unsafe { crate::rgbd::Kinfu_VolumeParams::opencv_from_extern(ret) }; + ret + } + + /// Default set of parameters that provide higher quality reconstruction + /// at the cost of slow performance. + #[inline] + pub fn default_params(_volume_type: crate::rgbd::Kinfu_VolumeType) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_kinfu_VolumeParams_defaultParams_VolumeType(_volume_type, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Coarse set of parameters that provides relatively higher performance + /// at the cost of reconstrution quality. + #[inline] + pub fn coarse_params(_volume_type: crate::rgbd::Kinfu_VolumeType) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_kinfu_VolumeParams_coarseParams_VolumeType(_volume_type, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::rgbd::Kinfu_VolumeParams] @@ -2790,21 +2837,31 @@ pub mod rgbd { } - pub struct Kinfu_VolumeParams { - ptr: *mut c_void, + impl Default for Kinfu_VolumeParams { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Kinfu_VolumeParams } - - impl Drop for Kinfu_VolumeParams { + impl std::fmt::Debug for Kinfu_VolumeParams { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_kinfu_VolumeParams_delete(self.as_raw_mut_Kinfu_VolumeParams()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Kinfu_VolumeParams") + .field("typ", &crate::rgbd::Kinfu_VolumeParamsTraitConst::typ(self)) + .field("resolution", &crate::rgbd::Kinfu_VolumeParamsTraitConst::resolution(self)) + .field("unit_resolution", &crate::rgbd::Kinfu_VolumeParamsTraitConst::unit_resolution(self)) + .field("pose", &crate::rgbd::Kinfu_VolumeParamsTraitConst::pose(self)) + .field("voxel_size", &crate::rgbd::Kinfu_VolumeParamsTraitConst::voxel_size(self)) + .field("tsdf_trunc_dist", &crate::rgbd::Kinfu_VolumeParamsTraitConst::tsdf_trunc_dist(self)) + .field("max_weight", &crate::rgbd::Kinfu_VolumeParamsTraitConst::max_weight(self)) + .field("depth_trunc_threshold", &crate::rgbd::Kinfu_VolumeParamsTraitConst::depth_trunc_threshold(self)) + .field("raycast_step_factor", &crate::rgbd::Kinfu_VolumeParamsTraitConst::raycast_step_factor(self)) + .finish() } } - unsafe impl Send for Kinfu_VolumeParams {} - impl crate::rgbd::Kinfu_VolumeParamsTraitConst for Kinfu_VolumeParams { #[inline] fn as_raw_Kinfu_VolumeParams(&self) -> *const c_void { self.as_raw() } } @@ -2815,64 +2872,34 @@ pub mod rgbd { boxed_ref! { Kinfu_VolumeParams, crate::rgbd::Kinfu_VolumeParamsTraitConst, as_raw_Kinfu_VolumeParams, crate::rgbd::Kinfu_VolumeParamsTrait, as_raw_mut_Kinfu_VolumeParams } - impl Kinfu_VolumeParams { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_kinfu_VolumeParams_defaultNew_const()) } - } + pub struct Kinfu_Detail_PoseGraph { + ptr: *mut c_void, + } - /// Default set of parameters that provide higher quality reconstruction - /// at the cost of slow performance. + opencv_type_boxed! { Kinfu_Detail_PoseGraph } + + impl Drop for Kinfu_Detail_PoseGraph { #[inline] - pub fn default_params(_volume_type: crate::rgbd::Kinfu_VolumeType) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_kinfu_VolumeParams_defaultParams_VolumeType(_volume_type, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_kinfu_detail_PoseGraph_delete(self.as_raw_mut_Kinfu_Detail_PoseGraph()) }; } + } - /// Coarse set of parameters that provides relatively higher performance - /// at the cost of reconstrution quality. + unsafe impl Send for Kinfu_Detail_PoseGraph {} + + impl Kinfu_Detail_PoseGraph { #[inline] - pub fn coarse_params(_volume_type: crate::rgbd::Kinfu_VolumeType) -> Result> { + pub fn create() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_kinfu_VolumeParams_coarseParams_VolumeType(_volume_type, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_kinfu_detail_PoseGraph_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for Kinfu_VolumeParams { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Kinfu_VolumeParams") - .field("typ", &crate::rgbd::Kinfu_VolumeParamsTraitConst::typ(self)) - .field("resolution", &crate::rgbd::Kinfu_VolumeParamsTraitConst::resolution(self)) - .field("unit_resolution", &crate::rgbd::Kinfu_VolumeParamsTraitConst::unit_resolution(self)) - .field("pose", &crate::rgbd::Kinfu_VolumeParamsTraitConst::pose(self)) - .field("voxel_size", &crate::rgbd::Kinfu_VolumeParamsTraitConst::voxel_size(self)) - .field("tsdf_trunc_dist", &crate::rgbd::Kinfu_VolumeParamsTraitConst::tsdf_trunc_dist(self)) - .field("max_weight", &crate::rgbd::Kinfu_VolumeParamsTraitConst::max_weight(self)) - .field("depth_trunc_threshold", &crate::rgbd::Kinfu_VolumeParamsTraitConst::depth_trunc_threshold(self)) - .field("raycast_step_factor", &crate::rgbd::Kinfu_VolumeParamsTraitConst::raycast_step_factor(self)) - .finish() - } - } - - impl Default for Kinfu_VolumeParams { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - /// Constant methods for [crate::rgbd::Kinfu_Detail_PoseGraph] pub trait Kinfu_Detail_PoseGraphTraitConst { fn as_raw_Kinfu_Detail_PoseGraph(&self) -> *const c_void; @@ -3040,21 +3067,14 @@ pub mod rgbd { } - pub struct Kinfu_Detail_PoseGraph { - ptr: *mut c_void, - } - - opencv_type_boxed! { Kinfu_Detail_PoseGraph } - - impl Drop for Kinfu_Detail_PoseGraph { + impl std::fmt::Debug for Kinfu_Detail_PoseGraph { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_kinfu_detail_PoseGraph_delete(self.as_raw_mut_Kinfu_Detail_PoseGraph()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Kinfu_Detail_PoseGraph") + .finish() } } - unsafe impl Send for Kinfu_Detail_PoseGraph {} - impl crate::rgbd::Kinfu_Detail_PoseGraphTraitConst for Kinfu_Detail_PoseGraph { #[inline] fn as_raw_Kinfu_Detail_PoseGraph(&self) -> *const c_void { self.as_raw() } } @@ -3065,27 +3085,63 @@ pub mod rgbd { boxed_ref! { Kinfu_Detail_PoseGraph, crate::rgbd::Kinfu_Detail_PoseGraphTraitConst, as_raw_Kinfu_Detail_PoseGraph, crate::rgbd::Kinfu_Detail_PoseGraphTrait, as_raw_mut_Kinfu_Detail_PoseGraph } - impl Kinfu_Detail_PoseGraph { + /// Large Scale Dense Depth Fusion implementation + /// + /// This class implements a 3d reconstruction algorithm for larger environments using + /// Spatially hashed TSDF volume "Submaps". + /// It also runs a periodic posegraph optimization to minimize drift in tracking over long sequences. + /// Currently the algorithm does not implement a relocalization or loop closure module. + /// Potentially a Bag of words implementation or RGBD relocalization as described in + /// Glocker et al. ISMAR 2013 will be implemented + /// + /// It takes a sequence of depth images taken from depth sensor + /// (or any depth images source such as stereo camera matching algorithm or even raymarching + /// renderer). The output can be obtained as a vector of points and their normals or can be + /// Phong-rendered from given camera pose. + /// + /// An internal representation of a model is a spatially hashed voxel cube that stores TSDF values + /// which represent the distance to the closest surface (for details read the [kinectfusion](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_kinectfusion) article + /// about TSDF). There is no interface to that representation yet. + /// + /// For posegraph optimization, a Submap abstraction over the Volume class is created. + /// New submaps are added to the model when there is low visibility overlap between current viewing frustrum + /// and the existing volume/model. Multiple submaps are simultaneously tracked and a posegraph is created and + /// optimized periodically. + /// + /// LargeKinfu does not use any OpenCL acceleration yet. + /// To enable or disable it explicitly use cv::setUseOptimized() or cv::ocl::setUseOpenCL(). + /// + /// This implementation is inspired from Kintinuous, InfiniTAM and other SOTA algorithms + /// + /// You need to set the OPENCV_ENABLE_NONFREE option in CMake to use KinectFusion. + pub struct LargeKinfu { + ptr: *mut c_void, + } + + opencv_type_boxed! { LargeKinfu } + + impl Drop for LargeKinfu { #[inline] - pub fn create() -> Result> { + fn drop(&mut self) { + unsafe { sys::cv_large_kinfu_LargeKinfu_delete(self.as_raw_mut_LargeKinfu()) }; + } + } + + unsafe impl Send for LargeKinfu {} + + impl LargeKinfu { + #[inline] + pub fn create(_params: &core::Ptr) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_kinfu_detail_PoseGraph_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_large_kinfu_LargeKinfu_create_const_PtrLParamsGR(_params.as_raw_PtrOfParams(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for Kinfu_Detail_PoseGraph { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Kinfu_Detail_PoseGraph") - .finish() - } - } - /// Constant methods for [crate::rgbd::LargeKinfu] pub trait LargeKinfuTraitConst { fn as_raw_LargeKinfu(&self) -> *const c_void; @@ -3188,50 +3244,14 @@ pub mod rgbd { } - /// Large Scale Dense Depth Fusion implementation - /// - /// This class implements a 3d reconstruction algorithm for larger environments using - /// Spatially hashed TSDF volume "Submaps". - /// It also runs a periodic posegraph optimization to minimize drift in tracking over long sequences. - /// Currently the algorithm does not implement a relocalization or loop closure module. - /// Potentially a Bag of words implementation or RGBD relocalization as described in - /// Glocker et al. ISMAR 2013 will be implemented - /// - /// It takes a sequence of depth images taken from depth sensor - /// (or any depth images source such as stereo camera matching algorithm or even raymarching - /// renderer). The output can be obtained as a vector of points and their normals or can be - /// Phong-rendered from given camera pose. - /// - /// An internal representation of a model is a spatially hashed voxel cube that stores TSDF values - /// which represent the distance to the closest surface (for details read the [kinectfusion](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_kinectfusion) article - /// about TSDF). There is no interface to that representation yet. - /// - /// For posegraph optimization, a Submap abstraction over the Volume class is created. - /// New submaps are added to the model when there is low visibility overlap between current viewing frustrum - /// and the existing volume/model. Multiple submaps are simultaneously tracked and a posegraph is created and - /// optimized periodically. - /// - /// LargeKinfu does not use any OpenCL acceleration yet. - /// To enable or disable it explicitly use cv::setUseOptimized() or cv::ocl::setUseOpenCL(). - /// - /// This implementation is inspired from Kintinuous, InfiniTAM and other SOTA algorithms - /// - /// You need to set the OPENCV_ENABLE_NONFREE option in CMake to use KinectFusion. - pub struct LargeKinfu { - ptr: *mut c_void, - } - - opencv_type_boxed! { LargeKinfu } - - impl Drop for LargeKinfu { + impl std::fmt::Debug for LargeKinfu { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_large_kinfu_LargeKinfu_delete(self.as_raw_mut_LargeKinfu()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LargeKinfu") + .finish() } } - unsafe impl Send for LargeKinfu {} - impl crate::rgbd::LargeKinfuTraitConst for LargeKinfu { #[inline] fn as_raw_LargeKinfu(&self) -> *const c_void { self.as_raw() } } @@ -3242,25 +3262,67 @@ pub mod rgbd { boxed_ref! { LargeKinfu, crate::rgbd::LargeKinfuTraitConst, as_raw_LargeKinfu, crate::rgbd::LargeKinfuTrait, as_raw_mut_LargeKinfu } - impl LargeKinfu { + pub struct Params { + ptr: *mut c_void, + } + + opencv_type_boxed! { Params } + + impl Drop for Params { #[inline] - pub fn create(_params: &core::Ptr) -> Result> { + fn drop(&mut self) { + unsafe { sys::cv_large_kinfu_Params_delete(self.as_raw_mut_Params()) }; + } + } + + unsafe impl Send for Params {} + + impl Params { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::rgbd::Params { + let ret = unsafe { sys::cv_large_kinfu_Params_defaultNew_const() }; + let ret = unsafe { crate::rgbd::Params::opencv_from_extern(ret) }; + ret + } + + /// Default parameters + /// A set of parameters which provides better model quality, can be very slow. + #[inline] + pub fn default_params() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_large_kinfu_LargeKinfu_create_const_PtrLParamsGR(_params.as_raw_PtrOfParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_large_kinfu_Params_defaultParams(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - } + /// Coarse parameters + /// A set of parameters which provides better speed, can fail to match frames + /// in case of rapid sensor motion. + #[inline] + pub fn coarse_params() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_large_kinfu_Params_coarseParams(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for LargeKinfu { + /// HashTSDF parameters + /// A set of parameters suitable for use with HashTSDFVolume #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LargeKinfu") - .finish() + pub fn hash_tsdf_params(is_coarse: bool) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_large_kinfu_Params_hashTSDFParams_bool(is_coarse, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::rgbd::Params] @@ -3507,21 +3569,37 @@ pub mod rgbd { } - pub struct Params { - ptr: *mut c_void, + impl Default for Params { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Params } - - impl Drop for Params { + impl std::fmt::Debug for Params { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_large_kinfu_Params_delete(self.as_raw_mut_Params()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Params") + .field("frame_size", &crate::rgbd::ParamsTraitConst::frame_size(self)) + .field("intr", &crate::rgbd::ParamsTraitConst::intr(self)) + .field("rgb_intr", &crate::rgbd::ParamsTraitConst::rgb_intr(self)) + .field("depth_factor", &crate::rgbd::ParamsTraitConst::depth_factor(self)) + .field("bilateral_sigma_depth", &crate::rgbd::ParamsTraitConst::bilateral_sigma_depth(self)) + .field("bilateral_sigma_spatial", &crate::rgbd::ParamsTraitConst::bilateral_sigma_spatial(self)) + .field("bilateral_kernel_size", &crate::rgbd::ParamsTraitConst::bilateral_kernel_size(self)) + .field("pyramid_levels", &crate::rgbd::ParamsTraitConst::pyramid_levels(self)) + .field("tsdf_min_camera_movement", &crate::rgbd::ParamsTraitConst::tsdf_min_camera_movement(self)) + .field("light_pose", &crate::rgbd::ParamsTraitConst::light_pose(self)) + .field("icp_dist_thresh", &crate::rgbd::ParamsTraitConst::icp_dist_thresh(self)) + .field("icp_angle_thresh", &crate::rgbd::ParamsTraitConst::icp_angle_thresh(self)) + .field("icp_iterations", &crate::rgbd::ParamsTraitConst::icp_iterations(self)) + .field("truncate_threshold", &crate::rgbd::ParamsTraitConst::truncate_threshold(self)) + .field("volume_params", &crate::rgbd::ParamsTraitConst::volume_params(self)) + .finish() } } - unsafe impl Send for Params {} - impl crate::rgbd::ParamsTraitConst for Params { #[inline] fn as_raw_Params(&self) -> *const c_void { self.as_raw() } } @@ -3532,83 +3610,62 @@ pub mod rgbd { boxed_ref! { Params, crate::rgbd::ParamsTraitConst, as_raw_Params, crate::rgbd::ParamsTrait, as_raw_mut_Params } - impl Params { - /// Creates a default instance of the class by calling the default constructor + /// \brief Modality that computes quantized gradient orientations from a color image. + pub struct LineMod_ColorGradient { + ptr: *mut c_void, + } + + opencv_type_boxed! { LineMod_ColorGradient } + + impl Drop for LineMod_ColorGradient { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_large_kinfu_Params_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_linemod_ColorGradient_delete(self.as_raw_mut_LineMod_ColorGradient()) }; } + } - /// Default parameters - /// A set of parameters which provides better model quality, can be very slow. + unsafe impl Send for LineMod_ColorGradient {} + + impl LineMod_ColorGradient { + /// \brief Default constructor. Uses reasonable default parameter values. #[inline] - pub fn default_params() -> Result> { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_large_kinfu_Params_defaultParams(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_linemod_ColorGradient_ColorGradient(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::LineMod_ColorGradient::opencv_from_extern(ret) }; Ok(ret) } - /// Coarse parameters - /// A set of parameters which provides better speed, can fail to match frames - /// in case of rapid sensor motion. + /// \brief Constructor. + /// + /// \param weak_threshold When quantizing, discard gradients with magnitude less than this. + /// \param num_features How many features a template must contain. + /// \param strong_threshold Consider as candidate features only gradients whose norms are + /// larger than this. #[inline] - pub fn coarse_params() -> Result> { + pub fn new(weak_threshold: f32, num_features: size_t, strong_threshold: f32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_large_kinfu_Params_coarseParams(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_linemod_ColorGradient_ColorGradient_float_size_t_float(weak_threshold, num_features, strong_threshold, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::LineMod_ColorGradient::opencv_from_extern(ret) }; Ok(ret) } - /// HashTSDF parameters - /// A set of parameters suitable for use with HashTSDFVolume #[inline] - pub fn hash_tsdf_params(is_coarse: bool) -> Result> { + pub fn create(weak_threshold: f32, num_features: size_t, strong_threshold: f32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_large_kinfu_Params_hashTSDFParams_bool(is_coarse, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_linemod_ColorGradient_create_float_size_t_float(weak_threshold, num_features, strong_threshold, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for Params { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Params") - .field("frame_size", &crate::rgbd::ParamsTraitConst::frame_size(self)) - .field("intr", &crate::rgbd::ParamsTraitConst::intr(self)) - .field("rgb_intr", &crate::rgbd::ParamsTraitConst::rgb_intr(self)) - .field("depth_factor", &crate::rgbd::ParamsTraitConst::depth_factor(self)) - .field("bilateral_sigma_depth", &crate::rgbd::ParamsTraitConst::bilateral_sigma_depth(self)) - .field("bilateral_sigma_spatial", &crate::rgbd::ParamsTraitConst::bilateral_sigma_spatial(self)) - .field("bilateral_kernel_size", &crate::rgbd::ParamsTraitConst::bilateral_kernel_size(self)) - .field("pyramid_levels", &crate::rgbd::ParamsTraitConst::pyramid_levels(self)) - .field("tsdf_min_camera_movement", &crate::rgbd::ParamsTraitConst::tsdf_min_camera_movement(self)) - .field("light_pose", &crate::rgbd::ParamsTraitConst::light_pose(self)) - .field("icp_dist_thresh", &crate::rgbd::ParamsTraitConst::icp_dist_thresh(self)) - .field("icp_angle_thresh", &crate::rgbd::ParamsTraitConst::icp_angle_thresh(self)) - .field("icp_iterations", &crate::rgbd::ParamsTraitConst::icp_iterations(self)) - .field("truncate_threshold", &crate::rgbd::ParamsTraitConst::truncate_threshold(self)) - .field("volume_params", &crate::rgbd::ParamsTraitConst::volume_params(self)) - .finish() - } - } - - impl Default for Params { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - /// Constant methods for [crate::rgbd::LineMod_ColorGradient] pub trait LineMod_ColorGradientTraitConst: crate::rgbd::LineMod_ModalityTraitConst { fn as_raw_LineMod_ColorGradient(&self) -> *const c_void; @@ -3685,21 +3742,18 @@ pub mod rgbd { } - /// \brief Modality that computes quantized gradient orientations from a color image. - pub struct LineMod_ColorGradient { - ptr: *mut c_void, - } - - opencv_type_boxed! { LineMod_ColorGradient } - - impl Drop for LineMod_ColorGradient { + impl std::fmt::Debug for LineMod_ColorGradient { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_linemod_ColorGradient_delete(self.as_raw_mut_LineMod_ColorGradient()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LineMod_ColorGradient") + .field("weak_threshold", &crate::rgbd::LineMod_ColorGradientTraitConst::weak_threshold(self)) + .field("num_features", &crate::rgbd::LineMod_ColorGradientTraitConst::num_features(self)) + .field("strong_threshold", &crate::rgbd::LineMod_ColorGradientTraitConst::strong_threshold(self)) + .finish() } } - unsafe impl Send for LineMod_ColorGradient {} + boxed_cast_base! { LineMod_ColorGradient, crate::rgbd::LineMod_Modality, cv_linemod_ColorGradient_to_LineMod_Modality } impl crate::rgbd::LineMod_ModalityTraitConst for LineMod_ColorGradient { #[inline] fn as_raw_LineMod_Modality(&self) -> *const c_void { self.as_raw() } @@ -3721,59 +3775,64 @@ pub mod rgbd { boxed_ref! { LineMod_ColorGradient, crate::rgbd::LineMod_ColorGradientTraitConst, as_raw_LineMod_ColorGradient, crate::rgbd::LineMod_ColorGradientTrait, as_raw_mut_LineMod_ColorGradient } - impl LineMod_ColorGradient { + /// \brief Modality that computes quantized surface normals from a dense depth map. + pub struct LineMod_DepthNormal { + ptr: *mut c_void, + } + + opencv_type_boxed! { LineMod_DepthNormal } + + impl Drop for LineMod_DepthNormal { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_linemod_DepthNormal_delete(self.as_raw_mut_LineMod_DepthNormal()) }; + } + } + + unsafe impl Send for LineMod_DepthNormal {} + + impl LineMod_DepthNormal { /// \brief Default constructor. Uses reasonable default parameter values. #[inline] - pub fn default() -> Result { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_linemod_ColorGradient_ColorGradient(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_linemod_DepthNormal_DepthNormal(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::LineMod_ColorGradient::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::LineMod_DepthNormal::opencv_from_extern(ret) }; Ok(ret) } /// \brief Constructor. /// - /// \param weak_threshold When quantizing, discard gradients with magnitude less than this. - /// \param num_features How many features a template must contain. - /// \param strong_threshold Consider as candidate features only gradients whose norms are - /// larger than this. + /// \param distance_threshold Ignore pixels beyond this distance. + /// \param difference_threshold When computing normals, ignore contributions of pixels whose + /// depth difference with the central pixel is above this threshold. + /// \param num_features How many features a template must contain. + /// \param extract_threshold Consider as candidate feature only if there are no differing + /// orientations within a distance of extract_threshold. #[inline] - pub fn new(weak_threshold: f32, num_features: size_t, strong_threshold: f32) -> Result { + pub fn new(distance_threshold: i32, difference_threshold: i32, num_features: size_t, extract_threshold: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_linemod_ColorGradient_ColorGradient_float_size_t_float(weak_threshold, num_features, strong_threshold, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_linemod_DepthNormal_DepthNormal_int_int_size_t_int(distance_threshold, difference_threshold, num_features, extract_threshold, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::LineMod_ColorGradient::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::LineMod_DepthNormal::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn create(weak_threshold: f32, num_features: size_t, strong_threshold: f32) -> Result> { + pub fn create(distance_threshold: i32, difference_threshold: i32, num_features: size_t, extract_threshold: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_linemod_ColorGradient_create_float_size_t_float(weak_threshold, num_features, strong_threshold, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_linemod_DepthNormal_create_int_int_size_t_int(distance_threshold, difference_threshold, num_features, extract_threshold, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { LineMod_ColorGradient, crate::rgbd::LineMod_Modality, cv_linemod_ColorGradient_to_LineMod_Modality } - - impl std::fmt::Debug for LineMod_ColorGradient { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LineMod_ColorGradient") - .field("weak_threshold", &crate::rgbd::LineMod_ColorGradientTraitConst::weak_threshold(self)) - .field("num_features", &crate::rgbd::LineMod_ColorGradientTraitConst::num_features(self)) - .field("strong_threshold", &crate::rgbd::LineMod_ColorGradientTraitConst::strong_threshold(self)) - .finish() - } - } - /// Constant methods for [crate::rgbd::LineMod_DepthNormal] pub trait LineMod_DepthNormalTraitConst: crate::rgbd::LineMod_ModalityTraitConst { fn as_raw_LineMod_DepthNormal(&self) -> *const c_void; @@ -3862,21 +3921,19 @@ pub mod rgbd { } - /// \brief Modality that computes quantized surface normals from a dense depth map. - pub struct LineMod_DepthNormal { - ptr: *mut c_void, - } - - opencv_type_boxed! { LineMod_DepthNormal } - - impl Drop for LineMod_DepthNormal { + impl std::fmt::Debug for LineMod_DepthNormal { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_linemod_DepthNormal_delete(self.as_raw_mut_LineMod_DepthNormal()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LineMod_DepthNormal") + .field("distance_threshold", &crate::rgbd::LineMod_DepthNormalTraitConst::distance_threshold(self)) + .field("difference_threshold", &crate::rgbd::LineMod_DepthNormalTraitConst::difference_threshold(self)) + .field("num_features", &crate::rgbd::LineMod_DepthNormalTraitConst::num_features(self)) + .field("extract_threshold", &crate::rgbd::LineMod_DepthNormalTraitConst::extract_threshold(self)) + .finish() } } - unsafe impl Send for LineMod_DepthNormal {} + boxed_cast_base! { LineMod_DepthNormal, crate::rgbd::LineMod_Modality, cv_linemod_DepthNormal_to_LineMod_Modality } impl crate::rgbd::LineMod_ModalityTraitConst for LineMod_DepthNormal { #[inline] fn as_raw_LineMod_Modality(&self) -> *const c_void { self.as_raw() } @@ -3898,62 +3955,52 @@ pub mod rgbd { boxed_ref! { LineMod_DepthNormal, crate::rgbd::LineMod_DepthNormalTraitConst, as_raw_LineMod_DepthNormal, crate::rgbd::LineMod_DepthNormalTrait, as_raw_mut_LineMod_DepthNormal } - impl LineMod_DepthNormal { - /// \brief Default constructor. Uses reasonable default parameter values. + /// \brief Object detector using the LINE template matching algorithm with any set of + /// modalities. + pub struct LineMod_Detector { + ptr: *mut c_void, + } + + opencv_type_boxed! { LineMod_Detector } + + impl Drop for LineMod_Detector { #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_linemod_DepthNormal_DepthNormal(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::LineMod_DepthNormal::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_linemod_Detector_delete(self.as_raw_mut_LineMod_Detector()) }; } + } - /// \brief Constructor. - /// - /// \param distance_threshold Ignore pixels beyond this distance. - /// \param difference_threshold When computing normals, ignore contributions of pixels whose - /// depth difference with the central pixel is above this threshold. - /// \param num_features How many features a template must contain. - /// \param extract_threshold Consider as candidate feature only if there are no differing - /// orientations within a distance of extract_threshold. + unsafe impl Send for LineMod_Detector {} + + impl LineMod_Detector { + /// \brief Empty constructor, initialize with read(). #[inline] - pub fn new(distance_threshold: i32, difference_threshold: i32, num_features: size_t, extract_threshold: i32) -> Result { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_linemod_DepthNormal_DepthNormal_int_int_size_t_int(distance_threshold, difference_threshold, num_features, extract_threshold, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_linemod_Detector_Detector(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::LineMod_DepthNormal::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::LineMod_Detector::opencv_from_extern(ret) }; Ok(ret) } + /// \brief Constructor. + /// + /// \param modalities Modalities to use (color gradients, depth normals, ...). + /// \param T_pyramid Value of the sampling step T at each pyramid level. The + /// number of pyramid levels is T_pyramid.size(). #[inline] - pub fn create(distance_threshold: i32, difference_threshold: i32, num_features: size_t, extract_threshold: i32) -> Result> { + pub fn new(modalities: &core::Vector>, t_pyramid: &core::Vector) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_linemod_DepthNormal_create_int_int_size_t_int(distance_threshold, difference_threshold, num_features, extract_threshold, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_linemod_Detector_Detector_const_vectorLPtrLModalityGGR_const_vectorLintGR(modalities.as_raw_VectorOfPtrOfLineMod_Modality(), t_pyramid.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::LineMod_Detector::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { LineMod_DepthNormal, crate::rgbd::LineMod_Modality, cv_linemod_DepthNormal_to_LineMod_Modality } - - impl std::fmt::Debug for LineMod_DepthNormal { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LineMod_DepthNormal") - .field("distance_threshold", &crate::rgbd::LineMod_DepthNormalTraitConst::distance_threshold(self)) - .field("difference_threshold", &crate::rgbd::LineMod_DepthNormalTraitConst::difference_threshold(self)) - .field("num_features", &crate::rgbd::LineMod_DepthNormalTraitConst::num_features(self)) - .field("extract_threshold", &crate::rgbd::LineMod_DepthNormalTraitConst::extract_threshold(self)) - .finish() - } - } - /// Constant methods for [crate::rgbd::LineMod_Detector] pub trait LineMod_DetectorTraitConst { fn as_raw_LineMod_Detector(&self) -> *const c_void; @@ -4265,23 +4312,14 @@ pub mod rgbd { } - /// \brief Object detector using the LINE template matching algorithm with any set of - /// modalities. - pub struct LineMod_Detector { - ptr: *mut c_void, - } - - opencv_type_boxed! { LineMod_Detector } - - impl Drop for LineMod_Detector { + impl std::fmt::Debug for LineMod_Detector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_linemod_Detector_delete(self.as_raw_mut_LineMod_Detector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LineMod_Detector") + .finish() } } - unsafe impl Send for LineMod_Detector {} - impl crate::rgbd::LineMod_DetectorTraitConst for LineMod_Detector { #[inline] fn as_raw_LineMod_Detector(&self) -> *const c_void { self.as_raw() } } @@ -4292,43 +4330,6 @@ pub mod rgbd { boxed_ref! { LineMod_Detector, crate::rgbd::LineMod_DetectorTraitConst, as_raw_LineMod_Detector, crate::rgbd::LineMod_DetectorTrait, as_raw_mut_LineMod_Detector } - impl LineMod_Detector { - /// \brief Empty constructor, initialize with read(). - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_linemod_Detector_Detector(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::LineMod_Detector::opencv_from_extern(ret) }; - Ok(ret) - } - - /// \brief Constructor. - /// - /// \param modalities Modalities to use (color gradients, depth normals, ...). - /// \param T_pyramid Value of the sampling step T at each pyramid level. The - /// number of pyramid levels is T_pyramid.size(). - #[inline] - pub fn new(modalities: &core::Vector>, t_pyramid: &core::Vector) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_linemod_Detector_Detector_const_vectorLPtrLModalityGGR_const_vectorLintGR(modalities.as_raw_VectorOfPtrOfLineMod_Modality(), t_pyramid.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::LineMod_Detector::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for LineMod_Detector { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LineMod_Detector") - .finish() - } - } - /// \brief Discriminant feature described by its location and label. #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] @@ -4382,6 +4383,46 @@ pub mod rgbd { } + /// \brief Represents a successful template match. + pub struct LineMod_Match { + ptr: *mut c_void, + } + + opencv_type_boxed! { LineMod_Match } + + impl Drop for LineMod_Match { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_linemod_Match_delete(self.as_raw_mut_LineMod_Match()) }; + } + } + + unsafe impl Send for LineMod_Match {} + + impl LineMod_Match { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_linemod_Match_Match(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::rgbd::LineMod_Match::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn new(x: i32, y: i32, similarity: f32, class_id: &str, template_id: i32) -> Result { + extern_container_arg!(class_id); + return_send!(via ocvrs_return); + unsafe { sys::cv_linemod_Match_Match_int_int_float_const_StringR_int(x, y, similarity, class_id.opencv_as_extern(), template_id, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::rgbd::LineMod_Match::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::rgbd::LineMod_Match] pub trait LineMod_MatchTraitConst { fn as_raw_LineMod_Match(&self) -> *const c_void; @@ -4475,22 +4516,26 @@ pub mod rgbd { } - /// \brief Represents a successful template match. - pub struct LineMod_Match { - ptr: *mut c_void, + impl Clone for LineMod_Match { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_linemod_Match_implicitClone_const(self.as_raw_LineMod_Match())) } + } } - opencv_type_boxed! { LineMod_Match } - - impl Drop for LineMod_Match { + impl std::fmt::Debug for LineMod_Match { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_linemod_Match_delete(self.as_raw_mut_LineMod_Match()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LineMod_Match") + .field("x", &crate::rgbd::LineMod_MatchTraitConst::x(self)) + .field("y", &crate::rgbd::LineMod_MatchTraitConst::y(self)) + .field("similarity", &crate::rgbd::LineMod_MatchTraitConst::similarity(self)) + .field("class_id", &crate::rgbd::LineMod_MatchTraitConst::class_id(self)) + .field("template_id", &crate::rgbd::LineMod_MatchTraitConst::template_id(self)) + .finish() } } - unsafe impl Send for LineMod_Match {} - impl crate::rgbd::LineMod_MatchTraitConst for LineMod_Match { #[inline] fn as_raw_LineMod_Match(&self) -> *const c_void { self.as_raw() } } @@ -4501,50 +4546,54 @@ pub mod rgbd { boxed_ref! { LineMod_Match, crate::rgbd::LineMod_MatchTraitConst, as_raw_LineMod_Match, crate::rgbd::LineMod_MatchTrait, as_raw_mut_LineMod_Match } - impl LineMod_Match { + /// \brief Interface for modalities that plug into the LINE template matching representation. + /// + /// \todo Max response, to allow optimization of summing (255/MAX) features as uint8 + pub struct LineMod_Modality { + ptr: *mut c_void, + } + + opencv_type_boxed! { LineMod_Modality } + + impl Drop for LineMod_Modality { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_linemod_Modality_delete(self.as_raw_mut_LineMod_Modality()) }; + } + } + + unsafe impl Send for LineMod_Modality {} + + impl LineMod_Modality { + /// \brief Create modality by name. + /// + /// The following modality types are supported: + /// - "ColorGradient" + /// - "DepthNormal" + #[inline] + pub fn create(modality_type: &str) -> Result> { + extern_container_arg!(modality_type); return_send!(via ocvrs_return); - unsafe { sys::cv_linemod_Match_Match(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_linemod_Modality_create_const_StringR(modality_type.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::LineMod_Match::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } + /// \brief Load a modality from file. #[inline] - pub fn new(x: i32, y: i32, similarity: f32, class_id: &str, template_id: i32) -> Result { - extern_container_arg!(class_id); + pub fn create_1(fn_: &impl core::FileNodeTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_linemod_Match_Match_int_int_float_const_StringR_int(x, y, similarity, class_id.opencv_as_extern(), template_id, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_linemod_Modality_create_const_FileNodeR(fn_.as_raw_FileNode(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::LineMod_Match::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - impl Clone for LineMod_Match { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_linemod_Match_implicitClone_const(self.as_raw_LineMod_Match())) } - } - } - - impl std::fmt::Debug for LineMod_Match { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LineMod_Match") - .field("x", &crate::rgbd::LineMod_MatchTraitConst::x(self)) - .field("y", &crate::rgbd::LineMod_MatchTraitConst::y(self)) - .field("similarity", &crate::rgbd::LineMod_MatchTraitConst::similarity(self)) - .field("class_id", &crate::rgbd::LineMod_MatchTraitConst::class_id(self)) - .field("template_id", &crate::rgbd::LineMod_MatchTraitConst::template_id(self)) - .finish() - } - } - /// Constant methods for [crate::rgbd::LineMod_Modality] pub trait LineMod_ModalityTraitConst { fn as_raw_LineMod_Modality(&self) -> *const c_void; @@ -4622,23 +4671,17 @@ pub mod rgbd { } - /// \brief Interface for modalities that plug into the LINE template matching representation. - /// - /// \todo Max response, to allow optimization of summing (255/MAX) features as uint8 - pub struct LineMod_Modality { - ptr: *mut c_void, - } - - opencv_type_boxed! { LineMod_Modality } - - impl Drop for LineMod_Modality { + impl std::fmt::Debug for LineMod_Modality { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_linemod_Modality_delete(self.as_raw_mut_LineMod_Modality()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LineMod_Modality") + .finish() } } - unsafe impl Send for LineMod_Modality {} + boxed_cast_descendant! { LineMod_Modality, crate::rgbd::LineMod_ColorGradient, cv_linemod_Modality_to_LineMod_ColorGradient } + + boxed_cast_descendant! { LineMod_Modality, crate::rgbd::LineMod_DepthNormal, cv_linemod_Modality_to_LineMod_DepthNormal } impl crate::rgbd::LineMod_ModalityTraitConst for LineMod_Modality { #[inline] fn as_raw_LineMod_Modality(&self) -> *const c_void { self.as_raw() } @@ -4650,48 +4693,22 @@ pub mod rgbd { boxed_ref! { LineMod_Modality, crate::rgbd::LineMod_ModalityTraitConst, as_raw_LineMod_Modality, crate::rgbd::LineMod_ModalityTrait, as_raw_mut_LineMod_Modality } - impl LineMod_Modality { - /// \brief Create modality by name. - /// - /// The following modality types are supported: - /// - "ColorGradient" - /// - "DepthNormal" - #[inline] - pub fn create(modality_type: &str) -> Result> { - extern_container_arg!(modality_type); - return_send!(via ocvrs_return); - unsafe { sys::cv_linemod_Modality_create_const_StringR(modality_type.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// \brief Load a modality from file. - #[inline] - pub fn create_1(fn_: &impl core::FileNodeTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_linemod_Modality_create_const_FileNodeR(fn_.as_raw_FileNode(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + /// \brief Represents a modality operating over an image pyramid. + pub struct LineMod_QuantizedPyramid { + ptr: *mut c_void, } - boxed_cast_descendant! { LineMod_Modality, crate::rgbd::LineMod_ColorGradient, cv_linemod_Modality_to_LineMod_ColorGradient } - - boxed_cast_descendant! { LineMod_Modality, crate::rgbd::LineMod_DepthNormal, cv_linemod_Modality_to_LineMod_DepthNormal } + opencv_type_boxed! { LineMod_QuantizedPyramid } - impl std::fmt::Debug for LineMod_Modality { + impl Drop for LineMod_QuantizedPyramid { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LineMod_Modality") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_linemod_QuantizedPyramid_delete(self.as_raw_mut_LineMod_QuantizedPyramid()) }; } } + unsafe impl Send for LineMod_QuantizedPyramid {} + /// Constant methods for [crate::rgbd::LineMod_QuantizedPyramid] pub trait LineMod_QuantizedPyramidTraitConst { fn as_raw_LineMod_QuantizedPyramid(&self) -> *const c_void; @@ -4741,22 +4758,14 @@ pub mod rgbd { } - /// \brief Represents a modality operating over an image pyramid. - pub struct LineMod_QuantizedPyramid { - ptr: *mut c_void, - } - - opencv_type_boxed! { LineMod_QuantizedPyramid } - - impl Drop for LineMod_QuantizedPyramid { + impl std::fmt::Debug for LineMod_QuantizedPyramid { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_linemod_QuantizedPyramid_delete(self.as_raw_mut_LineMod_QuantizedPyramid()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LineMod_QuantizedPyramid") + .finish() } } - unsafe impl Send for LineMod_QuantizedPyramid {} - impl crate::rgbd::LineMod_QuantizedPyramidTraitConst for LineMod_QuantizedPyramid { #[inline] fn as_raw_LineMod_QuantizedPyramid(&self) -> *const c_void { self.as_raw() } } @@ -4767,15 +4776,30 @@ pub mod rgbd { boxed_ref! { LineMod_QuantizedPyramid, crate::rgbd::LineMod_QuantizedPyramidTraitConst, as_raw_LineMod_QuantizedPyramid, crate::rgbd::LineMod_QuantizedPyramidTrait, as_raw_mut_LineMod_QuantizedPyramid } - impl LineMod_QuantizedPyramid { + pub struct LineMod_Template { + ptr: *mut c_void, } - impl std::fmt::Debug for LineMod_QuantizedPyramid { + opencv_type_boxed! { LineMod_Template } + + impl Drop for LineMod_Template { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LineMod_QuantizedPyramid") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_linemod_Template_delete(self.as_raw_mut_LineMod_Template()) }; + } + } + + unsafe impl Send for LineMod_Template {} + + impl LineMod_Template { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::rgbd::LineMod_Template { + let ret = unsafe { sys::cv_linemod_Template_defaultNew_const() }; + let ret = unsafe { crate::rgbd::LineMod_Template::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::rgbd::LineMod_Template] @@ -4857,20 +4881,32 @@ pub mod rgbd { } - pub struct LineMod_Template { - ptr: *mut c_void, + impl Default for LineMod_Template { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { LineMod_Template } - - impl Drop for LineMod_Template { + impl Clone for LineMod_Template { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_linemod_Template_delete(self.as_raw_mut_LineMod_Template()) }; + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_linemod_Template_implicitClone_const(self.as_raw_LineMod_Template())) } } } - unsafe impl Send for LineMod_Template {} + impl std::fmt::Debug for LineMod_Template { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LineMod_Template") + .field("width", &crate::rgbd::LineMod_TemplateTraitConst::width(self)) + .field("height", &crate::rgbd::LineMod_TemplateTraitConst::height(self)) + .field("pyramid_level", &crate::rgbd::LineMod_TemplateTraitConst::pyramid_level(self)) + .field("features", &crate::rgbd::LineMod_TemplateTraitConst::features(self)) + .finish() + } + } impl crate::rgbd::LineMod_TemplateTraitConst for LineMod_Template { #[inline] fn as_raw_LineMod_Template(&self) -> *const c_void { self.as_raw() } @@ -4882,40 +4918,99 @@ pub mod rgbd { boxed_ref! { LineMod_Template, crate::rgbd::LineMod_TemplateTraitConst, as_raw_LineMod_Template, crate::rgbd::LineMod_TemplateTrait, as_raw_mut_LineMod_Template } - impl LineMod_Template { - /// Creates a default instance of the class by calling the default constructor + /// Object that can clean a noisy depth image + pub struct DepthCleaner { + ptr: *mut c_void, + } + + opencv_type_boxed! { DepthCleaner } + + impl Drop for DepthCleaner { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_linemod_Template_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_rgbd_DepthCleaner_delete(self.as_raw_mut_DepthCleaner()) }; } - } - impl Clone for LineMod_Template { + unsafe impl Send for DepthCleaner {} + + impl DepthCleaner { #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_linemod_Template_implicitClone_const(self.as_raw_LineMod_Template())) } + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_rgbd_DepthCleaner_DepthCleaner(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::rgbd::DepthCleaner::opencv_from_extern(ret) }; + Ok(ret) } - } - impl std::fmt::Debug for LineMod_Template { + /// Constructor + /// ## Parameters + /// * depth: the depth of the normals (only CV_32F or CV_64F) + /// * window_size: the window size to compute the normals: can only be 1,3,5 or 7 + /// * method: one of the methods to use: RGBD_NORMALS_METHOD_SRI, RGBD_NORMALS_METHOD_FALS + /// + /// ## C++ default parameters + /// * window_size: 5 + /// * method: DepthCleaner::DEPTH_CLEANER_NIL #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LineMod_Template") - .field("width", &crate::rgbd::LineMod_TemplateTraitConst::width(self)) - .field("height", &crate::rgbd::LineMod_TemplateTraitConst::height(self)) - .field("pyramid_level", &crate::rgbd::LineMod_TemplateTraitConst::pyramid_level(self)) - .field("features", &crate::rgbd::LineMod_TemplateTraitConst::features(self)) - .finish() + pub fn new(depth: i32, window_size: i32, method: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_rgbd_DepthCleaner_DepthCleaner_int_int_int(depth, window_size, method, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::rgbd::DepthCleaner::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for LineMod_Template { + /// Constructor + /// ## Parameters + /// * depth: the depth of the normals (only CV_32F or CV_64F) + /// * window_size: the window size to compute the normals: can only be 1,3,5 or 7 + /// * method: one of the methods to use: RGBD_NORMALS_METHOD_SRI, RGBD_NORMALS_METHOD_FALS + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * window_size: 5 + /// * method: DepthCleaner::DEPTH_CLEANER_NIL #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new_def(depth: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_rgbd_DepthCleaner_DepthCleaner_int(depth, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::rgbd::DepthCleaner::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## C++ default parameters + /// * window_size: 5 + /// * method: DepthCleaner::DEPTH_CLEANER_NIL + #[inline] + pub fn create(depth: i32, window_size: i32, method: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_rgbd_DepthCleaner_create_int_int_int(depth, window_size, method, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [DepthCleaner::create] function uses the following default values for its arguments: + /// * window_size: 5 + /// * method: DepthCleaner::DEPTH_CLEANER_NIL + #[inline] + pub fn create_def(depth: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_rgbd_DepthCleaner_create_int(depth, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::rgbd::DepthCleaner] @@ -5010,21 +5105,15 @@ pub mod rgbd { } - /// Object that can clean a noisy depth image - pub struct DepthCleaner { - ptr: *mut c_void, - } - - opencv_type_boxed! { DepthCleaner } - - impl Drop for DepthCleaner { + impl std::fmt::Debug for DepthCleaner { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_rgbd_DepthCleaner_delete(self.as_raw_mut_DepthCleaner()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DepthCleaner") + .finish() } } - unsafe impl Send for DepthCleaner {} + boxed_cast_base! { DepthCleaner, core::Algorithm, cv_rgbd_DepthCleaner_to_Algorithm } impl core::AlgorithmTraitConst for DepthCleaner { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5046,95 +5135,138 @@ pub mod rgbd { boxed_ref! { DepthCleaner, crate::rgbd::DepthCleanerTraitConst, as_raw_DepthCleaner, crate::rgbd::DepthCleanerTrait, as_raw_mut_DepthCleaner } - impl DepthCleaner { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_DepthCleaner_DepthCleaner(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::DepthCleaner::opencv_from_extern(ret) }; - Ok(ret) + /// A faster version of ICPOdometry which is used in KinectFusion implementation + /// Partial list of differences: + /// - Works in parallel + /// - Written in universal intrinsics + /// - Filters points by angle + /// - Interpolates points and normals + /// - Doesn't use masks or min/max depth filtering + /// - Doesn't use random subsets of points + /// - Supports only Rt transform type + /// - Supports only 4-float vectors as input type + pub struct FastICPOdometry { + ptr: *mut c_void, + } + + opencv_type_boxed! { FastICPOdometry } + + impl Drop for FastICPOdometry { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_rgbd_FastICPOdometry_delete(self.as_raw_mut_FastICPOdometry()) }; } + } - /// Constructor + unsafe impl Send for FastICPOdometry {} + + impl FastICPOdometry { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_rgbd_FastICPOdometry_FastICPOdometry(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::rgbd::FastICPOdometry::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Constructor. /// ## Parameters - /// * depth: the depth of the normals (only CV_32F or CV_64F) - /// * window_size: the window size to compute the normals: can only be 1,3,5 or 7 - /// * method: one of the methods to use: RGBD_NORMALS_METHOD_SRI, RGBD_NORMALS_METHOD_FALS + /// * cameraMatrix: Camera matrix + /// * maxDistDiff: Correspondences between pixels of two given frames will be filtered out + /// if their depth difference is larger than maxDepthDiff + /// * angleThreshold: Correspondence will be filtered out + /// if an angle between their normals is bigger than threshold + /// * sigmaDepth: Depth sigma in meters for bilateral smooth + /// * sigmaSpatial: Spatial sigma in pixels for bilateral smooth + /// * kernelSize: Kernel size in pixels for bilateral smooth + /// * iterCounts: Count of iterations on each pyramid level /// /// ## C++ default parameters - /// * window_size: 5 - /// * method: DepthCleaner::DEPTH_CLEANER_NIL + /// * max_dist_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() + /// * angle_threshold: (float)(30.*CV_PI/180.) + /// * sigma_depth: 0.04f + /// * sigma_spatial: 4.5f + /// * kernel_size: 7 + /// * iter_counts: std::vector() #[inline] - pub fn new(depth: i32, window_size: i32, method: i32) -> Result { + pub fn new(camera_matrix: &impl core::MatTraitConst, max_dist_diff: f32, angle_threshold: f32, sigma_depth: f32, sigma_spatial: f32, kernel_size: i32, iter_counts: &core::Vector) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_DepthCleaner_DepthCleaner_int_int_int(depth, window_size, method, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_FastICPOdometry_FastICPOdometry_const_MatR_float_float_float_float_int_const_vectorLintGR(camera_matrix.as_raw_Mat(), max_dist_diff, angle_threshold, sigma_depth, sigma_spatial, kernel_size, iter_counts.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::DepthCleaner::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::FastICPOdometry::opencv_from_extern(ret) }; Ok(ret) } - /// Constructor + /// Constructor. /// ## Parameters - /// * depth: the depth of the normals (only CV_32F or CV_64F) - /// * window_size: the window size to compute the normals: can only be 1,3,5 or 7 - /// * method: one of the methods to use: RGBD_NORMALS_METHOD_SRI, RGBD_NORMALS_METHOD_FALS + /// * cameraMatrix: Camera matrix + /// * maxDistDiff: Correspondences between pixels of two given frames will be filtered out + /// if their depth difference is larger than maxDepthDiff + /// * angleThreshold: Correspondence will be filtered out + /// if an angle between their normals is bigger than threshold + /// * sigmaDepth: Depth sigma in meters for bilateral smooth + /// * sigmaSpatial: Spatial sigma in pixels for bilateral smooth + /// * kernelSize: Kernel size in pixels for bilateral smooth + /// * iterCounts: Count of iterations on each pyramid level /// /// ## Note /// This alternative version of [new] function uses the following default values for its arguments: - /// * window_size: 5 - /// * method: DepthCleaner::DEPTH_CLEANER_NIL + /// * max_dist_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() + /// * angle_threshold: (float)(30.*CV_PI/180.) + /// * sigma_depth: 0.04f + /// * sigma_spatial: 4.5f + /// * kernel_size: 7 + /// * iter_counts: std::vector() #[inline] - pub fn new_def(depth: i32) -> Result { + pub fn new_def(camera_matrix: &impl core::MatTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_DepthCleaner_DepthCleaner_int(depth, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_FastICPOdometry_FastICPOdometry_const_MatR(camera_matrix.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::DepthCleaner::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::FastICPOdometry::opencv_from_extern(ret) }; Ok(ret) } /// ## C++ default parameters - /// * window_size: 5 - /// * method: DepthCleaner::DEPTH_CLEANER_NIL + /// * max_dist_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() + /// * angle_threshold: (float)(30.*CV_PI/180.) + /// * sigma_depth: 0.04f + /// * sigma_spatial: 4.5f + /// * kernel_size: 7 + /// * iter_counts: std::vector() #[inline] - pub fn create(depth: i32, window_size: i32, method: i32) -> Result> { + pub fn create(camera_matrix: &impl core::MatTraitConst, max_dist_diff: f32, angle_threshold: f32, sigma_depth: f32, sigma_spatial: f32, kernel_size: i32, iter_counts: &core::Vector) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_DepthCleaner_create_int_int_int(depth, window_size, method, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_FastICPOdometry_create_const_MatR_float_float_float_float_int_const_vectorLintGR(camera_matrix.as_raw_Mat(), max_dist_diff, angle_threshold, sigma_depth, sigma_spatial, kernel_size, iter_counts.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } /// ## Note - /// This alternative version of [DepthCleaner::create] function uses the following default values for its arguments: - /// * window_size: 5 - /// * method: DepthCleaner::DEPTH_CLEANER_NIL + /// This alternative version of [FastICPOdometry::create] function uses the following default values for its arguments: + /// * max_dist_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() + /// * angle_threshold: (float)(30.*CV_PI/180.) + /// * sigma_depth: 0.04f + /// * sigma_spatial: 4.5f + /// * kernel_size: 7 + /// * iter_counts: std::vector() #[inline] - pub fn create_def(depth: i32) -> Result> { + pub fn create_def(camera_matrix: &impl core::MatTraitConst) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_DepthCleaner_create_int(depth, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_FastICPOdometry_create_const_MatR(camera_matrix.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { DepthCleaner, core::Algorithm, cv_rgbd_DepthCleaner_to_Algorithm } - - impl std::fmt::Debug for DepthCleaner { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DepthCleaner") - .finish() - } - } - /// Constant methods for [crate::rgbd::FastICPOdometry] pub trait FastICPOdometryTraitConst: crate::rgbd::OdometryTraitConst { fn as_raw_FastICPOdometry(&self) -> *const c_void; @@ -5302,30 +5434,17 @@ pub mod rgbd { } - /// A faster version of ICPOdometry which is used in KinectFusion implementation - /// Partial list of differences: - /// - Works in parallel - /// - Written in universal intrinsics - /// - Filters points by angle - /// - Interpolates points and normals - /// - Doesn't use masks or min/max depth filtering - /// - Doesn't use random subsets of points - /// - Supports only Rt transform type - /// - Supports only 4-float vectors as input type - pub struct FastICPOdometry { - ptr: *mut c_void, - } - - opencv_type_boxed! { FastICPOdometry } - - impl Drop for FastICPOdometry { + impl std::fmt::Debug for FastICPOdometry { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_rgbd_FastICPOdometry_delete(self.as_raw_mut_FastICPOdometry()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FastICPOdometry") + .finish() } } - unsafe impl Send for FastICPOdometry {} + boxed_cast_base! { FastICPOdometry, core::Algorithm, cv_rgbd_FastICPOdometry_to_Algorithm } + + boxed_cast_base! { FastICPOdometry, crate::rgbd::Odometry, cv_rgbd_FastICPOdometry_to_Odometry } impl core::AlgorithmTraitConst for FastICPOdometry { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5357,125 +5476,130 @@ pub mod rgbd { boxed_ref! { FastICPOdometry, crate::rgbd::FastICPOdometryTraitConst, as_raw_FastICPOdometry, crate::rgbd::FastICPOdometryTrait, as_raw_mut_FastICPOdometry } - impl FastICPOdometry { + /// Odometry based on the paper "KinectFusion: Real-Time Dense Surface Mapping and Tracking", + /// Richard A. Newcombe, Andrew Fitzgibbon, at al, SIGGRAPH, 2011. + pub struct ICPOdometry { + ptr: *mut c_void, + } + + opencv_type_boxed! { ICPOdometry } + + impl Drop for ICPOdometry { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_rgbd_ICPOdometry_delete(self.as_raw_mut_ICPOdometry()) }; + } + } + + unsafe impl Send for ICPOdometry {} + + impl ICPOdometry { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_FastICPOdometry_FastICPOdometry(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_ICPOdometry_ICPOdometry(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::FastICPOdometry::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::ICPOdometry::opencv_from_extern(ret) }; Ok(ret) } /// Constructor. /// ## Parameters /// * cameraMatrix: Camera matrix - /// * maxDistDiff: Correspondences between pixels of two given frames will be filtered out + /// * minDepth: Pixels with depth less than minDepth will not be used + /// * maxDepth: Pixels with depth larger than maxDepth will not be used + /// * maxDepthDiff: Correspondences between pixels of two given frames will be filtered out /// if their depth difference is larger than maxDepthDiff - /// * angleThreshold: Correspondence will be filtered out - /// if an angle between their normals is bigger than threshold - /// * sigmaDepth: Depth sigma in meters for bilateral smooth - /// * sigmaSpatial: Spatial sigma in pixels for bilateral smooth - /// * kernelSize: Kernel size in pixels for bilateral smooth - /// * iterCounts: Count of iterations on each pyramid level + /// * maxPointsPart: The method uses a random pixels subset of size frameWidth x frameHeight x pointsPart + /// * iterCounts: Count of iterations on each pyramid level. + /// * transformType: Class of trasformation /// /// ## C++ default parameters - /// * max_dist_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() - /// * angle_threshold: (float)(30.*CV_PI/180.) - /// * sigma_depth: 0.04f - /// * sigma_spatial: 4.5f - /// * kernel_size: 7 + /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() + /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() + /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() + /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() /// * iter_counts: std::vector() + /// * transform_type: Odometry::RIGID_BODY_MOTION #[inline] - pub fn new(camera_matrix: &impl core::MatTraitConst, max_dist_diff: f32, angle_threshold: f32, sigma_depth: f32, sigma_spatial: f32, kernel_size: i32, iter_counts: &core::Vector) -> Result { + pub fn new(camera_matrix: &impl core::MatTraitConst, min_depth: f32, max_depth: f32, max_depth_diff: f32, max_points_part: f32, iter_counts: &core::Vector, transform_type: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_FastICPOdometry_FastICPOdometry_const_MatR_float_float_float_float_int_const_vectorLintGR(camera_matrix.as_raw_Mat(), max_dist_diff, angle_threshold, sigma_depth, sigma_spatial, kernel_size, iter_counts.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_ICPOdometry_ICPOdometry_const_MatR_float_float_float_float_const_vectorLintGR_int(camera_matrix.as_raw_Mat(), min_depth, max_depth, max_depth_diff, max_points_part, iter_counts.as_raw_VectorOfi32(), transform_type, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::FastICPOdometry::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::ICPOdometry::opencv_from_extern(ret) }; Ok(ret) } /// Constructor. /// ## Parameters /// * cameraMatrix: Camera matrix - /// * maxDistDiff: Correspondences between pixels of two given frames will be filtered out + /// * minDepth: Pixels with depth less than minDepth will not be used + /// * maxDepth: Pixels with depth larger than maxDepth will not be used + /// * maxDepthDiff: Correspondences between pixels of two given frames will be filtered out /// if their depth difference is larger than maxDepthDiff - /// * angleThreshold: Correspondence will be filtered out - /// if an angle between their normals is bigger than threshold - /// * sigmaDepth: Depth sigma in meters for bilateral smooth - /// * sigmaSpatial: Spatial sigma in pixels for bilateral smooth - /// * kernelSize: Kernel size in pixels for bilateral smooth - /// * iterCounts: Count of iterations on each pyramid level + /// * maxPointsPart: The method uses a random pixels subset of size frameWidth x frameHeight x pointsPart + /// * iterCounts: Count of iterations on each pyramid level. + /// * transformType: Class of trasformation /// /// ## Note /// This alternative version of [new] function uses the following default values for its arguments: - /// * max_dist_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() - /// * angle_threshold: (float)(30.*CV_PI/180.) - /// * sigma_depth: 0.04f - /// * sigma_spatial: 4.5f - /// * kernel_size: 7 + /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() + /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() + /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() + /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() /// * iter_counts: std::vector() + /// * transform_type: Odometry::RIGID_BODY_MOTION #[inline] - pub fn new_def(camera_matrix: &impl core::MatTraitConst) -> Result { + pub fn new_def(camera_matrix: &impl core::MatTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_FastICPOdometry_FastICPOdometry_const_MatR(camera_matrix.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_ICPOdometry_ICPOdometry_const_MatR(camera_matrix.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::FastICPOdometry::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::ICPOdometry::opencv_from_extern(ret) }; Ok(ret) } /// ## C++ default parameters - /// * max_dist_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() - /// * angle_threshold: (float)(30.*CV_PI/180.) - /// * sigma_depth: 0.04f - /// * sigma_spatial: 4.5f - /// * kernel_size: 7 + /// * camera_matrix: Mat() + /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() + /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() + /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() + /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() /// * iter_counts: std::vector() + /// * transform_type: Odometry::RIGID_BODY_MOTION #[inline] - pub fn create(camera_matrix: &impl core::MatTraitConst, max_dist_diff: f32, angle_threshold: f32, sigma_depth: f32, sigma_spatial: f32, kernel_size: i32, iter_counts: &core::Vector) -> Result> { + pub fn create(camera_matrix: &impl core::MatTraitConst, min_depth: f32, max_depth: f32, max_depth_diff: f32, max_points_part: f32, iter_counts: &core::Vector, transform_type: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_FastICPOdometry_create_const_MatR_float_float_float_float_int_const_vectorLintGR(camera_matrix.as_raw_Mat(), max_dist_diff, angle_threshold, sigma_depth, sigma_spatial, kernel_size, iter_counts.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_ICPOdometry_create_const_MatR_float_float_float_float_const_vectorLintGR_int(camera_matrix.as_raw_Mat(), min_depth, max_depth, max_depth_diff, max_points_part, iter_counts.as_raw_VectorOfi32(), transform_type, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } /// ## Note - /// This alternative version of [FastICPOdometry::create] function uses the following default values for its arguments: - /// * max_dist_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() - /// * angle_threshold: (float)(30.*CV_PI/180.) - /// * sigma_depth: 0.04f - /// * sigma_spatial: 4.5f - /// * kernel_size: 7 + /// This alternative version of [ICPOdometry::create] function uses the following default values for its arguments: + /// * camera_matrix: Mat() + /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() + /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() + /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() + /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() /// * iter_counts: std::vector() + /// * transform_type: Odometry::RIGID_BODY_MOTION #[inline] - pub fn create_def(camera_matrix: &impl core::MatTraitConst) -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_FastICPOdometry_create_const_MatR(camera_matrix.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_ICPOdometry_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { FastICPOdometry, core::Algorithm, cv_rgbd_FastICPOdometry_to_Algorithm } - - boxed_cast_base! { FastICPOdometry, crate::rgbd::Odometry, cv_rgbd_FastICPOdometry_to_Odometry } - - impl std::fmt::Debug for FastICPOdometry { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FastICPOdometry") - .finish() - } - } - /// Constant methods for [crate::rgbd::ICPOdometry] pub trait ICPOdometryTraitConst: crate::rgbd::OdometryTraitConst { fn as_raw_ICPOdometry(&self) -> *const c_void; @@ -5671,22 +5795,17 @@ pub mod rgbd { } - /// Odometry based on the paper "KinectFusion: Real-Time Dense Surface Mapping and Tracking", - /// Richard A. Newcombe, Andrew Fitzgibbon, at al, SIGGRAPH, 2011. - pub struct ICPOdometry { - ptr: *mut c_void, - } - - opencv_type_boxed! { ICPOdometry } - - impl Drop for ICPOdometry { + impl std::fmt::Debug for ICPOdometry { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_rgbd_ICPOdometry_delete(self.as_raw_mut_ICPOdometry()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ICPOdometry") + .finish() } } - unsafe impl Send for ICPOdometry {} + boxed_cast_base! { ICPOdometry, core::Algorithm, cv_rgbd_ICPOdometry_to_Algorithm } + + boxed_cast_base! { ICPOdometry, crate::rgbd::Odometry, cv_rgbd_ICPOdometry_to_Odometry } impl core::AlgorithmTraitConst for ICPOdometry { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5718,123 +5837,88 @@ pub mod rgbd { boxed_ref! { ICPOdometry, crate::rgbd::ICPOdometryTraitConst, as_raw_ICPOdometry, crate::rgbd::ICPOdometryTrait, as_raw_mut_ICPOdometry } - impl ICPOdometry { + /// Base class for computation of odometry. + pub struct Odometry { + ptr: *mut c_void, + } + + opencv_type_boxed! { Odometry } + + impl Drop for Odometry { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_rgbd_Odometry_delete(self.as_raw_mut_Odometry()) }; + } + } + + unsafe impl Send for Odometry {} + + impl Odometry { + #[inline] + pub fn default_min_depth() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_ICPOdometry_ICPOdometry(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_Odometry_DEFAULT_MIN_DEPTH(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::ICPOdometry::opencv_from_extern(ret) }; Ok(ret) } - /// Constructor. - /// ## Parameters - /// * cameraMatrix: Camera matrix - /// * minDepth: Pixels with depth less than minDepth will not be used - /// * maxDepth: Pixels with depth larger than maxDepth will not be used - /// * maxDepthDiff: Correspondences between pixels of two given frames will be filtered out - /// if their depth difference is larger than maxDepthDiff - /// * maxPointsPart: The method uses a random pixels subset of size frameWidth x frameHeight x pointsPart - /// * iterCounts: Count of iterations on each pyramid level. - /// * transformType: Class of trasformation - /// - /// ## C++ default parameters - /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() - /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() - /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() - /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() - /// * iter_counts: std::vector() - /// * transform_type: Odometry::RIGID_BODY_MOTION #[inline] - pub fn new(camera_matrix: &impl core::MatTraitConst, min_depth: f32, max_depth: f32, max_depth_diff: f32, max_points_part: f32, iter_counts: &core::Vector, transform_type: i32) -> Result { + pub fn default_max_depth() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_ICPOdometry_ICPOdometry_const_MatR_float_float_float_float_const_vectorLintGR_int(camera_matrix.as_raw_Mat(), min_depth, max_depth, max_depth_diff, max_points_part, iter_counts.as_raw_VectorOfi32(), transform_type, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_Odometry_DEFAULT_MAX_DEPTH(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::ICPOdometry::opencv_from_extern(ret) }; Ok(ret) } - /// Constructor. - /// ## Parameters - /// * cameraMatrix: Camera matrix - /// * minDepth: Pixels with depth less than minDepth will not be used - /// * maxDepth: Pixels with depth larger than maxDepth will not be used - /// * maxDepthDiff: Correspondences between pixels of two given frames will be filtered out - /// if their depth difference is larger than maxDepthDiff - /// * maxPointsPart: The method uses a random pixels subset of size frameWidth x frameHeight x pointsPart - /// * iterCounts: Count of iterations on each pyramid level. - /// * transformType: Class of trasformation - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() - /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() - /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() - /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() - /// * iter_counts: std::vector() - /// * transform_type: Odometry::RIGID_BODY_MOTION #[inline] - pub fn new_def(camera_matrix: &impl core::MatTraitConst) -> Result { + pub fn default_max_depth_diff() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_ICPOdometry_ICPOdometry_const_MatR(camera_matrix.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_Odometry_DEFAULT_MAX_DEPTH_DIFF(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::ICPOdometry::opencv_from_extern(ret) }; Ok(ret) } - /// ## C++ default parameters - /// * camera_matrix: Mat() - /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() - /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() - /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() - /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() - /// * iter_counts: std::vector() - /// * transform_type: Odometry::RIGID_BODY_MOTION #[inline] - pub fn create(camera_matrix: &impl core::MatTraitConst, min_depth: f32, max_depth: f32, max_depth_diff: f32, max_points_part: f32, iter_counts: &core::Vector, transform_type: i32) -> Result> { + pub fn default_max_points_part() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_ICPOdometry_create_const_MatR_float_float_float_float_const_vectorLintGR_int(camera_matrix.as_raw_Mat(), min_depth, max_depth, max_depth_diff, max_points_part, iter_counts.as_raw_VectorOfi32(), transform_type, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_Odometry_DEFAULT_MAX_POINTS_PART(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [ICPOdometry::create] function uses the following default values for its arguments: - /// * camera_matrix: Mat() - /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() - /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() - /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() - /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() - /// * iter_counts: std::vector() - /// * transform_type: Odometry::RIGID_BODY_MOTION #[inline] - pub fn create_def() -> Result> { + pub fn default_max_translation() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_ICPOdometry_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_Odometry_DEFAULT_MAX_TRANSLATION(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { ICPOdometry, core::Algorithm, cv_rgbd_ICPOdometry_to_Algorithm } - - boxed_cast_base! { ICPOdometry, crate::rgbd::Odometry, cv_rgbd_ICPOdometry_to_Odometry } + #[inline] + pub fn default_max_rotation() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_rgbd_Odometry_DEFAULT_MAX_ROTATION(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - impl std::fmt::Debug for ICPOdometry { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ICPOdometry") - .finish() + pub fn create(odometry_type: &str) -> Result> { + extern_container_arg!(odometry_type); + return_send!(via ocvrs_return); + unsafe { sys::cv_rgbd_Odometry_create_const_StringR(odometry_type.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::rgbd::Odometry] @@ -6003,21 +6087,23 @@ pub mod rgbd { } - /// Base class for computation of odometry. - pub struct Odometry { - ptr: *mut c_void, - } - - opencv_type_boxed! { Odometry } - - impl Drop for Odometry { + impl std::fmt::Debug for Odometry { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_rgbd_Odometry_delete(self.as_raw_mut_Odometry()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Odometry") + .finish() } } - unsafe impl Send for Odometry {} + boxed_cast_base! { Odometry, core::Algorithm, cv_rgbd_Odometry_to_Algorithm } + + boxed_cast_descendant! { Odometry, crate::rgbd::FastICPOdometry, cv_rgbd_Odometry_to_FastICPOdometry } + + boxed_cast_descendant! { Odometry, crate::rgbd::ICPOdometry, cv_rgbd_Odometry_to_ICPOdometry } + + boxed_cast_descendant! { Odometry, crate::rgbd::RgbdICPOdometry, cv_rgbd_Odometry_to_RgbdICPOdometry } + + boxed_cast_descendant! { Odometry, crate::rgbd::RgbdOdometry, cv_rgbd_Odometry_to_RgbdOdometry } impl core::AlgorithmTraitConst for Odometry { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -6039,92 +6125,99 @@ pub mod rgbd { boxed_ref! { Odometry, crate::rgbd::OdometryTraitConst, as_raw_Odometry, crate::rgbd::OdometryTrait, as_raw_mut_Odometry } - impl Odometry { + /// Object that contains a frame data that is possibly needed for the Odometry. + /// It's used for the efficiency (to pass precomputed/cached data of the frame that participates + /// in the Odometry processing several times). + pub struct OdometryFrame { + ptr: *mut c_void, + } + + opencv_type_boxed! { OdometryFrame } + + impl Drop for OdometryFrame { #[inline] - pub fn default_min_depth() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_Odometry_DEFAULT_MIN_DEPTH(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_rgbd_OdometryFrame_delete(self.as_raw_mut_OdometryFrame()) }; } + } + + unsafe impl Send for OdometryFrame {} + impl OdometryFrame { #[inline] - pub fn default_max_depth() -> Result { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_Odometry_DEFAULT_MAX_DEPTH(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_OdometryFrame_OdometryFrame(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { crate::rgbd::OdometryFrame::opencv_from_extern(ret) }; Ok(ret) } + /// ## C++ default parameters + /// * mask: Mat() + /// * normals: Mat() + /// * id: -1 #[inline] - pub fn default_max_depth_diff() -> Result { + pub fn new(image: &impl core::MatTraitConst, depth: &impl core::MatTraitConst, mask: &impl core::MatTraitConst, normals: &impl core::MatTraitConst, id: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_Odometry_DEFAULT_MAX_DEPTH_DIFF(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_OdometryFrame_OdometryFrame_const_MatR_const_MatR_const_MatR_const_MatR_int(image.as_raw_Mat(), depth.as_raw_Mat(), mask.as_raw_Mat(), normals.as_raw_Mat(), id, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { crate::rgbd::OdometryFrame::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * mask: Mat() + /// * normals: Mat() + /// * id: -1 #[inline] - pub fn default_max_points_part() -> Result { + pub fn new_def(image: &impl core::MatTraitConst, depth: &impl core::MatTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_Odometry_DEFAULT_MAX_POINTS_PART(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_OdometryFrame_OdometryFrame_const_MatR_const_MatR(image.as_raw_Mat(), depth.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { crate::rgbd::OdometryFrame::opencv_from_extern(ret) }; Ok(ret) } + /// ## C++ default parameters + /// * image: Mat() + /// * depth: Mat() + /// * mask: Mat() + /// * normals: Mat() + /// * id: -1 #[inline] - pub fn default_max_translation() -> Result { + pub fn create(image: &impl core::MatTraitConst, depth: &impl core::MatTraitConst, mask: &impl core::MatTraitConst, normals: &impl core::MatTraitConst, id: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_Odometry_DEFAULT_MAX_TRANSLATION(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - pub fn default_max_rotation() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_Odometry_DEFAULT_MAX_ROTATION(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_OdometryFrame_create_const_MatR_const_MatR_const_MatR_const_MatR_int(image.as_raw_Mat(), depth.as_raw_Mat(), mask.as_raw_Mat(), normals.as_raw_Mat(), id, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [OdometryFrame::create] function uses the following default values for its arguments: + /// * image: Mat() + /// * depth: Mat() + /// * mask: Mat() + /// * normals: Mat() + /// * id: -1 #[inline] - pub fn create(odometry_type: &str) -> Result> { - extern_container_arg!(odometry_type); + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_Odometry_create_const_StringR(odometry_type.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_OdometryFrame_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_descendant! { Odometry, crate::rgbd::FastICPOdometry, cv_rgbd_Odometry_to_FastICPOdometry } - - boxed_cast_descendant! { Odometry, crate::rgbd::ICPOdometry, cv_rgbd_Odometry_to_ICPOdometry } - - boxed_cast_descendant! { Odometry, crate::rgbd::RgbdICPOdometry, cv_rgbd_Odometry_to_RgbdICPOdometry } - - boxed_cast_descendant! { Odometry, crate::rgbd::RgbdOdometry, cv_rgbd_Odometry_to_RgbdOdometry } - - boxed_cast_base! { Odometry, core::Algorithm, cv_rgbd_Odometry_to_Algorithm } - - impl std::fmt::Debug for Odometry { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Odometry") - .finish() - } - } - /// Constant methods for [crate::rgbd::OdometryFrame] pub trait OdometryFrameTraitConst: crate::rgbd::RgbdFrameTraitConst { fn as_raw_OdometryFrame(&self) -> *const c_void; @@ -6272,23 +6365,29 @@ pub mod rgbd { } - /// Object that contains a frame data that is possibly needed for the Odometry. - /// It's used for the efficiency (to pass precomputed/cached data of the frame that participates - /// in the Odometry processing several times). - pub struct OdometryFrame { - ptr: *mut c_void, - } - - opencv_type_boxed! { OdometryFrame } - - impl Drop for OdometryFrame { + impl std::fmt::Debug for OdometryFrame { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_rgbd_OdometryFrame_delete(self.as_raw_mut_OdometryFrame()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("OdometryFrame") + .field("pyramid_image", &crate::rgbd::OdometryFrameTraitConst::pyramid_image(self)) + .field("pyramid_depth", &crate::rgbd::OdometryFrameTraitConst::pyramid_depth(self)) + .field("pyramid_mask", &crate::rgbd::OdometryFrameTraitConst::pyramid_mask(self)) + .field("pyramid_cloud", &crate::rgbd::OdometryFrameTraitConst::pyramid_cloud(self)) + .field("pyramid_d_i_dx", &crate::rgbd::OdometryFrameTraitConst::pyramid_d_i_dx(self)) + .field("pyramid_d_i_dy", &crate::rgbd::OdometryFrameTraitConst::pyramid_d_i_dy(self)) + .field("pyramid_textured_mask", &crate::rgbd::OdometryFrameTraitConst::pyramid_textured_mask(self)) + .field("pyramid_normals", &crate::rgbd::OdometryFrameTraitConst::pyramid_normals(self)) + .field("pyramid_normals_mask", &crate::rgbd::OdometryFrameTraitConst::pyramid_normals_mask(self)) + .field("id", &crate::rgbd::RgbdFrameTraitConst::id(self)) + .field("image", &crate::rgbd::RgbdFrameTraitConst::image(self)) + .field("depth", &crate::rgbd::RgbdFrameTraitConst::depth(self)) + .field("mask", &crate::rgbd::RgbdFrameTraitConst::mask(self)) + .field("normals", &crate::rgbd::RgbdFrameTraitConst::normals(self)) + .finish() } } - unsafe impl Send for OdometryFrame {} + boxed_cast_base! { OdometryFrame, crate::rgbd::RgbdFrame, cv_rgbd_OdometryFrame_to_RgbdFrame } impl crate::rgbd::RgbdFrameTraitConst for OdometryFrame { #[inline] fn as_raw_RgbdFrame(&self) -> *const c_void { self.as_raw() } @@ -6310,14 +6409,30 @@ pub mod rgbd { boxed_ref! { OdometryFrame, crate::rgbd::OdometryFrameTraitConst, as_raw_OdometryFrame, crate::rgbd::OdometryFrameTrait, as_raw_mut_OdometryFrame } - impl OdometryFrame { + /// Object that contains a frame data. + pub struct RgbdFrame { + ptr: *mut c_void, + } + + opencv_type_boxed! { RgbdFrame } + + impl Drop for RgbdFrame { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_rgbd_RgbdFrame_delete(self.as_raw_mut_RgbdFrame()) }; + } + } + + unsafe impl Send for RgbdFrame {} + + impl RgbdFrame { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_OdometryFrame_OdometryFrame(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdFrame_RgbdFrame(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::OdometryFrame::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::RgbdFrame::opencv_from_extern(ret) }; Ok(ret) } @@ -6326,12 +6441,12 @@ pub mod rgbd { /// * normals: Mat() /// * id: -1 #[inline] - pub fn new(image: &impl core::MatTraitConst, depth: &impl core::MatTraitConst, mask: &impl core::MatTraitConst, normals: &impl core::MatTraitConst, id: i32) -> Result { + pub fn new(image: &impl core::MatTraitConst, depth: &impl core::MatTraitConst, mask: &impl core::MatTraitConst, normals: &impl core::MatTraitConst, id: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_OdometryFrame_OdometryFrame_const_MatR_const_MatR_const_MatR_const_MatR_int(image.as_raw_Mat(), depth.as_raw_Mat(), mask.as_raw_Mat(), normals.as_raw_Mat(), id, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdFrame_RgbdFrame_const_MatR_const_MatR_const_MatR_const_MatR_int(image.as_raw_Mat(), depth.as_raw_Mat(), mask.as_raw_Mat(), normals.as_raw_Mat(), id, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::OdometryFrame::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::RgbdFrame::opencv_from_extern(ret) }; Ok(ret) } @@ -6341,12 +6456,12 @@ pub mod rgbd { /// * normals: Mat() /// * id: -1 #[inline] - pub fn new_def(image: &impl core::MatTraitConst, depth: &impl core::MatTraitConst) -> Result { + pub fn new_def(image: &impl core::MatTraitConst, depth: &impl core::MatTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_OdometryFrame_OdometryFrame_const_MatR_const_MatR(image.as_raw_Mat(), depth.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdFrame_RgbdFrame_const_MatR_const_MatR(image.as_raw_Mat(), depth.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::OdometryFrame::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::RgbdFrame::opencv_from_extern(ret) }; Ok(ret) } @@ -6357,58 +6472,34 @@ pub mod rgbd { /// * normals: Mat() /// * id: -1 #[inline] - pub fn create(image: &impl core::MatTraitConst, depth: &impl core::MatTraitConst, mask: &impl core::MatTraitConst, normals: &impl core::MatTraitConst, id: i32) -> Result> { + pub fn create(image: &impl core::MatTraitConst, depth: &impl core::MatTraitConst, mask: &impl core::MatTraitConst, normals: &impl core::MatTraitConst, id: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_OdometryFrame_create_const_MatR_const_MatR_const_MatR_const_MatR_int(image.as_raw_Mat(), depth.as_raw_Mat(), mask.as_raw_Mat(), normals.as_raw_Mat(), id, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdFrame_create_const_MatR_const_MatR_const_MatR_const_MatR_int(image.as_raw_Mat(), depth.as_raw_Mat(), mask.as_raw_Mat(), normals.as_raw_Mat(), id, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } /// ## Note - /// This alternative version of [OdometryFrame::create] function uses the following default values for its arguments: + /// This alternative version of [RgbdFrame::create] function uses the following default values for its arguments: /// * image: Mat() /// * depth: Mat() /// * mask: Mat() /// * normals: Mat() /// * id: -1 #[inline] - pub fn create_def() -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_OdometryFrame_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdFrame_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { OdometryFrame, crate::rgbd::RgbdFrame, cv_rgbd_OdometryFrame_to_RgbdFrame } - - impl std::fmt::Debug for OdometryFrame { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("OdometryFrame") - .field("pyramid_image", &crate::rgbd::OdometryFrameTraitConst::pyramid_image(self)) - .field("pyramid_depth", &crate::rgbd::OdometryFrameTraitConst::pyramid_depth(self)) - .field("pyramid_mask", &crate::rgbd::OdometryFrameTraitConst::pyramid_mask(self)) - .field("pyramid_cloud", &crate::rgbd::OdometryFrameTraitConst::pyramid_cloud(self)) - .field("pyramid_d_i_dx", &crate::rgbd::OdometryFrameTraitConst::pyramid_d_i_dx(self)) - .field("pyramid_d_i_dy", &crate::rgbd::OdometryFrameTraitConst::pyramid_d_i_dy(self)) - .field("pyramid_textured_mask", &crate::rgbd::OdometryFrameTraitConst::pyramid_textured_mask(self)) - .field("pyramid_normals", &crate::rgbd::OdometryFrameTraitConst::pyramid_normals(self)) - .field("pyramid_normals_mask", &crate::rgbd::OdometryFrameTraitConst::pyramid_normals_mask(self)) - .field("id", &crate::rgbd::RgbdFrameTraitConst::id(self)) - .field("image", &crate::rgbd::RgbdFrameTraitConst::image(self)) - .field("depth", &crate::rgbd::RgbdFrameTraitConst::depth(self)) - .field("mask", &crate::rgbd::RgbdFrameTraitConst::mask(self)) - .field("normals", &crate::rgbd::RgbdFrameTraitConst::normals(self)) - .finish() - } - } - /// Constant methods for [crate::rgbd::RgbdFrame] pub trait RgbdFrameTraitConst { fn as_raw_RgbdFrame(&self) -> *const c_void; @@ -6494,21 +6585,20 @@ pub mod rgbd { } - /// Object that contains a frame data. - pub struct RgbdFrame { - ptr: *mut c_void, - } - - opencv_type_boxed! { RgbdFrame } - - impl Drop for RgbdFrame { + impl std::fmt::Debug for RgbdFrame { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_rgbd_RgbdFrame_delete(self.as_raw_mut_RgbdFrame()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RgbdFrame") + .field("id", &crate::rgbd::RgbdFrameTraitConst::id(self)) + .field("image", &crate::rgbd::RgbdFrameTraitConst::image(self)) + .field("depth", &crate::rgbd::RgbdFrameTraitConst::depth(self)) + .field("mask", &crate::rgbd::RgbdFrameTraitConst::mask(self)) + .field("normals", &crate::rgbd::RgbdFrameTraitConst::normals(self)) + .finish() } } - unsafe impl Send for RgbdFrame {} + boxed_cast_descendant! { RgbdFrame, crate::rgbd::OdometryFrame, cv_rgbd_RgbdFrame_to_OdometryFrame } impl crate::rgbd::RgbdFrameTraitConst for RgbdFrame { #[inline] fn as_raw_RgbdFrame(&self) -> *const c_void { self.as_raw() } @@ -6520,96 +6610,137 @@ pub mod rgbd { boxed_ref! { RgbdFrame, crate::rgbd::RgbdFrameTraitConst, as_raw_RgbdFrame, crate::rgbd::RgbdFrameTrait, as_raw_mut_RgbdFrame } - impl RgbdFrame { + /// Odometry that merges RgbdOdometry and ICPOdometry by minimize sum of their energy functions. + pub struct RgbdICPOdometry { + ptr: *mut c_void, + } + + opencv_type_boxed! { RgbdICPOdometry } + + impl Drop for RgbdICPOdometry { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_rgbd_RgbdICPOdometry_delete(self.as_raw_mut_RgbdICPOdometry()) }; + } + } + + unsafe impl Send for RgbdICPOdometry {} + + impl RgbdICPOdometry { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdFrame_RgbdFrame(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdICPOdometry_RgbdICPOdometry(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::RgbdFrame::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::RgbdICPOdometry::opencv_from_extern(ret) }; Ok(ret) } + /// Constructor. + /// ## Parameters + /// * cameraMatrix: Camera matrix + /// * minDepth: Pixels with depth less than minDepth will not be used + /// * maxDepth: Pixels with depth larger than maxDepth will not be used + /// * maxDepthDiff: Correspondences between pixels of two given frames will be filtered out + /// if their depth difference is larger than maxDepthDiff + /// * maxPointsPart: The method uses a random pixels subset of size frameWidth x frameHeight x pointsPart + /// * iterCounts: Count of iterations on each pyramid level. + /// * minGradientMagnitudes: For each pyramid level the pixels will be filtered out + /// if they have gradient magnitude less than minGradientMagnitudes[level]. + /// * transformType: Class of trasformation + /// /// ## C++ default parameters - /// * mask: Mat() - /// * normals: Mat() - /// * id: -1 + /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() + /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() + /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() + /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() + /// * iter_counts: std::vector() + /// * min_gradient_magnitudes: std::vector() + /// * transform_type: Odometry::RIGID_BODY_MOTION #[inline] - pub fn new(image: &impl core::MatTraitConst, depth: &impl core::MatTraitConst, mask: &impl core::MatTraitConst, normals: &impl core::MatTraitConst, id: i32) -> Result { + pub fn new(camera_matrix: &impl core::MatTraitConst, min_depth: f32, max_depth: f32, max_depth_diff: f32, max_points_part: f32, iter_counts: &core::Vector, min_gradient_magnitudes: &core::Vector, transform_type: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdFrame_RgbdFrame_const_MatR_const_MatR_const_MatR_const_MatR_int(image.as_raw_Mat(), depth.as_raw_Mat(), mask.as_raw_Mat(), normals.as_raw_Mat(), id, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdICPOdometry_RgbdICPOdometry_const_MatR_float_float_float_float_const_vectorLintGR_const_vectorLfloatGR_int(camera_matrix.as_raw_Mat(), min_depth, max_depth, max_depth_diff, max_points_part, iter_counts.as_raw_VectorOfi32(), min_gradient_magnitudes.as_raw_VectorOff32(), transform_type, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::RgbdFrame::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::RgbdICPOdometry::opencv_from_extern(ret) }; Ok(ret) } + /// Constructor. + /// ## Parameters + /// * cameraMatrix: Camera matrix + /// * minDepth: Pixels with depth less than minDepth will not be used + /// * maxDepth: Pixels with depth larger than maxDepth will not be used + /// * maxDepthDiff: Correspondences between pixels of two given frames will be filtered out + /// if their depth difference is larger than maxDepthDiff + /// * maxPointsPart: The method uses a random pixels subset of size frameWidth x frameHeight x pointsPart + /// * iterCounts: Count of iterations on each pyramid level. + /// * minGradientMagnitudes: For each pyramid level the pixels will be filtered out + /// if they have gradient magnitude less than minGradientMagnitudes[level]. + /// * transformType: Class of trasformation + /// /// ## Note /// This alternative version of [new] function uses the following default values for its arguments: - /// * mask: Mat() - /// * normals: Mat() - /// * id: -1 + /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() + /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() + /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() + /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() + /// * iter_counts: std::vector() + /// * min_gradient_magnitudes: std::vector() + /// * transform_type: Odometry::RIGID_BODY_MOTION #[inline] - pub fn new_def(image: &impl core::MatTraitConst, depth: &impl core::MatTraitConst) -> Result { + pub fn new_def(camera_matrix: &impl core::MatTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdFrame_RgbdFrame_const_MatR_const_MatR(image.as_raw_Mat(), depth.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdICPOdometry_RgbdICPOdometry_const_MatR(camera_matrix.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::RgbdFrame::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::RgbdICPOdometry::opencv_from_extern(ret) }; Ok(ret) } /// ## C++ default parameters - /// * image: Mat() - /// * depth: Mat() - /// * mask: Mat() - /// * normals: Mat() - /// * id: -1 - #[inline] - pub fn create(image: &impl core::MatTraitConst, depth: &impl core::MatTraitConst, mask: &impl core::MatTraitConst, normals: &impl core::MatTraitConst, id: i32) -> Result> { + /// * camera_matrix: Mat() + /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() + /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() + /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() + /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() + /// * iter_counts: std::vector() + /// * min_gradient_magnitudes: std::vector() + /// * transform_type: Odometry::RIGID_BODY_MOTION + #[inline] + pub fn create(camera_matrix: &impl core::MatTraitConst, min_depth: f32, max_depth: f32, max_depth_diff: f32, max_points_part: f32, iter_counts: &core::Vector, min_gradient_magnitudes: &core::Vector, transform_type: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdFrame_create_const_MatR_const_MatR_const_MatR_const_MatR_int(image.as_raw_Mat(), depth.as_raw_Mat(), mask.as_raw_Mat(), normals.as_raw_Mat(), id, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdICPOdometry_create_const_MatR_float_float_float_float_const_vectorLintGR_const_vectorLfloatGR_int(camera_matrix.as_raw_Mat(), min_depth, max_depth, max_depth_diff, max_points_part, iter_counts.as_raw_VectorOfi32(), min_gradient_magnitudes.as_raw_VectorOff32(), transform_type, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } /// ## Note - /// This alternative version of [RgbdFrame::create] function uses the following default values for its arguments: - /// * image: Mat() - /// * depth: Mat() - /// * mask: Mat() - /// * normals: Mat() - /// * id: -1 + /// This alternative version of [RgbdICPOdometry::create] function uses the following default values for its arguments: + /// * camera_matrix: Mat() + /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() + /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() + /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() + /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() + /// * iter_counts: std::vector() + /// * min_gradient_magnitudes: std::vector() + /// * transform_type: Odometry::RIGID_BODY_MOTION #[inline] - pub fn create_def() -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdFrame_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdICPOdometry_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_descendant! { RgbdFrame, crate::rgbd::OdometryFrame, cv_rgbd_RgbdFrame_to_OdometryFrame } - - impl std::fmt::Debug for RgbdFrame { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RgbdFrame") - .field("id", &crate::rgbd::RgbdFrameTraitConst::id(self)) - .field("image", &crate::rgbd::RgbdFrameTraitConst::image(self)) - .field("depth", &crate::rgbd::RgbdFrameTraitConst::depth(self)) - .field("mask", &crate::rgbd::RgbdFrameTraitConst::mask(self)) - .field("normals", &crate::rgbd::RgbdFrameTraitConst::normals(self)) - .finish() - } - } - /// Constant methods for [crate::rgbd::RgbdICPOdometry] pub trait RgbdICPOdometryTraitConst: crate::rgbd::OdometryTraitConst { fn as_raw_RgbdICPOdometry(&self) -> *const c_void; @@ -6824,21 +6955,17 @@ pub mod rgbd { } - /// Odometry that merges RgbdOdometry and ICPOdometry by minimize sum of their energy functions. - pub struct RgbdICPOdometry { - ptr: *mut c_void, - } - - opencv_type_boxed! { RgbdICPOdometry } - - impl Drop for RgbdICPOdometry { + impl std::fmt::Debug for RgbdICPOdometry { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_rgbd_RgbdICPOdometry_delete(self.as_raw_mut_RgbdICPOdometry()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RgbdICPOdometry") + .finish() } } - unsafe impl Send for RgbdICPOdometry {} + boxed_cast_base! { RgbdICPOdometry, core::Algorithm, cv_rgbd_RgbdICPOdometry_to_Algorithm } + + boxed_cast_base! { RgbdICPOdometry, crate::rgbd::Odometry, cv_rgbd_RgbdICPOdometry_to_Odometry } impl core::AlgorithmTraitConst for RgbdICPOdometry { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -6870,133 +6997,119 @@ pub mod rgbd { boxed_ref! { RgbdICPOdometry, crate::rgbd::RgbdICPOdometryTraitConst, as_raw_RgbdICPOdometry, crate::rgbd::RgbdICPOdometryTrait, as_raw_mut_RgbdICPOdometry } - impl RgbdICPOdometry { + /// Object that can compute the normals in an image. + /// It is an object as it can cache data for speed efficiency + /// The implemented methods are either: + /// - FALS (the fastest) and SRI from + /// ``Fast and Accurate Computation of Surface Normals from Range Images`` + /// by H. Badino, D. Huber, Y. Park and T. Kanade + /// - the normals with bilateral filtering on a depth image from + /// ``Gradient Response Maps for Real-Time Detection of Texture-Less Objects`` + /// by S. Hinterstoisser, C. Cagniart, S. Ilic, P. Sturm, N. Navab, P. Fua, and V. Lepetit + pub struct RgbdNormals { + ptr: *mut c_void, + } + + opencv_type_boxed! { RgbdNormals } + + impl Drop for RgbdNormals { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_rgbd_RgbdNormals_delete(self.as_raw_mut_RgbdNormals()) }; + } + } + + unsafe impl Send for RgbdNormals {} + + impl RgbdNormals { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdICPOdometry_RgbdICPOdometry(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdNormals_RgbdNormals(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::RgbdICPOdometry::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::RgbdNormals::opencv_from_extern(ret) }; Ok(ret) } - /// Constructor. + /// Constructor /// ## Parameters - /// * cameraMatrix: Camera matrix - /// * minDepth: Pixels with depth less than minDepth will not be used - /// * maxDepth: Pixels with depth larger than maxDepth will not be used - /// * maxDepthDiff: Correspondences between pixels of two given frames will be filtered out - /// if their depth difference is larger than maxDepthDiff - /// * maxPointsPart: The method uses a random pixels subset of size frameWidth x frameHeight x pointsPart - /// * iterCounts: Count of iterations on each pyramid level. - /// * minGradientMagnitudes: For each pyramid level the pixels will be filtered out - /// if they have gradient magnitude less than minGradientMagnitudes[level]. - /// * transformType: Class of trasformation + /// * rows: the number of rows of the depth image normals will be computed on + /// * cols: the number of cols of the depth image normals will be computed on + /// * depth: the depth of the normals (only CV_32F or CV_64F) + /// * K: the calibration matrix to use + /// * window_size: the window size to compute the normals: can only be 1,3,5 or 7 + /// * method: one of the methods to use: RGBD_NORMALS_METHOD_SRI, RGBD_NORMALS_METHOD_FALS /// /// ## C++ default parameters - /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() - /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() - /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() - /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() - /// * iter_counts: std::vector() - /// * min_gradient_magnitudes: std::vector() - /// * transform_type: Odometry::RIGID_BODY_MOTION + /// * window_size: 5 + /// * method: RgbdNormals::RGBD_NORMALS_METHOD_FALS #[inline] - pub fn new(camera_matrix: &impl core::MatTraitConst, min_depth: f32, max_depth: f32, max_depth_diff: f32, max_points_part: f32, iter_counts: &core::Vector, min_gradient_magnitudes: &core::Vector, transform_type: i32) -> Result { + pub fn new(rows: i32, cols: i32, depth: i32, k: &impl ToInputArray, window_size: i32, method: i32) -> Result { + input_array_arg!(k); return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdICPOdometry_RgbdICPOdometry_const_MatR_float_float_float_float_const_vectorLintGR_const_vectorLfloatGR_int(camera_matrix.as_raw_Mat(), min_depth, max_depth, max_depth_diff, max_points_part, iter_counts.as_raw_VectorOfi32(), min_gradient_magnitudes.as_raw_VectorOff32(), transform_type, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdNormals_RgbdNormals_int_int_int_const__InputArrayR_int_int(rows, cols, depth, k.as_raw__InputArray(), window_size, method, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::RgbdICPOdometry::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::RgbdNormals::opencv_from_extern(ret) }; Ok(ret) } - /// Constructor. + /// Constructor /// ## Parameters - /// * cameraMatrix: Camera matrix - /// * minDepth: Pixels with depth less than minDepth will not be used - /// * maxDepth: Pixels with depth larger than maxDepth will not be used - /// * maxDepthDiff: Correspondences between pixels of two given frames will be filtered out - /// if their depth difference is larger than maxDepthDiff - /// * maxPointsPart: The method uses a random pixels subset of size frameWidth x frameHeight x pointsPart - /// * iterCounts: Count of iterations on each pyramid level. - /// * minGradientMagnitudes: For each pyramid level the pixels will be filtered out - /// if they have gradient magnitude less than minGradientMagnitudes[level]. - /// * transformType: Class of trasformation + /// * rows: the number of rows of the depth image normals will be computed on + /// * cols: the number of cols of the depth image normals will be computed on + /// * depth: the depth of the normals (only CV_32F or CV_64F) + /// * K: the calibration matrix to use + /// * window_size: the window size to compute the normals: can only be 1,3,5 or 7 + /// * method: one of the methods to use: RGBD_NORMALS_METHOD_SRI, RGBD_NORMALS_METHOD_FALS /// /// ## Note /// This alternative version of [new] function uses the following default values for its arguments: - /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() - /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() - /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() - /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() - /// * iter_counts: std::vector() - /// * min_gradient_magnitudes: std::vector() - /// * transform_type: Odometry::RIGID_BODY_MOTION + /// * window_size: 5 + /// * method: RgbdNormals::RGBD_NORMALS_METHOD_FALS #[inline] - pub fn new_def(camera_matrix: &impl core::MatTraitConst) -> Result { + pub fn new_def(rows: i32, cols: i32, depth: i32, k: &impl ToInputArray) -> Result { + input_array_arg!(k); return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdICPOdometry_RgbdICPOdometry_const_MatR(camera_matrix.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdNormals_RgbdNormals_int_int_int_const__InputArrayR(rows, cols, depth, k.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::RgbdICPOdometry::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::RgbdNormals::opencv_from_extern(ret) }; Ok(ret) } /// ## C++ default parameters - /// * camera_matrix: Mat() - /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() - /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() - /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() - /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() - /// * iter_counts: std::vector() - /// * min_gradient_magnitudes: std::vector() - /// * transform_type: Odometry::RIGID_BODY_MOTION + /// * window_size: 5 + /// * method: RgbdNormals::RGBD_NORMALS_METHOD_FALS #[inline] - pub fn create(camera_matrix: &impl core::MatTraitConst, min_depth: f32, max_depth: f32, max_depth_diff: f32, max_points_part: f32, iter_counts: &core::Vector, min_gradient_magnitudes: &core::Vector, transform_type: i32) -> Result> { + pub fn create(rows: i32, cols: i32, depth: i32, k: &impl ToInputArray, window_size: i32, method: i32) -> Result> { + input_array_arg!(k); return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdICPOdometry_create_const_MatR_float_float_float_float_const_vectorLintGR_const_vectorLfloatGR_int(camera_matrix.as_raw_Mat(), min_depth, max_depth, max_depth_diff, max_points_part, iter_counts.as_raw_VectorOfi32(), min_gradient_magnitudes.as_raw_VectorOff32(), transform_type, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdNormals_create_int_int_int_const__InputArrayR_int_int(rows, cols, depth, k.as_raw__InputArray(), window_size, method, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } /// ## Note - /// This alternative version of [RgbdICPOdometry::create] function uses the following default values for its arguments: - /// * camera_matrix: Mat() - /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() - /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() - /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() - /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() - /// * iter_counts: std::vector() - /// * min_gradient_magnitudes: std::vector() - /// * transform_type: Odometry::RIGID_BODY_MOTION + /// This alternative version of [RgbdNormals::create] function uses the following default values for its arguments: + /// * window_size: 5 + /// * method: RgbdNormals::RGBD_NORMALS_METHOD_FALS #[inline] - pub fn create_def() -> Result> { + pub fn create_def(rows: i32, cols: i32, depth: i32, k: &impl ToInputArray) -> Result> { + input_array_arg!(k); return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdICPOdometry_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdNormals_create_int_int_int_const__InputArrayR(rows, cols, depth, k.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { RgbdICPOdometry, core::Algorithm, cv_rgbd_RgbdICPOdometry_to_Algorithm } - - boxed_cast_base! { RgbdICPOdometry, crate::rgbd::Odometry, cv_rgbd_RgbdICPOdometry_to_Odometry } - - impl std::fmt::Debug for RgbdICPOdometry { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RgbdICPOdometry") - .finish() - } - } - /// Constant methods for [crate::rgbd::RgbdNormals] pub trait RgbdNormalsTraitConst: core::AlgorithmTraitConst { fn as_raw_RgbdNormals(&self) -> *const c_void; @@ -7144,29 +7257,15 @@ pub mod rgbd { } - /// Object that can compute the normals in an image. - /// It is an object as it can cache data for speed efficiency - /// The implemented methods are either: - /// - FALS (the fastest) and SRI from - /// ``Fast and Accurate Computation of Surface Normals from Range Images`` - /// by H. Badino, D. Huber, Y. Park and T. Kanade - /// - the normals with bilateral filtering on a depth image from - /// ``Gradient Response Maps for Real-Time Detection of Texture-Less Objects`` - /// by S. Hinterstoisser, C. Cagniart, S. Ilic, P. Sturm, N. Navab, P. Fua, and V. Lepetit - pub struct RgbdNormals { - ptr: *mut c_void, - } - - opencv_type_boxed! { RgbdNormals } - - impl Drop for RgbdNormals { + impl std::fmt::Debug for RgbdNormals { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_rgbd_RgbdNormals_delete(self.as_raw_mut_RgbdNormals()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RgbdNormals") + .finish() } } - unsafe impl Send for RgbdNormals {} + boxed_cast_base! { RgbdNormals, core::Algorithm, cv_rgbd_RgbdNormals_to_Algorithm } impl core::AlgorithmTraitConst for RgbdNormals { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -7188,105 +7287,138 @@ pub mod rgbd { boxed_ref! { RgbdNormals, crate::rgbd::RgbdNormalsTraitConst, as_raw_RgbdNormals, crate::rgbd::RgbdNormalsTrait, as_raw_mut_RgbdNormals } - impl RgbdNormals { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdNormals_RgbdNormals(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::RgbdNormals::opencv_from_extern(ret) }; - Ok(ret) - } + /// Odometry based on the paper "Real-Time Visual Odometry from Dense RGB-D Images", + /// F. Steinbucker, J. Strum, D. Cremers, ICCV, 2011. + pub struct RgbdOdometry { + ptr: *mut c_void, + } - /// Constructor + opencv_type_boxed! { RgbdOdometry } + + impl Drop for RgbdOdometry { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_rgbd_RgbdOdometry_delete(self.as_raw_mut_RgbdOdometry()) }; + } + } + + unsafe impl Send for RgbdOdometry {} + + impl RgbdOdometry { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_rgbd_RgbdOdometry_RgbdOdometry(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::rgbd::RgbdOdometry::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Constructor. /// ## Parameters - /// * rows: the number of rows of the depth image normals will be computed on - /// * cols: the number of cols of the depth image normals will be computed on - /// * depth: the depth of the normals (only CV_32F or CV_64F) - /// * K: the calibration matrix to use - /// * window_size: the window size to compute the normals: can only be 1,3,5 or 7 - /// * method: one of the methods to use: RGBD_NORMALS_METHOD_SRI, RGBD_NORMALS_METHOD_FALS + /// * cameraMatrix: Camera matrix + /// * minDepth: Pixels with depth less than minDepth will not be used (in meters) + /// * maxDepth: Pixels with depth larger than maxDepth will not be used (in meters) + /// * maxDepthDiff: Correspondences between pixels of two given frames will be filtered out + /// if their depth difference is larger than maxDepthDiff (in meters) + /// * iterCounts: Count of iterations on each pyramid level. + /// * minGradientMagnitudes: For each pyramid level the pixels will be filtered out + /// if they have gradient magnitude less than minGradientMagnitudes[level]. + /// * maxPointsPart: The method uses a random pixels subset of size frameWidth x frameHeight x pointsPart + /// * transformType: Class of transformation /// /// ## C++ default parameters - /// * window_size: 5 - /// * method: RgbdNormals::RGBD_NORMALS_METHOD_FALS + /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() + /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() + /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() + /// * iter_counts: std::vector() + /// * min_gradient_magnitudes: std::vector() + /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() + /// * transform_type: Odometry::RIGID_BODY_MOTION #[inline] - pub fn new(rows: i32, cols: i32, depth: i32, k: &impl ToInputArray, window_size: i32, method: i32) -> Result { - input_array_arg!(k); + pub fn new(camera_matrix: &impl core::MatTraitConst, min_depth: f32, max_depth: f32, max_depth_diff: f32, iter_counts: &core::Vector, min_gradient_magnitudes: &core::Vector, max_points_part: f32, transform_type: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdNormals_RgbdNormals_int_int_int_const__InputArrayR_int_int(rows, cols, depth, k.as_raw__InputArray(), window_size, method, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdOdometry_RgbdOdometry_const_MatR_float_float_float_const_vectorLintGR_const_vectorLfloatGR_float_int(camera_matrix.as_raw_Mat(), min_depth, max_depth, max_depth_diff, iter_counts.as_raw_VectorOfi32(), min_gradient_magnitudes.as_raw_VectorOff32(), max_points_part, transform_type, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::RgbdNormals::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::RgbdOdometry::opencv_from_extern(ret) }; Ok(ret) } - /// Constructor + /// Constructor. /// ## Parameters - /// * rows: the number of rows of the depth image normals will be computed on - /// * cols: the number of cols of the depth image normals will be computed on - /// * depth: the depth of the normals (only CV_32F or CV_64F) - /// * K: the calibration matrix to use - /// * window_size: the window size to compute the normals: can only be 1,3,5 or 7 - /// * method: one of the methods to use: RGBD_NORMALS_METHOD_SRI, RGBD_NORMALS_METHOD_FALS + /// * cameraMatrix: Camera matrix + /// * minDepth: Pixels with depth less than minDepth will not be used (in meters) + /// * maxDepth: Pixels with depth larger than maxDepth will not be used (in meters) + /// * maxDepthDiff: Correspondences between pixels of two given frames will be filtered out + /// if their depth difference is larger than maxDepthDiff (in meters) + /// * iterCounts: Count of iterations on each pyramid level. + /// * minGradientMagnitudes: For each pyramid level the pixels will be filtered out + /// if they have gradient magnitude less than minGradientMagnitudes[level]. + /// * maxPointsPart: The method uses a random pixels subset of size frameWidth x frameHeight x pointsPart + /// * transformType: Class of transformation /// /// ## Note /// This alternative version of [new] function uses the following default values for its arguments: - /// * window_size: 5 - /// * method: RgbdNormals::RGBD_NORMALS_METHOD_FALS + /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() + /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() + /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() + /// * iter_counts: std::vector() + /// * min_gradient_magnitudes: std::vector() + /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() + /// * transform_type: Odometry::RIGID_BODY_MOTION #[inline] - pub fn new_def(rows: i32, cols: i32, depth: i32, k: &impl ToInputArray) -> Result { - input_array_arg!(k); + pub fn new_def(camera_matrix: &impl core::MatTraitConst) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdNormals_RgbdNormals_int_int_int_const__InputArrayR(rows, cols, depth, k.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdOdometry_RgbdOdometry_const_MatR(camera_matrix.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::RgbdNormals::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::RgbdOdometry::opencv_from_extern(ret) }; Ok(ret) } /// ## C++ default parameters - /// * window_size: 5 - /// * method: RgbdNormals::RGBD_NORMALS_METHOD_FALS + /// * camera_matrix: Mat() + /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() + /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() + /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() + /// * iter_counts: std::vector() + /// * min_gradient_magnitudes: std::vector() + /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() + /// * transform_type: Odometry::RIGID_BODY_MOTION #[inline] - pub fn create(rows: i32, cols: i32, depth: i32, k: &impl ToInputArray, window_size: i32, method: i32) -> Result> { - input_array_arg!(k); + pub fn create(camera_matrix: &impl core::MatTraitConst, min_depth: f32, max_depth: f32, max_depth_diff: f32, iter_counts: &core::Vector, min_gradient_magnitudes: &core::Vector, max_points_part: f32, transform_type: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdNormals_create_int_int_int_const__InputArrayR_int_int(rows, cols, depth, k.as_raw__InputArray(), window_size, method, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdOdometry_create_const_MatR_float_float_float_const_vectorLintGR_const_vectorLfloatGR_float_int(camera_matrix.as_raw_Mat(), min_depth, max_depth, max_depth_diff, iter_counts.as_raw_VectorOfi32(), min_gradient_magnitudes.as_raw_VectorOff32(), max_points_part, transform_type, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } /// ## Note - /// This alternative version of [RgbdNormals::create] function uses the following default values for its arguments: - /// * window_size: 5 - /// * method: RgbdNormals::RGBD_NORMALS_METHOD_FALS + /// This alternative version of [RgbdOdometry::create] function uses the following default values for its arguments: + /// * camera_matrix: Mat() + /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() + /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() + /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() + /// * iter_counts: std::vector() + /// * min_gradient_magnitudes: std::vector() + /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() + /// * transform_type: Odometry::RIGID_BODY_MOTION #[inline] - pub fn create_def(rows: i32, cols: i32, depth: i32, k: &impl ToInputArray) -> Result> { - input_array_arg!(k); + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdNormals_create_int_int_int_const__InputArrayR(rows, cols, depth, k.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdOdometry_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { RgbdNormals, core::Algorithm, cv_rgbd_RgbdNormals_to_Algorithm } - - impl std::fmt::Debug for RgbdNormals { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RgbdNormals") - .finish() - } - } - /// Constant methods for [crate::rgbd::RgbdOdometry] pub trait RgbdOdometryTraitConst: crate::rgbd::OdometryTraitConst { fn as_raw_RgbdOdometry(&self) -> *const c_void; @@ -7491,22 +7623,17 @@ pub mod rgbd { } - /// Odometry based on the paper "Real-Time Visual Odometry from Dense RGB-D Images", - /// F. Steinbucker, J. Strum, D. Cremers, ICCV, 2011. - pub struct RgbdOdometry { - ptr: *mut c_void, - } - - opencv_type_boxed! { RgbdOdometry } - - impl Drop for RgbdOdometry { + impl std::fmt::Debug for RgbdOdometry { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_rgbd_RgbdOdometry_delete(self.as_raw_mut_RgbdOdometry()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RgbdOdometry") + .finish() } } - unsafe impl Send for RgbdOdometry {} + boxed_cast_base! { RgbdOdometry, core::Algorithm, cv_rgbd_RgbdOdometry_to_Algorithm } + + boxed_cast_base! { RgbdOdometry, crate::rgbd::Odometry, cv_rgbd_RgbdOdometry_to_Odometry } impl core::AlgorithmTraitConst for RgbdOdometry { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -7538,133 +7665,128 @@ pub mod rgbd { boxed_ref! { RgbdOdometry, crate::rgbd::RgbdOdometryTraitConst, as_raw_RgbdOdometry, crate::rgbd::RgbdOdometryTrait, as_raw_mut_RgbdOdometry } - impl RgbdOdometry { + /// Object that can compute planes in an image + pub struct RgbdPlane { + ptr: *mut c_void, + } + + opencv_type_boxed! { RgbdPlane } + + impl Drop for RgbdPlane { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_rgbd_RgbdPlane_delete(self.as_raw_mut_RgbdPlane()) }; + } + } + + unsafe impl Send for RgbdPlane {} + + impl RgbdPlane { + /// ## C++ default parameters + /// * method: RgbdPlane::RGBD_PLANE_METHOD_DEFAULT + #[inline] + pub fn new(method: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdOdometry_RgbdOdometry(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdPlane_RgbdPlane_int(method, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::RgbdOdometry::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::RgbdPlane::opencv_from_extern(ret) }; Ok(ret) } - /// Constructor. + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * method: RgbdPlane::RGBD_PLANE_METHOD_DEFAULT + #[inline] + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_rgbd_RgbdPlane_RgbdPlane(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::rgbd::RgbdPlane::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Constructor /// ## Parameters - /// * cameraMatrix: Camera matrix - /// * minDepth: Pixels with depth less than minDepth will not be used (in meters) - /// * maxDepth: Pixels with depth larger than maxDepth will not be used (in meters) - /// * maxDepthDiff: Correspondences between pixels of two given frames will be filtered out - /// if their depth difference is larger than maxDepthDiff (in meters) - /// * iterCounts: Count of iterations on each pyramid level. - /// * minGradientMagnitudes: For each pyramid level the pixels will be filtered out - /// if they have gradient magnitude less than minGradientMagnitudes[level]. - /// * maxPointsPart: The method uses a random pixels subset of size frameWidth x frameHeight x pointsPart - /// * transformType: Class of transformation + /// * block_size: The size of the blocks to look at for a stable MSE + /// * min_size: The minimum size of a cluster to be considered a plane + /// * threshold: The maximum distance of a point from a plane to belong to it (in meters) + /// * sensor_error_a: coefficient of the sensor error. 0 by default, 0.0075 for a Kinect + /// * sensor_error_b: coefficient of the sensor error. 0 by default + /// * sensor_error_c: coefficient of the sensor error. 0 by default + /// * method: The method to use to compute the planes. /// /// ## C++ default parameters - /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() - /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() - /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() - /// * iter_counts: std::vector() - /// * min_gradient_magnitudes: std::vector() - /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() - /// * transform_type: Odometry::RIGID_BODY_MOTION + /// * sensor_error_a: 0 + /// * sensor_error_b: 0 + /// * sensor_error_c: 0 #[inline] - pub fn new(camera_matrix: &impl core::MatTraitConst, min_depth: f32, max_depth: f32, max_depth_diff: f32, iter_counts: &core::Vector, min_gradient_magnitudes: &core::Vector, max_points_part: f32, transform_type: i32) -> Result { + pub fn new_1(method: i32, block_size: i32, min_size: i32, threshold: f64, sensor_error_a: f64, sensor_error_b: f64, sensor_error_c: f64) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdOdometry_RgbdOdometry_const_MatR_float_float_float_const_vectorLintGR_const_vectorLfloatGR_float_int(camera_matrix.as_raw_Mat(), min_depth, max_depth, max_depth_diff, iter_counts.as_raw_VectorOfi32(), min_gradient_magnitudes.as_raw_VectorOff32(), max_points_part, transform_type, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdPlane_RgbdPlane_int_int_int_double_double_double_double(method, block_size, min_size, threshold, sensor_error_a, sensor_error_b, sensor_error_c, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::RgbdOdometry::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::RgbdPlane::opencv_from_extern(ret) }; Ok(ret) } - /// Constructor. + /// Constructor /// ## Parameters - /// * cameraMatrix: Camera matrix - /// * minDepth: Pixels with depth less than minDepth will not be used (in meters) - /// * maxDepth: Pixels with depth larger than maxDepth will not be used (in meters) - /// * maxDepthDiff: Correspondences between pixels of two given frames will be filtered out - /// if their depth difference is larger than maxDepthDiff (in meters) - /// * iterCounts: Count of iterations on each pyramid level. - /// * minGradientMagnitudes: For each pyramid level the pixels will be filtered out - /// if they have gradient magnitude less than minGradientMagnitudes[level]. - /// * maxPointsPart: The method uses a random pixels subset of size frameWidth x frameHeight x pointsPart - /// * transformType: Class of transformation + /// * block_size: The size of the blocks to look at for a stable MSE + /// * min_size: The minimum size of a cluster to be considered a plane + /// * threshold: The maximum distance of a point from a plane to belong to it (in meters) + /// * sensor_error_a: coefficient of the sensor error. 0 by default, 0.0075 for a Kinect + /// * sensor_error_b: coefficient of the sensor error. 0 by default + /// * sensor_error_c: coefficient of the sensor error. 0 by default + /// * method: The method to use to compute the planes. /// /// ## Note /// This alternative version of [new] function uses the following default values for its arguments: - /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() - /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() - /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() - /// * iter_counts: std::vector() - /// * min_gradient_magnitudes: std::vector() - /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() - /// * transform_type: Odometry::RIGID_BODY_MOTION + /// * sensor_error_a: 0 + /// * sensor_error_b: 0 + /// * sensor_error_c: 0 #[inline] - pub fn new_def(camera_matrix: &impl core::MatTraitConst) -> Result { + pub fn new_def_1(method: i32, block_size: i32, min_size: i32, threshold: f64) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdOdometry_RgbdOdometry_const_MatR(camera_matrix.as_raw_Mat(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdPlane_RgbdPlane_int_int_int_double(method, block_size, min_size, threshold, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::RgbdOdometry::opencv_from_extern(ret) }; + let ret = unsafe { crate::rgbd::RgbdPlane::opencv_from_extern(ret) }; Ok(ret) } /// ## C++ default parameters - /// * camera_matrix: Mat() - /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() - /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() - /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() - /// * iter_counts: std::vector() - /// * min_gradient_magnitudes: std::vector() - /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() - /// * transform_type: Odometry::RIGID_BODY_MOTION + /// * sensor_error_a: 0 + /// * sensor_error_b: 0 + /// * sensor_error_c: 0 #[inline] - pub fn create(camera_matrix: &impl core::MatTraitConst, min_depth: f32, max_depth: f32, max_depth_diff: f32, iter_counts: &core::Vector, min_gradient_magnitudes: &core::Vector, max_points_part: f32, transform_type: i32) -> Result> { + pub fn create(method: i32, block_size: i32, min_size: i32, threshold: f64, sensor_error_a: f64, sensor_error_b: f64, sensor_error_c: f64) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdOdometry_create_const_MatR_float_float_float_const_vectorLintGR_const_vectorLfloatGR_float_int(camera_matrix.as_raw_Mat(), min_depth, max_depth, max_depth_diff, iter_counts.as_raw_VectorOfi32(), min_gradient_magnitudes.as_raw_VectorOff32(), max_points_part, transform_type, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdPlane_create_int_int_int_double_double_double_double(method, block_size, min_size, threshold, sensor_error_a, sensor_error_b, sensor_error_c, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } /// ## Note - /// This alternative version of [RgbdOdometry::create] function uses the following default values for its arguments: - /// * camera_matrix: Mat() - /// * min_depth: Odometry::DEFAULT_MIN_DEPTH() - /// * max_depth: Odometry::DEFAULT_MAX_DEPTH() - /// * max_depth_diff: Odometry::DEFAULT_MAX_DEPTH_DIFF() - /// * iter_counts: std::vector() - /// * min_gradient_magnitudes: std::vector() - /// * max_points_part: Odometry::DEFAULT_MAX_POINTS_PART() - /// * transform_type: Odometry::RIGID_BODY_MOTION + /// This alternative version of [RgbdPlane::create] function uses the following default values for its arguments: + /// * sensor_error_a: 0 + /// * sensor_error_b: 0 + /// * sensor_error_c: 0 #[inline] - pub fn create_def() -> Result> { + pub fn create_def(method: i32, block_size: i32, min_size: i32, threshold: f64) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdOdometry_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_rgbd_RgbdPlane_create_int_int_int_double(method, block_size, min_size, threshold, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { RgbdOdometry, core::Algorithm, cv_rgbd_RgbdOdometry_to_Algorithm } - - boxed_cast_base! { RgbdOdometry, crate::rgbd::Odometry, cv_rgbd_RgbdOdometry_to_Odometry } - - impl std::fmt::Debug for RgbdOdometry { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RgbdOdometry") - .finish() - } - } - /// Constant methods for [crate::rgbd::RgbdPlane] pub trait RgbdPlaneTraitConst: core::AlgorithmTraitConst { fn as_raw_RgbdPlane(&self) -> *const c_void; @@ -7842,21 +7964,15 @@ pub mod rgbd { } - /// Object that can compute planes in an image - pub struct RgbdPlane { - ptr: *mut c_void, - } - - opencv_type_boxed! { RgbdPlane } - - impl Drop for RgbdPlane { + impl std::fmt::Debug for RgbdPlane { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_rgbd_RgbdPlane_delete(self.as_raw_mut_RgbdPlane()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RgbdPlane") + .finish() } } - unsafe impl Send for RgbdPlane {} + boxed_cast_base! { RgbdPlane, core::Algorithm, cv_rgbd_RgbdPlane_to_Algorithm } impl core::AlgorithmTraitConst for RgbdPlane { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -7878,119 +7994,4 @@ pub mod rgbd { boxed_ref! { RgbdPlane, crate::rgbd::RgbdPlaneTraitConst, as_raw_RgbdPlane, crate::rgbd::RgbdPlaneTrait, as_raw_mut_RgbdPlane } - impl RgbdPlane { - /// ## C++ default parameters - /// * method: RgbdPlane::RGBD_PLANE_METHOD_DEFAULT - #[inline] - pub fn new(method: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdPlane_RgbdPlane_int(method, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::RgbdPlane::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * method: RgbdPlane::RGBD_PLANE_METHOD_DEFAULT - #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdPlane_RgbdPlane(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::RgbdPlane::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Constructor - /// ## Parameters - /// * block_size: The size of the blocks to look at for a stable MSE - /// * min_size: The minimum size of a cluster to be considered a plane - /// * threshold: The maximum distance of a point from a plane to belong to it (in meters) - /// * sensor_error_a: coefficient of the sensor error. 0 by default, 0.0075 for a Kinect - /// * sensor_error_b: coefficient of the sensor error. 0 by default - /// * sensor_error_c: coefficient of the sensor error. 0 by default - /// * method: The method to use to compute the planes. - /// - /// ## C++ default parameters - /// * sensor_error_a: 0 - /// * sensor_error_b: 0 - /// * sensor_error_c: 0 - #[inline] - pub fn new_1(method: i32, block_size: i32, min_size: i32, threshold: f64, sensor_error_a: f64, sensor_error_b: f64, sensor_error_c: f64) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdPlane_RgbdPlane_int_int_int_double_double_double_double(method, block_size, min_size, threshold, sensor_error_a, sensor_error_b, sensor_error_c, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::RgbdPlane::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Constructor - /// ## Parameters - /// * block_size: The size of the blocks to look at for a stable MSE - /// * min_size: The minimum size of a cluster to be considered a plane - /// * threshold: The maximum distance of a point from a plane to belong to it (in meters) - /// * sensor_error_a: coefficient of the sensor error. 0 by default, 0.0075 for a Kinect - /// * sensor_error_b: coefficient of the sensor error. 0 by default - /// * sensor_error_c: coefficient of the sensor error. 0 by default - /// * method: The method to use to compute the planes. - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * sensor_error_a: 0 - /// * sensor_error_b: 0 - /// * sensor_error_c: 0 - #[inline] - pub fn new_def_1(method: i32, block_size: i32, min_size: i32, threshold: f64) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdPlane_RgbdPlane_int_int_int_double(method, block_size, min_size, threshold, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::rgbd::RgbdPlane::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## C++ default parameters - /// * sensor_error_a: 0 - /// * sensor_error_b: 0 - /// * sensor_error_c: 0 - #[inline] - pub fn create(method: i32, block_size: i32, min_size: i32, threshold: f64, sensor_error_a: f64, sensor_error_b: f64, sensor_error_c: f64) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdPlane_create_int_int_int_double_double_double_double(method, block_size, min_size, threshold, sensor_error_a, sensor_error_b, sensor_error_c, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [RgbdPlane::create] function uses the following default values for its arguments: - /// * sensor_error_a: 0 - /// * sensor_error_b: 0 - /// * sensor_error_c: 0 - #[inline] - pub fn create_def(method: i32, block_size: i32, min_size: i32, threshold: f64) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_rgbd_RgbdPlane_create_int_int_int_double(method, block_size, min_size, threshold, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { RgbdPlane, core::Algorithm, cv_rgbd_RgbdPlane_to_Algorithm } - - impl std::fmt::Debug for RgbdPlane { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RgbdPlane") - .finish() - } - } } diff --git a/docs/saliency.rs b/docs/saliency.rs index 091c2f995..0f0ef156e 100644 --- a/docs/saliency.rs +++ b/docs/saliency.rs @@ -38,6 +38,22 @@ pub mod saliency { pub use super::{MotionSaliencyBinWangApr2014Trait, MotionSaliencyBinWangApr2014TraitConst, MotionSaliencyTrait, MotionSaliencyTraitConst, ObjectnessBINGTrait, ObjectnessBINGTraitConst, ObjectnessTrait, ObjectnessTraitConst, SaliencyTrait, SaliencyTraitConst, StaticSaliencyFineGrainedTrait, StaticSaliencyFineGrainedTraitConst, StaticSaliencySpectralResidualTrait, StaticSaliencySpectralResidualTraitConst, StaticSaliencyTrait, StaticSaliencyTraitConst}; } + /// ********************************* Motion Saliency Base Class *********************************** + pub struct MotionSaliency { + ptr: *mut c_void, + } + + opencv_type_boxed! { MotionSaliency } + + impl Drop for MotionSaliency { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_saliency_MotionSaliency_delete(self.as_raw_mut_MotionSaliency()) }; + } + } + + unsafe impl Send for MotionSaliency {} + /// Constant methods for [crate::saliency::MotionSaliency] pub trait MotionSaliencyTraitConst: crate::saliency::SaliencyTraitConst { fn as_raw_MotionSaliency(&self) -> *const c_void; @@ -50,21 +66,19 @@ pub mod saliency { } - /// ********************************* Motion Saliency Base Class *********************************** - pub struct MotionSaliency { - ptr: *mut c_void, - } - - opencv_type_boxed! { MotionSaliency } - - impl Drop for MotionSaliency { + impl std::fmt::Debug for MotionSaliency { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_saliency_MotionSaliency_delete(self.as_raw_mut_MotionSaliency()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MotionSaliency") + .finish() } } - unsafe impl Send for MotionSaliency {} + boxed_cast_base! { MotionSaliency, core::Algorithm, cv_saliency_MotionSaliency_to_Algorithm } + + boxed_cast_base! { MotionSaliency, crate::saliency::Saliency, cv_saliency_MotionSaliency_to_Saliency } + + boxed_cast_descendant! { MotionSaliency, crate::saliency::MotionSaliencyBinWangApr2014, cv_saliency_MotionSaliency_to_MotionSaliencyBinWangApr2014 } impl core::AlgorithmTraitConst for MotionSaliency { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -96,21 +110,50 @@ pub mod saliency { boxed_ref! { MotionSaliency, crate::saliency::MotionSaliencyTraitConst, as_raw_MotionSaliency, crate::saliency::MotionSaliencyTrait, as_raw_mut_MotionSaliency } - impl MotionSaliency { + /// ! + /// * A Fast Self-tuning Background Subtraction Algorithm. + /// * + /// * This background subtraction algorithm is inspired to the work of B. Wang and P. Dudek [2] + /// * [2] B. Wang and P. Dudek "A Fast Self-tuning Background Subtraction Algorithm", in proc of IEEE Workshop on Change Detection, 2014 + /// * + /// + /// the Fast Self-tuning Background Subtraction Algorithm from [BinWangApr2014](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_BinWangApr2014) + pub struct MotionSaliencyBinWangApr2014 { + ptr: *mut c_void, } - boxed_cast_descendant! { MotionSaliency, crate::saliency::MotionSaliencyBinWangApr2014, cv_saliency_MotionSaliency_to_MotionSaliencyBinWangApr2014 } + opencv_type_boxed! { MotionSaliencyBinWangApr2014 } - boxed_cast_base! { MotionSaliency, core::Algorithm, cv_saliency_MotionSaliency_to_Algorithm } + impl Drop for MotionSaliencyBinWangApr2014 { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_saliency_MotionSaliencyBinWangApr2014_delete(self.as_raw_mut_MotionSaliencyBinWangApr2014()) }; + } + } - boxed_cast_base! { MotionSaliency, crate::saliency::Saliency, cv_saliency_MotionSaliency_to_Saliency } + unsafe impl Send for MotionSaliencyBinWangApr2014 {} - impl std::fmt::Debug for MotionSaliency { + impl MotionSaliencyBinWangApr2014 { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MotionSaliency") - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_saliency_MotionSaliencyBinWangApr2014_MotionSaliencyBinWangApr2014(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::saliency::MotionSaliencyBinWangApr2014::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn create() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_saliency_MotionSaliencyBinWangApr2014_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::saliency::MotionSaliencyBinWangApr2014] @@ -197,28 +240,19 @@ pub mod saliency { } - /// ! - /// * A Fast Self-tuning Background Subtraction Algorithm. - /// * - /// * This background subtraction algorithm is inspired to the work of B. Wang and P. Dudek [2] - /// * [2] B. Wang and P. Dudek "A Fast Self-tuning Background Subtraction Algorithm", in proc of IEEE Workshop on Change Detection, 2014 - /// * - /// - /// the Fast Self-tuning Background Subtraction Algorithm from [BinWangApr2014](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_BinWangApr2014) - pub struct MotionSaliencyBinWangApr2014 { - ptr: *mut c_void, - } - - opencv_type_boxed! { MotionSaliencyBinWangApr2014 } - - impl Drop for MotionSaliencyBinWangApr2014 { + impl std::fmt::Debug for MotionSaliencyBinWangApr2014 { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_saliency_MotionSaliencyBinWangApr2014_delete(self.as_raw_mut_MotionSaliencyBinWangApr2014()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MotionSaliencyBinWangApr2014") + .finish() } } - unsafe impl Send for MotionSaliencyBinWangApr2014 {} + boxed_cast_base! { MotionSaliencyBinWangApr2014, core::Algorithm, cv_saliency_MotionSaliencyBinWangApr2014_to_Algorithm } + + boxed_cast_base! { MotionSaliencyBinWangApr2014, crate::saliency::MotionSaliency, cv_saliency_MotionSaliencyBinWangApr2014_to_MotionSaliency } + + boxed_cast_base! { MotionSaliencyBinWangApr2014, crate::saliency::Saliency, cv_saliency_MotionSaliencyBinWangApr2014_to_Saliency } impl core::AlgorithmTraitConst for MotionSaliencyBinWangApr2014 { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -260,43 +294,22 @@ pub mod saliency { boxed_ref! { MotionSaliencyBinWangApr2014, crate::saliency::MotionSaliencyBinWangApr2014TraitConst, as_raw_MotionSaliencyBinWangApr2014, crate::saliency::MotionSaliencyBinWangApr2014Trait, as_raw_mut_MotionSaliencyBinWangApr2014 } - impl MotionSaliencyBinWangApr2014 { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_saliency_MotionSaliencyBinWangApr2014_MotionSaliencyBinWangApr2014(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::saliency::MotionSaliencyBinWangApr2014::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn create() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_saliency_MotionSaliencyBinWangApr2014_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + /// ********************************* Objectness Base Class *********************************** + pub struct Objectness { + ptr: *mut c_void, } - boxed_cast_base! { MotionSaliencyBinWangApr2014, core::Algorithm, cv_saliency_MotionSaliencyBinWangApr2014_to_Algorithm } - - boxed_cast_base! { MotionSaliencyBinWangApr2014, crate::saliency::MotionSaliency, cv_saliency_MotionSaliencyBinWangApr2014_to_MotionSaliency } - - boxed_cast_base! { MotionSaliencyBinWangApr2014, crate::saliency::Saliency, cv_saliency_MotionSaliencyBinWangApr2014_to_Saliency } + opencv_type_boxed! { Objectness } - impl std::fmt::Debug for MotionSaliencyBinWangApr2014 { + impl Drop for Objectness { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MotionSaliencyBinWangApr2014") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_saliency_Objectness_delete(self.as_raw_mut_Objectness()) }; } } + unsafe impl Send for Objectness {} + /// Constant methods for [crate::saliency::Objectness] pub trait ObjectnessTraitConst: crate::saliency::SaliencyTraitConst { fn as_raw_Objectness(&self) -> *const c_void; @@ -309,21 +322,19 @@ pub mod saliency { } - /// ********************************* Objectness Base Class *********************************** - pub struct Objectness { - ptr: *mut c_void, - } - - opencv_type_boxed! { Objectness } - - impl Drop for Objectness { + impl std::fmt::Debug for Objectness { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_saliency_Objectness_delete(self.as_raw_mut_Objectness()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Objectness") + .finish() } } - unsafe impl Send for Objectness {} + boxed_cast_base! { Objectness, core::Algorithm, cv_saliency_Objectness_to_Algorithm } + + boxed_cast_base! { Objectness, crate::saliency::Saliency, cv_saliency_Objectness_to_Saliency } + + boxed_cast_descendant! { Objectness, crate::saliency::ObjectnessBING, cv_saliency_Objectness_to_ObjectnessBING } impl core::AlgorithmTraitConst for Objectness { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -355,21 +366,43 @@ pub mod saliency { boxed_ref! { Objectness, crate::saliency::ObjectnessTraitConst, as_raw_Objectness, crate::saliency::ObjectnessTrait, as_raw_mut_Objectness } - impl Objectness { + /// the Binarized normed gradients algorithm from [BING](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_BING) + pub struct ObjectnessBING { + ptr: *mut c_void, } - boxed_cast_descendant! { Objectness, crate::saliency::ObjectnessBING, cv_saliency_Objectness_to_ObjectnessBING } + opencv_type_boxed! { ObjectnessBING } - boxed_cast_base! { Objectness, core::Algorithm, cv_saliency_Objectness_to_Algorithm } + impl Drop for ObjectnessBING { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_saliency_ObjectnessBING_delete(self.as_raw_mut_ObjectnessBING()) }; + } + } - boxed_cast_base! { Objectness, crate::saliency::Saliency, cv_saliency_Objectness_to_Saliency } + unsafe impl Send for ObjectnessBING {} - impl std::fmt::Debug for Objectness { + impl ObjectnessBING { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Objectness") - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_saliency_ObjectnessBING_ObjectnessBING(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::saliency::ObjectnessBING::opencv_from_extern(ret) }; + Ok(ret) } + + #[inline] + pub fn create() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_saliency_ObjectnessBING_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + } /// Constant methods for [crate::saliency::ObjectnessBING] @@ -513,21 +546,19 @@ pub mod saliency { } - /// the Binarized normed gradients algorithm from [BING](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_BING) - pub struct ObjectnessBING { - ptr: *mut c_void, - } - - opencv_type_boxed! { ObjectnessBING } - - impl Drop for ObjectnessBING { + impl std::fmt::Debug for ObjectnessBING { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_saliency_ObjectnessBING_delete(self.as_raw_mut_ObjectnessBING()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ObjectnessBING") + .finish() } } - unsafe impl Send for ObjectnessBING {} + boxed_cast_base! { ObjectnessBING, core::Algorithm, cv_saliency_ObjectnessBING_to_Algorithm } + + boxed_cast_base! { ObjectnessBING, crate::saliency::Objectness, cv_saliency_ObjectnessBING_to_Objectness } + + boxed_cast_base! { ObjectnessBING, crate::saliency::Saliency, cv_saliency_ObjectnessBING_to_Saliency } impl core::AlgorithmTraitConst for ObjectnessBING { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -569,46 +600,25 @@ pub mod saliency { boxed_ref! { ObjectnessBING, crate::saliency::ObjectnessBINGTraitConst, as_raw_ObjectnessBING, crate::saliency::ObjectnessBINGTrait, as_raw_mut_ObjectnessBING } - impl ObjectnessBING { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_saliency_ObjectnessBING_ObjectnessBING(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::saliency::ObjectnessBING::opencv_from_extern(ret) }; - Ok(ret) - } + /// ********************************* Saliency Base Class *********************************** + pub struct Saliency { + ptr: *mut c_void, + } + + opencv_type_boxed! { Saliency } + impl Drop for Saliency { #[inline] - pub fn create() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_saliency_ObjectnessBING_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_saliency_Saliency_delete(self.as_raw_mut_Saliency()) }; } - } - boxed_cast_base! { ObjectnessBING, core::Algorithm, cv_saliency_ObjectnessBING_to_Algorithm } + unsafe impl Send for Saliency {} - boxed_cast_base! { ObjectnessBING, crate::saliency::Objectness, cv_saliency_ObjectnessBING_to_Objectness } - - boxed_cast_base! { ObjectnessBING, crate::saliency::Saliency, cv_saliency_ObjectnessBING_to_Saliency } - - impl std::fmt::Debug for ObjectnessBING { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ObjectnessBING") - .finish() - } - } - - /// Constant methods for [crate::saliency::Saliency] - pub trait SaliencyTraitConst: core::AlgorithmTraitConst { - fn as_raw_Saliency(&self) -> *const c_void; + /// Constant methods for [crate::saliency::Saliency] + pub trait SaliencyTraitConst: core::AlgorithmTraitConst { + fn as_raw_Saliency(&self) -> *const c_void; } @@ -633,21 +643,29 @@ pub mod saliency { } - /// ********************************* Saliency Base Class *********************************** - pub struct Saliency { - ptr: *mut c_void, - } - - opencv_type_boxed! { Saliency } - - impl Drop for Saliency { + impl std::fmt::Debug for Saliency { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_saliency_Saliency_delete(self.as_raw_mut_Saliency()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Saliency") + .finish() } } - unsafe impl Send for Saliency {} + boxed_cast_base! { Saliency, core::Algorithm, cv_saliency_Saliency_to_Algorithm } + + boxed_cast_descendant! { Saliency, crate::saliency::MotionSaliency, cv_saliency_Saliency_to_MotionSaliency } + + boxed_cast_descendant! { Saliency, crate::saliency::MotionSaliencyBinWangApr2014, cv_saliency_Saliency_to_MotionSaliencyBinWangApr2014 } + + boxed_cast_descendant! { Saliency, crate::saliency::Objectness, cv_saliency_Saliency_to_Objectness } + + boxed_cast_descendant! { Saliency, crate::saliency::ObjectnessBING, cv_saliency_Saliency_to_ObjectnessBING } + + boxed_cast_descendant! { Saliency, crate::saliency::StaticSaliency, cv_saliency_Saliency_to_StaticSaliency } + + boxed_cast_descendant! { Saliency, crate::saliency::StaticSaliencyFineGrained, cv_saliency_Saliency_to_StaticSaliencyFineGrained } + + boxed_cast_descendant! { Saliency, crate::saliency::StaticSaliencySpectralResidual, cv_saliency_Saliency_to_StaticSaliencySpectralResidual } impl core::AlgorithmTraitConst for Saliency { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -669,33 +687,22 @@ pub mod saliency { boxed_ref! { Saliency, crate::saliency::SaliencyTraitConst, as_raw_Saliency, crate::saliency::SaliencyTrait, as_raw_mut_Saliency } - impl Saliency { + /// ********************************* Static Saliency Base Class *********************************** + pub struct StaticSaliency { + ptr: *mut c_void, } - boxed_cast_descendant! { Saliency, crate::saliency::MotionSaliency, cv_saliency_Saliency_to_MotionSaliency } - - boxed_cast_descendant! { Saliency, crate::saliency::MotionSaliencyBinWangApr2014, cv_saliency_Saliency_to_MotionSaliencyBinWangApr2014 } - - boxed_cast_descendant! { Saliency, crate::saliency::Objectness, cv_saliency_Saliency_to_Objectness } - - boxed_cast_descendant! { Saliency, crate::saliency::ObjectnessBING, cv_saliency_Saliency_to_ObjectnessBING } - - boxed_cast_descendant! { Saliency, crate::saliency::StaticSaliency, cv_saliency_Saliency_to_StaticSaliency } - - boxed_cast_descendant! { Saliency, crate::saliency::StaticSaliencyFineGrained, cv_saliency_Saliency_to_StaticSaliencyFineGrained } - - boxed_cast_descendant! { Saliency, crate::saliency::StaticSaliencySpectralResidual, cv_saliency_Saliency_to_StaticSaliencySpectralResidual } - - boxed_cast_base! { Saliency, core::Algorithm, cv_saliency_Saliency_to_Algorithm } + opencv_type_boxed! { StaticSaliency } - impl std::fmt::Debug for Saliency { + impl Drop for StaticSaliency { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Saliency") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_saliency_StaticSaliency_delete(self.as_raw_mut_StaticSaliency()) }; } } + unsafe impl Send for StaticSaliency {} + /// Constant methods for [crate::saliency::StaticSaliency] pub trait StaticSaliencyTraitConst: crate::saliency::SaliencyTraitConst { fn as_raw_StaticSaliency(&self) -> *const c_void; @@ -734,21 +741,21 @@ pub mod saliency { } - /// ********************************* Static Saliency Base Class *********************************** - pub struct StaticSaliency { - ptr: *mut c_void, - } - - opencv_type_boxed! { StaticSaliency } - - impl Drop for StaticSaliency { + impl std::fmt::Debug for StaticSaliency { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_saliency_StaticSaliency_delete(self.as_raw_mut_StaticSaliency()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("StaticSaliency") + .finish() } } - unsafe impl Send for StaticSaliency {} + boxed_cast_base! { StaticSaliency, core::Algorithm, cv_saliency_StaticSaliency_to_Algorithm } + + boxed_cast_base! { StaticSaliency, crate::saliency::Saliency, cv_saliency_StaticSaliency_to_Saliency } + + boxed_cast_descendant! { StaticSaliency, crate::saliency::StaticSaliencyFineGrained, cv_saliency_StaticSaliency_to_StaticSaliencyFineGrained } + + boxed_cast_descendant! { StaticSaliency, crate::saliency::StaticSaliencySpectralResidual, cv_saliency_StaticSaliency_to_StaticSaliencySpectralResidual } impl core::AlgorithmTraitConst for StaticSaliency { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -780,23 +787,46 @@ pub mod saliency { boxed_ref! { StaticSaliency, crate::saliency::StaticSaliencyTraitConst, as_raw_StaticSaliency, crate::saliency::StaticSaliencyTrait, as_raw_mut_StaticSaliency } - impl StaticSaliency { + /// the Fine Grained Saliency approach from [FGS](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_FGS) + /// + /// This method calculates saliency based on center-surround differences. + /// High resolution saliency maps are generated in real time by using integral images. + pub struct StaticSaliencyFineGrained { + ptr: *mut c_void, } - boxed_cast_descendant! { StaticSaliency, crate::saliency::StaticSaliencyFineGrained, cv_saliency_StaticSaliency_to_StaticSaliencyFineGrained } + opencv_type_boxed! { StaticSaliencyFineGrained } - boxed_cast_descendant! { StaticSaliency, crate::saliency::StaticSaliencySpectralResidual, cv_saliency_StaticSaliency_to_StaticSaliencySpectralResidual } + impl Drop for StaticSaliencyFineGrained { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_saliency_StaticSaliencyFineGrained_delete(self.as_raw_mut_StaticSaliencyFineGrained()) }; + } + } - boxed_cast_base! { StaticSaliency, core::Algorithm, cv_saliency_StaticSaliency_to_Algorithm } + unsafe impl Send for StaticSaliencyFineGrained {} - boxed_cast_base! { StaticSaliency, crate::saliency::Saliency, cv_saliency_StaticSaliency_to_Saliency } + impl StaticSaliencyFineGrained { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_saliency_StaticSaliencyFineGrained_StaticSaliencyFineGrained(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::saliency::StaticSaliencyFineGrained::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for StaticSaliency { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("StaticSaliency") - .finish() + pub fn create() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_saliency_StaticSaliencyFineGrained_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::saliency::StaticSaliencyFineGrained] @@ -822,24 +852,19 @@ pub mod saliency { } - /// the Fine Grained Saliency approach from [FGS](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_FGS) - /// - /// This method calculates saliency based on center-surround differences. - /// High resolution saliency maps are generated in real time by using integral images. - pub struct StaticSaliencyFineGrained { - ptr: *mut c_void, - } - - opencv_type_boxed! { StaticSaliencyFineGrained } - - impl Drop for StaticSaliencyFineGrained { + impl std::fmt::Debug for StaticSaliencyFineGrained { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_saliency_StaticSaliencyFineGrained_delete(self.as_raw_mut_StaticSaliencyFineGrained()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("StaticSaliencyFineGrained") + .finish() } } - unsafe impl Send for StaticSaliencyFineGrained {} + boxed_cast_base! { StaticSaliencyFineGrained, core::Algorithm, cv_saliency_StaticSaliencyFineGrained_to_Algorithm } + + boxed_cast_base! { StaticSaliencyFineGrained, crate::saliency::Saliency, cv_saliency_StaticSaliencyFineGrained_to_Saliency } + + boxed_cast_base! { StaticSaliencyFineGrained, crate::saliency::StaticSaliency, cv_saliency_StaticSaliencyFineGrained_to_StaticSaliency } impl core::AlgorithmTraitConst for StaticSaliencyFineGrained { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -881,43 +906,50 @@ pub mod saliency { boxed_ref! { StaticSaliencyFineGrained, crate::saliency::StaticSaliencyFineGrainedTraitConst, as_raw_StaticSaliencyFineGrained, crate::saliency::StaticSaliencyFineGrainedTrait, as_raw_mut_StaticSaliencyFineGrained } - impl StaticSaliencyFineGrained { + /// the Spectral Residual approach from [SR](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_SR) + /// + /// Starting from the principle of natural image statistics, this method simulate the behavior of + /// pre-attentive visual search. The algorithm analyze the log spectrum of each image and obtain the + /// spectral residual. Then transform the spectral residual to spatial domain to obtain the saliency + /// map, which suggests the positions of proto-objects. + pub struct StaticSaliencySpectralResidual { + ptr: *mut c_void, + } + + opencv_type_boxed! { StaticSaliencySpectralResidual } + + impl Drop for StaticSaliencySpectralResidual { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_saliency_StaticSaliencySpectralResidual_delete(self.as_raw_mut_StaticSaliencySpectralResidual()) }; + } + } + + unsafe impl Send for StaticSaliencySpectralResidual {} + + impl StaticSaliencySpectralResidual { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_saliency_StaticSaliencyFineGrained_StaticSaliencyFineGrained(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_saliency_StaticSaliencySpectralResidual_StaticSaliencySpectralResidual(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::saliency::StaticSaliencyFineGrained::opencv_from_extern(ret) }; + let ret = unsafe { crate::saliency::StaticSaliencySpectralResidual::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn create() -> Result> { + pub fn create() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_saliency_StaticSaliencyFineGrained_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_saliency_StaticSaliencySpectralResidual_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { StaticSaliencyFineGrained, core::Algorithm, cv_saliency_StaticSaliencyFineGrained_to_Algorithm } - - boxed_cast_base! { StaticSaliencyFineGrained, crate::saliency::Saliency, cv_saliency_StaticSaliencyFineGrained_to_Saliency } - - boxed_cast_base! { StaticSaliencyFineGrained, crate::saliency::StaticSaliency, cv_saliency_StaticSaliencyFineGrained_to_StaticSaliency } - - impl std::fmt::Debug for StaticSaliencyFineGrained { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("StaticSaliencyFineGrained") - .finish() - } - } - /// Constant methods for [crate::saliency::StaticSaliencySpectralResidual] pub trait StaticSaliencySpectralResidualTraitConst: crate::saliency::StaticSaliencyTraitConst { fn as_raw_StaticSaliencySpectralResidual(&self) -> *const c_void; @@ -995,26 +1027,19 @@ pub mod saliency { } - /// the Spectral Residual approach from [SR](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_SR) - /// - /// Starting from the principle of natural image statistics, this method simulate the behavior of - /// pre-attentive visual search. The algorithm analyze the log spectrum of each image and obtain the - /// spectral residual. Then transform the spectral residual to spatial domain to obtain the saliency - /// map, which suggests the positions of proto-objects. - pub struct StaticSaliencySpectralResidual { - ptr: *mut c_void, - } - - opencv_type_boxed! { StaticSaliencySpectralResidual } - - impl Drop for StaticSaliencySpectralResidual { + impl std::fmt::Debug for StaticSaliencySpectralResidual { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_saliency_StaticSaliencySpectralResidual_delete(self.as_raw_mut_StaticSaliencySpectralResidual()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("StaticSaliencySpectralResidual") + .finish() } } - unsafe impl Send for StaticSaliencySpectralResidual {} + boxed_cast_base! { StaticSaliencySpectralResidual, core::Algorithm, cv_saliency_StaticSaliencySpectralResidual_to_Algorithm } + + boxed_cast_base! { StaticSaliencySpectralResidual, crate::saliency::Saliency, cv_saliency_StaticSaliencySpectralResidual_to_Saliency } + + boxed_cast_base! { StaticSaliencySpectralResidual, crate::saliency::StaticSaliency, cv_saliency_StaticSaliencySpectralResidual_to_StaticSaliency } impl core::AlgorithmTraitConst for StaticSaliencySpectralResidual { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1056,40 +1081,4 @@ pub mod saliency { boxed_ref! { StaticSaliencySpectralResidual, crate::saliency::StaticSaliencySpectralResidualTraitConst, as_raw_StaticSaliencySpectralResidual, crate::saliency::StaticSaliencySpectralResidualTrait, as_raw_mut_StaticSaliencySpectralResidual } - impl StaticSaliencySpectralResidual { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_saliency_StaticSaliencySpectralResidual_StaticSaliencySpectralResidual(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::saliency::StaticSaliencySpectralResidual::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn create() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_saliency_StaticSaliencySpectralResidual_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { StaticSaliencySpectralResidual, core::Algorithm, cv_saliency_StaticSaliencySpectralResidual_to_Algorithm } - - boxed_cast_base! { StaticSaliencySpectralResidual, crate::saliency::Saliency, cv_saliency_StaticSaliencySpectralResidual_to_Saliency } - - boxed_cast_base! { StaticSaliencySpectralResidual, crate::saliency::StaticSaliency, cv_saliency_StaticSaliencySpectralResidual_to_StaticSaliency } - - impl std::fmt::Debug for StaticSaliencySpectralResidual { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("StaticSaliencySpectralResidual") - .finish() - } - } } diff --git a/docs/sfm.rs b/docs/sfm.rs index 4e9ea0fef..7207e5760 100644 --- a/docs/sfm.rs +++ b/docs/sfm.rs @@ -974,6 +974,22 @@ pub mod sfm { Ok(ret) } + /// base class BaseSFM declares a common API that would be used in a typical scene reconstruction scenario + pub struct BaseSFM { + ptr: *mut c_void, + } + + opencv_type_boxed! { BaseSFM } + + impl Drop for BaseSFM { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_sfm_BaseSFM_delete(self.as_raw_mut_BaseSFM()) }; + } + } + + unsafe impl Send for BaseSFM {} + /// Constant methods for [crate::sfm::BaseSFM] pub trait BaseSFMTraitConst { fn as_raw_BaseSFM(&self) -> *const c_void; @@ -1090,21 +1106,15 @@ pub mod sfm { } - /// base class BaseSFM declares a common API that would be used in a typical scene reconstruction scenario - pub struct BaseSFM { - ptr: *mut c_void, - } - - opencv_type_boxed! { BaseSFM } - - impl Drop for BaseSFM { + impl std::fmt::Debug for BaseSFM { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_sfm_BaseSFM_delete(self.as_raw_mut_BaseSFM()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BaseSFM") + .finish() } } - unsafe impl Send for BaseSFM {} + boxed_cast_descendant! { BaseSFM, crate::sfm::SFMLibmvEuclideanReconstruction, cv_sfm_BaseSFM_to_SFMLibmvEuclideanReconstruction } impl crate::sfm::BaseSFMTraitConst for BaseSFM { #[inline] fn as_raw_BaseSFM(&self) -> *const c_void { self.as_raw() } @@ -1116,19 +1126,56 @@ pub mod sfm { boxed_ref! { BaseSFM, crate::sfm::BaseSFMTraitConst, as_raw_BaseSFM, crate::sfm::BaseSFMTrait, as_raw_mut_BaseSFM } - impl BaseSFM { + /// SFMLibmvEuclideanReconstruction class provides an interface with the Libmv Structure From Motion pipeline. + pub struct SFMLibmvEuclideanReconstruction { + ptr: *mut c_void, } - boxed_cast_descendant! { BaseSFM, crate::sfm::SFMLibmvEuclideanReconstruction, cv_sfm_BaseSFM_to_SFMLibmvEuclideanReconstruction } + opencv_type_boxed! { SFMLibmvEuclideanReconstruction } - impl std::fmt::Debug for BaseSFM { + impl Drop for SFMLibmvEuclideanReconstruction { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BaseSFM") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_sfm_SFMLibmvEuclideanReconstruction_delete(self.as_raw_mut_SFMLibmvEuclideanReconstruction()) }; } } + unsafe impl Send for SFMLibmvEuclideanReconstruction {} + + impl SFMLibmvEuclideanReconstruction { + /// Creates an instance of the SFMLibmvEuclideanReconstruction class. Initializes Libmv. + /// + /// ## C++ default parameters + /// * camera_instrinsic_options: libmv_CameraIntrinsicsOptions() + /// * reconstruction_options: libmv_ReconstructionOptions() + #[inline] + pub fn create(camera_instrinsic_options: crate::sfm::libmv_CameraIntrinsicsOptions, reconstruction_options: crate::sfm::libmv_ReconstructionOptions) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_sfm_SFMLibmvEuclideanReconstruction_create_const_libmv_CameraIntrinsicsOptionsR_const_libmv_ReconstructionOptionsR(&camera_instrinsic_options, &reconstruction_options, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Creates an instance of the SFMLibmvEuclideanReconstruction class. Initializes Libmv. + /// + /// ## Note + /// This alternative version of [SFMLibmvEuclideanReconstruction::create] function uses the following default values for its arguments: + /// * camera_instrinsic_options: libmv_CameraIntrinsicsOptions() + /// * reconstruction_options: libmv_ReconstructionOptions() + #[inline] + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_sfm_SFMLibmvEuclideanReconstruction_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::sfm::SFMLibmvEuclideanReconstruction] pub trait SFMLibmvEuclideanReconstructionTraitConst: crate::sfm::BaseSFMTraitConst { fn as_raw_SFMLibmvEuclideanReconstruction(&self) -> *const c_void; @@ -1300,21 +1347,15 @@ pub mod sfm { } - /// SFMLibmvEuclideanReconstruction class provides an interface with the Libmv Structure From Motion pipeline. - pub struct SFMLibmvEuclideanReconstruction { - ptr: *mut c_void, - } - - opencv_type_boxed! { SFMLibmvEuclideanReconstruction } - - impl Drop for SFMLibmvEuclideanReconstruction { + impl std::fmt::Debug for SFMLibmvEuclideanReconstruction { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_sfm_SFMLibmvEuclideanReconstruction_delete(self.as_raw_mut_SFMLibmvEuclideanReconstruction()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SFMLibmvEuclideanReconstruction") + .finish() } } - unsafe impl Send for SFMLibmvEuclideanReconstruction {} + boxed_cast_base! { SFMLibmvEuclideanReconstruction, crate::sfm::BaseSFM, cv_sfm_SFMLibmvEuclideanReconstruction_to_BaseSFM } impl crate::sfm::BaseSFMTraitConst for SFMLibmvEuclideanReconstruction { #[inline] fn as_raw_BaseSFM(&self) -> *const c_void { self.as_raw() } @@ -1336,50 +1377,6 @@ pub mod sfm { boxed_ref! { SFMLibmvEuclideanReconstruction, crate::sfm::SFMLibmvEuclideanReconstructionTraitConst, as_raw_SFMLibmvEuclideanReconstruction, crate::sfm::SFMLibmvEuclideanReconstructionTrait, as_raw_mut_SFMLibmvEuclideanReconstruction } - impl SFMLibmvEuclideanReconstruction { - /// Creates an instance of the SFMLibmvEuclideanReconstruction class. Initializes Libmv. - /// - /// ## C++ default parameters - /// * camera_instrinsic_options: libmv_CameraIntrinsicsOptions() - /// * reconstruction_options: libmv_ReconstructionOptions() - #[inline] - pub fn create(camera_instrinsic_options: crate::sfm::libmv_CameraIntrinsicsOptions, reconstruction_options: crate::sfm::libmv_ReconstructionOptions) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_sfm_SFMLibmvEuclideanReconstruction_create_const_libmv_CameraIntrinsicsOptionsR_const_libmv_ReconstructionOptionsR(&camera_instrinsic_options, &reconstruction_options, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Creates an instance of the SFMLibmvEuclideanReconstruction class. Initializes Libmv. - /// - /// ## Note - /// This alternative version of [SFMLibmvEuclideanReconstruction::create] function uses the following default values for its arguments: - /// * camera_instrinsic_options: libmv_CameraIntrinsicsOptions() - /// * reconstruction_options: libmv_ReconstructionOptions() - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_sfm_SFMLibmvEuclideanReconstruction_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { SFMLibmvEuclideanReconstruction, crate::sfm::BaseSFM, cv_sfm_SFMLibmvEuclideanReconstruction_to_BaseSFM } - - impl std::fmt::Debug for SFMLibmvEuclideanReconstruction { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SFMLibmvEuclideanReconstruction") - .finish() - } - } - /// Data structure describing the camera model and its parameters. /// ## Parameters /// * _distortion_model: Type of camera model. @@ -1514,4 +1511,5 @@ pub mod sfm { } } + } diff --git a/docs/shape.rs b/docs/shape.rs index 96f5e93c0..aad221975 100644 --- a/docs/shape.rs +++ b/docs/shape.rs @@ -242,6 +242,22 @@ pub mod shape { Ok(ret) } + /// Wrapper class for the OpenCV Affine Transformation algorithm. : + pub struct AffineTransformer { + ptr: *mut c_void, + } + + opencv_type_boxed! { AffineTransformer } + + impl Drop for AffineTransformer { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_AffineTransformer_delete(self.as_raw_mut_AffineTransformer()) }; + } + } + + unsafe impl Send for AffineTransformer {} + /// Constant methods for [crate::shape::AffineTransformer] pub trait AffineTransformerTraitConst: crate::shape::ShapeTransformerTraitConst { fn as_raw_AffineTransformer(&self) -> *const c_void; @@ -272,21 +288,17 @@ pub mod shape { } - /// Wrapper class for the OpenCV Affine Transformation algorithm. : - pub struct AffineTransformer { - ptr: *mut c_void, - } - - opencv_type_boxed! { AffineTransformer } - - impl Drop for AffineTransformer { + impl std::fmt::Debug for AffineTransformer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_AffineTransformer_delete(self.as_raw_mut_AffineTransformer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AffineTransformer") + .finish() } } - unsafe impl Send for AffineTransformer {} + boxed_cast_base! { AffineTransformer, core::Algorithm, cv_AffineTransformer_to_Algorithm } + + boxed_cast_base! { AffineTransformer, crate::shape::ShapeTransformer, cv_AffineTransformer_to_ShapeTransformer } impl core::AlgorithmTraitConst for AffineTransformer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -318,21 +330,22 @@ pub mod shape { boxed_ref! { AffineTransformer, crate::shape::AffineTransformerTraitConst, as_raw_AffineTransformer, crate::shape::AffineTransformerTrait, as_raw_mut_AffineTransformer } - impl AffineTransformer { + /// An Chi based cost extraction. : + pub struct ChiHistogramCostExtractor { + ptr: *mut c_void, } - boxed_cast_base! { AffineTransformer, core::Algorithm, cv_AffineTransformer_to_Algorithm } - - boxed_cast_base! { AffineTransformer, crate::shape::ShapeTransformer, cv_AffineTransformer_to_ShapeTransformer } + opencv_type_boxed! { ChiHistogramCostExtractor } - impl std::fmt::Debug for AffineTransformer { + impl Drop for ChiHistogramCostExtractor { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AffineTransformer") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ChiHistogramCostExtractor_delete(self.as_raw_mut_ChiHistogramCostExtractor()) }; } } + unsafe impl Send for ChiHistogramCostExtractor {} + /// Constant methods for [crate::shape::ChiHistogramCostExtractor] pub trait ChiHistogramCostExtractorTraitConst: crate::shape::HistogramCostExtractorTraitConst { fn as_raw_ChiHistogramCostExtractor(&self) -> *const c_void; @@ -345,21 +358,17 @@ pub mod shape { } - /// An Chi based cost extraction. : - pub struct ChiHistogramCostExtractor { - ptr: *mut c_void, - } - - opencv_type_boxed! { ChiHistogramCostExtractor } - - impl Drop for ChiHistogramCostExtractor { + impl std::fmt::Debug for ChiHistogramCostExtractor { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ChiHistogramCostExtractor_delete(self.as_raw_mut_ChiHistogramCostExtractor()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ChiHistogramCostExtractor") + .finish() } } - unsafe impl Send for ChiHistogramCostExtractor {} + boxed_cast_base! { ChiHistogramCostExtractor, core::Algorithm, cv_ChiHistogramCostExtractor_to_Algorithm } + + boxed_cast_base! { ChiHistogramCostExtractor, crate::shape::HistogramCostExtractor, cv_ChiHistogramCostExtractor_to_HistogramCostExtractor } impl core::AlgorithmTraitConst for ChiHistogramCostExtractor { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -391,21 +400,22 @@ pub mod shape { boxed_ref! { ChiHistogramCostExtractor, crate::shape::ChiHistogramCostExtractorTraitConst, as_raw_ChiHistogramCostExtractor, crate::shape::ChiHistogramCostExtractorTrait, as_raw_mut_ChiHistogramCostExtractor } - impl ChiHistogramCostExtractor { + /// An EMD based cost extraction. : + pub struct EMDHistogramCostExtractor { + ptr: *mut c_void, } - boxed_cast_base! { ChiHistogramCostExtractor, core::Algorithm, cv_ChiHistogramCostExtractor_to_Algorithm } - - boxed_cast_base! { ChiHistogramCostExtractor, crate::shape::HistogramCostExtractor, cv_ChiHistogramCostExtractor_to_HistogramCostExtractor } + opencv_type_boxed! { EMDHistogramCostExtractor } - impl std::fmt::Debug for ChiHistogramCostExtractor { + impl Drop for EMDHistogramCostExtractor { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ChiHistogramCostExtractor") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_EMDHistogramCostExtractor_delete(self.as_raw_mut_EMDHistogramCostExtractor()) }; } } + unsafe impl Send for EMDHistogramCostExtractor {} + /// Constant methods for [crate::shape::EMDHistogramCostExtractor] pub trait EMDHistogramCostExtractorTraitConst: crate::shape::HistogramCostExtractorTraitConst { fn as_raw_EMDHistogramCostExtractor(&self) -> *const c_void; @@ -436,21 +446,17 @@ pub mod shape { } - /// An EMD based cost extraction. : - pub struct EMDHistogramCostExtractor { - ptr: *mut c_void, - } - - opencv_type_boxed! { EMDHistogramCostExtractor } - - impl Drop for EMDHistogramCostExtractor { + impl std::fmt::Debug for EMDHistogramCostExtractor { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_EMDHistogramCostExtractor_delete(self.as_raw_mut_EMDHistogramCostExtractor()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("EMDHistogramCostExtractor") + .finish() } } - unsafe impl Send for EMDHistogramCostExtractor {} + boxed_cast_base! { EMDHistogramCostExtractor, core::Algorithm, cv_EMDHistogramCostExtractor_to_Algorithm } + + boxed_cast_base! { EMDHistogramCostExtractor, crate::shape::HistogramCostExtractor, cv_EMDHistogramCostExtractor_to_HistogramCostExtractor } impl core::AlgorithmTraitConst for EMDHistogramCostExtractor { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -482,21 +488,22 @@ pub mod shape { boxed_ref! { EMDHistogramCostExtractor, crate::shape::EMDHistogramCostExtractorTraitConst, as_raw_EMDHistogramCostExtractor, crate::shape::EMDHistogramCostExtractorTrait, as_raw_mut_EMDHistogramCostExtractor } - impl EMDHistogramCostExtractor { + /// An EMD-L1 based cost extraction. : + pub struct EMDL1HistogramCostExtractor { + ptr: *mut c_void, } - boxed_cast_base! { EMDHistogramCostExtractor, core::Algorithm, cv_EMDHistogramCostExtractor_to_Algorithm } - - boxed_cast_base! { EMDHistogramCostExtractor, crate::shape::HistogramCostExtractor, cv_EMDHistogramCostExtractor_to_HistogramCostExtractor } + opencv_type_boxed! { EMDL1HistogramCostExtractor } - impl std::fmt::Debug for EMDHistogramCostExtractor { + impl Drop for EMDL1HistogramCostExtractor { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("EMDHistogramCostExtractor") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_EMDL1HistogramCostExtractor_delete(self.as_raw_mut_EMDL1HistogramCostExtractor()) }; } } + unsafe impl Send for EMDL1HistogramCostExtractor {} + /// Constant methods for [crate::shape::EMDL1HistogramCostExtractor] pub trait EMDL1HistogramCostExtractorTraitConst: crate::shape::HistogramCostExtractorTraitConst { fn as_raw_EMDL1HistogramCostExtractor(&self) -> *const c_void; @@ -509,21 +516,17 @@ pub mod shape { } - /// An EMD-L1 based cost extraction. : - pub struct EMDL1HistogramCostExtractor { - ptr: *mut c_void, - } - - opencv_type_boxed! { EMDL1HistogramCostExtractor } - - impl Drop for EMDL1HistogramCostExtractor { + impl std::fmt::Debug for EMDL1HistogramCostExtractor { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_EMDL1HistogramCostExtractor_delete(self.as_raw_mut_EMDL1HistogramCostExtractor()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("EMDL1HistogramCostExtractor") + .finish() } } - unsafe impl Send for EMDL1HistogramCostExtractor {} + boxed_cast_base! { EMDL1HistogramCostExtractor, core::Algorithm, cv_EMDL1HistogramCostExtractor_to_Algorithm } + + boxed_cast_base! { EMDL1HistogramCostExtractor, crate::shape::HistogramCostExtractor, cv_EMDL1HistogramCostExtractor_to_HistogramCostExtractor } impl core::AlgorithmTraitConst for EMDL1HistogramCostExtractor { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -555,21 +558,28 @@ pub mod shape { boxed_ref! { EMDL1HistogramCostExtractor, crate::shape::EMDL1HistogramCostExtractorTraitConst, as_raw_EMDL1HistogramCostExtractor, crate::shape::EMDL1HistogramCostExtractorTrait, as_raw_mut_EMDL1HistogramCostExtractor } - impl EMDL1HistogramCostExtractor { + /// ******************************************************************************** + /// / + /// / + /// A simple Hausdorff distance measure between shapes defined by contours + /// + /// according to the paper "Comparing Images using the Hausdorff distance." by D.P. Huttenlocher, G.A. + /// Klanderman, and W.J. Rucklidge. (PAMI 1993). : + pub struct HausdorffDistanceExtractor { + ptr: *mut c_void, } - boxed_cast_base! { EMDL1HistogramCostExtractor, core::Algorithm, cv_EMDL1HistogramCostExtractor_to_Algorithm } - - boxed_cast_base! { EMDL1HistogramCostExtractor, crate::shape::HistogramCostExtractor, cv_EMDL1HistogramCostExtractor_to_HistogramCostExtractor } + opencv_type_boxed! { HausdorffDistanceExtractor } - impl std::fmt::Debug for EMDL1HistogramCostExtractor { + impl Drop for HausdorffDistanceExtractor { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("EMDL1HistogramCostExtractor") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_HausdorffDistanceExtractor_delete(self.as_raw_mut_HausdorffDistanceExtractor()) }; } } + unsafe impl Send for HausdorffDistanceExtractor {} + /// Constant methods for [crate::shape::HausdorffDistanceExtractor] pub trait HausdorffDistanceExtractorTraitConst: crate::shape::ShapeDistanceExtractorTraitConst { fn as_raw_HausdorffDistanceExtractor(&self) -> *const c_void; @@ -629,27 +639,17 @@ pub mod shape { } - /// ******************************************************************************** - /// / - /// / - /// A simple Hausdorff distance measure between shapes defined by contours - /// - /// according to the paper "Comparing Images using the Hausdorff distance." by D.P. Huttenlocher, G.A. - /// Klanderman, and W.J. Rucklidge. (PAMI 1993). : - pub struct HausdorffDistanceExtractor { - ptr: *mut c_void, - } - - opencv_type_boxed! { HausdorffDistanceExtractor } - - impl Drop for HausdorffDistanceExtractor { + impl std::fmt::Debug for HausdorffDistanceExtractor { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_HausdorffDistanceExtractor_delete(self.as_raw_mut_HausdorffDistanceExtractor()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("HausdorffDistanceExtractor") + .finish() } } - unsafe impl Send for HausdorffDistanceExtractor {} + boxed_cast_base! { HausdorffDistanceExtractor, core::Algorithm, cv_HausdorffDistanceExtractor_to_Algorithm } + + boxed_cast_base! { HausdorffDistanceExtractor, crate::shape::ShapeDistanceExtractor, cv_HausdorffDistanceExtractor_to_ShapeDistanceExtractor } impl core::AlgorithmTraitConst for HausdorffDistanceExtractor { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -681,21 +681,22 @@ pub mod shape { boxed_ref! { HausdorffDistanceExtractor, crate::shape::HausdorffDistanceExtractorTraitConst, as_raw_HausdorffDistanceExtractor, crate::shape::HausdorffDistanceExtractorTrait, as_raw_mut_HausdorffDistanceExtractor } - impl HausdorffDistanceExtractor { + /// Abstract base class for histogram cost algorithms. + pub struct HistogramCostExtractor { + ptr: *mut c_void, } - boxed_cast_base! { HausdorffDistanceExtractor, core::Algorithm, cv_HausdorffDistanceExtractor_to_Algorithm } - - boxed_cast_base! { HausdorffDistanceExtractor, crate::shape::ShapeDistanceExtractor, cv_HausdorffDistanceExtractor_to_ShapeDistanceExtractor } + opencv_type_boxed! { HistogramCostExtractor } - impl std::fmt::Debug for HausdorffDistanceExtractor { + impl Drop for HistogramCostExtractor { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("HausdorffDistanceExtractor") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_HistogramCostExtractor_delete(self.as_raw_mut_HistogramCostExtractor()) }; } } + unsafe impl Send for HistogramCostExtractor {} + /// Constant methods for [crate::shape::HistogramCostExtractor] pub trait HistogramCostExtractorTraitConst: core::AlgorithmTraitConst { fn as_raw_HistogramCostExtractor(&self) -> *const c_void; @@ -756,21 +757,23 @@ pub mod shape { } - /// Abstract base class for histogram cost algorithms. - pub struct HistogramCostExtractor { - ptr: *mut c_void, - } - - opencv_type_boxed! { HistogramCostExtractor } - - impl Drop for HistogramCostExtractor { + impl std::fmt::Debug for HistogramCostExtractor { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_HistogramCostExtractor_delete(self.as_raw_mut_HistogramCostExtractor()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("HistogramCostExtractor") + .finish() } } - unsafe impl Send for HistogramCostExtractor {} + boxed_cast_base! { HistogramCostExtractor, core::Algorithm, cv_HistogramCostExtractor_to_Algorithm } + + boxed_cast_descendant! { HistogramCostExtractor, crate::shape::ChiHistogramCostExtractor, cv_HistogramCostExtractor_to_ChiHistogramCostExtractor } + + boxed_cast_descendant! { HistogramCostExtractor, crate::shape::EMDHistogramCostExtractor, cv_HistogramCostExtractor_to_EMDHistogramCostExtractor } + + boxed_cast_descendant! { HistogramCostExtractor, crate::shape::EMDL1HistogramCostExtractor, cv_HistogramCostExtractor_to_EMDL1HistogramCostExtractor } + + boxed_cast_descendant! { HistogramCostExtractor, crate::shape::NormHistogramCostExtractor, cv_HistogramCostExtractor_to_NormHistogramCostExtractor } impl core::AlgorithmTraitConst for HistogramCostExtractor { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -792,27 +795,22 @@ pub mod shape { boxed_ref! { HistogramCostExtractor, crate::shape::HistogramCostExtractorTraitConst, as_raw_HistogramCostExtractor, crate::shape::HistogramCostExtractorTrait, as_raw_mut_HistogramCostExtractor } - impl HistogramCostExtractor { + /// A norm based cost extraction. : + pub struct NormHistogramCostExtractor { + ptr: *mut c_void, } - boxed_cast_descendant! { HistogramCostExtractor, crate::shape::ChiHistogramCostExtractor, cv_HistogramCostExtractor_to_ChiHistogramCostExtractor } - - boxed_cast_descendant! { HistogramCostExtractor, crate::shape::EMDHistogramCostExtractor, cv_HistogramCostExtractor_to_EMDHistogramCostExtractor } - - boxed_cast_descendant! { HistogramCostExtractor, crate::shape::EMDL1HistogramCostExtractor, cv_HistogramCostExtractor_to_EMDL1HistogramCostExtractor } - - boxed_cast_descendant! { HistogramCostExtractor, crate::shape::NormHistogramCostExtractor, cv_HistogramCostExtractor_to_NormHistogramCostExtractor } - - boxed_cast_base! { HistogramCostExtractor, core::Algorithm, cv_HistogramCostExtractor_to_Algorithm } + opencv_type_boxed! { NormHistogramCostExtractor } - impl std::fmt::Debug for HistogramCostExtractor { + impl Drop for NormHistogramCostExtractor { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("HistogramCostExtractor") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_NormHistogramCostExtractor_delete(self.as_raw_mut_NormHistogramCostExtractor()) }; } } + unsafe impl Send for NormHistogramCostExtractor {} + /// Constant methods for [crate::shape::NormHistogramCostExtractor] pub trait NormHistogramCostExtractorTraitConst: crate::shape::HistogramCostExtractorTraitConst { fn as_raw_NormHistogramCostExtractor(&self) -> *const c_void; @@ -843,21 +841,17 @@ pub mod shape { } - /// A norm based cost extraction. : - pub struct NormHistogramCostExtractor { - ptr: *mut c_void, - } - - opencv_type_boxed! { NormHistogramCostExtractor } - - impl Drop for NormHistogramCostExtractor { + impl std::fmt::Debug for NormHistogramCostExtractor { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_NormHistogramCostExtractor_delete(self.as_raw_mut_NormHistogramCostExtractor()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("NormHistogramCostExtractor") + .finish() } } - unsafe impl Send for NormHistogramCostExtractor {} + boxed_cast_base! { NormHistogramCostExtractor, core::Algorithm, cv_NormHistogramCostExtractor_to_Algorithm } + + boxed_cast_base! { NormHistogramCostExtractor, crate::shape::HistogramCostExtractor, cv_NormHistogramCostExtractor_to_HistogramCostExtractor } impl core::AlgorithmTraitConst for NormHistogramCostExtractor { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -889,21 +883,29 @@ pub mod shape { boxed_ref! { NormHistogramCostExtractor, crate::shape::NormHistogramCostExtractorTraitConst, as_raw_NormHistogramCostExtractor, crate::shape::NormHistogramCostExtractorTrait, as_raw_mut_NormHistogramCostExtractor } - impl NormHistogramCostExtractor { + /// ******************************************************************************** + /// / + /// / + /// Implementation of the Shape Context descriptor and matching algorithm + /// + /// proposed by Belongie et al. in "Shape Matching and Object Recognition Using Shape Contexts" (PAMI + /// 2002). This implementation is packaged in a generic scheme, in order to allow you the + /// implementation of the common variations of the original pipeline. + pub struct ShapeContextDistanceExtractor { + ptr: *mut c_void, } - boxed_cast_base! { NormHistogramCostExtractor, core::Algorithm, cv_NormHistogramCostExtractor_to_Algorithm } - - boxed_cast_base! { NormHistogramCostExtractor, crate::shape::HistogramCostExtractor, cv_NormHistogramCostExtractor_to_HistogramCostExtractor } + opencv_type_boxed! { ShapeContextDistanceExtractor } - impl std::fmt::Debug for NormHistogramCostExtractor { + impl Drop for ShapeContextDistanceExtractor { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("NormHistogramCostExtractor") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ShapeContextDistanceExtractor_delete(self.as_raw_mut_ShapeContextDistanceExtractor()) }; } } + unsafe impl Send for ShapeContextDistanceExtractor {} + /// Constant methods for [crate::shape::ShapeContextDistanceExtractor] pub trait ShapeContextDistanceExtractorTraitConst: crate::shape::ShapeDistanceExtractorTraitConst { fn as_raw_ShapeContextDistanceExtractor(&self) -> *const c_void; @@ -1217,28 +1219,17 @@ pub mod shape { } - /// ******************************************************************************** - /// / - /// / - /// Implementation of the Shape Context descriptor and matching algorithm - /// - /// proposed by Belongie et al. in "Shape Matching and Object Recognition Using Shape Contexts" (PAMI - /// 2002). This implementation is packaged in a generic scheme, in order to allow you the - /// implementation of the common variations of the original pipeline. - pub struct ShapeContextDistanceExtractor { - ptr: *mut c_void, - } - - opencv_type_boxed! { ShapeContextDistanceExtractor } - - impl Drop for ShapeContextDistanceExtractor { + impl std::fmt::Debug for ShapeContextDistanceExtractor { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ShapeContextDistanceExtractor_delete(self.as_raw_mut_ShapeContextDistanceExtractor()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ShapeContextDistanceExtractor") + .finish() } } - unsafe impl Send for ShapeContextDistanceExtractor {} + boxed_cast_base! { ShapeContextDistanceExtractor, core::Algorithm, cv_ShapeContextDistanceExtractor_to_Algorithm } + + boxed_cast_base! { ShapeContextDistanceExtractor, crate::shape::ShapeDistanceExtractor, cv_ShapeContextDistanceExtractor_to_ShapeDistanceExtractor } impl core::AlgorithmTraitConst for ShapeContextDistanceExtractor { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1270,21 +1261,25 @@ pub mod shape { boxed_ref! { ShapeContextDistanceExtractor, crate::shape::ShapeContextDistanceExtractorTraitConst, as_raw_ShapeContextDistanceExtractor, crate::shape::ShapeContextDistanceExtractorTrait, as_raw_mut_ShapeContextDistanceExtractor } - impl ShapeContextDistanceExtractor { + /// @example modules/shape/samples/shape_example.cpp + /// An example using shape distance algorithm + /// + /// Abstract base class for shape distance algorithms. + pub struct ShapeDistanceExtractor { + ptr: *mut c_void, } - boxed_cast_base! { ShapeContextDistanceExtractor, core::Algorithm, cv_ShapeContextDistanceExtractor_to_Algorithm } - - boxed_cast_base! { ShapeContextDistanceExtractor, crate::shape::ShapeDistanceExtractor, cv_ShapeContextDistanceExtractor_to_ShapeDistanceExtractor } + opencv_type_boxed! { ShapeDistanceExtractor } - impl std::fmt::Debug for ShapeContextDistanceExtractor { + impl Drop for ShapeDistanceExtractor { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ShapeContextDistanceExtractor") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ShapeDistanceExtractor_delete(self.as_raw_mut_ShapeDistanceExtractor()) }; } } + unsafe impl Send for ShapeDistanceExtractor {} + /// Constant methods for [crate::shape::ShapeDistanceExtractor] pub trait ShapeDistanceExtractorTraitConst: core::AlgorithmTraitConst { fn as_raw_ShapeDistanceExtractor(&self) -> *const c_void; @@ -1313,24 +1308,19 @@ pub mod shape { } - /// @example modules/shape/samples/shape_example.cpp - /// An example using shape distance algorithm - /// - /// Abstract base class for shape distance algorithms. - pub struct ShapeDistanceExtractor { - ptr: *mut c_void, - } - - opencv_type_boxed! { ShapeDistanceExtractor } - - impl Drop for ShapeDistanceExtractor { + impl std::fmt::Debug for ShapeDistanceExtractor { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ShapeDistanceExtractor_delete(self.as_raw_mut_ShapeDistanceExtractor()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ShapeDistanceExtractor") + .finish() } } - unsafe impl Send for ShapeDistanceExtractor {} + boxed_cast_base! { ShapeDistanceExtractor, core::Algorithm, cv_ShapeDistanceExtractor_to_Algorithm } + + boxed_cast_descendant! { ShapeDistanceExtractor, crate::shape::HausdorffDistanceExtractor, cv_ShapeDistanceExtractor_to_HausdorffDistanceExtractor } + + boxed_cast_descendant! { ShapeDistanceExtractor, crate::shape::ShapeContextDistanceExtractor, cv_ShapeDistanceExtractor_to_ShapeContextDistanceExtractor } impl core::AlgorithmTraitConst for ShapeDistanceExtractor { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1352,23 +1342,22 @@ pub mod shape { boxed_ref! { ShapeDistanceExtractor, crate::shape::ShapeDistanceExtractorTraitConst, as_raw_ShapeDistanceExtractor, crate::shape::ShapeDistanceExtractorTrait, as_raw_mut_ShapeDistanceExtractor } - impl ShapeDistanceExtractor { + /// Abstract base class for shape transformation algorithms. + pub struct ShapeTransformer { + ptr: *mut c_void, } - boxed_cast_descendant! { ShapeDistanceExtractor, crate::shape::HausdorffDistanceExtractor, cv_ShapeDistanceExtractor_to_HausdorffDistanceExtractor } - - boxed_cast_descendant! { ShapeDistanceExtractor, crate::shape::ShapeContextDistanceExtractor, cv_ShapeDistanceExtractor_to_ShapeContextDistanceExtractor } - - boxed_cast_base! { ShapeDistanceExtractor, core::Algorithm, cv_ShapeDistanceExtractor_to_Algorithm } + opencv_type_boxed! { ShapeTransformer } - impl std::fmt::Debug for ShapeDistanceExtractor { + impl Drop for ShapeTransformer { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ShapeDistanceExtractor") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ShapeTransformer_delete(self.as_raw_mut_ShapeTransformer()) }; } } + unsafe impl Send for ShapeTransformer {} + /// Constant methods for [crate::shape::ShapeTransformer] pub trait ShapeTransformerTraitConst: core::AlgorithmTraitConst { fn as_raw_ShapeTransformer(&self) -> *const c_void; @@ -1485,21 +1474,19 @@ pub mod shape { } - /// Abstract base class for shape transformation algorithms. - pub struct ShapeTransformer { - ptr: *mut c_void, - } - - opencv_type_boxed! { ShapeTransformer } - - impl Drop for ShapeTransformer { + impl std::fmt::Debug for ShapeTransformer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ShapeTransformer_delete(self.as_raw_mut_ShapeTransformer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ShapeTransformer") + .finish() } } - unsafe impl Send for ShapeTransformer {} + boxed_cast_base! { ShapeTransformer, core::Algorithm, cv_ShapeTransformer_to_Algorithm } + + boxed_cast_descendant! { ShapeTransformer, crate::shape::AffineTransformer, cv_ShapeTransformer_to_AffineTransformer } + + boxed_cast_descendant! { ShapeTransformer, crate::shape::ThinPlateSplineShapeTransformer, cv_ShapeTransformer_to_ThinPlateSplineShapeTransformer } impl core::AlgorithmTraitConst for ShapeTransformer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1521,23 +1508,25 @@ pub mod shape { boxed_ref! { ShapeTransformer, crate::shape::ShapeTransformerTraitConst, as_raw_ShapeTransformer, crate::shape::ShapeTransformerTrait, as_raw_mut_ShapeTransformer } - impl ShapeTransformer { + /// Definition of the transformation + /// + /// occupied in the paper "Principal Warps: Thin-Plate Splines and Decomposition of Deformations", by + /// F.L. Bookstein (PAMI 1989). : + pub struct ThinPlateSplineShapeTransformer { + ptr: *mut c_void, } - boxed_cast_descendant! { ShapeTransformer, crate::shape::AffineTransformer, cv_ShapeTransformer_to_AffineTransformer } - - boxed_cast_descendant! { ShapeTransformer, crate::shape::ThinPlateSplineShapeTransformer, cv_ShapeTransformer_to_ThinPlateSplineShapeTransformer } - - boxed_cast_base! { ShapeTransformer, core::Algorithm, cv_ShapeTransformer_to_Algorithm } + opencv_type_boxed! { ThinPlateSplineShapeTransformer } - impl std::fmt::Debug for ShapeTransformer { + impl Drop for ThinPlateSplineShapeTransformer { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ShapeTransformer") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ThinPlateSplineShapeTransformer_delete(self.as_raw_mut_ThinPlateSplineShapeTransformer()) }; } } + unsafe impl Send for ThinPlateSplineShapeTransformer {} + /// Constant methods for [crate::shape::ThinPlateSplineShapeTransformer] pub trait ThinPlateSplineShapeTransformerTraitConst: crate::shape::ShapeTransformerTraitConst { fn as_raw_ThinPlateSplineShapeTransformer(&self) -> *const c_void; @@ -1573,24 +1562,17 @@ pub mod shape { } - /// Definition of the transformation - /// - /// occupied in the paper "Principal Warps: Thin-Plate Splines and Decomposition of Deformations", by - /// F.L. Bookstein (PAMI 1989). : - pub struct ThinPlateSplineShapeTransformer { - ptr: *mut c_void, - } - - opencv_type_boxed! { ThinPlateSplineShapeTransformer } - - impl Drop for ThinPlateSplineShapeTransformer { + impl std::fmt::Debug for ThinPlateSplineShapeTransformer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ThinPlateSplineShapeTransformer_delete(self.as_raw_mut_ThinPlateSplineShapeTransformer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ThinPlateSplineShapeTransformer") + .finish() } } - unsafe impl Send for ThinPlateSplineShapeTransformer {} + boxed_cast_base! { ThinPlateSplineShapeTransformer, core::Algorithm, cv_ThinPlateSplineShapeTransformer_to_Algorithm } + + boxed_cast_base! { ThinPlateSplineShapeTransformer, crate::shape::ShapeTransformer, cv_ThinPlateSplineShapeTransformer_to_ShapeTransformer } impl core::AlgorithmTraitConst for ThinPlateSplineShapeTransformer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1622,18 +1604,4 @@ pub mod shape { boxed_ref! { ThinPlateSplineShapeTransformer, crate::shape::ThinPlateSplineShapeTransformerTraitConst, as_raw_ThinPlateSplineShapeTransformer, crate::shape::ThinPlateSplineShapeTransformerTrait, as_raw_mut_ThinPlateSplineShapeTransformer } - impl ThinPlateSplineShapeTransformer { - } - - boxed_cast_base! { ThinPlateSplineShapeTransformer, core::Algorithm, cv_ThinPlateSplineShapeTransformer_to_Algorithm } - - boxed_cast_base! { ThinPlateSplineShapeTransformer, crate::shape::ShapeTransformer, cv_ThinPlateSplineShapeTransformer_to_ShapeTransformer } - - impl std::fmt::Debug for ThinPlateSplineShapeTransformer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ThinPlateSplineShapeTransformer") - .finish() - } - } } diff --git a/docs/signal.rs b/docs/signal.rs index 8373bcc17..4f1534110 100644 --- a/docs/signal.rs +++ b/docs/signal.rs @@ -27,4 +27,5 @@ pub mod signal { let ret = ret.into_result()?; Ok(ret) } + } diff --git a/docs/stereo.rs b/docs/stereo.rs index b59416ea8..88789c2cd 100644 --- a/docs/stereo.rs +++ b/docs/stereo.rs @@ -199,7 +199,69 @@ pub mod stereo { opencv_type_simple! { crate::stereo::PropagationParameters } - impl PropagationParameters { + /// Class containing the methods needed for Quasi Dense Stereo computation. + /// + /// This module contains the code to perform quasi dense stereo matching. + /// The method initially starts with a sparse 3D reconstruction based on feature matching across a + /// stereo image pair and subsequently propagates the structure into neighboring image regions. + /// To obtain initial seed correspondences, the algorithm locates Shi and Tomashi features in the + /// left image of the stereo pair and then tracks them using pyramidal Lucas-Kanade in the right image. + /// To densify the sparse correspondences, the algorithm computes the zero-mean normalized + /// cross-correlation (ZNCC) in small patches around every seed pair and uses it as a quality metric + /// for each match. In this code, we introduce a custom structure to store the location and ZNCC value + /// of correspondences called "Match". Seed Matches are stored in a priority queue sorted according to + /// their ZNCC value, allowing for the best quality Match to be readily available. The algorithm pops + /// Matches and uses them to extract new matches around them. This is done by considering a small + /// neighboring area around each Seed and retrieving correspondences above a certain texture threshold + /// that are not previously computed. New matches are stored in the seed priority queue and used as seeds. + /// The propagation process ends when no additional matches can be retrieved. + /// ## See also + /// This code represents the work presented in [Stoyanov2010](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Stoyanov2010). + /// If this code is useful for your work please cite [Stoyanov2010](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Stoyanov2010). + /// + /// Also the original growing scheme idea is described in [Lhuillier2000](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Lhuillier2000) + pub struct QuasiDenseStereo { + ptr: *mut c_void, + } + + opencv_type_boxed! { QuasiDenseStereo } + + impl Drop for QuasiDenseStereo { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_stereo_QuasiDenseStereo_delete(self.as_raw_mut_QuasiDenseStereo()) }; + } + } + + unsafe impl Send for QuasiDenseStereo {} + + impl QuasiDenseStereo { + /// ## C++ default parameters + /// * param_filepath: cv::String() + #[inline] + pub fn create(mono_img_size: core::Size, param_filepath: &str) -> Result> { + extern_container_arg!(param_filepath); + return_send!(via ocvrs_return); + unsafe { sys::cv_stereo_QuasiDenseStereo_create_Size_String(&mono_img_size, param_filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [QuasiDenseStereo::create] function uses the following default values for its arguments: + /// * param_filepath: cv::String() + #[inline] + pub fn create_def(mono_img_size: core::Size) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_stereo_QuasiDenseStereo_create_Size(&mono_img_size, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + } /// Constant methods for [crate::stereo::QuasiDenseStereo] @@ -363,42 +425,15 @@ pub mod stereo { } - /// Class containing the methods needed for Quasi Dense Stereo computation. - /// - /// This module contains the code to perform quasi dense stereo matching. - /// The method initially starts with a sparse 3D reconstruction based on feature matching across a - /// stereo image pair and subsequently propagates the structure into neighboring image regions. - /// To obtain initial seed correspondences, the algorithm locates Shi and Tomashi features in the - /// left image of the stereo pair and then tracks them using pyramidal Lucas-Kanade in the right image. - /// To densify the sparse correspondences, the algorithm computes the zero-mean normalized - /// cross-correlation (ZNCC) in small patches around every seed pair and uses it as a quality metric - /// for each match. In this code, we introduce a custom structure to store the location and ZNCC value - /// of correspondences called "Match". Seed Matches are stored in a priority queue sorted according to - /// their ZNCC value, allowing for the best quality Match to be readily available. The algorithm pops - /// Matches and uses them to extract new matches around them. This is done by considering a small - /// neighboring area around each Seed and retrieving correspondences above a certain texture threshold - /// that are not previously computed. New matches are stored in the seed priority queue and used as seeds. - /// The propagation process ends when no additional matches can be retrieved. - /// ## See also - /// This code represents the work presented in [Stoyanov2010](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Stoyanov2010). - /// If this code is useful for your work please cite [Stoyanov2010](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Stoyanov2010). - /// - /// Also the original growing scheme idea is described in [Lhuillier2000](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Lhuillier2000) - pub struct QuasiDenseStereo { - ptr: *mut c_void, - } - - opencv_type_boxed! { QuasiDenseStereo } - - impl Drop for QuasiDenseStereo { + impl std::fmt::Debug for QuasiDenseStereo { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_stereo_QuasiDenseStereo_delete(self.as_raw_mut_QuasiDenseStereo()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("QuasiDenseStereo") + .field("param", &crate::stereo::QuasiDenseStereoTraitConst::param(self)) + .finish() } } - unsafe impl Send for QuasiDenseStereo {} - impl crate::stereo::QuasiDenseStereoTraitConst for QuasiDenseStereo { #[inline] fn as_raw_QuasiDenseStereo(&self) -> *const c_void { self.as_raw() } } @@ -409,41 +444,4 @@ pub mod stereo { boxed_ref! { QuasiDenseStereo, crate::stereo::QuasiDenseStereoTraitConst, as_raw_QuasiDenseStereo, crate::stereo::QuasiDenseStereoTrait, as_raw_mut_QuasiDenseStereo } - impl QuasiDenseStereo { - /// ## C++ default parameters - /// * param_filepath: cv::String() - #[inline] - pub fn create(mono_img_size: core::Size, param_filepath: &str) -> Result> { - extern_container_arg!(param_filepath); - return_send!(via ocvrs_return); - unsafe { sys::cv_stereo_QuasiDenseStereo_create_Size_String(&mono_img_size, param_filepath.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [QuasiDenseStereo::create] function uses the following default values for its arguments: - /// * param_filepath: cv::String() - #[inline] - pub fn create_def(mono_img_size: core::Size) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_stereo_QuasiDenseStereo_create_Size(&mono_img_size, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for QuasiDenseStereo { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("QuasiDenseStereo") - .field("param", &crate::stereo::QuasiDenseStereoTraitConst::param(self)) - .finish() - } - } } diff --git a/docs/stitching.rs b/docs/stitching.rs index 5a9d37e2e..6530e43cc 100644 --- a/docs/stitching.rs +++ b/docs/stitching.rs @@ -465,6 +465,35 @@ pub mod stitching { Ok(ret) } + /// Affine warper factory class. + /// ## See also + /// detail::AffineWarper + pub struct AffineWarper { + ptr: *mut c_void, + } + + opencv_type_boxed! { AffineWarper } + + impl Drop for AffineWarper { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_AffineWarper_delete(self.as_raw_mut_AffineWarper()) }; + } + } + + unsafe impl Send for AffineWarper {} + + impl AffineWarper { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::stitching::AffineWarper { + let ret = unsafe { sys::cv_AffineWarper_defaultNew_const() }; + let ret = unsafe { crate::stitching::AffineWarper::opencv_from_extern(ret) }; + ret + } + + } + /// Constant methods for [crate::stitching::AffineWarper] pub trait AffineWarperTraitConst: crate::stitching::WarperCreatorTraitConst { fn as_raw_AffineWarper(&self) -> *const c_void; @@ -487,23 +516,23 @@ pub mod stitching { } - /// Affine warper factory class. - /// ## See also - /// detail::AffineWarper - pub struct AffineWarper { - ptr: *mut c_void, + impl Default for AffineWarper { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { AffineWarper } - - impl Drop for AffineWarper { + impl std::fmt::Debug for AffineWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_AffineWarper_delete(self.as_raw_mut_AffineWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AffineWarper") + .finish() } } - unsafe impl Send for AffineWarper {} + boxed_cast_base! { AffineWarper, crate::stitching::WarperCreator, cv_AffineWarper_to_WarperCreator } impl crate::stitching::WarperCreatorTraitConst for AffineWarper { #[inline] fn as_raw_WarperCreator(&self) -> *const c_void { self.as_raw() } @@ -525,31 +554,49 @@ pub mod stitching { boxed_ref! { AffineWarper, crate::stitching::AffineWarperTraitConst, as_raw_AffineWarper, crate::stitching::AffineWarperTrait, as_raw_mut_AffineWarper } - impl AffineWarper { - /// Creates a default instance of the class by calling the default constructor + pub struct CompressedRectilinearPortraitWarper { + ptr: *mut c_void, + } + + opencv_type_boxed! { CompressedRectilinearPortraitWarper } + + impl Drop for CompressedRectilinearPortraitWarper { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_AffineWarper_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_CompressedRectilinearPortraitWarper_delete(self.as_raw_mut_CompressedRectilinearPortraitWarper()) }; } - } - boxed_cast_base! { AffineWarper, crate::stitching::WarperCreator, cv_AffineWarper_to_WarperCreator } + unsafe impl Send for CompressedRectilinearPortraitWarper {} - impl std::fmt::Debug for AffineWarper { + impl CompressedRectilinearPortraitWarper { + /// ## C++ default parameters + /// * a: 1 + /// * b: 1 #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AffineWarper") - .finish() + pub fn new(a: f32, b: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_CompressedRectilinearPortraitWarper_CompressedRectilinearPortraitWarper_float_float(a, b, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::CompressedRectilinearPortraitWarper::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for AffineWarper { + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * a: 1 + /// * b: 1 #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_CompressedRectilinearPortraitWarper_CompressedRectilinearPortraitWarper(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::CompressedRectilinearPortraitWarper::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::CompressedRectilinearPortraitWarper] @@ -574,20 +621,15 @@ pub mod stitching { } - pub struct CompressedRectilinearPortraitWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { CompressedRectilinearPortraitWarper } - - impl Drop for CompressedRectilinearPortraitWarper { + impl std::fmt::Debug for CompressedRectilinearPortraitWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_CompressedRectilinearPortraitWarper_delete(self.as_raw_mut_CompressedRectilinearPortraitWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CompressedRectilinearPortraitWarper") + .finish() } } - unsafe impl Send for CompressedRectilinearPortraitWarper {} + boxed_cast_base! { CompressedRectilinearPortraitWarper, crate::stitching::WarperCreator, cv_CompressedRectilinearPortraitWarper_to_WarperCreator } impl crate::stitching::WarperCreatorTraitConst for CompressedRectilinearPortraitWarper { #[inline] fn as_raw_WarperCreator(&self) -> *const c_void { self.as_raw() } @@ -609,17 +651,32 @@ pub mod stitching { boxed_ref! { CompressedRectilinearPortraitWarper, crate::stitching::CompressedRectilinearPortraitWarperTraitConst, as_raw_CompressedRectilinearPortraitWarper, crate::stitching::CompressedRectilinearPortraitWarperTrait, as_raw_mut_CompressedRectilinearPortraitWarper } - impl CompressedRectilinearPortraitWarper { + pub struct CompressedRectilinearWarper { + ptr: *mut c_void, + } + + opencv_type_boxed! { CompressedRectilinearWarper } + + impl Drop for CompressedRectilinearWarper { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_CompressedRectilinearWarper_delete(self.as_raw_mut_CompressedRectilinearWarper()) }; + } + } + + unsafe impl Send for CompressedRectilinearWarper {} + + impl CompressedRectilinearWarper { /// ## C++ default parameters /// * a: 1 /// * b: 1 #[inline] - pub fn new(a: f32, b: f32) -> Result { + pub fn new(a: f32, b: f32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_CompressedRectilinearPortraitWarper_CompressedRectilinearPortraitWarper_float_float(a, b, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_CompressedRectilinearWarper_CompressedRectilinearWarper_float_float(a, b, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::CompressedRectilinearPortraitWarper::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::CompressedRectilinearWarper::opencv_from_extern(ret) }; Ok(ret) } @@ -628,27 +685,17 @@ pub mod stitching { /// * a: 1 /// * b: 1 #[inline] - pub fn new_def() -> Result { + pub fn new_def() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_CompressedRectilinearPortraitWarper_CompressedRectilinearPortraitWarper(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_CompressedRectilinearWarper_CompressedRectilinearWarper(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::CompressedRectilinearPortraitWarper::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::CompressedRectilinearWarper::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { CompressedRectilinearPortraitWarper, crate::stitching::WarperCreator, cv_CompressedRectilinearPortraitWarper_to_WarperCreator } - - impl std::fmt::Debug for CompressedRectilinearPortraitWarper { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CompressedRectilinearPortraitWarper") - .finish() - } - } - /// Constant methods for [crate::stitching::CompressedRectilinearWarper] pub trait CompressedRectilinearWarperTraitConst: crate::stitching::WarperCreatorTraitConst { fn as_raw_CompressedRectilinearWarper(&self) -> *const c_void; @@ -671,20 +718,15 @@ pub mod stitching { } - pub struct CompressedRectilinearWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { CompressedRectilinearWarper } - - impl Drop for CompressedRectilinearWarper { + impl std::fmt::Debug for CompressedRectilinearWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_CompressedRectilinearWarper_delete(self.as_raw_mut_CompressedRectilinearWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CompressedRectilinearWarper") + .finish() } } - unsafe impl Send for CompressedRectilinearWarper {} + boxed_cast_base! { CompressedRectilinearWarper, crate::stitching::WarperCreator, cv_CompressedRectilinearWarper_to_WarperCreator } impl crate::stitching::WarperCreatorTraitConst for CompressedRectilinearWarper { #[inline] fn as_raw_WarperCreator(&self) -> *const c_void { self.as_raw() } @@ -706,44 +748,33 @@ pub mod stitching { boxed_ref! { CompressedRectilinearWarper, crate::stitching::CompressedRectilinearWarperTraitConst, as_raw_CompressedRectilinearWarper, crate::stitching::CompressedRectilinearWarperTrait, as_raw_mut_CompressedRectilinearWarper } - impl CompressedRectilinearWarper { - /// ## C++ default parameters - /// * a: 1 - /// * b: 1 - #[inline] - pub fn new(a: f32, b: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_CompressedRectilinearWarper_CompressedRectilinearWarper_float_float(a, b, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::CompressedRectilinearWarper::opencv_from_extern(ret) }; - Ok(ret) - } + /// Cylindrical warper factory class. + /// ## See also + /// detail::CylindricalWarper + pub struct CylindricalWarper { + ptr: *mut c_void, + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * a: 1 - /// * b: 1 + opencv_type_boxed! { CylindricalWarper } + + impl Drop for CylindricalWarper { #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_CompressedRectilinearWarper_CompressedRectilinearWarper(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::CompressedRectilinearWarper::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_CylindricalWarper_delete(self.as_raw_mut_CylindricalWarper()) }; } - } - boxed_cast_base! { CompressedRectilinearWarper, crate::stitching::WarperCreator, cv_CompressedRectilinearWarper_to_WarperCreator } + unsafe impl Send for CylindricalWarper {} - impl std::fmt::Debug for CompressedRectilinearWarper { + impl CylindricalWarper { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CompressedRectilinearWarper") - .finish() + pub fn default() -> crate::stitching::CylindricalWarper { + let ret = unsafe { sys::cv_CylindricalWarper_defaultNew_const() }; + let ret = unsafe { crate::stitching::CylindricalWarper::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::CylindricalWarper] @@ -768,23 +799,23 @@ pub mod stitching { } - /// Cylindrical warper factory class. - /// ## See also - /// detail::CylindricalWarper - pub struct CylindricalWarper { - ptr: *mut c_void, + impl Default for CylindricalWarper { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { CylindricalWarper } - - impl Drop for CylindricalWarper { + impl std::fmt::Debug for CylindricalWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_CylindricalWarper_delete(self.as_raw_mut_CylindricalWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CylindricalWarper") + .finish() } } - unsafe impl Send for CylindricalWarper {} + boxed_cast_base! { CylindricalWarper, crate::stitching::WarperCreator, cv_CylindricalWarper_to_WarperCreator } impl crate::stitching::WarperCreatorTraitConst for CylindricalWarper { #[inline] fn as_raw_WarperCreator(&self) -> *const c_void { self.as_raw() } @@ -806,31 +837,30 @@ pub mod stitching { boxed_ref! { CylindricalWarper, crate::stitching::CylindricalWarperTraitConst, as_raw_CylindricalWarper, crate::stitching::CylindricalWarperTrait, as_raw_mut_CylindricalWarper } - impl CylindricalWarper { - /// Creates a default instance of the class by calling the default constructor + pub struct CylindricalWarperGpu { + ptr: *mut c_void, + } + + opencv_type_boxed! { CylindricalWarperGpu } + + impl Drop for CylindricalWarperGpu { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_CylindricalWarper_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_CylindricalWarperGpu_delete(self.as_raw_mut_CylindricalWarperGpu()) }; } - } - boxed_cast_base! { CylindricalWarper, crate::stitching::WarperCreator, cv_CylindricalWarper_to_WarperCreator } + unsafe impl Send for CylindricalWarperGpu {} - impl std::fmt::Debug for CylindricalWarper { + impl CylindricalWarperGpu { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CylindricalWarper") - .finish() - } - } - - impl Default for CylindricalWarper { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::stitching::CylindricalWarperGpu { + let ret = unsafe { sys::cv_CylindricalWarperGpu_defaultNew_const() }; + let ret = unsafe { crate::stitching::CylindricalWarperGpu::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::CylindricalWarperGpu] @@ -855,20 +885,23 @@ pub mod stitching { } - pub struct CylindricalWarperGpu { - ptr: *mut c_void, + impl Default for CylindricalWarperGpu { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { CylindricalWarperGpu } - - impl Drop for CylindricalWarperGpu { + impl std::fmt::Debug for CylindricalWarperGpu { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_CylindricalWarperGpu_delete(self.as_raw_mut_CylindricalWarperGpu()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("CylindricalWarperGpu") + .finish() } } - unsafe impl Send for CylindricalWarperGpu {} + boxed_cast_base! { CylindricalWarperGpu, crate::stitching::WarperCreator, cv_CylindricalWarperGpu_to_WarperCreator } impl crate::stitching::WarperCreatorTraitConst for CylindricalWarperGpu { #[inline] fn as_raw_WarperCreator(&self) -> *const c_void { self.as_raw() } @@ -890,31 +923,30 @@ pub mod stitching { boxed_ref! { CylindricalWarperGpu, crate::stitching::CylindricalWarperGpuTraitConst, as_raw_CylindricalWarperGpu, crate::stitching::CylindricalWarperGpuTrait, as_raw_mut_CylindricalWarperGpu } - impl CylindricalWarperGpu { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_CylindricalWarperGpu_defaultNew_const()) } - } - + pub struct FisheyeWarper { + ptr: *mut c_void, } - boxed_cast_base! { CylindricalWarperGpu, crate::stitching::WarperCreator, cv_CylindricalWarperGpu_to_WarperCreator } + opencv_type_boxed! { FisheyeWarper } - impl std::fmt::Debug for CylindricalWarperGpu { + impl Drop for FisheyeWarper { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("CylindricalWarperGpu") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_FisheyeWarper_delete(self.as_raw_mut_FisheyeWarper()) }; } } - impl Default for CylindricalWarperGpu { + unsafe impl Send for FisheyeWarper {} + + impl FisheyeWarper { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::stitching::FisheyeWarper { + let ret = unsafe { sys::cv_FisheyeWarper_defaultNew_const() }; + let ret = unsafe { crate::stitching::FisheyeWarper::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::FisheyeWarper] @@ -939,20 +971,23 @@ pub mod stitching { } - pub struct FisheyeWarper { - ptr: *mut c_void, + impl Default for FisheyeWarper { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { FisheyeWarper } - - impl Drop for FisheyeWarper { + impl std::fmt::Debug for FisheyeWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_FisheyeWarper_delete(self.as_raw_mut_FisheyeWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FisheyeWarper") + .finish() } } - unsafe impl Send for FisheyeWarper {} + boxed_cast_base! { FisheyeWarper, crate::stitching::WarperCreator, cv_FisheyeWarper_to_WarperCreator } impl crate::stitching::WarperCreatorTraitConst for FisheyeWarper { #[inline] fn as_raw_WarperCreator(&self) -> *const c_void { self.as_raw() } @@ -974,31 +1009,30 @@ pub mod stitching { boxed_ref! { FisheyeWarper, crate::stitching::FisheyeWarperTraitConst, as_raw_FisheyeWarper, crate::stitching::FisheyeWarperTrait, as_raw_mut_FisheyeWarper } - impl FisheyeWarper { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_FisheyeWarper_defaultNew_const()) } - } - + pub struct MercatorWarper { + ptr: *mut c_void, } - boxed_cast_base! { FisheyeWarper, crate::stitching::WarperCreator, cv_FisheyeWarper_to_WarperCreator } + opencv_type_boxed! { MercatorWarper } - impl std::fmt::Debug for FisheyeWarper { + impl Drop for MercatorWarper { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FisheyeWarper") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_MercatorWarper_delete(self.as_raw_mut_MercatorWarper()) }; } } - impl Default for FisheyeWarper { + unsafe impl Send for MercatorWarper {} + + impl MercatorWarper { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::stitching::MercatorWarper { + let ret = unsafe { sys::cv_MercatorWarper_defaultNew_const() }; + let ret = unsafe { crate::stitching::MercatorWarper::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::MercatorWarper] @@ -1023,20 +1057,23 @@ pub mod stitching { } - pub struct MercatorWarper { - ptr: *mut c_void, + impl Default for MercatorWarper { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { MercatorWarper } - - impl Drop for MercatorWarper { + impl std::fmt::Debug for MercatorWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_MercatorWarper_delete(self.as_raw_mut_MercatorWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MercatorWarper") + .finish() } } - unsafe impl Send for MercatorWarper {} + boxed_cast_base! { MercatorWarper, crate::stitching::WarperCreator, cv_MercatorWarper_to_WarperCreator } impl crate::stitching::WarperCreatorTraitConst for MercatorWarper { #[inline] fn as_raw_WarperCreator(&self) -> *const c_void { self.as_raw() } @@ -1058,31 +1095,49 @@ pub mod stitching { boxed_ref! { MercatorWarper, crate::stitching::MercatorWarperTraitConst, as_raw_MercatorWarper, crate::stitching::MercatorWarperTrait, as_raw_mut_MercatorWarper } - impl MercatorWarper { - /// Creates a default instance of the class by calling the default constructor + pub struct PaniniPortraitWarper { + ptr: *mut c_void, + } + + opencv_type_boxed! { PaniniPortraitWarper } + + impl Drop for PaniniPortraitWarper { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_MercatorWarper_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_PaniniPortraitWarper_delete(self.as_raw_mut_PaniniPortraitWarper()) }; } - } - boxed_cast_base! { MercatorWarper, crate::stitching::WarperCreator, cv_MercatorWarper_to_WarperCreator } + unsafe impl Send for PaniniPortraitWarper {} - impl std::fmt::Debug for MercatorWarper { + impl PaniniPortraitWarper { + /// ## C++ default parameters + /// * a: 1 + /// * b: 1 #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MercatorWarper") - .finish() + pub fn new(a: f32, b: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_PaniniPortraitWarper_PaniniPortraitWarper_float_float(a, b, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::PaniniPortraitWarper::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for MercatorWarper { + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * a: 1 + /// * b: 1 #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_PaniniPortraitWarper_PaniniPortraitWarper(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::PaniniPortraitWarper::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::PaniniPortraitWarper] @@ -1107,20 +1162,15 @@ pub mod stitching { } - pub struct PaniniPortraitWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { PaniniPortraitWarper } - - impl Drop for PaniniPortraitWarper { + impl std::fmt::Debug for PaniniPortraitWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_PaniniPortraitWarper_delete(self.as_raw_mut_PaniniPortraitWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PaniniPortraitWarper") + .finish() } } - unsafe impl Send for PaniniPortraitWarper {} + boxed_cast_base! { PaniniPortraitWarper, crate::stitching::WarperCreator, cv_PaniniPortraitWarper_to_WarperCreator } impl crate::stitching::WarperCreatorTraitConst for PaniniPortraitWarper { #[inline] fn as_raw_WarperCreator(&self) -> *const c_void { self.as_raw() } @@ -1142,17 +1192,32 @@ pub mod stitching { boxed_ref! { PaniniPortraitWarper, crate::stitching::PaniniPortraitWarperTraitConst, as_raw_PaniniPortraitWarper, crate::stitching::PaniniPortraitWarperTrait, as_raw_mut_PaniniPortraitWarper } - impl PaniniPortraitWarper { + pub struct PaniniWarper { + ptr: *mut c_void, + } + + opencv_type_boxed! { PaniniWarper } + + impl Drop for PaniniWarper { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_PaniniWarper_delete(self.as_raw_mut_PaniniWarper()) }; + } + } + + unsafe impl Send for PaniniWarper {} + + impl PaniniWarper { /// ## C++ default parameters /// * a: 1 /// * b: 1 #[inline] - pub fn new(a: f32, b: f32) -> Result { + pub fn new(a: f32, b: f32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_PaniniPortraitWarper_PaniniPortraitWarper_float_float(a, b, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_PaniniWarper_PaniniWarper_float_float(a, b, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::PaniniPortraitWarper::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::PaniniWarper::opencv_from_extern(ret) }; Ok(ret) } @@ -1161,27 +1226,17 @@ pub mod stitching { /// * a: 1 /// * b: 1 #[inline] - pub fn new_def() -> Result { + pub fn new_def() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_PaniniPortraitWarper_PaniniPortraitWarper(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_PaniniWarper_PaniniWarper(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::PaniniPortraitWarper::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::PaniniWarper::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { PaniniPortraitWarper, crate::stitching::WarperCreator, cv_PaniniPortraitWarper_to_WarperCreator } - - impl std::fmt::Debug for PaniniPortraitWarper { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PaniniPortraitWarper") - .finish() - } - } - /// Constant methods for [crate::stitching::PaniniWarper] pub trait PaniniWarperTraitConst: crate::stitching::WarperCreatorTraitConst { fn as_raw_PaniniWarper(&self) -> *const c_void; @@ -1204,20 +1259,15 @@ pub mod stitching { } - pub struct PaniniWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { PaniniWarper } - - impl Drop for PaniniWarper { + impl std::fmt::Debug for PaniniWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_PaniniWarper_delete(self.as_raw_mut_PaniniWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PaniniWarper") + .finish() } } - unsafe impl Send for PaniniWarper {} + boxed_cast_base! { PaniniWarper, crate::stitching::WarperCreator, cv_PaniniWarper_to_WarperCreator } impl crate::stitching::WarperCreatorTraitConst for PaniniWarper { #[inline] fn as_raw_WarperCreator(&self) -> *const c_void { self.as_raw() } @@ -1239,44 +1289,33 @@ pub mod stitching { boxed_ref! { PaniniWarper, crate::stitching::PaniniWarperTraitConst, as_raw_PaniniWarper, crate::stitching::PaniniWarperTrait, as_raw_mut_PaniniWarper } - impl PaniniWarper { - /// ## C++ default parameters - /// * a: 1 - /// * b: 1 - #[inline] - pub fn new(a: f32, b: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_PaniniWarper_PaniniWarper_float_float(a, b, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::PaniniWarper::opencv_from_extern(ret) }; - Ok(ret) - } + /// Plane warper factory class. + /// ## See also + /// detail::PlaneWarper + pub struct PlaneWarper { + ptr: *mut c_void, + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * a: 1 - /// * b: 1 + opencv_type_boxed! { PlaneWarper } + + impl Drop for PlaneWarper { #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_PaniniWarper_PaniniWarper(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::PaniniWarper::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_PlaneWarper_delete(self.as_raw_mut_PlaneWarper()) }; } - } - boxed_cast_base! { PaniniWarper, crate::stitching::WarperCreator, cv_PaniniWarper_to_WarperCreator } + unsafe impl Send for PlaneWarper {} - impl std::fmt::Debug for PaniniWarper { + impl PlaneWarper { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PaniniWarper") - .finish() + pub fn default() -> crate::stitching::PlaneWarper { + let ret = unsafe { sys::cv_PlaneWarper_defaultNew_const() }; + let ret = unsafe { crate::stitching::PlaneWarper::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::PlaneWarper] @@ -1301,23 +1340,23 @@ pub mod stitching { } - /// Plane warper factory class. - /// ## See also - /// detail::PlaneWarper - pub struct PlaneWarper { - ptr: *mut c_void, + impl Default for PlaneWarper { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { PlaneWarper } - - impl Drop for PlaneWarper { + impl std::fmt::Debug for PlaneWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_PlaneWarper_delete(self.as_raw_mut_PlaneWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PlaneWarper") + .finish() } } - unsafe impl Send for PlaneWarper {} + boxed_cast_base! { PlaneWarper, crate::stitching::WarperCreator, cv_PlaneWarper_to_WarperCreator } impl crate::stitching::WarperCreatorTraitConst for PlaneWarper { #[inline] fn as_raw_WarperCreator(&self) -> *const c_void { self.as_raw() } @@ -1339,31 +1378,30 @@ pub mod stitching { boxed_ref! { PlaneWarper, crate::stitching::PlaneWarperTraitConst, as_raw_PlaneWarper, crate::stitching::PlaneWarperTrait, as_raw_mut_PlaneWarper } - impl PlaneWarper { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_PlaneWarper_defaultNew_const()) } - } - + pub struct PlaneWarperGpu { + ptr: *mut c_void, } - boxed_cast_base! { PlaneWarper, crate::stitching::WarperCreator, cv_PlaneWarper_to_WarperCreator } + opencv_type_boxed! { PlaneWarperGpu } - impl std::fmt::Debug for PlaneWarper { + impl Drop for PlaneWarperGpu { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PlaneWarper") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_PlaneWarperGpu_delete(self.as_raw_mut_PlaneWarperGpu()) }; } } - impl Default for PlaneWarper { + unsafe impl Send for PlaneWarperGpu {} + + impl PlaneWarperGpu { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::stitching::PlaneWarperGpu { + let ret = unsafe { sys::cv_PlaneWarperGpu_defaultNew_const() }; + let ret = unsafe { crate::stitching::PlaneWarperGpu::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::PlaneWarperGpu] @@ -1388,20 +1426,23 @@ pub mod stitching { } - pub struct PlaneWarperGpu { - ptr: *mut c_void, + impl Default for PlaneWarperGpu { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { PlaneWarperGpu } - - impl Drop for PlaneWarperGpu { + impl std::fmt::Debug for PlaneWarperGpu { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_PlaneWarperGpu_delete(self.as_raw_mut_PlaneWarperGpu()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PlaneWarperGpu") + .finish() } } - unsafe impl Send for PlaneWarperGpu {} + boxed_cast_base! { PlaneWarperGpu, crate::stitching::WarperCreator, cv_PlaneWarperGpu_to_WarperCreator } impl crate::stitching::WarperCreatorTraitConst for PlaneWarperGpu { #[inline] fn as_raw_WarperCreator(&self) -> *const c_void { self.as_raw() } @@ -1423,31 +1464,43 @@ pub mod stitching { boxed_ref! { PlaneWarperGpu, crate::stitching::PlaneWarperGpuTraitConst, as_raw_PlaneWarperGpu, crate::stitching::PlaneWarperGpuTrait, as_raw_mut_PlaneWarperGpu } - impl PlaneWarperGpu { - /// Creates a default instance of the class by calling the default constructor + pub struct PyRotationWarper { + ptr: *mut c_void, + } + + opencv_type_boxed! { PyRotationWarper } + + impl Drop for PyRotationWarper { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_PlaneWarperGpu_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_PyRotationWarper_delete(self.as_raw_mut_PyRotationWarper()) }; } - } - boxed_cast_base! { PlaneWarperGpu, crate::stitching::WarperCreator, cv_PlaneWarperGpu_to_WarperCreator } + unsafe impl Send for PyRotationWarper {} - impl std::fmt::Debug for PlaneWarperGpu { + impl PyRotationWarper { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PlaneWarperGpu") - .finish() + pub fn new(typ: &str, scale: f32) -> Result { + extern_container_arg!(typ); + return_send!(via ocvrs_return); + unsafe { sys::cv_PyRotationWarper_PyRotationWarper_String_float(typ.opencv_as_extern(), scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::PyRotationWarper::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for PlaneWarperGpu { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_PyRotationWarper_PyRotationWarper(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::PyRotationWarper::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::PyRotationWarper] @@ -1597,21 +1650,14 @@ pub mod stitching { } - pub struct PyRotationWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { PyRotationWarper } - - impl Drop for PyRotationWarper { + impl std::fmt::Debug for PyRotationWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_PyRotationWarper_delete(self.as_raw_mut_PyRotationWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PyRotationWarper") + .finish() } } - unsafe impl Send for PyRotationWarper {} - impl crate::stitching::PyRotationWarperTraitConst for PyRotationWarper { #[inline] fn as_raw_PyRotationWarper(&self) -> *const c_void { self.as_raw() } } @@ -1622,36 +1668,31 @@ pub mod stitching { boxed_ref! { PyRotationWarper, crate::stitching::PyRotationWarperTraitConst, as_raw_PyRotationWarper, crate::stitching::PyRotationWarperTrait, as_raw_mut_PyRotationWarper } - impl PyRotationWarper { - #[inline] - pub fn new(typ: &str, scale: f32) -> Result { - extern_container_arg!(typ); - return_send!(via ocvrs_return); - unsafe { sys::cv_PyRotationWarper_PyRotationWarper_String_float(typ.opencv_as_extern(), scale, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::PyRotationWarper::opencv_from_extern(ret) }; - Ok(ret) - } + /// Spherical warper factory class + pub struct SphericalWarper { + ptr: *mut c_void, + } + + opencv_type_boxed! { SphericalWarper } + impl Drop for SphericalWarper { #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_PyRotationWarper_PyRotationWarper(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::PyRotationWarper::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_SphericalWarper_delete(self.as_raw_mut_SphericalWarper()) }; } - } - impl std::fmt::Debug for PyRotationWarper { + unsafe impl Send for SphericalWarper {} + + impl SphericalWarper { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PyRotationWarper") - .finish() + pub fn default() -> crate::stitching::SphericalWarper { + let ret = unsafe { sys::cv_SphericalWarper_defaultNew_const() }; + let ret = unsafe { crate::stitching::SphericalWarper::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::SphericalWarper] @@ -1676,21 +1717,23 @@ pub mod stitching { } - /// Spherical warper factory class - pub struct SphericalWarper { - ptr: *mut c_void, + impl Default for SphericalWarper { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { SphericalWarper } - - impl Drop for SphericalWarper { + impl std::fmt::Debug for SphericalWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_SphericalWarper_delete(self.as_raw_mut_SphericalWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SphericalWarper") + .finish() } } - unsafe impl Send for SphericalWarper {} + boxed_cast_base! { SphericalWarper, crate::stitching::WarperCreator, cv_SphericalWarper_to_WarperCreator } impl crate::stitching::WarperCreatorTraitConst for SphericalWarper { #[inline] fn as_raw_WarperCreator(&self) -> *const c_void { self.as_raw() } @@ -1712,31 +1755,30 @@ pub mod stitching { boxed_ref! { SphericalWarper, crate::stitching::SphericalWarperTraitConst, as_raw_SphericalWarper, crate::stitching::SphericalWarperTrait, as_raw_mut_SphericalWarper } - impl SphericalWarper { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_SphericalWarper_defaultNew_const()) } - } - + pub struct SphericalWarperGpu { + ptr: *mut c_void, } - boxed_cast_base! { SphericalWarper, crate::stitching::WarperCreator, cv_SphericalWarper_to_WarperCreator } + opencv_type_boxed! { SphericalWarperGpu } - impl std::fmt::Debug for SphericalWarper { + impl Drop for SphericalWarperGpu { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SphericalWarper") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_SphericalWarperGpu_delete(self.as_raw_mut_SphericalWarperGpu()) }; } } - impl Default for SphericalWarper { + unsafe impl Send for SphericalWarperGpu {} + + impl SphericalWarperGpu { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::stitching::SphericalWarperGpu { + let ret = unsafe { sys::cv_SphericalWarperGpu_defaultNew_const() }; + let ret = unsafe { crate::stitching::SphericalWarperGpu::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::SphericalWarperGpu] @@ -1761,20 +1803,23 @@ pub mod stitching { } - pub struct SphericalWarperGpu { - ptr: *mut c_void, + impl Default for SphericalWarperGpu { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { SphericalWarperGpu } - - impl Drop for SphericalWarperGpu { + impl std::fmt::Debug for SphericalWarperGpu { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_SphericalWarperGpu_delete(self.as_raw_mut_SphericalWarperGpu()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SphericalWarperGpu") + .finish() } } - unsafe impl Send for SphericalWarperGpu {} + boxed_cast_base! { SphericalWarperGpu, crate::stitching::WarperCreator, cv_SphericalWarperGpu_to_WarperCreator } impl crate::stitching::WarperCreatorTraitConst for SphericalWarperGpu { #[inline] fn as_raw_WarperCreator(&self) -> *const c_void { self.as_raw() } @@ -1796,31 +1841,30 @@ pub mod stitching { boxed_ref! { SphericalWarperGpu, crate::stitching::SphericalWarperGpuTraitConst, as_raw_SphericalWarperGpu, crate::stitching::SphericalWarperGpuTrait, as_raw_mut_SphericalWarperGpu } - impl SphericalWarperGpu { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_SphericalWarperGpu_defaultNew_const()) } - } - + pub struct StereographicWarper { + ptr: *mut c_void, } - boxed_cast_base! { SphericalWarperGpu, crate::stitching::WarperCreator, cv_SphericalWarperGpu_to_WarperCreator } + opencv_type_boxed! { StereographicWarper } - impl std::fmt::Debug for SphericalWarperGpu { + impl Drop for StereographicWarper { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SphericalWarperGpu") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_StereographicWarper_delete(self.as_raw_mut_StereographicWarper()) }; } } - impl Default for SphericalWarperGpu { + unsafe impl Send for StereographicWarper {} + + impl StereographicWarper { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::stitching::StereographicWarper { + let ret = unsafe { sys::cv_StereographicWarper_defaultNew_const() }; + let ret = unsafe { crate::stitching::StereographicWarper::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::StereographicWarper] @@ -1845,20 +1889,23 @@ pub mod stitching { } - pub struct StereographicWarper { - ptr: *mut c_void, + impl Default for StereographicWarper { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { StereographicWarper } - - impl Drop for StereographicWarper { + impl std::fmt::Debug for StereographicWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_StereographicWarper_delete(self.as_raw_mut_StereographicWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("StereographicWarper") + .finish() } } - unsafe impl Send for StereographicWarper {} + boxed_cast_base! { StereographicWarper, crate::stitching::WarperCreator, cv_StereographicWarper_to_WarperCreator } impl crate::stitching::WarperCreatorTraitConst for StereographicWarper { #[inline] fn as_raw_WarperCreator(&self) -> *const c_void { self.as_raw() } @@ -1880,31 +1927,88 @@ pub mod stitching { boxed_ref! { StereographicWarper, crate::stitching::StereographicWarperTraitConst, as_raw_StereographicWarper, crate::stitching::StereographicWarperTrait, as_raw_mut_StereographicWarper } - impl StereographicWarper { - /// Creates a default instance of the class by calling the default constructor + /// High level image stitcher. + /// + /// It's possible to use this class without being aware of the entire stitching pipeline. However, to + /// be able to achieve higher stitching stability and quality of the final images at least being + /// familiar with the theory is recommended. + /// + /// + /// Note: + /// * A basic example on image stitching can be found at + /// opencv_source_code/samples/cpp/stitching.cpp + /// * A basic example on image stitching in Python can be found at + /// opencv_source_code/samples/python/stitching.py + /// * A detailed example on image stitching can be found at + /// opencv_source_code/samples/cpp/stitching_detailed.cpp + pub struct Stitcher { + ptr: *mut c_void, + } + + opencv_type_boxed! { Stitcher } + + impl Drop for Stitcher { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_StereographicWarper_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_Stitcher_delete(self.as_raw_mut_Stitcher()) }; } - } - boxed_cast_base! { StereographicWarper, crate::stitching::WarperCreator, cv_StereographicWarper_to_WarperCreator } + unsafe impl Send for Stitcher {} - impl std::fmt::Debug for StereographicWarper { + impl Stitcher { + pub const ORIG_RESOL: f64 = -1.; + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("StereographicWarper") - .finish() + pub fn default() -> crate::stitching::Stitcher { + let ret = unsafe { sys::cv_Stitcher_defaultNew_const() }; + let ret = unsafe { crate::stitching::Stitcher::opencv_from_extern(ret) }; + ret } - } - impl Default for StereographicWarper { + /// Creates a Stitcher configured in one of the stitching modes. + /// + /// ## Parameters + /// * mode: Scenario for stitcher operation. This is usually determined by source of images + /// to stitch and their transformation. Default parameters will be chosen for operation in given + /// scenario. + /// ## Returns + /// Stitcher class instance. + /// + /// ## C++ default parameters + /// * mode: Stitcher::PANORAMA #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(mode: crate::stitching::Stitcher_Mode) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Stitcher_create_Mode(mode, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Creates a Stitcher configured in one of the stitching modes. + /// + /// ## Parameters + /// * mode: Scenario for stitcher operation. This is usually determined by source of images + /// to stitch and their transformation. Default parameters will be chosen for operation in given + /// scenario. + /// ## Returns + /// Stitcher class instance. + /// + /// ## Note + /// This alternative version of [Stitcher::create] function uses the following default values for its arguments: + /// * mode: Stitcher::PANORAMA + #[inline] + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_Stitcher_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Stitcher] @@ -2524,35 +2628,22 @@ pub mod stitching { } - /// High level image stitcher. - /// - /// It's possible to use this class without being aware of the entire stitching pipeline. However, to - /// be able to achieve higher stitching stability and quality of the final images at least being - /// familiar with the theory is recommended. - /// - /// - /// Note: - /// * A basic example on image stitching can be found at - /// opencv_source_code/samples/cpp/stitching.cpp - /// * A basic example on image stitching in Python can be found at - /// opencv_source_code/samples/python/stitching.py - /// * A detailed example on image stitching can be found at - /// opencv_source_code/samples/cpp/stitching_detailed.cpp - pub struct Stitcher { - ptr: *mut c_void, + impl Default for Stitcher { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Stitcher } - - impl Drop for Stitcher { + impl std::fmt::Debug for Stitcher { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_Stitcher_delete(self.as_raw_mut_Stitcher()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Stitcher") + .finish() } } - unsafe impl Send for Stitcher {} - impl crate::stitching::StitcherTraitConst for Stitcher { #[inline] fn as_raw_Stitcher(&self) -> *const c_void { self.as_raw() } } @@ -2563,73 +2654,30 @@ pub mod stitching { boxed_ref! { Stitcher, crate::stitching::StitcherTraitConst, as_raw_Stitcher, crate::stitching::StitcherTrait, as_raw_mut_Stitcher } - impl Stitcher { - pub const ORIG_RESOL: f64 = -1.; - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_Stitcher_defaultNew_const()) } - } + pub struct TransverseMercatorWarper { + ptr: *mut c_void, + } - /// Creates a Stitcher configured in one of the stitching modes. - /// - /// ## Parameters - /// * mode: Scenario for stitcher operation. This is usually determined by source of images - /// to stitch and their transformation. Default parameters will be chosen for operation in given - /// scenario. - /// ## Returns - /// Stitcher class instance. - /// - /// ## C++ default parameters - /// * mode: Stitcher::PANORAMA - #[inline] - pub fn create(mode: crate::stitching::Stitcher_Mode) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Stitcher_create_Mode(mode, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } + opencv_type_boxed! { TransverseMercatorWarper } - /// Creates a Stitcher configured in one of the stitching modes. - /// - /// ## Parameters - /// * mode: Scenario for stitcher operation. This is usually determined by source of images - /// to stitch and their transformation. Default parameters will be chosen for operation in given - /// scenario. - /// ## Returns - /// Stitcher class instance. - /// - /// ## Note - /// This alternative version of [Stitcher::create] function uses the following default values for its arguments: - /// * mode: Stitcher::PANORAMA + impl Drop for TransverseMercatorWarper { #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_Stitcher_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_TransverseMercatorWarper_delete(self.as_raw_mut_TransverseMercatorWarper()) }; } - } - impl std::fmt::Debug for Stitcher { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Stitcher") - .finish() - } - } + unsafe impl Send for TransverseMercatorWarper {} - impl Default for Stitcher { + impl TransverseMercatorWarper { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::stitching::TransverseMercatorWarper { + let ret = unsafe { sys::cv_TransverseMercatorWarper_defaultNew_const() }; + let ret = unsafe { crate::stitching::TransverseMercatorWarper::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::TransverseMercatorWarper] @@ -2654,20 +2702,23 @@ pub mod stitching { } - pub struct TransverseMercatorWarper { - ptr: *mut c_void, + impl Default for TransverseMercatorWarper { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { TransverseMercatorWarper } - - impl Drop for TransverseMercatorWarper { + impl std::fmt::Debug for TransverseMercatorWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_TransverseMercatorWarper_delete(self.as_raw_mut_TransverseMercatorWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TransverseMercatorWarper") + .finish() } } - unsafe impl Send for TransverseMercatorWarper {} + boxed_cast_base! { TransverseMercatorWarper, crate::stitching::WarperCreator, cv_TransverseMercatorWarper_to_WarperCreator } impl crate::stitching::WarperCreatorTraitConst for TransverseMercatorWarper { #[inline] fn as_raw_WarperCreator(&self) -> *const c_void { self.as_raw() } @@ -2689,32 +2740,21 @@ pub mod stitching { boxed_ref! { TransverseMercatorWarper, crate::stitching::TransverseMercatorWarperTraitConst, as_raw_TransverseMercatorWarper, crate::stitching::TransverseMercatorWarperTrait, as_raw_mut_TransverseMercatorWarper } - impl TransverseMercatorWarper { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_TransverseMercatorWarper_defaultNew_const()) } - } - + /// Image warper factories base class. + pub struct WarperCreator { + ptr: *mut c_void, } - boxed_cast_base! { TransverseMercatorWarper, crate::stitching::WarperCreator, cv_TransverseMercatorWarper_to_WarperCreator } + opencv_type_boxed! { WarperCreator } - impl std::fmt::Debug for TransverseMercatorWarper { + impl Drop for WarperCreator { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TransverseMercatorWarper") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_WarperCreator_delete(self.as_raw_mut_WarperCreator()) }; } } - impl Default for TransverseMercatorWarper { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } + unsafe impl Send for WarperCreator {} /// Constant methods for [crate::stitching::WarperCreator] pub trait WarperCreatorTraitConst { @@ -2738,35 +2778,14 @@ pub mod stitching { } - /// Image warper factories base class. - pub struct WarperCreator { - ptr: *mut c_void, - } - - opencv_type_boxed! { WarperCreator } - - impl Drop for WarperCreator { + impl std::fmt::Debug for WarperCreator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_WarperCreator_delete(self.as_raw_mut_WarperCreator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("WarperCreator") + .finish() } } - unsafe impl Send for WarperCreator {} - - impl crate::stitching::WarperCreatorTraitConst for WarperCreator { - #[inline] fn as_raw_WarperCreator(&self) -> *const c_void { self.as_raw() } - } - - impl crate::stitching::WarperCreatorTrait for WarperCreator { - #[inline] fn as_raw_mut_WarperCreator(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WarperCreator, crate::stitching::WarperCreatorTraitConst, as_raw_WarperCreator, crate::stitching::WarperCreatorTrait, as_raw_mut_WarperCreator } - - impl WarperCreator { - } - boxed_cast_descendant! { WarperCreator, crate::stitching::AffineWarper, cv_WarperCreator_to_AffineWarper } boxed_cast_descendant! { WarperCreator, crate::stitching::CompressedRectilinearPortraitWarper, cv_WarperCreator_to_CompressedRectilinearPortraitWarper } @@ -2797,25 +2816,15 @@ pub mod stitching { boxed_cast_descendant! { WarperCreator, crate::stitching::TransverseMercatorWarper, cv_WarperCreator_to_TransverseMercatorWarper } - impl std::fmt::Debug for WarperCreator { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("WarperCreator") - .finish() - } + impl crate::stitching::WarperCreatorTraitConst for WarperCreator { + #[inline] fn as_raw_WarperCreator(&self) -> *const c_void { self.as_raw() } } - /// Constant methods for [crate::stitching::Detail_AffineBasedEstimator] - pub trait Detail_AffineBasedEstimatorTraitConst: crate::stitching::Detail_EstimatorTraitConst { - fn as_raw_Detail_AffineBasedEstimator(&self) -> *const c_void; - + impl crate::stitching::WarperCreatorTrait for WarperCreator { + #[inline] fn as_raw_mut_WarperCreator(&mut self) -> *mut c_void { self.as_raw_mut() } } - /// Mutable methods for [crate::stitching::Detail_AffineBasedEstimator] - pub trait Detail_AffineBasedEstimatorTrait: crate::stitching::Detail_AffineBasedEstimatorTraitConst + crate::stitching::Detail_EstimatorTrait { - fn as_raw_mut_Detail_AffineBasedEstimator(&mut self) -> *mut c_void; - - } + boxed_ref! { WarperCreator, crate::stitching::WarperCreatorTraitConst, as_raw_WarperCreator, crate::stitching::WarperCreatorTrait, as_raw_mut_WarperCreator } /// Affine transformation based estimator. /// @@ -2838,26 +2847,6 @@ pub mod stitching { unsafe impl Send for Detail_AffineBasedEstimator {} - impl crate::stitching::Detail_EstimatorTraitConst for Detail_AffineBasedEstimator { - #[inline] fn as_raw_Detail_Estimator(&self) -> *const c_void { self.as_raw() } - } - - impl crate::stitching::Detail_EstimatorTrait for Detail_AffineBasedEstimator { - #[inline] fn as_raw_mut_Detail_Estimator(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Detail_AffineBasedEstimator, crate::stitching::Detail_EstimatorTraitConst, as_raw_Detail_Estimator, crate::stitching::Detail_EstimatorTrait, as_raw_mut_Detail_Estimator } - - impl crate::stitching::Detail_AffineBasedEstimatorTraitConst for Detail_AffineBasedEstimator { - #[inline] fn as_raw_Detail_AffineBasedEstimator(&self) -> *const c_void { self.as_raw() } - } - - impl crate::stitching::Detail_AffineBasedEstimatorTrait for Detail_AffineBasedEstimator { - #[inline] fn as_raw_mut_Detail_AffineBasedEstimator(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Detail_AffineBasedEstimator, crate::stitching::Detail_AffineBasedEstimatorTraitConst, as_raw_Detail_AffineBasedEstimator, crate::stitching::Detail_AffineBasedEstimatorTrait, as_raw_mut_Detail_AffineBasedEstimator } - impl Detail_AffineBasedEstimator { #[inline] pub fn default() -> Result { @@ -2871,7 +2860,17 @@ pub mod stitching { } - boxed_cast_base! { Detail_AffineBasedEstimator, crate::stitching::Detail_Estimator, cv_detail_AffineBasedEstimator_to_Detail_Estimator } + /// Constant methods for [crate::stitching::Detail_AffineBasedEstimator] + pub trait Detail_AffineBasedEstimatorTraitConst: crate::stitching::Detail_EstimatorTraitConst { + fn as_raw_Detail_AffineBasedEstimator(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::stitching::Detail_AffineBasedEstimator] + pub trait Detail_AffineBasedEstimatorTrait: crate::stitching::Detail_AffineBasedEstimatorTraitConst + crate::stitching::Detail_EstimatorTrait { + fn as_raw_mut_Detail_AffineBasedEstimator(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for Detail_AffineBasedEstimator { #[inline] @@ -2881,18 +2880,28 @@ pub mod stitching { } } - /// Constant methods for [crate::stitching::Detail_AffineBestOf2NearestMatcher] - pub trait Detail_AffineBestOf2NearestMatcherTraitConst: crate::stitching::Detail_BestOf2NearestMatcherTraitConst { - fn as_raw_Detail_AffineBestOf2NearestMatcher(&self) -> *const c_void; + boxed_cast_base! { Detail_AffineBasedEstimator, crate::stitching::Detail_Estimator, cv_detail_AffineBasedEstimator_to_Detail_Estimator } + impl crate::stitching::Detail_EstimatorTraitConst for Detail_AffineBasedEstimator { + #[inline] fn as_raw_Detail_Estimator(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::stitching::Detail_AffineBestOf2NearestMatcher] - pub trait Detail_AffineBestOf2NearestMatcherTrait: crate::stitching::Detail_AffineBestOf2NearestMatcherTraitConst + crate::stitching::Detail_BestOf2NearestMatcherTrait { - fn as_raw_mut_Detail_AffineBestOf2NearestMatcher(&mut self) -> *mut c_void; + impl crate::stitching::Detail_EstimatorTrait for Detail_AffineBasedEstimator { + #[inline] fn as_raw_mut_Detail_Estimator(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Detail_AffineBasedEstimator, crate::stitching::Detail_EstimatorTraitConst, as_raw_Detail_Estimator, crate::stitching::Detail_EstimatorTrait, as_raw_mut_Detail_Estimator } + + impl crate::stitching::Detail_AffineBasedEstimatorTraitConst for Detail_AffineBasedEstimator { + #[inline] fn as_raw_Detail_AffineBasedEstimator(&self) -> *const c_void { self.as_raw() } + } + impl crate::stitching::Detail_AffineBasedEstimatorTrait for Detail_AffineBasedEstimator { + #[inline] fn as_raw_mut_Detail_AffineBasedEstimator(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { Detail_AffineBasedEstimator, crate::stitching::Detail_AffineBasedEstimatorTraitConst, as_raw_Detail_AffineBasedEstimator, crate::stitching::Detail_AffineBasedEstimatorTrait, as_raw_mut_Detail_AffineBasedEstimator } + /// Features matcher similar to cv::detail::BestOf2NearestMatcher which /// finds two best matches for each feature and leaves the best one only if the /// ratio between descriptor distances is greater than the threshold match_conf. @@ -2916,36 +2925,6 @@ pub mod stitching { unsafe impl Send for Detail_AffineBestOf2NearestMatcher {} - impl crate::stitching::Detail_BestOf2NearestMatcherTraitConst for Detail_AffineBestOf2NearestMatcher { - #[inline] fn as_raw_Detail_BestOf2NearestMatcher(&self) -> *const c_void { self.as_raw() } - } - - impl crate::stitching::Detail_BestOf2NearestMatcherTrait for Detail_AffineBestOf2NearestMatcher { - #[inline] fn as_raw_mut_Detail_BestOf2NearestMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Detail_AffineBestOf2NearestMatcher, crate::stitching::Detail_BestOf2NearestMatcherTraitConst, as_raw_Detail_BestOf2NearestMatcher, crate::stitching::Detail_BestOf2NearestMatcherTrait, as_raw_mut_Detail_BestOf2NearestMatcher } - - impl crate::stitching::Detail_FeaturesMatcherTraitConst for Detail_AffineBestOf2NearestMatcher { - #[inline] fn as_raw_Detail_FeaturesMatcher(&self) -> *const c_void { self.as_raw() } - } - - impl crate::stitching::Detail_FeaturesMatcherTrait for Detail_AffineBestOf2NearestMatcher { - #[inline] fn as_raw_mut_Detail_FeaturesMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Detail_AffineBestOf2NearestMatcher, crate::stitching::Detail_FeaturesMatcherTraitConst, as_raw_Detail_FeaturesMatcher, crate::stitching::Detail_FeaturesMatcherTrait, as_raw_mut_Detail_FeaturesMatcher } - - impl crate::stitching::Detail_AffineBestOf2NearestMatcherTraitConst for Detail_AffineBestOf2NearestMatcher { - #[inline] fn as_raw_Detail_AffineBestOf2NearestMatcher(&self) -> *const c_void { self.as_raw() } - } - - impl crate::stitching::Detail_AffineBestOf2NearestMatcherTrait for Detail_AffineBestOf2NearestMatcher { - #[inline] fn as_raw_mut_Detail_AffineBestOf2NearestMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Detail_AffineBestOf2NearestMatcher, crate::stitching::Detail_AffineBestOf2NearestMatcherTraitConst, as_raw_Detail_AffineBestOf2NearestMatcher, crate::stitching::Detail_AffineBestOf2NearestMatcherTrait, as_raw_mut_Detail_AffineBestOf2NearestMatcher } - impl Detail_AffineBestOf2NearestMatcher { /// Constructs a "best of 2 nearest" matcher that expects affine transformation /// between images @@ -3006,9 +2985,17 @@ pub mod stitching { } - boxed_cast_base! { Detail_AffineBestOf2NearestMatcher, crate::stitching::Detail_BestOf2NearestMatcher, cv_detail_AffineBestOf2NearestMatcher_to_Detail_BestOf2NearestMatcher } + /// Constant methods for [crate::stitching::Detail_AffineBestOf2NearestMatcher] + pub trait Detail_AffineBestOf2NearestMatcherTraitConst: crate::stitching::Detail_BestOf2NearestMatcherTraitConst { + fn as_raw_Detail_AffineBestOf2NearestMatcher(&self) -> *const c_void; - boxed_cast_base! { Detail_AffineBestOf2NearestMatcher, crate::stitching::Detail_FeaturesMatcher, cv_detail_AffineBestOf2NearestMatcher_to_Detail_FeaturesMatcher } + } + + /// Mutable methods for [crate::stitching::Detail_AffineBestOf2NearestMatcher] + pub trait Detail_AffineBestOf2NearestMatcherTrait: crate::stitching::Detail_AffineBestOf2NearestMatcherTraitConst + crate::stitching::Detail_BestOf2NearestMatcherTrait { + fn as_raw_mut_Detail_AffineBestOf2NearestMatcher(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for Detail_AffineBestOf2NearestMatcher { #[inline] @@ -3018,6 +3005,97 @@ pub mod stitching { } } + boxed_cast_base! { Detail_AffineBestOf2NearestMatcher, crate::stitching::Detail_BestOf2NearestMatcher, cv_detail_AffineBestOf2NearestMatcher_to_Detail_BestOf2NearestMatcher } + + boxed_cast_base! { Detail_AffineBestOf2NearestMatcher, crate::stitching::Detail_FeaturesMatcher, cv_detail_AffineBestOf2NearestMatcher_to_Detail_FeaturesMatcher } + + impl crate::stitching::Detail_BestOf2NearestMatcherTraitConst for Detail_AffineBestOf2NearestMatcher { + #[inline] fn as_raw_Detail_BestOf2NearestMatcher(&self) -> *const c_void { self.as_raw() } + } + + impl crate::stitching::Detail_BestOf2NearestMatcherTrait for Detail_AffineBestOf2NearestMatcher { + #[inline] fn as_raw_mut_Detail_BestOf2NearestMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Detail_AffineBestOf2NearestMatcher, crate::stitching::Detail_BestOf2NearestMatcherTraitConst, as_raw_Detail_BestOf2NearestMatcher, crate::stitching::Detail_BestOf2NearestMatcherTrait, as_raw_mut_Detail_BestOf2NearestMatcher } + + impl crate::stitching::Detail_FeaturesMatcherTraitConst for Detail_AffineBestOf2NearestMatcher { + #[inline] fn as_raw_Detail_FeaturesMatcher(&self) -> *const c_void { self.as_raw() } + } + + impl crate::stitching::Detail_FeaturesMatcherTrait for Detail_AffineBestOf2NearestMatcher { + #[inline] fn as_raw_mut_Detail_FeaturesMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Detail_AffineBestOf2NearestMatcher, crate::stitching::Detail_FeaturesMatcherTraitConst, as_raw_Detail_FeaturesMatcher, crate::stitching::Detail_FeaturesMatcherTrait, as_raw_mut_Detail_FeaturesMatcher } + + impl crate::stitching::Detail_AffineBestOf2NearestMatcherTraitConst for Detail_AffineBestOf2NearestMatcher { + #[inline] fn as_raw_Detail_AffineBestOf2NearestMatcher(&self) -> *const c_void { self.as_raw() } + } + + impl crate::stitching::Detail_AffineBestOf2NearestMatcherTrait for Detail_AffineBestOf2NearestMatcher { + #[inline] fn as_raw_mut_Detail_AffineBestOf2NearestMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Detail_AffineBestOf2NearestMatcher, crate::stitching::Detail_AffineBestOf2NearestMatcherTraitConst, as_raw_Detail_AffineBestOf2NearestMatcher, crate::stitching::Detail_AffineBestOf2NearestMatcherTrait, as_raw_mut_Detail_AffineBestOf2NearestMatcher } + + /// Affine warper that uses rotations and translations + /// + /// Uses affine transformation in homogeneous coordinates to represent both rotation and + /// translation in camera rotation matrix. + pub struct Detail_AffineWarper { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_AffineWarper } + + impl Drop for Detail_AffineWarper { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_detail_AffineWarper_delete(self.as_raw_mut_Detail_AffineWarper()) }; + } + } + + unsafe impl Send for Detail_AffineWarper {} + + impl Detail_AffineWarper { + /// Construct an instance of the affine warper class. + /// + /// ## Parameters + /// * scale: Projected image scale multiplier + /// + /// ## C++ default parameters + /// * scale: 1.f + #[inline] + pub fn new(scale: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_AffineWarper_AffineWarper_float(scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_AffineWarper::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Construct an instance of the affine warper class. + /// + /// ## Parameters + /// * scale: Projected image scale multiplier + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * scale: 1.f + #[inline] + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_AffineWarper_AffineWarper(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_AffineWarper::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::stitching::Detail_AffineWarper] pub trait Detail_AffineWarperTraitConst: crate::stitching::Detail_PlaneWarperTraitConst { fn as_raw_Detail_AffineWarper(&self) -> *const c_void; @@ -3132,24 +3210,17 @@ pub mod stitching { } - /// Affine warper that uses rotations and translations - /// - /// Uses affine transformation in homogeneous coordinates to represent both rotation and - /// translation in camera rotation matrix. - pub struct Detail_AffineWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_AffineWarper } - - impl Drop for Detail_AffineWarper { + impl std::fmt::Debug for Detail_AffineWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_AffineWarper_delete(self.as_raw_mut_Detail_AffineWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_AffineWarper") + .finish() } } - unsafe impl Send for Detail_AffineWarper {} + boxed_cast_base! { Detail_AffineWarper, crate::stitching::Detail_PlaneWarper, cv_detail_AffineWarper_to_Detail_PlaneWarper } + + boxed_cast_base! { Detail_AffineWarper, crate::stitching::Detail_RotationWarper, cv_detail_AffineWarper_to_Detail_RotationWarper } impl crate::stitching::Detail_PlaneWarperTraitConst for Detail_AffineWarper { #[inline] fn as_raw_Detail_PlaneWarper(&self) -> *const c_void { self.as_raw() } @@ -3181,77 +3252,6 @@ pub mod stitching { boxed_ref! { Detail_AffineWarper, crate::stitching::Detail_AffineWarperTraitConst, as_raw_Detail_AffineWarper, crate::stitching::Detail_AffineWarperTrait, as_raw_mut_Detail_AffineWarper } - impl Detail_AffineWarper { - /// Construct an instance of the affine warper class. - /// - /// ## Parameters - /// * scale: Projected image scale multiplier - /// - /// ## C++ default parameters - /// * scale: 1.f - #[inline] - pub fn new(scale: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_AffineWarper_AffineWarper_float(scale, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_AffineWarper::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Construct an instance of the affine warper class. - /// - /// ## Parameters - /// * scale: Projected image scale multiplier - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * scale: 1.f - #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_AffineWarper_AffineWarper(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_AffineWarper::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { Detail_AffineWarper, crate::stitching::Detail_PlaneWarper, cv_detail_AffineWarper_to_Detail_PlaneWarper } - - boxed_cast_base! { Detail_AffineWarper, crate::stitching::Detail_RotationWarper, cv_detail_AffineWarper_to_Detail_RotationWarper } - - impl std::fmt::Debug for Detail_AffineWarper { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_AffineWarper") - .finish() - } - } - - /// Constant methods for [crate::stitching::Detail_BestOf2NearestMatcher] - pub trait Detail_BestOf2NearestMatcherTraitConst: crate::stitching::Detail_FeaturesMatcherTraitConst { - fn as_raw_Detail_BestOf2NearestMatcher(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::stitching::Detail_BestOf2NearestMatcher] - pub trait Detail_BestOf2NearestMatcherTrait: crate::stitching::Detail_BestOf2NearestMatcherTraitConst + crate::stitching::Detail_FeaturesMatcherTrait { - fn as_raw_mut_Detail_BestOf2NearestMatcher(&mut self) -> *mut c_void; - - #[inline] - fn collect_garbage(&mut self) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_BestOf2NearestMatcher_collectGarbage(self.as_raw_mut_Detail_BestOf2NearestMatcher(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - /// Features matcher which finds two best matches for each feature and leaves the best one only if the /// ratio between descriptor distances is greater than the threshold match_conf /// ## See also @@ -3271,26 +3271,6 @@ pub mod stitching { unsafe impl Send for Detail_BestOf2NearestMatcher {} - impl crate::stitching::Detail_FeaturesMatcherTraitConst for Detail_BestOf2NearestMatcher { - #[inline] fn as_raw_Detail_FeaturesMatcher(&self) -> *const c_void { self.as_raw() } - } - - impl crate::stitching::Detail_FeaturesMatcherTrait for Detail_BestOf2NearestMatcher { - #[inline] fn as_raw_mut_Detail_FeaturesMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Detail_BestOf2NearestMatcher, crate::stitching::Detail_FeaturesMatcherTraitConst, as_raw_Detail_FeaturesMatcher, crate::stitching::Detail_FeaturesMatcherTrait, as_raw_mut_Detail_FeaturesMatcher } - - impl crate::stitching::Detail_BestOf2NearestMatcherTraitConst for Detail_BestOf2NearestMatcher { - #[inline] fn as_raw_Detail_BestOf2NearestMatcher(&self) -> *const c_void { self.as_raw() } - } - - impl crate::stitching::Detail_BestOf2NearestMatcherTrait for Detail_BestOf2NearestMatcher { - #[inline] fn as_raw_mut_Detail_BestOf2NearestMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Detail_BestOf2NearestMatcher, crate::stitching::Detail_BestOf2NearestMatcherTraitConst, as_raw_Detail_BestOf2NearestMatcher, crate::stitching::Detail_BestOf2NearestMatcherTrait, as_raw_mut_Detail_BestOf2NearestMatcher } - impl Detail_BestOf2NearestMatcher { /// Constructs a "best of 2 nearest" matcher. /// @@ -3384,11 +3364,26 @@ pub mod stitching { } - boxed_cast_descendant! { Detail_BestOf2NearestMatcher, crate::stitching::Detail_AffineBestOf2NearestMatcher, cv_detail_BestOf2NearestMatcher_to_Detail_AffineBestOf2NearestMatcher } + /// Constant methods for [crate::stitching::Detail_BestOf2NearestMatcher] + pub trait Detail_BestOf2NearestMatcherTraitConst: crate::stitching::Detail_FeaturesMatcherTraitConst { + fn as_raw_Detail_BestOf2NearestMatcher(&self) -> *const c_void; - boxed_cast_descendant! { Detail_BestOf2NearestMatcher, crate::stitching::Detail_BestOf2NearestRangeMatcher, cv_detail_BestOf2NearestMatcher_to_Detail_BestOf2NearestRangeMatcher } + } - boxed_cast_base! { Detail_BestOf2NearestMatcher, crate::stitching::Detail_FeaturesMatcher, cv_detail_BestOf2NearestMatcher_to_Detail_FeaturesMatcher } + /// Mutable methods for [crate::stitching::Detail_BestOf2NearestMatcher] + pub trait Detail_BestOf2NearestMatcherTrait: crate::stitching::Detail_BestOf2NearestMatcherTraitConst + crate::stitching::Detail_FeaturesMatcherTrait { + fn as_raw_mut_Detail_BestOf2NearestMatcher(&mut self) -> *mut c_void; + + #[inline] + fn collect_garbage(&mut self) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_BestOf2NearestMatcher_collectGarbage(self.as_raw_mut_Detail_BestOf2NearestMatcher(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } impl std::fmt::Debug for Detail_BestOf2NearestMatcher { #[inline] @@ -3398,62 +3393,46 @@ pub mod stitching { } } - /// Constant methods for [crate::stitching::Detail_BestOf2NearestRangeMatcher] - pub trait Detail_BestOf2NearestRangeMatcherTraitConst: crate::stitching::Detail_BestOf2NearestMatcherTraitConst { - fn as_raw_Detail_BestOf2NearestRangeMatcher(&self) -> *const c_void; - - } + boxed_cast_base! { Detail_BestOf2NearestMatcher, crate::stitching::Detail_FeaturesMatcher, cv_detail_BestOf2NearestMatcher_to_Detail_FeaturesMatcher } - /// Mutable methods for [crate::stitching::Detail_BestOf2NearestRangeMatcher] - pub trait Detail_BestOf2NearestRangeMatcherTrait: crate::stitching::Detail_BestOf2NearestMatcherTrait + crate::stitching::Detail_BestOf2NearestRangeMatcherTraitConst { - fn as_raw_mut_Detail_BestOf2NearestRangeMatcher(&mut self) -> *mut c_void; + boxed_cast_descendant! { Detail_BestOf2NearestMatcher, crate::stitching::Detail_AffineBestOf2NearestMatcher, cv_detail_BestOf2NearestMatcher_to_Detail_AffineBestOf2NearestMatcher } - } + boxed_cast_descendant! { Detail_BestOf2NearestMatcher, crate::stitching::Detail_BestOf2NearestRangeMatcher, cv_detail_BestOf2NearestMatcher_to_Detail_BestOf2NearestRangeMatcher } - pub struct Detail_BestOf2NearestRangeMatcher { - ptr: *mut c_void, + impl crate::stitching::Detail_FeaturesMatcherTraitConst for Detail_BestOf2NearestMatcher { + #[inline] fn as_raw_Detail_FeaturesMatcher(&self) -> *const c_void { self.as_raw() } } - opencv_type_boxed! { Detail_BestOf2NearestRangeMatcher } - - impl Drop for Detail_BestOf2NearestRangeMatcher { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_BestOf2NearestRangeMatcher_delete(self.as_raw_mut_Detail_BestOf2NearestRangeMatcher()) }; - } + impl crate::stitching::Detail_FeaturesMatcherTrait for Detail_BestOf2NearestMatcher { + #[inline] fn as_raw_mut_Detail_FeaturesMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } } - unsafe impl Send for Detail_BestOf2NearestRangeMatcher {} + boxed_ref! { Detail_BestOf2NearestMatcher, crate::stitching::Detail_FeaturesMatcherTraitConst, as_raw_Detail_FeaturesMatcher, crate::stitching::Detail_FeaturesMatcherTrait, as_raw_mut_Detail_FeaturesMatcher } - impl crate::stitching::Detail_BestOf2NearestMatcherTraitConst for Detail_BestOf2NearestRangeMatcher { + impl crate::stitching::Detail_BestOf2NearestMatcherTraitConst for Detail_BestOf2NearestMatcher { #[inline] fn as_raw_Detail_BestOf2NearestMatcher(&self) -> *const c_void { self.as_raw() } } - impl crate::stitching::Detail_BestOf2NearestMatcherTrait for Detail_BestOf2NearestRangeMatcher { + impl crate::stitching::Detail_BestOf2NearestMatcherTrait for Detail_BestOf2NearestMatcher { #[inline] fn as_raw_mut_Detail_BestOf2NearestMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { Detail_BestOf2NearestRangeMatcher, crate::stitching::Detail_BestOf2NearestMatcherTraitConst, as_raw_Detail_BestOf2NearestMatcher, crate::stitching::Detail_BestOf2NearestMatcherTrait, as_raw_mut_Detail_BestOf2NearestMatcher } - - impl crate::stitching::Detail_FeaturesMatcherTraitConst for Detail_BestOf2NearestRangeMatcher { - #[inline] fn as_raw_Detail_FeaturesMatcher(&self) -> *const c_void { self.as_raw() } - } + boxed_ref! { Detail_BestOf2NearestMatcher, crate::stitching::Detail_BestOf2NearestMatcherTraitConst, as_raw_Detail_BestOf2NearestMatcher, crate::stitching::Detail_BestOf2NearestMatcherTrait, as_raw_mut_Detail_BestOf2NearestMatcher } - impl crate::stitching::Detail_FeaturesMatcherTrait for Detail_BestOf2NearestRangeMatcher { - #[inline] fn as_raw_mut_Detail_FeaturesMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } + pub struct Detail_BestOf2NearestRangeMatcher { + ptr: *mut c_void, } - boxed_ref! { Detail_BestOf2NearestRangeMatcher, crate::stitching::Detail_FeaturesMatcherTraitConst, as_raw_Detail_FeaturesMatcher, crate::stitching::Detail_FeaturesMatcherTrait, as_raw_mut_Detail_FeaturesMatcher } - - impl crate::stitching::Detail_BestOf2NearestRangeMatcherTraitConst for Detail_BestOf2NearestRangeMatcher { - #[inline] fn as_raw_Detail_BestOf2NearestRangeMatcher(&self) -> *const c_void { self.as_raw() } - } + opencv_type_boxed! { Detail_BestOf2NearestRangeMatcher } - impl crate::stitching::Detail_BestOf2NearestRangeMatcherTrait for Detail_BestOf2NearestRangeMatcher { - #[inline] fn as_raw_mut_Detail_BestOf2NearestRangeMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } + impl Drop for Detail_BestOf2NearestRangeMatcher { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_detail_BestOf2NearestRangeMatcher_delete(self.as_raw_mut_Detail_BestOf2NearestRangeMatcher()) }; + } } - boxed_ref! { Detail_BestOf2NearestRangeMatcher, crate::stitching::Detail_BestOf2NearestRangeMatcherTraitConst, as_raw_Detail_BestOf2NearestRangeMatcher, crate::stitching::Detail_BestOf2NearestRangeMatcherTrait, as_raw_mut_Detail_BestOf2NearestRangeMatcher } + unsafe impl Send for Detail_BestOf2NearestRangeMatcher {} impl Detail_BestOf2NearestRangeMatcher { /// ## C++ default parameters @@ -3491,9 +3470,17 @@ pub mod stitching { } - boxed_cast_base! { Detail_BestOf2NearestRangeMatcher, crate::stitching::Detail_BestOf2NearestMatcher, cv_detail_BestOf2NearestRangeMatcher_to_Detail_BestOf2NearestMatcher } + /// Constant methods for [crate::stitching::Detail_BestOf2NearestRangeMatcher] + pub trait Detail_BestOf2NearestRangeMatcherTraitConst: crate::stitching::Detail_BestOf2NearestMatcherTraitConst { + fn as_raw_Detail_BestOf2NearestRangeMatcher(&self) -> *const c_void; - boxed_cast_base! { Detail_BestOf2NearestRangeMatcher, crate::stitching::Detail_FeaturesMatcher, cv_detail_BestOf2NearestRangeMatcher_to_Detail_FeaturesMatcher } + } + + /// Mutable methods for [crate::stitching::Detail_BestOf2NearestRangeMatcher] + pub trait Detail_BestOf2NearestRangeMatcherTrait: crate::stitching::Detail_BestOf2NearestMatcherTrait + crate::stitching::Detail_BestOf2NearestRangeMatcherTraitConst { + fn as_raw_mut_Detail_BestOf2NearestRangeMatcher(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for Detail_BestOf2NearestRangeMatcher { #[inline] @@ -3503,28 +3490,116 @@ pub mod stitching { } } - /// Constant methods for [crate::stitching::Detail_Blender] - pub trait Detail_BlenderTraitConst { - fn as_raw_Detail_Blender(&self) -> *const c_void; + boxed_cast_base! { Detail_BestOf2NearestRangeMatcher, crate::stitching::Detail_BestOf2NearestMatcher, cv_detail_BestOf2NearestRangeMatcher_to_Detail_BestOf2NearestMatcher } + boxed_cast_base! { Detail_BestOf2NearestRangeMatcher, crate::stitching::Detail_FeaturesMatcher, cv_detail_BestOf2NearestRangeMatcher_to_Detail_FeaturesMatcher } + + impl crate::stitching::Detail_BestOf2NearestMatcherTraitConst for Detail_BestOf2NearestRangeMatcher { + #[inline] fn as_raw_Detail_BestOf2NearestMatcher(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::stitching::Detail_Blender] - pub trait Detail_BlenderTrait: crate::stitching::Detail_BlenderTraitConst { - fn as_raw_mut_Detail_Blender(&mut self) -> *mut c_void; + impl crate::stitching::Detail_BestOf2NearestMatcherTrait for Detail_BestOf2NearestRangeMatcher { + #[inline] fn as_raw_mut_Detail_BestOf2NearestMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } + } - /// Prepares the blender for blending. - /// - /// ## Parameters - /// * corners: Source images top-left corners - /// * sizes: Source image sizes + boxed_ref! { Detail_BestOf2NearestRangeMatcher, crate::stitching::Detail_BestOf2NearestMatcherTraitConst, as_raw_Detail_BestOf2NearestMatcher, crate::stitching::Detail_BestOf2NearestMatcherTrait, as_raw_mut_Detail_BestOf2NearestMatcher } + + impl crate::stitching::Detail_FeaturesMatcherTraitConst for Detail_BestOf2NearestRangeMatcher { + #[inline] fn as_raw_Detail_FeaturesMatcher(&self) -> *const c_void { self.as_raw() } + } + + impl crate::stitching::Detail_FeaturesMatcherTrait for Detail_BestOf2NearestRangeMatcher { + #[inline] fn as_raw_mut_Detail_FeaturesMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Detail_BestOf2NearestRangeMatcher, crate::stitching::Detail_FeaturesMatcherTraitConst, as_raw_Detail_FeaturesMatcher, crate::stitching::Detail_FeaturesMatcherTrait, as_raw_mut_Detail_FeaturesMatcher } + + impl crate::stitching::Detail_BestOf2NearestRangeMatcherTraitConst for Detail_BestOf2NearestRangeMatcher { + #[inline] fn as_raw_Detail_BestOf2NearestRangeMatcher(&self) -> *const c_void { self.as_raw() } + } + + impl crate::stitching::Detail_BestOf2NearestRangeMatcherTrait for Detail_BestOf2NearestRangeMatcher { + #[inline] fn as_raw_mut_Detail_BestOf2NearestRangeMatcher(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Detail_BestOf2NearestRangeMatcher, crate::stitching::Detail_BestOf2NearestRangeMatcherTraitConst, as_raw_Detail_BestOf2NearestRangeMatcher, crate::stitching::Detail_BestOf2NearestRangeMatcherTrait, as_raw_mut_Detail_BestOf2NearestRangeMatcher } + + /// Base class for all blenders. + /// + /// Simple blender which puts one image over another + pub struct Detail_Blender { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_Blender } + + impl Drop for Detail_Blender { #[inline] - fn prepare(&mut self, corners: &core::Vector, sizes: &core::Vector) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_Blender_prepare_const_vectorLPointGR_const_vectorLSizeGR(self.as_raw_mut_Detail_Blender(), corners.as_raw_VectorOfPoint(), sizes.as_raw_VectorOfSize(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_Blender_delete(self.as_raw_mut_Detail_Blender()) }; + } + } + + unsafe impl Send for Detail_Blender {} + + impl Detail_Blender { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::stitching::Detail_Blender { + let ret = unsafe { sys::cv_detail_Blender_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_Blender::opencv_from_extern(ret) }; + ret + } + + /// ## C++ default parameters + /// * try_gpu: false + #[inline] + pub fn create_default(typ: i32, try_gpu: bool) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_Blender_createDefault_int_bool(typ, try_gpu, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [Detail_Blender::create_default] function uses the following default values for its arguments: + /// * try_gpu: false + #[inline] + pub fn create_default_def(typ: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_Blender_createDefault_int(typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::stitching::Detail_Blender] + pub trait Detail_BlenderTraitConst { + fn as_raw_Detail_Blender(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::stitching::Detail_Blender] + pub trait Detail_BlenderTrait: crate::stitching::Detail_BlenderTraitConst { + fn as_raw_mut_Detail_Blender(&mut self) -> *mut c_void; + + /// Prepares the blender for blending. + /// + /// ## Parameters + /// * corners: Source images top-left corners + /// * sizes: Source image sizes + #[inline] + fn prepare(&mut self, corners: &core::Vector, sizes: &core::Vector) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_Blender_prepare_const_vectorLPointGR_const_vectorLSizeGR(self.as_raw_mut_Detail_Blender(), corners.as_raw_VectorOfPoint(), sizes.as_raw_VectorOfSize(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } /// Prepares the blender for blending. @@ -3578,23 +3653,25 @@ pub mod stitching { } - /// Base class for all blenders. - /// - /// Simple blender which puts one image over another - pub struct Detail_Blender { - ptr: *mut c_void, + impl Default for Detail_Blender { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_Blender } - - impl Drop for Detail_Blender { + impl std::fmt::Debug for Detail_Blender { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_Blender_delete(self.as_raw_mut_Detail_Blender()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_Blender") + .finish() } } - unsafe impl Send for Detail_Blender {} + boxed_cast_descendant! { Detail_Blender, crate::stitching::Detail_FeatherBlender, cv_detail_Blender_to_Detail_FeatherBlender } + + boxed_cast_descendant! { Detail_Blender, crate::stitching::Detail_MultiBandBlender, cv_detail_Blender_to_Detail_MultiBandBlender } impl crate::stitching::Detail_BlenderTraitConst for Detail_Blender { #[inline] fn as_raw_Detail_Blender(&self) -> *const c_void { self.as_raw() } @@ -3606,60 +3683,55 @@ pub mod stitching { boxed_ref! { Detail_Blender, crate::stitching::Detail_BlenderTraitConst, as_raw_Detail_Blender, crate::stitching::Detail_BlenderTrait, as_raw_mut_Detail_Blender } - impl Detail_Blender { - /// Creates a default instance of the class by calling the default constructor + /// Exposure compensator which tries to remove exposure related artifacts by adjusting image block + /// on each channel. + pub struct Detail_BlocksChannelsCompensator { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_BlocksChannelsCompensator } + + impl Drop for Detail_BlocksChannelsCompensator { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_Blender_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_detail_BlocksChannelsCompensator_delete(self.as_raw_mut_Detail_BlocksChannelsCompensator()) }; } + } + + unsafe impl Send for Detail_BlocksChannelsCompensator {} + impl Detail_BlocksChannelsCompensator { /// ## C++ default parameters - /// * try_gpu: false + /// * bl_width: 32 + /// * bl_height: 32 + /// * nr_feeds: 1 #[inline] - pub fn create_default(typ: i32, try_gpu: bool) -> Result> { + pub fn new(bl_width: i32, bl_height: i32, nr_feeds: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_Blender_createDefault_int_bool(typ, try_gpu, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_BlocksChannelsCompensator_BlocksChannelsCompensator_int_int_int(bl_width, bl_height, nr_feeds, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::Detail_BlocksChannelsCompensator::opencv_from_extern(ret) }; Ok(ret) } /// ## Note - /// This alternative version of [Detail_Blender::create_default] function uses the following default values for its arguments: - /// * try_gpu: false + /// This alternative version of [new] function uses the following default values for its arguments: + /// * bl_width: 32 + /// * bl_height: 32 + /// * nr_feeds: 1 #[inline] - pub fn create_default_def(typ: i32) -> Result> { + pub fn new_def() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_Blender_createDefault_int(typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_BlocksChannelsCompensator_BlocksChannelsCompensator(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::Detail_BlocksChannelsCompensator::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_descendant! { Detail_Blender, crate::stitching::Detail_FeatherBlender, cv_detail_Blender_to_Detail_FeatherBlender } - - boxed_cast_descendant! { Detail_Blender, crate::stitching::Detail_MultiBandBlender, cv_detail_Blender_to_Detail_MultiBandBlender } - - impl std::fmt::Debug for Detail_Blender { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_Blender") - .finish() - } - } - - impl Default for Detail_Blender { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - /// Constant methods for [crate::stitching::Detail_BlocksChannelsCompensator] pub trait Detail_BlocksChannelsCompensatorTraitConst: crate::stitching::Detail_BlocksCompensatorTraitConst { fn as_raw_Detail_BlocksChannelsCompensator(&self) -> *const c_void; @@ -3681,22 +3753,17 @@ pub mod stitching { } - /// Exposure compensator which tries to remove exposure related artifacts by adjusting image block - /// on each channel. - pub struct Detail_BlocksChannelsCompensator { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_BlocksChannelsCompensator } - - impl Drop for Detail_BlocksChannelsCompensator { + impl std::fmt::Debug for Detail_BlocksChannelsCompensator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_BlocksChannelsCompensator_delete(self.as_raw_mut_Detail_BlocksChannelsCompensator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_BlocksChannelsCompensator") + .finish() } } - unsafe impl Send for Detail_BlocksChannelsCompensator {} + boxed_cast_base! { Detail_BlocksChannelsCompensator, crate::stitching::Detail_BlocksCompensator, cv_detail_BlocksChannelsCompensator_to_Detail_BlocksCompensator } + + boxed_cast_base! { Detail_BlocksChannelsCompensator, crate::stitching::Detail_ExposureCompensator, cv_detail_BlocksChannelsCompensator_to_Detail_ExposureCompensator } impl crate::stitching::Detail_BlocksCompensatorTraitConst for Detail_BlocksChannelsCompensator { #[inline] fn as_raw_Detail_BlocksCompensator(&self) -> *const c_void { self.as_raw() } @@ -3728,50 +3795,22 @@ pub mod stitching { boxed_ref! { Detail_BlocksChannelsCompensator, crate::stitching::Detail_BlocksChannelsCompensatorTraitConst, as_raw_Detail_BlocksChannelsCompensator, crate::stitching::Detail_BlocksChannelsCompensatorTrait, as_raw_mut_Detail_BlocksChannelsCompensator } - impl Detail_BlocksChannelsCompensator { - /// ## C++ default parameters - /// * bl_width: 32 - /// * bl_height: 32 - /// * nr_feeds: 1 - #[inline] - pub fn new(bl_width: i32, bl_height: i32, nr_feeds: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_BlocksChannelsCompensator_BlocksChannelsCompensator_int_int_int(bl_width, bl_height, nr_feeds, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_BlocksChannelsCompensator::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * bl_width: 32 - /// * bl_height: 32 - /// * nr_feeds: 1 - #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_BlocksChannelsCompensator_BlocksChannelsCompensator(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_BlocksChannelsCompensator::opencv_from_extern(ret) }; - Ok(ret) - } - + /// Exposure compensator which tries to remove exposure related artifacts by adjusting image blocks. + pub struct Detail_BlocksCompensator { + ptr: *mut c_void, } - boxed_cast_base! { Detail_BlocksChannelsCompensator, crate::stitching::Detail_BlocksCompensator, cv_detail_BlocksChannelsCompensator_to_Detail_BlocksCompensator } - - boxed_cast_base! { Detail_BlocksChannelsCompensator, crate::stitching::Detail_ExposureCompensator, cv_detail_BlocksChannelsCompensator_to_Detail_ExposureCompensator } + opencv_type_boxed! { Detail_BlocksCompensator } - impl std::fmt::Debug for Detail_BlocksChannelsCompensator { + impl Drop for Detail_BlocksCompensator { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_BlocksChannelsCompensator") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_detail_BlocksCompensator_delete(self.as_raw_mut_Detail_BlocksCompensator()) }; } } + unsafe impl Send for Detail_BlocksCompensator {} + /// Constant methods for [crate::stitching::Detail_BlocksCompensator] pub trait Detail_BlocksCompensatorTraitConst: crate::stitching::Detail_ExposureCompensatorTraitConst { fn as_raw_Detail_BlocksCompensator(&self) -> *const c_void; @@ -3894,21 +3933,19 @@ pub mod stitching { } - /// Exposure compensator which tries to remove exposure related artifacts by adjusting image blocks. - pub struct Detail_BlocksCompensator { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_BlocksCompensator } - - impl Drop for Detail_BlocksCompensator { + impl std::fmt::Debug for Detail_BlocksCompensator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_BlocksCompensator_delete(self.as_raw_mut_Detail_BlocksCompensator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_BlocksCompensator") + .finish() } } - unsafe impl Send for Detail_BlocksCompensator {} + boxed_cast_base! { Detail_BlocksCompensator, crate::stitching::Detail_ExposureCompensator, cv_detail_BlocksCompensator_to_Detail_ExposureCompensator } + + boxed_cast_descendant! { Detail_BlocksCompensator, crate::stitching::Detail_BlocksChannelsCompensator, cv_detail_BlocksCompensator_to_Detail_BlocksChannelsCompensator } + + boxed_cast_descendant! { Detail_BlocksCompensator, crate::stitching::Detail_BlocksGainCompensator, cv_detail_BlocksCompensator_to_Detail_BlocksGainCompensator } impl crate::stitching::Detail_ExposureCompensatorTraitConst for Detail_BlocksCompensator { #[inline] fn as_raw_Detail_ExposureCompensator(&self) -> *const c_void { self.as_raw() } @@ -3930,34 +3967,74 @@ pub mod stitching { boxed_ref! { Detail_BlocksCompensator, crate::stitching::Detail_BlocksCompensatorTraitConst, as_raw_Detail_BlocksCompensator, crate::stitching::Detail_BlocksCompensatorTrait, as_raw_mut_Detail_BlocksCompensator } - impl Detail_BlocksCompensator { + /// Exposure compensator which tries to remove exposure related artifacts by adjusting image block + /// intensities, see [UES01](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_UES01) for details. + pub struct Detail_BlocksGainCompensator { + ptr: *mut c_void, } - boxed_cast_descendant! { Detail_BlocksCompensator, crate::stitching::Detail_BlocksChannelsCompensator, cv_detail_BlocksCompensator_to_Detail_BlocksChannelsCompensator } - - boxed_cast_descendant! { Detail_BlocksCompensator, crate::stitching::Detail_BlocksGainCompensator, cv_detail_BlocksCompensator_to_Detail_BlocksGainCompensator } - - boxed_cast_base! { Detail_BlocksCompensator, crate::stitching::Detail_ExposureCompensator, cv_detail_BlocksCompensator_to_Detail_ExposureCompensator } + opencv_type_boxed! { Detail_BlocksGainCompensator } - impl std::fmt::Debug for Detail_BlocksCompensator { + impl Drop for Detail_BlocksGainCompensator { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_BlocksCompensator") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_detail_BlocksGainCompensator_delete(self.as_raw_mut_Detail_BlocksGainCompensator()) }; } } - /// Constant methods for [crate::stitching::Detail_BlocksGainCompensator] - pub trait Detail_BlocksGainCompensatorTraitConst: crate::stitching::Detail_BlocksCompensatorTraitConst { - fn as_raw_Detail_BlocksGainCompensator(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::stitching::Detail_BlocksGainCompensator] - pub trait Detail_BlocksGainCompensatorTrait: crate::stitching::Detail_BlocksCompensatorTrait + crate::stitching::Detail_BlocksGainCompensatorTraitConst { - fn as_raw_mut_Detail_BlocksGainCompensator(&mut self) -> *mut c_void; + unsafe impl Send for Detail_BlocksGainCompensator {} - #[inline] + impl Detail_BlocksGainCompensator { + /// ## C++ default parameters + /// * bl_width: 32 + /// * bl_height: 32 + #[inline] + pub fn new(bl_width: i32, bl_height: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_BlocksGainCompensator_BlocksGainCompensator_int_int(bl_width, bl_height, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_BlocksGainCompensator::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * bl_width: 32 + /// * bl_height: 32 + #[inline] + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_BlocksGainCompensator_BlocksGainCompensator(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_BlocksGainCompensator::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn new_1(bl_width: i32, bl_height: i32, nr_feeds: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_BlocksGainCompensator_BlocksGainCompensator_int_int_int(bl_width, bl_height, nr_feeds, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_BlocksGainCompensator::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::stitching::Detail_BlocksGainCompensator] + pub trait Detail_BlocksGainCompensatorTraitConst: crate::stitching::Detail_BlocksCompensatorTraitConst { + fn as_raw_Detail_BlocksGainCompensator(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::stitching::Detail_BlocksGainCompensator] + pub trait Detail_BlocksGainCompensatorTrait: crate::stitching::Detail_BlocksCompensatorTrait + crate::stitching::Detail_BlocksGainCompensatorTraitConst { + fn as_raw_mut_Detail_BlocksGainCompensator(&mut self) -> *mut c_void; + + #[inline] fn feed(&mut self, corners: &core::Vector, images: &core::Vector, masks: &core::Vector>) -> Result<()> { return_send!(via ocvrs_return); unsafe { sys::cv_detail_BlocksGainCompensator_feed_const_vectorLPointGR_const_vectorLUMatGR_const_vectorLpairLcv_UMat__unsigned_charGGR(self.as_raw_mut_Detail_BlocksGainCompensator(), corners.as_raw_VectorOfPoint(), images.as_raw_VectorOfUMat(), masks.as_raw_VectorOfTupleOfUMat_u8(), ocvrs_return.as_mut_ptr()) }; @@ -3997,22 +4074,17 @@ pub mod stitching { } - /// Exposure compensator which tries to remove exposure related artifacts by adjusting image block - /// intensities, see [UES01](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_UES01) for details. - pub struct Detail_BlocksGainCompensator { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_BlocksGainCompensator } - - impl Drop for Detail_BlocksGainCompensator { + impl std::fmt::Debug for Detail_BlocksGainCompensator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_BlocksGainCompensator_delete(self.as_raw_mut_Detail_BlocksGainCompensator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_BlocksGainCompensator") + .finish() } } - unsafe impl Send for Detail_BlocksGainCompensator {} + boxed_cast_base! { Detail_BlocksGainCompensator, crate::stitching::Detail_BlocksCompensator, cv_detail_BlocksGainCompensator_to_Detail_BlocksCompensator } + + boxed_cast_base! { Detail_BlocksGainCompensator, crate::stitching::Detail_ExposureCompensator, cv_detail_BlocksGainCompensator_to_Detail_ExposureCompensator } impl crate::stitching::Detail_BlocksCompensatorTraitConst for Detail_BlocksGainCompensator { #[inline] fn as_raw_Detail_BlocksCompensator(&self) -> *const c_void { self.as_raw() } @@ -4044,58 +4116,42 @@ pub mod stitching { boxed_ref! { Detail_BlocksGainCompensator, crate::stitching::Detail_BlocksGainCompensatorTraitConst, as_raw_Detail_BlocksGainCompensator, crate::stitching::Detail_BlocksGainCompensatorTrait, as_raw_mut_Detail_BlocksGainCompensator } - impl Detail_BlocksGainCompensator { - /// ## C++ default parameters - /// * bl_width: 32 - /// * bl_height: 32 - #[inline] - pub fn new(bl_width: i32, bl_height: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_BlocksGainCompensator_BlocksGainCompensator_int_int(bl_width, bl_height, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_BlocksGainCompensator::opencv_from_extern(ret) }; - Ok(ret) - } + /// Bundle adjuster that expects affine transformation + /// represented in homogeneous coordinates in R for each camera param. Implements + /// camera parameters refinement algorithm which minimizes sum of the reprojection + /// error squares + /// + /// It estimates all transformation parameters. Refinement mask is ignored. + /// ## See also + /// AffineBasedEstimator AffineBestOf2NearestMatcher BundleAdjusterAffinePartial + pub struct Detail_BundleAdjusterAffine { + ptr: *mut c_void, + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * bl_width: 32 - /// * bl_height: 32 + opencv_type_boxed! { Detail_BundleAdjusterAffine } + + impl Drop for Detail_BundleAdjusterAffine { #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_BlocksGainCompensator_BlocksGainCompensator(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_BlocksGainCompensator::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_BundleAdjusterAffine_delete(self.as_raw_mut_Detail_BundleAdjusterAffine()) }; } + } + + unsafe impl Send for Detail_BundleAdjusterAffine {} + impl Detail_BundleAdjusterAffine { #[inline] - pub fn new_1(bl_width: i32, bl_height: i32, nr_feeds: i32) -> Result { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_BlocksGainCompensator_BlocksGainCompensator_int_int_int(bl_width, bl_height, nr_feeds, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_BundleAdjusterAffine_BundleAdjusterAffine(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_BlocksGainCompensator::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::Detail_BundleAdjusterAffine::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { Detail_BlocksGainCompensator, crate::stitching::Detail_BlocksCompensator, cv_detail_BlocksGainCompensator_to_Detail_BlocksCompensator } - - boxed_cast_base! { Detail_BlocksGainCompensator, crate::stitching::Detail_ExposureCompensator, cv_detail_BlocksGainCompensator_to_Detail_ExposureCompensator } - - impl std::fmt::Debug for Detail_BlocksGainCompensator { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_BlocksGainCompensator") - .finish() - } - } - /// Constant methods for [crate::stitching::Detail_BundleAdjusterAffine] pub trait Detail_BundleAdjusterAffineTraitConst: crate::stitching::Detail_BundleAdjusterBaseTraitConst { fn as_raw_Detail_BundleAdjusterAffine(&self) -> *const c_void; @@ -4108,28 +4164,17 @@ pub mod stitching { } - /// Bundle adjuster that expects affine transformation - /// represented in homogeneous coordinates in R for each camera param. Implements - /// camera parameters refinement algorithm which minimizes sum of the reprojection - /// error squares - /// - /// It estimates all transformation parameters. Refinement mask is ignored. - /// ## See also - /// AffineBasedEstimator AffineBestOf2NearestMatcher BundleAdjusterAffinePartial - pub struct Detail_BundleAdjusterAffine { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_BundleAdjusterAffine } - - impl Drop for Detail_BundleAdjusterAffine { + impl std::fmt::Debug for Detail_BundleAdjusterAffine { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_BundleAdjusterAffine_delete(self.as_raw_mut_Detail_BundleAdjusterAffine()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_BundleAdjusterAffine") + .finish() } } - unsafe impl Send for Detail_BundleAdjusterAffine {} + boxed_cast_base! { Detail_BundleAdjusterAffine, crate::stitching::Detail_BundleAdjusterBase, cv_detail_BundleAdjusterAffine_to_Detail_BundleAdjusterBase } + + boxed_cast_base! { Detail_BundleAdjusterAffine, crate::stitching::Detail_Estimator, cv_detail_BundleAdjusterAffine_to_Detail_Estimator } impl crate::stitching::Detail_BundleAdjusterBaseTraitConst for Detail_BundleAdjusterAffine { #[inline] fn as_raw_Detail_BundleAdjusterBase(&self) -> *const c_void { self.as_raw() } @@ -4161,29 +4206,40 @@ pub mod stitching { boxed_ref! { Detail_BundleAdjusterAffine, crate::stitching::Detail_BundleAdjusterAffineTraitConst, as_raw_Detail_BundleAdjusterAffine, crate::stitching::Detail_BundleAdjusterAffineTrait, as_raw_mut_Detail_BundleAdjusterAffine } - impl Detail_BundleAdjusterAffine { + /// Bundle adjuster that expects affine transformation with 4 DOF + /// represented in homogeneous coordinates in R for each camera param. Implements + /// camera parameters refinement algorithm which minimizes sum of the reprojection + /// error squares + /// + /// It estimates all transformation parameters. Refinement mask is ignored. + /// ## See also + /// AffineBasedEstimator AffineBestOf2NearestMatcher BundleAdjusterAffine + pub struct Detail_BundleAdjusterAffinePartial { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_BundleAdjusterAffinePartial } + + impl Drop for Detail_BundleAdjusterAffinePartial { #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_BundleAdjusterAffine_BundleAdjusterAffine(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_BundleAdjusterAffine::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_BundleAdjusterAffinePartial_delete(self.as_raw_mut_Detail_BundleAdjusterAffinePartial()) }; } - } - boxed_cast_base! { Detail_BundleAdjusterAffine, crate::stitching::Detail_BundleAdjusterBase, cv_detail_BundleAdjusterAffine_to_Detail_BundleAdjusterBase } - - boxed_cast_base! { Detail_BundleAdjusterAffine, crate::stitching::Detail_Estimator, cv_detail_BundleAdjusterAffine_to_Detail_Estimator } + unsafe impl Send for Detail_BundleAdjusterAffinePartial {} - impl std::fmt::Debug for Detail_BundleAdjusterAffine { + impl Detail_BundleAdjusterAffinePartial { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_BundleAdjusterAffine") - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_BundleAdjusterAffinePartial_BundleAdjusterAffinePartial(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_BundleAdjusterAffinePartial::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_BundleAdjusterAffinePartial] @@ -4198,28 +4254,17 @@ pub mod stitching { } - /// Bundle adjuster that expects affine transformation with 4 DOF - /// represented in homogeneous coordinates in R for each camera param. Implements - /// camera parameters refinement algorithm which minimizes sum of the reprojection - /// error squares - /// - /// It estimates all transformation parameters. Refinement mask is ignored. - /// ## See also - /// AffineBasedEstimator AffineBestOf2NearestMatcher BundleAdjusterAffine - pub struct Detail_BundleAdjusterAffinePartial { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_BundleAdjusterAffinePartial } - - impl Drop for Detail_BundleAdjusterAffinePartial { + impl std::fmt::Debug for Detail_BundleAdjusterAffinePartial { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_BundleAdjusterAffinePartial_delete(self.as_raw_mut_Detail_BundleAdjusterAffinePartial()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_BundleAdjusterAffinePartial") + .finish() } } - unsafe impl Send for Detail_BundleAdjusterAffinePartial {} + boxed_cast_base! { Detail_BundleAdjusterAffinePartial, crate::stitching::Detail_BundleAdjusterBase, cv_detail_BundleAdjusterAffinePartial_to_Detail_BundleAdjusterBase } + + boxed_cast_base! { Detail_BundleAdjusterAffinePartial, crate::stitching::Detail_Estimator, cv_detail_BundleAdjusterAffinePartial_to_Detail_Estimator } impl crate::stitching::Detail_BundleAdjusterBaseTraitConst for Detail_BundleAdjusterAffinePartial { #[inline] fn as_raw_Detail_BundleAdjusterBase(&self) -> *const c_void { self.as_raw() } @@ -4251,31 +4296,22 @@ pub mod stitching { boxed_ref! { Detail_BundleAdjusterAffinePartial, crate::stitching::Detail_BundleAdjusterAffinePartialTraitConst, as_raw_Detail_BundleAdjusterAffinePartial, crate::stitching::Detail_BundleAdjusterAffinePartialTrait, as_raw_mut_Detail_BundleAdjusterAffinePartial } - impl Detail_BundleAdjusterAffinePartial { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_BundleAdjusterAffinePartial_BundleAdjusterAffinePartial(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_BundleAdjusterAffinePartial::opencv_from_extern(ret) }; - Ok(ret) - } - + /// Base class for all camera parameters refinement methods. + pub struct Detail_BundleAdjusterBase { + ptr: *mut c_void, } - boxed_cast_base! { Detail_BundleAdjusterAffinePartial, crate::stitching::Detail_BundleAdjusterBase, cv_detail_BundleAdjusterAffinePartial_to_Detail_BundleAdjusterBase } - - boxed_cast_base! { Detail_BundleAdjusterAffinePartial, crate::stitching::Detail_Estimator, cv_detail_BundleAdjusterAffinePartial_to_Detail_Estimator } + opencv_type_boxed! { Detail_BundleAdjusterBase } - impl std::fmt::Debug for Detail_BundleAdjusterAffinePartial { + impl Drop for Detail_BundleAdjusterBase { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_BundleAdjusterAffinePartial") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_detail_BundleAdjusterBase_delete(self.as_raw_mut_Detail_BundleAdjusterBase()) }; } } + unsafe impl Send for Detail_BundleAdjusterBase {} + /// Constant methods for [crate::stitching::Detail_BundleAdjusterBase] pub trait Detail_BundleAdjusterBaseTraitConst: crate::stitching::Detail_EstimatorTraitConst { fn as_raw_Detail_BundleAdjusterBase(&self) -> *const c_void; @@ -4343,21 +4379,25 @@ pub mod stitching { } - /// Base class for all camera parameters refinement methods. - pub struct Detail_BundleAdjusterBase { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_BundleAdjusterBase } - - impl Drop for Detail_BundleAdjusterBase { + impl std::fmt::Debug for Detail_BundleAdjusterBase { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_BundleAdjusterBase_delete(self.as_raw_mut_Detail_BundleAdjusterBase()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_BundleAdjusterBase") + .finish() } } - unsafe impl Send for Detail_BundleAdjusterBase {} + boxed_cast_base! { Detail_BundleAdjusterBase, crate::stitching::Detail_Estimator, cv_detail_BundleAdjusterBase_to_Detail_Estimator } + + boxed_cast_descendant! { Detail_BundleAdjusterBase, crate::stitching::Detail_BundleAdjusterAffine, cv_detail_BundleAdjusterBase_to_Detail_BundleAdjusterAffine } + + boxed_cast_descendant! { Detail_BundleAdjusterBase, crate::stitching::Detail_BundleAdjusterAffinePartial, cv_detail_BundleAdjusterBase_to_Detail_BundleAdjusterAffinePartial } + + boxed_cast_descendant! { Detail_BundleAdjusterBase, crate::stitching::Detail_BundleAdjusterRay, cv_detail_BundleAdjusterBase_to_Detail_BundleAdjusterRay } + + boxed_cast_descendant! { Detail_BundleAdjusterBase, crate::stitching::Detail_BundleAdjusterReproj, cv_detail_BundleAdjusterBase_to_Detail_BundleAdjusterReproj } + + boxed_cast_descendant! { Detail_BundleAdjusterBase, crate::stitching::Detail_NoBundleAdjuster, cv_detail_BundleAdjusterBase_to_Detail_NoBundleAdjuster } impl crate::stitching::Detail_EstimatorTraitConst for Detail_BundleAdjusterBase { #[inline] fn as_raw_Detail_Estimator(&self) -> *const c_void { self.as_raw() } @@ -4379,27 +4419,36 @@ pub mod stitching { boxed_ref! { Detail_BundleAdjusterBase, crate::stitching::Detail_BundleAdjusterBaseTraitConst, as_raw_Detail_BundleAdjusterBase, crate::stitching::Detail_BundleAdjusterBaseTrait, as_raw_mut_Detail_BundleAdjusterBase } - impl Detail_BundleAdjusterBase { + /// Implementation of the camera parameters refinement algorithm which minimizes sum of the distances + /// between the rays passing through the camera center and a feature. : + /// + /// It can estimate focal length. It ignores the refinement mask for now. + pub struct Detail_BundleAdjusterRay { + ptr: *mut c_void, } - boxed_cast_descendant! { Detail_BundleAdjusterBase, crate::stitching::Detail_BundleAdjusterAffine, cv_detail_BundleAdjusterBase_to_Detail_BundleAdjusterAffine } - - boxed_cast_descendant! { Detail_BundleAdjusterBase, crate::stitching::Detail_BundleAdjusterAffinePartial, cv_detail_BundleAdjusterBase_to_Detail_BundleAdjusterAffinePartial } - - boxed_cast_descendant! { Detail_BundleAdjusterBase, crate::stitching::Detail_BundleAdjusterRay, cv_detail_BundleAdjusterBase_to_Detail_BundleAdjusterRay } - - boxed_cast_descendant! { Detail_BundleAdjusterBase, crate::stitching::Detail_BundleAdjusterReproj, cv_detail_BundleAdjusterBase_to_Detail_BundleAdjusterReproj } + opencv_type_boxed! { Detail_BundleAdjusterRay } - boxed_cast_descendant! { Detail_BundleAdjusterBase, crate::stitching::Detail_NoBundleAdjuster, cv_detail_BundleAdjusterBase_to_Detail_NoBundleAdjuster } + impl Drop for Detail_BundleAdjusterRay { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_detail_BundleAdjusterRay_delete(self.as_raw_mut_Detail_BundleAdjusterRay()) }; + } + } - boxed_cast_base! { Detail_BundleAdjusterBase, crate::stitching::Detail_Estimator, cv_detail_BundleAdjusterBase_to_Detail_Estimator } + unsafe impl Send for Detail_BundleAdjusterRay {} - impl std::fmt::Debug for Detail_BundleAdjusterBase { + impl Detail_BundleAdjusterRay { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_BundleAdjusterBase") - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_BundleAdjusterRay_BundleAdjusterRay(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_BundleAdjusterRay::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_BundleAdjusterRay] @@ -4414,24 +4463,17 @@ pub mod stitching { } - /// Implementation of the camera parameters refinement algorithm which minimizes sum of the distances - /// between the rays passing through the camera center and a feature. : - /// - /// It can estimate focal length. It ignores the refinement mask for now. - pub struct Detail_BundleAdjusterRay { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_BundleAdjusterRay } - - impl Drop for Detail_BundleAdjusterRay { + impl std::fmt::Debug for Detail_BundleAdjusterRay { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_BundleAdjusterRay_delete(self.as_raw_mut_Detail_BundleAdjusterRay()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_BundleAdjusterRay") + .finish() } } - unsafe impl Send for Detail_BundleAdjusterRay {} + boxed_cast_base! { Detail_BundleAdjusterRay, crate::stitching::Detail_BundleAdjusterBase, cv_detail_BundleAdjusterRay_to_Detail_BundleAdjusterBase } + + boxed_cast_base! { Detail_BundleAdjusterRay, crate::stitching::Detail_Estimator, cv_detail_BundleAdjusterRay_to_Detail_Estimator } impl crate::stitching::Detail_BundleAdjusterBaseTraitConst for Detail_BundleAdjusterRay { #[inline] fn as_raw_Detail_BundleAdjusterBase(&self) -> *const c_void { self.as_raw() } @@ -4463,29 +4505,37 @@ pub mod stitching { boxed_ref! { Detail_BundleAdjusterRay, crate::stitching::Detail_BundleAdjusterRayTraitConst, as_raw_Detail_BundleAdjusterRay, crate::stitching::Detail_BundleAdjusterRayTrait, as_raw_mut_Detail_BundleAdjusterRay } - impl Detail_BundleAdjusterRay { + /// Implementation of the camera parameters refinement algorithm which minimizes sum of the reprojection + /// error squares + /// + /// It can estimate focal length, aspect ratio, principal point. + /// You can affect only on them via the refinement mask. + pub struct Detail_BundleAdjusterReproj { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_BundleAdjusterReproj } + + impl Drop for Detail_BundleAdjusterReproj { #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_BundleAdjusterRay_BundleAdjusterRay(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_BundleAdjusterRay::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_BundleAdjusterReproj_delete(self.as_raw_mut_Detail_BundleAdjusterReproj()) }; } - } - boxed_cast_base! { Detail_BundleAdjusterRay, crate::stitching::Detail_BundleAdjusterBase, cv_detail_BundleAdjusterRay_to_Detail_BundleAdjusterBase } - - boxed_cast_base! { Detail_BundleAdjusterRay, crate::stitching::Detail_Estimator, cv_detail_BundleAdjusterRay_to_Detail_Estimator } + unsafe impl Send for Detail_BundleAdjusterReproj {} - impl std::fmt::Debug for Detail_BundleAdjusterRay { + impl Detail_BundleAdjusterReproj { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_BundleAdjusterRay") - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_BundleAdjusterReproj_BundleAdjusterReproj(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_BundleAdjusterReproj::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_BundleAdjusterReproj] @@ -4500,25 +4550,17 @@ pub mod stitching { } - /// Implementation of the camera parameters refinement algorithm which minimizes sum of the reprojection - /// error squares - /// - /// It can estimate focal length, aspect ratio, principal point. - /// You can affect only on them via the refinement mask. - pub struct Detail_BundleAdjusterReproj { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_BundleAdjusterReproj } - - impl Drop for Detail_BundleAdjusterReproj { + impl std::fmt::Debug for Detail_BundleAdjusterReproj { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_BundleAdjusterReproj_delete(self.as_raw_mut_Detail_BundleAdjusterReproj()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_BundleAdjusterReproj") + .finish() } } - unsafe impl Send for Detail_BundleAdjusterReproj {} + boxed_cast_base! { Detail_BundleAdjusterReproj, crate::stitching::Detail_BundleAdjusterBase, cv_detail_BundleAdjusterReproj_to_Detail_BundleAdjusterBase } + + boxed_cast_base! { Detail_BundleAdjusterReproj, crate::stitching::Detail_Estimator, cv_detail_BundleAdjusterReproj_to_Detail_Estimator } impl crate::stitching::Detail_BundleAdjusterBaseTraitConst for Detail_BundleAdjusterReproj { #[inline] fn as_raw_Detail_BundleAdjusterBase(&self) -> *const c_void { self.as_raw() } @@ -4550,29 +4592,46 @@ pub mod stitching { boxed_ref! { Detail_BundleAdjusterReproj, crate::stitching::Detail_BundleAdjusterReprojTraitConst, as_raw_Detail_BundleAdjusterReproj, crate::stitching::Detail_BundleAdjusterReprojTrait, as_raw_mut_Detail_BundleAdjusterReproj } - impl Detail_BundleAdjusterReproj { + /// Describes camera parameters. + /// + /// + /// Note: Translation is assumed to be zero during the whole stitching pipeline. : + pub struct Detail_CameraParams { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_CameraParams } + + impl Drop for Detail_CameraParams { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_detail_CameraParams_delete(self.as_raw_mut_Detail_CameraParams()) }; + } + } + + unsafe impl Send for Detail_CameraParams {} + + impl Detail_CameraParams { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_BundleAdjusterReproj_BundleAdjusterReproj(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_CameraParams_CameraParams(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_BundleAdjusterReproj::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::Detail_CameraParams::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { Detail_BundleAdjusterReproj, crate::stitching::Detail_BundleAdjusterBase, cv_detail_BundleAdjusterReproj_to_Detail_BundleAdjusterBase } - - boxed_cast_base! { Detail_BundleAdjusterReproj, crate::stitching::Detail_Estimator, cv_detail_BundleAdjusterReproj_to_Detail_Estimator } - - impl std::fmt::Debug for Detail_BundleAdjusterReproj { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_BundleAdjusterReproj") - .finish() + pub fn copy(other: &impl crate::stitching::Detail_CameraParamsTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_CameraParams_CameraParams_const_CameraParamsR(other.as_raw_Detail_CameraParams(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_CameraParams::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_CameraParams] @@ -4680,25 +4739,27 @@ pub mod stitching { } - /// Describes camera parameters. - /// - /// - /// Note: Translation is assumed to be zero during the whole stitching pipeline. : - pub struct Detail_CameraParams { - ptr: *mut c_void, + impl Clone for Detail_CameraParams { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_detail_CameraParams_implicitClone_const(self.as_raw_Detail_CameraParams())) } + } } - opencv_type_boxed! { Detail_CameraParams } - - impl Drop for Detail_CameraParams { + impl std::fmt::Debug for Detail_CameraParams { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_CameraParams_delete(self.as_raw_mut_Detail_CameraParams()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_CameraParams") + .field("focal", &crate::stitching::Detail_CameraParamsTraitConst::focal(self)) + .field("aspect", &crate::stitching::Detail_CameraParamsTraitConst::aspect(self)) + .field("ppx", &crate::stitching::Detail_CameraParamsTraitConst::ppx(self)) + .field("ppy", &crate::stitching::Detail_CameraParamsTraitConst::ppy(self)) + .field("r", &crate::stitching::Detail_CameraParamsTraitConst::r(self)) + .field("t", &crate::stitching::Detail_CameraParamsTraitConst::t(self)) + .finish() } } - unsafe impl Send for Detail_CameraParams {} - impl crate::stitching::Detail_CameraParamsTraitConst for Detail_CameraParams { #[inline] fn as_raw_Detail_CameraParams(&self) -> *const c_void { self.as_raw() } } @@ -4709,54 +4770,55 @@ pub mod stitching { boxed_ref! { Detail_CameraParams, crate::stitching::Detail_CameraParamsTraitConst, as_raw_Detail_CameraParams, crate::stitching::Detail_CameraParamsTrait, as_raw_mut_Detail_CameraParams } - impl Detail_CameraParams { + /// Exposure compensator which tries to remove exposure related artifacts by adjusting image + /// intensities on each channel independently. + pub struct Detail_ChannelsCompensator { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_ChannelsCompensator } + + impl Drop for Detail_ChannelsCompensator { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_detail_ChannelsCompensator_delete(self.as_raw_mut_Detail_ChannelsCompensator()) }; + } + } + + unsafe impl Send for Detail_ChannelsCompensator {} + + impl Detail_ChannelsCompensator { + /// ## C++ default parameters + /// * nr_feeds: 1 + #[inline] + pub fn new(nr_feeds: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_CameraParams_CameraParams(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_ChannelsCompensator_ChannelsCompensator_int(nr_feeds, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_CameraParams::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::Detail_ChannelsCompensator::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * nr_feeds: 1 #[inline] - pub fn copy(other: &impl crate::stitching::Detail_CameraParamsTraitConst) -> Result { + pub fn new_def() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_CameraParams_CameraParams_const_CameraParamsR(other.as_raw_Detail_CameraParams(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_ChannelsCompensator_ChannelsCompensator(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_CameraParams::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::Detail_ChannelsCompensator::opencv_from_extern(ret) }; Ok(ret) } } - impl Clone for Detail_CameraParams { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_detail_CameraParams_implicitClone_const(self.as_raw_Detail_CameraParams())) } - } - } - - impl std::fmt::Debug for Detail_CameraParams { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_CameraParams") - .field("focal", &crate::stitching::Detail_CameraParamsTraitConst::focal(self)) - .field("aspect", &crate::stitching::Detail_CameraParamsTraitConst::aspect(self)) - .field("ppx", &crate::stitching::Detail_CameraParamsTraitConst::ppx(self)) - .field("ppy", &crate::stitching::Detail_CameraParamsTraitConst::ppy(self)) - .field("r", &crate::stitching::Detail_CameraParamsTraitConst::r(self)) - .field("t", &crate::stitching::Detail_CameraParamsTraitConst::t(self)) - .finish() - } - } - - /// Constant methods for [crate::stitching::Detail_ChannelsCompensator] - pub trait Detail_ChannelsCompensatorTraitConst: crate::stitching::Detail_ExposureCompensatorTraitConst { - fn as_raw_Detail_ChannelsCompensator(&self) -> *const c_void; - + /// Constant methods for [crate::stitching::Detail_ChannelsCompensator] + pub trait Detail_ChannelsCompensatorTraitConst: crate::stitching::Detail_ExposureCompensatorTraitConst { + fn as_raw_Detail_ChannelsCompensator(&self) -> *const c_void; + #[inline] fn get_similarity_threshold(&self) -> Result { return_send!(via ocvrs_return); @@ -4849,22 +4911,15 @@ pub mod stitching { } - /// Exposure compensator which tries to remove exposure related artifacts by adjusting image - /// intensities on each channel independently. - pub struct Detail_ChannelsCompensator { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_ChannelsCompensator } - - impl Drop for Detail_ChannelsCompensator { + impl std::fmt::Debug for Detail_ChannelsCompensator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_ChannelsCompensator_delete(self.as_raw_mut_Detail_ChannelsCompensator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_ChannelsCompensator") + .finish() } } - unsafe impl Send for Detail_ChannelsCompensator {} + boxed_cast_base! { Detail_ChannelsCompensator, crate::stitching::Detail_ExposureCompensator, cv_detail_ChannelsCompensator_to_Detail_ExposureCompensator } impl crate::stitching::Detail_ExposureCompensatorTraitConst for Detail_ChannelsCompensator { #[inline] fn as_raw_Detail_ExposureCompensator(&self) -> *const c_void { self.as_raw() } @@ -4886,42 +4941,30 @@ pub mod stitching { boxed_ref! { Detail_ChannelsCompensator, crate::stitching::Detail_ChannelsCompensatorTraitConst, as_raw_Detail_ChannelsCompensator, crate::stitching::Detail_ChannelsCompensatorTrait, as_raw_mut_Detail_ChannelsCompensator } - impl Detail_ChannelsCompensator { - /// ## C++ default parameters - /// * nr_feeds: 1 - #[inline] - pub fn new(nr_feeds: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_ChannelsCompensator_ChannelsCompensator_int(nr_feeds, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_ChannelsCompensator::opencv_from_extern(ret) }; - Ok(ret) - } + pub struct Detail_CompressedRectilinearPortraitProjector { + ptr: *mut c_void, + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * nr_feeds: 1 + opencv_type_boxed! { Detail_CompressedRectilinearPortraitProjector } + + impl Drop for Detail_CompressedRectilinearPortraitProjector { #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_ChannelsCompensator_ChannelsCompensator(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_ChannelsCompensator::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_CompressedRectilinearPortraitProjector_delete(self.as_raw_mut_Detail_CompressedRectilinearPortraitProjector()) }; } - } - boxed_cast_base! { Detail_ChannelsCompensator, crate::stitching::Detail_ExposureCompensator, cv_detail_ChannelsCompensator_to_Detail_ExposureCompensator } + unsafe impl Send for Detail_CompressedRectilinearPortraitProjector {} - impl std::fmt::Debug for Detail_ChannelsCompensator { + impl Detail_CompressedRectilinearPortraitProjector { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_ChannelsCompensator") - .finish() + pub fn default() -> crate::stitching::Detail_CompressedRectilinearPortraitProjector { + let ret = unsafe { sys::cv_detail_CompressedRectilinearPortraitProjector_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_CompressedRectilinearPortraitProjector::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::Detail_CompressedRectilinearPortraitProjector] @@ -4978,20 +5021,31 @@ pub mod stitching { } - pub struct Detail_CompressedRectilinearPortraitProjector { - ptr: *mut c_void, + impl Default for Detail_CompressedRectilinearPortraitProjector { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_CompressedRectilinearPortraitProjector } - - impl Drop for Detail_CompressedRectilinearPortraitProjector { + impl std::fmt::Debug for Detail_CompressedRectilinearPortraitProjector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_CompressedRectilinearPortraitProjector_delete(self.as_raw_mut_Detail_CompressedRectilinearPortraitProjector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_CompressedRectilinearPortraitProjector") + .field("a", &crate::stitching::Detail_CompressedRectilinearPortraitProjectorTraitConst::a(self)) + .field("b", &crate::stitching::Detail_CompressedRectilinearPortraitProjectorTraitConst::b(self)) + .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) + .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) + .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) + .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) + .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) + .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) + .finish() } } - unsafe impl Send for Detail_CompressedRectilinearPortraitProjector {} + boxed_cast_base! { Detail_CompressedRectilinearPortraitProjector, crate::stitching::Detail_ProjectorBase, cv_detail_CompressedRectilinearPortraitProjector_to_Detail_ProjectorBase } impl crate::stitching::Detail_ProjectorBaseTraitConst for Detail_CompressedRectilinearPortraitProjector { #[inline] fn as_raw_Detail_ProjectorBase(&self) -> *const c_void { self.as_raw() } @@ -5013,39 +5067,49 @@ pub mod stitching { boxed_ref! { Detail_CompressedRectilinearPortraitProjector, crate::stitching::Detail_CompressedRectilinearPortraitProjectorTraitConst, as_raw_Detail_CompressedRectilinearPortraitProjector, crate::stitching::Detail_CompressedRectilinearPortraitProjectorTrait, as_raw_mut_Detail_CompressedRectilinearPortraitProjector } - impl Detail_CompressedRectilinearPortraitProjector { - /// Creates a default instance of the class by calling the default constructor + pub struct Detail_CompressedRectilinearPortraitWarper { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_CompressedRectilinearPortraitWarper } + + impl Drop for Detail_CompressedRectilinearPortraitWarper { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_CompressedRectilinearPortraitProjector_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_detail_CompressedRectilinearPortraitWarper_delete(self.as_raw_mut_Detail_CompressedRectilinearPortraitWarper()) }; } - } - boxed_cast_base! { Detail_CompressedRectilinearPortraitProjector, crate::stitching::Detail_ProjectorBase, cv_detail_CompressedRectilinearPortraitProjector_to_Detail_ProjectorBase } + unsafe impl Send for Detail_CompressedRectilinearPortraitWarper {} - impl std::fmt::Debug for Detail_CompressedRectilinearPortraitProjector { + impl Detail_CompressedRectilinearPortraitWarper { + /// ## C++ default parameters + /// * a: 1 + /// * b: 1 #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_CompressedRectilinearPortraitProjector") - .field("a", &crate::stitching::Detail_CompressedRectilinearPortraitProjectorTraitConst::a(self)) - .field("b", &crate::stitching::Detail_CompressedRectilinearPortraitProjectorTraitConst::b(self)) - .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) - .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) - .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) - .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) - .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) - .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) - .finish() + pub fn new(scale: f32, a: f32, b: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_CompressedRectilinearPortraitWarper_CompressedRectilinearPortraitWarper_float_float_float(scale, a, b, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_CompressedRectilinearPortraitWarper::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for Detail_CompressedRectilinearPortraitProjector { + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * a: 1 + /// * b: 1 #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new_def(scale: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_CompressedRectilinearPortraitWarper_CompressedRectilinearPortraitWarper_float(scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_CompressedRectilinearPortraitWarper::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_CompressedRectilinearPortraitWarper] @@ -5060,20 +5124,15 @@ pub mod stitching { } - pub struct Detail_CompressedRectilinearPortraitWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_CompressedRectilinearPortraitWarper } - - impl Drop for Detail_CompressedRectilinearPortraitWarper { + impl std::fmt::Debug for Detail_CompressedRectilinearPortraitWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_CompressedRectilinearPortraitWarper_delete(self.as_raw_mut_Detail_CompressedRectilinearPortraitWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_CompressedRectilinearPortraitWarper") + .finish() } } - unsafe impl Send for Detail_CompressedRectilinearPortraitWarper {} + boxed_cast_base! { Detail_CompressedRectilinearPortraitWarper, crate::stitching::Detail_RotationWarper, cv_detail_CompressedRectilinearPortraitWarper_to_Detail_RotationWarper } impl crate::stitching::Detail_RotationWarperTraitConst for Detail_CompressedRectilinearPortraitWarper { #[inline] fn as_raw_Detail_RotationWarper(&self) -> *const c_void { self.as_raw() } @@ -5095,44 +5154,30 @@ pub mod stitching { boxed_ref! { Detail_CompressedRectilinearPortraitWarper, crate::stitching::Detail_CompressedRectilinearPortraitWarperTraitConst, as_raw_Detail_CompressedRectilinearPortraitWarper, crate::stitching::Detail_CompressedRectilinearPortraitWarperTrait, as_raw_mut_Detail_CompressedRectilinearPortraitWarper } - impl Detail_CompressedRectilinearPortraitWarper { - /// ## C++ default parameters - /// * a: 1 - /// * b: 1 - #[inline] - pub fn new(scale: f32, a: f32, b: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_CompressedRectilinearPortraitWarper_CompressedRectilinearPortraitWarper_float_float_float(scale, a, b, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_CompressedRectilinearPortraitWarper::opencv_from_extern(ret) }; - Ok(ret) - } + pub struct Detail_CompressedRectilinearProjector { + ptr: *mut c_void, + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * a: 1 - /// * b: 1 + opencv_type_boxed! { Detail_CompressedRectilinearProjector } + + impl Drop for Detail_CompressedRectilinearProjector { #[inline] - pub fn new_def(scale: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_CompressedRectilinearPortraitWarper_CompressedRectilinearPortraitWarper_float(scale, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_CompressedRectilinearPortraitWarper::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_CompressedRectilinearProjector_delete(self.as_raw_mut_Detail_CompressedRectilinearProjector()) }; } - } - boxed_cast_base! { Detail_CompressedRectilinearPortraitWarper, crate::stitching::Detail_RotationWarper, cv_detail_CompressedRectilinearPortraitWarper_to_Detail_RotationWarper } + unsafe impl Send for Detail_CompressedRectilinearProjector {} - impl std::fmt::Debug for Detail_CompressedRectilinearPortraitWarper { + impl Detail_CompressedRectilinearProjector { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_CompressedRectilinearPortraitWarper") - .finish() + pub fn default() -> crate::stitching::Detail_CompressedRectilinearProjector { + let ret = unsafe { sys::cv_detail_CompressedRectilinearProjector_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_CompressedRectilinearProjector::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::Detail_CompressedRectilinearProjector] @@ -5189,20 +5234,31 @@ pub mod stitching { } - pub struct Detail_CompressedRectilinearProjector { - ptr: *mut c_void, + impl Default for Detail_CompressedRectilinearProjector { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_CompressedRectilinearProjector } - - impl Drop for Detail_CompressedRectilinearProjector { + impl std::fmt::Debug for Detail_CompressedRectilinearProjector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_CompressedRectilinearProjector_delete(self.as_raw_mut_Detail_CompressedRectilinearProjector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_CompressedRectilinearProjector") + .field("a", &crate::stitching::Detail_CompressedRectilinearProjectorTraitConst::a(self)) + .field("b", &crate::stitching::Detail_CompressedRectilinearProjectorTraitConst::b(self)) + .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) + .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) + .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) + .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) + .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) + .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) + .finish() } } - unsafe impl Send for Detail_CompressedRectilinearProjector {} + boxed_cast_base! { Detail_CompressedRectilinearProjector, crate::stitching::Detail_ProjectorBase, cv_detail_CompressedRectilinearProjector_to_Detail_ProjectorBase } impl crate::stitching::Detail_ProjectorBaseTraitConst for Detail_CompressedRectilinearProjector { #[inline] fn as_raw_Detail_ProjectorBase(&self) -> *const c_void { self.as_raw() } @@ -5224,39 +5280,49 @@ pub mod stitching { boxed_ref! { Detail_CompressedRectilinearProjector, crate::stitching::Detail_CompressedRectilinearProjectorTraitConst, as_raw_Detail_CompressedRectilinearProjector, crate::stitching::Detail_CompressedRectilinearProjectorTrait, as_raw_mut_Detail_CompressedRectilinearProjector } - impl Detail_CompressedRectilinearProjector { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_CompressedRectilinearProjector_defaultNew_const()) } - } - + pub struct Detail_CompressedRectilinearWarper { + ptr: *mut c_void, } - boxed_cast_base! { Detail_CompressedRectilinearProjector, crate::stitching::Detail_ProjectorBase, cv_detail_CompressedRectilinearProjector_to_Detail_ProjectorBase } + opencv_type_boxed! { Detail_CompressedRectilinearWarper } - impl std::fmt::Debug for Detail_CompressedRectilinearProjector { + impl Drop for Detail_CompressedRectilinearWarper { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_CompressedRectilinearProjector") - .field("a", &crate::stitching::Detail_CompressedRectilinearProjectorTraitConst::a(self)) - .field("b", &crate::stitching::Detail_CompressedRectilinearProjectorTraitConst::b(self)) - .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) - .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) - .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) - .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) - .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) - .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_detail_CompressedRectilinearWarper_delete(self.as_raw_mut_Detail_CompressedRectilinearWarper()) }; } } - impl Default for Detail_CompressedRectilinearProjector { + unsafe impl Send for Detail_CompressedRectilinearWarper {} + + impl Detail_CompressedRectilinearWarper { + /// ## C++ default parameters + /// * a: 1 + /// * b: 1 #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new(scale: f32, a: f32, b: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_CompressedRectilinearWarper_CompressedRectilinearWarper_float_float_float(scale, a, b, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_CompressedRectilinearWarper::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * a: 1 + /// * b: 1 + #[inline] + pub fn new_def(scale: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_CompressedRectilinearWarper_CompressedRectilinearWarper_float(scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_CompressedRectilinearWarper::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_CompressedRectilinearWarper] @@ -5271,20 +5337,15 @@ pub mod stitching { } - pub struct Detail_CompressedRectilinearWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_CompressedRectilinearWarper } - - impl Drop for Detail_CompressedRectilinearWarper { + impl std::fmt::Debug for Detail_CompressedRectilinearWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_CompressedRectilinearWarper_delete(self.as_raw_mut_Detail_CompressedRectilinearWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_CompressedRectilinearWarper") + .finish() } } - unsafe impl Send for Detail_CompressedRectilinearWarper {} + boxed_cast_base! { Detail_CompressedRectilinearWarper, crate::stitching::Detail_RotationWarper, cv_detail_CompressedRectilinearWarper_to_Detail_RotationWarper } impl crate::stitching::Detail_RotationWarperTraitConst for Detail_CompressedRectilinearWarper { #[inline] fn as_raw_Detail_RotationWarper(&self) -> *const c_void { self.as_raw() } @@ -5306,44 +5367,30 @@ pub mod stitching { boxed_ref! { Detail_CompressedRectilinearWarper, crate::stitching::Detail_CompressedRectilinearWarperTraitConst, as_raw_Detail_CompressedRectilinearWarper, crate::stitching::Detail_CompressedRectilinearWarperTrait, as_raw_mut_Detail_CompressedRectilinearWarper } - impl Detail_CompressedRectilinearWarper { - /// ## C++ default parameters - /// * a: 1 - /// * b: 1 - #[inline] - pub fn new(scale: f32, a: f32, b: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_CompressedRectilinearWarper_CompressedRectilinearWarper_float_float_float(scale, a, b, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_CompressedRectilinearWarper::opencv_from_extern(ret) }; - Ok(ret) - } + pub struct Detail_CylindricalPortraitProjector { + ptr: *mut c_void, + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * a: 1 - /// * b: 1 + opencv_type_boxed! { Detail_CylindricalPortraitProjector } + + impl Drop for Detail_CylindricalPortraitProjector { #[inline] - pub fn new_def(scale: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_CompressedRectilinearWarper_CompressedRectilinearWarper_float(scale, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_CompressedRectilinearWarper::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_CylindricalPortraitProjector_delete(self.as_raw_mut_Detail_CylindricalPortraitProjector()) }; } - } - boxed_cast_base! { Detail_CompressedRectilinearWarper, crate::stitching::Detail_RotationWarper, cv_detail_CompressedRectilinearWarper_to_Detail_RotationWarper } + unsafe impl Send for Detail_CylindricalPortraitProjector {} - impl std::fmt::Debug for Detail_CompressedRectilinearWarper { + impl Detail_CylindricalPortraitProjector { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_CompressedRectilinearWarper") - .finish() + pub fn default() -> crate::stitching::Detail_CylindricalPortraitProjector { + let ret = unsafe { sys::cv_detail_CylindricalPortraitProjector_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_CylindricalPortraitProjector::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::Detail_CylindricalPortraitProjector] @@ -5376,20 +5423,29 @@ pub mod stitching { } - pub struct Detail_CylindricalPortraitProjector { - ptr: *mut c_void, + impl Default for Detail_CylindricalPortraitProjector { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_CylindricalPortraitProjector } - - impl Drop for Detail_CylindricalPortraitProjector { + impl std::fmt::Debug for Detail_CylindricalPortraitProjector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_CylindricalPortraitProjector_delete(self.as_raw_mut_Detail_CylindricalPortraitProjector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_CylindricalPortraitProjector") + .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) + .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) + .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) + .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) + .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) + .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) + .finish() } } - unsafe impl Send for Detail_CylindricalPortraitProjector {} + boxed_cast_base! { Detail_CylindricalPortraitProjector, crate::stitching::Detail_ProjectorBase, cv_detail_CylindricalPortraitProjector_to_Detail_ProjectorBase } impl crate::stitching::Detail_ProjectorBaseTraitConst for Detail_CylindricalPortraitProjector { #[inline] fn as_raw_Detail_ProjectorBase(&self) -> *const c_void { self.as_raw() } @@ -5411,37 +5467,32 @@ pub mod stitching { boxed_ref! { Detail_CylindricalPortraitProjector, crate::stitching::Detail_CylindricalPortraitProjectorTraitConst, as_raw_Detail_CylindricalPortraitProjector, crate::stitching::Detail_CylindricalPortraitProjectorTrait, as_raw_mut_Detail_CylindricalPortraitProjector } - impl Detail_CylindricalPortraitProjector { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_CylindricalPortraitProjector_defaultNew_const()) } - } - + pub struct Detail_CylindricalPortraitWarper { + ptr: *mut c_void, } - boxed_cast_base! { Detail_CylindricalPortraitProjector, crate::stitching::Detail_ProjectorBase, cv_detail_CylindricalPortraitProjector_to_Detail_ProjectorBase } + opencv_type_boxed! { Detail_CylindricalPortraitWarper } - impl std::fmt::Debug for Detail_CylindricalPortraitProjector { + impl Drop for Detail_CylindricalPortraitWarper { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_CylindricalPortraitProjector") - .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) - .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) - .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) - .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) - .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) - .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_detail_CylindricalPortraitWarper_delete(self.as_raw_mut_Detail_CylindricalPortraitWarper()) }; } } - impl Default for Detail_CylindricalPortraitProjector { + unsafe impl Send for Detail_CylindricalPortraitWarper {} + + impl Detail_CylindricalPortraitWarper { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new(scale: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_CylindricalPortraitWarper_CylindricalPortraitWarper_float(scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_CylindricalPortraitWarper::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_CylindricalPortraitWarper] @@ -5456,20 +5507,15 @@ pub mod stitching { } - pub struct Detail_CylindricalPortraitWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_CylindricalPortraitWarper } - - impl Drop for Detail_CylindricalPortraitWarper { + impl std::fmt::Debug for Detail_CylindricalPortraitWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_CylindricalPortraitWarper_delete(self.as_raw_mut_Detail_CylindricalPortraitWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_CylindricalPortraitWarper") + .finish() } } - unsafe impl Send for Detail_CylindricalPortraitWarper {} + boxed_cast_base! { Detail_CylindricalPortraitWarper, crate::stitching::Detail_RotationWarper, cv_detail_CylindricalPortraitWarper_to_Detail_RotationWarper } impl crate::stitching::Detail_RotationWarperTraitConst for Detail_CylindricalPortraitWarper { #[inline] fn as_raw_Detail_RotationWarper(&self) -> *const c_void { self.as_raw() } @@ -5491,27 +5537,30 @@ pub mod stitching { boxed_ref! { Detail_CylindricalPortraitWarper, crate::stitching::Detail_CylindricalPortraitWarperTraitConst, as_raw_Detail_CylindricalPortraitWarper, crate::stitching::Detail_CylindricalPortraitWarperTrait, as_raw_mut_Detail_CylindricalPortraitWarper } - impl Detail_CylindricalPortraitWarper { + pub struct Detail_CylindricalProjector { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_CylindricalProjector } + + impl Drop for Detail_CylindricalProjector { #[inline] - pub fn new(scale: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_CylindricalPortraitWarper_CylindricalPortraitWarper_float(scale, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_CylindricalPortraitWarper::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_CylindricalProjector_delete(self.as_raw_mut_Detail_CylindricalProjector()) }; } - } - boxed_cast_base! { Detail_CylindricalPortraitWarper, crate::stitching::Detail_RotationWarper, cv_detail_CylindricalPortraitWarper_to_Detail_RotationWarper } + unsafe impl Send for Detail_CylindricalProjector {} - impl std::fmt::Debug for Detail_CylindricalPortraitWarper { + impl Detail_CylindricalProjector { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_CylindricalPortraitWarper") - .finish() + pub fn default() -> crate::stitching::Detail_CylindricalProjector { + let ret = unsafe { sys::cv_detail_CylindricalProjector_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_CylindricalProjector::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::Detail_CylindricalProjector] @@ -5544,20 +5593,29 @@ pub mod stitching { } - pub struct Detail_CylindricalProjector { - ptr: *mut c_void, + impl Default for Detail_CylindricalProjector { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_CylindricalProjector } - - impl Drop for Detail_CylindricalProjector { + impl std::fmt::Debug for Detail_CylindricalProjector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_CylindricalProjector_delete(self.as_raw_mut_Detail_CylindricalProjector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_CylindricalProjector") + .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) + .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) + .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) + .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) + .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) + .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) + .finish() } } - unsafe impl Send for Detail_CylindricalProjector {} + boxed_cast_base! { Detail_CylindricalProjector, crate::stitching::Detail_ProjectorBase, cv_detail_CylindricalProjector_to_Detail_ProjectorBase } impl crate::stitching::Detail_ProjectorBaseTraitConst for Detail_CylindricalProjector { #[inline] fn as_raw_Detail_ProjectorBase(&self) -> *const c_void { self.as_raw() } @@ -5579,37 +5637,37 @@ pub mod stitching { boxed_ref! { Detail_CylindricalProjector, crate::stitching::Detail_CylindricalProjectorTraitConst, as_raw_Detail_CylindricalProjector, crate::stitching::Detail_CylindricalProjectorTrait, as_raw_mut_Detail_CylindricalProjector } - impl Detail_CylindricalProjector { - /// Creates a default instance of the class by calling the default constructor + /// Warper that maps an image onto the x\*x + z\*z = 1 cylinder. + pub struct Detail_CylindricalWarper { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_CylindricalWarper } + + impl Drop for Detail_CylindricalWarper { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_CylindricalProjector_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_detail_CylindricalWarper_delete(self.as_raw_mut_Detail_CylindricalWarper()) }; } - } - boxed_cast_base! { Detail_CylindricalProjector, crate::stitching::Detail_ProjectorBase, cv_detail_CylindricalProjector_to_Detail_ProjectorBase } + unsafe impl Send for Detail_CylindricalWarper {} - impl std::fmt::Debug for Detail_CylindricalProjector { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_CylindricalProjector") - .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) - .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) - .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) - .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) - .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) - .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) - .finish() - } - } - - impl Default for Detail_CylindricalProjector { + impl Detail_CylindricalWarper { + /// Construct an instance of the cylindrical warper class. + /// + /// ## Parameters + /// * scale: Projected image scale multiplier #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new(scale: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_CylindricalWarper_CylindricalWarper_float(scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_CylindricalWarper::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_CylindricalWarper] @@ -5650,21 +5708,17 @@ pub mod stitching { } - /// Warper that maps an image onto the x\*x + z\*z = 1 cylinder. - pub struct Detail_CylindricalWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_CylindricalWarper } - - impl Drop for Detail_CylindricalWarper { + impl std::fmt::Debug for Detail_CylindricalWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_CylindricalWarper_delete(self.as_raw_mut_Detail_CylindricalWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_CylindricalWarper") + .finish() } } - unsafe impl Send for Detail_CylindricalWarper {} + boxed_cast_base! { Detail_CylindricalWarper, crate::stitching::Detail_RotationWarper, cv_detail_CylindricalWarper_to_Detail_RotationWarper } + + boxed_cast_descendant! { Detail_CylindricalWarper, crate::stitching::Detail_CylindricalWarperGpu, cv_detail_CylindricalWarper_to_Detail_CylindricalWarperGpu } impl crate::stitching::Detail_RotationWarperTraitConst for Detail_CylindricalWarper { #[inline] fn as_raw_Detail_RotationWarper(&self) -> *const c_void { self.as_raw() } @@ -5686,33 +5740,32 @@ pub mod stitching { boxed_ref! { Detail_CylindricalWarper, crate::stitching::Detail_CylindricalWarperTraitConst, as_raw_Detail_CylindricalWarper, crate::stitching::Detail_CylindricalWarperTrait, as_raw_mut_Detail_CylindricalWarper } - impl Detail_CylindricalWarper { - /// Construct an instance of the cylindrical warper class. - /// - /// ## Parameters - /// * scale: Projected image scale multiplier + pub struct Detail_CylindricalWarperGpu { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_CylindricalWarperGpu } + + impl Drop for Detail_CylindricalWarperGpu { #[inline] - pub fn new(scale: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_CylindricalWarper_CylindricalWarper_float(scale, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_CylindricalWarper::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_CylindricalWarperGpu_delete(self.as_raw_mut_Detail_CylindricalWarperGpu()) }; } - } - boxed_cast_descendant! { Detail_CylindricalWarper, crate::stitching::Detail_CylindricalWarperGpu, cv_detail_CylindricalWarper_to_Detail_CylindricalWarperGpu } - - boxed_cast_base! { Detail_CylindricalWarper, crate::stitching::Detail_RotationWarper, cv_detail_CylindricalWarper_to_Detail_RotationWarper } + unsafe impl Send for Detail_CylindricalWarperGpu {} - impl std::fmt::Debug for Detail_CylindricalWarper { + impl Detail_CylindricalWarperGpu { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_CylindricalWarper") - .finish() + pub fn new(scale: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_CylindricalWarperGpu_CylindricalWarperGpu_float(scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_CylindricalWarperGpu::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_CylindricalWarperGpu] @@ -5775,20 +5828,17 @@ pub mod stitching { } - pub struct Detail_CylindricalWarperGpu { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_CylindricalWarperGpu } - - impl Drop for Detail_CylindricalWarperGpu { + impl std::fmt::Debug for Detail_CylindricalWarperGpu { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_CylindricalWarperGpu_delete(self.as_raw_mut_Detail_CylindricalWarperGpu()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_CylindricalWarperGpu") + .finish() } } - unsafe impl Send for Detail_CylindricalWarperGpu {} + boxed_cast_base! { Detail_CylindricalWarperGpu, crate::stitching::Detail_CylindricalWarper, cv_detail_CylindricalWarperGpu_to_Detail_CylindricalWarper } + + boxed_cast_base! { Detail_CylindricalWarperGpu, crate::stitching::Detail_RotationWarper, cv_detail_CylindricalWarperGpu_to_Detail_RotationWarper } impl crate::stitching::Detail_CylindricalWarperTraitConst for Detail_CylindricalWarperGpu { #[inline] fn as_raw_Detail_CylindricalWarper(&self) -> *const c_void { self.as_raw() } @@ -5820,29 +5870,47 @@ pub mod stitching { boxed_ref! { Detail_CylindricalWarperGpu, crate::stitching::Detail_CylindricalWarperGpuTraitConst, as_raw_Detail_CylindricalWarperGpu, crate::stitching::Detail_CylindricalWarperGpuTrait, as_raw_mut_Detail_CylindricalWarperGpu } - impl Detail_CylindricalWarperGpu { + pub struct Detail_DisjointSets { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_DisjointSets } + + impl Drop for Detail_DisjointSets { #[inline] - pub fn new(scale: f32) -> Result { + fn drop(&mut self) { + unsafe { sys::cv_detail_DisjointSets_delete(self.as_raw_mut_Detail_DisjointSets()) }; + } + } + + unsafe impl Send for Detail_DisjointSets {} + + impl Detail_DisjointSets { + /// ## C++ default parameters + /// * elem_count: 0 + #[inline] + pub fn new(elem_count: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_CylindricalWarperGpu_CylindricalWarperGpu_float(scale, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_DisjointSets_DisjointSets_int(elem_count, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_CylindricalWarperGpu::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::Detail_DisjointSets::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { Detail_CylindricalWarperGpu, crate::stitching::Detail_CylindricalWarper, cv_detail_CylindricalWarperGpu_to_Detail_CylindricalWarper } - - boxed_cast_base! { Detail_CylindricalWarperGpu, crate::stitching::Detail_RotationWarper, cv_detail_CylindricalWarperGpu_to_Detail_RotationWarper } - - impl std::fmt::Debug for Detail_CylindricalWarperGpu { + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * elem_count: 0 #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_CylindricalWarperGpu") - .finish() + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_DisjointSets_DisjointSets(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_DisjointSets::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_DisjointSets] @@ -5910,21 +5978,16 @@ pub mod stitching { } - pub struct Detail_DisjointSets { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_DisjointSets } - - impl Drop for Detail_DisjointSets { + impl std::fmt::Debug for Detail_DisjointSets { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_DisjointSets_delete(self.as_raw_mut_Detail_DisjointSets()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_DisjointSets") + .field("parent", &crate::stitching::Detail_DisjointSetsTraitConst::parent(self)) + .field("size", &crate::stitching::Detail_DisjointSetsTraitConst::size(self)) + .finish() } } - unsafe impl Send for Detail_DisjointSets {} - impl crate::stitching::Detail_DisjointSetsTraitConst for Detail_DisjointSets { #[inline] fn as_raw_Detail_DisjointSets(&self) -> *const c_void { self.as_raw() } } @@ -5935,42 +5998,58 @@ pub mod stitching { boxed_ref! { Detail_DisjointSets, crate::stitching::Detail_DisjointSetsTraitConst, as_raw_Detail_DisjointSets, crate::stitching::Detail_DisjointSetsTrait, as_raw_mut_Detail_DisjointSets } - impl Detail_DisjointSets { + pub struct Detail_DpSeamFinder { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_DpSeamFinder } + + impl Drop for Detail_DpSeamFinder { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_detail_DpSeamFinder_delete(self.as_raw_mut_Detail_DpSeamFinder()) }; + } + } + + unsafe impl Send for Detail_DpSeamFinder {} + + impl Detail_DpSeamFinder { /// ## C++ default parameters - /// * elem_count: 0 + /// * cost_func: COLOR #[inline] - pub fn new(elem_count: i32) -> Result { + pub fn new(cost_func: crate::stitching::Detail_DpSeamFinder_CostFunction) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_DisjointSets_DisjointSets_int(elem_count, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_DpSeamFinder_DpSeamFinder_CostFunction(cost_func, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_DisjointSets::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::Detail_DpSeamFinder::opencv_from_extern(ret) }; Ok(ret) } /// ## Note /// This alternative version of [new] function uses the following default values for its arguments: - /// * elem_count: 0 + /// * cost_func: COLOR #[inline] - pub fn new_def() -> Result { + pub fn new_def() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_DisjointSets_DisjointSets(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_DpSeamFinder_DpSeamFinder(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_DisjointSets::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::Detail_DpSeamFinder::opencv_from_extern(ret) }; Ok(ret) } - } - - impl std::fmt::Debug for Detail_DisjointSets { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_DisjointSets") - .field("parent", &crate::stitching::Detail_DisjointSetsTraitConst::parent(self)) - .field("size", &crate::stitching::Detail_DisjointSetsTraitConst::size(self)) - .finish() + pub fn new_1(cost_func: &str) -> Result { + extern_container_arg!(cost_func); + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_DpSeamFinder_DpSeamFinder_String(cost_func.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_DpSeamFinder::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_DpSeamFinder] @@ -6022,20 +6101,15 @@ pub mod stitching { } - pub struct Detail_DpSeamFinder { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_DpSeamFinder } - - impl Drop for Detail_DpSeamFinder { + impl std::fmt::Debug for Detail_DpSeamFinder { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_DpSeamFinder_delete(self.as_raw_mut_Detail_DpSeamFinder()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_DpSeamFinder") + .finish() } } - unsafe impl Send for Detail_DpSeamFinder {} + boxed_cast_base! { Detail_DpSeamFinder, crate::stitching::Detail_SeamFinder, cv_detail_DpSeamFinder_to_Detail_SeamFinder } impl crate::stitching::Detail_SeamFinderTraitConst for Detail_DpSeamFinder { #[inline] fn as_raw_Detail_SeamFinder(&self) -> *const c_void { self.as_raw() } @@ -6057,54 +6131,28 @@ pub mod stitching { boxed_ref! { Detail_DpSeamFinder, crate::stitching::Detail_DpSeamFinderTraitConst, as_raw_Detail_DpSeamFinder, crate::stitching::Detail_DpSeamFinderTrait, as_raw_mut_Detail_DpSeamFinder } - impl Detail_DpSeamFinder { - /// ## C++ default parameters - /// * cost_func: COLOR - #[inline] - pub fn new(cost_func: crate::stitching::Detail_DpSeamFinder_CostFunction) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_DpSeamFinder_DpSeamFinder_CostFunction(cost_func, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_DpSeamFinder::opencv_from_extern(ret) }; - Ok(ret) - } + /// Rotation estimator base class. + /// + /// It takes features of all images, pairwise matches between all images and estimates rotations of all + /// cameras. + /// + /// + /// Note: The coordinate system origin is implementation-dependent, but you can always normalize the + /// rotations in respect to the first camera, for instance. : + pub struct Detail_Estimator { + ptr: *mut c_void, + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * cost_func: COLOR - #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_DpSeamFinder_DpSeamFinder(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_DpSeamFinder::opencv_from_extern(ret) }; - Ok(ret) - } + opencv_type_boxed! { Detail_Estimator } + impl Drop for Detail_Estimator { #[inline] - pub fn new_1(cost_func: &str) -> Result { - extern_container_arg!(cost_func); - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_DpSeamFinder_DpSeamFinder_String(cost_func.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_DpSeamFinder::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_Estimator_delete(self.as_raw_mut_Detail_Estimator()) }; } - } - boxed_cast_base! { Detail_DpSeamFinder, crate::stitching::Detail_SeamFinder, cv_detail_DpSeamFinder_to_Detail_SeamFinder } - - impl std::fmt::Debug for Detail_DpSeamFinder { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_DpSeamFinder") - .finish() - } - } + unsafe impl Send for Detail_Estimator {} /// Constant methods for [crate::stitching::Detail_Estimator] pub trait Detail_EstimatorTraitConst { @@ -6135,42 +6183,14 @@ pub mod stitching { } - /// Rotation estimator base class. - /// - /// It takes features of all images, pairwise matches between all images and estimates rotations of all - /// cameras. - /// - /// - /// Note: The coordinate system origin is implementation-dependent, but you can always normalize the - /// rotations in respect to the first camera, for instance. : - pub struct Detail_Estimator { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_Estimator } - - impl Drop for Detail_Estimator { + impl std::fmt::Debug for Detail_Estimator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_Estimator_delete(self.as_raw_mut_Detail_Estimator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_Estimator") + .finish() } } - unsafe impl Send for Detail_Estimator {} - - impl crate::stitching::Detail_EstimatorTraitConst for Detail_Estimator { - #[inline] fn as_raw_Detail_Estimator(&self) -> *const c_void { self.as_raw() } - } - - impl crate::stitching::Detail_EstimatorTrait for Detail_Estimator { - #[inline] fn as_raw_mut_Detail_Estimator(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Detail_Estimator, crate::stitching::Detail_EstimatorTraitConst, as_raw_Detail_Estimator, crate::stitching::Detail_EstimatorTrait, as_raw_mut_Detail_Estimator } - - impl Detail_Estimator { - } - boxed_cast_descendant! { Detail_Estimator, crate::stitching::Detail_AffineBasedEstimator, cv_detail_Estimator_to_Detail_AffineBasedEstimator } boxed_cast_descendant! { Detail_Estimator, crate::stitching::Detail_BundleAdjusterAffine, cv_detail_Estimator_to_Detail_BundleAdjusterAffine } @@ -6187,12 +6207,43 @@ pub mod stitching { boxed_cast_descendant! { Detail_Estimator, crate::stitching::Detail_NoBundleAdjuster, cv_detail_Estimator_to_Detail_NoBundleAdjuster } - impl std::fmt::Debug for Detail_Estimator { + impl crate::stitching::Detail_EstimatorTraitConst for Detail_Estimator { + #[inline] fn as_raw_Detail_Estimator(&self) -> *const c_void { self.as_raw() } + } + + impl crate::stitching::Detail_EstimatorTrait for Detail_Estimator { + #[inline] fn as_raw_mut_Detail_Estimator(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Detail_Estimator, crate::stitching::Detail_EstimatorTraitConst, as_raw_Detail_Estimator, crate::stitching::Detail_EstimatorTrait, as_raw_mut_Detail_Estimator } + + /// Base class for all exposure compensators. + pub struct Detail_ExposureCompensator { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_ExposureCompensator } + + impl Drop for Detail_ExposureCompensator { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_Estimator") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_detail_ExposureCompensator_delete(self.as_raw_mut_Detail_ExposureCompensator()) }; + } + } + + unsafe impl Send for Detail_ExposureCompensator {} + + impl Detail_ExposureCompensator { + #[inline] + pub fn create_default(typ: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_ExposureCompensator_createDefault_int(typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_ExposureCompensator] @@ -6291,21 +6342,25 @@ pub mod stitching { } - /// Base class for all exposure compensators. - pub struct Detail_ExposureCompensator { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_ExposureCompensator } - - impl Drop for Detail_ExposureCompensator { + impl std::fmt::Debug for Detail_ExposureCompensator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_ExposureCompensator_delete(self.as_raw_mut_Detail_ExposureCompensator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_ExposureCompensator") + .finish() } } - unsafe impl Send for Detail_ExposureCompensator {} + boxed_cast_descendant! { Detail_ExposureCompensator, crate::stitching::Detail_BlocksChannelsCompensator, cv_detail_ExposureCompensator_to_Detail_BlocksChannelsCompensator } + + boxed_cast_descendant! { Detail_ExposureCompensator, crate::stitching::Detail_BlocksCompensator, cv_detail_ExposureCompensator_to_Detail_BlocksCompensator } + + boxed_cast_descendant! { Detail_ExposureCompensator, crate::stitching::Detail_BlocksGainCompensator, cv_detail_ExposureCompensator_to_Detail_BlocksGainCompensator } + + boxed_cast_descendant! { Detail_ExposureCompensator, crate::stitching::Detail_ChannelsCompensator, cv_detail_ExposureCompensator_to_Detail_ChannelsCompensator } + + boxed_cast_descendant! { Detail_ExposureCompensator, crate::stitching::Detail_GainCompensator, cv_detail_ExposureCompensator_to_Detail_GainCompensator } + + boxed_cast_descendant! { Detail_ExposureCompensator, crate::stitching::Detail_NoExposureCompensator, cv_detail_ExposureCompensator_to_Detail_NoExposureCompensator } impl crate::stitching::Detail_ExposureCompensatorTraitConst for Detail_ExposureCompensator { #[inline] fn as_raw_Detail_ExposureCompensator(&self) -> *const c_void { self.as_raw() } @@ -6317,37 +6372,48 @@ pub mod stitching { boxed_ref! { Detail_ExposureCompensator, crate::stitching::Detail_ExposureCompensatorTraitConst, as_raw_Detail_ExposureCompensator, crate::stitching::Detail_ExposureCompensatorTrait, as_raw_mut_Detail_ExposureCompensator } - impl Detail_ExposureCompensator { + /// Simple blender which mixes images at its borders. + pub struct Detail_FeatherBlender { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_FeatherBlender } + + impl Drop for Detail_FeatherBlender { #[inline] - pub fn create_default(typ: i32) -> Result> { + fn drop(&mut self) { + unsafe { sys::cv_detail_FeatherBlender_delete(self.as_raw_mut_Detail_FeatherBlender()) }; + } + } + + unsafe impl Send for Detail_FeatherBlender {} + + impl Detail_FeatherBlender { + /// ## C++ default parameters + /// * sharpness: 0.02f + #[inline] + pub fn new(sharpness: f32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_ExposureCompensator_createDefault_int(typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_FeatherBlender_FeatherBlender_float(sharpness, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::Detail_FeatherBlender::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_descendant! { Detail_ExposureCompensator, crate::stitching::Detail_BlocksChannelsCompensator, cv_detail_ExposureCompensator_to_Detail_BlocksChannelsCompensator } - - boxed_cast_descendant! { Detail_ExposureCompensator, crate::stitching::Detail_BlocksCompensator, cv_detail_ExposureCompensator_to_Detail_BlocksCompensator } - - boxed_cast_descendant! { Detail_ExposureCompensator, crate::stitching::Detail_BlocksGainCompensator, cv_detail_ExposureCompensator_to_Detail_BlocksGainCompensator } - - boxed_cast_descendant! { Detail_ExposureCompensator, crate::stitching::Detail_ChannelsCompensator, cv_detail_ExposureCompensator_to_Detail_ChannelsCompensator } - - boxed_cast_descendant! { Detail_ExposureCompensator, crate::stitching::Detail_GainCompensator, cv_detail_ExposureCompensator_to_Detail_GainCompensator } - - boxed_cast_descendant! { Detail_ExposureCompensator, crate::stitching::Detail_NoExposureCompensator, cv_detail_ExposureCompensator_to_Detail_NoExposureCompensator } - - impl std::fmt::Debug for Detail_ExposureCompensator { + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * sharpness: 0.02f #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_ExposureCompensator") - .finish() + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_FeatherBlender_FeatherBlender(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_FeatherBlender::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_FeatherBlender] @@ -6422,21 +6488,15 @@ pub mod stitching { } - /// Simple blender which mixes images at its borders. - pub struct Detail_FeatherBlender { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_FeatherBlender } - - impl Drop for Detail_FeatherBlender { + impl std::fmt::Debug for Detail_FeatherBlender { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_FeatherBlender_delete(self.as_raw_mut_Detail_FeatherBlender()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_FeatherBlender") + .finish() } } - unsafe impl Send for Detail_FeatherBlender {} + boxed_cast_base! { Detail_FeatherBlender, crate::stitching::Detail_Blender, cv_detail_FeatherBlender_to_Detail_Blender } impl crate::stitching::Detail_BlenderTraitConst for Detail_FeatherBlender { #[inline] fn as_raw_Detail_Blender(&self) -> *const c_void { self.as_raw() } @@ -6458,44 +6518,22 @@ pub mod stitching { boxed_ref! { Detail_FeatherBlender, crate::stitching::Detail_FeatherBlenderTraitConst, as_raw_Detail_FeatherBlender, crate::stitching::Detail_FeatherBlenderTrait, as_raw_mut_Detail_FeatherBlender } - impl Detail_FeatherBlender { - /// ## C++ default parameters - /// * sharpness: 0.02f - #[inline] - pub fn new(sharpness: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_FeatherBlender_FeatherBlender_float(sharpness, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_FeatherBlender::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * sharpness: 0.02f - #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_FeatherBlender_FeatherBlender(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_FeatherBlender::opencv_from_extern(ret) }; - Ok(ret) - } - + /// Feature matchers base class. + pub struct Detail_FeaturesMatcher { + ptr: *mut c_void, } - boxed_cast_base! { Detail_FeatherBlender, crate::stitching::Detail_Blender, cv_detail_FeatherBlender_to_Detail_Blender } + opencv_type_boxed! { Detail_FeaturesMatcher } - impl std::fmt::Debug for Detail_FeatherBlender { + impl Drop for Detail_FeaturesMatcher { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_FeatherBlender") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_detail_FeaturesMatcher_delete(self.as_raw_mut_Detail_FeaturesMatcher()) }; } } + unsafe impl Send for Detail_FeaturesMatcher {} + /// Constant methods for [crate::stitching::Detail_FeaturesMatcher] pub trait Detail_FeaturesMatcherTraitConst { fn as_raw_Detail_FeaturesMatcher(&self) -> *const c_void; @@ -6599,21 +6637,19 @@ pub mod stitching { } - /// Feature matchers base class. - pub struct Detail_FeaturesMatcher { - ptr: *mut c_void, + impl std::fmt::Debug for Detail_FeaturesMatcher { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_FeaturesMatcher") + .finish() + } } - opencv_type_boxed! { Detail_FeaturesMatcher } + boxed_cast_descendant! { Detail_FeaturesMatcher, crate::stitching::Detail_AffineBestOf2NearestMatcher, cv_detail_FeaturesMatcher_to_Detail_AffineBestOf2NearestMatcher } - impl Drop for Detail_FeaturesMatcher { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_FeaturesMatcher_delete(self.as_raw_mut_Detail_FeaturesMatcher()) }; - } - } + boxed_cast_descendant! { Detail_FeaturesMatcher, crate::stitching::Detail_BestOf2NearestMatcher, cv_detail_FeaturesMatcher_to_Detail_BestOf2NearestMatcher } - unsafe impl Send for Detail_FeaturesMatcher {} + boxed_cast_descendant! { Detail_FeaturesMatcher, crate::stitching::Detail_BestOf2NearestRangeMatcher, cv_detail_FeaturesMatcher_to_Detail_BestOf2NearestRangeMatcher } impl crate::stitching::Detail_FeaturesMatcherTraitConst for Detail_FeaturesMatcher { #[inline] fn as_raw_Detail_FeaturesMatcher(&self) -> *const c_void { self.as_raw() } @@ -6625,21 +6661,30 @@ pub mod stitching { boxed_ref! { Detail_FeaturesMatcher, crate::stitching::Detail_FeaturesMatcherTraitConst, as_raw_Detail_FeaturesMatcher, crate::stitching::Detail_FeaturesMatcherTrait, as_raw_mut_Detail_FeaturesMatcher } - impl Detail_FeaturesMatcher { + pub struct Detail_FisheyeProjector { + ptr: *mut c_void, } - boxed_cast_descendant! { Detail_FeaturesMatcher, crate::stitching::Detail_AffineBestOf2NearestMatcher, cv_detail_FeaturesMatcher_to_Detail_AffineBestOf2NearestMatcher } + opencv_type_boxed! { Detail_FisheyeProjector } - boxed_cast_descendant! { Detail_FeaturesMatcher, crate::stitching::Detail_BestOf2NearestMatcher, cv_detail_FeaturesMatcher_to_Detail_BestOf2NearestMatcher } + impl Drop for Detail_FisheyeProjector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_detail_FisheyeProjector_delete(self.as_raw_mut_Detail_FisheyeProjector()) }; + } + } - boxed_cast_descendant! { Detail_FeaturesMatcher, crate::stitching::Detail_BestOf2NearestRangeMatcher, cv_detail_FeaturesMatcher_to_Detail_BestOf2NearestRangeMatcher } + unsafe impl Send for Detail_FisheyeProjector {} - impl std::fmt::Debug for Detail_FeaturesMatcher { + impl Detail_FisheyeProjector { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_FeaturesMatcher") - .finish() + pub fn default() -> crate::stitching::Detail_FisheyeProjector { + let ret = unsafe { sys::cv_detail_FisheyeProjector_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_FisheyeProjector::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::Detail_FisheyeProjector] @@ -6672,20 +6717,29 @@ pub mod stitching { } - pub struct Detail_FisheyeProjector { - ptr: *mut c_void, + impl Default for Detail_FisheyeProjector { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_FisheyeProjector } - - impl Drop for Detail_FisheyeProjector { + impl std::fmt::Debug for Detail_FisheyeProjector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_FisheyeProjector_delete(self.as_raw_mut_Detail_FisheyeProjector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_FisheyeProjector") + .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) + .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) + .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) + .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) + .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) + .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) + .finish() } } - unsafe impl Send for Detail_FisheyeProjector {} + boxed_cast_base! { Detail_FisheyeProjector, crate::stitching::Detail_ProjectorBase, cv_detail_FisheyeProjector_to_Detail_ProjectorBase } impl crate::stitching::Detail_ProjectorBaseTraitConst for Detail_FisheyeProjector { #[inline] fn as_raw_Detail_ProjectorBase(&self) -> *const c_void { self.as_raw() } @@ -6707,37 +6761,32 @@ pub mod stitching { boxed_ref! { Detail_FisheyeProjector, crate::stitching::Detail_FisheyeProjectorTraitConst, as_raw_Detail_FisheyeProjector, crate::stitching::Detail_FisheyeProjectorTrait, as_raw_mut_Detail_FisheyeProjector } - impl Detail_FisheyeProjector { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_FisheyeProjector_defaultNew_const()) } - } - + pub struct Detail_FisheyeWarper { + ptr: *mut c_void, } - boxed_cast_base! { Detail_FisheyeProjector, crate::stitching::Detail_ProjectorBase, cv_detail_FisheyeProjector_to_Detail_ProjectorBase } + opencv_type_boxed! { Detail_FisheyeWarper } - impl std::fmt::Debug for Detail_FisheyeProjector { + impl Drop for Detail_FisheyeWarper { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_FisheyeProjector") - .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) - .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) - .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) - .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) - .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) - .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_detail_FisheyeWarper_delete(self.as_raw_mut_Detail_FisheyeWarper()) }; } } - impl Default for Detail_FisheyeProjector { + unsafe impl Send for Detail_FisheyeWarper {} + + impl Detail_FisheyeWarper { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new(scale: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_FisheyeWarper_FisheyeWarper_float(scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_FisheyeWarper::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_FisheyeWarper] @@ -6752,20 +6801,15 @@ pub mod stitching { } - pub struct Detail_FisheyeWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_FisheyeWarper } - - impl Drop for Detail_FisheyeWarper { + impl std::fmt::Debug for Detail_FisheyeWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_FisheyeWarper_delete(self.as_raw_mut_Detail_FisheyeWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_FisheyeWarper") + .finish() } } - unsafe impl Send for Detail_FisheyeWarper {} + boxed_cast_base! { Detail_FisheyeWarper, crate::stitching::Detail_RotationWarper, cv_detail_FisheyeWarper_to_Detail_RotationWarper } impl crate::stitching::Detail_RotationWarperTraitConst for Detail_FisheyeWarper { #[inline] fn as_raw_Detail_RotationWarper(&self) -> *const c_void { self.as_raw() } @@ -6787,27 +6831,44 @@ pub mod stitching { boxed_ref! { Detail_FisheyeWarper, crate::stitching::Detail_FisheyeWarperTraitConst, as_raw_Detail_FisheyeWarper, crate::stitching::Detail_FisheyeWarperTrait, as_raw_mut_Detail_FisheyeWarper } - impl Detail_FisheyeWarper { + /// Exposure compensator which tries to remove exposure related artifacts by adjusting image + /// intensities, see [BL07](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_BL07) and [WJ10](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_WJ10) for details. + pub struct Detail_GainCompensator { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_GainCompensator } + + impl Drop for Detail_GainCompensator { #[inline] - pub fn new(scale: f32) -> Result { + fn drop(&mut self) { + unsafe { sys::cv_detail_GainCompensator_delete(self.as_raw_mut_Detail_GainCompensator()) }; + } + } + + unsafe impl Send for Detail_GainCompensator {} + + impl Detail_GainCompensator { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_FisheyeWarper_FisheyeWarper_float(scale, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_GainCompensator_GainCompensator(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_FisheyeWarper::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::Detail_GainCompensator::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { Detail_FisheyeWarper, crate::stitching::Detail_RotationWarper, cv_detail_FisheyeWarper_to_Detail_RotationWarper } - - impl std::fmt::Debug for Detail_FisheyeWarper { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_FisheyeWarper") - .finish() + pub fn new(nr_feeds: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_GainCompensator_GainCompensator_int(nr_feeds, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_GainCompensator::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_GainCompensator] @@ -6924,22 +6985,15 @@ pub mod stitching { } - /// Exposure compensator which tries to remove exposure related artifacts by adjusting image - /// intensities, see [BL07](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_BL07) and [WJ10](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_WJ10) for details. - pub struct Detail_GainCompensator { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_GainCompensator } - - impl Drop for Detail_GainCompensator { + impl std::fmt::Debug for Detail_GainCompensator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_GainCompensator_delete(self.as_raw_mut_Detail_GainCompensator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_GainCompensator") + .finish() } } - unsafe impl Send for Detail_GainCompensator {} + boxed_cast_base! { Detail_GainCompensator, crate::stitching::Detail_ExposureCompensator, cv_detail_GainCompensator_to_Detail_ExposureCompensator } impl crate::stitching::Detail_ExposureCompensatorTraitConst for Detail_GainCompensator { #[inline] fn as_raw_Detail_ExposureCompensator(&self) -> *const c_void { self.as_raw() } @@ -6961,39 +7015,49 @@ pub mod stitching { boxed_ref! { Detail_GainCompensator, crate::stitching::Detail_GainCompensatorTraitConst, as_raw_Detail_GainCompensator, crate::stitching::Detail_GainCompensatorTrait, as_raw_mut_Detail_GainCompensator } - impl Detail_GainCompensator { + pub struct Detail_Graph { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_Graph } + + impl Drop for Detail_Graph { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_detail_Graph_delete(self.as_raw_mut_Detail_Graph()) }; + } + } + + unsafe impl Send for Detail_Graph {} + + impl Detail_Graph { + /// ## C++ default parameters + /// * num_vertices: 0 + #[inline] + pub fn new(num_vertices: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_GainCompensator_GainCompensator(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_Graph_Graph_int(num_vertices, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_GainCompensator::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::Detail_Graph::opencv_from_extern(ret) }; Ok(ret) } + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * num_vertices: 0 #[inline] - pub fn new(nr_feeds: i32) -> Result { + pub fn new_def() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_GainCompensator_GainCompensator_int(nr_feeds, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_Graph_Graph(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_GainCompensator::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::Detail_Graph::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { Detail_GainCompensator, crate::stitching::Detail_ExposureCompensator, cv_detail_GainCompensator_to_Detail_ExposureCompensator } - - impl std::fmt::Debug for Detail_GainCompensator { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_GainCompensator") - .finish() - } - } - /// Constant methods for [crate::stitching::Detail_Graph] pub trait Detail_GraphTraitConst { fn as_raw_Detail_Graph(&self) -> *const c_void; @@ -7033,21 +7097,14 @@ pub mod stitching { } - pub struct Detail_Graph { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_Graph } - - impl Drop for Detail_Graph { + impl std::fmt::Debug for Detail_Graph { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_Graph_delete(self.as_raw_mut_Detail_Graph()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_Graph") + .finish() } } - unsafe impl Send for Detail_Graph {} - impl crate::stitching::Detail_GraphTraitConst for Detail_Graph { #[inline] fn as_raw_Detail_Graph(&self) -> *const c_void { self.as_raw() } } @@ -7058,40 +7115,81 @@ pub mod stitching { boxed_ref! { Detail_Graph, crate::stitching::Detail_GraphTraitConst, as_raw_Detail_Graph, crate::stitching::Detail_GraphTrait, as_raw_mut_Detail_Graph } - impl Detail_Graph { + /// Minimum graph cut-based seam estimator. See details in [V03](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_V03) . + pub struct Detail_GraphCutSeamFinder { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_GraphCutSeamFinder } + + impl Drop for Detail_GraphCutSeamFinder { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_detail_GraphCutSeamFinder_delete(self.as_raw_mut_Detail_GraphCutSeamFinder()) }; + } + } + + unsafe impl Send for Detail_GraphCutSeamFinder {} + + impl Detail_GraphCutSeamFinder { /// ## C++ default parameters - /// * num_vertices: 0 + /// * cost_type: COST_COLOR_GRAD + /// * terminal_cost: 10000.f + /// * bad_region_penalty: 1000.f #[inline] - pub fn new(num_vertices: i32) -> Result { + pub fn new(cost_type: i32, terminal_cost: f32, bad_region_penalty: f32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_Graph_Graph_int(num_vertices, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_GraphCutSeamFinder_GraphCutSeamFinder_int_float_float(cost_type, terminal_cost, bad_region_penalty, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_Graph::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::Detail_GraphCutSeamFinder::opencv_from_extern(ret) }; Ok(ret) } /// ## Note /// This alternative version of [new] function uses the following default values for its arguments: - /// * num_vertices: 0 + /// * cost_type: COST_COLOR_GRAD + /// * terminal_cost: 10000.f + /// * bad_region_penalty: 1000.f #[inline] - pub fn new_def() -> Result { + pub fn new_def() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_Graph_Graph(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_GraphCutSeamFinder_GraphCutSeamFinder(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_Graph::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::Detail_GraphCutSeamFinder::opencv_from_extern(ret) }; Ok(ret) } - } + /// ## C++ default parameters + /// * terminal_cost: 10000.f + /// * bad_region_penalty: 1000.f + #[inline] + pub fn new_1(cost_type: &str, terminal_cost: f32, bad_region_penalty: f32) -> Result { + extern_container_arg!(cost_type); + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_GraphCutSeamFinder_GraphCutSeamFinder_String_float_float(cost_type.opencv_as_extern(), terminal_cost, bad_region_penalty, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_GraphCutSeamFinder::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for Detail_Graph { + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * terminal_cost: 10000.f + /// * bad_region_penalty: 1000.f #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_Graph") - .finish() + pub fn new_def_1(cost_type: &str) -> Result { + extern_container_arg!(cost_type); + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_GraphCutSeamFinder_GraphCutSeamFinder_String(cost_type.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_GraphCutSeamFinder::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_GraphCutSeamFinder] @@ -7115,21 +7213,17 @@ pub mod stitching { } - /// Minimum graph cut-based seam estimator. See details in [V03](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_V03) . - pub struct Detail_GraphCutSeamFinder { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_GraphCutSeamFinder } - - impl Drop for Detail_GraphCutSeamFinder { + impl std::fmt::Debug for Detail_GraphCutSeamFinder { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_GraphCutSeamFinder_delete(self.as_raw_mut_Detail_GraphCutSeamFinder()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_GraphCutSeamFinder") + .finish() } } - unsafe impl Send for Detail_GraphCutSeamFinder {} + boxed_cast_base! { Detail_GraphCutSeamFinder, crate::stitching::Detail_GraphCutSeamFinderBase, cv_detail_GraphCutSeamFinder_to_Detail_GraphCutSeamFinderBase } + + boxed_cast_base! { Detail_GraphCutSeamFinder, crate::stitching::Detail_SeamFinder, cv_detail_GraphCutSeamFinder_to_Detail_SeamFinder } impl crate::stitching::Detail_GraphCutSeamFinderBaseTraitConst for Detail_GraphCutSeamFinder { #[inline] fn as_raw_Detail_GraphCutSeamFinderBase(&self) -> *const c_void { self.as_raw() } @@ -7161,77 +7255,31 @@ pub mod stitching { boxed_ref! { Detail_GraphCutSeamFinder, crate::stitching::Detail_GraphCutSeamFinderTraitConst, as_raw_Detail_GraphCutSeamFinder, crate::stitching::Detail_GraphCutSeamFinderTrait, as_raw_mut_Detail_GraphCutSeamFinder } - impl Detail_GraphCutSeamFinder { - /// ## C++ default parameters - /// * cost_type: COST_COLOR_GRAD - /// * terminal_cost: 10000.f - /// * bad_region_penalty: 1000.f - #[inline] - pub fn new(cost_type: i32, terminal_cost: f32, bad_region_penalty: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_GraphCutSeamFinder_GraphCutSeamFinder_int_float_float(cost_type, terminal_cost, bad_region_penalty, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_GraphCutSeamFinder::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * cost_type: COST_COLOR_GRAD - /// * terminal_cost: 10000.f - /// * bad_region_penalty: 1000.f - #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_GraphCutSeamFinder_GraphCutSeamFinder(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_GraphCutSeamFinder::opencv_from_extern(ret) }; - Ok(ret) - } + /// Base class for all minimum graph-cut-based seam estimators. + pub struct Detail_GraphCutSeamFinderBase { + ptr: *mut c_void, + } - /// ## C++ default parameters - /// * terminal_cost: 10000.f - /// * bad_region_penalty: 1000.f - #[inline] - pub fn new_1(cost_type: &str, terminal_cost: f32, bad_region_penalty: f32) -> Result { - extern_container_arg!(cost_type); - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_GraphCutSeamFinder_GraphCutSeamFinder_String_float_float(cost_type.opencv_as_extern(), terminal_cost, bad_region_penalty, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_GraphCutSeamFinder::opencv_from_extern(ret) }; - Ok(ret) - } + opencv_type_boxed! { Detail_GraphCutSeamFinderBase } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * terminal_cost: 10000.f - /// * bad_region_penalty: 1000.f + impl Drop for Detail_GraphCutSeamFinderBase { #[inline] - pub fn new_def_1(cost_type: &str) -> Result { - extern_container_arg!(cost_type); - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_GraphCutSeamFinder_GraphCutSeamFinder_String(cost_type.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_GraphCutSeamFinder::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_GraphCutSeamFinderBase_delete(self.as_raw_mut_Detail_GraphCutSeamFinderBase()) }; } - } - boxed_cast_base! { Detail_GraphCutSeamFinder, crate::stitching::Detail_GraphCutSeamFinderBase, cv_detail_GraphCutSeamFinder_to_Detail_GraphCutSeamFinderBase } - - boxed_cast_base! { Detail_GraphCutSeamFinder, crate::stitching::Detail_SeamFinder, cv_detail_GraphCutSeamFinder_to_Detail_SeamFinder } + unsafe impl Send for Detail_GraphCutSeamFinderBase {} - impl std::fmt::Debug for Detail_GraphCutSeamFinder { + impl Detail_GraphCutSeamFinderBase { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_GraphCutSeamFinder") - .finish() + pub fn default() -> crate::stitching::Detail_GraphCutSeamFinderBase { + let ret = unsafe { sys::cv_detail_GraphCutSeamFinderBase_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_GraphCutSeamFinderBase::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::Detail_GraphCutSeamFinderBase] @@ -7246,22 +7294,22 @@ pub mod stitching { } - /// Base class for all minimum graph-cut-based seam estimators. - pub struct Detail_GraphCutSeamFinderBase { - ptr: *mut c_void, + impl Default for Detail_GraphCutSeamFinderBase { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_GraphCutSeamFinderBase } - - impl Drop for Detail_GraphCutSeamFinderBase { + impl std::fmt::Debug for Detail_GraphCutSeamFinderBase { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_GraphCutSeamFinderBase_delete(self.as_raw_mut_Detail_GraphCutSeamFinderBase()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_GraphCutSeamFinderBase") + .finish() } } - unsafe impl Send for Detail_GraphCutSeamFinderBase {} - impl crate::stitching::Detail_GraphCutSeamFinderBaseTraitConst for Detail_GraphCutSeamFinderBase { #[inline] fn as_raw_Detail_GraphCutSeamFinderBase(&self) -> *const c_void { self.as_raw() } } @@ -7272,29 +7320,51 @@ pub mod stitching { boxed_ref! { Detail_GraphCutSeamFinderBase, crate::stitching::Detail_GraphCutSeamFinderBaseTraitConst, as_raw_Detail_GraphCutSeamFinderBase, crate::stitching::Detail_GraphCutSeamFinderBaseTrait, as_raw_mut_Detail_GraphCutSeamFinderBase } - impl Detail_GraphCutSeamFinderBase { - /// Creates a default instance of the class by calling the default constructor + pub struct Detail_GraphCutSeamFinderGpu { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_GraphCutSeamFinderGpu } + + impl Drop for Detail_GraphCutSeamFinderGpu { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_GraphCutSeamFinderBase_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_detail_GraphCutSeamFinderGpu_delete(self.as_raw_mut_Detail_GraphCutSeamFinderGpu()) }; } - } - impl std::fmt::Debug for Detail_GraphCutSeamFinderBase { + unsafe impl Send for Detail_GraphCutSeamFinderGpu {} + + impl Detail_GraphCutSeamFinderGpu { + /// ## C++ default parameters + /// * cost_type: COST_COLOR_GRAD + /// * terminal_cost: 10000.f + /// * bad_region_penalty: 1000.f #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_GraphCutSeamFinderBase") - .finish() + pub fn new(cost_type: i32, terminal_cost: f32, bad_region_penalty: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_GraphCutSeamFinderGpu_GraphCutSeamFinderGpu_int_float_float(cost_type, terminal_cost, bad_region_penalty, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_GraphCutSeamFinderGpu::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for Detail_GraphCutSeamFinderBase { + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * cost_type: COST_COLOR_GRAD + /// * terminal_cost: 10000.f + /// * bad_region_penalty: 1000.f #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_GraphCutSeamFinderGpu_GraphCutSeamFinderGpu(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_GraphCutSeamFinderGpu::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_GraphCutSeamFinderGpu] @@ -7327,20 +7397,19 @@ pub mod stitching { } - pub struct Detail_GraphCutSeamFinderGpu { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_GraphCutSeamFinderGpu } - - impl Drop for Detail_GraphCutSeamFinderGpu { + impl std::fmt::Debug for Detail_GraphCutSeamFinderGpu { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_GraphCutSeamFinderGpu_delete(self.as_raw_mut_Detail_GraphCutSeamFinderGpu()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_GraphCutSeamFinderGpu") + .finish() } } - unsafe impl Send for Detail_GraphCutSeamFinderGpu {} + boxed_cast_base! { Detail_GraphCutSeamFinderGpu, crate::stitching::Detail_GraphCutSeamFinderBase, cv_detail_GraphCutSeamFinderGpu_to_Detail_GraphCutSeamFinderBase } + + boxed_cast_base! { Detail_GraphCutSeamFinderGpu, crate::stitching::Detail_PairwiseSeamFinder, cv_detail_GraphCutSeamFinderGpu_to_Detail_PairwiseSeamFinder } + + boxed_cast_base! { Detail_GraphCutSeamFinderGpu, crate::stitching::Detail_SeamFinder, cv_detail_GraphCutSeamFinderGpu_to_Detail_SeamFinder } impl crate::stitching::Detail_GraphCutSeamFinderBaseTraitConst for Detail_GraphCutSeamFinderGpu { #[inline] fn as_raw_Detail_GraphCutSeamFinderBase(&self) -> *const c_void { self.as_raw() } @@ -7382,50 +7451,32 @@ pub mod stitching { boxed_ref! { Detail_GraphCutSeamFinderGpu, crate::stitching::Detail_GraphCutSeamFinderGpuTraitConst, as_raw_Detail_GraphCutSeamFinderGpu, crate::stitching::Detail_GraphCutSeamFinderGpuTrait, as_raw_mut_Detail_GraphCutSeamFinderGpu } - impl Detail_GraphCutSeamFinderGpu { - /// ## C++ default parameters - /// * cost_type: COST_COLOR_GRAD - /// * terminal_cost: 10000.f - /// * bad_region_penalty: 1000.f - #[inline] - pub fn new(cost_type: i32, terminal_cost: f32, bad_region_penalty: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_GraphCutSeamFinderGpu_GraphCutSeamFinderGpu_int_float_float(cost_type, terminal_cost, bad_region_penalty, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_GraphCutSeamFinderGpu::opencv_from_extern(ret) }; - Ok(ret) - } + pub struct Detail_GraphEdge { + ptr: *mut c_void, + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * cost_type: COST_COLOR_GRAD - /// * terminal_cost: 10000.f - /// * bad_region_penalty: 1000.f + opencv_type_boxed! { Detail_GraphEdge } + + impl Drop for Detail_GraphEdge { #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_GraphCutSeamFinderGpu_GraphCutSeamFinderGpu(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_GraphCutSeamFinderGpu::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_GraphEdge_delete(self.as_raw_mut_Detail_GraphEdge()) }; } - } - boxed_cast_base! { Detail_GraphCutSeamFinderGpu, crate::stitching::Detail_GraphCutSeamFinderBase, cv_detail_GraphCutSeamFinderGpu_to_Detail_GraphCutSeamFinderBase } - - boxed_cast_base! { Detail_GraphCutSeamFinderGpu, crate::stitching::Detail_PairwiseSeamFinder, cv_detail_GraphCutSeamFinderGpu_to_Detail_PairwiseSeamFinder } - - boxed_cast_base! { Detail_GraphCutSeamFinderGpu, crate::stitching::Detail_SeamFinder, cv_detail_GraphCutSeamFinderGpu_to_Detail_SeamFinder } + unsafe impl Send for Detail_GraphEdge {} - impl std::fmt::Debug for Detail_GraphCutSeamFinderGpu { + impl Detail_GraphEdge { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_GraphCutSeamFinderGpu") - .finish() + pub fn new(from: i32, to: i32, weight: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_GraphEdge_GraphEdge_int_int_float(from, to, weight, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_GraphEdge::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_GraphEdge] @@ -7494,21 +7545,17 @@ pub mod stitching { } - pub struct Detail_GraphEdge { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_GraphEdge } - - impl Drop for Detail_GraphEdge { + impl std::fmt::Debug for Detail_GraphEdge { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_GraphEdge_delete(self.as_raw_mut_Detail_GraphEdge()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_GraphEdge") + .field("from", &crate::stitching::Detail_GraphEdgeTraitConst::from(self)) + .field("to", &crate::stitching::Detail_GraphEdgeTraitConst::to(self)) + .field("weight", &crate::stitching::Detail_GraphEdgeTraitConst::weight(self)) + .finish() } } - unsafe impl Send for Detail_GraphEdge {} - impl crate::stitching::Detail_GraphEdgeTraitConst for Detail_GraphEdge { #[inline] fn as_raw_Detail_GraphEdge(&self) -> *const c_void { self.as_raw() } } @@ -7519,28 +7566,48 @@ pub mod stitching { boxed_ref! { Detail_GraphEdge, crate::stitching::Detail_GraphEdgeTraitConst, as_raw_Detail_GraphEdge, crate::stitching::Detail_GraphEdgeTrait, as_raw_mut_Detail_GraphEdge } - impl Detail_GraphEdge { + /// Homography based rotation estimator. + pub struct Detail_HomographyBasedEstimator { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_HomographyBasedEstimator } + + impl Drop for Detail_HomographyBasedEstimator { #[inline] - pub fn new(from: i32, to: i32, weight: f32) -> Result { + fn drop(&mut self) { + unsafe { sys::cv_detail_HomographyBasedEstimator_delete(self.as_raw_mut_Detail_HomographyBasedEstimator()) }; + } + } + + unsafe impl Send for Detail_HomographyBasedEstimator {} + + impl Detail_HomographyBasedEstimator { + /// ## C++ default parameters + /// * is_focals_estimated: false + #[inline] + pub fn new(is_focals_estimated: bool) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_GraphEdge_GraphEdge_int_int_float(from, to, weight, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_HomographyBasedEstimator_HomographyBasedEstimator_bool(is_focals_estimated, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_GraphEdge::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::Detail_HomographyBasedEstimator::opencv_from_extern(ret) }; Ok(ret) } - } - - impl std::fmt::Debug for Detail_GraphEdge { + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * is_focals_estimated: false #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_GraphEdge") - .field("from", &crate::stitching::Detail_GraphEdgeTraitConst::from(self)) - .field("to", &crate::stitching::Detail_GraphEdgeTraitConst::to(self)) - .field("weight", &crate::stitching::Detail_GraphEdgeTraitConst::weight(self)) - .finish() + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_HomographyBasedEstimator_HomographyBasedEstimator(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_HomographyBasedEstimator::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_HomographyBasedEstimator] @@ -7555,21 +7622,15 @@ pub mod stitching { } - /// Homography based rotation estimator. - pub struct Detail_HomographyBasedEstimator { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_HomographyBasedEstimator } - - impl Drop for Detail_HomographyBasedEstimator { + impl std::fmt::Debug for Detail_HomographyBasedEstimator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_HomographyBasedEstimator_delete(self.as_raw_mut_Detail_HomographyBasedEstimator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_HomographyBasedEstimator") + .finish() } } - unsafe impl Send for Detail_HomographyBasedEstimator {} + boxed_cast_base! { Detail_HomographyBasedEstimator, crate::stitching::Detail_Estimator, cv_detail_HomographyBasedEstimator_to_Detail_Estimator } impl crate::stitching::Detail_EstimatorTraitConst for Detail_HomographyBasedEstimator { #[inline] fn as_raw_Detail_Estimator(&self) -> *const c_void { self.as_raw() } @@ -7591,42 +7652,31 @@ pub mod stitching { boxed_ref! { Detail_HomographyBasedEstimator, crate::stitching::Detail_HomographyBasedEstimatorTraitConst, as_raw_Detail_HomographyBasedEstimator, crate::stitching::Detail_HomographyBasedEstimatorTrait, as_raw_mut_Detail_HomographyBasedEstimator } - impl Detail_HomographyBasedEstimator { - /// ## C++ default parameters - /// * is_focals_estimated: false - #[inline] - pub fn new(is_focals_estimated: bool) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_HomographyBasedEstimator_HomographyBasedEstimator_bool(is_focals_estimated, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_HomographyBasedEstimator::opencv_from_extern(ret) }; - Ok(ret) - } + /// Structure containing image keypoints and descriptors. + pub struct Detail_ImageFeatures { + ptr: *mut c_void, + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * is_focals_estimated: false + opencv_type_boxed! { Detail_ImageFeatures } + + impl Drop for Detail_ImageFeatures { #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_HomographyBasedEstimator_HomographyBasedEstimator(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_HomographyBasedEstimator::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_ImageFeatures_delete(self.as_raw_mut_Detail_ImageFeatures()) }; } - } - boxed_cast_base! { Detail_HomographyBasedEstimator, crate::stitching::Detail_Estimator, cv_detail_HomographyBasedEstimator_to_Detail_Estimator } + unsafe impl Send for Detail_ImageFeatures {} - impl std::fmt::Debug for Detail_HomographyBasedEstimator { + impl Detail_ImageFeatures { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_HomographyBasedEstimator") - .finish() + pub fn default() -> crate::stitching::Detail_ImageFeatures { + let ret = unsafe { sys::cv_detail_ImageFeatures_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_ImageFeatures::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::Detail_ImageFeatures] @@ -7703,21 +7753,32 @@ pub mod stitching { } - /// Structure containing image keypoints and descriptors. - pub struct Detail_ImageFeatures { - ptr: *mut c_void, + impl Default for Detail_ImageFeatures { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_ImageFeatures } - - impl Drop for Detail_ImageFeatures { + impl Clone for Detail_ImageFeatures { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_ImageFeatures_delete(self.as_raw_mut_Detail_ImageFeatures()) }; + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_detail_ImageFeatures_implicitClone_const(self.as_raw_Detail_ImageFeatures())) } } } - unsafe impl Send for Detail_ImageFeatures {} + impl std::fmt::Debug for Detail_ImageFeatures { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_ImageFeatures") + .field("img_idx", &crate::stitching::Detail_ImageFeaturesTraitConst::img_idx(self)) + .field("img_size", &crate::stitching::Detail_ImageFeaturesTraitConst::img_size(self)) + .field("keypoints", &crate::stitching::Detail_ImageFeaturesTraitConst::keypoints(self)) + .field("descriptors", &crate::stitching::Detail_ImageFeaturesTraitConst::descriptors(self)) + .finish() + } + } impl crate::stitching::Detail_ImageFeaturesTraitConst for Detail_ImageFeatures { #[inline] fn as_raw_Detail_ImageFeatures(&self) -> *const c_void { self.as_raw() } @@ -7729,40 +7790,48 @@ pub mod stitching { boxed_ref! { Detail_ImageFeatures, crate::stitching::Detail_ImageFeaturesTraitConst, as_raw_Detail_ImageFeatures, crate::stitching::Detail_ImageFeaturesTrait, as_raw_mut_Detail_ImageFeatures } - impl Detail_ImageFeatures { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_ImageFeatures_defaultNew_const()) } - } - + /// Structure containing information about matches between two images. + /// + /// It's assumed that there is a transformation between those images. Transformation may be + /// homography or affine transformation based on selected matcher. + /// ## See also + /// detail::FeaturesMatcher + pub struct Detail_MatchesInfo { + ptr: *mut c_void, } - impl Clone for Detail_ImageFeatures { + opencv_type_boxed! { Detail_MatchesInfo } + + impl Drop for Detail_MatchesInfo { #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_detail_ImageFeatures_implicitClone_const(self.as_raw_Detail_ImageFeatures())) } + fn drop(&mut self) { + unsafe { sys::cv_detail_MatchesInfo_delete(self.as_raw_mut_Detail_MatchesInfo()) }; } } - impl std::fmt::Debug for Detail_ImageFeatures { + unsafe impl Send for Detail_MatchesInfo {} + + impl Detail_MatchesInfo { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_ImageFeatures") - .field("img_idx", &crate::stitching::Detail_ImageFeaturesTraitConst::img_idx(self)) - .field("img_size", &crate::stitching::Detail_ImageFeaturesTraitConst::img_size(self)) - .field("keypoints", &crate::stitching::Detail_ImageFeaturesTraitConst::keypoints(self)) - .field("descriptors", &crate::stitching::Detail_ImageFeaturesTraitConst::descriptors(self)) - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_MatchesInfo_MatchesInfo(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_MatchesInfo::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for Detail_ImageFeatures { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn copy(other: &impl crate::stitching::Detail_MatchesInfoTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_MatchesInfo_MatchesInfo_const_MatchesInfoR(other.as_raw_Detail_MatchesInfo(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_MatchesInfo::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_MatchesInfo] @@ -7869,89 +7938,35 @@ pub mod stitching { #[inline] fn set_confidence(&mut self, val: f64) { let ret = unsafe { sys::cv_detail_MatchesInfo_propConfidence_const_double(self.as_raw_mut_Detail_MatchesInfo(), val) }; - ret - } - - #[inline] - fn set(&mut self, other: &impl crate::stitching::Detail_MatchesInfoTraitConst) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_MatchesInfo_operatorST_const_MatchesInfoR(self.as_raw_mut_Detail_MatchesInfo(), other.as_raw_Detail_MatchesInfo(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_matches(&mut self) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_MatchesInfo_getMatches(self.as_raw_mut_Detail_MatchesInfo(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Vector::::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - fn get_inliers(&mut self) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_MatchesInfo_getInliers(self.as_raw_mut_Detail_MatchesInfo(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Vector::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - /// Structure containing information about matches between two images. - /// - /// It's assumed that there is a transformation between those images. Transformation may be - /// homography or affine transformation based on selected matcher. - /// ## See also - /// detail::FeaturesMatcher - pub struct Detail_MatchesInfo { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_MatchesInfo } + ret + } - impl Drop for Detail_MatchesInfo { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_MatchesInfo_delete(self.as_raw_mut_Detail_MatchesInfo()) }; + fn set(&mut self, other: &impl crate::stitching::Detail_MatchesInfoTraitConst) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_MatchesInfo_operatorST_const_MatchesInfoR(self.as_raw_mut_Detail_MatchesInfo(), other.as_raw_Detail_MatchesInfo(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } - } - - unsafe impl Send for Detail_MatchesInfo {} - - impl crate::stitching::Detail_MatchesInfoTraitConst for Detail_MatchesInfo { - #[inline] fn as_raw_Detail_MatchesInfo(&self) -> *const c_void { self.as_raw() } - } - - impl crate::stitching::Detail_MatchesInfoTrait for Detail_MatchesInfo { - #[inline] fn as_raw_mut_Detail_MatchesInfo(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Detail_MatchesInfo, crate::stitching::Detail_MatchesInfoTraitConst, as_raw_Detail_MatchesInfo, crate::stitching::Detail_MatchesInfoTrait, as_raw_mut_Detail_MatchesInfo } - impl Detail_MatchesInfo { #[inline] - pub fn default() -> Result { + fn get_matches(&mut self) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_MatchesInfo_MatchesInfo(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_MatchesInfo_getMatches(self.as_raw_mut_Detail_MatchesInfo(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_MatchesInfo::opencv_from_extern(ret) }; + let ret = unsafe { core::Vector::::opencv_from_extern(ret) }; Ok(ret) } #[inline] - pub fn copy(other: &impl crate::stitching::Detail_MatchesInfoTraitConst) -> Result { + fn get_inliers(&mut self) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_MatchesInfo_MatchesInfo_const_MatchesInfoR(other.as_raw_Detail_MatchesInfo(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_MatchesInfo_getInliers(self.as_raw_mut_Detail_MatchesInfo(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_MatchesInfo::opencv_from_extern(ret) }; + let ret = unsafe { core::Vector::::opencv_from_extern(ret) }; Ok(ret) } @@ -7979,6 +7994,42 @@ pub mod stitching { } } + impl crate::stitching::Detail_MatchesInfoTraitConst for Detail_MatchesInfo { + #[inline] fn as_raw_Detail_MatchesInfo(&self) -> *const c_void { self.as_raw() } + } + + impl crate::stitching::Detail_MatchesInfoTrait for Detail_MatchesInfo { + #[inline] fn as_raw_mut_Detail_MatchesInfo(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Detail_MatchesInfo, crate::stitching::Detail_MatchesInfoTraitConst, as_raw_Detail_MatchesInfo, crate::stitching::Detail_MatchesInfoTrait, as_raw_mut_Detail_MatchesInfo } + + pub struct Detail_MercatorProjector { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_MercatorProjector } + + impl Drop for Detail_MercatorProjector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_detail_MercatorProjector_delete(self.as_raw_mut_Detail_MercatorProjector()) }; + } + } + + unsafe impl Send for Detail_MercatorProjector {} + + impl Detail_MercatorProjector { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::stitching::Detail_MercatorProjector { + let ret = unsafe { sys::cv_detail_MercatorProjector_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_MercatorProjector::opencv_from_extern(ret) }; + ret + } + + } + /// Constant methods for [crate::stitching::Detail_MercatorProjector] pub trait Detail_MercatorProjectorTraitConst: crate::stitching::Detail_ProjectorBaseTraitConst { fn as_raw_Detail_MercatorProjector(&self) -> *const c_void; @@ -8009,20 +8060,29 @@ pub mod stitching { } - pub struct Detail_MercatorProjector { - ptr: *mut c_void, + impl Default for Detail_MercatorProjector { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_MercatorProjector } - - impl Drop for Detail_MercatorProjector { + impl std::fmt::Debug for Detail_MercatorProjector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_MercatorProjector_delete(self.as_raw_mut_Detail_MercatorProjector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_MercatorProjector") + .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) + .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) + .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) + .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) + .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) + .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) + .finish() } } - unsafe impl Send for Detail_MercatorProjector {} + boxed_cast_base! { Detail_MercatorProjector, crate::stitching::Detail_ProjectorBase, cv_detail_MercatorProjector_to_Detail_ProjectorBase } impl crate::stitching::Detail_ProjectorBaseTraitConst for Detail_MercatorProjector { #[inline] fn as_raw_Detail_ProjectorBase(&self) -> *const c_void { self.as_raw() } @@ -8044,37 +8104,32 @@ pub mod stitching { boxed_ref! { Detail_MercatorProjector, crate::stitching::Detail_MercatorProjectorTraitConst, as_raw_Detail_MercatorProjector, crate::stitching::Detail_MercatorProjectorTrait, as_raw_mut_Detail_MercatorProjector } - impl Detail_MercatorProjector { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_MercatorProjector_defaultNew_const()) } - } - + pub struct Detail_MercatorWarper { + ptr: *mut c_void, } - boxed_cast_base! { Detail_MercatorProjector, crate::stitching::Detail_ProjectorBase, cv_detail_MercatorProjector_to_Detail_ProjectorBase } + opencv_type_boxed! { Detail_MercatorWarper } - impl std::fmt::Debug for Detail_MercatorProjector { + impl Drop for Detail_MercatorWarper { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_MercatorProjector") - .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) - .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) - .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) - .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) - .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) - .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_detail_MercatorWarper_delete(self.as_raw_mut_Detail_MercatorWarper()) }; } } - impl Default for Detail_MercatorProjector { + unsafe impl Send for Detail_MercatorWarper {} + + impl Detail_MercatorWarper { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new(scale: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_MercatorWarper_MercatorWarper_float(scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_MercatorWarper::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_MercatorWarper] @@ -8089,20 +8144,15 @@ pub mod stitching { } - pub struct Detail_MercatorWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_MercatorWarper } - - impl Drop for Detail_MercatorWarper { + impl std::fmt::Debug for Detail_MercatorWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_MercatorWarper_delete(self.as_raw_mut_Detail_MercatorWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_MercatorWarper") + .finish() } } - unsafe impl Send for Detail_MercatorWarper {} + boxed_cast_base! { Detail_MercatorWarper, crate::stitching::Detail_RotationWarper, cv_detail_MercatorWarper_to_Detail_RotationWarper } impl crate::stitching::Detail_RotationWarperTraitConst for Detail_MercatorWarper { #[inline] fn as_raw_Detail_RotationWarper(&self) -> *const c_void { self.as_raw() } @@ -8124,27 +8174,52 @@ pub mod stitching { boxed_ref! { Detail_MercatorWarper, crate::stitching::Detail_MercatorWarperTraitConst, as_raw_Detail_MercatorWarper, crate::stitching::Detail_MercatorWarperTrait, as_raw_mut_Detail_MercatorWarper } - impl Detail_MercatorWarper { + /// Blender which uses multi-band blending algorithm (see [BA83](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_BA83)). + pub struct Detail_MultiBandBlender { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_MultiBandBlender } + + impl Drop for Detail_MultiBandBlender { #[inline] - pub fn new(scale: f32) -> Result { + fn drop(&mut self) { + unsafe { sys::cv_detail_MultiBandBlender_delete(self.as_raw_mut_Detail_MultiBandBlender()) }; + } + } + + unsafe impl Send for Detail_MultiBandBlender {} + + impl Detail_MultiBandBlender { + /// ## C++ default parameters + /// * try_gpu: false + /// * num_bands: 5 + /// * weight_type: CV_32F + #[inline] + pub fn new(try_gpu: i32, num_bands: i32, weight_type: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_MercatorWarper_MercatorWarper_float(scale, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_MultiBandBlender_MultiBandBlender_int_int_int(try_gpu, num_bands, weight_type, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_MercatorWarper::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::Detail_MultiBandBlender::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { Detail_MercatorWarper, crate::stitching::Detail_RotationWarper, cv_detail_MercatorWarper_to_Detail_RotationWarper } - - impl std::fmt::Debug for Detail_MercatorWarper { + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * try_gpu: false + /// * num_bands: 5 + /// * weight_type: CV_32F #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_MercatorWarper") - .finish() + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_MultiBandBlender_MultiBandBlender(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_MultiBandBlender::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_MultiBandBlender] @@ -8208,21 +8283,15 @@ pub mod stitching { } - /// Blender which uses multi-band blending algorithm (see [BA83](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_BA83)). - pub struct Detail_MultiBandBlender { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_MultiBandBlender } - - impl Drop for Detail_MultiBandBlender { + impl std::fmt::Debug for Detail_MultiBandBlender { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_MultiBandBlender_delete(self.as_raw_mut_Detail_MultiBandBlender()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_MultiBandBlender") + .finish() } } - unsafe impl Send for Detail_MultiBandBlender {} + boxed_cast_base! { Detail_MultiBandBlender, crate::stitching::Detail_Blender, cv_detail_MultiBandBlender_to_Detail_Blender } impl crate::stitching::Detail_BlenderTraitConst for Detail_MultiBandBlender { #[inline] fn as_raw_Detail_Blender(&self) -> *const c_void { self.as_raw() } @@ -8244,46 +8313,33 @@ pub mod stitching { boxed_ref! { Detail_MultiBandBlender, crate::stitching::Detail_MultiBandBlenderTraitConst, as_raw_Detail_MultiBandBlender, crate::stitching::Detail_MultiBandBlenderTrait, as_raw_mut_Detail_MultiBandBlender } - impl Detail_MultiBandBlender { - /// ## C++ default parameters - /// * try_gpu: false - /// * num_bands: 5 - /// * weight_type: CV_32F - #[inline] - pub fn new(try_gpu: i32, num_bands: i32, weight_type: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_MultiBandBlender_MultiBandBlender_int_int_int(try_gpu, num_bands, weight_type, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_MultiBandBlender::opencv_from_extern(ret) }; - Ok(ret) - } + /// Stub bundle adjuster that does nothing. + pub struct Detail_NoBundleAdjuster { + ptr: *mut c_void, + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * try_gpu: false - /// * num_bands: 5 - /// * weight_type: CV_32F + opencv_type_boxed! { Detail_NoBundleAdjuster } + + impl Drop for Detail_NoBundleAdjuster { #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_MultiBandBlender_MultiBandBlender(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_MultiBandBlender::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_NoBundleAdjuster_delete(self.as_raw_mut_Detail_NoBundleAdjuster()) }; } - } - boxed_cast_base! { Detail_MultiBandBlender, crate::stitching::Detail_Blender, cv_detail_MultiBandBlender_to_Detail_Blender } + unsafe impl Send for Detail_NoBundleAdjuster {} - impl std::fmt::Debug for Detail_MultiBandBlender { + impl Detail_NoBundleAdjuster { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_MultiBandBlender") - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_NoBundleAdjuster_NoBundleAdjuster(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_NoBundleAdjuster::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_NoBundleAdjuster] @@ -8298,21 +8354,17 @@ pub mod stitching { } - /// Stub bundle adjuster that does nothing. - pub struct Detail_NoBundleAdjuster { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_NoBundleAdjuster } - - impl Drop for Detail_NoBundleAdjuster { + impl std::fmt::Debug for Detail_NoBundleAdjuster { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_NoBundleAdjuster_delete(self.as_raw_mut_Detail_NoBundleAdjuster()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_NoBundleAdjuster") + .finish() } } - unsafe impl Send for Detail_NoBundleAdjuster {} + boxed_cast_base! { Detail_NoBundleAdjuster, crate::stitching::Detail_BundleAdjusterBase, cv_detail_NoBundleAdjuster_to_Detail_BundleAdjusterBase } + + boxed_cast_base! { Detail_NoBundleAdjuster, crate::stitching::Detail_Estimator, cv_detail_NoBundleAdjuster_to_Detail_Estimator } impl crate::stitching::Detail_BundleAdjusterBaseTraitConst for Detail_NoBundleAdjuster { #[inline] fn as_raw_Detail_BundleAdjusterBase(&self) -> *const c_void { self.as_raw() } @@ -8344,29 +8396,31 @@ pub mod stitching { boxed_ref! { Detail_NoBundleAdjuster, crate::stitching::Detail_NoBundleAdjusterTraitConst, as_raw_Detail_NoBundleAdjuster, crate::stitching::Detail_NoBundleAdjusterTrait, as_raw_mut_Detail_NoBundleAdjuster } - impl Detail_NoBundleAdjuster { + /// Stub exposure compensator which does nothing. + pub struct Detail_NoExposureCompensator { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_NoExposureCompensator } + + impl Drop for Detail_NoExposureCompensator { #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_NoBundleAdjuster_NoBundleAdjuster(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_NoBundleAdjuster::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_NoExposureCompensator_delete(self.as_raw_mut_Detail_NoExposureCompensator()) }; } - } - boxed_cast_base! { Detail_NoBundleAdjuster, crate::stitching::Detail_BundleAdjusterBase, cv_detail_NoBundleAdjuster_to_Detail_BundleAdjusterBase } - - boxed_cast_base! { Detail_NoBundleAdjuster, crate::stitching::Detail_Estimator, cv_detail_NoBundleAdjuster_to_Detail_Estimator } + unsafe impl Send for Detail_NoExposureCompensator {} - impl std::fmt::Debug for Detail_NoBundleAdjuster { + impl Detail_NoExposureCompensator { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_NoBundleAdjuster") - .finish() + pub fn default() -> crate::stitching::Detail_NoExposureCompensator { + let ret = unsafe { sys::cv_detail_NoExposureCompensator_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_NoExposureCompensator::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::Detail_NoExposureCompensator] @@ -8419,21 +8473,23 @@ pub mod stitching { } - /// Stub exposure compensator which does nothing. - pub struct Detail_NoExposureCompensator { - ptr: *mut c_void, + impl Default for Detail_NoExposureCompensator { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_NoExposureCompensator } - - impl Drop for Detail_NoExposureCompensator { + impl std::fmt::Debug for Detail_NoExposureCompensator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_NoExposureCompensator_delete(self.as_raw_mut_Detail_NoExposureCompensator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_NoExposureCompensator") + .finish() } } - unsafe impl Send for Detail_NoExposureCompensator {} + boxed_cast_base! { Detail_NoExposureCompensator, crate::stitching::Detail_ExposureCompensator, cv_detail_NoExposureCompensator_to_Detail_ExposureCompensator } impl crate::stitching::Detail_ExposureCompensatorTraitConst for Detail_NoExposureCompensator { #[inline] fn as_raw_Detail_ExposureCompensator(&self) -> *const c_void { self.as_raw() } @@ -8455,31 +8511,31 @@ pub mod stitching { boxed_ref! { Detail_NoExposureCompensator, crate::stitching::Detail_NoExposureCompensatorTraitConst, as_raw_Detail_NoExposureCompensator, crate::stitching::Detail_NoExposureCompensatorTrait, as_raw_mut_Detail_NoExposureCompensator } - impl Detail_NoExposureCompensator { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_NoExposureCompensator_defaultNew_const()) } - } - + /// Stub seam estimator which does nothing. + pub struct Detail_NoSeamFinder { + ptr: *mut c_void, } - boxed_cast_base! { Detail_NoExposureCompensator, crate::stitching::Detail_ExposureCompensator, cv_detail_NoExposureCompensator_to_Detail_ExposureCompensator } + opencv_type_boxed! { Detail_NoSeamFinder } - impl std::fmt::Debug for Detail_NoExposureCompensator { + impl Drop for Detail_NoSeamFinder { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_NoExposureCompensator") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_detail_NoSeamFinder_delete(self.as_raw_mut_Detail_NoSeamFinder()) }; } } - impl Default for Detail_NoExposureCompensator { + unsafe impl Send for Detail_NoSeamFinder {} + + impl Detail_NoSeamFinder { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::stitching::Detail_NoSeamFinder { + let ret = unsafe { sys::cv_detail_NoSeamFinder_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_NoSeamFinder::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::Detail_NoSeamFinder] @@ -8503,21 +8559,23 @@ pub mod stitching { } - /// Stub seam estimator which does nothing. - pub struct Detail_NoSeamFinder { - ptr: *mut c_void, + impl Default for Detail_NoSeamFinder { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_NoSeamFinder } - - impl Drop for Detail_NoSeamFinder { + impl std::fmt::Debug for Detail_NoSeamFinder { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_NoSeamFinder_delete(self.as_raw_mut_Detail_NoSeamFinder()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_NoSeamFinder") + .finish() } } - unsafe impl Send for Detail_NoSeamFinder {} + boxed_cast_base! { Detail_NoSeamFinder, crate::stitching::Detail_SeamFinder, cv_detail_NoSeamFinder_to_Detail_SeamFinder } impl crate::stitching::Detail_SeamFinderTraitConst for Detail_NoSeamFinder { #[inline] fn as_raw_Detail_SeamFinder(&self) -> *const c_void { self.as_raw() } @@ -8539,32 +8597,21 @@ pub mod stitching { boxed_ref! { Detail_NoSeamFinder, crate::stitching::Detail_NoSeamFinderTraitConst, as_raw_Detail_NoSeamFinder, crate::stitching::Detail_NoSeamFinderTrait, as_raw_mut_Detail_NoSeamFinder } - impl Detail_NoSeamFinder { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_NoSeamFinder_defaultNew_const()) } - } - + /// Base class for all pairwise seam estimators. + pub struct Detail_PairwiseSeamFinder { + ptr: *mut c_void, } - boxed_cast_base! { Detail_NoSeamFinder, crate::stitching::Detail_SeamFinder, cv_detail_NoSeamFinder_to_Detail_SeamFinder } + opencv_type_boxed! { Detail_PairwiseSeamFinder } - impl std::fmt::Debug for Detail_NoSeamFinder { + impl Drop for Detail_PairwiseSeamFinder { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_NoSeamFinder") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_detail_PairwiseSeamFinder_delete(self.as_raw_mut_Detail_PairwiseSeamFinder()) }; } } - impl Default for Detail_NoSeamFinder { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } + unsafe impl Send for Detail_PairwiseSeamFinder {} /// Constant methods for [crate::stitching::Detail_PairwiseSeamFinder] pub trait Detail_PairwiseSeamFinderTraitConst: crate::stitching::Detail_SeamFinderTraitConst { @@ -8587,21 +8634,19 @@ pub mod stitching { } - /// Base class for all pairwise seam estimators. - pub struct Detail_PairwiseSeamFinder { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_PairwiseSeamFinder } - - impl Drop for Detail_PairwiseSeamFinder { + impl std::fmt::Debug for Detail_PairwiseSeamFinder { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_PairwiseSeamFinder_delete(self.as_raw_mut_Detail_PairwiseSeamFinder()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_PairwiseSeamFinder") + .finish() } } - unsafe impl Send for Detail_PairwiseSeamFinder {} + boxed_cast_base! { Detail_PairwiseSeamFinder, crate::stitching::Detail_SeamFinder, cv_detail_PairwiseSeamFinder_to_Detail_SeamFinder } + + boxed_cast_descendant! { Detail_PairwiseSeamFinder, crate::stitching::Detail_GraphCutSeamFinderGpu, cv_detail_PairwiseSeamFinder_to_Detail_GraphCutSeamFinderGpu } + + boxed_cast_descendant! { Detail_PairwiseSeamFinder, crate::stitching::Detail_VoronoiSeamFinder, cv_detail_PairwiseSeamFinder_to_Detail_VoronoiSeamFinder } impl crate::stitching::Detail_SeamFinderTraitConst for Detail_PairwiseSeamFinder { #[inline] fn as_raw_Detail_SeamFinder(&self) -> *const c_void { self.as_raw() } @@ -8623,21 +8668,30 @@ pub mod stitching { boxed_ref! { Detail_PairwiseSeamFinder, crate::stitching::Detail_PairwiseSeamFinderTraitConst, as_raw_Detail_PairwiseSeamFinder, crate::stitching::Detail_PairwiseSeamFinderTrait, as_raw_mut_Detail_PairwiseSeamFinder } - impl Detail_PairwiseSeamFinder { + pub struct Detail_PaniniPortraitProjector { + ptr: *mut c_void, } - boxed_cast_descendant! { Detail_PairwiseSeamFinder, crate::stitching::Detail_GraphCutSeamFinderGpu, cv_detail_PairwiseSeamFinder_to_Detail_GraphCutSeamFinderGpu } + opencv_type_boxed! { Detail_PaniniPortraitProjector } - boxed_cast_descendant! { Detail_PairwiseSeamFinder, crate::stitching::Detail_VoronoiSeamFinder, cv_detail_PairwiseSeamFinder_to_Detail_VoronoiSeamFinder } + impl Drop for Detail_PaniniPortraitProjector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_detail_PaniniPortraitProjector_delete(self.as_raw_mut_Detail_PaniniPortraitProjector()) }; + } + } - boxed_cast_base! { Detail_PairwiseSeamFinder, crate::stitching::Detail_SeamFinder, cv_detail_PairwiseSeamFinder_to_Detail_SeamFinder } + unsafe impl Send for Detail_PaniniPortraitProjector {} - impl std::fmt::Debug for Detail_PairwiseSeamFinder { + impl Detail_PaniniPortraitProjector { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_PairwiseSeamFinder") - .finish() + pub fn default() -> crate::stitching::Detail_PaniniPortraitProjector { + let ret = unsafe { sys::cv_detail_PaniniPortraitProjector_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_PaniniPortraitProjector::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::Detail_PaniniPortraitProjector] @@ -8694,52 +8748,14 @@ pub mod stitching { } - pub struct Detail_PaniniPortraitProjector { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_PaniniPortraitProjector } - - impl Drop for Detail_PaniniPortraitProjector { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_PaniniPortraitProjector_delete(self.as_raw_mut_Detail_PaniniPortraitProjector()) }; - } - } - - unsafe impl Send for Detail_PaniniPortraitProjector {} - - impl crate::stitching::Detail_ProjectorBaseTraitConst for Detail_PaniniPortraitProjector { - #[inline] fn as_raw_Detail_ProjectorBase(&self) -> *const c_void { self.as_raw() } - } - - impl crate::stitching::Detail_ProjectorBaseTrait for Detail_PaniniPortraitProjector { - #[inline] fn as_raw_mut_Detail_ProjectorBase(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Detail_PaniniPortraitProjector, crate::stitching::Detail_ProjectorBaseTraitConst, as_raw_Detail_ProjectorBase, crate::stitching::Detail_ProjectorBaseTrait, as_raw_mut_Detail_ProjectorBase } - - impl crate::stitching::Detail_PaniniPortraitProjectorTraitConst for Detail_PaniniPortraitProjector { - #[inline] fn as_raw_Detail_PaniniPortraitProjector(&self) -> *const c_void { self.as_raw() } - } - - impl crate::stitching::Detail_PaniniPortraitProjectorTrait for Detail_PaniniPortraitProjector { - #[inline] fn as_raw_mut_Detail_PaniniPortraitProjector(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Detail_PaniniPortraitProjector, crate::stitching::Detail_PaniniPortraitProjectorTraitConst, as_raw_Detail_PaniniPortraitProjector, crate::stitching::Detail_PaniniPortraitProjectorTrait, as_raw_mut_Detail_PaniniPortraitProjector } - - impl Detail_PaniniPortraitProjector { - /// Creates a default instance of the class by calling the default constructor + impl Default for Detail_PaniniPortraitProjector { #[inline] + /// Forwards to infallible Self::default() fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_PaniniPortraitProjector_defaultNew_const()) } + Self::default() } - } - boxed_cast_base! { Detail_PaniniPortraitProjector, crate::stitching::Detail_ProjectorBase, cv_detail_PaniniPortraitProjector_to_Detail_ProjectorBase } - impl std::fmt::Debug for Detail_PaniniPortraitProjector { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -8756,26 +8772,28 @@ pub mod stitching { } } - impl Default for Detail_PaniniPortraitProjector { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } + boxed_cast_base! { Detail_PaniniPortraitProjector, crate::stitching::Detail_ProjectorBase, cv_detail_PaniniPortraitProjector_to_Detail_ProjectorBase } - /// Constant methods for [crate::stitching::Detail_PaniniPortraitWarper] - pub trait Detail_PaniniPortraitWarperTraitConst { - fn as_raw_Detail_PaniniPortraitWarper(&self) -> *const c_void; + impl crate::stitching::Detail_ProjectorBaseTraitConst for Detail_PaniniPortraitProjector { + #[inline] fn as_raw_Detail_ProjectorBase(&self) -> *const c_void { self.as_raw() } + } + impl crate::stitching::Detail_ProjectorBaseTrait for Detail_PaniniPortraitProjector { + #[inline] fn as_raw_mut_Detail_ProjectorBase(&mut self) -> *mut c_void { self.as_raw_mut() } } - /// Mutable methods for [crate::stitching::Detail_PaniniPortraitWarper] - pub trait Detail_PaniniPortraitWarperTrait: crate::stitching::Detail_PaniniPortraitWarperTraitConst { - fn as_raw_mut_Detail_PaniniPortraitWarper(&mut self) -> *mut c_void; + boxed_ref! { Detail_PaniniPortraitProjector, crate::stitching::Detail_ProjectorBaseTraitConst, as_raw_Detail_ProjectorBase, crate::stitching::Detail_ProjectorBaseTrait, as_raw_mut_Detail_ProjectorBase } + + impl crate::stitching::Detail_PaniniPortraitProjectorTraitConst for Detail_PaniniPortraitProjector { + #[inline] fn as_raw_Detail_PaniniPortraitProjector(&self) -> *const c_void { self.as_raw() } + } + impl crate::stitching::Detail_PaniniPortraitProjectorTrait for Detail_PaniniPortraitProjector { + #[inline] fn as_raw_mut_Detail_PaniniPortraitProjector(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { Detail_PaniniPortraitProjector, crate::stitching::Detail_PaniniPortraitProjectorTraitConst, as_raw_Detail_PaniniPortraitProjector, crate::stitching::Detail_PaniniPortraitProjectorTrait, as_raw_mut_Detail_PaniniPortraitProjector } + pub struct Detail_PaniniPortraitWarper { ptr: *mut c_void, } @@ -8791,26 +8809,6 @@ pub mod stitching { unsafe impl Send for Detail_PaniniPortraitWarper {} - impl crate::stitching::Detail_RotationWarperTraitConst for Detail_PaniniPortraitWarper { - #[inline] fn as_raw_Detail_RotationWarper(&self) -> *const c_void { self.as_raw() } - } - - impl crate::stitching::Detail_RotationWarperTrait for Detail_PaniniPortraitWarper { - #[inline] fn as_raw_mut_Detail_RotationWarper(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Detail_PaniniPortraitWarper, crate::stitching::Detail_RotationWarperTraitConst, as_raw_Detail_RotationWarper, crate::stitching::Detail_RotationWarperTrait, as_raw_mut_Detail_RotationWarper } - - impl crate::stitching::Detail_PaniniPortraitWarperTraitConst for Detail_PaniniPortraitWarper { - #[inline] fn as_raw_Detail_PaniniPortraitWarper(&self) -> *const c_void { self.as_raw() } - } - - impl crate::stitching::Detail_PaniniPortraitWarperTrait for Detail_PaniniPortraitWarper { - #[inline] fn as_raw_mut_Detail_PaniniPortraitWarper(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Detail_PaniniPortraitWarper, crate::stitching::Detail_PaniniPortraitWarperTraitConst, as_raw_Detail_PaniniPortraitWarper, crate::stitching::Detail_PaniniPortraitWarperTrait, as_raw_mut_Detail_PaniniPortraitWarper } - impl Detail_PaniniPortraitWarper { /// ## C++ default parameters /// * a: 1 @@ -8841,7 +8839,17 @@ pub mod stitching { } - boxed_cast_base! { Detail_PaniniPortraitWarper, crate::stitching::Detail_RotationWarper, cv_detail_PaniniPortraitWarper_to_Detail_RotationWarper } + /// Constant methods for [crate::stitching::Detail_PaniniPortraitWarper] + pub trait Detail_PaniniPortraitWarperTraitConst { + fn as_raw_Detail_PaniniPortraitWarper(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::stitching::Detail_PaniniPortraitWarper] + pub trait Detail_PaniniPortraitWarperTrait: crate::stitching::Detail_PaniniPortraitWarperTraitConst { + fn as_raw_mut_Detail_PaniniPortraitWarper(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for Detail_PaniniPortraitWarper { #[inline] @@ -8851,6 +8859,54 @@ pub mod stitching { } } + boxed_cast_base! { Detail_PaniniPortraitWarper, crate::stitching::Detail_RotationWarper, cv_detail_PaniniPortraitWarper_to_Detail_RotationWarper } + + impl crate::stitching::Detail_RotationWarperTraitConst for Detail_PaniniPortraitWarper { + #[inline] fn as_raw_Detail_RotationWarper(&self) -> *const c_void { self.as_raw() } + } + + impl crate::stitching::Detail_RotationWarperTrait for Detail_PaniniPortraitWarper { + #[inline] fn as_raw_mut_Detail_RotationWarper(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Detail_PaniniPortraitWarper, crate::stitching::Detail_RotationWarperTraitConst, as_raw_Detail_RotationWarper, crate::stitching::Detail_RotationWarperTrait, as_raw_mut_Detail_RotationWarper } + + impl crate::stitching::Detail_PaniniPortraitWarperTraitConst for Detail_PaniniPortraitWarper { + #[inline] fn as_raw_Detail_PaniniPortraitWarper(&self) -> *const c_void { self.as_raw() } + } + + impl crate::stitching::Detail_PaniniPortraitWarperTrait for Detail_PaniniPortraitWarper { + #[inline] fn as_raw_mut_Detail_PaniniPortraitWarper(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Detail_PaniniPortraitWarper, crate::stitching::Detail_PaniniPortraitWarperTraitConst, as_raw_Detail_PaniniPortraitWarper, crate::stitching::Detail_PaniniPortraitWarperTrait, as_raw_mut_Detail_PaniniPortraitWarper } + + pub struct Detail_PaniniProjector { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_PaniniProjector } + + impl Drop for Detail_PaniniProjector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_detail_PaniniProjector_delete(self.as_raw_mut_Detail_PaniniProjector()) }; + } + } + + unsafe impl Send for Detail_PaniniProjector {} + + impl Detail_PaniniProjector { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::stitching::Detail_PaniniProjector { + let ret = unsafe { sys::cv_detail_PaniniProjector_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_PaniniProjector::opencv_from_extern(ret) }; + ret + } + + } + /// Constant methods for [crate::stitching::Detail_PaniniProjector] pub trait Detail_PaniniProjectorTraitConst: crate::stitching::Detail_ProjectorBaseTraitConst { fn as_raw_Detail_PaniniProjector(&self) -> *const c_void; @@ -8905,20 +8961,31 @@ pub mod stitching { } - pub struct Detail_PaniniProjector { - ptr: *mut c_void, + impl Default for Detail_PaniniProjector { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_PaniniProjector } - - impl Drop for Detail_PaniniProjector { + impl std::fmt::Debug for Detail_PaniniProjector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_PaniniProjector_delete(self.as_raw_mut_Detail_PaniniProjector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_PaniniProjector") + .field("a", &crate::stitching::Detail_PaniniProjectorTraitConst::a(self)) + .field("b", &crate::stitching::Detail_PaniniProjectorTraitConst::b(self)) + .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) + .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) + .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) + .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) + .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) + .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) + .finish() } } - unsafe impl Send for Detail_PaniniProjector {} + boxed_cast_base! { Detail_PaniniProjector, crate::stitching::Detail_ProjectorBase, cv_detail_PaniniProjector_to_Detail_ProjectorBase } impl crate::stitching::Detail_ProjectorBaseTraitConst for Detail_PaniniProjector { #[inline] fn as_raw_Detail_ProjectorBase(&self) -> *const c_void { self.as_raw() } @@ -8940,39 +9007,49 @@ pub mod stitching { boxed_ref! { Detail_PaniniProjector, crate::stitching::Detail_PaniniProjectorTraitConst, as_raw_Detail_PaniniProjector, crate::stitching::Detail_PaniniProjectorTrait, as_raw_mut_Detail_PaniniProjector } - impl Detail_PaniniProjector { - /// Creates a default instance of the class by calling the default constructor + pub struct Detail_PaniniWarper { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_PaniniWarper } + + impl Drop for Detail_PaniniWarper { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_PaniniProjector_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_detail_PaniniWarper_delete(self.as_raw_mut_Detail_PaniniWarper()) }; } - } - boxed_cast_base! { Detail_PaniniProjector, crate::stitching::Detail_ProjectorBase, cv_detail_PaniniProjector_to_Detail_ProjectorBase } + unsafe impl Send for Detail_PaniniWarper {} - impl std::fmt::Debug for Detail_PaniniProjector { + impl Detail_PaniniWarper { + /// ## C++ default parameters + /// * a: 1 + /// * b: 1 #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_PaniniProjector") - .field("a", &crate::stitching::Detail_PaniniProjectorTraitConst::a(self)) - .field("b", &crate::stitching::Detail_PaniniProjectorTraitConst::b(self)) - .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) - .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) - .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) - .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) - .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) - .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) - .finish() + pub fn new(scale: f32, a: f32, b: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_PaniniWarper_PaniniWarper_float_float_float(scale, a, b, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_PaniniWarper::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for Detail_PaniniProjector { + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * a: 1 + /// * b: 1 #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new_def(scale: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_PaniniWarper_PaniniWarper_float(scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_PaniniWarper::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_PaniniWarper] @@ -8987,20 +9064,15 @@ pub mod stitching { } - pub struct Detail_PaniniWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_PaniniWarper } - - impl Drop for Detail_PaniniWarper { + impl std::fmt::Debug for Detail_PaniniWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_PaniniWarper_delete(self.as_raw_mut_Detail_PaniniWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_PaniniWarper") + .finish() } } - unsafe impl Send for Detail_PaniniWarper {} + boxed_cast_base! { Detail_PaniniWarper, crate::stitching::Detail_RotationWarper, cv_detail_PaniniWarper_to_Detail_RotationWarper } impl crate::stitching::Detail_RotationWarperTraitConst for Detail_PaniniWarper { #[inline] fn as_raw_Detail_RotationWarper(&self) -> *const c_void { self.as_raw() } @@ -9022,44 +9094,30 @@ pub mod stitching { boxed_ref! { Detail_PaniniWarper, crate::stitching::Detail_PaniniWarperTraitConst, as_raw_Detail_PaniniWarper, crate::stitching::Detail_PaniniWarperTrait, as_raw_mut_Detail_PaniniWarper } - impl Detail_PaniniWarper { - /// ## C++ default parameters - /// * a: 1 - /// * b: 1 - #[inline] - pub fn new(scale: f32, a: f32, b: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_PaniniWarper_PaniniWarper_float_float_float(scale, a, b, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_PaniniWarper::opencv_from_extern(ret) }; - Ok(ret) - } + pub struct Detail_PlanePortraitProjector { + ptr: *mut c_void, + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * a: 1 - /// * b: 1 + opencv_type_boxed! { Detail_PlanePortraitProjector } + + impl Drop for Detail_PlanePortraitProjector { #[inline] - pub fn new_def(scale: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_PaniniWarper_PaniniWarper_float(scale, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_PaniniWarper::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_PlanePortraitProjector_delete(self.as_raw_mut_Detail_PlanePortraitProjector()) }; } - } - boxed_cast_base! { Detail_PaniniWarper, crate::stitching::Detail_RotationWarper, cv_detail_PaniniWarper_to_Detail_RotationWarper } + unsafe impl Send for Detail_PlanePortraitProjector {} - impl std::fmt::Debug for Detail_PaniniWarper { + impl Detail_PlanePortraitProjector { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_PaniniWarper") - .finish() + pub fn default() -> crate::stitching::Detail_PlanePortraitProjector { + let ret = unsafe { sys::cv_detail_PlanePortraitProjector_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_PlanePortraitProjector::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::Detail_PlanePortraitProjector] @@ -9092,20 +9150,29 @@ pub mod stitching { } - pub struct Detail_PlanePortraitProjector { - ptr: *mut c_void, + impl Default for Detail_PlanePortraitProjector { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_PlanePortraitProjector } - - impl Drop for Detail_PlanePortraitProjector { + impl std::fmt::Debug for Detail_PlanePortraitProjector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_PlanePortraitProjector_delete(self.as_raw_mut_Detail_PlanePortraitProjector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_PlanePortraitProjector") + .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) + .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) + .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) + .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) + .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) + .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) + .finish() } } - unsafe impl Send for Detail_PlanePortraitProjector {} + boxed_cast_base! { Detail_PlanePortraitProjector, crate::stitching::Detail_ProjectorBase, cv_detail_PlanePortraitProjector_to_Detail_ProjectorBase } impl crate::stitching::Detail_ProjectorBaseTraitConst for Detail_PlanePortraitProjector { #[inline] fn as_raw_Detail_ProjectorBase(&self) -> *const c_void { self.as_raw() } @@ -9127,37 +9194,32 @@ pub mod stitching { boxed_ref! { Detail_PlanePortraitProjector, crate::stitching::Detail_PlanePortraitProjectorTraitConst, as_raw_Detail_PlanePortraitProjector, crate::stitching::Detail_PlanePortraitProjectorTrait, as_raw_mut_Detail_PlanePortraitProjector } - impl Detail_PlanePortraitProjector { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_PlanePortraitProjector_defaultNew_const()) } - } - + pub struct Detail_PlanePortraitWarper { + ptr: *mut c_void, } - boxed_cast_base! { Detail_PlanePortraitProjector, crate::stitching::Detail_ProjectorBase, cv_detail_PlanePortraitProjector_to_Detail_ProjectorBase } + opencv_type_boxed! { Detail_PlanePortraitWarper } - impl std::fmt::Debug for Detail_PlanePortraitProjector { + impl Drop for Detail_PlanePortraitWarper { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_PlanePortraitProjector") - .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) - .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) - .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) - .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) - .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) - .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_detail_PlanePortraitWarper_delete(self.as_raw_mut_Detail_PlanePortraitWarper()) }; } } - impl Default for Detail_PlanePortraitProjector { + unsafe impl Send for Detail_PlanePortraitWarper {} + + impl Detail_PlanePortraitWarper { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new(scale: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_PlanePortraitWarper_PlanePortraitWarper_float(scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_PlanePortraitWarper::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_PlanePortraitWarper] @@ -9172,20 +9234,15 @@ pub mod stitching { } - pub struct Detail_PlanePortraitWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_PlanePortraitWarper } - - impl Drop for Detail_PlanePortraitWarper { + impl std::fmt::Debug for Detail_PlanePortraitWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_PlanePortraitWarper_delete(self.as_raw_mut_Detail_PlanePortraitWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_PlanePortraitWarper") + .finish() } } - unsafe impl Send for Detail_PlanePortraitWarper {} + boxed_cast_base! { Detail_PlanePortraitWarper, crate::stitching::Detail_RotationWarper, cv_detail_PlanePortraitWarper_to_Detail_RotationWarper } impl crate::stitching::Detail_RotationWarperTraitConst for Detail_PlanePortraitWarper { #[inline] fn as_raw_Detail_RotationWarper(&self) -> *const c_void { self.as_raw() } @@ -9207,27 +9264,30 @@ pub mod stitching { boxed_ref! { Detail_PlanePortraitWarper, crate::stitching::Detail_PlanePortraitWarperTraitConst, as_raw_Detail_PlanePortraitWarper, crate::stitching::Detail_PlanePortraitWarperTrait, as_raw_mut_Detail_PlanePortraitWarper } - impl Detail_PlanePortraitWarper { + pub struct Detail_PlaneProjector { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_PlaneProjector } + + impl Drop for Detail_PlaneProjector { #[inline] - pub fn new(scale: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_PlanePortraitWarper_PlanePortraitWarper_float(scale, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_PlanePortraitWarper::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_PlaneProjector_delete(self.as_raw_mut_Detail_PlaneProjector()) }; } - } - boxed_cast_base! { Detail_PlanePortraitWarper, crate::stitching::Detail_RotationWarper, cv_detail_PlanePortraitWarper_to_Detail_RotationWarper } + unsafe impl Send for Detail_PlaneProjector {} - impl std::fmt::Debug for Detail_PlanePortraitWarper { + impl Detail_PlaneProjector { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_PlanePortraitWarper") - .finish() + pub fn default() -> crate::stitching::Detail_PlaneProjector { + let ret = unsafe { sys::cv_detail_PlaneProjector_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_PlaneProjector::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::Detail_PlaneProjector] @@ -9260,20 +9320,29 @@ pub mod stitching { } - pub struct Detail_PlaneProjector { - ptr: *mut c_void, + impl Default for Detail_PlaneProjector { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_PlaneProjector } - - impl Drop for Detail_PlaneProjector { + impl std::fmt::Debug for Detail_PlaneProjector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_PlaneProjector_delete(self.as_raw_mut_Detail_PlaneProjector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_PlaneProjector") + .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) + .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) + .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) + .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) + .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) + .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) + .finish() } } - unsafe impl Send for Detail_PlaneProjector {} + boxed_cast_base! { Detail_PlaneProjector, crate::stitching::Detail_ProjectorBase, cv_detail_PlaneProjector_to_Detail_ProjectorBase } impl crate::stitching::Detail_ProjectorBaseTraitConst for Detail_PlaneProjector { #[inline] fn as_raw_Detail_ProjectorBase(&self) -> *const c_void { self.as_raw() } @@ -9295,37 +9364,58 @@ pub mod stitching { boxed_ref! { Detail_PlaneProjector, crate::stitching::Detail_PlaneProjectorTraitConst, as_raw_Detail_PlaneProjector, crate::stitching::Detail_PlaneProjectorTrait, as_raw_mut_Detail_PlaneProjector } - impl Detail_PlaneProjector { - /// Creates a default instance of the class by calling the default constructor + /// Warper that maps an image onto the z = 1 plane. + pub struct Detail_PlaneWarper { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_PlaneWarper } + + impl Drop for Detail_PlaneWarper { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_PlaneProjector_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_detail_PlaneWarper_delete(self.as_raw_mut_Detail_PlaneWarper()) }; } - } - boxed_cast_base! { Detail_PlaneProjector, crate::stitching::Detail_ProjectorBase, cv_detail_PlaneProjector_to_Detail_ProjectorBase } + unsafe impl Send for Detail_PlaneWarper {} - impl std::fmt::Debug for Detail_PlaneProjector { + impl Detail_PlaneWarper { + /// Construct an instance of the plane warper class. + /// + /// ## Parameters + /// * scale: Projected image scale multiplier + /// + /// ## C++ default parameters + /// * scale: 1.f #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_PlaneProjector") - .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) - .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) - .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) - .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) - .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) - .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) - .finish() + pub fn new(scale: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_PlaneWarper_PlaneWarper_float(scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_PlaneWarper::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for Detail_PlaneProjector { + /// Construct an instance of the plane warper class. + /// + /// ## Parameters + /// * scale: Projected image scale multiplier + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * scale: 1.f #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_PlaneWarper_PlaneWarper(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_PlaneWarper::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_PlaneWarper] @@ -9463,21 +9553,19 @@ pub mod stitching { } - /// Warper that maps an image onto the z = 1 plane. - pub struct Detail_PlaneWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_PlaneWarper } - - impl Drop for Detail_PlaneWarper { + impl std::fmt::Debug for Detail_PlaneWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_PlaneWarper_delete(self.as_raw_mut_Detail_PlaneWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_PlaneWarper") + .finish() } } - unsafe impl Send for Detail_PlaneWarper {} + boxed_cast_base! { Detail_PlaneWarper, crate::stitching::Detail_RotationWarper, cv_detail_PlaneWarper_to_Detail_RotationWarper } + + boxed_cast_descendant! { Detail_PlaneWarper, crate::stitching::Detail_AffineWarper, cv_detail_PlaneWarper_to_Detail_AffineWarper } + + boxed_cast_descendant! { Detail_PlaneWarper, crate::stitching::Detail_PlaneWarperGpu, cv_detail_PlaneWarper_to_Detail_PlaneWarperGpu } impl crate::stitching::Detail_RotationWarperTraitConst for Detail_PlaneWarper { #[inline] fn as_raw_Detail_RotationWarper(&self) -> *const c_void { self.as_raw() } @@ -9499,58 +9587,49 @@ pub mod stitching { boxed_ref! { Detail_PlaneWarper, crate::stitching::Detail_PlaneWarperTraitConst, as_raw_Detail_PlaneWarper, crate::stitching::Detail_PlaneWarperTrait, as_raw_mut_Detail_PlaneWarper } - impl Detail_PlaneWarper { - /// Construct an instance of the plane warper class. - /// - /// ## Parameters - /// * scale: Projected image scale multiplier - /// + pub struct Detail_PlaneWarperGpu { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_PlaneWarperGpu } + + impl Drop for Detail_PlaneWarperGpu { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_detail_PlaneWarperGpu_delete(self.as_raw_mut_Detail_PlaneWarperGpu()) }; + } + } + + unsafe impl Send for Detail_PlaneWarperGpu {} + + impl Detail_PlaneWarperGpu { /// ## C++ default parameters /// * scale: 1.f #[inline] - pub fn new(scale: f32) -> Result { + pub fn new(scale: f32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_PlaneWarper_PlaneWarper_float(scale, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_PlaneWarperGpu_PlaneWarperGpu_float(scale, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_PlaneWarper::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::Detail_PlaneWarperGpu::opencv_from_extern(ret) }; Ok(ret) } - /// Construct an instance of the plane warper class. - /// - /// ## Parameters - /// * scale: Projected image scale multiplier - /// /// ## Note /// This alternative version of [new] function uses the following default values for its arguments: /// * scale: 1.f #[inline] - pub fn new_def() -> Result { + pub fn new_def() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_detail_PlaneWarper_PlaneWarper(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_detail_PlaneWarperGpu_PlaneWarperGpu(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_PlaneWarper::opencv_from_extern(ret) }; + let ret = unsafe { crate::stitching::Detail_PlaneWarperGpu::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_descendant! { Detail_PlaneWarper, crate::stitching::Detail_AffineWarper, cv_detail_PlaneWarper_to_Detail_AffineWarper } - - boxed_cast_descendant! { Detail_PlaneWarper, crate::stitching::Detail_PlaneWarperGpu, cv_detail_PlaneWarper_to_Detail_PlaneWarperGpu } - - boxed_cast_base! { Detail_PlaneWarper, crate::stitching::Detail_RotationWarper, cv_detail_PlaneWarper_to_Detail_RotationWarper } - - impl std::fmt::Debug for Detail_PlaneWarper { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_PlaneWarper") - .finish() - } - } - /// Constant methods for [crate::stitching::Detail_PlaneWarperGpu] pub trait Detail_PlaneWarperGpuTraitConst: crate::stitching::Detail_PlaneWarperTraitConst { fn as_raw_Detail_PlaneWarperGpu(&self) -> *const c_void; @@ -9663,20 +9742,17 @@ pub mod stitching { } - pub struct Detail_PlaneWarperGpu { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_PlaneWarperGpu } - - impl Drop for Detail_PlaneWarperGpu { + impl std::fmt::Debug for Detail_PlaneWarperGpu { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_PlaneWarperGpu_delete(self.as_raw_mut_Detail_PlaneWarperGpu()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_PlaneWarperGpu") + .finish() } } - unsafe impl Send for Detail_PlaneWarperGpu {} + boxed_cast_base! { Detail_PlaneWarperGpu, crate::stitching::Detail_PlaneWarper, cv_detail_PlaneWarperGpu_to_Detail_PlaneWarper } + + boxed_cast_base! { Detail_PlaneWarperGpu, crate::stitching::Detail_RotationWarper, cv_detail_PlaneWarperGpu_to_Detail_RotationWarper } impl crate::stitching::Detail_PlaneWarperTraitConst for Detail_PlaneWarperGpu { #[inline] fn as_raw_Detail_PlaneWarper(&self) -> *const c_void { self.as_raw() } @@ -9706,46 +9782,33 @@ pub mod stitching { #[inline] fn as_raw_mut_Detail_PlaneWarperGpu(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { Detail_PlaneWarperGpu, crate::stitching::Detail_PlaneWarperGpuTraitConst, as_raw_Detail_PlaneWarperGpu, crate::stitching::Detail_PlaneWarperGpuTrait, as_raw_mut_Detail_PlaneWarperGpu } - - impl Detail_PlaneWarperGpu { - /// ## C++ default parameters - /// * scale: 1.f - #[inline] - pub fn new(scale: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_PlaneWarperGpu_PlaneWarperGpu_float(scale, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_PlaneWarperGpu::opencv_from_extern(ret) }; - Ok(ret) - } + boxed_ref! { Detail_PlaneWarperGpu, crate::stitching::Detail_PlaneWarperGpuTraitConst, as_raw_Detail_PlaneWarperGpu, crate::stitching::Detail_PlaneWarperGpuTrait, as_raw_mut_Detail_PlaneWarperGpu } + + /// Base class for warping logic implementation. + pub struct Detail_ProjectorBase { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_ProjectorBase } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * scale: 1.f + impl Drop for Detail_ProjectorBase { #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_PlaneWarperGpu_PlaneWarperGpu(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_PlaneWarperGpu::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_ProjectorBase_delete(self.as_raw_mut_Detail_ProjectorBase()) }; } - } - boxed_cast_base! { Detail_PlaneWarperGpu, crate::stitching::Detail_PlaneWarper, cv_detail_PlaneWarperGpu_to_Detail_PlaneWarper } - - boxed_cast_base! { Detail_PlaneWarperGpu, crate::stitching::Detail_RotationWarper, cv_detail_PlaneWarperGpu_to_Detail_RotationWarper } + unsafe impl Send for Detail_ProjectorBase {} - impl std::fmt::Debug for Detail_PlaneWarperGpu { + impl Detail_ProjectorBase { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_PlaneWarperGpu") - .finish() + pub fn default() -> crate::stitching::Detail_ProjectorBase { + let ret = unsafe { sys::cv_detail_ProjectorBase_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_ProjectorBase::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::Detail_ProjectorBase] @@ -9872,39 +9935,12 @@ pub mod stitching { } - /// Base class for warping logic implementation. - pub struct Detail_ProjectorBase { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_ProjectorBase } - - impl Drop for Detail_ProjectorBase { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_ProjectorBase_delete(self.as_raw_mut_Detail_ProjectorBase()) }; - } - } - - unsafe impl Send for Detail_ProjectorBase {} - - impl crate::stitching::Detail_ProjectorBaseTraitConst for Detail_ProjectorBase { - #[inline] fn as_raw_Detail_ProjectorBase(&self) -> *const c_void { self.as_raw() } - } - - impl crate::stitching::Detail_ProjectorBaseTrait for Detail_ProjectorBase { - #[inline] fn as_raw_mut_Detail_ProjectorBase(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Detail_ProjectorBase, crate::stitching::Detail_ProjectorBaseTraitConst, as_raw_Detail_ProjectorBase, crate::stitching::Detail_ProjectorBaseTrait, as_raw_mut_Detail_ProjectorBase } - - impl Detail_ProjectorBase { - /// Creates a default instance of the class by calling the default constructor + impl Default for Detail_ProjectorBase { #[inline] + /// Forwards to infallible Self::default() fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_ProjectorBase_defaultNew_const()) } + Self::default() } - } impl Clone for Detail_ProjectorBase { @@ -9928,14 +9964,32 @@ pub mod stitching { } } - impl Default for Detail_ProjectorBase { + impl crate::stitching::Detail_ProjectorBaseTraitConst for Detail_ProjectorBase { + #[inline] fn as_raw_Detail_ProjectorBase(&self) -> *const c_void { self.as_raw() } + } + + impl crate::stitching::Detail_ProjectorBaseTrait for Detail_ProjectorBase { + #[inline] fn as_raw_mut_Detail_ProjectorBase(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Detail_ProjectorBase, crate::stitching::Detail_ProjectorBaseTraitConst, as_raw_Detail_ProjectorBase, crate::stitching::Detail_ProjectorBaseTrait, as_raw_mut_Detail_ProjectorBase } + + /// Rotation-only model image warper interface. + pub struct Detail_RotationWarper { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_RotationWarper } + + impl Drop for Detail_RotationWarper { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + fn drop(&mut self) { + unsafe { sys::cv_detail_RotationWarper_delete(self.as_raw_mut_Detail_RotationWarper()) }; } } + unsafe impl Send for Detail_RotationWarper {} + /// Constant methods for [crate::stitching::Detail_RotationWarper] pub trait Detail_RotationWarperTraitConst { fn as_raw_Detail_RotationWarper(&self) -> *const c_void; @@ -10083,22 +10137,14 @@ pub mod stitching { } - /// Rotation-only model image warper interface. - pub struct Detail_RotationWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_RotationWarper } - - impl Drop for Detail_RotationWarper { + impl std::fmt::Debug for Detail_RotationWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_RotationWarper_delete(self.as_raw_mut_Detail_RotationWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_RotationWarper") + .finish() } } - unsafe impl Send for Detail_RotationWarper {} - impl crate::stitching::Detail_RotationWarperTraitConst for Detail_RotationWarper { #[inline] fn as_raw_Detail_RotationWarper(&self) -> *const c_void { self.as_raw() } } @@ -10109,15 +10155,33 @@ pub mod stitching { boxed_ref! { Detail_RotationWarper, crate::stitching::Detail_RotationWarperTraitConst, as_raw_Detail_RotationWarper, crate::stitching::Detail_RotationWarperTrait, as_raw_mut_Detail_RotationWarper } - impl Detail_RotationWarper { + /// Base class for a seam estimator. + pub struct Detail_SeamFinder { + ptr: *mut c_void, } - impl std::fmt::Debug for Detail_RotationWarper { + opencv_type_boxed! { Detail_SeamFinder } + + impl Drop for Detail_SeamFinder { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_RotationWarper") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_detail_SeamFinder_delete(self.as_raw_mut_Detail_SeamFinder()) }; + } + } + + unsafe impl Send for Detail_SeamFinder {} + + impl Detail_SeamFinder { + #[inline] + pub fn create_default(typ: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_SeamFinder_createDefault_int(typ, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_SeamFinder] @@ -10147,21 +10211,25 @@ pub mod stitching { } - /// Base class for a seam estimator. - pub struct Detail_SeamFinder { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_SeamFinder } - - impl Drop for Detail_SeamFinder { + impl std::fmt::Debug for Detail_SeamFinder { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_SeamFinder_delete(self.as_raw_mut_Detail_SeamFinder()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_SeamFinder") + .finish() } } - unsafe impl Send for Detail_SeamFinder {} + boxed_cast_descendant! { Detail_SeamFinder, crate::stitching::Detail_DpSeamFinder, cv_detail_SeamFinder_to_Detail_DpSeamFinder } + + boxed_cast_descendant! { Detail_SeamFinder, crate::stitching::Detail_GraphCutSeamFinder, cv_detail_SeamFinder_to_Detail_GraphCutSeamFinder } + + boxed_cast_descendant! { Detail_SeamFinder, crate::stitching::Detail_GraphCutSeamFinderGpu, cv_detail_SeamFinder_to_Detail_GraphCutSeamFinderGpu } + + boxed_cast_descendant! { Detail_SeamFinder, crate::stitching::Detail_NoSeamFinder, cv_detail_SeamFinder_to_Detail_NoSeamFinder } + + boxed_cast_descendant! { Detail_SeamFinder, crate::stitching::Detail_PairwiseSeamFinder, cv_detail_SeamFinder_to_Detail_PairwiseSeamFinder } + + boxed_cast_descendant! { Detail_SeamFinder, crate::stitching::Detail_VoronoiSeamFinder, cv_detail_SeamFinder_to_Detail_VoronoiSeamFinder } impl crate::stitching::Detail_SeamFinderTraitConst for Detail_SeamFinder { #[inline] fn as_raw_Detail_SeamFinder(&self) -> *const c_void { self.as_raw() } @@ -10173,37 +10241,30 @@ pub mod stitching { boxed_ref! { Detail_SeamFinder, crate::stitching::Detail_SeamFinderTraitConst, as_raw_Detail_SeamFinder, crate::stitching::Detail_SeamFinderTrait, as_raw_mut_Detail_SeamFinder } - impl Detail_SeamFinder { - #[inline] - pub fn create_default(typ: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_SeamFinder_createDefault_int(typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + pub struct Detail_SphericalPortraitProjector { + ptr: *mut c_void, } - boxed_cast_descendant! { Detail_SeamFinder, crate::stitching::Detail_DpSeamFinder, cv_detail_SeamFinder_to_Detail_DpSeamFinder } - - boxed_cast_descendant! { Detail_SeamFinder, crate::stitching::Detail_GraphCutSeamFinder, cv_detail_SeamFinder_to_Detail_GraphCutSeamFinder } - - boxed_cast_descendant! { Detail_SeamFinder, crate::stitching::Detail_GraphCutSeamFinderGpu, cv_detail_SeamFinder_to_Detail_GraphCutSeamFinderGpu } - - boxed_cast_descendant! { Detail_SeamFinder, crate::stitching::Detail_NoSeamFinder, cv_detail_SeamFinder_to_Detail_NoSeamFinder } + opencv_type_boxed! { Detail_SphericalPortraitProjector } - boxed_cast_descendant! { Detail_SeamFinder, crate::stitching::Detail_PairwiseSeamFinder, cv_detail_SeamFinder_to_Detail_PairwiseSeamFinder } + impl Drop for Detail_SphericalPortraitProjector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_detail_SphericalPortraitProjector_delete(self.as_raw_mut_Detail_SphericalPortraitProjector()) }; + } + } - boxed_cast_descendant! { Detail_SeamFinder, crate::stitching::Detail_VoronoiSeamFinder, cv_detail_SeamFinder_to_Detail_VoronoiSeamFinder } + unsafe impl Send for Detail_SphericalPortraitProjector {} - impl std::fmt::Debug for Detail_SeamFinder { + impl Detail_SphericalPortraitProjector { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_SeamFinder") - .finish() + pub fn default() -> crate::stitching::Detail_SphericalPortraitProjector { + let ret = unsafe { sys::cv_detail_SphericalPortraitProjector_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_SphericalPortraitProjector::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::Detail_SphericalPortraitProjector] @@ -10236,20 +10297,29 @@ pub mod stitching { } - pub struct Detail_SphericalPortraitProjector { - ptr: *mut c_void, + impl Default for Detail_SphericalPortraitProjector { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_SphericalPortraitProjector } - - impl Drop for Detail_SphericalPortraitProjector { + impl std::fmt::Debug for Detail_SphericalPortraitProjector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_SphericalPortraitProjector_delete(self.as_raw_mut_Detail_SphericalPortraitProjector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_SphericalPortraitProjector") + .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) + .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) + .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) + .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) + .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) + .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) + .finish() } } - unsafe impl Send for Detail_SphericalPortraitProjector {} + boxed_cast_base! { Detail_SphericalPortraitProjector, crate::stitching::Detail_ProjectorBase, cv_detail_SphericalPortraitProjector_to_Detail_ProjectorBase } impl crate::stitching::Detail_ProjectorBaseTraitConst for Detail_SphericalPortraitProjector { #[inline] fn as_raw_Detail_ProjectorBase(&self) -> *const c_void { self.as_raw() } @@ -10271,37 +10341,32 @@ pub mod stitching { boxed_ref! { Detail_SphericalPortraitProjector, crate::stitching::Detail_SphericalPortraitProjectorTraitConst, as_raw_Detail_SphericalPortraitProjector, crate::stitching::Detail_SphericalPortraitProjectorTrait, as_raw_mut_Detail_SphericalPortraitProjector } - impl Detail_SphericalPortraitProjector { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_SphericalPortraitProjector_defaultNew_const()) } - } - + pub struct Detail_SphericalPortraitWarper { + ptr: *mut c_void, } - boxed_cast_base! { Detail_SphericalPortraitProjector, crate::stitching::Detail_ProjectorBase, cv_detail_SphericalPortraitProjector_to_Detail_ProjectorBase } + opencv_type_boxed! { Detail_SphericalPortraitWarper } - impl std::fmt::Debug for Detail_SphericalPortraitProjector { + impl Drop for Detail_SphericalPortraitWarper { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_SphericalPortraitProjector") - .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) - .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) - .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) - .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) - .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) - .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_detail_SphericalPortraitWarper_delete(self.as_raw_mut_Detail_SphericalPortraitWarper()) }; } } - impl Default for Detail_SphericalPortraitProjector { + unsafe impl Send for Detail_SphericalPortraitWarper {} + + impl Detail_SphericalPortraitWarper { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new(scale: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_SphericalPortraitWarper_SphericalPortraitWarper_float(scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_SphericalPortraitWarper::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_SphericalPortraitWarper] @@ -10316,20 +10381,15 @@ pub mod stitching { } - pub struct Detail_SphericalPortraitWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_SphericalPortraitWarper } - - impl Drop for Detail_SphericalPortraitWarper { + impl std::fmt::Debug for Detail_SphericalPortraitWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_SphericalPortraitWarper_delete(self.as_raw_mut_Detail_SphericalPortraitWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_SphericalPortraitWarper") + .finish() } } - unsafe impl Send for Detail_SphericalPortraitWarper {} + boxed_cast_base! { Detail_SphericalPortraitWarper, crate::stitching::Detail_RotationWarper, cv_detail_SphericalPortraitWarper_to_Detail_RotationWarper } impl crate::stitching::Detail_RotationWarperTraitConst for Detail_SphericalPortraitWarper { #[inline] fn as_raw_Detail_RotationWarper(&self) -> *const c_void { self.as_raw() } @@ -10351,27 +10411,30 @@ pub mod stitching { boxed_ref! { Detail_SphericalPortraitWarper, crate::stitching::Detail_SphericalPortraitWarperTraitConst, as_raw_Detail_SphericalPortraitWarper, crate::stitching::Detail_SphericalPortraitWarperTrait, as_raw_mut_Detail_SphericalPortraitWarper } - impl Detail_SphericalPortraitWarper { + pub struct Detail_SphericalProjector { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_SphericalProjector } + + impl Drop for Detail_SphericalProjector { #[inline] - pub fn new(scale: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_SphericalPortraitWarper_SphericalPortraitWarper_float(scale, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_SphericalPortraitWarper::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_SphericalProjector_delete(self.as_raw_mut_Detail_SphericalProjector()) }; } - } - boxed_cast_base! { Detail_SphericalPortraitWarper, crate::stitching::Detail_RotationWarper, cv_detail_SphericalPortraitWarper_to_Detail_RotationWarper } + unsafe impl Send for Detail_SphericalProjector {} - impl std::fmt::Debug for Detail_SphericalPortraitWarper { + impl Detail_SphericalProjector { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_SphericalPortraitWarper") - .finish() + pub fn default() -> crate::stitching::Detail_SphericalProjector { + let ret = unsafe { sys::cv_detail_SphericalProjector_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_SphericalProjector::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::Detail_SphericalProjector] @@ -10404,20 +10467,36 @@ pub mod stitching { } - pub struct Detail_SphericalProjector { - ptr: *mut c_void, + impl Default for Detail_SphericalProjector { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_SphericalProjector } + impl Clone for Detail_SphericalProjector { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_detail_SphericalProjector_implicitClone_const(self.as_raw_Detail_SphericalProjector())) } + } + } - impl Drop for Detail_SphericalProjector { + impl std::fmt::Debug for Detail_SphericalProjector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_SphericalProjector_delete(self.as_raw_mut_Detail_SphericalProjector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_SphericalProjector") + .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) + .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) + .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) + .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) + .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) + .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) + .finish() } } - unsafe impl Send for Detail_SphericalProjector {} + boxed_cast_base! { Detail_SphericalProjector, crate::stitching::Detail_ProjectorBase, cv_detail_SphericalProjector_to_Detail_ProjectorBase } impl crate::stitching::Detail_ProjectorBaseTraitConst for Detail_SphericalProjector { #[inline] fn as_raw_Detail_ProjectorBase(&self) -> *const c_void { self.as_raw() } @@ -10439,44 +10518,42 @@ pub mod stitching { boxed_ref! { Detail_SphericalProjector, crate::stitching::Detail_SphericalProjectorTraitConst, as_raw_Detail_SphericalProjector, crate::stitching::Detail_SphericalProjectorTrait, as_raw_mut_Detail_SphericalProjector } - impl Detail_SphericalProjector { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_SphericalProjector_defaultNew_const()) } - } - + /// Warper that maps an image onto the unit sphere located at the origin. + /// + /// Projects image onto unit sphere with origin at (0, 0, 0) and radius scale, measured in pixels. + /// A 360 panorama would therefore have a resulting width of 2 * scale * PI pixels. + /// Poles are located at (0, -1, 0) and (0, 1, 0) points. + pub struct Detail_SphericalWarper { + ptr: *mut c_void, } - impl Clone for Detail_SphericalProjector { + opencv_type_boxed! { Detail_SphericalWarper } + + impl Drop for Detail_SphericalWarper { #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_detail_SphericalProjector_implicitClone_const(self.as_raw_Detail_SphericalProjector())) } + fn drop(&mut self) { + unsafe { sys::cv_detail_SphericalWarper_delete(self.as_raw_mut_Detail_SphericalWarper()) }; } } - boxed_cast_base! { Detail_SphericalProjector, crate::stitching::Detail_ProjectorBase, cv_detail_SphericalProjector_to_Detail_ProjectorBase } + unsafe impl Send for Detail_SphericalWarper {} - impl std::fmt::Debug for Detail_SphericalProjector { + impl Detail_SphericalWarper { + /// Construct an instance of the spherical warper class. + /// + /// ## Parameters + /// * scale: Radius of the projected sphere, in pixels. An image spanning the + /// whole sphere will have a width of 2 * scale * PI pixels. #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_SphericalProjector") - .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) - .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) - .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) - .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) - .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) - .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) - .finish() + pub fn new(scale: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_SphericalWarper_SphericalWarper_float(scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_SphericalWarper::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for Detail_SphericalProjector { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } } /// Constant methods for [crate::stitching::Detail_SphericalWarper] @@ -10517,25 +10594,17 @@ pub mod stitching { } - /// Warper that maps an image onto the unit sphere located at the origin. - /// - /// Projects image onto unit sphere with origin at (0, 0, 0) and radius scale, measured in pixels. - /// A 360 panorama would therefore have a resulting width of 2 * scale * PI pixels. - /// Poles are located at (0, -1, 0) and (0, 1, 0) points. - pub struct Detail_SphericalWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_SphericalWarper } - - impl Drop for Detail_SphericalWarper { + impl std::fmt::Debug for Detail_SphericalWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_SphericalWarper_delete(self.as_raw_mut_Detail_SphericalWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_SphericalWarper") + .finish() } } - unsafe impl Send for Detail_SphericalWarper {} + boxed_cast_base! { Detail_SphericalWarper, crate::stitching::Detail_RotationWarper, cv_detail_SphericalWarper_to_Detail_RotationWarper } + + boxed_cast_descendant! { Detail_SphericalWarper, crate::stitching::Detail_SphericalWarperGpu, cv_detail_SphericalWarper_to_Detail_SphericalWarperGpu } impl crate::stitching::Detail_RotationWarperTraitConst for Detail_SphericalWarper { #[inline] fn as_raw_Detail_RotationWarper(&self) -> *const c_void { self.as_raw() } @@ -10557,34 +10626,32 @@ pub mod stitching { boxed_ref! { Detail_SphericalWarper, crate::stitching::Detail_SphericalWarperTraitConst, as_raw_Detail_SphericalWarper, crate::stitching::Detail_SphericalWarperTrait, as_raw_mut_Detail_SphericalWarper } - impl Detail_SphericalWarper { - /// Construct an instance of the spherical warper class. - /// - /// ## Parameters - /// * scale: Radius of the projected sphere, in pixels. An image spanning the - /// whole sphere will have a width of 2 * scale * PI pixels. + pub struct Detail_SphericalWarperGpu { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_SphericalWarperGpu } + + impl Drop for Detail_SphericalWarperGpu { #[inline] - pub fn new(scale: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_SphericalWarper_SphericalWarper_float(scale, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_SphericalWarper::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_SphericalWarperGpu_delete(self.as_raw_mut_Detail_SphericalWarperGpu()) }; } - } - boxed_cast_descendant! { Detail_SphericalWarper, crate::stitching::Detail_SphericalWarperGpu, cv_detail_SphericalWarper_to_Detail_SphericalWarperGpu } - - boxed_cast_base! { Detail_SphericalWarper, crate::stitching::Detail_RotationWarper, cv_detail_SphericalWarper_to_Detail_RotationWarper } + unsafe impl Send for Detail_SphericalWarperGpu {} - impl std::fmt::Debug for Detail_SphericalWarper { + impl Detail_SphericalWarperGpu { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_SphericalWarper") - .finish() + pub fn new(scale: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_SphericalWarperGpu_SphericalWarperGpu_float(scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_SphericalWarperGpu::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_SphericalWarperGpu] @@ -10647,20 +10714,17 @@ pub mod stitching { } - pub struct Detail_SphericalWarperGpu { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_SphericalWarperGpu } - - impl Drop for Detail_SphericalWarperGpu { + impl std::fmt::Debug for Detail_SphericalWarperGpu { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_SphericalWarperGpu_delete(self.as_raw_mut_Detail_SphericalWarperGpu()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_SphericalWarperGpu") + .finish() } } - unsafe impl Send for Detail_SphericalWarperGpu {} + boxed_cast_base! { Detail_SphericalWarperGpu, crate::stitching::Detail_RotationWarper, cv_detail_SphericalWarperGpu_to_Detail_RotationWarper } + + boxed_cast_base! { Detail_SphericalWarperGpu, crate::stitching::Detail_SphericalWarper, cv_detail_SphericalWarperGpu_to_Detail_SphericalWarper } impl crate::stitching::Detail_RotationWarperTraitConst for Detail_SphericalWarperGpu { #[inline] fn as_raw_Detail_RotationWarper(&self) -> *const c_void { self.as_raw() } @@ -10692,29 +10756,30 @@ pub mod stitching { boxed_ref! { Detail_SphericalWarperGpu, crate::stitching::Detail_SphericalWarperGpuTraitConst, as_raw_Detail_SphericalWarperGpu, crate::stitching::Detail_SphericalWarperGpuTrait, as_raw_mut_Detail_SphericalWarperGpu } - impl Detail_SphericalWarperGpu { + pub struct Detail_StereographicProjector { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_StereographicProjector } + + impl Drop for Detail_StereographicProjector { #[inline] - pub fn new(scale: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_SphericalWarperGpu_SphericalWarperGpu_float(scale, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_SphericalWarperGpu::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_StereographicProjector_delete(self.as_raw_mut_Detail_StereographicProjector()) }; } - } - boxed_cast_base! { Detail_SphericalWarperGpu, crate::stitching::Detail_RotationWarper, cv_detail_SphericalWarperGpu_to_Detail_RotationWarper } - - boxed_cast_base! { Detail_SphericalWarperGpu, crate::stitching::Detail_SphericalWarper, cv_detail_SphericalWarperGpu_to_Detail_SphericalWarper } + unsafe impl Send for Detail_StereographicProjector {} - impl std::fmt::Debug for Detail_SphericalWarperGpu { + impl Detail_StereographicProjector { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_SphericalWarperGpu") - .finish() + pub fn default() -> crate::stitching::Detail_StereographicProjector { + let ret = unsafe { sys::cv_detail_StereographicProjector_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_StereographicProjector::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::Detail_StereographicProjector] @@ -10747,20 +10812,29 @@ pub mod stitching { } - pub struct Detail_StereographicProjector { - ptr: *mut c_void, + impl Default for Detail_StereographicProjector { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_StereographicProjector } - - impl Drop for Detail_StereographicProjector { + impl std::fmt::Debug for Detail_StereographicProjector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_StereographicProjector_delete(self.as_raw_mut_Detail_StereographicProjector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_StereographicProjector") + .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) + .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) + .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) + .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) + .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) + .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) + .finish() } } - unsafe impl Send for Detail_StereographicProjector {} + boxed_cast_base! { Detail_StereographicProjector, crate::stitching::Detail_ProjectorBase, cv_detail_StereographicProjector_to_Detail_ProjectorBase } impl crate::stitching::Detail_ProjectorBaseTraitConst for Detail_StereographicProjector { #[inline] fn as_raw_Detail_ProjectorBase(&self) -> *const c_void { self.as_raw() } @@ -10782,37 +10856,32 @@ pub mod stitching { boxed_ref! { Detail_StereographicProjector, crate::stitching::Detail_StereographicProjectorTraitConst, as_raw_Detail_StereographicProjector, crate::stitching::Detail_StereographicProjectorTrait, as_raw_mut_Detail_StereographicProjector } - impl Detail_StereographicProjector { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_StereographicProjector_defaultNew_const()) } - } - + pub struct Detail_StereographicWarper { + ptr: *mut c_void, } - boxed_cast_base! { Detail_StereographicProjector, crate::stitching::Detail_ProjectorBase, cv_detail_StereographicProjector_to_Detail_ProjectorBase } + opencv_type_boxed! { Detail_StereographicWarper } - impl std::fmt::Debug for Detail_StereographicProjector { + impl Drop for Detail_StereographicWarper { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_StereographicProjector") - .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) - .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) - .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) - .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) - .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) - .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_detail_StereographicWarper_delete(self.as_raw_mut_Detail_StereographicWarper()) }; } } - impl Default for Detail_StereographicProjector { + unsafe impl Send for Detail_StereographicWarper {} + + impl Detail_StereographicWarper { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new(scale: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_StereographicWarper_StereographicWarper_float(scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_StereographicWarper::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_StereographicWarper] @@ -10827,20 +10896,15 @@ pub mod stitching { } - pub struct Detail_StereographicWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_StereographicWarper } - - impl Drop for Detail_StereographicWarper { + impl std::fmt::Debug for Detail_StereographicWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_StereographicWarper_delete(self.as_raw_mut_Detail_StereographicWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_StereographicWarper") + .finish() } } - unsafe impl Send for Detail_StereographicWarper {} + boxed_cast_base! { Detail_StereographicWarper, crate::stitching::Detail_RotationWarper, cv_detail_StereographicWarper_to_Detail_RotationWarper } impl crate::stitching::Detail_RotationWarperTraitConst for Detail_StereographicWarper { #[inline] fn as_raw_Detail_RotationWarper(&self) -> *const c_void { self.as_raw() } @@ -10862,27 +10926,30 @@ pub mod stitching { boxed_ref! { Detail_StereographicWarper, crate::stitching::Detail_StereographicWarperTraitConst, as_raw_Detail_StereographicWarper, crate::stitching::Detail_StereographicWarperTrait, as_raw_mut_Detail_StereographicWarper } - impl Detail_StereographicWarper { + pub struct Detail_TransverseMercatorProjector { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_TransverseMercatorProjector } + + impl Drop for Detail_TransverseMercatorProjector { #[inline] - pub fn new(scale: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_StereographicWarper_StereographicWarper_float(scale, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_StereographicWarper::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_TransverseMercatorProjector_delete(self.as_raw_mut_Detail_TransverseMercatorProjector()) }; } - } - boxed_cast_base! { Detail_StereographicWarper, crate::stitching::Detail_RotationWarper, cv_detail_StereographicWarper_to_Detail_RotationWarper } + unsafe impl Send for Detail_TransverseMercatorProjector {} - impl std::fmt::Debug for Detail_StereographicWarper { + impl Detail_TransverseMercatorProjector { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_StereographicWarper") - .finish() + pub fn default() -> crate::stitching::Detail_TransverseMercatorProjector { + let ret = unsafe { sys::cv_detail_TransverseMercatorProjector_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_TransverseMercatorProjector::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::Detail_TransverseMercatorProjector] @@ -10915,20 +10982,29 @@ pub mod stitching { } - pub struct Detail_TransverseMercatorProjector { - ptr: *mut c_void, + impl Default for Detail_TransverseMercatorProjector { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_TransverseMercatorProjector } - - impl Drop for Detail_TransverseMercatorProjector { + impl std::fmt::Debug for Detail_TransverseMercatorProjector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_TransverseMercatorProjector_delete(self.as_raw_mut_Detail_TransverseMercatorProjector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_TransverseMercatorProjector") + .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) + .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) + .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) + .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) + .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) + .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) + .finish() } } - unsafe impl Send for Detail_TransverseMercatorProjector {} + boxed_cast_base! { Detail_TransverseMercatorProjector, crate::stitching::Detail_ProjectorBase, cv_detail_TransverseMercatorProjector_to_Detail_ProjectorBase } impl crate::stitching::Detail_ProjectorBaseTraitConst for Detail_TransverseMercatorProjector { #[inline] fn as_raw_Detail_ProjectorBase(&self) -> *const c_void { self.as_raw() } @@ -10950,37 +11026,32 @@ pub mod stitching { boxed_ref! { Detail_TransverseMercatorProjector, crate::stitching::Detail_TransverseMercatorProjectorTraitConst, as_raw_Detail_TransverseMercatorProjector, crate::stitching::Detail_TransverseMercatorProjectorTrait, as_raw_mut_Detail_TransverseMercatorProjector } - impl Detail_TransverseMercatorProjector { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_TransverseMercatorProjector_defaultNew_const()) } - } - + pub struct Detail_TransverseMercatorWarper { + ptr: *mut c_void, } - boxed_cast_base! { Detail_TransverseMercatorProjector, crate::stitching::Detail_ProjectorBase, cv_detail_TransverseMercatorProjector_to_Detail_ProjectorBase } + opencv_type_boxed! { Detail_TransverseMercatorWarper } - impl std::fmt::Debug for Detail_TransverseMercatorProjector { + impl Drop for Detail_TransverseMercatorWarper { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_TransverseMercatorProjector") - .field("scale", &crate::stitching::Detail_ProjectorBaseTraitConst::scale(self)) - .field("k", &crate::stitching::Detail_ProjectorBaseTraitConst::k(self)) - .field("rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::rinv(self)) - .field("r_kinv", &crate::stitching::Detail_ProjectorBaseTraitConst::r_kinv(self)) - .field("k_rinv", &crate::stitching::Detail_ProjectorBaseTraitConst::k_rinv(self)) - .field("t", &crate::stitching::Detail_ProjectorBaseTraitConst::t(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_detail_TransverseMercatorWarper_delete(self.as_raw_mut_Detail_TransverseMercatorWarper()) }; } } - impl Default for Detail_TransverseMercatorProjector { + unsafe impl Send for Detail_TransverseMercatorWarper {} + + impl Detail_TransverseMercatorWarper { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new(scale: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_detail_TransverseMercatorWarper_TransverseMercatorWarper_float(scale, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::stitching::Detail_TransverseMercatorWarper::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::stitching::Detail_TransverseMercatorWarper] @@ -10995,20 +11066,15 @@ pub mod stitching { } - pub struct Detail_TransverseMercatorWarper { - ptr: *mut c_void, - } - - opencv_type_boxed! { Detail_TransverseMercatorWarper } - - impl Drop for Detail_TransverseMercatorWarper { + impl std::fmt::Debug for Detail_TransverseMercatorWarper { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_TransverseMercatorWarper_delete(self.as_raw_mut_Detail_TransverseMercatorWarper()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_TransverseMercatorWarper") + .finish() } } - unsafe impl Send for Detail_TransverseMercatorWarper {} + boxed_cast_base! { Detail_TransverseMercatorWarper, crate::stitching::Detail_RotationWarper, cv_detail_TransverseMercatorWarper_to_Detail_RotationWarper } impl crate::stitching::Detail_RotationWarperTraitConst for Detail_TransverseMercatorWarper { #[inline] fn as_raw_Detail_RotationWarper(&self) -> *const c_void { self.as_raw() } @@ -11030,27 +11096,31 @@ pub mod stitching { boxed_ref! { Detail_TransverseMercatorWarper, crate::stitching::Detail_TransverseMercatorWarperTraitConst, as_raw_Detail_TransverseMercatorWarper, crate::stitching::Detail_TransverseMercatorWarperTrait, as_raw_mut_Detail_TransverseMercatorWarper } - impl Detail_TransverseMercatorWarper { + /// Voronoi diagram-based seam estimator. + pub struct Detail_VoronoiSeamFinder { + ptr: *mut c_void, + } + + opencv_type_boxed! { Detail_VoronoiSeamFinder } + + impl Drop for Detail_VoronoiSeamFinder { #[inline] - pub fn new(scale: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_detail_TransverseMercatorWarper_TransverseMercatorWarper_float(scale, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::stitching::Detail_TransverseMercatorWarper::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_detail_VoronoiSeamFinder_delete(self.as_raw_mut_Detail_VoronoiSeamFinder()) }; } - } - boxed_cast_base! { Detail_TransverseMercatorWarper, crate::stitching::Detail_RotationWarper, cv_detail_TransverseMercatorWarper_to_Detail_RotationWarper } + unsafe impl Send for Detail_VoronoiSeamFinder {} - impl std::fmt::Debug for Detail_TransverseMercatorWarper { + impl Detail_VoronoiSeamFinder { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_TransverseMercatorWarper") - .finish() + pub fn default() -> crate::stitching::Detail_VoronoiSeamFinder { + let ret = unsafe { sys::cv_detail_VoronoiSeamFinder_defaultNew_const() }; + let ret = unsafe { crate::stitching::Detail_VoronoiSeamFinder::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::stitching::Detail_VoronoiSeamFinder] @@ -11083,21 +11153,25 @@ pub mod stitching { } - /// Voronoi diagram-based seam estimator. - pub struct Detail_VoronoiSeamFinder { - ptr: *mut c_void, + impl Default for Detail_VoronoiSeamFinder { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { Detail_VoronoiSeamFinder } - - impl Drop for Detail_VoronoiSeamFinder { + impl std::fmt::Debug for Detail_VoronoiSeamFinder { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_detail_VoronoiSeamFinder_delete(self.as_raw_mut_Detail_VoronoiSeamFinder()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Detail_VoronoiSeamFinder") + .finish() } } - unsafe impl Send for Detail_VoronoiSeamFinder {} + boxed_cast_base! { Detail_VoronoiSeamFinder, crate::stitching::Detail_PairwiseSeamFinder, cv_detail_VoronoiSeamFinder_to_Detail_PairwiseSeamFinder } + + boxed_cast_base! { Detail_VoronoiSeamFinder, crate::stitching::Detail_SeamFinder, cv_detail_VoronoiSeamFinder_to_Detail_SeamFinder } impl crate::stitching::Detail_PairwiseSeamFinderTraitConst for Detail_VoronoiSeamFinder { #[inline] fn as_raw_Detail_PairwiseSeamFinder(&self) -> *const c_void { self.as_raw() } @@ -11129,32 +11203,4 @@ pub mod stitching { boxed_ref! { Detail_VoronoiSeamFinder, crate::stitching::Detail_VoronoiSeamFinderTraitConst, as_raw_Detail_VoronoiSeamFinder, crate::stitching::Detail_VoronoiSeamFinderTrait, as_raw_mut_Detail_VoronoiSeamFinder } - impl Detail_VoronoiSeamFinder { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_detail_VoronoiSeamFinder_defaultNew_const()) } - } - - } - - boxed_cast_base! { Detail_VoronoiSeamFinder, crate::stitching::Detail_PairwiseSeamFinder, cv_detail_VoronoiSeamFinder_to_Detail_PairwiseSeamFinder } - - boxed_cast_base! { Detail_VoronoiSeamFinder, crate::stitching::Detail_SeamFinder, cv_detail_VoronoiSeamFinder_to_Detail_SeamFinder } - - impl std::fmt::Debug for Detail_VoronoiSeamFinder { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Detail_VoronoiSeamFinder") - .finish() - } - } - - impl Default for Detail_VoronoiSeamFinder { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } } diff --git a/docs/structured_light.rs b/docs/structured_light.rs index 418226d1d..1f9be68b3 100644 --- a/docs/structured_light.rs +++ b/docs/structured_light.rs @@ -27,6 +27,80 @@ pub mod structured_light { pub const FAPS: i32 = 2; pub const FTP: i32 = 0; pub const PSP: i32 = 1; + /// Class implementing the Gray-code pattern, based on [UNDERWORLD](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_UNDERWORLD). + /// + /// The generation of the pattern images is performed with Gray encoding using the traditional white and black colors. + /// + /// The information about the two image axes x, y is encoded separately into two different pattern sequences. + /// A projector P with resolution (P_res_x, P_res_y) will result in Ncols = log 2 (P_res_x) encoded pattern images representing the columns, and + /// in Nrows = log 2 (P_res_y) encoded pattern images representing the rows. + /// For example a projector with resolution 1024x768 will result in Ncols = 10 and Nrows = 10. + /// + /// However, the generated pattern sequence consists of both regular color and color-inverted images: inverted pattern images are images + /// with the same structure as the original but with inverted colors. + /// This provides an effective method for easily determining the intensity value of each pixel when it is lit (highest value) and + /// when it is not lit (lowest value). So for a a projector with resolution 1024x768, the number of pattern images will be Ncols * 2 + Nrows * 2 = 40. + pub struct GrayCodePattern { + ptr: *mut c_void, + } + + opencv_type_boxed! { GrayCodePattern } + + impl Drop for GrayCodePattern { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_structured_light_GrayCodePattern_delete(self.as_raw_mut_GrayCodePattern()) }; + } + } + + unsafe impl Send for GrayCodePattern {} + + impl GrayCodePattern { + /// Constructor + /// ## Parameters + /// * parameters: GrayCodePattern parameters GrayCodePattern::Params: the width and the height of the projector. + /// + /// ## C++ default parameters + /// * parameters: GrayCodePattern::Params() + #[inline] + pub fn create(parameters: &impl crate::structured_light::GrayCodePattern_ParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_structured_light_GrayCodePattern_create_const_ParamsR(parameters.as_raw_GrayCodePattern_Params(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Constructor + /// ## Parameters + /// * parameters: GrayCodePattern parameters GrayCodePattern::Params: the width and the height of the projector. + /// + /// ## Note + /// This alternative version of [GrayCodePattern::create] function uses the following default values for its arguments: + /// * parameters: GrayCodePattern::Params() + #[inline] + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_structured_light_GrayCodePattern_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + #[inline] + pub fn create_1(width: i32, height: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_structured_light_GrayCodePattern_create_int_int(width, height, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::structured_light::GrayCodePattern] pub trait GrayCodePatternTraitConst: crate::structured_light::StructuredLightPatternTraitConst { fn as_raw_GrayCodePattern(&self) -> *const c_void; @@ -122,33 +196,17 @@ pub mod structured_light { } - /// Class implementing the Gray-code pattern, based on [UNDERWORLD](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_UNDERWORLD). - /// - /// The generation of the pattern images is performed with Gray encoding using the traditional white and black colors. - /// - /// The information about the two image axes x, y is encoded separately into two different pattern sequences. - /// A projector P with resolution (P_res_x, P_res_y) will result in Ncols = log 2 (P_res_x) encoded pattern images representing the columns, and - /// in Nrows = log 2 (P_res_y) encoded pattern images representing the rows. - /// For example a projector with resolution 1024x768 will result in Ncols = 10 and Nrows = 10. - /// - /// However, the generated pattern sequence consists of both regular color and color-inverted images: inverted pattern images are images - /// with the same structure as the original but with inverted colors. - /// This provides an effective method for easily determining the intensity value of each pixel when it is lit (highest value) and - /// when it is not lit (lowest value). So for a a projector with resolution 1024x768, the number of pattern images will be Ncols * 2 + Nrows * 2 = 40. - pub struct GrayCodePattern { - ptr: *mut c_void, - } - - opencv_type_boxed! { GrayCodePattern } - - impl Drop for GrayCodePattern { + impl std::fmt::Debug for GrayCodePattern { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_structured_light_GrayCodePattern_delete(self.as_raw_mut_GrayCodePattern()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GrayCodePattern") + .finish() } } - unsafe impl Send for GrayCodePattern {} + boxed_cast_base! { GrayCodePattern, core::Algorithm, cv_structured_light_GrayCodePattern_to_Algorithm } + + boxed_cast_base! { GrayCodePattern, crate::structured_light::StructuredLightPattern, cv_structured_light_GrayCodePattern_to_StructuredLightPattern } impl core::AlgorithmTraitConst for GrayCodePattern { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -180,64 +238,38 @@ pub mod structured_light { boxed_ref! { GrayCodePattern, crate::structured_light::GrayCodePatternTraitConst, as_raw_GrayCodePattern, crate::structured_light::GrayCodePatternTrait, as_raw_mut_GrayCodePattern } - impl GrayCodePattern { - /// Constructor - /// ## Parameters - /// * parameters: GrayCodePattern parameters GrayCodePattern::Params: the width and the height of the projector. - /// - /// ## C++ default parameters - /// * parameters: GrayCodePattern::Params() - #[inline] - pub fn create(parameters: &impl crate::structured_light::GrayCodePattern_ParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_structured_light_GrayCodePattern_create_const_ParamsR(parameters.as_raw_GrayCodePattern_Params(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } + /// Parameters of StructuredLightPattern constructor. + /// ## Parameters + /// * width: Projector's width. Default value is 1024. + /// * height: Projector's height. Default value is 768. + pub struct GrayCodePattern_Params { + ptr: *mut c_void, + } - /// Constructor - /// ## Parameters - /// * parameters: GrayCodePattern parameters GrayCodePattern::Params: the width and the height of the projector. - /// - /// ## Note - /// This alternative version of [GrayCodePattern::create] function uses the following default values for its arguments: - /// * parameters: GrayCodePattern::Params() + opencv_type_boxed! { GrayCodePattern_Params } + + impl Drop for GrayCodePattern_Params { #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_structured_light_GrayCodePattern_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_structured_light_GrayCodePattern_Params_delete(self.as_raw_mut_GrayCodePattern_Params()) }; } + } + + unsafe impl Send for GrayCodePattern_Params {} + impl GrayCodePattern_Params { #[inline] - pub fn create_1(width: i32, height: i32) -> Result> { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_structured_light_GrayCodePattern_create_int_int(width, height, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_structured_light_GrayCodePattern_Params_Params(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::structured_light::GrayCodePattern_Params::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { GrayCodePattern, core::Algorithm, cv_structured_light_GrayCodePattern_to_Algorithm } - - boxed_cast_base! { GrayCodePattern, crate::structured_light::StructuredLightPattern, cv_structured_light_GrayCodePattern_to_StructuredLightPattern } - - impl std::fmt::Debug for GrayCodePattern { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GrayCodePattern") - .finish() - } - } - /// Constant methods for [crate::structured_light::GrayCodePattern_Params] pub trait GrayCodePattern_ParamsTraitConst { fn as_raw_GrayCodePattern_Params(&self) -> *const c_void; @@ -274,25 +306,16 @@ pub mod structured_light { } - /// Parameters of StructuredLightPattern constructor. - /// ## Parameters - /// * width: Projector's width. Default value is 1024. - /// * height: Projector's height. Default value is 768. - pub struct GrayCodePattern_Params { - ptr: *mut c_void, - } - - opencv_type_boxed! { GrayCodePattern_Params } - - impl Drop for GrayCodePattern_Params { + impl std::fmt::Debug for GrayCodePattern_Params { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_structured_light_GrayCodePattern_Params_delete(self.as_raw_mut_GrayCodePattern_Params()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GrayCodePattern_Params") + .field("width", &crate::structured_light::GrayCodePattern_ParamsTraitConst::width(self)) + .field("height", &crate::structured_light::GrayCodePattern_ParamsTraitConst::height(self)) + .finish() } } - unsafe impl Send for GrayCodePattern_Params {} - impl crate::structured_light::GrayCodePattern_ParamsTraitConst for GrayCodePattern_Params { #[inline] fn as_raw_GrayCodePattern_Params(&self) -> *const c_void { self.as_raw() } } @@ -303,27 +326,59 @@ pub mod structured_light { boxed_ref! { GrayCodePattern_Params, crate::structured_light::GrayCodePattern_ParamsTraitConst, as_raw_GrayCodePattern_Params, crate::structured_light::GrayCodePattern_ParamsTrait, as_raw_mut_GrayCodePattern_Params } - impl GrayCodePattern_Params { + /// Class implementing Fourier transform profilometry (FTP) , phase-shifting profilometry (PSP) + /// and Fourier-assisted phase-shifting profilometry (FAPS) based on [faps](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_faps). + /// + /// This class generates sinusoidal patterns that can be used with FTP, PSP and FAPS. + pub struct SinusoidalPattern { + ptr: *mut c_void, + } + + opencv_type_boxed! { SinusoidalPattern } + + impl Drop for SinusoidalPattern { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_structured_light_SinusoidalPattern_delete(self.as_raw_mut_SinusoidalPattern()) }; + } + } + + unsafe impl Send for SinusoidalPattern {} + + impl SinusoidalPattern { + /// Constructor. + /// ## Parameters + /// * parameters: SinusoidalPattern parameters SinusoidalPattern::Params: width, height of the projector and patterns parameters. + /// + /// ## C++ default parameters + /// * parameters: makePtr() + #[inline] + pub fn create(mut parameters: core::Ptr) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_structured_light_GrayCodePattern_Params_Params(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_structured_light_SinusoidalPattern_create_PtrLParamsG(parameters.as_raw_mut_PtrOfSinusoidalPattern_Params(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::structured_light::GrayCodePattern_Params::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - } - - impl std::fmt::Debug for GrayCodePattern_Params { + /// Constructor. + /// ## Parameters + /// * parameters: SinusoidalPattern parameters SinusoidalPattern::Params: width, height of the projector and patterns parameters. + /// + /// ## Note + /// This alternative version of [SinusoidalPattern::create] function uses the following default values for its arguments: + /// * parameters: makePtr() #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GrayCodePattern_Params") - .field("width", &crate::structured_light::GrayCodePattern_ParamsTraitConst::width(self)) - .field("height", &crate::structured_light::GrayCodePattern_ParamsTraitConst::height(self)) - .finish() + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_structured_light_SinusoidalPattern_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::structured_light::SinusoidalPattern] @@ -459,24 +514,17 @@ pub mod structured_light { } - /// Class implementing Fourier transform profilometry (FTP) , phase-shifting profilometry (PSP) - /// and Fourier-assisted phase-shifting profilometry (FAPS) based on [faps](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_faps). - /// - /// This class generates sinusoidal patterns that can be used with FTP, PSP and FAPS. - pub struct SinusoidalPattern { - ptr: *mut c_void, - } - - opencv_type_boxed! { SinusoidalPattern } - - impl Drop for SinusoidalPattern { + impl std::fmt::Debug for SinusoidalPattern { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_structured_light_SinusoidalPattern_delete(self.as_raw_mut_SinusoidalPattern()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SinusoidalPattern") + .finish() } } - unsafe impl Send for SinusoidalPattern {} + boxed_cast_base! { SinusoidalPattern, core::Algorithm, cv_structured_light_SinusoidalPattern_to_Algorithm } + + boxed_cast_base! { SinusoidalPattern, crate::structured_light::StructuredLightPattern, cv_structured_light_SinusoidalPattern_to_StructuredLightPattern } impl core::AlgorithmTraitConst for SinusoidalPattern { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -508,54 +556,44 @@ pub mod structured_light { boxed_ref! { SinusoidalPattern, crate::structured_light::SinusoidalPatternTraitConst, as_raw_SinusoidalPattern, crate::structured_light::SinusoidalPatternTrait, as_raw_mut_SinusoidalPattern } - impl SinusoidalPattern { - /// Constructor. - /// ## Parameters - /// * parameters: SinusoidalPattern parameters SinusoidalPattern::Params: width, height of the projector and patterns parameters. - /// - /// ## C++ default parameters - /// * parameters: makePtr() + /// Parameters of SinusoidalPattern constructor + /// ## Parameters + /// * width: Projector's width. + /// * height: Projector's height. + /// * nbrOfPeriods: Number of period along the patterns direction. + /// * shiftValue: Phase shift between two consecutive patterns. + /// * methodId: Allow to choose between FTP, PSP and FAPS. + /// * nbrOfPixelsBetweenMarkers: Number of pixels between two consecutive markers on the same row. + /// * setMarkers: Allow to set markers on the patterns. + /// * markersLocation: vector used to store markers location on the patterns. + pub struct SinusoidalPattern_Params { + ptr: *mut c_void, + } + + opencv_type_boxed! { SinusoidalPattern_Params } + + impl Drop for SinusoidalPattern_Params { #[inline] - pub fn create(mut parameters: core::Ptr) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_structured_light_SinusoidalPattern_create_PtrLParamsG(parameters.as_raw_mut_PtrOfSinusoidalPattern_Params(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_structured_light_SinusoidalPattern_Params_delete(self.as_raw_mut_SinusoidalPattern_Params()) }; } + } - /// Constructor. - /// ## Parameters - /// * parameters: SinusoidalPattern parameters SinusoidalPattern::Params: width, height of the projector and patterns parameters. - /// - /// ## Note - /// This alternative version of [SinusoidalPattern::create] function uses the following default values for its arguments: - /// * parameters: makePtr() + unsafe impl Send for SinusoidalPattern_Params {} + + impl SinusoidalPattern_Params { #[inline] - pub fn create_def() -> Result> { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_structured_light_SinusoidalPattern_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_structured_light_SinusoidalPattern_Params_Params(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::structured_light::SinusoidalPattern_Params::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { SinusoidalPattern, core::Algorithm, cv_structured_light_SinusoidalPattern_to_Algorithm } - - boxed_cast_base! { SinusoidalPattern, crate::structured_light::StructuredLightPattern, cv_structured_light_SinusoidalPattern_to_StructuredLightPattern } - - impl std::fmt::Debug for SinusoidalPattern { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SinusoidalPattern") - .finish() - } - } - /// Constant methods for [crate::structured_light::SinusoidalPattern_Params] pub trait SinusoidalPattern_ParamsTraitConst { fn as_raw_SinusoidalPattern_Params(&self) -> *const c_void; @@ -677,31 +715,23 @@ pub mod structured_light { } - /// Parameters of SinusoidalPattern constructor - /// ## Parameters - /// * width: Projector's width. - /// * height: Projector's height. - /// * nbrOfPeriods: Number of period along the patterns direction. - /// * shiftValue: Phase shift between two consecutive patterns. - /// * methodId: Allow to choose between FTP, PSP and FAPS. - /// * nbrOfPixelsBetweenMarkers: Number of pixels between two consecutive markers on the same row. - /// * setMarkers: Allow to set markers on the patterns. - /// * markersLocation: vector used to store markers location on the patterns. - pub struct SinusoidalPattern_Params { - ptr: *mut c_void, - } - - opencv_type_boxed! { SinusoidalPattern_Params } - - impl Drop for SinusoidalPattern_Params { + impl std::fmt::Debug for SinusoidalPattern_Params { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_structured_light_SinusoidalPattern_Params_delete(self.as_raw_mut_SinusoidalPattern_Params()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SinusoidalPattern_Params") + .field("width", &crate::structured_light::SinusoidalPattern_ParamsTraitConst::width(self)) + .field("height", &crate::structured_light::SinusoidalPattern_ParamsTraitConst::height(self)) + .field("nbr_of_periods", &crate::structured_light::SinusoidalPattern_ParamsTraitConst::nbr_of_periods(self)) + .field("shift_value", &crate::structured_light::SinusoidalPattern_ParamsTraitConst::shift_value(self)) + .field("method_id", &crate::structured_light::SinusoidalPattern_ParamsTraitConst::method_id(self)) + .field("nbr_of_pixels_between_markers", &crate::structured_light::SinusoidalPattern_ParamsTraitConst::nbr_of_pixels_between_markers(self)) + .field("horizontal", &crate::structured_light::SinusoidalPattern_ParamsTraitConst::horizontal(self)) + .field("set_markers", &crate::structured_light::SinusoidalPattern_ParamsTraitConst::set_markers(self)) + .field("markers_location", &crate::structured_light::SinusoidalPattern_ParamsTraitConst::markers_location(self)) + .finish() } } - unsafe impl Send for SinusoidalPattern_Params {} - impl crate::structured_light::SinusoidalPattern_ParamsTraitConst for SinusoidalPattern_Params { #[inline] fn as_raw_SinusoidalPattern_Params(&self) -> *const c_void { self.as_raw() } } @@ -712,36 +742,22 @@ pub mod structured_light { boxed_ref! { SinusoidalPattern_Params, crate::structured_light::SinusoidalPattern_ParamsTraitConst, as_raw_SinusoidalPattern_Params, crate::structured_light::SinusoidalPattern_ParamsTrait, as_raw_mut_SinusoidalPattern_Params } - impl SinusoidalPattern_Params { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_structured_light_SinusoidalPattern_Params_Params(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::structured_light::SinusoidalPattern_Params::opencv_from_extern(ret) }; - Ok(ret) - } - + /// Abstract base class for generating and decoding structured light patterns. + pub struct StructuredLightPattern { + ptr: *mut c_void, } - impl std::fmt::Debug for SinusoidalPattern_Params { + opencv_type_boxed! { StructuredLightPattern } + + impl Drop for StructuredLightPattern { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SinusoidalPattern_Params") - .field("width", &crate::structured_light::SinusoidalPattern_ParamsTraitConst::width(self)) - .field("height", &crate::structured_light::SinusoidalPattern_ParamsTraitConst::height(self)) - .field("nbr_of_periods", &crate::structured_light::SinusoidalPattern_ParamsTraitConst::nbr_of_periods(self)) - .field("shift_value", &crate::structured_light::SinusoidalPattern_ParamsTraitConst::shift_value(self)) - .field("method_id", &crate::structured_light::SinusoidalPattern_ParamsTraitConst::method_id(self)) - .field("nbr_of_pixels_between_markers", &crate::structured_light::SinusoidalPattern_ParamsTraitConst::nbr_of_pixels_between_markers(self)) - .field("horizontal", &crate::structured_light::SinusoidalPattern_ParamsTraitConst::horizontal(self)) - .field("set_markers", &crate::structured_light::SinusoidalPattern_ParamsTraitConst::set_markers(self)) - .field("markers_location", &crate::structured_light::SinusoidalPattern_ParamsTraitConst::markers_location(self)) - .finish() + fn drop(&mut self) { + unsafe { sys::cv_structured_light_StructuredLightPattern_delete(self.as_raw_mut_StructuredLightPattern()) }; } } + unsafe impl Send for StructuredLightPattern {} + /// Constant methods for [crate::structured_light::StructuredLightPattern] pub trait StructuredLightPatternTraitConst: core::AlgorithmTraitConst { fn as_raw_StructuredLightPattern(&self) -> *const c_void; @@ -821,21 +837,19 @@ pub mod structured_light { } - /// Abstract base class for generating and decoding structured light patterns. - pub struct StructuredLightPattern { - ptr: *mut c_void, - } - - opencv_type_boxed! { StructuredLightPattern } - - impl Drop for StructuredLightPattern { + impl std::fmt::Debug for StructuredLightPattern { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_structured_light_StructuredLightPattern_delete(self.as_raw_mut_StructuredLightPattern()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("StructuredLightPattern") + .finish() } } - unsafe impl Send for StructuredLightPattern {} + boxed_cast_base! { StructuredLightPattern, core::Algorithm, cv_structured_light_StructuredLightPattern_to_Algorithm } + + boxed_cast_descendant! { StructuredLightPattern, crate::structured_light::GrayCodePattern, cv_structured_light_StructuredLightPattern_to_GrayCodePattern } + + boxed_cast_descendant! { StructuredLightPattern, crate::structured_light::SinusoidalPattern, cv_structured_light_StructuredLightPattern_to_SinusoidalPattern } impl core::AlgorithmTraitConst for StructuredLightPattern { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -857,20 +871,4 @@ pub mod structured_light { boxed_ref! { StructuredLightPattern, crate::structured_light::StructuredLightPatternTraitConst, as_raw_StructuredLightPattern, crate::structured_light::StructuredLightPatternTrait, as_raw_mut_StructuredLightPattern } - impl StructuredLightPattern { - } - - boxed_cast_descendant! { StructuredLightPattern, crate::structured_light::GrayCodePattern, cv_structured_light_StructuredLightPattern_to_GrayCodePattern } - - boxed_cast_descendant! { StructuredLightPattern, crate::structured_light::SinusoidalPattern, cv_structured_light_StructuredLightPattern_to_SinusoidalPattern } - - boxed_cast_base! { StructuredLightPattern, core::Algorithm, cv_structured_light_StructuredLightPattern_to_Algorithm } - - impl std::fmt::Debug for StructuredLightPattern { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("StructuredLightPattern") - .finish() - } - } } diff --git a/docs/superres.rs b/docs/superres.rs index fc56e3890..eda0ed479 100644 --- a/docs/superres.rs +++ b/docs/superres.rs @@ -165,6 +165,21 @@ pub mod superres { Ok(ret) } + pub struct SuperRes_BroxOpticalFlow { + ptr: *mut c_void, + } + + opencv_type_boxed! { SuperRes_BroxOpticalFlow } + + impl Drop for SuperRes_BroxOpticalFlow { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_superres_BroxOpticalFlow_delete(self.as_raw_mut_SuperRes_BroxOpticalFlow()) }; + } + } + + unsafe impl Send for SuperRes_BroxOpticalFlow {} + /// Constant methods for [crate::superres::SuperRes_BroxOpticalFlow] pub trait SuperRes_BroxOpticalFlowTraitConst: crate::superres::SuperRes_DenseOpticalFlowExtTraitConst { fn as_raw_SuperRes_BroxOpticalFlow(&self) -> *const c_void; @@ -321,20 +336,17 @@ pub mod superres { } - pub struct SuperRes_BroxOpticalFlow { - ptr: *mut c_void, - } - - opencv_type_boxed! { SuperRes_BroxOpticalFlow } - - impl Drop for SuperRes_BroxOpticalFlow { + impl std::fmt::Debug for SuperRes_BroxOpticalFlow { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_superres_BroxOpticalFlow_delete(self.as_raw_mut_SuperRes_BroxOpticalFlow()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SuperRes_BroxOpticalFlow") + .finish() } } - unsafe impl Send for SuperRes_BroxOpticalFlow {} + boxed_cast_base! { SuperRes_BroxOpticalFlow, core::Algorithm, cv_superres_BroxOpticalFlow_to_Algorithm } + + boxed_cast_base! { SuperRes_BroxOpticalFlow, crate::superres::SuperRes_DenseOpticalFlowExt, cv_superres_BroxOpticalFlow_to_SuperRes_DenseOpticalFlowExt } impl core::AlgorithmTraitConst for SuperRes_BroxOpticalFlow { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -366,21 +378,21 @@ pub mod superres { boxed_ref! { SuperRes_BroxOpticalFlow, crate::superres::SuperRes_BroxOpticalFlowTraitConst, as_raw_SuperRes_BroxOpticalFlow, crate::superres::SuperRes_BroxOpticalFlowTrait, as_raw_mut_SuperRes_BroxOpticalFlow } - impl SuperRes_BroxOpticalFlow { + pub struct SuperRes_DenseOpticalFlowExt { + ptr: *mut c_void, } - boxed_cast_base! { SuperRes_BroxOpticalFlow, core::Algorithm, cv_superres_BroxOpticalFlow_to_Algorithm } - - boxed_cast_base! { SuperRes_BroxOpticalFlow, crate::superres::SuperRes_DenseOpticalFlowExt, cv_superres_BroxOpticalFlow_to_SuperRes_DenseOpticalFlowExt } + opencv_type_boxed! { SuperRes_DenseOpticalFlowExt } - impl std::fmt::Debug for SuperRes_BroxOpticalFlow { + impl Drop for SuperRes_DenseOpticalFlowExt { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SuperRes_BroxOpticalFlow") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_superres_DenseOpticalFlowExt_delete(self.as_raw_mut_SuperRes_DenseOpticalFlowExt()) }; } } + unsafe impl Send for SuperRes_DenseOpticalFlowExt {} + /// Constant methods for [crate::superres::SuperRes_DenseOpticalFlowExt] pub trait SuperRes_DenseOpticalFlowExtTraitConst: core::AlgorithmTraitConst { fn as_raw_SuperRes_DenseOpticalFlowExt(&self) -> *const c_void; @@ -432,20 +444,23 @@ pub mod superres { } - pub struct SuperRes_DenseOpticalFlowExt { - ptr: *mut c_void, - } - - opencv_type_boxed! { SuperRes_DenseOpticalFlowExt } - - impl Drop for SuperRes_DenseOpticalFlowExt { + impl std::fmt::Debug for SuperRes_DenseOpticalFlowExt { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_superres_DenseOpticalFlowExt_delete(self.as_raw_mut_SuperRes_DenseOpticalFlowExt()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SuperRes_DenseOpticalFlowExt") + .finish() } } - unsafe impl Send for SuperRes_DenseOpticalFlowExt {} + boxed_cast_base! { SuperRes_DenseOpticalFlowExt, core::Algorithm, cv_superres_DenseOpticalFlowExt_to_Algorithm } + + boxed_cast_descendant! { SuperRes_DenseOpticalFlowExt, crate::superres::SuperRes_BroxOpticalFlow, cv_superres_DenseOpticalFlowExt_to_SuperRes_BroxOpticalFlow } + + boxed_cast_descendant! { SuperRes_DenseOpticalFlowExt, crate::superres::SuperRes_DualTVL1OpticalFlow, cv_superres_DenseOpticalFlowExt_to_SuperRes_DualTVL1OpticalFlow } + + boxed_cast_descendant! { SuperRes_DenseOpticalFlowExt, crate::superres::SuperRes_FarnebackOpticalFlow, cv_superres_DenseOpticalFlowExt_to_SuperRes_FarnebackOpticalFlow } + + boxed_cast_descendant! { SuperRes_DenseOpticalFlowExt, crate::superres::SuperRes_PyrLKOpticalFlow, cv_superres_DenseOpticalFlowExt_to_SuperRes_PyrLKOpticalFlow } impl core::AlgorithmTraitConst for SuperRes_DenseOpticalFlowExt { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -467,27 +482,21 @@ pub mod superres { boxed_ref! { SuperRes_DenseOpticalFlowExt, crate::superres::SuperRes_DenseOpticalFlowExtTraitConst, as_raw_SuperRes_DenseOpticalFlowExt, crate::superres::SuperRes_DenseOpticalFlowExtTrait, as_raw_mut_SuperRes_DenseOpticalFlowExt } - impl SuperRes_DenseOpticalFlowExt { + pub struct SuperRes_DualTVL1OpticalFlow { + ptr: *mut c_void, } - boxed_cast_descendant! { SuperRes_DenseOpticalFlowExt, crate::superres::SuperRes_BroxOpticalFlow, cv_superres_DenseOpticalFlowExt_to_SuperRes_BroxOpticalFlow } - - boxed_cast_descendant! { SuperRes_DenseOpticalFlowExt, crate::superres::SuperRes_DualTVL1OpticalFlow, cv_superres_DenseOpticalFlowExt_to_SuperRes_DualTVL1OpticalFlow } - - boxed_cast_descendant! { SuperRes_DenseOpticalFlowExt, crate::superres::SuperRes_FarnebackOpticalFlow, cv_superres_DenseOpticalFlowExt_to_SuperRes_FarnebackOpticalFlow } - - boxed_cast_descendant! { SuperRes_DenseOpticalFlowExt, crate::superres::SuperRes_PyrLKOpticalFlow, cv_superres_DenseOpticalFlowExt_to_SuperRes_PyrLKOpticalFlow } - - boxed_cast_base! { SuperRes_DenseOpticalFlowExt, core::Algorithm, cv_superres_DenseOpticalFlowExt_to_Algorithm } + opencv_type_boxed! { SuperRes_DualTVL1OpticalFlow } - impl std::fmt::Debug for SuperRes_DenseOpticalFlowExt { + impl Drop for SuperRes_DualTVL1OpticalFlow { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SuperRes_DenseOpticalFlowExt") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_superres_DualTVL1OpticalFlow_delete(self.as_raw_mut_SuperRes_DualTVL1OpticalFlow()) }; } } + unsafe impl Send for SuperRes_DualTVL1OpticalFlow {} + /// Constant methods for [crate::superres::SuperRes_DualTVL1OpticalFlow] pub trait SuperRes_DualTVL1OpticalFlowTraitConst: crate::superres::SuperRes_DenseOpticalFlowExtTraitConst { fn as_raw_SuperRes_DualTVL1OpticalFlow(&self) -> *const c_void; @@ -676,20 +685,17 @@ pub mod superres { } - pub struct SuperRes_DualTVL1OpticalFlow { - ptr: *mut c_void, - } - - opencv_type_boxed! { SuperRes_DualTVL1OpticalFlow } - - impl Drop for SuperRes_DualTVL1OpticalFlow { + impl std::fmt::Debug for SuperRes_DualTVL1OpticalFlow { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_superres_DualTVL1OpticalFlow_delete(self.as_raw_mut_SuperRes_DualTVL1OpticalFlow()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SuperRes_DualTVL1OpticalFlow") + .finish() } } - unsafe impl Send for SuperRes_DualTVL1OpticalFlow {} + boxed_cast_base! { SuperRes_DualTVL1OpticalFlow, core::Algorithm, cv_superres_DualTVL1OpticalFlow_to_Algorithm } + + boxed_cast_base! { SuperRes_DualTVL1OpticalFlow, crate::superres::SuperRes_DenseOpticalFlowExt, cv_superres_DualTVL1OpticalFlow_to_SuperRes_DenseOpticalFlowExt } impl core::AlgorithmTraitConst for SuperRes_DualTVL1OpticalFlow { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -721,21 +727,21 @@ pub mod superres { boxed_ref! { SuperRes_DualTVL1OpticalFlow, crate::superres::SuperRes_DualTVL1OpticalFlowTraitConst, as_raw_SuperRes_DualTVL1OpticalFlow, crate::superres::SuperRes_DualTVL1OpticalFlowTrait, as_raw_mut_SuperRes_DualTVL1OpticalFlow } - impl SuperRes_DualTVL1OpticalFlow { + pub struct SuperRes_FarnebackOpticalFlow { + ptr: *mut c_void, } - boxed_cast_base! { SuperRes_DualTVL1OpticalFlow, core::Algorithm, cv_superres_DualTVL1OpticalFlow_to_Algorithm } - - boxed_cast_base! { SuperRes_DualTVL1OpticalFlow, crate::superres::SuperRes_DenseOpticalFlowExt, cv_superres_DualTVL1OpticalFlow_to_SuperRes_DenseOpticalFlowExt } + opencv_type_boxed! { SuperRes_FarnebackOpticalFlow } - impl std::fmt::Debug for SuperRes_DualTVL1OpticalFlow { + impl Drop for SuperRes_FarnebackOpticalFlow { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SuperRes_DualTVL1OpticalFlow") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_superres_FarnebackOpticalFlow_delete(self.as_raw_mut_SuperRes_FarnebackOpticalFlow()) }; } } + unsafe impl Send for SuperRes_FarnebackOpticalFlow {} + /// Constant methods for [crate::superres::SuperRes_FarnebackOpticalFlow] pub trait SuperRes_FarnebackOpticalFlowTraitConst: crate::superres::SuperRes_DenseOpticalFlowExtTraitConst { fn as_raw_SuperRes_FarnebackOpticalFlow(&self) -> *const c_void; @@ -902,20 +908,17 @@ pub mod superres { } - pub struct SuperRes_FarnebackOpticalFlow { - ptr: *mut c_void, - } - - opencv_type_boxed! { SuperRes_FarnebackOpticalFlow } - - impl Drop for SuperRes_FarnebackOpticalFlow { + impl std::fmt::Debug for SuperRes_FarnebackOpticalFlow { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_superres_FarnebackOpticalFlow_delete(self.as_raw_mut_SuperRes_FarnebackOpticalFlow()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SuperRes_FarnebackOpticalFlow") + .finish() } } - unsafe impl Send for SuperRes_FarnebackOpticalFlow {} + boxed_cast_base! { SuperRes_FarnebackOpticalFlow, core::Algorithm, cv_superres_FarnebackOpticalFlow_to_Algorithm } + + boxed_cast_base! { SuperRes_FarnebackOpticalFlow, crate::superres::SuperRes_DenseOpticalFlowExt, cv_superres_FarnebackOpticalFlow_to_SuperRes_DenseOpticalFlowExt } impl core::AlgorithmTraitConst for SuperRes_FarnebackOpticalFlow { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -947,21 +950,21 @@ pub mod superres { boxed_ref! { SuperRes_FarnebackOpticalFlow, crate::superres::SuperRes_FarnebackOpticalFlowTraitConst, as_raw_SuperRes_FarnebackOpticalFlow, crate::superres::SuperRes_FarnebackOpticalFlowTrait, as_raw_mut_SuperRes_FarnebackOpticalFlow } - impl SuperRes_FarnebackOpticalFlow { + pub struct SuperRes_FrameSource { + ptr: *mut c_void, } - boxed_cast_base! { SuperRes_FarnebackOpticalFlow, core::Algorithm, cv_superres_FarnebackOpticalFlow_to_Algorithm } - - boxed_cast_base! { SuperRes_FarnebackOpticalFlow, crate::superres::SuperRes_DenseOpticalFlowExt, cv_superres_FarnebackOpticalFlow_to_SuperRes_DenseOpticalFlowExt } + opencv_type_boxed! { SuperRes_FrameSource } - impl std::fmt::Debug for SuperRes_FarnebackOpticalFlow { + impl Drop for SuperRes_FrameSource { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SuperRes_FarnebackOpticalFlow") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_superres_FrameSource_delete(self.as_raw_mut_SuperRes_FrameSource()) }; } } + unsafe impl Send for SuperRes_FrameSource {} + /// Constant methods for [crate::superres::SuperRes_FrameSource] pub trait SuperRes_FrameSourceTraitConst { fn as_raw_SuperRes_FrameSource(&self) -> *const c_void; @@ -993,20 +996,15 @@ pub mod superres { } - pub struct SuperRes_FrameSource { - ptr: *mut c_void, - } - - opencv_type_boxed! { SuperRes_FrameSource } - - impl Drop for SuperRes_FrameSource { + impl std::fmt::Debug for SuperRes_FrameSource { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_superres_FrameSource_delete(self.as_raw_mut_SuperRes_FrameSource()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SuperRes_FrameSource") + .finish() } } - unsafe impl Send for SuperRes_FrameSource {} + boxed_cast_descendant! { SuperRes_FrameSource, crate::superres::SuperRes_SuperResolution, cv_superres_FrameSource_to_SuperRes_SuperResolution } impl crate::superres::SuperRes_FrameSourceTraitConst for SuperRes_FrameSource { #[inline] fn as_raw_SuperRes_FrameSource(&self) -> *const c_void { self.as_raw() } @@ -1018,19 +1016,21 @@ pub mod superres { boxed_ref! { SuperRes_FrameSource, crate::superres::SuperRes_FrameSourceTraitConst, as_raw_SuperRes_FrameSource, crate::superres::SuperRes_FrameSourceTrait, as_raw_mut_SuperRes_FrameSource } - impl SuperRes_FrameSource { + pub struct SuperRes_PyrLKOpticalFlow { + ptr: *mut c_void, } - boxed_cast_descendant! { SuperRes_FrameSource, crate::superres::SuperRes_SuperResolution, cv_superres_FrameSource_to_SuperRes_SuperResolution } + opencv_type_boxed! { SuperRes_PyrLKOpticalFlow } - impl std::fmt::Debug for SuperRes_FrameSource { + impl Drop for SuperRes_PyrLKOpticalFlow { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SuperRes_FrameSource") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_superres_PyrLKOpticalFlow_delete(self.as_raw_mut_SuperRes_PyrLKOpticalFlow()) }; } } + unsafe impl Send for SuperRes_PyrLKOpticalFlow {} + /// Constant methods for [crate::superres::SuperRes_PyrLKOpticalFlow] pub trait SuperRes_PyrLKOpticalFlowTraitConst: crate::superres::SuperRes_DenseOpticalFlowExtTraitConst { fn as_raw_SuperRes_PyrLKOpticalFlow(&self) -> *const c_void; @@ -1109,20 +1109,17 @@ pub mod superres { } - pub struct SuperRes_PyrLKOpticalFlow { - ptr: *mut c_void, - } - - opencv_type_boxed! { SuperRes_PyrLKOpticalFlow } - - impl Drop for SuperRes_PyrLKOpticalFlow { + impl std::fmt::Debug for SuperRes_PyrLKOpticalFlow { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_superres_PyrLKOpticalFlow_delete(self.as_raw_mut_SuperRes_PyrLKOpticalFlow()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SuperRes_PyrLKOpticalFlow") + .finish() } } - unsafe impl Send for SuperRes_PyrLKOpticalFlow {} + boxed_cast_base! { SuperRes_PyrLKOpticalFlow, core::Algorithm, cv_superres_PyrLKOpticalFlow_to_Algorithm } + + boxed_cast_base! { SuperRes_PyrLKOpticalFlow, crate::superres::SuperRes_DenseOpticalFlowExt, cv_superres_PyrLKOpticalFlow_to_SuperRes_DenseOpticalFlowExt } impl core::AlgorithmTraitConst for SuperRes_PyrLKOpticalFlow { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1154,21 +1151,25 @@ pub mod superres { boxed_ref! { SuperRes_PyrLKOpticalFlow, crate::superres::SuperRes_PyrLKOpticalFlowTraitConst, as_raw_SuperRes_PyrLKOpticalFlow, crate::superres::SuperRes_PyrLKOpticalFlowTrait, as_raw_mut_SuperRes_PyrLKOpticalFlow } - impl SuperRes_PyrLKOpticalFlow { + /// Base class for Super Resolution algorithms. + /// + /// The class is only used to define the common interface for the whole family of Super Resolution + /// algorithms. + pub struct SuperRes_SuperResolution { + ptr: *mut c_void, } - boxed_cast_base! { SuperRes_PyrLKOpticalFlow, core::Algorithm, cv_superres_PyrLKOpticalFlow_to_Algorithm } - - boxed_cast_base! { SuperRes_PyrLKOpticalFlow, crate::superres::SuperRes_DenseOpticalFlowExt, cv_superres_PyrLKOpticalFlow_to_SuperRes_DenseOpticalFlowExt } + opencv_type_boxed! { SuperRes_SuperResolution } - impl std::fmt::Debug for SuperRes_PyrLKOpticalFlow { + impl Drop for SuperRes_SuperResolution { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SuperRes_PyrLKOpticalFlow") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_superres_SuperResolution_delete(self.as_raw_mut_SuperRes_SuperResolution()) }; } } + unsafe impl Send for SuperRes_SuperResolution {} + /// Constant methods for [crate::superres::SuperRes_SuperResolution] pub trait SuperRes_SuperResolutionTraitConst: core::AlgorithmTraitConst + crate::superres::SuperRes_FrameSourceTraitConst { fn as_raw_SuperRes_SuperResolution(&self) -> *const c_void; @@ -1468,24 +1469,17 @@ pub mod superres { } - /// Base class for Super Resolution algorithms. - /// - /// The class is only used to define the common interface for the whole family of Super Resolution - /// algorithms. - pub struct SuperRes_SuperResolution { - ptr: *mut c_void, - } - - opencv_type_boxed! { SuperRes_SuperResolution } - - impl Drop for SuperRes_SuperResolution { + impl std::fmt::Debug for SuperRes_SuperResolution { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_superres_SuperResolution_delete(self.as_raw_mut_SuperRes_SuperResolution()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SuperRes_SuperResolution") + .finish() } } - unsafe impl Send for SuperRes_SuperResolution {} + boxed_cast_base! { SuperRes_SuperResolution, core::Algorithm, cv_superres_SuperResolution_to_Algorithm } + + boxed_cast_base! { SuperRes_SuperResolution, crate::superres::SuperRes_FrameSource, cv_superres_SuperResolution_to_SuperRes_FrameSource } impl core::AlgorithmTraitConst for SuperRes_SuperResolution { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1517,18 +1511,4 @@ pub mod superres { boxed_ref! { SuperRes_SuperResolution, crate::superres::SuperRes_SuperResolutionTraitConst, as_raw_SuperRes_SuperResolution, crate::superres::SuperRes_SuperResolutionTrait, as_raw_mut_SuperRes_SuperResolution } - impl SuperRes_SuperResolution { - } - - boxed_cast_base! { SuperRes_SuperResolution, core::Algorithm, cv_superres_SuperResolution_to_Algorithm } - - boxed_cast_base! { SuperRes_SuperResolution, crate::superres::SuperRes_FrameSource, cv_superres_SuperResolution_to_SuperRes_FrameSource } - - impl std::fmt::Debug for SuperRes_SuperResolution { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SuperRes_SuperResolution") - .finish() - } - } } diff --git a/docs/surface_matching.rs b/docs/surface_matching.rs index f5590e9aa..91134c409 100644 --- a/docs/surface_matching.rs +++ b/docs/surface_matching.rs @@ -364,57 +364,6 @@ pub mod surface_matching { pub type KeyType = u32; pub type Pose3DPtr = core::Ptr; pub type PoseCluster3DPtr = core::Ptr; - /// Constant methods for [crate::surface_matching::ICP] - pub trait ICPTraitConst { - fn as_raw_ICP(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::surface_matching::ICP] - pub trait ICPTrait: crate::surface_matching::ICPTraitConst { - fn as_raw_mut_ICP(&mut self) -> *mut c_void; - - /// \brief Perform registration - /// - /// ## Parameters - /// * srcPC: The input point cloud for the model. Expected to have the normals (Nx6). Currently, - /// CV_32F is the only supported data type. - /// * dstPC: The input point cloud for the scene. It is assumed that the model is registered on the scene. Scene remains static. Expected to have the normals (Nx6). Currently, CV_32F is the only supported data type. - /// * residual:[out] The output registration error. - /// * pose:[out] Transformation between srcPC and dstPC. - /// \return On successful termination, the function returns 0. - /// - /// \details It is assumed that the model is registered on the scene. Scene remains static, while the model transforms. The output poses transform the models onto the scene. Because of the point to plane minimization, the scene is expected to have the normals available. Expected to have the normals (Nx6). - #[inline] - fn register_model_to_scene(&mut self, src_pc: &impl core::MatTraitConst, dst_pc: &impl core::MatTraitConst, residual: &mut f64, pose: &mut core::Matx44d) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ppf_match_3d_ICP_registerModelToScene_const_MatR_const_MatR_doubleR_Matx44dR(self.as_raw_mut_ICP(), src_pc.as_raw_Mat(), dst_pc.as_raw_Mat(), residual, pose, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// \brief Perform registration with multiple initial poses - /// - /// ## Parameters - /// * srcPC: The input point cloud for the model. Expected to have the normals (Nx6). Currently, - /// CV_32F is the only supported data type. - /// * dstPC: The input point cloud for the scene. Currently, CV_32F is the only supported data type. - /// @param [in,out] poses Input poses to start with but also list output of poses. - /// \return On successful termination, the function returns 0. - /// - /// \details It is assumed that the model is registered on the scene. Scene remains static, while the model transforms. The output poses transform the models onto the scene. Because of the point to plane minimization, the scene is expected to have the normals available. Expected to have the normals (Nx6). - #[inline] - fn register_model_to_scene_vec(&mut self, src_pc: &impl core::MatTraitConst, dst_pc: &impl core::MatTraitConst, poses: &mut core::Vector) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ppf_match_3d_ICP_registerModelToScene_const_MatR_const_MatR_vectorLPose3DPtrGR(self.as_raw_mut_ICP(), src_pc.as_raw_Mat(), dst_pc.as_raw_Mat(), poses.as_raw_mut_VectorOfPose3DPtr(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - /// This class implements a very efficient and robust variant of the iterative closest point (ICP) algorithm. /// The task is to register a 3D model (or point cloud) against a set of noisy target data. The variants are put together /// by myself after certain tests. The task is to be able to match partial, noisy point clouds in cluttered scenes, quickly. @@ -446,16 +395,6 @@ pub mod surface_matching { unsafe impl Send for ICP {} - impl crate::surface_matching::ICPTraitConst for ICP { - #[inline] fn as_raw_ICP(&self) -> *const c_void { self.as_raw() } - } - - impl crate::surface_matching::ICPTrait for ICP { - #[inline] fn as_raw_mut_ICP(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { ICP, crate::surface_matching::ICPTraitConst, as_raw_ICP, crate::surface_matching::ICPTrait, as_raw_mut_ICP } - impl ICP { #[inline] pub fn default() -> Result { @@ -532,6 +471,57 @@ pub mod surface_matching { } + /// Constant methods for [crate::surface_matching::ICP] + pub trait ICPTraitConst { + fn as_raw_ICP(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::surface_matching::ICP] + pub trait ICPTrait: crate::surface_matching::ICPTraitConst { + fn as_raw_mut_ICP(&mut self) -> *mut c_void; + + /// \brief Perform registration + /// + /// ## Parameters + /// * srcPC: The input point cloud for the model. Expected to have the normals (Nx6). Currently, + /// CV_32F is the only supported data type. + /// * dstPC: The input point cloud for the scene. It is assumed that the model is registered on the scene. Scene remains static. Expected to have the normals (Nx6). Currently, CV_32F is the only supported data type. + /// * residual:[out] The output registration error. + /// * pose:[out] Transformation between srcPC and dstPC. + /// \return On successful termination, the function returns 0. + /// + /// \details It is assumed that the model is registered on the scene. Scene remains static, while the model transforms. The output poses transform the models onto the scene. Because of the point to plane minimization, the scene is expected to have the normals available. Expected to have the normals (Nx6). + #[inline] + fn register_model_to_scene(&mut self, src_pc: &impl core::MatTraitConst, dst_pc: &impl core::MatTraitConst, residual: &mut f64, pose: &mut core::Matx44d) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ppf_match_3d_ICP_registerModelToScene_const_MatR_const_MatR_doubleR_Matx44dR(self.as_raw_mut_ICP(), src_pc.as_raw_Mat(), dst_pc.as_raw_Mat(), residual, pose, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// \brief Perform registration with multiple initial poses + /// + /// ## Parameters + /// * srcPC: The input point cloud for the model. Expected to have the normals (Nx6). Currently, + /// CV_32F is the only supported data type. + /// * dstPC: The input point cloud for the scene. Currently, CV_32F is the only supported data type. + /// @param [in,out] poses Input poses to start with but also list output of poses. + /// \return On successful termination, the function returns 0. + /// + /// \details It is assumed that the model is registered on the scene. Scene remains static, while the model transforms. The output poses transform the models onto the scene. Because of the point to plane minimization, the scene is expected to have the normals available. Expected to have the normals (Nx6). + #[inline] + fn register_model_to_scene_vec(&mut self, src_pc: &impl core::MatTraitConst, dst_pc: &impl core::MatTraitConst, poses: &mut core::Vector) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ppf_match_3d_ICP_registerModelToScene_const_MatR_const_MatR_vectorLPose3DPtrGR(self.as_raw_mut_ICP(), src_pc.as_raw_Mat(), dst_pc.as_raw_Mat(), poses.as_raw_mut_VectorOfPose3DPtr(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + impl std::fmt::Debug for ICP { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -540,6 +530,95 @@ pub mod surface_matching { } } + impl crate::surface_matching::ICPTraitConst for ICP { + #[inline] fn as_raw_ICP(&self) -> *const c_void { self.as_raw() } + } + + impl crate::surface_matching::ICPTrait for ICP { + #[inline] fn as_raw_mut_ICP(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { ICP, crate::surface_matching::ICPTraitConst, as_raw_ICP, crate::surface_matching::ICPTrait, as_raw_mut_ICP } + + /// Class, allowing the load and matching 3D models. + /// Typical Use: + /// ```C++ + /// // Train a model + /// ppf_match_3d::PPF3DDetector detector(0.05, 0.05); + /// detector.trainModel(pc); + /// // Search the model in a given scene + /// vector results; + /// detector.match(pcTest, results, 1.0/5.0,0.05); + /// ``` + /// + pub struct PPF3DDetector { + ptr: *mut c_void, + } + + opencv_type_boxed! { PPF3DDetector } + + impl Drop for PPF3DDetector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_ppf_match_3d_PPF3DDetector_delete(self.as_raw_mut_PPF3DDetector()) }; + } + } + + unsafe impl Send for PPF3DDetector {} + + impl PPF3DDetector { + /// \brief Empty constructor. Sets default arguments + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ppf_match_3d_PPF3DDetector_PPF3DDetector(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::surface_matching::PPF3DDetector::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Constructor with arguments + /// ## Parameters + /// * relativeSamplingStep: Sampling distance relative to the object's diameter. Models are first sampled uniformly in order to improve efficiency. Decreasing this value leads to a denser model, and a more accurate pose estimation but the larger the model, the slower the training. Increasing the value leads to a less accurate pose computation but a smaller model and faster model generation and matching. Beware of the memory consumption when using small values. + /// * relativeDistanceStep: The discretization distance of the point pair distance relative to the model's diameter. This value has a direct impact on the hashtable. Using small values would lead to too fine discretization, and thus ambiguity in the bins of hashtable. Too large values would lead to no discrimination over the feature vectors and different point pair features would be assigned to the same bin. This argument defaults to the value of RelativeSamplingStep. For noisy scenes, the value can be increased to improve the robustness of the matching against noisy points. + /// * numAngles: Set the discretization of the point pair orientation as the number of subdivisions of the angle. This value is the equivalent of RelativeDistanceStep for the orientations. Increasing the value increases the precision of the matching but decreases the robustness against incorrect normal directions. Decreasing the value decreases the precision of the matching but increases the robustness against incorrect normal directions. For very noisy scenes where the normal directions can not be computed accurately, the value can be set to 25 or 20. + /// + /// ## C++ default parameters + /// * relative_distance_step: 0.05 + /// * num_angles: 30 + #[inline] + pub fn new(relative_sampling_step: f64, relative_distance_step: f64, num_angles: f64) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ppf_match_3d_PPF3DDetector_PPF3DDetector_const_double_const_double_const_double(relative_sampling_step, relative_distance_step, num_angles, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::surface_matching::PPF3DDetector::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Constructor with arguments + /// ## Parameters + /// * relativeSamplingStep: Sampling distance relative to the object's diameter. Models are first sampled uniformly in order to improve efficiency. Decreasing this value leads to a denser model, and a more accurate pose estimation but the larger the model, the slower the training. Increasing the value leads to a less accurate pose computation but a smaller model and faster model generation and matching. Beware of the memory consumption when using small values. + /// * relativeDistanceStep: The discretization distance of the point pair distance relative to the model's diameter. This value has a direct impact on the hashtable. Using small values would lead to too fine discretization, and thus ambiguity in the bins of hashtable. Too large values would lead to no discrimination over the feature vectors and different point pair features would be assigned to the same bin. This argument defaults to the value of RelativeSamplingStep. For noisy scenes, the value can be increased to improve the robustness of the matching against noisy points. + /// * numAngles: Set the discretization of the point pair orientation as the number of subdivisions of the angle. This value is the equivalent of RelativeDistanceStep for the orientations. Increasing the value increases the precision of the matching but decreases the robustness against incorrect normal directions. Decreasing the value decreases the precision of the matching but increases the robustness against incorrect normal directions. For very noisy scenes where the normal directions can not be computed accurately, the value can be set to 25 or 20. + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * relative_distance_step: 0.05 + /// * num_angles: 30 + #[inline] + pub fn new_def(relative_sampling_step: f64) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ppf_match_3d_PPF3DDetector_PPF3DDetector_const_double(relative_sampling_step, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::surface_matching::PPF3DDetector::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::surface_matching::PPF3DDetector] pub trait PPF3DDetectorTraitConst { fn as_raw_PPF3DDetector(&self) -> *const c_void; @@ -647,32 +726,14 @@ pub mod surface_matching { } - /// Class, allowing the load and matching 3D models. - /// Typical Use: - /// ```C++ - /// // Train a model - /// ppf_match_3d::PPF3DDetector detector(0.05, 0.05); - /// detector.trainModel(pc); - /// // Search the model in a given scene - /// vector results; - /// detector.match(pcTest, results, 1.0/5.0,0.05); - /// ``` - /// - pub struct PPF3DDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { PPF3DDetector } - - impl Drop for PPF3DDetector { + impl std::fmt::Debug for PPF3DDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ppf_match_3d_PPF3DDetector_delete(self.as_raw_mut_PPF3DDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PPF3DDetector") + .finish() } } - unsafe impl Send for PPF3DDetector {} - impl crate::surface_matching::PPF3DDetectorTraitConst for PPF3DDetector { #[inline] fn as_raw_PPF3DDetector(&self) -> *const c_void { self.as_raw() } } @@ -683,67 +744,64 @@ pub mod surface_matching { boxed_ref! { PPF3DDetector, crate::surface_matching::PPF3DDetectorTraitConst, as_raw_PPF3DDetector, crate::surface_matching::PPF3DDetectorTrait, as_raw_mut_PPF3DDetector } - impl PPF3DDetector { - /// \brief Empty constructor. Sets default arguments + /// Class, allowing the storage of a pose. The data structure stores both + /// the quaternions and the matrix forms. It supports IO functionality together with + /// various helper methods to work with poses + pub struct Pose3D { + ptr: *mut c_void, + } + + opencv_type_boxed! { Pose3D } + + impl Drop for Pose3D { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_ppf_match_3d_Pose3D_delete(self.as_raw_mut_Pose3D()) }; + } + } + + unsafe impl Send for Pose3D {} + + impl Pose3D { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ppf_match_3d_PPF3DDetector_PPF3DDetector(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ppf_match_3d_Pose3D_Pose3D(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::surface_matching::PPF3DDetector::opencv_from_extern(ret) }; + let ret = unsafe { crate::surface_matching::Pose3D::opencv_from_extern(ret) }; Ok(ret) } - /// Constructor with arguments - /// ## Parameters - /// * relativeSamplingStep: Sampling distance relative to the object's diameter. Models are first sampled uniformly in order to improve efficiency. Decreasing this value leads to a denser model, and a more accurate pose estimation but the larger the model, the slower the training. Increasing the value leads to a less accurate pose computation but a smaller model and faster model generation and matching. Beware of the memory consumption when using small values. - /// * relativeDistanceStep: The discretization distance of the point pair distance relative to the model's diameter. This value has a direct impact on the hashtable. Using small values would lead to too fine discretization, and thus ambiguity in the bins of hashtable. Too large values would lead to no discrimination over the feature vectors and different point pair features would be assigned to the same bin. This argument defaults to the value of RelativeSamplingStep. For noisy scenes, the value can be increased to improve the robustness of the matching against noisy points. - /// * numAngles: Set the discretization of the point pair orientation as the number of subdivisions of the angle. This value is the equivalent of RelativeDistanceStep for the orientations. Increasing the value increases the precision of the matching but decreases the robustness against incorrect normal directions. Decreasing the value decreases the precision of the matching but increases the robustness against incorrect normal directions. For very noisy scenes where the normal directions can not be computed accurately, the value can be set to 25 or 20. - /// /// ## C++ default parameters - /// * relative_distance_step: 0.05 - /// * num_angles: 30 + /// * model_index: 0 + /// * num_votes: 0 #[inline] - pub fn new(relative_sampling_step: f64, relative_distance_step: f64, num_angles: f64) -> Result { + pub fn new(alpha: f64, model_index: size_t, num_votes: size_t) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ppf_match_3d_PPF3DDetector_PPF3DDetector_const_double_const_double_const_double(relative_sampling_step, relative_distance_step, num_angles, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ppf_match_3d_Pose3D_Pose3D_double_size_t_size_t(alpha, model_index, num_votes, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::surface_matching::PPF3DDetector::opencv_from_extern(ret) }; + let ret = unsafe { crate::surface_matching::Pose3D::opencv_from_extern(ret) }; Ok(ret) } - /// Constructor with arguments - /// ## Parameters - /// * relativeSamplingStep: Sampling distance relative to the object's diameter. Models are first sampled uniformly in order to improve efficiency. Decreasing this value leads to a denser model, and a more accurate pose estimation but the larger the model, the slower the training. Increasing the value leads to a less accurate pose computation but a smaller model and faster model generation and matching. Beware of the memory consumption when using small values. - /// * relativeDistanceStep: The discretization distance of the point pair distance relative to the model's diameter. This value has a direct impact on the hashtable. Using small values would lead to too fine discretization, and thus ambiguity in the bins of hashtable. Too large values would lead to no discrimination over the feature vectors and different point pair features would be assigned to the same bin. This argument defaults to the value of RelativeSamplingStep. For noisy scenes, the value can be increased to improve the robustness of the matching against noisy points. - /// * numAngles: Set the discretization of the point pair orientation as the number of subdivisions of the angle. This value is the equivalent of RelativeDistanceStep for the orientations. Increasing the value increases the precision of the matching but decreases the robustness against incorrect normal directions. Decreasing the value decreases the precision of the matching but increases the robustness against incorrect normal directions. For very noisy scenes where the normal directions can not be computed accurately, the value can be set to 25 or 20. - /// /// ## Note /// This alternative version of [new] function uses the following default values for its arguments: - /// * relative_distance_step: 0.05 - /// * num_angles: 30 + /// * model_index: 0 + /// * num_votes: 0 #[inline] - pub fn new_def(relative_sampling_step: f64) -> Result { + pub fn new_def(alpha: f64) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ppf_match_3d_PPF3DDetector_PPF3DDetector_const_double(relative_sampling_step, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ppf_match_3d_Pose3D_Pose3D_double(alpha, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::surface_matching::PPF3DDetector::opencv_from_extern(ret) }; + let ret = unsafe { crate::surface_matching::Pose3D::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for PPF3DDetector { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PPF3DDetector") - .finish() - } - } - /// Constant methods for [crate::surface_matching::Pose3D] pub trait Pose3DTraitConst { fn as_raw_Pose3D(&self) -> *const c_void; @@ -939,24 +997,22 @@ pub mod surface_matching { } - /// Class, allowing the storage of a pose. The data structure stores both - /// the quaternions and the matrix forms. It supports IO functionality together with - /// various helper methods to work with poses - pub struct Pose3D { - ptr: *mut c_void, - } - - opencv_type_boxed! { Pose3D } - - impl Drop for Pose3D { + impl std::fmt::Debug for Pose3D { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ppf_match_3d_Pose3D_delete(self.as_raw_mut_Pose3D()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Pose3D") + .field("alpha", &crate::surface_matching::Pose3DTraitConst::alpha(self)) + .field("residual", &crate::surface_matching::Pose3DTraitConst::residual(self)) + .field("model_index", &crate::surface_matching::Pose3DTraitConst::model_index(self)) + .field("num_votes", &crate::surface_matching::Pose3DTraitConst::num_votes(self)) + .field("pose", &crate::surface_matching::Pose3DTraitConst::pose(self)) + .field("angle", &crate::surface_matching::Pose3DTraitConst::angle(self)) + .field("t", &crate::surface_matching::Pose3DTraitConst::t(self)) + .field("q", &crate::surface_matching::Pose3DTraitConst::q(self)) + .finish() } } - unsafe impl Send for Pose3D {} - impl crate::surface_matching::Pose3DTraitConst for Pose3D { #[inline] fn as_raw_Pose3D(&self) -> *const c_void { self.as_raw() } } @@ -967,62 +1023,57 @@ pub mod surface_matching { boxed_ref! { Pose3D, crate::surface_matching::Pose3DTraitConst, as_raw_Pose3D, crate::surface_matching::Pose3DTrait, as_raw_mut_Pose3D } - impl Pose3D { + /// When multiple poses (see Pose3D) are grouped together (contribute to the same transformation) + /// pose clusters occur. This class is a general container for such groups of poses. It is possible to store, + /// load and perform IO on these poses. + pub struct PoseCluster3D { + ptr: *mut c_void, + } + + opencv_type_boxed! { PoseCluster3D } + + impl Drop for PoseCluster3D { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_ppf_match_3d_PoseCluster3D_delete(self.as_raw_mut_PoseCluster3D()) }; + } + } + + unsafe impl Send for PoseCluster3D {} + + impl PoseCluster3D { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ppf_match_3d_Pose3D_Pose3D(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ppf_match_3d_PoseCluster3D_PoseCluster3D(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::surface_matching::Pose3D::opencv_from_extern(ret) }; + let ret = unsafe { crate::surface_matching::PoseCluster3D::opencv_from_extern(ret) }; Ok(ret) } - /// ## C++ default parameters - /// * model_index: 0 - /// * num_votes: 0 #[inline] - pub fn new(alpha: f64, model_index: size_t, num_votes: size_t) -> Result { + pub fn new(mut new_pose: crate::surface_matching::Pose3DPtr) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ppf_match_3d_Pose3D_Pose3D_double_size_t_size_t(alpha, model_index, num_votes, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ppf_match_3d_PoseCluster3D_PoseCluster3D_Pose3DPtr(new_pose.as_raw_mut_PtrOfPose3D(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::surface_matching::Pose3D::opencv_from_extern(ret) }; + let ret = unsafe { crate::surface_matching::PoseCluster3D::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * model_index: 0 - /// * num_votes: 0 #[inline] - pub fn new_def(alpha: f64) -> Result { + pub fn new_1(mut new_pose: crate::surface_matching::Pose3DPtr, new_id: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_ppf_match_3d_Pose3D_Pose3D_double(alpha, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ppf_match_3d_PoseCluster3D_PoseCluster3D_Pose3DPtr_int(new_pose.as_raw_mut_PtrOfPose3D(), new_id, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::surface_matching::Pose3D::opencv_from_extern(ret) }; + let ret = unsafe { crate::surface_matching::PoseCluster3D::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for Pose3D { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Pose3D") - .field("alpha", &crate::surface_matching::Pose3DTraitConst::alpha(self)) - .field("residual", &crate::surface_matching::Pose3DTraitConst::residual(self)) - .field("model_index", &crate::surface_matching::Pose3DTraitConst::model_index(self)) - .field("num_votes", &crate::surface_matching::Pose3DTraitConst::num_votes(self)) - .field("pose", &crate::surface_matching::Pose3DTraitConst::pose(self)) - .field("angle", &crate::surface_matching::Pose3DTraitConst::angle(self)) - .field("t", &crate::surface_matching::Pose3DTraitConst::t(self)) - .field("q", &crate::surface_matching::Pose3DTraitConst::q(self)) - .finish() - } - } - /// Constant methods for [crate::surface_matching::PoseCluster3D] pub trait PoseCluster3DTraitConst { fn as_raw_PoseCluster3D(&self) -> *const c_void; @@ -1104,24 +1155,17 @@ pub mod surface_matching { } - /// When multiple poses (see Pose3D) are grouped together (contribute to the same transformation) - /// pose clusters occur. This class is a general container for such groups of poses. It is possible to store, - /// load and perform IO on these poses. - pub struct PoseCluster3D { - ptr: *mut c_void, - } - - opencv_type_boxed! { PoseCluster3D } - - impl Drop for PoseCluster3D { + impl std::fmt::Debug for PoseCluster3D { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ppf_match_3d_PoseCluster3D_delete(self.as_raw_mut_PoseCluster3D()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PoseCluster3D") + .field("pose_list", &crate::surface_matching::PoseCluster3DTraitConst::pose_list(self)) + .field("num_votes", &crate::surface_matching::PoseCluster3DTraitConst::num_votes(self)) + .field("id", &crate::surface_matching::PoseCluster3DTraitConst::id(self)) + .finish() } } - unsafe impl Send for PoseCluster3D {} - impl crate::surface_matching::PoseCluster3DTraitConst for PoseCluster3D { #[inline] fn as_raw_PoseCluster3D(&self) -> *const c_void { self.as_raw() } } @@ -1132,47 +1176,4 @@ pub mod surface_matching { boxed_ref! { PoseCluster3D, crate::surface_matching::PoseCluster3DTraitConst, as_raw_PoseCluster3D, crate::surface_matching::PoseCluster3DTrait, as_raw_mut_PoseCluster3D } - impl PoseCluster3D { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ppf_match_3d_PoseCluster3D_PoseCluster3D(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::surface_matching::PoseCluster3D::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn new(mut new_pose: crate::surface_matching::Pose3DPtr) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ppf_match_3d_PoseCluster3D_PoseCluster3D_Pose3DPtr(new_pose.as_raw_mut_PtrOfPose3D(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::surface_matching::PoseCluster3D::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn new_1(mut new_pose: crate::surface_matching::Pose3DPtr, new_id: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ppf_match_3d_PoseCluster3D_PoseCluster3D_Pose3DPtr_int(new_pose.as_raw_mut_PtrOfPose3D(), new_id, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::surface_matching::PoseCluster3D::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for PoseCluster3D { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PoseCluster3D") - .field("pose_list", &crate::surface_matching::PoseCluster3DTraitConst::pose_list(self)) - .field("num_votes", &crate::surface_matching::PoseCluster3DTraitConst::num_votes(self)) - .field("id", &crate::surface_matching::PoseCluster3DTraitConst::id(self)) - .finish() - } - } } diff --git a/docs/text.rs b/docs/text.rs index 03852576a..a5a9a6d7f 100644 --- a/docs/text.rs +++ b/docs/text.rs @@ -949,6 +949,21 @@ pub mod text { Ok(ret) } + pub struct BaseOCR { + ptr: *mut c_void, + } + + opencv_type_boxed! { BaseOCR } + + impl Drop for BaseOCR { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_text_BaseOCR_delete(self.as_raw_mut_BaseOCR()) }; + } + } + + unsafe impl Send for BaseOCR {} + /// Constant methods for [crate::text::BaseOCR] pub trait BaseOCRTraitConst { fn as_raw_BaseOCR(&self) -> *const c_void; @@ -1027,20 +1042,21 @@ pub mod text { } - pub struct BaseOCR { - ptr: *mut c_void, - } - - opencv_type_boxed! { BaseOCR } - - impl Drop for BaseOCR { + impl std::fmt::Debug for BaseOCR { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_text_BaseOCR_delete(self.as_raw_mut_BaseOCR()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BaseOCR") + .finish() } } - unsafe impl Send for BaseOCR {} + boxed_cast_descendant! { BaseOCR, crate::text::OCRBeamSearchDecoder, cv_text_BaseOCR_to_OCRBeamSearchDecoder } + + boxed_cast_descendant! { BaseOCR, crate::text::OCRHMMDecoder, cv_text_BaseOCR_to_OCRHMMDecoder } + + boxed_cast_descendant! { BaseOCR, crate::text::OCRHolisticWordRecognizer, cv_text_BaseOCR_to_OCRHolisticWordRecognizer } + + boxed_cast_descendant! { BaseOCR, crate::text::OCRTesseract, cv_text_BaseOCR_to_OCRTesseract } impl crate::text::BaseOCRTraitConst for BaseOCR { #[inline] fn as_raw_BaseOCR(&self) -> *const c_void { self.as_raw() } @@ -1052,25 +1068,24 @@ pub mod text { boxed_ref! { BaseOCR, crate::text::BaseOCRTraitConst, as_raw_BaseOCR, crate::text::BaseOCRTrait, as_raw_mut_BaseOCR } - impl BaseOCR { + /// Base class for 1st and 2nd stages of Neumann and Matas scene text detection algorithm [Neumann12](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Neumann12). : + /// + /// Extracts the component tree (if needed) and filter the extremal regions (ER's) by using a given classifier. + pub struct ERFilter { + ptr: *mut c_void, } - boxed_cast_descendant! { BaseOCR, crate::text::OCRBeamSearchDecoder, cv_text_BaseOCR_to_OCRBeamSearchDecoder } - - boxed_cast_descendant! { BaseOCR, crate::text::OCRHMMDecoder, cv_text_BaseOCR_to_OCRHMMDecoder } - - boxed_cast_descendant! { BaseOCR, crate::text::OCRHolisticWordRecognizer, cv_text_BaseOCR_to_OCRHolisticWordRecognizer } - - boxed_cast_descendant! { BaseOCR, crate::text::OCRTesseract, cv_text_BaseOCR_to_OCRTesseract } + opencv_type_boxed! { ERFilter } - impl std::fmt::Debug for BaseOCR { + impl Drop for ERFilter { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BaseOCR") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_text_ERFilter_delete(self.as_raw_mut_ERFilter()) }; } } + unsafe impl Send for ERFilter {} + /// Constant methods for [crate::text::ERFilter] pub trait ERFilterTraitConst: core::AlgorithmTraitConst { fn as_raw_ERFilter(&self) -> *const c_void; @@ -1179,23 +1194,15 @@ pub mod text { } - /// Base class for 1st and 2nd stages of Neumann and Matas scene text detection algorithm [Neumann12](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Neumann12). : - /// - /// Extracts the component tree (if needed) and filter the extremal regions (ER's) by using a given classifier. - pub struct ERFilter { - ptr: *mut c_void, - } - - opencv_type_boxed! { ERFilter } - - impl Drop for ERFilter { + impl std::fmt::Debug for ERFilter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_text_ERFilter_delete(self.as_raw_mut_ERFilter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ERFilter") + .finish() } } - unsafe impl Send for ERFilter {} + boxed_cast_base! { ERFilter, core::Algorithm, cv_text_ERFilter_to_Algorithm } impl core::AlgorithmTraitConst for ERFilter { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1217,19 +1224,25 @@ pub mod text { boxed_ref! { ERFilter, crate::text::ERFilterTraitConst, as_raw_ERFilter, crate::text::ERFilterTrait, as_raw_mut_ERFilter } - impl ERFilter { + /// Callback with the classifier is made a class. + /// + /// By doing it we hide SVM, Boost etc. Developers can provide their own classifiers to the + /// ERFilter algorithm. + pub struct ERFilter_Callback { + ptr: *mut c_void, } - boxed_cast_base! { ERFilter, core::Algorithm, cv_text_ERFilter_to_Algorithm } + opencv_type_boxed! { ERFilter_Callback } - impl std::fmt::Debug for ERFilter { + impl Drop for ERFilter_Callback { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ERFilter") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_text_ERFilter_Callback_delete(self.as_raw_mut_ERFilter_Callback()) }; } } + unsafe impl Send for ERFilter_Callback {} + /// Constant methods for [crate::text::ERFilter_Callback] pub trait ERFilter_CallbackTraitConst { fn as_raw_ERFilter_Callback(&self) -> *const c_void; @@ -1255,25 +1268,14 @@ pub mod text { } - /// Callback with the classifier is made a class. - /// - /// By doing it we hide SVM, Boost etc. Developers can provide their own classifiers to the - /// ERFilter algorithm. - pub struct ERFilter_Callback { - ptr: *mut c_void, - } - - opencv_type_boxed! { ERFilter_Callback } - - impl Drop for ERFilter_Callback { + impl std::fmt::Debug for ERFilter_Callback { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_text_ERFilter_Callback_delete(self.as_raw_mut_ERFilter_Callback()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ERFilter_Callback") + .finish() } } - unsafe impl Send for ERFilter_Callback {} - impl crate::text::ERFilter_CallbackTraitConst for ERFilter_Callback { #[inline] fn as_raw_ERFilter_Callback(&self) -> *const c_void { self.as_raw() } } @@ -1284,17 +1286,64 @@ pub mod text { boxed_ref! { ERFilter_Callback, crate::text::ERFilter_CallbackTraitConst, as_raw_ERFilter_Callback, crate::text::ERFilter_CallbackTrait, as_raw_mut_ERFilter_Callback } - impl ERFilter_Callback { + /// The ERStat structure represents a class-specific Extremal Region (ER). + /// + /// An ER is a 4-connected set of pixels with all its grey-level values smaller than the values in its + /// outer boundary. A class-specific ER is selected (using a classifier) from all the ER's in the + /// component tree of the image. : + pub struct ERStat { + ptr: *mut c_void, } - impl std::fmt::Debug for ERFilter_Callback { + opencv_type_boxed! { ERStat } + + impl Drop for ERStat { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ERFilter_Callback") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_text_ERStat_delete(self.as_raw_mut_ERStat()) }; } } + unsafe impl Send for ERStat {} + + impl ERStat { + /// Constructor + /// + /// ## C++ default parameters + /// * level: 256 + /// * pixel: 0 + /// * x: 0 + /// * y: 0 + #[inline] + pub fn new(level: i32, pixel: i32, x: i32, y: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_text_ERStat_ERStat_int_int_int_int(level, pixel, x, y, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::text::ERStat::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Constructor + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * level: 256 + /// * pixel: 0 + /// * x: 0 + /// * y: 0 + #[inline] + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_text_ERStat_ERStat(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::text::ERStat::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::text::ERStat] pub trait ERStatTraitConst { fn as_raw_ERStat(&self) -> *const c_void; @@ -1579,74 +1628,6 @@ pub mod text { } - /// The ERStat structure represents a class-specific Extremal Region (ER). - /// - /// An ER is a 4-connected set of pixels with all its grey-level values smaller than the values in its - /// outer boundary. A class-specific ER is selected (using a classifier) from all the ER's in the - /// component tree of the image. : - pub struct ERStat { - ptr: *mut c_void, - } - - opencv_type_boxed! { ERStat } - - impl Drop for ERStat { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_text_ERStat_delete(self.as_raw_mut_ERStat()) }; - } - } - - unsafe impl Send for ERStat {} - - impl crate::text::ERStatTraitConst for ERStat { - #[inline] fn as_raw_ERStat(&self) -> *const c_void { self.as_raw() } - } - - impl crate::text::ERStatTrait for ERStat { - #[inline] fn as_raw_mut_ERStat(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { ERStat, crate::text::ERStatTraitConst, as_raw_ERStat, crate::text::ERStatTrait, as_raw_mut_ERStat } - - impl ERStat { - /// Constructor - /// - /// ## C++ default parameters - /// * level: 256 - /// * pixel: 0 - /// * x: 0 - /// * y: 0 - #[inline] - pub fn new(level: i32, pixel: i32, x: i32, y: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_text_ERStat_ERStat_int_int_int_int(level, pixel, x, y, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::text::ERStat::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Constructor - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * level: 256 - /// * pixel: 0 - /// * x: 0 - /// * y: 0 - #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_text_ERStat_ERStat(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::text::ERStat::opencv_from_extern(ret) }; - Ok(ret) - } - - } - impl std::fmt::Debug for ERStat { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -1669,24 +1650,164 @@ pub mod text { } } - /// Constant methods for [crate::text::OCRBeamSearchDecoder] - pub trait OCRBeamSearchDecoderTraitConst: crate::text::BaseOCRTraitConst { - fn as_raw_OCRBeamSearchDecoder(&self) -> *const c_void; + impl crate::text::ERStatTraitConst for ERStat { + #[inline] fn as_raw_ERStat(&self) -> *const c_void { self.as_raw() } + } + impl crate::text::ERStatTrait for ERStat { + #[inline] fn as_raw_mut_ERStat(&mut self) -> *mut c_void { self.as_raw_mut() } } - /// Mutable methods for [crate::text::OCRBeamSearchDecoder] - pub trait OCRBeamSearchDecoderTrait: crate::text::BaseOCRTrait + crate::text::OCRBeamSearchDecoderTraitConst { - fn as_raw_mut_OCRBeamSearchDecoder(&mut self) -> *mut c_void; + boxed_ref! { ERStat, crate::text::ERStatTraitConst, as_raw_ERStat, crate::text::ERStatTrait, as_raw_mut_ERStat } - /// Recognize text using Beam Search. - /// - /// Takes image on input and returns recognized text in the output_text parameter. Optionally - /// provides also the Rects for individual text elements found (e.g. words), and the list of those - /// text elements with their confidence values. - /// - /// ## Parameters - /// * image: Input binary image CV_8UC1 with a single text line (or word). + /// OCRBeamSearchDecoder class provides an interface for OCR using Beam Search algorithm. + /// + /// + /// Note: + /// * (C++) An example on using OCRBeamSearchDecoder recognition combined with scene text detection can + /// be found at the demo sample: + /// + pub struct OCRBeamSearchDecoder { + ptr: *mut c_void, + } + + opencv_type_boxed! { OCRBeamSearchDecoder } + + impl Drop for OCRBeamSearchDecoder { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_text_OCRBeamSearchDecoder_delete(self.as_raw_mut_OCRBeamSearchDecoder()) }; + } + } + + unsafe impl Send for OCRBeamSearchDecoder {} + + impl OCRBeamSearchDecoder { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::text::OCRBeamSearchDecoder { + let ret = unsafe { sys::cv_text_OCRBeamSearchDecoder_defaultNew_const() }; + let ret = unsafe { crate::text::OCRBeamSearchDecoder::opencv_from_extern(ret) }; + ret + } + + /// Creates an instance of the OCRBeamSearchDecoder class. Initializes HMMDecoder. + /// + /// ## Parameters + /// * classifier: The character classifier with built in feature extractor. + /// + /// * vocabulary: The language vocabulary (chars when ASCII English text). vocabulary.size() + /// must be equal to the number of classes of the classifier. + /// + /// * transition_probabilities_table: Table with transition probabilities between character + /// pairs. cols == rows == vocabulary.size(). + /// + /// * emission_probabilities_table: Table with observation emission probabilities. cols == + /// rows == vocabulary.size(). + /// + /// * mode: HMM Decoding algorithm. Only OCR_DECODER_VITERBI is available for the moment + /// (). + /// + /// * beam_size: Size of the beam in Beam Search algorithm. + /// + /// ## C++ default parameters + /// * mode: OCR_DECODER_VITERBI + /// * beam_size: 500 + #[inline] + pub fn create(classifier: core::Ptr, vocabulary: &str, transition_probabilities_table: &impl ToInputArray, emission_probabilities_table: &impl ToInputArray, mode: crate::text::decoder_mode, beam_size: i32) -> Result> { + extern_container_arg!(vocabulary); + input_array_arg!(transition_probabilities_table); + input_array_arg!(emission_probabilities_table); + return_send!(via ocvrs_return); + unsafe { sys::cv_text_OCRBeamSearchDecoder_create_const_PtrLClassifierCallbackG_const_stringR_const__InputArrayR_const__InputArrayR_decoder_mode_int(classifier.as_raw_PtrOfOCRBeamSearchDecoder_ClassifierCallback(), vocabulary.opencv_as_extern(), transition_probabilities_table.as_raw__InputArray(), emission_probabilities_table.as_raw__InputArray(), mode, beam_size, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Creates an instance of the OCRBeamSearchDecoder class. Initializes HMMDecoder from the specified path. + /// + /// Creates an instance of the OCRBeamSearchDecoder class. Initializes HMMDecoder. + /// + /// ## Parameters + /// * classifier: The character classifier with built in feature extractor. + /// + /// * vocabulary: The language vocabulary (chars when ASCII English text). vocabulary.size() + /// must be equal to the number of classes of the classifier. + /// + /// * transition_probabilities_table: Table with transition probabilities between character + /// pairs. cols == rows == vocabulary.size(). + /// + /// * emission_probabilities_table: Table with observation emission probabilities. cols == + /// rows == vocabulary.size(). + /// + /// * mode: HMM Decoding algorithm. Only OCR_DECODER_VITERBI is available for the moment + /// (). + /// + /// * beam_size: Size of the beam in Beam Search algorithm. + /// + /// ## Overloaded parameters + /// + /// ## C++ default parameters + /// * mode: OCR_DECODER_VITERBI + /// * beam_size: 500 + #[inline] + pub fn create_from_file(filename: &str, vocabulary: &str, transition_probabilities_table: &impl ToInputArray, emission_probabilities_table: &impl ToInputArray, mode: crate::text::decoder_mode, beam_size: i32) -> Result> { + extern_container_arg!(filename); + extern_container_arg!(vocabulary); + input_array_arg!(transition_probabilities_table); + input_array_arg!(emission_probabilities_table); + return_send!(via ocvrs_return); + unsafe { sys::cv_text_OCRBeamSearchDecoder_create_const_StringR_const_StringR_const__InputArrayR_const__InputArrayR_decoder_mode_int(filename.opencv_as_extern(), vocabulary.opencv_as_extern(), transition_probabilities_table.as_raw__InputArray(), emission_probabilities_table.as_raw__InputArray(), mode, beam_size, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Creates an instance of the OCRBeamSearchDecoder class. Initializes HMMDecoder from the specified path. + /// + /// @overload + /// + /// ## Note + /// This alternative version of [OCRBeamSearchDecoder::create_from_file] function uses the following default values for its arguments: + /// * mode: OCR_DECODER_VITERBI + /// * beam_size: 500 + #[inline] + pub fn create_from_file_def(filename: &str, vocabulary: &str, transition_probabilities_table: &impl ToInputArray, emission_probabilities_table: &impl ToInputArray) -> Result> { + extern_container_arg!(filename); + extern_container_arg!(vocabulary); + input_array_arg!(transition_probabilities_table); + input_array_arg!(emission_probabilities_table); + return_send!(via ocvrs_return); + unsafe { sys::cv_text_OCRBeamSearchDecoder_create_const_StringR_const_StringR_const__InputArrayR_const__InputArrayR(filename.opencv_as_extern(), vocabulary.opencv_as_extern(), transition_probabilities_table.as_raw__InputArray(), emission_probabilities_table.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::text::OCRBeamSearchDecoder] + pub trait OCRBeamSearchDecoderTraitConst: crate::text::BaseOCRTraitConst { + fn as_raw_OCRBeamSearchDecoder(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::text::OCRBeamSearchDecoder] + pub trait OCRBeamSearchDecoderTrait: crate::text::BaseOCRTrait + crate::text::OCRBeamSearchDecoderTraitConst { + fn as_raw_mut_OCRBeamSearchDecoder(&mut self) -> *mut c_void; + + /// Recognize text using Beam Search. + /// + /// Takes image on input and returns recognized text in the output_text parameter. Optionally + /// provides also the Rects for individual text elements found (e.g. words), and the list of those + /// text elements with their confidence values. + /// + /// ## Parameters + /// * image: Input binary image CV_8UC1 with a single text line (or word). /// /// * output_text: Output text. Most likely character sequence found by the HMM decoder. /// @@ -1847,27 +1968,23 @@ pub mod text { } - /// OCRBeamSearchDecoder class provides an interface for OCR using Beam Search algorithm. - /// - /// - /// Note: - /// * (C++) An example on using OCRBeamSearchDecoder recognition combined with scene text detection can - /// be found at the demo sample: - /// - pub struct OCRBeamSearchDecoder { - ptr: *mut c_void, + impl Default for OCRBeamSearchDecoder { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { OCRBeamSearchDecoder } - - impl Drop for OCRBeamSearchDecoder { + impl std::fmt::Debug for OCRBeamSearchDecoder { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_text_OCRBeamSearchDecoder_delete(self.as_raw_mut_OCRBeamSearchDecoder()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("OCRBeamSearchDecoder") + .finish() } } - unsafe impl Send for OCRBeamSearchDecoder {} + boxed_cast_base! { OCRBeamSearchDecoder, crate::text::BaseOCR, cv_text_OCRBeamSearchDecoder_to_BaseOCR } impl crate::text::BaseOCRTraitConst for OCRBeamSearchDecoder { #[inline] fn as_raw_BaseOCR(&self) -> *const c_void { self.as_raw() } @@ -1889,19 +2006,151 @@ pub mod text { boxed_ref! { OCRBeamSearchDecoder, crate::text::OCRBeamSearchDecoderTraitConst, as_raw_OCRBeamSearchDecoder, crate::text::OCRBeamSearchDecoderTrait, as_raw_mut_OCRBeamSearchDecoder } - impl OCRBeamSearchDecoder { + /// Callback with the character classifier is made a class. + /// + /// This way it hides the feature extractor and the classifier itself, so developers can write + /// their own OCR code. + /// + /// The default character classifier and feature extractor can be loaded using the utility function + /// loadOCRBeamSearchClassifierCNN with all its parameters provided in + /// . + pub struct OCRBeamSearchDecoder_ClassifierCallback { + ptr: *mut c_void, + } + + opencv_type_boxed! { OCRBeamSearchDecoder_ClassifierCallback } + + impl Drop for OCRBeamSearchDecoder_ClassifierCallback { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_text_OCRBeamSearchDecoder_ClassifierCallback_delete(self.as_raw_mut_OCRBeamSearchDecoder_ClassifierCallback()) }; + } + } + + unsafe impl Send for OCRBeamSearchDecoder_ClassifierCallback {} + + impl OCRBeamSearchDecoder_ClassifierCallback { /// Creates a default instance of the class by calling the default constructor #[inline] + pub fn default() -> crate::text::OCRBeamSearchDecoder_ClassifierCallback { + let ret = unsafe { sys::cv_text_OCRBeamSearchDecoder_ClassifierCallback_defaultNew_const() }; + let ret = unsafe { crate::text::OCRBeamSearchDecoder_ClassifierCallback::opencv_from_extern(ret) }; + ret + } + + } + + /// Constant methods for [crate::text::OCRBeamSearchDecoder_ClassifierCallback] + pub trait OCRBeamSearchDecoder_ClassifierCallbackTraitConst { + fn as_raw_OCRBeamSearchDecoder_ClassifierCallback(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::text::OCRBeamSearchDecoder_ClassifierCallback] + pub trait OCRBeamSearchDecoder_ClassifierCallbackTrait: crate::text::OCRBeamSearchDecoder_ClassifierCallbackTraitConst { + fn as_raw_mut_OCRBeamSearchDecoder_ClassifierCallback(&mut self) -> *mut c_void; + + /// The character classifier must return a (ranked list of) class(es) id('s) + /// + /// ## Parameters + /// * image: Input image CV_8UC1 or CV_8UC3 with a single letter. + /// * recognition_probabilities: For each of the N characters found the classifier returns a list with + /// class probabilities for each class. + /// * oversegmentation: The classifier returns a list of N+1 character locations' x-coordinates, + /// including 0 as start-sequence location. + #[inline] + fn eval(&mut self, image: &impl ToInputArray, recognition_probabilities: &mut core::Vector>, oversegmentation: &mut core::Vector) -> Result<()> { + input_array_arg!(image); + return_send!(via ocvrs_return); + unsafe { sys::cv_text_OCRBeamSearchDecoder_ClassifierCallback_eval_const__InputArrayR_vectorLvectorLdoubleGGR_vectorLintGR(self.as_raw_mut_OCRBeamSearchDecoder_ClassifierCallback(), image.as_raw__InputArray(), recognition_probabilities.as_raw_mut_VectorOfVectorOff64(), oversegmentation.as_raw_mut_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn get_window_size(&mut self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_text_OCRBeamSearchDecoder_ClassifierCallback_getWindowSize(self.as_raw_mut_OCRBeamSearchDecoder_ClassifierCallback(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn get_step_size(&mut self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_text_OCRBeamSearchDecoder_ClassifierCallback_getStepSize(self.as_raw_mut_OCRBeamSearchDecoder_ClassifierCallback(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + impl Default for OCRBeamSearchDecoder_ClassifierCallback { + #[inline] + /// Forwards to infallible Self::default() fn default() -> Self { - unsafe { Self::from_raw(sys::cv_text_OCRBeamSearchDecoder_defaultNew_const()) } + Self::default() } + } - /// Creates an instance of the OCRBeamSearchDecoder class. Initializes HMMDecoder. + impl std::fmt::Debug for OCRBeamSearchDecoder_ClassifierCallback { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("OCRBeamSearchDecoder_ClassifierCallback") + .finish() + } + } + + impl crate::text::OCRBeamSearchDecoder_ClassifierCallbackTraitConst for OCRBeamSearchDecoder_ClassifierCallback { + #[inline] fn as_raw_OCRBeamSearchDecoder_ClassifierCallback(&self) -> *const c_void { self.as_raw() } + } + + impl crate::text::OCRBeamSearchDecoder_ClassifierCallbackTrait for OCRBeamSearchDecoder_ClassifierCallback { + #[inline] fn as_raw_mut_OCRBeamSearchDecoder_ClassifierCallback(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { OCRBeamSearchDecoder_ClassifierCallback, crate::text::OCRBeamSearchDecoder_ClassifierCallbackTraitConst, as_raw_OCRBeamSearchDecoder_ClassifierCallback, crate::text::OCRBeamSearchDecoder_ClassifierCallbackTrait, as_raw_mut_OCRBeamSearchDecoder_ClassifierCallback } + + /// OCRHMMDecoder class provides an interface for OCR using Hidden Markov Models. + /// + /// + /// Note: + /// * (C++) An example on using OCRHMMDecoder recognition combined with scene text detection can + /// be found at the webcam_demo sample: + /// + pub struct OCRHMMDecoder { + ptr: *mut c_void, + } + + opencv_type_boxed! { OCRHMMDecoder } + + impl Drop for OCRHMMDecoder { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_text_OCRHMMDecoder_delete(self.as_raw_mut_OCRHMMDecoder()) }; + } + } + + unsafe impl Send for OCRHMMDecoder {} + + impl OCRHMMDecoder { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::text::OCRHMMDecoder { + let ret = unsafe { sys::cv_text_OCRHMMDecoder_defaultNew_const() }; + let ret = unsafe { crate::text::OCRHMMDecoder::opencv_from_extern(ret) }; + ret + } + + /// Creates an instance of the OCRHMMDecoder class. Initializes HMMDecoder. /// /// ## Parameters /// * classifier: The character classifier with built in feature extractor. /// - /// * vocabulary: The language vocabulary (chars when ASCII English text). vocabulary.size() + /// * vocabulary: The language vocabulary (chars when ascii english text). vocabulary.size() /// must be equal to the number of classes of the classifier. /// /// * transition_probabilities_table: Table with transition probabilities between character @@ -1913,32 +2162,27 @@ pub mod text { /// * mode: HMM Decoding algorithm. Only OCR_DECODER_VITERBI is available for the moment /// (). /// - /// * beam_size: Size of the beam in Beam Search algorithm. - /// /// ## C++ default parameters /// * mode: OCR_DECODER_VITERBI - /// * beam_size: 500 #[inline] - pub fn create(classifier: core::Ptr, vocabulary: &str, transition_probabilities_table: &impl ToInputArray, emission_probabilities_table: &impl ToInputArray, mode: crate::text::decoder_mode, beam_size: i32) -> Result> { + pub fn create(classifier: core::Ptr, vocabulary: &str, transition_probabilities_table: &impl ToInputArray, emission_probabilities_table: &impl ToInputArray, mode: i32) -> Result> { extern_container_arg!(vocabulary); input_array_arg!(transition_probabilities_table); input_array_arg!(emission_probabilities_table); return_send!(via ocvrs_return); - unsafe { sys::cv_text_OCRBeamSearchDecoder_create_const_PtrLClassifierCallbackG_const_stringR_const__InputArrayR_const__InputArrayR_decoder_mode_int(classifier.as_raw_PtrOfOCRBeamSearchDecoder_ClassifierCallback(), vocabulary.opencv_as_extern(), transition_probabilities_table.as_raw__InputArray(), emission_probabilities_table.as_raw__InputArray(), mode, beam_size, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_text_OCRHMMDecoder_create_const_PtrLClassifierCallbackG_const_StringR_const__InputArrayR_const__InputArrayR_int(classifier.as_raw_PtrOfOCRHMMDecoder_ClassifierCallback(), vocabulary.opencv_as_extern(), transition_probabilities_table.as_raw__InputArray(), emission_probabilities_table.as_raw__InputArray(), mode, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Creates an instance of the OCRBeamSearchDecoder class. Initializes HMMDecoder from the specified path. - /// - /// Creates an instance of the OCRBeamSearchDecoder class. Initializes HMMDecoder. + /// Creates an instance of the OCRHMMDecoder class. Initializes HMMDecoder. /// /// ## Parameters /// * classifier: The character classifier with built in feature extractor. /// - /// * vocabulary: The language vocabulary (chars when ASCII English text). vocabulary.size() + /// * vocabulary: The language vocabulary (chars when ascii english text). vocabulary.size() /// must be equal to the number of classes of the classifier. /// /// * transition_probabilities_table: Table with transition probabilities between character @@ -1950,175 +2194,84 @@ pub mod text { /// * mode: HMM Decoding algorithm. Only OCR_DECODER_VITERBI is available for the moment /// (). /// - /// * beam_size: Size of the beam in Beam Search algorithm. - /// - /// ## Overloaded parameters - /// - /// ## C++ default parameters + /// ## Note + /// This alternative version of [OCRHMMDecoder::create] function uses the following default values for its arguments: /// * mode: OCR_DECODER_VITERBI - /// * beam_size: 500 #[inline] - pub fn create_from_file(filename: &str, vocabulary: &str, transition_probabilities_table: &impl ToInputArray, emission_probabilities_table: &impl ToInputArray, mode: crate::text::decoder_mode, beam_size: i32) -> Result> { - extern_container_arg!(filename); + pub fn create_def(classifier: core::Ptr, vocabulary: &str, transition_probabilities_table: &impl ToInputArray, emission_probabilities_table: &impl ToInputArray) -> Result> { extern_container_arg!(vocabulary); input_array_arg!(transition_probabilities_table); input_array_arg!(emission_probabilities_table); return_send!(via ocvrs_return); - unsafe { sys::cv_text_OCRBeamSearchDecoder_create_const_StringR_const_StringR_const__InputArrayR_const__InputArrayR_decoder_mode_int(filename.opencv_as_extern(), vocabulary.opencv_as_extern(), transition_probabilities_table.as_raw__InputArray(), emission_probabilities_table.as_raw__InputArray(), mode, beam_size, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_text_OCRHMMDecoder_create_const_PtrLClassifierCallbackG_const_StringR_const__InputArrayR_const__InputArrayR(classifier.as_raw_PtrOfOCRHMMDecoder_ClassifierCallback(), vocabulary.opencv_as_extern(), transition_probabilities_table.as_raw__InputArray(), emission_probabilities_table.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Creates an instance of the OCRBeamSearchDecoder class. Initializes HMMDecoder from the specified path. + /// Creates an instance of the OCRHMMDecoder class. Loads and initializes HMMDecoder from the specified path /// - /// @overload + /// Creates an instance of the OCRHMMDecoder class. Initializes HMMDecoder. /// - /// ## Note - /// This alternative version of [OCRBeamSearchDecoder::create_from_file] function uses the following default values for its arguments: + /// ## Parameters + /// * classifier: The character classifier with built in feature extractor. + /// + /// * vocabulary: The language vocabulary (chars when ascii english text). vocabulary.size() + /// must be equal to the number of classes of the classifier. + /// + /// * transition_probabilities_table: Table with transition probabilities between character + /// pairs. cols == rows == vocabulary.size(). + /// + /// * emission_probabilities_table: Table with observation emission probabilities. cols == + /// rows == vocabulary.size(). + /// + /// * mode: HMM Decoding algorithm. Only OCR_DECODER_VITERBI is available for the moment + /// (). + /// + /// ## Overloaded parameters + /// + /// ## C++ default parameters /// * mode: OCR_DECODER_VITERBI - /// * beam_size: 500 + /// * classifier: OCR_KNN_CLASSIFIER #[inline] - pub fn create_from_file_def(filename: &str, vocabulary: &str, transition_probabilities_table: &impl ToInputArray, emission_probabilities_table: &impl ToInputArray) -> Result> { + pub fn create_from_file(filename: &str, vocabulary: &str, transition_probabilities_table: &impl ToInputArray, emission_probabilities_table: &impl ToInputArray, mode: i32, classifier: i32) -> Result> { extern_container_arg!(filename); extern_container_arg!(vocabulary); input_array_arg!(transition_probabilities_table); - input_array_arg!(emission_probabilities_table); - return_send!(via ocvrs_return); - unsafe { sys::cv_text_OCRBeamSearchDecoder_create_const_StringR_const_StringR_const__InputArrayR_const__InputArrayR(filename.opencv_as_extern(), vocabulary.opencv_as_extern(), transition_probabilities_table.as_raw__InputArray(), emission_probabilities_table.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { OCRBeamSearchDecoder, crate::text::BaseOCR, cv_text_OCRBeamSearchDecoder_to_BaseOCR } - - impl std::fmt::Debug for OCRBeamSearchDecoder { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("OCRBeamSearchDecoder") - .finish() - } - } - - impl Default for OCRBeamSearchDecoder { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - - /// Constant methods for [crate::text::OCRBeamSearchDecoder_ClassifierCallback] - pub trait OCRBeamSearchDecoder_ClassifierCallbackTraitConst { - fn as_raw_OCRBeamSearchDecoder_ClassifierCallback(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::text::OCRBeamSearchDecoder_ClassifierCallback] - pub trait OCRBeamSearchDecoder_ClassifierCallbackTrait: crate::text::OCRBeamSearchDecoder_ClassifierCallbackTraitConst { - fn as_raw_mut_OCRBeamSearchDecoder_ClassifierCallback(&mut self) -> *mut c_void; - - /// The character classifier must return a (ranked list of) class(es) id('s) - /// - /// ## Parameters - /// * image: Input image CV_8UC1 or CV_8UC3 with a single letter. - /// * recognition_probabilities: For each of the N characters found the classifier returns a list with - /// class probabilities for each class. - /// * oversegmentation: The classifier returns a list of N+1 character locations' x-coordinates, - /// including 0 as start-sequence location. - #[inline] - fn eval(&mut self, image: &impl ToInputArray, recognition_probabilities: &mut core::Vector>, oversegmentation: &mut core::Vector) -> Result<()> { - input_array_arg!(image); - return_send!(via ocvrs_return); - unsafe { sys::cv_text_OCRBeamSearchDecoder_ClassifierCallback_eval_const__InputArrayR_vectorLvectorLdoubleGGR_vectorLintGR(self.as_raw_mut_OCRBeamSearchDecoder_ClassifierCallback(), image.as_raw__InputArray(), recognition_probabilities.as_raw_mut_VectorOfVectorOff64(), oversegmentation.as_raw_mut_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_window_size(&mut self) -> Result { + input_array_arg!(emission_probabilities_table); return_send!(via ocvrs_return); - unsafe { sys::cv_text_OCRBeamSearchDecoder_ClassifierCallback_getWindowSize(self.as_raw_mut_OCRBeamSearchDecoder_ClassifierCallback(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_text_OCRHMMDecoder_create_const_StringR_const_StringR_const__InputArrayR_const__InputArrayR_int_int(filename.opencv_as_extern(), vocabulary.opencv_as_extern(), transition_probabilities_table.as_raw__InputArray(), emission_probabilities_table.as_raw__InputArray(), mode, classifier, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } + /// Creates an instance of the OCRHMMDecoder class. Loads and initializes HMMDecoder from the specified path + /// + /// @overload + /// + /// ## Note + /// This alternative version of [OCRHMMDecoder::create_from_file] function uses the following default values for its arguments: + /// * mode: OCR_DECODER_VITERBI + /// * classifier: OCR_KNN_CLASSIFIER #[inline] - fn get_step_size(&mut self) -> Result { + pub fn create_from_file_def(filename: &str, vocabulary: &str, transition_probabilities_table: &impl ToInputArray, emission_probabilities_table: &impl ToInputArray) -> Result> { + extern_container_arg!(filename); + extern_container_arg!(vocabulary); + input_array_arg!(transition_probabilities_table); + input_array_arg!(emission_probabilities_table); return_send!(via ocvrs_return); - unsafe { sys::cv_text_OCRBeamSearchDecoder_ClassifierCallback_getStepSize(self.as_raw_mut_OCRBeamSearchDecoder_ClassifierCallback(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_text_OCRHMMDecoder_create_const_StringR_const_StringR_const__InputArrayR_const__InputArrayR(filename.opencv_as_extern(), vocabulary.opencv_as_extern(), transition_probabilities_table.as_raw__InputArray(), emission_probabilities_table.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - /// Callback with the character classifier is made a class. - /// - /// This way it hides the feature extractor and the classifier itself, so developers can write - /// their own OCR code. - /// - /// The default character classifier and feature extractor can be loaded using the utility function - /// loadOCRBeamSearchClassifierCNN with all its parameters provided in - /// . - pub struct OCRBeamSearchDecoder_ClassifierCallback { - ptr: *mut c_void, - } - - opencv_type_boxed! { OCRBeamSearchDecoder_ClassifierCallback } - - impl Drop for OCRBeamSearchDecoder_ClassifierCallback { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_text_OCRBeamSearchDecoder_ClassifierCallback_delete(self.as_raw_mut_OCRBeamSearchDecoder_ClassifierCallback()) }; - } - } - - unsafe impl Send for OCRBeamSearchDecoder_ClassifierCallback {} - - impl crate::text::OCRBeamSearchDecoder_ClassifierCallbackTraitConst for OCRBeamSearchDecoder_ClassifierCallback { - #[inline] fn as_raw_OCRBeamSearchDecoder_ClassifierCallback(&self) -> *const c_void { self.as_raw() } - } - - impl crate::text::OCRBeamSearchDecoder_ClassifierCallbackTrait for OCRBeamSearchDecoder_ClassifierCallback { - #[inline] fn as_raw_mut_OCRBeamSearchDecoder_ClassifierCallback(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { OCRBeamSearchDecoder_ClassifierCallback, crate::text::OCRBeamSearchDecoder_ClassifierCallbackTraitConst, as_raw_OCRBeamSearchDecoder_ClassifierCallback, crate::text::OCRBeamSearchDecoder_ClassifierCallbackTrait, as_raw_mut_OCRBeamSearchDecoder_ClassifierCallback } - - impl OCRBeamSearchDecoder_ClassifierCallback { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_text_OCRBeamSearchDecoder_ClassifierCallback_defaultNew_const()) } - } - - } - - impl std::fmt::Debug for OCRBeamSearchDecoder_ClassifierCallback { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("OCRBeamSearchDecoder_ClassifierCallback") - .finish() - } - } - - impl Default for OCRBeamSearchDecoder_ClassifierCallback { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } - /// Constant methods for [crate::text::OCRHMMDecoder] pub trait OCRHMMDecoderTraitConst: crate::text::BaseOCRTraitConst { fn as_raw_OCRHMMDecoder(&self) -> *const c_void; @@ -2332,196 +2485,26 @@ pub mod text { /// This alternative version of [OCRHMMDecoderTrait::run_mask] function uses the following default values for its arguments: /// * component_level: 0 #[inline] - fn run_mask_def(&mut self, image: &impl ToInputArray, mask: &impl ToInputArray, min_confidence: i32) -> Result { - input_array_arg!(image); - input_array_arg!(mask); - return_send!(via ocvrs_return); - unsafe { sys::cv_text_OCRHMMDecoder_run_const__InputArrayR_const__InputArrayR_int(self.as_raw_mut_OCRHMMDecoder(), image.as_raw__InputArray(), mask.as_raw__InputArray(), min_confidence, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { String::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - /// OCRHMMDecoder class provides an interface for OCR using Hidden Markov Models. - /// - /// - /// Note: - /// * (C++) An example on using OCRHMMDecoder recognition combined with scene text detection can - /// be found at the webcam_demo sample: - /// - pub struct OCRHMMDecoder { - ptr: *mut c_void, - } - - opencv_type_boxed! { OCRHMMDecoder } - - impl Drop for OCRHMMDecoder { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_text_OCRHMMDecoder_delete(self.as_raw_mut_OCRHMMDecoder()) }; - } - } - - unsafe impl Send for OCRHMMDecoder {} - - impl crate::text::BaseOCRTraitConst for OCRHMMDecoder { - #[inline] fn as_raw_BaseOCR(&self) -> *const c_void { self.as_raw() } - } - - impl crate::text::BaseOCRTrait for OCRHMMDecoder { - #[inline] fn as_raw_mut_BaseOCR(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { OCRHMMDecoder, crate::text::BaseOCRTraitConst, as_raw_BaseOCR, crate::text::BaseOCRTrait, as_raw_mut_BaseOCR } - - impl crate::text::OCRHMMDecoderTraitConst for OCRHMMDecoder { - #[inline] fn as_raw_OCRHMMDecoder(&self) -> *const c_void { self.as_raw() } - } - - impl crate::text::OCRHMMDecoderTrait for OCRHMMDecoder { - #[inline] fn as_raw_mut_OCRHMMDecoder(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { OCRHMMDecoder, crate::text::OCRHMMDecoderTraitConst, as_raw_OCRHMMDecoder, crate::text::OCRHMMDecoderTrait, as_raw_mut_OCRHMMDecoder } - - impl OCRHMMDecoder { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_text_OCRHMMDecoder_defaultNew_const()) } - } - - /// Creates an instance of the OCRHMMDecoder class. Initializes HMMDecoder. - /// - /// ## Parameters - /// * classifier: The character classifier with built in feature extractor. - /// - /// * vocabulary: The language vocabulary (chars when ascii english text). vocabulary.size() - /// must be equal to the number of classes of the classifier. - /// - /// * transition_probabilities_table: Table with transition probabilities between character - /// pairs. cols == rows == vocabulary.size(). - /// - /// * emission_probabilities_table: Table with observation emission probabilities. cols == - /// rows == vocabulary.size(). - /// - /// * mode: HMM Decoding algorithm. Only OCR_DECODER_VITERBI is available for the moment - /// (). - /// - /// ## C++ default parameters - /// * mode: OCR_DECODER_VITERBI - #[inline] - pub fn create(classifier: core::Ptr, vocabulary: &str, transition_probabilities_table: &impl ToInputArray, emission_probabilities_table: &impl ToInputArray, mode: i32) -> Result> { - extern_container_arg!(vocabulary); - input_array_arg!(transition_probabilities_table); - input_array_arg!(emission_probabilities_table); - return_send!(via ocvrs_return); - unsafe { sys::cv_text_OCRHMMDecoder_create_const_PtrLClassifierCallbackG_const_StringR_const__InputArrayR_const__InputArrayR_int(classifier.as_raw_PtrOfOCRHMMDecoder_ClassifierCallback(), vocabulary.opencv_as_extern(), transition_probabilities_table.as_raw__InputArray(), emission_probabilities_table.as_raw__InputArray(), mode, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Creates an instance of the OCRHMMDecoder class. Initializes HMMDecoder. - /// - /// ## Parameters - /// * classifier: The character classifier with built in feature extractor. - /// - /// * vocabulary: The language vocabulary (chars when ascii english text). vocabulary.size() - /// must be equal to the number of classes of the classifier. - /// - /// * transition_probabilities_table: Table with transition probabilities between character - /// pairs. cols == rows == vocabulary.size(). - /// - /// * emission_probabilities_table: Table with observation emission probabilities. cols == - /// rows == vocabulary.size(). - /// - /// * mode: HMM Decoding algorithm. Only OCR_DECODER_VITERBI is available for the moment - /// (). - /// - /// ## Note - /// This alternative version of [OCRHMMDecoder::create] function uses the following default values for its arguments: - /// * mode: OCR_DECODER_VITERBI - #[inline] - pub fn create_def(classifier: core::Ptr, vocabulary: &str, transition_probabilities_table: &impl ToInputArray, emission_probabilities_table: &impl ToInputArray) -> Result> { - extern_container_arg!(vocabulary); - input_array_arg!(transition_probabilities_table); - input_array_arg!(emission_probabilities_table); - return_send!(via ocvrs_return); - unsafe { sys::cv_text_OCRHMMDecoder_create_const_PtrLClassifierCallbackG_const_StringR_const__InputArrayR_const__InputArrayR(classifier.as_raw_PtrOfOCRHMMDecoder_ClassifierCallback(), vocabulary.opencv_as_extern(), transition_probabilities_table.as_raw__InputArray(), emission_probabilities_table.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Creates an instance of the OCRHMMDecoder class. Loads and initializes HMMDecoder from the specified path - /// - /// Creates an instance of the OCRHMMDecoder class. Initializes HMMDecoder. - /// - /// ## Parameters - /// * classifier: The character classifier with built in feature extractor. - /// - /// * vocabulary: The language vocabulary (chars when ascii english text). vocabulary.size() - /// must be equal to the number of classes of the classifier. - /// - /// * transition_probabilities_table: Table with transition probabilities between character - /// pairs. cols == rows == vocabulary.size(). - /// - /// * emission_probabilities_table: Table with observation emission probabilities. cols == - /// rows == vocabulary.size(). - /// - /// * mode: HMM Decoding algorithm. Only OCR_DECODER_VITERBI is available for the moment - /// (). - /// - /// ## Overloaded parameters - /// - /// ## C++ default parameters - /// * mode: OCR_DECODER_VITERBI - /// * classifier: OCR_KNN_CLASSIFIER - #[inline] - pub fn create_from_file(filename: &str, vocabulary: &str, transition_probabilities_table: &impl ToInputArray, emission_probabilities_table: &impl ToInputArray, mode: i32, classifier: i32) -> Result> { - extern_container_arg!(filename); - extern_container_arg!(vocabulary); - input_array_arg!(transition_probabilities_table); - input_array_arg!(emission_probabilities_table); - return_send!(via ocvrs_return); - unsafe { sys::cv_text_OCRHMMDecoder_create_const_StringR_const_StringR_const__InputArrayR_const__InputArrayR_int_int(filename.opencv_as_extern(), vocabulary.opencv_as_extern(), transition_probabilities_table.as_raw__InputArray(), emission_probabilities_table.as_raw__InputArray(), mode, classifier, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Creates an instance of the OCRHMMDecoder class. Loads and initializes HMMDecoder from the specified path - /// - /// @overload - /// - /// ## Note - /// This alternative version of [OCRHMMDecoder::create_from_file] function uses the following default values for its arguments: - /// * mode: OCR_DECODER_VITERBI - /// * classifier: OCR_KNN_CLASSIFIER - #[inline] - pub fn create_from_file_def(filename: &str, vocabulary: &str, transition_probabilities_table: &impl ToInputArray, emission_probabilities_table: &impl ToInputArray) -> Result> { - extern_container_arg!(filename); - extern_container_arg!(vocabulary); - input_array_arg!(transition_probabilities_table); - input_array_arg!(emission_probabilities_table); + fn run_mask_def(&mut self, image: &impl ToInputArray, mask: &impl ToInputArray, min_confidence: i32) -> Result { + input_array_arg!(image); + input_array_arg!(mask); return_send!(via ocvrs_return); - unsafe { sys::cv_text_OCRHMMDecoder_create_const_StringR_const_StringR_const__InputArrayR_const__InputArrayR(filename.opencv_as_extern(), vocabulary.opencv_as_extern(), transition_probabilities_table.as_raw__InputArray(), emission_probabilities_table.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_text_OCRHMMDecoder_run_const__InputArrayR_const__InputArrayR_int(self.as_raw_mut_OCRHMMDecoder(), image.as_raw__InputArray(), mask.as_raw__InputArray(), min_confidence, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { String::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { OCRHMMDecoder, crate::text::BaseOCR, cv_text_OCRHMMDecoder_to_BaseOCR } + impl Default for OCRHMMDecoder { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } + } impl std::fmt::Debug for OCRHMMDecoder { #[inline] @@ -2531,12 +2514,60 @@ pub mod text { } } - impl Default for OCRHMMDecoder { + boxed_cast_base! { OCRHMMDecoder, crate::text::BaseOCR, cv_text_OCRHMMDecoder_to_BaseOCR } + + impl crate::text::BaseOCRTraitConst for OCRHMMDecoder { + #[inline] fn as_raw_BaseOCR(&self) -> *const c_void { self.as_raw() } + } + + impl crate::text::BaseOCRTrait for OCRHMMDecoder { + #[inline] fn as_raw_mut_BaseOCR(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { OCRHMMDecoder, crate::text::BaseOCRTraitConst, as_raw_BaseOCR, crate::text::BaseOCRTrait, as_raw_mut_BaseOCR } + + impl crate::text::OCRHMMDecoderTraitConst for OCRHMMDecoder { + #[inline] fn as_raw_OCRHMMDecoder(&self) -> *const c_void { self.as_raw() } + } + + impl crate::text::OCRHMMDecoderTrait for OCRHMMDecoder { + #[inline] fn as_raw_mut_OCRHMMDecoder(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { OCRHMMDecoder, crate::text::OCRHMMDecoderTraitConst, as_raw_OCRHMMDecoder, crate::text::OCRHMMDecoderTrait, as_raw_mut_OCRHMMDecoder } + + /// Callback with the character classifier is made a class. + /// + /// This way it hides the feature extractor and the classifier itself, so developers can write + /// their own OCR code. + /// + /// The default character classifier and feature extractor can be loaded using the utility function + /// loadOCRHMMClassifierNM and KNN model provided in + /// . + pub struct OCRHMMDecoder_ClassifierCallback { + ptr: *mut c_void, + } + + opencv_type_boxed! { OCRHMMDecoder_ClassifierCallback } + + impl Drop for OCRHMMDecoder_ClassifierCallback { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + fn drop(&mut self) { + unsafe { sys::cv_text_OCRHMMDecoder_ClassifierCallback_delete(self.as_raw_mut_OCRHMMDecoder_ClassifierCallback()) }; + } + } + + unsafe impl Send for OCRHMMDecoder_ClassifierCallback {} + + impl OCRHMMDecoder_ClassifierCallback { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::text::OCRHMMDecoder_ClassifierCallback { + let ret = unsafe { sys::cv_text_OCRHMMDecoder_ClassifierCallback_defaultNew_const() }; + let ret = unsafe { crate::text::OCRHMMDecoder_ClassifierCallback::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::text::OCRHMMDecoder_ClassifierCallback] @@ -2569,29 +2600,22 @@ pub mod text { } - /// Callback with the character classifier is made a class. - /// - /// This way it hides the feature extractor and the classifier itself, so developers can write - /// their own OCR code. - /// - /// The default character classifier and feature extractor can be loaded using the utility function - /// loadOCRHMMClassifierNM and KNN model provided in - /// . - pub struct OCRHMMDecoder_ClassifierCallback { - ptr: *mut c_void, + impl Default for OCRHMMDecoder_ClassifierCallback { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { OCRHMMDecoder_ClassifierCallback } - - impl Drop for OCRHMMDecoder_ClassifierCallback { + impl std::fmt::Debug for OCRHMMDecoder_ClassifierCallback { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_text_OCRHMMDecoder_ClassifierCallback_delete(self.as_raw_mut_OCRHMMDecoder_ClassifierCallback()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("OCRHMMDecoder_ClassifierCallback") + .finish() } } - unsafe impl Send for OCRHMMDecoder_ClassifierCallback {} - impl crate::text::OCRHMMDecoder_ClassifierCallbackTraitConst for OCRHMMDecoder_ClassifierCallback { #[inline] fn as_raw_OCRHMMDecoder_ClassifierCallback(&self) -> *const c_void { self.as_raw() } } @@ -2602,29 +2626,43 @@ pub mod text { boxed_ref! { OCRHMMDecoder_ClassifierCallback, crate::text::OCRHMMDecoder_ClassifierCallbackTraitConst, as_raw_OCRHMMDecoder_ClassifierCallback, crate::text::OCRHMMDecoder_ClassifierCallbackTrait, as_raw_mut_OCRHMMDecoder_ClassifierCallback } - impl OCRHMMDecoder_ClassifierCallback { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_text_OCRHMMDecoder_ClassifierCallback_defaultNew_const()) } - } - + /// OCRHolisticWordRecognizer class provides the functionallity of segmented wordspotting. + /// Given a predefined vocabulary , a DictNet is employed to select the most probable + /// word given an input image. + /// + /// DictNet is described in detail in: + /// Max Jaderberg et al.: Reading Text in the Wild with Convolutional Neural Networks, IJCV 2015 + /// + pub struct OCRHolisticWordRecognizer { + ptr: *mut c_void, } - impl std::fmt::Debug for OCRHMMDecoder_ClassifierCallback { + opencv_type_boxed! { OCRHolisticWordRecognizer } + + impl Drop for OCRHolisticWordRecognizer { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("OCRHMMDecoder_ClassifierCallback") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_text_OCRHolisticWordRecognizer_delete(self.as_raw_mut_OCRHolisticWordRecognizer()) }; } } - impl Default for OCRHMMDecoder_ClassifierCallback { + unsafe impl Send for OCRHolisticWordRecognizer {} + + impl OCRHolisticWordRecognizer { + /// Creates an instance of the OCRHolisticWordRecognizer class. #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn create(arch_filename: &str, weights_filename: &str, words_filename: &str) -> Result> { + extern_container_arg!(arch_filename); + extern_container_arg!(weights_filename); + extern_container_arg!(words_filename); + return_send!(via ocvrs_return); + unsafe { sys::cv_text_OCRHolisticWordRecognizer_create_const_stringR_const_stringR_const_stringR(arch_filename.opencv_as_extern(), weights_filename.opencv_as_extern(), words_filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::text::OCRHolisticWordRecognizer] @@ -2753,27 +2791,15 @@ pub mod text { } - /// OCRHolisticWordRecognizer class provides the functionallity of segmented wordspotting. - /// Given a predefined vocabulary , a DictNet is employed to select the most probable - /// word given an input image. - /// - /// DictNet is described in detail in: - /// Max Jaderberg et al.: Reading Text in the Wild with Convolutional Neural Networks, IJCV 2015 - /// - pub struct OCRHolisticWordRecognizer { - ptr: *mut c_void, - } - - opencv_type_boxed! { OCRHolisticWordRecognizer } - - impl Drop for OCRHolisticWordRecognizer { + impl std::fmt::Debug for OCRHolisticWordRecognizer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_text_OCRHolisticWordRecognizer_delete(self.as_raw_mut_OCRHolisticWordRecognizer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("OCRHolisticWordRecognizer") + .finish() } } - unsafe impl Send for OCRHolisticWordRecognizer {} + boxed_cast_base! { OCRHolisticWordRecognizer, crate::text::BaseOCR, cv_text_OCRHolisticWordRecognizer_to_BaseOCR } impl crate::text::BaseOCRTraitConst for OCRHolisticWordRecognizer { #[inline] fn as_raw_BaseOCR(&self) -> *const c_void { self.as_raw() } @@ -2795,33 +2821,108 @@ pub mod text { boxed_ref! { OCRHolisticWordRecognizer, crate::text::OCRHolisticWordRecognizerTraitConst, as_raw_OCRHolisticWordRecognizer, crate::text::OCRHolisticWordRecognizerTrait, as_raw_mut_OCRHolisticWordRecognizer } - impl OCRHolisticWordRecognizer { - /// Creates an instance of the OCRHolisticWordRecognizer class. + /// OCRTesseract class provides an interface with the tesseract-ocr API (v3.02.02) in C++. + /// + /// Notice that it is compiled only when tesseract-ocr is correctly installed. + /// + /// + /// Note: + /// * (C++) An example of OCRTesseract recognition combined with scene text detection can be found + /// at the end_to_end_recognition demo: + /// + /// * (C++) Another example of OCRTesseract recognition combined with scene text detection can be + /// found at the webcam_demo: + /// + pub struct OCRTesseract { + ptr: *mut c_void, + } + + opencv_type_boxed! { OCRTesseract } + + impl Drop for OCRTesseract { #[inline] - pub fn create(arch_filename: &str, weights_filename: &str, words_filename: &str) -> Result> { - extern_container_arg!(arch_filename); - extern_container_arg!(weights_filename); - extern_container_arg!(words_filename); + fn drop(&mut self) { + unsafe { sys::cv_text_OCRTesseract_delete(self.as_raw_mut_OCRTesseract()) }; + } + } + + unsafe impl Send for OCRTesseract {} + + impl OCRTesseract { + /// Creates an instance of the OCRTesseract class. Initializes Tesseract. + /// + /// ## Parameters + /// * datapath: the name of the parent directory of tessdata ended with "/", or NULL to use the + /// system's default directory. + /// * language: an ISO 639-3 code or NULL will default to "eng". + /// * char_whitelist: specifies the list of characters used for recognition. NULL defaults to "" + /// (All characters will be used for recognition). + /// * oem: tesseract-ocr offers different OCR Engine Modes (OEM), by default + /// tesseract::OEM_DEFAULT is used. See the tesseract-ocr API documentation for other possible + /// values. + /// * psmode: tesseract-ocr offers different Page Segmentation Modes (PSM) tesseract::PSM_AUTO + /// (fully automatic layout analysis) is used. See the tesseract-ocr API documentation for other + /// possible values. + /// + /// + /// Note: The char_whitelist default is changed after OpenCV 4.7.0/3.19.0 from "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" to "". + /// + /// ## C++ default parameters + /// * datapath: NULL + /// * language: NULL + /// * char_whitelist: NULL + /// * oem: OEM_DEFAULT + /// * psmode: PSM_AUTO + #[inline] + pub fn create(datapath: &str, language: &str, char_whitelist: &str, oem: i32, psmode: i32) -> Result> { + extern_container_arg!(datapath); + extern_container_arg!(language); + extern_container_arg!(char_whitelist); + return_send!(via ocvrs_return); + unsafe { sys::cv_text_OCRTesseract_create_const_charX_const_charX_const_charX_int_int(datapath.opencv_as_extern(), language.opencv_as_extern(), char_whitelist.opencv_as_extern(), oem, psmode, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Creates an instance of the OCRTesseract class. Initializes Tesseract. + /// + /// ## Parameters + /// * datapath: the name of the parent directory of tessdata ended with "/", or NULL to use the + /// system's default directory. + /// * language: an ISO 639-3 code or NULL will default to "eng". + /// * char_whitelist: specifies the list of characters used for recognition. NULL defaults to "" + /// (All characters will be used for recognition). + /// * oem: tesseract-ocr offers different OCR Engine Modes (OEM), by default + /// tesseract::OEM_DEFAULT is used. See the tesseract-ocr API documentation for other possible + /// values. + /// * psmode: tesseract-ocr offers different Page Segmentation Modes (PSM) tesseract::PSM_AUTO + /// (fully automatic layout analysis) is used. See the tesseract-ocr API documentation for other + /// possible values. + /// + /// + /// Note: The char_whitelist default is changed after OpenCV 4.7.0/3.19.0 from "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" to "". + /// + /// ## Note + /// This alternative version of [OCRTesseract::create] function uses the following default values for its arguments: + /// * datapath: NULL + /// * language: NULL + /// * char_whitelist: NULL + /// * oem: OEM_DEFAULT + /// * psmode: PSM_AUTO + #[inline] + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_text_OCRHolisticWordRecognizer_create_const_stringR_const_stringR_const_stringR(arch_filename.opencv_as_extern(), weights_filename.opencv_as_extern(), words_filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_text_OCRTesseract_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { OCRHolisticWordRecognizer, crate::text::BaseOCR, cv_text_OCRHolisticWordRecognizer_to_BaseOCR } - - impl std::fmt::Debug for OCRHolisticWordRecognizer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("OCRHolisticWordRecognizer") - .finish() - } - } - /// Constant methods for [crate::text::OCRTesseract] pub trait OCRTesseractTraitConst: crate::text::BaseOCRTraitConst { fn as_raw_OCRTesseract(&self) -> *const c_void; @@ -3000,32 +3101,15 @@ pub mod text { } - /// OCRTesseract class provides an interface with the tesseract-ocr API (v3.02.02) in C++. - /// - /// Notice that it is compiled only when tesseract-ocr is correctly installed. - /// - /// - /// Note: - /// * (C++) An example of OCRTesseract recognition combined with scene text detection can be found - /// at the end_to_end_recognition demo: - /// - /// * (C++) Another example of OCRTesseract recognition combined with scene text detection can be - /// found at the webcam_demo: - /// - pub struct OCRTesseract { - ptr: *mut c_void, - } - - opencv_type_boxed! { OCRTesseract } - - impl Drop for OCRTesseract { + impl std::fmt::Debug for OCRTesseract { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_text_OCRTesseract_delete(self.as_raw_mut_OCRTesseract()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("OCRTesseract") + .finish() } } - unsafe impl Send for OCRTesseract {} + boxed_cast_base! { OCRTesseract, crate::text::BaseOCR, cv_text_OCRTesseract_to_BaseOCR } impl crate::text::BaseOCRTraitConst for OCRTesseract { #[inline] fn as_raw_BaseOCR(&self) -> *const c_void { self.as_raw() } @@ -3047,91 +3131,22 @@ pub mod text { boxed_ref! { OCRTesseract, crate::text::OCRTesseractTraitConst, as_raw_OCRTesseract, crate::text::OCRTesseractTrait, as_raw_mut_OCRTesseract } - impl OCRTesseract { - /// Creates an instance of the OCRTesseract class. Initializes Tesseract. - /// - /// ## Parameters - /// * datapath: the name of the parent directory of tessdata ended with "/", or NULL to use the - /// system's default directory. - /// * language: an ISO 639-3 code or NULL will default to "eng". - /// * char_whitelist: specifies the list of characters used for recognition. NULL defaults to "" - /// (All characters will be used for recognition). - /// * oem: tesseract-ocr offers different OCR Engine Modes (OEM), by default - /// tesseract::OEM_DEFAULT is used. See the tesseract-ocr API documentation for other possible - /// values. - /// * psmode: tesseract-ocr offers different Page Segmentation Modes (PSM) tesseract::PSM_AUTO - /// (fully automatic layout analysis) is used. See the tesseract-ocr API documentation for other - /// possible values. - /// - /// - /// Note: The char_whitelist default is changed after OpenCV 4.7.0/3.19.0 from "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" to "". - /// - /// ## C++ default parameters - /// * datapath: NULL - /// * language: NULL - /// * char_whitelist: NULL - /// * oem: OEM_DEFAULT - /// * psmode: PSM_AUTO - #[inline] - pub fn create(datapath: &str, language: &str, char_whitelist: &str, oem: i32, psmode: i32) -> Result> { - extern_container_arg!(datapath); - extern_container_arg!(language); - extern_container_arg!(char_whitelist); - return_send!(via ocvrs_return); - unsafe { sys::cv_text_OCRTesseract_create_const_charX_const_charX_const_charX_int_int(datapath.opencv_as_extern(), language.opencv_as_extern(), char_whitelist.opencv_as_extern(), oem, psmode, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Creates an instance of the OCRTesseract class. Initializes Tesseract. - /// - /// ## Parameters - /// * datapath: the name of the parent directory of tessdata ended with "/", or NULL to use the - /// system's default directory. - /// * language: an ISO 639-3 code or NULL will default to "eng". - /// * char_whitelist: specifies the list of characters used for recognition. NULL defaults to "" - /// (All characters will be used for recognition). - /// * oem: tesseract-ocr offers different OCR Engine Modes (OEM), by default - /// tesseract::OEM_DEFAULT is used. See the tesseract-ocr API documentation for other possible - /// values. - /// * psmode: tesseract-ocr offers different Page Segmentation Modes (PSM) tesseract::PSM_AUTO - /// (fully automatic layout analysis) is used. See the tesseract-ocr API documentation for other - /// possible values. - /// - /// - /// Note: The char_whitelist default is changed after OpenCV 4.7.0/3.19.0 from "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" to "". - /// - /// ## Note - /// This alternative version of [OCRTesseract::create] function uses the following default values for its arguments: - /// * datapath: NULL - /// * language: NULL - /// * char_whitelist: NULL - /// * oem: OEM_DEFAULT - /// * psmode: PSM_AUTO - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_text_OCRTesseract_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + /// An abstract class providing interface for text detection algorithms + pub struct TextDetector { + ptr: *mut c_void, } - boxed_cast_base! { OCRTesseract, crate::text::BaseOCR, cv_text_OCRTesseract_to_BaseOCR } + opencv_type_boxed! { TextDetector } - impl std::fmt::Debug for OCRTesseract { + impl Drop for TextDetector { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("OCRTesseract") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_text_TextDetector_delete(self.as_raw_mut_TextDetector()) }; } } + unsafe impl Send for TextDetector {} + /// Constant methods for [crate::text::TextDetector] pub trait TextDetectorTraitConst { fn as_raw_TextDetector(&self) -> *const c_void; @@ -3160,21 +3175,15 @@ pub mod text { } - /// An abstract class providing interface for text detection algorithms - pub struct TextDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { TextDetector } - - impl Drop for TextDetector { + impl std::fmt::Debug for TextDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_text_TextDetector_delete(self.as_raw_mut_TextDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TextDetector") + .finish() } } - unsafe impl Send for TextDetector {} + boxed_cast_descendant! { TextDetector, crate::text::TextDetectorCNN, cv_text_TextDetector_to_TextDetectorCNN } impl crate::text::TextDetectorTraitConst for TextDetector { #[inline] fn as_raw_TextDetector(&self) -> *const c_void { self.as_raw() } @@ -3186,47 +3195,6 @@ pub mod text { boxed_ref! { TextDetector, crate::text::TextDetectorTraitConst, as_raw_TextDetector, crate::text::TextDetectorTrait, as_raw_mut_TextDetector } - impl TextDetector { - } - - boxed_cast_descendant! { TextDetector, crate::text::TextDetectorCNN, cv_text_TextDetector_to_TextDetectorCNN } - - impl std::fmt::Debug for TextDetector { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TextDetector") - .finish() - } - } - - /// Constant methods for [crate::text::TextDetectorCNN] - pub trait TextDetectorCNNTraitConst: crate::text::TextDetectorTraitConst { - fn as_raw_TextDetectorCNN(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::text::TextDetectorCNN] - pub trait TextDetectorCNNTrait: crate::text::TextDetectorCNNTraitConst + crate::text::TextDetectorTrait { - fn as_raw_mut_TextDetectorCNN(&mut self) -> *mut c_void; - - /// This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. - /// - /// ## Parameters - /// * inputImage: an image expected to be a CV_U8C3 of any size - /// * Bbox: a vector of Rect that will store the detected word bounding box - /// * confidence: a vector of float that will be updated with the confidence the classifier has for the selected bounding box - #[inline] - fn detect(&mut self, input_image: &impl ToInputArray, bbox: &mut core::Vector, confidence: &mut core::Vector) -> Result<()> { - input_array_arg!(input_image); - return_send!(via ocvrs_return); - unsafe { sys::cv_text_TextDetectorCNN_detect_const__InputArrayR_vectorLRectGR_vectorLfloatGR(self.as_raw_mut_TextDetectorCNN(), input_image.as_raw__InputArray(), bbox.as_raw_mut_VectorOfRect(), confidence.as_raw_mut_VectorOff32(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - /// TextDetectorCNN class provides the functionallity of text bounding box detection. /// This class is representing to find bounding boxes of text words given an input image. /// This class uses OpenCV dnn module to load pre-trained model described in [LiaoSBWL17](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_LiaoSBWL17). @@ -3248,26 +3216,6 @@ pub mod text { unsafe impl Send for TextDetectorCNN {} - impl crate::text::TextDetectorTraitConst for TextDetectorCNN { - #[inline] fn as_raw_TextDetector(&self) -> *const c_void { self.as_raw() } - } - - impl crate::text::TextDetectorTrait for TextDetectorCNN { - #[inline] fn as_raw_mut_TextDetector(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TextDetectorCNN, crate::text::TextDetectorTraitConst, as_raw_TextDetector, crate::text::TextDetectorTrait, as_raw_mut_TextDetector } - - impl crate::text::TextDetectorCNNTraitConst for TextDetectorCNN { - #[inline] fn as_raw_TextDetectorCNN(&self) -> *const c_void { self.as_raw() } - } - - impl crate::text::TextDetectorCNNTrait for TextDetectorCNN { - #[inline] fn as_raw_mut_TextDetectorCNN(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TextDetectorCNN, crate::text::TextDetectorCNNTraitConst, as_raw_TextDetectorCNN, crate::text::TextDetectorCNNTrait, as_raw_mut_TextDetectorCNN } - impl TextDetectorCNN { /// Creates an instance of the TextDetectorCNN class using the provided parameters. /// @@ -3311,7 +3259,33 @@ pub mod text { } - boxed_cast_base! { TextDetectorCNN, crate::text::TextDetector, cv_text_TextDetectorCNN_to_TextDetector } + /// Constant methods for [crate::text::TextDetectorCNN] + pub trait TextDetectorCNNTraitConst: crate::text::TextDetectorTraitConst { + fn as_raw_TextDetectorCNN(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::text::TextDetectorCNN] + pub trait TextDetectorCNNTrait: crate::text::TextDetectorCNNTraitConst + crate::text::TextDetectorTrait { + fn as_raw_mut_TextDetectorCNN(&mut self) -> *mut c_void; + + /// This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. + /// + /// ## Parameters + /// * inputImage: an image expected to be a CV_U8C3 of any size + /// * Bbox: a vector of Rect that will store the detected word bounding box + /// * confidence: a vector of float that will be updated with the confidence the classifier has for the selected bounding box + #[inline] + fn detect(&mut self, input_image: &impl ToInputArray, bbox: &mut core::Vector, confidence: &mut core::Vector) -> Result<()> { + input_array_arg!(input_image); + return_send!(via ocvrs_return); + unsafe { sys::cv_text_TextDetectorCNN_detect_const__InputArrayR_vectorLRectGR_vectorLfloatGR(self.as_raw_mut_TextDetectorCNN(), input_image.as_raw__InputArray(), bbox.as_raw_mut_VectorOfRect(), confidence.as_raw_mut_VectorOff32(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } impl std::fmt::Debug for TextDetectorCNN { #[inline] @@ -3320,4 +3294,27 @@ pub mod text { .finish() } } + + boxed_cast_base! { TextDetectorCNN, crate::text::TextDetector, cv_text_TextDetectorCNN_to_TextDetector } + + impl crate::text::TextDetectorTraitConst for TextDetectorCNN { + #[inline] fn as_raw_TextDetector(&self) -> *const c_void { self.as_raw() } + } + + impl crate::text::TextDetectorTrait for TextDetectorCNN { + #[inline] fn as_raw_mut_TextDetector(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { TextDetectorCNN, crate::text::TextDetectorTraitConst, as_raw_TextDetector, crate::text::TextDetectorTrait, as_raw_mut_TextDetector } + + impl crate::text::TextDetectorCNNTraitConst for TextDetectorCNN { + #[inline] fn as_raw_TextDetectorCNN(&self) -> *const c_void { self.as_raw() } + } + + impl crate::text::TextDetectorCNNTrait for TextDetectorCNN { + #[inline] fn as_raw_mut_TextDetectorCNN(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { TextDetectorCNN, crate::text::TextDetectorCNNTraitConst, as_raw_TextDetectorCNN, crate::text::TextDetectorCNNTrait, as_raw_mut_TextDetectorCNN } + } diff --git a/docs/tracking.rs b/docs/tracking.rs index 962c7b73c..1f89316da 100644 --- a/docs/tracking.rs +++ b/docs/tracking.rs @@ -39,28 +39,6 @@ pub mod tracking { opencv_type_enum! { crate::tracking::TrackerKCF_MODE } pub type TrackerKCF_FeatureExtractorCallbackFN = Option ()>; - /// Constant methods for [crate::tracking::TrackerCSRT] - pub trait TrackerCSRTTraitConst: crate::video::TrackerTraitConst { - fn as_raw_TrackerCSRT(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::tracking::TrackerCSRT] - pub trait TrackerCSRTTrait: crate::tracking::TrackerCSRTTraitConst + crate::video::TrackerTrait { - fn as_raw_mut_TrackerCSRT(&mut self) -> *mut c_void; - - #[inline] - fn set_initial_mask(&mut self, mask: &impl ToInputArray) -> Result<()> { - input_array_arg!(mask); - return_send!(via ocvrs_return); - unsafe { sys::cv_tracking_TrackerCSRT_setInitialMask_const__InputArrayR(self.as_raw_mut_TrackerCSRT(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - /// the CSRT tracker /// /// The implementation is based on [Lukezic_IJCV2018](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Lukezic_IJCV2018) Discriminative Correlation Filter with Channel and Spatial Reliability @@ -79,26 +57,6 @@ pub mod tracking { unsafe impl Send for TrackerCSRT {} - impl crate::video::TrackerTraitConst for TrackerCSRT { - #[inline] fn as_raw_Tracker(&self) -> *const c_void { self.as_raw() } - } - - impl crate::video::TrackerTrait for TrackerCSRT { - #[inline] fn as_raw_mut_Tracker(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TrackerCSRT, crate::video::TrackerTraitConst, as_raw_Tracker, crate::video::TrackerTrait, as_raw_mut_Tracker } - - impl crate::tracking::TrackerCSRTTraitConst for TrackerCSRT { - #[inline] fn as_raw_TrackerCSRT(&self) -> *const c_void { self.as_raw() } - } - - impl crate::tracking::TrackerCSRTTrait for TrackerCSRT { - #[inline] fn as_raw_mut_TrackerCSRT(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TrackerCSRT, crate::tracking::TrackerCSRTTraitConst, as_raw_TrackerCSRT, crate::tracking::TrackerCSRTTrait, as_raw_mut_TrackerCSRT } - impl TrackerCSRT { /// Create CSRT tracker instance /// ## Parameters @@ -135,7 +93,27 @@ pub mod tracking { } - boxed_cast_base! { TrackerCSRT, crate::video::Tracker, cv_tracking_TrackerCSRT_to_Tracker } + /// Constant methods for [crate::tracking::TrackerCSRT] + pub trait TrackerCSRTTraitConst: crate::video::TrackerTraitConst { + fn as_raw_TrackerCSRT(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::tracking::TrackerCSRT] + pub trait TrackerCSRTTrait: crate::tracking::TrackerCSRTTraitConst + crate::video::TrackerTrait { + fn as_raw_mut_TrackerCSRT(&mut self) -> *mut c_void; + + #[inline] + fn set_initial_mask(&mut self, mask: &impl ToInputArray) -> Result<()> { + input_array_arg!(mask); + return_send!(via ocvrs_return); + unsafe { sys::cv_tracking_TrackerCSRT_setInitialMask_const__InputArrayR(self.as_raw_mut_TrackerCSRT(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } impl std::fmt::Debug for TrackerCSRT { #[inline] @@ -145,6 +123,56 @@ pub mod tracking { } } + boxed_cast_base! { TrackerCSRT, crate::video::Tracker, cv_tracking_TrackerCSRT_to_Tracker } + + impl crate::video::TrackerTraitConst for TrackerCSRT { + #[inline] fn as_raw_Tracker(&self) -> *const c_void { self.as_raw() } + } + + impl crate::video::TrackerTrait for TrackerCSRT { + #[inline] fn as_raw_mut_Tracker(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { TrackerCSRT, crate::video::TrackerTraitConst, as_raw_Tracker, crate::video::TrackerTrait, as_raw_mut_Tracker } + + impl crate::tracking::TrackerCSRTTraitConst for TrackerCSRT { + #[inline] fn as_raw_TrackerCSRT(&self) -> *const c_void { self.as_raw() } + } + + impl crate::tracking::TrackerCSRTTrait for TrackerCSRT { + #[inline] fn as_raw_mut_TrackerCSRT(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { TrackerCSRT, crate::tracking::TrackerCSRTTraitConst, as_raw_TrackerCSRT, crate::tracking::TrackerCSRTTrait, as_raw_mut_TrackerCSRT } + + pub struct TrackerCSRT_Params { + ptr: *mut c_void, + } + + opencv_type_boxed! { TrackerCSRT_Params } + + impl Drop for TrackerCSRT_Params { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_tracking_TrackerCSRT_Params_delete(self.as_raw_mut_TrackerCSRT_Params()) }; + } + } + + unsafe impl Send for TrackerCSRT_Params {} + + impl TrackerCSRT_Params { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_tracking_TrackerCSRT_Params_Params(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::tracking::TrackerCSRT_Params::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::tracking::TrackerCSRT_Params] pub trait TrackerCSRT_ParamsTraitConst { fn as_raw_TrackerCSRT_Params(&self) -> *const c_void; @@ -487,44 +515,6 @@ pub mod tracking { } - pub struct TrackerCSRT_Params { - ptr: *mut c_void, - } - - opencv_type_boxed! { TrackerCSRT_Params } - - impl Drop for TrackerCSRT_Params { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_tracking_TrackerCSRT_Params_delete(self.as_raw_mut_TrackerCSRT_Params()) }; - } - } - - unsafe impl Send for TrackerCSRT_Params {} - - impl crate::tracking::TrackerCSRT_ParamsTraitConst for TrackerCSRT_Params { - #[inline] fn as_raw_TrackerCSRT_Params(&self) -> *const c_void { self.as_raw() } - } - - impl crate::tracking::TrackerCSRT_ParamsTrait for TrackerCSRT_Params { - #[inline] fn as_raw_mut_TrackerCSRT_Params(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TrackerCSRT_Params, crate::tracking::TrackerCSRT_ParamsTraitConst, as_raw_TrackerCSRT_Params, crate::tracking::TrackerCSRT_ParamsTrait, as_raw_mut_TrackerCSRT_Params } - - impl TrackerCSRT_Params { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_tracking_TrackerCSRT_Params_Params(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::tracking::TrackerCSRT_Params::opencv_from_extern(ret) }; - Ok(ret) - } - - } - impl Clone for TrackerCSRT_Params { #[inline] fn clone(&self) -> Self { @@ -567,41 +557,16 @@ pub mod tracking { } } - /// Constant methods for [crate::tracking::TrackerKCF] - pub trait TrackerKCFTraitConst: crate::video::TrackerTraitConst { - fn as_raw_TrackerKCF(&self) -> *const c_void; - + impl crate::tracking::TrackerCSRT_ParamsTraitConst for TrackerCSRT_Params { + #[inline] fn as_raw_TrackerCSRT_Params(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::tracking::TrackerKCF] - pub trait TrackerKCFTrait: crate::tracking::TrackerKCFTraitConst + crate::video::TrackerTrait { - fn as_raw_mut_TrackerKCF(&mut self) -> *mut c_void; - - /// ## C++ default parameters - /// * pca_func: false - #[inline] - fn set_feature_extractor(&mut self, callback: crate::tracking::TrackerKCF_FeatureExtractorCallbackFN, pca_func: bool) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_tracking_TrackerKCF_setFeatureExtractor_FeatureExtractorCallbackFN_bool(self.as_raw_mut_TrackerKCF(), callback, pca_func, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// ## Note - /// This alternative version of [TrackerKCFTrait::set_feature_extractor] function uses the following default values for its arguments: - /// * pca_func: false - #[inline] - fn set_feature_extractor_def(&mut self, callback: crate::tracking::TrackerKCF_FeatureExtractorCallbackFN) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_tracking_TrackerKCF_setFeatureExtractor_FeatureExtractorCallbackFN(self.as_raw_mut_TrackerKCF(), callback, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - + impl crate::tracking::TrackerCSRT_ParamsTrait for TrackerCSRT_Params { + #[inline] fn as_raw_mut_TrackerCSRT_Params(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { TrackerCSRT_Params, crate::tracking::TrackerCSRT_ParamsTraitConst, as_raw_TrackerCSRT_Params, crate::tracking::TrackerCSRT_ParamsTrait, as_raw_mut_TrackerCSRT_Params } + /// the KCF (Kernelized Correlation Filter) tracker /// /// * KCF is a novel tracking framework that utilizes properties of circulant matrix to enhance the processing speed. @@ -624,26 +589,6 @@ pub mod tracking { unsafe impl Send for TrackerKCF {} - impl crate::video::TrackerTraitConst for TrackerKCF { - #[inline] fn as_raw_Tracker(&self) -> *const c_void { self.as_raw() } - } - - impl crate::video::TrackerTrait for TrackerKCF { - #[inline] fn as_raw_mut_Tracker(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TrackerKCF, crate::video::TrackerTraitConst, as_raw_Tracker, crate::video::TrackerTrait, as_raw_mut_Tracker } - - impl crate::tracking::TrackerKCFTraitConst for TrackerKCF { - #[inline] fn as_raw_TrackerKCF(&self) -> *const c_void { self.as_raw() } - } - - impl crate::tracking::TrackerKCFTrait for TrackerKCF { - #[inline] fn as_raw_mut_TrackerKCF(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TrackerKCF, crate::tracking::TrackerKCFTraitConst, as_raw_TrackerKCF, crate::tracking::TrackerKCFTrait, as_raw_mut_TrackerKCF } - impl TrackerKCF { /// Create KCF tracker instance /// ## Parameters @@ -680,7 +625,40 @@ pub mod tracking { } - boxed_cast_base! { TrackerKCF, crate::video::Tracker, cv_tracking_TrackerKCF_to_Tracker } + /// Constant methods for [crate::tracking::TrackerKCF] + pub trait TrackerKCFTraitConst: crate::video::TrackerTraitConst { + fn as_raw_TrackerKCF(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::tracking::TrackerKCF] + pub trait TrackerKCFTrait: crate::tracking::TrackerKCFTraitConst + crate::video::TrackerTrait { + fn as_raw_mut_TrackerKCF(&mut self) -> *mut c_void; + + /// ## C++ default parameters + /// * pca_func: false + #[inline] + fn set_feature_extractor(&mut self, callback: crate::tracking::TrackerKCF_FeatureExtractorCallbackFN, pca_func: bool) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_tracking_TrackerKCF_setFeatureExtractor_FeatureExtractorCallbackFN_bool(self.as_raw_mut_TrackerKCF(), callback, pca_func, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// ## Note + /// This alternative version of [TrackerKCFTrait::set_feature_extractor] function uses the following default values for its arguments: + /// * pca_func: false + #[inline] + fn set_feature_extractor_def(&mut self, callback: crate::tracking::TrackerKCF_FeatureExtractorCallbackFN) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_tracking_TrackerKCF_setFeatureExtractor_FeatureExtractorCallbackFN(self.as_raw_mut_TrackerKCF(), callback, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } impl std::fmt::Debug for TrackerKCF { #[inline] @@ -690,6 +668,28 @@ pub mod tracking { } } + boxed_cast_base! { TrackerKCF, crate::video::Tracker, cv_tracking_TrackerKCF_to_Tracker } + + impl crate::video::TrackerTraitConst for TrackerKCF { + #[inline] fn as_raw_Tracker(&self) -> *const c_void { self.as_raw() } + } + + impl crate::video::TrackerTrait for TrackerKCF { + #[inline] fn as_raw_mut_Tracker(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { TrackerKCF, crate::video::TrackerTraitConst, as_raw_Tracker, crate::video::TrackerTrait, as_raw_mut_Tracker } + + impl crate::tracking::TrackerKCFTraitConst for TrackerKCF { + #[inline] fn as_raw_TrackerKCF(&self) -> *const c_void { self.as_raw() } + } + + impl crate::tracking::TrackerKCFTrait for TrackerKCF { + #[inline] fn as_raw_mut_TrackerKCF(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { TrackerKCF, crate::tracking::TrackerKCFTraitConst, as_raw_TrackerKCF, crate::tracking::TrackerKCFTrait, as_raw_mut_TrackerKCF } + #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] pub struct TrackerKCF_Params { @@ -736,4 +736,5 @@ pub mod tracking { } } + } diff --git a/docs/types.rs b/docs/types.rs index 7b0d47822..da6048e24 100644 --- a/docs/types.rs +++ b/docs/types.rs @@ -656,14 +656,6 @@ mod core_types { #[inline] fn as_raw_mut_GpuMat_Allocator(&mut self) -> extern_send!(mut Self) { self.as_raw_mut() } } - impl core::MatOpTraitConst for types::AbstractRefMut<'static, core::MatOp> { - #[inline] fn as_raw_MatOp(&self) -> extern_send!(Self) { self.as_raw() } - } - - impl core::MatOpTrait for types::AbstractRefMut<'static, core::MatOp> { - #[inline] fn as_raw_mut_MatOp(&mut self) -> extern_send!(mut Self) { self.as_raw_mut() } - } - ptr_extern! { core::Algorithm, cv_PtrLcv_AlgorithmG_new_null_const, cv_PtrLcv_AlgorithmG_delete, cv_PtrLcv_AlgorithmG_getInnerPtr_const, cv_PtrLcv_AlgorithmG_getInnerPtrMut } @@ -3945,6 +3937,14 @@ mod core_types { output_array_ref_forward! { core::Vector } + impl core::MatOpTraitConst for types::AbstractRefMut<'static, core::MatOp> { + #[inline] fn as_raw_MatOp(&self) -> extern_send!(Self) { self.as_raw() } + } + + impl core::MatOpTrait for types::AbstractRefMut<'static, core::MatOp> { + #[inline] fn as_raw_mut_MatOp(&mut self) -> extern_send!(mut Self) { self.as_raw_mut() } + } + } pub use core_types::*; diff --git a/docs/video.rs b/docs/video.rs index bdab975d7..e36bdba8c 100644 --- a/docs/video.rs +++ b/docs/video.rs @@ -712,6 +712,25 @@ pub mod video { Ok(ret) } + /// Base class for background/foreground segmentation. : + /// + /// The class is only used to define the common interface for the whole family of background/foreground + /// segmentation algorithms. + pub struct BackgroundSubtractor { + ptr: *mut c_void, + } + + opencv_type_boxed! { BackgroundSubtractor } + + impl Drop for BackgroundSubtractor { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_BackgroundSubtractor_delete(self.as_raw_mut_BackgroundSubtractor()) }; + } + } + + unsafe impl Send for BackgroundSubtractor {} + /// Constant methods for [crate::video::BackgroundSubtractor] pub trait BackgroundSubtractorTraitConst: core::AlgorithmTraitConst { fn as_raw_BackgroundSubtractor(&self) -> *const c_void; @@ -789,24 +808,19 @@ pub mod video { } - /// Base class for background/foreground segmentation. : - /// - /// The class is only used to define the common interface for the whole family of background/foreground - /// segmentation algorithms. - pub struct BackgroundSubtractor { - ptr: *mut c_void, - } - - opencv_type_boxed! { BackgroundSubtractor } - - impl Drop for BackgroundSubtractor { + impl std::fmt::Debug for BackgroundSubtractor { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_BackgroundSubtractor_delete(self.as_raw_mut_BackgroundSubtractor()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BackgroundSubtractor") + .finish() } } - unsafe impl Send for BackgroundSubtractor {} + boxed_cast_base! { BackgroundSubtractor, core::Algorithm, cv_BackgroundSubtractor_to_Algorithm } + + boxed_cast_descendant! { BackgroundSubtractor, crate::video::BackgroundSubtractorKNN, cv_BackgroundSubtractor_to_BackgroundSubtractorKNN } + + boxed_cast_descendant! { BackgroundSubtractor, crate::video::BackgroundSubtractorMOG2, cv_BackgroundSubtractor_to_BackgroundSubtractorMOG2 } impl core::AlgorithmTraitConst for BackgroundSubtractor { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -828,23 +842,25 @@ pub mod video { boxed_ref! { BackgroundSubtractor, crate::video::BackgroundSubtractorTraitConst, as_raw_BackgroundSubtractor, crate::video::BackgroundSubtractorTrait, as_raw_mut_BackgroundSubtractor } - impl BackgroundSubtractor { + /// K-nearest neighbours - based Background/Foreground Segmentation Algorithm. + /// + /// The class implements the K-nearest neighbours background subtraction described in [Zivkovic2006](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Zivkovic2006) . + /// Very efficient if number of foreground pixels is low. + pub struct BackgroundSubtractorKNN { + ptr: *mut c_void, } - boxed_cast_descendant! { BackgroundSubtractor, crate::video::BackgroundSubtractorKNN, cv_BackgroundSubtractor_to_BackgroundSubtractorKNN } - - boxed_cast_descendant! { BackgroundSubtractor, crate::video::BackgroundSubtractorMOG2, cv_BackgroundSubtractor_to_BackgroundSubtractorMOG2 } - - boxed_cast_base! { BackgroundSubtractor, core::Algorithm, cv_BackgroundSubtractor_to_Algorithm } + opencv_type_boxed! { BackgroundSubtractorKNN } - impl std::fmt::Debug for BackgroundSubtractor { + impl Drop for BackgroundSubtractorKNN { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BackgroundSubtractor") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_BackgroundSubtractorKNN_delete(self.as_raw_mut_BackgroundSubtractorKNN()) }; } } + unsafe impl Send for BackgroundSubtractorKNN {} + /// Constant methods for [crate::video::BackgroundSubtractorKNN] pub trait BackgroundSubtractorKNNTraitConst: crate::video::BackgroundSubtractorTraitConst { fn as_raw_BackgroundSubtractorKNN(&self) -> *const c_void; @@ -1016,24 +1032,17 @@ pub mod video { } - /// K-nearest neighbours - based Background/Foreground Segmentation Algorithm. - /// - /// The class implements the K-nearest neighbours background subtraction described in [Zivkovic2006](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Zivkovic2006) . - /// Very efficient if number of foreground pixels is low. - pub struct BackgroundSubtractorKNN { - ptr: *mut c_void, - } - - opencv_type_boxed! { BackgroundSubtractorKNN } - - impl Drop for BackgroundSubtractorKNN { + impl std::fmt::Debug for BackgroundSubtractorKNN { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_BackgroundSubtractorKNN_delete(self.as_raw_mut_BackgroundSubtractorKNN()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BackgroundSubtractorKNN") + .finish() } } - unsafe impl Send for BackgroundSubtractorKNN {} + boxed_cast_base! { BackgroundSubtractorKNN, core::Algorithm, cv_BackgroundSubtractorKNN_to_Algorithm } + + boxed_cast_base! { BackgroundSubtractorKNN, crate::video::BackgroundSubtractor, cv_BackgroundSubtractorKNN_to_BackgroundSubtractor } impl core::AlgorithmTraitConst for BackgroundSubtractorKNN { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1065,21 +1074,25 @@ pub mod video { boxed_ref! { BackgroundSubtractorKNN, crate::video::BackgroundSubtractorKNNTraitConst, as_raw_BackgroundSubtractorKNN, crate::video::BackgroundSubtractorKNNTrait, as_raw_mut_BackgroundSubtractorKNN } - impl BackgroundSubtractorKNN { + /// Gaussian Mixture-based Background/Foreground Segmentation Algorithm. + /// + /// The class implements the Gaussian mixture model background subtraction described in [Zivkovic2004](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Zivkovic2004) + /// and [Zivkovic2006](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Zivkovic2006) . + pub struct BackgroundSubtractorMOG2 { + ptr: *mut c_void, } - boxed_cast_base! { BackgroundSubtractorKNN, core::Algorithm, cv_BackgroundSubtractorKNN_to_Algorithm } - - boxed_cast_base! { BackgroundSubtractorKNN, crate::video::BackgroundSubtractor, cv_BackgroundSubtractorKNN_to_BackgroundSubtractor } + opencv_type_boxed! { BackgroundSubtractorMOG2 } - impl std::fmt::Debug for BackgroundSubtractorKNN { + impl Drop for BackgroundSubtractorMOG2 { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BackgroundSubtractorKNN") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_BackgroundSubtractorMOG2_delete(self.as_raw_mut_BackgroundSubtractorMOG2()) }; } } + unsafe impl Send for BackgroundSubtractorMOG2 {} + /// Constant methods for [crate::video::BackgroundSubtractorMOG2] pub trait BackgroundSubtractorMOG2TraitConst: crate::video::BackgroundSubtractorTraitConst { fn as_raw_BackgroundSubtractorMOG2(&self) -> *const c_void; @@ -1405,24 +1418,17 @@ pub mod video { } - /// Gaussian Mixture-based Background/Foreground Segmentation Algorithm. - /// - /// The class implements the Gaussian mixture model background subtraction described in [Zivkovic2004](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Zivkovic2004) - /// and [Zivkovic2006](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Zivkovic2006) . - pub struct BackgroundSubtractorMOG2 { - ptr: *mut c_void, - } - - opencv_type_boxed! { BackgroundSubtractorMOG2 } - - impl Drop for BackgroundSubtractorMOG2 { + impl std::fmt::Debug for BackgroundSubtractorMOG2 { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_BackgroundSubtractorMOG2_delete(self.as_raw_mut_BackgroundSubtractorMOG2()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BackgroundSubtractorMOG2") + .finish() } } - unsafe impl Send for BackgroundSubtractorMOG2 {} + boxed_cast_base! { BackgroundSubtractorMOG2, core::Algorithm, cv_BackgroundSubtractorMOG2_to_Algorithm } + + boxed_cast_base! { BackgroundSubtractorMOG2, crate::video::BackgroundSubtractor, cv_BackgroundSubtractorMOG2_to_BackgroundSubtractor } impl core::AlgorithmTraitConst for BackgroundSubtractorMOG2 { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1454,19 +1460,68 @@ pub mod video { boxed_ref! { BackgroundSubtractorMOG2, crate::video::BackgroundSubtractorMOG2TraitConst, as_raw_BackgroundSubtractorMOG2, crate::video::BackgroundSubtractorMOG2Trait, as_raw_mut_BackgroundSubtractorMOG2 } - impl BackgroundSubtractorMOG2 { + /// DIS optical flow algorithm. + /// + /// This class implements the Dense Inverse Search (DIS) optical flow algorithm. More + /// details about the algorithm can be found at [Kroeger2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Kroeger2016) . Includes three presets with preselected + /// parameters to provide reasonable trade-off between speed and quality. However, even the slowest preset is + /// still relatively fast, use DeepFlow if you need better quality and don't care about speed. + /// + /// This implementation includes several additional features compared to the algorithm described in the paper, + /// including spatial propagation of flow vectors ([getUseSpatialPropagation]), as well as an option to + /// utilize an initial flow approximation passed to [calc] (which is, essentially, temporal propagation, + /// if the previous frame's flow field is passed). + pub struct DISOpticalFlow { + ptr: *mut c_void, + } + + opencv_type_boxed! { DISOpticalFlow } + + impl Drop for DISOpticalFlow { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_DISOpticalFlow_delete(self.as_raw_mut_DISOpticalFlow()) }; + } } - boxed_cast_base! { BackgroundSubtractorMOG2, core::Algorithm, cv_BackgroundSubtractorMOG2_to_Algorithm } + unsafe impl Send for DISOpticalFlow {} - boxed_cast_base! { BackgroundSubtractorMOG2, crate::video::BackgroundSubtractor, cv_BackgroundSubtractorMOG2_to_BackgroundSubtractor } + impl DISOpticalFlow { + /// Creates an instance of DISOpticalFlow + /// + /// ## Parameters + /// * preset: one of PRESET_ULTRAFAST, PRESET_FAST and PRESET_MEDIUM + /// + /// ## C++ default parameters + /// * preset: DISOpticalFlow::PRESET_FAST + #[inline] + pub fn create(preset: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_DISOpticalFlow_create_int(preset, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for BackgroundSubtractorMOG2 { + /// Creates an instance of DISOpticalFlow + /// + /// ## Parameters + /// * preset: one of PRESET_ULTRAFAST, PRESET_FAST and PRESET_MEDIUM + /// + /// ## Note + /// This alternative version of [DISOpticalFlow::create] function uses the following default values for its arguments: + /// * preset: DISOpticalFlow::PRESET_FAST #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BackgroundSubtractorMOG2") - .finish() + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_DISOpticalFlow_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::video::DISOpticalFlow] @@ -1768,31 +1823,17 @@ pub mod video { } - /// DIS optical flow algorithm. - /// - /// This class implements the Dense Inverse Search (DIS) optical flow algorithm. More - /// details about the algorithm can be found at [Kroeger2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Kroeger2016) . Includes three presets with preselected - /// parameters to provide reasonable trade-off between speed and quality. However, even the slowest preset is - /// still relatively fast, use DeepFlow if you need better quality and don't care about speed. - /// - /// This implementation includes several additional features compared to the algorithm described in the paper, - /// including spatial propagation of flow vectors ([getUseSpatialPropagation]), as well as an option to - /// utilize an initial flow approximation passed to [calc] (which is, essentially, temporal propagation, - /// if the previous frame's flow field is passed). - pub struct DISOpticalFlow { - ptr: *mut c_void, - } - - opencv_type_boxed! { DISOpticalFlow } - - impl Drop for DISOpticalFlow { + impl std::fmt::Debug for DISOpticalFlow { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_DISOpticalFlow_delete(self.as_raw_mut_DISOpticalFlow()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DISOpticalFlow") + .finish() } } - unsafe impl Send for DISOpticalFlow {} + boxed_cast_base! { DISOpticalFlow, core::Algorithm, cv_DISOpticalFlow_to_Algorithm } + + boxed_cast_base! { DISOpticalFlow, crate::video::DenseOpticalFlow, cv_DISOpticalFlow_to_DenseOpticalFlow } impl core::AlgorithmTraitConst for DISOpticalFlow { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1824,55 +1865,21 @@ pub mod video { boxed_ref! { DISOpticalFlow, crate::video::DISOpticalFlowTraitConst, as_raw_DISOpticalFlow, crate::video::DISOpticalFlowTrait, as_raw_mut_DISOpticalFlow } - impl DISOpticalFlow { - /// Creates an instance of DISOpticalFlow - /// - /// ## Parameters - /// * preset: one of PRESET_ULTRAFAST, PRESET_FAST and PRESET_MEDIUM - /// - /// ## C++ default parameters - /// * preset: DISOpticalFlow::PRESET_FAST - #[inline] - pub fn create(preset: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_DISOpticalFlow_create_int(preset, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } + /// Base class for dense optical flow algorithms + pub struct DenseOpticalFlow { + ptr: *mut c_void, + } - /// Creates an instance of DISOpticalFlow - /// - /// ## Parameters - /// * preset: one of PRESET_ULTRAFAST, PRESET_FAST and PRESET_MEDIUM - /// - /// ## Note - /// This alternative version of [DISOpticalFlow::create] function uses the following default values for its arguments: - /// * preset: DISOpticalFlow::PRESET_FAST + opencv_type_boxed! { DenseOpticalFlow } + + impl Drop for DenseOpticalFlow { #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_DISOpticalFlow_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_DenseOpticalFlow_delete(self.as_raw_mut_DenseOpticalFlow()) }; } - } - boxed_cast_base! { DISOpticalFlow, core::Algorithm, cv_DISOpticalFlow_to_Algorithm } - - boxed_cast_base! { DISOpticalFlow, crate::video::DenseOpticalFlow, cv_DISOpticalFlow_to_DenseOpticalFlow } - - impl std::fmt::Debug for DISOpticalFlow { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DISOpticalFlow") - .finish() - } - } + unsafe impl Send for DenseOpticalFlow {} /// Constant methods for [crate::video::DenseOpticalFlow] pub trait DenseOpticalFlowTraitConst: core::AlgorithmTraitConst { @@ -1914,21 +1921,21 @@ pub mod video { } - /// Base class for dense optical flow algorithms - pub struct DenseOpticalFlow { - ptr: *mut c_void, - } - - opencv_type_boxed! { DenseOpticalFlow } - - impl Drop for DenseOpticalFlow { + impl std::fmt::Debug for DenseOpticalFlow { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_DenseOpticalFlow_delete(self.as_raw_mut_DenseOpticalFlow()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DenseOpticalFlow") + .finish() } } - unsafe impl Send for DenseOpticalFlow {} + boxed_cast_base! { DenseOpticalFlow, core::Algorithm, cv_DenseOpticalFlow_to_Algorithm } + + boxed_cast_descendant! { DenseOpticalFlow, crate::video::DISOpticalFlow, cv_DenseOpticalFlow_to_DISOpticalFlow } + + boxed_cast_descendant! { DenseOpticalFlow, crate::video::FarnebackOpticalFlow, cv_DenseOpticalFlow_to_FarnebackOpticalFlow } + + boxed_cast_descendant! { DenseOpticalFlow, crate::video::VariationalRefinement, cv_DenseOpticalFlow_to_VariationalRefinement } impl core::AlgorithmTraitConst for DenseOpticalFlow { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1950,23 +1957,62 @@ pub mod video { boxed_ref! { DenseOpticalFlow, crate::video::DenseOpticalFlowTraitConst, as_raw_DenseOpticalFlow, crate::video::DenseOpticalFlowTrait, as_raw_mut_DenseOpticalFlow } - impl DenseOpticalFlow { + /// Class computing a dense optical flow using the Gunnar Farneback's algorithm. + pub struct FarnebackOpticalFlow { + ptr: *mut c_void, } - boxed_cast_descendant! { DenseOpticalFlow, crate::video::DISOpticalFlow, cv_DenseOpticalFlow_to_DISOpticalFlow } + opencv_type_boxed! { FarnebackOpticalFlow } - boxed_cast_descendant! { DenseOpticalFlow, crate::video::FarnebackOpticalFlow, cv_DenseOpticalFlow_to_FarnebackOpticalFlow } + impl Drop for FarnebackOpticalFlow { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_FarnebackOpticalFlow_delete(self.as_raw_mut_FarnebackOpticalFlow()) }; + } + } - boxed_cast_descendant! { DenseOpticalFlow, crate::video::VariationalRefinement, cv_DenseOpticalFlow_to_VariationalRefinement } + unsafe impl Send for FarnebackOpticalFlow {} - boxed_cast_base! { DenseOpticalFlow, core::Algorithm, cv_DenseOpticalFlow_to_Algorithm } + impl FarnebackOpticalFlow { + /// ## C++ default parameters + /// * num_levels: 5 + /// * pyr_scale: 0.5 + /// * fast_pyramids: false + /// * win_size: 13 + /// * num_iters: 10 + /// * poly_n: 5 + /// * poly_sigma: 1.1 + /// * flags: 0 + #[inline] + pub fn create(num_levels: i32, pyr_scale: f64, fast_pyramids: bool, win_size: i32, num_iters: i32, poly_n: i32, poly_sigma: f64, flags: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_FarnebackOpticalFlow_create_int_double_bool_int_int_int_double_int(num_levels, pyr_scale, fast_pyramids, win_size, num_iters, poly_n, poly_sigma, flags, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for DenseOpticalFlow { + /// ## Note + /// This alternative version of [FarnebackOpticalFlow::create] function uses the following default values for its arguments: + /// * num_levels: 5 + /// * pyr_scale: 0.5 + /// * fast_pyramids: false + /// * win_size: 13 + /// * num_iters: 10 + /// * poly_n: 5 + /// * poly_sigma: 1.1 + /// * flags: 0 #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DenseOpticalFlow") - .finish() + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_FarnebackOpticalFlow_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::video::FarnebackOpticalFlow] @@ -2125,21 +2171,17 @@ pub mod video { } - /// Class computing a dense optical flow using the Gunnar Farneback's algorithm. - pub struct FarnebackOpticalFlow { - ptr: *mut c_void, - } - - opencv_type_boxed! { FarnebackOpticalFlow } - - impl Drop for FarnebackOpticalFlow { + impl std::fmt::Debug for FarnebackOpticalFlow { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_FarnebackOpticalFlow_delete(self.as_raw_mut_FarnebackOpticalFlow()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FarnebackOpticalFlow") + .finish() } } - unsafe impl Send for FarnebackOpticalFlow {} + boxed_cast_base! { FarnebackOpticalFlow, core::Algorithm, cv_FarnebackOpticalFlow_to_Algorithm } + + boxed_cast_base! { FarnebackOpticalFlow, crate::video::DenseOpticalFlow, cv_FarnebackOpticalFlow_to_DenseOpticalFlow } impl core::AlgorithmTraitConst for FarnebackOpticalFlow { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2171,58 +2213,81 @@ pub mod video { boxed_ref! { FarnebackOpticalFlow, crate::video::FarnebackOpticalFlowTraitConst, as_raw_FarnebackOpticalFlow, crate::video::FarnebackOpticalFlowTrait, as_raw_mut_FarnebackOpticalFlow } - impl FarnebackOpticalFlow { - /// ## C++ default parameters - /// * num_levels: 5 - /// * pyr_scale: 0.5 - /// * fast_pyramids: false - /// * win_size: 13 - /// * num_iters: 10 - /// * poly_n: 5 - /// * poly_sigma: 1.1 - /// * flags: 0 + /// Kalman filter class. + /// + /// The class implements a standard Kalman filter , + /// [Welch95](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Welch95) . However, you can modify transitionMatrix, controlMatrix, and measurementMatrix to get + /// an extended Kalman filter functionality. + /// + /// Note: In C API when CvKalman\* kalmanFilter structure is not needed anymore, it should be released + /// with cvReleaseKalman(&kalmanFilter) + pub struct KalmanFilter { + ptr: *mut c_void, + } + + opencv_type_boxed! { KalmanFilter } + + impl Drop for KalmanFilter { #[inline] - pub fn create(num_levels: i32, pyr_scale: f64, fast_pyramids: bool, win_size: i32, num_iters: i32, poly_n: i32, poly_sigma: f64, flags: i32) -> Result> { + fn drop(&mut self) { + unsafe { sys::cv_KalmanFilter_delete(self.as_raw_mut_KalmanFilter()) }; + } + } + + unsafe impl Send for KalmanFilter {} + + impl KalmanFilter { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_FarnebackOpticalFlow_create_int_double_bool_int_int_int_double_int(num_levels, pyr_scale, fast_pyramids, win_size, num_iters, poly_n, poly_sigma, flags, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_KalmanFilter_KalmanFilter(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::video::KalmanFilter::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [FarnebackOpticalFlow::create] function uses the following default values for its arguments: - /// * num_levels: 5 - /// * pyr_scale: 0.5 - /// * fast_pyramids: false - /// * win_size: 13 - /// * num_iters: 10 - /// * poly_n: 5 - /// * poly_sigma: 1.1 - /// * flags: 0 + /// This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. + /// ## Parameters + /// * dynamParams: Dimensionality of the state. + /// * measureParams: Dimensionality of the measurement. + /// * controlParams: Dimensionality of the control vector. + /// * type: Type of the created matrices that should be CV_32F or CV_64F. + /// + /// ## C++ default parameters + /// * control_params: 0 + /// * typ: CV_32F #[inline] - pub fn create_def() -> Result> { + pub fn new(dynam_params: i32, measure_params: i32, control_params: i32, typ: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_FarnebackOpticalFlow_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_KalmanFilter_KalmanFilter_int_int_int_int(dynam_params, measure_params, control_params, typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::video::KalmanFilter::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { FarnebackOpticalFlow, core::Algorithm, cv_FarnebackOpticalFlow_to_Algorithm } - - boxed_cast_base! { FarnebackOpticalFlow, crate::video::DenseOpticalFlow, cv_FarnebackOpticalFlow_to_DenseOpticalFlow } - - impl std::fmt::Debug for FarnebackOpticalFlow { + /// @overload + /// ## Parameters + /// * dynamParams: Dimensionality of the state. + /// * measureParams: Dimensionality of the measurement. + /// * controlParams: Dimensionality of the control vector. + /// * type: Type of the created matrices that should be CV_32F or CV_64F. + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * control_params: 0 + /// * typ: CV_32F #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FarnebackOpticalFlow") - .finish() + pub fn new_def(dynam_params: i32, measure_params: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_KalmanFilter_KalmanFilter_int_int(dynam_params, measure_params, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::video::KalmanFilter::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::video::KalmanFilter] @@ -2542,29 +2607,29 @@ pub mod video { } - /// Kalman filter class. - /// - /// The class implements a standard Kalman filter , - /// [Welch95](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Welch95) . However, you can modify transitionMatrix, controlMatrix, and measurementMatrix to get - /// an extended Kalman filter functionality. - /// - /// Note: In C API when CvKalman\* kalmanFilter structure is not needed anymore, it should be released - /// with cvReleaseKalman(&kalmanFilter) - pub struct KalmanFilter { - ptr: *mut c_void, - } - - opencv_type_boxed! { KalmanFilter } - - impl Drop for KalmanFilter { + impl std::fmt::Debug for KalmanFilter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_KalmanFilter_delete(self.as_raw_mut_KalmanFilter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("KalmanFilter") + .field("state_pre", &crate::video::KalmanFilterTraitConst::state_pre(self)) + .field("state_post", &crate::video::KalmanFilterTraitConst::state_post(self)) + .field("transition_matrix", &crate::video::KalmanFilterTraitConst::transition_matrix(self)) + .field("control_matrix", &crate::video::KalmanFilterTraitConst::control_matrix(self)) + .field("measurement_matrix", &crate::video::KalmanFilterTraitConst::measurement_matrix(self)) + .field("process_noise_cov", &crate::video::KalmanFilterTraitConst::process_noise_cov(self)) + .field("measurement_noise_cov", &crate::video::KalmanFilterTraitConst::measurement_noise_cov(self)) + .field("error_cov_pre", &crate::video::KalmanFilterTraitConst::error_cov_pre(self)) + .field("gain", &crate::video::KalmanFilterTraitConst::gain(self)) + .field("error_cov_post", &crate::video::KalmanFilterTraitConst::error_cov_post(self)) + .field("temp1", &crate::video::KalmanFilterTraitConst::temp1(self)) + .field("temp2", &crate::video::KalmanFilterTraitConst::temp2(self)) + .field("temp3", &crate::video::KalmanFilterTraitConst::temp3(self)) + .field("temp4", &crate::video::KalmanFilterTraitConst::temp4(self)) + .field("temp5", &crate::video::KalmanFilterTraitConst::temp5(self)) + .finish() } } - unsafe impl Send for KalmanFilter {} - impl crate::video::KalmanFilterTraitConst for KalmanFilter { #[inline] fn as_raw_KalmanFilter(&self) -> *const c_void { self.as_raw() } } @@ -2575,82 +2640,21 @@ pub mod video { boxed_ref! { KalmanFilter, crate::video::KalmanFilterTraitConst, as_raw_KalmanFilter, crate::video::KalmanFilterTrait, as_raw_mut_KalmanFilter } - impl KalmanFilter { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_KalmanFilter_KalmanFilter(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::video::KalmanFilter::opencv_from_extern(ret) }; - Ok(ret) - } + /// Base interface for sparse optical flow algorithms. + pub struct SparseOpticalFlow { + ptr: *mut c_void, + } - /// This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. - /// ## Parameters - /// * dynamParams: Dimensionality of the state. - /// * measureParams: Dimensionality of the measurement. - /// * controlParams: Dimensionality of the control vector. - /// * type: Type of the created matrices that should be CV_32F or CV_64F. - /// - /// ## C++ default parameters - /// * control_params: 0 - /// * typ: CV_32F - #[inline] - pub fn new(dynam_params: i32, measure_params: i32, control_params: i32, typ: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_KalmanFilter_KalmanFilter_int_int_int_int(dynam_params, measure_params, control_params, typ, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::video::KalmanFilter::opencv_from_extern(ret) }; - Ok(ret) - } + opencv_type_boxed! { SparseOpticalFlow } - /// @overload - /// ## Parameters - /// * dynamParams: Dimensionality of the state. - /// * measureParams: Dimensionality of the measurement. - /// * controlParams: Dimensionality of the control vector. - /// * type: Type of the created matrices that should be CV_32F or CV_64F. - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * control_params: 0 - /// * typ: CV_32F + impl Drop for SparseOpticalFlow { #[inline] - pub fn new_def(dynam_params: i32, measure_params: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_KalmanFilter_KalmanFilter_int_int(dynam_params, measure_params, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::video::KalmanFilter::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_SparseOpticalFlow_delete(self.as_raw_mut_SparseOpticalFlow()) }; } - } - impl std::fmt::Debug for KalmanFilter { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("KalmanFilter") - .field("state_pre", &crate::video::KalmanFilterTraitConst::state_pre(self)) - .field("state_post", &crate::video::KalmanFilterTraitConst::state_post(self)) - .field("transition_matrix", &crate::video::KalmanFilterTraitConst::transition_matrix(self)) - .field("control_matrix", &crate::video::KalmanFilterTraitConst::control_matrix(self)) - .field("measurement_matrix", &crate::video::KalmanFilterTraitConst::measurement_matrix(self)) - .field("process_noise_cov", &crate::video::KalmanFilterTraitConst::process_noise_cov(self)) - .field("measurement_noise_cov", &crate::video::KalmanFilterTraitConst::measurement_noise_cov(self)) - .field("error_cov_pre", &crate::video::KalmanFilterTraitConst::error_cov_pre(self)) - .field("gain", &crate::video::KalmanFilterTraitConst::gain(self)) - .field("error_cov_post", &crate::video::KalmanFilterTraitConst::error_cov_post(self)) - .field("temp1", &crate::video::KalmanFilterTraitConst::temp1(self)) - .field("temp2", &crate::video::KalmanFilterTraitConst::temp2(self)) - .field("temp3", &crate::video::KalmanFilterTraitConst::temp3(self)) - .field("temp4", &crate::video::KalmanFilterTraitConst::temp4(self)) - .field("temp5", &crate::video::KalmanFilterTraitConst::temp5(self)) - .finish() - } - } + unsafe impl Send for SparseOpticalFlow {} /// Constant methods for [crate::video::SparseOpticalFlow] pub trait SparseOpticalFlowTraitConst: core::AlgorithmTraitConst { @@ -2720,21 +2724,17 @@ pub mod video { } - /// Base interface for sparse optical flow algorithms. - pub struct SparseOpticalFlow { - ptr: *mut c_void, - } - - opencv_type_boxed! { SparseOpticalFlow } - - impl Drop for SparseOpticalFlow { + impl std::fmt::Debug for SparseOpticalFlow { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_SparseOpticalFlow_delete(self.as_raw_mut_SparseOpticalFlow()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SparseOpticalFlow") + .finish() } } - unsafe impl Send for SparseOpticalFlow {} + boxed_cast_base! { SparseOpticalFlow, core::Algorithm, cv_SparseOpticalFlow_to_Algorithm } + + boxed_cast_descendant! { SparseOpticalFlow, crate::video::SparsePyrLKOpticalFlow, cv_SparseOpticalFlow_to_SparsePyrLKOpticalFlow } impl core::AlgorithmTraitConst for SparseOpticalFlow { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2756,19 +2756,61 @@ pub mod video { boxed_ref! { SparseOpticalFlow, crate::video::SparseOpticalFlowTraitConst, as_raw_SparseOpticalFlow, crate::video::SparseOpticalFlowTrait, as_raw_mut_SparseOpticalFlow } - impl SparseOpticalFlow { + /// Class used for calculating a sparse optical flow. + /// + /// The class can calculate an optical flow for a sparse feature set using the + /// iterative Lucas-Kanade method with pyramids. + /// ## See also + /// calcOpticalFlowPyrLK + pub struct SparsePyrLKOpticalFlow { + ptr: *mut c_void, } - boxed_cast_descendant! { SparseOpticalFlow, crate::video::SparsePyrLKOpticalFlow, cv_SparseOpticalFlow_to_SparsePyrLKOpticalFlow } + opencv_type_boxed! { SparsePyrLKOpticalFlow } - boxed_cast_base! { SparseOpticalFlow, core::Algorithm, cv_SparseOpticalFlow_to_Algorithm } + impl Drop for SparsePyrLKOpticalFlow { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_SparsePyrLKOpticalFlow_delete(self.as_raw_mut_SparsePyrLKOpticalFlow()) }; + } + } - impl std::fmt::Debug for SparseOpticalFlow { + unsafe impl Send for SparsePyrLKOpticalFlow {} + + impl SparsePyrLKOpticalFlow { + /// ## C++ default parameters + /// * win_size: Size(21,21) + /// * max_level: 3 + /// * crit: TermCriteria(TermCriteria::COUNT+TermCriteria::EPS,30,0.01) + /// * flags: 0 + /// * min_eig_threshold: 1e-4 #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SparseOpticalFlow") - .finish() + pub fn create(win_size: core::Size, max_level: i32, crit: core::TermCriteria, flags: i32, min_eig_threshold: f64) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_SparsePyrLKOpticalFlow_create_Size_int_TermCriteria_int_double(&win_size, max_level, &crit, flags, min_eig_threshold, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [SparsePyrLKOpticalFlow::create] function uses the following default values for its arguments: + /// * win_size: Size(21,21) + /// * max_level: 3 + /// * crit: TermCriteria(TermCriteria::COUNT+TermCriteria::EPS,30,0.01) + /// * flags: 0 + /// * min_eig_threshold: 1e-4 + #[inline] + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_SparsePyrLKOpticalFlow_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::video::SparsePyrLKOpticalFlow] @@ -2873,26 +2915,17 @@ pub mod video { } - /// Class used for calculating a sparse optical flow. - /// - /// The class can calculate an optical flow for a sparse feature set using the - /// iterative Lucas-Kanade method with pyramids. - /// ## See also - /// calcOpticalFlowPyrLK - pub struct SparsePyrLKOpticalFlow { - ptr: *mut c_void, - } - - opencv_type_boxed! { SparsePyrLKOpticalFlow } - - impl Drop for SparsePyrLKOpticalFlow { + impl std::fmt::Debug for SparsePyrLKOpticalFlow { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_SparsePyrLKOpticalFlow_delete(self.as_raw_mut_SparsePyrLKOpticalFlow()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SparsePyrLKOpticalFlow") + .finish() } } - unsafe impl Send for SparsePyrLKOpticalFlow {} + boxed_cast_base! { SparsePyrLKOpticalFlow, core::Algorithm, cv_SparsePyrLKOpticalFlow_to_Algorithm } + + boxed_cast_base! { SparsePyrLKOpticalFlow, crate::video::SparseOpticalFlow, cv_SparsePyrLKOpticalFlow_to_SparseOpticalFlow } impl core::AlgorithmTraitConst for SparsePyrLKOpticalFlow { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2924,54 +2957,22 @@ pub mod video { boxed_ref! { SparsePyrLKOpticalFlow, crate::video::SparsePyrLKOpticalFlowTraitConst, as_raw_SparsePyrLKOpticalFlow, crate::video::SparsePyrLKOpticalFlowTrait, as_raw_mut_SparsePyrLKOpticalFlow } - impl SparsePyrLKOpticalFlow { - /// ## C++ default parameters - /// * win_size: Size(21,21) - /// * max_level: 3 - /// * crit: TermCriteria(TermCriteria::COUNT+TermCriteria::EPS,30,0.01) - /// * flags: 0 - /// * min_eig_threshold: 1e-4 - #[inline] - pub fn create(win_size: core::Size, max_level: i32, crit: core::TermCriteria, flags: i32, min_eig_threshold: f64) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_SparsePyrLKOpticalFlow_create_Size_int_TermCriteria_int_double(&win_size, max_level, &crit, flags, min_eig_threshold, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [SparsePyrLKOpticalFlow::create] function uses the following default values for its arguments: - /// * win_size: Size(21,21) - /// * max_level: 3 - /// * crit: TermCriteria(TermCriteria::COUNT+TermCriteria::EPS,30,0.01) - /// * flags: 0 - /// * min_eig_threshold: 1e-4 - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_SparsePyrLKOpticalFlow_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - + /// Base abstract class for the long-term tracker + pub struct Tracker { + ptr: *mut c_void, } - boxed_cast_base! { SparsePyrLKOpticalFlow, core::Algorithm, cv_SparsePyrLKOpticalFlow_to_Algorithm } - - boxed_cast_base! { SparsePyrLKOpticalFlow, crate::video::SparseOpticalFlow, cv_SparsePyrLKOpticalFlow_to_SparseOpticalFlow } + opencv_type_boxed! { Tracker } - impl std::fmt::Debug for SparsePyrLKOpticalFlow { + impl Drop for Tracker { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SparsePyrLKOpticalFlow") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_Tracker_delete(self.as_raw_mut_Tracker()) }; } } + unsafe impl Send for Tracker {} + /// Constant methods for [crate::video::Tracker] pub trait TrackerTraitConst { fn as_raw_Tracker(&self) -> *const c_void; @@ -3018,21 +3019,23 @@ pub mod video { } - /// Base abstract class for the long-term tracker - pub struct Tracker { - ptr: *mut c_void, - } - - opencv_type_boxed! { Tracker } - - impl Drop for Tracker { + impl std::fmt::Debug for Tracker { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_Tracker_delete(self.as_raw_mut_Tracker()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Tracker") + .finish() } } - unsafe impl Send for Tracker {} + boxed_cast_descendant! { Tracker, crate::video::TrackerDaSiamRPN, cv_Tracker_to_TrackerDaSiamRPN } + + boxed_cast_descendant! { Tracker, crate::video::TrackerGOTURN, cv_Tracker_to_TrackerGOTURN } + + boxed_cast_descendant! { Tracker, crate::video::TrackerMIL, cv_Tracker_to_TrackerMIL } + + boxed_cast_descendant! { Tracker, crate::video::TrackerNano, cv_Tracker_to_TrackerNano } + + boxed_cast_descendant! { Tracker, crate::video::TrackerVit, cv_Tracker_to_TrackerVit } impl crate::video::TrackerTraitConst for Tracker { #[inline] fn as_raw_Tracker(&self) -> *const c_void { self.as_raw() } @@ -3044,30 +3047,60 @@ pub mod video { boxed_ref! { Tracker, crate::video::TrackerTraitConst, as_raw_Tracker, crate::video::TrackerTrait, as_raw_mut_Tracker } - impl Tracker { + pub struct TrackerDaSiamRPN { + ptr: *mut c_void, } - boxed_cast_descendant! { Tracker, crate::video::TrackerDaSiamRPN, cv_Tracker_to_TrackerDaSiamRPN } - - boxed_cast_descendant! { Tracker, crate::video::TrackerGOTURN, cv_Tracker_to_TrackerGOTURN } - - boxed_cast_descendant! { Tracker, crate::video::TrackerMIL, cv_Tracker_to_TrackerMIL } - - boxed_cast_descendant! { Tracker, crate::video::TrackerNano, cv_Tracker_to_TrackerNano } - - boxed_cast_descendant! { Tracker, crate::video::TrackerVit, cv_Tracker_to_TrackerVit } + opencv_type_boxed! { TrackerDaSiamRPN } - impl std::fmt::Debug for Tracker { + impl Drop for TrackerDaSiamRPN { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Tracker") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_TrackerDaSiamRPN_delete(self.as_raw_mut_TrackerDaSiamRPN()) }; } } - /// Constant methods for [crate::video::TrackerDaSiamRPN] - pub trait TrackerDaSiamRPNTraitConst: crate::video::TrackerTraitConst { - fn as_raw_TrackerDaSiamRPN(&self) -> *const c_void; + unsafe impl Send for TrackerDaSiamRPN {} + + impl TrackerDaSiamRPN { + /// Constructor + /// ## Parameters + /// * parameters: DaSiamRPN parameters TrackerDaSiamRPN::Params + /// + /// ## C++ default parameters + /// * parameters: TrackerDaSiamRPN::Params() + #[inline] + pub fn create(parameters: &impl crate::video::TrackerDaSiamRPN_ParamsTraitConst) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_TrackerDaSiamRPN_create_const_ParamsR(parameters.as_raw_TrackerDaSiamRPN_Params(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Constructor + /// ## Parameters + /// * parameters: DaSiamRPN parameters TrackerDaSiamRPN::Params + /// + /// ## Note + /// This alternative version of [TrackerDaSiamRPN::create] function uses the following default values for its arguments: + /// * parameters: TrackerDaSiamRPN::Params() + #[inline] + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_TrackerDaSiamRPN_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::video::TrackerDaSiamRPN] + pub trait TrackerDaSiamRPNTraitConst: crate::video::TrackerTraitConst { + fn as_raw_TrackerDaSiamRPN(&self) -> *const c_void; } @@ -3087,20 +3120,15 @@ pub mod video { } - pub struct TrackerDaSiamRPN { - ptr: *mut c_void, - } - - opencv_type_boxed! { TrackerDaSiamRPN } - - impl Drop for TrackerDaSiamRPN { + impl std::fmt::Debug for TrackerDaSiamRPN { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_TrackerDaSiamRPN_delete(self.as_raw_mut_TrackerDaSiamRPN()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TrackerDaSiamRPN") + .finish() } } - unsafe impl Send for TrackerDaSiamRPN {} + boxed_cast_base! { TrackerDaSiamRPN, crate::video::Tracker, cv_TrackerDaSiamRPN_to_Tracker } impl crate::video::TrackerTraitConst for TrackerDaSiamRPN { #[inline] fn as_raw_Tracker(&self) -> *const c_void { self.as_raw() } @@ -3122,52 +3150,34 @@ pub mod video { boxed_ref! { TrackerDaSiamRPN, crate::video::TrackerDaSiamRPNTraitConst, as_raw_TrackerDaSiamRPN, crate::video::TrackerDaSiamRPNTrait, as_raw_mut_TrackerDaSiamRPN } - impl TrackerDaSiamRPN { - /// Constructor - /// ## Parameters - /// * parameters: DaSiamRPN parameters TrackerDaSiamRPN::Params - /// - /// ## C++ default parameters - /// * parameters: TrackerDaSiamRPN::Params() + pub struct TrackerDaSiamRPN_Params { + ptr: *mut c_void, + } + + opencv_type_boxed! { TrackerDaSiamRPN_Params } + + impl Drop for TrackerDaSiamRPN_Params { #[inline] - pub fn create(parameters: &impl crate::video::TrackerDaSiamRPN_ParamsTraitConst) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_TrackerDaSiamRPN_create_const_ParamsR(parameters.as_raw_TrackerDaSiamRPN_Params(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_TrackerDaSiamRPN_Params_delete(self.as_raw_mut_TrackerDaSiamRPN_Params()) }; } + } - /// Constructor - /// ## Parameters - /// * parameters: DaSiamRPN parameters TrackerDaSiamRPN::Params - /// - /// ## Note - /// This alternative version of [TrackerDaSiamRPN::create] function uses the following default values for its arguments: - /// * parameters: TrackerDaSiamRPN::Params() + unsafe impl Send for TrackerDaSiamRPN_Params {} + + impl TrackerDaSiamRPN_Params { #[inline] - pub fn create_def() -> Result> { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_TrackerDaSiamRPN_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_TrackerDaSiamRPN_Params_Params(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::video::TrackerDaSiamRPN_Params::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { TrackerDaSiamRPN, crate::video::Tracker, cv_TrackerDaSiamRPN_to_Tracker } - - impl std::fmt::Debug for TrackerDaSiamRPN { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TrackerDaSiamRPN") - .finish() - } - } - /// Constant methods for [crate::video::TrackerDaSiamRPN_Params] pub trait TrackerDaSiamRPN_ParamsTraitConst { fn as_raw_TrackerDaSiamRPN_Params(&self) -> *const c_void; @@ -3246,44 +3256,6 @@ pub mod video { } - pub struct TrackerDaSiamRPN_Params { - ptr: *mut c_void, - } - - opencv_type_boxed! { TrackerDaSiamRPN_Params } - - impl Drop for TrackerDaSiamRPN_Params { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_TrackerDaSiamRPN_Params_delete(self.as_raw_mut_TrackerDaSiamRPN_Params()) }; - } - } - - unsafe impl Send for TrackerDaSiamRPN_Params {} - - impl crate::video::TrackerDaSiamRPN_ParamsTraitConst for TrackerDaSiamRPN_Params { - #[inline] fn as_raw_TrackerDaSiamRPN_Params(&self) -> *const c_void { self.as_raw() } - } - - impl crate::video::TrackerDaSiamRPN_ParamsTrait for TrackerDaSiamRPN_Params { - #[inline] fn as_raw_mut_TrackerDaSiamRPN_Params(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TrackerDaSiamRPN_Params, crate::video::TrackerDaSiamRPN_ParamsTraitConst, as_raw_TrackerDaSiamRPN_Params, crate::video::TrackerDaSiamRPN_ParamsTrait, as_raw_mut_TrackerDaSiamRPN_Params } - - impl TrackerDaSiamRPN_Params { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_TrackerDaSiamRPN_Params_Params(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::video::TrackerDaSiamRPN_Params::opencv_from_extern(ret) }; - Ok(ret) - } - - } - impl Clone for TrackerDaSiamRPN_Params { #[inline] fn clone(&self) -> Self { @@ -3304,18 +3276,16 @@ pub mod video { } } - /// Constant methods for [crate::video::TrackerGOTURN] - pub trait TrackerGOTURNTraitConst: crate::video::TrackerTraitConst { - fn as_raw_TrackerGOTURN(&self) -> *const c_void; - + impl crate::video::TrackerDaSiamRPN_ParamsTraitConst for TrackerDaSiamRPN_Params { + #[inline] fn as_raw_TrackerDaSiamRPN_Params(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::video::TrackerGOTURN] - pub trait TrackerGOTURNTrait: crate::video::TrackerGOTURNTraitConst + crate::video::TrackerTrait { - fn as_raw_mut_TrackerGOTURN(&mut self) -> *mut c_void; - + impl crate::video::TrackerDaSiamRPN_ParamsTrait for TrackerDaSiamRPN_Params { + #[inline] fn as_raw_mut_TrackerDaSiamRPN_Params(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { TrackerDaSiamRPN_Params, crate::video::TrackerDaSiamRPN_ParamsTraitConst, as_raw_TrackerDaSiamRPN_Params, crate::video::TrackerDaSiamRPN_ParamsTrait, as_raw_mut_TrackerDaSiamRPN_Params } + /// the GOTURN (Generic Object Tracking Using Regression Networks) tracker /// /// GOTURN ([GOTURN](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_GOTURN)) is kind of trackers based on Convolutional Neural Networks (CNN). While taking all advantages of CNN trackers, @@ -3345,26 +3315,6 @@ pub mod video { unsafe impl Send for TrackerGOTURN {} - impl crate::video::TrackerTraitConst for TrackerGOTURN { - #[inline] fn as_raw_Tracker(&self) -> *const c_void { self.as_raw() } - } - - impl crate::video::TrackerTrait for TrackerGOTURN { - #[inline] fn as_raw_mut_Tracker(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TrackerGOTURN, crate::video::TrackerTraitConst, as_raw_Tracker, crate::video::TrackerTrait, as_raw_mut_Tracker } - - impl crate::video::TrackerGOTURNTraitConst for TrackerGOTURN { - #[inline] fn as_raw_TrackerGOTURN(&self) -> *const c_void { self.as_raw() } - } - - impl crate::video::TrackerGOTURNTrait for TrackerGOTURN { - #[inline] fn as_raw_mut_TrackerGOTURN(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TrackerGOTURN, crate::video::TrackerGOTURNTraitConst, as_raw_TrackerGOTURN, crate::video::TrackerGOTURNTrait, as_raw_mut_TrackerGOTURN } - impl TrackerGOTURN { /// Constructor /// ## Parameters @@ -3401,7 +3351,17 @@ pub mod video { } - boxed_cast_base! { TrackerGOTURN, crate::video::Tracker, cv_TrackerGOTURN_to_Tracker } + /// Constant methods for [crate::video::TrackerGOTURN] + pub trait TrackerGOTURNTraitConst: crate::video::TrackerTraitConst { + fn as_raw_TrackerGOTURN(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::video::TrackerGOTURN] + pub trait TrackerGOTURNTrait: crate::video::TrackerGOTURNTraitConst + crate::video::TrackerTrait { + fn as_raw_mut_TrackerGOTURN(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for TrackerGOTURN { #[inline] @@ -3411,6 +3371,56 @@ pub mod video { } } + boxed_cast_base! { TrackerGOTURN, crate::video::Tracker, cv_TrackerGOTURN_to_Tracker } + + impl crate::video::TrackerTraitConst for TrackerGOTURN { + #[inline] fn as_raw_Tracker(&self) -> *const c_void { self.as_raw() } + } + + impl crate::video::TrackerTrait for TrackerGOTURN { + #[inline] fn as_raw_mut_Tracker(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { TrackerGOTURN, crate::video::TrackerTraitConst, as_raw_Tracker, crate::video::TrackerTrait, as_raw_mut_Tracker } + + impl crate::video::TrackerGOTURNTraitConst for TrackerGOTURN { + #[inline] fn as_raw_TrackerGOTURN(&self) -> *const c_void { self.as_raw() } + } + + impl crate::video::TrackerGOTURNTrait for TrackerGOTURN { + #[inline] fn as_raw_mut_TrackerGOTURN(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { TrackerGOTURN, crate::video::TrackerGOTURNTraitConst, as_raw_TrackerGOTURN, crate::video::TrackerGOTURNTrait, as_raw_mut_TrackerGOTURN } + + pub struct TrackerGOTURN_Params { + ptr: *mut c_void, + } + + opencv_type_boxed! { TrackerGOTURN_Params } + + impl Drop for TrackerGOTURN_Params { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_TrackerGOTURN_Params_delete(self.as_raw_mut_TrackerGOTURN_Params()) }; + } + } + + unsafe impl Send for TrackerGOTURN_Params {} + + impl TrackerGOTURN_Params { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_TrackerGOTURN_Params_Params(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::video::TrackerGOTURN_Params::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::video::TrackerGOTURN_Params] pub trait TrackerGOTURN_ParamsTraitConst { fn as_raw_TrackerGOTURN_Params(&self) -> *const c_void; @@ -3451,44 +3461,6 @@ pub mod video { } - pub struct TrackerGOTURN_Params { - ptr: *mut c_void, - } - - opencv_type_boxed! { TrackerGOTURN_Params } - - impl Drop for TrackerGOTURN_Params { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_TrackerGOTURN_Params_delete(self.as_raw_mut_TrackerGOTURN_Params()) }; - } - } - - unsafe impl Send for TrackerGOTURN_Params {} - - impl crate::video::TrackerGOTURN_ParamsTraitConst for TrackerGOTURN_Params { - #[inline] fn as_raw_TrackerGOTURN_Params(&self) -> *const c_void { self.as_raw() } - } - - impl crate::video::TrackerGOTURN_ParamsTrait for TrackerGOTURN_Params { - #[inline] fn as_raw_mut_TrackerGOTURN_Params(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TrackerGOTURN_Params, crate::video::TrackerGOTURN_ParamsTraitConst, as_raw_TrackerGOTURN_Params, crate::video::TrackerGOTURN_ParamsTrait, as_raw_mut_TrackerGOTURN_Params } - - impl TrackerGOTURN_Params { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_TrackerGOTURN_Params_Params(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::video::TrackerGOTURN_Params::opencv_from_extern(ret) }; - Ok(ret) - } - - } - impl Clone for TrackerGOTURN_Params { #[inline] fn clone(&self) -> Self { @@ -3506,18 +3478,16 @@ pub mod video { } } - /// Constant methods for [crate::video::TrackerMIL] - pub trait TrackerMILTraitConst: crate::video::TrackerTraitConst { - fn as_raw_TrackerMIL(&self) -> *const c_void; - + impl crate::video::TrackerGOTURN_ParamsTraitConst for TrackerGOTURN_Params { + #[inline] fn as_raw_TrackerGOTURN_Params(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::video::TrackerMIL] - pub trait TrackerMILTrait: crate::video::TrackerMILTraitConst + crate::video::TrackerTrait { - fn as_raw_mut_TrackerMIL(&mut self) -> *mut c_void; - + impl crate::video::TrackerGOTURN_ParamsTrait for TrackerGOTURN_Params { + #[inline] fn as_raw_mut_TrackerGOTURN_Params(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { TrackerGOTURN_Params, crate::video::TrackerGOTURN_ParamsTraitConst, as_raw_TrackerGOTURN_Params, crate::video::TrackerGOTURN_ParamsTrait, as_raw_mut_TrackerGOTURN_Params } + /// The MIL algorithm trains a classifier in an online manner to separate the object from the /// background. /// @@ -3540,26 +3510,6 @@ pub mod video { unsafe impl Send for TrackerMIL {} - impl crate::video::TrackerTraitConst for TrackerMIL { - #[inline] fn as_raw_Tracker(&self) -> *const c_void { self.as_raw() } - } - - impl crate::video::TrackerTrait for TrackerMIL { - #[inline] fn as_raw_mut_Tracker(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TrackerMIL, crate::video::TrackerTraitConst, as_raw_Tracker, crate::video::TrackerTrait, as_raw_mut_Tracker } - - impl crate::video::TrackerMILTraitConst for TrackerMIL { - #[inline] fn as_raw_TrackerMIL(&self) -> *const c_void { self.as_raw() } - } - - impl crate::video::TrackerMILTrait for TrackerMIL { - #[inline] fn as_raw_mut_TrackerMIL(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TrackerMIL, crate::video::TrackerMILTraitConst, as_raw_TrackerMIL, crate::video::TrackerMILTrait, as_raw_mut_TrackerMIL } - impl TrackerMIL { /// Create MIL tracker instance /// ## Parameters @@ -3596,7 +3546,17 @@ pub mod video { } - boxed_cast_base! { TrackerMIL, crate::video::Tracker, cv_TrackerMIL_to_Tracker } + /// Constant methods for [crate::video::TrackerMIL] + pub trait TrackerMILTraitConst: crate::video::TrackerTraitConst { + fn as_raw_TrackerMIL(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::video::TrackerMIL] + pub trait TrackerMILTrait: crate::video::TrackerMILTraitConst + crate::video::TrackerTrait { + fn as_raw_mut_TrackerMIL(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for TrackerMIL { #[inline] @@ -3606,6 +3566,28 @@ pub mod video { } } + boxed_cast_base! { TrackerMIL, crate::video::Tracker, cv_TrackerMIL_to_Tracker } + + impl crate::video::TrackerTraitConst for TrackerMIL { + #[inline] fn as_raw_Tracker(&self) -> *const c_void { self.as_raw() } + } + + impl crate::video::TrackerTrait for TrackerMIL { + #[inline] fn as_raw_mut_Tracker(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { TrackerMIL, crate::video::TrackerTraitConst, as_raw_Tracker, crate::video::TrackerTrait, as_raw_mut_Tracker } + + impl crate::video::TrackerMILTraitConst for TrackerMIL { + #[inline] fn as_raw_TrackerMIL(&self) -> *const c_void { self.as_raw() } + } + + impl crate::video::TrackerMILTrait for TrackerMIL { + #[inline] fn as_raw_mut_TrackerMIL(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { TrackerMIL, crate::video::TrackerMILTraitConst, as_raw_TrackerMIL, crate::video::TrackerMILTrait, as_raw_mut_TrackerMIL } + #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] pub struct TrackerMIL_Params { @@ -3639,28 +3621,6 @@ pub mod video { } - /// Constant methods for [crate::video::TrackerNano] - pub trait TrackerNanoTraitConst: crate::video::TrackerTraitConst { - fn as_raw_TrackerNano(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::video::TrackerNano] - pub trait TrackerNanoTrait: crate::video::TrackerNanoTraitConst + crate::video::TrackerTrait { - fn as_raw_mut_TrackerNano(&mut self) -> *mut c_void; - - /// Return tracking score - #[inline] - fn get_tracking_score(&mut self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_TrackerNano_getTrackingScore(self.as_raw_mut_TrackerNano(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - /// the Nano tracker is a super lightweight dnn-based general object tracking. /// /// Nano tracker is much faster and extremely lightweight due to special model structure, the whole model size is about 1.9 MB. @@ -3683,26 +3643,6 @@ pub mod video { unsafe impl Send for TrackerNano {} - impl crate::video::TrackerTraitConst for TrackerNano { - #[inline] fn as_raw_Tracker(&self) -> *const c_void { self.as_raw() } - } - - impl crate::video::TrackerTrait for TrackerNano { - #[inline] fn as_raw_mut_Tracker(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TrackerNano, crate::video::TrackerTraitConst, as_raw_Tracker, crate::video::TrackerTrait, as_raw_mut_Tracker } - - impl crate::video::TrackerNanoTraitConst for TrackerNano { - #[inline] fn as_raw_TrackerNano(&self) -> *const c_void { self.as_raw() } - } - - impl crate::video::TrackerNanoTrait for TrackerNano { - #[inline] fn as_raw_mut_TrackerNano(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TrackerNano, crate::video::TrackerNanoTraitConst, as_raw_TrackerNano, crate::video::TrackerNanoTrait, as_raw_mut_TrackerNano } - impl TrackerNano { /// Constructor /// ## Parameters @@ -3739,7 +3679,27 @@ pub mod video { } - boxed_cast_base! { TrackerNano, crate::video::Tracker, cv_TrackerNano_to_Tracker } + /// Constant methods for [crate::video::TrackerNano] + pub trait TrackerNanoTraitConst: crate::video::TrackerTraitConst { + fn as_raw_TrackerNano(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::video::TrackerNano] + pub trait TrackerNanoTrait: crate::video::TrackerNanoTraitConst + crate::video::TrackerTrait { + fn as_raw_mut_TrackerNano(&mut self) -> *mut c_void; + + /// Return tracking score + #[inline] + fn get_tracking_score(&mut self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_TrackerNano_getTrackingScore(self.as_raw_mut_TrackerNano(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } impl std::fmt::Debug for TrackerNano { #[inline] @@ -3749,6 +3709,56 @@ pub mod video { } } + boxed_cast_base! { TrackerNano, crate::video::Tracker, cv_TrackerNano_to_Tracker } + + impl crate::video::TrackerTraitConst for TrackerNano { + #[inline] fn as_raw_Tracker(&self) -> *const c_void { self.as_raw() } + } + + impl crate::video::TrackerTrait for TrackerNano { + #[inline] fn as_raw_mut_Tracker(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { TrackerNano, crate::video::TrackerTraitConst, as_raw_Tracker, crate::video::TrackerTrait, as_raw_mut_Tracker } + + impl crate::video::TrackerNanoTraitConst for TrackerNano { + #[inline] fn as_raw_TrackerNano(&self) -> *const c_void { self.as_raw() } + } + + impl crate::video::TrackerNanoTrait for TrackerNano { + #[inline] fn as_raw_mut_TrackerNano(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { TrackerNano, crate::video::TrackerNanoTraitConst, as_raw_TrackerNano, crate::video::TrackerNanoTrait, as_raw_mut_TrackerNano } + + pub struct TrackerNano_Params { + ptr: *mut c_void, + } + + opencv_type_boxed! { TrackerNano_Params } + + impl Drop for TrackerNano_Params { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_TrackerNano_Params_delete(self.as_raw_mut_TrackerNano_Params()) }; + } + } + + unsafe impl Send for TrackerNano_Params {} + + impl TrackerNano_Params { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_TrackerNano_Params_Params(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::video::TrackerNano_Params::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::video::TrackerNano_Params] pub trait TrackerNano_ParamsTraitConst { fn as_raw_TrackerNano_Params(&self) -> *const c_void; @@ -3802,51 +3812,13 @@ pub mod video { #[inline] fn set_backend(&mut self, val: i32) { let ret = unsafe { sys::cv_TrackerNano_Params_propBackend_const_int(self.as_raw_mut_TrackerNano_Params(), val) }; - ret - } - - #[inline] - fn set_target(&mut self, val: i32) { - let ret = unsafe { sys::cv_TrackerNano_Params_propTarget_const_int(self.as_raw_mut_TrackerNano_Params(), val) }; - ret - } - - } - - pub struct TrackerNano_Params { - ptr: *mut c_void, - } - - opencv_type_boxed! { TrackerNano_Params } - - impl Drop for TrackerNano_Params { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_TrackerNano_Params_delete(self.as_raw_mut_TrackerNano_Params()) }; - } - } - - unsafe impl Send for TrackerNano_Params {} - - impl crate::video::TrackerNano_ParamsTraitConst for TrackerNano_Params { - #[inline] fn as_raw_TrackerNano_Params(&self) -> *const c_void { self.as_raw() } - } - - impl crate::video::TrackerNano_ParamsTrait for TrackerNano_Params { - #[inline] fn as_raw_mut_TrackerNano_Params(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TrackerNano_Params, crate::video::TrackerNano_ParamsTraitConst, as_raw_TrackerNano_Params, crate::video::TrackerNano_ParamsTrait, as_raw_mut_TrackerNano_Params } + ret + } - impl TrackerNano_Params { #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_TrackerNano_Params_Params(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::video::TrackerNano_Params::opencv_from_extern(ret) }; - Ok(ret) + fn set_target(&mut self, val: i32) { + let ret = unsafe { sys::cv_TrackerNano_Params_propTarget_const_int(self.as_raw_mut_TrackerNano_Params(), val) }; + ret } } @@ -3870,28 +3842,16 @@ pub mod video { } } - /// Constant methods for [crate::video::TrackerVit] - pub trait TrackerVitTraitConst: crate::video::TrackerTraitConst { - fn as_raw_TrackerVit(&self) -> *const c_void; - + impl crate::video::TrackerNano_ParamsTraitConst for TrackerNano_Params { + #[inline] fn as_raw_TrackerNano_Params(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::video::TrackerVit] - pub trait TrackerVitTrait: crate::video::TrackerTrait + crate::video::TrackerVitTraitConst { - fn as_raw_mut_TrackerVit(&mut self) -> *mut c_void; - - /// Return tracking score - #[inline] - fn get_tracking_score(&mut self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_TrackerVit_getTrackingScore(self.as_raw_mut_TrackerVit(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - + impl crate::video::TrackerNano_ParamsTrait for TrackerNano_Params { + #[inline] fn as_raw_mut_TrackerNano_Params(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { TrackerNano_Params, crate::video::TrackerNano_ParamsTraitConst, as_raw_TrackerNano_Params, crate::video::TrackerNano_ParamsTrait, as_raw_mut_TrackerNano_Params } + /// the VIT tracker is a super lightweight dnn-based general object tracking. /// /// VIT tracker is much faster and extremely lightweight due to special model structure, the model file is about 767KB. @@ -3912,26 +3872,6 @@ pub mod video { unsafe impl Send for TrackerVit {} - impl crate::video::TrackerTraitConst for TrackerVit { - #[inline] fn as_raw_Tracker(&self) -> *const c_void { self.as_raw() } - } - - impl crate::video::TrackerTrait for TrackerVit { - #[inline] fn as_raw_mut_Tracker(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TrackerVit, crate::video::TrackerTraitConst, as_raw_Tracker, crate::video::TrackerTrait, as_raw_mut_Tracker } - - impl crate::video::TrackerVitTraitConst for TrackerVit { - #[inline] fn as_raw_TrackerVit(&self) -> *const c_void { self.as_raw() } - } - - impl crate::video::TrackerVitTrait for TrackerVit { - #[inline] fn as_raw_mut_TrackerVit(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TrackerVit, crate::video::TrackerVitTraitConst, as_raw_TrackerVit, crate::video::TrackerVitTrait, as_raw_mut_TrackerVit } - impl TrackerVit { /// Constructor /// ## Parameters @@ -3968,7 +3908,27 @@ pub mod video { } - boxed_cast_base! { TrackerVit, crate::video::Tracker, cv_TrackerVit_to_Tracker } + /// Constant methods for [crate::video::TrackerVit] + pub trait TrackerVitTraitConst: crate::video::TrackerTraitConst { + fn as_raw_TrackerVit(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::video::TrackerVit] + pub trait TrackerVitTrait: crate::video::TrackerTrait + crate::video::TrackerVitTraitConst { + fn as_raw_mut_TrackerVit(&mut self) -> *mut c_void; + + /// Return tracking score + #[inline] + fn get_tracking_score(&mut self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_TrackerVit_getTrackingScore(self.as_raw_mut_TrackerVit(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } impl std::fmt::Debug for TrackerVit { #[inline] @@ -3978,6 +3938,56 @@ pub mod video { } } + boxed_cast_base! { TrackerVit, crate::video::Tracker, cv_TrackerVit_to_Tracker } + + impl crate::video::TrackerTraitConst for TrackerVit { + #[inline] fn as_raw_Tracker(&self) -> *const c_void { self.as_raw() } + } + + impl crate::video::TrackerTrait for TrackerVit { + #[inline] fn as_raw_mut_Tracker(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { TrackerVit, crate::video::TrackerTraitConst, as_raw_Tracker, crate::video::TrackerTrait, as_raw_mut_Tracker } + + impl crate::video::TrackerVitTraitConst for TrackerVit { + #[inline] fn as_raw_TrackerVit(&self) -> *const c_void { self.as_raw() } + } + + impl crate::video::TrackerVitTrait for TrackerVit { + #[inline] fn as_raw_mut_TrackerVit(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { TrackerVit, crate::video::TrackerVitTraitConst, as_raw_TrackerVit, crate::video::TrackerVitTrait, as_raw_mut_TrackerVit } + + pub struct TrackerVit_Params { + ptr: *mut c_void, + } + + opencv_type_boxed! { TrackerVit_Params } + + impl Drop for TrackerVit_Params { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_TrackerVit_Params_delete(self.as_raw_mut_TrackerVit_Params()) }; + } + } + + unsafe impl Send for TrackerVit_Params {} + + impl TrackerVit_Params { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_TrackerVit_Params_Params(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::video::TrackerVit_Params::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::video::TrackerVit_Params] pub trait TrackerVit_ParamsTraitConst { fn as_raw_TrackerVit_Params(&self) -> *const c_void; @@ -4068,21 +4078,27 @@ pub mod video { } - pub struct TrackerVit_Params { - ptr: *mut c_void, + impl Clone for TrackerVit_Params { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_TrackerVit_Params_implicitClone_const(self.as_raw_TrackerVit_Params())) } + } } - opencv_type_boxed! { TrackerVit_Params } - - impl Drop for TrackerVit_Params { + impl std::fmt::Debug for TrackerVit_Params { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_TrackerVit_Params_delete(self.as_raw_mut_TrackerVit_Params()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TrackerVit_Params") + .field("net", &crate::video::TrackerVit_ParamsTraitConst::net(self)) + .field("backend", &crate::video::TrackerVit_ParamsTraitConst::backend(self)) + .field("target", &crate::video::TrackerVit_ParamsTraitConst::target(self)) + .field("meanvalue", &crate::video::TrackerVit_ParamsTraitConst::meanvalue(self)) + .field("stdvalue", &crate::video::TrackerVit_ParamsTraitConst::stdvalue(self)) + .field("tracking_score_threshold", &crate::video::TrackerVit_ParamsTraitConst::tracking_score_threshold(self)) + .finish() } } - unsafe impl Send for TrackerVit_Params {} - impl crate::video::TrackerVit_ParamsTraitConst for TrackerVit_Params { #[inline] fn as_raw_TrackerVit_Params(&self) -> *const c_void { self.as_raw() } } @@ -4093,38 +4109,42 @@ pub mod video { boxed_ref! { TrackerVit_Params, crate::video::TrackerVit_ParamsTraitConst, as_raw_TrackerVit_Params, crate::video::TrackerVit_ParamsTrait, as_raw_mut_TrackerVit_Params } - impl TrackerVit_Params { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_TrackerVit_Params_Params(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::video::TrackerVit_Params::opencv_from_extern(ret) }; - Ok(ret) - } - + /// Variational optical flow refinement + /// + /// This class implements variational refinement of the input flow field, i.e. + /// it uses input flow to initialize the minimization of the following functional: + /// ![inline formula](https://latex.codecogs.com/png.latex?E%28U%29%20%3D%20%5Cint%5F%7B%5COmega%7D%20%5Cdelta%20%5CPsi%28E%5FI%29%20%2B%20%5Cgamma%20%5CPsi%28E%5FG%29%20%2B%20%5Calpha%20%5CPsi%28E%5FS%29%20), + /// where ![inline formula](https://latex.codecogs.com/png.latex?E%5FI%2CE%5FG%2CE%5FS) are color constancy, gradient constancy and smoothness terms + /// respectively. ![inline formula](https://latex.codecogs.com/png.latex?%5CPsi%28s%5E2%29%3D%5Csqrt%7Bs%5E2%2B%5Cepsilon%5E2%7D) is a robust penalizer to limit the + /// influence of outliers. A complete formulation and a description of the minimization + /// procedure can be found in [Brox2004](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Brox2004) + pub struct VariationalRefinement { + ptr: *mut c_void, } - impl Clone for TrackerVit_Params { + opencv_type_boxed! { VariationalRefinement } + + impl Drop for VariationalRefinement { #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_TrackerVit_Params_implicitClone_const(self.as_raw_TrackerVit_Params())) } + fn drop(&mut self) { + unsafe { sys::cv_VariationalRefinement_delete(self.as_raw_mut_VariationalRefinement()) }; } } - impl std::fmt::Debug for TrackerVit_Params { + unsafe impl Send for VariationalRefinement {} + + impl VariationalRefinement { + /// Creates an instance of VariationalRefinement #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TrackerVit_Params") - .field("net", &crate::video::TrackerVit_ParamsTraitConst::net(self)) - .field("backend", &crate::video::TrackerVit_ParamsTraitConst::backend(self)) - .field("target", &crate::video::TrackerVit_ParamsTraitConst::target(self)) - .field("meanvalue", &crate::video::TrackerVit_ParamsTraitConst::meanvalue(self)) - .field("stdvalue", &crate::video::TrackerVit_ParamsTraitConst::stdvalue(self)) - .field("tracking_score_threshold", &crate::video::TrackerVit_ParamsTraitConst::tracking_score_threshold(self)) - .finish() + pub fn create() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_VariationalRefinement_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::video::VariationalRefinement] @@ -4324,29 +4344,17 @@ pub mod video { } - /// Variational optical flow refinement - /// - /// This class implements variational refinement of the input flow field, i.e. - /// it uses input flow to initialize the minimization of the following functional: - /// ![inline formula](https://latex.codecogs.com/png.latex?E%28U%29%20%3D%20%5Cint%5F%7B%5COmega%7D%20%5Cdelta%20%5CPsi%28E%5FI%29%20%2B%20%5Cgamma%20%5CPsi%28E%5FG%29%20%2B%20%5Calpha%20%5CPsi%28E%5FS%29%20), - /// where ![inline formula](https://latex.codecogs.com/png.latex?E%5FI%2CE%5FG%2CE%5FS) are color constancy, gradient constancy and smoothness terms - /// respectively. ![inline formula](https://latex.codecogs.com/png.latex?%5CPsi%28s%5E2%29%3D%5Csqrt%7Bs%5E2%2B%5Cepsilon%5E2%7D) is a robust penalizer to limit the - /// influence of outliers. A complete formulation and a description of the minimization - /// procedure can be found in [Brox2004](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Brox2004) - pub struct VariationalRefinement { - ptr: *mut c_void, - } - - opencv_type_boxed! { VariationalRefinement } - - impl Drop for VariationalRefinement { + impl std::fmt::Debug for VariationalRefinement { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_VariationalRefinement_delete(self.as_raw_mut_VariationalRefinement()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("VariationalRefinement") + .finish() } } - unsafe impl Send for VariationalRefinement {} + boxed_cast_base! { VariationalRefinement, core::Algorithm, cv_VariationalRefinement_to_Algorithm } + + boxed_cast_base! { VariationalRefinement, crate::video::DenseOpticalFlow, cv_VariationalRefinement_to_DenseOpticalFlow } impl core::AlgorithmTraitConst for VariationalRefinement { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -4378,29 +4386,4 @@ pub mod video { boxed_ref! { VariationalRefinement, crate::video::VariationalRefinementTraitConst, as_raw_VariationalRefinement, crate::video::VariationalRefinementTrait, as_raw_mut_VariationalRefinement } - impl VariationalRefinement { - /// Creates an instance of VariationalRefinement - #[inline] - pub fn create() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_VariationalRefinement_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { VariationalRefinement, core::Algorithm, cv_VariationalRefinement_to_Algorithm } - - boxed_cast_base! { VariationalRefinement, crate::video::DenseOpticalFlow, cv_VariationalRefinement_to_DenseOpticalFlow } - - impl std::fmt::Debug for VariationalRefinement { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("VariationalRefinement") - .finish() - } - } } diff --git a/docs/videoio.rs b/docs/videoio.rs index 6f94f89df..5bb1e7a79 100644 --- a/docs/videoio.rs +++ b/docs/videoio.rs @@ -1435,6 +1435,22 @@ pub mod videoio { Ok(ret) } + /// Read data stream interface + pub struct IStreamReader { + ptr: *mut c_void, + } + + opencv_type_boxed! { IStreamReader } + + impl Drop for IStreamReader { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_IStreamReader_delete(self.as_raw_mut_IStreamReader()) }; + } + } + + unsafe impl Send for IStreamReader {} + /// Constant methods for [crate::videoio::IStreamReader] pub trait IStreamReaderTraitConst { fn as_raw_IStreamReader(&self) -> *const c_void; @@ -1475,22 +1491,14 @@ pub mod videoio { } - /// Read data stream interface - pub struct IStreamReader { - ptr: *mut c_void, - } - - opencv_type_boxed! { IStreamReader } - - impl Drop for IStreamReader { + impl std::fmt::Debug for IStreamReader { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_IStreamReader_delete(self.as_raw_mut_IStreamReader()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("IStreamReader") + .finish() } } - unsafe impl Send for IStreamReader {} - impl crate::videoio::IStreamReaderTraitConst for IStreamReader { #[inline] fn as_raw_IStreamReader(&self) -> *const c_void { self.as_raw() } } @@ -1501,170 +1509,453 @@ pub mod videoio { boxed_ref! { IStreamReader, crate::videoio::IStreamReaderTraitConst, as_raw_IStreamReader, crate::videoio::IStreamReaderTrait, as_raw_mut_IStreamReader } - impl IStreamReader { + /// Class for video capturing from video files, image sequences or cameras. + /// + /// The class provides C++ API for capturing video from cameras or for reading video files and image sequences. + /// + /// Here is how the class can be used: + /// @include samples/cpp/videocapture_basic.cpp + /// + /// + /// Note: In [videoio_c] "C API" the black-box structure `CvCapture` is used instead of %VideoCapture. + /// + /// Note: + /// * (C++) A basic sample on using the %VideoCapture interface can be found at + /// `OPENCV_SOURCE_CODE/samples/cpp/videocapture_starter.cpp` + /// * (Python) A basic sample on using the %VideoCapture interface can be found at + /// `OPENCV_SOURCE_CODE/samples/python/video.py` + /// * (Python) A multi threaded video processing sample can be found at + /// `OPENCV_SOURCE_CODE/samples/python/video_threaded.py` + /// * (Python) %VideoCapture sample showcasing some features of the Video4Linux2 backend + /// `OPENCV_SOURCE_CODE/samples/python/video_v4l2.py` + pub struct VideoCapture { + ptr: *mut c_void, } - impl std::fmt::Debug for IStreamReader { + opencv_type_boxed! { VideoCapture } + + impl Drop for VideoCapture { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("IStreamReader") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_VideoCapture_delete(self.as_raw_mut_VideoCapture()) }; } } - /// Constant methods for [crate::videoio::VideoCapture] - pub trait VideoCaptureTraitConst { - fn as_raw_VideoCapture(&self) -> *const c_void; + unsafe impl Send for VideoCapture {} - /// Returns true if video capturing has been initialized already. + impl VideoCapture { + /// Default constructor /// - /// If the previous call to VideoCapture constructor or VideoCapture::open() succeeded, the method returns - /// true. + /// Note: In [videoio_c] "C API", when you finished working with video, release CvCapture structure with + /// cvReleaseCapture(), or use Ptr\ that calls cvReleaseCapture() automatically in the + /// destructor. #[inline] - fn is_opened(&self) -> Result { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_VideoCapture_isOpened_const(self.as_raw_VideoCapture(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_VideoCapture_VideoCapture(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { crate::videoio::VideoCapture::opencv_from_extern(ret) }; Ok(ret) } - /// Returns the specified VideoCapture property + /// Default constructor /// - /// ## Parameters - /// * propId: Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...) - /// or one from [videoio_flags_others] - /// ## Returns - /// Value for the specified property. Value 0 is returned when querying a property that is - /// not supported by the backend used by the VideoCapture instance. + /// Note: In [videoio_c] "C API", when you finished working with video, release CvCapture structure with + /// cvReleaseCapture(), or use Ptr\ that calls cvReleaseCapture() automatically in the + /// destructor. /// + /// ## Overloaded parameters /// - /// Note: Reading / writing properties involves many layers. Some unexpected result might happens - /// along this chain. - /// ```C++ - /// VideoCapture -> API Backend -> Operating System -> Device Driver -> Device Hardware - /// ``` + /// Opens a video file or a capturing device or an IP video stream for video capturing with API Preference /// - /// The returned value might be different from what really used by the device or it could be encoded - /// using device dependent rules (eg. steps or percentage). Effective behaviour depends from device - /// driver and API Backend + /// ## Parameters + /// * filename: it can be: + /// - name of video file (eg. `video.avi`) + /// - or image sequence (eg. `img_%02d.jpg`, which will read samples like `img_00.jpg, img_01.jpg, img_02.jpg, ...`) + /// - or URL of video stream (eg. `protocol://host:port/script_name?script_params|auth`) + /// - or GStreamer pipeline string in gst-launch tool format in case if GStreamer is used as backend + /// Note that each video stream or IP camera feed has its own URL scheme. Please refer to the + /// documentation of source stream to know the right URL. + /// * apiPreference: preferred Capture API backends to use. Can be used to enforce a specific reader + /// implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW. + /// ## See also + /// cv::VideoCaptureAPIs + /// + /// ## C++ default parameters + /// * api_preference: CAP_ANY #[inline] - fn get(&self, prop_id: i32) -> Result { + pub fn from_file(filename: &str, api_preference: i32) -> Result { + extern_container_arg!(filename); return_send!(via ocvrs_return); - unsafe { sys::cv_VideoCapture_get_const_int(self.as_raw_VideoCapture(), prop_id, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_VideoCapture_VideoCapture_const_StringR_int(filename.opencv_as_extern(), api_preference, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { crate::videoio::VideoCapture::opencv_from_extern(ret) }; Ok(ret) } - /// Returns used backend API name + /// @overload + /// Opens a video file or a capturing device or an IP video stream for video capturing with API Preference /// + /// ## Parameters + /// * filename: it can be: + /// - name of video file (eg. `video.avi`) + /// - or image sequence (eg. `img_%02d.jpg`, which will read samples like `img_00.jpg, img_01.jpg, img_02.jpg, ...`) + /// - or URL of video stream (eg. `protocol://host:port/script_name?script_params|auth`) + /// - or GStreamer pipeline string in gst-launch tool format in case if GStreamer is used as backend + /// Note that each video stream or IP camera feed has its own URL scheme. Please refer to the + /// documentation of source stream to know the right URL. + /// * apiPreference: preferred Capture API backends to use. Can be used to enforce a specific reader + /// implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW. + /// ## See also + /// cv::VideoCaptureAPIs /// - /// Note: Stream should be opened. + /// ## Note + /// This alternative version of [from_file] function uses the following default values for its arguments: + /// * api_preference: CAP_ANY #[inline] - fn get_backend_name(&self) -> Result { + pub fn from_file_def(filename: &str) -> Result { + extern_container_arg!(filename); return_send!(via ocvrs_return); - unsafe { sys::cv_VideoCapture_getBackendName_const(self.as_raw_VideoCapture(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_VideoCapture_VideoCapture_const_StringR(filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { String::opencv_from_extern(ret) }; + let ret = unsafe { crate::videoio::VideoCapture::opencv_from_extern(ret) }; Ok(ret) } - /// query if exception mode is active + /// Default constructor + /// + /// Note: In [videoio_c] "C API", when you finished working with video, release CvCapture structure with + /// cvReleaseCapture(), or use Ptr\ that calls cvReleaseCapture() automatically in the + /// destructor. + /// + /// ## Overloaded parameters + /// + /// Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters + /// + /// The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`. + /// See cv::VideoCaptureProperties #[inline] - fn get_exception_mode(&self) -> Result { + pub fn from_file_with_params(filename: &str, api_preference: i32, params: &core::Vector) -> Result { + extern_container_arg!(filename); return_send!(via ocvrs_return); - unsafe { sys::cv_VideoCapture_getExceptionMode_const(self.as_raw_VideoCapture(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_VideoCapture_VideoCapture_const_StringR_int_const_vectorLintGR(filename.opencv_as_extern(), api_preference, params.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { crate::videoio::VideoCapture::opencv_from_extern(ret) }; Ok(ret) } - } - - /// Mutable methods for [crate::videoio::VideoCapture] - pub trait VideoCaptureTrait: crate::videoio::VideoCaptureTraitConst { - fn as_raw_mut_VideoCapture(&mut self) -> *mut c_void; - - /// Opens a video file or a capturing device or an IP video stream for video capturing. + /// Default constructor /// - /// This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. + /// Note: In [videoio_c] "C API", when you finished working with video, release CvCapture structure with + /// cvReleaseCapture(), or use Ptr\ that calls cvReleaseCapture() automatically in the + /// destructor. /// - /// Parameters are same as the constructor VideoCapture(const String& filename, int apiPreference = CAP_ANY) - /// ## Returns - /// `true` if the file has been successfully opened + /// ## Overloaded parameters /// - /// The method first calls VideoCapture::release to close the already opened file or camera. + /// Opens a camera for video capturing + /// + /// ## Parameters + /// * index: id of the video capturing device to open. To open default camera using default backend just pass 0. + /// (to backward compatibility usage of camera_id + domain_offset (CAP_*) is valid when apiPreference is CAP_ANY) + /// * apiPreference: preferred Capture API backends to use. Can be used to enforce a specific reader + /// implementation if multiple are available: e.g. cv::CAP_DSHOW or cv::CAP_MSMF or cv::CAP_V4L. + /// ## See also + /// cv::VideoCaptureAPIs /// /// ## C++ default parameters /// * api_preference: CAP_ANY #[inline] - fn open_file(&mut self, filename: &str, api_preference: i32) -> Result { - extern_container_arg!(filename); + pub fn new(index: i32, api_preference: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_VideoCapture_open_const_StringR_int(self.as_raw_mut_VideoCapture(), filename.opencv_as_extern(), api_preference, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_VideoCapture_VideoCapture_int_int(index, api_preference, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { crate::videoio::VideoCapture::opencv_from_extern(ret) }; Ok(ret) } - /// Opens a video file or a capturing device or an IP video stream for video capturing. - /// /// @overload + /// Opens a camera for video capturing /// - /// Parameters are same as the constructor VideoCapture(const String& filename, int apiPreference = CAP_ANY) - /// ## Returns - /// `true` if the file has been successfully opened - /// - /// The method first calls VideoCapture::release to close the already opened file or camera. + /// ## Parameters + /// * index: id of the video capturing device to open. To open default camera using default backend just pass 0. + /// (to backward compatibility usage of camera_id + domain_offset (CAP_*) is valid when apiPreference is CAP_ANY) + /// * apiPreference: preferred Capture API backends to use. Can be used to enforce a specific reader + /// implementation if multiple are available: e.g. cv::CAP_DSHOW or cv::CAP_MSMF or cv::CAP_V4L. + /// ## See also + /// cv::VideoCaptureAPIs /// /// ## Note - /// This alternative version of [VideoCaptureTrait::open_file] function uses the following default values for its arguments: + /// This alternative version of [new] function uses the following default values for its arguments: /// * api_preference: CAP_ANY #[inline] - fn open_file_def(&mut self, filename: &str) -> Result { - extern_container_arg!(filename); + pub fn new_def(index: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_VideoCapture_open_const_StringR(self.as_raw_mut_VideoCapture(), filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_VideoCapture_VideoCapture_int(index, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { crate::videoio::VideoCapture::opencv_from_extern(ret) }; Ok(ret) } - /// Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters + /// Default constructor /// - /// This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. + /// Note: In [videoio_c] "C API", when you finished working with video, release CvCapture structure with + /// cvReleaseCapture(), or use Ptr\ that calls cvReleaseCapture() automatically in the + /// destructor. /// - /// The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`. - /// See cv::VideoCaptureProperties + /// ## Overloaded parameters /// - /// ## Returns - /// `true` if the file has been successfully opened + /// Opens a camera for video capturing with API Preference and parameters /// - /// The method first calls VideoCapture::release to close the already opened file or camera. + /// The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`. + /// See cv::VideoCaptureProperties #[inline] - fn open_file_with_params(&mut self, filename: &str, api_preference: i32, params: &core::Vector) -> Result { - extern_container_arg!(filename); + pub fn new_with_params(index: i32, api_preference: i32, params: &core::Vector) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_VideoCapture_open_const_StringR_int_const_vectorLintGR(self.as_raw_mut_VideoCapture(), filename.opencv_as_extern(), api_preference, params.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_VideoCapture_VideoCapture_int_int_const_vectorLintGR(index, api_preference, params.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { crate::videoio::VideoCapture::opencv_from_extern(ret) }; Ok(ret) } - /// Opens a camera for video capturing + /// Default constructor /// - /// This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. + /// Note: In [videoio_c] "C API", when you finished working with video, release CvCapture structure with + /// cvReleaseCapture(), or use Ptr\ that calls cvReleaseCapture() automatically in the + /// destructor. /// - /// Parameters are same as the constructor VideoCapture(int index, int apiPreference = CAP_ANY) - /// ## Returns - /// `true` if the camera has been successfully opened. + /// ## Overloaded parameters /// - /// The method first calls VideoCapture::release to close the already opened file or camera. + /// Opens a video using data stream. /// - /// ## C++ default parameters - /// * api_preference: CAP_ANY + /// The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`. + /// See cv::VideoCaptureProperties + #[inline] + pub fn new_1(source: &core::Ptr, api_preference: i32, params: &core::Vector) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_VideoCapture_VideoCapture_const_PtrLIStreamReaderGR_int_const_vectorLintGR(source.as_raw_PtrOfIStreamReader(), api_preference, params.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videoio::VideoCapture::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Wait for ready frames from VideoCapture. + /// + /// ## Parameters + /// * streams: input video streams + /// * readyIndex: stream indexes with grabbed frames (ready to use .retrieve() to fetch actual frame) + /// * timeoutNs: number of nanoseconds (0 - infinite) + /// ## Returns + /// `true` if streamReady is not empty + /// + /// @throws Exception %Exception on stream errors (check .isOpened() to filter out malformed streams) or VideoCapture type is not supported + /// + /// The primary use of the function is in multi-camera environments. + /// The method fills the ready state vector, grabs video frame, if camera is ready. + /// + /// After this call use VideoCapture::retrieve() to decode and fetch frame data. + /// + /// ## C++ default parameters + /// * timeout_ns: 0 + #[inline] + pub fn wait_any(streams: &core::Vector, ready_index: &mut core::Vector, timeout_ns: i64) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_VideoCapture_waitAny_const_vectorLVideoCaptureGR_vectorLintGR_int64_t(streams.as_raw_VectorOfVideoCapture(), ready_index.as_raw_mut_VectorOfi32(), timeout_ns, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Wait for ready frames from VideoCapture. + /// + /// ## Parameters + /// * streams: input video streams + /// * readyIndex: stream indexes with grabbed frames (ready to use .retrieve() to fetch actual frame) + /// * timeoutNs: number of nanoseconds (0 - infinite) + /// ## Returns + /// `true` if streamReady is not empty + /// + /// @throws Exception %Exception on stream errors (check .isOpened() to filter out malformed streams) or VideoCapture type is not supported + /// + /// The primary use of the function is in multi-camera environments. + /// The method fills the ready state vector, grabs video frame, if camera is ready. + /// + /// After this call use VideoCapture::retrieve() to decode and fetch frame data. + /// + /// ## Note + /// This alternative version of [VideoCapture::wait_any] function uses the following default values for its arguments: + /// * timeout_ns: 0 + #[inline] + pub fn wait_any_def(streams: &core::Vector, ready_index: &mut core::Vector) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_VideoCapture_waitAny_const_vectorLVideoCaptureGR_vectorLintGR(streams.as_raw_VectorOfVideoCapture(), ready_index.as_raw_mut_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + /// Constant methods for [crate::videoio::VideoCapture] + pub trait VideoCaptureTraitConst { + fn as_raw_VideoCapture(&self) -> *const c_void; + + /// Returns true if video capturing has been initialized already. + /// + /// If the previous call to VideoCapture constructor or VideoCapture::open() succeeded, the method returns + /// true. + #[inline] + fn is_opened(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_VideoCapture_isOpened_const(self.as_raw_VideoCapture(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Returns the specified VideoCapture property + /// + /// ## Parameters + /// * propId: Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...) + /// or one from [videoio_flags_others] + /// ## Returns + /// Value for the specified property. Value 0 is returned when querying a property that is + /// not supported by the backend used by the VideoCapture instance. + /// + /// + /// Note: Reading / writing properties involves many layers. Some unexpected result might happens + /// along this chain. + /// ```C++ + /// VideoCapture -> API Backend -> Operating System -> Device Driver -> Device Hardware + /// ``` + /// + /// The returned value might be different from what really used by the device or it could be encoded + /// using device dependent rules (eg. steps or percentage). Effective behaviour depends from device + /// driver and API Backend + #[inline] + fn get(&self, prop_id: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_VideoCapture_get_const_int(self.as_raw_VideoCapture(), prop_id, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Returns used backend API name + /// + /// + /// Note: Stream should be opened. + #[inline] + fn get_backend_name(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_VideoCapture_getBackendName_const(self.as_raw_VideoCapture(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { String::opencv_from_extern(ret) }; + Ok(ret) + } + + /// query if exception mode is active + #[inline] + fn get_exception_mode(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_VideoCapture_getExceptionMode_const(self.as_raw_VideoCapture(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + /// Mutable methods for [crate::videoio::VideoCapture] + pub trait VideoCaptureTrait: crate::videoio::VideoCaptureTraitConst { + fn as_raw_mut_VideoCapture(&mut self) -> *mut c_void; + + /// Opens a video file or a capturing device or an IP video stream for video capturing. + /// + /// This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. + /// + /// Parameters are same as the constructor VideoCapture(const String& filename, int apiPreference = CAP_ANY) + /// ## Returns + /// `true` if the file has been successfully opened + /// + /// The method first calls VideoCapture::release to close the already opened file or camera. + /// + /// ## C++ default parameters + /// * api_preference: CAP_ANY + #[inline] + fn open_file(&mut self, filename: &str, api_preference: i32) -> Result { + extern_container_arg!(filename); + return_send!(via ocvrs_return); + unsafe { sys::cv_VideoCapture_open_const_StringR_int(self.as_raw_mut_VideoCapture(), filename.opencv_as_extern(), api_preference, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Opens a video file or a capturing device or an IP video stream for video capturing. + /// + /// @overload + /// + /// Parameters are same as the constructor VideoCapture(const String& filename, int apiPreference = CAP_ANY) + /// ## Returns + /// `true` if the file has been successfully opened + /// + /// The method first calls VideoCapture::release to close the already opened file or camera. + /// + /// ## Note + /// This alternative version of [VideoCaptureTrait::open_file] function uses the following default values for its arguments: + /// * api_preference: CAP_ANY + #[inline] + fn open_file_def(&mut self, filename: &str) -> Result { + extern_container_arg!(filename); + return_send!(via ocvrs_return); + unsafe { sys::cv_VideoCapture_open_const_StringR(self.as_raw_mut_VideoCapture(), filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters + /// + /// This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. + /// + /// The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`. + /// See cv::VideoCaptureProperties + /// + /// ## Returns + /// `true` if the file has been successfully opened + /// + /// The method first calls VideoCapture::release to close the already opened file or camera. + #[inline] + fn open_file_with_params(&mut self, filename: &str, api_preference: i32, params: &core::Vector) -> Result { + extern_container_arg!(filename); + return_send!(via ocvrs_return); + unsafe { sys::cv_VideoCapture_open_const_StringR_int_const_vectorLintGR(self.as_raw_mut_VideoCapture(), filename.opencv_as_extern(), api_preference, params.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Opens a camera for video capturing + /// + /// This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. + /// + /// Parameters are same as the constructor VideoCapture(int index, int apiPreference = CAP_ANY) + /// ## Returns + /// `true` if the camera has been successfully opened. + /// + /// The method first calls VideoCapture::release to close the already opened file or camera. + /// + /// ## C++ default parameters + /// * api_preference: CAP_ANY #[inline] fn open(&mut self, index: i32, api_preference: i32) -> Result { return_send!(via ocvrs_return); @@ -1902,40 +2193,14 @@ pub mod videoio { } - /// Class for video capturing from video files, image sequences or cameras. - /// - /// The class provides C++ API for capturing video from cameras or for reading video files and image sequences. - /// - /// Here is how the class can be used: - /// @include samples/cpp/videocapture_basic.cpp - /// - /// - /// Note: In [videoio_c] "C API" the black-box structure `CvCapture` is used instead of %VideoCapture. - /// - /// Note: - /// * (C++) A basic sample on using the %VideoCapture interface can be found at - /// `OPENCV_SOURCE_CODE/samples/cpp/videocapture_starter.cpp` - /// * (Python) A basic sample on using the %VideoCapture interface can be found at - /// `OPENCV_SOURCE_CODE/samples/python/video.py` - /// * (Python) A multi threaded video processing sample can be found at - /// `OPENCV_SOURCE_CODE/samples/python/video_threaded.py` - /// * (Python) %VideoCapture sample showcasing some features of the Video4Linux2 backend - /// `OPENCV_SOURCE_CODE/samples/python/video_v4l2.py` - pub struct VideoCapture { - ptr: *mut c_void, - } - - opencv_type_boxed! { VideoCapture } - - impl Drop for VideoCapture { + impl std::fmt::Debug for VideoCapture { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_VideoCapture_delete(self.as_raw_mut_VideoCapture()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("VideoCapture") + .finish() } } - unsafe impl Send for VideoCapture {} - impl crate::videoio::VideoCaptureTraitConst for VideoCapture { #[inline] fn as_raw_VideoCapture(&self) -> *const c_void { self.as_raw() } } @@ -1946,259 +2211,225 @@ pub mod videoio { boxed_ref! { VideoCapture, crate::videoio::VideoCaptureTraitConst, as_raw_VideoCapture, crate::videoio::VideoCaptureTrait, as_raw_mut_VideoCapture } - impl VideoCapture { - /// Default constructor + /// Video writer class. + /// + /// The class provides C++ API for writing video files or image sequences. + pub struct VideoWriter { + ptr: *mut c_void, + } + + opencv_type_boxed! { VideoWriter } + + impl Drop for VideoWriter { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_VideoWriter_delete(self.as_raw_mut_VideoWriter()) }; + } + } + + unsafe impl Send for VideoWriter {} + + impl VideoWriter { + /// Default constructors /// - /// Note: In [videoio_c] "C API", when you finished working with video, release CvCapture structure with - /// cvReleaseCapture(), or use Ptr\ that calls cvReleaseCapture() automatically in the - /// destructor. + /// The constructors/functions initialize video writers. + /// * On Linux FFMPEG is used to write videos; + /// * On Windows FFMPEG or MSWF or DSHOW is used; + /// * On MacOSX AVFoundation is used. #[inline] - pub fn default() -> Result { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_VideoCapture_VideoCapture(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_VideoWriter_VideoWriter(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::videoio::VideoCapture::opencv_from_extern(ret) }; + let ret = unsafe { crate::videoio::VideoWriter::opencv_from_extern(ret) }; Ok(ret) } - /// Default constructor + /// Default constructors /// - /// Note: In [videoio_c] "C API", when you finished working with video, release CvCapture structure with - /// cvReleaseCapture(), or use Ptr\ that calls cvReleaseCapture() automatically in the - /// destructor. + /// The constructors/functions initialize video writers. + /// * On Linux FFMPEG is used to write videos; + /// * On Windows FFMPEG or MSWF or DSHOW is used; + /// * On MacOSX AVFoundation is used. /// /// ## Overloaded parameters /// - /// Opens a video file or a capturing device or an IP video stream for video capturing with API Preference - /// /// ## Parameters - /// * filename: it can be: - /// - name of video file (eg. `video.avi`) - /// - or image sequence (eg. `img_%02d.jpg`, which will read samples like `img_00.jpg, img_01.jpg, img_02.jpg, ...`) - /// - or URL of video stream (eg. `protocol://host:port/script_name?script_params|auth`) - /// - or GStreamer pipeline string in gst-launch tool format in case if GStreamer is used as backend - /// Note that each video stream or IP camera feed has its own URL scheme. Please refer to the - /// documentation of source stream to know the right URL. - /// * apiPreference: preferred Capture API backends to use. Can be used to enforce a specific reader - /// implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW. - /// ## See also - /// cv::VideoCaptureAPIs + /// * filename: Name of the output video file. + /// * fourcc: 4-character code of codec used to compress the frames. For example, + /// VideoWriter::fourcc('P','I','M','1') is a MPEG-1 codec, VideoWriter::fourcc('M','J','P','G') + /// is a motion-jpeg codec etc. List of codes can be obtained at + /// [MSDN](https://docs.microsoft.com/en-us/windows/win32/medfound/video-fourccs) page + /// or with this [page](https://fourcc.org/codecs.php) + /// of the fourcc site for a more complete list). FFMPEG backend with MP4 container natively uses + /// other values as fourcc code: see [ObjectType](http://mp4ra.org/#/codecs), + /// so you may receive a warning message from OpenCV about fourcc code conversion. + /// * fps: Framerate of the created video stream. + /// * frameSize: Size of the video frames. + /// * isColor: If it is not zero, the encoder will expect and encode color frames, otherwise it + /// will work with grayscale frames. + /// + /// @b Tips: + /// - With some backends `fourcc=-1` pops up the codec selection dialog from the system. + /// - To save image sequence use a proper filename (eg. `img_%02d.jpg`) and `fourcc=0` + /// OR `fps=0`. Use uncompressed image format (eg. `img_%02d.BMP`) to save raw frames. + /// - Most codecs are lossy. If you want lossless video file you need to use a lossless codecs + /// (eg. FFMPEG FFV1, Huffman HFYU, Lagarith LAGS, etc...) + /// - If FFMPEG is enabled, using `codec=0; fps=0;` you can create an uncompressed (raw) video file. + /// - If FFMPEG is used, we allow frames of odd width or height, but in this case we truncate + /// the rightmost column/the bottom row. Probably, this should be handled more elegantly, + /// but some internal functions inside FFMPEG swscale require even width/height. /// /// ## C++ default parameters - /// * api_preference: CAP_ANY + /// * is_color: true #[inline] - pub fn from_file(filename: &str, api_preference: i32) -> Result { + pub fn new(filename: &str, fourcc: i32, fps: f64, frame_size: core::Size, is_color: bool) -> Result { extern_container_arg!(filename); return_send!(via ocvrs_return); - unsafe { sys::cv_VideoCapture_VideoCapture_const_StringR_int(filename.opencv_as_extern(), api_preference, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_VideoWriter_VideoWriter_const_StringR_int_double_Size_bool(filename.opencv_as_extern(), fourcc, fps, &frame_size, is_color, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::videoio::VideoCapture::opencv_from_extern(ret) }; + let ret = unsafe { crate::videoio::VideoWriter::opencv_from_extern(ret) }; Ok(ret) } /// @overload - /// Opens a video file or a capturing device or an IP video stream for video capturing with API Preference - /// /// ## Parameters - /// * filename: it can be: - /// - name of video file (eg. `video.avi`) - /// - or image sequence (eg. `img_%02d.jpg`, which will read samples like `img_00.jpg, img_01.jpg, img_02.jpg, ...`) - /// - or URL of video stream (eg. `protocol://host:port/script_name?script_params|auth`) - /// - or GStreamer pipeline string in gst-launch tool format in case if GStreamer is used as backend - /// Note that each video stream or IP camera feed has its own URL scheme. Please refer to the - /// documentation of source stream to know the right URL. - /// * apiPreference: preferred Capture API backends to use. Can be used to enforce a specific reader - /// implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW. - /// ## See also - /// cv::VideoCaptureAPIs - /// - /// ## Note - /// This alternative version of [from_file] function uses the following default values for its arguments: - /// * api_preference: CAP_ANY - #[inline] - pub fn from_file_def(filename: &str) -> Result { - extern_container_arg!(filename); - return_send!(via ocvrs_return); - unsafe { sys::cv_VideoCapture_VideoCapture_const_StringR(filename.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videoio::VideoCapture::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Default constructor - /// - /// Note: In [videoio_c] "C API", when you finished working with video, release CvCapture structure with - /// cvReleaseCapture(), or use Ptr\ that calls cvReleaseCapture() automatically in the - /// destructor. - /// - /// ## Overloaded parameters + /// * filename: Name of the output video file. + /// * fourcc: 4-character code of codec used to compress the frames. For example, + /// VideoWriter::fourcc('P','I','M','1') is a MPEG-1 codec, VideoWriter::fourcc('M','J','P','G') + /// is a motion-jpeg codec etc. List of codes can be obtained at + /// [MSDN](https://docs.microsoft.com/en-us/windows/win32/medfound/video-fourccs) page + /// or with this [page](https://fourcc.org/codecs.php) + /// of the fourcc site for a more complete list). FFMPEG backend with MP4 container natively uses + /// other values as fourcc code: see [ObjectType](http://mp4ra.org/#/codecs), + /// so you may receive a warning message from OpenCV about fourcc code conversion. + /// * fps: Framerate of the created video stream. + /// * frameSize: Size of the video frames. + /// * isColor: If it is not zero, the encoder will expect and encode color frames, otherwise it + /// will work with grayscale frames. /// - /// Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters + /// @b Tips: + /// - With some backends `fourcc=-1` pops up the codec selection dialog from the system. + /// - To save image sequence use a proper filename (eg. `img_%02d.jpg`) and `fourcc=0` + /// OR `fps=0`. Use uncompressed image format (eg. `img_%02d.BMP`) to save raw frames. + /// - Most codecs are lossy. If you want lossless video file you need to use a lossless codecs + /// (eg. FFMPEG FFV1, Huffman HFYU, Lagarith LAGS, etc...) + /// - If FFMPEG is enabled, using `codec=0; fps=0;` you can create an uncompressed (raw) video file. + /// - If FFMPEG is used, we allow frames of odd width or height, but in this case we truncate + /// the rightmost column/the bottom row. Probably, this should be handled more elegantly, + /// but some internal functions inside FFMPEG swscale require even width/height. /// - /// The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`. - /// See cv::VideoCaptureProperties + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * is_color: true #[inline] - pub fn from_file_with_params(filename: &str, api_preference: i32, params: &core::Vector) -> Result { + pub fn new_def(filename: &str, fourcc: i32, fps: f64, frame_size: core::Size) -> Result { extern_container_arg!(filename); return_send!(via ocvrs_return); - unsafe { sys::cv_VideoCapture_VideoCapture_const_StringR_int_const_vectorLintGR(filename.opencv_as_extern(), api_preference, params.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_VideoWriter_VideoWriter_const_StringR_int_double_Size(filename.opencv_as_extern(), fourcc, fps, &frame_size, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::videoio::VideoCapture::opencv_from_extern(ret) }; + let ret = unsafe { crate::videoio::VideoWriter::opencv_from_extern(ret) }; Ok(ret) } - /// Default constructor + /// Default constructors /// - /// Note: In [videoio_c] "C API", when you finished working with video, release CvCapture structure with - /// cvReleaseCapture(), or use Ptr\ that calls cvReleaseCapture() automatically in the - /// destructor. + /// The constructors/functions initialize video writers. + /// * On Linux FFMPEG is used to write videos; + /// * On Windows FFMPEG or MSWF or DSHOW is used; + /// * On MacOSX AVFoundation is used. /// /// ## Overloaded parameters /// - /// Opens a camera for video capturing - /// - /// ## Parameters - /// * index: id of the video capturing device to open. To open default camera using default backend just pass 0. - /// (to backward compatibility usage of camera_id + domain_offset (CAP_*) is valid when apiPreference is CAP_ANY) - /// * apiPreference: preferred Capture API backends to use. Can be used to enforce a specific reader - /// implementation if multiple are available: e.g. cv::CAP_DSHOW or cv::CAP_MSMF or cv::CAP_V4L. - /// ## See also - /// cv::VideoCaptureAPIs + /// The `apiPreference` parameter allows to specify API backends to use. Can be used to enforce a specific reader implementation + /// if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_GSTREAMER. /// /// ## C++ default parameters - /// * api_preference: CAP_ANY + /// * is_color: true #[inline] - pub fn new(index: i32, api_preference: i32) -> Result { + pub fn new_with_backend(filename: &str, api_preference: i32, fourcc: i32, fps: f64, frame_size: core::Size, is_color: bool) -> Result { + extern_container_arg!(filename); return_send!(via ocvrs_return); - unsafe { sys::cv_VideoCapture_VideoCapture_int_int(index, api_preference, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_VideoWriter_VideoWriter_const_StringR_int_int_double_Size_bool(filename.opencv_as_extern(), api_preference, fourcc, fps, &frame_size, is_color, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::videoio::VideoCapture::opencv_from_extern(ret) }; + let ret = unsafe { crate::videoio::VideoWriter::opencv_from_extern(ret) }; Ok(ret) } /// @overload - /// Opens a camera for video capturing - /// - /// ## Parameters - /// * index: id of the video capturing device to open. To open default camera using default backend just pass 0. - /// (to backward compatibility usage of camera_id + domain_offset (CAP_*) is valid when apiPreference is CAP_ANY) - /// * apiPreference: preferred Capture API backends to use. Can be used to enforce a specific reader - /// implementation if multiple are available: e.g. cv::CAP_DSHOW or cv::CAP_MSMF or cv::CAP_V4L. - /// ## See also - /// cv::VideoCaptureAPIs + /// The `apiPreference` parameter allows to specify API backends to use. Can be used to enforce a specific reader implementation + /// if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_GSTREAMER. /// /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * api_preference: CAP_ANY + /// This alternative version of [new_with_backend] function uses the following default values for its arguments: + /// * is_color: true #[inline] - pub fn new_def(index: i32) -> Result { + pub fn new_with_backend_def(filename: &str, api_preference: i32, fourcc: i32, fps: f64, frame_size: core::Size) -> Result { + extern_container_arg!(filename); return_send!(via ocvrs_return); - unsafe { sys::cv_VideoCapture_VideoCapture_int(index, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_VideoWriter_VideoWriter_const_StringR_int_int_double_Size(filename.opencv_as_extern(), api_preference, fourcc, fps, &frame_size, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::videoio::VideoCapture::opencv_from_extern(ret) }; + let ret = unsafe { crate::videoio::VideoWriter::opencv_from_extern(ret) }; Ok(ret) } - /// Default constructor + /// Default constructors /// - /// Note: In [videoio_c] "C API", when you finished working with video, release CvCapture structure with - /// cvReleaseCapture(), or use Ptr\ that calls cvReleaseCapture() automatically in the - /// destructor. + /// The constructors/functions initialize video writers. + /// * On Linux FFMPEG is used to write videos; + /// * On Windows FFMPEG or MSWF or DSHOW is used; + /// * On MacOSX AVFoundation is used. /// /// ## Overloaded parameters /// - /// Opens a camera for video capturing with API Preference and parameters - /// - /// The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`. - /// See cv::VideoCaptureProperties + /// The `params` parameter allows to specify extra encoder parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) + /// see cv::VideoWriterProperties #[inline] - pub fn new_with_params(index: i32, api_preference: i32, params: &core::Vector) -> Result { + pub fn new_1(filename: &str, fourcc: i32, fps: f64, frame_size: core::Size, params: &core::Vector) -> Result { + extern_container_arg!(filename); return_send!(via ocvrs_return); - unsafe { sys::cv_VideoCapture_VideoCapture_int_int_const_vectorLintGR(index, api_preference, params.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_VideoWriter_VideoWriter_const_StringR_int_double_const_SizeR_const_vectorLintGR(filename.opencv_as_extern(), fourcc, fps, &frame_size, params.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::videoio::VideoCapture::opencv_from_extern(ret) }; + let ret = unsafe { crate::videoio::VideoWriter::opencv_from_extern(ret) }; Ok(ret) } - /// Default constructor + /// Default constructors /// - /// Note: In [videoio_c] "C API", when you finished working with video, release CvCapture structure with - /// cvReleaseCapture(), or use Ptr\ that calls cvReleaseCapture() automatically in the - /// destructor. + /// The constructors/functions initialize video writers. + /// * On Linux FFMPEG is used to write videos; + /// * On Windows FFMPEG or MSWF or DSHOW is used; + /// * On MacOSX AVFoundation is used. /// /// ## Overloaded parameters - /// - /// Opens a video using data stream. - /// - /// The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`. - /// See cv::VideoCaptureProperties #[inline] - pub fn new_1(source: &core::Ptr, api_preference: i32, params: &core::Vector) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_VideoCapture_VideoCapture_const_PtrLIStreamReaderGR_int_const_vectorLintGR(source.as_raw_PtrOfIStreamReader(), api_preference, params.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videoio::VideoCapture::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Wait for ready frames from VideoCapture. - /// - /// ## Parameters - /// * streams: input video streams - /// * readyIndex: stream indexes with grabbed frames (ready to use .retrieve() to fetch actual frame) - /// * timeoutNs: number of nanoseconds (0 - infinite) - /// ## Returns - /// `true` if streamReady is not empty - /// - /// @throws Exception %Exception on stream errors (check .isOpened() to filter out malformed streams) or VideoCapture type is not supported - /// - /// The primary use of the function is in multi-camera environments. - /// The method fills the ready state vector, grabs video frame, if camera is ready. - /// - /// After this call use VideoCapture::retrieve() to decode and fetch frame data. - /// - /// ## C++ default parameters - /// * timeout_ns: 0 - #[inline] - pub fn wait_any(streams: &core::Vector, ready_index: &mut core::Vector, timeout_ns: i64) -> Result { + pub fn new_2(filename: &str, api_preference: i32, fourcc: i32, fps: f64, frame_size: core::Size, params: &core::Vector) -> Result { + extern_container_arg!(filename); return_send!(via ocvrs_return); - unsafe { sys::cv_VideoCapture_waitAny_const_vectorLVideoCaptureGR_vectorLintGR_int64_t(streams.as_raw_VectorOfVideoCapture(), ready_index.as_raw_mut_VectorOfi32(), timeout_ns, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_VideoWriter_VideoWriter_const_StringR_int_int_double_const_SizeR_const_vectorLintGR(filename.opencv_as_extern(), api_preference, fourcc, fps, &frame_size, params.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { crate::videoio::VideoWriter::opencv_from_extern(ret) }; Ok(ret) - } - - /// Wait for ready frames from VideoCapture. - /// - /// ## Parameters - /// * streams: input video streams - /// * readyIndex: stream indexes with grabbed frames (ready to use .retrieve() to fetch actual frame) - /// * timeoutNs: number of nanoseconds (0 - infinite) - /// ## Returns - /// `true` if streamReady is not empty - /// - /// @throws Exception %Exception on stream errors (check .isOpened() to filter out malformed streams) or VideoCapture type is not supported - /// - /// The primary use of the function is in multi-camera environments. - /// The method fills the ready state vector, grabs video frame, if camera is ready. + } + + /// Concatenates 4 chars to a fourcc code /// - /// After this call use VideoCapture::retrieve() to decode and fetch frame data. + /// ## Returns + /// a fourcc code /// - /// ## Note - /// This alternative version of [VideoCapture::wait_any] function uses the following default values for its arguments: - /// * timeout_ns: 0 + /// This static method constructs the fourcc code of the codec to be used in the constructor + /// VideoWriter::VideoWriter or VideoWriter::open. #[inline] - pub fn wait_any_def(streams: &core::Vector, ready_index: &mut core::Vector) -> Result { + pub fn fourcc(c1: char, c2: char, c3: char, c4: char) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_VideoCapture_waitAny_const_vectorLVideoCaptureGR_vectorLintGR(streams.as_raw_VectorOfVideoCapture(), ready_index.as_raw_mut_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_VideoWriter_fourcc_char_char_char_char(u8::try_from(c1)? as c_char, u8::try_from(c2)? as c_char, u8::try_from(c3)? as c_char, u8::try_from(c4)? as c_char, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -2206,14 +2437,6 @@ pub mod videoio { } - impl std::fmt::Debug for VideoCapture { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("VideoCapture") - .finish() - } - } - /// Constant methods for [crate::videoio::VideoWriter] pub trait VideoWriterTraitConst { fn as_raw_VideoWriter(&self) -> *const c_void; @@ -2437,24 +2660,14 @@ pub mod videoio { } - /// Video writer class. - /// - /// The class provides C++ API for writing video files or image sequences. - pub struct VideoWriter { - ptr: *mut c_void, - } - - opencv_type_boxed! { VideoWriter } - - impl Drop for VideoWriter { + impl std::fmt::Debug for VideoWriter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_VideoWriter_delete(self.as_raw_mut_VideoWriter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("VideoWriter") + .finish() } } - unsafe impl Send for VideoWriter {} - impl crate::videoio::VideoWriterTraitConst for VideoWriter { #[inline] fn as_raw_VideoWriter(&self) -> *const c_void { self.as_raw() } } @@ -2465,219 +2678,4 @@ pub mod videoio { boxed_ref! { VideoWriter, crate::videoio::VideoWriterTraitConst, as_raw_VideoWriter, crate::videoio::VideoWriterTrait, as_raw_mut_VideoWriter } - impl VideoWriter { - /// Default constructors - /// - /// The constructors/functions initialize video writers. - /// * On Linux FFMPEG is used to write videos; - /// * On Windows FFMPEG or MSWF or DSHOW is used; - /// * On MacOSX AVFoundation is used. - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_VideoWriter_VideoWriter(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videoio::VideoWriter::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Default constructors - /// - /// The constructors/functions initialize video writers. - /// * On Linux FFMPEG is used to write videos; - /// * On Windows FFMPEG or MSWF or DSHOW is used; - /// * On MacOSX AVFoundation is used. - /// - /// ## Overloaded parameters - /// - /// ## Parameters - /// * filename: Name of the output video file. - /// * fourcc: 4-character code of codec used to compress the frames. For example, - /// VideoWriter::fourcc('P','I','M','1') is a MPEG-1 codec, VideoWriter::fourcc('M','J','P','G') - /// is a motion-jpeg codec etc. List of codes can be obtained at - /// [MSDN](https://docs.microsoft.com/en-us/windows/win32/medfound/video-fourccs) page - /// or with this [page](https://fourcc.org/codecs.php) - /// of the fourcc site for a more complete list). FFMPEG backend with MP4 container natively uses - /// other values as fourcc code: see [ObjectType](http://mp4ra.org/#/codecs), - /// so you may receive a warning message from OpenCV about fourcc code conversion. - /// * fps: Framerate of the created video stream. - /// * frameSize: Size of the video frames. - /// * isColor: If it is not zero, the encoder will expect and encode color frames, otherwise it - /// will work with grayscale frames. - /// - /// @b Tips: - /// - With some backends `fourcc=-1` pops up the codec selection dialog from the system. - /// - To save image sequence use a proper filename (eg. `img_%02d.jpg`) and `fourcc=0` - /// OR `fps=0`. Use uncompressed image format (eg. `img_%02d.BMP`) to save raw frames. - /// - Most codecs are lossy. If you want lossless video file you need to use a lossless codecs - /// (eg. FFMPEG FFV1, Huffman HFYU, Lagarith LAGS, etc...) - /// - If FFMPEG is enabled, using `codec=0; fps=0;` you can create an uncompressed (raw) video file. - /// - If FFMPEG is used, we allow frames of odd width or height, but in this case we truncate - /// the rightmost column/the bottom row. Probably, this should be handled more elegantly, - /// but some internal functions inside FFMPEG swscale require even width/height. - /// - /// ## C++ default parameters - /// * is_color: true - #[inline] - pub fn new(filename: &str, fourcc: i32, fps: f64, frame_size: core::Size, is_color: bool) -> Result { - extern_container_arg!(filename); - return_send!(via ocvrs_return); - unsafe { sys::cv_VideoWriter_VideoWriter_const_StringR_int_double_Size_bool(filename.opencv_as_extern(), fourcc, fps, &frame_size, is_color, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videoio::VideoWriter::opencv_from_extern(ret) }; - Ok(ret) - } - - /// @overload - /// ## Parameters - /// * filename: Name of the output video file. - /// * fourcc: 4-character code of codec used to compress the frames. For example, - /// VideoWriter::fourcc('P','I','M','1') is a MPEG-1 codec, VideoWriter::fourcc('M','J','P','G') - /// is a motion-jpeg codec etc. List of codes can be obtained at - /// [MSDN](https://docs.microsoft.com/en-us/windows/win32/medfound/video-fourccs) page - /// or with this [page](https://fourcc.org/codecs.php) - /// of the fourcc site for a more complete list). FFMPEG backend with MP4 container natively uses - /// other values as fourcc code: see [ObjectType](http://mp4ra.org/#/codecs), - /// so you may receive a warning message from OpenCV about fourcc code conversion. - /// * fps: Framerate of the created video stream. - /// * frameSize: Size of the video frames. - /// * isColor: If it is not zero, the encoder will expect and encode color frames, otherwise it - /// will work with grayscale frames. - /// - /// @b Tips: - /// - With some backends `fourcc=-1` pops up the codec selection dialog from the system. - /// - To save image sequence use a proper filename (eg. `img_%02d.jpg`) and `fourcc=0` - /// OR `fps=0`. Use uncompressed image format (eg. `img_%02d.BMP`) to save raw frames. - /// - Most codecs are lossy. If you want lossless video file you need to use a lossless codecs - /// (eg. FFMPEG FFV1, Huffman HFYU, Lagarith LAGS, etc...) - /// - If FFMPEG is enabled, using `codec=0; fps=0;` you can create an uncompressed (raw) video file. - /// - If FFMPEG is used, we allow frames of odd width or height, but in this case we truncate - /// the rightmost column/the bottom row. Probably, this should be handled more elegantly, - /// but some internal functions inside FFMPEG swscale require even width/height. - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * is_color: true - #[inline] - pub fn new_def(filename: &str, fourcc: i32, fps: f64, frame_size: core::Size) -> Result { - extern_container_arg!(filename); - return_send!(via ocvrs_return); - unsafe { sys::cv_VideoWriter_VideoWriter_const_StringR_int_double_Size(filename.opencv_as_extern(), fourcc, fps, &frame_size, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videoio::VideoWriter::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Default constructors - /// - /// The constructors/functions initialize video writers. - /// * On Linux FFMPEG is used to write videos; - /// * On Windows FFMPEG or MSWF or DSHOW is used; - /// * On MacOSX AVFoundation is used. - /// - /// ## Overloaded parameters - /// - /// The `apiPreference` parameter allows to specify API backends to use. Can be used to enforce a specific reader implementation - /// if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_GSTREAMER. - /// - /// ## C++ default parameters - /// * is_color: true - #[inline] - pub fn new_with_backend(filename: &str, api_preference: i32, fourcc: i32, fps: f64, frame_size: core::Size, is_color: bool) -> Result { - extern_container_arg!(filename); - return_send!(via ocvrs_return); - unsafe { sys::cv_VideoWriter_VideoWriter_const_StringR_int_int_double_Size_bool(filename.opencv_as_extern(), api_preference, fourcc, fps, &frame_size, is_color, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videoio::VideoWriter::opencv_from_extern(ret) }; - Ok(ret) - } - - /// @overload - /// The `apiPreference` parameter allows to specify API backends to use. Can be used to enforce a specific reader implementation - /// if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_GSTREAMER. - /// - /// ## Note - /// This alternative version of [new_with_backend] function uses the following default values for its arguments: - /// * is_color: true - #[inline] - pub fn new_with_backend_def(filename: &str, api_preference: i32, fourcc: i32, fps: f64, frame_size: core::Size) -> Result { - extern_container_arg!(filename); - return_send!(via ocvrs_return); - unsafe { sys::cv_VideoWriter_VideoWriter_const_StringR_int_int_double_Size(filename.opencv_as_extern(), api_preference, fourcc, fps, &frame_size, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videoio::VideoWriter::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Default constructors - /// - /// The constructors/functions initialize video writers. - /// * On Linux FFMPEG is used to write videos; - /// * On Windows FFMPEG or MSWF or DSHOW is used; - /// * On MacOSX AVFoundation is used. - /// - /// ## Overloaded parameters - /// - /// The `params` parameter allows to specify extra encoder parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) - /// see cv::VideoWriterProperties - #[inline] - pub fn new_1(filename: &str, fourcc: i32, fps: f64, frame_size: core::Size, params: &core::Vector) -> Result { - extern_container_arg!(filename); - return_send!(via ocvrs_return); - unsafe { sys::cv_VideoWriter_VideoWriter_const_StringR_int_double_const_SizeR_const_vectorLintGR(filename.opencv_as_extern(), fourcc, fps, &frame_size, params.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videoio::VideoWriter::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Default constructors - /// - /// The constructors/functions initialize video writers. - /// * On Linux FFMPEG is used to write videos; - /// * On Windows FFMPEG or MSWF or DSHOW is used; - /// * On MacOSX AVFoundation is used. - /// - /// ## Overloaded parameters - #[inline] - pub fn new_2(filename: &str, api_preference: i32, fourcc: i32, fps: f64, frame_size: core::Size, params: &core::Vector) -> Result { - extern_container_arg!(filename); - return_send!(via ocvrs_return); - unsafe { sys::cv_VideoWriter_VideoWriter_const_StringR_int_int_double_const_SizeR_const_vectorLintGR(filename.opencv_as_extern(), api_preference, fourcc, fps, &frame_size, params.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videoio::VideoWriter::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Concatenates 4 chars to a fourcc code - /// - /// ## Returns - /// a fourcc code - /// - /// This static method constructs the fourcc code of the codec to be used in the constructor - /// VideoWriter::VideoWriter or VideoWriter::open. - #[inline] - pub fn fourcc(c1: char, c2: char, c3: char, c4: char) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_VideoWriter_fourcc_char_char_char_char(u8::try_from(c1)? as c_char, u8::try_from(c2)? as c_char, u8::try_from(c3)? as c_char, u8::try_from(c4)? as c_char, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - impl std::fmt::Debug for VideoWriter { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("VideoWriter") - .finish() - } - } } diff --git a/docs/videostab.rs b/docs/videostab.rs index 1e2c52119..c43f3b8a6 100644 --- a/docs/videostab.rs +++ b/docs/videostab.rs @@ -247,6 +247,32 @@ pub mod videostab { Ok(ret) } + pub struct ColorAverageInpainter { + ptr: *mut c_void, + } + + opencv_type_boxed! { ColorAverageInpainter } + + impl Drop for ColorAverageInpainter { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_videostab_ColorAverageInpainter_delete(self.as_raw_mut_ColorAverageInpainter()) }; + } + } + + unsafe impl Send for ColorAverageInpainter {} + + impl ColorAverageInpainter { + /// Creates a default instance of the class by calling the default constructor + #[inline] + pub fn default() -> crate::videostab::ColorAverageInpainter { + let ret = unsafe { sys::cv_videostab_ColorAverageInpainter_defaultNew_const() }; + let ret = unsafe { crate::videostab::ColorAverageInpainter::opencv_from_extern(ret) }; + ret + } + + } + /// Constant methods for [crate::videostab::ColorAverageInpainter] pub trait ColorAverageInpainterTraitConst: crate::videostab::InpainterBaseTraitConst { fn as_raw_ColorAverageInpainter(&self) -> *const c_void; @@ -268,20 +294,23 @@ pub mod videostab { } - pub struct ColorAverageInpainter { - ptr: *mut c_void, + impl Default for ColorAverageInpainter { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { ColorAverageInpainter } - - impl Drop for ColorAverageInpainter { + impl std::fmt::Debug for ColorAverageInpainter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_ColorAverageInpainter_delete(self.as_raw_mut_ColorAverageInpainter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ColorAverageInpainter") + .finish() } } - unsafe impl Send for ColorAverageInpainter {} + boxed_cast_base! { ColorAverageInpainter, crate::videostab::InpainterBase, cv_videostab_ColorAverageInpainter_to_InpainterBase } impl crate::videostab::InpainterBaseTraitConst for ColorAverageInpainter { #[inline] fn as_raw_InpainterBase(&self) -> *const c_void { self.as_raw() } @@ -303,31 +332,49 @@ pub mod videostab { boxed_ref! { ColorAverageInpainter, crate::videostab::ColorAverageInpainterTraitConst, as_raw_ColorAverageInpainter, crate::videostab::ColorAverageInpainterTrait, as_raw_mut_ColorAverageInpainter } - impl ColorAverageInpainter { - /// Creates a default instance of the class by calling the default constructor + pub struct ColorInpainter { + ptr: *mut c_void, + } + + opencv_type_boxed! { ColorInpainter } + + impl Drop for ColorInpainter { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_videostab_ColorAverageInpainter_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_videostab_ColorInpainter_delete(self.as_raw_mut_ColorInpainter()) }; } - } - boxed_cast_base! { ColorAverageInpainter, crate::videostab::InpainterBase, cv_videostab_ColorAverageInpainter_to_InpainterBase } + unsafe impl Send for ColorInpainter {} - impl std::fmt::Debug for ColorAverageInpainter { + impl ColorInpainter { + /// ## C++ default parameters + /// * method: INPAINT_TELEA + /// * radius: 2. #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ColorAverageInpainter") - .finish() + pub fn new(method: i32, radius: f64) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_ColorInpainter_ColorInpainter_int_double(method, radius, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::ColorInpainter::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for ColorAverageInpainter { + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * method: INPAINT_TELEA + /// * radius: 2. #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_ColorInpainter_ColorInpainter(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::ColorInpainter::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::videostab::ColorInpainter] @@ -351,20 +398,15 @@ pub mod videostab { } - pub struct ColorInpainter { - ptr: *mut c_void, - } - - opencv_type_boxed! { ColorInpainter } - - impl Drop for ColorInpainter { + impl std::fmt::Debug for ColorInpainter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_ColorInpainter_delete(self.as_raw_mut_ColorInpainter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ColorInpainter") + .finish() } } - unsafe impl Send for ColorInpainter {} + boxed_cast_base! { ColorInpainter, crate::videostab::InpainterBase, cv_videostab_ColorInpainter_to_InpainterBase } impl crate::videostab::InpainterBaseTraitConst for ColorInpainter { #[inline] fn as_raw_InpainterBase(&self) -> *const c_void { self.as_raw() } @@ -386,46 +428,34 @@ pub mod videostab { boxed_ref! { ColorInpainter, crate::videostab::ColorInpainterTraitConst, as_raw_ColorInpainter, crate::videostab::ColorInpainterTrait, as_raw_mut_ColorInpainter } - impl ColorInpainter { - /// ## C++ default parameters - /// * method: INPAINT_TELEA - /// * radius: 2. + pub struct ConsistentMosaicInpainter { + ptr: *mut c_void, + } + + opencv_type_boxed! { ConsistentMosaicInpainter } + + impl Drop for ConsistentMosaicInpainter { #[inline] - pub fn new(method: i32, radius: f64) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_ColorInpainter_ColorInpainter_int_double(method, radius, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::ColorInpainter::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_videostab_ConsistentMosaicInpainter_delete(self.as_raw_mut_ConsistentMosaicInpainter()) }; } + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * method: INPAINT_TELEA - /// * radius: 2. + unsafe impl Send for ConsistentMosaicInpainter {} + + impl ConsistentMosaicInpainter { #[inline] - pub fn new_def() -> Result { + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_ColorInpainter_ColorInpainter(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_videostab_ConsistentMosaicInpainter_ConsistentMosaicInpainter(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::ColorInpainter::opencv_from_extern(ret) }; + let ret = unsafe { crate::videostab::ConsistentMosaicInpainter::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { ColorInpainter, crate::videostab::InpainterBase, cv_videostab_ColorInpainter_to_InpainterBase } - - impl std::fmt::Debug for ColorInpainter { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ColorInpainter") - .finish() - } - } - /// Constant methods for [crate::videostab::ConsistentMosaicInpainter] pub trait ConsistentMosaicInpainterTraitConst: crate::videostab::InpainterBaseTraitConst { fn as_raw_ConsistentMosaicInpainter(&self) -> *const c_void; @@ -465,20 +495,15 @@ pub mod videostab { } - pub struct ConsistentMosaicInpainter { - ptr: *mut c_void, - } - - opencv_type_boxed! { ConsistentMosaicInpainter } - - impl Drop for ConsistentMosaicInpainter { + impl std::fmt::Debug for ConsistentMosaicInpainter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_ConsistentMosaicInpainter_delete(self.as_raw_mut_ConsistentMosaicInpainter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ConsistentMosaicInpainter") + .finish() } } - unsafe impl Send for ConsistentMosaicInpainter {} + boxed_cast_base! { ConsistentMosaicInpainter, crate::videostab::InpainterBase, cv_videostab_ConsistentMosaicInpainter_to_InpainterBase } impl crate::videostab::InpainterBaseTraitConst for ConsistentMosaicInpainter { #[inline] fn as_raw_InpainterBase(&self) -> *const c_void { self.as_raw() } @@ -500,29 +525,21 @@ pub mod videostab { boxed_ref! { ConsistentMosaicInpainter, crate::videostab::ConsistentMosaicInpainterTraitConst, as_raw_ConsistentMosaicInpainter, crate::videostab::ConsistentMosaicInpainterTrait, as_raw_mut_ConsistentMosaicInpainter } - impl ConsistentMosaicInpainter { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_ConsistentMosaicInpainter_ConsistentMosaicInpainter(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::ConsistentMosaicInpainter::opencv_from_extern(ret) }; - Ok(ret) - } - + pub struct DeblurerBase { + ptr: *mut c_void, } - boxed_cast_base! { ConsistentMosaicInpainter, crate::videostab::InpainterBase, cv_videostab_ConsistentMosaicInpainter_to_InpainterBase } + opencv_type_boxed! { DeblurerBase } - impl std::fmt::Debug for ConsistentMosaicInpainter { + impl Drop for DeblurerBase { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ConsistentMosaicInpainter") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_DeblurerBase_delete(self.as_raw_mut_DeblurerBase()) }; } } + unsafe impl Send for DeblurerBase {} + /// Constant methods for [crate::videostab::DeblurerBase] pub trait DeblurerBaseTraitConst { fn as_raw_DeblurerBase(&self) -> *const c_void; @@ -619,20 +636,17 @@ pub mod videostab { } - pub struct DeblurerBase { - ptr: *mut c_void, - } - - opencv_type_boxed! { DeblurerBase } - - impl Drop for DeblurerBase { + impl std::fmt::Debug for DeblurerBase { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_DeblurerBase_delete(self.as_raw_mut_DeblurerBase()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DeblurerBase") + .finish() } } - unsafe impl Send for DeblurerBase {} + boxed_cast_descendant! { DeblurerBase, crate::videostab::NullDeblurer, cv_videostab_DeblurerBase_to_NullDeblurer } + + boxed_cast_descendant! { DeblurerBase, crate::videostab::WeightingDeblurer, cv_videostab_DeblurerBase_to_WeightingDeblurer } impl crate::videostab::DeblurerBaseTraitConst for DeblurerBase { #[inline] fn as_raw_DeblurerBase(&self) -> *const c_void { self.as_raw() } @@ -644,19 +658,32 @@ pub mod videostab { boxed_ref! { DeblurerBase, crate::videostab::DeblurerBaseTraitConst, as_raw_DeblurerBase, crate::videostab::DeblurerBaseTrait, as_raw_mut_DeblurerBase } - impl DeblurerBase { + pub struct DensePyrLkOptFlowEstimatorGpu { + ptr: *mut c_void, } - boxed_cast_descendant! { DeblurerBase, crate::videostab::NullDeblurer, cv_videostab_DeblurerBase_to_NullDeblurer } + opencv_type_boxed! { DensePyrLkOptFlowEstimatorGpu } - boxed_cast_descendant! { DeblurerBase, crate::videostab::WeightingDeblurer, cv_videostab_DeblurerBase_to_WeightingDeblurer } + impl Drop for DensePyrLkOptFlowEstimatorGpu { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_videostab_DensePyrLkOptFlowEstimatorGpu_delete(self.as_raw_mut_DensePyrLkOptFlowEstimatorGpu()) }; + } + } - impl std::fmt::Debug for DeblurerBase { + unsafe impl Send for DensePyrLkOptFlowEstimatorGpu {} + + impl DensePyrLkOptFlowEstimatorGpu { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DeblurerBase") - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_DensePyrLkOptFlowEstimatorGpu_DensePyrLkOptFlowEstimatorGpu(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::DensePyrLkOptFlowEstimatorGpu::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::videostab::DensePyrLkOptFlowEstimatorGpu] @@ -685,20 +712,17 @@ pub mod videostab { } - pub struct DensePyrLkOptFlowEstimatorGpu { - ptr: *mut c_void, - } - - opencv_type_boxed! { DensePyrLkOptFlowEstimatorGpu } - - impl Drop for DensePyrLkOptFlowEstimatorGpu { + impl std::fmt::Debug for DensePyrLkOptFlowEstimatorGpu { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_DensePyrLkOptFlowEstimatorGpu_delete(self.as_raw_mut_DensePyrLkOptFlowEstimatorGpu()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DensePyrLkOptFlowEstimatorGpu") + .finish() } } - unsafe impl Send for DensePyrLkOptFlowEstimatorGpu {} + boxed_cast_base! { DensePyrLkOptFlowEstimatorGpu, crate::videostab::IDenseOptFlowEstimator, cv_videostab_DensePyrLkOptFlowEstimatorGpu_to_IDenseOptFlowEstimator } + + boxed_cast_base! { DensePyrLkOptFlowEstimatorGpu, crate::videostab::PyrLkOptFlowEstimatorBase, cv_videostab_DensePyrLkOptFlowEstimatorGpu_to_PyrLkOptFlowEstimatorBase } impl crate::videostab::IDenseOptFlowEstimatorTraitConst for DensePyrLkOptFlowEstimatorGpu { #[inline] fn as_raw_IDenseOptFlowEstimator(&self) -> *const c_void { self.as_raw() } @@ -730,29 +754,35 @@ pub mod videostab { boxed_ref! { DensePyrLkOptFlowEstimatorGpu, crate::videostab::DensePyrLkOptFlowEstimatorGpuTraitConst, as_raw_DensePyrLkOptFlowEstimatorGpu, crate::videostab::DensePyrLkOptFlowEstimatorGpuTrait, as_raw_mut_DensePyrLkOptFlowEstimatorGpu } - impl DensePyrLkOptFlowEstimatorGpu { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_DensePyrLkOptFlowEstimatorGpu_DensePyrLkOptFlowEstimatorGpu(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::DensePyrLkOptFlowEstimatorGpu::opencv_from_extern(ret) }; - Ok(ret) - } - + /// Describes the Fast Marching Method implementation. + /// + /// See + pub struct FastMarchingMethod { + ptr: *mut c_void, } - boxed_cast_base! { DensePyrLkOptFlowEstimatorGpu, crate::videostab::IDenseOptFlowEstimator, cv_videostab_DensePyrLkOptFlowEstimatorGpu_to_IDenseOptFlowEstimator } + opencv_type_boxed! { FastMarchingMethod } - boxed_cast_base! { DensePyrLkOptFlowEstimatorGpu, crate::videostab::PyrLkOptFlowEstimatorBase, cv_videostab_DensePyrLkOptFlowEstimatorGpu_to_PyrLkOptFlowEstimatorBase } + impl Drop for FastMarchingMethod { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_videostab_FastMarchingMethod_delete(self.as_raw_mut_FastMarchingMethod()) }; + } + } - impl std::fmt::Debug for DensePyrLkOptFlowEstimatorGpu { + unsafe impl Send for FastMarchingMethod {} + + impl FastMarchingMethod { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DensePyrLkOptFlowEstimatorGpu") - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_FastMarchingMethod_FastMarchingMethod(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::FastMarchingMethod::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::videostab::FastMarchingMethod] @@ -779,24 +809,14 @@ pub mod videostab { } - /// Describes the Fast Marching Method implementation. - /// - /// See - pub struct FastMarchingMethod { - ptr: *mut c_void, - } - - opencv_type_boxed! { FastMarchingMethod } - - impl Drop for FastMarchingMethod { + impl std::fmt::Debug for FastMarchingMethod { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_FastMarchingMethod_delete(self.as_raw_mut_FastMarchingMethod()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FastMarchingMethod") + .finish() } } - unsafe impl Send for FastMarchingMethod {} - impl crate::videostab::FastMarchingMethodTraitConst for FastMarchingMethod { #[inline] fn as_raw_FastMarchingMethod(&self) -> *const c_void { self.as_raw() } } @@ -807,27 +827,35 @@ pub mod videostab { boxed_ref! { FastMarchingMethod, crate::videostab::FastMarchingMethodTraitConst, as_raw_FastMarchingMethod, crate::videostab::FastMarchingMethodTrait, as_raw_mut_FastMarchingMethod } - impl FastMarchingMethod { + pub struct FromFileMotionReader { + ptr: *mut c_void, + } + + opencv_type_boxed! { FromFileMotionReader } + + impl Drop for FromFileMotionReader { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_videostab_FromFileMotionReader_delete(self.as_raw_mut_FromFileMotionReader()) }; + } + } + + unsafe impl Send for FromFileMotionReader {} + + impl FromFileMotionReader { + #[inline] + pub fn new(path: &str) -> Result { + extern_container_arg!(path); return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_FastMarchingMethod_FastMarchingMethod(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_videostab_FromFileMotionReader_FromFileMotionReader_const_StringR(path.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::FastMarchingMethod::opencv_from_extern(ret) }; + let ret = unsafe { crate::videostab::FromFileMotionReader::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for FastMarchingMethod { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FastMarchingMethod") - .finish() - } - } - /// Constant methods for [crate::videostab::FromFileMotionReader] pub trait FromFileMotionReaderTraitConst: crate::videostab::ImageMotionEstimatorBaseTraitConst { fn as_raw_FromFileMotionReader(&self) -> *const c_void; @@ -865,20 +893,15 @@ pub mod videostab { } - pub struct FromFileMotionReader { - ptr: *mut c_void, - } - - opencv_type_boxed! { FromFileMotionReader } - - impl Drop for FromFileMotionReader { + impl std::fmt::Debug for FromFileMotionReader { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_FromFileMotionReader_delete(self.as_raw_mut_FromFileMotionReader()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FromFileMotionReader") + .finish() } } - unsafe impl Send for FromFileMotionReader {} + boxed_cast_base! { FromFileMotionReader, crate::videostab::ImageMotionEstimatorBase, cv_videostab_FromFileMotionReader_to_ImageMotionEstimatorBase } impl crate::videostab::ImageMotionEstimatorBaseTraitConst for FromFileMotionReader { #[inline] fn as_raw_ImageMotionEstimatorBase(&self) -> *const c_void { self.as_raw() } @@ -900,28 +923,49 @@ pub mod videostab { boxed_ref! { FromFileMotionReader, crate::videostab::FromFileMotionReaderTraitConst, as_raw_FromFileMotionReader, crate::videostab::FromFileMotionReaderTrait, as_raw_mut_FromFileMotionReader } - impl FromFileMotionReader { + pub struct GaussianMotionFilter { + ptr: *mut c_void, + } + + opencv_type_boxed! { GaussianMotionFilter } + + impl Drop for GaussianMotionFilter { #[inline] - pub fn new(path: &str) -> Result { - extern_container_arg!(path); + fn drop(&mut self) { + unsafe { sys::cv_videostab_GaussianMotionFilter_delete(self.as_raw_mut_GaussianMotionFilter()) }; + } + } + + unsafe impl Send for GaussianMotionFilter {} + + impl GaussianMotionFilter { + /// ## C++ default parameters + /// * radius: 15 + /// * stdev: -1.f + #[inline] + pub fn new(radius: i32, stdev: f32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_FromFileMotionReader_FromFileMotionReader_const_StringR(path.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_videostab_GaussianMotionFilter_GaussianMotionFilter_int_float(radius, stdev, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::FromFileMotionReader::opencv_from_extern(ret) }; + let ret = unsafe { crate::videostab::GaussianMotionFilter::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { FromFileMotionReader, crate::videostab::ImageMotionEstimatorBase, cv_videostab_FromFileMotionReader_to_ImageMotionEstimatorBase } - - impl std::fmt::Debug for FromFileMotionReader { + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * radius: 15 + /// * stdev: -1.f #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FromFileMotionReader") - .finish() + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_GaussianMotionFilter_GaussianMotionFilter(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::GaussianMotionFilter::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::videostab::GaussianMotionFilter] @@ -987,20 +1031,17 @@ pub mod videostab { } - pub struct GaussianMotionFilter { - ptr: *mut c_void, - } - - opencv_type_boxed! { GaussianMotionFilter } - - impl Drop for GaussianMotionFilter { + impl std::fmt::Debug for GaussianMotionFilter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_GaussianMotionFilter_delete(self.as_raw_mut_GaussianMotionFilter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GaussianMotionFilter") + .finish() } } - unsafe impl Send for GaussianMotionFilter {} + boxed_cast_base! { GaussianMotionFilter, crate::videostab::IMotionStabilizer, cv_videostab_GaussianMotionFilter_to_IMotionStabilizer } + + boxed_cast_base! { GaussianMotionFilter, crate::videostab::MotionFilterBase, cv_videostab_GaussianMotionFilter_to_MotionFilterBase } impl crate::videostab::IMotionStabilizerTraitConst for GaussianMotionFilter { #[inline] fn as_raw_IMotionStabilizer(&self) -> *const c_void { self.as_raw() } @@ -1032,48 +1073,21 @@ pub mod videostab { boxed_ref! { GaussianMotionFilter, crate::videostab::GaussianMotionFilterTraitConst, as_raw_GaussianMotionFilter, crate::videostab::GaussianMotionFilterTrait, as_raw_mut_GaussianMotionFilter } - impl GaussianMotionFilter { - /// ## C++ default parameters - /// * radius: 15 - /// * stdev: -1.f - #[inline] - pub fn new(radius: i32, stdev: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_GaussianMotionFilter_GaussianMotionFilter_int_float(radius, stdev, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::GaussianMotionFilter::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * radius: 15 - /// * stdev: -1.f - #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_GaussianMotionFilter_GaussianMotionFilter(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::GaussianMotionFilter::opencv_from_extern(ret) }; - Ok(ret) - } - + pub struct IDenseOptFlowEstimator { + ptr: *mut c_void, } - boxed_cast_base! { GaussianMotionFilter, crate::videostab::IMotionStabilizer, cv_videostab_GaussianMotionFilter_to_IMotionStabilizer } - - boxed_cast_base! { GaussianMotionFilter, crate::videostab::MotionFilterBase, cv_videostab_GaussianMotionFilter_to_MotionFilterBase } + opencv_type_boxed! { IDenseOptFlowEstimator } - impl std::fmt::Debug for GaussianMotionFilter { + impl Drop for IDenseOptFlowEstimator { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GaussianMotionFilter") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_IDenseOptFlowEstimator_delete(self.as_raw_mut_IDenseOptFlowEstimator()) }; } } + unsafe impl Send for IDenseOptFlowEstimator {} + /// Constant methods for [crate::videostab::IDenseOptFlowEstimator] pub trait IDenseOptFlowEstimatorTraitConst { fn as_raw_IDenseOptFlowEstimator(&self) -> *const c_void; @@ -1100,20 +1114,15 @@ pub mod videostab { } - pub struct IDenseOptFlowEstimator { - ptr: *mut c_void, - } - - opencv_type_boxed! { IDenseOptFlowEstimator } - - impl Drop for IDenseOptFlowEstimator { + impl std::fmt::Debug for IDenseOptFlowEstimator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_IDenseOptFlowEstimator_delete(self.as_raw_mut_IDenseOptFlowEstimator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("IDenseOptFlowEstimator") + .finish() } } - unsafe impl Send for IDenseOptFlowEstimator {} + boxed_cast_descendant! { IDenseOptFlowEstimator, crate::videostab::DensePyrLkOptFlowEstimatorGpu, cv_videostab_IDenseOptFlowEstimator_to_DensePyrLkOptFlowEstimatorGpu } impl crate::videostab::IDenseOptFlowEstimatorTraitConst for IDenseOptFlowEstimator { #[inline] fn as_raw_IDenseOptFlowEstimator(&self) -> *const c_void { self.as_raw() } @@ -1125,19 +1134,21 @@ pub mod videostab { boxed_ref! { IDenseOptFlowEstimator, crate::videostab::IDenseOptFlowEstimatorTraitConst, as_raw_IDenseOptFlowEstimator, crate::videostab::IDenseOptFlowEstimatorTrait, as_raw_mut_IDenseOptFlowEstimator } - impl IDenseOptFlowEstimator { + pub struct IFrameSource { + ptr: *mut c_void, } - boxed_cast_descendant! { IDenseOptFlowEstimator, crate::videostab::DensePyrLkOptFlowEstimatorGpu, cv_videostab_IDenseOptFlowEstimator_to_DensePyrLkOptFlowEstimatorGpu } + opencv_type_boxed! { IFrameSource } - impl std::fmt::Debug for IDenseOptFlowEstimator { + impl Drop for IFrameSource { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("IDenseOptFlowEstimator") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_IFrameSource_delete(self.as_raw_mut_IFrameSource()) }; } } + unsafe impl Send for IFrameSource {} + /// Constant methods for [crate::videostab::IFrameSource] pub trait IFrameSourceTraitConst { fn as_raw_IFrameSource(&self) -> *const c_void; @@ -1169,20 +1180,23 @@ pub mod videostab { } - pub struct IFrameSource { - ptr: *mut c_void, - } - - opencv_type_boxed! { IFrameSource } - - impl Drop for IFrameSource { + impl std::fmt::Debug for IFrameSource { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_IFrameSource_delete(self.as_raw_mut_IFrameSource()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("IFrameSource") + .finish() } } - unsafe impl Send for IFrameSource {} + boxed_cast_descendant! { IFrameSource, crate::videostab::MaskFrameSource, cv_videostab_IFrameSource_to_MaskFrameSource } + + boxed_cast_descendant! { IFrameSource, crate::videostab::NullFrameSource, cv_videostab_IFrameSource_to_NullFrameSource } + + boxed_cast_descendant! { IFrameSource, crate::videostab::OnePassStabilizer, cv_videostab_IFrameSource_to_OnePassStabilizer } + + boxed_cast_descendant! { IFrameSource, crate::videostab::TwoPassStabilizer, cv_videostab_IFrameSource_to_TwoPassStabilizer } + + boxed_cast_descendant! { IFrameSource, crate::videostab::VideoFileSource, cv_videostab_IFrameSource_to_VideoFileSource } impl crate::videostab::IFrameSourceTraitConst for IFrameSource { #[inline] fn as_raw_IFrameSource(&self) -> *const c_void { self.as_raw() } @@ -1194,27 +1208,21 @@ pub mod videostab { boxed_ref! { IFrameSource, crate::videostab::IFrameSourceTraitConst, as_raw_IFrameSource, crate::videostab::IFrameSourceTrait, as_raw_mut_IFrameSource } - impl IFrameSource { + pub struct ILog { + ptr: *mut c_void, } - boxed_cast_descendant! { IFrameSource, crate::videostab::MaskFrameSource, cv_videostab_IFrameSource_to_MaskFrameSource } - - boxed_cast_descendant! { IFrameSource, crate::videostab::NullFrameSource, cv_videostab_IFrameSource_to_NullFrameSource } - - boxed_cast_descendant! { IFrameSource, crate::videostab::OnePassStabilizer, cv_videostab_IFrameSource_to_OnePassStabilizer } - - boxed_cast_descendant! { IFrameSource, crate::videostab::TwoPassStabilizer, cv_videostab_IFrameSource_to_TwoPassStabilizer } - - boxed_cast_descendant! { IFrameSource, crate::videostab::VideoFileSource, cv_videostab_IFrameSource_to_VideoFileSource } + opencv_type_boxed! { ILog } - impl std::fmt::Debug for IFrameSource { + impl Drop for ILog { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("IFrameSource") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_ILog_delete(self.as_raw_mut_ILog()) }; } } + unsafe impl Send for ILog {} + /// Constant methods for [crate::videostab::ILog] pub trait ILogTraitConst { fn as_raw_ILog(&self) -> *const c_void; @@ -1237,20 +1245,17 @@ pub mod videostab { } - pub struct ILog { - ptr: *mut c_void, - } - - opencv_type_boxed! { ILog } - - impl Drop for ILog { + impl std::fmt::Debug for ILog { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_ILog_delete(self.as_raw_mut_ILog()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ILog") + .finish() } } - unsafe impl Send for ILog {} + boxed_cast_descendant! { ILog, crate::videostab::LogToStdout, cv_videostab_ILog_to_LogToStdout } + + boxed_cast_descendant! { ILog, crate::videostab::NullLog, cv_videostab_ILog_to_NullLog } impl crate::videostab::ILogTraitConst for ILog { #[inline] fn as_raw_ILog(&self) -> *const c_void { self.as_raw() } @@ -1262,21 +1267,21 @@ pub mod videostab { boxed_ref! { ILog, crate::videostab::ILogTraitConst, as_raw_ILog, crate::videostab::ILogTrait, as_raw_mut_ILog } - impl ILog { + pub struct IMotionStabilizer { + ptr: *mut c_void, } - boxed_cast_descendant! { ILog, crate::videostab::LogToStdout, cv_videostab_ILog_to_LogToStdout } - - boxed_cast_descendant! { ILog, crate::videostab::NullLog, cv_videostab_ILog_to_NullLog } + opencv_type_boxed! { IMotionStabilizer } - impl std::fmt::Debug for ILog { + impl Drop for IMotionStabilizer { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ILog") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_IMotionStabilizer_delete(self.as_raw_mut_IMotionStabilizer()) }; } } + unsafe impl Send for IMotionStabilizer {} + /// Constant methods for [crate::videostab::IMotionStabilizer] pub trait IMotionStabilizerTraitConst { fn as_raw_IMotionStabilizer(&self) -> *const c_void; @@ -1299,20 +1304,21 @@ pub mod videostab { } - pub struct IMotionStabilizer { - ptr: *mut c_void, - } - - opencv_type_boxed! { IMotionStabilizer } - - impl Drop for IMotionStabilizer { + impl std::fmt::Debug for IMotionStabilizer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_IMotionStabilizer_delete(self.as_raw_mut_IMotionStabilizer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("IMotionStabilizer") + .finish() } } - unsafe impl Send for IMotionStabilizer {} + boxed_cast_descendant! { IMotionStabilizer, crate::videostab::GaussianMotionFilter, cv_videostab_IMotionStabilizer_to_GaussianMotionFilter } + + boxed_cast_descendant! { IMotionStabilizer, crate::videostab::LpMotionStabilizer, cv_videostab_IMotionStabilizer_to_LpMotionStabilizer } + + boxed_cast_descendant! { IMotionStabilizer, crate::videostab::MotionFilterBase, cv_videostab_IMotionStabilizer_to_MotionFilterBase } + + boxed_cast_descendant! { IMotionStabilizer, crate::videostab::MotionStabilizationPipeline, cv_videostab_IMotionStabilizer_to_MotionStabilizationPipeline } impl crate::videostab::IMotionStabilizerTraitConst for IMotionStabilizer { #[inline] fn as_raw_IMotionStabilizer(&self) -> *const c_void { self.as_raw() } @@ -1324,25 +1330,21 @@ pub mod videostab { boxed_ref! { IMotionStabilizer, crate::videostab::IMotionStabilizerTraitConst, as_raw_IMotionStabilizer, crate::videostab::IMotionStabilizerTrait, as_raw_mut_IMotionStabilizer } - impl IMotionStabilizer { + pub struct IOutlierRejector { + ptr: *mut c_void, } - boxed_cast_descendant! { IMotionStabilizer, crate::videostab::GaussianMotionFilter, cv_videostab_IMotionStabilizer_to_GaussianMotionFilter } - - boxed_cast_descendant! { IMotionStabilizer, crate::videostab::LpMotionStabilizer, cv_videostab_IMotionStabilizer_to_LpMotionStabilizer } - - boxed_cast_descendant! { IMotionStabilizer, crate::videostab::MotionFilterBase, cv_videostab_IMotionStabilizer_to_MotionFilterBase } - - boxed_cast_descendant! { IMotionStabilizer, crate::videostab::MotionStabilizationPipeline, cv_videostab_IMotionStabilizer_to_MotionStabilizationPipeline } + opencv_type_boxed! { IOutlierRejector } - impl std::fmt::Debug for IMotionStabilizer { + impl Drop for IOutlierRejector { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("IMotionStabilizer") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_IOutlierRejector_delete(self.as_raw_mut_IOutlierRejector()) }; } } + unsafe impl Send for IOutlierRejector {} + /// Constant methods for [crate::videostab::IOutlierRejector] pub trait IOutlierRejectorTraitConst { fn as_raw_IOutlierRejector(&self) -> *const c_void; @@ -1367,20 +1369,17 @@ pub mod videostab { } - pub struct IOutlierRejector { - ptr: *mut c_void, - } - - opencv_type_boxed! { IOutlierRejector } - - impl Drop for IOutlierRejector { + impl std::fmt::Debug for IOutlierRejector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_IOutlierRejector_delete(self.as_raw_mut_IOutlierRejector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("IOutlierRejector") + .finish() } } - unsafe impl Send for IOutlierRejector {} + boxed_cast_descendant! { IOutlierRejector, crate::videostab::NullOutlierRejector, cv_videostab_IOutlierRejector_to_NullOutlierRejector } + + boxed_cast_descendant! { IOutlierRejector, crate::videostab::TranslationBasedLocalOutlierRejector, cv_videostab_IOutlierRejector_to_TranslationBasedLocalOutlierRejector } impl crate::videostab::IOutlierRejectorTraitConst for IOutlierRejector { #[inline] fn as_raw_IOutlierRejector(&self) -> *const c_void { self.as_raw() } @@ -1392,21 +1391,21 @@ pub mod videostab { boxed_ref! { IOutlierRejector, crate::videostab::IOutlierRejectorTraitConst, as_raw_IOutlierRejector, crate::videostab::IOutlierRejectorTrait, as_raw_mut_IOutlierRejector } - impl IOutlierRejector { + pub struct ISparseOptFlowEstimator { + ptr: *mut c_void, } - boxed_cast_descendant! { IOutlierRejector, crate::videostab::NullOutlierRejector, cv_videostab_IOutlierRejector_to_NullOutlierRejector } - - boxed_cast_descendant! { IOutlierRejector, crate::videostab::TranslationBasedLocalOutlierRejector, cv_videostab_IOutlierRejector_to_TranslationBasedLocalOutlierRejector } + opencv_type_boxed! { ISparseOptFlowEstimator } - impl std::fmt::Debug for IOutlierRejector { + impl Drop for ISparseOptFlowEstimator { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("IOutlierRejector") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_ISparseOptFlowEstimator_delete(self.as_raw_mut_ISparseOptFlowEstimator()) }; } } + unsafe impl Send for ISparseOptFlowEstimator {} + /// Constant methods for [crate::videostab::ISparseOptFlowEstimator] pub trait ISparseOptFlowEstimatorTraitConst { fn as_raw_ISparseOptFlowEstimator(&self) -> *const c_void; @@ -1434,20 +1433,17 @@ pub mod videostab { } - pub struct ISparseOptFlowEstimator { - ptr: *mut c_void, - } - - opencv_type_boxed! { ISparseOptFlowEstimator } - - impl Drop for ISparseOptFlowEstimator { + impl std::fmt::Debug for ISparseOptFlowEstimator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_ISparseOptFlowEstimator_delete(self.as_raw_mut_ISparseOptFlowEstimator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ISparseOptFlowEstimator") + .finish() } } - unsafe impl Send for ISparseOptFlowEstimator {} + boxed_cast_descendant! { ISparseOptFlowEstimator, crate::videostab::SparsePyrLkOptFlowEstimator, cv_videostab_ISparseOptFlowEstimator_to_SparsePyrLkOptFlowEstimator } + + boxed_cast_descendant! { ISparseOptFlowEstimator, crate::videostab::SparsePyrLkOptFlowEstimatorGpu, cv_videostab_ISparseOptFlowEstimator_to_SparsePyrLkOptFlowEstimatorGpu } impl crate::videostab::ISparseOptFlowEstimatorTraitConst for ISparseOptFlowEstimator { #[inline] fn as_raw_ISparseOptFlowEstimator(&self) -> *const c_void { self.as_raw() } @@ -1459,21 +1455,22 @@ pub mod videostab { boxed_ref! { ISparseOptFlowEstimator, crate::videostab::ISparseOptFlowEstimatorTraitConst, as_raw_ISparseOptFlowEstimator, crate::videostab::ISparseOptFlowEstimatorTrait, as_raw_mut_ISparseOptFlowEstimator } - impl ISparseOptFlowEstimator { + /// Base class for global 2D motion estimation methods which take frames as input. + pub struct ImageMotionEstimatorBase { + ptr: *mut c_void, } - boxed_cast_descendant! { ISparseOptFlowEstimator, crate::videostab::SparsePyrLkOptFlowEstimator, cv_videostab_ISparseOptFlowEstimator_to_SparsePyrLkOptFlowEstimator } - - boxed_cast_descendant! { ISparseOptFlowEstimator, crate::videostab::SparsePyrLkOptFlowEstimatorGpu, cv_videostab_ISparseOptFlowEstimator_to_SparsePyrLkOptFlowEstimatorGpu } + opencv_type_boxed! { ImageMotionEstimatorBase } - impl std::fmt::Debug for ISparseOptFlowEstimator { + impl Drop for ImageMotionEstimatorBase { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ISparseOptFlowEstimator") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_ImageMotionEstimatorBase_delete(self.as_raw_mut_ImageMotionEstimatorBase()) }; } } + unsafe impl Send for ImageMotionEstimatorBase {} + /// Constant methods for [crate::videostab::ImageMotionEstimatorBase] pub trait ImageMotionEstimatorBaseTraitConst { fn as_raw_ImageMotionEstimatorBase(&self) -> *const c_void; @@ -1539,21 +1536,21 @@ pub mod videostab { } - /// Base class for global 2D motion estimation methods which take frames as input. - pub struct ImageMotionEstimatorBase { - ptr: *mut c_void, - } - - opencv_type_boxed! { ImageMotionEstimatorBase } - - impl Drop for ImageMotionEstimatorBase { + impl std::fmt::Debug for ImageMotionEstimatorBase { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_ImageMotionEstimatorBase_delete(self.as_raw_mut_ImageMotionEstimatorBase()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ImageMotionEstimatorBase") + .finish() } } - unsafe impl Send for ImageMotionEstimatorBase {} + boxed_cast_descendant! { ImageMotionEstimatorBase, crate::videostab::FromFileMotionReader, cv_videostab_ImageMotionEstimatorBase_to_FromFileMotionReader } + + boxed_cast_descendant! { ImageMotionEstimatorBase, crate::videostab::KeypointBasedMotionEstimator, cv_videostab_ImageMotionEstimatorBase_to_KeypointBasedMotionEstimator } + + boxed_cast_descendant! { ImageMotionEstimatorBase, crate::videostab::KeypointBasedMotionEstimatorGpu, cv_videostab_ImageMotionEstimatorBase_to_KeypointBasedMotionEstimatorGpu } + + boxed_cast_descendant! { ImageMotionEstimatorBase, crate::videostab::ToFileMotionWriter, cv_videostab_ImageMotionEstimatorBase_to_ToFileMotionWriter } impl crate::videostab::ImageMotionEstimatorBaseTraitConst for ImageMotionEstimatorBase { #[inline] fn as_raw_ImageMotionEstimatorBase(&self) -> *const c_void { self.as_raw() } @@ -1565,25 +1562,21 @@ pub mod videostab { boxed_ref! { ImageMotionEstimatorBase, crate::videostab::ImageMotionEstimatorBaseTraitConst, as_raw_ImageMotionEstimatorBase, crate::videostab::ImageMotionEstimatorBaseTrait, as_raw_mut_ImageMotionEstimatorBase } - impl ImageMotionEstimatorBase { + pub struct InpainterBase { + ptr: *mut c_void, } - boxed_cast_descendant! { ImageMotionEstimatorBase, crate::videostab::FromFileMotionReader, cv_videostab_ImageMotionEstimatorBase_to_FromFileMotionReader } - - boxed_cast_descendant! { ImageMotionEstimatorBase, crate::videostab::KeypointBasedMotionEstimator, cv_videostab_ImageMotionEstimatorBase_to_KeypointBasedMotionEstimator } - - boxed_cast_descendant! { ImageMotionEstimatorBase, crate::videostab::KeypointBasedMotionEstimatorGpu, cv_videostab_ImageMotionEstimatorBase_to_KeypointBasedMotionEstimatorGpu } - - boxed_cast_descendant! { ImageMotionEstimatorBase, crate::videostab::ToFileMotionWriter, cv_videostab_ImageMotionEstimatorBase_to_ToFileMotionWriter } + opencv_type_boxed! { InpainterBase } - impl std::fmt::Debug for ImageMotionEstimatorBase { + impl Drop for InpainterBase { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ImageMotionEstimatorBase") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_InpainterBase_delete(self.as_raw_mut_InpainterBase()) }; } } + unsafe impl Send for InpainterBase {} + /// Constant methods for [crate::videostab::InpainterBase] pub trait InpainterBaseTraitConst { fn as_raw_InpainterBase(&self) -> *const c_void; @@ -1717,20 +1710,25 @@ pub mod videostab { } - pub struct InpainterBase { - ptr: *mut c_void, - } - - opencv_type_boxed! { InpainterBase } - - impl Drop for InpainterBase { + impl std::fmt::Debug for InpainterBase { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_InpainterBase_delete(self.as_raw_mut_InpainterBase()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("InpainterBase") + .finish() } } - unsafe impl Send for InpainterBase {} + boxed_cast_descendant! { InpainterBase, crate::videostab::ColorAverageInpainter, cv_videostab_InpainterBase_to_ColorAverageInpainter } + + boxed_cast_descendant! { InpainterBase, crate::videostab::ColorInpainter, cv_videostab_InpainterBase_to_ColorInpainter } + + boxed_cast_descendant! { InpainterBase, crate::videostab::ConsistentMosaicInpainter, cv_videostab_InpainterBase_to_ConsistentMosaicInpainter } + + boxed_cast_descendant! { InpainterBase, crate::videostab::InpaintingPipeline, cv_videostab_InpainterBase_to_InpaintingPipeline } + + boxed_cast_descendant! { InpainterBase, crate::videostab::MotionInpainter, cv_videostab_InpainterBase_to_MotionInpainter } + + boxed_cast_descendant! { InpainterBase, crate::videostab::NullInpainter, cv_videostab_InpainterBase_to_NullInpainter } impl crate::videostab::InpainterBaseTraitConst for InpainterBase { #[inline] fn as_raw_InpainterBase(&self) -> *const c_void { self.as_raw() } @@ -1742,27 +1740,30 @@ pub mod videostab { boxed_ref! { InpainterBase, crate::videostab::InpainterBaseTraitConst, as_raw_InpainterBase, crate::videostab::InpainterBaseTrait, as_raw_mut_InpainterBase } - impl InpainterBase { + pub struct InpaintingPipeline { + ptr: *mut c_void, } - boxed_cast_descendant! { InpainterBase, crate::videostab::ColorAverageInpainter, cv_videostab_InpainterBase_to_ColorAverageInpainter } - - boxed_cast_descendant! { InpainterBase, crate::videostab::ColorInpainter, cv_videostab_InpainterBase_to_ColorInpainter } - - boxed_cast_descendant! { InpainterBase, crate::videostab::ConsistentMosaicInpainter, cv_videostab_InpainterBase_to_ConsistentMosaicInpainter } - - boxed_cast_descendant! { InpainterBase, crate::videostab::InpaintingPipeline, cv_videostab_InpainterBase_to_InpaintingPipeline } + opencv_type_boxed! { InpaintingPipeline } - boxed_cast_descendant! { InpainterBase, crate::videostab::MotionInpainter, cv_videostab_InpainterBase_to_MotionInpainter } + impl Drop for InpaintingPipeline { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_videostab_InpaintingPipeline_delete(self.as_raw_mut_InpaintingPipeline()) }; + } + } - boxed_cast_descendant! { InpainterBase, crate::videostab::NullInpainter, cv_videostab_InpainterBase_to_NullInpainter } + unsafe impl Send for InpaintingPipeline {} - impl std::fmt::Debug for InpainterBase { + impl InpaintingPipeline { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("InpainterBase") - .finish() + pub fn default() -> crate::videostab::InpaintingPipeline { + let ret = unsafe { sys::cv_videostab_InpaintingPipeline_defaultNew_const() }; + let ret = unsafe { crate::videostab::InpaintingPipeline::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::videostab::InpaintingPipeline] @@ -1858,20 +1859,23 @@ pub mod videostab { } - pub struct InpaintingPipeline { - ptr: *mut c_void, + impl Default for InpaintingPipeline { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { InpaintingPipeline } - - impl Drop for InpaintingPipeline { + impl std::fmt::Debug for InpaintingPipeline { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_InpaintingPipeline_delete(self.as_raw_mut_InpaintingPipeline()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("InpaintingPipeline") + .finish() } } - unsafe impl Send for InpaintingPipeline {} + boxed_cast_base! { InpaintingPipeline, crate::videostab::InpainterBase, cv_videostab_InpaintingPipeline_to_InpainterBase } impl crate::videostab::InpainterBaseTraitConst for InpaintingPipeline { #[inline] fn as_raw_InpainterBase(&self) -> *const c_void { self.as_raw() } @@ -1893,31 +1897,34 @@ pub mod videostab { boxed_ref! { InpaintingPipeline, crate::videostab::InpaintingPipelineTraitConst, as_raw_InpaintingPipeline, crate::videostab::InpaintingPipelineTrait, as_raw_mut_InpaintingPipeline } - impl InpaintingPipeline { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_videostab_InpaintingPipeline_defaultNew_const()) } - } - + /// Describes a global 2D motion estimation method which uses keypoints detection and optical flow for + /// matching. + pub struct KeypointBasedMotionEstimator { + ptr: *mut c_void, } - boxed_cast_base! { InpaintingPipeline, crate::videostab::InpainterBase, cv_videostab_InpaintingPipeline_to_InpainterBase } + opencv_type_boxed! { KeypointBasedMotionEstimator } - impl std::fmt::Debug for InpaintingPipeline { + impl Drop for KeypointBasedMotionEstimator { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("InpaintingPipeline") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_KeypointBasedMotionEstimator_delete(self.as_raw_mut_KeypointBasedMotionEstimator()) }; } } - impl Default for InpaintingPipeline { + unsafe impl Send for KeypointBasedMotionEstimator {} + + impl KeypointBasedMotionEstimator { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new(mut estimator: core::Ptr) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_KeypointBasedMotionEstimator_KeypointBasedMotionEstimator_PtrLMotionEstimatorBaseG(estimator.as_raw_mut_PtrOfMotionEstimatorBase(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::KeypointBasedMotionEstimator::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::videostab::KeypointBasedMotionEstimator] @@ -2071,22 +2078,15 @@ pub mod videostab { } - /// Describes a global 2D motion estimation method which uses keypoints detection and optical flow for - /// matching. - pub struct KeypointBasedMotionEstimator { - ptr: *mut c_void, - } - - opencv_type_boxed! { KeypointBasedMotionEstimator } - - impl Drop for KeypointBasedMotionEstimator { + impl std::fmt::Debug for KeypointBasedMotionEstimator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_KeypointBasedMotionEstimator_delete(self.as_raw_mut_KeypointBasedMotionEstimator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("KeypointBasedMotionEstimator") + .finish() } } - unsafe impl Send for KeypointBasedMotionEstimator {} + boxed_cast_base! { KeypointBasedMotionEstimator, crate::videostab::ImageMotionEstimatorBase, cv_videostab_KeypointBasedMotionEstimator_to_ImageMotionEstimatorBase } impl crate::videostab::ImageMotionEstimatorBaseTraitConst for KeypointBasedMotionEstimator { #[inline] fn as_raw_ImageMotionEstimatorBase(&self) -> *const c_void { self.as_raw() } @@ -2108,27 +2108,32 @@ pub mod videostab { boxed_ref! { KeypointBasedMotionEstimator, crate::videostab::KeypointBasedMotionEstimatorTraitConst, as_raw_KeypointBasedMotionEstimator, crate::videostab::KeypointBasedMotionEstimatorTrait, as_raw_mut_KeypointBasedMotionEstimator } - impl KeypointBasedMotionEstimator { + pub struct KeypointBasedMotionEstimatorGpu { + ptr: *mut c_void, + } + + opencv_type_boxed! { KeypointBasedMotionEstimatorGpu } + + impl Drop for KeypointBasedMotionEstimatorGpu { #[inline] - pub fn new(mut estimator: core::Ptr) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_KeypointBasedMotionEstimator_KeypointBasedMotionEstimator_PtrLMotionEstimatorBaseG(estimator.as_raw_mut_PtrOfMotionEstimatorBase(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::KeypointBasedMotionEstimator::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_videostab_KeypointBasedMotionEstimatorGpu_delete(self.as_raw_mut_KeypointBasedMotionEstimatorGpu()) }; } - } - boxed_cast_base! { KeypointBasedMotionEstimator, crate::videostab::ImageMotionEstimatorBase, cv_videostab_KeypointBasedMotionEstimator_to_ImageMotionEstimatorBase } + unsafe impl Send for KeypointBasedMotionEstimatorGpu {} - impl std::fmt::Debug for KeypointBasedMotionEstimator { + impl KeypointBasedMotionEstimatorGpu { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("KeypointBasedMotionEstimator") - .finish() + pub fn new(mut estimator: core::Ptr) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_KeypointBasedMotionEstimatorGpu_KeypointBasedMotionEstimatorGpu_PtrLMotionEstimatorBaseG(estimator.as_raw_mut_PtrOfMotionEstimatorBase(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::KeypointBasedMotionEstimatorGpu::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::videostab::KeypointBasedMotionEstimatorGpu] @@ -2230,20 +2235,15 @@ pub mod videostab { } - pub struct KeypointBasedMotionEstimatorGpu { - ptr: *mut c_void, - } - - opencv_type_boxed! { KeypointBasedMotionEstimatorGpu } - - impl Drop for KeypointBasedMotionEstimatorGpu { + impl std::fmt::Debug for KeypointBasedMotionEstimatorGpu { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_KeypointBasedMotionEstimatorGpu_delete(self.as_raw_mut_KeypointBasedMotionEstimatorGpu()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("KeypointBasedMotionEstimatorGpu") + .finish() } } - unsafe impl Send for KeypointBasedMotionEstimatorGpu {} + boxed_cast_base! { KeypointBasedMotionEstimatorGpu, crate::videostab::ImageMotionEstimatorBase, cv_videostab_KeypointBasedMotionEstimatorGpu_to_ImageMotionEstimatorBase } impl crate::videostab::ImageMotionEstimatorBaseTraitConst for KeypointBasedMotionEstimatorGpu { #[inline] fn as_raw_ImageMotionEstimatorBase(&self) -> *const c_void { self.as_raw() } @@ -2265,27 +2265,30 @@ pub mod videostab { boxed_ref! { KeypointBasedMotionEstimatorGpu, crate::videostab::KeypointBasedMotionEstimatorGpuTraitConst, as_raw_KeypointBasedMotionEstimatorGpu, crate::videostab::KeypointBasedMotionEstimatorGpuTrait, as_raw_mut_KeypointBasedMotionEstimatorGpu } - impl KeypointBasedMotionEstimatorGpu { + pub struct LogToStdout { + ptr: *mut c_void, + } + + opencv_type_boxed! { LogToStdout } + + impl Drop for LogToStdout { #[inline] - pub fn new(mut estimator: core::Ptr) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_KeypointBasedMotionEstimatorGpu_KeypointBasedMotionEstimatorGpu_PtrLMotionEstimatorBaseG(estimator.as_raw_mut_PtrOfMotionEstimatorBase(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::KeypointBasedMotionEstimatorGpu::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_videostab_LogToStdout_delete(self.as_raw_mut_LogToStdout()) }; } - } - boxed_cast_base! { KeypointBasedMotionEstimatorGpu, crate::videostab::ImageMotionEstimatorBase, cv_videostab_KeypointBasedMotionEstimatorGpu_to_ImageMotionEstimatorBase } + unsafe impl Send for LogToStdout {} - impl std::fmt::Debug for KeypointBasedMotionEstimatorGpu { + impl LogToStdout { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("KeypointBasedMotionEstimatorGpu") - .finish() + pub fn default() -> crate::videostab::LogToStdout { + let ret = unsafe { sys::cv_videostab_LogToStdout_defaultNew_const() }; + let ret = unsafe { crate::videostab::LogToStdout::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::videostab::LogToStdout] @@ -2310,20 +2313,23 @@ pub mod videostab { } - pub struct LogToStdout { - ptr: *mut c_void, + impl Default for LogToStdout { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { LogToStdout } - - impl Drop for LogToStdout { + impl std::fmt::Debug for LogToStdout { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_LogToStdout_delete(self.as_raw_mut_LogToStdout()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LogToStdout") + .finish() } } - unsafe impl Send for LogToStdout {} + boxed_cast_base! { LogToStdout, crate::videostab::ILog, cv_videostab_LogToStdout_to_ILog } impl crate::videostab::ILogTraitConst for LogToStdout { #[inline] fn as_raw_ILog(&self) -> *const c_void { self.as_raw() } @@ -2345,31 +2351,47 @@ pub mod videostab { boxed_ref! { LogToStdout, crate::videostab::LogToStdoutTraitConst, as_raw_LogToStdout, crate::videostab::LogToStdoutTrait, as_raw_mut_LogToStdout } - impl LogToStdout { - /// Creates a default instance of the class by calling the default constructor + pub struct LpMotionStabilizer { + ptr: *mut c_void, + } + + opencv_type_boxed! { LpMotionStabilizer } + + impl Drop for LpMotionStabilizer { #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_videostab_LogToStdout_defaultNew_const()) } + fn drop(&mut self) { + unsafe { sys::cv_videostab_LpMotionStabilizer_delete(self.as_raw_mut_LpMotionStabilizer()) }; } - } - boxed_cast_base! { LogToStdout, crate::videostab::ILog, cv_videostab_LogToStdout_to_ILog } + unsafe impl Send for LpMotionStabilizer {} - impl std::fmt::Debug for LogToStdout { + impl LpMotionStabilizer { + /// ## C++ default parameters + /// * model: MM_SIMILARITY #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LogToStdout") - .finish() + pub fn new(model: crate::videostab::MotionModel) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_LpMotionStabilizer_LpMotionStabilizer_MotionModel(model, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::LpMotionStabilizer::opencv_from_extern(ret) }; + Ok(ret) } - } - impl Default for LogToStdout { + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * model: MM_SIMILARITY #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_LpMotionStabilizer_LpMotionStabilizer(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::LpMotionStabilizer::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::videostab::LpMotionStabilizer] @@ -2519,20 +2541,15 @@ pub mod videostab { } - pub struct LpMotionStabilizer { - ptr: *mut c_void, - } - - opencv_type_boxed! { LpMotionStabilizer } - - impl Drop for LpMotionStabilizer { + impl std::fmt::Debug for LpMotionStabilizer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_LpMotionStabilizer_delete(self.as_raw_mut_LpMotionStabilizer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LpMotionStabilizer") + .finish() } } - unsafe impl Send for LpMotionStabilizer {} + boxed_cast_base! { LpMotionStabilizer, crate::videostab::IMotionStabilizer, cv_videostab_LpMotionStabilizer_to_IMotionStabilizer } impl crate::videostab::IMotionStabilizerTraitConst for LpMotionStabilizer { #[inline] fn as_raw_IMotionStabilizer(&self) -> *const c_void { self.as_raw() } @@ -2554,44 +2571,34 @@ pub mod videostab { boxed_ref! { LpMotionStabilizer, crate::videostab::LpMotionStabilizerTraitConst, as_raw_LpMotionStabilizer, crate::videostab::LpMotionStabilizerTrait, as_raw_mut_LpMotionStabilizer } - impl LpMotionStabilizer { - /// ## C++ default parameters - /// * model: MM_SIMILARITY + pub struct MaskFrameSource { + ptr: *mut c_void, + } + + opencv_type_boxed! { MaskFrameSource } + + impl Drop for MaskFrameSource { #[inline] - pub fn new(model: crate::videostab::MotionModel) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_LpMotionStabilizer_LpMotionStabilizer_MotionModel(model, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::LpMotionStabilizer::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_videostab_MaskFrameSource_delete(self.as_raw_mut_MaskFrameSource()) }; } + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * model: MM_SIMILARITY + unsafe impl Send for MaskFrameSource {} + + impl MaskFrameSource { #[inline] - pub fn new_def() -> Result { + pub fn from_base(source: &core::Ptr) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_LpMotionStabilizer_LpMotionStabilizer(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_videostab_MaskFrameSource_MaskFrameSource_const_PtrLIFrameSourceGR(source.as_raw_PtrOfIFrameSource(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::LpMotionStabilizer::opencv_from_extern(ret) }; + let ret = unsafe { crate::videostab::MaskFrameSource::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { LpMotionStabilizer, crate::videostab::IMotionStabilizer, cv_videostab_LpMotionStabilizer_to_IMotionStabilizer } - - impl std::fmt::Debug for LpMotionStabilizer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LpMotionStabilizer") - .finish() - } - } - /// Constant methods for [crate::videostab::MaskFrameSource] pub trait MaskFrameSourceTraitConst: crate::videostab::IFrameSourceTraitConst { fn as_raw_MaskFrameSource(&self) -> *const c_void; @@ -2623,20 +2630,15 @@ pub mod videostab { } - pub struct MaskFrameSource { - ptr: *mut c_void, - } - - opencv_type_boxed! { MaskFrameSource } - - impl Drop for MaskFrameSource { + impl std::fmt::Debug for MaskFrameSource { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_MaskFrameSource_delete(self.as_raw_mut_MaskFrameSource()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MaskFrameSource") + .finish() } } - unsafe impl Send for MaskFrameSource {} + boxed_cast_base! { MaskFrameSource, crate::videostab::IFrameSource, cv_videostab_MaskFrameSource_to_IFrameSource } impl crate::videostab::IFrameSourceTraitConst for MaskFrameSource { #[inline] fn as_raw_IFrameSource(&self) -> *const c_void { self.as_raw() } @@ -2658,27 +2660,30 @@ pub mod videostab { boxed_ref! { MaskFrameSource, crate::videostab::MaskFrameSourceTraitConst, as_raw_MaskFrameSource, crate::videostab::MaskFrameSourceTrait, as_raw_mut_MaskFrameSource } - impl MaskFrameSource { + pub struct MoreAccurateMotionWobbleSuppressor { + ptr: *mut c_void, + } + + opencv_type_boxed! { MoreAccurateMotionWobbleSuppressor } + + impl Drop for MoreAccurateMotionWobbleSuppressor { #[inline] - pub fn from_base(source: &core::Ptr) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_MaskFrameSource_MaskFrameSource_const_PtrLIFrameSourceGR(source.as_raw_PtrOfIFrameSource(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::MaskFrameSource::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_videostab_MoreAccurateMotionWobbleSuppressor_delete(self.as_raw_mut_MoreAccurateMotionWobbleSuppressor()) }; } - } - boxed_cast_base! { MaskFrameSource, crate::videostab::IFrameSource, cv_videostab_MaskFrameSource_to_IFrameSource } + unsafe impl Send for MoreAccurateMotionWobbleSuppressor {} - impl std::fmt::Debug for MaskFrameSource { + impl MoreAccurateMotionWobbleSuppressor { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MaskFrameSource") - .finish() + pub fn default() -> crate::videostab::MoreAccurateMotionWobbleSuppressor { + let ret = unsafe { sys::cv_videostab_MoreAccurateMotionWobbleSuppressor_defaultNew_const() }; + let ret = unsafe { crate::videostab::MoreAccurateMotionWobbleSuppressor::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::videostab::MoreAccurateMotionWobbleSuppressor] @@ -2702,20 +2707,25 @@ pub mod videostab { } - pub struct MoreAccurateMotionWobbleSuppressor { - ptr: *mut c_void, + impl Default for MoreAccurateMotionWobbleSuppressor { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { MoreAccurateMotionWobbleSuppressor } - - impl Drop for MoreAccurateMotionWobbleSuppressor { + impl std::fmt::Debug for MoreAccurateMotionWobbleSuppressor { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_MoreAccurateMotionWobbleSuppressor_delete(self.as_raw_mut_MoreAccurateMotionWobbleSuppressor()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MoreAccurateMotionWobbleSuppressor") + .finish() } } - unsafe impl Send for MoreAccurateMotionWobbleSuppressor {} + boxed_cast_base! { MoreAccurateMotionWobbleSuppressor, crate::videostab::MoreAccurateMotionWobbleSuppressorBase, cv_videostab_MoreAccurateMotionWobbleSuppressor_to_MoreAccurateMotionWobbleSuppressorBase } + + boxed_cast_base! { MoreAccurateMotionWobbleSuppressor, crate::videostab::WobbleSuppressorBase, cv_videostab_MoreAccurateMotionWobbleSuppressor_to_WobbleSuppressorBase } impl crate::videostab::MoreAccurateMotionWobbleSuppressorBaseTraitConst for MoreAccurateMotionWobbleSuppressor { #[inline] fn as_raw_MoreAccurateMotionWobbleSuppressorBase(&self) -> *const c_void { self.as_raw() } @@ -2747,34 +2757,20 @@ pub mod videostab { boxed_ref! { MoreAccurateMotionWobbleSuppressor, crate::videostab::MoreAccurateMotionWobbleSuppressorTraitConst, as_raw_MoreAccurateMotionWobbleSuppressor, crate::videostab::MoreAccurateMotionWobbleSuppressorTrait, as_raw_mut_MoreAccurateMotionWobbleSuppressor } - impl MoreAccurateMotionWobbleSuppressor { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_videostab_MoreAccurateMotionWobbleSuppressor_defaultNew_const()) } - } - + pub struct MoreAccurateMotionWobbleSuppressorBase { + ptr: *mut c_void, } - boxed_cast_base! { MoreAccurateMotionWobbleSuppressor, crate::videostab::MoreAccurateMotionWobbleSuppressorBase, cv_videostab_MoreAccurateMotionWobbleSuppressor_to_MoreAccurateMotionWobbleSuppressorBase } - - boxed_cast_base! { MoreAccurateMotionWobbleSuppressor, crate::videostab::WobbleSuppressorBase, cv_videostab_MoreAccurateMotionWobbleSuppressor_to_WobbleSuppressorBase } + opencv_type_boxed! { MoreAccurateMotionWobbleSuppressorBase } - impl std::fmt::Debug for MoreAccurateMotionWobbleSuppressor { + impl Drop for MoreAccurateMotionWobbleSuppressorBase { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MoreAccurateMotionWobbleSuppressor") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_MoreAccurateMotionWobbleSuppressorBase_delete(self.as_raw_mut_MoreAccurateMotionWobbleSuppressorBase()) }; } } - impl Default for MoreAccurateMotionWobbleSuppressor { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } + unsafe impl Send for MoreAccurateMotionWobbleSuppressorBase {} /// Constant methods for [crate::videostab::MoreAccurateMotionWobbleSuppressorBase] pub trait MoreAccurateMotionWobbleSuppressorBaseTraitConst: crate::videostab::WobbleSuppressorBaseTraitConst { @@ -2806,20 +2802,19 @@ pub mod videostab { } - pub struct MoreAccurateMotionWobbleSuppressorBase { - ptr: *mut c_void, - } - - opencv_type_boxed! { MoreAccurateMotionWobbleSuppressorBase } - - impl Drop for MoreAccurateMotionWobbleSuppressorBase { + impl std::fmt::Debug for MoreAccurateMotionWobbleSuppressorBase { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_MoreAccurateMotionWobbleSuppressorBase_delete(self.as_raw_mut_MoreAccurateMotionWobbleSuppressorBase()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MoreAccurateMotionWobbleSuppressorBase") + .finish() } } - unsafe impl Send for MoreAccurateMotionWobbleSuppressorBase {} + boxed_cast_base! { MoreAccurateMotionWobbleSuppressorBase, crate::videostab::WobbleSuppressorBase, cv_videostab_MoreAccurateMotionWobbleSuppressorBase_to_WobbleSuppressorBase } + + boxed_cast_descendant! { MoreAccurateMotionWobbleSuppressorBase, crate::videostab::MoreAccurateMotionWobbleSuppressor, cv_videostab_MoreAccurateMotionWobbleSuppressorBase_to_MoreAccurateMotionWobbleSuppressor } + + boxed_cast_descendant! { MoreAccurateMotionWobbleSuppressorBase, crate::videostab::MoreAccurateMotionWobbleSuppressorGpu, cv_videostab_MoreAccurateMotionWobbleSuppressorBase_to_MoreAccurateMotionWobbleSuppressorGpu } impl crate::videostab::WobbleSuppressorBaseTraitConst for MoreAccurateMotionWobbleSuppressorBase { #[inline] fn as_raw_WobbleSuppressorBase(&self) -> *const c_void { self.as_raw() } @@ -2841,21 +2836,30 @@ pub mod videostab { boxed_ref! { MoreAccurateMotionWobbleSuppressorBase, crate::videostab::MoreAccurateMotionWobbleSuppressorBaseTraitConst, as_raw_MoreAccurateMotionWobbleSuppressorBase, crate::videostab::MoreAccurateMotionWobbleSuppressorBaseTrait, as_raw_mut_MoreAccurateMotionWobbleSuppressorBase } - impl MoreAccurateMotionWobbleSuppressorBase { + pub struct MoreAccurateMotionWobbleSuppressorGpu { + ptr: *mut c_void, } - boxed_cast_descendant! { MoreAccurateMotionWobbleSuppressorBase, crate::videostab::MoreAccurateMotionWobbleSuppressor, cv_videostab_MoreAccurateMotionWobbleSuppressorBase_to_MoreAccurateMotionWobbleSuppressor } + opencv_type_boxed! { MoreAccurateMotionWobbleSuppressorGpu } - boxed_cast_descendant! { MoreAccurateMotionWobbleSuppressorBase, crate::videostab::MoreAccurateMotionWobbleSuppressorGpu, cv_videostab_MoreAccurateMotionWobbleSuppressorBase_to_MoreAccurateMotionWobbleSuppressorGpu } + impl Drop for MoreAccurateMotionWobbleSuppressorGpu { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_videostab_MoreAccurateMotionWobbleSuppressorGpu_delete(self.as_raw_mut_MoreAccurateMotionWobbleSuppressorGpu()) }; + } + } - boxed_cast_base! { MoreAccurateMotionWobbleSuppressorBase, crate::videostab::WobbleSuppressorBase, cv_videostab_MoreAccurateMotionWobbleSuppressorBase_to_WobbleSuppressorBase } + unsafe impl Send for MoreAccurateMotionWobbleSuppressorGpu {} - impl std::fmt::Debug for MoreAccurateMotionWobbleSuppressorBase { + impl MoreAccurateMotionWobbleSuppressorGpu { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MoreAccurateMotionWobbleSuppressorBase") - .finish() + pub fn default() -> crate::videostab::MoreAccurateMotionWobbleSuppressorGpu { + let ret = unsafe { sys::cv_videostab_MoreAccurateMotionWobbleSuppressorGpu_defaultNew_const() }; + let ret = unsafe { crate::videostab::MoreAccurateMotionWobbleSuppressorGpu::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::videostab::MoreAccurateMotionWobbleSuppressorGpu] @@ -2888,20 +2892,25 @@ pub mod videostab { } - pub struct MoreAccurateMotionWobbleSuppressorGpu { - ptr: *mut c_void, + impl Default for MoreAccurateMotionWobbleSuppressorGpu { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { MoreAccurateMotionWobbleSuppressorGpu } - - impl Drop for MoreAccurateMotionWobbleSuppressorGpu { + impl std::fmt::Debug for MoreAccurateMotionWobbleSuppressorGpu { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_MoreAccurateMotionWobbleSuppressorGpu_delete(self.as_raw_mut_MoreAccurateMotionWobbleSuppressorGpu()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MoreAccurateMotionWobbleSuppressorGpu") + .finish() } } - unsafe impl Send for MoreAccurateMotionWobbleSuppressorGpu {} + boxed_cast_base! { MoreAccurateMotionWobbleSuppressorGpu, crate::videostab::MoreAccurateMotionWobbleSuppressorBase, cv_videostab_MoreAccurateMotionWobbleSuppressorGpu_to_MoreAccurateMotionWobbleSuppressorBase } + + boxed_cast_base! { MoreAccurateMotionWobbleSuppressorGpu, crate::videostab::WobbleSuppressorBase, cv_videostab_MoreAccurateMotionWobbleSuppressorGpu_to_WobbleSuppressorBase } impl crate::videostab::MoreAccurateMotionWobbleSuppressorBaseTraitConst for MoreAccurateMotionWobbleSuppressorGpu { #[inline] fn as_raw_MoreAccurateMotionWobbleSuppressorBase(&self) -> *const c_void { self.as_raw() } @@ -2933,34 +2942,21 @@ pub mod videostab { boxed_ref! { MoreAccurateMotionWobbleSuppressorGpu, crate::videostab::MoreAccurateMotionWobbleSuppressorGpuTraitConst, as_raw_MoreAccurateMotionWobbleSuppressorGpu, crate::videostab::MoreAccurateMotionWobbleSuppressorGpuTrait, as_raw_mut_MoreAccurateMotionWobbleSuppressorGpu } - impl MoreAccurateMotionWobbleSuppressorGpu { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_videostab_MoreAccurateMotionWobbleSuppressorGpu_defaultNew_const()) } - } - + /// Base class for all global motion estimation methods. + pub struct MotionEstimatorBase { + ptr: *mut c_void, } - boxed_cast_base! { MoreAccurateMotionWobbleSuppressorGpu, crate::videostab::MoreAccurateMotionWobbleSuppressorBase, cv_videostab_MoreAccurateMotionWobbleSuppressorGpu_to_MoreAccurateMotionWobbleSuppressorBase } - - boxed_cast_base! { MoreAccurateMotionWobbleSuppressorGpu, crate::videostab::WobbleSuppressorBase, cv_videostab_MoreAccurateMotionWobbleSuppressorGpu_to_WobbleSuppressorBase } + opencv_type_boxed! { MotionEstimatorBase } - impl std::fmt::Debug for MoreAccurateMotionWobbleSuppressorGpu { + impl Drop for MotionEstimatorBase { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MoreAccurateMotionWobbleSuppressorGpu") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_MotionEstimatorBase_delete(self.as_raw_mut_MotionEstimatorBase()) }; } } - impl Default for MoreAccurateMotionWobbleSuppressorGpu { - #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() - } - } + unsafe impl Send for MotionEstimatorBase {} /// Constant methods for [crate::videostab::MotionEstimatorBase] pub trait MotionEstimatorBaseTraitConst { @@ -3045,21 +3041,17 @@ pub mod videostab { } - /// Base class for all global motion estimation methods. - pub struct MotionEstimatorBase { - ptr: *mut c_void, - } - - opencv_type_boxed! { MotionEstimatorBase } - - impl Drop for MotionEstimatorBase { + impl std::fmt::Debug for MotionEstimatorBase { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_MotionEstimatorBase_delete(self.as_raw_mut_MotionEstimatorBase()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MotionEstimatorBase") + .finish() } } - unsafe impl Send for MotionEstimatorBase {} + boxed_cast_descendant! { MotionEstimatorBase, crate::videostab::MotionEstimatorL1, cv_videostab_MotionEstimatorBase_to_MotionEstimatorL1 } + + boxed_cast_descendant! { MotionEstimatorBase, crate::videostab::MotionEstimatorRansacL2, cv_videostab_MotionEstimatorBase_to_MotionEstimatorRansacL2 } impl crate::videostab::MotionEstimatorBaseTraitConst for MotionEstimatorBase { #[inline] fn as_raw_MotionEstimatorBase(&self) -> *const c_void { self.as_raw() } @@ -3071,19 +3063,51 @@ pub mod videostab { boxed_ref! { MotionEstimatorBase, crate::videostab::MotionEstimatorBaseTraitConst, as_raw_MotionEstimatorBase, crate::videostab::MotionEstimatorBaseTrait, as_raw_mut_MotionEstimatorBase } - impl MotionEstimatorBase { + /// Describes a global 2D motion estimation method which minimizes L1 error. + /// + /// + /// Note: To be able to use this method you must build OpenCV with CLP library support. : + pub struct MotionEstimatorL1 { + ptr: *mut c_void, } - boxed_cast_descendant! { MotionEstimatorBase, crate::videostab::MotionEstimatorL1, cv_videostab_MotionEstimatorBase_to_MotionEstimatorL1 } + opencv_type_boxed! { MotionEstimatorL1 } - boxed_cast_descendant! { MotionEstimatorBase, crate::videostab::MotionEstimatorRansacL2, cv_videostab_MotionEstimatorBase_to_MotionEstimatorRansacL2 } + impl Drop for MotionEstimatorL1 { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_videostab_MotionEstimatorL1_delete(self.as_raw_mut_MotionEstimatorL1()) }; + } + } - impl std::fmt::Debug for MotionEstimatorBase { + unsafe impl Send for MotionEstimatorL1 {} + + impl MotionEstimatorL1 { + /// ## C++ default parameters + /// * model: MM_AFFINE #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MotionEstimatorBase") - .finish() + pub fn new(model: crate::videostab::MotionModel) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_MotionEstimatorL1_MotionEstimatorL1_MotionModel(model, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::MotionEstimatorL1::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * model: MM_AFFINE + #[inline] + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_MotionEstimatorL1_MotionEstimatorL1(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::MotionEstimatorL1::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::videostab::MotionEstimatorL1] @@ -3127,24 +3151,15 @@ pub mod videostab { } - /// Describes a global 2D motion estimation method which minimizes L1 error. - /// - /// - /// Note: To be able to use this method you must build OpenCV with CLP library support. : - pub struct MotionEstimatorL1 { - ptr: *mut c_void, - } - - opencv_type_boxed! { MotionEstimatorL1 } - - impl Drop for MotionEstimatorL1 { + impl std::fmt::Debug for MotionEstimatorL1 { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_MotionEstimatorL1_delete(self.as_raw_mut_MotionEstimatorL1()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MotionEstimatorL1") + .finish() } } - unsafe impl Send for MotionEstimatorL1 {} + boxed_cast_base! { MotionEstimatorL1, crate::videostab::MotionEstimatorBase, cv_videostab_MotionEstimatorL1_to_MotionEstimatorBase } impl crate::videostab::MotionEstimatorBaseTraitConst for MotionEstimatorL1 { #[inline] fn as_raw_MotionEstimatorBase(&self) -> *const c_void { self.as_raw() } @@ -3166,16 +3181,32 @@ pub mod videostab { boxed_ref! { MotionEstimatorL1, crate::videostab::MotionEstimatorL1TraitConst, as_raw_MotionEstimatorL1, crate::videostab::MotionEstimatorL1Trait, as_raw_mut_MotionEstimatorL1 } - impl MotionEstimatorL1 { + /// Describes a robust RANSAC-based global 2D motion estimation method which minimizes L2 error. + pub struct MotionEstimatorRansacL2 { + ptr: *mut c_void, + } + + opencv_type_boxed! { MotionEstimatorRansacL2 } + + impl Drop for MotionEstimatorRansacL2 { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_videostab_MotionEstimatorRansacL2_delete(self.as_raw_mut_MotionEstimatorRansacL2()) }; + } + } + + unsafe impl Send for MotionEstimatorRansacL2 {} + + impl MotionEstimatorRansacL2 { /// ## C++ default parameters /// * model: MM_AFFINE #[inline] - pub fn new(model: crate::videostab::MotionModel) -> Result { + pub fn new(model: crate::videostab::MotionModel) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_MotionEstimatorL1_MotionEstimatorL1_MotionModel(model, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_videostab_MotionEstimatorRansacL2_MotionEstimatorRansacL2_MotionModel(model, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::MotionEstimatorL1::opencv_from_extern(ret) }; + let ret = unsafe { crate::videostab::MotionEstimatorRansacL2::opencv_from_extern(ret) }; Ok(ret) } @@ -3183,27 +3214,17 @@ pub mod videostab { /// This alternative version of [new] function uses the following default values for its arguments: /// * model: MM_AFFINE #[inline] - pub fn new_def() -> Result { + pub fn new_def() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_MotionEstimatorL1_MotionEstimatorL1(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_videostab_MotionEstimatorRansacL2_MotionEstimatorRansacL2(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::MotionEstimatorL1::opencv_from_extern(ret) }; + let ret = unsafe { crate::videostab::MotionEstimatorRansacL2::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { MotionEstimatorL1, crate::videostab::MotionEstimatorBase, cv_videostab_MotionEstimatorL1_to_MotionEstimatorBase } - - impl std::fmt::Debug for MotionEstimatorL1 { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MotionEstimatorL1") - .finish() - } - } - /// Constant methods for [crate::videostab::MotionEstimatorRansacL2] pub trait MotionEstimatorRansacL2TraitConst: crate::videostab::MotionEstimatorBaseTraitConst { fn as_raw_MotionEstimatorRansacL2(&self) -> *const c_void; @@ -3282,21 +3303,15 @@ pub mod videostab { } - /// Describes a robust RANSAC-based global 2D motion estimation method which minimizes L2 error. - pub struct MotionEstimatorRansacL2 { - ptr: *mut c_void, - } - - opencv_type_boxed! { MotionEstimatorRansacL2 } - - impl Drop for MotionEstimatorRansacL2 { + impl std::fmt::Debug for MotionEstimatorRansacL2 { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_MotionEstimatorRansacL2_delete(self.as_raw_mut_MotionEstimatorRansacL2()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MotionEstimatorRansacL2") + .finish() } } - unsafe impl Send for MotionEstimatorRansacL2 {} + boxed_cast_base! { MotionEstimatorRansacL2, crate::videostab::MotionEstimatorBase, cv_videostab_MotionEstimatorRansacL2_to_MotionEstimatorBase } impl crate::videostab::MotionEstimatorBaseTraitConst for MotionEstimatorRansacL2 { #[inline] fn as_raw_MotionEstimatorBase(&self) -> *const c_void { self.as_raw() } @@ -3318,44 +3333,21 @@ pub mod videostab { boxed_ref! { MotionEstimatorRansacL2, crate::videostab::MotionEstimatorRansacL2TraitConst, as_raw_MotionEstimatorRansacL2, crate::videostab::MotionEstimatorRansacL2Trait, as_raw_mut_MotionEstimatorRansacL2 } - impl MotionEstimatorRansacL2 { - /// ## C++ default parameters - /// * model: MM_AFFINE - #[inline] - pub fn new(model: crate::videostab::MotionModel) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_MotionEstimatorRansacL2_MotionEstimatorRansacL2_MotionModel(model, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::MotionEstimatorRansacL2::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * model: MM_AFFINE - #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_MotionEstimatorRansacL2_MotionEstimatorRansacL2(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::MotionEstimatorRansacL2::opencv_from_extern(ret) }; - Ok(ret) - } - + pub struct MotionFilterBase { + ptr: *mut c_void, } - boxed_cast_base! { MotionEstimatorRansacL2, crate::videostab::MotionEstimatorBase, cv_videostab_MotionEstimatorRansacL2_to_MotionEstimatorBase } + opencv_type_boxed! { MotionFilterBase } - impl std::fmt::Debug for MotionEstimatorRansacL2 { + impl Drop for MotionFilterBase { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MotionEstimatorRansacL2") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_MotionFilterBase_delete(self.as_raw_mut_MotionFilterBase()) }; } } + unsafe impl Send for MotionFilterBase {} + /// Constant methods for [crate::videostab::MotionFilterBase] pub trait MotionFilterBaseTraitConst: crate::videostab::IMotionStabilizerTraitConst { fn as_raw_MotionFilterBase(&self) -> *const c_void; @@ -3387,20 +3379,17 @@ pub mod videostab { } - pub struct MotionFilterBase { - ptr: *mut c_void, - } - - opencv_type_boxed! { MotionFilterBase } - - impl Drop for MotionFilterBase { + impl std::fmt::Debug for MotionFilterBase { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_MotionFilterBase_delete(self.as_raw_mut_MotionFilterBase()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MotionFilterBase") + .finish() } } - unsafe impl Send for MotionFilterBase {} + boxed_cast_base! { MotionFilterBase, crate::videostab::IMotionStabilizer, cv_videostab_MotionFilterBase_to_IMotionStabilizer } + + boxed_cast_descendant! { MotionFilterBase, crate::videostab::GaussianMotionFilter, cv_videostab_MotionFilterBase_to_GaussianMotionFilter } impl crate::videostab::IMotionStabilizerTraitConst for MotionFilterBase { #[inline] fn as_raw_IMotionStabilizer(&self) -> *const c_void { self.as_raw() } @@ -3422,19 +3411,32 @@ pub mod videostab { boxed_ref! { MotionFilterBase, crate::videostab::MotionFilterBaseTraitConst, as_raw_MotionFilterBase, crate::videostab::MotionFilterBaseTrait, as_raw_mut_MotionFilterBase } - impl MotionFilterBase { + pub struct MotionInpainter { + ptr: *mut c_void, } - boxed_cast_descendant! { MotionFilterBase, crate::videostab::GaussianMotionFilter, cv_videostab_MotionFilterBase_to_GaussianMotionFilter } + opencv_type_boxed! { MotionInpainter } - boxed_cast_base! { MotionFilterBase, crate::videostab::IMotionStabilizer, cv_videostab_MotionFilterBase_to_IMotionStabilizer } + impl Drop for MotionInpainter { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_videostab_MotionInpainter_delete(self.as_raw_mut_MotionInpainter()) }; + } + } - impl std::fmt::Debug for MotionFilterBase { + unsafe impl Send for MotionInpainter {} + + impl MotionInpainter { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MotionFilterBase") - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_MotionInpainter_MotionInpainter(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::MotionInpainter::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::videostab::MotionInpainter] @@ -3531,20 +3533,15 @@ pub mod videostab { } - pub struct MotionInpainter { - ptr: *mut c_void, - } - - opencv_type_boxed! { MotionInpainter } - - impl Drop for MotionInpainter { + impl std::fmt::Debug for MotionInpainter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_MotionInpainter_delete(self.as_raw_mut_MotionInpainter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MotionInpainter") + .finish() } } - unsafe impl Send for MotionInpainter {} + boxed_cast_base! { MotionInpainter, crate::videostab::InpainterBase, cv_videostab_MotionInpainter_to_InpainterBase } impl crate::videostab::InpainterBaseTraitConst for MotionInpainter { #[inline] fn as_raw_InpainterBase(&self) -> *const c_void { self.as_raw() } @@ -3566,27 +3563,30 @@ pub mod videostab { boxed_ref! { MotionInpainter, crate::videostab::MotionInpainterTraitConst, as_raw_MotionInpainter, crate::videostab::MotionInpainterTrait, as_raw_mut_MotionInpainter } - impl MotionInpainter { + pub struct MotionStabilizationPipeline { + ptr: *mut c_void, + } + + opencv_type_boxed! { MotionStabilizationPipeline } + + impl Drop for MotionStabilizationPipeline { #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_MotionInpainter_MotionInpainter(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::MotionInpainter::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_videostab_MotionStabilizationPipeline_delete(self.as_raw_mut_MotionStabilizationPipeline()) }; } - } - boxed_cast_base! { MotionInpainter, crate::videostab::InpainterBase, cv_videostab_MotionInpainter_to_InpainterBase } + unsafe impl Send for MotionStabilizationPipeline {} - impl std::fmt::Debug for MotionInpainter { + impl MotionStabilizationPipeline { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MotionInpainter") - .finish() + pub fn default() -> crate::videostab::MotionStabilizationPipeline { + let ret = unsafe { sys::cv_videostab_MotionStabilizationPipeline_defaultNew_const() }; + let ret = unsafe { crate::videostab::MotionStabilizationPipeline::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::videostab::MotionStabilizationPipeline] @@ -3628,20 +3628,23 @@ pub mod videostab { } - pub struct MotionStabilizationPipeline { - ptr: *mut c_void, + impl Default for MotionStabilizationPipeline { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { MotionStabilizationPipeline } - - impl Drop for MotionStabilizationPipeline { + impl std::fmt::Debug for MotionStabilizationPipeline { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_MotionStabilizationPipeline_delete(self.as_raw_mut_MotionStabilizationPipeline()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MotionStabilizationPipeline") + .finish() } } - unsafe impl Send for MotionStabilizationPipeline {} + boxed_cast_base! { MotionStabilizationPipeline, crate::videostab::IMotionStabilizer, cv_videostab_MotionStabilizationPipeline_to_IMotionStabilizer } impl crate::videostab::IMotionStabilizerTraitConst for MotionStabilizationPipeline { #[inline] fn as_raw_IMotionStabilizer(&self) -> *const c_void { self.as_raw() } @@ -3663,31 +3666,30 @@ pub mod videostab { boxed_ref! { MotionStabilizationPipeline, crate::videostab::MotionStabilizationPipelineTraitConst, as_raw_MotionStabilizationPipeline, crate::videostab::MotionStabilizationPipelineTrait, as_raw_mut_MotionStabilizationPipeline } - impl MotionStabilizationPipeline { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_videostab_MotionStabilizationPipeline_defaultNew_const()) } - } - + pub struct NullDeblurer { + ptr: *mut c_void, } - boxed_cast_base! { MotionStabilizationPipeline, crate::videostab::IMotionStabilizer, cv_videostab_MotionStabilizationPipeline_to_IMotionStabilizer } + opencv_type_boxed! { NullDeblurer } - impl std::fmt::Debug for MotionStabilizationPipeline { + impl Drop for NullDeblurer { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MotionStabilizationPipeline") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_NullDeblurer_delete(self.as_raw_mut_NullDeblurer()) }; } } - impl Default for MotionStabilizationPipeline { + unsafe impl Send for NullDeblurer {} + + impl NullDeblurer { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::videostab::NullDeblurer { + let ret = unsafe { sys::cv_videostab_NullDeblurer_defaultNew_const() }; + let ret = unsafe { crate::videostab::NullDeblurer::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::videostab::NullDeblurer] @@ -3711,20 +3713,23 @@ pub mod videostab { } - pub struct NullDeblurer { - ptr: *mut c_void, + impl Default for NullDeblurer { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { NullDeblurer } - - impl Drop for NullDeblurer { + impl std::fmt::Debug for NullDeblurer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_NullDeblurer_delete(self.as_raw_mut_NullDeblurer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("NullDeblurer") + .finish() } } - unsafe impl Send for NullDeblurer {} + boxed_cast_base! { NullDeblurer, crate::videostab::DeblurerBase, cv_videostab_NullDeblurer_to_DeblurerBase } impl crate::videostab::DeblurerBaseTraitConst for NullDeblurer { #[inline] fn as_raw_DeblurerBase(&self) -> *const c_void { self.as_raw() } @@ -3746,31 +3751,30 @@ pub mod videostab { boxed_ref! { NullDeblurer, crate::videostab::NullDeblurerTraitConst, as_raw_NullDeblurer, crate::videostab::NullDeblurerTrait, as_raw_mut_NullDeblurer } - impl NullDeblurer { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_videostab_NullDeblurer_defaultNew_const()) } - } - + pub struct NullFrameSource { + ptr: *mut c_void, } - boxed_cast_base! { NullDeblurer, crate::videostab::DeblurerBase, cv_videostab_NullDeblurer_to_DeblurerBase } + opencv_type_boxed! { NullFrameSource } - impl std::fmt::Debug for NullDeblurer { + impl Drop for NullFrameSource { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("NullDeblurer") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_NullFrameSource_delete(self.as_raw_mut_NullFrameSource()) }; } } - impl Default for NullDeblurer { + unsafe impl Send for NullFrameSource {} + + impl NullFrameSource { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::videostab::NullFrameSource { + let ret = unsafe { sys::cv_videostab_NullFrameSource_defaultNew_const() }; + let ret = unsafe { crate::videostab::NullFrameSource::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::videostab::NullFrameSource] @@ -3804,20 +3808,23 @@ pub mod videostab { } - pub struct NullFrameSource { - ptr: *mut c_void, + impl Default for NullFrameSource { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { NullFrameSource } - - impl Drop for NullFrameSource { + impl std::fmt::Debug for NullFrameSource { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_NullFrameSource_delete(self.as_raw_mut_NullFrameSource()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("NullFrameSource") + .finish() } } - unsafe impl Send for NullFrameSource {} + boxed_cast_base! { NullFrameSource, crate::videostab::IFrameSource, cv_videostab_NullFrameSource_to_IFrameSource } impl crate::videostab::IFrameSourceTraitConst for NullFrameSource { #[inline] fn as_raw_IFrameSource(&self) -> *const c_void { self.as_raw() } @@ -3839,31 +3846,30 @@ pub mod videostab { boxed_ref! { NullFrameSource, crate::videostab::NullFrameSourceTraitConst, as_raw_NullFrameSource, crate::videostab::NullFrameSourceTrait, as_raw_mut_NullFrameSource } - impl NullFrameSource { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_videostab_NullFrameSource_defaultNew_const()) } - } - + pub struct NullInpainter { + ptr: *mut c_void, } - boxed_cast_base! { NullFrameSource, crate::videostab::IFrameSource, cv_videostab_NullFrameSource_to_IFrameSource } + opencv_type_boxed! { NullInpainter } - impl std::fmt::Debug for NullFrameSource { + impl Drop for NullInpainter { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("NullFrameSource") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_NullInpainter_delete(self.as_raw_mut_NullInpainter()) }; } } - impl Default for NullFrameSource { + unsafe impl Send for NullInpainter {} + + impl NullInpainter { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::videostab::NullInpainter { + let ret = unsafe { sys::cv_videostab_NullInpainter_defaultNew_const() }; + let ret = unsafe { crate::videostab::NullInpainter::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::videostab::NullInpainter] @@ -3887,20 +3893,23 @@ pub mod videostab { } - pub struct NullInpainter { - ptr: *mut c_void, + impl Default for NullInpainter { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { NullInpainter } - - impl Drop for NullInpainter { + impl std::fmt::Debug for NullInpainter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_NullInpainter_delete(self.as_raw_mut_NullInpainter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("NullInpainter") + .finish() } } - unsafe impl Send for NullInpainter {} + boxed_cast_base! { NullInpainter, crate::videostab::InpainterBase, cv_videostab_NullInpainter_to_InpainterBase } impl crate::videostab::InpainterBaseTraitConst for NullInpainter { #[inline] fn as_raw_InpainterBase(&self) -> *const c_void { self.as_raw() } @@ -3922,31 +3931,30 @@ pub mod videostab { boxed_ref! { NullInpainter, crate::videostab::NullInpainterTraitConst, as_raw_NullInpainter, crate::videostab::NullInpainterTrait, as_raw_mut_NullInpainter } - impl NullInpainter { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_videostab_NullInpainter_defaultNew_const()) } - } - + pub struct NullLog { + ptr: *mut c_void, } - boxed_cast_base! { NullInpainter, crate::videostab::InpainterBase, cv_videostab_NullInpainter_to_InpainterBase } + opencv_type_boxed! { NullLog } - impl std::fmt::Debug for NullInpainter { + impl Drop for NullLog { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("NullInpainter") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_NullLog_delete(self.as_raw_mut_NullLog()) }; } } - impl Default for NullInpainter { + unsafe impl Send for NullLog {} + + impl NullLog { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::videostab::NullLog { + let ret = unsafe { sys::cv_videostab_NullLog_defaultNew_const() }; + let ret = unsafe { crate::videostab::NullLog::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::videostab::NullLog] @@ -3971,20 +3979,23 @@ pub mod videostab { } - pub struct NullLog { - ptr: *mut c_void, + impl Default for NullLog { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { NullLog } - - impl Drop for NullLog { + impl std::fmt::Debug for NullLog { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_NullLog_delete(self.as_raw_mut_NullLog()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("NullLog") + .finish() } } - unsafe impl Send for NullLog {} + boxed_cast_base! { NullLog, crate::videostab::ILog, cv_videostab_NullLog_to_ILog } impl crate::videostab::ILogTraitConst for NullLog { #[inline] fn as_raw_ILog(&self) -> *const c_void { self.as_raw() } @@ -4006,31 +4017,30 @@ pub mod videostab { boxed_ref! { NullLog, crate::videostab::NullLogTraitConst, as_raw_NullLog, crate::videostab::NullLogTrait, as_raw_mut_NullLog } - impl NullLog { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_videostab_NullLog_defaultNew_const()) } - } - + pub struct NullOutlierRejector { + ptr: *mut c_void, } - boxed_cast_base! { NullLog, crate::videostab::ILog, cv_videostab_NullLog_to_ILog } + opencv_type_boxed! { NullOutlierRejector } - impl std::fmt::Debug for NullLog { + impl Drop for NullOutlierRejector { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("NullLog") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_NullOutlierRejector_delete(self.as_raw_mut_NullOutlierRejector()) }; } } - impl Default for NullLog { + unsafe impl Send for NullOutlierRejector {} + + impl NullOutlierRejector { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::videostab::NullOutlierRejector { + let ret = unsafe { sys::cv_videostab_NullOutlierRejector_defaultNew_const() }; + let ret = unsafe { crate::videostab::NullOutlierRejector::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::videostab::NullOutlierRejector] @@ -4057,20 +4067,23 @@ pub mod videostab { } - pub struct NullOutlierRejector { - ptr: *mut c_void, + impl Default for NullOutlierRejector { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { NullOutlierRejector } - - impl Drop for NullOutlierRejector { + impl std::fmt::Debug for NullOutlierRejector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_NullOutlierRejector_delete(self.as_raw_mut_NullOutlierRejector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("NullOutlierRejector") + .finish() } } - unsafe impl Send for NullOutlierRejector {} + boxed_cast_base! { NullOutlierRejector, crate::videostab::IOutlierRejector, cv_videostab_NullOutlierRejector_to_IOutlierRejector } impl crate::videostab::IOutlierRejectorTraitConst for NullOutlierRejector { #[inline] fn as_raw_IOutlierRejector(&self) -> *const c_void { self.as_raw() } @@ -4092,31 +4105,30 @@ pub mod videostab { boxed_ref! { NullOutlierRejector, crate::videostab::NullOutlierRejectorTraitConst, as_raw_NullOutlierRejector, crate::videostab::NullOutlierRejectorTrait, as_raw_mut_NullOutlierRejector } - impl NullOutlierRejector { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_videostab_NullOutlierRejector_defaultNew_const()) } - } - + pub struct NullWobbleSuppressor { + ptr: *mut c_void, } - boxed_cast_base! { NullOutlierRejector, crate::videostab::IOutlierRejector, cv_videostab_NullOutlierRejector_to_IOutlierRejector } + opencv_type_boxed! { NullWobbleSuppressor } - impl std::fmt::Debug for NullOutlierRejector { + impl Drop for NullWobbleSuppressor { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("NullOutlierRejector") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_NullWobbleSuppressor_delete(self.as_raw_mut_NullWobbleSuppressor()) }; } } - impl Default for NullOutlierRejector { + unsafe impl Send for NullWobbleSuppressor {} + + impl NullWobbleSuppressor { + /// Creates a default instance of the class by calling the default constructor #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> crate::videostab::NullWobbleSuppressor { + let ret = unsafe { sys::cv_videostab_NullWobbleSuppressor_defaultNew_const() }; + let ret = unsafe { crate::videostab::NullWobbleSuppressor::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::videostab::NullWobbleSuppressor] @@ -4140,20 +4152,23 @@ pub mod videostab { } - pub struct NullWobbleSuppressor { - ptr: *mut c_void, + impl Default for NullWobbleSuppressor { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { NullWobbleSuppressor } - - impl Drop for NullWobbleSuppressor { + impl std::fmt::Debug for NullWobbleSuppressor { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_NullWobbleSuppressor_delete(self.as_raw_mut_NullWobbleSuppressor()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("NullWobbleSuppressor") + .finish() } } - unsafe impl Send for NullWobbleSuppressor {} + boxed_cast_base! { NullWobbleSuppressor, crate::videostab::WobbleSuppressorBase, cv_videostab_NullWobbleSuppressor_to_WobbleSuppressorBase } impl crate::videostab::WobbleSuppressorBaseTraitConst for NullWobbleSuppressor { #[inline] fn as_raw_WobbleSuppressorBase(&self) -> *const c_void { self.as_raw() } @@ -4175,31 +4190,32 @@ pub mod videostab { boxed_ref! { NullWobbleSuppressor, crate::videostab::NullWobbleSuppressorTraitConst, as_raw_NullWobbleSuppressor, crate::videostab::NullWobbleSuppressorTrait, as_raw_mut_NullWobbleSuppressor } - impl NullWobbleSuppressor { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_videostab_NullWobbleSuppressor_defaultNew_const()) } - } - + pub struct OnePassStabilizer { + ptr: *mut c_void, } - boxed_cast_base! { NullWobbleSuppressor, crate::videostab::WobbleSuppressorBase, cv_videostab_NullWobbleSuppressor_to_WobbleSuppressorBase } + opencv_type_boxed! { OnePassStabilizer } - impl std::fmt::Debug for NullWobbleSuppressor { + impl Drop for OnePassStabilizer { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("NullWobbleSuppressor") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_OnePassStabilizer_delete(self.as_raw_mut_OnePassStabilizer()) }; } } - impl Default for NullWobbleSuppressor { + unsafe impl Send for OnePassStabilizer {} + + impl OnePassStabilizer { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_OnePassStabilizer_OnePassStabilizer(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::OnePassStabilizer::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::videostab::OnePassStabilizer] @@ -4252,20 +4268,17 @@ pub mod videostab { } - pub struct OnePassStabilizer { - ptr: *mut c_void, - } - - opencv_type_boxed! { OnePassStabilizer } - - impl Drop for OnePassStabilizer { + impl std::fmt::Debug for OnePassStabilizer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_OnePassStabilizer_delete(self.as_raw_mut_OnePassStabilizer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("OnePassStabilizer") + .finish() } } - unsafe impl Send for OnePassStabilizer {} + boxed_cast_base! { OnePassStabilizer, crate::videostab::IFrameSource, cv_videostab_OnePassStabilizer_to_IFrameSource } + + boxed_cast_base! { OnePassStabilizer, crate::videostab::StabilizerBase, cv_videostab_OnePassStabilizer_to_StabilizerBase } impl crate::videostab::IFrameSourceTraitConst for OnePassStabilizer { #[inline] fn as_raw_IFrameSource(&self) -> *const c_void { self.as_raw() } @@ -4297,29 +4310,32 @@ pub mod videostab { boxed_ref! { OnePassStabilizer, crate::videostab::OnePassStabilizerTraitConst, as_raw_OnePassStabilizer, crate::videostab::OnePassStabilizerTrait, as_raw_mut_OnePassStabilizer } - impl OnePassStabilizer { + pub struct PyrLkOptFlowEstimatorBase { + ptr: *mut c_void, + } + + opencv_type_boxed! { PyrLkOptFlowEstimatorBase } + + impl Drop for PyrLkOptFlowEstimatorBase { #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_OnePassStabilizer_OnePassStabilizer(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::OnePassStabilizer::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_videostab_PyrLkOptFlowEstimatorBase_delete(self.as_raw_mut_PyrLkOptFlowEstimatorBase()) }; } - } - boxed_cast_base! { OnePassStabilizer, crate::videostab::IFrameSource, cv_videostab_OnePassStabilizer_to_IFrameSource } - - boxed_cast_base! { OnePassStabilizer, crate::videostab::StabilizerBase, cv_videostab_OnePassStabilizer_to_StabilizerBase } + unsafe impl Send for PyrLkOptFlowEstimatorBase {} - impl std::fmt::Debug for OnePassStabilizer { + impl PyrLkOptFlowEstimatorBase { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("OnePassStabilizer") - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_PyrLkOptFlowEstimatorBase_PyrLkOptFlowEstimatorBase(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::PyrLkOptFlowEstimatorBase::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::videostab::PyrLkOptFlowEstimatorBase] @@ -4370,20 +4386,19 @@ pub mod videostab { } - pub struct PyrLkOptFlowEstimatorBase { - ptr: *mut c_void, - } - - opencv_type_boxed! { PyrLkOptFlowEstimatorBase } - - impl Drop for PyrLkOptFlowEstimatorBase { + impl std::fmt::Debug for PyrLkOptFlowEstimatorBase { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_PyrLkOptFlowEstimatorBase_delete(self.as_raw_mut_PyrLkOptFlowEstimatorBase()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PyrLkOptFlowEstimatorBase") + .finish() } } - unsafe impl Send for PyrLkOptFlowEstimatorBase {} + boxed_cast_descendant! { PyrLkOptFlowEstimatorBase, crate::videostab::DensePyrLkOptFlowEstimatorGpu, cv_videostab_PyrLkOptFlowEstimatorBase_to_DensePyrLkOptFlowEstimatorGpu } + + boxed_cast_descendant! { PyrLkOptFlowEstimatorBase, crate::videostab::SparsePyrLkOptFlowEstimator, cv_videostab_PyrLkOptFlowEstimatorBase_to_SparsePyrLkOptFlowEstimator } + + boxed_cast_descendant! { PyrLkOptFlowEstimatorBase, crate::videostab::SparsePyrLkOptFlowEstimatorGpu, cv_videostab_PyrLkOptFlowEstimatorBase_to_SparsePyrLkOptFlowEstimatorGpu } impl crate::videostab::PyrLkOptFlowEstimatorBaseTraitConst for PyrLkOptFlowEstimatorBase { #[inline] fn as_raw_PyrLkOptFlowEstimatorBase(&self) -> *const c_void { self.as_raw() } @@ -4395,31 +4410,63 @@ pub mod videostab { boxed_ref! { PyrLkOptFlowEstimatorBase, crate::videostab::PyrLkOptFlowEstimatorBaseTraitConst, as_raw_PyrLkOptFlowEstimatorBase, crate::videostab::PyrLkOptFlowEstimatorBaseTrait, as_raw_mut_PyrLkOptFlowEstimatorBase } - impl PyrLkOptFlowEstimatorBase { + /// Describes RANSAC method parameters. + pub struct RansacParams { + ptr: *mut c_void, + } + + opencv_type_boxed! { RansacParams } + + impl Drop for RansacParams { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_videostab_RansacParams_delete(self.as_raw_mut_RansacParams()) }; + } + } + + unsafe impl Send for RansacParams {} + + impl RansacParams { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_PyrLkOptFlowEstimatorBase_PyrLkOptFlowEstimatorBase(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_videostab_RansacParams_RansacParams(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::PyrLkOptFlowEstimatorBase::opencv_from_extern(ret) }; + let ret = unsafe { crate::videostab::RansacParams::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_descendant! { PyrLkOptFlowEstimatorBase, crate::videostab::DensePyrLkOptFlowEstimatorGpu, cv_videostab_PyrLkOptFlowEstimatorBase_to_DensePyrLkOptFlowEstimatorGpu } - - boxed_cast_descendant! { PyrLkOptFlowEstimatorBase, crate::videostab::SparsePyrLkOptFlowEstimator, cv_videostab_PyrLkOptFlowEstimatorBase_to_SparsePyrLkOptFlowEstimator } - - boxed_cast_descendant! { PyrLkOptFlowEstimatorBase, crate::videostab::SparsePyrLkOptFlowEstimatorGpu, cv_videostab_PyrLkOptFlowEstimatorBase_to_SparsePyrLkOptFlowEstimatorGpu } + /// Constructor + /// ## Parameters + /// * size: Subset size. + /// * thresh: Maximum re-projection error value to classify as inlier. + /// * eps: Maximum ratio of incorrect correspondences. + /// * prob: Required success probability. + #[inline] + pub fn new(size: i32, thresh: f32, eps: f32, prob: f32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_RansacParams_RansacParams_int_float_float_float(size, thresh, eps, prob, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::RansacParams::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for PyrLkOptFlowEstimatorBase { + /// ## Parameters + /// * model: Motion model. See cv::videostab::MotionModel. + /// ## Returns + /// Default RANSAC method parameters for the given motion model. #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PyrLkOptFlowEstimatorBase") - .finish() + pub fn default2d_motion(model: crate::videostab::MotionModel) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_RansacParams_default2dMotion_MotionModel(model, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::RansacParams::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::videostab::RansacParams] @@ -4499,24 +4546,20 @@ pub mod videostab { ret } - } - - /// Describes RANSAC method parameters. - pub struct RansacParams { - ptr: *mut c_void, - } - - opencv_type_boxed! { RansacParams } + } - impl Drop for RansacParams { + impl std::fmt::Debug for RansacParams { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_RansacParams_delete(self.as_raw_mut_RansacParams()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RansacParams") + .field("size", &crate::videostab::RansacParamsTraitConst::size(self)) + .field("thresh", &crate::videostab::RansacParamsTraitConst::thresh(self)) + .field("eps", &crate::videostab::RansacParamsTraitConst::eps(self)) + .field("prob", &crate::videostab::RansacParamsTraitConst::prob(self)) + .finish() } } - unsafe impl Send for RansacParams {} - impl crate::videostab::RansacParamsTraitConst for RansacParams { #[inline] fn as_raw_RansacParams(&self) -> *const c_void { self.as_raw() } } @@ -4527,59 +4570,30 @@ pub mod videostab { boxed_ref! { RansacParams, crate::videostab::RansacParamsTraitConst, as_raw_RansacParams, crate::videostab::RansacParamsTrait, as_raw_mut_RansacParams } - impl RansacParams { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_RansacParams_RansacParams(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::RansacParams::opencv_from_extern(ret) }; - Ok(ret) - } + pub struct SparsePyrLkOptFlowEstimator { + ptr: *mut c_void, + } - /// Constructor - /// ## Parameters - /// * size: Subset size. - /// * thresh: Maximum re-projection error value to classify as inlier. - /// * eps: Maximum ratio of incorrect correspondences. - /// * prob: Required success probability. - #[inline] - pub fn new(size: i32, thresh: f32, eps: f32, prob: f32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_RansacParams_RansacParams_int_float_float_float(size, thresh, eps, prob, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::RansacParams::opencv_from_extern(ret) }; - Ok(ret) - } + opencv_type_boxed! { SparsePyrLkOptFlowEstimator } - /// ## Parameters - /// * model: Motion model. See cv::videostab::MotionModel. - /// ## Returns - /// Default RANSAC method parameters for the given motion model. + impl Drop for SparsePyrLkOptFlowEstimator { #[inline] - pub fn default2d_motion(model: crate::videostab::MotionModel) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_RansacParams_default2dMotion_MotionModel(model, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::RansacParams::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_videostab_SparsePyrLkOptFlowEstimator_delete(self.as_raw_mut_SparsePyrLkOptFlowEstimator()) }; } - } - impl std::fmt::Debug for RansacParams { + unsafe impl Send for SparsePyrLkOptFlowEstimator {} + + impl SparsePyrLkOptFlowEstimator { + /// Creates a default instance of the class by calling the default constructor #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RansacParams") - .field("size", &crate::videostab::RansacParamsTraitConst::size(self)) - .field("thresh", &crate::videostab::RansacParamsTraitConst::thresh(self)) - .field("eps", &crate::videostab::RansacParamsTraitConst::eps(self)) - .field("prob", &crate::videostab::RansacParamsTraitConst::prob(self)) - .finish() + pub fn default() -> crate::videostab::SparsePyrLkOptFlowEstimator { + let ret = unsafe { sys::cv_videostab_SparsePyrLkOptFlowEstimator_defaultNew_const() }; + let ret = unsafe { crate::videostab::SparsePyrLkOptFlowEstimator::opencv_from_extern(ret) }; + ret } + } /// Constant methods for [crate::videostab::SparsePyrLkOptFlowEstimator] @@ -4609,20 +4623,25 @@ pub mod videostab { } - pub struct SparsePyrLkOptFlowEstimator { - ptr: *mut c_void, + impl Default for SparsePyrLkOptFlowEstimator { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } } - opencv_type_boxed! { SparsePyrLkOptFlowEstimator } - - impl Drop for SparsePyrLkOptFlowEstimator { + impl std::fmt::Debug for SparsePyrLkOptFlowEstimator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_SparsePyrLkOptFlowEstimator_delete(self.as_raw_mut_SparsePyrLkOptFlowEstimator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SparsePyrLkOptFlowEstimator") + .finish() } } - unsafe impl Send for SparsePyrLkOptFlowEstimator {} + boxed_cast_base! { SparsePyrLkOptFlowEstimator, crate::videostab::ISparseOptFlowEstimator, cv_videostab_SparsePyrLkOptFlowEstimator_to_ISparseOptFlowEstimator } + + boxed_cast_base! { SparsePyrLkOptFlowEstimator, crate::videostab::PyrLkOptFlowEstimatorBase, cv_videostab_SparsePyrLkOptFlowEstimator_to_PyrLkOptFlowEstimatorBase } impl crate::videostab::ISparseOptFlowEstimatorTraitConst for SparsePyrLkOptFlowEstimator { #[inline] fn as_raw_ISparseOptFlowEstimator(&self) -> *const c_void { self.as_raw() } @@ -4654,33 +4673,32 @@ pub mod videostab { boxed_ref! { SparsePyrLkOptFlowEstimator, crate::videostab::SparsePyrLkOptFlowEstimatorTraitConst, as_raw_SparsePyrLkOptFlowEstimator, crate::videostab::SparsePyrLkOptFlowEstimatorTrait, as_raw_mut_SparsePyrLkOptFlowEstimator } - impl SparsePyrLkOptFlowEstimator { - /// Creates a default instance of the class by calling the default constructor - #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_videostab_SparsePyrLkOptFlowEstimator_defaultNew_const()) } - } - + pub struct SparsePyrLkOptFlowEstimatorGpu { + ptr: *mut c_void, } - boxed_cast_base! { SparsePyrLkOptFlowEstimator, crate::videostab::ISparseOptFlowEstimator, cv_videostab_SparsePyrLkOptFlowEstimator_to_ISparseOptFlowEstimator } - - boxed_cast_base! { SparsePyrLkOptFlowEstimator, crate::videostab::PyrLkOptFlowEstimatorBase, cv_videostab_SparsePyrLkOptFlowEstimator_to_PyrLkOptFlowEstimatorBase } + opencv_type_boxed! { SparsePyrLkOptFlowEstimatorGpu } - impl std::fmt::Debug for SparsePyrLkOptFlowEstimator { + impl Drop for SparsePyrLkOptFlowEstimatorGpu { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SparsePyrLkOptFlowEstimator") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_SparsePyrLkOptFlowEstimatorGpu_delete(self.as_raw_mut_SparsePyrLkOptFlowEstimatorGpu()) }; } } - impl Default for SparsePyrLkOptFlowEstimator { + unsafe impl Send for SparsePyrLkOptFlowEstimatorGpu {} + + impl SparsePyrLkOptFlowEstimatorGpu { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_SparsePyrLkOptFlowEstimatorGpu_SparsePyrLkOptFlowEstimatorGpu(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::SparsePyrLkOptFlowEstimatorGpu::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::videostab::SparsePyrLkOptFlowEstimatorGpu] @@ -4728,20 +4746,17 @@ pub mod videostab { } - pub struct SparsePyrLkOptFlowEstimatorGpu { - ptr: *mut c_void, - } - - opencv_type_boxed! { SparsePyrLkOptFlowEstimatorGpu } - - impl Drop for SparsePyrLkOptFlowEstimatorGpu { + impl std::fmt::Debug for SparsePyrLkOptFlowEstimatorGpu { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_SparsePyrLkOptFlowEstimatorGpu_delete(self.as_raw_mut_SparsePyrLkOptFlowEstimatorGpu()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SparsePyrLkOptFlowEstimatorGpu") + .finish() } } - unsafe impl Send for SparsePyrLkOptFlowEstimatorGpu {} + boxed_cast_base! { SparsePyrLkOptFlowEstimatorGpu, crate::videostab::ISparseOptFlowEstimator, cv_videostab_SparsePyrLkOptFlowEstimatorGpu_to_ISparseOptFlowEstimator } + + boxed_cast_base! { SparsePyrLkOptFlowEstimatorGpu, crate::videostab::PyrLkOptFlowEstimatorBase, cv_videostab_SparsePyrLkOptFlowEstimatorGpu_to_PyrLkOptFlowEstimatorBase } impl crate::videostab::ISparseOptFlowEstimatorTraitConst for SparsePyrLkOptFlowEstimatorGpu { #[inline] fn as_raw_ISparseOptFlowEstimator(&self) -> *const c_void { self.as_raw() } @@ -4773,31 +4788,21 @@ pub mod videostab { boxed_ref! { SparsePyrLkOptFlowEstimatorGpu, crate::videostab::SparsePyrLkOptFlowEstimatorGpuTraitConst, as_raw_SparsePyrLkOptFlowEstimatorGpu, crate::videostab::SparsePyrLkOptFlowEstimatorGpuTrait, as_raw_mut_SparsePyrLkOptFlowEstimatorGpu } - impl SparsePyrLkOptFlowEstimatorGpu { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_SparsePyrLkOptFlowEstimatorGpu_SparsePyrLkOptFlowEstimatorGpu(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::SparsePyrLkOptFlowEstimatorGpu::opencv_from_extern(ret) }; - Ok(ret) - } - + pub struct StabilizerBase { + ptr: *mut c_void, } - boxed_cast_base! { SparsePyrLkOptFlowEstimatorGpu, crate::videostab::ISparseOptFlowEstimator, cv_videostab_SparsePyrLkOptFlowEstimatorGpu_to_ISparseOptFlowEstimator } - - boxed_cast_base! { SparsePyrLkOptFlowEstimatorGpu, crate::videostab::PyrLkOptFlowEstimatorBase, cv_videostab_SparsePyrLkOptFlowEstimatorGpu_to_PyrLkOptFlowEstimatorBase } + opencv_type_boxed! { StabilizerBase } - impl std::fmt::Debug for SparsePyrLkOptFlowEstimatorGpu { + impl Drop for StabilizerBase { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SparsePyrLkOptFlowEstimatorGpu") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_StabilizerBase_delete(self.as_raw_mut_StabilizerBase()) }; } } + unsafe impl Send for StabilizerBase {} + /// Constant methods for [crate::videostab::StabilizerBase] pub trait StabilizerBaseTraitConst { fn as_raw_StabilizerBase(&self) -> *const c_void; @@ -4996,20 +5001,17 @@ pub mod videostab { } - pub struct StabilizerBase { - ptr: *mut c_void, - } - - opencv_type_boxed! { StabilizerBase } - - impl Drop for StabilizerBase { + impl std::fmt::Debug for StabilizerBase { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_StabilizerBase_delete(self.as_raw_mut_StabilizerBase()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("StabilizerBase") + .finish() } } - unsafe impl Send for StabilizerBase {} + boxed_cast_descendant! { StabilizerBase, crate::videostab::OnePassStabilizer, cv_videostab_StabilizerBase_to_OnePassStabilizer } + + boxed_cast_descendant! { StabilizerBase, crate::videostab::TwoPassStabilizer, cv_videostab_StabilizerBase_to_TwoPassStabilizer } impl crate::videostab::StabilizerBaseTraitConst for StabilizerBase { #[inline] fn as_raw_StabilizerBase(&self) -> *const c_void { self.as_raw() } @@ -5021,19 +5023,33 @@ pub mod videostab { boxed_ref! { StabilizerBase, crate::videostab::StabilizerBaseTraitConst, as_raw_StabilizerBase, crate::videostab::StabilizerBaseTrait, as_raw_mut_StabilizerBase } - impl StabilizerBase { + pub struct ToFileMotionWriter { + ptr: *mut c_void, } - boxed_cast_descendant! { StabilizerBase, crate::videostab::OnePassStabilizer, cv_videostab_StabilizerBase_to_OnePassStabilizer } + opencv_type_boxed! { ToFileMotionWriter } - boxed_cast_descendant! { StabilizerBase, crate::videostab::TwoPassStabilizer, cv_videostab_StabilizerBase_to_TwoPassStabilizer } + impl Drop for ToFileMotionWriter { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_videostab_ToFileMotionWriter_delete(self.as_raw_mut_ToFileMotionWriter()) }; + } + } - impl std::fmt::Debug for StabilizerBase { + unsafe impl Send for ToFileMotionWriter {} + + impl ToFileMotionWriter { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("StabilizerBase") - .finish() + pub fn new(path: &str, mut estimator: core::Ptr) -> Result { + extern_container_arg!(path); + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_ToFileMotionWriter_ToFileMotionWriter_const_StringR_PtrLImageMotionEstimatorBaseG(path.opencv_as_extern(), estimator.as_raw_mut_PtrOfImageMotionEstimatorBase(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::ToFileMotionWriter::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::videostab::ToFileMotionWriter] @@ -5101,20 +5117,15 @@ pub mod videostab { } - pub struct ToFileMotionWriter { - ptr: *mut c_void, - } - - opencv_type_boxed! { ToFileMotionWriter } - - impl Drop for ToFileMotionWriter { + impl std::fmt::Debug for ToFileMotionWriter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_ToFileMotionWriter_delete(self.as_raw_mut_ToFileMotionWriter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ToFileMotionWriter") + .finish() } } - unsafe impl Send for ToFileMotionWriter {} + boxed_cast_base! { ToFileMotionWriter, crate::videostab::ImageMotionEstimatorBase, cv_videostab_ToFileMotionWriter_to_ImageMotionEstimatorBase } impl crate::videostab::ImageMotionEstimatorBaseTraitConst for ToFileMotionWriter { #[inline] fn as_raw_ImageMotionEstimatorBase(&self) -> *const c_void { self.as_raw() } @@ -5136,28 +5147,32 @@ pub mod videostab { boxed_ref! { ToFileMotionWriter, crate::videostab::ToFileMotionWriterTraitConst, as_raw_ToFileMotionWriter, crate::videostab::ToFileMotionWriterTrait, as_raw_mut_ToFileMotionWriter } - impl ToFileMotionWriter { + pub struct TranslationBasedLocalOutlierRejector { + ptr: *mut c_void, + } + + opencv_type_boxed! { TranslationBasedLocalOutlierRejector } + + impl Drop for TranslationBasedLocalOutlierRejector { #[inline] - pub fn new(path: &str, mut estimator: core::Ptr) -> Result { - extern_container_arg!(path); - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_ToFileMotionWriter_ToFileMotionWriter_const_StringR_PtrLImageMotionEstimatorBaseG(path.opencv_as_extern(), estimator.as_raw_mut_PtrOfImageMotionEstimatorBase(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::ToFileMotionWriter::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_videostab_TranslationBasedLocalOutlierRejector_delete(self.as_raw_mut_TranslationBasedLocalOutlierRejector()) }; } - } - boxed_cast_base! { ToFileMotionWriter, crate::videostab::ImageMotionEstimatorBase, cv_videostab_ToFileMotionWriter_to_ImageMotionEstimatorBase } + unsafe impl Send for TranslationBasedLocalOutlierRejector {} - impl std::fmt::Debug for ToFileMotionWriter { + impl TranslationBasedLocalOutlierRejector { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ToFileMotionWriter") - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_TranslationBasedLocalOutlierRejector_TranslationBasedLocalOutlierRejector(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::TranslationBasedLocalOutlierRejector::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::videostab::TranslationBasedLocalOutlierRejector] @@ -5221,20 +5236,15 @@ pub mod videostab { } - pub struct TranslationBasedLocalOutlierRejector { - ptr: *mut c_void, - } - - opencv_type_boxed! { TranslationBasedLocalOutlierRejector } - - impl Drop for TranslationBasedLocalOutlierRejector { + impl std::fmt::Debug for TranslationBasedLocalOutlierRejector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_TranslationBasedLocalOutlierRejector_delete(self.as_raw_mut_TranslationBasedLocalOutlierRejector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TranslationBasedLocalOutlierRejector") + .finish() } } - unsafe impl Send for TranslationBasedLocalOutlierRejector {} + boxed_cast_base! { TranslationBasedLocalOutlierRejector, crate::videostab::IOutlierRejector, cv_videostab_TranslationBasedLocalOutlierRejector_to_IOutlierRejector } impl crate::videostab::IOutlierRejectorTraitConst for TranslationBasedLocalOutlierRejector { #[inline] fn as_raw_IOutlierRejector(&self) -> *const c_void { self.as_raw() } @@ -5256,27 +5266,32 @@ pub mod videostab { boxed_ref! { TranslationBasedLocalOutlierRejector, crate::videostab::TranslationBasedLocalOutlierRejectorTraitConst, as_raw_TranslationBasedLocalOutlierRejector, crate::videostab::TranslationBasedLocalOutlierRejectorTrait, as_raw_mut_TranslationBasedLocalOutlierRejector } - impl TranslationBasedLocalOutlierRejector { + pub struct TwoPassStabilizer { + ptr: *mut c_void, + } + + opencv_type_boxed! { TwoPassStabilizer } + + impl Drop for TwoPassStabilizer { #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_TranslationBasedLocalOutlierRejector_TranslationBasedLocalOutlierRejector(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::TranslationBasedLocalOutlierRejector::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_videostab_TwoPassStabilizer_delete(self.as_raw_mut_TwoPassStabilizer()) }; } - } - boxed_cast_base! { TranslationBasedLocalOutlierRejector, crate::videostab::IOutlierRejector, cv_videostab_TranslationBasedLocalOutlierRejector_to_IOutlierRejector } + unsafe impl Send for TwoPassStabilizer {} - impl std::fmt::Debug for TranslationBasedLocalOutlierRejector { + impl TwoPassStabilizer { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TranslationBasedLocalOutlierRejector") - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_TwoPassStabilizer_TwoPassStabilizer(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::TwoPassStabilizer::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::videostab::TwoPassStabilizer] @@ -5366,20 +5381,17 @@ pub mod videostab { } - pub struct TwoPassStabilizer { - ptr: *mut c_void, - } - - opencv_type_boxed! { TwoPassStabilizer } - - impl Drop for TwoPassStabilizer { + impl std::fmt::Debug for TwoPassStabilizer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_TwoPassStabilizer_delete(self.as_raw_mut_TwoPassStabilizer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TwoPassStabilizer") + .finish() } } - unsafe impl Send for TwoPassStabilizer {} + boxed_cast_base! { TwoPassStabilizer, crate::videostab::IFrameSource, cv_videostab_TwoPassStabilizer_to_IFrameSource } + + boxed_cast_base! { TwoPassStabilizer, crate::videostab::StabilizerBase, cv_videostab_TwoPassStabilizer_to_StabilizerBase } impl crate::videostab::IFrameSourceTraitConst for TwoPassStabilizer { #[inline] fn as_raw_IFrameSource(&self) -> *const c_void { self.as_raw() } @@ -5411,29 +5423,49 @@ pub mod videostab { boxed_ref! { TwoPassStabilizer, crate::videostab::TwoPassStabilizerTraitConst, as_raw_TwoPassStabilizer, crate::videostab::TwoPassStabilizerTrait, as_raw_mut_TwoPassStabilizer } - impl TwoPassStabilizer { + pub struct VideoFileSource { + ptr: *mut c_void, + } + + opencv_type_boxed! { VideoFileSource } + + impl Drop for VideoFileSource { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_videostab_VideoFileSource_delete(self.as_raw_mut_VideoFileSource()) }; + } + } + + unsafe impl Send for VideoFileSource {} + + impl VideoFileSource { + /// ## C++ default parameters + /// * volatile_frame: false + #[inline] + pub fn new(path: &str, volatile_frame: bool) -> Result { + extern_container_arg!(path); return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_TwoPassStabilizer_TwoPassStabilizer(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_videostab_VideoFileSource_VideoFileSource_const_StringR_bool(path.opencv_as_extern(), volatile_frame, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::TwoPassStabilizer::opencv_from_extern(ret) }; + let ret = unsafe { crate::videostab::VideoFileSource::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { TwoPassStabilizer, crate::videostab::IFrameSource, cv_videostab_TwoPassStabilizer_to_IFrameSource } - - boxed_cast_base! { TwoPassStabilizer, crate::videostab::StabilizerBase, cv_videostab_TwoPassStabilizer_to_StabilizerBase } - - impl std::fmt::Debug for TwoPassStabilizer { + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * volatile_frame: false #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TwoPassStabilizer") - .finish() + pub fn new_def(path: &str) -> Result { + extern_container_arg!(path); + return_send!(via ocvrs_return); + unsafe { sys::cv_videostab_VideoFileSource_VideoFileSource_const_StringR(path.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::videostab::VideoFileSource::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::videostab::VideoFileSource] @@ -5503,20 +5535,15 @@ pub mod videostab { } - pub struct VideoFileSource { - ptr: *mut c_void, - } - - opencv_type_boxed! { VideoFileSource } - - impl Drop for VideoFileSource { + impl std::fmt::Debug for VideoFileSource { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_VideoFileSource_delete(self.as_raw_mut_VideoFileSource()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("VideoFileSource") + .finish() } } - unsafe impl Send for VideoFileSource {} + boxed_cast_base! { VideoFileSource, crate::videostab::IFrameSource, cv_videostab_VideoFileSource_to_IFrameSource } impl crate::videostab::IFrameSourceTraitConst for VideoFileSource { #[inline] fn as_raw_IFrameSource(&self) -> *const c_void { self.as_raw() } @@ -5538,46 +5565,34 @@ pub mod videostab { boxed_ref! { VideoFileSource, crate::videostab::VideoFileSourceTraitConst, as_raw_VideoFileSource, crate::videostab::VideoFileSourceTrait, as_raw_mut_VideoFileSource } - impl VideoFileSource { - /// ## C++ default parameters - /// * volatile_frame: false + pub struct WeightingDeblurer { + ptr: *mut c_void, + } + + opencv_type_boxed! { WeightingDeblurer } + + impl Drop for WeightingDeblurer { #[inline] - pub fn new(path: &str, volatile_frame: bool) -> Result { - extern_container_arg!(path); - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_VideoFileSource_VideoFileSource_const_StringR_bool(path.opencv_as_extern(), volatile_frame, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::VideoFileSource::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_videostab_WeightingDeblurer_delete(self.as_raw_mut_WeightingDeblurer()) }; } + } - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * volatile_frame: false + unsafe impl Send for WeightingDeblurer {} + + impl WeightingDeblurer { #[inline] - pub fn new_def(path: &str) -> Result { - extern_container_arg!(path); + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_VideoFileSource_VideoFileSource_const_StringR(path.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_videostab_WeightingDeblurer_WeightingDeblurer(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::VideoFileSource::opencv_from_extern(ret) }; + let ret = unsafe { crate::videostab::WeightingDeblurer::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { VideoFileSource, crate::videostab::IFrameSource, cv_videostab_VideoFileSource_to_IFrameSource } - - impl std::fmt::Debug for VideoFileSource { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("VideoFileSource") - .finish() - } - } - /// Constant methods for [crate::videostab::WeightingDeblurer] pub trait WeightingDeblurerTraitConst: crate::videostab::DeblurerBaseTraitConst { fn as_raw_WeightingDeblurer(&self) -> *const c_void; @@ -5617,20 +5632,15 @@ pub mod videostab { } - pub struct WeightingDeblurer { - ptr: *mut c_void, - } - - opencv_type_boxed! { WeightingDeblurer } - - impl Drop for WeightingDeblurer { + impl std::fmt::Debug for WeightingDeblurer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_WeightingDeblurer_delete(self.as_raw_mut_WeightingDeblurer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("WeightingDeblurer") + .finish() } } - unsafe impl Send for WeightingDeblurer {} + boxed_cast_base! { WeightingDeblurer, crate::videostab::DeblurerBase, cv_videostab_WeightingDeblurer_to_DeblurerBase } impl crate::videostab::DeblurerBaseTraitConst for WeightingDeblurer { #[inline] fn as_raw_DeblurerBase(&self) -> *const c_void { self.as_raw() } @@ -5652,29 +5662,21 @@ pub mod videostab { boxed_ref! { WeightingDeblurer, crate::videostab::WeightingDeblurerTraitConst, as_raw_WeightingDeblurer, crate::videostab::WeightingDeblurerTrait, as_raw_mut_WeightingDeblurer } - impl WeightingDeblurer { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_videostab_WeightingDeblurer_WeightingDeblurer(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::videostab::WeightingDeblurer::opencv_from_extern(ret) }; - Ok(ret) - } - + pub struct WobbleSuppressorBase { + ptr: *mut c_void, } - boxed_cast_base! { WeightingDeblurer, crate::videostab::DeblurerBase, cv_videostab_WeightingDeblurer_to_DeblurerBase } + opencv_type_boxed! { WobbleSuppressorBase } - impl std::fmt::Debug for WeightingDeblurer { + impl Drop for WobbleSuppressorBase { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("WeightingDeblurer") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_videostab_WobbleSuppressorBase_delete(self.as_raw_mut_WobbleSuppressorBase()) }; } } + unsafe impl Send for WobbleSuppressorBase {} + /// Constant methods for [crate::videostab::WobbleSuppressorBase] pub trait WobbleSuppressorBaseTraitConst { fn as_raw_WobbleSuppressorBase(&self) -> *const c_void; @@ -5790,20 +5792,21 @@ pub mod videostab { } - pub struct WobbleSuppressorBase { - ptr: *mut c_void, - } - - opencv_type_boxed! { WobbleSuppressorBase } - - impl Drop for WobbleSuppressorBase { + impl std::fmt::Debug for WobbleSuppressorBase { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_videostab_WobbleSuppressorBase_delete(self.as_raw_mut_WobbleSuppressorBase()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("WobbleSuppressorBase") + .finish() } } - unsafe impl Send for WobbleSuppressorBase {} + boxed_cast_descendant! { WobbleSuppressorBase, crate::videostab::MoreAccurateMotionWobbleSuppressor, cv_videostab_WobbleSuppressorBase_to_MoreAccurateMotionWobbleSuppressor } + + boxed_cast_descendant! { WobbleSuppressorBase, crate::videostab::MoreAccurateMotionWobbleSuppressorBase, cv_videostab_WobbleSuppressorBase_to_MoreAccurateMotionWobbleSuppressorBase } + + boxed_cast_descendant! { WobbleSuppressorBase, crate::videostab::MoreAccurateMotionWobbleSuppressorGpu, cv_videostab_WobbleSuppressorBase_to_MoreAccurateMotionWobbleSuppressorGpu } + + boxed_cast_descendant! { WobbleSuppressorBase, crate::videostab::NullWobbleSuppressor, cv_videostab_WobbleSuppressorBase_to_NullWobbleSuppressor } impl crate::videostab::WobbleSuppressorBaseTraitConst for WobbleSuppressorBase { #[inline] fn as_raw_WobbleSuppressorBase(&self) -> *const c_void { self.as_raw() } @@ -5815,22 +5818,4 @@ pub mod videostab { boxed_ref! { WobbleSuppressorBase, crate::videostab::WobbleSuppressorBaseTraitConst, as_raw_WobbleSuppressorBase, crate::videostab::WobbleSuppressorBaseTrait, as_raw_mut_WobbleSuppressorBase } - impl WobbleSuppressorBase { - } - - boxed_cast_descendant! { WobbleSuppressorBase, crate::videostab::MoreAccurateMotionWobbleSuppressor, cv_videostab_WobbleSuppressorBase_to_MoreAccurateMotionWobbleSuppressor } - - boxed_cast_descendant! { WobbleSuppressorBase, crate::videostab::MoreAccurateMotionWobbleSuppressorBase, cv_videostab_WobbleSuppressorBase_to_MoreAccurateMotionWobbleSuppressorBase } - - boxed_cast_descendant! { WobbleSuppressorBase, crate::videostab::MoreAccurateMotionWobbleSuppressorGpu, cv_videostab_WobbleSuppressorBase_to_MoreAccurateMotionWobbleSuppressorGpu } - - boxed_cast_descendant! { WobbleSuppressorBase, crate::videostab::NullWobbleSuppressor, cv_videostab_WobbleSuppressorBase_to_NullWobbleSuppressor } - - impl std::fmt::Debug for WobbleSuppressorBase { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("WobbleSuppressorBase") - .finish() - } - } } diff --git a/docs/viz.rs b/docs/viz.rs index 3d58bb62c..cbd109d4c 100644 --- a/docs/viz.rs +++ b/docs/viz.rs @@ -669,105 +669,6 @@ pub mod viz { Ok(ret) } - /// Constant methods for [crate::viz::Camera] - pub trait CameraTraitConst { - fn as_raw_Camera(&self) -> *const c_void; - - #[inline] - fn get_clip(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Camera_getClip_const(self.as_raw_Camera(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_window_size(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Camera_getWindowSize_const(self.as_raw_Camera(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_fov(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Camera_getFov_const(self.as_raw_Camera(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_principal_point(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Camera_getPrincipalPoint_const(self.as_raw_Camera(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn get_focal_length(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Camera_getFocalLength_const(self.as_raw_Camera(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Computes projection matrix using intrinsic parameters of the camera. - /// - /// - /// ## Parameters - /// * proj: Output projection matrix with the following form - /// ![block formula](https://latex.codecogs.com/png.latex?%0A%20%20%5Cbegin%7Bbmatrix%7D%0A%20%20%5Cfrac%7B2n%7D%7Br%2Dl%7D%20%26%20%20%20%20%20%20%20%200%20%20%20%20%20%20%20%26%20%5Cfrac%7Br%2Bl%7D%7Br%2Dl%7D%20%20%26%200%5C%5C%0A%20%20%20%20%20%20%20%200%20%20%20%20%20%20%20%20%26%20%5Cfrac%7B2n%7D%7Bt%2Db%7D%20%26%20%5Cfrac%7Bt%2Bb%7D%7Bt%2Db%7D%20%20%26%200%5C%5C%0A%20%20%20%20%20%20%20%200%20%20%20%20%20%20%20%20%26%20%20%20%20%20%20%20%200%20%20%20%20%20%20%20%26%20%2D%5Cfrac%7Bf%2Bn%7D%7Bf%2Dn%7D%20%26%20%2D%5Cfrac%7B2fn%7D%7Bf%2Dn%7D%5C%5C%0A%20%20%20%20%20%20%20%200%20%20%20%20%20%20%20%20%26%20%20%20%20%20%20%20%200%20%20%20%20%20%20%20%26%20%2D1%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%26%200%5C%5C%0A%20%20%5Cend%7Bbmatrix%7D%0A) - #[inline] - fn compute_projection_matrix(&self, proj: &mut core::Matx44d) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Camera_computeProjectionMatrix_const_Matx44dR(self.as_raw_Camera(), proj, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - /// Mutable methods for [crate::viz::Camera] - pub trait CameraTrait: crate::viz::CameraTraitConst { - fn as_raw_mut_Camera(&mut self) -> *mut c_void; - - #[inline] - fn set_clip(&mut self, clip: core::Vec2d) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Camera_setClip_const_Vec2dR(self.as_raw_mut_Camera(), &clip, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn set_window_size(&mut self, window_size: core::Size) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Camera_setWindowSize_const_SizeR(self.as_raw_mut_Camera(), &window_size, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - #[inline] - fn set_fov(&mut self, fov: core::Vec2d) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Camera_setFov_const_Vec2dR(self.as_raw_mut_Camera(), &fov, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - /// This class wraps intrinsic parameters of a camera. /// /// It provides several constructors that can extract the intrinsic parameters from field of @@ -787,16 +688,6 @@ pub mod viz { unsafe impl Send for Camera {} - impl crate::viz::CameraTraitConst for Camera { - #[inline] fn as_raw_Camera(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::CameraTrait for Camera { - #[inline] fn as_raw_mut_Camera(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Camera, crate::viz::CameraTraitConst, as_raw_Camera, crate::viz::CameraTrait, as_raw_mut_Camera } - impl Camera { /// Constructs a Camera. /// @@ -915,22 +806,98 @@ pub mod viz { } - impl std::fmt::Debug for Camera { + /// Constant methods for [crate::viz::Camera] + pub trait CameraTraitConst { + fn as_raw_Camera(&self) -> *const c_void; + #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Camera") - .finish() + fn get_clip(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_Camera_getClip_const(self.as_raw_Camera(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn get_window_size(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_Camera_getWindowSize_const(self.as_raw_Camera(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn get_fov(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_Camera_getFov_const(self.as_raw_Camera(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn get_principal_point(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_Camera_getPrincipalPoint_const(self.as_raw_Camera(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn get_focal_length(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_Camera_getFocalLength_const(self.as_raw_Camera(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Computes projection matrix using intrinsic parameters of the camera. + /// + /// + /// ## Parameters + /// * proj: Output projection matrix with the following form + /// ![block formula](https://latex.codecogs.com/png.latex?%0A%20%20%5Cbegin%7Bbmatrix%7D%0A%20%20%5Cfrac%7B2n%7D%7Br%2Dl%7D%20%26%20%20%20%20%20%20%20%200%20%20%20%20%20%20%20%26%20%5Cfrac%7Br%2Bl%7D%7Br%2Dl%7D%20%20%26%200%5C%5C%0A%20%20%20%20%20%20%20%200%20%20%20%20%20%20%20%20%26%20%5Cfrac%7B2n%7D%7Bt%2Db%7D%20%26%20%5Cfrac%7Bt%2Bb%7D%7Bt%2Db%7D%20%20%26%200%5C%5C%0A%20%20%20%20%20%20%20%200%20%20%20%20%20%20%20%20%26%20%20%20%20%20%20%20%200%20%20%20%20%20%20%20%26%20%2D%5Cfrac%7Bf%2Bn%7D%7Bf%2Dn%7D%20%26%20%2D%5Cfrac%7B2fn%7D%7Bf%2Dn%7D%5C%5C%0A%20%20%20%20%20%20%20%200%20%20%20%20%20%20%20%20%26%20%20%20%20%20%20%20%200%20%20%20%20%20%20%20%26%20%2D1%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%26%200%5C%5C%0A%20%20%5Cend%7Bbmatrix%7D%0A) + #[inline] + fn compute_projection_matrix(&self, proj: &mut core::Matx44d) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_Camera_computeProjectionMatrix_const_Matx44dR(self.as_raw_Camera(), proj, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } + } - /// Constant methods for [crate::viz::Color] - pub trait ColorTraitConst { - fn as_raw_Color(&self) -> *const c_void; + /// Mutable methods for [crate::viz::Camera] + pub trait CameraTrait: crate::viz::CameraTraitConst { + fn as_raw_mut_Camera(&mut self) -> *mut c_void; #[inline] - fn to_vec3b(&self) -> Result { + fn set_clip(&mut self, clip: core::Vec2d) -> Result<()> { return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Color_operator_cv_Vec3b_const(self.as_raw_Color(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_viz_Camera_setClip_const_Vec2dR(self.as_raw_mut_Camera(), &clip, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn set_window_size(&mut self, window_size: core::Size) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_Camera_setWindowSize_const_SizeR(self.as_raw_mut_Camera(), &window_size, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + #[inline] + fn set_fov(&mut self, fov: core::Vec2d) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_Camera_setFov_const_Vec2dR(self.as_raw_mut_Camera(), &fov, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -938,12 +905,24 @@ pub mod viz { } - /// Mutable methods for [crate::viz::Color] - pub trait ColorTrait: crate::viz::ColorTraitConst { - fn as_raw_mut_Color(&mut self) -> *mut c_void; + impl std::fmt::Debug for Camera { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Camera") + .finish() + } + } + + impl crate::viz::CameraTraitConst for Camera { + #[inline] fn as_raw_Camera(&self) -> *const c_void { self.as_raw() } + } + impl crate::viz::CameraTrait for Camera { + #[inline] fn as_raw_mut_Camera(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { Camera, crate::viz::CameraTraitConst, as_raw_Camera, crate::viz::CameraTrait, as_raw_mut_Camera } + /// This class represents color in BGR order. pub struct Color { ptr: *mut c_void, @@ -960,16 +939,6 @@ pub mod viz { unsafe impl Send for Color {} - impl crate::viz::ColorTraitConst for Color { - #[inline] fn as_raw_Color(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::ColorTrait for Color { - #[inline] fn as_raw_mut_Color(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { Color, crate::viz::ColorTraitConst, as_raw_Color, crate::viz::ColorTrait, as_raw_mut_Color } - impl Color { /// /////////////////////////////////////////////////////////////////////////////////////////////////// /// cv::viz::Color @@ -1366,6 +1335,27 @@ pub mod viz { } + /// Constant methods for [crate::viz::Color] + pub trait ColorTraitConst { + fn as_raw_Color(&self) -> *const c_void; + + #[inline] + fn to_vec3b(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_Color_operator_cv_Vec3b_const(self.as_raw_Color(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + } + + /// Mutable methods for [crate::viz::Color] + pub trait ColorTrait: crate::viz::ColorTraitConst { + fn as_raw_mut_Color(&mut self) -> *mut c_void; + + } + impl std::fmt::Debug for Color { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -1374,10 +1364,57 @@ pub mod viz { } } - /// Constant methods for [crate::viz::KeyboardEvent] - pub trait KeyboardEventTraitConst { - fn as_raw_KeyboardEvent(&self) -> *const c_void; - + impl crate::viz::ColorTraitConst for Color { + #[inline] fn as_raw_Color(&self) -> *const c_void { self.as_raw() } + } + + impl crate::viz::ColorTrait for Color { + #[inline] fn as_raw_mut_Color(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { Color, crate::viz::ColorTraitConst, as_raw_Color, crate::viz::ColorTrait, as_raw_mut_Color } + + /// This class represents a keyboard event. + pub struct KeyboardEvent { + ptr: *mut c_void, + } + + opencv_type_boxed! { KeyboardEvent } + + impl Drop for KeyboardEvent { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_viz_KeyboardEvent_delete(self.as_raw_mut_KeyboardEvent()) }; + } + } + + unsafe impl Send for KeyboardEvent {} + + impl KeyboardEvent { + /// Constructs a KeyboardEvent. + /// + /// ## Parameters + /// * action: Signals if key is pressed or released. + /// * symbol: Name of the key. + /// * code: Code of the key. + /// * modifiers: Signals if alt, ctrl or shift are pressed or their combination. + #[inline] + pub fn new(action: crate::viz::KeyboardEvent_Action, symbol: &str, code: u8, modifiers: i32) -> Result { + extern_container_arg!(symbol); + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_KeyboardEvent_KeyboardEvent_Action_const_StringR_unsigned_char_int(action, symbol.opencv_as_extern(), code, modifiers, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::viz::KeyboardEvent::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::viz::KeyboardEvent] + pub trait KeyboardEventTraitConst { + fn as_raw_KeyboardEvent(&self) -> *const c_void; + #[inline] fn action(&self) -> crate::viz::KeyboardEvent_Action { return_send!(via ocvrs_return); @@ -1438,22 +1475,18 @@ pub mod viz { } - /// This class represents a keyboard event. - pub struct KeyboardEvent { - ptr: *mut c_void, - } - - opencv_type_boxed! { KeyboardEvent } - - impl Drop for KeyboardEvent { + impl std::fmt::Debug for KeyboardEvent { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_KeyboardEvent_delete(self.as_raw_mut_KeyboardEvent()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("KeyboardEvent") + .field("action", &crate::viz::KeyboardEventTraitConst::action(self)) + .field("symbol", &crate::viz::KeyboardEventTraitConst::symbol(self)) + .field("code", &crate::viz::KeyboardEventTraitConst::code(self)) + .field("modifiers", &crate::viz::KeyboardEventTraitConst::modifiers(self)) + .finish() } } - unsafe impl Send for KeyboardEvent {} - impl crate::viz::KeyboardEventTraitConst for KeyboardEvent { #[inline] fn as_raw_KeyboardEvent(&self) -> *const c_void { self.as_raw() } } @@ -1464,37 +1497,80 @@ pub mod viz { boxed_ref! { KeyboardEvent, crate::viz::KeyboardEventTraitConst, as_raw_KeyboardEvent, crate::viz::KeyboardEventTrait, as_raw_mut_KeyboardEvent } - impl KeyboardEvent { - /// Constructs a KeyboardEvent. + /// This class wraps mesh attributes, and it can load a mesh from a ply file. : + pub struct Mesh { + ptr: *mut c_void, + } + + opencv_type_boxed! { Mesh } + + impl Drop for Mesh { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_viz_Mesh_delete(self.as_raw_mut_Mesh()) }; + } + } + + unsafe impl Send for Mesh {} + + impl Mesh { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_Mesh_Mesh(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::viz::Mesh::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Loads a mesh from a ply or a obj file. /// /// ## Parameters - /// * action: Signals if key is pressed or released. - /// * symbol: Name of the key. - /// * code: Code of the key. - /// * modifiers: Signals if alt, ctrl or shift are pressed or their combination. + /// * file: File name + /// * type: File type (for now only PLY and OBJ are supported) + /// + /// **File type** can be one of the following: + /// * **LOAD_PLY** + /// * **LOAD_OBJ** + /// + /// ## C++ default parameters + /// * typ: LOAD_PLY #[inline] - pub fn new(action: crate::viz::KeyboardEvent_Action, symbol: &str, code: u8, modifiers: i32) -> Result { - extern_container_arg!(symbol); + pub fn load(file: &str, typ: i32) -> Result { + extern_container_arg!(file); return_send!(via ocvrs_return); - unsafe { sys::cv_viz_KeyboardEvent_KeyboardEvent_Action_const_StringR_unsigned_char_int(action, symbol.opencv_as_extern(), code, modifiers, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_viz_Mesh_load_const_StringR_int(file.opencv_as_extern(), typ, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::viz::KeyboardEvent::opencv_from_extern(ret) }; + let ret = unsafe { crate::viz::Mesh::opencv_from_extern(ret) }; Ok(ret) } - } - - impl std::fmt::Debug for KeyboardEvent { + /// Loads a mesh from a ply or a obj file. + /// + /// ## Parameters + /// * file: File name + /// * type: File type (for now only PLY and OBJ are supported) + /// + /// **File type** can be one of the following: + /// * **LOAD_PLY** + /// * **LOAD_OBJ** + /// + /// ## Note + /// This alternative version of [Mesh::load] function uses the following default values for its arguments: + /// * typ: LOAD_PLY #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("KeyboardEvent") - .field("action", &crate::viz::KeyboardEventTraitConst::action(self)) - .field("symbol", &crate::viz::KeyboardEventTraitConst::symbol(self)) - .field("code", &crate::viz::KeyboardEventTraitConst::code(self)) - .field("modifiers", &crate::viz::KeyboardEventTraitConst::modifiers(self)) - .finish() + pub fn load_def(file: &str) -> Result { + extern_container_arg!(file); + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_Mesh_load_const_StringR(file.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::viz::Mesh::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::viz::Mesh] @@ -1597,22 +1673,27 @@ pub mod viz { } - /// This class wraps mesh attributes, and it can load a mesh from a ply file. : - pub struct Mesh { - ptr: *mut c_void, + impl Clone for Mesh { + #[inline] + fn clone(&self) -> Self { + unsafe { Self::from_raw(sys::cv_viz_Mesh_implicitClone_const(self.as_raw_Mesh())) } + } } - opencv_type_boxed! { Mesh } - - impl Drop for Mesh { + impl std::fmt::Debug for Mesh { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_Mesh_delete(self.as_raw_mut_Mesh()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Mesh") + .field("cloud", &crate::viz::MeshTraitConst::cloud(self)) + .field("colors", &crate::viz::MeshTraitConst::colors(self)) + .field("normals", &crate::viz::MeshTraitConst::normals(self)) + .field("polygons", &crate::viz::MeshTraitConst::polygons(self)) + .field("texture", &crate::viz::MeshTraitConst::texture(self)) + .field("tcoords", &crate::viz::MeshTraitConst::tcoords(self)) + .finish() } } - unsafe impl Send for Mesh {} - impl crate::viz::MeshTraitConst for Mesh { #[inline] fn as_raw_Mesh(&self) -> *const c_void { self.as_raw() } } @@ -1623,97 +1704,54 @@ pub mod viz { boxed_ref! { Mesh, crate::viz::MeshTraitConst, as_raw_Mesh, crate::viz::MeshTrait, as_raw_mut_Mesh } - impl Mesh { + /// This class represents a mouse event. + pub struct MouseEvent { + ptr: *mut c_void, + } + + opencv_type_boxed! { MouseEvent } + + impl Drop for MouseEvent { #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Mesh_Mesh(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::viz::Mesh::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_viz_MouseEvent_delete(self.as_raw_mut_MouseEvent()) }; } + } - /// Loads a mesh from a ply or a obj file. + unsafe impl Send for MouseEvent {} + + impl MouseEvent { + /// Constructs a MouseEvent. /// /// ## Parameters - /// * file: File name - /// * type: File type (for now only PLY and OBJ are supported) - /// - /// **File type** can be one of the following: - /// * **LOAD_PLY** - /// * **LOAD_OBJ** - /// - /// ## C++ default parameters - /// * typ: LOAD_PLY + /// * type: Type of the event. This can be **MouseMove**, **MouseButtonPress**, + /// **MouseButtonRelease**, **MouseScrollDown**, **MouseScrollUp**, **MouseDblClick**. + /// * button: Mouse button. This can be **NoButton**, **LeftButton**, **MiddleButton**, + /// **RightButton**, **VScroll**. + /// * pointer: Position of the event. + /// * modifiers: Signals if alt, ctrl or shift are pressed or their combination. #[inline] - pub fn load(file: &str, typ: i32) -> Result { - extern_container_arg!(file); + pub fn new(typ: crate::viz::MouseEvent_Type, button: crate::viz::MouseEvent_MouseButton, pointer: core::Point, modifiers: i32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Mesh_load_const_StringR_int(file.opencv_as_extern(), typ, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_viz_MouseEvent_MouseEvent_const_TypeR_const_MouseButtonR_const_PointR_int(typ, button, &pointer, modifiers, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::viz::Mesh::opencv_from_extern(ret) }; + let ret = unsafe { crate::viz::MouseEvent::opencv_from_extern(ret) }; Ok(ret) } - /// Loads a mesh from a ply or a obj file. - /// - /// ## Parameters - /// * file: File name - /// * type: File type (for now only PLY and OBJ are supported) - /// - /// **File type** can be one of the following: - /// * **LOAD_PLY** - /// * **LOAD_OBJ** - /// - /// ## Note - /// This alternative version of [Mesh::load] function uses the following default values for its arguments: - /// * typ: LOAD_PLY + } + + /// Constant methods for [crate::viz::MouseEvent] + pub trait MouseEventTraitConst { + fn as_raw_MouseEvent(&self) -> *const c_void; + #[inline] - pub fn load_def(file: &str) -> Result { - extern_container_arg!(file); + fn typ(&self) -> crate::viz::MouseEvent_Type { return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Mesh_load_const_StringR(file.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_viz_MouseEvent_propType_const(self.as_raw_MouseEvent(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::viz::Mesh::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl Clone for Mesh { - #[inline] - fn clone(&self) -> Self { - unsafe { Self::from_raw(sys::cv_viz_Mesh_implicitClone_const(self.as_raw_Mesh())) } - } - } - - impl std::fmt::Debug for Mesh { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Mesh") - .field("cloud", &crate::viz::MeshTraitConst::cloud(self)) - .field("colors", &crate::viz::MeshTraitConst::colors(self)) - .field("normals", &crate::viz::MeshTraitConst::normals(self)) - .field("polygons", &crate::viz::MeshTraitConst::polygons(self)) - .field("texture", &crate::viz::MeshTraitConst::texture(self)) - .field("tcoords", &crate::viz::MeshTraitConst::tcoords(self)) - .finish() - } - } - - /// Constant methods for [crate::viz::MouseEvent] - pub trait MouseEventTraitConst { - fn as_raw_MouseEvent(&self) -> *const c_void; - - #[inline] - fn typ(&self) -> crate::viz::MouseEvent_Type { - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_MouseEvent_propType_const(self.as_raw_MouseEvent(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - ret + ret } #[inline] @@ -1770,22 +1808,18 @@ pub mod viz { } - /// This class represents a mouse event. - pub struct MouseEvent { - ptr: *mut c_void, - } - - opencv_type_boxed! { MouseEvent } - - impl Drop for MouseEvent { + impl std::fmt::Debug for MouseEvent { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_MouseEvent_delete(self.as_raw_mut_MouseEvent()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MouseEvent") + .field("typ", &crate::viz::MouseEventTraitConst::typ(self)) + .field("button", &crate::viz::MouseEventTraitConst::button(self)) + .field("pointer", &crate::viz::MouseEventTraitConst::pointer(self)) + .field("modifiers", &crate::viz::MouseEventTraitConst::modifiers(self)) + .finish() } } - unsafe impl Send for MouseEvent {} - impl crate::viz::MouseEventTraitConst for MouseEvent { #[inline] fn as_raw_MouseEvent(&self) -> *const c_void { self.as_raw() } } @@ -1796,38 +1830,69 @@ pub mod viz { boxed_ref! { MouseEvent, crate::viz::MouseEventTraitConst, as_raw_MouseEvent, crate::viz::MouseEventTrait, as_raw_mut_MouseEvent } - impl MouseEvent { - /// Constructs a MouseEvent. + /// The Viz3d class represents a 3D visualizer window. This class is implicitly shared. + pub struct Viz3d { + ptr: *mut c_void, + } + + opencv_type_boxed! { Viz3d } + + impl Drop for Viz3d { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_viz_Viz3d_delete(self.as_raw_mut_Viz3d()) }; + } + } + + unsafe impl Send for Viz3d {} + + impl Viz3d { + /// The constructors. /// /// ## Parameters - /// * type: Type of the event. This can be **MouseMove**, **MouseButtonPress**, - /// **MouseButtonRelease**, **MouseScrollDown**, **MouseScrollUp**, **MouseDblClick**. - /// * button: Mouse button. This can be **NoButton**, **LeftButton**, **MiddleButton**, - /// **RightButton**, **VScroll**. - /// * pointer: Position of the event. - /// * modifiers: Signals if alt, ctrl or shift are pressed or their combination. + /// * window_name: Name of the window. + /// + /// ## C++ default parameters + /// * window_name: String() #[inline] - pub fn new(typ: crate::viz::MouseEvent_Type, button: crate::viz::MouseEvent_MouseButton, pointer: core::Point, modifiers: i32) -> Result { + pub fn new(window_name: &str) -> Result { + extern_container_arg!(window_name); return_send!(via ocvrs_return); - unsafe { sys::cv_viz_MouseEvent_MouseEvent_const_TypeR_const_MouseButtonR_const_PointR_int(typ, button, &pointer, modifiers, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_viz_Viz3d_Viz3d_const_StringR(window_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::viz::MouseEvent::opencv_from_extern(ret) }; + let ret = unsafe { crate::viz::Viz3d::opencv_from_extern(ret) }; Ok(ret) } - } + /// The constructors. + /// + /// ## Parameters + /// * window_name: Name of the window. + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * window_name: String() + #[inline] + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_Viz3d_Viz3d(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::viz::Viz3d::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for MouseEvent { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MouseEvent") - .field("typ", &crate::viz::MouseEventTraitConst::typ(self)) - .field("button", &crate::viz::MouseEventTraitConst::button(self)) - .field("pointer", &crate::viz::MouseEventTraitConst::pointer(self)) - .field("modifiers", &crate::viz::MouseEventTraitConst::modifiers(self)) - .finish() + pub fn copy(unnamed: &impl crate::viz::Viz3dTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_Viz3d_Viz3d_const_Viz3dR(unnamed.as_raw_Viz3d(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::viz::Viz3d::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::viz::Viz3d] @@ -2557,22 +2622,14 @@ pub mod viz { } - /// The Viz3d class represents a 3D visualizer window. This class is implicitly shared. - pub struct Viz3d { - ptr: *mut c_void, - } - - opencv_type_boxed! { Viz3d } - - impl Drop for Viz3d { + impl std::fmt::Debug for Viz3d { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_Viz3d_delete(self.as_raw_mut_Viz3d()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Viz3d") + .finish() } } - unsafe impl Send for Viz3d {} - impl crate::viz::Viz3dTraitConst for Viz3d { #[inline] fn as_raw_Viz3d(&self) -> *const c_void { self.as_raw() } } @@ -2583,75 +2640,6 @@ pub mod viz { boxed_ref! { Viz3d, crate::viz::Viz3dTraitConst, as_raw_Viz3d, crate::viz::Viz3dTrait, as_raw_mut_Viz3d } - impl Viz3d { - /// The constructors. - /// - /// ## Parameters - /// * window_name: Name of the window. - /// - /// ## C++ default parameters - /// * window_name: String() - #[inline] - pub fn new(window_name: &str) -> Result { - extern_container_arg!(window_name); - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Viz3d_Viz3d_const_StringR(window_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::viz::Viz3d::opencv_from_extern(ret) }; - Ok(ret) - } - - /// The constructors. - /// - /// ## Parameters - /// * window_name: Name of the window. - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * window_name: String() - #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Viz3d_Viz3d(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::viz::Viz3d::opencv_from_extern(ret) }; - Ok(ret) - } - - #[inline] - pub fn copy(unnamed: &impl crate::viz::Viz3dTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Viz3d_Viz3d_const_Viz3dR(unnamed.as_raw_Viz3d(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::viz::Viz3d::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for Viz3d { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Viz3d") - .finish() - } - } - - /// Constant methods for [crate::viz::WArrow] - pub trait WArrowTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WArrow(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::viz::WArrow] - pub trait WArrowTrait: crate::viz::WArrowTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WArrow(&mut self) -> *mut c_void; - - } - /// This 3D Widget defines an arrow. pub struct WArrow { ptr: *mut c_void, @@ -2668,36 +2656,6 @@ pub mod viz { unsafe impl Send for WArrow {} - impl crate::viz::WidgetTraitConst for WArrow { - #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::WidgetTrait for WArrow { - #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WArrow, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - - impl crate::viz::Widget3DTraitConst for WArrow { - #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::Widget3DTrait for WArrow { - #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WArrow, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } - - impl crate::viz::WArrowTraitConst for WArrow { - #[inline] fn as_raw_WArrow(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::WArrowTrait for WArrow { - #[inline] fn as_raw_mut_WArrow(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WArrow, crate::viz::WArrowTraitConst, as_raw_WArrow, crate::viz::WArrowTrait, as_raw_mut_WArrow } - impl WArrow { /// Constructs an WArrow. /// @@ -2750,9 +2708,17 @@ pub mod viz { } - boxed_cast_base! { WArrow, crate::viz::Widget, cv_viz_WArrow_to_Widget } + /// Constant methods for [crate::viz::WArrow] + pub trait WArrowTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WArrow(&self) -> *const c_void; - boxed_cast_base! { WArrow, crate::viz::Widget3D, cv_viz_WArrow_to_Widget3D } + } + + /// Mutable methods for [crate::viz::WArrow] + pub trait WArrowTrait: crate::viz::WArrowTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WArrow(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for WArrow { #[inline] @@ -2762,63 +2728,55 @@ pub mod viz { } } - /// Constant methods for [crate::viz::WCameraPosition] - pub trait WCameraPositionTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WCameraPosition(&self) -> *const c_void; + boxed_cast_base! { WArrow, crate::viz::Widget, cv_viz_WArrow_to_Widget } - } + boxed_cast_base! { WArrow, crate::viz::Widget3D, cv_viz_WArrow_to_Widget3D } - /// Mutable methods for [crate::viz::WCameraPosition] - pub trait WCameraPositionTrait: crate::viz::WCameraPositionTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WCameraPosition(&mut self) -> *mut c_void; - - } - - /// This 3D Widget represents camera position in a scene by its axes or viewing frustum. : - pub struct WCameraPosition { - ptr: *mut c_void, + impl crate::viz::WidgetTraitConst for WArrow { + #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } - opencv_type_boxed! { WCameraPosition } - - impl Drop for WCameraPosition { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_WCameraPosition_delete(self.as_raw_mut_WCameraPosition()) }; - } + impl crate::viz::WidgetTrait for WArrow { + #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } } - unsafe impl Send for WCameraPosition {} + boxed_ref! { WArrow, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - impl crate::viz::WidgetTraitConst for WCameraPosition { - #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } + impl crate::viz::Widget3DTraitConst for WArrow { + #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::WidgetTrait for WCameraPosition { - #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::Widget3DTrait for WArrow { + #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WCameraPosition, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + boxed_ref! { WArrow, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } - impl crate::viz::Widget3DTraitConst for WCameraPosition { - #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + impl crate::viz::WArrowTraitConst for WArrow { + #[inline] fn as_raw_WArrow(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::Widget3DTrait for WCameraPosition { - #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::WArrowTrait for WArrow { + #[inline] fn as_raw_mut_WArrow(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WCameraPosition, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + boxed_ref! { WArrow, crate::viz::WArrowTraitConst, as_raw_WArrow, crate::viz::WArrowTrait, as_raw_mut_WArrow } - impl crate::viz::WCameraPositionTraitConst for WCameraPosition { - #[inline] fn as_raw_WCameraPosition(&self) -> *const c_void { self.as_raw() } + /// This 3D Widget represents camera position in a scene by its axes or viewing frustum. : + pub struct WCameraPosition { + ptr: *mut c_void, } - impl crate::viz::WCameraPositionTrait for WCameraPosition { - #[inline] fn as_raw_mut_WCameraPosition(&mut self) -> *mut c_void { self.as_raw_mut() } + opencv_type_boxed! { WCameraPosition } + + impl Drop for WCameraPosition { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_viz_WCameraPosition_delete(self.as_raw_mut_WCameraPosition()) }; + } } - boxed_ref! { WCameraPosition, crate::viz::WCameraPositionTraitConst, as_raw_WCameraPosition, crate::viz::WCameraPositionTrait, as_raw_mut_WCameraPosition } + unsafe impl Send for WCameraPosition {} impl WCameraPosition { /// Creates camera coordinate frame at the origin. @@ -3060,9 +3018,17 @@ pub mod viz { } - boxed_cast_base! { WCameraPosition, crate::viz::Widget, cv_viz_WCameraPosition_to_Widget } + /// Constant methods for [crate::viz::WCameraPosition] + pub trait WCameraPositionTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WCameraPosition(&self) -> *const c_void; - boxed_cast_base! { WCameraPosition, crate::viz::Widget3D, cv_viz_WCameraPosition_to_Widget3D } + } + + /// Mutable methods for [crate::viz::WCameraPosition] + pub trait WCameraPositionTrait: crate::viz::WCameraPositionTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WCameraPosition(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for WCameraPosition { #[inline] @@ -3072,63 +3038,55 @@ pub mod viz { } } - /// Constant methods for [crate::viz::WCircle] - pub trait WCircleTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WCircle(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::viz::WCircle] - pub trait WCircleTrait: crate::viz::WCircleTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WCircle(&mut self) -> *mut c_void; + boxed_cast_base! { WCameraPosition, crate::viz::Widget, cv_viz_WCameraPosition_to_Widget } - } + boxed_cast_base! { WCameraPosition, crate::viz::Widget3D, cv_viz_WCameraPosition_to_Widget3D } - /// This 3D Widget defines a circle. - pub struct WCircle { - ptr: *mut c_void, + impl crate::viz::WidgetTraitConst for WCameraPosition { + #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } - opencv_type_boxed! { WCircle } - - impl Drop for WCircle { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_WCircle_delete(self.as_raw_mut_WCircle()) }; - } + impl crate::viz::WidgetTrait for WCameraPosition { + #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } } - unsafe impl Send for WCircle {} + boxed_ref! { WCameraPosition, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - impl crate::viz::WidgetTraitConst for WCircle { - #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } + impl crate::viz::Widget3DTraitConst for WCameraPosition { + #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::WidgetTrait for WCircle { - #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::Widget3DTrait for WCameraPosition { + #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WCircle, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + boxed_ref! { WCameraPosition, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } - impl crate::viz::Widget3DTraitConst for WCircle { - #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + impl crate::viz::WCameraPositionTraitConst for WCameraPosition { + #[inline] fn as_raw_WCameraPosition(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::Widget3DTrait for WCircle { - #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::WCameraPositionTrait for WCameraPosition { + #[inline] fn as_raw_mut_WCameraPosition(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WCircle, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + boxed_ref! { WCameraPosition, crate::viz::WCameraPositionTraitConst, as_raw_WCameraPosition, crate::viz::WCameraPositionTrait, as_raw_mut_WCameraPosition } - impl crate::viz::WCircleTraitConst for WCircle { - #[inline] fn as_raw_WCircle(&self) -> *const c_void { self.as_raw() } + /// This 3D Widget defines a circle. + pub struct WCircle { + ptr: *mut c_void, } - impl crate::viz::WCircleTrait for WCircle { - #[inline] fn as_raw_mut_WCircle(&mut self) -> *mut c_void { self.as_raw_mut() } + opencv_type_boxed! { WCircle } + + impl Drop for WCircle { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_viz_WCircle_delete(self.as_raw_mut_WCircle()) }; + } } - boxed_ref! { WCircle, crate::viz::WCircleTraitConst, as_raw_WCircle, crate::viz::WCircleTrait, as_raw_mut_WCircle } + unsafe impl Send for WCircle {} impl WCircle { /// Constructs default planar circle centered at origin with plane normal along z-axis @@ -3219,9 +3177,17 @@ pub mod viz { } - boxed_cast_base! { WCircle, crate::viz::Widget, cv_viz_WCircle_to_Widget } + /// Constant methods for [crate::viz::WCircle] + pub trait WCircleTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WCircle(&self) -> *const c_void; - boxed_cast_base! { WCircle, crate::viz::Widget3D, cv_viz_WCircle_to_Widget3D } + } + + /// Mutable methods for [crate::viz::WCircle] + pub trait WCircleTrait: crate::viz::WCircleTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WCircle(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for WCircle { #[inline] @@ -3231,18 +3197,40 @@ pub mod viz { } } - /// Constant methods for [crate::viz::WCloud] - pub trait WCloudTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WCloud(&self) -> *const c_void; + boxed_cast_base! { WCircle, crate::viz::Widget, cv_viz_WCircle_to_Widget } + + boxed_cast_base! { WCircle, crate::viz::Widget3D, cv_viz_WCircle_to_Widget3D } + impl crate::viz::WidgetTraitConst for WCircle { + #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::viz::WCloud] - pub trait WCloudTrait: crate::viz::WCloudTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WCloud(&mut self) -> *mut c_void; + impl crate::viz::WidgetTrait for WCircle { + #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } + } + boxed_ref! { WCircle, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + + impl crate::viz::Widget3DTraitConst for WCircle { + #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + } + + impl crate::viz::Widget3DTrait for WCircle { + #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { WCircle, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + + impl crate::viz::WCircleTraitConst for WCircle { + #[inline] fn as_raw_WCircle(&self) -> *const c_void { self.as_raw() } + } + + impl crate::viz::WCircleTrait for WCircle { + #[inline] fn as_raw_mut_WCircle(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { WCircle, crate::viz::WCircleTraitConst, as_raw_WCircle, crate::viz::WCircleTrait, as_raw_mut_WCircle } + /// This 3D Widget defines a point cloud. : /// /// @@ -3262,36 +3250,6 @@ pub mod viz { unsafe impl Send for WCloud {} - impl crate::viz::WidgetTraitConst for WCloud { - #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::WidgetTrait for WCloud { - #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WCloud, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - - impl crate::viz::Widget3DTraitConst for WCloud { - #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::Widget3DTrait for WCloud { - #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WCloud, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } - - impl crate::viz::WCloudTraitConst for WCloud { - #[inline] fn as_raw_WCloud(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::WCloudTrait for WCloud { - #[inline] fn as_raw_mut_WCloud(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WCloud, crate::viz::WCloudTraitConst, as_raw_WCloud, crate::viz::WCloudTrait, as_raw_mut_WCloud } - impl WCloud { /// Constructs a WCloud. /// @@ -3395,9 +3353,17 @@ pub mod viz { } - boxed_cast_base! { WCloud, crate::viz::Widget, cv_viz_WCloud_to_Widget } + /// Constant methods for [crate::viz::WCloud] + pub trait WCloudTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WCloud(&self) -> *const c_void; - boxed_cast_base! { WCloud, crate::viz::Widget3D, cv_viz_WCloud_to_Widget3D } + } + + /// Mutable methods for [crate::viz::WCloud] + pub trait WCloudTrait: crate::viz::WCloudTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WCloud(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for WCloud { #[inline] @@ -3407,35 +3373,100 @@ pub mod viz { } } - /// Constant methods for [crate::viz::WCloudCollection] - pub trait WCloudCollectionTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WCloudCollection(&self) -> *const c_void; + boxed_cast_base! { WCloud, crate::viz::Widget, cv_viz_WCloud_to_Widget } + + boxed_cast_base! { WCloud, crate::viz::Widget3D, cv_viz_WCloud_to_Widget3D } + impl crate::viz::WidgetTraitConst for WCloud { + #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::viz::WCloudCollection] - pub trait WCloudCollectionTrait: crate::viz::WCloudCollectionTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WCloudCollection(&mut self) -> *mut c_void; + impl crate::viz::WidgetTrait for WCloud { + #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } + } - /// Adds a cloud to the collection. - /// - /// ## Parameters - /// * cloud: Point set which can be of type: CV_32FC3, CV_32FC4, CV_64FC3, CV_64FC4. - /// * colors: Set of colors. It has to be of the same size with cloud. - /// * pose: Pose of the cloud. Points in the cloud belong to mask when they are set to (NaN, NaN, NaN). - /// - /// ## C++ default parameters - /// * pose: Affine3d::Identity() - #[inline] - fn add_cloud(&mut self, cloud: &impl ToInputArray, colors: &impl ToInputArray, pose: core::Affine3d) -> Result<()> { - input_array_arg!(cloud); - input_array_arg!(colors); - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_WCloudCollection_addCloud_const__InputArrayR_const__InputArrayR_const_Affine3dR(self.as_raw_mut_WCloudCollection(), cloud.as_raw__InputArray(), colors.as_raw__InputArray(), &pose, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } + boxed_ref! { WCloud, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + + impl crate::viz::Widget3DTraitConst for WCloud { + #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + } + + impl crate::viz::Widget3DTrait for WCloud { + #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { WCloud, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + + impl crate::viz::WCloudTraitConst for WCloud { + #[inline] fn as_raw_WCloud(&self) -> *const c_void { self.as_raw() } + } + + impl crate::viz::WCloudTrait for WCloud { + #[inline] fn as_raw_mut_WCloud(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { WCloud, crate::viz::WCloudTraitConst, as_raw_WCloud, crate::viz::WCloudTrait, as_raw_mut_WCloud } + + /// This 3D Widget defines a collection of clouds. : + /// + /// Note: In case there are four channels in the cloud, fourth channel is ignored. + pub struct WCloudCollection { + ptr: *mut c_void, + } + + opencv_type_boxed! { WCloudCollection } + + impl Drop for WCloudCollection { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_viz_WCloudCollection_delete(self.as_raw_mut_WCloudCollection()) }; + } + } + + unsafe impl Send for WCloudCollection {} + + impl WCloudCollection { + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_WCloudCollection_WCloudCollection(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::viz::WCloudCollection::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::viz::WCloudCollection] + pub trait WCloudCollectionTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WCloudCollection(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::viz::WCloudCollection] + pub trait WCloudCollectionTrait: crate::viz::WCloudCollectionTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WCloudCollection(&mut self) -> *mut c_void; + + /// Adds a cloud to the collection. + /// + /// ## Parameters + /// * cloud: Point set which can be of type: CV_32FC3, CV_32FC4, CV_64FC3, CV_64FC4. + /// * colors: Set of colors. It has to be of the same size with cloud. + /// * pose: Pose of the cloud. Points in the cloud belong to mask when they are set to (NaN, NaN, NaN). + /// + /// ## C++ default parameters + /// * pose: Affine3d::Identity() + #[inline] + fn add_cloud(&mut self, cloud: &impl ToInputArray, colors: &impl ToInputArray, pose: core::Affine3d) -> Result<()> { + input_array_arg!(cloud); + input_array_arg!(colors); + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_WCloudCollection_addCloud_const__InputArrayR_const__InputArrayR_const_Affine3dR(self.as_raw_mut_WCloudCollection(), cloud.as_raw__InputArray(), colors.as_raw__InputArray(), &pose, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } /// Adds a cloud to the collection. /// @@ -3513,23 +3544,17 @@ pub mod viz { } - /// This 3D Widget defines a collection of clouds. : - /// - /// Note: In case there are four channels in the cloud, fourth channel is ignored. - pub struct WCloudCollection { - ptr: *mut c_void, - } - - opencv_type_boxed! { WCloudCollection } - - impl Drop for WCloudCollection { + impl std::fmt::Debug for WCloudCollection { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_WCloudCollection_delete(self.as_raw_mut_WCloudCollection()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("WCloudCollection") + .finish() } } - unsafe impl Send for WCloudCollection {} + boxed_cast_base! { WCloudCollection, crate::viz::Widget, cv_viz_WCloudCollection_to_Widget } + + boxed_cast_base! { WCloudCollection, crate::viz::Widget3D, cv_viz_WCloudCollection_to_Widget3D } impl crate::viz::WidgetTraitConst for WCloudCollection { #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } @@ -3561,43 +3586,6 @@ pub mod viz { boxed_ref! { WCloudCollection, crate::viz::WCloudCollectionTraitConst, as_raw_WCloudCollection, crate::viz::WCloudCollectionTrait, as_raw_mut_WCloudCollection } - impl WCloudCollection { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_WCloudCollection_WCloudCollection(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::viz::WCloudCollection::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { WCloudCollection, crate::viz::Widget, cv_viz_WCloudCollection_to_Widget } - - boxed_cast_base! { WCloudCollection, crate::viz::Widget3D, cv_viz_WCloudCollection_to_Widget3D } - - impl std::fmt::Debug for WCloudCollection { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("WCloudCollection") - .finish() - } - } - - /// Constant methods for [crate::viz::WCloudNormals] - pub trait WCloudNormalsTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WCloudNormals(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::viz::WCloudNormals] - pub trait WCloudNormalsTrait: crate::viz::WCloudNormalsTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WCloudNormals(&mut self) -> *mut c_void; - - } - /// This 3D Widget represents normals of a point cloud. : pub struct WCloudNormals { ptr: *mut c_void, @@ -3614,36 +3602,6 @@ pub mod viz { unsafe impl Send for WCloudNormals {} - impl crate::viz::WidgetTraitConst for WCloudNormals { - #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::WidgetTrait for WCloudNormals { - #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WCloudNormals, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - - impl crate::viz::Widget3DTraitConst for WCloudNormals { - #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::Widget3DTrait for WCloudNormals { - #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WCloudNormals, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } - - impl crate::viz::WCloudNormalsTraitConst for WCloudNormals { - #[inline] fn as_raw_WCloudNormals(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::WCloudNormalsTrait for WCloudNormals { - #[inline] fn as_raw_mut_WCloudNormals(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WCloudNormals, crate::viz::WCloudNormalsTraitConst, as_raw_WCloudNormals, crate::viz::WCloudNormalsTrait, as_raw_mut_WCloudNormals } - impl WCloudNormals { /// Constructs a WCloudNormals. /// @@ -3704,9 +3662,17 @@ pub mod viz { } - boxed_cast_base! { WCloudNormals, crate::viz::Widget, cv_viz_WCloudNormals_to_Widget } + /// Constant methods for [crate::viz::WCloudNormals] + pub trait WCloudNormalsTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WCloudNormals(&self) -> *const c_void; - boxed_cast_base! { WCloudNormals, crate::viz::Widget3D, cv_viz_WCloudNormals_to_Widget3D } + } + + /// Mutable methods for [crate::viz::WCloudNormals] + pub trait WCloudNormalsTrait: crate::viz::WCloudNormalsTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WCloudNormals(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for WCloudNormals { #[inline] @@ -3716,63 +3682,55 @@ pub mod viz { } } - /// Constant methods for [crate::viz::WCone] - pub trait WConeTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WCone(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::viz::WCone] - pub trait WConeTrait: crate::viz::WConeTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WCone(&mut self) -> *mut c_void; + boxed_cast_base! { WCloudNormals, crate::viz::Widget, cv_viz_WCloudNormals_to_Widget } - } + boxed_cast_base! { WCloudNormals, crate::viz::Widget3D, cv_viz_WCloudNormals_to_Widget3D } - /// This 3D Widget defines a cone. : - pub struct WCone { - ptr: *mut c_void, + impl crate::viz::WidgetTraitConst for WCloudNormals { + #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } - opencv_type_boxed! { WCone } - - impl Drop for WCone { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_WCone_delete(self.as_raw_mut_WCone()) }; - } + impl crate::viz::WidgetTrait for WCloudNormals { + #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } } - unsafe impl Send for WCone {} + boxed_ref! { WCloudNormals, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - impl crate::viz::WidgetTraitConst for WCone { - #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } + impl crate::viz::Widget3DTraitConst for WCloudNormals { + #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::WidgetTrait for WCone { - #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::Widget3DTrait for WCloudNormals { + #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WCone, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + boxed_ref! { WCloudNormals, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } - impl crate::viz::Widget3DTraitConst for WCone { - #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + impl crate::viz::WCloudNormalsTraitConst for WCloudNormals { + #[inline] fn as_raw_WCloudNormals(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::Widget3DTrait for WCone { - #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::WCloudNormalsTrait for WCloudNormals { + #[inline] fn as_raw_mut_WCloudNormals(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WCone, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + boxed_ref! { WCloudNormals, crate::viz::WCloudNormalsTraitConst, as_raw_WCloudNormals, crate::viz::WCloudNormalsTrait, as_raw_mut_WCloudNormals } - impl crate::viz::WConeTraitConst for WCone { - #[inline] fn as_raw_WCone(&self) -> *const c_void { self.as_raw() } + /// This 3D Widget defines a cone. : + pub struct WCone { + ptr: *mut c_void, } - impl crate::viz::WConeTrait for WCone { - #[inline] fn as_raw_mut_WCone(&mut self) -> *mut c_void { self.as_raw_mut() } + opencv_type_boxed! { WCone } + + impl Drop for WCone { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_viz_WCone_delete(self.as_raw_mut_WCone()) }; + } } - boxed_ref! { WCone, crate::viz::WConeTraitConst, as_raw_WCone, crate::viz::WConeTrait, as_raw_mut_WCone } + unsafe impl Send for WCone {} impl WCone { /// Constructs default cone oriented along x-axis with center of its base located at origin @@ -3865,9 +3823,17 @@ pub mod viz { } - boxed_cast_base! { WCone, crate::viz::Widget, cv_viz_WCone_to_Widget } + /// Constant methods for [crate::viz::WCone] + pub trait WConeTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WCone(&self) -> *const c_void; - boxed_cast_base! { WCone, crate::viz::Widget3D, cv_viz_WCone_to_Widget3D } + } + + /// Mutable methods for [crate::viz::WCone] + pub trait WConeTrait: crate::viz::WConeTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WCone(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for WCone { #[inline] @@ -3877,63 +3843,55 @@ pub mod viz { } } - /// Constant methods for [crate::viz::WCoordinateSystem] - pub trait WCoordinateSystemTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WCoordinateSystem(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::viz::WCoordinateSystem] - pub trait WCoordinateSystemTrait: crate::viz::WCoordinateSystemTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WCoordinateSystem(&mut self) -> *mut c_void; + boxed_cast_base! { WCone, crate::viz::Widget, cv_viz_WCone_to_Widget } - } + boxed_cast_base! { WCone, crate::viz::Widget3D, cv_viz_WCone_to_Widget3D } - /// This 3D Widget represents a coordinate system. : - pub struct WCoordinateSystem { - ptr: *mut c_void, + impl crate::viz::WidgetTraitConst for WCone { + #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } - opencv_type_boxed! { WCoordinateSystem } - - impl Drop for WCoordinateSystem { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_WCoordinateSystem_delete(self.as_raw_mut_WCoordinateSystem()) }; - } + impl crate::viz::WidgetTrait for WCone { + #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } } - unsafe impl Send for WCoordinateSystem {} + boxed_ref! { WCone, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - impl crate::viz::WidgetTraitConst for WCoordinateSystem { - #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } + impl crate::viz::Widget3DTraitConst for WCone { + #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::WidgetTrait for WCoordinateSystem { - #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::Widget3DTrait for WCone { + #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WCoordinateSystem, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + boxed_ref! { WCone, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } - impl crate::viz::Widget3DTraitConst for WCoordinateSystem { - #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + impl crate::viz::WConeTraitConst for WCone { + #[inline] fn as_raw_WCone(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::Widget3DTrait for WCoordinateSystem { - #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::WConeTrait for WCone { + #[inline] fn as_raw_mut_WCone(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WCoordinateSystem, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + boxed_ref! { WCone, crate::viz::WConeTraitConst, as_raw_WCone, crate::viz::WConeTrait, as_raw_mut_WCone } - impl crate::viz::WCoordinateSystemTraitConst for WCoordinateSystem { - #[inline] fn as_raw_WCoordinateSystem(&self) -> *const c_void { self.as_raw() } + /// This 3D Widget represents a coordinate system. : + pub struct WCoordinateSystem { + ptr: *mut c_void, } - impl crate::viz::WCoordinateSystemTrait for WCoordinateSystem { - #[inline] fn as_raw_mut_WCoordinateSystem(&mut self) -> *mut c_void { self.as_raw_mut() } + opencv_type_boxed! { WCoordinateSystem } + + impl Drop for WCoordinateSystem { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_viz_WCoordinateSystem_delete(self.as_raw_mut_WCoordinateSystem()) }; + } } - boxed_ref! { WCoordinateSystem, crate::viz::WCoordinateSystemTraitConst, as_raw_WCoordinateSystem, crate::viz::WCoordinateSystemTrait, as_raw_mut_WCoordinateSystem } + unsafe impl Send for WCoordinateSystem {} impl WCoordinateSystem { /// Constructs a WCoordinateSystem. @@ -3973,9 +3931,17 @@ pub mod viz { } - boxed_cast_base! { WCoordinateSystem, crate::viz::Widget, cv_viz_WCoordinateSystem_to_Widget } + /// Constant methods for [crate::viz::WCoordinateSystem] + pub trait WCoordinateSystemTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WCoordinateSystem(&self) -> *const c_void; - boxed_cast_base! { WCoordinateSystem, crate::viz::Widget3D, cv_viz_WCoordinateSystem_to_Widget3D } + } + + /// Mutable methods for [crate::viz::WCoordinateSystem] + pub trait WCoordinateSystemTrait: crate::viz::WCoordinateSystemTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WCoordinateSystem(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for WCoordinateSystem { #[inline] @@ -3985,63 +3951,55 @@ pub mod viz { } } - /// Constant methods for [crate::viz::WCube] - pub trait WCubeTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WCube(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::viz::WCube] - pub trait WCubeTrait: crate::viz::WCubeTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WCube(&mut self) -> *mut c_void; + boxed_cast_base! { WCoordinateSystem, crate::viz::Widget, cv_viz_WCoordinateSystem_to_Widget } - } + boxed_cast_base! { WCoordinateSystem, crate::viz::Widget3D, cv_viz_WCoordinateSystem_to_Widget3D } - /// This 3D Widget defines a cube. - pub struct WCube { - ptr: *mut c_void, + impl crate::viz::WidgetTraitConst for WCoordinateSystem { + #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } - opencv_type_boxed! { WCube } - - impl Drop for WCube { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_WCube_delete(self.as_raw_mut_WCube()) }; - } + impl crate::viz::WidgetTrait for WCoordinateSystem { + #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } } - unsafe impl Send for WCube {} + boxed_ref! { WCoordinateSystem, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - impl crate::viz::WidgetTraitConst for WCube { - #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } + impl crate::viz::Widget3DTraitConst for WCoordinateSystem { + #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::WidgetTrait for WCube { - #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::Widget3DTrait for WCoordinateSystem { + #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WCube, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + boxed_ref! { WCoordinateSystem, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } - impl crate::viz::Widget3DTraitConst for WCube { - #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + impl crate::viz::WCoordinateSystemTraitConst for WCoordinateSystem { + #[inline] fn as_raw_WCoordinateSystem(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::Widget3DTrait for WCube { - #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::WCoordinateSystemTrait for WCoordinateSystem { + #[inline] fn as_raw_mut_WCoordinateSystem(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WCube, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + boxed_ref! { WCoordinateSystem, crate::viz::WCoordinateSystemTraitConst, as_raw_WCoordinateSystem, crate::viz::WCoordinateSystemTrait, as_raw_mut_WCoordinateSystem } - impl crate::viz::WCubeTraitConst for WCube { - #[inline] fn as_raw_WCube(&self) -> *const c_void { self.as_raw() } + /// This 3D Widget defines a cube. + pub struct WCube { + ptr: *mut c_void, } - impl crate::viz::WCubeTrait for WCube { - #[inline] fn as_raw_mut_WCube(&mut self) -> *mut c_void { self.as_raw_mut() } + opencv_type_boxed! { WCube } + + impl Drop for WCube { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_viz_WCube_delete(self.as_raw_mut_WCube()) }; + } } - boxed_ref! { WCube, crate::viz::WCubeTraitConst, as_raw_WCube, crate::viz::WCubeTrait, as_raw_mut_WCube } + unsafe impl Send for WCube {} impl WCube { /// Constructs a WCube. @@ -4097,9 +4055,17 @@ pub mod viz { } - boxed_cast_base! { WCube, crate::viz::Widget, cv_viz_WCube_to_Widget } + /// Constant methods for [crate::viz::WCube] + pub trait WCubeTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WCube(&self) -> *const c_void; - boxed_cast_base! { WCube, crate::viz::Widget3D, cv_viz_WCube_to_Widget3D } + } + + /// Mutable methods for [crate::viz::WCube] + pub trait WCubeTrait: crate::viz::WCubeTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WCube(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for WCube { #[inline] @@ -4109,63 +4075,55 @@ pub mod viz { } } - /// Constant methods for [crate::viz::WCylinder] - pub trait WCylinderTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WCylinder(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::viz::WCylinder] - pub trait WCylinderTrait: crate::viz::WCylinderTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WCylinder(&mut self) -> *mut c_void; + boxed_cast_base! { WCube, crate::viz::Widget, cv_viz_WCube_to_Widget } - } + boxed_cast_base! { WCube, crate::viz::Widget3D, cv_viz_WCube_to_Widget3D } - /// This 3D Widget defines a cylinder. : - pub struct WCylinder { - ptr: *mut c_void, + impl crate::viz::WidgetTraitConst for WCube { + #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } - opencv_type_boxed! { WCylinder } - - impl Drop for WCylinder { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_WCylinder_delete(self.as_raw_mut_WCylinder()) }; - } + impl crate::viz::WidgetTrait for WCube { + #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } } - unsafe impl Send for WCylinder {} + boxed_ref! { WCube, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - impl crate::viz::WidgetTraitConst for WCylinder { - #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } + impl crate::viz::Widget3DTraitConst for WCube { + #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::WidgetTrait for WCylinder { - #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::Widget3DTrait for WCube { + #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WCylinder, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + boxed_ref! { WCube, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } - impl crate::viz::Widget3DTraitConst for WCylinder { - #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + impl crate::viz::WCubeTraitConst for WCube { + #[inline] fn as_raw_WCube(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::Widget3DTrait for WCylinder { - #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::WCubeTrait for WCube { + #[inline] fn as_raw_mut_WCube(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WCylinder, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + boxed_ref! { WCube, crate::viz::WCubeTraitConst, as_raw_WCube, crate::viz::WCubeTrait, as_raw_mut_WCube } - impl crate::viz::WCylinderTraitConst for WCylinder { - #[inline] fn as_raw_WCylinder(&self) -> *const c_void { self.as_raw() } + /// This 3D Widget defines a cylinder. : + pub struct WCylinder { + ptr: *mut c_void, } - impl crate::viz::WCylinderTrait for WCylinder { - #[inline] fn as_raw_mut_WCylinder(&mut self) -> *mut c_void { self.as_raw_mut() } + opencv_type_boxed! { WCylinder } + + impl Drop for WCylinder { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_viz_WCylinder_delete(self.as_raw_mut_WCylinder()) }; + } } - boxed_ref! { WCylinder, crate::viz::WCylinderTraitConst, as_raw_WCylinder, crate::viz::WCylinderTrait, as_raw_mut_WCylinder } + unsafe impl Send for WCylinder {} impl WCylinder { /// Constructs a WCylinder. @@ -4215,9 +4173,17 @@ pub mod viz { } - boxed_cast_base! { WCylinder, crate::viz::Widget, cv_viz_WCylinder_to_Widget } + /// Constant methods for [crate::viz::WCylinder] + pub trait WCylinderTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WCylinder(&self) -> *const c_void; - boxed_cast_base! { WCylinder, crate::viz::Widget3D, cv_viz_WCylinder_to_Widget3D } + } + + /// Mutable methods for [crate::viz::WCylinder] + pub trait WCylinderTrait: crate::viz::WCylinderTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WCylinder(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for WCylinder { #[inline] @@ -4227,63 +4193,55 @@ pub mod viz { } } - /// Constant methods for [crate::viz::WGrid] - pub trait WGridTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WGrid(&self) -> *const c_void; - - } + boxed_cast_base! { WCylinder, crate::viz::Widget, cv_viz_WCylinder_to_Widget } - /// Mutable methods for [crate::viz::WGrid] - pub trait WGridTrait: crate::viz::WGridTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WGrid(&mut self) -> *mut c_void; + boxed_cast_base! { WCylinder, crate::viz::Widget3D, cv_viz_WCylinder_to_Widget3D } + impl crate::viz::WidgetTraitConst for WCylinder { + #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } - /// This 3D Widget defines a grid. : - pub struct WGrid { - ptr: *mut c_void, + impl crate::viz::WidgetTrait for WCylinder { + #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } } - opencv_type_boxed! { WGrid } + boxed_ref! { WCylinder, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - impl Drop for WGrid { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_WGrid_delete(self.as_raw_mut_WGrid()) }; - } + impl crate::viz::Widget3DTraitConst for WCylinder { + #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } } - unsafe impl Send for WGrid {} - - impl crate::viz::WidgetTraitConst for WGrid { - #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::WidgetTrait for WGrid { - #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::Widget3DTrait for WCylinder { + #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WGrid, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + boxed_ref! { WCylinder, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } - impl crate::viz::Widget3DTraitConst for WGrid { - #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + impl crate::viz::WCylinderTraitConst for WCylinder { + #[inline] fn as_raw_WCylinder(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::Widget3DTrait for WGrid { - #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::WCylinderTrait for WCylinder { + #[inline] fn as_raw_mut_WCylinder(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WGrid, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + boxed_ref! { WCylinder, crate::viz::WCylinderTraitConst, as_raw_WCylinder, crate::viz::WCylinderTrait, as_raw_mut_WCylinder } - impl crate::viz::WGridTraitConst for WGrid { - #[inline] fn as_raw_WGrid(&self) -> *const c_void { self.as_raw() } + /// This 3D Widget defines a grid. : + pub struct WGrid { + ptr: *mut c_void, } - impl crate::viz::WGridTrait for WGrid { - #[inline] fn as_raw_mut_WGrid(&mut self) -> *mut c_void { self.as_raw_mut() } + opencv_type_boxed! { WGrid } + + impl Drop for WGrid { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_viz_WGrid_delete(self.as_raw_mut_WGrid()) }; + } } - boxed_ref! { WGrid, crate::viz::WGridTraitConst, as_raw_WGrid, crate::viz::WGridTrait, as_raw_mut_WGrid } + unsafe impl Send for WGrid {} impl WGrid { /// Constructs a WGrid. @@ -4364,9 +4322,17 @@ pub mod viz { } - boxed_cast_base! { WGrid, crate::viz::Widget, cv_viz_WGrid_to_Widget } + /// Constant methods for [crate::viz::WGrid] + pub trait WGridTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WGrid(&self) -> *const c_void; - boxed_cast_base! { WGrid, crate::viz::Widget3D, cv_viz_WGrid_to_Widget3D } + } + + /// Mutable methods for [crate::viz::WGrid] + pub trait WGridTrait: crate::viz::WGridTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WGrid(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for WGrid { #[inline] @@ -4376,6 +4342,94 @@ pub mod viz { } } + boxed_cast_base! { WGrid, crate::viz::Widget, cv_viz_WGrid_to_Widget } + + boxed_cast_base! { WGrid, crate::viz::Widget3D, cv_viz_WGrid_to_Widget3D } + + impl crate::viz::WidgetTraitConst for WGrid { + #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } + } + + impl crate::viz::WidgetTrait for WGrid { + #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { WGrid, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + + impl crate::viz::Widget3DTraitConst for WGrid { + #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + } + + impl crate::viz::Widget3DTrait for WGrid { + #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { WGrid, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + + impl crate::viz::WGridTraitConst for WGrid { + #[inline] fn as_raw_WGrid(&self) -> *const c_void { self.as_raw() } + } + + impl crate::viz::WGridTrait for WGrid { + #[inline] fn as_raw_mut_WGrid(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { WGrid, crate::viz::WGridTraitConst, as_raw_WGrid, crate::viz::WGridTrait, as_raw_mut_WGrid } + + /// This 3D Widget represents an image in 3D space. : + pub struct WImage3D { + ptr: *mut c_void, + } + + opencv_type_boxed! { WImage3D } + + impl Drop for WImage3D { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_viz_WImage3D_delete(self.as_raw_mut_WImage3D()) }; + } + } + + unsafe impl Send for WImage3D {} + + impl WImage3D { + /// Constructs an WImage3D. + /// + /// ## Parameters + /// * image: BGR or Gray-Scale image. + /// * size: Size of the image. + #[inline] + pub fn new(image: &impl ToInputArray, size: core::Size2d) -> Result { + input_array_arg!(image); + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_WImage3D_WImage3D_const__InputArrayR_const_Size2dR(image.as_raw__InputArray(), &size, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::viz::WImage3D::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Constructs an WImage3D. + /// + /// ## Parameters + /// * image: BGR or Gray-Scale image. + /// * size: Size of the image. + /// * center: Position of the image. + /// * normal: Normal of the plane that represents the image. + /// * up_vector: Determines orientation of the image. + #[inline] + pub fn new_1(image: &impl ToInputArray, size: core::Size2d, center: core::Vec3d, normal: core::Vec3d, up_vector: core::Vec3d) -> Result { + input_array_arg!(image); + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_WImage3D_WImage3D_const__InputArrayR_const_Size2dR_const_Vec3dR_const_Vec3dR_const_Vec3dR(image.as_raw__InputArray(), &size, ¢er, &normal, &up_vector, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::viz::WImage3D::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::viz::WImage3D] pub trait WImage3DTraitConst: crate::viz::Widget3DTraitConst { fn as_raw_WImage3D(&self) -> *const c_void; @@ -4415,21 +4469,17 @@ pub mod viz { } - /// This 3D Widget represents an image in 3D space. : - pub struct WImage3D { - ptr: *mut c_void, - } - - opencv_type_boxed! { WImage3D } - - impl Drop for WImage3D { + impl std::fmt::Debug for WImage3D { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_WImage3D_delete(self.as_raw_mut_WImage3D()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("WImage3D") + .finish() } } - unsafe impl Send for WImage3D {} + boxed_cast_base! { WImage3D, crate::viz::Widget, cv_viz_WImage3D_to_Widget } + + boxed_cast_base! { WImage3D, crate::viz::Widget3D, cv_viz_WImage3D_to_Widget3D } impl crate::viz::WidgetTraitConst for WImage3D { #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } @@ -4461,56 +4511,41 @@ pub mod viz { boxed_ref! { WImage3D, crate::viz::WImage3DTraitConst, as_raw_WImage3D, crate::viz::WImage3DTrait, as_raw_mut_WImage3D } - impl WImage3D { - /// Constructs an WImage3D. - /// - /// ## Parameters - /// * image: BGR or Gray-Scale image. - /// * size: Size of the image. + /// This 2D Widget represents an image overlay. : + pub struct WImageOverlay { + ptr: *mut c_void, + } + + opencv_type_boxed! { WImageOverlay } + + impl Drop for WImageOverlay { #[inline] - pub fn new(image: &impl ToInputArray, size: core::Size2d) -> Result { - input_array_arg!(image); - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_WImage3D_WImage3D_const__InputArrayR_const_Size2dR(image.as_raw__InputArray(), &size, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::viz::WImage3D::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_viz_WImageOverlay_delete(self.as_raw_mut_WImageOverlay()) }; } + } - /// Constructs an WImage3D. + unsafe impl Send for WImageOverlay {} + + impl WImageOverlay { + /// Constructs an WImageOverlay. /// /// ## Parameters /// * image: BGR or Gray-Scale image. - /// * size: Size of the image. - /// * center: Position of the image. - /// * normal: Normal of the plane that represents the image. - /// * up_vector: Determines orientation of the image. + /// * rect: Image is scaled and positioned based on rect. #[inline] - pub fn new_1(image: &impl ToInputArray, size: core::Size2d, center: core::Vec3d, normal: core::Vec3d, up_vector: core::Vec3d) -> Result { + pub fn new(image: &impl ToInputArray, rect: core::Rect) -> Result { input_array_arg!(image); return_send!(via ocvrs_return); - unsafe { sys::cv_viz_WImage3D_WImage3D_const__InputArrayR_const_Size2dR_const_Vec3dR_const_Vec3dR_const_Vec3dR(image.as_raw__InputArray(), &size, ¢er, &normal, &up_vector, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_viz_WImageOverlay_WImageOverlay_const__InputArrayR_const_RectR(image.as_raw__InputArray(), &rect, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::viz::WImage3D::opencv_from_extern(ret) }; + let ret = unsafe { crate::viz::WImageOverlay::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { WImage3D, crate::viz::Widget, cv_viz_WImage3D_to_Widget } - - boxed_cast_base! { WImage3D, crate::viz::Widget3D, cv_viz_WImage3D_to_Widget3D } - - impl std::fmt::Debug for WImage3D { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("WImage3D") - .finish() - } - } - /// Constant methods for [crate::viz::WImageOverlay] pub trait WImageOverlayTraitConst: crate::viz::Widget2DTraitConst { fn as_raw_WImageOverlay(&self) -> *const c_void; @@ -4537,21 +4572,17 @@ pub mod viz { } - /// This 2D Widget represents an image overlay. : - pub struct WImageOverlay { - ptr: *mut c_void, - } - - opencv_type_boxed! { WImageOverlay } - - impl Drop for WImageOverlay { + impl std::fmt::Debug for WImageOverlay { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_WImageOverlay_delete(self.as_raw_mut_WImageOverlay()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("WImageOverlay") + .finish() } } - unsafe impl Send for WImageOverlay {} + boxed_cast_base! { WImageOverlay, crate::viz::Widget, cv_viz_WImageOverlay_to_Widget } + + boxed_cast_base! { WImageOverlay, crate::viz::Widget2D, cv_viz_WImageOverlay_to_Widget2D } impl crate::viz::WidgetTraitConst for WImageOverlay { #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } @@ -4583,95 +4614,22 @@ pub mod viz { boxed_ref! { WImageOverlay, crate::viz::WImageOverlayTraitConst, as_raw_WImageOverlay, crate::viz::WImageOverlayTrait, as_raw_mut_WImageOverlay } - impl WImageOverlay { - /// Constructs an WImageOverlay. - /// - /// ## Parameters - /// * image: BGR or Gray-Scale image. - /// * rect: Image is scaled and positioned based on rect. - #[inline] - pub fn new(image: &impl ToInputArray, rect: core::Rect) -> Result { - input_array_arg!(image); - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_WImageOverlay_WImageOverlay_const__InputArrayR_const_RectR(image.as_raw__InputArray(), &rect, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::viz::WImageOverlay::opencv_from_extern(ret) }; - Ok(ret) - } - + /// This 3D Widget defines a finite line. + pub struct WLine { + ptr: *mut c_void, } - boxed_cast_base! { WImageOverlay, crate::viz::Widget, cv_viz_WImageOverlay_to_Widget } - - boxed_cast_base! { WImageOverlay, crate::viz::Widget2D, cv_viz_WImageOverlay_to_Widget2D } + opencv_type_boxed! { WLine } - impl std::fmt::Debug for WImageOverlay { + impl Drop for WLine { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("WImageOverlay") - .finish() - } - } - - /// Constant methods for [crate::viz::WLine] - pub trait WLineTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WLine(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::viz::WLine] - pub trait WLineTrait: crate::viz::WLineTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WLine(&mut self) -> *mut c_void; - - } - - /// This 3D Widget defines a finite line. - pub struct WLine { - ptr: *mut c_void, - } - - opencv_type_boxed! { WLine } - - impl Drop for WLine { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_WLine_delete(self.as_raw_mut_WLine()) }; + fn drop(&mut self) { + unsafe { sys::cv_viz_WLine_delete(self.as_raw_mut_WLine()) }; } } unsafe impl Send for WLine {} - impl crate::viz::WidgetTraitConst for WLine { - #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::WidgetTrait for WLine { - #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WLine, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - - impl crate::viz::Widget3DTraitConst for WLine { - #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::Widget3DTrait for WLine { - #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WLine, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } - - impl crate::viz::WLineTraitConst for WLine { - #[inline] fn as_raw_WLine(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::WLineTrait for WLine { - #[inline] fn as_raw_mut_WLine(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WLine, crate::viz::WLineTraitConst, as_raw_WLine, crate::viz::WLineTrait, as_raw_mut_WLine } - impl WLine { /// Constructs a WLine. /// @@ -4714,9 +4672,17 @@ pub mod viz { } - boxed_cast_base! { WLine, crate::viz::Widget, cv_viz_WLine_to_Widget } + /// Constant methods for [crate::viz::WLine] + pub trait WLineTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WLine(&self) -> *const c_void; - boxed_cast_base! { WLine, crate::viz::Widget3D, cv_viz_WLine_to_Widget3D } + } + + /// Mutable methods for [crate::viz::WLine] + pub trait WLineTrait: crate::viz::WLineTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WLine(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for WLine { #[inline] @@ -4726,18 +4692,40 @@ pub mod viz { } } - /// Constant methods for [crate::viz::WMesh] - pub trait WMeshTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WMesh(&self) -> *const c_void; + boxed_cast_base! { WLine, crate::viz::Widget, cv_viz_WLine_to_Widget } + boxed_cast_base! { WLine, crate::viz::Widget3D, cv_viz_WLine_to_Widget3D } + + impl crate::viz::WidgetTraitConst for WLine { + #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::viz::WMesh] - pub trait WMeshTrait: crate::viz::WMeshTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WMesh(&mut self) -> *mut c_void; + impl crate::viz::WidgetTrait for WLine { + #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { WLine, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + + impl crate::viz::Widget3DTraitConst for WLine { + #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + } + + impl crate::viz::Widget3DTrait for WLine { + #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { WLine, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + + impl crate::viz::WLineTraitConst for WLine { + #[inline] fn as_raw_WLine(&self) -> *const c_void { self.as_raw() } + } + impl crate::viz::WLineTrait for WLine { + #[inline] fn as_raw_mut_WLine(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { WLine, crate::viz::WLineTraitConst, as_raw_WLine, crate::viz::WLineTrait, as_raw_mut_WLine } + /// Constructs a WMesh. /// /// ## Parameters @@ -4761,36 +4749,6 @@ pub mod viz { unsafe impl Send for WMesh {} - impl crate::viz::WidgetTraitConst for WMesh { - #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::WidgetTrait for WMesh { - #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WMesh, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - - impl crate::viz::Widget3DTraitConst for WMesh { - #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::Widget3DTrait for WMesh { - #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WMesh, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } - - impl crate::viz::WMeshTraitConst for WMesh { - #[inline] fn as_raw_WMesh(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::WMeshTrait for WMesh { - #[inline] fn as_raw_mut_WMesh(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WMesh, crate::viz::WMeshTraitConst, as_raw_WMesh, crate::viz::WMeshTrait, as_raw_mut_WMesh } - impl WMesh { #[inline] pub fn new(mesh: &impl crate::viz::MeshTraitConst) -> Result { @@ -4837,9 +4795,17 @@ pub mod viz { } - boxed_cast_base! { WMesh, crate::viz::Widget, cv_viz_WMesh_to_Widget } + /// Constant methods for [crate::viz::WMesh] + pub trait WMeshTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WMesh(&self) -> *const c_void; - boxed_cast_base! { WMesh, crate::viz::Widget3D, cv_viz_WMesh_to_Widget3D } + } + + /// Mutable methods for [crate::viz::WMesh] + pub trait WMeshTrait: crate::viz::WMeshTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WMesh(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for WMesh { #[inline] @@ -4849,62 +4815,54 @@ pub mod viz { } } - /// Constant methods for [crate::viz::WPaintedCloud] - pub trait WPaintedCloudTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WPaintedCloud(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::viz::WPaintedCloud] - pub trait WPaintedCloudTrait: crate::viz::WPaintedCloudTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WPaintedCloud(&mut self) -> *mut c_void; + boxed_cast_base! { WMesh, crate::viz::Widget, cv_viz_WMesh_to_Widget } - } + boxed_cast_base! { WMesh, crate::viz::Widget3D, cv_viz_WMesh_to_Widget3D } - pub struct WPaintedCloud { - ptr: *mut c_void, + impl crate::viz::WidgetTraitConst for WMesh { + #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } - opencv_type_boxed! { WPaintedCloud } - - impl Drop for WPaintedCloud { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_WPaintedCloud_delete(self.as_raw_mut_WPaintedCloud()) }; - } + impl crate::viz::WidgetTrait for WMesh { + #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } } - unsafe impl Send for WPaintedCloud {} + boxed_ref! { WMesh, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - impl crate::viz::WidgetTraitConst for WPaintedCloud { - #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } + impl crate::viz::Widget3DTraitConst for WMesh { + #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::WidgetTrait for WPaintedCloud { - #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::Widget3DTrait for WMesh { + #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WPaintedCloud, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + boxed_ref! { WMesh, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } - impl crate::viz::Widget3DTraitConst for WPaintedCloud { - #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + impl crate::viz::WMeshTraitConst for WMesh { + #[inline] fn as_raw_WMesh(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::Widget3DTrait for WPaintedCloud { - #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::WMeshTrait for WMesh { + #[inline] fn as_raw_mut_WMesh(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WPaintedCloud, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + boxed_ref! { WMesh, crate::viz::WMeshTraitConst, as_raw_WMesh, crate::viz::WMeshTrait, as_raw_mut_WMesh } - impl crate::viz::WPaintedCloudTraitConst for WPaintedCloud { - #[inline] fn as_raw_WPaintedCloud(&self) -> *const c_void { self.as_raw() } + pub struct WPaintedCloud { + ptr: *mut c_void, } - impl crate::viz::WPaintedCloudTrait for WPaintedCloud { - #[inline] fn as_raw_mut_WPaintedCloud(&mut self) -> *mut c_void { self.as_raw_mut() } + opencv_type_boxed! { WPaintedCloud } + + impl Drop for WPaintedCloud { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_viz_WPaintedCloud_delete(self.as_raw_mut_WPaintedCloud()) }; + } } - boxed_ref! { WPaintedCloud, crate::viz::WPaintedCloudTraitConst, as_raw_WPaintedCloud, crate::viz::WPaintedCloudTrait, as_raw_mut_WPaintedCloud } + unsafe impl Send for WPaintedCloud {} impl WPaintedCloud { /// Paint cloud with default gradient between cloud bounds points @@ -4945,9 +4903,17 @@ pub mod viz { } - boxed_cast_base! { WPaintedCloud, crate::viz::Widget, cv_viz_WPaintedCloud_to_Widget } + /// Constant methods for [crate::viz::WPaintedCloud] + pub trait WPaintedCloudTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WPaintedCloud(&self) -> *const c_void; - boxed_cast_base! { WPaintedCloud, crate::viz::Widget3D, cv_viz_WPaintedCloud_to_Widget3D } + } + + /// Mutable methods for [crate::viz::WPaintedCloud] + pub trait WPaintedCloudTrait: crate::viz::WPaintedCloudTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WPaintedCloud(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for WPaintedCloud { #[inline] @@ -4957,18 +4923,40 @@ pub mod viz { } } - /// Constant methods for [crate::viz::WPlane] - pub trait WPlaneTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WPlane(&self) -> *const c_void; + boxed_cast_base! { WPaintedCloud, crate::viz::Widget, cv_viz_WPaintedCloud_to_Widget } + + boxed_cast_base! { WPaintedCloud, crate::viz::Widget3D, cv_viz_WPaintedCloud_to_Widget3D } + impl crate::viz::WidgetTraitConst for WPaintedCloud { + #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::viz::WPlane] - pub trait WPlaneTrait: crate::viz::WPlaneTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WPlane(&mut self) -> *mut c_void; + impl crate::viz::WidgetTrait for WPaintedCloud { + #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { WPaintedCloud, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + + impl crate::viz::Widget3DTraitConst for WPaintedCloud { + #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + } + + impl crate::viz::Widget3DTrait for WPaintedCloud { + #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { WPaintedCloud, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + + impl crate::viz::WPaintedCloudTraitConst for WPaintedCloud { + #[inline] fn as_raw_WPaintedCloud(&self) -> *const c_void { self.as_raw() } + } + impl crate::viz::WPaintedCloudTrait for WPaintedCloud { + #[inline] fn as_raw_mut_WPaintedCloud(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { WPaintedCloud, crate::viz::WPaintedCloudTraitConst, as_raw_WPaintedCloud, crate::viz::WPaintedCloudTrait, as_raw_mut_WPaintedCloud } + /// This 3D Widget defines a finite plane. pub struct WPlane { ptr: *mut c_void, @@ -4985,36 +4973,6 @@ pub mod viz { unsafe impl Send for WPlane {} - impl crate::viz::WidgetTraitConst for WPlane { - #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::WidgetTrait for WPlane { - #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WPlane, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - - impl crate::viz::Widget3DTraitConst for WPlane { - #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::Widget3DTrait for WPlane { - #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WPlane, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } - - impl crate::viz::WPlaneTraitConst for WPlane { - #[inline] fn as_raw_WPlane(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::WPlaneTrait for WPlane { - #[inline] fn as_raw_mut_WPlane(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WPlane, crate::viz::WPlaneTraitConst, as_raw_WPlane, crate::viz::WPlaneTrait, as_raw_mut_WPlane } - impl WPlane { /// Constructs a default plane with center point at origin and normal oriented along z-axis. /// @@ -5102,9 +5060,17 @@ pub mod viz { } - boxed_cast_base! { WPlane, crate::viz::Widget, cv_viz_WPlane_to_Widget } + /// Constant methods for [crate::viz::WPlane] + pub trait WPlaneTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WPlane(&self) -> *const c_void; - boxed_cast_base! { WPlane, crate::viz::Widget3D, cv_viz_WPlane_to_Widget3D } + } + + /// Mutable methods for [crate::viz::WPlane] + pub trait WPlaneTrait: crate::viz::WPlaneTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WPlane(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for WPlane { #[inline] @@ -5114,63 +5080,55 @@ pub mod viz { } } - /// Constant methods for [crate::viz::WPolyLine] - pub trait WPolyLineTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WPolyLine(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::viz::WPolyLine] - pub trait WPolyLineTrait: crate::viz::WPolyLineTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WPolyLine(&mut self) -> *mut c_void; + boxed_cast_base! { WPlane, crate::viz::Widget, cv_viz_WPlane_to_Widget } - } + boxed_cast_base! { WPlane, crate::viz::Widget3D, cv_viz_WPlane_to_Widget3D } - /// This 3D Widget defines a poly line. : - pub struct WPolyLine { - ptr: *mut c_void, + impl crate::viz::WidgetTraitConst for WPlane { + #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } - opencv_type_boxed! { WPolyLine } - - impl Drop for WPolyLine { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_WPolyLine_delete(self.as_raw_mut_WPolyLine()) }; - } + impl crate::viz::WidgetTrait for WPlane { + #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } } - unsafe impl Send for WPolyLine {} + boxed_ref! { WPlane, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - impl crate::viz::WidgetTraitConst for WPolyLine { - #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } + impl crate::viz::Widget3DTraitConst for WPlane { + #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::WidgetTrait for WPolyLine { - #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::Widget3DTrait for WPlane { + #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WPolyLine, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + boxed_ref! { WPlane, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } - impl crate::viz::Widget3DTraitConst for WPolyLine { - #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + impl crate::viz::WPlaneTraitConst for WPlane { + #[inline] fn as_raw_WPlane(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::Widget3DTrait for WPolyLine { - #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::WPlaneTrait for WPlane { + #[inline] fn as_raw_mut_WPlane(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WPolyLine, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + boxed_ref! { WPlane, crate::viz::WPlaneTraitConst, as_raw_WPlane, crate::viz::WPlaneTrait, as_raw_mut_WPlane } - impl crate::viz::WPolyLineTraitConst for WPolyLine { - #[inline] fn as_raw_WPolyLine(&self) -> *const c_void { self.as_raw() } + /// This 3D Widget defines a poly line. : + pub struct WPolyLine { + ptr: *mut c_void, } - impl crate::viz::WPolyLineTrait for WPolyLine { - #[inline] fn as_raw_mut_WPolyLine(&mut self) -> *mut c_void { self.as_raw_mut() } + opencv_type_boxed! { WPolyLine } + + impl Drop for WPolyLine { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_viz_WPolyLine_delete(self.as_raw_mut_WPolyLine()) }; + } } - boxed_ref! { WPolyLine, crate::viz::WPolyLineTraitConst, as_raw_WPolyLine, crate::viz::WPolyLineTrait, as_raw_mut_WPolyLine } + unsafe impl Send for WPolyLine {} impl WPolyLine { #[inline] @@ -5226,9 +5184,17 @@ pub mod viz { } - boxed_cast_base! { WPolyLine, crate::viz::Widget, cv_viz_WPolyLine_to_Widget } + /// Constant methods for [crate::viz::WPolyLine] + pub trait WPolyLineTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WPolyLine(&self) -> *const c_void; - boxed_cast_base! { WPolyLine, crate::viz::Widget3D, cv_viz_WPolyLine_to_Widget3D } + } + + /// Mutable methods for [crate::viz::WPolyLine] + pub trait WPolyLineTrait: crate::viz::WPolyLineTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WPolyLine(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for WPolyLine { #[inline] @@ -5238,63 +5204,55 @@ pub mod viz { } } - /// Constant methods for [crate::viz::WSphere] - pub trait WSphereTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WSphere(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::viz::WSphere] - pub trait WSphereTrait: crate::viz::WSphereTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WSphere(&mut self) -> *mut c_void; + boxed_cast_base! { WPolyLine, crate::viz::Widget, cv_viz_WPolyLine_to_Widget } - } + boxed_cast_base! { WPolyLine, crate::viz::Widget3D, cv_viz_WPolyLine_to_Widget3D } - /// This 3D Widget defines a sphere. : - pub struct WSphere { - ptr: *mut c_void, + impl crate::viz::WidgetTraitConst for WPolyLine { + #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } - opencv_type_boxed! { WSphere } - - impl Drop for WSphere { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_WSphere_delete(self.as_raw_mut_WSphere()) }; - } + impl crate::viz::WidgetTrait for WPolyLine { + #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } } - unsafe impl Send for WSphere {} + boxed_ref! { WPolyLine, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - impl crate::viz::WidgetTraitConst for WSphere { - #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } + impl crate::viz::Widget3DTraitConst for WPolyLine { + #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::WidgetTrait for WSphere { - #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::Widget3DTrait for WPolyLine { + #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WSphere, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + boxed_ref! { WPolyLine, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } - impl crate::viz::Widget3DTraitConst for WSphere { - #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + impl crate::viz::WPolyLineTraitConst for WPolyLine { + #[inline] fn as_raw_WPolyLine(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::Widget3DTrait for WSphere { - #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::WPolyLineTrait for WPolyLine { + #[inline] fn as_raw_mut_WPolyLine(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WSphere, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + boxed_ref! { WPolyLine, crate::viz::WPolyLineTraitConst, as_raw_WPolyLine, crate::viz::WPolyLineTrait, as_raw_mut_WPolyLine } - impl crate::viz::WSphereTraitConst for WSphere { - #[inline] fn as_raw_WSphere(&self) -> *const c_void { self.as_raw() } + /// This 3D Widget defines a sphere. : + pub struct WSphere { + ptr: *mut c_void, } - impl crate::viz::WSphereTrait for WSphere { - #[inline] fn as_raw_mut_WSphere(&mut self) -> *mut c_void { self.as_raw_mut() } + opencv_type_boxed! { WSphere } + + impl Drop for WSphere { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_viz_WSphere_delete(self.as_raw_mut_WSphere()) }; + } } - boxed_ref! { WSphere, crate::viz::WSphereTraitConst, as_raw_WSphere, crate::viz::WSphereTrait, as_raw_mut_WSphere } + unsafe impl Send for WSphere {} impl WSphere { /// Constructs a WSphere. @@ -5342,9 +5300,17 @@ pub mod viz { } - boxed_cast_base! { WSphere, crate::viz::Widget, cv_viz_WSphere_to_Widget } + /// Constant methods for [crate::viz::WSphere] + pub trait WSphereTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WSphere(&self) -> *const c_void; - boxed_cast_base! { WSphere, crate::viz::Widget3D, cv_viz_WSphere_to_Widget3D } + } + + /// Mutable methods for [crate::viz::WSphere] + pub trait WSphereTrait: crate::viz::WSphereTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WSphere(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for WSphere { #[inline] @@ -5354,43 +5320,40 @@ pub mod viz { } } - /// Constant methods for [crate::viz::WText] - pub trait WTextTraitConst: crate::viz::Widget2DTraitConst { - fn as_raw_WText(&self) -> *const c_void; + boxed_cast_base! { WSphere, crate::viz::Widget, cv_viz_WSphere_to_Widget } - /// Returns the current text content of the widget. - #[inline] - fn get_text(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_WText_getText_const(self.as_raw_WText(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { String::opencv_from_extern(ret) }; - Ok(ret) - } + boxed_cast_base! { WSphere, crate::viz::Widget3D, cv_viz_WSphere_to_Widget3D } + impl crate::viz::WidgetTraitConst for WSphere { + #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::viz::WText] - pub trait WTextTrait: crate::viz::WTextTraitConst + crate::viz::Widget2DTrait { - fn as_raw_mut_WText(&mut self) -> *mut c_void; + impl crate::viz::WidgetTrait for WSphere { + #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } + } - /// Sets the text content of the widget. - /// - /// ## Parameters - /// * text: Text content of the widget. - #[inline] - fn set_text(&mut self, text: &str) -> Result<()> { - extern_container_arg!(text); - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_WText_setText_const_StringR(self.as_raw_mut_WText(), text.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } + boxed_ref! { WSphere, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + + impl crate::viz::Widget3DTraitConst for WSphere { + #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + } + + impl crate::viz::Widget3DTrait for WSphere { + #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { WSphere, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + + impl crate::viz::WSphereTraitConst for WSphere { + #[inline] fn as_raw_WSphere(&self) -> *const c_void { self.as_raw() } + } + impl crate::viz::WSphereTrait for WSphere { + #[inline] fn as_raw_mut_WSphere(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { WSphere, crate::viz::WSphereTraitConst, as_raw_WSphere, crate::viz::WSphereTrait, as_raw_mut_WSphere } + /// This 2D Widget represents text overlay. pub struct WText { ptr: *mut c_void, @@ -5407,36 +5370,6 @@ pub mod viz { unsafe impl Send for WText {} - impl crate::viz::WidgetTraitConst for WText { - #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::WidgetTrait for WText { - #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WText, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - - impl crate::viz::Widget2DTraitConst for WText { - #[inline] fn as_raw_Widget2D(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::Widget2DTrait for WText { - #[inline] fn as_raw_mut_Widget2D(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WText, crate::viz::Widget2DTraitConst, as_raw_Widget2D, crate::viz::Widget2DTrait, as_raw_mut_Widget2D } - - impl crate::viz::WTextTraitConst for WText { - #[inline] fn as_raw_WText(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::WTextTrait for WText { - #[inline] fn as_raw_mut_WText(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WText, crate::viz::WTextTraitConst, as_raw_WText, crate::viz::WTextTrait, as_raw_mut_WText } - impl WText { /// Constructs a WText. /// @@ -5485,27 +5418,15 @@ pub mod viz { } - boxed_cast_base! { WText, crate::viz::Widget, cv_viz_WText_to_Widget } - - boxed_cast_base! { WText, crate::viz::Widget2D, cv_viz_WText_to_Widget2D } - - impl std::fmt::Debug for WText { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("WText") - .finish() - } - } - - /// Constant methods for [crate::viz::WText3D] - pub trait WText3DTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WText3D(&self) -> *const c_void; + /// Constant methods for [crate::viz::WText] + pub trait WTextTraitConst: crate::viz::Widget2DTraitConst { + fn as_raw_WText(&self) -> *const c_void; /// Returns the current text content of the widget. #[inline] fn get_text(&self) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_viz_WText3D_getText_const(self.as_raw_WText3D(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_viz_WText_getText_const(self.as_raw_WText(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; let ret = unsafe { String::opencv_from_extern(ret) }; @@ -5514,9 +5435,9 @@ pub mod viz { } - /// Mutable methods for [crate::viz::WText3D] - pub trait WText3DTrait: crate::viz::WText3DTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WText3D(&mut self) -> *mut c_void; + /// Mutable methods for [crate::viz::WText] + pub trait WTextTrait: crate::viz::WTextTraitConst + crate::viz::Widget2DTrait { + fn as_raw_mut_WText(&mut self) -> *mut c_void; /// Sets the text content of the widget. /// @@ -5526,7 +5447,7 @@ pub mod viz { fn set_text(&mut self, text: &str) -> Result<()> { extern_container_arg!(text); return_send!(via ocvrs_return); - unsafe { sys::cv_viz_WText3D_setText_const_StringR(self.as_raw_mut_WText3D(), text.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_viz_WText_setText_const_StringR(self.as_raw_mut_WText(), text.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) @@ -5534,51 +5455,63 @@ pub mod viz { } - /// This 3D Widget represents 3D text. The text always faces the camera. - pub struct WText3D { - ptr: *mut c_void, - } - - opencv_type_boxed! { WText3D } - - impl Drop for WText3D { + impl std::fmt::Debug for WText { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_WText3D_delete(self.as_raw_mut_WText3D()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("WText") + .finish() } } - unsafe impl Send for WText3D {} + boxed_cast_base! { WText, crate::viz::Widget, cv_viz_WText_to_Widget } - impl crate::viz::WidgetTraitConst for WText3D { + boxed_cast_base! { WText, crate::viz::Widget2D, cv_viz_WText_to_Widget2D } + + impl crate::viz::WidgetTraitConst for WText { #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::WidgetTrait for WText3D { + impl crate::viz::WidgetTrait for WText { #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WText3D, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + boxed_ref! { WText, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - impl crate::viz::Widget3DTraitConst for WText3D { - #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + impl crate::viz::Widget2DTraitConst for WText { + #[inline] fn as_raw_Widget2D(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::Widget3DTrait for WText3D { - #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::Widget2DTrait for WText { + #[inline] fn as_raw_mut_Widget2D(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WText3D, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + boxed_ref! { WText, crate::viz::Widget2DTraitConst, as_raw_Widget2D, crate::viz::Widget2DTrait, as_raw_mut_Widget2D } - impl crate::viz::WText3DTraitConst for WText3D { - #[inline] fn as_raw_WText3D(&self) -> *const c_void { self.as_raw() } + impl crate::viz::WTextTraitConst for WText { + #[inline] fn as_raw_WText(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::WText3DTrait for WText3D { - #[inline] fn as_raw_mut_WText3D(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::WTextTrait for WText { + #[inline] fn as_raw_mut_WText(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WText3D, crate::viz::WText3DTraitConst, as_raw_WText3D, crate::viz::WText3DTrait, as_raw_mut_WText3D } + boxed_ref! { WText, crate::viz::WTextTraitConst, as_raw_WText, crate::viz::WTextTrait, as_raw_mut_WText } + + /// This 3D Widget represents 3D text. The text always faces the camera. + pub struct WText3D { + ptr: *mut c_void, + } + + opencv_type_boxed! { WText3D } + + impl Drop for WText3D { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_viz_WText3D_delete(self.as_raw_mut_WText3D()) }; + } + } + + unsafe impl Send for WText3D {} impl WText3D { /// Constructs a WText3D. @@ -5632,75 +5565,100 @@ pub mod viz { } - boxed_cast_base! { WText3D, crate::viz::Widget, cv_viz_WText3D_to_Widget } - - boxed_cast_base! { WText3D, crate::viz::Widget3D, cv_viz_WText3D_to_Widget3D } + /// Constant methods for [crate::viz::WText3D] + pub trait WText3DTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WText3D(&self) -> *const c_void; - impl std::fmt::Debug for WText3D { + /// Returns the current text content of the widget. #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("WText3D") - .finish() + fn get_text(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_WText3D_getText_const(self.as_raw_WText3D(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { String::opencv_from_extern(ret) }; + Ok(ret) } - } - - /// Constant methods for [crate::viz::WTrajectory] - pub trait WTrajectoryTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WTrajectory(&self) -> *const c_void; } - /// Mutable methods for [crate::viz::WTrajectory] - pub trait WTrajectoryTrait: crate::viz::WTrajectoryTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WTrajectory(&mut self) -> *mut c_void; + /// Mutable methods for [crate::viz::WText3D] + pub trait WText3DTrait: crate::viz::WText3DTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WText3D(&mut self) -> *mut c_void; - } + /// Sets the text content of the widget. + /// + /// ## Parameters + /// * text: Text content of the widget. + #[inline] + fn set_text(&mut self, text: &str) -> Result<()> { + extern_container_arg!(text); + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_WText3D_setText_const_StringR(self.as_raw_mut_WText3D(), text.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - /// This 3D Widget represents a trajectory. : - pub struct WTrajectory { - ptr: *mut c_void, } - opencv_type_boxed! { WTrajectory } - - impl Drop for WTrajectory { + impl std::fmt::Debug for WText3D { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_WTrajectory_delete(self.as_raw_mut_WTrajectory()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("WText3D") + .finish() } } - unsafe impl Send for WTrajectory {} + boxed_cast_base! { WText3D, crate::viz::Widget, cv_viz_WText3D_to_Widget } - impl crate::viz::WidgetTraitConst for WTrajectory { + boxed_cast_base! { WText3D, crate::viz::Widget3D, cv_viz_WText3D_to_Widget3D } + + impl crate::viz::WidgetTraitConst for WText3D { #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::WidgetTrait for WTrajectory { + impl crate::viz::WidgetTrait for WText3D { #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WTrajectory, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + boxed_ref! { WText3D, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - impl crate::viz::Widget3DTraitConst for WTrajectory { + impl crate::viz::Widget3DTraitConst for WText3D { #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::Widget3DTrait for WTrajectory { + impl crate::viz::Widget3DTrait for WText3D { #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WTrajectory, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + boxed_ref! { WText3D, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + + impl crate::viz::WText3DTraitConst for WText3D { + #[inline] fn as_raw_WText3D(&self) -> *const c_void { self.as_raw() } + } + + impl crate::viz::WText3DTrait for WText3D { + #[inline] fn as_raw_mut_WText3D(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { WText3D, crate::viz::WText3DTraitConst, as_raw_WText3D, crate::viz::WText3DTrait, as_raw_mut_WText3D } - impl crate::viz::WTrajectoryTraitConst for WTrajectory { - #[inline] fn as_raw_WTrajectory(&self) -> *const c_void { self.as_raw() } + /// This 3D Widget represents a trajectory. : + pub struct WTrajectory { + ptr: *mut c_void, } - impl crate::viz::WTrajectoryTrait for WTrajectory { - #[inline] fn as_raw_mut_WTrajectory(&mut self) -> *mut c_void { self.as_raw_mut() } + opencv_type_boxed! { WTrajectory } + + impl Drop for WTrajectory { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_viz_WTrajectory_delete(self.as_raw_mut_WTrajectory()) }; + } } - boxed_ref! { WTrajectory, crate::viz::WTrajectoryTraitConst, as_raw_WTrajectory, crate::viz::WTrajectoryTrait, as_raw_mut_WTrajectory } + unsafe impl Send for WTrajectory {} impl WTrajectory { /// Constructs a WTrajectory. @@ -5764,9 +5722,17 @@ pub mod viz { } - boxed_cast_base! { WTrajectory, crate::viz::Widget, cv_viz_WTrajectory_to_Widget } + /// Constant methods for [crate::viz::WTrajectory] + pub trait WTrajectoryTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WTrajectory(&self) -> *const c_void; - boxed_cast_base! { WTrajectory, crate::viz::Widget3D, cv_viz_WTrajectory_to_Widget3D } + } + + /// Mutable methods for [crate::viz::WTrajectory] + pub trait WTrajectoryTrait: crate::viz::WTrajectoryTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WTrajectory(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for WTrajectory { #[inline] @@ -5776,63 +5742,55 @@ pub mod viz { } } - /// Constant methods for [crate::viz::WTrajectoryFrustums] - pub trait WTrajectoryFrustumsTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WTrajectoryFrustums(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::viz::WTrajectoryFrustums] - pub trait WTrajectoryFrustumsTrait: crate::viz::WTrajectoryFrustumsTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WTrajectoryFrustums(&mut self) -> *mut c_void; + boxed_cast_base! { WTrajectory, crate::viz::Widget, cv_viz_WTrajectory_to_Widget } - } + boxed_cast_base! { WTrajectory, crate::viz::Widget3D, cv_viz_WTrajectory_to_Widget3D } - /// This 3D Widget represents a trajectory. : - pub struct WTrajectoryFrustums { - ptr: *mut c_void, + impl crate::viz::WidgetTraitConst for WTrajectory { + #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } - opencv_type_boxed! { WTrajectoryFrustums } - - impl Drop for WTrajectoryFrustums { - #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_WTrajectoryFrustums_delete(self.as_raw_mut_WTrajectoryFrustums()) }; - } + impl crate::viz::WidgetTrait for WTrajectory { + #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } } - unsafe impl Send for WTrajectoryFrustums {} + boxed_ref! { WTrajectory, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - impl crate::viz::WidgetTraitConst for WTrajectoryFrustums { - #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } + impl crate::viz::Widget3DTraitConst for WTrajectory { + #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::WidgetTrait for WTrajectoryFrustums { - #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::Widget3DTrait for WTrajectory { + #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WTrajectoryFrustums, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + boxed_ref! { WTrajectory, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } - impl crate::viz::Widget3DTraitConst for WTrajectoryFrustums { - #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + impl crate::viz::WTrajectoryTraitConst for WTrajectory { + #[inline] fn as_raw_WTrajectory(&self) -> *const c_void { self.as_raw() } } - impl crate::viz::Widget3DTrait for WTrajectoryFrustums { - #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + impl crate::viz::WTrajectoryTrait for WTrajectory { + #[inline] fn as_raw_mut_WTrajectory(&mut self) -> *mut c_void { self.as_raw_mut() } } - boxed_ref! { WTrajectoryFrustums, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + boxed_ref! { WTrajectory, crate::viz::WTrajectoryTraitConst, as_raw_WTrajectory, crate::viz::WTrajectoryTrait, as_raw_mut_WTrajectory } - impl crate::viz::WTrajectoryFrustumsTraitConst for WTrajectoryFrustums { - #[inline] fn as_raw_WTrajectoryFrustums(&self) -> *const c_void { self.as_raw() } + /// This 3D Widget represents a trajectory. : + pub struct WTrajectoryFrustums { + ptr: *mut c_void, } - impl crate::viz::WTrajectoryFrustumsTrait for WTrajectoryFrustums { - #[inline] fn as_raw_mut_WTrajectoryFrustums(&mut self) -> *mut c_void { self.as_raw_mut() } + opencv_type_boxed! { WTrajectoryFrustums } + + impl Drop for WTrajectoryFrustums { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_viz_WTrajectoryFrustums_delete(self.as_raw_mut_WTrajectoryFrustums()) }; + } } - boxed_ref! { WTrajectoryFrustums, crate::viz::WTrajectoryFrustumsTraitConst, as_raw_WTrajectoryFrustums, crate::viz::WTrajectoryFrustumsTrait, as_raw_mut_WTrajectoryFrustums } + unsafe impl Send for WTrajectoryFrustums {} impl WTrajectoryFrustums { /// Constructs a WTrajectoryFrustums. @@ -5935,9 +5893,17 @@ pub mod viz { } - boxed_cast_base! { WTrajectoryFrustums, crate::viz::Widget, cv_viz_WTrajectoryFrustums_to_Widget } + /// Constant methods for [crate::viz::WTrajectoryFrustums] + pub trait WTrajectoryFrustumsTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WTrajectoryFrustums(&self) -> *const c_void; - boxed_cast_base! { WTrajectoryFrustums, crate::viz::Widget3D, cv_viz_WTrajectoryFrustums_to_Widget3D } + } + + /// Mutable methods for [crate::viz::WTrajectoryFrustums] + pub trait WTrajectoryFrustumsTrait: crate::viz::WTrajectoryFrustumsTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WTrajectoryFrustums(&mut self) -> *mut c_void; + + } impl std::fmt::Debug for WTrajectoryFrustums { #[inline] @@ -5947,18 +5913,40 @@ pub mod viz { } } - /// Constant methods for [crate::viz::WTrajectorySpheres] - pub trait WTrajectorySpheresTraitConst: crate::viz::Widget3DTraitConst { - fn as_raw_WTrajectorySpheres(&self) -> *const c_void; + boxed_cast_base! { WTrajectoryFrustums, crate::viz::Widget, cv_viz_WTrajectoryFrustums_to_Widget } + + boxed_cast_base! { WTrajectoryFrustums, crate::viz::Widget3D, cv_viz_WTrajectoryFrustums_to_Widget3D } + impl crate::viz::WidgetTraitConst for WTrajectoryFrustums { + #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::viz::WTrajectorySpheres] - pub trait WTrajectorySpheresTrait: crate::viz::WTrajectorySpheresTraitConst + crate::viz::Widget3DTrait { - fn as_raw_mut_WTrajectorySpheres(&mut self) -> *mut c_void; + impl crate::viz::WidgetTrait for WTrajectoryFrustums { + #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { WTrajectoryFrustums, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + + impl crate::viz::Widget3DTraitConst for WTrajectoryFrustums { + #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + } + + impl crate::viz::Widget3DTrait for WTrajectoryFrustums { + #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { WTrajectoryFrustums, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + + impl crate::viz::WTrajectoryFrustumsTraitConst for WTrajectoryFrustums { + #[inline] fn as_raw_WTrajectoryFrustums(&self) -> *const c_void { self.as_raw() } + } + impl crate::viz::WTrajectoryFrustumsTrait for WTrajectoryFrustums { + #[inline] fn as_raw_mut_WTrajectoryFrustums(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { WTrajectoryFrustums, crate::viz::WTrajectoryFrustumsTraitConst, as_raw_WTrajectoryFrustums, crate::viz::WTrajectoryFrustumsTrait, as_raw_mut_WTrajectoryFrustums } + /// This 3D Widget represents a trajectory using spheres and lines /// /// where spheres represent the positions of the camera, and lines represent the direction from @@ -5978,36 +5966,6 @@ pub mod viz { unsafe impl Send for WTrajectorySpheres {} - impl crate::viz::WidgetTraitConst for WTrajectorySpheres { - #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::WidgetTrait for WTrajectorySpheres { - #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WTrajectorySpheres, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - - impl crate::viz::Widget3DTraitConst for WTrajectorySpheres { - #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::Widget3DTrait for WTrajectorySpheres { - #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WTrajectorySpheres, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } - - impl crate::viz::WTrajectorySpheresTraitConst for WTrajectorySpheres { - #[inline] fn as_raw_WTrajectorySpheres(&self) -> *const c_void { self.as_raw() } - } - - impl crate::viz::WTrajectorySpheresTrait for WTrajectorySpheres { - #[inline] fn as_raw_mut_WTrajectorySpheres(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { WTrajectorySpheres, crate::viz::WTrajectorySpheresTraitConst, as_raw_WTrajectorySpheres, crate::viz::WTrajectorySpheresTrait, as_raw_mut_WTrajectorySpheres } - impl WTrajectorySpheres { /// Constructs a WTrajectorySpheres. /// @@ -6050,30 +6008,106 @@ pub mod viz { /// * from: Color::red() /// * to: Color::white() #[inline] - pub fn new_def(path: &impl ToInputArray) -> Result { - input_array_arg!(path); + pub fn new_def(path: &impl ToInputArray) -> Result { + input_array_arg!(path); + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_WTrajectorySpheres_WTrajectorySpheres_const__InputArrayR(path.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::viz::WTrajectorySpheres::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Constant methods for [crate::viz::WTrajectorySpheres] + pub trait WTrajectorySpheresTraitConst: crate::viz::Widget3DTraitConst { + fn as_raw_WTrajectorySpheres(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::viz::WTrajectorySpheres] + pub trait WTrajectorySpheresTrait: crate::viz::WTrajectorySpheresTraitConst + crate::viz::Widget3DTrait { + fn as_raw_mut_WTrajectorySpheres(&mut self) -> *mut c_void; + + } + + impl std::fmt::Debug for WTrajectorySpheres { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("WTrajectorySpheres") + .finish() + } + } + + boxed_cast_base! { WTrajectorySpheres, crate::viz::Widget, cv_viz_WTrajectorySpheres_to_Widget } + + boxed_cast_base! { WTrajectorySpheres, crate::viz::Widget3D, cv_viz_WTrajectorySpheres_to_Widget3D } + + impl crate::viz::WidgetTraitConst for WTrajectorySpheres { + #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } + } + + impl crate::viz::WidgetTrait for WTrajectorySpheres { + #[inline] fn as_raw_mut_Widget(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { WTrajectorySpheres, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } + + impl crate::viz::Widget3DTraitConst for WTrajectorySpheres { + #[inline] fn as_raw_Widget3D(&self) -> *const c_void { self.as_raw() } + } + + impl crate::viz::Widget3DTrait for WTrajectorySpheres { + #[inline] fn as_raw_mut_Widget3D(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { WTrajectorySpheres, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } + + impl crate::viz::WTrajectorySpheresTraitConst for WTrajectorySpheres { + #[inline] fn as_raw_WTrajectorySpheres(&self) -> *const c_void { self.as_raw() } + } + + impl crate::viz::WTrajectorySpheresTrait for WTrajectorySpheres { + #[inline] fn as_raw_mut_WTrajectorySpheres(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { WTrajectorySpheres, crate::viz::WTrajectorySpheresTraitConst, as_raw_WTrajectorySpheres, crate::viz::WTrajectorySpheresTrait, as_raw_mut_WTrajectorySpheres } + + /// This class allows to merge several widgets to single one. + /// + /// It has quite limited functionality and can't merge widgets with different attributes. For + /// instance, if widgetA has color array and widgetB has only global color defined, then result + /// of merge won't have color at all. The class is suitable for merging large amount of similar + /// widgets. : + pub struct WWidgetMerger { + ptr: *mut c_void, + } + + opencv_type_boxed! { WWidgetMerger } + + impl Drop for WWidgetMerger { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_viz_WWidgetMerger_delete(self.as_raw_mut_WWidgetMerger()) }; + } + } + + unsafe impl Send for WWidgetMerger {} + + impl WWidgetMerger { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_viz_WTrajectorySpheres_WTrajectorySpheres_const__InputArrayR(path.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_viz_WWidgetMerger_WWidgetMerger(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::viz::WTrajectorySpheres::opencv_from_extern(ret) }; + let ret = unsafe { crate::viz::WWidgetMerger::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { WTrajectorySpheres, crate::viz::Widget, cv_viz_WTrajectorySpheres_to_Widget } - - boxed_cast_base! { WTrajectorySpheres, crate::viz::Widget3D, cv_viz_WTrajectorySpheres_to_Widget3D } - - impl std::fmt::Debug for WTrajectorySpheres { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("WTrajectorySpheres") - .finish() - } - } - /// Constant methods for [crate::viz::WWidgetMerger] pub trait WWidgetMergerTraitConst: crate::viz::Widget3DTraitConst { fn as_raw_WWidgetMerger(&self) -> *const c_void; @@ -6123,26 +6157,17 @@ pub mod viz { } - /// This class allows to merge several widgets to single one. - /// - /// It has quite limited functionality and can't merge widgets with different attributes. For - /// instance, if widgetA has color array and widgetB has only global color defined, then result - /// of merge won't have color at all. The class is suitable for merging large amount of similar - /// widgets. : - pub struct WWidgetMerger { - ptr: *mut c_void, - } - - opencv_type_boxed! { WWidgetMerger } - - impl Drop for WWidgetMerger { + impl std::fmt::Debug for WWidgetMerger { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_WWidgetMerger_delete(self.as_raw_mut_WWidgetMerger()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("WWidgetMerger") + .finish() } } - unsafe impl Send for WWidgetMerger {} + boxed_cast_base! { WWidgetMerger, crate::viz::Widget, cv_viz_WWidgetMerger_to_Widget } + + boxed_cast_base! { WWidgetMerger, crate::viz::Widget3D, cv_viz_WWidgetMerger_to_Widget3D } impl crate::viz::WidgetTraitConst for WWidgetMerger { #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } @@ -6174,29 +6199,58 @@ pub mod viz { boxed_ref! { WWidgetMerger, crate::viz::WWidgetMergerTraitConst, as_raw_WWidgetMerger, crate::viz::WWidgetMergerTrait, as_raw_mut_WWidgetMerger } - impl WWidgetMerger { + /// Base class of all widgets. Widget is implicitly shared. + pub struct Widget { + ptr: *mut c_void, + } + + opencv_type_boxed! { Widget } + + impl Drop for Widget { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_viz_Widget_delete(self.as_raw_mut_Widget()) }; + } + } + + unsafe impl Send for Widget {} + + impl Widget { + #[inline] + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_viz_WWidgetMerger_WWidgetMerger(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_viz_Widget_Widget(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::viz::WWidgetMerger::opencv_from_extern(ret) }; + let ret = unsafe { crate::viz::Widget::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { WWidgetMerger, crate::viz::Widget, cv_viz_WWidgetMerger_to_Widget } - - boxed_cast_base! { WWidgetMerger, crate::viz::Widget3D, cv_viz_WWidgetMerger_to_Widget3D } + #[inline] + pub fn copy(other: &impl crate::viz::WidgetTraitConst) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_Widget_Widget_const_WidgetR(other.as_raw_Widget(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::viz::Widget::opencv_from_extern(ret) }; + Ok(ret) + } - impl std::fmt::Debug for WWidgetMerger { + /// Creates a widget from ply file. + /// + /// ## Parameters + /// * file_name: Ply file name. #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("WWidgetMerger") - .finish() + pub fn from_ply_file(file_name: &str) -> Result { + extern_container_arg!(file_name); + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_Widget_fromPlyFile_const_StringR(file_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::viz::Widget::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::viz::Widget] @@ -6288,22 +6342,14 @@ pub mod viz { } - /// Base class of all widgets. Widget is implicitly shared. - pub struct Widget { - ptr: *mut c_void, - } - - opencv_type_boxed! { Widget } - - impl Drop for Widget { + impl std::fmt::Debug for Widget { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_Widget_delete(self.as_raw_mut_Widget()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Widget") + .finish() } } - unsafe impl Send for Widget {} - impl crate::viz::WidgetTraitConst for Widget { #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } } @@ -6314,52 +6360,35 @@ pub mod viz { boxed_ref! { Widget, crate::viz::WidgetTraitConst, as_raw_Widget, crate::viz::WidgetTrait, as_raw_mut_Widget } - impl Widget { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Widget_Widget(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::viz::Widget::opencv_from_extern(ret) }; - Ok(ret) - } + /// Base class of all 2D widgets. + pub struct Widget2D { + ptr: *mut c_void, + } + + opencv_type_boxed! { Widget2D } + impl Drop for Widget2D { #[inline] - pub fn copy(other: &impl crate::viz::WidgetTraitConst) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Widget_Widget_const_WidgetR(other.as_raw_Widget(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::viz::Widget::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_viz_Widget2D_delete(self.as_raw_mut_Widget2D()) }; } + } - /// Creates a widget from ply file. - /// - /// ## Parameters - /// * file_name: Ply file name. + unsafe impl Send for Widget2D {} + + impl Widget2D { #[inline] - pub fn from_ply_file(file_name: &str) -> Result { - extern_container_arg!(file_name); + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Widget_fromPlyFile_const_StringR(file_name.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_viz_Widget2D_Widget2D(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::viz::Widget::opencv_from_extern(ret) }; + let ret = unsafe { crate::viz::Widget2D::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for Widget { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Widget") - .finish() - } - } - /// Constant methods for [crate::viz::Widget2D] pub trait Widget2DTraitConst: crate::viz::WidgetTraitConst { fn as_raw_Widget2D(&self) -> *const c_void; @@ -6385,21 +6414,15 @@ pub mod viz { } - /// Base class of all 2D widgets. - pub struct Widget2D { - ptr: *mut c_void, - } - - opencv_type_boxed! { Widget2D } - - impl Drop for Widget2D { + impl std::fmt::Debug for Widget2D { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_Widget2D_delete(self.as_raw_mut_Widget2D()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Widget2D") + .finish() } } - unsafe impl Send for Widget2D {} + boxed_cast_base! { Widget2D, crate::viz::Widget, cv_viz_Widget2D_to_Widget } impl crate::viz::WidgetTraitConst for Widget2D { #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } @@ -6421,27 +6444,33 @@ pub mod viz { boxed_ref! { Widget2D, crate::viz::Widget2DTraitConst, as_raw_Widget2D, crate::viz::Widget2DTrait, as_raw_mut_Widget2D } - impl Widget2D { + /// Base class of all 3D widgets. + pub struct Widget3D { + ptr: *mut c_void, + } + + opencv_type_boxed! { Widget3D } + + impl Drop for Widget3D { #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Widget2D_Widget2D(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::viz::Widget2D::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_viz_Widget3D_delete(self.as_raw_mut_Widget3D()) }; } - } - boxed_cast_base! { Widget2D, crate::viz::Widget, cv_viz_Widget2D_to_Widget } + unsafe impl Send for Widget3D {} - impl std::fmt::Debug for Widget2D { + impl Widget3D { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Widget2D") - .finish() + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_viz_Widget3D_Widget3D(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::viz::Widget3D::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::viz::Widget3D] @@ -6518,21 +6547,15 @@ pub mod viz { } - /// Base class of all 3D widgets. - pub struct Widget3D { - ptr: *mut c_void, - } - - opencv_type_boxed! { Widget3D } - - impl Drop for Widget3D { + impl std::fmt::Debug for Widget3D { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_viz_Widget3D_delete(self.as_raw_mut_Widget3D()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Widget3D") + .finish() } } - unsafe impl Send for Widget3D {} + boxed_cast_base! { Widget3D, crate::viz::Widget, cv_viz_Widget3D_to_Widget } impl crate::viz::WidgetTraitConst for Widget3D { #[inline] fn as_raw_Widget(&self) -> *const c_void { self.as_raw() } @@ -6554,26 +6577,4 @@ pub mod viz { boxed_ref! { Widget3D, crate::viz::Widget3DTraitConst, as_raw_Widget3D, crate::viz::Widget3DTrait, as_raw_mut_Widget3D } - impl Widget3D { - #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_viz_Widget3D_Widget3D(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::viz::Widget3D::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { Widget3D, crate::viz::Widget, cv_viz_Widget3D_to_Widget } - - impl std::fmt::Debug for Widget3D { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Widget3D") - .finish() - } - } } diff --git a/docs/wechat_qrcode.rs b/docs/wechat_qrcode.rs index 7fdd12e45..2313358a9 100644 --- a/docs/wechat_qrcode.rs +++ b/docs/wechat_qrcode.rs @@ -6,6 +6,84 @@ pub mod wechat_qrcode { pub use super::{WeChatQRCodeTrait, WeChatQRCodeTraitConst}; } + /// * WeChat QRCode includes two CNN-based models: + /// * A object detection model and a super resolution model. + /// * Object detection model is applied to detect QRCode with the bounding box. + /// * super resolution model is applied to zoom in QRCode when it is small. + ///* + pub struct WeChatQRCode { + ptr: *mut c_void, + } + + opencv_type_boxed! { WeChatQRCode } + + impl Drop for WeChatQRCode { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_wechat_qrcode_WeChatQRCode_delete(self.as_raw_mut_WeChatQRCode()) }; + } + } + + unsafe impl Send for WeChatQRCode {} + + impl WeChatQRCode { + /// Initialize the WeChatQRCode. + /// It includes two models, which are packaged with caffe format. + /// Therefore, there are prototxt and caffe models (In total, four paramenters). + /// + /// ## Parameters + /// * detector_prototxt_path: prototxt file path for the detector + /// * detector_caffe_model_path: caffe model file path for the detector + /// * super_resolution_prototxt_path: prototxt file path for the super resolution model + /// * super_resolution_caffe_model_path: caffe file path for the super resolution model + /// + /// ## C++ default parameters + /// * detector_prototxt_path: "" + /// * detector_caffe_model_path: "" + /// * super_resolution_prototxt_path: "" + /// * super_resolution_caffe_model_path: "" + #[inline] + pub fn new(detector_prototxt_path: &str, detector_caffe_model_path: &str, super_resolution_prototxt_path: &str, super_resolution_caffe_model_path: &str) -> Result { + extern_container_arg!(detector_prototxt_path); + extern_container_arg!(detector_caffe_model_path); + extern_container_arg!(super_resolution_prototxt_path); + extern_container_arg!(super_resolution_caffe_model_path); + return_send!(via ocvrs_return); + unsafe { sys::cv_wechat_qrcode_WeChatQRCode_WeChatQRCode_const_stringR_const_stringR_const_stringR_const_stringR(detector_prototxt_path.opencv_as_extern(), detector_caffe_model_path.opencv_as_extern(), super_resolution_prototxt_path.opencv_as_extern(), super_resolution_caffe_model_path.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::wechat_qrcode::WeChatQRCode::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Initialize the WeChatQRCode. + /// It includes two models, which are packaged with caffe format. + /// Therefore, there are prototxt and caffe models (In total, four paramenters). + /// + /// ## Parameters + /// * detector_prototxt_path: prototxt file path for the detector + /// * detector_caffe_model_path: caffe model file path for the detector + /// * super_resolution_prototxt_path: prototxt file path for the super resolution model + /// * super_resolution_caffe_model_path: caffe file path for the super resolution model + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * detector_prototxt_path: "" + /// * detector_caffe_model_path: "" + /// * super_resolution_prototxt_path: "" + /// * super_resolution_caffe_model_path: "" + #[inline] + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_wechat_qrcode_WeChatQRCode_WeChatQRCode(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::wechat_qrcode::WeChatQRCode::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::wechat_qrcode::WeChatQRCode] pub trait WeChatQRCodeTraitConst { fn as_raw_WeChatQRCode(&self) -> *const c_void; @@ -94,26 +172,14 @@ pub mod wechat_qrcode { } - /// * WeChat QRCode includes two CNN-based models: - /// * A object detection model and a super resolution model. - /// * Object detection model is applied to detect QRCode with the bounding box. - /// * super resolution model is applied to zoom in QRCode when it is small. - ///* - pub struct WeChatQRCode { - ptr: *mut c_void, - } - - opencv_type_boxed! { WeChatQRCode } - - impl Drop for WeChatQRCode { + impl std::fmt::Debug for WeChatQRCode { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_wechat_qrcode_WeChatQRCode_delete(self.as_raw_mut_WeChatQRCode()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("WeChatQRCode") + .finish() } } - unsafe impl Send for WeChatQRCode {} - impl crate::wechat_qrcode::WeChatQRCodeTraitConst for WeChatQRCode { #[inline] fn as_raw_WeChatQRCode(&self) -> *const c_void { self.as_raw() } } @@ -124,69 +190,4 @@ pub mod wechat_qrcode { boxed_ref! { WeChatQRCode, crate::wechat_qrcode::WeChatQRCodeTraitConst, as_raw_WeChatQRCode, crate::wechat_qrcode::WeChatQRCodeTrait, as_raw_mut_WeChatQRCode } - impl WeChatQRCode { - /// Initialize the WeChatQRCode. - /// It includes two models, which are packaged with caffe format. - /// Therefore, there are prototxt and caffe models (In total, four paramenters). - /// - /// ## Parameters - /// * detector_prototxt_path: prototxt file path for the detector - /// * detector_caffe_model_path: caffe model file path for the detector - /// * super_resolution_prototxt_path: prototxt file path for the super resolution model - /// * super_resolution_caffe_model_path: caffe file path for the super resolution model - /// - /// ## C++ default parameters - /// * detector_prototxt_path: "" - /// * detector_caffe_model_path: "" - /// * super_resolution_prototxt_path: "" - /// * super_resolution_caffe_model_path: "" - #[inline] - pub fn new(detector_prototxt_path: &str, detector_caffe_model_path: &str, super_resolution_prototxt_path: &str, super_resolution_caffe_model_path: &str) -> Result { - extern_container_arg!(detector_prototxt_path); - extern_container_arg!(detector_caffe_model_path); - extern_container_arg!(super_resolution_prototxt_path); - extern_container_arg!(super_resolution_caffe_model_path); - return_send!(via ocvrs_return); - unsafe { sys::cv_wechat_qrcode_WeChatQRCode_WeChatQRCode_const_stringR_const_stringR_const_stringR_const_stringR(detector_prototxt_path.opencv_as_extern(), detector_caffe_model_path.opencv_as_extern(), super_resolution_prototxt_path.opencv_as_extern(), super_resolution_caffe_model_path.opencv_as_extern(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::wechat_qrcode::WeChatQRCode::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Initialize the WeChatQRCode. - /// It includes two models, which are packaged with caffe format. - /// Therefore, there are prototxt and caffe models (In total, four paramenters). - /// - /// ## Parameters - /// * detector_prototxt_path: prototxt file path for the detector - /// * detector_caffe_model_path: caffe model file path for the detector - /// * super_resolution_prototxt_path: prototxt file path for the super resolution model - /// * super_resolution_caffe_model_path: caffe file path for the super resolution model - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * detector_prototxt_path: "" - /// * detector_caffe_model_path: "" - /// * super_resolution_prototxt_path: "" - /// * super_resolution_caffe_model_path: "" - #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_wechat_qrcode_WeChatQRCode_WeChatQRCode(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::wechat_qrcode::WeChatQRCode::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for WeChatQRCode { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("WeChatQRCode") - .finish() - } - } } diff --git a/docs/xfeatures2d.rs b/docs/xfeatures2d.rs index c45350d12..f4b47fb8b 100644 --- a/docs/xfeatures2d.rs +++ b/docs/xfeatures2d.rs @@ -407,6 +407,157 @@ pub mod xfeatures2d { Ok(ret) } + /// Class used for extracting Speeded Up Robust Features (SURF) from an image. : + /// + /// The class SURF_CUDA implements Speeded Up Robust Features descriptor. There is a fast multi-scale + /// Hessian keypoint detector that can be used to find the keypoints (which is the default option). But + /// the descriptors can also be computed for the user-specified keypoints. Only 8-bit grayscale images + /// are supported. + /// + /// The class SURF_CUDA can store results in the GPU and CPU memory. It provides functions to convert + /// results between CPU and GPU version ( uploadKeypoints, downloadKeypoints, downloadDescriptors ). The + /// format of CPU results is the same as SURF results. GPU results are stored in GpuMat. The keypoints + /// matrix is ![inline formula](https://latex.codecogs.com/png.latex?%5Ctexttt%7BnFeatures%7D%20%5Ctimes%207) matrix with the CV_32FC1 type. + /// + /// * keypoints.ptr\(X_ROW)[i] contains x coordinate of the i-th feature. + /// * keypoints.ptr\(Y_ROW)[i] contains y coordinate of the i-th feature. + /// * keypoints.ptr\(LAPLACIAN_ROW)[i] contains the laplacian sign of the i-th feature. + /// * keypoints.ptr\(OCTAVE_ROW)[i] contains the octave of the i-th feature. + /// * keypoints.ptr\(SIZE_ROW)[i] contains the size of the i-th feature. + /// * keypoints.ptr\(ANGLE_ROW)[i] contain orientation of the i-th feature. + /// * keypoints.ptr\(HESSIAN_ROW)[i] contains the response of the i-th feature. + /// + /// The descriptors matrix is ![inline formula](https://latex.codecogs.com/png.latex?%5Ctexttt%7BnFeatures%7D%20%5Ctimes%20%5Ctexttt%7BdescriptorSize%7D) matrix with the + /// CV_32FC1 type. + /// + /// The class SURF_CUDA uses some buffers and provides access to it. All buffers can be safely released + /// between function calls. + /// ## See also + /// SURF + /// + /// + /// Note: + /// * An example for using the SURF keypoint matcher on GPU can be found at + /// opencv_source_code/samples/gpu/surf_keypoint_matcher.cpp + pub struct SURF_CUDA { + ptr: *mut c_void, + } + + opencv_type_boxed! { SURF_CUDA } + + impl Drop for SURF_CUDA { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_cuda_SURF_CUDA_delete(self.as_raw_mut_SURF_CUDA()) }; + } + } + + unsafe impl Send for SURF_CUDA {} + + impl SURF_CUDA { + /// the default constructor + #[inline] + pub fn default() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_SURF_CUDA_SURF_CUDA(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::xfeatures2d::SURF_CUDA::opencv_from_extern(ret) }; + Ok(ret) + } + + /// the full constructor taking all the necessary parameters + /// + /// ## C++ default parameters + /// * _n_octaves: 4 + /// * _n_octave_layers: 2 + /// * _extended: false + /// * _keypoints_ratio: 0.01f + /// * _upright: false + #[inline] + pub fn new(_hessian_threshold: f64, _n_octaves: i32, _n_octave_layers: i32, _extended: bool, _keypoints_ratio: f32, _upright: bool) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_SURF_CUDA_SURF_CUDA_double_int_int_bool_float_bool(_hessian_threshold, _n_octaves, _n_octave_layers, _extended, _keypoints_ratio, _upright, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::xfeatures2d::SURF_CUDA::opencv_from_extern(ret) }; + Ok(ret) + } + + /// the full constructor taking all the necessary parameters + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * _n_octaves: 4 + /// * _n_octave_layers: 2 + /// * _extended: false + /// * _keypoints_ratio: 0.01f + /// * _upright: false + #[inline] + pub fn new_def(_hessian_threshold: f64) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_SURF_CUDA_SURF_CUDA_double(_hessian_threshold, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::xfeatures2d::SURF_CUDA::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Parameters + /// * _hessianThreshold: Threshold for hessian keypoint detector used in SURF. + /// * _nOctaves: Number of pyramid octaves the keypoint detector will use. + /// * _nOctaveLayers: Number of octave layers within each octave. + /// * _extended: Extended descriptor flag (true - use extended 128-element descriptors; false - use + /// 64-element descriptors). + /// * _keypointsRatio: Limits a maximum number of features + /// * _upright: Up-right or rotated features flag (true - do not compute orientation of features; + /// false - compute orientation). + /// + /// ## C++ default parameters + /// * _n_octaves: 4 + /// * _n_octave_layers: 2 + /// * _extended: false + /// * _keypoints_ratio: 0.01f + /// * _upright: false + #[inline] + pub fn create(_hessian_threshold: f64, _n_octaves: i32, _n_octave_layers: i32, _extended: bool, _keypoints_ratio: f32, _upright: bool) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_SURF_CUDA_create_double_int_int_bool_float_bool(_hessian_threshold, _n_octaves, _n_octave_layers, _extended, _keypoints_ratio, _upright, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Parameters + /// * _hessianThreshold: Threshold for hessian keypoint detector used in SURF. + /// * _nOctaves: Number of pyramid octaves the keypoint detector will use. + /// * _nOctaveLayers: Number of octave layers within each octave. + /// * _extended: Extended descriptor flag (true - use extended 128-element descriptors; false - use + /// 64-element descriptors). + /// * _keypointsRatio: Limits a maximum number of features + /// * _upright: Up-right or rotated features flag (true - do not compute orientation of features; + /// false - compute orientation). + /// + /// ## Note + /// This alternative version of [SURF_CUDA::create] function uses the following default values for its arguments: + /// * _n_octaves: 4 + /// * _n_octave_layers: 2 + /// * _extended: false + /// * _keypoints_ratio: 0.01f + /// * _upright: false + #[inline] + pub fn create_def(_hessian_threshold: f64) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_cuda_SURF_CUDA_create_double(_hessian_threshold, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::xfeatures2d::SURF_CUDA] pub trait SURF_CUDATraitConst { fn as_raw_SURF_CUDA(&self) -> *const c_void; @@ -789,53 +940,26 @@ pub mod xfeatures2d { } - /// Class used for extracting Speeded Up Robust Features (SURF) from an image. : - /// - /// The class SURF_CUDA implements Speeded Up Robust Features descriptor. There is a fast multi-scale - /// Hessian keypoint detector that can be used to find the keypoints (which is the default option). But - /// the descriptors can also be computed for the user-specified keypoints. Only 8-bit grayscale images - /// are supported. - /// - /// The class SURF_CUDA can store results in the GPU and CPU memory. It provides functions to convert - /// results between CPU and GPU version ( uploadKeypoints, downloadKeypoints, downloadDescriptors ). The - /// format of CPU results is the same as SURF results. GPU results are stored in GpuMat. The keypoints - /// matrix is ![inline formula](https://latex.codecogs.com/png.latex?%5Ctexttt%7BnFeatures%7D%20%5Ctimes%207) matrix with the CV_32FC1 type. - /// - /// * keypoints.ptr\(X_ROW)[i] contains x coordinate of the i-th feature. - /// * keypoints.ptr\(Y_ROW)[i] contains y coordinate of the i-th feature. - /// * keypoints.ptr\(LAPLACIAN_ROW)[i] contains the laplacian sign of the i-th feature. - /// * keypoints.ptr\(OCTAVE_ROW)[i] contains the octave of the i-th feature. - /// * keypoints.ptr\(SIZE_ROW)[i] contains the size of the i-th feature. - /// * keypoints.ptr\(ANGLE_ROW)[i] contain orientation of the i-th feature. - /// * keypoints.ptr\(HESSIAN_ROW)[i] contains the response of the i-th feature. - /// - /// The descriptors matrix is ![inline formula](https://latex.codecogs.com/png.latex?%5Ctexttt%7BnFeatures%7D%20%5Ctimes%20%5Ctexttt%7BdescriptorSize%7D) matrix with the - /// CV_32FC1 type. - /// - /// The class SURF_CUDA uses some buffers and provides access to it. All buffers can be safely released - /// between function calls. - /// ## See also - /// SURF - /// - /// - /// Note: - /// * An example for using the SURF keypoint matcher on GPU can be found at - /// opencv_source_code/samples/gpu/surf_keypoint_matcher.cpp - pub struct SURF_CUDA { - ptr: *mut c_void, - } - - opencv_type_boxed! { SURF_CUDA } - - impl Drop for SURF_CUDA { + impl std::fmt::Debug for SURF_CUDA { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_cuda_SURF_CUDA_delete(self.as_raw_mut_SURF_CUDA()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SURF_CUDA") + .field("hessian_threshold", &crate::xfeatures2d::SURF_CUDATraitConst::hessian_threshold(self)) + .field("n_octaves", &crate::xfeatures2d::SURF_CUDATraitConst::n_octaves(self)) + .field("n_octave_layers", &crate::xfeatures2d::SURF_CUDATraitConst::n_octave_layers(self)) + .field("extended", &crate::xfeatures2d::SURF_CUDATraitConst::extended(self)) + .field("upright", &crate::xfeatures2d::SURF_CUDATraitConst::upright(self)) + .field("keypoints_ratio", &crate::xfeatures2d::SURF_CUDATraitConst::keypoints_ratio(self)) + .field("sum", &crate::xfeatures2d::SURF_CUDATraitConst::sum(self)) + .field("mask1", &crate::xfeatures2d::SURF_CUDATraitConst::mask1(self)) + .field("mask_sum", &crate::xfeatures2d::SURF_CUDATraitConst::mask_sum(self)) + .field("det", &crate::xfeatures2d::SURF_CUDATraitConst::det(self)) + .field("trace", &crate::xfeatures2d::SURF_CUDATraitConst::trace(self)) + .field("max_pos_buffer", &crate::xfeatures2d::SURF_CUDATraitConst::max_pos_buffer(self)) + .finish() } } - unsafe impl Send for SURF_CUDA {} - impl crate::xfeatures2d::SURF_CUDATraitConst for SURF_CUDA { #[inline] fn as_raw_SURF_CUDA(&self) -> *const c_void { self.as_raw() } } @@ -846,130 +970,56 @@ pub mod xfeatures2d { boxed_ref! { SURF_CUDA, crate::xfeatures2d::SURF_CUDATraitConst, as_raw_SURF_CUDA, crate::xfeatures2d::SURF_CUDATrait, as_raw_mut_SURF_CUDA } - impl SURF_CUDA { - /// the default constructor + /// Class implementing affine adaptation for key points. + /// + /// A [FeatureDetector] and a [DescriptorExtractor] are wrapped to augment the + /// detected points with their affine invariant elliptic region and to compute + /// the feature descriptors on the regions after warping them into circles. + /// + /// The interface is equivalent to [Feature2D], adding operations for + /// [Elliptic_KeyPoint] "Elliptic_KeyPoints" instead of [KeyPoint] "KeyPoints". + pub struct AffineFeature2D { + ptr: *mut c_void, + } + + opencv_type_boxed! { AffineFeature2D } + + impl Drop for AffineFeature2D { #[inline] - pub fn default() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_SURF_CUDA_SURF_CUDA(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::xfeatures2d::SURF_CUDA::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_xfeatures2d_AffineFeature2D_delete(self.as_raw_mut_AffineFeature2D()) }; } + } - /// the full constructor taking all the necessary parameters - /// - /// ## C++ default parameters - /// * _n_octaves: 4 - /// * _n_octave_layers: 2 - /// * _extended: false - /// * _keypoints_ratio: 0.01f - /// * _upright: false + unsafe impl Send for AffineFeature2D {} + + impl AffineFeature2D { + /// Creates an instance wrapping the given keypoint detector and + /// descriptor extractor. #[inline] - pub fn new(_hessian_threshold: f64, _n_octaves: i32, _n_octave_layers: i32, _extended: bool, _keypoints_ratio: f32, _upright: bool) -> Result { + pub fn create(mut keypoint_detector: core::Ptr, mut descriptor_extractor: core::Ptr) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_SURF_CUDA_SURF_CUDA_double_int_int_bool_float_bool(_hessian_threshold, _n_octaves, _n_octave_layers, _extended, _keypoints_ratio, _upright, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_AffineFeature2D_create_PtrLFeature2DG_PtrLFeature2DG(keypoint_detector.as_raw_mut_PtrOfFeature2D(), descriptor_extractor.as_raw_mut_PtrOfFeature2D(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::xfeatures2d::SURF_CUDA::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// the full constructor taking all the necessary parameters - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * _n_octaves: 4 - /// * _n_octave_layers: 2 - /// * _extended: false - /// * _keypoints_ratio: 0.01f - /// * _upright: false - #[inline] - pub fn new_def(_hessian_threshold: f64) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_SURF_CUDA_SURF_CUDA_double(_hessian_threshold, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::xfeatures2d::SURF_CUDA::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Parameters - /// * _hessianThreshold: Threshold for hessian keypoint detector used in SURF. - /// * _nOctaves: Number of pyramid octaves the keypoint detector will use. - /// * _nOctaveLayers: Number of octave layers within each octave. - /// * _extended: Extended descriptor flag (true - use extended 128-element descriptors; false - use - /// 64-element descriptors). - /// * _keypointsRatio: Limits a maximum number of features - /// * _upright: Up-right or rotated features flag (true - do not compute orientation of features; - /// false - compute orientation). - /// - /// ## C++ default parameters - /// * _n_octaves: 4 - /// * _n_octave_layers: 2 - /// * _extended: false - /// * _keypoints_ratio: 0.01f - /// * _upright: false - #[inline] - pub fn create(_hessian_threshold: f64, _n_octaves: i32, _n_octave_layers: i32, _extended: bool, _keypoints_ratio: f32, _upright: bool) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_SURF_CUDA_create_double_int_int_bool_float_bool(_hessian_threshold, _n_octaves, _n_octave_layers, _extended, _keypoints_ratio, _upright, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Parameters - /// * _hessianThreshold: Threshold for hessian keypoint detector used in SURF. - /// * _nOctaves: Number of pyramid octaves the keypoint detector will use. - /// * _nOctaveLayers: Number of octave layers within each octave. - /// * _extended: Extended descriptor flag (true - use extended 128-element descriptors; false - use - /// 64-element descriptors). - /// * _keypointsRatio: Limits a maximum number of features - /// * _upright: Up-right or rotated features flag (true - do not compute orientation of features; - /// false - compute orientation). - /// - /// ## Note - /// This alternative version of [SURF_CUDA::create] function uses the following default values for its arguments: - /// * _n_octaves: 4 - /// * _n_octave_layers: 2 - /// * _extended: false - /// * _keypoints_ratio: 0.01f - /// * _upright: false + /// Creates an instance where keypoint detector and descriptor + /// extractor are identical. #[inline] - pub fn create_def(_hessian_threshold: f64) -> Result> { + pub fn create_1(mut keypoint_detector: core::Ptr) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_cuda_SURF_CUDA_create_double(_hessian_threshold, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_AffineFeature2D_create_PtrLFeature2DG(keypoint_detector.as_raw_mut_PtrOfFeature2D(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - impl std::fmt::Debug for SURF_CUDA { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SURF_CUDA") - .field("hessian_threshold", &crate::xfeatures2d::SURF_CUDATraitConst::hessian_threshold(self)) - .field("n_octaves", &crate::xfeatures2d::SURF_CUDATraitConst::n_octaves(self)) - .field("n_octave_layers", &crate::xfeatures2d::SURF_CUDATraitConst::n_octave_layers(self)) - .field("extended", &crate::xfeatures2d::SURF_CUDATraitConst::extended(self)) - .field("upright", &crate::xfeatures2d::SURF_CUDATraitConst::upright(self)) - .field("keypoints_ratio", &crate::xfeatures2d::SURF_CUDATraitConst::keypoints_ratio(self)) - .field("sum", &crate::xfeatures2d::SURF_CUDATraitConst::sum(self)) - .field("mask1", &crate::xfeatures2d::SURF_CUDATraitConst::mask1(self)) - .field("mask_sum", &crate::xfeatures2d::SURF_CUDATraitConst::mask_sum(self)) - .field("det", &crate::xfeatures2d::SURF_CUDATraitConst::det(self)) - .field("trace", &crate::xfeatures2d::SURF_CUDATraitConst::trace(self)) - .field("max_pos_buffer", &crate::xfeatures2d::SURF_CUDATraitConst::max_pos_buffer(self)) - .finish() - } - } - /// Constant methods for [crate::xfeatures2d::AffineFeature2D] pub trait AffineFeature2DTraitConst: crate::features2d::Feature2DTraitConst { fn as_raw_AffineFeature2D(&self) -> *const c_void; @@ -1049,28 +1099,19 @@ pub mod xfeatures2d { } - /// Class implementing affine adaptation for key points. - /// - /// A [FeatureDetector] and a [DescriptorExtractor] are wrapped to augment the - /// detected points with their affine invariant elliptic region and to compute - /// the feature descriptors on the regions after warping them into circles. - /// - /// The interface is equivalent to [Feature2D], adding operations for - /// [Elliptic_KeyPoint] "Elliptic_KeyPoints" instead of [KeyPoint] "KeyPoints". - pub struct AffineFeature2D { - ptr: *mut c_void, - } - - opencv_type_boxed! { AffineFeature2D } - - impl Drop for AffineFeature2D { + impl std::fmt::Debug for AffineFeature2D { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xfeatures2d_AffineFeature2D_delete(self.as_raw_mut_AffineFeature2D()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AffineFeature2D") + .finish() } } - unsafe impl Send for AffineFeature2D {} + boxed_cast_base! { AffineFeature2D, core::Algorithm, cv_xfeatures2d_AffineFeature2D_to_Algorithm } + + boxed_cast_base! { AffineFeature2D, crate::features2d::Feature2D, cv_xfeatures2d_AffineFeature2D_to_Feature2D } + + boxed_cast_descendant! { AffineFeature2D, crate::xfeatures2d::TBMR, cv_xfeatures2d_AffineFeature2D_to_TBMR } impl core::AlgorithmTraitConst for AffineFeature2D { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1102,47 +1143,90 @@ pub mod xfeatures2d { boxed_ref! { AffineFeature2D, crate::xfeatures2d::AffineFeature2DTraitConst, as_raw_AffineFeature2D, crate::xfeatures2d::AffineFeature2DTrait, as_raw_mut_AffineFeature2D } - impl AffineFeature2D { - /// Creates an instance wrapping the given keypoint detector and - /// descriptor extractor. + /// Class implementing BEBLID (Boosted Efficient Binary Local Image Descriptor), + /// described in [Suarez2020BEBLID](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Suarez2020BEBLID) . + /// + /// BEBLID \cite Suarez2020BEBLID is a efficient binary descriptor learned with boosting. + /// It is able to describe keypoints from any detector just by changing the scale_factor parameter. + /// In several benchmarks it has proved to largely improve other binary descriptors like ORB or + /// BRISK with the same efficiency. BEBLID describes using the difference of mean gray values in + /// different regions of the image around the KeyPoint, the descriptor is specifically optimized for + /// image matching and patch retrieval addressing the asymmetries of these problems. + /// + /// If you find this code useful, please add a reference to the following paper: + ///
Iago Suárez, Ghesn Sfeir, José M. Buenaposada, and Luis Baumela. + /// BEBLID: Boosted efficient binary local image descriptor. + /// Pattern Recognition Letters, 133:366–372, 2020.
+ /// + /// The descriptor was trained using 1 million of randomly sampled pairs of patches + /// (20% positives and 80% negatives) from the Liberty split of the UBC datasets + /// \cite winder2007learning as described in the paper [Suarez2020BEBLID](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Suarez2020BEBLID). + /// You can check in the [AKAZE example](https://raw.githubusercontent.com/opencv/opencv/master/samples/cpp/tutorial_code/features2D/AKAZE_match.cpp) + /// how well BEBLID works. Detecting 10000 keypoints with ORB and describing with BEBLID obtains + /// 561 inliers (75%) whereas describing with ORB obtains only 493 inliers (63%). + pub struct BEBLID { + ptr: *mut c_void, + } + + opencv_type_boxed! { BEBLID } + + impl Drop for BEBLID { #[inline] - pub fn create(mut keypoint_detector: core::Ptr, mut descriptor_extractor: core::Ptr) -> Result> { + fn drop(&mut self) { + unsafe { sys::cv_xfeatures2d_BEBLID_delete(self.as_raw_mut_BEBLID()) }; + } + } + + unsafe impl Send for BEBLID {} + + impl BEBLID { + /// Creates the BEBLID descriptor. + /// ## Parameters + /// * scale_factor: Adjust the sampling window around detected keypoints: + /// - 1.00f should be the scale for ORB keypoints + /// - 6.75f should be the scale for SIFT detected keypoints + /// - 6.25f is default and fits for KAZE, SURF detected keypoints + /// - 5.00f should be the scale for AKAZE, MSD, AGAST, FAST, BRISK keypoints + /// * n_bits: Determine the number of bits in the descriptor. Should be either + /// BEBLID::SIZE_512_BITS or BEBLID::SIZE_256_BITS. + /// + /// ## C++ default parameters + /// * n_bits: BEBLID::SIZE_512_BITS + #[inline] + pub fn create(scale_factor: f32, n_bits: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_AffineFeature2D_create_PtrLFeature2DG_PtrLFeature2DG(keypoint_detector.as_raw_mut_PtrOfFeature2D(), descriptor_extractor.as_raw_mut_PtrOfFeature2D(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_BEBLID_create_float_int(scale_factor, n_bits, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Creates an instance where keypoint detector and descriptor - /// extractor are identical. + /// Creates the BEBLID descriptor. + /// ## Parameters + /// * scale_factor: Adjust the sampling window around detected keypoints: + /// - 1.00f should be the scale for ORB keypoints + /// - 6.75f should be the scale for SIFT detected keypoints + /// - 6.25f is default and fits for KAZE, SURF detected keypoints + /// - 5.00f should be the scale for AKAZE, MSD, AGAST, FAST, BRISK keypoints + /// * n_bits: Determine the number of bits in the descriptor. Should be either + /// BEBLID::SIZE_512_BITS or BEBLID::SIZE_256_BITS. + /// + /// ## Note + /// This alternative version of [BEBLID::create] function uses the following default values for its arguments: + /// * n_bits: BEBLID::SIZE_512_BITS #[inline] - pub fn create_1(mut keypoint_detector: core::Ptr) -> Result> { + pub fn create_def(scale_factor: f32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_AffineFeature2D_create_PtrLFeature2DG(keypoint_detector.as_raw_mut_PtrOfFeature2D(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_BEBLID_create_float(scale_factor, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_descendant! { AffineFeature2D, crate::xfeatures2d::TBMR, cv_xfeatures2d_AffineFeature2D_to_TBMR } - - boxed_cast_base! { AffineFeature2D, core::Algorithm, cv_xfeatures2d_AffineFeature2D_to_Algorithm } - - boxed_cast_base! { AffineFeature2D, crate::features2d::Feature2D, cv_xfeatures2d_AffineFeature2D_to_Feature2D } - - impl std::fmt::Debug for AffineFeature2D { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AffineFeature2D") - .finish() - } - } - /// Constant methods for [crate::xfeatures2d::BEBLID] pub trait BEBLIDTraitConst: crate::features2d::Feature2DTraitConst { fn as_raw_BEBLID(&self) -> *const c_void; @@ -1183,41 +1267,17 @@ pub mod xfeatures2d { } - /// Class implementing BEBLID (Boosted Efficient Binary Local Image Descriptor), - /// described in [Suarez2020BEBLID](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Suarez2020BEBLID) . - /// - /// BEBLID \cite Suarez2020BEBLID is a efficient binary descriptor learned with boosting. - /// It is able to describe keypoints from any detector just by changing the scale_factor parameter. - /// In several benchmarks it has proved to largely improve other binary descriptors like ORB or - /// BRISK with the same efficiency. BEBLID describes using the difference of mean gray values in - /// different regions of the image around the KeyPoint, the descriptor is specifically optimized for - /// image matching and patch retrieval addressing the asymmetries of these problems. - /// - /// If you find this code useful, please add a reference to the following paper: - ///
Iago Suárez, Ghesn Sfeir, José M. Buenaposada, and Luis Baumela. - /// BEBLID: Boosted efficient binary local image descriptor. - /// Pattern Recognition Letters, 133:366–372, 2020.
- /// - /// The descriptor was trained using 1 million of randomly sampled pairs of patches - /// (20% positives and 80% negatives) from the Liberty split of the UBC datasets - /// \cite winder2007learning as described in the paper [Suarez2020BEBLID](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Suarez2020BEBLID). - /// You can check in the [AKAZE example](https://raw.githubusercontent.com/opencv/opencv/master/samples/cpp/tutorial_code/features2D/AKAZE_match.cpp) - /// how well BEBLID works. Detecting 10000 keypoints with ORB and describing with BEBLID obtains - /// 561 inliers (75%) whereas describing with ORB obtains only 493 inliers (63%). - pub struct BEBLID { - ptr: *mut c_void, - } - - opencv_type_boxed! { BEBLID } - - impl Drop for BEBLID { + impl std::fmt::Debug for BEBLID { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xfeatures2d_BEBLID_delete(self.as_raw_mut_BEBLID()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BEBLID") + .finish() } } - unsafe impl Send for BEBLID {} + boxed_cast_base! { BEBLID, core::Algorithm, cv_xfeatures2d_BEBLID_to_Algorithm } + + boxed_cast_base! { BEBLID, crate::features2d::Feature2D, cv_xfeatures2d_BEBLID_to_Feature2D } impl core::AlgorithmTraitConst for BEBLID { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1249,64 +1309,77 @@ pub mod xfeatures2d { boxed_ref! { BEBLID, crate::xfeatures2d::BEBLIDTraitConst, as_raw_BEBLID, crate::xfeatures2d::BEBLIDTrait, as_raw_mut_BEBLID } - impl BEBLID { - /// Creates the BEBLID descriptor. - /// ## Parameters - /// * scale_factor: Adjust the sampling window around detected keypoints: - /// - 1.00f should be the scale for ORB keypoints - /// - 6.75f should be the scale for SIFT detected keypoints - /// - 6.25f is default and fits for KAZE, SURF detected keypoints - /// - 5.00f should be the scale for AKAZE, MSD, AGAST, FAST, BRISK keypoints - /// * n_bits: Determine the number of bits in the descriptor. Should be either - /// BEBLID::SIZE_512_BITS or BEBLID::SIZE_256_BITS. - /// - /// ## C++ default parameters - /// * n_bits: BEBLID::SIZE_512_BITS + /// Class implementing BoostDesc (Learning Image Descriptors with Boosting), described in + /// [Trzcinski13a](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Trzcinski13a) and [Trzcinski13b](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Trzcinski13b). + /// + /// ## Parameters + /// * desc: type of descriptor to use, BoostDesc::BINBOOST_256 is default (256 bit long dimension) + /// Available types are: BoostDesc::BGM, BoostDesc::BGM_HARD, BoostDesc::BGM_BILINEAR, BoostDesc::LBGM, + /// BoostDesc::BINBOOST_64, BoostDesc::BINBOOST_128, BoostDesc::BINBOOST_256 + /// * use_orientation: sample patterns using keypoints orientation, enabled by default + /// * scale_factor: adjust the sampling window of detected keypoints + /// 6.25f is default and fits for KAZE, SURF detected keypoints window ratio + /// 6.75f should be the scale for SIFT detected keypoints window ratio + /// 5.00f should be the scale for AKAZE, MSD, AGAST, FAST, BRISK keypoints window ratio + /// 0.75f should be the scale for ORB keypoints ratio + /// 1.50f was the default in original implementation + /// + /// + /// Note: BGM is the base descriptor where each binary dimension is computed as the output of a single weak learner. + /// BGM_HARD and BGM_BILINEAR refers to same BGM but use different type of gradient binning. In the BGM_HARD that + /// use ASSIGN_HARD binning type the gradient is assigned to the nearest orientation bin. In the BGM_BILINEAR that use + /// ASSIGN_BILINEAR binning type the gradient is assigned to the two neighbouring bins. In the BGM and all other modes that use + /// ASSIGN_SOFT binning type the gradient is assigned to 8 nearest bins according to the cosine value between the gradient + /// angle and the bin center. LBGM (alias FP-Boost) is the floating point extension where each dimension is computed + /// as a linear combination of the weak learner responses. BINBOOST and subvariants are the binary extensions of LBGM + /// where each bit is computed as a thresholded linear combination of a set of weak learners. + /// BoostDesc header files (boostdesc_*.i) was exported from original binaries with export-boostdesc.py script from + /// samples subfolder. + pub struct BoostDesc { + ptr: *mut c_void, + } + + opencv_type_boxed! { BoostDesc } + + impl Drop for BoostDesc { #[inline] - pub fn create(scale_factor: f32, n_bits: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_BEBLID_create_float_int(scale_factor, n_bits, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_xfeatures2d_BoostDesc_delete(self.as_raw_mut_BoostDesc()) }; } + } - /// Creates the BEBLID descriptor. - /// ## Parameters - /// * scale_factor: Adjust the sampling window around detected keypoints: - /// - 1.00f should be the scale for ORB keypoints - /// - 6.75f should be the scale for SIFT detected keypoints - /// - 6.25f is default and fits for KAZE, SURF detected keypoints - /// - 5.00f should be the scale for AKAZE, MSD, AGAST, FAST, BRISK keypoints - /// * n_bits: Determine the number of bits in the descriptor. Should be either - /// BEBLID::SIZE_512_BITS or BEBLID::SIZE_256_BITS. - /// - /// ## Note - /// This alternative version of [BEBLID::create] function uses the following default values for its arguments: - /// * n_bits: BEBLID::SIZE_512_BITS + unsafe impl Send for BoostDesc {} + + impl BoostDesc { + /// ## C++ default parameters + /// * desc: BoostDesc::BINBOOST_256 + /// * use_scale_orientation: true + /// * scale_factor: 6.25f #[inline] - pub fn create_def(scale_factor: f32) -> Result> { + pub fn create(desc: i32, use_scale_orientation: bool, scale_factor: f32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_BEBLID_create_float(scale_factor, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_BoostDesc_create_int_bool_float(desc, use_scale_orientation, scale_factor, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { BEBLID, core::Algorithm, cv_xfeatures2d_BEBLID_to_Algorithm } - - boxed_cast_base! { BEBLID, crate::features2d::Feature2D, cv_xfeatures2d_BEBLID_to_Feature2D } - - impl std::fmt::Debug for BEBLID { + /// ## Note + /// This alternative version of [BoostDesc::create] function uses the following default values for its arguments: + /// * desc: BoostDesc::BINBOOST_256 + /// * use_scale_orientation: true + /// * scale_factor: 6.25f #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BEBLID") - .finish() + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_xfeatures2d_BoostDesc_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::xfeatures2d::BoostDesc] @@ -1367,46 +1440,17 @@ pub mod xfeatures2d { } - /// Class implementing BoostDesc (Learning Image Descriptors with Boosting), described in - /// [Trzcinski13a](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Trzcinski13a) and [Trzcinski13b](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Trzcinski13b). - /// - /// ## Parameters - /// * desc: type of descriptor to use, BoostDesc::BINBOOST_256 is default (256 bit long dimension) - /// Available types are: BoostDesc::BGM, BoostDesc::BGM_HARD, BoostDesc::BGM_BILINEAR, BoostDesc::LBGM, - /// BoostDesc::BINBOOST_64, BoostDesc::BINBOOST_128, BoostDesc::BINBOOST_256 - /// * use_orientation: sample patterns using keypoints orientation, enabled by default - /// * scale_factor: adjust the sampling window of detected keypoints - /// 6.25f is default and fits for KAZE, SURF detected keypoints window ratio - /// 6.75f should be the scale for SIFT detected keypoints window ratio - /// 5.00f should be the scale for AKAZE, MSD, AGAST, FAST, BRISK keypoints window ratio - /// 0.75f should be the scale for ORB keypoints ratio - /// 1.50f was the default in original implementation - /// - /// - /// Note: BGM is the base descriptor where each binary dimension is computed as the output of a single weak learner. - /// BGM_HARD and BGM_BILINEAR refers to same BGM but use different type of gradient binning. In the BGM_HARD that - /// use ASSIGN_HARD binning type the gradient is assigned to the nearest orientation bin. In the BGM_BILINEAR that use - /// ASSIGN_BILINEAR binning type the gradient is assigned to the two neighbouring bins. In the BGM and all other modes that use - /// ASSIGN_SOFT binning type the gradient is assigned to 8 nearest bins according to the cosine value between the gradient - /// angle and the bin center. LBGM (alias FP-Boost) is the floating point extension where each dimension is computed - /// as a linear combination of the weak learner responses. BINBOOST and subvariants are the binary extensions of LBGM - /// where each bit is computed as a thresholded linear combination of a set of weak learners. - /// BoostDesc header files (boostdesc_*.i) was exported from original binaries with export-boostdesc.py script from - /// samples subfolder. - pub struct BoostDesc { - ptr: *mut c_void, - } - - opencv_type_boxed! { BoostDesc } - - impl Drop for BoostDesc { + impl std::fmt::Debug for BoostDesc { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xfeatures2d_BoostDesc_delete(self.as_raw_mut_BoostDesc()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BoostDesc") + .finish() } } - unsafe impl Send for BoostDesc {} + boxed_cast_base! { BoostDesc, core::Algorithm, cv_xfeatures2d_BoostDesc_to_Algorithm } + + boxed_cast_base! { BoostDesc, crate::features2d::Feature2D, cv_xfeatures2d_BoostDesc_to_Feature2D } impl core::AlgorithmTraitConst for BoostDesc { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1438,50 +1482,56 @@ pub mod xfeatures2d { boxed_ref! { BoostDesc, crate::xfeatures2d::BoostDescTraitConst, as_raw_BoostDesc, crate::xfeatures2d::BoostDescTrait, as_raw_mut_BoostDesc } - impl BoostDesc { + /// Class for computing BRIEF descriptors described in [calon2010](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_calon2010) . + /// + /// ## Parameters + /// * bytes: legth of the descriptor in bytes, valid values are: 16, 32 (default) or 64 . + /// * use_orientation: sample patterns using keypoints orientation, disabled by default. + pub struct BriefDescriptorExtractor { + ptr: *mut c_void, + } + + opencv_type_boxed! { BriefDescriptorExtractor } + + impl Drop for BriefDescriptorExtractor { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_xfeatures2d_BriefDescriptorExtractor_delete(self.as_raw_mut_BriefDescriptorExtractor()) }; + } + } + + unsafe impl Send for BriefDescriptorExtractor {} + + impl BriefDescriptorExtractor { /// ## C++ default parameters - /// * desc: BoostDesc::BINBOOST_256 - /// * use_scale_orientation: true - /// * scale_factor: 6.25f + /// * bytes: 32 + /// * use_orientation: false #[inline] - pub fn create(desc: i32, use_scale_orientation: bool, scale_factor: f32) -> Result> { + pub fn create(bytes: i32, use_orientation: bool) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_BoostDesc_create_int_bool_float(desc, use_scale_orientation, scale_factor, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_BriefDescriptorExtractor_create_int_bool(bytes, use_orientation, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } /// ## Note - /// This alternative version of [BoostDesc::create] function uses the following default values for its arguments: - /// * desc: BoostDesc::BINBOOST_256 - /// * use_scale_orientation: true - /// * scale_factor: 6.25f + /// This alternative version of [BriefDescriptorExtractor::create] function uses the following default values for its arguments: + /// * bytes: 32 + /// * use_orientation: false #[inline] - pub fn create_def() -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_BoostDesc_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_BriefDescriptorExtractor_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { BoostDesc, core::Algorithm, cv_xfeatures2d_BoostDesc_to_Algorithm } - - boxed_cast_base! { BoostDesc, crate::features2d::Feature2D, cv_xfeatures2d_BoostDesc_to_Feature2D } - - impl std::fmt::Debug for BoostDesc { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BoostDesc") - .finish() - } - } - /// Constant methods for [crate::xfeatures2d::BriefDescriptorExtractor] pub trait BriefDescriptorExtractorTraitConst: crate::features2d::Feature2DTraitConst { fn as_raw_BriefDescriptorExtractor(&self) -> *const c_void; @@ -1540,25 +1590,17 @@ pub mod xfeatures2d { } - /// Class for computing BRIEF descriptors described in [calon2010](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_calon2010) . - /// - /// ## Parameters - /// * bytes: legth of the descriptor in bytes, valid values are: 16, 32 (default) or 64 . - /// * use_orientation: sample patterns using keypoints orientation, disabled by default. - pub struct BriefDescriptorExtractor { - ptr: *mut c_void, - } - - opencv_type_boxed! { BriefDescriptorExtractor } - - impl Drop for BriefDescriptorExtractor { + impl std::fmt::Debug for BriefDescriptorExtractor { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xfeatures2d_BriefDescriptorExtractor_delete(self.as_raw_mut_BriefDescriptorExtractor()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("BriefDescriptorExtractor") + .finish() } } - unsafe impl Send for BriefDescriptorExtractor {} + boxed_cast_base! { BriefDescriptorExtractor, core::Algorithm, cv_xfeatures2d_BriefDescriptorExtractor_to_Algorithm } + + boxed_cast_base! { BriefDescriptorExtractor, crate::features2d::Feature2D, cv_xfeatures2d_BriefDescriptorExtractor_to_Feature2D } impl core::AlgorithmTraitConst for BriefDescriptorExtractor { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1590,48 +1632,79 @@ pub mod xfeatures2d { boxed_ref! { BriefDescriptorExtractor, crate::xfeatures2d::BriefDescriptorExtractorTraitConst, as_raw_BriefDescriptorExtractor, crate::xfeatures2d::BriefDescriptorExtractorTrait, as_raw_mut_BriefDescriptorExtractor } - impl BriefDescriptorExtractor { + /// Class implementing DAISY descriptor, described in [Tola10](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Tola10) + /// + /// ## Parameters + /// * radius: radius of the descriptor at the initial scale + /// * q_radius: amount of radial range division quantity + /// * q_theta: amount of angular range division quantity + /// * q_hist: amount of gradient orientations range division quantity + /// * norm: choose descriptors normalization type, where + /// DAISY::NRM_NONE will not do any normalization (default), + /// DAISY::NRM_PARTIAL mean that histograms are normalized independently for L2 norm equal to 1.0, + /// DAISY::NRM_FULL mean that descriptors are normalized for L2 norm equal to 1.0, + /// DAISY::NRM_SIFT mean that descriptors are normalized for L2 norm equal to 1.0 but no individual one is bigger than 0.154 as in SIFT + /// * H: optional 3x3 homography matrix used to warp the grid of daisy but sampling keypoints remains unwarped on image + /// * interpolation: switch to disable interpolation for speed improvement at minor quality loss + /// * use_orientation: sample patterns using keypoints orientation, disabled by default. + pub struct DAISY { + ptr: *mut c_void, + } + + opencv_type_boxed! { DAISY } + + impl Drop for DAISY { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_xfeatures2d_DAISY_delete(self.as_raw_mut_DAISY()) }; + } + } + + unsafe impl Send for DAISY {} + + impl DAISY { /// ## C++ default parameters - /// * bytes: 32 + /// * radius: 15 + /// * q_radius: 3 + /// * q_theta: 8 + /// * q_hist: 8 + /// * norm: DAISY::NRM_NONE + /// * h: noArray() + /// * interpolation: true /// * use_orientation: false #[inline] - pub fn create(bytes: i32, use_orientation: bool) -> Result> { + pub fn create(radius: f32, q_radius: i32, q_theta: i32, q_hist: i32, norm: crate::xfeatures2d::DAISY_NormalizationType, h: &impl ToInputArray, interpolation: bool, use_orientation: bool) -> Result> { + input_array_arg!(h); return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_BriefDescriptorExtractor_create_int_bool(bytes, use_orientation, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_DAISY_create_float_int_int_int_NormalizationType_const__InputArrayR_bool_bool(radius, q_radius, q_theta, q_hist, norm, h.as_raw__InputArray(), interpolation, use_orientation, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } /// ## Note - /// This alternative version of [BriefDescriptorExtractor::create] function uses the following default values for its arguments: - /// * bytes: 32 + /// This alternative version of [DAISY::create] function uses the following default values for its arguments: + /// * radius: 15 + /// * q_radius: 3 + /// * q_theta: 8 + /// * q_hist: 8 + /// * norm: DAISY::NRM_NONE + /// * h: noArray() + /// * interpolation: true /// * use_orientation: false #[inline] - pub fn create_def() -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_BriefDescriptorExtractor_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_DAISY_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { BriefDescriptorExtractor, core::Algorithm, cv_xfeatures2d_BriefDescriptorExtractor_to_Algorithm } - - boxed_cast_base! { BriefDescriptorExtractor, crate::features2d::Feature2D, cv_xfeatures2d_BriefDescriptorExtractor_to_Feature2D } - - impl std::fmt::Debug for BriefDescriptorExtractor { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("BriefDescriptorExtractor") - .finish() - } - } - /// Constant methods for [crate::xfeatures2d::DAISY] pub trait DAISYTraitConst: crate::features2d::Feature2DTraitConst { fn as_raw_DAISY(&self) -> *const c_void; @@ -1916,35 +1989,17 @@ pub mod xfeatures2d { } - /// Class implementing DAISY descriptor, described in [Tola10](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Tola10) - /// - /// ## Parameters - /// * radius: radius of the descriptor at the initial scale - /// * q_radius: amount of radial range division quantity - /// * q_theta: amount of angular range division quantity - /// * q_hist: amount of gradient orientations range division quantity - /// * norm: choose descriptors normalization type, where - /// DAISY::NRM_NONE will not do any normalization (default), - /// DAISY::NRM_PARTIAL mean that histograms are normalized independently for L2 norm equal to 1.0, - /// DAISY::NRM_FULL mean that descriptors are normalized for L2 norm equal to 1.0, - /// DAISY::NRM_SIFT mean that descriptors are normalized for L2 norm equal to 1.0 but no individual one is bigger than 0.154 as in SIFT - /// * H: optional 3x3 homography matrix used to warp the grid of daisy but sampling keypoints remains unwarped on image - /// * interpolation: switch to disable interpolation for speed improvement at minor quality loss - /// * use_orientation: sample patterns using keypoints orientation, disabled by default. - pub struct DAISY { - ptr: *mut c_void, - } - - opencv_type_boxed! { DAISY } - - impl Drop for DAISY { + impl std::fmt::Debug for DAISY { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xfeatures2d_DAISY_delete(self.as_raw_mut_DAISY()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DAISY") + .finish() } } - unsafe impl Send for DAISY {} + boxed_cast_base! { DAISY, core::Algorithm, cv_xfeatures2d_DAISY_to_Algorithm } + + boxed_cast_base! { DAISY, crate::features2d::Feature2D, cv_xfeatures2d_DAISY_to_Feature2D } impl core::AlgorithmTraitConst for DAISY { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1976,61 +2031,45 @@ pub mod xfeatures2d { boxed_ref! { DAISY, crate::xfeatures2d::DAISYTraitConst, as_raw_DAISY, crate::xfeatures2d::DAISYTrait, as_raw_mut_DAISY } - impl DAISY { - /// ## C++ default parameters - /// * radius: 15 - /// * q_radius: 3 - /// * q_theta: 8 - /// * q_hist: 8 - /// * norm: DAISY::NRM_NONE - /// * h: noArray() - /// * interpolation: true - /// * use_orientation: false + /// Elliptic region around an interest point. + pub struct Elliptic_KeyPoint { + ptr: *mut c_void, + } + + opencv_type_boxed! { Elliptic_KeyPoint } + + impl Drop for Elliptic_KeyPoint { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_xfeatures2d_Elliptic_KeyPoint_delete(self.as_raw_mut_Elliptic_KeyPoint()) }; + } + } + + unsafe impl Send for Elliptic_KeyPoint {} + + impl Elliptic_KeyPoint { #[inline] - pub fn create(radius: f32, q_radius: i32, q_theta: i32, q_hist: i32, norm: crate::xfeatures2d::DAISY_NormalizationType, h: &impl ToInputArray, interpolation: bool, use_orientation: bool) -> Result> { - input_array_arg!(h); + pub fn default() -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_DAISY_create_float_int_int_int_NormalizationType_const__InputArrayR_bool_bool(radius, q_radius, q_theta, q_hist, norm, h.as_raw__InputArray(), interpolation, use_orientation, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_Elliptic_KeyPoint_Elliptic_KeyPoint(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::xfeatures2d::Elliptic_KeyPoint::opencv_from_extern(ret) }; Ok(ret) } - /// ## Note - /// This alternative version of [DAISY::create] function uses the following default values for its arguments: - /// * radius: 15 - /// * q_radius: 3 - /// * q_theta: 8 - /// * q_hist: 8 - /// * norm: DAISY::NRM_NONE - /// * h: noArray() - /// * interpolation: true - /// * use_orientation: false #[inline] - pub fn create_def() -> Result> { + pub fn new(pt: core::Point2f, angle: f32, axes: core::Size, size: f32, si: f32) -> Result { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_DAISY_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_Elliptic_KeyPoint_Elliptic_KeyPoint_Point2f_float_Size_float_float(&pt, angle, &axes, size, si, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { crate::xfeatures2d::Elliptic_KeyPoint::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { DAISY, core::Algorithm, cv_xfeatures2d_DAISY_to_Algorithm } - - boxed_cast_base! { DAISY, crate::features2d::Feature2D, cv_xfeatures2d_DAISY_to_Feature2D } - - impl std::fmt::Debug for DAISY { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DAISY") - .finish() - } - } - /// Constant methods for [crate::xfeatures2d::Elliptic_KeyPoint] pub trait Elliptic_KeyPointTraitConst: core::KeyPointTraitConst { fn as_raw_Elliptic_KeyPoint(&self) -> *const c_void; @@ -2089,21 +2128,24 @@ pub mod xfeatures2d { } - /// Elliptic region around an interest point. - pub struct Elliptic_KeyPoint { - ptr: *mut c_void, - } - - opencv_type_boxed! { Elliptic_KeyPoint } - - impl Drop for Elliptic_KeyPoint { + impl std::fmt::Debug for Elliptic_KeyPoint { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xfeatures2d_Elliptic_KeyPoint_delete(self.as_raw_mut_Elliptic_KeyPoint()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Elliptic_KeyPoint") + .field("axes", &crate::xfeatures2d::Elliptic_KeyPointTraitConst::axes(self)) + .field("si", &crate::xfeatures2d::Elliptic_KeyPointTraitConst::si(self)) + .field("transf", &crate::xfeatures2d::Elliptic_KeyPointTraitConst::transf(self)) + .field("pt", &core::KeyPointTraitConst::pt(self)) + .field("size", &core::KeyPointTraitConst::size(self)) + .field("angle", &core::KeyPointTraitConst::angle(self)) + .field("response", &core::KeyPointTraitConst::response(self)) + .field("octave", &core::KeyPointTraitConst::octave(self)) + .field("class_id", &core::KeyPointTraitConst::class_id(self)) + .finish() } } - unsafe impl Send for Elliptic_KeyPoint {} + boxed_cast_base! { Elliptic_KeyPoint, core::KeyPoint, cv_xfeatures2d_Elliptic_KeyPoint_to_KeyPoint } impl core::KeyPointTraitConst for Elliptic_KeyPoint { #[inline] fn as_raw_KeyPoint(&self) -> *const c_void { self.as_raw() } @@ -2125,48 +2167,86 @@ pub mod xfeatures2d { boxed_ref! { Elliptic_KeyPoint, crate::xfeatures2d::Elliptic_KeyPointTraitConst, as_raw_Elliptic_KeyPoint, crate::xfeatures2d::Elliptic_KeyPointTrait, as_raw_mut_Elliptic_KeyPoint } - impl Elliptic_KeyPoint { + /// Class implementing the FREAK (*Fast Retina Keypoint*) keypoint descriptor, described in [AOV12](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_AOV12) . + /// + /// The algorithm propose a novel keypoint descriptor inspired by the human visual system and more + /// precisely the retina, coined Fast Retina Key- point (FREAK). A cascade of binary strings is + /// computed by efficiently comparing image intensities over a retinal sampling pattern. FREAKs are in + /// general faster to compute with lower memory load and also more robust than SIFT, SURF or BRISK. + /// They are competitive alternatives to existing keypoints in particular for embedded applications. + /// + /// + /// Note: + /// * An example on how to use the FREAK descriptor can be found at + /// opencv_source_code/samples/cpp/freak_demo.cpp + pub struct FREAK { + ptr: *mut c_void, + } + + opencv_type_boxed! { FREAK } + + impl Drop for FREAK { #[inline] - pub fn default() -> Result { + fn drop(&mut self) { + unsafe { sys::cv_xfeatures2d_FREAK_delete(self.as_raw_mut_FREAK()) }; + } + } + + unsafe impl Send for FREAK {} + + impl FREAK { + pub const NB_SCALES: i32 = 64; + pub const NB_PAIRS: i32 = 512; + pub const NB_ORIENPAIRS: i32 = 45; + /// ## Parameters + /// * orientationNormalized: Enable orientation normalization. + /// * scaleNormalized: Enable scale normalization. + /// * patternScale: Scaling of the description pattern. + /// * nOctaves: Number of octaves covered by the detected keypoints. + /// * selectedPairs: (Optional) user defined selected pairs indexes, + /// + /// ## C++ default parameters + /// * orientation_normalized: true + /// * scale_normalized: true + /// * pattern_scale: 22.0f + /// * n_octaves: 4 + /// * selected_pairs: std::vector() + #[inline] + pub fn create(orientation_normalized: bool, scale_normalized: bool, pattern_scale: f32, n_octaves: i32, selected_pairs: &core::Vector) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_Elliptic_KeyPoint_Elliptic_KeyPoint(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_FREAK_create_bool_bool_float_int_const_vectorLintGR(orientation_normalized, scale_normalized, pattern_scale, n_octaves, selected_pairs.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::xfeatures2d::Elliptic_KeyPoint::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } + /// ## Parameters + /// * orientationNormalized: Enable orientation normalization. + /// * scaleNormalized: Enable scale normalization. + /// * patternScale: Scaling of the description pattern. + /// * nOctaves: Number of octaves covered by the detected keypoints. + /// * selectedPairs: (Optional) user defined selected pairs indexes, + /// + /// ## Note + /// This alternative version of [FREAK::create] function uses the following default values for its arguments: + /// * orientation_normalized: true + /// * scale_normalized: true + /// * pattern_scale: 22.0f + /// * n_octaves: 4 + /// * selected_pairs: std::vector() #[inline] - pub fn new(pt: core::Point2f, angle: f32, axes: core::Size, size: f32, si: f32) -> Result { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_Elliptic_KeyPoint_Elliptic_KeyPoint_Point2f_float_Size_float_float(&pt, angle, &axes, size, si, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_FREAK_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { crate::xfeatures2d::Elliptic_KeyPoint::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { Elliptic_KeyPoint, core::KeyPoint, cv_xfeatures2d_Elliptic_KeyPoint_to_KeyPoint } - - impl std::fmt::Debug for Elliptic_KeyPoint { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("Elliptic_KeyPoint") - .field("axes", &crate::xfeatures2d::Elliptic_KeyPointTraitConst::axes(self)) - .field("si", &crate::xfeatures2d::Elliptic_KeyPointTraitConst::si(self)) - .field("transf", &crate::xfeatures2d::Elliptic_KeyPointTraitConst::transf(self)) - .field("pt", &core::KeyPointTraitConst::pt(self)) - .field("size", &core::KeyPointTraitConst::size(self)) - .field("angle", &core::KeyPointTraitConst::angle(self)) - .field("response", &core::KeyPointTraitConst::response(self)) - .field("octave", &core::KeyPointTraitConst::octave(self)) - .field("class_id", &core::KeyPointTraitConst::class_id(self)) - .finish() - } - } - /// Constant methods for [crate::xfeatures2d::FREAK] pub trait FREAKTraitConst: crate::features2d::Feature2DTraitConst { fn as_raw_FREAK(&self) -> *const c_void; @@ -2261,32 +2341,17 @@ pub mod xfeatures2d { } - /// Class implementing the FREAK (*Fast Retina Keypoint*) keypoint descriptor, described in [AOV12](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_AOV12) . - /// - /// The algorithm propose a novel keypoint descriptor inspired by the human visual system and more - /// precisely the retina, coined Fast Retina Key- point (FREAK). A cascade of binary strings is - /// computed by efficiently comparing image intensities over a retinal sampling pattern. FREAKs are in - /// general faster to compute with lower memory load and also more robust than SIFT, SURF or BRISK. - /// They are competitive alternatives to existing keypoints in particular for embedded applications. - /// - /// - /// Note: - /// * An example on how to use the FREAK descriptor can be found at - /// opencv_source_code/samples/cpp/freak_demo.cpp - pub struct FREAK { - ptr: *mut c_void, - } - - opencv_type_boxed! { FREAK } - - impl Drop for FREAK { + impl std::fmt::Debug for FREAK { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xfeatures2d_FREAK_delete(self.as_raw_mut_FREAK()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FREAK") + .finish() } } - unsafe impl Send for FREAK {} + boxed_cast_base! { FREAK, core::Algorithm, cv_xfeatures2d_FREAK_to_Algorithm } + + boxed_cast_base! { FREAK, crate::features2d::Feature2D, cv_xfeatures2d_FREAK_to_Feature2D } impl core::AlgorithmTraitConst for FREAK { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2318,71 +2383,76 @@ pub mod xfeatures2d { boxed_ref! { FREAK, crate::xfeatures2d::FREAKTraitConst, as_raw_FREAK, crate::xfeatures2d::FREAKTrait, as_raw_mut_FREAK } - impl FREAK { - pub const NB_SCALES: i32 = 64; - pub const NB_PAIRS: i32 = 512; - pub const NB_ORIENPAIRS: i32 = 45; + /// Class implementing the Harris-Laplace feature detector as described in [Mikolajczyk2004](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Mikolajczyk2004). + pub struct HarrisLaplaceFeatureDetector { + ptr: *mut c_void, + } + + opencv_type_boxed! { HarrisLaplaceFeatureDetector } + + impl Drop for HarrisLaplaceFeatureDetector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_xfeatures2d_HarrisLaplaceFeatureDetector_delete(self.as_raw_mut_HarrisLaplaceFeatureDetector()) }; + } + } + + unsafe impl Send for HarrisLaplaceFeatureDetector {} + + impl HarrisLaplaceFeatureDetector { + /// Creates a new implementation instance. + /// /// ## Parameters - /// * orientationNormalized: Enable orientation normalization. - /// * scaleNormalized: Enable scale normalization. - /// * patternScale: Scaling of the description pattern. - /// * nOctaves: Number of octaves covered by the detected keypoints. - /// * selectedPairs: (Optional) user defined selected pairs indexes, + /// * numOctaves: the number of octaves in the scale-space pyramid + /// * corn_thresh: the threshold for the Harris cornerness measure + /// * DOG_thresh: the threshold for the Difference-of-Gaussians scale selection + /// * maxCorners: the maximum number of corners to consider + /// * num_layers: the number of intermediate scales per octave /// /// ## C++ default parameters - /// * orientation_normalized: true - /// * scale_normalized: true - /// * pattern_scale: 22.0f - /// * n_octaves: 4 - /// * selected_pairs: std::vector() + /// * num_octaves: 6 + /// * corn_thresh: 0.01f + /// * dog_thresh: 0.01f + /// * max_corners: 5000 + /// * num_layers: 4 #[inline] - pub fn create(orientation_normalized: bool, scale_normalized: bool, pattern_scale: f32, n_octaves: i32, selected_pairs: &core::Vector) -> Result> { + pub fn create(num_octaves: i32, corn_thresh: f32, dog_thresh: f32, max_corners: i32, num_layers: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_FREAK_create_bool_bool_float_int_const_vectorLintGR(orientation_normalized, scale_normalized, pattern_scale, n_octaves, selected_pairs.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_HarrisLaplaceFeatureDetector_create_int_float_float_int_int(num_octaves, corn_thresh, dog_thresh, max_corners, num_layers, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } + /// Creates a new implementation instance. + /// /// ## Parameters - /// * orientationNormalized: Enable orientation normalization. - /// * scaleNormalized: Enable scale normalization. - /// * patternScale: Scaling of the description pattern. - /// * nOctaves: Number of octaves covered by the detected keypoints. - /// * selectedPairs: (Optional) user defined selected pairs indexes, + /// * numOctaves: the number of octaves in the scale-space pyramid + /// * corn_thresh: the threshold for the Harris cornerness measure + /// * DOG_thresh: the threshold for the Difference-of-Gaussians scale selection + /// * maxCorners: the maximum number of corners to consider + /// * num_layers: the number of intermediate scales per octave /// /// ## Note - /// This alternative version of [FREAK::create] function uses the following default values for its arguments: - /// * orientation_normalized: true - /// * scale_normalized: true - /// * pattern_scale: 22.0f - /// * n_octaves: 4 - /// * selected_pairs: std::vector() + /// This alternative version of [HarrisLaplaceFeatureDetector::create] function uses the following default values for its arguments: + /// * num_octaves: 6 + /// * corn_thresh: 0.01f + /// * dog_thresh: 0.01f + /// * max_corners: 5000 + /// * num_layers: 4 #[inline] - pub fn create_def() -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_FREAK_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_HarrisLaplaceFeatureDetector_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { FREAK, core::Algorithm, cv_xfeatures2d_FREAK_to_Algorithm } - - boxed_cast_base! { FREAK, crate::features2d::Feature2D, cv_xfeatures2d_FREAK_to_Feature2D } - - impl std::fmt::Debug for FREAK { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FREAK") - .finish() - } - } - /// Constant methods for [crate::xfeatures2d::HarrisLaplaceFeatureDetector] pub trait HarrisLaplaceFeatureDetectorTraitConst: crate::features2d::Feature2DTraitConst { fn as_raw_HarrisLaplaceFeatureDetector(&self) -> *const c_void; @@ -2495,21 +2565,17 @@ pub mod xfeatures2d { } - /// Class implementing the Harris-Laplace feature detector as described in [Mikolajczyk2004](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Mikolajczyk2004). - pub struct HarrisLaplaceFeatureDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { HarrisLaplaceFeatureDetector } - - impl Drop for HarrisLaplaceFeatureDetector { + impl std::fmt::Debug for HarrisLaplaceFeatureDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xfeatures2d_HarrisLaplaceFeatureDetector_delete(self.as_raw_mut_HarrisLaplaceFeatureDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("HarrisLaplaceFeatureDetector") + .finish() } } - unsafe impl Send for HarrisLaplaceFeatureDetector {} + boxed_cast_base! { HarrisLaplaceFeatureDetector, core::Algorithm, cv_xfeatures2d_HarrisLaplaceFeatureDetector_to_Algorithm } + + boxed_cast_base! { HarrisLaplaceFeatureDetector, crate::features2d::Feature2D, cv_xfeatures2d_HarrisLaplaceFeatureDetector_to_Feature2D } impl core::AlgorithmTraitConst for HarrisLaplaceFeatureDetector { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2541,72 +2607,71 @@ pub mod xfeatures2d { boxed_ref! { HarrisLaplaceFeatureDetector, crate::xfeatures2d::HarrisLaplaceFeatureDetectorTraitConst, as_raw_HarrisLaplaceFeatureDetector, crate::xfeatures2d::HarrisLaplaceFeatureDetectorTrait, as_raw_mut_HarrisLaplaceFeatureDetector } - impl HarrisLaplaceFeatureDetector { - /// Creates a new implementation instance. - /// - /// ## Parameters - /// * numOctaves: the number of octaves in the scale-space pyramid - /// * corn_thresh: the threshold for the Harris cornerness measure - /// * DOG_thresh: the threshold for the Difference-of-Gaussians scale selection - /// * maxCorners: the maximum number of corners to consider - /// * num_layers: the number of intermediate scales per octave - /// + /// latch Class for computing the LATCH descriptor. + /// If you find this code useful, please add a reference to the following paper in your work: + /// Gil Levi and Tal Hassner, "LATCH: Learned Arrangements of Three Patch Codes", arXiv preprint arXiv:1501.03719, 15 Jan. 2015 + /// + /// LATCH is a binary descriptor based on learned comparisons of triplets of image patches. + /// + /// * bytes is the size of the descriptor - can be 64, 32, 16, 8, 4, 2 or 1 + /// * rotationInvariance - whether or not the descriptor should compansate for orientation changes. + /// * half_ssd_size - the size of half of the mini-patches size. For example, if we would like to compare triplets of patches of size 7x7x + /// then the half_ssd_size should be (7-1)/2 = 3. + /// * sigma - sigma value for GaussianBlur smoothing of the source image. Source image will be used without smoothing in case sigma value is 0. + /// + /// Note: the descriptor can be coupled with any keypoint extractor. The only demand is that if you use set rotationInvariance = True then + /// you will have to use an extractor which estimates the patch orientation (in degrees). Examples for such extractors are ORB and SIFT. + /// + /// Note: a complete example can be found under /samples/cpp/tutorial_code/xfeatures2D/latch_match.cpp + pub struct LATCH { + ptr: *mut c_void, + } + + opencv_type_boxed! { LATCH } + + impl Drop for LATCH { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_xfeatures2d_LATCH_delete(self.as_raw_mut_LATCH()) }; + } + } + + unsafe impl Send for LATCH {} + + impl LATCH { /// ## C++ default parameters - /// * num_octaves: 6 - /// * corn_thresh: 0.01f - /// * dog_thresh: 0.01f - /// * max_corners: 5000 - /// * num_layers: 4 + /// * bytes: 32 + /// * rotation_invariance: true + /// * half_ssd_size: 3 + /// * sigma: 2.0 #[inline] - pub fn create(num_octaves: i32, corn_thresh: f32, dog_thresh: f32, max_corners: i32, num_layers: i32) -> Result> { + pub fn create(bytes: i32, rotation_invariance: bool, half_ssd_size: i32, sigma: f64) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_HarrisLaplaceFeatureDetector_create_int_float_float_int_int(num_octaves, corn_thresh, dog_thresh, max_corners, num_layers, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_LATCH_create_int_bool_int_double(bytes, rotation_invariance, half_ssd_size, sigma, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Creates a new implementation instance. - /// - /// ## Parameters - /// * numOctaves: the number of octaves in the scale-space pyramid - /// * corn_thresh: the threshold for the Harris cornerness measure - /// * DOG_thresh: the threshold for the Difference-of-Gaussians scale selection - /// * maxCorners: the maximum number of corners to consider - /// * num_layers: the number of intermediate scales per octave - /// /// ## Note - /// This alternative version of [HarrisLaplaceFeatureDetector::create] function uses the following default values for its arguments: - /// * num_octaves: 6 - /// * corn_thresh: 0.01f - /// * dog_thresh: 0.01f - /// * max_corners: 5000 - /// * num_layers: 4 + /// This alternative version of [LATCH::create] function uses the following default values for its arguments: + /// * bytes: 32 + /// * rotation_invariance: true + /// * half_ssd_size: 3 + /// * sigma: 2.0 #[inline] - pub fn create_def() -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_HarrisLaplaceFeatureDetector_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_LATCH_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { HarrisLaplaceFeatureDetector, core::Algorithm, cv_xfeatures2d_HarrisLaplaceFeatureDetector_to_Algorithm } - - boxed_cast_base! { HarrisLaplaceFeatureDetector, crate::features2d::Feature2D, cv_xfeatures2d_HarrisLaplaceFeatureDetector_to_Feature2D } - - impl std::fmt::Debug for HarrisLaplaceFeatureDetector { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("HarrisLaplaceFeatureDetector") - .finish() - } - } - /// Constant methods for [crate::xfeatures2d::LATCH] pub trait LATCHTraitConst: crate::features2d::Feature2DTraitConst { fn as_raw_LATCH(&self) -> *const c_void; @@ -2701,36 +2766,17 @@ pub mod xfeatures2d { } - /// latch Class for computing the LATCH descriptor. - /// If you find this code useful, please add a reference to the following paper in your work: - /// Gil Levi and Tal Hassner, "LATCH: Learned Arrangements of Three Patch Codes", arXiv preprint arXiv:1501.03719, 15 Jan. 2015 - /// - /// LATCH is a binary descriptor based on learned comparisons of triplets of image patches. - /// - /// * bytes is the size of the descriptor - can be 64, 32, 16, 8, 4, 2 or 1 - /// * rotationInvariance - whether or not the descriptor should compansate for orientation changes. - /// * half_ssd_size - the size of half of the mini-patches size. For example, if we would like to compare triplets of patches of size 7x7x - /// then the half_ssd_size should be (7-1)/2 = 3. - /// * sigma - sigma value for GaussianBlur smoothing of the source image. Source image will be used without smoothing in case sigma value is 0. - /// - /// Note: the descriptor can be coupled with any keypoint extractor. The only demand is that if you use set rotationInvariance = True then - /// you will have to use an extractor which estimates the patch orientation (in degrees). Examples for such extractors are ORB and SIFT. - /// - /// Note: a complete example can be found under /samples/cpp/tutorial_code/xfeatures2D/latch_match.cpp - pub struct LATCH { - ptr: *mut c_void, - } - - opencv_type_boxed! { LATCH } - - impl Drop for LATCH { + impl std::fmt::Debug for LATCH { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xfeatures2d_LATCH_delete(self.as_raw_mut_LATCH()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LATCH") + .finish() } } - unsafe impl Send for LATCH {} + boxed_cast_base! { LATCH, core::Algorithm, cv_xfeatures2d_LATCH_to_Algorithm } + + boxed_cast_base! { LATCH, crate::features2d::Feature2D, cv_xfeatures2d_LATCH_to_Feature2D } impl core::AlgorithmTraitConst for LATCH { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2762,52 +2808,66 @@ pub mod xfeatures2d { boxed_ref! { LATCH, crate::xfeatures2d::LATCHTraitConst, as_raw_LATCH, crate::xfeatures2d::LATCHTrait, as_raw_mut_LATCH } - impl LATCH { + /// Class implementing the locally uniform comparison image descriptor, described in [LUCID](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_LUCID) + /// + /// An image descriptor that can be computed very fast, while being + /// about as robust as, for example, SURF or BRIEF. + /// + /// + /// Note: It requires a color image as input. + pub struct LUCID { + ptr: *mut c_void, + } + + opencv_type_boxed! { LUCID } + + impl Drop for LUCID { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_xfeatures2d_LUCID_delete(self.as_raw_mut_LUCID()) }; + } + } + + unsafe impl Send for LUCID {} + + impl LUCID { + /// ## Parameters + /// * lucid_kernel: kernel for descriptor construction, where 1=3x3, 2=5x5, 3=7x7 and so forth + /// * blur_kernel: kernel for blurring image prior to descriptor construction, where 1=3x3, 2=5x5, 3=7x7 and so forth + /// /// ## C++ default parameters - /// * bytes: 32 - /// * rotation_invariance: true - /// * half_ssd_size: 3 - /// * sigma: 2.0 + /// * lucid_kernel: 1 + /// * blur_kernel: 2 #[inline] - pub fn create(bytes: i32, rotation_invariance: bool, half_ssd_size: i32, sigma: f64) -> Result> { + pub fn create(lucid_kernel: i32, blur_kernel: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_LATCH_create_int_bool_int_double(bytes, rotation_invariance, half_ssd_size, sigma, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_LUCID_create_const_int_const_int(lucid_kernel, blur_kernel, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } + /// ## Parameters + /// * lucid_kernel: kernel for descriptor construction, where 1=3x3, 2=5x5, 3=7x7 and so forth + /// * blur_kernel: kernel for blurring image prior to descriptor construction, where 1=3x3, 2=5x5, 3=7x7 and so forth + /// /// ## Note - /// This alternative version of [LATCH::create] function uses the following default values for its arguments: - /// * bytes: 32 - /// * rotation_invariance: true - /// * half_ssd_size: 3 - /// * sigma: 2.0 + /// This alternative version of [LUCID::create] function uses the following default values for its arguments: + /// * lucid_kernel: 1 + /// * blur_kernel: 2 #[inline] - pub fn create_def() -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_LATCH_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_LUCID_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { LATCH, core::Algorithm, cv_xfeatures2d_LATCH_to_Algorithm } - - boxed_cast_base! { LATCH, crate::features2d::Feature2D, cv_xfeatures2d_LATCH_to_Feature2D } - - impl std::fmt::Debug for LATCH { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LATCH") - .finish() - } - } - /// Constant methods for [crate::xfeatures2d::LUCID] pub trait LUCIDTraitConst: crate::features2d::Feature2DTraitConst { fn as_raw_LUCID(&self) -> *const c_void; @@ -2857,36 +2917,26 @@ pub mod xfeatures2d { #[inline] fn set_blur_kernel(&mut self, blur_kernel: i32) -> Result<()> { - return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_LUCID_setBlurKernel_int(self.as_raw_mut_LUCID(), blur_kernel, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - - /// Class implementing the locally uniform comparison image descriptor, described in [LUCID](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_LUCID) - /// - /// An image descriptor that can be computed very fast, while being - /// about as robust as, for example, SURF or BRIEF. - /// - /// - /// Note: It requires a color image as input. - pub struct LUCID { - ptr: *mut c_void, - } + return_send!(via ocvrs_return); + unsafe { sys::cv_xfeatures2d_LUCID_setBlurKernel_int(self.as_raw_mut_LUCID(), blur_kernel, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } - opencv_type_boxed! { LUCID } + } - impl Drop for LUCID { + impl std::fmt::Debug for LUCID { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xfeatures2d_LUCID_delete(self.as_raw_mut_LUCID()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LUCID") + .finish() } } - unsafe impl Send for LUCID {} + boxed_cast_base! { LUCID, core::Algorithm, cv_xfeatures2d_LUCID_to_Algorithm } + + boxed_cast_base! { LUCID, crate::features2d::Feature2D, cv_xfeatures2d_LUCID_to_Feature2D } impl core::AlgorithmTraitConst for LUCID { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -2918,56 +2968,75 @@ pub mod xfeatures2d { boxed_ref! { LUCID, crate::xfeatures2d::LUCIDTraitConst, as_raw_LUCID, crate::xfeatures2d::LUCIDTrait, as_raw_mut_LUCID } - impl LUCID { - /// ## Parameters - /// * lucid_kernel: kernel for descriptor construction, where 1=3x3, 2=5x5, 3=7x7 and so forth - /// * blur_kernel: kernel for blurring image prior to descriptor construction, where 1=3x3, 2=5x5, 3=7x7 and so forth - /// + /// Class implementing the MSD (*Maximal Self-Dissimilarity*) keypoint detector, described in [Tombari14](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Tombari14). + /// + /// The algorithm implements a novel interest point detector stemming from the intuition that image patches + /// which are highly dissimilar over a relatively large extent of their surroundings hold the property of + /// being repeatable and distinctive. This concept of "contextual self-dissimilarity" reverses the key + /// paradigm of recent successful techniques such as the Local Self-Similarity descriptor and the Non-Local + /// Means filter, which build upon the presence of similar - rather than dissimilar - patches. Moreover, + /// it extends to contextual information the local self-dissimilarity notion embedded in established + /// detectors of corner-like interest points, thereby achieving enhanced repeatability, distinctiveness and + /// localization accuracy. + pub struct MSDDetector { + ptr: *mut c_void, + } + + opencv_type_boxed! { MSDDetector } + + impl Drop for MSDDetector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_xfeatures2d_MSDDetector_delete(self.as_raw_mut_MSDDetector()) }; + } + } + + unsafe impl Send for MSDDetector {} + + impl MSDDetector { /// ## C++ default parameters - /// * lucid_kernel: 1 - /// * blur_kernel: 2 + /// * m_patch_radius: 3 + /// * m_search_area_radius: 5 + /// * m_nms_radius: 5 + /// * m_nms_scale_radius: 0 + /// * m_th_saliency: 250.0f + /// * m_k_nn: 4 + /// * m_scale_factor: 1.25f + /// * m_n_scales: -1 + /// * m_compute_orientation: false #[inline] - pub fn create(lucid_kernel: i32, blur_kernel: i32) -> Result> { + pub fn create(m_patch_radius: i32, m_search_area_radius: i32, m_nms_radius: i32, m_nms_scale_radius: i32, m_th_saliency: f32, m_k_nn: i32, m_scale_factor: f32, m_n_scales: i32, m_compute_orientation: bool) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_LUCID_create_const_int_const_int(lucid_kernel, blur_kernel, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_MSDDetector_create_int_int_int_int_float_int_float_int_bool(m_patch_radius, m_search_area_radius, m_nms_radius, m_nms_scale_radius, m_th_saliency, m_k_nn, m_scale_factor, m_n_scales, m_compute_orientation, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// ## Parameters - /// * lucid_kernel: kernel for descriptor construction, where 1=3x3, 2=5x5, 3=7x7 and so forth - /// * blur_kernel: kernel for blurring image prior to descriptor construction, where 1=3x3, 2=5x5, 3=7x7 and so forth - /// /// ## Note - /// This alternative version of [LUCID::create] function uses the following default values for its arguments: - /// * lucid_kernel: 1 - /// * blur_kernel: 2 + /// This alternative version of [MSDDetector::create] function uses the following default values for its arguments: + /// * m_patch_radius: 3 + /// * m_search_area_radius: 5 + /// * m_nms_radius: 5 + /// * m_nms_scale_radius: 0 + /// * m_th_saliency: 250.0f + /// * m_k_nn: 4 + /// * m_scale_factor: 1.25f + /// * m_n_scales: -1 + /// * m_compute_orientation: false #[inline] - pub fn create_def() -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_LUCID_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_MSDDetector_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { LUCID, core::Algorithm, cv_xfeatures2d_LUCID_to_Algorithm } - - boxed_cast_base! { LUCID, crate::features2d::Feature2D, cv_xfeatures2d_LUCID_to_Feature2D } - - impl std::fmt::Debug for LUCID { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LUCID") - .finish() - } - } - /// Constant methods for [crate::xfeatures2d::MSDDetector] pub trait MSDDetectorTraitConst: crate::features2d::Feature2DTraitConst { fn as_raw_MSDDetector(&self) -> *const c_void; @@ -3152,30 +3221,17 @@ pub mod xfeatures2d { } - /// Class implementing the MSD (*Maximal Self-Dissimilarity*) keypoint detector, described in [Tombari14](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Tombari14). - /// - /// The algorithm implements a novel interest point detector stemming from the intuition that image patches - /// which are highly dissimilar over a relatively large extent of their surroundings hold the property of - /// being repeatable and distinctive. This concept of "contextual self-dissimilarity" reverses the key - /// paradigm of recent successful techniques such as the Local Self-Similarity descriptor and the Non-Local - /// Means filter, which build upon the presence of similar - rather than dissimilar - patches. Moreover, - /// it extends to contextual information the local self-dissimilarity notion embedded in established - /// detectors of corner-like interest points, thereby achieving enhanced repeatability, distinctiveness and - /// localization accuracy. - pub struct MSDDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { MSDDetector } - - impl Drop for MSDDetector { + impl std::fmt::Debug for MSDDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xfeatures2d_MSDDetector_delete(self.as_raw_mut_MSDDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("MSDDetector") + .finish() } } - unsafe impl Send for MSDDetector {} + boxed_cast_base! { MSDDetector, core::Algorithm, cv_xfeatures2d_MSDDetector_to_Algorithm } + + boxed_cast_base! { MSDDetector, crate::features2d::Feature2D, cv_xfeatures2d_MSDDetector_to_Feature2D } impl core::AlgorithmTraitConst for MSDDetector { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3207,60 +3263,194 @@ pub mod xfeatures2d { boxed_ref! { MSDDetector, crate::xfeatures2d::MSDDetectorTraitConst, as_raw_MSDDetector, crate::xfeatures2d::MSDDetectorTrait, as_raw_mut_MSDDetector } - impl MSDDetector { + /// Class implementing PCT (position-color-texture) signature extraction + /// as described in [KrulisLS16](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_KrulisLS16). + /// The algorithm is divided to a feature sampler and a clusterizer. + /// Feature sampler produces samples at given set of coordinates. + /// Clusterizer then produces clusters of these samples using k-means algorithm. + /// Resulting set of clusters is the signature of the input image. + /// + /// A signature is an array of SIGNATURE_DIMENSION-dimensional points. + /// Used dimensions are: + /// weight, x, y position; lab color, contrast, entropy. + /// [KrulisLS16](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_KrulisLS16) + /// [BeecksUS10](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_BeecksUS10) + pub struct PCTSignatures { + ptr: *mut c_void, + } + + opencv_type_boxed! { PCTSignatures } + + impl Drop for PCTSignatures { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_xfeatures2d_PCTSignatures_delete(self.as_raw_mut_PCTSignatures()) }; + } + } + + unsafe impl Send for PCTSignatures {} + + impl PCTSignatures { + /// Creates PCTSignatures algorithm using sample and seed count. + /// It generates its own sets of sampling points and clusterization seed indexes. + /// ## Parameters + /// * initSampleCount: Number of points used for image sampling. + /// * initSeedCount: Number of initial clusterization seeds. + /// Must be lower or equal to initSampleCount + /// * pointDistribution: Distribution of generated points. Default: UNIFORM. + /// Available: UNIFORM, REGULAR, NORMAL. + /// ## Returns + /// Created algorithm. + /// + /// ## C++ default parameters + /// * init_sample_count: 2000 + /// * init_seed_count: 400 + /// * point_distribution: 0 + #[inline] + pub fn create(init_sample_count: i32, init_seed_count: i32, point_distribution: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_xfeatures2d_PCTSignatures_create_const_int_const_int_const_int(init_sample_count, init_seed_count, point_distribution, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Creates PCTSignatures algorithm using sample and seed count. + /// It generates its own sets of sampling points and clusterization seed indexes. + /// ## Parameters + /// * initSampleCount: Number of points used for image sampling. + /// * initSeedCount: Number of initial clusterization seeds. + /// Must be lower or equal to initSampleCount + /// * pointDistribution: Distribution of generated points. Default: UNIFORM. + /// Available: UNIFORM, REGULAR, NORMAL. + /// ## Returns + /// Created algorithm. + /// + /// ## Note + /// This alternative version of [PCTSignatures::create] function uses the following default values for its arguments: + /// * init_sample_count: 2000 + /// * init_seed_count: 400 + /// * point_distribution: 0 + #[inline] + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_xfeatures2d_PCTSignatures_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Creates PCTSignatures algorithm using pre-generated sampling points + /// and number of clusterization seeds. It uses the provided + /// sampling points and generates its own clusterization seed indexes. + /// ## Parameters + /// * initSamplingPoints: Sampling points used in image sampling. + /// * initSeedCount: Number of initial clusterization seeds. + /// Must be lower or equal to initSamplingPoints.size(). + /// ## Returns + /// Created algorithm. + #[inline] + pub fn create_1(init_sampling_points: &core::Vector, init_seed_count: i32) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_xfeatures2d_PCTSignatures_create_const_vectorLPoint2fGR_const_int(init_sampling_points.as_raw_VectorOfPoint2f(), init_seed_count, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Creates PCTSignatures algorithm using pre-generated sampling points + /// and clusterization seeds indexes. + /// ## Parameters + /// * initSamplingPoints: Sampling points used in image sampling. + /// * initClusterSeedIndexes: Indexes of initial clusterization seeds. + /// Its size must be lower or equal to initSamplingPoints.size(). + /// ## Returns + /// Created algorithm. + #[inline] + pub fn create_2(init_sampling_points: &core::Vector, init_cluster_seed_indexes: &core::Vector) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_xfeatures2d_PCTSignatures_create_const_vectorLPoint2fGR_const_vectorLintGR(init_sampling_points.as_raw_VectorOfPoint2f(), init_cluster_seed_indexes.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Draws signature in the source image and outputs the result. + /// Signatures are visualized as a circle + /// with radius based on signature weight + /// and color based on signature color. + /// Contrast and entropy are not visualized. + /// ## Parameters + /// * source: Source image. + /// * signature: Image signature. + /// * result: Output result. + /// * radiusToShorterSideRatio: Determines maximal radius of signature in the output image. + /// * borderThickness: Border thickness of the visualized signature. + /// /// ## C++ default parameters - /// * m_patch_radius: 3 - /// * m_search_area_radius: 5 - /// * m_nms_radius: 5 - /// * m_nms_scale_radius: 0 - /// * m_th_saliency: 250.0f - /// * m_k_nn: 4 - /// * m_scale_factor: 1.25f - /// * m_n_scales: -1 - /// * m_compute_orientation: false + /// * radius_to_shorter_side_ratio: 1.0/8 + /// * border_thickness: 1 #[inline] - pub fn create(m_patch_radius: i32, m_search_area_radius: i32, m_nms_radius: i32, m_nms_scale_radius: i32, m_th_saliency: f32, m_k_nn: i32, m_scale_factor: f32, m_n_scales: i32, m_compute_orientation: bool) -> Result> { + pub fn draw_signature(source: &impl ToInputArray, signature: &impl ToInputArray, result: &mut impl ToOutputArray, radius_to_shorter_side_ratio: f32, border_thickness: i32) -> Result<()> { + input_array_arg!(source); + input_array_arg!(signature); + output_array_arg!(result); return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_MSDDetector_create_int_int_int_int_float_int_float_int_bool(m_patch_radius, m_search_area_radius, m_nms_radius, m_nms_scale_radius, m_th_saliency, m_k_nn, m_scale_factor, m_n_scales, m_compute_orientation, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_PCTSignatures_drawSignature_const__InputArrayR_const__InputArrayR_const__OutputArrayR_float_int(source.as_raw__InputArray(), signature.as_raw__InputArray(), result.as_raw__OutputArray(), radius_to_shorter_side_ratio, border_thickness, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } + /// Draws signature in the source image and outputs the result. + /// Signatures are visualized as a circle + /// with radius based on signature weight + /// and color based on signature color. + /// Contrast and entropy are not visualized. + /// ## Parameters + /// * source: Source image. + /// * signature: Image signature. + /// * result: Output result. + /// * radiusToShorterSideRatio: Determines maximal radius of signature in the output image. + /// * borderThickness: Border thickness of the visualized signature. + /// /// ## Note - /// This alternative version of [MSDDetector::create] function uses the following default values for its arguments: - /// * m_patch_radius: 3 - /// * m_search_area_radius: 5 - /// * m_nms_radius: 5 - /// * m_nms_scale_radius: 0 - /// * m_th_saliency: 250.0f - /// * m_k_nn: 4 - /// * m_scale_factor: 1.25f - /// * m_n_scales: -1 - /// * m_compute_orientation: false + /// This alternative version of [PCTSignatures::draw_signature] function uses the following default values for its arguments: + /// * radius_to_shorter_side_ratio: 1.0/8 + /// * border_thickness: 1 #[inline] - pub fn create_def() -> Result> { + pub fn draw_signature_def(source: &impl ToInputArray, signature: &impl ToInputArray, result: &mut impl ToOutputArray) -> Result<()> { + input_array_arg!(source); + input_array_arg!(signature); + output_array_arg!(result); return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_MSDDetector_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_PCTSignatures_drawSignature_const__InputArrayR_const__InputArrayR_const__OutputArrayR(source.as_raw__InputArray(), signature.as_raw__InputArray(), result.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - } - - boxed_cast_base! { MSDDetector, core::Algorithm, cv_xfeatures2d_MSDDetector_to_Algorithm } - - boxed_cast_base! { MSDDetector, crate::features2d::Feature2D, cv_xfeatures2d_MSDDetector_to_Feature2D } - - impl std::fmt::Debug for MSDDetector { + /// Generates initial sampling points according to selected point distribution. + /// ## Parameters + /// * initPoints: Output vector where the generated points will be saved. + /// * count: Number of points to generate. + /// * pointDistribution: Point distribution selector. + /// Available: UNIFORM, REGULAR, NORMAL. + /// + /// Note: Generated coordinates are in range [0..1) #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("MSDDetector") - .finish() + pub fn generate_init_points(init_points: &mut core::Vector, count: i32, point_distribution: i32) -> Result<()> { + return_send!(via ocvrs_return); + unsafe { sys::cv_xfeatures2d_PCTSignatures_generateInitPoints_vectorLPoint2fGR_const_int_int(init_points.as_raw_mut_VectorOfPoint2f(), count, point_distribution, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) } + } /// Constant methods for [crate::xfeatures2d::PCTSignatures] @@ -3799,32 +3989,15 @@ pub mod xfeatures2d { } - /// Class implementing PCT (position-color-texture) signature extraction - /// as described in [KrulisLS16](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_KrulisLS16). - /// The algorithm is divided to a feature sampler and a clusterizer. - /// Feature sampler produces samples at given set of coordinates. - /// Clusterizer then produces clusters of these samples using k-means algorithm. - /// Resulting set of clusters is the signature of the input image. - /// - /// A signature is an array of SIGNATURE_DIMENSION-dimensional points. - /// Used dimensions are: - /// weight, x, y position; lab color, contrast, entropy. - /// [KrulisLS16](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_KrulisLS16) - /// [BeecksUS10](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_BeecksUS10) - pub struct PCTSignatures { - ptr: *mut c_void, - } - - opencv_type_boxed! { PCTSignatures } - - impl Drop for PCTSignatures { + impl std::fmt::Debug for PCTSignatures { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xfeatures2d_PCTSignatures_delete(self.as_raw_mut_PCTSignatures()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PCTSignatures") + .finish() } } - unsafe impl Send for PCTSignatures {} + boxed_cast_base! { PCTSignatures, core::Algorithm, cv_xfeatures2d_PCTSignatures_to_Algorithm } impl core::AlgorithmTraitConst for PCTSignatures { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3846,179 +4019,78 @@ pub mod xfeatures2d { boxed_ref! { PCTSignatures, crate::xfeatures2d::PCTSignaturesTraitConst, as_raw_PCTSignatures, crate::xfeatures2d::PCTSignaturesTrait, as_raw_mut_PCTSignatures } - impl PCTSignatures { - /// Creates PCTSignatures algorithm using sample and seed count. - /// It generates its own sets of sampling points and clusterization seed indexes. - /// ## Parameters - /// * initSampleCount: Number of points used for image sampling. - /// * initSeedCount: Number of initial clusterization seeds. - /// Must be lower or equal to initSampleCount - /// * pointDistribution: Distribution of generated points. Default: UNIFORM. - /// Available: UNIFORM, REGULAR, NORMAL. - /// ## Returns - /// Created algorithm. - /// - /// ## C++ default parameters - /// * init_sample_count: 2000 - /// * init_seed_count: 400 - /// * point_distribution: 0 - #[inline] - pub fn create(init_sample_count: i32, init_seed_count: i32, point_distribution: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_PCTSignatures_create_const_int_const_int_const_int(init_sample_count, init_seed_count, point_distribution, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } + /// Class implementing Signature Quadratic Form Distance (SQFD). + /// ## See also + /// Christian Beecks, Merih Seran Uysal, Thomas Seidl. + /// Signature quadratic form distance. + /// In Proceedings of the ACM International Conference on Image and Video Retrieval, pages 438-445. + /// ACM, 2010. + /// [BeecksUS10](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_BeecksUS10) + pub struct PCTSignaturesSQFD { + ptr: *mut c_void, + } - /// Creates PCTSignatures algorithm using sample and seed count. - /// It generates its own sets of sampling points and clusterization seed indexes. - /// ## Parameters - /// * initSampleCount: Number of points used for image sampling. - /// * initSeedCount: Number of initial clusterization seeds. - /// Must be lower or equal to initSampleCount - /// * pointDistribution: Distribution of generated points. Default: UNIFORM. - /// Available: UNIFORM, REGULAR, NORMAL. - /// ## Returns - /// Created algorithm. - /// - /// ## Note - /// This alternative version of [PCTSignatures::create] function uses the following default values for its arguments: - /// * init_sample_count: 2000 - /// * init_seed_count: 400 - /// * point_distribution: 0 - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_PCTSignatures_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } + opencv_type_boxed! { PCTSignaturesSQFD } - /// Creates PCTSignatures algorithm using pre-generated sampling points - /// and number of clusterization seeds. It uses the provided - /// sampling points and generates its own clusterization seed indexes. - /// ## Parameters - /// * initSamplingPoints: Sampling points used in image sampling. - /// * initSeedCount: Number of initial clusterization seeds. - /// Must be lower or equal to initSamplingPoints.size(). - /// ## Returns - /// Created algorithm. + impl Drop for PCTSignaturesSQFD { #[inline] - pub fn create_1(init_sampling_points: &core::Vector, init_seed_count: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_PCTSignatures_create_const_vectorLPoint2fGR_const_int(init_sampling_points.as_raw_VectorOfPoint2f(), init_seed_count, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) + fn drop(&mut self) { + unsafe { sys::cv_xfeatures2d_PCTSignaturesSQFD_delete(self.as_raw_mut_PCTSignaturesSQFD()) }; } + } - /// Creates PCTSignatures algorithm using pre-generated sampling points - /// and clusterization seeds indexes. - /// ## Parameters - /// * initSamplingPoints: Sampling points used in image sampling. - /// * initClusterSeedIndexes: Indexes of initial clusterization seeds. - /// Its size must be lower or equal to initSamplingPoints.size(). - /// ## Returns - /// Created algorithm. - #[inline] - pub fn create_2(init_sampling_points: &core::Vector, init_cluster_seed_indexes: &core::Vector) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_PCTSignatures_create_const_vectorLPoint2fGR_const_vectorLintGR(init_sampling_points.as_raw_VectorOfPoint2f(), init_cluster_seed_indexes.as_raw_VectorOfi32(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } + unsafe impl Send for PCTSignaturesSQFD {} - /// Draws signature in the source image and outputs the result. - /// Signatures are visualized as a circle - /// with radius based on signature weight - /// and color based on signature color. - /// Contrast and entropy are not visualized. + impl PCTSignaturesSQFD { + /// Creates the algorithm instance using selected distance function, + /// similarity function and similarity function parameter. /// ## Parameters - /// * source: Source image. - /// * signature: Image signature. - /// * result: Output result. - /// * radiusToShorterSideRatio: Determines maximal radius of signature in the output image. - /// * borderThickness: Border thickness of the visualized signature. + /// * distanceFunction: Distance function selector. Default: L2 + /// Available: L0_25, L0_5, L1, L2, L2SQUARED, L5, L_INFINITY + /// * similarityFunction: Similarity function selector. Default: HEURISTIC + /// Available: MINUS, GAUSSIAN, HEURISTIC + /// * similarityParameter: Parameter of the similarity function. /// /// ## C++ default parameters - /// * radius_to_shorter_side_ratio: 1.0/8 - /// * border_thickness: 1 - #[inline] - pub fn draw_signature(source: &impl ToInputArray, signature: &impl ToInputArray, result: &mut impl ToOutputArray, radius_to_shorter_side_ratio: f32, border_thickness: i32) -> Result<()> { - input_array_arg!(source); - input_array_arg!(signature); - output_array_arg!(result); - return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_PCTSignatures_drawSignature_const__InputArrayR_const__InputArrayR_const__OutputArrayR_float_int(source.as_raw__InputArray(), signature.as_raw__InputArray(), result.as_raw__OutputArray(), radius_to_shorter_side_ratio, border_thickness, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - /// Draws signature in the source image and outputs the result. - /// Signatures are visualized as a circle - /// with radius based on signature weight - /// and color based on signature color. - /// Contrast and entropy are not visualized. - /// ## Parameters - /// * source: Source image. - /// * signature: Image signature. - /// * result: Output result. - /// * radiusToShorterSideRatio: Determines maximal radius of signature in the output image. - /// * borderThickness: Border thickness of the visualized signature. - /// - /// ## Note - /// This alternative version of [PCTSignatures::draw_signature] function uses the following default values for its arguments: - /// * radius_to_shorter_side_ratio: 1.0/8 - /// * border_thickness: 1 + /// * distance_function: 3 + /// * similarity_function: 2 + /// * similarity_parameter: 1.0f #[inline] - pub fn draw_signature_def(source: &impl ToInputArray, signature: &impl ToInputArray, result: &mut impl ToOutputArray) -> Result<()> { - input_array_arg!(source); - input_array_arg!(signature); - output_array_arg!(result); + pub fn create(distance_function: i32, similarity_function: i32, similarity_parameter: f32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_PCTSignatures_drawSignature_const__InputArrayR_const__InputArrayR_const__OutputArrayR(source.as_raw__InputArray(), signature.as_raw__InputArray(), result.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_PCTSignaturesSQFD_create_const_int_const_int_const_float(distance_function, similarity_function, similarity_parameter, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Generates initial sampling points according to selected point distribution. + /// Creates the algorithm instance using selected distance function, + /// similarity function and similarity function parameter. /// ## Parameters - /// * initPoints: Output vector where the generated points will be saved. - /// * count: Number of points to generate. - /// * pointDistribution: Point distribution selector. - /// Available: UNIFORM, REGULAR, NORMAL. + /// * distanceFunction: Distance function selector. Default: L2 + /// Available: L0_25, L0_5, L1, L2, L2SQUARED, L5, L_INFINITY + /// * similarityFunction: Similarity function selector. Default: HEURISTIC + /// Available: MINUS, GAUSSIAN, HEURISTIC + /// * similarityParameter: Parameter of the similarity function. /// - /// Note: Generated coordinates are in range [0..1) + /// ## Note + /// This alternative version of [PCTSignaturesSQFD::create] function uses the following default values for its arguments: + /// * distance_function: 3 + /// * similarity_function: 2 + /// * similarity_parameter: 1.0f #[inline] - pub fn generate_init_points(init_points: &mut core::Vector, count: i32, point_distribution: i32) -> Result<()> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_PCTSignatures_generateInitPoints_vectorLPoint2fGR_const_int_int(init_points.as_raw_mut_VectorOfPoint2f(), count, point_distribution, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_PCTSignaturesSQFD_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { PCTSignatures, core::Algorithm, cv_xfeatures2d_PCTSignatures_to_Algorithm } - - impl std::fmt::Debug for PCTSignatures { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PCTSignatures") - .finish() - } - } - /// Constant methods for [crate::xfeatures2d::PCTSignaturesSQFD] pub trait PCTSignaturesSQFDTraitConst: core::AlgorithmTraitConst { fn as_raw_PCTSignaturesSQFD(&self) -> *const c_void; @@ -4061,27 +4133,15 @@ pub mod xfeatures2d { } - /// Class implementing Signature Quadratic Form Distance (SQFD). - /// ## See also - /// Christian Beecks, Merih Seran Uysal, Thomas Seidl. - /// Signature quadratic form distance. - /// In Proceedings of the ACM International Conference on Image and Video Retrieval, pages 438-445. - /// ACM, 2010. - /// [BeecksUS10](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_BeecksUS10) - pub struct PCTSignaturesSQFD { - ptr: *mut c_void, - } - - opencv_type_boxed! { PCTSignaturesSQFD } - - impl Drop for PCTSignaturesSQFD { + impl std::fmt::Debug for PCTSignaturesSQFD { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xfeatures2d_PCTSignaturesSQFD_delete(self.as_raw_mut_PCTSignaturesSQFD()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("PCTSignaturesSQFD") + .finish() } } - unsafe impl Send for PCTSignaturesSQFD {} + boxed_cast_base! { PCTSignaturesSQFD, core::Algorithm, cv_xfeatures2d_PCTSignaturesSQFD_to_Algorithm } impl core::AlgorithmTraitConst for PCTSignaturesSQFD { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -4103,66 +4163,104 @@ pub mod xfeatures2d { boxed_ref! { PCTSignaturesSQFD, crate::xfeatures2d::PCTSignaturesSQFDTraitConst, as_raw_PCTSignaturesSQFD, crate::xfeatures2d::PCTSignaturesSQFDTrait, as_raw_mut_PCTSignaturesSQFD } - impl PCTSignaturesSQFD { - /// Creates the algorithm instance using selected distance function, - /// similarity function and similarity function parameter. + /// Class for extracting Speeded Up Robust Features from an image [Bay06](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Bay06) . + /// + /// The algorithm parameters: + /// * member int extended + /// * 0 means that the basic descriptors (64 elements each) shall be computed + /// * 1 means that the extended descriptors (128 elements each) shall be computed + /// * member int upright + /// * 0 means that detector computes orientation of each feature. + /// * 1 means that the orientation is not computed (which is much, much faster). For example, + /// if you match images from a stereo pair, or do image stitching, the matched features + /// likely have very similar angles, and you can speed up feature extraction by setting + /// upright=1. + /// * member double hessianThreshold + /// Threshold for the keypoint detector. Only features, whose hessian is larger than + /// hessianThreshold are retained by the detector. Therefore, the larger the value, the less + /// keypoints you will get. A good default value could be from 300 to 500, depending from the + /// image contrast. + /// * member int nOctaves + /// The number of a gaussian pyramid octaves that the detector uses. It is set to 4 by default. + /// If you want to get very large features, use the larger value. If you want just small + /// features, decrease it. + /// * member int nOctaveLayers + /// The number of images within each octave of a gaussian pyramid. It is set to 2 by default. + /// + /// Note: + /// * An example using the SURF feature detector can be found at + /// opencv_source_code/samples/cpp/generic_descriptor_match.cpp + /// * Another example using the SURF feature detector, extractor and matcher can be found at + /// opencv_source_code/samples/cpp/matcher_simple.cpp + pub struct SURF { + ptr: *mut c_void, + } + + opencv_type_boxed! { SURF } + + impl Drop for SURF { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_xfeatures2d_SURF_delete(self.as_raw_mut_SURF()) }; + } + } + + unsafe impl Send for SURF {} + + impl SURF { /// ## Parameters - /// * distanceFunction: Distance function selector. Default: L2 - /// Available: L0_25, L0_5, L1, L2, L2SQUARED, L5, L_INFINITY - /// * similarityFunction: Similarity function selector. Default: HEURISTIC - /// Available: MINUS, GAUSSIAN, HEURISTIC - /// * similarityParameter: Parameter of the similarity function. + /// * hessianThreshold: Threshold for hessian keypoint detector used in SURF. + /// * nOctaves: Number of pyramid octaves the keypoint detector will use. + /// * nOctaveLayers: Number of octave layers within each octave. + /// * extended: Extended descriptor flag (true - use extended 128-element descriptors; false - use + /// 64-element descriptors). + /// * upright: Up-right or rotated features flag (true - do not compute orientation of features; + /// false - compute orientation). /// /// ## C++ default parameters - /// * distance_function: 3 - /// * similarity_function: 2 - /// * similarity_parameter: 1.0f + /// * hessian_threshold: 100 + /// * n_octaves: 4 + /// * n_octave_layers: 3 + /// * extended: false + /// * upright: false #[inline] - pub fn create(distance_function: i32, similarity_function: i32, similarity_parameter: f32) -> Result> { + pub fn create(hessian_threshold: f64, n_octaves: i32, n_octave_layers: i32, extended: bool, upright: bool) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_PCTSignaturesSQFD_create_const_int_const_int_const_float(distance_function, similarity_function, similarity_parameter, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_SURF_create_double_int_int_bool_bool(hessian_threshold, n_octaves, n_octave_layers, extended, upright, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// Creates the algorithm instance using selected distance function, - /// similarity function and similarity function parameter. /// ## Parameters - /// * distanceFunction: Distance function selector. Default: L2 - /// Available: L0_25, L0_5, L1, L2, L2SQUARED, L5, L_INFINITY - /// * similarityFunction: Similarity function selector. Default: HEURISTIC - /// Available: MINUS, GAUSSIAN, HEURISTIC - /// * similarityParameter: Parameter of the similarity function. + /// * hessianThreshold: Threshold for hessian keypoint detector used in SURF. + /// * nOctaves: Number of pyramid octaves the keypoint detector will use. + /// * nOctaveLayers: Number of octave layers within each octave. + /// * extended: Extended descriptor flag (true - use extended 128-element descriptors; false - use + /// 64-element descriptors). + /// * upright: Up-right or rotated features flag (true - do not compute orientation of features; + /// false - compute orientation). /// /// ## Note - /// This alternative version of [PCTSignaturesSQFD::create] function uses the following default values for its arguments: - /// * distance_function: 3 - /// * similarity_function: 2 - /// * similarity_parameter: 1.0f + /// This alternative version of [SURF::create] function uses the following default values for its arguments: + /// * hessian_threshold: 100 + /// * n_octaves: 4 + /// * n_octave_layers: 3 + /// * extended: false + /// * upright: false #[inline] - pub fn create_def() -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_PCTSignaturesSQFD_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_SURF_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { PCTSignaturesSQFD, core::Algorithm, cv_xfeatures2d_PCTSignaturesSQFD_to_Algorithm } - - impl std::fmt::Debug for PCTSignaturesSQFD { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("PCTSignaturesSQFD") - .finish() - } - } - /// Constant methods for [crate::xfeatures2d::SURF] pub trait SURFTraitConst: crate::features2d::Feature2DTraitConst { fn as_raw_SURF(&self) -> *const c_void; @@ -4275,49 +4373,17 @@ pub mod xfeatures2d { } - /// Class for extracting Speeded Up Robust Features from an image [Bay06](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Bay06) . - /// - /// The algorithm parameters: - /// * member int extended - /// * 0 means that the basic descriptors (64 elements each) shall be computed - /// * 1 means that the extended descriptors (128 elements each) shall be computed - /// * member int upright - /// * 0 means that detector computes orientation of each feature. - /// * 1 means that the orientation is not computed (which is much, much faster). For example, - /// if you match images from a stereo pair, or do image stitching, the matched features - /// likely have very similar angles, and you can speed up feature extraction by setting - /// upright=1. - /// * member double hessianThreshold - /// Threshold for the keypoint detector. Only features, whose hessian is larger than - /// hessianThreshold are retained by the detector. Therefore, the larger the value, the less - /// keypoints you will get. A good default value could be from 300 to 500, depending from the - /// image contrast. - /// * member int nOctaves - /// The number of a gaussian pyramid octaves that the detector uses. It is set to 4 by default. - /// If you want to get very large features, use the larger value. If you want just small - /// features, decrease it. - /// * member int nOctaveLayers - /// The number of images within each octave of a gaussian pyramid. It is set to 2 by default. - /// - /// Note: - /// * An example using the SURF feature detector can be found at - /// opencv_source_code/samples/cpp/generic_descriptor_match.cpp - /// * Another example using the SURF feature detector, extractor and matcher can be found at - /// opencv_source_code/samples/cpp/matcher_simple.cpp - pub struct SURF { - ptr: *mut c_void, - } - - opencv_type_boxed! { SURF } - - impl Drop for SURF { + impl std::fmt::Debug for SURF { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xfeatures2d_SURF_delete(self.as_raw_mut_SURF()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SURF") + .finish() } } - unsafe impl Send for SURF {} + boxed_cast_base! { SURF, core::Algorithm, cv_xfeatures2d_SURF_to_Algorithm } + + boxed_cast_base! { SURF, crate::features2d::Feature2D, cv_xfeatures2d_SURF_to_Feature2D } impl core::AlgorithmTraitConst for SURF { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -4349,72 +4415,62 @@ pub mod xfeatures2d { boxed_ref! { SURF, crate::xfeatures2d::SURFTraitConst, as_raw_SURF, crate::xfeatures2d::SURFTrait, as_raw_mut_SURF } - impl SURF { - /// ## Parameters - /// * hessianThreshold: Threshold for hessian keypoint detector used in SURF. - /// * nOctaves: Number of pyramid octaves the keypoint detector will use. - /// * nOctaveLayers: Number of octave layers within each octave. - /// * extended: Extended descriptor flag (true - use extended 128-element descriptors; false - use - /// 64-element descriptors). - /// * upright: Up-right or rotated features flag (true - do not compute orientation of features; - /// false - compute orientation). + /// The class implements the keypoint detector introduced by [Agrawal08](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Agrawal08), synonym of StarDetector. : + pub struct StarDetector { + ptr: *mut c_void, + } + + opencv_type_boxed! { StarDetector } + + impl Drop for StarDetector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_xfeatures2d_StarDetector_delete(self.as_raw_mut_StarDetector()) }; + } + } + + unsafe impl Send for StarDetector {} + + impl StarDetector { + /// the full constructor /// - /// ## C++ default parameters - /// * hessian_threshold: 100 - /// * n_octaves: 4 - /// * n_octave_layers: 3 - /// * extended: false - /// * upright: false + /// ## C++ default parameters + /// * max_size: 45 + /// * response_threshold: 30 + /// * line_threshold_projected: 10 + /// * line_threshold_binarized: 8 + /// * suppress_nonmax_size: 5 #[inline] - pub fn create(hessian_threshold: f64, n_octaves: i32, n_octave_layers: i32, extended: bool, upright: bool) -> Result> { + pub fn create(max_size: i32, response_threshold: i32, line_threshold_projected: i32, line_threshold_binarized: i32, suppress_nonmax_size: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_SURF_create_double_int_int_bool_bool(hessian_threshold, n_octaves, n_octave_layers, extended, upright, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_StarDetector_create_int_int_int_int_int(max_size, response_threshold, line_threshold_projected, line_threshold_binarized, suppress_nonmax_size, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// ## Parameters - /// * hessianThreshold: Threshold for hessian keypoint detector used in SURF. - /// * nOctaves: Number of pyramid octaves the keypoint detector will use. - /// * nOctaveLayers: Number of octave layers within each octave. - /// * extended: Extended descriptor flag (true - use extended 128-element descriptors; false - use - /// 64-element descriptors). - /// * upright: Up-right or rotated features flag (true - do not compute orientation of features; - /// false - compute orientation). + /// the full constructor /// /// ## Note - /// This alternative version of [SURF::create] function uses the following default values for its arguments: - /// * hessian_threshold: 100 - /// * n_octaves: 4 - /// * n_octave_layers: 3 - /// * extended: false - /// * upright: false + /// This alternative version of [StarDetector::create] function uses the following default values for its arguments: + /// * max_size: 45 + /// * response_threshold: 30 + /// * line_threshold_projected: 10 + /// * line_threshold_binarized: 8 + /// * suppress_nonmax_size: 5 #[inline] - pub fn create_def() -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_SURF_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_StarDetector_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { SURF, core::Algorithm, cv_xfeatures2d_SURF_to_Algorithm } - - boxed_cast_base! { SURF, crate::features2d::Feature2D, cv_xfeatures2d_SURF_to_Feature2D } - - impl std::fmt::Debug for SURF { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SURF") - .finish() - } - } - /// Constant methods for [crate::xfeatures2d::StarDetector] pub trait StarDetectorTraitConst: crate::features2d::Feature2DTraitConst { fn as_raw_StarDetector(&self) -> *const c_void; @@ -4527,21 +4583,17 @@ pub mod xfeatures2d { } - /// The class implements the keypoint detector introduced by [Agrawal08](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Agrawal08), synonym of StarDetector. : - pub struct StarDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { StarDetector } - - impl Drop for StarDetector { + impl std::fmt::Debug for StarDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xfeatures2d_StarDetector_delete(self.as_raw_mut_StarDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("StarDetector") + .finish() } } - unsafe impl Send for StarDetector {} + boxed_cast_base! { StarDetector, core::Algorithm, cv_xfeatures2d_StarDetector_to_Algorithm } + + boxed_cast_base! { StarDetector, crate::features2d::Feature2D, cv_xfeatures2d_StarDetector_to_Feature2D } impl core::AlgorithmTraitConst for StarDetector { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -4573,58 +4625,71 @@ pub mod xfeatures2d { boxed_ref! { StarDetector, crate::xfeatures2d::StarDetectorTraitConst, as_raw_StarDetector, crate::xfeatures2d::StarDetectorTrait, as_raw_mut_StarDetector } - impl StarDetector { - /// the full constructor - /// + /// Class implementing the Tree Based Morse Regions (TBMR) as described in + /// [Najman2014](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Najman2014) extended with scaled extraction ability. + /// + /// ## Parameters + /// * min_area: prune areas smaller than minArea + /// * max_area_relative: prune areas bigger than maxArea = max_area_relative * + /// input_image_size + /// * scale_factor: scale factor for scaled extraction. + /// * n_scales: number of applications of the scale factor (octaves). + /// + /// + /// Note: This algorithm is based on Component Tree (Min/Max) as well as MSER but + /// uses a Morse-theory approach to extract features. + /// + /// Features are ellipses (similar to MSER, however a MSER feature can never be a + /// TBMR feature and vice versa). + pub struct TBMR { + ptr: *mut c_void, + } + + opencv_type_boxed! { TBMR } + + impl Drop for TBMR { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_xfeatures2d_TBMR_delete(self.as_raw_mut_TBMR()) }; + } + } + + unsafe impl Send for TBMR {} + + impl TBMR { /// ## C++ default parameters - /// * max_size: 45 - /// * response_threshold: 30 - /// * line_threshold_projected: 10 - /// * line_threshold_binarized: 8 - /// * suppress_nonmax_size: 5 + /// * min_area: 60 + /// * max_area_relative: 0.01f + /// * scale_factor: 1.25f + /// * n_scales: -1 #[inline] - pub fn create(max_size: i32, response_threshold: i32, line_threshold_projected: i32, line_threshold_binarized: i32, suppress_nonmax_size: i32) -> Result> { + pub fn create(min_area: i32, max_area_relative: f32, scale_factor: f32, n_scales: i32) -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_StarDetector_create_int_int_int_int_int(max_size, response_threshold, line_threshold_projected, line_threshold_binarized, suppress_nonmax_size, ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_TBMR_create_int_float_float_int(min_area, max_area_relative, scale_factor, n_scales, ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } - /// the full constructor - /// /// ## Note - /// This alternative version of [StarDetector::create] function uses the following default values for its arguments: - /// * max_size: 45 - /// * response_threshold: 30 - /// * line_threshold_projected: 10 - /// * line_threshold_binarized: 8 - /// * suppress_nonmax_size: 5 + /// This alternative version of [TBMR::create] function uses the following default values for its arguments: + /// * min_area: 60 + /// * max_area_relative: 0.01f + /// * scale_factor: 1.25f + /// * n_scales: -1 #[inline] - pub fn create_def() -> Result> { + pub fn create_def() -> Result> { return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_StarDetector_create(ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_xfeatures2d_TBMR_create(ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; Ok(ret) } } - boxed_cast_base! { StarDetector, core::Algorithm, cv_xfeatures2d_StarDetector_to_Algorithm } - - boxed_cast_base! { StarDetector, crate::features2d::Feature2D, cv_xfeatures2d_StarDetector_to_Feature2D } - - impl std::fmt::Debug for StarDetector { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("StarDetector") - .finish() - } - } - /// Constant methods for [crate::xfeatures2d::TBMR] pub trait TBMRTraitConst: crate::xfeatures2d::AffineFeature2DTraitConst { fn as_raw_TBMR(&self) -> *const c_void; @@ -4719,36 +4784,19 @@ pub mod xfeatures2d { } - /// Class implementing the Tree Based Morse Regions (TBMR) as described in - /// [Najman2014](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Najman2014) extended with scaled extraction ability. - /// - /// ## Parameters - /// * min_area: prune areas smaller than minArea - /// * max_area_relative: prune areas bigger than maxArea = max_area_relative * - /// input_image_size - /// * scale_factor: scale factor for scaled extraction. - /// * n_scales: number of applications of the scale factor (octaves). - /// - /// - /// Note: This algorithm is based on Component Tree (Min/Max) as well as MSER but - /// uses a Morse-theory approach to extract features. - /// - /// Features are ellipses (similar to MSER, however a MSER feature can never be a - /// TBMR feature and vice versa). - pub struct TBMR { - ptr: *mut c_void, - } - - opencv_type_boxed! { TBMR } - - impl Drop for TBMR { + impl std::fmt::Debug for TBMR { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xfeatures2d_TBMR_delete(self.as_raw_mut_TBMR()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TBMR") + .finish() } } - unsafe impl Send for TBMR {} + boxed_cast_base! { TBMR, crate::xfeatures2d::AffineFeature2D, cv_xfeatures2d_TBMR_to_AffineFeature2D } + + boxed_cast_base! { TBMR, core::Algorithm, cv_xfeatures2d_TBMR_to_Algorithm } + + boxed_cast_base! { TBMR, crate::features2d::Feature2D, cv_xfeatures2d_TBMR_to_Feature2D } impl crate::xfeatures2d::AffineFeature2DTraitConst for TBMR { #[inline] fn as_raw_AffineFeature2D(&self) -> *const c_void { self.as_raw() } @@ -4781,85 +4829,15 @@ pub mod xfeatures2d { boxed_ref! { TBMR, crate::features2d::Feature2DTraitConst, as_raw_Feature2D, crate::features2d::Feature2DTrait, as_raw_mut_Feature2D } impl crate::xfeatures2d::TBMRTraitConst for TBMR { - #[inline] fn as_raw_TBMR(&self) -> *const c_void { self.as_raw() } - } - - impl crate::xfeatures2d::TBMRTrait for TBMR { - #[inline] fn as_raw_mut_TBMR(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TBMR, crate::xfeatures2d::TBMRTraitConst, as_raw_TBMR, crate::xfeatures2d::TBMRTrait, as_raw_mut_TBMR } - - impl TBMR { - /// ## C++ default parameters - /// * min_area: 60 - /// * max_area_relative: 0.01f - /// * scale_factor: 1.25f - /// * n_scales: -1 - #[inline] - pub fn create(min_area: i32, max_area_relative: f32, scale_factor: f32, n_scales: i32) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_TBMR_create_int_float_float_int(min_area, max_area_relative, scale_factor, n_scales, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [TBMR::create] function uses the following default values for its arguments: - /// * min_area: 60 - /// * max_area_relative: 0.01f - /// * scale_factor: 1.25f - /// * n_scales: -1 - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_TBMR_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { TBMR, crate::xfeatures2d::AffineFeature2D, cv_xfeatures2d_TBMR_to_AffineFeature2D } - - boxed_cast_base! { TBMR, core::Algorithm, cv_xfeatures2d_TBMR_to_Algorithm } - - boxed_cast_base! { TBMR, crate::features2d::Feature2D, cv_xfeatures2d_TBMR_to_Feature2D } - - impl std::fmt::Debug for TBMR { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TBMR") - .finish() - } - } - - /// Constant methods for [crate::xfeatures2d::TEBLID] - pub trait TEBLIDTraitConst: crate::features2d::Feature2DTraitConst { - fn as_raw_TEBLID(&self) -> *const c_void; - - #[inline] - fn get_default_name(&self) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_TEBLID_getDefaultName_const(self.as_raw_TEBLID(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { String::opencv_from_extern(ret) }; - Ok(ret) - } - + #[inline] fn as_raw_TBMR(&self) -> *const c_void { self.as_raw() } } - /// Mutable methods for [crate::xfeatures2d::TEBLID] - pub trait TEBLIDTrait: crate::features2d::Feature2DTrait + crate::xfeatures2d::TEBLIDTraitConst { - fn as_raw_mut_TEBLID(&mut self) -> *mut c_void; - + impl crate::xfeatures2d::TBMRTrait for TBMR { + #[inline] fn as_raw_mut_TBMR(&mut self) -> *mut c_void { self.as_raw_mut() } } + boxed_ref! { TBMR, crate::xfeatures2d::TBMRTraitConst, as_raw_TBMR, crate::xfeatures2d::TBMRTrait, as_raw_mut_TBMR } + /// Class implementing TEBLID (Triplet-based Efficient Binary Local Image Descriptor), /// described in [Suarez2021TEBLID](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Suarez2021TEBLID). /// @@ -4894,41 +4872,13 @@ pub mod xfeatures2d { unsafe impl Send for TEBLID {} - impl core::AlgorithmTraitConst for TEBLID { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for TEBLID { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TEBLID, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::features2d::Feature2DTraitConst for TEBLID { - #[inline] fn as_raw_Feature2D(&self) -> *const c_void { self.as_raw() } - } - - impl crate::features2d::Feature2DTrait for TEBLID { - #[inline] fn as_raw_mut_Feature2D(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TEBLID, crate::features2d::Feature2DTraitConst, as_raw_Feature2D, crate::features2d::Feature2DTrait, as_raw_mut_Feature2D } - - impl crate::xfeatures2d::TEBLIDTraitConst for TEBLID { - #[inline] fn as_raw_TEBLID(&self) -> *const c_void { self.as_raw() } - } - - impl crate::xfeatures2d::TEBLIDTrait for TEBLID { - #[inline] fn as_raw_mut_TEBLID(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { TEBLID, crate::xfeatures2d::TEBLIDTraitConst, as_raw_TEBLID, crate::xfeatures2d::TEBLIDTrait, as_raw_mut_TEBLID } - impl TEBLID { /// Creates a default instance of the class by calling the default constructor #[inline] - fn default() -> Self { - unsafe { Self::from_raw(sys::cv_xfeatures2d_TEBLID_defaultNew_const()) } + pub fn default() -> crate::xfeatures2d::TEBLID { + let ret = unsafe { sys::cv_xfeatures2d_TEBLID_defaultNew_const() }; + let ret = unsafe { crate::xfeatures2d::TEBLID::opencv_from_extern(ret) }; + ret } /// Creates the TEBLID descriptor. @@ -4978,9 +4928,35 @@ pub mod xfeatures2d { } - boxed_cast_base! { TEBLID, core::Algorithm, cv_xfeatures2d_TEBLID_to_Algorithm } + /// Constant methods for [crate::xfeatures2d::TEBLID] + pub trait TEBLIDTraitConst: crate::features2d::Feature2DTraitConst { + fn as_raw_TEBLID(&self) -> *const c_void; - boxed_cast_base! { TEBLID, crate::features2d::Feature2D, cv_xfeatures2d_TEBLID_to_Feature2D } + #[inline] + fn get_default_name(&self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_xfeatures2d_TEBLID_getDefaultName_const(self.as_raw_TEBLID(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { String::opencv_from_extern(ret) }; + Ok(ret) + } + + } + + /// Mutable methods for [crate::xfeatures2d::TEBLID] + pub trait TEBLIDTrait: crate::features2d::Feature2DTrait + crate::xfeatures2d::TEBLIDTraitConst { + fn as_raw_mut_TEBLID(&mut self) -> *mut c_void; + + } + + impl Default for TEBLID { + #[inline] + /// Forwards to infallible Self::default() + fn default() -> Self { + Self::default() + } + } impl std::fmt::Debug for TEBLID { #[inline] @@ -4990,12 +4966,107 @@ pub mod xfeatures2d { } } - impl Default for TEBLID { + boxed_cast_base! { TEBLID, core::Algorithm, cv_xfeatures2d_TEBLID_to_Algorithm } + + boxed_cast_base! { TEBLID, crate::features2d::Feature2D, cv_xfeatures2d_TEBLID_to_Feature2D } + + impl core::AlgorithmTraitConst for TEBLID { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } + } + + impl core::AlgorithmTrait for TEBLID { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { TEBLID, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + + impl crate::features2d::Feature2DTraitConst for TEBLID { + #[inline] fn as_raw_Feature2D(&self) -> *const c_void { self.as_raw() } + } + + impl crate::features2d::Feature2DTrait for TEBLID { + #[inline] fn as_raw_mut_Feature2D(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { TEBLID, crate::features2d::Feature2DTraitConst, as_raw_Feature2D, crate::features2d::Feature2DTrait, as_raw_mut_Feature2D } + + impl crate::xfeatures2d::TEBLIDTraitConst for TEBLID { + #[inline] fn as_raw_TEBLID(&self) -> *const c_void { self.as_raw() } + } + + impl crate::xfeatures2d::TEBLIDTrait for TEBLID { + #[inline] fn as_raw_mut_TEBLID(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { TEBLID, crate::xfeatures2d::TEBLIDTraitConst, as_raw_TEBLID, crate::xfeatures2d::TEBLIDTrait, as_raw_mut_TEBLID } + + /// Class implementing VGG (Oxford Visual Geometry Group) descriptor trained end to end + /// using "Descriptor Learning Using Convex Optimisation" (DLCO) aparatus described in [Simonyan14](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Simonyan14). + /// + /// ## Parameters + /// * desc: type of descriptor to use, VGG::VGG_120 is default (120 dimensions float) + /// Available types are VGG::VGG_120, VGG::VGG_80, VGG::VGG_64, VGG::VGG_48 + /// * isigma: gaussian kernel value for image blur (default is 1.4f) + /// * img_normalize: use image sample intensity normalization (enabled by default) + /// * use_orientation: sample patterns using keypoints orientation, enabled by default + /// * scale_factor: adjust the sampling window of detected keypoints to 64.0f (VGG sampling window) + /// 6.25f is default and fits for KAZE, SURF detected keypoints window ratio + /// 6.75f should be the scale for SIFT detected keypoints window ratio + /// 5.00f should be the scale for AKAZE, MSD, AGAST, FAST, BRISK keypoints window ratio + /// 0.75f should be the scale for ORB keypoints ratio + /// + /// * dsc_normalize: clamp descriptors to 255 and convert to uchar CV_8UC1 (disabled by default) + pub struct VGG { + ptr: *mut c_void, + } + + opencv_type_boxed! { VGG } + + impl Drop for VGG { #[inline] - /// Forwards to infallible Self::default() - fn default() -> Self { - Self::default() + fn drop(&mut self) { + unsafe { sys::cv_xfeatures2d_VGG_delete(self.as_raw_mut_VGG()) }; + } + } + + unsafe impl Send for VGG {} + + impl VGG { + /// ## C++ default parameters + /// * desc: VGG::VGG_120 + /// * isigma: 1.4f + /// * img_normalize: true + /// * use_scale_orientation: true + /// * scale_factor: 6.25f + /// * dsc_normalize: false + #[inline] + pub fn create(desc: i32, isigma: f32, img_normalize: bool, use_scale_orientation: bool, scale_factor: f32, dsc_normalize: bool) -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_xfeatures2d_VGG_create_int_float_bool_bool_float_bool(desc, isigma, img_normalize, use_scale_orientation, scale_factor, dsc_normalize, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + /// ## Note + /// This alternative version of [VGG::create] function uses the following default values for its arguments: + /// * desc: VGG::VGG_120 + /// * isigma: 1.4f + /// * img_normalize: true + /// * use_scale_orientation: true + /// * scale_factor: 6.25f + /// * dsc_normalize: false + #[inline] + pub fn create_def() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_xfeatures2d_VGG_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) } + } /// Constant methods for [crate::xfeatures2d::VGG] @@ -5110,36 +5181,17 @@ pub mod xfeatures2d { } - /// Class implementing VGG (Oxford Visual Geometry Group) descriptor trained end to end - /// using "Descriptor Learning Using Convex Optimisation" (DLCO) aparatus described in [Simonyan14](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Simonyan14). - /// - /// ## Parameters - /// * desc: type of descriptor to use, VGG::VGG_120 is default (120 dimensions float) - /// Available types are VGG::VGG_120, VGG::VGG_80, VGG::VGG_64, VGG::VGG_48 - /// * isigma: gaussian kernel value for image blur (default is 1.4f) - /// * img_normalize: use image sample intensity normalization (enabled by default) - /// * use_orientation: sample patterns using keypoints orientation, enabled by default - /// * scale_factor: adjust the sampling window of detected keypoints to 64.0f (VGG sampling window) - /// 6.25f is default and fits for KAZE, SURF detected keypoints window ratio - /// 6.75f should be the scale for SIFT detected keypoints window ratio - /// 5.00f should be the scale for AKAZE, MSD, AGAST, FAST, BRISK keypoints window ratio - /// 0.75f should be the scale for ORB keypoints ratio - /// - /// * dsc_normalize: clamp descriptors to 255 and convert to uchar CV_8UC1 (disabled by default) - pub struct VGG { - ptr: *mut c_void, - } - - opencv_type_boxed! { VGG } - - impl Drop for VGG { + impl std::fmt::Debug for VGG { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xfeatures2d_VGG_delete(self.as_raw_mut_VGG()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("VGG") + .finish() } } - unsafe impl Send for VGG {} + boxed_cast_base! { VGG, core::Algorithm, cv_xfeatures2d_VGG_to_Algorithm } + + boxed_cast_base! { VGG, crate::features2d::Feature2D, cv_xfeatures2d_VGG_to_Feature2D } impl core::AlgorithmTraitConst for VGG { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5171,53 +5223,4 @@ pub mod xfeatures2d { boxed_ref! { VGG, crate::xfeatures2d::VGGTraitConst, as_raw_VGG, crate::xfeatures2d::VGGTrait, as_raw_mut_VGG } - impl VGG { - /// ## C++ default parameters - /// * desc: VGG::VGG_120 - /// * isigma: 1.4f - /// * img_normalize: true - /// * use_scale_orientation: true - /// * scale_factor: 6.25f - /// * dsc_normalize: false - #[inline] - pub fn create(desc: i32, isigma: f32, img_normalize: bool, use_scale_orientation: bool, scale_factor: f32, dsc_normalize: bool) -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_VGG_create_int_float_bool_bool_float_bool(desc, isigma, img_normalize, use_scale_orientation, scale_factor, dsc_normalize, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - /// ## Note - /// This alternative version of [VGG::create] function uses the following default values for its arguments: - /// * desc: VGG::VGG_120 - /// * isigma: 1.4f - /// * img_normalize: true - /// * use_scale_orientation: true - /// * scale_factor: 6.25f - /// * dsc_normalize: false - #[inline] - pub fn create_def() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_xfeatures2d_VGG_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { VGG, core::Algorithm, cv_xfeatures2d_VGG_to_Algorithm } - - boxed_cast_base! { VGG, crate::features2d::Feature2D, cv_xfeatures2d_VGG_to_Feature2D } - - impl std::fmt::Debug for VGG { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("VGG") - .finish() - } - } } diff --git a/docs/ximgproc.rs b/docs/ximgproc.rs index 693752c10..815314f16 100644 --- a/docs/ximgproc.rs +++ b/docs/ximgproc.rs @@ -3476,6 +3476,51 @@ pub mod ximgproc { Ok(ret) } + /// Interface for Adaptive Manifold Filter realizations. + /// + /// For more details about this filter see [Gastal12](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Gastal12) and References_. + /// + /// Below listed optional parameters which may be set up with Algorithm::set function. + /// * member double sigma_s = 16.0 + /// Spatial standard deviation. + /// * member double sigma_r = 0.2 + /// Color space standard deviation. + /// * member int tree_height = -1 + /// Height of the manifold tree (default = -1 : automatically computed). + /// * member int num_pca_iterations = 1 + /// Number of iterations to computed the eigenvector. + /// * member bool adjust_outliers = false + /// Specify adjust outliers using Eq. 9 or not. + /// * member bool use_RNG = true + /// Specify use random number generator to compute eigenvector or not. + pub struct AdaptiveManifoldFilter { + ptr: *mut c_void, + } + + opencv_type_boxed! { AdaptiveManifoldFilter } + + impl Drop for AdaptiveManifoldFilter { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_AdaptiveManifoldFilter_delete(self.as_raw_mut_AdaptiveManifoldFilter()) }; + } + } + + unsafe impl Send for AdaptiveManifoldFilter {} + + impl AdaptiveManifoldFilter { + #[inline] + pub fn create() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_ximgproc_AdaptiveManifoldFilter_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::ximgproc::AdaptiveManifoldFilter] pub trait AdaptiveManifoldFilterTraitConst: core::AlgorithmTraitConst { fn as_raw_AdaptiveManifoldFilter(&self) -> *const c_void; @@ -3675,37 +3720,15 @@ pub mod ximgproc { } - /// Interface for Adaptive Manifold Filter realizations. - /// - /// For more details about this filter see [Gastal12](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Gastal12) and References_. - /// - /// Below listed optional parameters which may be set up with Algorithm::set function. - /// * member double sigma_s = 16.0 - /// Spatial standard deviation. - /// * member double sigma_r = 0.2 - /// Color space standard deviation. - /// * member int tree_height = -1 - /// Height of the manifold tree (default = -1 : automatically computed). - /// * member int num_pca_iterations = 1 - /// Number of iterations to computed the eigenvector. - /// * member bool adjust_outliers = false - /// Specify adjust outliers using Eq. 9 or not. - /// * member bool use_RNG = true - /// Specify use random number generator to compute eigenvector or not. - pub struct AdaptiveManifoldFilter { - ptr: *mut c_void, - } - - opencv_type_boxed! { AdaptiveManifoldFilter } - - impl Drop for AdaptiveManifoldFilter { + impl std::fmt::Debug for AdaptiveManifoldFilter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_AdaptiveManifoldFilter_delete(self.as_raw_mut_AdaptiveManifoldFilter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("AdaptiveManifoldFilter") + .finish() } } - unsafe impl Send for AdaptiveManifoldFilter {} + boxed_cast_base! { AdaptiveManifoldFilter, core::Algorithm, cv_ximgproc_AdaptiveManifoldFilter_to_Algorithm } impl core::AlgorithmTraitConst for AdaptiveManifoldFilter { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3727,29 +3750,6 @@ pub mod ximgproc { boxed_ref! { AdaptiveManifoldFilter, crate::ximgproc::AdaptiveManifoldFilterTraitConst, as_raw_AdaptiveManifoldFilter, crate::ximgproc::AdaptiveManifoldFilterTrait, as_raw_mut_AdaptiveManifoldFilter } - impl AdaptiveManifoldFilter { - #[inline] - pub fn create() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_ximgproc_AdaptiveManifoldFilter_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - boxed_cast_base! { AdaptiveManifoldFilter, core::Algorithm, cv_ximgproc_AdaptiveManifoldFilter_to_Algorithm } - - impl std::fmt::Debug for AdaptiveManifoldFilter { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("AdaptiveManifoldFilter") - .finish() - } - } - #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] pub struct Box { @@ -3762,7 +3762,64 @@ pub mod ximgproc { opencv_type_simple! { crate::ximgproc::Box } - impl Box { + /// Class for ContourFitting algorithms. + /// ContourFitting match two contours ![inline formula](https://latex.codecogs.com/png.latex?%20z%5Fa%20) and ![inline formula](https://latex.codecogs.com/png.latex?%20z%5Fb%20) minimizing distance + /// ![block formula](https://latex.codecogs.com/png.latex?%20d%28z%5Fa%2Cz%5Fb%29%3D%5Csum%20%28a%5Fn%20%2D%20s%20%20b%5Fn%20e%5E%7Bj%28n%20%5Calpha%20%2B%5Cphi%20%29%7D%29%5E2%20) where ![inline formula](https://latex.codecogs.com/png.latex?%20a%5Fn%20) and ![inline formula](https://latex.codecogs.com/png.latex?%20b%5Fn%20) are Fourier descriptors of ![inline formula](https://latex.codecogs.com/png.latex?%20z%5Fa%20) and ![inline formula](https://latex.codecogs.com/png.latex?%20z%5Fb%20) and s is a scaling factor and ![inline formula](https://latex.codecogs.com/png.latex?%20%5Cphi%20) is angle rotation and ![inline formula](https://latex.codecogs.com/png.latex?%20%5Calpha%20) is starting point factor adjustement + pub struct ContourFitting { + ptr: *mut c_void, + } + + opencv_type_boxed! { ContourFitting } + + impl Drop for ContourFitting { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_ContourFitting_delete(self.as_raw_mut_ContourFitting()) }; + } + } + + unsafe impl Send for ContourFitting {} + + impl ContourFitting { + /// Fit two closed curves using fourier descriptors. More details in [PersoonFu1977](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_PersoonFu1977) and [BergerRaghunathan1998](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_BergerRaghunathan1998) + /// + /// ## Parameters + /// * ctr: number of Fourier descriptors equal to number of contour points after resampling. + /// * fd: Contour defining second shape (Target). + /// + /// ## C++ default parameters + /// * ctr: 1024 + /// * fd: 16 + #[inline] + pub fn new(ctr: i32, fd: i32) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ximgproc_ContourFitting_ContourFitting_int_int(ctr, fd, ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::ximgproc::ContourFitting::opencv_from_extern(ret) }; + Ok(ret) + } + + /// Fit two closed curves using fourier descriptors. More details in [PersoonFu1977](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_PersoonFu1977) and [BergerRaghunathan1998](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_BergerRaghunathan1998) + /// + /// ## Parameters + /// * ctr: number of Fourier descriptors equal to number of contour points after resampling. + /// * fd: Contour defining second shape (Target). + /// + /// ## Note + /// This alternative version of [new] function uses the following default values for its arguments: + /// * ctr: 1024 + /// * fd: 16 + #[inline] + pub fn new_def() -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ximgproc_ContourFitting_ContourFitting(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { crate::ximgproc::ContourFitting::opencv_from_extern(ret) }; + Ok(ret) + } + } /// Constant methods for [crate::ximgproc::ContourFitting] @@ -3921,23 +3978,15 @@ pub mod ximgproc { } - /// Class for ContourFitting algorithms. - /// ContourFitting match two contours ![inline formula](https://latex.codecogs.com/png.latex?%20z%5Fa%20) and ![inline formula](https://latex.codecogs.com/png.latex?%20z%5Fb%20) minimizing distance - /// ![block formula](https://latex.codecogs.com/png.latex?%20d%28z%5Fa%2Cz%5Fb%29%3D%5Csum%20%28a%5Fn%20%2D%20s%20%20b%5Fn%20e%5E%7Bj%28n%20%5Calpha%20%2B%5Cphi%20%29%7D%29%5E2%20) where ![inline formula](https://latex.codecogs.com/png.latex?%20a%5Fn%20) and ![inline formula](https://latex.codecogs.com/png.latex?%20b%5Fn%20) are Fourier descriptors of ![inline formula](https://latex.codecogs.com/png.latex?%20z%5Fa%20) and ![inline formula](https://latex.codecogs.com/png.latex?%20z%5Fb%20) and s is a scaling factor and ![inline formula](https://latex.codecogs.com/png.latex?%20%5Cphi%20) is angle rotation and ![inline formula](https://latex.codecogs.com/png.latex?%20%5Calpha%20) is starting point factor adjustement - pub struct ContourFitting { - ptr: *mut c_void, - } - - opencv_type_boxed! { ContourFitting } - - impl Drop for ContourFitting { + impl std::fmt::Debug for ContourFitting { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_ContourFitting_delete(self.as_raw_mut_ContourFitting()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ContourFitting") + .finish() } } - unsafe impl Send for ContourFitting {} + boxed_cast_base! { ContourFitting, core::Algorithm, cv_ximgproc_ContourFitting_to_Algorithm } impl core::AlgorithmTraitConst for ContourFitting { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -3959,58 +4008,24 @@ pub mod ximgproc { boxed_ref! { ContourFitting, crate::ximgproc::ContourFittingTraitConst, as_raw_ContourFitting, crate::ximgproc::ContourFittingTrait, as_raw_mut_ContourFitting } - impl ContourFitting { - /// Fit two closed curves using fourier descriptors. More details in [PersoonFu1977](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_PersoonFu1977) and [BergerRaghunathan1998](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_BergerRaghunathan1998) - /// - /// ## Parameters - /// * ctr: number of Fourier descriptors equal to number of contour points after resampling. - /// * fd: Contour defining second shape (Target). - /// - /// ## C++ default parameters - /// * ctr: 1024 - /// * fd: 16 - #[inline] - pub fn new(ctr: i32, fd: i32) -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ximgproc_ContourFitting_ContourFitting_int_int(ctr, fd, ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::ximgproc::ContourFitting::opencv_from_extern(ret) }; - Ok(ret) - } - - /// Fit two closed curves using fourier descriptors. More details in [PersoonFu1977](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_PersoonFu1977) and [BergerRaghunathan1998](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_BergerRaghunathan1998) - /// - /// ## Parameters - /// * ctr: number of Fourier descriptors equal to number of contour points after resampling. - /// * fd: Contour defining second shape (Target). - /// - /// ## Note - /// This alternative version of [new] function uses the following default values for its arguments: - /// * ctr: 1024 - /// * fd: 16 - #[inline] - pub fn new_def() -> Result { - return_send!(via ocvrs_return); - unsafe { sys::cv_ximgproc_ContourFitting_ContourFitting(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { crate::ximgproc::ContourFitting::opencv_from_extern(ret) }; - Ok(ret) - } - + /// Interface for realizations of Domain Transform filter. + /// + /// For more details about this filter see [Gastal11](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Gastal11) . + pub struct DTFilter { + ptr: *mut c_void, } - boxed_cast_base! { ContourFitting, core::Algorithm, cv_ximgproc_ContourFitting_to_Algorithm } + opencv_type_boxed! { DTFilter } - impl std::fmt::Debug for ContourFitting { + impl Drop for DTFilter { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ContourFitting") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_DTFilter_delete(self.as_raw_mut_DTFilter()) }; } } + unsafe impl Send for DTFilter {} + /// Constant methods for [crate::ximgproc::DTFilter] pub trait DTFilterTraitConst: core::AlgorithmTraitConst { fn as_raw_DTFilter(&self) -> *const c_void; @@ -4070,23 +4085,15 @@ pub mod ximgproc { } - /// Interface for realizations of Domain Transform filter. - /// - /// For more details about this filter see [Gastal11](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Gastal11) . - pub struct DTFilter { - ptr: *mut c_void, - } - - opencv_type_boxed! { DTFilter } - - impl Drop for DTFilter { + impl std::fmt::Debug for DTFilter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_DTFilter_delete(self.as_raw_mut_DTFilter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DTFilter") + .finish() } } - unsafe impl Send for DTFilter {} + boxed_cast_base! { DTFilter, core::Algorithm, cv_ximgproc_DTFilter_to_Algorithm } impl core::AlgorithmTraitConst for DTFilter { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -4108,19 +4115,22 @@ pub mod ximgproc { boxed_ref! { DTFilter, crate::ximgproc::DTFilterTraitConst, as_raw_DTFilter, crate::ximgproc::DTFilterTrait, as_raw_mut_DTFilter } - impl DTFilter { + /// Main interface for all disparity map filters. + pub struct DisparityFilter { + ptr: *mut c_void, } - boxed_cast_base! { DTFilter, core::Algorithm, cv_ximgproc_DTFilter_to_Algorithm } + opencv_type_boxed! { DisparityFilter } - impl std::fmt::Debug for DTFilter { + impl Drop for DisparityFilter { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DTFilter") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_DisparityFilter_delete(self.as_raw_mut_DisparityFilter()) }; } } + unsafe impl Send for DisparityFilter {} + /// Constant methods for [crate::ximgproc::DisparityFilter] pub trait DisparityFilterTraitConst: core::AlgorithmTraitConst { fn as_raw_DisparityFilter(&self) -> *const c_void; @@ -4208,21 +4218,17 @@ pub mod ximgproc { } - /// Main interface for all disparity map filters. - pub struct DisparityFilter { - ptr: *mut c_void, - } - - opencv_type_boxed! { DisparityFilter } - - impl Drop for DisparityFilter { + impl std::fmt::Debug for DisparityFilter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_DisparityFilter_delete(self.as_raw_mut_DisparityFilter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DisparityFilter") + .finish() } } - unsafe impl Send for DisparityFilter {} + boxed_cast_base! { DisparityFilter, core::Algorithm, cv_ximgproc_DisparityFilter_to_Algorithm } + + boxed_cast_descendant! { DisparityFilter, crate::ximgproc::DisparityWLSFilter, cv_ximgproc_DisparityFilter_to_DisparityWLSFilter } impl core::AlgorithmTraitConst for DisparityFilter { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -4244,21 +4250,24 @@ pub mod ximgproc { boxed_ref! { DisparityFilter, crate::ximgproc::DisparityFilterTraitConst, as_raw_DisparityFilter, crate::ximgproc::DisparityFilterTrait, as_raw_mut_DisparityFilter } - impl DisparityFilter { + /// Disparity map filter based on Weighted Least Squares filter (in form of Fast Global Smoother that + /// is a lot faster than traditional Weighted Least Squares filter implementations) and optional use of + /// left-right-consistency-based confidence to refine the results in half-occlusions and uniform areas. + pub struct DisparityWLSFilter { + ptr: *mut c_void, } - boxed_cast_descendant! { DisparityFilter, crate::ximgproc::DisparityWLSFilter, cv_ximgproc_DisparityFilter_to_DisparityWLSFilter } - - boxed_cast_base! { DisparityFilter, core::Algorithm, cv_ximgproc_DisparityFilter_to_Algorithm } + opencv_type_boxed! { DisparityWLSFilter } - impl std::fmt::Debug for DisparityFilter { + impl Drop for DisparityWLSFilter { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DisparityFilter") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_DisparityWLSFilter_delete(self.as_raw_mut_DisparityWLSFilter()) }; } } + unsafe impl Send for DisparityWLSFilter {} + /// Constant methods for [crate::ximgproc::DisparityWLSFilter] pub trait DisparityWLSFilterTraitConst: crate::ximgproc::DisparityFilterTraitConst { fn as_raw_DisparityWLSFilter(&self) -> *const c_void; @@ -4383,23 +4392,17 @@ pub mod ximgproc { } - /// Disparity map filter based on Weighted Least Squares filter (in form of Fast Global Smoother that - /// is a lot faster than traditional Weighted Least Squares filter implementations) and optional use of - /// left-right-consistency-based confidence to refine the results in half-occlusions and uniform areas. - pub struct DisparityWLSFilter { - ptr: *mut c_void, - } - - opencv_type_boxed! { DisparityWLSFilter } - - impl Drop for DisparityWLSFilter { + impl std::fmt::Debug for DisparityWLSFilter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_DisparityWLSFilter_delete(self.as_raw_mut_DisparityWLSFilter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("DisparityWLSFilter") + .finish() } } - unsafe impl Send for DisparityWLSFilter {} + boxed_cast_base! { DisparityWLSFilter, core::Algorithm, cv_ximgproc_DisparityWLSFilter_to_Algorithm } + + boxed_cast_base! { DisparityWLSFilter, crate::ximgproc::DisparityFilter, cv_ximgproc_DisparityWLSFilter_to_DisparityFilter } impl core::AlgorithmTraitConst for DisparityWLSFilter { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -4431,21 +4434,23 @@ pub mod ximgproc { boxed_ref! { DisparityWLSFilter, crate::ximgproc::DisparityWLSFilterTraitConst, as_raw_DisparityWLSFilter, crate::ximgproc::DisparityWLSFilterTrait, as_raw_mut_DisparityWLSFilter } - impl DisparityWLSFilter { + /// Sparse match interpolation algorithm based on modified locally-weighted affine + /// estimator from [Revaud2015](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Revaud2015) and Fast Global Smoother as post-processing filter. + pub struct EdgeAwareInterpolator { + ptr: *mut c_void, } - boxed_cast_base! { DisparityWLSFilter, core::Algorithm, cv_ximgproc_DisparityWLSFilter_to_Algorithm } - - boxed_cast_base! { DisparityWLSFilter, crate::ximgproc::DisparityFilter, cv_ximgproc_DisparityWLSFilter_to_DisparityFilter } + opencv_type_boxed! { EdgeAwareInterpolator } - impl std::fmt::Debug for DisparityWLSFilter { + impl Drop for EdgeAwareInterpolator { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("DisparityWLSFilter") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_EdgeAwareInterpolator_delete(self.as_raw_mut_EdgeAwareInterpolator()) }; } } + unsafe impl Send for EdgeAwareInterpolator {} + /// Constant methods for [crate::ximgproc::EdgeAwareInterpolator] pub trait EdgeAwareInterpolatorTraitConst: crate::ximgproc::SparseMatchInterpolatorTraitConst { fn as_raw_EdgeAwareInterpolator(&self) -> *const c_void; @@ -4613,22 +4618,17 @@ pub mod ximgproc { } - /// Sparse match interpolation algorithm based on modified locally-weighted affine - /// estimator from [Revaud2015](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Revaud2015) and Fast Global Smoother as post-processing filter. - pub struct EdgeAwareInterpolator { - ptr: *mut c_void, - } - - opencv_type_boxed! { EdgeAwareInterpolator } - - impl Drop for EdgeAwareInterpolator { + impl std::fmt::Debug for EdgeAwareInterpolator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_EdgeAwareInterpolator_delete(self.as_raw_mut_EdgeAwareInterpolator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("EdgeAwareInterpolator") + .finish() } } - unsafe impl Send for EdgeAwareInterpolator {} + boxed_cast_base! { EdgeAwareInterpolator, core::Algorithm, cv_ximgproc_EdgeAwareInterpolator_to_Algorithm } + + boxed_cast_base! { EdgeAwareInterpolator, crate::ximgproc::SparseMatchInterpolator, cv_ximgproc_EdgeAwareInterpolator_to_SparseMatchInterpolator } impl core::AlgorithmTraitConst for EdgeAwareInterpolator { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -4660,21 +4660,22 @@ pub mod ximgproc { boxed_ref! { EdgeAwareInterpolator, crate::ximgproc::EdgeAwareInterpolatorTraitConst, as_raw_EdgeAwareInterpolator, crate::ximgproc::EdgeAwareInterpolatorTrait, as_raw_mut_EdgeAwareInterpolator } - impl EdgeAwareInterpolator { + /// Class implementing EdgeBoxes algorithm from [ZitnickECCV14edgeBoxes](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_ZitnickECCV14edgeBoxes) : + pub struct EdgeBoxes { + ptr: *mut c_void, } - boxed_cast_base! { EdgeAwareInterpolator, core::Algorithm, cv_ximgproc_EdgeAwareInterpolator_to_Algorithm } - - boxed_cast_base! { EdgeAwareInterpolator, crate::ximgproc::SparseMatchInterpolator, cv_ximgproc_EdgeAwareInterpolator_to_SparseMatchInterpolator } + opencv_type_boxed! { EdgeBoxes } - impl std::fmt::Debug for EdgeAwareInterpolator { + impl Drop for EdgeBoxes { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("EdgeAwareInterpolator") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_EdgeBoxes_delete(self.as_raw_mut_EdgeBoxes()) }; } } + unsafe impl Send for EdgeBoxes {} + /// Constant methods for [crate::ximgproc::EdgeBoxes] pub trait EdgeBoxesTraitConst: core::AlgorithmTraitConst { fn as_raw_EdgeBoxes(&self) -> *const c_void; @@ -4971,21 +4972,15 @@ pub mod ximgproc { } - /// Class implementing EdgeBoxes algorithm from [ZitnickECCV14edgeBoxes](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_ZitnickECCV14edgeBoxes) : - pub struct EdgeBoxes { - ptr: *mut c_void, - } - - opencv_type_boxed! { EdgeBoxes } - - impl Drop for EdgeBoxes { + impl std::fmt::Debug for EdgeBoxes { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_EdgeBoxes_delete(self.as_raw_mut_EdgeBoxes()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("EdgeBoxes") + .finish() } } - unsafe impl Send for EdgeBoxes {} + boxed_cast_base! { EdgeBoxes, core::Algorithm, cv_ximgproc_EdgeBoxes_to_Algorithm } impl core::AlgorithmTraitConst for EdgeBoxes { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5007,19 +5002,22 @@ pub mod ximgproc { boxed_ref! { EdgeBoxes, crate::ximgproc::EdgeBoxesTraitConst, as_raw_EdgeBoxes, crate::ximgproc::EdgeBoxesTrait, as_raw_mut_EdgeBoxes } - impl EdgeBoxes { + /// Class implementing the ED (EdgeDrawing) [topal2012edge](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_topal2012edge), EDLines [akinlar2011edlines](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_akinlar2011edlines), EDPF [akinlar2012edpf](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_akinlar2012edpf) and EDCircles [akinlar2013edcircles](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_akinlar2013edcircles) algorithms + pub struct EdgeDrawing { + ptr: *mut c_void, } - boxed_cast_base! { EdgeBoxes, core::Algorithm, cv_ximgproc_EdgeBoxes_to_Algorithm } + opencv_type_boxed! { EdgeDrawing } - impl std::fmt::Debug for EdgeBoxes { + impl Drop for EdgeDrawing { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("EdgeBoxes") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_EdgeDrawing_delete(self.as_raw_mut_EdgeDrawing()) }; } } + unsafe impl Send for EdgeDrawing {} + /// Constant methods for [crate::ximgproc::EdgeDrawing] pub trait EdgeDrawingTraitConst: core::AlgorithmTraitConst { fn as_raw_EdgeDrawing(&self) -> *const c_void; @@ -5156,21 +5154,16 @@ pub mod ximgproc { } - /// Class implementing the ED (EdgeDrawing) [topal2012edge](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_topal2012edge), EDLines [akinlar2011edlines](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_akinlar2011edlines), EDPF [akinlar2012edpf](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_akinlar2012edpf) and EDCircles [akinlar2013edcircles](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_akinlar2013edcircles) algorithms - pub struct EdgeDrawing { - ptr: *mut c_void, - } - - opencv_type_boxed! { EdgeDrawing } - - impl Drop for EdgeDrawing { + impl std::fmt::Debug for EdgeDrawing { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_EdgeDrawing_delete(self.as_raw_mut_EdgeDrawing()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("EdgeDrawing") + .field("params", &crate::ximgproc::EdgeDrawingTraitConst::params(self)) + .finish() } } - unsafe impl Send for EdgeDrawing {} + boxed_cast_base! { EdgeDrawing, core::Algorithm, cv_ximgproc_EdgeDrawing_to_Algorithm } impl core::AlgorithmTraitConst for EdgeDrawing { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5192,20 +5185,6 @@ pub mod ximgproc { boxed_ref! { EdgeDrawing, crate::ximgproc::EdgeDrawingTraitConst, as_raw_EdgeDrawing, crate::ximgproc::EdgeDrawingTrait, as_raw_mut_EdgeDrawing } - impl EdgeDrawing { - } - - boxed_cast_base! { EdgeDrawing, core::Algorithm, cv_ximgproc_EdgeDrawing_to_Algorithm } - - impl std::fmt::Debug for EdgeDrawing { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("EdgeDrawing") - .field("params", &crate::ximgproc::EdgeDrawingTraitConst::params(self)) - .finish() - } - } - #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] pub struct EdgeDrawing_Params { @@ -5273,6 +5252,24 @@ pub mod ximgproc { } + /// Interface for implementations of Fast Bilateral Solver. + /// + /// For more details about this solver see [BarronPoole2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_BarronPoole2016) . + pub struct FastBilateralSolverFilter { + ptr: *mut c_void, + } + + opencv_type_boxed! { FastBilateralSolverFilter } + + impl Drop for FastBilateralSolverFilter { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_FastBilateralSolverFilter_delete(self.as_raw_mut_FastBilateralSolverFilter()) }; + } + } + + unsafe impl Send for FastBilateralSolverFilter {} + /// Constant methods for [crate::ximgproc::FastBilateralSolverFilter] pub trait FastBilateralSolverFilterTraitConst: core::AlgorithmTraitConst { fn as_raw_FastBilateralSolverFilter(&self) -> *const c_void; @@ -5308,23 +5305,15 @@ pub mod ximgproc { } - /// Interface for implementations of Fast Bilateral Solver. - /// - /// For more details about this solver see [BarronPoole2016](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_BarronPoole2016) . - pub struct FastBilateralSolverFilter { - ptr: *mut c_void, - } - - opencv_type_boxed! { FastBilateralSolverFilter } - - impl Drop for FastBilateralSolverFilter { + impl std::fmt::Debug for FastBilateralSolverFilter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_FastBilateralSolverFilter_delete(self.as_raw_mut_FastBilateralSolverFilter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FastBilateralSolverFilter") + .finish() } } - unsafe impl Send for FastBilateralSolverFilter {} + boxed_cast_base! { FastBilateralSolverFilter, core::Algorithm, cv_ximgproc_FastBilateralSolverFilter_to_Algorithm } impl core::AlgorithmTraitConst for FastBilateralSolverFilter { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5346,19 +5335,24 @@ pub mod ximgproc { boxed_ref! { FastBilateralSolverFilter, crate::ximgproc::FastBilateralSolverFilterTraitConst, as_raw_FastBilateralSolverFilter, crate::ximgproc::FastBilateralSolverFilterTrait, as_raw_mut_FastBilateralSolverFilter } - impl FastBilateralSolverFilter { + /// Interface for implementations of Fast Global Smoother filter. + /// + /// For more details about this filter see [Min2014](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Min2014) and [Farbman2008](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Farbman2008) . + pub struct FastGlobalSmootherFilter { + ptr: *mut c_void, } - boxed_cast_base! { FastBilateralSolverFilter, core::Algorithm, cv_ximgproc_FastBilateralSolverFilter_to_Algorithm } + opencv_type_boxed! { FastGlobalSmootherFilter } - impl std::fmt::Debug for FastBilateralSolverFilter { + impl Drop for FastGlobalSmootherFilter { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FastBilateralSolverFilter") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_FastGlobalSmootherFilter_delete(self.as_raw_mut_FastGlobalSmootherFilter()) }; } } + unsafe impl Send for FastGlobalSmootherFilter {} + /// Constant methods for [crate::ximgproc::FastGlobalSmootherFilter] pub trait FastGlobalSmootherFilterTraitConst: core::AlgorithmTraitConst { fn as_raw_FastGlobalSmootherFilter(&self) -> *const c_void; @@ -5388,23 +5382,15 @@ pub mod ximgproc { } - /// Interface for implementations of Fast Global Smoother filter. - /// - /// For more details about this filter see [Min2014](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Min2014) and [Farbman2008](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Farbman2008) . - pub struct FastGlobalSmootherFilter { - ptr: *mut c_void, - } - - opencv_type_boxed! { FastGlobalSmootherFilter } - - impl Drop for FastGlobalSmootherFilter { + impl std::fmt::Debug for FastGlobalSmootherFilter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_FastGlobalSmootherFilter_delete(self.as_raw_mut_FastGlobalSmootherFilter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FastGlobalSmootherFilter") + .finish() } } - unsafe impl Send for FastGlobalSmootherFilter {} + boxed_cast_base! { FastGlobalSmootherFilter, core::Algorithm, cv_ximgproc_FastGlobalSmootherFilter_to_Algorithm } impl core::AlgorithmTraitConst for FastGlobalSmootherFilter { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5426,19 +5412,22 @@ pub mod ximgproc { boxed_ref! { FastGlobalSmootherFilter, crate::ximgproc::FastGlobalSmootherFilterTraitConst, as_raw_FastGlobalSmootherFilter, crate::ximgproc::FastGlobalSmootherFilterTrait, as_raw_mut_FastGlobalSmootherFilter } - impl FastGlobalSmootherFilter { + /// @include samples/fld_lines.cpp + pub struct FastLineDetector { + ptr: *mut c_void, } - boxed_cast_base! { FastGlobalSmootherFilter, core::Algorithm, cv_ximgproc_FastGlobalSmootherFilter_to_Algorithm } + opencv_type_boxed! { FastLineDetector } - impl std::fmt::Debug for FastGlobalSmootherFilter { + impl Drop for FastLineDetector { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FastGlobalSmootherFilter") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_FastLineDetector_delete(self.as_raw_mut_FastLineDetector()) }; } } + unsafe impl Send for FastLineDetector {} + /// Constant methods for [crate::ximgproc::FastLineDetector] pub trait FastLineDetectorTraitConst: core::AlgorithmTraitConst { fn as_raw_FastLineDetector(&self) -> *const c_void; @@ -5528,21 +5517,15 @@ pub mod ximgproc { } - /// @include samples/fld_lines.cpp - pub struct FastLineDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { FastLineDetector } - - impl Drop for FastLineDetector { + impl std::fmt::Debug for FastLineDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_FastLineDetector_delete(self.as_raw_mut_FastLineDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("FastLineDetector") + .finish() } } - unsafe impl Send for FastLineDetector {} + boxed_cast_base! { FastLineDetector, core::Algorithm, cv_ximgproc_FastLineDetector_to_Algorithm } impl core::AlgorithmTraitConst for FastLineDetector { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5564,19 +5547,24 @@ pub mod ximgproc { boxed_ref! { FastLineDetector, crate::ximgproc::FastLineDetectorTraitConst, as_raw_FastLineDetector, crate::ximgproc::FastLineDetectorTrait, as_raw_mut_FastLineDetector } - impl FastLineDetector { + /// Interface for realizations of (Fast) Guided Filter. + /// + /// For more details about this filter see [Kaiming10](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Kaiming10) [Kaiming15](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Kaiming15) . + pub struct GuidedFilter { + ptr: *mut c_void, } - boxed_cast_base! { FastLineDetector, core::Algorithm, cv_ximgproc_FastLineDetector_to_Algorithm } + opencv_type_boxed! { GuidedFilter } - impl std::fmt::Debug for FastLineDetector { + impl Drop for GuidedFilter { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("FastLineDetector") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_GuidedFilter_delete(self.as_raw_mut_GuidedFilter()) }; } } + unsafe impl Send for GuidedFilter {} + /// Constant methods for [crate::ximgproc::GuidedFilter] pub trait GuidedFilterTraitConst: core::AlgorithmTraitConst { fn as_raw_GuidedFilter(&self) -> *const c_void; @@ -5636,23 +5624,15 @@ pub mod ximgproc { } - /// Interface for realizations of (Fast) Guided Filter. - /// - /// For more details about this filter see [Kaiming10](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Kaiming10) [Kaiming15](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Kaiming15) . - pub struct GuidedFilter { - ptr: *mut c_void, - } - - opencv_type_boxed! { GuidedFilter } - - impl Drop for GuidedFilter { + impl std::fmt::Debug for GuidedFilter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_GuidedFilter_delete(self.as_raw_mut_GuidedFilter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GuidedFilter") + .finish() } } - unsafe impl Send for GuidedFilter {} + boxed_cast_base! { GuidedFilter, core::Algorithm, cv_ximgproc_GuidedFilter_to_Algorithm } impl core::AlgorithmTraitConst for GuidedFilter { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5674,19 +5654,23 @@ pub mod ximgproc { boxed_ref! { GuidedFilter, crate::ximgproc::GuidedFilterTraitConst, as_raw_GuidedFilter, crate::ximgproc::GuidedFilterTrait, as_raw_mut_GuidedFilter } - impl GuidedFilter { + /// ! + /// Helper class for training part of [P. Dollar and C. L. Zitnick. Structured Forests for Fast Edge Detection, 2013]. + pub struct RFFeatureGetter { + ptr: *mut c_void, } - boxed_cast_base! { GuidedFilter, core::Algorithm, cv_ximgproc_GuidedFilter_to_Algorithm } + opencv_type_boxed! { RFFeatureGetter } - impl std::fmt::Debug for GuidedFilter { + impl Drop for RFFeatureGetter { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GuidedFilter") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_RFFeatureGetter_delete(self.as_raw_mut_RFFeatureGetter()) }; } } + unsafe impl Send for RFFeatureGetter {} + /// Constant methods for [crate::ximgproc::RFFeatureGetter] pub trait RFFeatureGetterTraitConst: core::AlgorithmTraitConst { fn as_raw_RFFeatureGetter(&self) -> *const c_void; @@ -5721,22 +5705,15 @@ pub mod ximgproc { } - /// ! - /// Helper class for training part of [P. Dollar and C. L. Zitnick. Structured Forests for Fast Edge Detection, 2013]. - pub struct RFFeatureGetter { - ptr: *mut c_void, - } - - opencv_type_boxed! { RFFeatureGetter } - - impl Drop for RFFeatureGetter { + impl std::fmt::Debug for RFFeatureGetter { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_RFFeatureGetter_delete(self.as_raw_mut_RFFeatureGetter()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RFFeatureGetter") + .finish() } } - unsafe impl Send for RFFeatureGetter {} + boxed_cast_base! { RFFeatureGetter, core::Algorithm, cv_ximgproc_RFFeatureGetter_to_Algorithm } impl core::AlgorithmTraitConst for RFFeatureGetter { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -5758,19 +5735,26 @@ pub mod ximgproc { boxed_ref! { RFFeatureGetter, crate::ximgproc::RFFeatureGetterTraitConst, as_raw_RFFeatureGetter, crate::ximgproc::RFFeatureGetterTrait, as_raw_mut_RFFeatureGetter } - impl RFFeatureGetter { + /// Sparse match interpolation algorithm based on modified piecewise locally-weighted affine + /// estimator called Robust Interpolation method of Correspondences or RIC from [Hu2017](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Hu2017) and Variational + /// and Fast Global Smoother as post-processing filter. The RICInterpolator is a extension of the EdgeAwareInterpolator. + /// Main concept of this extension is an piece-wise affine model based on over-segmentation via SLIC superpixel estimation. + /// The method contains an efficient propagation mechanism to estimate among the pieces-wise models. + pub struct RICInterpolator { + ptr: *mut c_void, } - boxed_cast_base! { RFFeatureGetter, core::Algorithm, cv_ximgproc_RFFeatureGetter_to_Algorithm } + opencv_type_boxed! { RICInterpolator } - impl std::fmt::Debug for RFFeatureGetter { + impl Drop for RICInterpolator { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RFFeatureGetter") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_RICInterpolator_delete(self.as_raw_mut_RICInterpolator()) }; } } + unsafe impl Send for RICInterpolator {} + /// Constant methods for [crate::ximgproc::RICInterpolator] pub trait RICInterpolatorTraitConst: crate::ximgproc::SparseMatchInterpolatorTraitConst { fn as_raw_RICInterpolator(&self) -> *const c_void; @@ -6344,25 +6328,17 @@ pub mod ximgproc { } - /// Sparse match interpolation algorithm based on modified piecewise locally-weighted affine - /// estimator called Robust Interpolation method of Correspondences or RIC from [Hu2017](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Hu2017) and Variational - /// and Fast Global Smoother as post-processing filter. The RICInterpolator is a extension of the EdgeAwareInterpolator. - /// Main concept of this extension is an piece-wise affine model based on over-segmentation via SLIC superpixel estimation. - /// The method contains an efficient propagation mechanism to estimate among the pieces-wise models. - pub struct RICInterpolator { - ptr: *mut c_void, - } - - opencv_type_boxed! { RICInterpolator } - - impl Drop for RICInterpolator { + impl std::fmt::Debug for RICInterpolator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_RICInterpolator_delete(self.as_raw_mut_RICInterpolator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RICInterpolator") + .finish() } } - unsafe impl Send for RICInterpolator {} + boxed_cast_base! { RICInterpolator, core::Algorithm, cv_ximgproc_RICInterpolator_to_Algorithm } + + boxed_cast_base! { RICInterpolator, crate::ximgproc::SparseMatchInterpolator, cv_ximgproc_RICInterpolator_to_SparseMatchInterpolator } impl core::AlgorithmTraitConst for RICInterpolator { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -6394,48 +6370,6 @@ pub mod ximgproc { boxed_ref! { RICInterpolator, crate::ximgproc::RICInterpolatorTraitConst, as_raw_RICInterpolator, crate::ximgproc::RICInterpolatorTrait, as_raw_mut_RICInterpolator } - impl RICInterpolator { - } - - boxed_cast_base! { RICInterpolator, core::Algorithm, cv_ximgproc_RICInterpolator_to_Algorithm } - - boxed_cast_base! { RICInterpolator, crate::ximgproc::SparseMatchInterpolator, cv_ximgproc_RICInterpolator_to_SparseMatchInterpolator } - - impl std::fmt::Debug for RICInterpolator { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RICInterpolator") - .finish() - } - } - - /// Constant methods for [crate::ximgproc::RidgeDetectionFilter] - pub trait RidgeDetectionFilterTraitConst: core::AlgorithmTraitConst { - fn as_raw_RidgeDetectionFilter(&self) -> *const c_void; - - } - - /// Mutable methods for [crate::ximgproc::RidgeDetectionFilter] - pub trait RidgeDetectionFilterTrait: core::AlgorithmTrait + crate::ximgproc::RidgeDetectionFilterTraitConst { - fn as_raw_mut_RidgeDetectionFilter(&mut self) -> *mut c_void; - - /// Apply Ridge detection filter on input image. - /// ## Parameters - /// * _img: InputArray as supported by Sobel. img can be 1-Channel or 3-Channels. - /// * out: OutputAray of structure as RidgeDetectionFilter::ddepth. Output image with ridges. - #[inline] - fn get_ridge_filtered_image(&mut self, _img: &impl ToInputArray, out: &mut impl ToOutputArray) -> Result<()> { - input_array_arg!(_img); - output_array_arg!(out); - return_send!(via ocvrs_return); - unsafe { sys::cv_ximgproc_RidgeDetectionFilter_getRidgeFilteredImage_const__InputArrayR_const__OutputArrayR(self.as_raw_mut_RidgeDetectionFilter(), _img.as_raw__InputArray(), out.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) - } - - } - /// Applies Ridge Detection Filter to an input image. /// Implements Ridge detection similar to the one in [Mathematica](http://reference.wolfram.com/language/ref/RidgeFilter.html) /// using the eigen values from the Hessian Matrix of the input image using Sobel Derivatives. @@ -6455,26 +6389,6 @@ pub mod ximgproc { unsafe impl Send for RidgeDetectionFilter {} - impl core::AlgorithmTraitConst for RidgeDetectionFilter { - #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } - } - - impl core::AlgorithmTrait for RidgeDetectionFilter { - #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { RidgeDetectionFilter, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } - - impl crate::ximgproc::RidgeDetectionFilterTraitConst for RidgeDetectionFilter { - #[inline] fn as_raw_RidgeDetectionFilter(&self) -> *const c_void { self.as_raw() } - } - - impl crate::ximgproc::RidgeDetectionFilterTrait for RidgeDetectionFilter { - #[inline] fn as_raw_mut_RidgeDetectionFilter(&mut self) -> *mut c_void { self.as_raw_mut() } - } - - boxed_ref! { RidgeDetectionFilter, crate::ximgproc::RidgeDetectionFilterTraitConst, as_raw_RidgeDetectionFilter, crate::ximgproc::RidgeDetectionFilterTrait, as_raw_mut_RidgeDetectionFilter } - impl RidgeDetectionFilter { /// Create pointer to the Ridge detection filter. /// ## Parameters @@ -6543,68 +6457,138 @@ pub mod ximgproc { } - boxed_cast_base! { RidgeDetectionFilter, core::Algorithm, cv_ximgproc_RidgeDetectionFilter_to_Algorithm } - - impl std::fmt::Debug for RidgeDetectionFilter { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("RidgeDetectionFilter") - .finish() - } - } - - /// Constant methods for [crate::ximgproc::ScanSegment] - pub trait ScanSegmentTraitConst: core::AlgorithmTraitConst { - fn as_raw_ScanSegment(&self) -> *const c_void; + /// Constant methods for [crate::ximgproc::RidgeDetectionFilter] + pub trait RidgeDetectionFilterTraitConst: core::AlgorithmTraitConst { + fn as_raw_RidgeDetectionFilter(&self) -> *const c_void; } - /// Mutable methods for [crate::ximgproc::ScanSegment] - pub trait ScanSegmentTrait: core::AlgorithmTrait + crate::ximgproc::ScanSegmentTraitConst { - fn as_raw_mut_ScanSegment(&mut self) -> *mut c_void; + /// Mutable methods for [crate::ximgproc::RidgeDetectionFilter] + pub trait RidgeDetectionFilterTrait: core::AlgorithmTrait + crate::ximgproc::RidgeDetectionFilterTraitConst { + fn as_raw_mut_RidgeDetectionFilter(&mut self) -> *mut c_void; - /// Returns the actual superpixel segmentation from the last image processed using iterate. - /// - /// Returns zero if no image has been processed. + /// Apply Ridge detection filter on input image. + /// ## Parameters + /// * _img: InputArray as supported by Sobel. img can be 1-Channel or 3-Channels. + /// * out: OutputAray of structure as RidgeDetectionFilter::ddepth. Output image with ridges. #[inline] - fn get_number_of_superpixels(&mut self) -> Result { + fn get_ridge_filtered_image(&mut self, _img: &impl ToInputArray, out: &mut impl ToOutputArray) -> Result<()> { + input_array_arg!(_img); + output_array_arg!(out); return_send!(via ocvrs_return); - unsafe { sys::cv_ximgproc_ScanSegment_getNumberOfSuperpixels(self.as_raw_mut_ScanSegment(), ocvrs_return.as_mut_ptr()) }; + unsafe { sys::cv_ximgproc_RidgeDetectionFilter_getRidgeFilteredImage_const__InputArrayR_const__OutputArrayR(self.as_raw_mut_RidgeDetectionFilter(), _img.as_raw__InputArray(), out.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; Ok(ret) } - /// Calculates the superpixel segmentation on a given image with the initialized - /// parameters in the ScanSegment object. - /// - /// This function can be called again for other images without the need of initializing the algorithm with createScanSegment(). - /// This save the computational cost of allocating memory for all the structures of the algorithm. - /// - /// ## Parameters - /// * img: Input image. Supported format: CV_8UC3. Image size must match with the initialized - /// image size with the function createScanSegment(). It MUST be in Lab color space. + } + + impl std::fmt::Debug for RidgeDetectionFilter { #[inline] - fn iterate(&mut self, img: &impl ToInputArray) -> Result<()> { - input_array_arg!(img); - return_send!(via ocvrs_return); - unsafe { sys::cv_ximgproc_ScanSegment_iterate_const__InputArrayR(self.as_raw_mut_ScanSegment(), img.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - Ok(ret) + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("RidgeDetectionFilter") + .finish() } + } - /// Returns the segmentation labeling of the image. - /// - /// Each label represents a superpixel, and each pixel is assigned to one superpixel label. - /// - /// ## Parameters - /// * labels_out: Return: A CV_32UC1 integer array containing the labels of the superpixel - /// segmentation. The labels are in the range [0, getNumberOfSuperpixels()]. - #[inline] - fn get_labels(&mut self, labels_out: &mut impl ToOutputArray) -> Result<()> { - output_array_arg!(labels_out); - return_send!(via ocvrs_return); + boxed_cast_base! { RidgeDetectionFilter, core::Algorithm, cv_ximgproc_RidgeDetectionFilter_to_Algorithm } + + impl core::AlgorithmTraitConst for RidgeDetectionFilter { + #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } + } + + impl core::AlgorithmTrait for RidgeDetectionFilter { + #[inline] fn as_raw_mut_Algorithm(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { RidgeDetectionFilter, core::AlgorithmTraitConst, as_raw_Algorithm, core::AlgorithmTrait, as_raw_mut_Algorithm } + + impl crate::ximgproc::RidgeDetectionFilterTraitConst for RidgeDetectionFilter { + #[inline] fn as_raw_RidgeDetectionFilter(&self) -> *const c_void { self.as_raw() } + } + + impl crate::ximgproc::RidgeDetectionFilterTrait for RidgeDetectionFilter { + #[inline] fn as_raw_mut_RidgeDetectionFilter(&mut self) -> *mut c_void { self.as_raw_mut() } + } + + boxed_ref! { RidgeDetectionFilter, crate::ximgproc::RidgeDetectionFilterTraitConst, as_raw_RidgeDetectionFilter, crate::ximgproc::RidgeDetectionFilterTrait, as_raw_mut_RidgeDetectionFilter } + + /// Class implementing the F-DBSCAN (Accelerated superpixel image segmentation with a parallelized DBSCAN algorithm) superpixels + /// algorithm by Loke SC, et al. [loke2021accelerated](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_loke2021accelerated) for original paper. + /// + /// The algorithm uses a parallelised DBSCAN cluster search that is resistant to noise, competitive in segmentation quality, and faster than + /// existing superpixel segmentation methods. When tested on the Berkeley Segmentation Dataset, the average processing speed is 175 frames/s + /// with a Boundary Recall of 0.797 and an Achievable Segmentation Accuracy of 0.944. The computational complexity is quadratic O(n2) and + /// more suited to smaller images, but can still process a 2MP colour image faster than the SEEDS algorithm in OpenCV. The output is deterministic + /// when the number of processing threads is fixed, and requires the source image to be in Lab colour format. + pub struct ScanSegment { + ptr: *mut c_void, + } + + opencv_type_boxed! { ScanSegment } + + impl Drop for ScanSegment { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_ScanSegment_delete(self.as_raw_mut_ScanSegment()) }; + } + } + + unsafe impl Send for ScanSegment {} + + /// Constant methods for [crate::ximgproc::ScanSegment] + pub trait ScanSegmentTraitConst: core::AlgorithmTraitConst { + fn as_raw_ScanSegment(&self) -> *const c_void; + + } + + /// Mutable methods for [crate::ximgproc::ScanSegment] + pub trait ScanSegmentTrait: core::AlgorithmTrait + crate::ximgproc::ScanSegmentTraitConst { + fn as_raw_mut_ScanSegment(&mut self) -> *mut c_void; + + /// Returns the actual superpixel segmentation from the last image processed using iterate. + /// + /// Returns zero if no image has been processed. + #[inline] + fn get_number_of_superpixels(&mut self) -> Result { + return_send!(via ocvrs_return); + unsafe { sys::cv_ximgproc_ScanSegment_getNumberOfSuperpixels(self.as_raw_mut_ScanSegment(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Calculates the superpixel segmentation on a given image with the initialized + /// parameters in the ScanSegment object. + /// + /// This function can be called again for other images without the need of initializing the algorithm with createScanSegment(). + /// This save the computational cost of allocating memory for all the structures of the algorithm. + /// + /// ## Parameters + /// * img: Input image. Supported format: CV_8UC3. Image size must match with the initialized + /// image size with the function createScanSegment(). It MUST be in Lab color space. + #[inline] + fn iterate(&mut self, img: &impl ToInputArray) -> Result<()> { + input_array_arg!(img); + return_send!(via ocvrs_return); + unsafe { sys::cv_ximgproc_ScanSegment_iterate_const__InputArrayR(self.as_raw_mut_ScanSegment(), img.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + Ok(ret) + } + + /// Returns the segmentation labeling of the image. + /// + /// Each label represents a superpixel, and each pixel is assigned to one superpixel label. + /// + /// ## Parameters + /// * labels_out: Return: A CV_32UC1 integer array containing the labels of the superpixel + /// segmentation. The labels are in the range [0, getNumberOfSuperpixels()]. + #[inline] + fn get_labels(&mut self, labels_out: &mut impl ToOutputArray) -> Result<()> { + output_array_arg!(labels_out); + return_send!(via ocvrs_return); unsafe { sys::cv_ximgproc_ScanSegment_getLabels_const__OutputArrayR(self.as_raw_mut_ScanSegment(), labels_out.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ret.into_result()?; @@ -6654,28 +6638,15 @@ pub mod ximgproc { } - /// Class implementing the F-DBSCAN (Accelerated superpixel image segmentation with a parallelized DBSCAN algorithm) superpixels - /// algorithm by Loke SC, et al. [loke2021accelerated](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_loke2021accelerated) for original paper. - /// - /// The algorithm uses a parallelised DBSCAN cluster search that is resistant to noise, competitive in segmentation quality, and faster than - /// existing superpixel segmentation methods. When tested on the Berkeley Segmentation Dataset, the average processing speed is 175 frames/s - /// with a Boundary Recall of 0.797 and an Achievable Segmentation Accuracy of 0.944. The computational complexity is quadratic O(n2) and - /// more suited to smaller images, but can still process a 2MP colour image faster than the SEEDS algorithm in OpenCV. The output is deterministic - /// when the number of processing threads is fixed, and requires the source image to be in Lab colour format. - pub struct ScanSegment { - ptr: *mut c_void, - } - - opencv_type_boxed! { ScanSegment } - - impl Drop for ScanSegment { + impl std::fmt::Debug for ScanSegment { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_ScanSegment_delete(self.as_raw_mut_ScanSegment()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ScanSegment") + .finish() } } - unsafe impl Send for ScanSegment {} + boxed_cast_base! { ScanSegment, core::Algorithm, cv_ximgproc_ScanSegment_to_Algorithm } impl core::AlgorithmTraitConst for ScanSegment { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -6697,19 +6668,23 @@ pub mod ximgproc { boxed_ref! { ScanSegment, crate::ximgproc::ScanSegmentTraitConst, as_raw_ScanSegment, crate::ximgproc::ScanSegmentTrait, as_raw_mut_ScanSegment } - impl ScanSegment { + /// Main interface for all filters, that take sparse matches as an + /// input and produce a dense per-pixel matching (optical flow) as an output. + pub struct SparseMatchInterpolator { + ptr: *mut c_void, } - boxed_cast_base! { ScanSegment, core::Algorithm, cv_ximgproc_ScanSegment_to_Algorithm } + opencv_type_boxed! { SparseMatchInterpolator } - impl std::fmt::Debug for ScanSegment { + impl Drop for SparseMatchInterpolator { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ScanSegment") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_SparseMatchInterpolator_delete(self.as_raw_mut_SparseMatchInterpolator()) }; } } + unsafe impl Send for SparseMatchInterpolator {} + /// Constant methods for [crate::ximgproc::SparseMatchInterpolator] pub trait SparseMatchInterpolatorTraitConst: core::AlgorithmTraitConst { fn as_raw_SparseMatchInterpolator(&self) -> *const c_void; @@ -6750,22 +6725,19 @@ pub mod ximgproc { } - /// Main interface for all filters, that take sparse matches as an - /// input and produce a dense per-pixel matching (optical flow) as an output. - pub struct SparseMatchInterpolator { - ptr: *mut c_void, - } - - opencv_type_boxed! { SparseMatchInterpolator } - - impl Drop for SparseMatchInterpolator { + impl std::fmt::Debug for SparseMatchInterpolator { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_SparseMatchInterpolator_delete(self.as_raw_mut_SparseMatchInterpolator()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SparseMatchInterpolator") + .finish() } } - unsafe impl Send for SparseMatchInterpolator {} + boxed_cast_base! { SparseMatchInterpolator, core::Algorithm, cv_ximgproc_SparseMatchInterpolator_to_Algorithm } + + boxed_cast_descendant! { SparseMatchInterpolator, crate::ximgproc::EdgeAwareInterpolator, cv_ximgproc_SparseMatchInterpolator_to_EdgeAwareInterpolator } + + boxed_cast_descendant! { SparseMatchInterpolator, crate::ximgproc::RICInterpolator, cv_ximgproc_SparseMatchInterpolator_to_RICInterpolator } impl core::AlgorithmTraitConst for SparseMatchInterpolator { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -6787,23 +6759,22 @@ pub mod ximgproc { boxed_ref! { SparseMatchInterpolator, crate::ximgproc::SparseMatchInterpolatorTraitConst, as_raw_SparseMatchInterpolator, crate::ximgproc::SparseMatchInterpolatorTrait, as_raw_mut_SparseMatchInterpolator } - impl SparseMatchInterpolator { + /// Class implementing edge detection algorithm from [Dollar2013](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Dollar2013) : + pub struct StructuredEdgeDetection { + ptr: *mut c_void, } - boxed_cast_descendant! { SparseMatchInterpolator, crate::ximgproc::EdgeAwareInterpolator, cv_ximgproc_SparseMatchInterpolator_to_EdgeAwareInterpolator } - - boxed_cast_descendant! { SparseMatchInterpolator, crate::ximgproc::RICInterpolator, cv_ximgproc_SparseMatchInterpolator_to_RICInterpolator } - - boxed_cast_base! { SparseMatchInterpolator, core::Algorithm, cv_ximgproc_SparseMatchInterpolator_to_Algorithm } + opencv_type_boxed! { StructuredEdgeDetection } - impl std::fmt::Debug for SparseMatchInterpolator { + impl Drop for StructuredEdgeDetection { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SparseMatchInterpolator") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_StructuredEdgeDetection_delete(self.as_raw_mut_StructuredEdgeDetection()) }; } } + unsafe impl Send for StructuredEdgeDetection {} + /// Constant methods for [crate::ximgproc::StructuredEdgeDetection] pub trait StructuredEdgeDetectionTraitConst: core::AlgorithmTraitConst { fn as_raw_StructuredEdgeDetection(&self) -> *const c_void; @@ -6909,21 +6880,15 @@ pub mod ximgproc { } - /// Class implementing edge detection algorithm from [Dollar2013](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Dollar2013) : - pub struct StructuredEdgeDetection { - ptr: *mut c_void, - } - - opencv_type_boxed! { StructuredEdgeDetection } - - impl Drop for StructuredEdgeDetection { + impl std::fmt::Debug for StructuredEdgeDetection { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_StructuredEdgeDetection_delete(self.as_raw_mut_StructuredEdgeDetection()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("StructuredEdgeDetection") + .finish() } } - unsafe impl Send for StructuredEdgeDetection {} + boxed_cast_base! { StructuredEdgeDetection, core::Algorithm, cv_ximgproc_StructuredEdgeDetection_to_Algorithm } impl core::AlgorithmTraitConst for StructuredEdgeDetection { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -6945,19 +6910,29 @@ pub mod ximgproc { boxed_ref! { StructuredEdgeDetection, crate::ximgproc::StructuredEdgeDetectionTraitConst, as_raw_StructuredEdgeDetection, crate::ximgproc::StructuredEdgeDetectionTrait, as_raw_mut_StructuredEdgeDetection } - impl StructuredEdgeDetection { + /// Class implementing the LSC (Linear Spectral Clustering) superpixels + /// algorithm described in [LiCVPR2015LSC](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_LiCVPR2015LSC). + /// + /// LSC (Linear Spectral Clustering) produces compact and uniform superpixels with low + /// computational costs. Basically, a normalized cuts formulation of the superpixel + /// segmentation is adopted based on a similarity metric that measures the color + /// similarity and space proximity between image pixels. LSC is of linear computational + /// complexity and high memory efficiency and is able to preserve global properties of images + pub struct SuperpixelLSC { + ptr: *mut c_void, } - boxed_cast_base! { StructuredEdgeDetection, core::Algorithm, cv_ximgproc_StructuredEdgeDetection_to_Algorithm } + opencv_type_boxed! { SuperpixelLSC } - impl std::fmt::Debug for StructuredEdgeDetection { + impl Drop for SuperpixelLSC { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("StructuredEdgeDetection") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_SuperpixelLSC_delete(self.as_raw_mut_SuperpixelLSC()) }; } } + unsafe impl Send for SuperpixelLSC {} + /// Constant methods for [crate::ximgproc::SuperpixelLSC] pub trait SuperpixelLSCTraitConst: core::AlgorithmTraitConst { fn as_raw_SuperpixelLSC(&self) -> *const c_void; @@ -7142,28 +7117,15 @@ pub mod ximgproc { } - /// Class implementing the LSC (Linear Spectral Clustering) superpixels - /// algorithm described in [LiCVPR2015LSC](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_LiCVPR2015LSC). - /// - /// LSC (Linear Spectral Clustering) produces compact and uniform superpixels with low - /// computational costs. Basically, a normalized cuts formulation of the superpixel - /// segmentation is adopted based on a similarity metric that measures the color - /// similarity and space proximity between image pixels. LSC is of linear computational - /// complexity and high memory efficiency and is able to preserve global properties of images - pub struct SuperpixelLSC { - ptr: *mut c_void, - } - - opencv_type_boxed! { SuperpixelLSC } - - impl Drop for SuperpixelLSC { + impl std::fmt::Debug for SuperpixelLSC { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_SuperpixelLSC_delete(self.as_raw_mut_SuperpixelLSC()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SuperpixelLSC") + .finish() } } - unsafe impl Send for SuperpixelLSC {} + boxed_cast_base! { SuperpixelLSC, core::Algorithm, cv_ximgproc_SuperpixelLSC_to_Algorithm } impl core::AlgorithmTraitConst for SuperpixelLSC { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -7185,19 +7147,30 @@ pub mod ximgproc { boxed_ref! { SuperpixelLSC, crate::ximgproc::SuperpixelLSCTraitConst, as_raw_SuperpixelLSC, crate::ximgproc::SuperpixelLSCTrait, as_raw_mut_SuperpixelLSC } - impl SuperpixelLSC { + /// Class implementing the SEEDS (Superpixels Extracted via Energy-Driven Sampling) superpixels + /// algorithm described in [VBRV14](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_VBRV14) . + /// + /// The algorithm uses an efficient hill-climbing algorithm to optimize the superpixels' energy + /// function that is based on color histograms and a boundary term, which is optional. The energy + /// function encourages superpixels to be of the same color, and if the boundary term is activated, the + /// superpixels have smooth boundaries and are of similar shape. In practice it starts from a regular + /// grid of superpixels and moves the pixels or blocks of pixels at the boundaries to refine the + /// solution. The algorithm runs in real-time using a single CPU. + pub struct SuperpixelSEEDS { + ptr: *mut c_void, } - boxed_cast_base! { SuperpixelLSC, core::Algorithm, cv_ximgproc_SuperpixelLSC_to_Algorithm } + opencv_type_boxed! { SuperpixelSEEDS } - impl std::fmt::Debug for SuperpixelLSC { + impl Drop for SuperpixelSEEDS { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SuperpixelLSC") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_SuperpixelSEEDS_delete(self.as_raw_mut_SuperpixelSEEDS()) }; } } + unsafe impl Send for SuperpixelSEEDS {} + /// Constant methods for [crate::ximgproc::SuperpixelSEEDS] pub trait SuperpixelSEEDSTraitConst: core::AlgorithmTraitConst { fn as_raw_SuperpixelSEEDS(&self) -> *const c_void; @@ -7395,29 +7368,15 @@ pub mod ximgproc { } - /// Class implementing the SEEDS (Superpixels Extracted via Energy-Driven Sampling) superpixels - /// algorithm described in [VBRV14](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_VBRV14) . - /// - /// The algorithm uses an efficient hill-climbing algorithm to optimize the superpixels' energy - /// function that is based on color histograms and a boundary term, which is optional. The energy - /// function encourages superpixels to be of the same color, and if the boundary term is activated, the - /// superpixels have smooth boundaries and are of similar shape. In practice it starts from a regular - /// grid of superpixels and moves the pixels or blocks of pixels at the boundaries to refine the - /// solution. The algorithm runs in real-time using a single CPU. - pub struct SuperpixelSEEDS { - ptr: *mut c_void, - } - - opencv_type_boxed! { SuperpixelSEEDS } - - impl Drop for SuperpixelSEEDS { + impl std::fmt::Debug for SuperpixelSEEDS { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_SuperpixelSEEDS_delete(self.as_raw_mut_SuperpixelSEEDS()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SuperpixelSEEDS") + .finish() } } - unsafe impl Send for SuperpixelSEEDS {} + boxed_cast_base! { SuperpixelSEEDS, core::Algorithm, cv_ximgproc_SuperpixelSEEDS_to_Algorithm } impl core::AlgorithmTraitConst for SuperpixelSEEDS { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -7439,19 +7398,31 @@ pub mod ximgproc { boxed_ref! { SuperpixelSEEDS, crate::ximgproc::SuperpixelSEEDSTraitConst, as_raw_SuperpixelSEEDS, crate::ximgproc::SuperpixelSEEDSTrait, as_raw_mut_SuperpixelSEEDS } - impl SuperpixelSEEDS { + /// Class implementing the SLIC (Simple Linear Iterative Clustering) superpixels + /// algorithm described in [Achanta2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Achanta2012). + /// + /// SLIC (Simple Linear Iterative Clustering) clusters pixels using pixel channels and image plane space + /// to efficiently generate compact, nearly uniform superpixels. The simplicity of approach makes it + /// extremely easy to use a lone parameter specifies the number of superpixels and the efficiency of + /// the algorithm makes it very practical. + /// Several optimizations are available for SLIC class: + /// SLICO stands for "Zero parameter SLIC" and it is an optimization of baseline SLIC described in [Achanta2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Achanta2012). + /// MSLIC stands for "Manifold SLIC" and it is an optimization of baseline SLIC described in [Liu_2017_IEEE](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Liu_2017_IEEE). + pub struct SuperpixelSLIC { + ptr: *mut c_void, } - boxed_cast_base! { SuperpixelSEEDS, core::Algorithm, cv_ximgproc_SuperpixelSEEDS_to_Algorithm } + opencv_type_boxed! { SuperpixelSLIC } - impl std::fmt::Debug for SuperpixelSEEDS { + impl Drop for SuperpixelSLIC { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SuperpixelSEEDS") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_SuperpixelSLIC_delete(self.as_raw_mut_SuperpixelSLIC()) }; } } + unsafe impl Send for SuperpixelSLIC {} + /// Constant methods for [crate::ximgproc::SuperpixelSLIC] pub trait SuperpixelSLICTraitConst: core::AlgorithmTraitConst { fn as_raw_SuperpixelSLIC(&self) -> *const c_void; @@ -7636,30 +7607,15 @@ pub mod ximgproc { } - /// Class implementing the SLIC (Simple Linear Iterative Clustering) superpixels - /// algorithm described in [Achanta2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Achanta2012). - /// - /// SLIC (Simple Linear Iterative Clustering) clusters pixels using pixel channels and image plane space - /// to efficiently generate compact, nearly uniform superpixels. The simplicity of approach makes it - /// extremely easy to use a lone parameter specifies the number of superpixels and the efficiency of - /// the algorithm makes it very practical. - /// Several optimizations are available for SLIC class: - /// SLICO stands for "Zero parameter SLIC" and it is an optimization of baseline SLIC described in [Achanta2012](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Achanta2012). - /// MSLIC stands for "Manifold SLIC" and it is an optimization of baseline SLIC described in [Liu_2017_IEEE](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Liu_2017_IEEE). - pub struct SuperpixelSLIC { - ptr: *mut c_void, - } - - opencv_type_boxed! { SuperpixelSLIC } - - impl Drop for SuperpixelSLIC { + impl std::fmt::Debug for SuperpixelSLIC { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_SuperpixelSLIC_delete(self.as_raw_mut_SuperpixelSLIC()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SuperpixelSLIC") + .finish() } } - unsafe impl Send for SuperpixelSLIC {} + boxed_cast_base! { SuperpixelSLIC, core::Algorithm, cv_ximgproc_SuperpixelSLIC_to_Algorithm } impl core::AlgorithmTraitConst for SuperpixelSLIC { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -7681,19 +7637,23 @@ pub mod ximgproc { boxed_ref! { SuperpixelSLIC, crate::ximgproc::SuperpixelSLICTraitConst, as_raw_SuperpixelSLIC, crate::ximgproc::SuperpixelSLICTrait, as_raw_mut_SuperpixelSLIC } - impl SuperpixelSLIC { + /// Graph Based Segmentation Algorithm. + /// The class implements the algorithm described in [PFF2004](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_PFF2004) . + pub struct GraphSegmentation { + ptr: *mut c_void, } - boxed_cast_base! { SuperpixelSLIC, core::Algorithm, cv_ximgproc_SuperpixelSLIC_to_Algorithm } + opencv_type_boxed! { GraphSegmentation } - impl std::fmt::Debug for SuperpixelSLIC { + impl Drop for GraphSegmentation { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SuperpixelSLIC") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_segmentation_GraphSegmentation_delete(self.as_raw_mut_GraphSegmentation()) }; } } + unsafe impl Send for GraphSegmentation {} + /// Constant methods for [crate::ximgproc::GraphSegmentation] pub trait GraphSegmentationTraitConst: core::AlgorithmTraitConst { fn as_raw_GraphSegmentation(&self) -> *const c_void; @@ -7775,22 +7735,15 @@ pub mod ximgproc { } - /// Graph Based Segmentation Algorithm. - /// The class implements the algorithm described in [PFF2004](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_PFF2004) . - pub struct GraphSegmentation { - ptr: *mut c_void, - } - - opencv_type_boxed! { GraphSegmentation } - - impl Drop for GraphSegmentation { + impl std::fmt::Debug for GraphSegmentation { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_segmentation_GraphSegmentation_delete(self.as_raw_mut_GraphSegmentation()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GraphSegmentation") + .finish() } } - unsafe impl Send for GraphSegmentation {} + boxed_cast_base! { GraphSegmentation, core::Algorithm, cv_ximgproc_segmentation_GraphSegmentation_to_Algorithm } impl core::AlgorithmTraitConst for GraphSegmentation { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -7812,19 +7765,23 @@ pub mod ximgproc { boxed_ref! { GraphSegmentation, crate::ximgproc::GraphSegmentationTraitConst, as_raw_GraphSegmentation, crate::ximgproc::GraphSegmentationTrait, as_raw_mut_GraphSegmentation } - impl GraphSegmentation { + /// Selective search segmentation algorithm + /// The class implements the algorithm described in [uijlings2013selective](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_uijlings2013selective). + pub struct SelectiveSearchSegmentation { + ptr: *mut c_void, } - boxed_cast_base! { GraphSegmentation, core::Algorithm, cv_ximgproc_segmentation_GraphSegmentation_to_Algorithm } + opencv_type_boxed! { SelectiveSearchSegmentation } - impl std::fmt::Debug for GraphSegmentation { + impl Drop for SelectiveSearchSegmentation { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GraphSegmentation") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_segmentation_SelectiveSearchSegmentation_delete(self.as_raw_mut_SelectiveSearchSegmentation()) }; } } + unsafe impl Send for SelectiveSearchSegmentation {} + /// Constant methods for [crate::ximgproc::SelectiveSearchSegmentation] pub trait SelectiveSearchSegmentationTraitConst: core::AlgorithmTraitConst { fn as_raw_SelectiveSearchSegmentation(&self) -> *const c_void; @@ -8042,22 +7999,15 @@ pub mod ximgproc { } - /// Selective search segmentation algorithm - /// The class implements the algorithm described in [uijlings2013selective](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_uijlings2013selective). - pub struct SelectiveSearchSegmentation { - ptr: *mut c_void, - } - - opencv_type_boxed! { SelectiveSearchSegmentation } - - impl Drop for SelectiveSearchSegmentation { + impl std::fmt::Debug for SelectiveSearchSegmentation { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_segmentation_SelectiveSearchSegmentation_delete(self.as_raw_mut_SelectiveSearchSegmentation()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SelectiveSearchSegmentation") + .finish() } } - unsafe impl Send for SelectiveSearchSegmentation {} + boxed_cast_base! { SelectiveSearchSegmentation, core::Algorithm, cv_ximgproc_segmentation_SelectiveSearchSegmentation_to_Algorithm } impl core::AlgorithmTraitConst for SelectiveSearchSegmentation { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -8079,19 +8029,23 @@ pub mod ximgproc { boxed_ref! { SelectiveSearchSegmentation, crate::ximgproc::SelectiveSearchSegmentationTraitConst, as_raw_SelectiveSearchSegmentation, crate::ximgproc::SelectiveSearchSegmentationTrait, as_raw_mut_SelectiveSearchSegmentation } - impl SelectiveSearchSegmentation { + /// Strategie for the selective search segmentation algorithm + /// The class implements a generic stragery for the algorithm described in [uijlings2013selective](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_uijlings2013selective). + pub struct SelectiveSearchSegmentationStrategy { + ptr: *mut c_void, } - boxed_cast_base! { SelectiveSearchSegmentation, core::Algorithm, cv_ximgproc_segmentation_SelectiveSearchSegmentation_to_Algorithm } + opencv_type_boxed! { SelectiveSearchSegmentationStrategy } - impl std::fmt::Debug for SelectiveSearchSegmentation { + impl Drop for SelectiveSearchSegmentationStrategy { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SelectiveSearchSegmentation") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategy_delete(self.as_raw_mut_SelectiveSearchSegmentationStrategy()) }; } } + unsafe impl Send for SelectiveSearchSegmentationStrategy {} + /// Constant methods for [crate::ximgproc::SelectiveSearchSegmentationStrategy] pub trait SelectiveSearchSegmentationStrategyTraitConst: core::AlgorithmTraitConst { fn as_raw_SelectiveSearchSegmentationStrategy(&self) -> *const c_void; @@ -8173,22 +8127,25 @@ pub mod ximgproc { } - /// Strategie for the selective search segmentation algorithm - /// The class implements a generic stragery for the algorithm described in [uijlings2013selective](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_uijlings2013selective). - pub struct SelectiveSearchSegmentationStrategy { - ptr: *mut c_void, - } - - opencv_type_boxed! { SelectiveSearchSegmentationStrategy } - - impl Drop for SelectiveSearchSegmentationStrategy { + impl std::fmt::Debug for SelectiveSearchSegmentationStrategy { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategy_delete(self.as_raw_mut_SelectiveSearchSegmentationStrategy()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SelectiveSearchSegmentationStrategy") + .finish() } } - unsafe impl Send for SelectiveSearchSegmentationStrategy {} + boxed_cast_base! { SelectiveSearchSegmentationStrategy, core::Algorithm, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategy_to_Algorithm } + + boxed_cast_descendant! { SelectiveSearchSegmentationStrategy, crate::ximgproc::SelectiveSearchSegmentationStrategyColor, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategy_to_SelectiveSearchSegmentationStrategyColor } + + boxed_cast_descendant! { SelectiveSearchSegmentationStrategy, crate::ximgproc::SelectiveSearchSegmentationStrategyFill, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategy_to_SelectiveSearchSegmentationStrategyFill } + + boxed_cast_descendant! { SelectiveSearchSegmentationStrategy, crate::ximgproc::SelectiveSearchSegmentationStrategyMultiple, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategy_to_SelectiveSearchSegmentationStrategyMultiple } + + boxed_cast_descendant! { SelectiveSearchSegmentationStrategy, crate::ximgproc::SelectiveSearchSegmentationStrategySize, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategy_to_SelectiveSearchSegmentationStrategySize } + + boxed_cast_descendant! { SelectiveSearchSegmentationStrategy, crate::ximgproc::SelectiveSearchSegmentationStrategyTexture, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategy_to_SelectiveSearchSegmentationStrategyTexture } impl core::AlgorithmTraitConst for SelectiveSearchSegmentationStrategy { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -8210,29 +8167,23 @@ pub mod ximgproc { boxed_ref! { SelectiveSearchSegmentationStrategy, crate::ximgproc::SelectiveSearchSegmentationStrategyTraitConst, as_raw_SelectiveSearchSegmentationStrategy, crate::ximgproc::SelectiveSearchSegmentationStrategyTrait, as_raw_mut_SelectiveSearchSegmentationStrategy } - impl SelectiveSearchSegmentationStrategy { + /// Color-based strategy for the selective search segmentation algorithm + /// The class is implemented from the algorithm described in [uijlings2013selective](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_uijlings2013selective). + pub struct SelectiveSearchSegmentationStrategyColor { + ptr: *mut c_void, } - boxed_cast_descendant! { SelectiveSearchSegmentationStrategy, crate::ximgproc::SelectiveSearchSegmentationStrategyColor, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategy_to_SelectiveSearchSegmentationStrategyColor } - - boxed_cast_descendant! { SelectiveSearchSegmentationStrategy, crate::ximgproc::SelectiveSearchSegmentationStrategyFill, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategy_to_SelectiveSearchSegmentationStrategyFill } - - boxed_cast_descendant! { SelectiveSearchSegmentationStrategy, crate::ximgproc::SelectiveSearchSegmentationStrategyMultiple, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategy_to_SelectiveSearchSegmentationStrategyMultiple } - - boxed_cast_descendant! { SelectiveSearchSegmentationStrategy, crate::ximgproc::SelectiveSearchSegmentationStrategySize, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategy_to_SelectiveSearchSegmentationStrategySize } - - boxed_cast_descendant! { SelectiveSearchSegmentationStrategy, crate::ximgproc::SelectiveSearchSegmentationStrategyTexture, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategy_to_SelectiveSearchSegmentationStrategyTexture } - - boxed_cast_base! { SelectiveSearchSegmentationStrategy, core::Algorithm, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategy_to_Algorithm } + opencv_type_boxed! { SelectiveSearchSegmentationStrategyColor } - impl std::fmt::Debug for SelectiveSearchSegmentationStrategy { + impl Drop for SelectiveSearchSegmentationStrategyColor { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SelectiveSearchSegmentationStrategy") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyColor_delete(self.as_raw_mut_SelectiveSearchSegmentationStrategyColor()) }; } } + unsafe impl Send for SelectiveSearchSegmentationStrategyColor {} + /// Constant methods for [crate::ximgproc::SelectiveSearchSegmentationStrategyColor] pub trait SelectiveSearchSegmentationStrategyColorTraitConst: crate::ximgproc::SelectiveSearchSegmentationStrategyTraitConst { fn as_raw_SelectiveSearchSegmentationStrategyColor(&self) -> *const c_void; @@ -8245,22 +8196,17 @@ pub mod ximgproc { } - /// Color-based strategy for the selective search segmentation algorithm - /// The class is implemented from the algorithm described in [uijlings2013selective](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_uijlings2013selective). - pub struct SelectiveSearchSegmentationStrategyColor { - ptr: *mut c_void, - } - - opencv_type_boxed! { SelectiveSearchSegmentationStrategyColor } - - impl Drop for SelectiveSearchSegmentationStrategyColor { + impl std::fmt::Debug for SelectiveSearchSegmentationStrategyColor { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyColor_delete(self.as_raw_mut_SelectiveSearchSegmentationStrategyColor()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SelectiveSearchSegmentationStrategyColor") + .finish() } } - unsafe impl Send for SelectiveSearchSegmentationStrategyColor {} + boxed_cast_base! { SelectiveSearchSegmentationStrategyColor, core::Algorithm, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyColor_to_Algorithm } + + boxed_cast_base! { SelectiveSearchSegmentationStrategyColor, crate::ximgproc::SelectiveSearchSegmentationStrategy, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyColor_to_SelectiveSearchSegmentationStrategy } impl core::AlgorithmTraitConst for SelectiveSearchSegmentationStrategyColor { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -8292,21 +8238,23 @@ pub mod ximgproc { boxed_ref! { SelectiveSearchSegmentationStrategyColor, crate::ximgproc::SelectiveSearchSegmentationStrategyColorTraitConst, as_raw_SelectiveSearchSegmentationStrategyColor, crate::ximgproc::SelectiveSearchSegmentationStrategyColorTrait, as_raw_mut_SelectiveSearchSegmentationStrategyColor } - impl SelectiveSearchSegmentationStrategyColor { + /// Fill-based strategy for the selective search segmentation algorithm + /// The class is implemented from the algorithm described in [uijlings2013selective](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_uijlings2013selective). + pub struct SelectiveSearchSegmentationStrategyFill { + ptr: *mut c_void, } - boxed_cast_base! { SelectiveSearchSegmentationStrategyColor, core::Algorithm, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyColor_to_Algorithm } - - boxed_cast_base! { SelectiveSearchSegmentationStrategyColor, crate::ximgproc::SelectiveSearchSegmentationStrategy, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyColor_to_SelectiveSearchSegmentationStrategy } + opencv_type_boxed! { SelectiveSearchSegmentationStrategyFill } - impl std::fmt::Debug for SelectiveSearchSegmentationStrategyColor { + impl Drop for SelectiveSearchSegmentationStrategyFill { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SelectiveSearchSegmentationStrategyColor") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyFill_delete(self.as_raw_mut_SelectiveSearchSegmentationStrategyFill()) }; } } + unsafe impl Send for SelectiveSearchSegmentationStrategyFill {} + /// Constant methods for [crate::ximgproc::SelectiveSearchSegmentationStrategyFill] pub trait SelectiveSearchSegmentationStrategyFillTraitConst: crate::ximgproc::SelectiveSearchSegmentationStrategyTraitConst { fn as_raw_SelectiveSearchSegmentationStrategyFill(&self) -> *const c_void; @@ -8319,22 +8267,17 @@ pub mod ximgproc { } - /// Fill-based strategy for the selective search segmentation algorithm - /// The class is implemented from the algorithm described in [uijlings2013selective](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_uijlings2013selective). - pub struct SelectiveSearchSegmentationStrategyFill { - ptr: *mut c_void, - } - - opencv_type_boxed! { SelectiveSearchSegmentationStrategyFill } - - impl Drop for SelectiveSearchSegmentationStrategyFill { + impl std::fmt::Debug for SelectiveSearchSegmentationStrategyFill { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyFill_delete(self.as_raw_mut_SelectiveSearchSegmentationStrategyFill()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SelectiveSearchSegmentationStrategyFill") + .finish() } } - unsafe impl Send for SelectiveSearchSegmentationStrategyFill {} + boxed_cast_base! { SelectiveSearchSegmentationStrategyFill, core::Algorithm, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyFill_to_Algorithm } + + boxed_cast_base! { SelectiveSearchSegmentationStrategyFill, crate::ximgproc::SelectiveSearchSegmentationStrategy, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyFill_to_SelectiveSearchSegmentationStrategy } impl core::AlgorithmTraitConst for SelectiveSearchSegmentationStrategyFill { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -8366,21 +8309,22 @@ pub mod ximgproc { boxed_ref! { SelectiveSearchSegmentationStrategyFill, crate::ximgproc::SelectiveSearchSegmentationStrategyFillTraitConst, as_raw_SelectiveSearchSegmentationStrategyFill, crate::ximgproc::SelectiveSearchSegmentationStrategyFillTrait, as_raw_mut_SelectiveSearchSegmentationStrategyFill } - impl SelectiveSearchSegmentationStrategyFill { + /// Regroup multiple strategies for the selective search segmentation algorithm + pub struct SelectiveSearchSegmentationStrategyMultiple { + ptr: *mut c_void, } - boxed_cast_base! { SelectiveSearchSegmentationStrategyFill, core::Algorithm, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyFill_to_Algorithm } - - boxed_cast_base! { SelectiveSearchSegmentationStrategyFill, crate::ximgproc::SelectiveSearchSegmentationStrategy, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyFill_to_SelectiveSearchSegmentationStrategy } + opencv_type_boxed! { SelectiveSearchSegmentationStrategyMultiple } - impl std::fmt::Debug for SelectiveSearchSegmentationStrategyFill { + impl Drop for SelectiveSearchSegmentationStrategyMultiple { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SelectiveSearchSegmentationStrategyFill") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyMultiple_delete(self.as_raw_mut_SelectiveSearchSegmentationStrategyMultiple()) }; } } + unsafe impl Send for SelectiveSearchSegmentationStrategyMultiple {} + /// Constant methods for [crate::ximgproc::SelectiveSearchSegmentationStrategyMultiple] pub trait SelectiveSearchSegmentationStrategyMultipleTraitConst: crate::ximgproc::SelectiveSearchSegmentationStrategyTraitConst { fn as_raw_SelectiveSearchSegmentationStrategyMultiple(&self) -> *const c_void; @@ -8416,21 +8360,17 @@ pub mod ximgproc { } - /// Regroup multiple strategies for the selective search segmentation algorithm - pub struct SelectiveSearchSegmentationStrategyMultiple { - ptr: *mut c_void, - } - - opencv_type_boxed! { SelectiveSearchSegmentationStrategyMultiple } - - impl Drop for SelectiveSearchSegmentationStrategyMultiple { + impl std::fmt::Debug for SelectiveSearchSegmentationStrategyMultiple { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyMultiple_delete(self.as_raw_mut_SelectiveSearchSegmentationStrategyMultiple()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SelectiveSearchSegmentationStrategyMultiple") + .finish() } } - unsafe impl Send for SelectiveSearchSegmentationStrategyMultiple {} + boxed_cast_base! { SelectiveSearchSegmentationStrategyMultiple, core::Algorithm, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyMultiple_to_Algorithm } + + boxed_cast_base! { SelectiveSearchSegmentationStrategyMultiple, crate::ximgproc::SelectiveSearchSegmentationStrategy, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyMultiple_to_SelectiveSearchSegmentationStrategy } impl core::AlgorithmTraitConst for SelectiveSearchSegmentationStrategyMultiple { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -8462,21 +8402,23 @@ pub mod ximgproc { boxed_ref! { SelectiveSearchSegmentationStrategyMultiple, crate::ximgproc::SelectiveSearchSegmentationStrategyMultipleTraitConst, as_raw_SelectiveSearchSegmentationStrategyMultiple, crate::ximgproc::SelectiveSearchSegmentationStrategyMultipleTrait, as_raw_mut_SelectiveSearchSegmentationStrategyMultiple } - impl SelectiveSearchSegmentationStrategyMultiple { + /// Size-based strategy for the selective search segmentation algorithm + /// The class is implemented from the algorithm described in [uijlings2013selective](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_uijlings2013selective). + pub struct SelectiveSearchSegmentationStrategySize { + ptr: *mut c_void, } - boxed_cast_base! { SelectiveSearchSegmentationStrategyMultiple, core::Algorithm, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyMultiple_to_Algorithm } - - boxed_cast_base! { SelectiveSearchSegmentationStrategyMultiple, crate::ximgproc::SelectiveSearchSegmentationStrategy, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyMultiple_to_SelectiveSearchSegmentationStrategy } + opencv_type_boxed! { SelectiveSearchSegmentationStrategySize } - impl std::fmt::Debug for SelectiveSearchSegmentationStrategyMultiple { + impl Drop for SelectiveSearchSegmentationStrategySize { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SelectiveSearchSegmentationStrategyMultiple") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategySize_delete(self.as_raw_mut_SelectiveSearchSegmentationStrategySize()) }; } } + unsafe impl Send for SelectiveSearchSegmentationStrategySize {} + /// Constant methods for [crate::ximgproc::SelectiveSearchSegmentationStrategySize] pub trait SelectiveSearchSegmentationStrategySizeTraitConst: crate::ximgproc::SelectiveSearchSegmentationStrategyTraitConst { fn as_raw_SelectiveSearchSegmentationStrategySize(&self) -> *const c_void; @@ -8489,22 +8431,17 @@ pub mod ximgproc { } - /// Size-based strategy for the selective search segmentation algorithm - /// The class is implemented from the algorithm described in [uijlings2013selective](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_uijlings2013selective). - pub struct SelectiveSearchSegmentationStrategySize { - ptr: *mut c_void, - } - - opencv_type_boxed! { SelectiveSearchSegmentationStrategySize } - - impl Drop for SelectiveSearchSegmentationStrategySize { + impl std::fmt::Debug for SelectiveSearchSegmentationStrategySize { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategySize_delete(self.as_raw_mut_SelectiveSearchSegmentationStrategySize()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SelectiveSearchSegmentationStrategySize") + .finish() } } - unsafe impl Send for SelectiveSearchSegmentationStrategySize {} + boxed_cast_base! { SelectiveSearchSegmentationStrategySize, core::Algorithm, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategySize_to_Algorithm } + + boxed_cast_base! { SelectiveSearchSegmentationStrategySize, crate::ximgproc::SelectiveSearchSegmentationStrategy, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategySize_to_SelectiveSearchSegmentationStrategy } impl core::AlgorithmTraitConst for SelectiveSearchSegmentationStrategySize { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -8536,21 +8473,23 @@ pub mod ximgproc { boxed_ref! { SelectiveSearchSegmentationStrategySize, crate::ximgproc::SelectiveSearchSegmentationStrategySizeTraitConst, as_raw_SelectiveSearchSegmentationStrategySize, crate::ximgproc::SelectiveSearchSegmentationStrategySizeTrait, as_raw_mut_SelectiveSearchSegmentationStrategySize } - impl SelectiveSearchSegmentationStrategySize { + /// Texture-based strategy for the selective search segmentation algorithm + /// The class is implemented from the algorithm described in [uijlings2013selective](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_uijlings2013selective). + pub struct SelectiveSearchSegmentationStrategyTexture { + ptr: *mut c_void, } - boxed_cast_base! { SelectiveSearchSegmentationStrategySize, core::Algorithm, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategySize_to_Algorithm } - - boxed_cast_base! { SelectiveSearchSegmentationStrategySize, crate::ximgproc::SelectiveSearchSegmentationStrategy, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategySize_to_SelectiveSearchSegmentationStrategy } + opencv_type_boxed! { SelectiveSearchSegmentationStrategyTexture } - impl std::fmt::Debug for SelectiveSearchSegmentationStrategySize { + impl Drop for SelectiveSearchSegmentationStrategyTexture { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SelectiveSearchSegmentationStrategySize") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyTexture_delete(self.as_raw_mut_SelectiveSearchSegmentationStrategyTexture()) }; } } + unsafe impl Send for SelectiveSearchSegmentationStrategyTexture {} + /// Constant methods for [crate::ximgproc::SelectiveSearchSegmentationStrategyTexture] pub trait SelectiveSearchSegmentationStrategyTextureTraitConst: crate::ximgproc::SelectiveSearchSegmentationStrategyTraitConst { fn as_raw_SelectiveSearchSegmentationStrategyTexture(&self) -> *const c_void; @@ -8563,22 +8502,17 @@ pub mod ximgproc { } - /// Texture-based strategy for the selective search segmentation algorithm - /// The class is implemented from the algorithm described in [uijlings2013selective](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_uijlings2013selective). - pub struct SelectiveSearchSegmentationStrategyTexture { - ptr: *mut c_void, - } - - opencv_type_boxed! { SelectiveSearchSegmentationStrategyTexture } - - impl Drop for SelectiveSearchSegmentationStrategyTexture { + impl std::fmt::Debug for SelectiveSearchSegmentationStrategyTexture { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyTexture_delete(self.as_raw_mut_SelectiveSearchSegmentationStrategyTexture()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SelectiveSearchSegmentationStrategyTexture") + .finish() } } - unsafe impl Send for SelectiveSearchSegmentationStrategyTexture {} + boxed_cast_base! { SelectiveSearchSegmentationStrategyTexture, core::Algorithm, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyTexture_to_Algorithm } + + boxed_cast_base! { SelectiveSearchSegmentationStrategyTexture, crate::ximgproc::SelectiveSearchSegmentationStrategy, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyTexture_to_SelectiveSearchSegmentationStrategy } impl core::AlgorithmTraitConst for SelectiveSearchSegmentationStrategyTexture { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -8610,18 +8544,4 @@ pub mod ximgproc { boxed_ref! { SelectiveSearchSegmentationStrategyTexture, crate::ximgproc::SelectiveSearchSegmentationStrategyTextureTraitConst, as_raw_SelectiveSearchSegmentationStrategyTexture, crate::ximgproc::SelectiveSearchSegmentationStrategyTextureTrait, as_raw_mut_SelectiveSearchSegmentationStrategyTexture } - impl SelectiveSearchSegmentationStrategyTexture { - } - - boxed_cast_base! { SelectiveSearchSegmentationStrategyTexture, core::Algorithm, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyTexture_to_Algorithm } - - boxed_cast_base! { SelectiveSearchSegmentationStrategyTexture, crate::ximgproc::SelectiveSearchSegmentationStrategy, cv_ximgproc_segmentation_SelectiveSearchSegmentationStrategyTexture_to_SelectiveSearchSegmentationStrategy } - - impl std::fmt::Debug for SelectiveSearchSegmentationStrategyTexture { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SelectiveSearchSegmentationStrategyTexture") - .finish() - } - } } diff --git a/docs/xobjdetect.rs b/docs/xobjdetect.rs index af6a5f732..cbf8a78e5 100644 --- a/docs/xobjdetect.rs +++ b/docs/xobjdetect.rs @@ -6,6 +6,36 @@ pub mod xobjdetect { pub use super::{WBDetectorTrait, WBDetectorTraitConst}; } + /// WaldBoost detector + pub struct WBDetector { + ptr: *mut c_void, + } + + opencv_type_boxed! { WBDetector } + + impl Drop for WBDetector { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_xobjdetect_WBDetector_delete(self.as_raw_mut_WBDetector()) }; + } + } + + unsafe impl Send for WBDetector {} + + impl WBDetector { + /// Create instance of WBDetector + #[inline] + pub fn create() -> Result> { + return_send!(via ocvrs_return); + unsafe { sys::cv_xobjdetect_WBDetector_create(ocvrs_return.as_mut_ptr()) }; + return_receive!(unsafe ocvrs_return => ret); + let ret = ret.into_result()?; + let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; + Ok(ret) + } + + } + /// Constant methods for [crate::xobjdetect::WBDetector] pub trait WBDetectorTraitConst { fn as_raw_WBDetector(&self) -> *const c_void; @@ -71,22 +101,14 @@ pub mod xobjdetect { } - /// WaldBoost detector - pub struct WBDetector { - ptr: *mut c_void, - } - - opencv_type_boxed! { WBDetector } - - impl Drop for WBDetector { + impl std::fmt::Debug for WBDetector { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xobjdetect_WBDetector_delete(self.as_raw_mut_WBDetector()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("WBDetector") + .finish() } } - unsafe impl Send for WBDetector {} - impl crate::xobjdetect::WBDetectorTraitConst for WBDetector { #[inline] fn as_raw_WBDetector(&self) -> *const c_void { self.as_raw() } } @@ -97,25 +119,4 @@ pub mod xobjdetect { boxed_ref! { WBDetector, crate::xobjdetect::WBDetectorTraitConst, as_raw_WBDetector, crate::xobjdetect::WBDetectorTrait, as_raw_mut_WBDetector } - impl WBDetector { - /// Create instance of WBDetector - #[inline] - pub fn create() -> Result> { - return_send!(via ocvrs_return); - unsafe { sys::cv_xobjdetect_WBDetector_create(ocvrs_return.as_mut_ptr()) }; - return_receive!(unsafe ocvrs_return => ret); - let ret = ret.into_result()?; - let ret = unsafe { core::Ptr::::opencv_from_extern(ret) }; - Ok(ret) - } - - } - - impl std::fmt::Debug for WBDetector { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("WBDetector") - .finish() - } - } } diff --git a/docs/xphoto.rs b/docs/xphoto.rs index 08e77246c..b24e2d8e4 100644 --- a/docs/xphoto.rs +++ b/docs/xphoto.rs @@ -620,6 +620,41 @@ pub mod xphoto { Ok(ret) } + /// Gray-world white balance algorithm + /// + /// This algorithm scales the values of pixels based on a + /// gray-world assumption which states that the average of all channels + /// should result in a gray image. + /// + /// It adds a modification which thresholds pixels based on their + /// saturation value and only uses pixels below the provided threshold in + /// finding average pixel values. + /// + /// Saturation is calculated using the following for a 3-channel RGB image per + /// pixel I and is in the range [0, 1]: + /// + /// ![block formula](https://latex.codecogs.com/png.latex?%20%5Ctexttt%7BSaturation%7D%20%5BI%5D%20%3D%20%5Cfrac%7B%5Ctextrm%7Bmax%7D%28R%2CG%2CB%29%20%2D%20%5Ctextrm%7Bmin%7D%28R%2CG%2CB%29%0A%7D%7B%5Ctextrm%7Bmax%7D%28R%2CG%2CB%29%7D%20) + /// + /// A threshold of 1 means that all pixels are used to white-balance, while a + /// threshold of 0 means no pixels are used. Lower thresholds are useful in + /// white-balancing saturated images. + /// + /// Currently supports images of type [CV_8UC3] and [CV_16UC3]. + pub struct GrayworldWB { + ptr: *mut c_void, + } + + opencv_type_boxed! { GrayworldWB } + + impl Drop for GrayworldWB { + #[inline] + fn drop(&mut self) { + unsafe { sys::cv_xphoto_GrayworldWB_delete(self.as_raw_mut_GrayworldWB()) }; + } + } + + unsafe impl Send for GrayworldWB {} + /// Constant methods for [crate::xphoto::GrayworldWB] pub trait GrayworldWBTraitConst: crate::xphoto::WhiteBalancerTraitConst { fn as_raw_GrayworldWB(&self) -> *const c_void; @@ -658,40 +693,17 @@ pub mod xphoto { } - /// Gray-world white balance algorithm - /// - /// This algorithm scales the values of pixels based on a - /// gray-world assumption which states that the average of all channels - /// should result in a gray image. - /// - /// It adds a modification which thresholds pixels based on their - /// saturation value and only uses pixels below the provided threshold in - /// finding average pixel values. - /// - /// Saturation is calculated using the following for a 3-channel RGB image per - /// pixel I and is in the range [0, 1]: - /// - /// ![block formula](https://latex.codecogs.com/png.latex?%20%5Ctexttt%7BSaturation%7D%20%5BI%5D%20%3D%20%5Cfrac%7B%5Ctextrm%7Bmax%7D%28R%2CG%2CB%29%20%2D%20%5Ctextrm%7Bmin%7D%28R%2CG%2CB%29%0A%7D%7B%5Ctextrm%7Bmax%7D%28R%2CG%2CB%29%7D%20) - /// - /// A threshold of 1 means that all pixels are used to white-balance, while a - /// threshold of 0 means no pixels are used. Lower thresholds are useful in - /// white-balancing saturated images. - /// - /// Currently supports images of type [CV_8UC3] and [CV_16UC3]. - pub struct GrayworldWB { - ptr: *mut c_void, - } - - opencv_type_boxed! { GrayworldWB } - - impl Drop for GrayworldWB { + impl std::fmt::Debug for GrayworldWB { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xphoto_GrayworldWB_delete(self.as_raw_mut_GrayworldWB()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("GrayworldWB") + .finish() } } - unsafe impl Send for GrayworldWB {} + boxed_cast_base! { GrayworldWB, core::Algorithm, cv_xphoto_GrayworldWB_to_Algorithm } + + boxed_cast_base! { GrayworldWB, crate::xphoto::WhiteBalancer, cv_xphoto_GrayworldWB_to_WhiteBalancer } impl core::AlgorithmTraitConst for GrayworldWB { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -723,21 +735,34 @@ pub mod xphoto { boxed_ref! { GrayworldWB, crate::xphoto::GrayworldWBTraitConst, as_raw_GrayworldWB, crate::xphoto::GrayworldWBTrait, as_raw_mut_GrayworldWB } - impl GrayworldWB { + /// More sophisticated learning-based automatic white balance algorithm. + /// + /// As [GrayworldWB], this algorithm works by applying different gains to the input + /// image channels, but their computation is a bit more involved compared to the + /// simple gray-world assumption. More details about the algorithm can be found in + /// [Cheng2015](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Cheng2015) . + /// + /// To mask out saturated pixels this function uses only pixels that satisfy the + /// following condition: + /// + /// ![block formula](https://latex.codecogs.com/png.latex?%20%5Cfrac%7B%5Ctextrm%7Bmax%7D%28R%2CG%2CB%29%7D%7B%5Ctexttt%7Brange%5Fmax%5Fval%7D%7D%20%3C%20%5Ctexttt%7Bsaturation%5Fthresh%7D%20) + /// + /// Currently supports images of type [CV_8UC3] and [CV_16UC3]. + pub struct LearningBasedWB { + ptr: *mut c_void, } - boxed_cast_base! { GrayworldWB, core::Algorithm, cv_xphoto_GrayworldWB_to_Algorithm } - - boxed_cast_base! { GrayworldWB, crate::xphoto::WhiteBalancer, cv_xphoto_GrayworldWB_to_WhiteBalancer } + opencv_type_boxed! { LearningBasedWB } - impl std::fmt::Debug for GrayworldWB { + impl Drop for LearningBasedWB { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("GrayworldWB") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_xphoto_LearningBasedWB_delete(self.as_raw_mut_LearningBasedWB()) }; } } + unsafe impl Send for LearningBasedWB {} + /// Constant methods for [crate::xphoto::LearningBasedWB] pub trait LearningBasedWBTraitConst: crate::xphoto::WhiteBalancerTraitConst { fn as_raw_LearningBasedWB(&self) -> *const c_void; @@ -855,33 +880,17 @@ pub mod xphoto { } - /// More sophisticated learning-based automatic white balance algorithm. - /// - /// As [GrayworldWB], this algorithm works by applying different gains to the input - /// image channels, but their computation is a bit more involved compared to the - /// simple gray-world assumption. More details about the algorithm can be found in - /// [Cheng2015](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Cheng2015) . - /// - /// To mask out saturated pixels this function uses only pixels that satisfy the - /// following condition: - /// - /// ![block formula](https://latex.codecogs.com/png.latex?%20%5Cfrac%7B%5Ctextrm%7Bmax%7D%28R%2CG%2CB%29%7D%7B%5Ctexttt%7Brange%5Fmax%5Fval%7D%7D%20%3C%20%5Ctexttt%7Bsaturation%5Fthresh%7D%20) - /// - /// Currently supports images of type [CV_8UC3] and [CV_16UC3]. - pub struct LearningBasedWB { - ptr: *mut c_void, - } - - opencv_type_boxed! { LearningBasedWB } - - impl Drop for LearningBasedWB { + impl std::fmt::Debug for LearningBasedWB { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xphoto_LearningBasedWB_delete(self.as_raw_mut_LearningBasedWB()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("LearningBasedWB") + .finish() } } - unsafe impl Send for LearningBasedWB {} + boxed_cast_base! { LearningBasedWB, core::Algorithm, cv_xphoto_LearningBasedWB_to_Algorithm } + + boxed_cast_base! { LearningBasedWB, crate::xphoto::WhiteBalancer, cv_xphoto_LearningBasedWB_to_WhiteBalancer } impl core::AlgorithmTraitConst for LearningBasedWB { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -913,21 +922,24 @@ pub mod xphoto { boxed_ref! { LearningBasedWB, crate::xphoto::LearningBasedWBTraitConst, as_raw_LearningBasedWB, crate::xphoto::LearningBasedWBTrait, as_raw_mut_LearningBasedWB } - impl LearningBasedWB { + /// A simple white balance algorithm that works by independently stretching + /// each of the input image channels to the specified range. For increased robustness + /// it ignores the top and bottom ![inline formula](https://latex.codecogs.com/png.latex?p%5C%25) of pixel values. + pub struct SimpleWB { + ptr: *mut c_void, } - boxed_cast_base! { LearningBasedWB, core::Algorithm, cv_xphoto_LearningBasedWB_to_Algorithm } - - boxed_cast_base! { LearningBasedWB, crate::xphoto::WhiteBalancer, cv_xphoto_LearningBasedWB_to_WhiteBalancer } + opencv_type_boxed! { SimpleWB } - impl std::fmt::Debug for LearningBasedWB { + impl Drop for SimpleWB { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("LearningBasedWB") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_xphoto_SimpleWB_delete(self.as_raw_mut_SimpleWB()) }; } } + unsafe impl Send for SimpleWB {} + /// Constant methods for [crate::xphoto::SimpleWB] pub trait SimpleWBTraitConst: crate::xphoto::WhiteBalancerTraitConst { fn as_raw_SimpleWB(&self) -> *const c_void; @@ -1060,23 +1072,17 @@ pub mod xphoto { } - /// A simple white balance algorithm that works by independently stretching - /// each of the input image channels to the specified range. For increased robustness - /// it ignores the top and bottom ![inline formula](https://latex.codecogs.com/png.latex?p%5C%25) of pixel values. - pub struct SimpleWB { - ptr: *mut c_void, - } - - opencv_type_boxed! { SimpleWB } - - impl Drop for SimpleWB { + impl std::fmt::Debug for SimpleWB { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xphoto_SimpleWB_delete(self.as_raw_mut_SimpleWB()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("SimpleWB") + .finish() } } - unsafe impl Send for SimpleWB {} + boxed_cast_base! { SimpleWB, core::Algorithm, cv_xphoto_SimpleWB_to_Algorithm } + + boxed_cast_base! { SimpleWB, crate::xphoto::WhiteBalancer, cv_xphoto_SimpleWB_to_WhiteBalancer } impl core::AlgorithmTraitConst for SimpleWB { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1108,21 +1114,29 @@ pub mod xphoto { boxed_ref! { SimpleWB, crate::xphoto::SimpleWBTraitConst, as_raw_SimpleWB, crate::xphoto::SimpleWBTrait, as_raw_mut_SimpleWB } - impl SimpleWB { + /// This algorithm decomposes image into two layers: base layer and detail layer using bilateral filter + /// and compresses contrast of the base layer thus preserving all the details. + /// + /// This implementation uses regular bilateral filter from OpenCV. + /// + /// Saturation enhancement is possible as in cv::TonemapDrago. + /// + /// For more information see [DD02](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_DD02) . + pub struct TonemapDurand { + ptr: *mut c_void, } - boxed_cast_base! { SimpleWB, core::Algorithm, cv_xphoto_SimpleWB_to_Algorithm } - - boxed_cast_base! { SimpleWB, crate::xphoto::WhiteBalancer, cv_xphoto_SimpleWB_to_WhiteBalancer } + opencv_type_boxed! { TonemapDurand } - impl std::fmt::Debug for SimpleWB { + impl Drop for TonemapDurand { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("SimpleWB") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_xphoto_TonemapDurand_delete(self.as_raw_mut_TonemapDurand()) }; } } + unsafe impl Send for TonemapDurand {} + /// Constant methods for [crate::xphoto::TonemapDurand] pub trait TonemapDurandTraitConst: crate::photo::TonemapTraitConst { fn as_raw_TonemapDurand(&self) -> *const c_void; @@ -1207,28 +1221,17 @@ pub mod xphoto { } - /// This algorithm decomposes image into two layers: base layer and detail layer using bilateral filter - /// and compresses contrast of the base layer thus preserving all the details. - /// - /// This implementation uses regular bilateral filter from OpenCV. - /// - /// Saturation enhancement is possible as in cv::TonemapDrago. - /// - /// For more information see [DD02](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_DD02) . - pub struct TonemapDurand { - ptr: *mut c_void, - } - - opencv_type_boxed! { TonemapDurand } - - impl Drop for TonemapDurand { + impl std::fmt::Debug for TonemapDurand { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xphoto_TonemapDurand_delete(self.as_raw_mut_TonemapDurand()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("TonemapDurand") + .finish() } } - unsafe impl Send for TonemapDurand {} + boxed_cast_base! { TonemapDurand, core::Algorithm, cv_xphoto_TonemapDurand_to_Algorithm } + + boxed_cast_base! { TonemapDurand, crate::photo::Tonemap, cv_xphoto_TonemapDurand_to_Tonemap } impl core::AlgorithmTraitConst for TonemapDurand { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1260,21 +1263,22 @@ pub mod xphoto { boxed_ref! { TonemapDurand, crate::xphoto::TonemapDurandTraitConst, as_raw_TonemapDurand, crate::xphoto::TonemapDurandTrait, as_raw_mut_TonemapDurand } - impl TonemapDurand { + /// The base class for auto white balance algorithms. + pub struct WhiteBalancer { + ptr: *mut c_void, } - boxed_cast_base! { TonemapDurand, core::Algorithm, cv_xphoto_TonemapDurand_to_Algorithm } - - boxed_cast_base! { TonemapDurand, crate::photo::Tonemap, cv_xphoto_TonemapDurand_to_Tonemap } + opencv_type_boxed! { WhiteBalancer } - impl std::fmt::Debug for TonemapDurand { + impl Drop for WhiteBalancer { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("TonemapDurand") - .finish() + fn drop(&mut self) { + unsafe { sys::cv_xphoto_WhiteBalancer_delete(self.as_raw_mut_WhiteBalancer()) }; } } + unsafe impl Send for WhiteBalancer {} + /// Constant methods for [crate::xphoto::WhiteBalancer] pub trait WhiteBalancerTraitConst: core::AlgorithmTraitConst { fn as_raw_WhiteBalancer(&self) -> *const c_void; @@ -1305,21 +1309,21 @@ pub mod xphoto { } - /// The base class for auto white balance algorithms. - pub struct WhiteBalancer { - ptr: *mut c_void, - } - - opencv_type_boxed! { WhiteBalancer } - - impl Drop for WhiteBalancer { + impl std::fmt::Debug for WhiteBalancer { #[inline] - fn drop(&mut self) { - unsafe { sys::cv_xphoto_WhiteBalancer_delete(self.as_raw_mut_WhiteBalancer()) }; + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("WhiteBalancer") + .finish() } } - unsafe impl Send for WhiteBalancer {} + boxed_cast_base! { WhiteBalancer, core::Algorithm, cv_xphoto_WhiteBalancer_to_Algorithm } + + boxed_cast_descendant! { WhiteBalancer, crate::xphoto::GrayworldWB, cv_xphoto_WhiteBalancer_to_GrayworldWB } + + boxed_cast_descendant! { WhiteBalancer, crate::xphoto::LearningBasedWB, cv_xphoto_WhiteBalancer_to_LearningBasedWB } + + boxed_cast_descendant! { WhiteBalancer, crate::xphoto::SimpleWB, cv_xphoto_WhiteBalancer_to_SimpleWB } impl core::AlgorithmTraitConst for WhiteBalancer { #[inline] fn as_raw_Algorithm(&self) -> *const c_void { self.as_raw() } @@ -1341,22 +1345,4 @@ pub mod xphoto { boxed_ref! { WhiteBalancer, crate::xphoto::WhiteBalancerTraitConst, as_raw_WhiteBalancer, crate::xphoto::WhiteBalancerTrait, as_raw_mut_WhiteBalancer } - impl WhiteBalancer { - } - - boxed_cast_descendant! { WhiteBalancer, crate::xphoto::GrayworldWB, cv_xphoto_WhiteBalancer_to_GrayworldWB } - - boxed_cast_descendant! { WhiteBalancer, crate::xphoto::LearningBasedWB, cv_xphoto_WhiteBalancer_to_LearningBasedWB } - - boxed_cast_descendant! { WhiteBalancer, crate::xphoto::SimpleWB, cv_xphoto_WhiteBalancer_to_SimpleWB } - - boxed_cast_base! { WhiteBalancer, core::Algorithm, cv_xphoto_WhiteBalancer_to_Algorithm } - - impl std::fmt::Debug for WhiteBalancer { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("WhiteBalancer") - .finish() - } - } }