Cannot import any contrib modules in Python

asked 2016-08-10 08:50:22 -0600

I'm trying to build OpenCV on my desktop with contrib modules after having successfully built it on my laptop. As far as I can tell, all the .dll's for the contrib modules get generated and in general, I cannot find any differences in the file structure on both machines. Yet on the desktop, I cannot import any contrib modules and when I run cv2.getBuildInformation, the contrib modules are not in the list of modules to be built.

OpenCV 3.1.0, Windows 7, Python 2.7.11

Thank you.

edit retag flag offensive close merge delete

Comments

can you show us the cmake output ? (append to your question)

berak gravatar imageberak ( 2016-08-10 09:17:12 -0600 )edit

Sorry for a silly question - which file would contain CMake output? I used CMake GUI.

n.jmurov gravatar imagen.jmurov ( 2016-08-10 09:56:24 -0600 )edit

it's the same as cv2.getBuildInformation()

any cjhance there is an older cv2 installed ? did you build the INSTALL project after building opencv ?

berak gravatar imageberak ( 2016-08-10 09:58:42 -0600 )edit
1

It looks like it was indeed picking up cv2.pyd that was left from a previous installation (without contrib modules). What should I do now? I've tried replacing the old cv2.pyd with the new one but now I'm getting 'DLL load failed'.

n.jmurov gravatar imagen.jmurov ( 2016-08-10 10:31:05 -0600 )edit
1

"but now I'm getting 'DLL load failed'."

so you built opencv with dynamic libs. either:

  • put the folder with the opencv dlls on the PATH
  • or rebuild with cmake -DBUILD_SHARED_LIBS=OFF to get a statically linked cv2.pyd, which is independant of other opencv dlls.
berak gravatar imageberak ( 2016-08-10 10:43:36 -0600 )edit

"the folder with the opencv dlls on the PATH" - They are on the PATH already.

n.jmurov gravatar imagen.jmurov ( 2016-08-10 10:53:35 -0600 )edit
1

double check, if it's the correct PATH, and again, - static linking is the recommended way for python / java wrappers.

berak gravatar imageberak ( 2016-08-10 10:56:12 -0600 )edit

OK thanks - I didn't know about static linking. I don't believe I saw it mentioned in any of OpenCV installation tutorials.

n.jmurov gravatar imagen.jmurov ( 2016-08-10 11:04:51 -0600 )edit