This time to bring you the Python configuration and OpenCV use of the detailed, Python configuration and OpenCV use of the attention of what, the following is the actual case, together to see.
After downloading opencv2.4.9 (python2.7 match)
(1) running OpenCV 2.4.9.exe;
(2) Configure Python: Will \opencv\build\python\2.7\x64 this directory: Cv2.pyd
Copy to: Python27\lib\site-packages\ directory;
(3) Test: Input import Cv2, such as error, indicating not installed successfully
1, OpenCV version must match with Python version, otherwise Python is unable to call Cv2 this module.
error message: Importerror DLL load failed:%1 is not a valid WIN32 application
The reason for this error is because the Python bit does not match the OPENCV, such as your python2.7 is 32 bits, and OPENCV is 64 bits.
2, the solution: is if your Python is 64 bits of the \opencv\build\python\2.7\x64 under the Cv2.pyd copy python27\lib\site-packages\, otherwise will \ Opencv\build\python\2.7\x86 Copy the past.
If your Python joins the environment variable, enter the Python carriage return directly in the console to see how many bits of your python are:
3, some problems of opencv3
Opencv3 use and Opencv2 there are some differences, take Cv2.cv.CV_HAAR_SCALE_IMAGE, OPENCV3 will error, hint CV2 no CV this attribute, replace Opencv2 is good.
Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!
Recommended reading:
Python bulk reading of pictures and database implementation
How the object life cycle is used in Python replication