twistedfall / opencv-rust

Rust bindings for OpenCV 3 & 4
MIT License
2k stars 160 forks source link

Unable to build example gapi_api_example.rs #440

Closed hansg60 closed 1 year ago

hansg60 commented 1 year ago

Tried to build gapi_api_example.rs and build could not find gapi mod.

  1. OS: Ubuntu 22.10
  2. added opencv = "0.77.0" in Cargo.toml
  3. rustc --version rustc 1.67.1 (d5a82bbd2 2023-02-07)
  4. attached full output from RUST_BACKTRACE=full cargo build -vv

Short version here:

error[E0432]: unresolved import opencv::gapi --> src/main.rs:4:13 | 4 | use opencv::gapi::GMat; | ^^^^ could not find gapi in opencv

error[E0432]: unresolved import opencv::gapi --> src/main.rs:8:14 | 8 | use opencv::{gapi, highgui, Result}; | ^^^^ no gapi in the root

For more information about this error, try rustc --explain E0432. error: could not compile vision due to 2 previous errors

buildoutput.txt

twistedfall commented 1 year ago

I would guess that your OpenCV installation doesn't enable gapi module. From my experience the pre-built OpenCV distributions rarely do so you'll need to built your own and make sure to enable gapi.

hansg60 commented 1 year ago

I would guess that your OpenCV installation doesn't enable gapi module. From my experience the pre-built OpenCV distributions rarely do so you'll need to built your own and make sure to enable gapi.

Thanks, I think that helped but now I'm running into a new build error

Compiling opencv v0.77.0 error[E0412]: cannot find type FunctionParams in module core --> /home/hans/rust/vision/target/debug/build/opencv-7dbf144e6a8a1700/out/opencv/core.rs:7873:123 | 7873 | ...dst: &mut dyn core::ToOutputArray, params: &core::FunctionParams) -> Result { | ^^^^^^^^^^^^^^ not found in core

For more information about this error, try rustc --explain E0412. error: could not compile opencv due to previous error

twistedfall commented 1 year ago

Please use a released version of OpenCV (e.g. 4.7.0) and not master or the tip of 4.x branch

hansg60 commented 1 year ago

Please use a released version of OpenCV (e.g. 4.7.0) and not master or the tip of 4.x branch

Thanks for your help. That was it. I thought I had downloaded the source for 4.7.0, but it was the latest from the 4.x branch.

twistedfall commented 1 year ago

BTW, the latest 0.78.0 release contains the fix for the missing FunctionParams on master.