提交 666920d7 编写于 作者: E Eric.Lee

create handpose_x onnx

上级 b28f29a5
# ONNX Runtime
## 项目配置
### 1、作者开发环境: Windows10 (vs 2019 or vs 2022)
### 2、项目依赖
* opencv 3.4.15
安装方法:自行安装配置项目依赖。
* 如模型运行平台 GPU :
- [x] onnxruntime-win-x64-gpu-1.3.0
- [x] cuda_10.1.105_418.96_win10
- [x] cudnn-10.1-windows10-x64-v7.6.5.32
安装方法:自行安装配置项目依赖。
* 如模型运行平台 CPU :
- [x] Microsoft.ML.OnnxRuntime.1.10.0 & Microsoft.ML.OnnxRuntime.MKLML.1.6.0
安装方法:
进入 visual studio 编辑环境,选择:工具 -> NuGet 包管理器 -> 管理解决方案的 NuGet程序包,
然后选择“浏览”,在搜索栏分别输入 “Microsoft.ML.OnnxRuntime.1.10.0”、“Microsoft.ML.OnnxRuntime.MKLML.1.6.0”,进行安装。
## 项目依赖工具包
* [项目依赖工具包下载地址(百度网盘 Password: s46l )](https://pan.baidu.com/s/18KhFz5_ea-HCcRWqzHXwhg)
## ONNX 模型
* [handpose_X 模型下载地址(百度网盘 Password: obxa )](https://pan.baidu.com/s/13oo9t4DGKu26yQ9Th393Ag)
## 项目使用方法
### 1、如GPU运行自行确定软件已安装及硬件环境符合。
### 2、配置项目依赖库。
### 3、配置模型本地路径。
### 4、配置样本路径。
### 5、运行项目。

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31410.357
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "onnxtest", "onnxtest.vcxproj", "{ADB195F6-7D06-47D7-9690-CE73419A9AA0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{ADB195F6-7D06-47D7-9690-CE73419A9AA0}.Debug|x64.ActiveCfg = Debug|x64
{ADB195F6-7D06-47D7-9690-CE73419A9AA0}.Debug|x64.Build.0 = Debug|x64
{ADB195F6-7D06-47D7-9690-CE73419A9AA0}.Debug|x86.ActiveCfg = Debug|Win32
{ADB195F6-7D06-47D7-9690-CE73419A9AA0}.Debug|x86.Build.0 = Debug|Win32
{ADB195F6-7D06-47D7-9690-CE73419A9AA0}.Release|x64.ActiveCfg = Release|x64
{ADB195F6-7D06-47D7-9690-CE73419A9AA0}.Release|x64.Build.0 = Release|x64
{ADB195F6-7D06-47D7-9690-CE73419A9AA0}.Release|x86.ActiveCfg = Release|Win32
{ADB195F6-7D06-47D7-9690-CE73419A9AA0}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2C2375E0-262D-4E79-9EFE-2105AD842171}
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="packages\Microsoft.ML.OnnxRuntime.MKLML.1.6.0\build\native\Microsoft.ML.OnnxRuntime.MKLML.props" Condition="Exists('packages\Microsoft.ML.OnnxRuntime.MKLML.1.6.0\build\native\Microsoft.ML.OnnxRuntime.MKLML.props')" />
<Import Project="packages\Microsoft.ML.OnnxRuntime.1.10.0\build\native\Microsoft.ML.OnnxRuntime.props" Condition="Exists('packages\Microsoft.ML.OnnxRuntime.1.10.0\build\native\Microsoft.ML.OnnxRuntime.props')" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{adb195f6-7d06-47d7-9690-ce73419a9aa0}</ProjectGuid>
<RootNamespace>onnxtest</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>D:\opencv\build\include;D:\opencv\build\include\opencv;D:\opencv\build\include\opencv2;$(IncludePath)</IncludePath>
<LibraryPath>D:\opencv\build\x64\vc15\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>opencv_world3415.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\main.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="packages\Microsoft.ML.OnnxRuntime.1.10.0\build\native\Microsoft.ML.OnnxRuntime.targets" Condition="Exists('packages\Microsoft.ML.OnnxRuntime.1.10.0\build\native\Microsoft.ML.OnnxRuntime.targets')" />
<Import Project="packages\Microsoft.ML.OnnxRuntime.MKLML.1.6.0\build\native\Microsoft.ML.OnnxRuntime.MKLML.targets" Condition="Exists('packages\Microsoft.ML.OnnxRuntime.MKLML.1.6.0\build\native\Microsoft.ML.OnnxRuntime.MKLML.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\Microsoft.ML.OnnxRuntime.1.10.0\build\native\Microsoft.ML.OnnxRuntime.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.ML.OnnxRuntime.1.10.0\build\native\Microsoft.ML.OnnxRuntime.props'))" />
<Error Condition="!Exists('packages\Microsoft.ML.OnnxRuntime.1.10.0\build\native\Microsoft.ML.OnnxRuntime.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.ML.OnnxRuntime.1.10.0\build\native\Microsoft.ML.OnnxRuntime.targets'))" />
<Error Condition="!Exists('packages\Microsoft.ML.OnnxRuntime.MKLML.1.6.0\build\native\Microsoft.ML.OnnxRuntime.MKLML.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.ML.OnnxRuntime.MKLML.1.6.0\build\native\Microsoft.ML.OnnxRuntime.MKLML.props'))" />
<Error Condition="!Exists('packages\Microsoft.ML.OnnxRuntime.MKLML.1.6.0\build\native\Microsoft.ML.OnnxRuntime.MKLML.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.ML.OnnxRuntime.MKLML.1.6.0\build\native\Microsoft.ML.OnnxRuntime.MKLML.targets'))" />
</Target>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\main.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.ML.OnnxRuntime" version="1.10.0" targetFramework="native" />
<package id="Microsoft.ML.OnnxRuntime.MKLML" version="1.6.0" targetFramework="native" />
</packages>
\ No newline at end of file
#include <iostream>
#include <assert.h>
#include <vector>
#include <onnxruntime_cxx_api.h>
#include <onnxruntime_c_api.h>
#include <string>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include<ctime>
using namespace cv;
using namespace std;
//#define USE_CUDA
#ifdef USE_CUDA
#include <cuda_provider_factory.h>
#endif //
/************** 图像输入预处理 ************/
std::vector<float> preprocess_image(Mat img_dst, std::vector<float> input_tensor_values)
{
std::size_t counter = 0;
for (unsigned k = 0; k < 3; k++)
{
for (unsigned i = 0; i < img_dst.rows; i++)
{
for (unsigned j = 0; j < img_dst.cols; j++)
{
input_tensor_values[counter++] = (static_cast<float>(img_dst.at<cv::Vec3b>(i, j)[k]) - 128.) / 256.0;
}
}
}
return input_tensor_values;
}
/************** 绘制关键点 ************/
void draw_keypoints(Mat &img_o, std::vector<int> pts)
{
for (unsigned k = 0; k < 5; k++)
{
int i = k*8;
unsigned char R = 255, G = 0, B = 0;
switch(k)
{
case 0:R = 255; G = 0; B = 0;break;
case 1:R = 255; G = 0; B = 255;break;
case 2:R = 255; G = 255; B = 0;break;
case 3:R = 0; G = 255; B = 0;break;
case 4:R = 0; G = 0; B = 255;break;
default:printf("error\n");
}
line(img_o, Point(pts[0], pts[1]), Point(pts[i + 2], pts[i + 3]), Scalar(B,G,R), 2, CV_AA);
line(img_o, Point(pts[i + 2], pts[i + 3]), Point(pts[i + 4], pts[i + 5]), Scalar(B, G, R), 2, CV_AA);
line(img_o, Point(pts[i + 4], pts[i + 5]), Point(pts[i + 6], pts[i + 7]), Scalar(B, G, R), 2, CV_AA);
line(img_o, Point(pts[i + 6], pts[i + 7]), Point(pts[i + 8], pts[i + 9]), Scalar(B, G, R), 2, CV_AA);
}
}
int main(int argc, char* argv[]) {
/***************** ONNX 测试 ****************/
const wchar_t* model_path = L"./resnet_50_size-256.onnx";
Ort::Env env(ORT_LOGGING_LEVEL_WARNING, "onnx_test");
Ort::SessionOptions session_options;
session_options.SetIntraOpNumThreads(1);
//session_options.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_BASIC);
session_options.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_ALL);
#ifdef USE_CUDA
OrtSessionOptionsAppendExecutionProvider_CUDA(session_options, 0);
printf(" --->>> ONNX Runtime USE_CUDA \n");
#endif
Ort::AllocatorWithDefaultOptions allocator;
Ort::Session session(env, model_path, session_options);
//Ort::Session session(env, model_path, session_options);
printf(" load onnx model");
// print model input layer (node names, types, shape etc.)
size_t num_input_nodes = session.GetInputCount();
size_t num_output_nodes = session.GetOutputCount();
std::cout << session.GetInputName(0, allocator) << std::endl;
std::cout << session.GetOutputName(0, allocator) << std::endl;
//--------------------------------------------------------------
printf("Number of inputs = %zu\n", num_input_nodes);
std::vector<const char*> input_node_names(num_input_nodes);
std::vector<const char*> output_node_names(num_output_nodes);
std::vector<int64_t> input_node_dims;
/********************************* 打印模型 节点 *****************************/
//迭代所有的输入节点
for (int i = 0; i < num_input_nodes; i++) {
//输出输入节点的名称
char* input_name = session.GetInputName(i, allocator);
printf("Input %d : name=%s\n", i, input_name);
input_node_names[i] = input_name;
// 输出输入节点的类型
Ort::TypeInfo type_info = session.GetInputTypeInfo(i);
auto tensor_info = type_info.GetTensorTypeAndShapeInfo();
ONNXTensorElementDataType type = tensor_info.GetElementType();
printf("Input %d : type=%d\n", i, type);
input_node_dims = tensor_info.GetShape();
//输入节点的打印维度
printf("Input %d : num_dims=%zu\n", i, input_node_dims.size());
//打印各个维度的大小
for (int j = 0; j < input_node_dims.size(); j++)
printf("Input %d : dim %d=%jd\n", i, j, input_node_dims[j]);
//batch_size=1
input_node_dims[0] = 1;
}
//打印输出节点信息,方法类似
for (int i = 0; i < num_output_nodes; i++)
{
char* output_name = session.GetOutputName(i, allocator);
printf("Output: %d name=%s\n", i, output_name);
output_node_names[i] = output_name;
Ort::TypeInfo type_info = session.GetOutputTypeInfo(i);
auto tensor_info = type_info.GetTensorTypeAndShapeInfo();
ONNXTensorElementDataType type = tensor_info.GetElementType();
printf("Output %d : type=%d\n", i, type);
auto output_node_dims = tensor_info.GetShape();
printf("Output %d : num_dims=%zu\n", i, output_node_dims.size());
for (int j = 0; j < output_node_dims.size(); j++)
printf("Output %d : dim %d=%jd\n", i, j, output_node_dims[j]);
}
// 使用样本数据对模型进行评分,并检验出入值的合法性
size_t input_tensor_size = 3 * 256 * 256; // simplify ... using known dim values to calculate size
// use OrtGetTensorShapeElementCount() to get official size!
std::vector<float> input_tensor_values(input_tensor_size);
// 加载样本文件夹
vector<cv::String> fn;
cv::String pattern = "./sample/*.jpg";
glob(pattern, fn, false);
size_t count = fn.size(); //number of png files in images folder
Size dsize = Size(256, 256);
int64_t output_tensor_size = 42;// 关键点输出 (x,y)*21= 42
for (size_t k = 0; k < 10; k++)
{
for (size_t i = 0; i < count; i++)
{
Mat img_o = imread(fn[i]);
Mat img_dst = Mat(dsize, CV_8UC3);
resize(img_o, img_dst, dsize);
//printf("cols: %d ,rows: %d\n", img_dst.cols, img_dst.rows);
input_tensor_values = preprocess_image(img_dst, input_tensor_values);
auto start_time = clock();
// 为输入数据创建一个Tensor对象
try
{
auto memory_info = Ort::MemoryInfo::CreateCpu(OrtArenaAllocator, OrtMemTypeDefault);
Ort::Value input_tensor = Ort::Value::CreateTensor<float>(memory_info, input_tensor_values.data(), input_tensor_size, input_node_dims.data(), 4);
assert(input_tensor.IsTensor());
// 推理得到结果
auto output_tensors = session.Run(Ort::RunOptions{ nullptr }, input_node_names.data(), &input_tensor, input_node_names.size(), output_node_names.data(), output_node_names.size());
assert(output_tensors.size() == 1 && output_tensors.front().IsTensor());
// Get pointer to output tensor float values
//float* output = output_tensors[0].GetTensorMutableData<float>();
float* output = output_tensors.front().GetTensorMutableData<float>();
//printf(" --->>> Number of outputs = %d\n", output_tensors.size());
auto end_time = clock();
printf(" -> ONNX Inference Cost Time: %.5f Seconds\n", static_cast<float>(end_time - start_time) / CLOCKS_PER_SEC);
// 获取关键点像素坐标
std::vector<int>results(output_tensor_size);
for (unsigned i = 0; i < 21; i++)
{
int x = output[i * 2] * img_o.cols;
int y = output[i * 2 + 1] * img_o.rows;
results[i * 2] = x;
results[i * 2 + 1] = y;
circle(img_o, Point(x, y), 4, Scalar(255, 155, 0), 2);
}
// 绘制关键点
draw_keypoints(img_o, results);
}
catch (Ort::Exception& e)
{
printf(e.what());
}
// 创建一个名为 "图片"窗口
namedWindow("keypoint", 0);
// 在窗口中显示图片
imshow("keypoint", img_o);
if (waitKey(1) == 27) break;
img_o.release();
img_dst.release();
}
}
cout << "well done !" << endl;
return 0;
}
\ No newline at end of file
 main.cpp
D:\git_pro\onnx_run\demo\handpose_x\src\main.cpp(8,10): fatal error C1083: 无法打开包括文件: “opencv2/opencv.hpp”: No such file or directory
PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30037:VCServicingVersionATL=14.29.30038:VCServicingVersionCrtHeaders=14.29.30038:VCServicingVersionCompilers=14.29.30038:TargetPlatformVersion=10.0.19041.0:
Debug|x64|D:\git_pro\onnx_run\demo\handpose_x\|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册