Skip to content

Commit f2f717b

Browse files
committed
qt 5.13 test
1 parent 83acfc9 commit f2f717b

File tree

8 files changed

+118
-69
lines changed

8 files changed

+118
-69
lines changed

cv2/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# wildcard import above does not import "private" variables like __version__
99
# this makes them available
10-
globals().update(importlib.import_module('cv2.cv2').__dict__)
10+
globals().update(importlib.import_module("cv2.cv2").__dict__)
1111

1212
is_ci_build = False
1313

@@ -18,7 +18,7 @@
1818
pass
1919

2020
# the Qt plugin is included currently only in the pre-built wheels
21-
if sys.platform == 'darwin' and is_ci_build:
22-
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = os.path.join(
23-
os.path.dirname(os.path.abspath(__file__)), 'qt', 'plugins'
21+
if (sys.platform == "darwin" or sys.platform.startswith("linux")) and is_ci_build:
22+
os.environ["QT_QPA_PLATFORM_PLUGIN_PATH"] = os.path.join(
23+
os.path.dirname(os.path.abspath(__file__)), "qt", "plugins"
2424
)

cv2/data/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import os
22

3-
haarcascades = os.path.join(os.path.dirname(__file__), '')
3+
haarcascades = os.path.join(os.path.dirname(__file__), "")

docker/manylinux2014/Dockerfile_i686

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
FROM quay.io/pypa/manylinux2014_i686:latest
22

3-
RUN yum install bzip2-devel curl-devel zlib-devel qt-devel -y
3+
RUN yum install bzip2-devel curl-devel zlib-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel freetype-devel -y
4+
5+
RUN curl -O -L https://download.qt.io/official_releases/qt/5.13/5.13.2/single/qt-everywhere-src-5.13.2.tar.xz && \
6+
tar -xf qt-everywhere-src-5.13.2.tar.xz && \
7+
cd qt-everywhere* && \
8+
export MAKEFLAGS=-j$(nproc) && \
9+
./configure -prefix /opt/Qt5.13.2 -release -opensource -confirm-license -qtnamespace QtOpenCVPython -qt-xcb -no-openssl -no-dbus -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdatavis3d -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtmultimedia -skip qtpurchasing -skip qtqa -skip qtremoteobjects -skip qtrepotools -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qttranslations -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip xmlpatterns -skip declarative -make libs && \
10+
make && \
11+
make install && \
12+
cd .. && \
13+
rm -rf qt-everywhere-src-5.13.2 && \
14+
rm qt-everywhere-src-5.13.2.tar.xz
15+
16+
ENV QTDIR /opt/Qt5.13.2
17+
ENV PATH "$QTDIR/bin:$PATH"
418

519
RUN mkdir ~/ffmpeg_sources && \
620
cd ~/ffmpeg_sources && \

docker/manylinux2014/Dockerfile_x86_64

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
FROM quay.io/pypa/manylinux2014_x86_64:latest
22

3-
RUN yum install bzip2-devel curl-devel zlib-devel qt-devel -y
3+
RUN yum install bzip2-devel curl-devel zlib-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel freetype-devel -y
4+
5+
RUN curl -O -L https://download.qt.io/official_releases/qt/5.13/5.13.2/single/qt-everywhere-src-5.13.2.tar.xz && \
6+
tar -xf qt-everywhere-src-5.13.2.tar.xz && \
7+
cd qt-everywhere* && \
8+
export MAKEFLAGS=-j$(nproc) && \
9+
./configure -prefix /opt/Qt5.13.2 -release -opensource -confirm-license -qtnamespace QtOpenCVPython -qt-xcb -no-openssl -no-dbus -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdatavis3d -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtmultimedia -skip qtpurchasing -skip qtqa -skip qtremoteobjects -skip qtrepotools -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qttranslations -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip xmlpatterns -skip declarative -make libs && \
10+
make && \
11+
make install && \
12+
cd .. && \
13+
rm -rf qt-everywhere-src-5.13.2 && \
14+
rm qt-everywhere-src-5.13.2.tar.xz
15+
16+
ENV QTDIR /opt/Qt5.13.2
17+
ENV PATH "$QTDIR/bin:$PATH"
418

519
RUN mkdir ~/ffmpeg_sources && \
620
cd ~/ffmpeg_sources && \

find_version.py

+63-51
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,66 @@
33
import subprocess
44

55
if __name__ == "__main__":
6-
contrib = sys.argv[1]
7-
headless = sys.argv[2]
8-
ci_build = sys.argv[3]
9-
10-
opencv_version = ""
11-
# dig out the version from OpenCV sources
12-
version_file_path = "opencv/modules/core/include/opencv2/core/version.hpp"
13-
14-
with open(version_file_path, 'r') as f:
15-
for line in f:
16-
words = line.split()
17-
18-
if "CV_VERSION_MAJOR" in words:
19-
opencv_version += words[2]
20-
opencv_version += "."
21-
22-
if "CV_VERSION_MINOR" in words:
23-
opencv_version += words[2]
24-
opencv_version += "."
25-
26-
if "CV_VERSION_REVISION" in words:
27-
opencv_version += words[2]
28-
break
29-
30-
# used in local dev releases
31-
git_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).splitlines()[0].decode()
32-
# this outputs the annotated tag if we are exactly on a tag, otherwise <tag>-<n>-g<shortened sha-1>
33-
try:
34-
tag = subprocess.check_output(['git', 'describe', '--tags'], stderr = subprocess.STDOUT).splitlines()[0].decode().split('-')
35-
except subprocess.CalledProcessError as e:
36-
# no tags reachable (e.g. on a topic branch in a fork), see
37-
# https://stackoverflow.com/questions/4916492/git-describe-fails-with-fatal-no-names-found-cannot-describe-anything
38-
if e.output.rstrip() == b"fatal: No names found, cannot describe anything.":
39-
tag=[]
40-
else:
41-
print(e.output); raise
42-
43-
if len(tag) == 1:
44-
# tag identifies the build and should be a sequential revision number
45-
version = tag[0]
46-
opencv_version += ".{}".format(version)
47-
else:
48-
# local version identifier, not to be published on PyPI
49-
version = git_hash
50-
opencv_version += "+{}".format(version)
51-
52-
with open('cv2/version.py', 'w') as f:
53-
f.write("opencv_version = \"{}\"\n".format(opencv_version))
54-
f.write("contrib = {}\n".format(contrib))
55-
f.write("headless = {}\n".format(headless))
56-
f.write("ci_build = {}".format(ci_build))
6+
contrib = sys.argv[1]
7+
headless = sys.argv[2]
8+
ci_build = sys.argv[3]
9+
10+
opencv_version = ""
11+
# dig out the version from OpenCV sources
12+
version_file_path = "opencv/modules/core/include/opencv2/core/version.hpp"
13+
14+
with open(version_file_path, "r") as f:
15+
for line in f:
16+
words = line.split()
17+
18+
if "CV_VERSION_MAJOR" in words:
19+
opencv_version += words[2]
20+
opencv_version += "."
21+
22+
if "CV_VERSION_MINOR" in words:
23+
opencv_version += words[2]
24+
opencv_version += "."
25+
26+
if "CV_VERSION_REVISION" in words:
27+
opencv_version += words[2]
28+
break
29+
30+
# used in local dev releases
31+
git_hash = (
32+
subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
33+
.splitlines()[0]
34+
.decode()
35+
)
36+
# this outputs the annotated tag if we are exactly on a tag, otherwise <tag>-<n>-g<shortened sha-1>
37+
try:
38+
tag = (
39+
subprocess.check_output(
40+
["git", "describe", "--tags"], stderr=subprocess.STDOUT
41+
)
42+
.splitlines()[0]
43+
.decode()
44+
.split("-")
45+
)
46+
except subprocess.CalledProcessError as e:
47+
# no tags reachable (e.g. on a topic branch in a fork), see
48+
# https://stackoverflow.com/questions/4916492/git-describe-fails-with-fatal-no-names-found-cannot-describe-anything
49+
if e.output.rstrip() == b"fatal: No names found, cannot describe anything.":
50+
tag = []
51+
else:
52+
print(e.output)
53+
raise
54+
55+
if len(tag) == 1:
56+
# tag identifies the build and should be a sequential revision number
57+
version = tag[0]
58+
opencv_version += ".{}".format(version)
59+
else:
60+
# local version identifier, not to be published on PyPI
61+
version = git_hash
62+
opencv_version += "+{}".format(version)
63+
64+
with open("cv2/version.py", "w") as f:
65+
f.write('opencv_version = "{}"\n'.format(opencv_version))
66+
f.write("contrib = {}\n".format(contrib))
67+
f.write("headless = {}\n".format(headless))
68+
f.write("ci_build = {}".format(ci_build))

patches/patchQtPlugins

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
diff --git a/opencv/CMakeLists.txt b/opencv/CMakeLists.txt
2-
index 8ccad4d03a..0d5e2a79e9 100644
2+
index 4c0b3880fc..54da25f151 100644
33
--- a/opencv/CMakeLists.txt
44
+++ b/opencv/CMakeLists.txt
5-
@@ -1164,6 +1164,7 @@ if(WITH_QT OR HAVE_QT)
5+
@@ -1187,6 +1187,12 @@ if(WITH_QT OR HAVE_QT)
66
if(HAVE_QT5)
77
status(" QT:" "YES (ver ${Qt5Core_VERSION_STRING})")
88
status(" QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${Qt5OpenGL_LIBRARIES} ${Qt5OpenGL_VERSION_STRING})" ELSE NO)
9-
+ install(DIRECTORY ${Qt5_DIR}/../../../plugins DESTINATION lib/qt)
9+
+ if(APPLE)
10+
+ install(DIRECTORY ${Qt5_DIR}/../../../plugins DESTINATION lib/qt)
11+
+ endif()
12+
+ if(UNIX AND NOT APPLE)
13+
+ install(DIRECTORY /opt/Qt5.13.2/plugins DESTINATION lib/qt)
14+
+ endif()
1015
elseif(HAVE_QT)
1116
status(" QT:" "YES (ver ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH} ${QT_EDITION})")
12-
status(" QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${QT_QTOPENGL_LIBRARY})" ELSE NO)
17+
status(" QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${QT_QTOPENGL_LIBRARY})" ELSE NO)

setup.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,21 @@ def main():
159159
if sys.platform.startswith("linux") and not x64 and "bdist_wheel" in sys.argv:
160160
subprocess.check_call("patch -p0 < patches/patchOpenEXR", shell=True)
161161

162-
# OS-specific components during CI builds
162+
# OS-specific components during CI build_headless
163163
if is_CI_build:
164-
if sys.platform.startswith("linux") and not build_headless:
165-
cmake_args.append("-DWITH_QT=4")
166164

167-
if sys.platform == "darwin" and not build_headless:
168-
if "bdist_wheel" in sys.argv:
169-
cmake_args.append("-DWITH_QT=5")
165+
if not build_headless and "bdist_wheel" in sys.argv:
166+
cmake_args.append("-DWITH_QT=5")
167+
subprocess.check_call("patch -p1 < patches/patchQtPlugins", shell=True)
168+
169+
if sys.platform.startswith("linux"):
170+
rearrange_cmake_output_data["cv2.qt.plugins.platforms"] = [
171+
(r"lib/qt/plugins/platforms/libqxcb\.so")
172+
]
173+
if sys.platform == "darwin":
170174
rearrange_cmake_output_data["cv2.qt.plugins.platforms"] = [
171175
(r"lib/qt/plugins/platforms/libqcocoa\.dylib")
172176
]
173-
subprocess.check_call("patch -p1 < patches/patchQtPlugins", shell=True)
174177

175178
if sys.platform.startswith("linux"):
176179
cmake_args.append("-DWITH_V4L=ON")

tests/test.py

+1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ def test_import(self):
1212
def test_video_capture(self):
1313

1414
import cv2
15+
1516
cap = cv2.VideoCapture("SampleVideo_1280x720_1mb.mp4")
1617
self.assertTrue(cap.isOpened())

0 commit comments

Comments
 (0)