Installing OpenCv

Hello everyone,

I discovered about rust a few days ago and am really excited about using it for image processing. I looked into the rust book for a few chapters, wrote a few simple programs, learnt about the basic rust syntax and also the awesome rust compiler & cargo package manager.

Question, I tried installing opencv from crates with opencv = "0.34.0" into Cargo.toml, but the opencv installation fails with the error

error: failed to run custom build command for `opencv v0.34.0`

How do I resolve this?

Other questions, is there any other crate that I can use to get raw camera streams (cause all opencv does is call c++ api internally, hence want to do it at rust level if it exists)

Hello, do you have the library installed on your system? I mean, can you compile C ++ samples?

Hey, thanks for the reply,

I am able to run c++ examples by providing opencv via the command line since I built it myself, something like this, `g++ detect-camera.cpp pkg-config --cflags --libs opencv

Thank you.

Maybe you don't have the appropriate version of the library. I have version 4.3.0 and it works fine from Rust

1 Like

Hi, please file a bug report at https://github.com/twistedfall/opencv-rust/issues and provide some information about your environment and the output of cargo build -vv. It's difficult to say what exactly is failing without it.

But just to make a guess, since you built the OpenCV yourself you most probably need to specify the pkg-config files location via PKG_CONFIG_PATH environment variable (see https://github.com/twistedfall/opencv-rust/blob/master/README.md#environment-variables)

2 Likes

After spending some time I figured out that OpenCv wasn't properly installed on my machine (The environment variables weren't properly set to be exact), so I had to rebuild opencv from source with pkg-config generation enabled, then link the opencv4.pc file to PKG_CONFIG_PATH and the installation went through successfully.

Thanks for all the help :slight_smile:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.