Update YOLOv8-ONNXRuntime-CPP (#3455)
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
1c4a363497
commit
69a2d70a78
5 changed files with 453 additions and 0 deletions
44
examples/YOLOv8-ONNXRuntime-CPP/main.cpp
Normal file
44
examples/YOLOv8-ONNXRuntime-CPP/main.cpp
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include "inference.h"
|
||||
#include <filesystem>
|
||||
|
||||
|
||||
|
||||
void file_iterator(DCSP_CORE*& p)
|
||||
{
|
||||
std::filesystem::path img_path = R"(E:\project\Project_C++\DCPS_ONNX\TEST_ORIGIN)";
|
||||
int k = 0;
|
||||
for (auto& i : std::filesystem::directory_iterator(img_path))
|
||||
{
|
||||
if (i.path().extension() == ".jpg")
|
||||
{
|
||||
std::string img_path = i.path().string();
|
||||
//std::cout << img_path << std::endl;
|
||||
cv::Mat img = cv::imread(img_path);
|
||||
std::vector<DCSP_RESULT> res;
|
||||
char* ret = p->RunSession(img, res);
|
||||
for (int i = 0; i < res.size(); i++)
|
||||
{
|
||||
cv::rectangle(img, res.at(i).box, cv::Scalar(125, 123, 0), 3);
|
||||
}
|
||||
|
||||
k++;
|
||||
cv::imshow("TEST_ORIGIN", img);
|
||||
cv::waitKey(0);
|
||||
cv::destroyAllWindows();
|
||||
//cv::imwrite("E:\\output\\" + std::to_string(k) + ".png", img);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
DCSP_CORE* p1 = new DCSP_CORE;
|
||||
std::string model_path = "yolov8n.onnx";
|
||||
DCSP_INIT_PARAM params{ model_path, YOLO_ORIGIN_V8, {640, 640}, 80, 0.1, 0.5, false };
|
||||
char* ret = p1->CreateSession(params);
|
||||
file_iterator(p1);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue