Ask Your Question
0

Building opencv-master for Python

asked 2013-09-24 04:39:37 -0600

pyro gravatar image

updated 2013-09-24 05:51:44 -0600

berak gravatar image

I want to build the latest version of OpenCV (dev 3.0.0) from source. I followed the instructions in official tutorial and was able to successfully complete the build.

But importing cv2.pyd in Python (after copying to \Python27\Lib\site-packages) throws an error "ImportError: DLL load failed: The specified module could not be found."

I found 5 files named cv2.* after the build:

  1. cv2.obj in \build\modules\python\opencv_python.dir\Release

  2. cv2.pyd, cv2.obj, cv2.exp, cv2.pdb in \build\lib\Release

What are these files (especially the pyd files) and why aren't they usable like in 2.4.6 prebuilt version which can just be plugged into the \Python27\Lib\site-packages folder directly?

Thanks!

edit retag flag offensive close merge delete

Comments

1

@Abid Thanks, but I already referred to the link. I was able to build, but it was dynamically linked, and I didn't add the DLL path to the PATH env variable. I fixed the problem from @berak's answer. BTW, is this the official OpenCV-Python site for the next release?

pyro gravatar imagepyro ( 2013-09-25 05:55:59 -0600 )edit

@Abid it's strange that I couldn't find "INSTALL" in my OpenCv.sln

pyro gravatar imagepyro ( 2013-09-25 05:58:36 -0600 )edit

@pyro : berak's answer is correct. Even I had the same issue and @berak gave me the same solution that worked.

But it is strange you don't have INSTALL. But still you can copy cv2.pyd files to python site packages.

No, it is not official site... it is just for time being. That site will be integrated to docs.opencv.org, just like official OpenCV C++ tutorials.

Abid Rahman K gravatar imageAbid Rahman K ( 2013-09-26 00:19:40 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-09-24 06:27:51 -0600

berak gravatar image

updated 2013-09-24 06:52:10 -0600

did you put the opencv-dlls on the PATH env var ? the prebuilt cv2.pyd is statically linked ( containing all opencv functionality ) , your build probably is not, and thus depends on the opencv-dlls.

if you need a static build yourself, just rerun cmake with -D BUILD_SHARED_LIBS=OFF and recompile opencv.

you actually only need the cv2.pyd file in your Python27\Lib\site-packages folder. the cv2.pdb file contains the debugging information ( might come handy, if you need [remote] debugging )

edit flag offensive delete link more

Comments

Thanks for the extra tip on building a shared library.

pyro gravatar imagepyro ( 2013-09-24 22:59:37 -0600 )edit

Question Tools

Stats

Asked: 2013-09-24 04:39:37 -0600

Seen: 1,276 times

Last updated: Sep 24 '13