adjust class names, drop custom Input/OutputArray
MODIFY
gen_rust.py
gen_rust.py
@@ -345,10 +345,20 @@ func_rename = {
"cv_ocl_Kernel_set_int_KernelArg": "+_kernel_arg",
"cv_ocl_Program_getPrefix_String": "+_build_flags",
"cv_ocl_ProgramSource_ProgramSource_String": "from_str",
+ "cv__InputArray__InputArray_Mat": "from_mat",
+ "cv__InputArray__InputArray_MatExpr": "from_matexpr",
+ "cv__InputArray__InputArray_VectorOfMat": "from_mat_vec",
+ "cv__InputArray__InputArray_VectorOfbool": "from_bool_vec",
+ "cv__InputArray__InputArray_double": "from_f64",
+ "cv__InputArray__InputArray_UMat": "from_umat",
+ "cv__InputArray__InputArray_VectorOfUMat": "from_umat_vec",
"cv__InputArray_copyTo_const__OutputArray__InputArray": "+_with_mask",
+ "cv__OutputArray__OutputArray_Mat": "from_mat",
+ "cv__OutputArray__OutputArray_VectorOfMat": "from_mat_vec",
+ "cv__OutputArray__OutputArray_UMat": "from_umat",
+ "cv__OutputArray__OutputArray_VectorOfUMat": "from_umat_vec",
"cv__InputOutputArray__InputOutputArray_Mat": "from_mat",
"cv__InputOutputArray__InputOutputArray_VectorOfMat": "from_mat_vec",
- # "cv__InputArray__InputArray_double": "from_f64",
"cv__InputOutputArray__InputOutputArray_UMat": "from_umat",
"cv__InputOutputArray__InputOutputArray_VectorOfUMat": "from_umat_vec",
"cv_read_FileNode_schar_schar": "-",
@@ -2009,7 +2019,7 @@ class TypeInfo(object):
if not ci and isinstance(self, RawPtrTypeInfo):
ci = self.inner.ci
if ci and ci.is_trait:
- if not ci.is_abstract:
+ if not ci.is_abstract and ci.fullname not in ("cv::_InputArray", "cv::_OutputArray", "cv::_InputOutputArray"):
rust_full += "Trait"
mods.append("dyn")
if len(mods) > 0:
@@ -2797,60 +2807,60 @@ class VectorTypeInfo(TypeInfo):
impl core::ToInputArray for ${rust_local} {
#[inline]
- fn input_array(&self) -> Result<core::InputArray> {
+ fn input_array(&self) -> Result<core::_InputArray> {
let me = self.as_raw_${rust_local}();
cpp!(unsafe [me as "${cpptype}*"] -> sys::cv_return_value_const_void_X as "cv_return_value_void_X" {
try {
return { Error::Code::StsOk, NULL, new _InputArray(*me) };
} CVRS_CATCH(cv_return_value_void_X)
}).into_result()
- .map(|ptr| core::InputArray { ptr })
+ .map(|ptr| core::_InputArray { ptr })
}
}
impl core::ToInputArray for &${rust_local} {
#[inline]
- fn input_array(&self) -> Result<core::InputArray> {
+ fn input_array(&self) -> Result<core::_InputArray> {
(*self).input_array()
}
}
impl core::ToOutputArray for ${rust_local} {
#[inline]
- fn output_array(&mut self) -> Result<core::OutputArray> {
+ fn output_array(&mut self) -> Result<core::_OutputArray> {
let me = self.as_raw_${rust_local}();
cpp!(unsafe [me as "${cpptype}*"] -> sys::cv_return_value_const_void_X as "cv_return_value_void_X" {
try {
return { Error::Code::StsOk, NULL, new _OutputArray(*me) };
} CVRS_CATCH(cv_return_value_void_X)
}).into_result()
- .map(|ptr| core::OutputArray { ptr })
+ .map(|ptr| core::_OutputArray { ptr })
}
}
impl core::ToOutputArray for &mut ${rust_local} {
#[inline]
- fn output_array(&mut self) -> Result<core::OutputArray> {
+ fn output_array(&mut self) -> Result<core::_OutputArray> {
(*self).output_array()
}
}
impl core::ToInputOutputArray for ${rust_local} {
#[inline]
- fn input_output_array(&mut self) -> Result<core::InputOutputArray> {
+ fn input_output_array(&mut self) -> Result<core::_InputOutputArray> {
let me = self.as_raw_${rust_local}();
cpp!(unsafe [me as "${cpptype}*"] -> sys::cv_return_value_const_void_X as "cv_return_value_void_X" {
try {
return { Error::Code::StsOk, NULL, new _InputOutputArray(*me) };
} CVRS_CATCH(cv_return_value_void_X)
}).into_result()
- .map(|ptr| core::InputOutputArray { ptr })
+ .map(|ptr| core::_InputOutputArray { ptr })
}
}
impl core::ToInputOutputArray for &mut ${rust_local} {
#[inline]
- fn input_output_array(&mut self) -> Result<core::InputOutputArray> {
+ fn input_output_array(&mut self) -> Result<core::_InputOutputArray> {
(*self).input_output_array()
}
}

MODIFY
src/manual/core/input_output_array.rs
src/manual/core/input_output_array.rs
-use std::ffi::c_void;
-
use crate::{
- core::{_InputArrayTrait, _InputOutputArray, _OutputArrayTrait, Mat, MatExpr, UMat},
+ core::{_InputArray, _InputOutputArray, _OutputArray},
Result,
- sys,
- types::{VectorOfMat, VectorOfUMat},
};
-pub struct InputArray {
- #[doc(hidden)] pub(crate) ptr: *mut c_void
-}
-
-impl InputArray {
- #[inline]
- pub fn from_mat(m: &Mat) -> Result<Self> {
- let m = m.as_raw_Mat();
- cpp!(unsafe [m as "const Mat*"] -> sys::cv_return_value_const_void_X as "cv_return_value_void_X" {
- try {
- return { Error::Code::StsOk, NULL, new _InputArray(*m) };
- } CVRS_CATCH(cv_return_value_void_X)
- }).into_result()
- .map(|ptr| Self { ptr })
- }
-
- #[inline]
- pub fn from_mat_expr(m: &MatExpr) -> Result<Self> {
- let m = m.as_raw_MatExpr();
- cpp!(unsafe [m as "const MatExpr*"] -> sys::cv_return_value_const_void_X as "cv_return_value_void_X" {
- try {
- return { Error::Code::StsOk, NULL, new _InputArray(*m) };
- } CVRS_CATCH(cv_return_value_void_X)
- }).into_result()
- .map(|ptr| Self { ptr })
- }
-
- #[inline]
- pub fn from_mat_vec(m: &VectorOfMat) -> Result<Self> {
- let m = m.as_raw_VectorOfMat();
- cpp!(unsafe [m as "const std::vector<Mat>*"] -> sys::cv_return_value_const_void_X as "cv_return_value_void_X" {
- try {
- return { Error::Code::StsOk, NULL, new _InputArray(*m) };
- } CVRS_CATCH(cv_return_value_void_X)
- }).into_result()
- .map(|ptr| Self { ptr })
- }
-
- #[inline]
- pub fn from_f64(val: &f64) -> Result<Self> {
- cpp!(unsafe [val as "const double*"] -> sys::cv_return_value_const_void_X as "cv_return_value_void_X" {
- try {
- return { Error::Code::StsOk, NULL, new _InputArray(*val) };
- } CVRS_CATCH(cv_return_value_void_X)
- }).into_result()
- .map(|ptr| Self { ptr })
- }
-
- #[inline]
- pub fn from_umat(m: &UMat) -> Result<Self> {
- let m = m.as_raw_UMat();
- cpp!(unsafe [m as "const UMat*"] -> sys::cv_return_value_const_void_X as "cv_return_value_void_X" {
- try {
- return { Error::Code::StsOk, NULL, new _InputArray(*m) };
- } CVRS_CATCH(cv_return_value_void_X)
- }).into_result()
- .map(|ptr| Self { ptr })
- }
-
- #[inline]
- pub fn from_umat_vec(m: &VectorOfUMat) -> Result<Self> {
- let m = m.as_raw_VectorOfUMat();
- cpp!(unsafe [m as "const std::vector<UMat>*"] -> sys::cv_return_value_const_void_X as "cv_return_value_void_X" {
- try {
- return { Error::Code::StsOk, NULL, new _InputArray(*m) };
- } CVRS_CATCH(cv_return_value_void_X)
- }).into_result()
- .map(|ptr| Self { ptr })
- }
-}
-
-impl _InputArrayTrait for InputArray {
- fn as_raw__InputArray(&self) -> *mut c_void {
- self.ptr
- }
-}
-
-impl Drop for InputArray {
- fn drop(&mut self) {
- let me = self.as_raw__InputArray();
- cpp!(unsafe [me as "cv::_InputArray*"] {
- delete me;
- })
- }
-}
-
/// Trait to serve as a replacement for `InputArray` in C++ OpenCV
///
/// You can pass references to the types implementing this trait everywhere where OpenCV API expects
@@ -100,94 +10,23 @@ impl Drop for InputArray {
///
/// More info in [OpenCV docs](https://docs.opencv.org/master/d4/d32/classcv_1_1__InputArray.html#details).
pub trait ToInputArray {
- fn input_array(&self) -> Result<InputArray>;
+ fn input_array(&self) -> Result<_InputArray>;
}
impl ToInputArray for f64 {
#[inline]
- fn input_array(&self) -> Result<InputArray> {
- InputArray::from_f64(self)
+ fn input_array(&self) -> Result<_InputArray> {
+ _InputArray::from_f64(self)
}
}
impl ToInputArray for &f64 {
#[inline]
- fn input_array(&self) -> Result<InputArray> {
+ fn input_array(&self) -> Result<_InputArray> {
(*self).input_array()
}
}
-pub struct OutputArray {
- #[doc(hidden)] pub(crate) ptr: *mut c_void
-}
-
-impl OutputArray {
- #[inline]
- pub fn from_mat(m: &mut Mat) -> Result<Self> {
- let m = m.as_raw_Mat();
- cpp!(unsafe [m as "Mat*"] -> sys::cv_return_value_const_void_X as "cv_return_value_void_X" {
- try {
- return { Error::Code::StsOk, NULL, new _OutputArray(*m) };
- } CVRS_CATCH(cv_return_value_void_X)
- }).into_result()
- .map(|ptr| Self { ptr })
- }
-
- #[inline]
- pub fn from_mat_vec(m: &mut VectorOfMat) -> Result<Self> {
- let m = m.as_raw_VectorOfMat();
- cpp!(unsafe [m as "std::vector<Mat>*"] -> sys::cv_return_value_const_void_X as "cv_return_value_void_X" {
- try {
- return { Error::Code::StsOk, NULL, new _OutputArray(*m) };
- } CVRS_CATCH(cv_return_value_void_X)
- }).into_result()
- .map(|ptr| Self { ptr })
- }
-
- #[inline]
- pub fn from_umat(m: &mut UMat) -> Result<Self> {
- let m = m.as_raw_UMat();
- cpp!(unsafe [m as "UMat*"] -> sys::cv_return_value_const_void_X as "cv_return_value_void_X" {
- try {
- return { Error::Code::StsOk, NULL, new _OutputArray(*m) };
- } CVRS_CATCH(cv_return_value_void_X)
- }).into_result()
- .map(|ptr| Self { ptr })
- }
-
- #[inline]
- pub fn from_umat_vec(m: &mut VectorOfUMat) -> Result<Self> {
- let m = m.as_raw_VectorOfUMat();
- cpp!(unsafe [m as "std::vector<UMat>*"] -> sys::cv_return_value_const_void_X as "cv_return_value_void_X" {
- try {
- return { Error::Code::StsOk, NULL, new _OutputArray(*m) };
- } CVRS_CATCH(cv_return_value_void_X)
- }).into_result()
- .map(|ptr| Self { ptr })
- }
-}
-
-impl _InputArrayTrait for OutputArray {
- fn as_raw__InputArray(&self) -> *mut c_void {
- self.ptr
- }
-}
-
-impl _OutputArrayTrait for OutputArray {
- fn as_raw__OutputArray(&self) -> *mut c_void {
- self.as_raw__InputArray()
- }
-}
-
-impl Drop for OutputArray {
- fn drop(&mut self) {
- let me = self.as_raw__OutputArray();
- cpp!(unsafe [me as "cv::_OutputArray*"] {
- delete me;
- })
- }
-}
-
/// Trait to serve as a replacement for `OutputArray` in C++ OpenCV
///
/// You can pass reference to the type implementing this trait everywhere where OpenCV API expects
@@ -195,11 +34,9 @@ impl Drop for OutputArray {
///
/// More info in [OpenCV docs](https://docs.opencv.org/master/d2/d9e/classcv_1_1__OutputArray.html#details).
pub trait ToOutputArray {
- fn output_array(&mut self) -> Result<OutputArray>;
+ fn output_array(&mut self) -> Result<_OutputArray>;
}
-pub type InputOutputArray = _InputOutputArray;
-
/// Trait to serve as a replacement for `InputOutputArray` in C++ OpenCV
///
/// You can pass reference to the type implementing this trait everywhere where OpenCV API expects
@@ -207,5 +44,5 @@ pub type InputOutputArray = _InputOutputArray;
///
/// For more info see comments for `ToInputArray` and `ToOutputArray`.
pub trait ToInputOutputArray {
- fn input_output_array(&mut self) -> Result<InputOutputArray>;
+ fn input_output_array(&mut self) -> Result<_InputOutputArray>;
}

MODIFY
src/manual/core/mat.rs
src/manual/core/mat.rs
@@ -9,14 +9,14 @@ use libc::{c_uchar, size_t};
use crate::{
core::{
self,
- InputArray,
- InputOutputArray,
+ _InputArray,
+ _InputOutputArray,
+ _OutputArray,
Mat,
MatConstIterator,
MatExpr,
MatSize,
MatStep,
- OutputArray,
Scalar,
ToInputArray,
ToInputOutputArray,
@@ -442,42 +442,42 @@ impl Mat {
impl ToInputArray for Mat {
#[inline]
- fn input_array(&self) -> Result<InputArray> {
- InputArray::from_mat(self)
+ fn input_array(&self) -> Result<_InputArray> {
+ _InputArray::from_mat(self)
}
}
impl ToInputArray for &Mat {
#[inline]
- fn input_array(&self) -> Result<InputArray> {
+ fn input_array(&self) -> Result<_InputArray> {
(*self).input_array()
}
}
impl ToOutputArray for Mat {
#[inline]
- fn output_array(&mut self) -> Result<OutputArray> {
- OutputArray::from_mat(self)
+ fn output_array(&mut self) -> Result<_OutputArray> {
+ _OutputArray::from_mat(self)
}
}
impl ToOutputArray for &mut Mat {
#[inline]
- fn output_array(&mut self) -> Result<OutputArray> {
+ fn output_array(&mut self) -> Result<_OutputArray> {
(*self).output_array()
}
}
impl ToInputOutputArray for Mat {
#[inline]
- fn input_output_array(&mut self) -> Result<InputOutputArray> {
- InputOutputArray::from_mat(self)
+ fn input_output_array(&mut self) -> Result<_InputOutputArray> {
+ _InputOutputArray::from_mat(self)
}
}
impl ToInputOutputArray for &mut Mat {
#[inline]
- fn input_output_array(&mut self) -> Result<InputOutputArray> {
+ fn input_output_array(&mut self) -> Result<_InputOutputArray> {
(*self).input_output_array()
}
}
@@ -523,42 +523,42 @@ impl UMat {
impl ToInputArray for UMat {
#[inline]
- fn input_array(&self) -> Result<InputArray> {
- InputArray::from_umat(self)
+ fn input_array(&self) -> Result<_InputArray> {
+ _InputArray::from_umat(self)
}
}
impl ToInputArray for &UMat {
#[inline]
- fn input_array(&self) -> Result<InputArray> {
+ fn input_array(&self) -> Result<_InputArray> {
(*self).input_array()
}
}
impl ToOutputArray for UMat {
#[inline]
- fn output_array(&mut self) -> Result<OutputArray> {
- OutputArray::from_umat(self)
+ fn output_array(&mut self) -> Result<_OutputArray> {
+ _OutputArray::from_umat(self)
}
}
impl ToOutputArray for &mut UMat {
#[inline]
- fn output_array(&mut self) -> Result<OutputArray> {
+ fn output_array(&mut self) -> Result<_OutputArray> {
(*self).output_array()
}
}
impl ToInputOutputArray for UMat {
#[inline]
- fn input_output_array(&mut self) -> Result<InputOutputArray> {
- InputOutputArray::from_umat(self)
+ fn input_output_array(&mut self) -> Result<_InputOutputArray> {
+ _InputOutputArray::from_umat(self)
}
}
impl ToInputOutputArray for &mut UMat {
#[inline]
- fn input_output_array(&mut self) -> Result<InputOutputArray> {
+ fn input_output_array(&mut self) -> Result<_InputOutputArray> {
(*self).input_output_array()
}
}
@@ -654,14 +654,14 @@ impl MatConstIterator {
impl ToInputArray for MatExpr {
#[inline]
- fn input_array(&self) -> Result<InputArray> {
- InputArray::from_mat_expr(self)
+ fn input_array(&self) -> Result<_InputArray> {
+ _InputArray::from_matexpr(self)
}
}
impl ToInputArray for &MatExpr {
#[inline]
- fn input_array(&self) -> Result<InputArray> {
+ fn input_array(&self) -> Result<_InputArray> {
(*self).input_array()
}
}

MODIFY
src/manual/types.rs
src/manual/types.rs
-use crate::{core, Result, types};
+use crate::{
+ core::{_InputArray, _InputOutputArray, _OutputArray, ToInputArray, ToInputOutputArray, ToOutputArray},
+ Result,
+ types,
+};
#[doc(hidden)]
#[repr(C)]
@@ -11,86 +15,86 @@ impl From<Unit> for () {
}
}
-impl core::ToInputArray for types::VectorOfMat {
+impl ToInputArray for types::VectorOfMat {
#[inline]
- fn input_array(&self) -> Result<core::InputArray> {
- core::InputArray::from_mat_vec(self)
+ fn input_array(&self) -> Result<_InputArray> {
+ _InputArray::from_mat_vec(self)
}
}
-impl core::ToInputArray for &types::VectorOfMat {
+impl ToInputArray for &types::VectorOfMat {
#[inline]
- fn input_array(&self) -> Result<core::InputArray> {
+ fn input_array(&self) -> Result<_InputArray> {
(*self).input_array()
}
}
-impl core::ToOutputArray for types::VectorOfMat {
+impl ToOutputArray for types::VectorOfMat {
#[inline]
- fn output_array(&mut self) -> Result<core::OutputArray> {
- core::OutputArray::from_mat_vec(self)
+ fn output_array(&mut self) -> Result<_OutputArray> {
+ _OutputArray::from_mat_vec(self)
}
}
-impl core::ToOutputArray for &mut types::VectorOfMat {
+impl ToOutputArray for &mut types::VectorOfMat {
#[inline]
- fn output_array(&mut self) -> Result<core::OutputArray> {
+ fn output_array(&mut self) -> Result<_OutputArray> {
(*self).output_array()
}
}
-impl core::ToInputOutputArray for types::VectorOfMat {
+impl ToInputOutputArray for types::VectorOfMat {
#[inline]
- fn input_output_array(&mut self) -> Result<core::InputOutputArray> {
- core::InputOutputArray::from_mat_vec(self)
+ fn input_output_array(&mut self) -> Result<_InputOutputArray> {
+ _InputOutputArray::from_mat_vec(self)
}
}
-impl core::ToInputOutputArray for &mut types::VectorOfMat {
+impl ToInputOutputArray for &mut types::VectorOfMat {
#[inline]
- fn input_output_array(&mut self) -> Result<core::InputOutputArray> {
+ fn input_output_array(&mut self) -> Result<_InputOutputArray> {
(*self).input_output_array()
}
}
-impl core::ToInputArray for types::VectorOfUMat {
+impl ToInputArray for types::VectorOfUMat {
#[inline]
- fn input_array(&self) -> Result<core::InputArray> {
- core::InputArray::from_umat_vec(self)
+ fn input_array(&self) -> Result<_InputArray> {
+ _InputArray::from_umat_vec(self)
}
}
-impl core::ToInputArray for &types::VectorOfUMat {
+impl ToInputArray for &types::VectorOfUMat {
#[inline]
- fn input_array(&self) -> Result<core::InputArray> {
+ fn input_array(&self) -> Result<_InputArray> {
(*self).input_array()
}
}
-impl core::ToOutputArray for types::VectorOfUMat {
+impl ToOutputArray for types::VectorOfUMat {
#[inline]
- fn output_array(&mut self) -> Result<core::OutputArray> {
- core::OutputArray::from_umat_vec(self)
+ fn output_array(&mut self) -> Result<_OutputArray> {
+ _OutputArray::from_umat_vec(self)
}
}
-impl core::ToOutputArray for &mut types::VectorOfUMat {
+impl ToOutputArray for &mut types::VectorOfUMat {
#[inline]
- fn output_array(&mut self) -> Result<core::OutputArray> {
+ fn output_array(&mut self) -> Result<_OutputArray> {
(*self).output_array()
}
}
-impl core::ToInputOutputArray for types::VectorOfUMat {
+impl ToInputOutputArray for types::VectorOfUMat {
#[inline]
- fn input_output_array(&mut self) -> Result<core::InputOutputArray> {
- core::InputOutputArray::from_umat_vec(self)
+ fn input_output_array(&mut self) -> Result<_InputOutputArray> {
+ _InputOutputArray::from_umat_vec(self)
}
}
-impl core::ToInputOutputArray for &mut types::VectorOfUMat {
+impl ToInputOutputArray for &mut types::VectorOfUMat {
#[inline]
- fn input_output_array(&mut self) -> Result<core::InputOutputArray> {
+ fn input_output_array(&mut self) -> Result<_InputOutputArray> {
(*self).input_output_array()
}
}

adjust class names, drop custom Input/OutputArray