Detailed explanation of python configuration and use of OpenCV

php中世界最好的语言
Release: 2018-04-09 14:43:40
Original
3035 people have browsed it

This time I will bring you a detailed explanation of the use of python configuration and OpenCV. What are the precautions for python configuration and use of OpenCV. The following is a practical case, let's take a look.

After downloading opencv2.4.9 (python2.7 matching)

(1) Run OpenCV 2.4.9.exe;

(2) Configure Python: Copy the \opencv\build\python\2.7\x64 directory: cv2.pyd

to: Python27\Lib \site-packages\ directory;

(3) Test: Enter import cv2. If an error is reported, it means the installation is not successful

1. The version of opencv must match the version of python, otherwise python will not be able to call the cv2 module.

Error message:ImportError DLL load failed: %1 is not a valid Win32 application

This error occurred The reason is that the bits of python and opencv do not match. For example, your python2.7 is 32-bit, but opencv is 64-bit.

2. Solution: If your python is 64-bit, copy cv2.pyd under \opencv\build\python\2.7\x64 Python27\Lib\site-packages\, otherwise copy \opencv\build\python\2.7\x86.

If your python has added environment variables, just enter python directly in the console and press Enter to see how many bits your python has:

3. Some problems with opencv3

There are some differences between the use of opencv3 and opencv2. Take cv2.cv.CV_HAAR_SCALE_IMAGE as an example. An error will be reported in opencv3, prompting that it is in cv2. If there is no cv attribute, just switch to opencv2.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Implementation of python batch reading of images and storing them in the database

Object life in Python replication How to use cycles

The above is the detailed content of Detailed explanation of python configuration and use of OpenCV. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!