c++ opencv 导出dll 头文件需要多个include opencv.hpp文件如何解决

将opencv静态库加入了自己写的ocr算法一个类中,并且生成dll用loadlibrary调用,但问题是调用dll时必须要该类的头文件,不然无法找到该类,而头文件又包含多个hpp第三方依赖头文件,应该如何解决
private中含有Net类型,函数参数含有Mat类型

#include <opencv2/opencv.hpp>
#include <opencv2/dnn.hpp>
#include <opencv2/dnn/all_layers.hpp>
class _declspec(dllexport) ocr
{
private:
    int crop_mode = 1;
    int thresh_mode=1;
public:
    //void ~ocr(){}
    //inline
    void set_morph(int x, int y, int iter);
    void char2mat(unsigned char* cimg, Mat &mat, int h, int w, int channel);
    void rotate(Mat &frame);

头文件里不要用Mat,直接用unsigned char *把数据位保存,在cpp里调用这几个opencv的头文件即可。private类型,增加一个成员函数修改即可。

写个简单例子吧,
.h文件里opencv啥类型都不加,
void test(const char* ImgBuf, int width, int height, int channel );
.cpp文件里实现:
void test(const char* ImgBuf, int width, int height, int channel )
{
Mat srcImage = Mat(height, width, CV_MAKETYPE(CV_8U, channel), (void*)ImgBuf);
}
这样就转换成你需要的Mat类型了,而且头文件里没有Mat类型。第三方头文件放在cpp里,就不影响你要的要求了。

头文件里只有:
string model_path;
.cpp里set_net(model_path)就可以了
有什么问题吗?

qq私发给你了,接口有说明文档即可。或者整个调用示例。