Support OpenCV 4.5.1
MODIFY
.github/workflows/opencv-rust.yml
.github/workflows/opencv-rust.yml
@@ -22,9 +22,9 @@ jobs:
- stable
- beta
version:
- - opencv: 3.4.12
+ - opencv: 3.4.13
features: opencv-34
- - opencv: 4.5.0
+ - opencv: 4.5.1
features: opencv-4
exclude:
- os:

MODIFY
binding-generator/src/element.rs
binding-generator/src/element.rs
@@ -286,7 +286,7 @@ fn opencv_module_component(path: &Path) -> Option<&OsStr> {
let mut module = None;
while let Some(cur) = module_comp.next() {
if let Some(&parent) = module_comp.peek() {
- if parent == "opencv2" {
+ if parent == "opencv2" || parent == "src_cpp" {
module = Some(cur);
break;
}

MODIFY
binding-generator/src/lib.rs
binding-generator/src/lib.rs
// fixme MatConstIterator::m return Mat**, is it handled correctly?
// fixme docs.rs fails to build crates that have opencv as dependency
// fixme VectorOfMat::get allows mutation
+// fixme TextDetectionModel_EAST (and all others inheriting from Model) seems to have no fields, but it fails when generated as simple, probably makes sense to have a special case for that
// copy-pasted form python generator (may be obsolete):
// fixme returning MatAllocator (trait) by reference is bad, check knearestneighbour

MODIFY
binding-generator/src/settings.rs
binding-generator/src/settings.rs
@@ -367,6 +367,7 @@ pub static FUNC_RENAME: Lazy<HashMap<&str, &str>> = Lazy::new(|| hashmap! {
"cv_dnn_DictValue_DictValue_const_StringR" => "-", // effectively duplicate of cv_dnn_DictValue_DictValue_const_charX
"cv_dnn_Layer_finalize_const_vector_MatX_R_vector_Mat_R" => "-", // dup of cv_dnn_Layer_finalize_const_vector_Mat_X_vector_Mat_X
+ "cv_dnn_Model_operator_cv_dnn_Net_const" => "-", // fixme, should generate fine, it's a dup of get_network_() anyway
// ### face ###
"cv_face_FacemarkLBF_Params_getPropPupils" => "-", // fixme array of vectors
@@ -638,10 +639,15 @@ pub static ELEMENT_EXPORT: Lazy<HashMap<&str, ExportConfig>> = Lazy::new(|| hash
"cv::dnn::DetectionModel" => ExportConfig::default(),
"cv::dnn::Model" => ExportConfig::default(),
"cv::dnn::Net" => ExportConfig::default(), // incorrectly marked as simple
+ "cv::dnn::TextDetectionModel_DB" => ExportConfig::default(), // incorrectly marked as simple
+ "cv::dnn::TextDetectionModel_EAST" => ExportConfig::default(), // incorrectly marked as simple
+ "cv::dnn::TextRecognitionModel" => ExportConfig::default(), // incorrectly marked as simple
"cv::linemod::Match" => ExportConfig::default(), // contains String
"cv::linemod::Template" => ExportConfig::default(), // contains String
"cv::linemod::QuantizedPyramid" => ExportConfig::default(), // missing export in 3.2
"cv::ocl::Device" => ExportConfig::default(),
+ "cv::tracking::TrackerCSRT::Params" => ExportConfig::default(), // contains String, so no Copy
+ "cv::TrackerGOTURN::Params" => ExportConfig::default(), // contains String, so no Copy
});
/// set of functions that should have unsafe in their declaration, element is Func.identifier()

MODIFY
binding-generator/src/writer/rust_native/mod.rs
binding-generator/src/writer/rust_native/mod.rs
@@ -21,7 +21,6 @@ use crate::{
Func,
GeneratorVisitor,
IteratorExt,
- main_module_from_path,
module_from_path,
settings,
StrExt,
@@ -123,7 +122,6 @@ impl<'tu> GeneratorVisitor<'tu> for RustNativeBindingWriter<'_> {
fn wants_file(&mut self, path: &Path) -> bool {
module_from_path(path).map_or(false, |m| m == self.module)
- || main_module_from_path(path).map_or(false, |m| m == self.module)
}
fn visit_module_comment(&mut self, comment: String) {

MODIFY
tests/mat.rs
tests/mat.rs
@@ -37,7 +37,6 @@ fn mat_create() -> Result<()> {
mat.release()?;
assert!(!mat.is_allocated());
assert_eq!(Size::new(0, 0), mat.size()?);
- assert_eq!(2, mat.dims());
Ok(())
}

MODIFY
tests/tracking.rs
tests/tracking.rs
#![cfg(feature = "contrib")]
-use opencv::{
- prelude::*,
- Result,
- tracking::TrackerSamplerPF_Params,
-};
-use opencv::core::Scalar;
-
-#[test]
-fn typed_mat() -> Result<()> {
- let mut params = TrackerSamplerPF_Params::default()?;
- assert_eq!(&[15., 15., 15., 15.], params.std().data_typed()?);
- let mat = Mat::new_rows_cols_with_default(1, 4, f64::typ(), Scalar::all(8.))?.try_into_typed::<f64>()?;
- let mat_src = mat.try_clone()?.try_into_typed::<f64>()?;
- params.set_std(mat);
- let mat = params.std();
- assert_eq!(mat.size()?, mat_src.size()?);
- assert_eq!(mat.data_typed()?, mat_src.data_typed()?);
- Ok(())
-}
+// use opencv::{
+// prelude::*,
+// Result,
+// tracking::TrackerSamplerPF_Params,
+// };
+// use opencv::core::Scalar;
+//
+// The TrackerSamplerPF_Params no longer exists since OpenCV 4.5.1 and there no other methods that
+// accept typed Mat's, so disable the test for now.
+// #[test]
+// fn typed_mat() -> Result<()> {
+// let mut params = TrackerSamplerPF_Params::default()?;
+// assert_eq!(&[15., 15., 15., 15.], params.std().data_typed()?);
+// let mat = Mat::new_rows_cols_with_default(1, 4, f64::typ(), Scalar::all(8.))?.try_into_typed::<f64>()?;
+// let mat_src = mat.try_clone()?.try_into_typed::<f64>()?;
+// params.set_std(mat);
+// let mat = params.std();
+// assert_eq!(mat.size()?, mat_src.size()?);
+// assert_eq!(mat.data_typed()?, mat_src.data_typed()?);
+// Ok(())
+// }

MODIFY
tests/vector.rs
tests/vector.rs
@@ -6,7 +6,6 @@ use opencv::{
DMatch,
Point2d,
Point2f,
- Point3i,
Scalar,
SparseMat_Hdr,
Vec4i,
@@ -23,12 +22,10 @@ use opencv::{
VectorOfMat,
VectorOfPoint2d,
VectorOfPoint2f,
- VectorOfPoint3i,
VectorOfString,
VectorOfu8,
VectorOfVec4i,
VectorOfVectorOfPoint2f,
- VectorOfVectorOfPoint3i,
}
};
@@ -163,36 +160,36 @@ fn simple() -> Result<()> {
#[test]
fn vector_of_vector_simple_struct() -> Result<()> {
#[inline(never)]
- fn make_vec() -> VectorOfVectorOfPoint3i {
- let mut outer = VectorOfVectorOfPoint3i::new();
+ fn make_vec() -> VectorOfVectorOfPoint2f {
+ let mut outer = VectorOfVectorOfPoint2f::new();
outer.push({
- let mut inner = VectorOfPoint3i::new();
- inner.push(Point3i::new(1, 1, 1));
- inner.push(Point3i::new(2, 2, 2));
- inner.push(Point3i::new(3, 3, 3));
+ let mut inner = VectorOfPoint2f::new();
+ inner.push(Point2f::new(1., 1.));
+ inner.push(Point2f::new(2., 2.));
+ inner.push(Point2f::new(3., 3.));
inner
});
outer.push({
- let mut inner = VectorOfPoint3i::new();
- inner.push(Point3i::new(4, 4, 4));
- inner.push(Point3i::new(5, 5, 5));
- inner.push(Point3i::new(6, 6, 6));
+ let mut inner = VectorOfPoint2f::new();
+ inner.push(Point2f::new(4., 4.));
+ inner.push(Point2f::new(5., 5.));
+ inner.push(Point2f::new(6., 6.));
inner
});
outer.push({
- let mut inner = VectorOfPoint3i::new();
- inner.push(Point3i::new(7, 7, 7));
- inner.push(Point3i::new(8, 8, 8));
- inner.push(Point3i::new(9, 9, 9));
+ let mut inner = VectorOfPoint2f::new();
+ inner.push(Point2f::new(7., 7.));
+ inner.push(Point2f::new(8., 8.));
+ inner.push(Point2f::new(9., 9.));
inner
});
outer
}
let mut outer = make_vec();
- assert_eq!(6, outer.get(1)?.get(2)?.x);
+ assert_eq!(6., outer.get(1)?.get(2)?.x);
outer.remove(1)?;
- assert_eq!(9, outer.get(1)?.get(2)?.x);
+ assert_eq!(9., outer.get(1)?.get(2)?.x);
Ok(())
}
@@ -493,12 +490,13 @@ fn to_vec() -> Result<()> {
assert_eq!(vec_new, src_vec);
}
{
- let src_vec = vec![];
- let vec = VectorOfVec4i::new();
+ let src_vec = vec![Vec4i::from([1, 2, 3, 4])];
+ let mut vec = VectorOfVec4i::new();
+ vec.push(Vec4i::from([1, 2, 3, 4]));
assert_eq!(vec.to_vec(), src_vec);
assert_eq!(Vec::from(vec), src_vec);
let vec_new: Vec<Vec4i> = VectorOfVec4i::new().into();
- assert_eq!(vec_new, src_vec);
+ assert_eq!(vec_new, vec![]);
}
{
let mut vec = VectorOfMat::new();

Support OpenCV 4.5.1