Improve YOLOv8 ONNX Runtime c++ example for all OS with CmakeList.txt support (#4274)
Signed-off-by: Onuralp SEZER <thunderbirdtr@fedoraproject.org> Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
c9be1f3cce
commit
22474e9ad5
5 changed files with 179 additions and 53 deletions
|
|
@ -1,15 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define RET_OK nullptr
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include "io.h"
|
||||
#include "direct.h"
|
||||
#include "opencv.hpp"
|
||||
#include <Windows.h>
|
||||
#include <cstdio>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include "onnxruntime_cxx_api.h"
|
||||
|
||||
|
||||
|
|
@ -23,13 +25,12 @@ enum MODEL_TYPE
|
|||
};
|
||||
|
||||
|
||||
|
||||
typedef struct _DCSP_INIT_PARAM
|
||||
{
|
||||
std::string ModelPath;
|
||||
MODEL_TYPE ModelType = YOLO_ORIGIN_V8;
|
||||
std::vector<int> imgSize={640, 640};
|
||||
|
||||
int classesNum=80;
|
||||
float RectConfidenceThreshold = 0.6;
|
||||
float iouThreshold = 0.5;
|
||||
bool CudaEnable = false;
|
||||
|
|
@ -55,16 +56,14 @@ public:
|
|||
public:
|
||||
char* CreateSession(DCSP_INIT_PARAM &iParams);
|
||||
|
||||
|
||||
char* RunSession(cv::Mat &iImg, std::vector<DCSP_RESULT>& oResult);
|
||||
|
||||
|
||||
char* WarmUpSession();
|
||||
|
||||
|
||||
template<typename N>
|
||||
char* TensorProcess(clock_t& starttime_1, cv::Mat& iImg, N& blob, std::vector<int64_t>& inputNodeDims, std::vector<DCSP_RESULT>& oResult);
|
||||
|
||||
std::vector<std::string> classes{};
|
||||
|
||||
private:
|
||||
Ort::Env env;
|
||||
|
|
@ -74,9 +73,7 @@ private:
|
|||
std::vector<const char*> inputNodeNames;
|
||||
std::vector<const char*> outputNodeNames;
|
||||
|
||||
|
||||
int classesNum;
|
||||
MODEL_TYPE modelType;
|
||||
MODEL_TYPE modelType;
|
||||
std::vector<int> imgSize;
|
||||
float rectConfidenceThreshold;
|
||||
float iouThreshold;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue