无法在python中使用opencv加载dll

问题描述 投票:0回答:1

我正在尝试使用Visual Studio构建C ++ dll并在python中加载该dll。 dll代码

#define DLLEXPORT extern "C" __declspec(dllexport)

#include "test.h"
#include "opencv2\\highgui.hpp"

using namespace cv;

DLLEXPORT int sumV() {

    Mat a = Mat::zeros(5,5, CV_8U);


    return 11;

}

并且python代码是

from ctypes import *
from ctypes.util import *

dll = find_library('C:\\path\\dll1.dll')
lib = cdll.LoadLibrary(dll)

我总是收到“ OSError:[WinError 126]找不到指定的模块。”当我运行python代码时。

有人知道如何解决此问题吗?非常感谢。

python opencv dll
1个回答
0
投票

这是我解决问题的方式。在我的C ++代码中,我调用了opencv函数,但是忘记了将opencv dll复制到我的python脚本文件夹中。因此,python无法找到它。再次感谢Yunus的帮助。

© www.soinside.com 2019 - 2024. All rights reserved.