tek5030 in Rust

Currently, this is mostly an example of how to get Rust's opencv crate (which is bindings to OpenCV) to link to Conan's OpenCV.

install dependencies

I use Conan to install the OpenCV and other system dependencies. Additionally, to create the Cargo build script which performs linking, I parse the conanbuildinfo.txt to tell the opencv crate about link information. Shortcuts via just are available. Install instructions are available in that repo, but the simplest way is to cargo install just. I use alias j=just.

j install # uses conan to install dependencies to the build directory
j apply   # parses conanbuildinfo.txt and sets environments variable
          # within the .cargo/config.toml env section

details

Two command line utilities within the manage_opencv crate are used to apply the Conan-generated OpenCV link targets to Cargo's environment:

  • get_conan_libs parses conanbuildinfo.txt and outputs TOML-compatible lists to standard output.
  • apply_to_env reads such TOML-input and applies them to the env section of a project-specific Cargo configuration.

The provided justfile glues this together.

With the OPENCV_* environment variables now applied to .cargo/config.toml, Cargo will now build the opencv crate using Conan's OpenCV version.

lab_00-opencv-higui

Read camera input, output in a window. Do everything with the opencv library.

lab_00-native-egui

Read camera input, do processing, show in a window. Do everything with Rust-native libraries (imageproc, image, cv). Show in the Rust-native GUI egui.

lab_00-opencv-egui

highgui is crappy and native Rust CV is super slow, so this is the "best of both worlds". egui for GUI and OpenCV for image processing.