1 前言
博客Pytorch学习系列之九:OpenCV加载onnx模型进行推理_thequitesunshine007的博客-CSDN博客_opencv 加载onnx记载了python版本opencv加载onnx模型进行推理的方法。这里记录的是C++版本OpenCV加载onnx模型进行推理。
pytorch版本1.7.1 OpenCV 4.5.4
2 代码
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<opencv2/dnn/dnn.hpp>
#include <opencv2/core/utils/logger.hpp>
#include<string>
#include<iostream>
#include<fstream>
#include<vector>
using namespace cv;
using namespace std;
class ONNXClassifier
{
publ