I've compiled OpenCV 3.2.0 from source using MinGW64 GCC 4.8.1, on Windows 10 (64 bit), for Python 3.5.2 (64 bit).
However, when I run import cv2
, python crashes.
Debugging python.exe with Visual Studio shows the following stack trace
python35.dll!PyUnicode_FromString(const char * u) Line 1884
python35.dll!PyDict_GetItemString(_object * v, const char * key) Line 2810
python35.dll!add_getset(_typeobject * type, PyGetSetDef * gsp) Line 4526
python35.dll!PyType_Ready(_typeobject * type) Line 4874
cv2.cp35-win_amd64.pyd!0000000070cee706()
...
Any ideas?
My OpenCV compilation process:
My cmake
command (CMake 3.7.2) was
cmake -G "MinGW Makefiles" -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DOPENCV_EXTRA_MODULES_PATH=D:/opencv/source/opencv_contrib/modules D:/opencv/source/opencv -DBUILD_opencv_python3=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DBUILD_DOCS=OFF -DPYTHON_EXECUTABLE=D:/Python352/python.exe -DPYTHON_INCLUDE_DIRS=D:/Python352/include -DPYTHON_LIBRARY=D:/Python352/libs/libpython35.a
I then compiled with mingw3-make
and it compiled without errors. I moved the resulting cv2.cp35-win_amd64.pyd
(~39 MB) to Python352/Lib/site-packages/
I recompiled using Visual Studio 2015 and the resulting .pyd works fine. Must have been an issue with GCC.