未验证 提交 8b596d06 编写于 作者: O Olli-Pekka Heinisuo 提交者: GitHub

Linux FFmpeg + libjpeg-turbo builds (#59)

* try new images, make sure that ffmpeg is built as LGPL library

* prepend ~/bin to PATH

* enable linux video test

* add ffmpeg pkg config location

* cherry-pick FFmpeg fix from OpenCV upstream

* add FFmpeg lib path to linker flags

* add also libjepg-turbo

* add additional flags

* add missing $

* update READMEs

* enable all video tests
上级 731e0d43
......@@ -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 <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.
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 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 <https://github.com/skvark/opencv-python/issues/36>`__ 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 <https://github.com/opencv/opencv/blob/master/LICENSE>`__
(`LICENSE-3RD-PARTY.txt <https://github.com/skvark/opencv-python/blob/master/LICENSE-3RD-PARTY.txt>`__).
Windows wheels ship with `FFmpeg <http://ffmpeg.org>`__ licensed under the `LGPLv2.1 <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>`__.
All wheels ship with `FFmpeg <http://ffmpeg.org>`__ licensed under the `LGPLv2.1 <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>`__.
Linux and MacOS wheels ship with `Qt 4.8.7 <http://doc.qt.io/qt-4.8/lgpl.html>`__ licensed under the `LGPLv2.1 <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>`__.
......
......@@ -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 <https://pypi.python.org/pypi/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 <https://github.com/skvark/opencv-python/issues/36>`__ 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 <https://github.com/opencv/opencv/blob/master/LICENSE>`__
(`LICENSE-3RD-PARTY.txt <https://github.com/skvark/opencv-python/blob/master/LICENSE-3RD-PARTY.txt>`__).
Windows wheels ship with `FFmpeg <http://ffmpeg.org>`__ licensed under the `LGPLv2.1 <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>`__.
All wheels ship with `FFmpeg <http://ffmpeg.org>`__ licensed under the `LGPLv2.1 <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>`__.
Linux and MacOS wheels ship with `Qt 4.8.7 <http://doc.qt.io/qt-4.8/lgpl.html>`__ licensed under the `LGPLv2.1 <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>`__.
......
import unittest
import os
import sys
class OpenCVTest(unittest.TestCase):
""" Simple functionality tests. """
......@@ -10,8 +11,6 @@ class OpenCVTest(unittest.TestCase):
def test_video_capture(self):
if os.name != 'posix':
import cv2
cap = cv2.VideoCapture("SampleVideo_1280x720_1mb.mp4")
self.assertTrue(cap.isOpened())
\ No newline at end of file
import cv2
cap = cv2.VideoCapture("SampleVideo_1280x720_1mb.mp4")
self.assertTrue(cap.isOpened())
......@@ -26,8 +26,27 @@ 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 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
ffmpeg -L
export QTDIR=/opt/Qt4.8.7
export PATH=$QTDIR/bin:$PATH
......@@ -45,7 +64,11 @@ 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" \
-DWITH_JPEG=ON \
-DBUILD_JPEG=OFF \
-DJPEG_INCLUDE_DIR="$JPEG_INCLUDE_DIR" \
-DJPEG_LIBRARY="$JPEG_LIBRARY"
fi
......@@ -61,7 +84,11 @@ 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" \
-DWITH_JPEG=ON \
-DBUILD_JPEG=OFF \
-DJPEG_INCLUDE_DIR="$JPEG_INCLUDE_DIR" \
-DJPEG_LIBRARY="$JPEG_LIBRARY"
fi
......@@ -77,7 +104,11 @@ 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" \
-DWITH_JPEG=ON \
-DBUILD_JPEG=OFF \
-DJPEG_INCLUDE_DIR="$JPEG_INCLUDE_DIR" \
-DJPEG_LIBRARY="$JPEG_LIBRARY"
fi
......@@ -93,7 +124,11 @@ 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" \
-DWITH_JPEG=ON \
-DBUILD_JPEG=OFF \
-DJPEG_INCLUDE_DIR="$JPEG_INCLUDE_DIR" \
-DJPEG_LIBRARY="$JPEG_LIBRARY"
fi
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册