I know that I can pip install opencv-python
which installs opencv3, but is there a separate command or name for opencv2.4.9? If not, how can I specify which version to install?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
cv2 vs. "opencv3"
To get a potential misunderstanding out of the way: The python OpenCV module is named and imported via
import cv2
in all versions > 2.0, including > 3.0. If you want to work withcv2
, installing OpenCV versions > 3 is fine - unless you're looking for specific compatibility with older versions or are a fan of the 2.4.x versions. The switch from 2.4.x to 3.x was in 2015 and in terms of features, speed and transparency, it makes much sense to use the newer versions. You can read here and here about major differences. 2.4.x versions are still supported though, current release is 2.4.13.5.Installing a specific version, e.g. OpenCV 2.4.9
That said: If you want to install a specific version that neither
pip install opencv-python==2.4.X
,sudo apt-get install opencv
norconda install opencv=2.4.x
provide (as explained by other answers here), you can always install from sources. In the sourceforge repository you can find all major versions for each operating system. Although for unxeperienced users this might be scary, it is well explained in some tutorials. E.g. here for 2.4.9 on Ubuntu 14.04. Or here is the official Linux install doc for the latest release 2.4.13.5.In essence, the install process boils down to:
install dependencies, refer to docs (e.g. here) for required packages
get sources from OpenCVs sourceforge
e.g.
wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv-2.4.9.zip
unzip sources and prepare build by creating build directory and running cmake
build in the created build directory with:
will install cv2 in linux in branch python3.6