Skip to content

Instantly share code, notes, and snippets.

@rajeshpachaikani
Created November 14, 2021 11:14
Show Gist options
  • Save rajeshpachaikani/949652fe9fac4b246d68fd3f301019df to your computer and use it in GitHub Desktop.
Save rajeshpachaikani/949652fe9fac4b246d68fd3f301019df to your computer and use it in GitHub Desktop.
Rust opencv demo
/*
Author: Rajesh Pachaikani
Contact: [email protected]
*/
use opencv::{highgui, prelude::*, videoio, Result};
fn main() -> Result<()> {
let mut cam = videoio::VideoCapture::new(0, videoio::CAP_ANY)?;
highgui::named_window("window", highgui::WINDOW_FULLSCREEN)?;
let mut frame = Mat::default();
loop{
cam.read(&mut frame)?;
highgui::imshow("window", &frame)?;
let key = highgui::wait_key(1)?;
if key == 113{
break;
}
}
Ok(())
}
@MuneebHoda
Copy link

failed to run custom build command for opencv v0.78.0
-- Error while running this code

@vanvuongngo
Copy link

Issues 🐛

If you encountered an error similar to what is shown below:

warning: could not execute `llvm-config` one or more times, if the LLVM_CONFIG_PATH environment variable is set to a full path to valid `llvm-config` executable it will be used to try to find an instance of `libclang` on your system: "couldn't execute `llvm-config --prefix` (path=llvm-config) (error: No such file or directory (os error 2))"

error: failed to run custom build command for `clang-sys v1.4.0`

You can resolve this issue by running the command below:

sudo apt-get install clang libclang-dev

This rust tutorial is mindblowing. Thanks a lot.
If you encountered a libclang.dylib' (no such file) error on macos.
Then install xcode and opencv

brew install opencv

and link the lib

sudo ln -s /Library/Developer/CommandLineTools/usr/lib/libclang.dylib /usr/local/lib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment