本文主要是介绍关于C++封装类为动态链接库,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
之前用caffe做图片分类,对caffe的代码进行了封装。为了让代码看起来尽可能简洁,对分类的类进行了封装,刚开始的封装是这样的:
classification.h如下:
#ifndef CLASSIFICATION_H_
#define CLASSIFICATION_H_#include <caffe/caffe.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iosfwd>
#include <memory>
#include <utility>
#include <vector>
#include <iostream>
#include <string>
#include <sstream>
#include <time.h>using namespace caffe;
using std::string;
typedef std::pair<int, float> Prediction;class ClassifierImpl {
public:ClassifierImpl(const string& model_file,const string& trained_file,const string& mean_file);std::vector<std::vector<Prediction> > Classify(const cv::Mat& img, int N = 2);
private:void SetMean(const stri
这篇关于关于C++封装类为动态链接库的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!