|
Installation_OpenCV
Instructions for installing OpenCV 2.x so that it is usable by PyOpenCV
Installing OpenCV 2.xWillow Garage's pre-compiled OpenCV 2.x builds are in general not suitable for PyOpenCV. The reasons are mainly due to the use of manually written SSE+SSE2 code (see below) and "parallel mode" STL containers (only for OpenCV 2.0 with OpenMP enabled). It is likely that you require a new OpenCV 2.x build that is compiled from source. Do not worry though, you can still use your current OpenCV 2.x build (if any) in other applications. PyOpenCV always tries to load the build you have specified in the config.py file instead of other builds. You have two options to obtain a usable OpenCV build for PyOpenCV: build OpenCV 2.x from source, or download a pre-compiled build. Building OpenCV 2.x from sourceIf you have decided to build OpenCV 2.x from source, just use the standard cmake approach. However, take note of the followings:
This is important. When the SWIG option is set, the majority of new C++ member functions of various classes in the ML component are disabled in OpenCV's header file ml.h. PyOpenCV, however, relies on these C++ functions to interface with the classes. Therefore, not using SWIG is a must. It appears that when the option is checked, the resultant OpenCV is somehow modified such that it could lead to a crash in PyOpenCV. The issue is still under investigation. When either of these options are enabled, along with SIMP code automatically generated by the compiler, some manually written SIMP code is used. However, with no offence to the Willow Garage people, it appears that the manually written code crashes when being invoked from a Python extension. Therefore, the safest best for now is to uncheck these options. For the record, the C++ wrapping code of PyOpenCV can be built safely with -msse -msse2 -mfpmath=sse -mtune=generic flags set. Before running cmake, edit file CMakeLists.txt, search for "-D_GLIBCXX_PARALLEL" and remove it. Basically, when this option is set, experimental "parallel mode" STL containers are used, which are incompatible with the standard "normal mode" STL containers used by Boost.Python and other libraries. Of course, if you could recompile every single library that is connected to OpenCV with option "-D_GLIBCXX_PARALLEL" set, then it would be another matter. The libvideoInput.a library file that comes with OpenCV was built using the old SJLJ exception handling method. Hence, you can only link against it by using a compiler that uses SJLJ. To link against it using a compiler that uses the DWARF-2 exception handling method, replace the libvideoInput.a file in OpenCV with this file. In addition, search in file src/highgui/CMakeLists.txt for the following text: "videoInput strmiids". It should be at somewhere near line 199. Then, insert " ole32 oleaut32 uuid" right after the text, i.e. "videoInput strmiids ole32 oleaut32 uuid". The developers have forgotten to insert these Windows libraries. Downloading a pre-compiled OpenCV 2.x buildIn some cases, there is a faster and trouble-free way to install OpenCV 2.x that is suitable for PyOpenCV. Just go to the Downloads page, download a pre-compiled OpenCV 2.x suitable for your platform, and follow the instructions inside the file to install. I have gone through most of the troubles that could have happened to build them. You do not have to go through the same pain. |
what if I am using 64-Bit windows? will win32 still work sheehy.john@gmail.com