twistedfall / opencv-rust

Rust bindings for OpenCV 3 & 4
MIT License
1.92k stars 149 forks source link

Build Failure on OpenCV 4.8 #472

Closed noxowl closed 1 year ago

noxowl commented 1 year ago

I really appreciate your contribution.

Currently, building OpenCV 4.8 with the latest version results in a error.

error[E0119]:` conflicting implementations of trait `Debug` for type `RotatedRect

Since Homebrew only provides the latest version of OpenCV, I have to downgrade by compiling OpenCV 4.7 myself.

  1. Operating system: MacOS Ventura 13.4.1(22F82)
  2. The way you installed OpenCV: package, official binary distribution, manual compilation, etc.: brew install opencv
  3. OpenCV version: 4.8.0
  4. rustc version (rustc --version): rustc 1.70.0 (90c541806 2023-05-31)
  5. Attach the full output of the following command from your project directory:

full log: https://gist.github.com/noxowl/a24c52dd108a5b2afa02e7716b0f24ed

[opencv 0.82.1] cargo:rustc-link-lib=opencv_core
warning: In file included from /tmp/build/cv-project/debug/build/opencv-b13b4b53572b4da2/out/saliency.cpp:2:
warning: In file included from /usr/local/opt/opencv/include/opencv4/opencv2/saliency.hpp:46:
warning: /usr/local/opt/opencv/include/opencv4/opencv2/saliency/saliencySpecializedClasses.hpp:311:16: warning: 'cv::saliency::ObjectnessBING::read' hides overloaded virtual function [-Woverloaded-virtual]
warning:   CV_WRAP void read();
warning:                ^
warning: /usr/local/opt/opencv/include/opencv4/opencv2/core.hpp:3174:26: note: hidden overloaded virtual function 'cv::Algorithm::read' declared here: different number of parameters (1 vs 0)
warning:     CV_WRAP virtual void read(const FileNode& fn) { CV_UNUSED(fn); }
warning:                          ^
warning: In file included from /tmp/build/cv-project/debug/build/opencv-b13b4b53572b4da2/out/saliency.cpp:2:
warning: In file included from /usr/local/opt/opencv/include/opencv4/opencv2/saliency.hpp:46:
warning: /usr/local/opt/opencv/include/opencv4/opencv2/saliency/saliencySpecializedClasses.hpp:312:16: warning: 'cv::saliency::ObjectnessBING::write' hides overloaded virtual function [-Woverloaded-virtual]
warning:   CV_WRAP void write() const;
warning:                ^
warning: /usr/local/opt/opencv/include/opencv4/opencv2/core.hpp:3161:26: note: hidden overloaded virtual function 'cv::Algorithm::write' declared here: different number of parameters (1 vs 0)
warning:     CV_WRAP virtual void write(FileStorage& fs) const { CV_UNUSED(fs); }
warning:                          ^
warning: 2 warnings generated.
     Running `CARGO=/Users/noxowl/.rustup/toolchains/stable-x86_64-apple-darwin/bin/cargo CARGO_CRATE_NAME=opencv CARGO_MANIFEST_DIR=/Users/noxowl/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.82.1 CARGO_PKG_AUTHORS='Pro <twisted.fall@gmail.com>:Mathieu Poumeyrol <kali@zoy.org>' CARGO_PKG_DESCRIPTION='Rust bindings for OpenCV' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE=MIT CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=opencv CARGO_PKG_README=README.md CARGO_PKG_REPOSITORY='https://github.com/twistedfall/opencv-rust' CARGO_PKG_RUST_VERSION=1.59 CARGO_PKG_VERSION=0.82.1 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=82 CARGO_PKG_VERSION_PATCH=1 CARGO_PKG_VERSION_PRE='' DYLD_FALLBACK_LIBRARY_PATH='/tmp/build/cv-project/debug/deps:/Users/noxowl/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/noxowl/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/noxowl/lib:/usr/local/lib:/usr/lib' OUT_DIR=/tmp/build/cv-project/debug/build/opencv-b13b4b53572b4da2/out rustc --crate-name opencv --edition=2021 /Users/noxowl/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.82.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=163 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="alphamat"' --cfg 'feature="aruco"' --cfg 'feature="aruco_detector"' --cfg 'feature="barcode"' --cfg 'feature="bgsegm"' --cfg 'feature="bioinspired"' --cfg 'feature="calib3d"' --cfg 'feature="ccalib"' --cfg 'feature="cudaarithm"' --cfg 'feature="cudabgsegm"' --cfg 'feature="cudacodec"' --cfg 'feature="cudafeatures2d"' --cfg 'feature="cudafilters"' --cfg 'feature="cudaimgproc"' --cfg 'feature="cudaobjdetect"' --cfg 'feature="cudaoptflow"' --cfg 'feature="cudastereo"' --cfg 'feature="cudawarping"' --cfg 'feature="cvv"' --cfg 'feature="default"' --cfg 'feature="dnn"' --cfg 'feature="dnn_superres"' --cfg 'feature="dpm"' --cfg 'feature="face"' --cfg 'feature="features2d"' --cfg 'feature="flann"' --cfg 'feature="freetype"' --cfg 'feature="fuzzy"' --cfg 'feature="gapi"' --cfg 'feature="hdf"' --cfg 'feature="hfs"' --cfg 'feature="highgui"' --cfg 'feature="img_hash"' --cfg 'feature="imgcodecs"' --cfg 'feature="imgproc"' --cfg 'feature="intensity_transform"' --cfg 'feature="line_descriptor"' --cfg 'feature="mcc"' --cfg 'feature="ml"' --cfg 'feature="objdetect"' --cfg 'feature="optflow"' --cfg 'feature="ovis"' --cfg 'feature="phase_unwrapping"' --cfg 'feature="photo"' --cfg 'feature="plot"' --cfg 'feature="quality"' --cfg 'feature="rapid"' --cfg 'feature="rgbd"' --cfg 'feature="saliency"' --cfg 'feature="sfm"' --cfg 'feature="shape"' --cfg 'feature="stereo"' --cfg 'feature="stitching"' --cfg 'feature="structured_light"' --cfg 'feature="superres"' --cfg 'feature="surface_matching"' --cfg 'feature="text"' --cfg 'feature="tracking"' --cfg 'feature="video"' --cfg 'feature="videoio"' --cfg 'feature="videostab"' --cfg 'feature="viz"' --cfg 'feature="wechat_qrcode"' --cfg 'feature="xfeatures2d"' --cfg 'feature="ximgproc"' --cfg 'feature="xobjdetect"' --cfg 'feature="xphoto"' -C metadata=61c56095358fa708 -C extra-filename=-61c56095358fa708 --out-dir /tmp/build/cv-project/debug/deps -L dependency=/tmp/build/cv-project/debug/deps --extern libc=/tmp/build/cv-project/debug/deps/liblibc-0d1935ecb7a8d909.rmeta --extern num_traits=/tmp/build/cv-project/debug/deps/libnum_traits-87bb33f683e775d4.rmeta --extern once_cell=/tmp/build/cv-project/debug/deps/libonce_cell-970e6e8921b00403.rmeta --cap-lints warn -L native=/tmp/build/cv-project/debug/build/opencv-b13b4b53572b4da2/out -L /usr/local/opt/opencv/lib -L framework=/usr/local/opt/opencv/lib -l static=ocvrs -l c++ -l opencv_gapi -l opencv_stitching -l opencv_alphamat -l opencv_aruco -l opencv_bgsegm -l opencv_bioinspired -l opencv_ccalib -l opencv_dnn_objdetect -l opencv_dnn_superres -l opencv_dpm -l opencv_face -l opencv_freetype -l opencv_fuzzy -l opencv_hfs -l opencv_img_hash -l opencv_intensity_transform -l opencv_line_descriptor -l opencv_mcc -l opencv_quality -l opencv_rapid -l opencv_reg -l opencv_rgbd -l opencv_saliency -l opencv_sfm -l opencv_stereo -l opencv_structured_light -l opencv_phase_unwrapping -l opencv_superres -l opencv_optflow -l opencv_surface_matching -l opencv_tracking -l opencv_highgui -l opencv_datasets -l opencv_text -l opencv_plot -l opencv_videostab -l opencv_videoio -l opencv_viz -l opencv_wechat_qrcode -l opencv_xfeatures2d -l opencv_shape -l opencv_ml -l opencv_ximgproc -l opencv_video -l opencv_xobjdetect -l opencv_objdetect -l opencv_calib3d -l opencv_imgcodecs -l opencv_features2d -l opencv_dnn -l opencv_flann -l opencv_xphoto -l opencv_photo -l opencv_imgproc -l opencv_core --cfg ocvrs_opencv_branch_4 --cfg ocvrs_has_module_alphamat --cfg ocvrs_has_module_aruco --cfg ocvrs_has_module_bgsegm --cfg ocvrs_has_module_bioinspired --cfg ocvrs_has_module_calib3d --cfg ocvrs_has_module_ccalib --cfg ocvrs_has_module_core --cfg ocvrs_has_module_dnn --cfg ocvrs_has_module_dnn_superres --cfg ocvrs_has_module_dpm --cfg ocvrs_has_module_face --cfg ocvrs_has_module_features2d --cfg ocvrs_has_module_flann --cfg ocvrs_has_module_freetype --cfg ocvrs_has_module_fuzzy --cfg ocvrs_has_module_gapi --cfg ocvrs_has_module_hfs --cfg ocvrs_has_module_highgui --cfg ocvrs_has_module_img_hash --cfg ocvrs_has_module_imgcodecs --cfg ocvrs_has_module_imgproc --cfg ocvrs_has_module_intensity_transform --cfg ocvrs_has_module_line_descriptor --cfg ocvrs_has_module_mcc --cfg ocvrs_has_module_ml --cfg ocvrs_has_module_objdetect --cfg ocvrs_has_module_optflow --cfg ocvrs_has_module_phase_unwrapping --cfg ocvrs_has_module_photo --cfg ocvrs_has_module_plot --cfg ocvrs_has_module_quality --cfg ocvrs_has_module_rapid --cfg ocvrs_has_module_rgbd --cfg ocvrs_has_module_saliency --cfg ocvrs_has_module_sfm --cfg ocvrs_has_module_shape --cfg ocvrs_has_module_stereo --cfg ocvrs_has_module_stitching --cfg ocvrs_has_module_structured_light --cfg ocvrs_has_module_superres --cfg ocvrs_has_module_surface_matching --cfg ocvrs_has_module_text --cfg ocvrs_has_module_tracking --cfg ocvrs_has_module_video --cfg ocvrs_has_module_videoio --cfg ocvrs_has_module_videostab --cfg ocvrs_has_module_viz --cfg ocvrs_has_module_wechat_qrcode --cfg ocvrs_has_module_xfeatures2d --cfg ocvrs_has_module_ximgproc --cfg ocvrs_has_module_xobjdetect --cfg ocvrs_has_module_xphoto`
warning: ambiguous glob re-exports
   --> /tmp/build/cv-project/debug/build/opencv-b13b4b53572b4da2/out/opencv/hub.rs:176:10
    |
176 |     pub use super::rapid::prelude::*;
    |             ^^^^^^^^^^^^^^^^^^^^^^^^ the name `TrackerTraitConst` in the type namespace is first re-exported here
...
200 |     pub use super::video::prelude::*;
    |             ------------------------ but the name `TrackerTraitConst` in the type namespace is also re-exported here
    |
    = note: `#[warn(ambiguous_glob_reexports)]` on by default

warning: ambiguous glob re-exports
   --> /tmp/build/cv-project/debug/build/opencv-b13b4b53572b4da2/out/opencv/hub.rs:176:10
    |
176 |     pub use super::rapid::prelude::*;
    |             ^^^^^^^^^^^^^^^^^^^^^^^^ the name `TrackerTrait` in the type namespace is first re-exported here
...
200 |     pub use super::video::prelude::*;
    |             ------------------------ but the name `TrackerTrait` in the type namespace is also re-exported here

error[E0119]: conflicting implementations of trait `Debug` for type `RotatedRect`
     --> /tmp/build/cv-project/debug/build/opencv-b13b4b53572b4da2/out/opencv/core.rs:17920:24
      |
17920 |     #[derive(Copy, Clone, Debug, PartialEq)]
      |                           ^^^^^ conflicting implementation for `RotatedRect`
      |
     ::: /Users/noxowl/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.82.1/src/manual/core/rect.rs:277:1
      |
277   | impl fmt::Debug for RotatedRect {
      | ------------------------------- first implementation here
      |
      = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0119`.
warning: `opencv` (lib) generated 2 warnings
The following warnings were emitted during compilation:

warning: In file included from /tmp/build/cv-project/debug/build/opencv-b13b4b53572b4da2/out/saliency.cpp:2:
warning: In file included from /usr/local/opt/opencv/include/opencv4/opencv2/saliency.hpp:46:
warning: /usr/local/opt/opencv/include/opencv4/opencv2/saliency/saliencySpecializedClasses.hpp:311:16: warning: 'cv::saliency::ObjectnessBING::read' hides overloaded virtual function [-Woverloaded-virtual]
warning:   CV_WRAP void read();
warning:                ^
warning: /usr/local/opt/opencv/include/opencv4/opencv2/core.hpp:3174:26: note: hidden overloaded virtual function 'cv::Algorithm::read' declared here: different number of parameters (1 vs 0)
warning:     CV_WRAP virtual void read(const FileNode& fn) { CV_UNUSED(fn); }
warning:                          ^
warning: In file included from /tmp/build/cv-project/debug/build/opencv-b13b4b53572b4da2/out/saliency.cpp:2:
warning: In file included from /usr/local/opt/opencv/include/opencv4/opencv2/saliency.hpp:46:
warning: /usr/local/opt/opencv/include/opencv4/opencv2/saliency/saliencySpecializedClasses.hpp:312:16: warning: 'cv::saliency::ObjectnessBING::write' hides overloaded virtual function [-Woverloaded-virtual]
warning:   CV_WRAP void write() const;
warning:                ^
warning: /usr/local/opt/opencv/include/opencv4/opencv2/core.hpp:3161:26: note: hidden overloaded virtual function 'cv::Algorithm::write' declared here: different number of parameters (1 vs 0)
warning:     CV_WRAP virtual void write(FileStorage& fs) const { CV_UNUSED(fs); }
warning:                          ^
warning: 2 warnings generated.

error: could not compile `opencv` (lib) due to previous error; 2 warnings emitted

Caused by:
  process didn't exit successfully: `CARGO=/Users/noxowl/.rustup/toolchains/stable-x86_64-apple-darwin/bin/cargo CARGO_CRATE_NAME=opencv CARGO_MANIFEST_DIR=/Users/noxowl/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.82.1 CARGO_PKG_AUTHORS='Pro <twisted.fall@gmail.com>:Mathieu Poumeyrol <kali@zoy.org>' CARGO_PKG_DESCRIPTION='Rust bindings for OpenCV' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE=MIT CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=opencv CARGO_PKG_README=README.md CARGO_PKG_REPOSITORY='https://github.com/twistedfall/opencv-rust' CARGO_PKG_RUST_VERSION=1.59 CARGO_PKG_VERSION=0.82.1 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=82 CARGO_PKG_VERSION_PATCH=1 CARGO_PKG_VERSION_PRE='' DYLD_FALLBACK_LIBRARY_PATH='/tmp/build/cv-project/debug/deps:/Users/noxowl/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/noxowl/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/noxowl/lib:/usr/local/lib:/usr/lib' OUT_DIR=/tmp/build/cv-project/debug/build/opencv-b13b4b53572b4da2/out rustc --crate-name opencv --edition=2021 /Users/noxowl/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.82.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=163 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="alphamat"' --cfg 'feature="aruco"' --cfg 'feature="aruco_detector"' --cfg 'feature="barcode"' --cfg 'feature="bgsegm"' --cfg 'feature="bioinspired"' --cfg 'feature="calib3d"' --cfg 'feature="ccalib"' --cfg 'feature="cudaarithm"' --cfg 'feature="cudabgsegm"' --cfg 'feature="cudacodec"' --cfg 'feature="cudafeatures2d"' --cfg 'feature="cudafilters"' --cfg 'feature="cudaimgproc"' --cfg 'feature="cudaobjdetect"' --cfg 'feature="cudaoptflow"' --cfg 'feature="cudastereo"' --cfg 'feature="cudawarping"' --cfg 'feature="cvv"' --cfg 'feature="default"' --cfg 'feature="dnn"' --cfg 'feature="dnn_superres"' --cfg 'feature="dpm"' --cfg 'feature="face"' --cfg 'feature="features2d"' --cfg 'feature="flann"' --cfg 'feature="freetype"' --cfg 'feature="fuzzy"' --cfg 'feature="gapi"' --cfg 'feature="hdf"' --cfg 'feature="hfs"' --cfg 'feature="highgui"' --cfg 'feature="img_hash"' --cfg 'feature="imgcodecs"' --cfg 'feature="imgproc"' --cfg 'feature="intensity_transform"' --cfg 'feature="line_descriptor"' --cfg 'feature="mcc"' --cfg 'feature="ml"' --cfg 'feature="objdetect"' --cfg 'feature="optflow"' --cfg 'feature="ovis"' --cfg 'feature="phase_unwrapping"' --cfg 'feature="photo"' --cfg 'feature="plot"' --cfg 'feature="quality"' --cfg 'feature="rapid"' --cfg 'feature="rgbd"' --cfg 'feature="saliency"' --cfg 'feature="sfm"' --cfg 'feature="shape"' --cfg 'feature="stereo"' --cfg 'feature="stitching"' --cfg 'feature="structured_light"' --cfg 'feature="superres"' --cfg 'feature="surface_matching"' --cfg 'feature="text"' --cfg 'feature="tracking"' --cfg 'feature="video"' --cfg 'feature="videoio"' --cfg 'feature="videostab"' --cfg 'feature="viz"' --cfg 'feature="wechat_qrcode"' --cfg 'feature="xfeatures2d"' --cfg 'feature="ximgproc"' --cfg 'feature="xobjdetect"' --cfg 'feature="xphoto"' -C metadata=61c56095358fa708 -C extra-filename=-61c56095358fa708 --out-dir /tmp/build/cv-project/debug/deps -L dependency=/tmp/build/cv-project/debug/deps --extern libc=/tmp/build/cv-project/debug/deps/liblibc-0d1935ecb7a8d909.rmeta --extern num_traits=/tmp/build/cv-project/debug/deps/libnum_traits-87bb33f683e775d4.rmeta --extern once_cell=/tmp/build/cv-project/debug/deps/libonce_cell-970e6e8921b00403.rmeta --cap-lints warn -L native=/tmp/build/cv-project/debug/build/opencv-b13b4b53572b4da2/out -L /usr/local/opt/opencv/lib -L framework=/usr/local/opt/opencv/lib -l static=ocvrs -l c++ -l opencv_gapi -l opencv_stitching -l opencv_alphamat -l opencv_aruco -l opencv_bgsegm -l opencv_bioinspired -l opencv_ccalib -l opencv_dnn_objdetect -l opencv_dnn_superres -l opencv_dpm -l opencv_face -l opencv_freetype -l opencv_fuzzy -l opencv_hfs -l opencv_img_hash -l opencv_intensity_transform -l opencv_line_descriptor -l opencv_mcc -l opencv_quality -l opencv_rapid -l opencv_reg -l opencv_rgbd -l opencv_saliency -l opencv_sfm -l opencv_stereo -l opencv_structured_light -l opencv_phase_unwrapping -l opencv_superres -l opencv_optflow -l opencv_surface_matching -l opencv_tracking -l opencv_highgui -l opencv_datasets -l opencv_text -l opencv_plot -l opencv_videostab -l opencv_videoio -l opencv_viz -l opencv_wechat_qrcode -l opencv_xfeatures2d -l opencv_shape -l opencv_ml -l opencv_ximgproc -l opencv_video -l opencv_xobjdetect -l opencv_objdetect -l opencv_calib3d -l opencv_imgcodecs -l opencv_features2d -l opencv_dnn -l opencv_flann -l opencv_xphoto -l opencv_photo -l opencv_imgproc -l opencv_core --cfg ocvrs_opencv_branch_4 --cfg ocvrs_has_module_alphamat --cfg ocvrs_has_module_aruco --cfg ocvrs_has_module_bgsegm --cfg ocvrs_has_module_bioinspired --cfg ocvrs_has_module_calib3d --cfg ocvrs_has_module_ccalib --cfg ocvrs_has_module_core --cfg ocvrs_has_module_dnn --cfg ocvrs_has_module_dnn_superres --cfg ocvrs_has_module_dpm --cfg ocvrs_has_module_face --cfg ocvrs_has_module_features2d --cfg ocvrs_has_module_flann --cfg ocvrs_has_module_freetype --cfg ocvrs_has_module_fuzzy --cfg ocvrs_has_module_gapi --cfg ocvrs_has_module_hfs --cfg ocvrs_has_module_highgui --cfg ocvrs_has_module_img_hash --cfg ocvrs_has_module_imgcodecs --cfg ocvrs_has_module_imgproc --cfg ocvrs_has_module_intensity_transform --cfg ocvrs_has_module_line_descriptor --cfg ocvrs_has_module_mcc --cfg ocvrs_has_module_ml --cfg ocvrs_has_module_objdetect --cfg ocvrs_has_module_optflow --cfg ocvrs_has_module_phase_unwrapping --cfg ocvrs_has_module_photo --cfg ocvrs_has_module_plot --cfg ocvrs_has_module_quality --cfg ocvrs_has_module_rapid --cfg ocvrs_has_module_rgbd --cfg ocvrs_has_module_saliency --cfg ocvrs_has_module_sfm --cfg ocvrs_has_module_shape --cfg ocvrs_has_module_stereo --cfg ocvrs_has_module_stitching --cfg ocvrs_has_module_structured_light --cfg ocvrs_has_module_superres --cfg ocvrs_has_module_surface_matching --cfg ocvrs_has_module_text --cfg ocvrs_has_module_tracking --cfg ocvrs_has_module_video --cfg ocvrs_has_module_videoio --cfg ocvrs_has_module_videostab --cfg ocvrs_has_module_viz --cfg ocvrs_has_module_wechat_qrcode --cfg ocvrs_has_module_xfeatures2d --cfg ocvrs_has_module_ximgproc --cfg ocvrs_has_module_xobjdetect --cfg ocvrs_has_module_xphoto` (exit status: 1)
twistedfall commented 1 year ago

Yep, I'm aware of this and working to fix it, thanks!

xvolks commented 1 year ago

Hello, is there any temporary workaround (except recompiling 4.7 version)?

twistedfall commented 1 year ago

For now, the best option is to use OpenCV 4.7, but the fix will be released shortly!

proski commented 1 year ago

@xvolks The workaround I'm using is to comment out the Debug trait implementation for RotatedRect as there is another derived implementation of that trait.

diff --git a/src/manual/core/rect.rs b/src/manual/core/rect.rs
index ae8b7ac2..14bc5fc1 100644
--- a/src/manual/core/rect.rs
+++ b/src/manual/core/rect.rs
@@ -274,6 +274,7 @@ where
        }
 }

+/*
 impl fmt::Debug for RotatedRect {
        fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                f.debug_struct("RotatedRect")
@@ -283,6 +284,7 @@ impl fmt::Debug for RotatedRect {
                        .finish()
        }
 }
+*/

 #[test]
 fn test_partial() {
xvolks commented 1 year ago

After applying @proski workaround, and for some reason I now have the error : error[E0277]: KeyPoint doesn't implement Debug On : pub kp_model: Vector<KeyPoint>,

This was not an issue before.

twistedfall commented 1 year ago

@xvolks @proski @noxowl Can you please try the alpha branch, the compatibility with OpenCV 4.8 should be fixed there

xvolks commented 1 year ago

@twistedfall It seems that the Debug issue is fixed, but my project stil does not compile with following errors:

error[E0277]: `KeyPoint` doesn't implement `Debug`
error[E0277]: the trait bound `Vector<KeyPoint>: VectorExternCopyNonBool<KeyPoint>` is not satisfied
twistedfall commented 1 year ago

Thanks for the report, I think I know how to fix it

noxowl commented 1 year ago

@twistedfall Mine seems to be fine. Here is full log: https://gist.github.com/noxowl/579f25cc39d650e33fbc5271453bc261 (cargo.toml -> opencv = { git = "https://github.com/twistedfall/opencv-rust.git", branch = "alpha" }) (/usr/local/opt/opencv -> ../Cellar/opencv/4.8.0_1)

proski commented 1 year ago

I have good results with the alpha branch and following systems:

twistedfall commented 1 year ago

The OpenCV 4.8 support is released in v0.83, additionally the default Debug implementations should be available for all classes (that should fix the @xvolks issue)

xvolks commented 1 year ago

Thank you @twistedfall, most of the compile errors are gone.

I still have: the trait boundVector: VectorExternCopyNonBoolis not satisfied

at this line

let kp_model_slice = self.model.kp_model.as_slice();

With :

123 |             let kp_model_slice = self.model.kp_model.as_slice();
    |                                                      ^^^^^^^^ the trait `VectorExternCopyNonBool<KeyPoint>` is not implemented for `Vector<KeyPoint>`

Edit: to stop using as_slice and as a workaround I replaced :

            let kp_model_slice = self.model.kp_model.as_slice();
            let kp_slice = kp.as_slice();
            for m in good_matches {
                let point: KeyPoint = kp_model_slice[m.query_idx as usize];
                src_points.push(point.pt());
                let point: KeyPoint = kp_slice[m.train_idx as usize];
                dst_points.push(point.pt());
            }

by

            let kpm = &self.model.kp_model;

            for m in good_matches {
                let Ok(point1) = kpm.get(m.query_idx as usize) else { continue; };
                let Ok(point2) = kp.get(m.train_idx as usize) else { continue; };
                src_points.push(point1.pt());
                dst_points.push(point2.pt());
            }
twistedfall commented 1 year ago

Yeah, that's the correct way to deal with this issue. Recently KeyPoint stopped being a simple struct because it has descendants so its vector lost the as_slice() method.

On the side note technically the replacement code is not equivalent. Previously it would panic on the out of bounds index and in the new code it will continue looping.