Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.

An example and setup guide on how to get ort and opencv-rust working together. I've tested this on both Linux and Windows.

License

Notifications You must be signed in to change notification settings

TDiblik/rust-ort-opencv-yolov8-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Showcase

Showcase gif

Why?

At the time of writing, 12.04.2024 (dd.MM.yyyy), it's kinda hard to configure ort and opencv-rust inside one Rust project. This repo serves as a guide/starter to save you precious time debugging! There is even an issue saying that this is impossible lol.

Setup

First of all, you need to download and compile opencv. At the time of writing, the version 4.9.0 is the latest stable.

Once you're done with that, you need to add the following to you system path (on Linux, add to $PATH Linux's equivalents)

C:\Program Files\opencv-4.9.0\build\x64\vc16\lib\
C:\Program Files\opencv-4.9.0\build\include\
C:\Program Files\opencv-4.9.0\build\x64\vc16\bin

Btw, you NEED to add these to your path, if you use the OPENCV_LINK_LIBS / OPENCV_LINK_PATHS / OPENCV_INCLUDE_PATHS, you will get runtime linking errors (at least on windows).

Now we can add the dependencies to our Rust project.

[dependencies]
opencv = "0.89"
ort = "2.0.0-rc.1"

And that's it! Now you can go ahead and run OPENCV_LINK_LIBS='opencv_world490' OPENCV_MSVC_CRT='static' cargo r to compile your program. Yes, the arguments before the command are required. Alternatively, you can set them as enviromental variables.

Other

  • To ensure that VSCode's autocomplete is working properly, copy settings from ./vscode/settings.json to your repository.

About

An example and setup guide on how to get ort and opencv-rust working together. I've tested this on both Linux and Windows.

Topics

Resources

License

Stars

Watchers

Forks

Languages