Make sure that casts to Ptr<Feature2D> are also generated (fixes
MODIFY
binding-generator/src/settings.rs
binding-generator/src/settings.rs
@@ -1015,6 +1015,16 @@ pub static GENERATOR_MODULE_TWEAKS: Lazy<HashMap<&str, ModuleTweak>> = Lazy::new
],
..Default::default()
},
+ "features2d" => ModuleTweak {
+ includes: vec![
+ "features2d.hpp",
+ ],
+ // type used in other modules, thus needs casting (https://github.com/twistedfall/opencv-rust/issues/218)
+ generate_types: vec![
+ "cv::Ptr<cv::Feature2D>",
+ ],
+ ..Default::default()
+ },
"imgproc" => ModuleTweak {
generate_types: vec![
"std::vector<cv::Vec4i>",

MODIFY
tests/videostab.rs
tests/videostab.rs
use opencv::{
core::Ptr,
+ features2d::FastFeatureDetector,
+ prelude::*,
Result,
videostab::{KeypointBasedMotionEstimator, MotionEstimatorRansacL2, MotionModel},
};
+#[cfg(feature = "opencv-4")]
+use opencv::features2d::FastFeatureDetector_DetectorType;
#[test]
fn motion_estimator() -> Result<()> {
// just test the Ptr creation, conversion to base class and linking for now
let est = MotionEstimatorRansacL2::new(MotionModel::MM_AFFINE).unwrap();
let est_ptr = Ptr::new(est);
- let _estimator = KeypointBasedMotionEstimator::new(est_ptr.into()).unwrap();
+ let mut estimator = KeypointBasedMotionEstimator::new(est_ptr.into()).unwrap();
+ #[cfg(feature = "opencv-4")]
+ let detector_ptr = <dyn FastFeatureDetector>::create(10, true, FastFeatureDetector_DetectorType::TYPE_9_16).unwrap();
+ #[cfg(not(feature = "opencv-4"))]
+ let detector_ptr = <dyn FastFeatureDetector>::create(10, true, 2).unwrap();
+ estimator.set_detector(detector_ptr.into()).unwrap();
Ok(())
}

Make sure that casts to Ptr<Feature2D> are also generated (fixes #218)