From c4bfc751e2da5095d125c8e497f8f0e77a5ef013 Mon Sep 17 00:00:00 2001 From: Olli-Pekka Heinisuo Date: Wed, 13 Dec 2017 22:19:40 +0200 Subject: [PATCH 01/11] try new images, make sure that ffmpeg is built as LGPL library --- travis/build-wheels.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/travis/build-wheels.sh b/travis/build-wheels.sh index 4378d768..b34808c1 100755 --- a/travis/build-wheels.sh +++ b/travis/build-wheels.sh @@ -28,6 +28,8 @@ echo 'Begin build' cd opencv mkdir build +ffmpeg -L + export QTDIR=/opt/Qt4.8.7 export PATH=$QTDIR/bin:$PATH From e3b324d123f0ddfd62ba2447fb7b0185fbce095e Mon Sep 17 00:00:00 2001 From: Olli-Pekka Heinisuo Date: Wed, 13 Dec 2017 22:41:41 +0200 Subject: [PATCH 02/11] prepend ~/bin to PATH --- travis/build-wheels.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/travis/build-wheels.sh b/travis/build-wheels.sh index b34808c1..11ad1e37 100755 --- a/travis/build-wheels.sh +++ b/travis/build-wheels.sh @@ -28,6 +28,8 @@ echo 'Begin build' cd opencv mkdir build +export PATH=~/bin:$PATH + ffmpeg -L export QTDIR=/opt/Qt4.8.7 From 7d113a77dcde94a751edcd3f27daa3181ad8bb54 Mon Sep 17 00:00:00 2001 From: Olli-Pekka Heinisuo Date: Wed, 13 Dec 2017 22:49:44 +0200 Subject: [PATCH 03/11] enable linux video test --- tests/test.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test.py b/tests/test.py index cd560763..d5a3230a 100644 --- a/tests/test.py +++ b/tests/test.py @@ -1,5 +1,6 @@ import unittest -import os +import sys + class OpenCVTest(unittest.TestCase): """ Simple functionality tests. """ @@ -10,8 +11,8 @@ def test_import(self): def test_video_capture(self): - if os.name != 'posix': - import cv2 + if sys.platform != 'darwin': + import cv2 cap = cv2.VideoCapture("SampleVideo_1280x720_1mb.mp4") - self.assertTrue(cap.isOpened()) \ No newline at end of file + self.assertTrue(cap.isOpened()) From ad0c45a83eb66a3e57b6f54a165f8839d8e2d45f Mon Sep 17 00:00:00 2001 From: Olli-Pekka Heinisuo Date: Wed, 13 Dec 2017 23:12:18 +0200 Subject: [PATCH 04/11] add ffmpeg pkg config location --- travis/build-wheels.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/travis/build-wheels.sh b/travis/build-wheels.sh index 11ad1e37..92c785e7 100755 --- a/travis/build-wheels.sh +++ b/travis/build-wheels.sh @@ -28,6 +28,7 @@ echo 'Begin build' cd opencv mkdir build +export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/root/ffmpeg_build/lib/pkgconfig export PATH=~/bin:$PATH ffmpeg -L From 8cebceea8ee1368dc77ef42b07fe17b31c576615 Mon Sep 17 00:00:00 2001 From: Olli-Pekka Heinisuo Date: Wed, 13 Dec 2017 23:46:10 +0200 Subject: [PATCH 05/11] cherry-pick FFmpeg fix from OpenCV upstream --- travis/build-wheels.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/travis/build-wheels.sh b/travis/build-wheels.sh index 92c785e7..7477cec3 100755 --- a/travis/build-wheels.sh +++ b/travis/build-wheels.sh @@ -26,6 +26,11 @@ echo "Python numpy version: $PYTHON_NUMPY_VERSION" # Begin build echo 'Begin build' cd opencv + +# FFmpeg version is too new. +# This is a temporary fix from upstream until we have a new OpenCV release. +git cherry-pick b1d208891b9f + mkdir build export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/root/ffmpeg_build/lib/pkgconfig From 44c4ebc736b1dce6d53d97f0c38dc585f358d971 Mon Sep 17 00:00:00 2001 From: Olli-Pekka Heinisuo Date: Fri, 15 Dec 2017 17:39:11 +0200 Subject: [PATCH 06/11] add FFmpeg lib path to linker flags --- travis/build-wheels.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/travis/build-wheels.sh b/travis/build-wheels.sh index 7477cec3..505f7a1c 100755 --- a/travis/build-wheels.sh +++ b/travis/build-wheels.sh @@ -33,6 +33,7 @@ git cherry-pick b1d208891b9f mkdir build +export LDFLAGS=-L/root/ffmpeg_build/lib export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/root/ffmpeg_build/lib/pkgconfig export PATH=~/bin:$PATH From 0188706787884733b7561835d14abdfcac1e7f3e Mon Sep 17 00:00:00 2001 From: Olli-Pekka Heinisuo Date: Sat, 16 Dec 2017 15:52:27 +0200 Subject: [PATCH 07/11] add also libjepg-turbo --- travis/build-wheels.sh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/travis/build-wheels.sh b/travis/build-wheels.sh index 505f7a1c..2f4a5226 100755 --- a/travis/build-wheels.sh +++ b/travis/build-wheels.sh @@ -33,6 +33,14 @@ git cherry-pick b1d208891b9f mkdir build +export JPEG_INCLUDE_DIR="/opt/libjpeg-turbo/include" +export JPEG_LIBRARY="/opt/libjpeg-turbo/lib32/libjpeg.a" + +MACHINE_TYPE=$(uname -m) +if [[ ${MACHINE_TYPE} == 'x86_64' ]]; then + JPEG_LIBRARY="/opt/libjpeg-turbo/lib64/libjpeg.a" +fi + export LDFLAGS=-L/root/ffmpeg_build/lib export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/root/ffmpeg_build/lib/pkgconfig export PATH=~/bin:$PATH @@ -56,7 +64,9 @@ if [[ $PYTHON_VERSION == 2* ]] && [[ $ENABLE_CONTRIB == 0 ]]; then -DPYTHON2_INCLUDE_PATH="$PYTHON_INCLUDE_PATH" \ -DPYTHON2_PACKAGES_PATH="$PYTHON_PACKAGES_PATH" \ -DPYTHON2_NUMPY_INCLUDE_DIRS="$PYTHON_NUMPY_INCLUDE_DIRS" \ - -DPYTHON2_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" + -DPYTHON2_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" \ + -DJPEG_INCLUDE_DIR="JPEG_INCLUDE_DIR" \ + -DJPEG_LIBRARY="JPEG_LIBRARY" fi @@ -72,7 +82,9 @@ if [[ $PYTHON_VERSION == 3* ]] && [[ $ENABLE_CONTRIB == 0 ]]; then -DPYTHON3_INCLUDE_PATH="$PYTHON_INCLUDE_PATH" \ -DPYTHON3_PACKAGES_PATH="$PYTHON_PACKAGES_PATH" \ -DPYTHON3_NUMPY_INCLUDE_DIRS="$PYTHON_NUMPY_INCLUDE_DIRS" \ - -DPYTHON3_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" + -DPYTHON3_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" \ + -DJPEG_INCLUDE_DIR="JPEG_INCLUDE_DIR" \ + -DJPEG_LIBRARY="JPEG_LIBRARY" fi @@ -88,7 +100,9 @@ if [[ $PYTHON_VERSION == 2* ]] && [[ $ENABLE_CONTRIB == 1 ]]; then -DPYTHON2_INCLUDE_PATH="$PYTHON_INCLUDE_PATH" \ -DPYTHON2_PACKAGES_PATH="$PYTHON_PACKAGES_PATH" \ -DPYTHON2_NUMPY_INCLUDE_DIRS="$PYTHON_NUMPY_INCLUDE_DIRS" \ - -DPYTHON2_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" + -DPYTHON2_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" \ + -DJPEG_INCLUDE_DIR="JPEG_INCLUDE_DIR" \ + -DJPEG_LIBRARY="JPEG_LIBRARY" fi @@ -104,7 +118,9 @@ if [[ $PYTHON_VERSION == 3* ]] && [[ $ENABLE_CONTRIB == 1 ]]; then -DPYTHON3_INCLUDE_PATH="$PYTHON_INCLUDE_PATH" \ -DPYTHON3_PACKAGES_PATH="$PYTHON_PACKAGES_PATH" \ -DPYTHON3_NUMPY_INCLUDE_DIRS="$PYTHON_NUMPY_INCLUDE_DIRS" \ - -DPYTHON3_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" + -DPYTHON3_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" \ + -DJPEG_INCLUDE_DIR="JPEG_INCLUDE_DIR" \ + -DJPEG_LIBRARY="JPEG_LIBRARY" fi From a741c0eccbcaaebfb68c88b555202531d3b24bfb Mon Sep 17 00:00:00 2001 From: Olli-Pekka Heinisuo Date: Sat, 16 Dec 2017 16:59:06 +0200 Subject: [PATCH 08/11] add additional flags --- travis/build-wheels.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/travis/build-wheels.sh b/travis/build-wheels.sh index 2f4a5226..1a94b21d 100755 --- a/travis/build-wheels.sh +++ b/travis/build-wheels.sh @@ -65,6 +65,8 @@ if [[ $PYTHON_VERSION == 2* ]] && [[ $ENABLE_CONTRIB == 0 ]]; then -DPYTHON2_PACKAGES_PATH="$PYTHON_PACKAGES_PATH" \ -DPYTHON2_NUMPY_INCLUDE_DIRS="$PYTHON_NUMPY_INCLUDE_DIRS" \ -DPYTHON2_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" \ + -DWITH_JPEG=ON \ + -DBUILD_JPEG=OFF \ -DJPEG_INCLUDE_DIR="JPEG_INCLUDE_DIR" \ -DJPEG_LIBRARY="JPEG_LIBRARY" @@ -83,6 +85,8 @@ if [[ $PYTHON_VERSION == 3* ]] && [[ $ENABLE_CONTRIB == 0 ]]; then -DPYTHON3_PACKAGES_PATH="$PYTHON_PACKAGES_PATH" \ -DPYTHON3_NUMPY_INCLUDE_DIRS="$PYTHON_NUMPY_INCLUDE_DIRS" \ -DPYTHON3_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" \ + -DWITH_JPEG=ON \ + -DBUILD_JPEG=OFF \ -DJPEG_INCLUDE_DIR="JPEG_INCLUDE_DIR" \ -DJPEG_LIBRARY="JPEG_LIBRARY" @@ -101,6 +105,8 @@ if [[ $PYTHON_VERSION == 2* ]] && [[ $ENABLE_CONTRIB == 1 ]]; then -DPYTHON2_PACKAGES_PATH="$PYTHON_PACKAGES_PATH" \ -DPYTHON2_NUMPY_INCLUDE_DIRS="$PYTHON_NUMPY_INCLUDE_DIRS" \ -DPYTHON2_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" \ + -DWITH_JPEG=ON \ + -DBUILD_JPEG=OFF \ -DJPEG_INCLUDE_DIR="JPEG_INCLUDE_DIR" \ -DJPEG_LIBRARY="JPEG_LIBRARY" @@ -119,6 +125,8 @@ if [[ $PYTHON_VERSION == 3* ]] && [[ $ENABLE_CONTRIB == 1 ]]; then -DPYTHON3_PACKAGES_PATH="$PYTHON_PACKAGES_PATH" \ -DPYTHON3_NUMPY_INCLUDE_DIRS="$PYTHON_NUMPY_INCLUDE_DIRS" \ -DPYTHON3_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" \ + -DWITH_JPEG=ON \ + -DBUILD_JPEG=OFF \ -DJPEG_INCLUDE_DIR="JPEG_INCLUDE_DIR" \ -DJPEG_LIBRARY="JPEG_LIBRARY" From 30309f4984d05918d5f758e2cf0fada33b8d4be9 Mon Sep 17 00:00:00 2001 From: Olli-Pekka Heinisuo Date: Sat, 16 Dec 2017 17:38:35 +0200 Subject: [PATCH 09/11] add missing $ --- travis/build-wheels.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/travis/build-wheels.sh b/travis/build-wheels.sh index 1a94b21d..6a8dd0a7 100755 --- a/travis/build-wheels.sh +++ b/travis/build-wheels.sh @@ -67,8 +67,8 @@ if [[ $PYTHON_VERSION == 2* ]] && [[ $ENABLE_CONTRIB == 0 ]]; then -DPYTHON2_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" \ -DWITH_JPEG=ON \ -DBUILD_JPEG=OFF \ - -DJPEG_INCLUDE_DIR="JPEG_INCLUDE_DIR" \ - -DJPEG_LIBRARY="JPEG_LIBRARY" + -DJPEG_INCLUDE_DIR="$JPEG_INCLUDE_DIR" \ + -DJPEG_LIBRARY="$JPEG_LIBRARY" fi @@ -87,8 +87,8 @@ if [[ $PYTHON_VERSION == 3* ]] && [[ $ENABLE_CONTRIB == 0 ]]; then -DPYTHON3_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" \ -DWITH_JPEG=ON \ -DBUILD_JPEG=OFF \ - -DJPEG_INCLUDE_DIR="JPEG_INCLUDE_DIR" \ - -DJPEG_LIBRARY="JPEG_LIBRARY" + -DJPEG_INCLUDE_DIR="$JPEG_INCLUDE_DIR" \ + -DJPEG_LIBRARY="$JPEG_LIBRARY" fi @@ -107,8 +107,8 @@ if [[ $PYTHON_VERSION == 2* ]] && [[ $ENABLE_CONTRIB == 1 ]]; then -DPYTHON2_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" \ -DWITH_JPEG=ON \ -DBUILD_JPEG=OFF \ - -DJPEG_INCLUDE_DIR="JPEG_INCLUDE_DIR" \ - -DJPEG_LIBRARY="JPEG_LIBRARY" + -DJPEG_INCLUDE_DIR="$JPEG_INCLUDE_DIR" \ + -DJPEG_LIBRARY="$JPEG_LIBRARY" fi @@ -127,8 +127,8 @@ if [[ $PYTHON_VERSION == 3* ]] && [[ $ENABLE_CONTRIB == 1 ]]; then -DPYTHON3_NUMPY_VERSION="$PYTHON_NUMPY_VERSION" \ -DWITH_JPEG=ON \ -DBUILD_JPEG=OFF \ - -DJPEG_INCLUDE_DIR="JPEG_INCLUDE_DIR" \ - -DJPEG_LIBRARY="JPEG_LIBRARY" + -DJPEG_INCLUDE_DIR="$JPEG_INCLUDE_DIR" \ + -DJPEG_LIBRARY="$JPEG_LIBRARY" fi From fb2a97c5d06ec951c35c08214bf0a80c6998c447 Mon Sep 17 00:00:00 2001 From: Olli-Pekka Heinisuo Date: Mon, 18 Dec 2017 18:19:24 +0200 Subject: [PATCH 10/11] update READMEs --- README.rst | 14 ++------------ README_CONTRIB.rst | 14 ++------------ 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/README.rst b/README.rst index 6f8eed53..1d9d0eb0 100644 --- a/README.rst +++ b/README.rst @@ -11,10 +11,6 @@ This enables super fast (usually < 10 seconds) OpenCV installation for Python. If you need only OpenCV Python bindings, no separate OpenCV installation is required. -**IMPORTANT NOTE** - -MacOS and Linux packages do not support video related functionality (not compiled with FFmpeg). - Installation and Usage ---------------------- @@ -49,7 +45,7 @@ A: The wheel package format and manylinux builds are pretty new things. Most lik **Q: I need contrib modules?** -A: Please install `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. +A: Please install `opencv-contrib-python `__ instead. However, note that commercial usage might be restricted in some countries since the contrib modules might contain some non-free/patented algorithms. **Q: Import fails on Windows to some DLL load error?** @@ -61,12 +57,6 @@ See also `this issue `__ if y A: Make sure you have removed old manual installations of OpenCV Python bindings (cv2.so or cv2.pyd in site-packages). -**Q: Why I can't open video files on GNU/Linux distribution X or on macOS?** - -A: OpenCV video I/O depends heavily on FFmpeg. Manylinux and macOS OpenCV binaries are not compiled against it. -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. -Adding FFmpeg as an additional dependency without a "universal" FFmpeg build (e.g. LGPL licensed build like in the Windows wheels) the goal is considerably harder to achieve. This might change in the future. - Documentation for opencv-python ------------------------------- @@ -139,7 +129,7 @@ OpenCV itself is available under `3-clause BSD License `__ (`LICENSE-3RD-PARTY.txt `__). -Windows wheels ship with `FFmpeg `__ licensed under the `LGPLv2.1 `__. +All wheels ship with `FFmpeg `__ licensed under the `LGPLv2.1 `__. Linux and MacOS wheels ship with `Qt 4.8.7 `__ licensed under the `LGPLv2.1 `__. diff --git a/README_CONTRIB.rst b/README_CONTRIB.rst index 11bf61e7..53f60e0b 100644 --- a/README_CONTRIB.rst +++ b/README_CONTRIB.rst @@ -3,7 +3,7 @@ OpenCV on Wheels **Unofficial** OpenCV packages for Python with contrib modules. -**Note: the usage of opencv-contrib-python might be restricted in some countries since the contrib package contains some patented algorithms/non-free modules.** +**Note: the (commercial) usage of opencv-contrib-python might be restricted in some countries since the contrib package might contain some patented algorithms/non-free modules.** If you are looking for a version without the contrib modules, please install `opencv-python `__ instead. @@ -12,10 +12,6 @@ This enables super fast (usually < 10 seconds) OpenCV installation for Python. If you need only OpenCV Python bindings, no separate OpenCV installation is required. -**IMPORTANT NOTE** - -MacOS and Linux wheels do not support video related functionality (not compiled with FFmpeg). - Installation and Usage ---------------------- @@ -57,12 +53,6 @@ See also `this issue `__ if y A: Make sure you have removed old manual installations of OpenCV Python bindings (cv2.so or cv2.pyd in site-packages). -**Q: Why I can't open video files on GNU/Linux distribution X or on macOS?** - -A: OpenCV video I/O depends heavily on FFmpeg. Manylinux and macOS OpenCV binaries provided withing these packages are not compiled against it. -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. -Adding FFmpeg as an additional dependency without a "universal" FFmpeg build (e.g. LGPL licensed build like in the Windows wheels) the goal is considerably harder to achieve. This might change in the future. - Documentation for opencv-python ------------------------------- @@ -135,7 +125,7 @@ OpenCV itself is available under `3-clause BSD License `__ (`LICENSE-3RD-PARTY.txt `__). -Windows wheels ship with `FFmpeg `__ licensed under the `LGPLv2.1 `__. +All wheels ship with `FFmpeg `__ licensed under the `LGPLv2.1 `__. Linux and MacOS wheels ship with `Qt 4.8.7 `__ licensed under the `LGPLv2.1 `__. From 08fe8b268efeb0819d14dadccead606cd6aa3516 Mon Sep 17 00:00:00 2001 From: Olli-Pekka Heinisuo Date: Tue, 19 Dec 2017 18:24:30 +0200 Subject: [PATCH 11/11] enable all video tests --- tests/test.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/test.py b/tests/test.py index d5a3230a..e520814f 100644 --- a/tests/test.py +++ b/tests/test.py @@ -11,8 +11,6 @@ def test_import(self): def test_video_capture(self): - if sys.platform != 'darwin': - - import cv2 - cap = cv2.VideoCapture("SampleVideo_1280x720_1mb.mp4") - self.assertTrue(cap.isOpened()) + import cv2 + cap = cv2.VideoCapture("SampleVideo_1280x720_1mb.mp4") + self.assertTrue(cap.isOpened())