#pragma once
#include <iostream>
#include <assert.h>
#include <vector>
#include <onnxruntime_cxx_api.h>
#include <string>
#include <opencv2/opencv.hpp>
#include "postProcess.h"
using namespace std;
using namespace cv;
using namespace postProcess;
void preDataDet(cv::Mat& matSrc, int& model_width, int& model_height, cv::Mat& matDst)
{
cv::cvtColor(matSrc, matDst, cv::COLOR_BGR2RGB);
cv::resize(matDst, matDst, cv::Size(model_width, model_height));
matDst.convertTo(matDst, CV_32FC3);
matDst = matDst / 255.0f;
}
int main()
{
Ort::Env env(ORT_LOGGING_LEVEL_WARNING, "ONNX_DETECTION");
Ort::SessionOptions session_options;
session_options.SetIntraOpNumThreads(1);
session_options.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_BASIC);
#ifdef _WIN32
const wchar_t* model_path = L"/OnnxRuntimeInference/weights/yolov5_model/best.onnx";
#else
const char* model_path = "/OnnxRuntimeInference/weights/yolov5_model/best.onnx";
#endif
Ort::Session session(env, model_path, session_options);
Ort::AllocatorWithDefaultOptions allocator;
size_t num_input_nodes = session.GetInputCount();
size_t numInputNodes = session.GetInputCount();
size_t numOutputNodes = session.GetOutputCount();
vector<char*> input_names;
vector<char*> output_names;
vector<vector<int64_t>> input_node_dims;
vector<vector<int64_t>> output_node_dims;
for (int i = 0; i < numInputNodes; i