qq_41747698 2021-09-23 09:03 采纳率: 75%
浏览 139
已结题

c++ dll 类 摆脱头文件依赖opencv,有源码如何使用

现有一个依赖opencv的算法,类成员函数可实现输入输出,但参数中含有mat,private中含有net类型,头文件因此无法摆脱opencv依赖,问:现欲摆脱opencv的头文件和dll依赖,将该dll交付他人使用,是否可以做到将头文件写进cpp中,直接无头文件或者写个头文件接口直接dll和lib调用该类中的算法,以及修改接口中的私有变量参数

class _declspec(dllexport) ocr
{
private:
    int crop_mode = 1;
    int thresh_mode=1;
    int bitwise_mode2 = 0;
    double blur1 = 3;
    double blur2 = 11;
    //int rect_morph_x;
    //int rect_morph_y;
    int morph_x = 1;
    int morph_y = 9;
    int iteration = 1;
    int canny_max = 300;
    int min_width = 8;
    int i;//高斯模糊
    int flag;
    int flag2;
    string model_path = "./1.onnx";
    Net net;
    int rect_thresh = 0;
    int blocksize = 31;
    int C = 10;
    int a = 3;
    int c = 5;
    int b = -5;
    int d = 10;
    int softmax_thresh=0.9;

    
    //block,C,threshold

    //unsigned char * img


public:
    //void ~ocr(){}

    //inline
    void set_morph(int x, int y, int iter)
    {
        morph_x = x;
        morph_y = y;
        iteration = iter;
    }
    
    void set_blocksize(int x)
    {
        blocksize = x;
    }
    //inline
    void set_net(string model_path)
    {
        net = cv::dnn::readNetFromONNX(model_path);
    }

    void set_rect_thresh(int x)
    {
        rect_thresh = x;
    }


  • 写回答

7条回答 默认 最新

  • orange4reg 2021-09-23 09:18
    关注

    都已经告诉过你了,你不使用的话,也没有其它办法了,隐藏其它依赖dll,确确实实只能那样做,如果你嫌动态加载资源中的dll麻烦,你也可以把资源里的dll偷偷的复制到system32那里。动态复制,就是dllmain执行的时候检查有没有OpenCV的相关dll,没有再复制过去。或者找OpenCV的源码一起编译进去是最好的啦。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
    1人已打赏
查看更多回答(6条)

报告相同问题?

问题事件

  • 系统已结题 10月1日
  • 已采纳回答 9月23日
  • 修改了问题 9月23日
  • 创建了问题 9月23日

悬赏问题

  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知