I compiled OpenCV 2.4.9 on x64 / Windows 7, with Visual Studio 2012.
To use the python binding I copied
cv2.pyd in the proper place on the python path, and then got the following error upon import :
>>> import cv2 Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: dynamic module does not define init function (initcv2)
Here's what worked for me to correct the issue
cv2.cpp I replaced:
extern "C" CV_EXPORTS void initcv2();
extern "C" __declspec(dllexport) void initcv2();
Of course, this works only for Windows.
Here's what I hoped would work, but did not
Trying to modify the definition of CV_EXPORTS:
#if (defined WIN32 || defined _WIN32 || defined WINCE || defined __CYGWIN__) && defined CVAPI_EXPORTS
#if (defined WIN32 || defined _WIN32 || defined _WIN64 || defined WINCE || defined __CYGWIN__) && defined CVAPI_EXPORTS
So, what would be the proper way to correct this issue ?