Closed EthanAbitbol3 closed 1 year ago
set opencv and opnnxruntime path. If you don't know how to use cmake, please Google it. This is no something that can be explained clearly in just a few words, especially since different IDEs have different configuration schemes. I'm not sure what IDE you're using, I can only tell you about the general purpose.
If you are using VS/VScode, please configure the library path and header file path for opencv and onnxruntime in the project properties (this is not difficult, I believe it will be much simpler than the cmake above, as long as you Google VS to configure opencv and onnxruntime), and then add the source code to the project for compilation.
For example of vs2019: (I'm sorry I only have Chinese UI)
File->new ->progect ->win32 Console Application -> Empty project ->next step
set your peoject name and path,and then create project.
download src code to project,and then add into project.Right-click the source code option and select Add existing item
change project to x64
Find the Property-Manager-window in the View
Open the X64 properties page and configure the include paths for opencv and onnxruntime.Note that you are using your own path and version number replacements for opencv and onnxruntime
add libliry path,Note that you are using your own path and version number replacements for opencv and onnxruntime 8.Add additional dependencies,include "onnxruntime.lib" and "opencv_worldxxxd.lib",“xxx” is your opencv version
When everything is configured, you are ready to run. Just replace the models and images with your own path. https://github.com/UNeedCryDear/yolov8-opencv-onnxruntime-cpp/blob/4b90bf0c3d86d67faf1a3683ccace79163b7c16d/main.cpp#L81
I greatly appreciate your explanations! I'm going to start working on this right away.
Do I have to use the ONNX Runtime library? Because I can't seem to download it on Windows, and I just want to use OpenCV. I tried downloading it directly through Visual Studio 2019, but I'm not sure if that will work.
I have created the project and imported the files:
Then I changed the solution platform to x64:
Next, I located the Property Manager:
I added the path :
Then, I modified the additional dependencies:
Finally, I updated the paths for the models and images as follows:
To compile, I executed:
I encountered the following error:
Thank you again for your time and your help !
If you only want opencv to inference, remove the files with “xxxx_onnx.h/.cpp” characters in the file name from your project, and finally remove the relevant "xxx_onn.h" and classes from the main.cpp
thank you again for thoses informations, unfortunately :
I forgot to mention that i train on a custom dataset with 2 classes and image size of 512x512
Thank you again !
change _ClassNames and _netWidth/_netHeight/_segW/_segH
Amazing ! Thank you so much for everything !!
Hello and thank you for your work !
I am a newcomer to C++ and I've been attempting to comprehend how to use/compile the code, but I haven't been successful. Could you kindly provide guidance on how to utilize your code? Here's some additional information:
Thank you once again for your help!