Skip to content

Commit 81a454c

Browse files
committed
merge opencv_contrib for testing
2 parents caae056 + e720f7e commit 81a454c

13 files changed

+668
-130
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "multibuild"]
55
path = multibuild
66
url = https://github.com/matthew-brett/multibuild.git
7+
[submodule "opencv_contrib"]
8+
path = opencv_contrib
9+
url = https://github.com/opencv/opencv_contrib.git

.travis.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,79 +27,188 @@ matrix:
2727
# Exclude the default Python 3.5 build
2828
- python: 3.5
2929
include:
30+
31+
# default builds for MacOS
32+
- os: osx
33+
language: generic
34+
osx_image: xcode8.2
35+
env:
36+
- MB_PYTHON_VERSION=2.7
37+
- ENABLE_CONTRIB=0
38+
- os: osx
39+
language: generic
40+
osx_image: xcode8.2
41+
env:
42+
- MB_PYTHON_VERSION=3.4
43+
- ENABLE_CONTRIB=0
44+
- os: osx
45+
language: generic
46+
osx_image: xcode8.2
47+
env:
48+
- MB_PYTHON_VERSION=3.5
49+
- ENABLE_CONTRIB=0
50+
- os: osx
51+
language: generic
52+
osx_image: xcode8.2
53+
env:
54+
- MB_PYTHON_VERSION=3.6
55+
- ENABLE_CONTRIB=0
56+
57+
# Contrib builds for MacOS
3058
- os: osx
3159
language: generic
3260
osx_image: xcode8.2
3361
env:
3462
- MB_PYTHON_VERSION=2.7
63+
- ENABLE_CONTRIB=1
3564
- os: osx
3665
language: generic
3766
osx_image: xcode8.2
3867
env:
3968
- MB_PYTHON_VERSION=3.4
69+
- ENABLE_CONTRIB=1
4070
- os: osx
4171
language: generic
4272
osx_image: xcode8.2
4373
env:
4474
- MB_PYTHON_VERSION=3.5
75+
- ENABLE_CONTRIB=1
4576
- os: osx
4677
language: generic
4778
osx_image: xcode8.2
4879
env:
4980
- MB_PYTHON_VERSION=3.6
81+
- ENABLE_CONTRIB=1
82+
83+
# default builds for Linux
84+
- os: linux
85+
env:
86+
- MB_PYTHON_VERSION=2.7
87+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
88+
- ENABLE_CONTRIB=0
89+
- os: linux
90+
env:
91+
- MB_PYTHON_VERSION=2.7
92+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
93+
- UNICODE_WIDTH=16
94+
- ENABLE_CONTRIB=0
95+
- os: linux
96+
env:
97+
- MB_PYTHON_VERSION=2.7
98+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
99+
- PLAT=i686
100+
- ENABLE_CONTRIB=0
101+
- os: linux
102+
env:
103+
- MB_PYTHON_VERSION=2.7
104+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
105+
- PLAT=i686
106+
- UNICODE_WIDTH=16
107+
- ENABLE_CONTRIB=0
108+
- os: linux
109+
env:
110+
- MB_PYTHON_VERSION=3.4
111+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
112+
- ENABLE_CONTRIB=0
113+
- os: linux
114+
env:
115+
- MB_PYTHON_VERSION=3.4
116+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
117+
- PLAT=i686
118+
- ENABLE_CONTRIB=0
119+
- os: linux
120+
env:
121+
- MB_PYTHON_VERSION=3.5
122+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
123+
- ENABLE_CONTRIB=0
124+
- os: linux
125+
env:
126+
- MB_PYTHON_VERSION=3.5
127+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
128+
- PLAT=i686
129+
- ENABLE_CONTRIB=0
130+
- os: linux
131+
env:
132+
- MB_PYTHON_VERSION=3.6
133+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
134+
- ENABLE_CONTRIB=0
135+
- BUILD_DEPENDS=numpy==1.11.3
136+
- TEST_DEPENDS=numpy==1.11.3
137+
- os: linux
138+
env:
139+
- MB_PYTHON_VERSION=3.6
140+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
141+
- PLAT=i686
142+
- ENABLE_CONTRIB=0
143+
- BUILD_DEPENDS=numpy==1.11.3
144+
- TEST_DEPENDS=numpy==1.11.3
145+
146+
# contrib builds for Linux
50147
- os: linux
51148
env:
52149
- MB_PYTHON_VERSION=2.7
53150
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
151+
- ENABLE_CONTRIB=1
54152
- os: linux
55153
env:
56154
- MB_PYTHON_VERSION=2.7
57155
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
58156
- UNICODE_WIDTH=16
157+
- ENABLE_CONTRIB=1
59158
- os: linux
60159
env:
61160
- MB_PYTHON_VERSION=2.7
62161
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
63162
- PLAT=i686
163+
- ENABLE_CONTRIB=1
64164
- os: linux
65165
env:
66166
- MB_PYTHON_VERSION=2.7
67167
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
68168
- PLAT=i686
69169
- UNICODE_WIDTH=16
170+
- ENABLE_CONTRIB=1
70171
- os: linux
71172
env:
72173
- MB_PYTHON_VERSION=3.4
73174
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
175+
- ENABLE_CONTRIB=1
74176
- os: linux
75177
env:
76178
- MB_PYTHON_VERSION=3.4
77179
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
78180
- PLAT=i686
181+
- ENABLE_CONTRIB=1
79182
- os: linux
80183
env:
81184
- MB_PYTHON_VERSION=3.5
82185
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
186+
- ENABLE_CONTRIB=1
83187
- os: linux
84188
env:
85189
- MB_PYTHON_VERSION=3.5
86190
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
87191
- PLAT=i686
192+
- ENABLE_CONTRIB=1
88193
- os: linux
89194
env:
90195
- MB_PYTHON_VERSION=3.6
91196
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
92197
- BUILD_DEPENDS=numpy==1.11.3
93198
- TEST_DEPENDS=numpy==1.11.3
199+
- ENABLE_CONTRIB=1
200+
94201
- os: linux
95202
env:
96203
- MB_PYTHON_VERSION=3.6
97204
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
98205
- PLAT=i686
99206
- BUILD_DEPENDS=numpy==1.11.3
100207
- TEST_DEPENDS=numpy==1.11.3
208+
- ENABLE_CONTRIB=1
101209

102210
before_install:
211+
- echo $ENABLE_CONTRIB > contrib.enabled
103212
- source multibuild/common_utils.sh
104213
- source multibuild/travis_steps.sh
105214
- python find_version.py
@@ -117,3 +226,4 @@ after_success:
117226
# Upload wheels to pypi
118227
- pip install twine
119228
- if [ -n "$TRAVIS_TAG" ]; then twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*; else echo "Tag not set, deployment skipped."; fi
229+
- source travis/deploy.sh

MANIFEST.in

Lines changed: 0 additions & 2 deletions
This file was deleted.

README.rst

Lines changed: 67 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,78 @@
66
:target: https://travis-ci.org/skvark/opencv-python
77
:alt: Travis CI test status (Linux and OS X)
88

9-
OpenCV on wheels
9+
OpenCV on Wheels
1010
================
1111

1212
**Unofficial** OpenCV packages for Python.
1313

14-
This repository generates packages which contain pre-compiled OpenCV binary with Python bindings. This enables super fast (usually < 10 seconds) OpenCV installation for Python.
14+
This package contains only the OpenCV core modules without the optional contrib modules.
15+
If you are looking for a version which includes OpenCV contrib modules, please install `opencv-contrib-python <https://pypi.python.org/pypi/opencv-contrib-python>`__ instead.
1516

16-
If you need only OpenCV Python bindings, no separate OpenCV installation is required.
17+
The packages contain pre-compiled OpenCV binary with Python bindings.
18+
This enables super fast (usually < 10 seconds) OpenCV installation for Python.
19+
20+
If you need only OpenCV Python bindings, no separate OpenCV installation is required.
1721

1822
**IMPORTANT NOTE**
1923

20-
MacOS and Linux wheels have some limitations:
24+
MacOS and Linux wheels have currently some limitations:
2125

2226
- video related functionality is not supported (not compiled with FFmpeg)
23-
- for example ``cv.imshow()`` will not work (not compiled with GTK+ 2.x or Carbon support)
27+
- for example ``cv2.imshow()`` will not work (not compiled with GTK+ 2.x or Carbon support)
2428

2529
Installation and Usage
2630
----------------------
2731

2832
1. If you have previous/other version of OpenCV installed (e.g. cv2 module in the root of Python's site-packages), remove it before installation to avoid conflicts.
2933
- To further avoid conflicts and to make development easier, Python's `virtual environments <https://docs.python.org/3/library/venv.html>`__ are highly recommended for development purposes.
30-
2. Install this package:
34+
35+
2. If you have an existing ``opencv-contrib-python`` installation, run ``pip uninstall opencv-contrib-python``
36+
37+
3. Install this package:
3138

3239
``pip install opencv-python``
3340

34-
3. Import the package:
41+
4. Import the package:
3542

3643
``import cv2``
3744

38-
4. Read `OpenCV documentation <http://docs.opencv.org/>`__
45+
5. Read `OpenCV documentation <http://docs.opencv.org/>`__
46+
47+
6. Before opening a new issue, read the FAQ below and have a look at the other issues which are already open.
48+
49+
Frequently Asked Questions
50+
--------------------------
51+
52+
**Q: Do I need to install also OpenCV separately?**
53+
54+
A: No, the packages are special wheel binary packages and they already contain statically built OpenCV binaries.
55+
56+
**Q: Pip does not find package ``opencv-python``?**
57+
58+
A: The wheel package format and manylinux builds are pretty new things. Most likely the issue is related to too old pip and can be fixed by running ``pip install --upgrade pip``.
59+
60+
**Q: I need contrib modules?**
61+
62+
A: Please install `opencv-contrib-python <https://pypi.python.org/pypi/opencv-contrib-python>`__ instead. However, note that commercial usage might be restricted in some countries since the contrib modules contain some non-free/patented algorithms.
63+
64+
**Q: Import fails on Windows to some DLL load error?**
65+
66+
A: If the import fails on Windows, make sure you have `Visual C++ redistributable 2015 <https://www.microsoft.com/en-us/download/details.aspx?id=48145>`__ installed. If you are using older Windows version than Windows 10 and latest system updates are not installed, `Universal C Runtime <https://support.microsoft.com/en-us/help/2999226/update-for-universal-c-runtime-in-windows>`__ might be also required.
67+
68+
**Q: I have some other import errors?**
69+
70+
A: Make sure you have removed old manual installations of OpenCV Python bindings (cv2.so or cv2.pyd in site-packages).
71+
72+
**Q: Why I can't open video files on GNU/Linux distribution X or on macOS?**
73+
74+
A: OpenCV video I/O depends heavily on FFmpeg. Manylinux and macOS OpenCV binaries are not compiled against it.
75+
The purpose of these packages is to provide as easy as possible installation experience for OpenCV Python bindings and they should work directly out-of-the-box.
76+
Adding FFmpeg as an additional dependency without a "universal" FFmpeg build (e.g. LGPL licensed static build like in the Windows wheels) the goal is considerably harder to achieve. This might change in the future.
77+
78+
**Q: Why I can't open GUI windows (``cv2.imshow()``) on GNU/Linux distribution X or on macOS?**
79+
80+
A: Like above, OpenCV was not compiled against GTK or Carbon. Support for these might be added in the future.
3981

4082
Documentation for opencv-python
4183
-------------------------------
@@ -52,36 +94,46 @@ Build process
5294
-------------
5395

5496
The project is structured like a normal Python package with a standard
55-
``setup.py`` file. The build process is as follows (see for example
97+
``setup.py`` file. The build process for a single entry in the build matrices is as follows (see for example
5698
``appveyor.yml`` file):
5799

58100
1. Checkout repository and submodules
59101

60102
- OpenCV is included as submodule and the version is updated
61103
manually by maintainers when a new OpenCV release has been made
104+
- Contrib modules are also included as a submodule
62105

63106
2. Find OpenCV version from the sources
64-
3. Upgrade pip and install numpy for each Python version
107+
3. Install dependencies (numpy)
65108
4. Build OpenCV
66109

67110
- tests are disabled, otherwise build time increases too much
111+
- there are 2 build matrix entries for each build combination: with and without contrib modules
112+
- Linux builds run in manylinux Docker containers (CentOS 5)
68113

69114
5. Copy each ``.pyd/.so`` file to cv2 folder of this project and
70115
generate wheel
71-
6. Install the generated wheels for each Python version
72-
7. Test that the Python versions can import them
73-
8. Use twine to upload all wheels to PyPI
116+
117+
- Linux and macOS wheels are checked with auditwheel and delocate
118+
119+
6. Install the generated wheel
120+
7. Test that Python can import the library and run some sanity checks
121+
8. Use twine to upload the generated wheel to PyPI (only in release builds)
74122

75123
Currently the ``find_version.py`` file parses OpenCV version information
76124
from the OpenCV sources. OpenCV depends on numpy, so ``setup.py`` checks
77-
the numpy version also with the help of pip.
125+
the minimum required numpy version also with the help of pip.
78126

79-
The ``cv2.pyd`` file for example on Windows is normally copied to site-packages.
127+
The ``cv2.pyd`` file is normally copied to site-packages.
80128
To avoid polluting the root folder the ``__init__.py`` file in cv2 folder
81129
handles the import logic correctly by importing the actual ``.pyd`` module
82130
and replacing the imported cv2 package in ``sys.modudes`` with the
83131
cv2 module to retain backward compatibility.
84132

133+
Since both ``opencv-python`` and ``opencv-contrib-python`` use the same namespace explained above,
134+
it is highly recommended to uninstall the other package before switching from example from
135+
``opencv-python`` to ``opencv-contrib-python`` package.
136+
85137
Licensing
86138
---------
87139

0 commit comments

Comments
 (0)