diff --git a/b624b995ec9c439cbc2e9e6ee940d3a2-v0.1.1f.zip b/b624b995ec9c439cbc2e9e6ee940d3a2-v0.1.1f.zip new file mode 100644 index 0000000000000000000000000000000000000000..a65465b211656c9611e5f1c0b75c9c2da766c17d Binary files /dev/null and b/b624b995ec9c439cbc2e9e6ee940d3a2-v0.1.1f.zip differ diff --git a/face_landmark_model.dat.xz b/face_landmark_model.dat.xz new file mode 100644 index 0000000000000000000000000000000000000000..b66a21034c37dfaa721e5bfb9e7680245af798f9 Binary files /dev/null and b/face_landmark_model.dat.xz differ diff --git a/opencv-4.1.0-install_3rdparty_licenses.patch b/opencv-4.1.0-install_3rdparty_licenses.patch new file mode 100644 index 0000000000000000000000000000000000000000..7bbc85f66cff52e5b9cc353d5ac13eb5cac5f491 --- /dev/null +++ b/opencv-4.1.0-install_3rdparty_licenses.patch @@ -0,0 +1,11 @@ +--- ./cmake/OpenCVDetectOpenCL.cmake.orig 2019-05-14 00:35:41.373094435 +0100 ++++ ./cmake/OpenCVDetectOpenCL.cmake 2019-05-14 00:35:50.833189862 +0100 +@@ -5,7 +5,7 @@ if(APPLE) + else() + set(OPENCL_LIBRARY "" CACHE STRING "OpenCL library") + set(OPENCL_INCLUDE_DIR "${OpenCV_SOURCE_DIR}/3rdparty/include/opencl/1.2" CACHE PATH "OpenCL include directory") +- ocv_install_3rdparty_licenses(opencl-headers "${OpenCV_SOURCE_DIR}/3rdparty/include/opencl/LICENSE.txt") ++ #ocv_install_3rdparty_licenses(opencl-headers "${OpenCV_SOURCE_DIR}/3rdparty/include/opencl/LICENSE.txt") + endif() + mark_as_advanced(OPENCL_INCLUDE_DIR OPENCL_LIBRARY) + diff --git a/opencv-clean-4.5.2.tar.gz b/opencv-clean-4.5.2.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..b52fdb0901a5420c76bb80f853ff04712cb8f981 Binary files /dev/null and b/opencv-clean-4.5.2.tar.gz differ diff --git a/opencv-py2-to-py3.patch b/opencv-py2-to-py3.patch new file mode 100644 index 0000000000000000000000000000000000000000..f93e3f7732ea16d97d1315af148a5b2bb056dd53 --- /dev/null +++ b/opencv-py2-to-py3.patch @@ -0,0 +1,6128 @@ +--- ./doc/tools/add_signatures.py (original) ++++ ./doc/tools/add_signatures.py (refactored) +@@ -11,7 +11,7 @@ + * clarify special case: + http://docs.opencv.org/3.2.0/db/de0/group__core__utils.html#ga4910d7f86336cd4eff9dd05575667e41 + """ +-from __future__ import print_function ++ + import sys + sys.dont_write_bytecode = True # Don't generate .pyc files / __pycache__ directories + +--- ./modules/calib3d/misc/python/test/test_calibration.py (original) ++++ ./modules/calib3d/misc/python/test/test_calibration.py (refactored) +@@ -6,7 +6,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./doc/tools/scan_tutorials.py (original) ++++ ./doc/tools/scan_tutorials.py (refactored) +@@ -34,7 +34,7 @@ + if m: + self.prev = m.group(1) + continue +- if self.next is None: ++ if self.__next__ is None: + m = rx_next.search(line) + if m: + self.next = m.group(1) +@@ -55,19 +55,19 @@ + for one in self.children: + c = storage[one] + if c.prev is not None and c.prev != prev: +- print("[W] Wrong prev_tutorial: expected {} / actual {}".format(c.prev, prev)) ++ print(("[W] Wrong prev_tutorial: expected {} / actual {}".format(c.prev, prev))) + res = False + prev = c.title + + next = None + for one in reversed(self.children): + c = storage[one] +- if c.next is not None and c.next != next: +- print("[W] Wrong next_tutorial: expected {} / actual {}".format(c.next, next)) ++ if c.__next__ is not None and c.__next__ != next: ++ print(("[W] Wrong next_tutorial: expected {} / actual {}".format(c.__next__, next))) + res = False + next = c.title + +- if len(self.children) == 0 and self.prev is None and self.next is None: ++ if len(self.children) == 0 and self.prev is None and self.__next__ is None: + print("[W] No prev and next tutorials") + res = False + +@@ -76,7 +76,7 @@ + if __name__ == "__main__": + + p = Path('tutorials') +- print("Looking for tutorials in: '{}'".format(p)) ++ print(("Looking for tutorials in: '{}'".format(p))) + + all_tutorials = dict() + for f in p.glob('**/*'): +@@ -85,11 +85,11 @@ + all_tutorials[t.title] = t + + res = 0 +- print("Found: {}".format(len(all_tutorials))) ++ print(("Found: {}".format(len(all_tutorials)))) + print("------") +- for title, t in all_tutorials.items(): ++ for title, t in list(all_tutorials.items()): + if not t.verify_prev_next(all_tutorials): +- print("[E] Verification failed: {}".format(t.path)) ++ print(("[E] Verification failed: {}".format(t.path))) + print("------") + res = 1 + +--- ./modules/calib3d/misc/python/test/test_solvepnp.py (original) ++++ ./modules/calib3d/misc/python/test/test_solvepnp.py (refactored) +@@ -1,6 +1,6 @@ + #!/usr/bin/env python + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./modules/core/src/opencl/runtime/generator/parser_clamdfft.py (original) ++++ ./modules/core/src/opencl/runtime/generator/parser_clamdfft.py (refactored) +@@ -1,7 +1,7 @@ + #!/bin/python + # usage: + # cat clAmdFft.h | $0 +-from __future__ import print_function ++ + import sys, re; + + from common import remove_comments, getTokens, getParameters, postProcessParameters +--- ./modules/gapi/scripts/measure_privacy_masking.py (original) ++++ ./modules/gapi/scripts/measure_privacy_masking.py (refactored) +@@ -16,7 +16,7 @@ + ## The script itself ################################################# + ## + if len(sys.argv) != 3: +- print("Usage: %s /path/to/input/video /path/to/models" % sys.argv[0]) ++ print(("Usage: %s /path/to/input/video /path/to/models" % sys.argv[0])) + exit(1) + + input_file_path = sys.argv[1] +@@ -73,7 +73,7 @@ + out = str(subprocess.check_output(cmd)) + match = re.search('Processed [0-9]+ frames \(([0-9]+\.[0-9]+) FPS\)', out) + fps = float(match.group(1)) +- print(cmd, fps, "FPS") ++ print((cmd, fps, "FPS")) + table[m[0],u[0],f,p] = fps + + # Write the performance summary +@@ -96,4 +96,4 @@ + row += "\n" + csv.write(row) + +-print("DONE: ", output_file) ++print(("DONE: ", output_file)) +--- ./modules/core/src/opencl/runtime/generator/parser_clamdblas.py (original) ++++ ./modules/core/src/opencl/runtime/generator/parser_clamdblas.py (refactored) +@@ -1,7 +1,7 @@ + #!/bin/python + # usage: + # cat clAmdBlas.h | $0 +-from __future__ import print_function ++ + import sys, re; + + from common import remove_comments, getTokens, getParameters, postProcessParameters +--- ./modules/python/package/cv2/load_config_py2.py (original) ++++ ./modules/python/package/cv2/load_config_py2.py (refactored) +@@ -3,4 +3,4 @@ + + if sys.version_info[:2] < (3, 0): + def exec_file_wrapper(fpath, g_vars, l_vars): +- execfile(fpath, g_vars, l_vars) ++ exec(compile(open(fpath, "rb").read(), fpath, 'exec'), g_vars, l_vars) +--- ./modules/core/src/opencl/runtime/generator/parser_cl.py (original) ++++ ./modules/core/src/opencl/runtime/generator/parser_cl.py (refactored) +@@ -2,7 +2,7 @@ + # usage: + # cat opencl11/cl.h | $0 cl_runtime_opencl11 + # cat opencl12/cl.h | $0 cl_runtime_opencl12 +-from __future__ import print_function ++ + import sys, re; + + from common import remove_comments, getTokens, getParameters, postProcessParameters +--- ./doc/tools/html_functions.py (original) ++++ ./doc/tools/html_functions.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import sys + + import logging +--- ./modules/ml/misc/python/test/test_goodfeatures.py (original) ++++ ./modules/ml/misc/python/test/test_goodfeatures.py (refactored) +@@ -1,7 +1,7 @@ + #!/usr/bin/env python + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import cv2 as cv + import numpy as np +--- ./modules/objdetect/misc/python/test/test_peopledetect.py (original) ++++ ./modules/objdetect/misc/python/test/test_peopledetect.py (refactored) +@@ -5,7 +5,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./modules/python/test/test_async.py (original) ++++ ./modules/python/test/test_async.py (refactored) +@@ -1,5 +1,5 @@ + #!/usr/bin/env python +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./modules/dnn/test/cityscapes_semsegm_test_enet.py (original) ++++ ./modules/dnn/test/cityscapes_semsegm_test_enet.py (refactored) +@@ -61,7 +61,7 @@ + def __iter__(self): + return self + +- def next(self): ++ def __next__(self): + if self.i < len(self.segm_files): + segm_file = self.segm_files[self.i] + segm = cv.imread(segm_file, cv.IMREAD_COLOR)[:, :, ::-1] +--- ./modules/objdetect/misc/python/test/test_facedetect.py (original) ++++ ./modules/objdetect/misc/python/test/test_facedetect.py (refactored) +@@ -5,7 +5,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./modules/java/check-tests.py (original) ++++ ./modules/java/check-tests.py (refactored) +@@ -1,6 +1,6 @@ + #!/usr/bin/env python + +-from __future__ import print_function ++ + import sys, os, re + + classes_ignore_list = ( +@@ -33,7 +33,7 @@ + + def dict2set(self, d): + s = set() +- for f in d.keys(): ++ for f in list(d.keys()): + if len(d[f]) == 1: + s.add(f) + else: +--- ./modules/python/test/test_features2d.py (original) ++++ ./modules/python/test/test_features2d.py (refactored) +@@ -1,5 +1,5 @@ + #!/usr/bin/env python +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./modules/python/test/test_copytomask.py (original) ++++ ./modules/python/test/test_copytomask.py (refactored) +@@ -5,7 +5,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./modules/features2d/misc/python/test/test_feature_homography.py (original) ++++ ./modules/features2d/misc/python/test/test_feature_homography.py (refactored) +@@ -10,7 +10,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +@@ -126,7 +126,7 @@ + matches = [m[0] for m in matches if len(m) == 2 and m[0].distance < m[1].distance * 0.75] + if len(matches) < MIN_MATCH_COUNT: + return [] +- matches_by_id = [[] for _ in xrange(len(self.targets))] ++ matches_by_id = [[] for _ in range(len(self.targets))] + for m in matches: + matches_by_id[m.imgIdx].append(m) + tracked = [] +--- ./modules/python/test/test.py (original) ++++ ./modules/python/test/test.py (refactored) +@@ -5,7 +5,7 @@ + - /modules//misc/python/test/ + ''' + +-from __future__ import print_function ++ + + import sys + sys.dont_write_bytecode = True # Don't generate .pyc files / __pycache__ directories +@@ -17,7 +17,7 @@ + try: + from urllib.request import urlopen + except ImportError: +- from urllib import urlopen ++ from urllib.request import urlopen + + from tests_common import NewOpenCVTests + +--- ./modules/python/test/test_cuda.py (original) ++++ ./modules/python/test/test_cuda.py (refactored) +@@ -5,7 +5,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./modules/python/test/test_camshift.py (original) ++++ ./modules/python/test/test_camshift.py (refactored) +@@ -13,7 +13,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + import sys + PY3 = sys.version_info[0] == 3 + +--- ./modules/python/package/cv2/__init__.py (original) ++++ ./modules/python/package/cv2/__init__.py (refactored) +@@ -23,7 +23,7 @@ + save_sys_path = copy.copy(sys.path) + + if hasattr(sys, 'OpenCV_LOADER'): +- print(sys.path) ++ print((sys.path)) + raise ImportError('ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.') + sys.OpenCV_LOADER = True + +@@ -32,7 +32,7 @@ + DEBUG = True + + import platform +- if DEBUG: print('OpenCV loader: os.name="{}" platform.system()="{}"'.format(os.name, str(platform.system()))) ++ if DEBUG: print(('OpenCV loader: os.name="{}" platform.system()="{}"'.format(os.name, str(platform.system())))) + + LOADER_DIR=os.path.dirname(os.path.abspath(__file__)) + +@@ -51,9 +51,9 @@ + for fname in fnames: + fpath = os.path.join(LOADER_DIR, fname) + if not os.path.exists(fpath): +- if DEBUG: print('OpenCV loader: config not found, skip: {}'.format(fpath)) ++ if DEBUG: print(('OpenCV loader: config not found, skip: {}'.format(fpath))) + continue +- if DEBUG: print('OpenCV loader: loading config: {}'.format(fpath)) ++ if DEBUG: print(('OpenCV loader: loading config: {}'.format(fpath))) + exec_file_wrapper(fpath, g_vars, l_vars) + return True + if required: +@@ -65,8 +65,8 @@ + 'config-{}.py'.format(sys.version_info[0]) + ], True) + +- if DEBUG: print('OpenCV loader: PYTHON_EXTENSIONS_PATHS={}'.format(str(l_vars['PYTHON_EXTENSIONS_PATHS']))) +- if DEBUG: print('OpenCV loader: BINARIES_PATHS={}'.format(str(l_vars['BINARIES_PATHS']))) ++ if DEBUG: print(('OpenCV loader: PYTHON_EXTENSIONS_PATHS={}'.format(str(l_vars['PYTHON_EXTENSIONS_PATHS'])))) ++ if DEBUG: print(('OpenCV loader: BINARIES_PATHS={}'.format(str(l_vars['BINARIES_PATHS'])))) + + for p in reversed(l_vars['PYTHON_EXTENSIONS_PATHS']): + sys.path.insert(1, p) +@@ -77,10 +77,10 @@ + try: + os.add_dll_directory(p) + except Exception as e: +- if DEBUG: print('Failed os.add_dll_directory(): '+ str(e)) ++ if DEBUG: print(('Failed os.add_dll_directory(): '+ str(e))) + pass + os.environ['PATH'] = ';'.join(l_vars['BINARIES_PATHS']) + ';' + os.environ.get('PATH', '') +- if DEBUG: print('OpenCV loader: PATH={}'.format(str(os.environ['PATH']))) ++ if DEBUG: print(('OpenCV loader: PATH={}'.format(str(os.environ['PATH'])))) + else: + # amending of LD_LIBRARY_PATH works for sub-processes only + os.environ['LD_LIBRARY_PATH'] = ':'.join(l_vars['BINARIES_PATHS']) + ':' + os.environ.get('LD_LIBRARY_PATH', '') +--- ./modules/python/test/test_fs_cache_dir.py (original) ++++ ./modules/python/test/test_fs_cache_dir.py (refactored) +@@ -1,5 +1,5 @@ + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./modules/python/test/test_fitline.py (original) ++++ ./modules/python/test/test_fitline.py (refactored) +@@ -14,7 +14,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + import sys + PY3 = sys.version_info[0] == 3 + +--- ./modules/python/test/test_dft.py (original) ++++ ./modules/python/test/test_dft.py (refactored) +@@ -5,7 +5,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import cv2 as cv + import numpy as np +--- ./modules/ml/misc/python/test/test_letter_recog.py (original) ++++ ./modules/ml/misc/python/test/test_letter_recog.py (refactored) +@@ -21,7 +21,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./modules/python/test/test_kmeans.py (original) ++++ ./modules/python/test/test_kmeans.py (refactored) +@@ -5,7 +5,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +@@ -21,7 +21,7 @@ + points = [] + ref_distrs = [] + sizes = [] +- for _ in xrange(cluster_n): ++ for _ in range(cluster_n): + mean = (0.1 + 0.8*random.rand(2)) * img_size + a = (random.rand(2, 2)-0.5)*img_size*0.1 + cov = np.dot(a.T, a) + img_size*0.05*np.eye(2) +@@ -36,8 +36,8 @@ + def getMainLabelConfidence(labels, nLabels): + + n = len(labels) +- labelsDict = dict.fromkeys(range(nLabels), 0) +- labelsConfDict = dict.fromkeys(range(nLabels)) ++ labelsDict = dict.fromkeys(list(range(nLabels)), 0) ++ labelsConfDict = dict.fromkeys(list(range(nLabels))) + + for i in range(n): + labelsDict[labels[i][0]] += 1 +--- ./modules/python/test/test_gaussian_mix.py (original) ++++ ./modules/python/test/test_gaussian_mix.py (refactored) +@@ -1,7 +1,7 @@ + #!/usr/bin/env python + + # Python 2/3 compatibility +-from __future__ import print_function ++ + import sys + PY3 = sys.version_info[0] == 3 + +@@ -15,7 +15,7 @@ + def make_gaussians(cluster_n, img_size): + points = [] + ref_distrs = [] +- for _ in xrange(cluster_n): ++ for _ in range(cluster_n): + mean = (0.1 + 0.8*random.rand(2)) * img_size + a = (random.rand(2, 2)-0.5)*img_size*0.1 + cov = np.dot(a.T, a) + img_size*0.05*np.eye(2) +--- ./modules/python/test/test_houghlines.py (original) ++++ ./modules/python/test/test_houghlines.py (refactored) +@@ -5,7 +5,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import cv2 as cv + import numpy as np +--- ./modules/python/test/test_houghcircles.py (original) ++++ ./modules/python/test/test_houghcircles.py (refactored) +@@ -5,7 +5,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import cv2 as cv + import numpy as np +--- ./modules/python/test/test_grabcut.py (original) ++++ ./modules/python/test/test_grabcut.py (refactored) +@@ -6,7 +6,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./modules/dnn/test/pascal_semsegm_test_fcn.py (original) ++++ ./modules/dnn/test/pascal_semsegm_test_fcn.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + from abc import ABCMeta, abstractmethod + import numpy as np + import sys +@@ -69,8 +69,7 @@ + return image_data + + +-class DatasetImageFetch(object): +- __metaclass__ = ABCMeta ++class DatasetImageFetch(object, metaclass=ABCMeta): + data_prepoc = object + + @abstractmethod +@@ -121,14 +120,14 @@ + result = [] + with open(img_classes_file) as f: + for l in f.readlines(): +- color = np.array(map(int, l.split()[1:])) ++ color = np.array(list(map(int, l.split()[1:]))) + result.append(DatasetImageFetch.pix_to_c(color)) + return result + + def __iter__(self): + return self + +- def next(self): ++ def __next__(self): + if self.i < len(self.names): + name = self.names[self.i] + self.i += 1 +--- ./modules/python/test/test_texture_flow.py (original) ++++ ./modules/python/test/test_texture_flow.py (refactored) +@@ -8,7 +8,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./modules/python/test/test_morphology.py (original) ++++ ./modules/python/test/test_morphology.py (refactored) +@@ -5,7 +5,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + import sys + PY3 = sys.version_info[0] == 3 + +--- ./modules/python/test/test_filestorage_io.py (original) ++++ ./modules/python/test/test_filestorage_io.py (refactored) +@@ -1,6 +1,6 @@ + #!/usr/bin/env python + """Algorithm serialization test.""" +-from __future__ import print_function ++ + import tempfile + import os + import cv2 as cv +--- ./modules/python/test/test_watershed.py (original) ++++ ./modules/python/test/test_watershed.py (refactored) +@@ -5,7 +5,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./modules/dnn/test/imagenet_cls_test_alexnet.py (original) ++++ ./modules/dnn/test/imagenet_cls_test_alexnet.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + from abc import ABCMeta, abstractmethod + import numpy as np + import sys +@@ -23,11 +23,10 @@ + xrange = range # Python 3 + + +-class DataFetch(object): ++class DataFetch(object, metaclass=ABCMeta): + imgs_dir = '' + frame_size = 0 + bgr_to_rgb = False +- __metaclass__ = ABCMeta + + @abstractmethod + def preprocess(self, img): +@@ -105,11 +104,9 @@ + return correct_answers + + +-class Framework(object): ++class Framework(object, metaclass=ABCMeta): + in_blob_name = '' + out_blob_name = '' +- +- __metaclass__ = ABCMeta + + @abstractmethod + def get_name(self): +@@ -183,7 +180,7 @@ + blobs_l_inf_diff = [sys.float_info.min] * len(frameworks) + inference_time = [0.0] * len(frameworks) + +- for x in xrange(0, len(sorted_imgs_names), self.batch_size): ++ for x in range(0, len(sorted_imgs_names), self.batch_size): + sublist = sorted_imgs_names[x:x + self.batch_size] + batch = data_fetcher.get_batch(sublist) + +--- ./modules/core/src/opencl/runtime/generator/common.py (original) ++++ ./modules/core/src/opencl/runtime/generator/common.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import sys, os, re + + # +@@ -116,7 +116,7 @@ + + def outputToString(f): + def wrapped(*args, **kwargs): +- from cStringIO import StringIO ++ from io import StringIO + old_stdout = sys.stdout + sys.stdout = str_stdout = StringIO() + res = f(*args, **kwargs) +--- ./modules/ml/misc/python/test/test_digits.py (original) ++++ ./modules/ml/misc/python/test/test_digits.py (refactored) +@@ -23,7 +23,7 @@ + + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + # built-in modules + from multiprocessing.pool import ThreadPool +--- ./modules/python/test/test_squares.py (original) ++++ ./modules/python/test/test_squares.py (refactored) +@@ -25,7 +25,7 @@ + img = cv.GaussianBlur(img, (5, 5), 0) + squares = [] + for gray in cv.split(img): +- for thrs in xrange(0, 255, 26): ++ for thrs in range(0, 255, 26): + if thrs == 0: + bin = cv.Canny(gray, 0, 50, apertureSize=5) + bin = cv.dilate(bin, None) +@@ -37,7 +37,7 @@ + cnt = cv.approxPolyDP(cnt, 0.02*cnt_len, True) + if len(cnt) == 4 and cv.contourArea(cnt) > 1000 and cv.isContourConvex(cnt): + cnt = cnt.reshape(-1, 2) +- max_cos = np.max([angle_cos( cnt[i], cnt[(i+1) % 4], cnt[(i+2) % 4] ) for i in xrange(4)]) ++ max_cos = np.max([angle_cos( cnt[i], cnt[(i+1) % 4], cnt[(i+2) % 4] ) for i in range(4)]) + if max_cos < 0.1 and filterSquares(squares, cnt): + squares.append(cnt) + +--- ./modules/python/test/test_legacy.py (original) ++++ ./modules/python/test/test_legacy.py (refactored) +@@ -1,5 +1,5 @@ + #!/usr/bin/env python +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./modules/python/test/test_mser.py (original) ++++ ./modules/python/test/test_mser.py (refactored) +@@ -4,7 +4,7 @@ + MSER detector test + ''' + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./modules/python/test/tests_common.py (original) ++++ ./modules/python/test/tests_common.py (refactored) +@@ -1,6 +1,6 @@ + #!/usr/bin/env python + +-from __future__ import print_function ++ + + import os + import sys +@@ -16,7 +16,7 @@ + try: + from urllib.request import urlopen + except ImportError: +- from urllib import urlopen ++ from urllib.request import urlopen + + class NewOpenCVTests(unittest.TestCase): + +--- ./modules/python/test/test_umat.py (original) ++++ ./modules/python/test/test_umat.py (refactored) +@@ -1,5 +1,5 @@ + #!/usr/bin/env python +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +@@ -87,9 +87,9 @@ + + _p1_mask_err = cv.calcOpticalFlowPyrLK(img1, img2, p0, None) + +- _p1_mask_err_umat0 = list(map(lambda umat: umat.get(), cv.calcOpticalFlowPyrLK(img1, img2, p0_umat, None))) +- _p1_mask_err_umat1 = list(map(lambda umat: umat.get(), cv.calcOpticalFlowPyrLK(cv.UMat(img1), img2, p0_umat, None))) +- _p1_mask_err_umat2 = list(map(lambda umat: umat.get(), cv.calcOpticalFlowPyrLK(img1, cv.UMat(img2), p0_umat, None))) ++ _p1_mask_err_umat0 = list([umat.get() for umat in cv.calcOpticalFlowPyrLK(img1, img2, p0_umat, None)]) ++ _p1_mask_err_umat1 = list([umat.get() for umat in cv.calcOpticalFlowPyrLK(cv.UMat(img1), img2, p0_umat, None)]) ++ _p1_mask_err_umat2 = list([umat.get() for umat in cv.calcOpticalFlowPyrLK(img1, cv.UMat(img2), p0_umat, None)]) + + for _p1_mask_err_umat in [_p1_mask_err_umat0, _p1_mask_err_umat1, _p1_mask_err_umat2]: + for data, data_umat in zip(_p1_mask_err, _p1_mask_err_umat): +--- ./modules/python/test/test_norm.py (original) ++++ ./modules/python/test/test_norm.py (refactored) +@@ -54,9 +54,8 @@ + binary_str = bin(element).split('b')[-1] + if len(binary_str) % 2 == 1: + binary_str = '0' + binary_str +- gen = filter(lambda p: p != '00', +- (binary_str[i:i+2] +- for i in range(0, len(binary_str), 2))) ++ gen = [p for p in (binary_str[i:i+2] ++ for i in range(0, len(binary_str), 2)) if p != '00'] + return sum(1 for _ in gen) + + return sum(element_norm(element) for element in vec.flatten()) +@@ -105,7 +104,7 @@ + + def test_norm_for_one_array(self): + np.random.seed(123) +- for norm_type, norm in norm_type_under_test.items(): ++ for norm_type, norm in list(norm_type_under_test.items()): + element_types = get_element_types(norm_type) + for shape, element_type in product(shapes, element_types): + array = generate_vector(shape, element_type) +@@ -120,7 +119,7 @@ + + def test_norm_for_two_arrays(self): + np.random.seed(456) +- for norm_type, norm in norm_type_under_test.items(): ++ for norm_type, norm in list(norm_type_under_test.items()): + element_types = get_element_types(norm_type) + for shape, element_type in product(shapes, element_types): + first = generate_vector(shape, element_type) +--- ./modules/python/test/tst_scene_render.py (original) ++++ ./modules/python/test/tst_scene_render.py (refactored) +@@ -2,7 +2,7 @@ + + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + from numpy import pi, sin, cos +--- ./modules/dnn/misc/python/test/test_dnn.py (original) ++++ ./modules/dnn/misc/python/test/test_dnn.py (refactored) +@@ -60,7 +60,7 @@ + cv.dnn.DNN_TARGET_OPENCL_FP16: 'OCL_FP16', + cv.dnn.DNN_TARGET_MYRIAD: 'MYRIAD' + } +- print('%s/%s' % (backendNames[backend], targetNames[target])) ++ print(('%s/%s' % (backendNames[backend], targetNames[target]))) + + testdata_required = bool(os.environ.get('OPENCV_DNN_TEST_REQUIRE_TESTDATA', False)) + +@@ -289,11 +289,11 @@ + + # Run asynchronously. To make test more robust, process inputs in the reversed order. + outs = [] +- for i in reversed(range(numInputs)): ++ for i in reversed(list(range(numInputs))): + netAsync.setInput(inputs[i]) + outs.insert(0, netAsync.forwardAsync()) + +- for i in reversed(range(numInputs)): ++ for i in reversed(list(range(numInputs))): + ret, result = outs[i].get(timeoutNs=float(timeout)) + self.assertTrue(ret) + normAssert(self, refs[i], result, 'Index: %d' % i, 1e-10) +--- ./modules/ts/misc/report.py (original) ++++ ./modules/ts/misc/report.py (refactored) +@@ -14,7 +14,7 @@ + (options, args) = parser.parse_args() + + if len(args) < 1: +- print >> sys.stderr, "Usage:\n", os.path.basename(sys.argv[0]), ".xml" ++ print("Usage:\n", os.path.basename(sys.argv[0]), ".xml", file=sys.stderr) + exit(0) + + options.generateHtml = detectHtmlOutputType(options.format) +--- ./modules/videoio/misc/python/test/test_videoio.py (original) ++++ ./modules/videoio/misc/python/test/test_videoio.py (refactored) +@@ -1,5 +1,5 @@ + #!/usr/bin/env python +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./modules/ts/misc/run_long.py (original) ++++ ./modules/ts/misc/run_long.py (refactored) +@@ -1,5 +1,5 @@ + #!/usr/bin/env python +-from __future__ import print_function ++ + import xml.etree.ElementTree as ET + from glob import glob + from pprint import PrettyPrinter as PP +--- ./modules/video/misc/python/test/test_lk_homography.py (original) ++++ ./modules/video/misc/python/test/test_lk_homography.py (refactored) +@@ -8,7 +8,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./modules/dnn/misc/quantize_face_detector.py (original) ++++ ./modules/dnn/misc/quantize_face_detector.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import sys + import argparse + import cv2 as cv +@@ -35,7 +35,7 @@ + cvNet = cv.dnn.readNetFromCaffe(args.proto, args.model) + + def dnnLayer(name): +- return cvNet.getLayer(long(cvNet.getLayerId(name))) ++ return cvNet.getLayer(int(cvNet.getLayerId(name))) + + def scale(x, name): + with tf.variable_scope(name): +@@ -260,7 +260,7 @@ + return msg + '}' + + # Remove Const nodes and unused attributes. +-for i in reversed(range(len(graph_def.node))): ++for i in reversed(list(range(len(graph_def.node)))): + if graph_def.node[i].op in ['Const', 'Dequantize']: + del graph_def.node[i] + for attr in ['T', 'data_format', 'Tshape', 'N', 'Tidx', 'Tdim', +@@ -322,7 +322,7 @@ + graph_def.node.extend([detectionOut]) + + # Replace L2Normalization subgraph onto a single node. +-for i in reversed(range(len(graph_def.node))): ++for i in reversed(list(range(len(graph_def.node)))): + if graph_def.node[i].name in ['conv4_3_norm/l2_normalize/Square', + 'conv4_3_norm/l2_normalize/Sum', + 'conv4_3_norm/l2_normalize/Maximum', +--- ./opencv_contrib-4.5.2/modules/bgsegm/samples/viz.py (original) ++++ ./opencv_contrib-4.5.2/modules/bgsegm/samples/viz.py (refactored) +@@ -12,20 +12,20 @@ + argparser.add_argument('-l', '--lsbp', help='Display LSBP instead of GSOC', default=False) + args = argparser.parse_args() + +- gt = map(lambda x: os.path.join(args.gt, x), os.listdir(args.gt)) ++ gt = [os.path.join(args.gt, x) for x in os.listdir(args.gt)] + gt.sort() +- f = map(lambda x: os.path.join(args.frames, x), os.listdir(args.frames)) ++ f = [os.path.join(args.frames, x) for x in os.listdir(args.frames)] + f.sort() + +- gt = np.uint8(map(lambda x: cv.imread(x, cv.IMREAD_GRAYSCALE), gt)) +- f = np.uint8(map(lambda x: cv.imread(x, cv.IMREAD_COLOR), f)) ++ gt = np.uint8([cv.imread(x, cv.IMREAD_GRAYSCALE) for x in gt]) ++ f = np.uint8([cv.imread(x, cv.IMREAD_COLOR) for x in f]) + + if not args.lsbp: + bgs = cv.bgsegm.createBackgroundSubtractorGSOC() + else: + bgs = cv.bgsegm.createBackgroundSubtractorLSBP() + +- for i in xrange(f.shape[0]): ++ for i in range(f.shape[0]): + cv.imshow('Frame', f[i]) + cv.imshow('Ground-truth', gt[i]) + mask = bgs.apply(f[i]) +--- ./modules/video/misc/python/test/test_lk_track.py (original) ++++ ./modules/video/misc/python/test/test_lk_track.py (refactored) +@@ -10,7 +10,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./modules/ts/misc/run_android.py (original) ++++ ./modules/ts/misc/run_android.py (refactored) +@@ -151,7 +151,7 @@ + android_exe = android_dir + exename + self.adb.run(["push", exe, android_exe]) + self.adb.run(["shell", "chmod 777 " + android_exe]) +- env_pieces = ["export %s=%s" % (a, b) for a, b in self.env.items()] ++ env_pieces = ["export %s=%s" % (a, b) for a, b in list(self.env.items())] + pieces = ["cd %s" % android_dir, "./%s %s" % (exename, " ".join(args))] + log.warning("Run: %s" % " && ".join(pieces)) + ret = self.adb.run(["shell", " && ".join(env_pieces + pieces)]) +--- ./modules/ts/misc/run.py (original) ++++ ./modules/ts/misc/run.py (refactored) +@@ -71,7 +71,7 @@ + if args.android_env: + android_env.extend([entry.split("=", 1) for entry in args.android_env]) + if args.android_propagate_opencv_env: +- android_env.extend([entry for entry in os.environ.items() if entry[0].startswith('OPENCV')]) ++ android_env.extend([entry for entry in list(os.environ.items()) if entry[0].startswith('OPENCV')]) + android_env = dict(android_env) + if args.android_test_data_path: + android_env['OPENCV_TEST_DATA_PATH'] = args.android_test_data_path +--- ./modules/ts/misc/perf_tests_timing.py (original) ++++ ./modules/ts/misc/perf_tests_timing.py (refactored) +@@ -1,6 +1,6 @@ + #!/usr/bin/env python + +-from __future__ import print_function ++ + import testlog_parser, sys, os, xml, glob, re + from table_formatter import * + from optparse import OptionParser +@@ -78,7 +78,7 @@ + suit_time = 0 + suit_num = 0 + fails_num = 0 +- for name in sorted(test_cases.iterkeys(), key=alphanum_keyselector): ++ for name in sorted(iter(test_cases.keys()), key=alphanum_keyselector): + cases = test_cases[name] + + groupName = next(c for c in cases if c).shortName() +--- ./opencv_contrib-4.5.2/modules/face/samples/etc/create_csv.py (original) ++++ ./opencv_contrib-4.5.2/modules/face/samples/etc/create_csv.py (refactored) +@@ -27,7 +27,7 @@ + if __name__ == "__main__": + + if len(sys.argv) != 2: +- print "usage: create_csv " ++ print("usage: create_csv ") + sys.exit(1) + + BASE_PATH=sys.argv[1] +@@ -39,5 +39,5 @@ + subject_path = os.path.join(dirname, subdirname) + for filename in os.listdir(subject_path): + abs_path = "%s/%s" % (subject_path, filename) +- print "%s%s%d" % (abs_path, SEPARATOR, label) ++ print("%s%s%d" % (abs_path, SEPARATOR, label)) + label = label + 1 +--- ./modules/ts/misc/chart.py (original) ++++ ./modules/ts/misc/chart.py (refactored) +@@ -116,7 +116,7 @@ + (options, args) = parser.parse_args() + + if len(args) != 1: +- print >> sys.stderr, "Usage:\n", os.path.basename(sys.argv[0]), ".xml" ++ print("Usage:\n", os.path.basename(sys.argv[0]), ".xml", file=sys.stderr) + exit(1) + + options.generateHtml = detectHtmlOutputType(options.format) +@@ -136,7 +136,7 @@ + args[0] = os.path.basename(args[0]) + + if not tests: +- print >> sys.stderr, "Error - no tests matched" ++ print("Error - no tests matched", file=sys.stderr) + exit(1) + + argsnum = len(tests[0][1]) +@@ -156,30 +156,30 @@ + names1.add(sn) + if sn == sname: + if len(pair[1]) != argsnum: +- print >> sys.stderr, "Error - unable to create chart tables for functions having different argument numbers" ++ print("Error - unable to create chart tables for functions having different argument numbers", file=sys.stderr) + sys.exit(1) + for i in range(argsnum): + arglists[i][pair[1][i]] = 1 + + if names1 or len(names) != 1: +- print >> sys.stderr, "Error - unable to create tables for functions from different test suits:" ++ print("Error - unable to create tables for functions from different test suits:", file=sys.stderr) + i = 1 + for name in sorted(names): +- print >> sys.stderr, "%4s: %s" % (i, name) ++ print("%4s: %s" % (i, name), file=sys.stderr) + i += 1 + if names1: +- print >> sys.stderr, "Other suits in this log (can not be chosen):" ++ print("Other suits in this log (can not be chosen):", file=sys.stderr) + for name in sorted(names1): +- print >> sys.stderr, "%4s: %s" % (i, name) ++ print("%4s: %s" % (i, name), file=sys.stderr) + i += 1 + sys.exit(1) + + if argsnum < 2: +- print >> sys.stderr, "Error - tests from %s have less than 2 parameters" % sname ++ print("Error - tests from %s have less than 2 parameters" % sname, file=sys.stderr) + exit(1) + + for i in range(argsnum): +- arglists[i] = sorted([str(key) for key in arglists[i].iterkeys()], key=alphanum_keyselector) ++ arglists[i] = sorted([str(key) for key in arglists[i].keys()], key=alphanum_keyselector) + + if options.generateHtml and options.format != "moinwiki": + htmlPrintHeader(sys.stdout, "Report %s for %s" % (args[0], sname)) +--- ./modules/ts/misc/run_utils.py (original) ++++ ./modules/ts/misc/run_utils.py (refactored) +@@ -135,7 +135,7 @@ + if "Visual Studio" in self.cmake_generator: + self.tests_dir = os.path.join(self.tests_dir, self.build_type) + +- for module, path in module_paths.items(): ++ for module, path in list(module_paths.items()): + rel = os.path.relpath(path, self.opencv_home) + if ".." not in rel: + self.main_modules.append(module) +--- ./opencv_contrib-4.5.2/modules/dnn_objdetect/scripts/pascal_preprocess.py (original) ++++ ./opencv_contrib-4.5.2/modules/dnn_objdetect/scripts/pascal_preprocess.py (refactored) +@@ -5,7 +5,7 @@ + try: + img = io.imread(root_old+"/"+img_path) + except Exception as E: +- print E ++ print(E) + h, w, _ = img.shape + f_h, f_w = float(out_shape)/h, float(out_shape)/w + trans_img = transform.rescale(img, (f_h, f_w)) +@@ -16,7 +16,7 @@ + ann = ann.split(' ') + ann = [float(i) for i in ann] + num_objs = len(ann) / 5 +- for idx in xrange(num_objs): ++ for idx in range(num_objs): + ann[idx * 5 + 0] = int(f_w * ann[idx * 5 + 0]) + ann[idx * 5 + 1] = int(f_h * ann[idx * 5 + 1]) + ann[idx * 5 + 2] = int(f_w * ann[idx * 5 + 2]) +@@ -35,7 +35,7 @@ + out_shape = 416 + with open(source, 'r') as src: + lines = src.readlines() +- print 'Processing {} images and annotations'.format(len(lines)) ++ print('Processing {} images and annotations'.format(len(lines))) + for line in lines: + line = line.rstrip() + line = line.split(' ') +--- ./modules/ts/misc/testlog_parser.py (original) ++++ ./modules/ts/misc/testlog_parser.py (refactored) +@@ -1,6 +1,6 @@ + #!/usr/bin/env python + +-from __future__ import print_function ++ + import collections + import re + import os.path +@@ -56,9 +56,9 @@ + + def parseLongMetric(self, xmlnode, name, default = 0): + if name in self.properties: +- self.metrix[name] = long(self.properties[name]) +- elif xmlnode.hasAttribute(name): +- self.metrix[name] = long(xmlnode.getAttribute(name)) ++ self.metrix[name] = int(self.properties[name]) ++ elif xmlnode.hasAttribute(name): ++ self.metrix[name] = int(xmlnode.getAttribute(name)) + else: + self.metrix[name] = default + +@@ -114,8 +114,8 @@ + if units == "ns": + scale = 1000000000.0 + if units == "ticks": +- frequency = long(1) +- scale = long(1) ++ frequency = int(1) ++ scale = int(1) + return val * scale / frequency + return val + +@@ -142,18 +142,18 @@ + + + def param(self): +- return '::'.join(filter(None, [self.type_param, self.value_param])) ++ return '::'.join([_f for _f in [self.type_param, self.value_param] if _f]) + + def shortName(self): + name = self.getName() + fixture = self.getFixture() +- return '::'.join(filter(None, [name, fixture])) ++ return '::'.join([_f for _f in [name, fixture] if _f]) + + + def __str__(self): + name = self.getName() + fixture = self.getFixture() +- return '::'.join(filter(None, [name, fixture, self.type_param, self.value_param])) ++ return '::'.join([_f for _f in [name, fixture, self.type_param, self.value_param] if _f]) + + + def __cmp__(self, other): +@@ -200,7 +200,7 @@ + + properties = { + attr_name[3:]: attr_value +- for (attr_name, attr_value) in log.documentElement.attributes.items() ++ for (attr_name, attr_value) in list(log.documentElement.attributes.items()) + if attr_name.startswith('cv_') + } + +@@ -221,7 +221,7 @@ + + print("Properties:") + +- for (prop_name, prop_value) in run.properties.items(): ++ for (prop_name, prop_value) in list(run.properties.items()): + print("\t{} = {}".format(prop_name, prop_value)) + + print("Tests:") +--- ./opencv_contrib-4.5.2/modules/bgsegm/samples/evaluation.py (original) ++++ ./opencv_contrib-4.5.2/modules/bgsegm/samples/evaluation.py (refactored) +@@ -85,16 +85,16 @@ + def evaluate_on_sequence(seq, summary): + gt, frames = load_sequence(seq) + category, video_name = os.path.basename(os.path.dirname(seq)), os.path.basename(seq) +- print('=== %s:%s ===' % (category, video_name)) ++ print(('=== %s:%s ===' % (category, video_name))) + + for algo, algo_name, algo_arguments in ALGORITHMS_TO_EVALUATE: +- print('Algorithm name: %s' % algo_name) ++ print(('Algorithm name: %s' % algo_name)) + sec_per_step, precision, recall, f1, accuracy = evaluate_algorithm(gt, frames, algo, algo_arguments) +- print('Average accuracy: %.3f' % accuracy) +- print('Average precision: %.3f' % precision) +- print('Average recall: %.3f' % recall) +- print('Average F1: %.3f' % f1) +- print('Average sec. per step: %.4f' % sec_per_step) ++ print(('Average accuracy: %.3f' % accuracy)) ++ print(('Average precision: %.3f' % precision)) ++ print(('Average recall: %.3f' % recall)) ++ print(('Average F1: %.3f' % f1)) ++ print(('Average sec. per step: %.4f' % sec_per_step)) + print('') + + if category not in summary: +@@ -114,7 +114,7 @@ + assert len(dataset_dirs) > 0, ("Passed directory must contain at least one sequence from the Change Detection dataset. There is no relevant directories in %s. Check that this directory is correct." % (args.dataset_path)) + if args.algorithm is not None: + global ALGORITHMS_TO_EVALUATE +- ALGORITHMS_TO_EVALUATE = filter(lambda a: a[1].lower() == args.algorithm.lower(), ALGORITHMS_TO_EVALUATE) ++ ALGORITHMS_TO_EVALUATE = [a for a in ALGORITHMS_TO_EVALUATE if a[1].lower() == args.algorithm.lower()] + summary = {} + + for seq in dataset_dirs: +@@ -125,9 +125,9 @@ + summary[category][algo_name] = np.mean(summary[category][algo_name], axis=0) + + for category in summary: +- print('=== SUMMARY for %s (Precision, Recall, F1, Accuracy) ===' % category) ++ print(('=== SUMMARY for %s (Precision, Recall, F1, Accuracy) ===' % category)) + for algo_name in summary[category]: +- print('%05s: %.3f %.3f %.3f %.3f' % ((algo_name,) + tuple(summary[category][algo_name]))) ++ print(('%05s: %.3f %.3f %.3f %.3f' % ((algo_name,) + tuple(summary[category][algo_name])))) + + + if __name__ == '__main__': +--- ./opencv_contrib-4.5.2/modules/intensity_transform/misc/python/test/test_intensity_transform_bimef.py (original) ++++ ./opencv_contrib-4.5.2/modules/intensity_transform/misc/python/test/test_intensity_transform_bimef.py (refactored) +@@ -1,7 +1,7 @@ + #!/usr/bin/env python + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import os + import cv2 as cv +--- ./modules/ts/misc/run_suite.py (original) ++++ ./modules/ts/misc/run_suite.py (refactored) +@@ -86,16 +86,16 @@ + if os.path.isfile(f): + res.append("--suppressions=%s" % f) + else: +- print("WARNING: Valgrind suppression file is missing, SKIP: %s" % f) ++ print(("WARNING: Valgrind suppression file is missing, SKIP: %s" % f)) + res.extend(self.options.valgrind_opt) + has_gtest_filter = next((True for x in cmd if x.startswith('--gtest_filter=')), False) + return res + cmd + ([longTestFilter(LONG_TESTS_DEBUG_VALGRIND, module)] if not has_gtest_filter else []) + elif self.options.qemu: + import shlex + res = shlex.split(self.options.qemu) +- for (name, value) in [entry for entry in os.environ.items() if entry[0].startswith('OPENCV') and not entry[0] in env]: ++ for (name, value) in [entry for entry in list(os.environ.items()) if entry[0].startswith('OPENCV') and not entry[0] in env]: + res += ['-E', '"{}={}"'.format(name, value)] +- for (name, value) in env.items(): ++ for (name, value) in list(env.items()): + res += ['-E', '"{}={}"'.format(name, value)] + return res + ['--'] + cmd + return cmd +--- ./opencv_contrib-4.5.2/modules/optflow/samples/gpc_train_sintel.py (original) ++++ ./opencv_contrib-4.5.2/modules/optflow/samples/gpc_train_sintel.py (refactored) +@@ -13,9 +13,9 @@ + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + for stdout_line in iter(popen.stdout.readline, ''): +- print(stdout_line.rstrip()) ++ print((stdout_line.rstrip())) + for stderr_line in iter(popen.stderr.readline, ''): +- print(stderr_line.rstrip()) ++ print((stderr_line.rstrip())) + popen.stdout.close() + popen.stderr.close() + return_code = popen.wait() +--- ./opencv_contrib-4.5.2/modules/dnn_objdetect/scripts/k_means.py (original) ++++ ./opencv_contrib-4.5.2/modules/dnn_objdetect/scripts/k_means.py (refactored) +@@ -11,9 +11,9 @@ + X = np.array(data) + np.random.shuffle(X) + begin = time.time() +- print 'Running kmeans' ++ print('Running kmeans') + kmeans = KMeans(n_clusters=K, max_iter=max_iter, n_jobs=n_jobs, verbose=1).fit(X) +- print 'K-Means took {} seconds to complete'.format(time.time()-begin) ++ print('K-Means took {} seconds to complete'.format(time.time()-begin)) + step_size = 0.2 + xmin, xmax = X[:, 0].min()-1, X[:, 0].max()+1 + ymin, ymax = X[:, 1].min()-1, X[:, 1].max()+1 +@@ -30,19 +30,19 @@ + plt.title("Anchor shapes generated using K-Means") + plt.xlim(xmin, xmax) + plt.ylim(ymin, ymax) +- print 'Mean centroids are:' ++ print('Mean centroids are:') + for i, center in enumerate(centroids): +- print '{}: {}, {}'.format(i, center[0], center[1]) ++ print('{}: {}, {}'.format(i, center[0], center[1])) + # plt.xticks(()) + # plt.yticks(()) + plt.show() + + def pre_process(directory, data_list): + if not os.path.exists(directory): +- print "Path {} doesn't exist".format(directory) ++ print("Path {} doesn't exist".format(directory)) + return + files = os.listdir(directory) +- print 'Loading data...' ++ print('Loading data...') + for i, f in enumerate(files): + # Progress bar + sys.stdout.write('\r') +@@ -89,10 +89,10 @@ + pre_process(directory, data_list ) + sys.stdout.write('\nDone collecting data\n') + k_means(K, data_list, int(p.iter), int(p.jobs), p.image_file) +- print 'Done !' ++ print('Done !') + + if __name__=='__main__': + try: + main() + except Exception as E: +- print E ++ print(E) +--- ./opencv_contrib-4.5.2/modules/optflow/samples/gpc_train_middlebury.py (original) ++++ ./opencv_contrib-4.5.2/modules/optflow/samples/gpc_train_middlebury.py (refactored) +@@ -9,9 +9,9 @@ + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + for stdout_line in iter(popen.stdout.readline, ''): +- print(stdout_line.rstrip()) ++ print((stdout_line.rstrip())) + for stderr_line in iter(popen.stderr.readline, ''): +- print(stderr_line.rstrip()) ++ print((stderr_line.rstrip())) + popen.stdout.close() + popen.stderr.close() + return_code = popen.wait() +--- ./opencv_contrib-4.5.2/modules/julia/gen/gen3_julia.py (original) ++++ ./opencv_contrib-4.5.2/modules/julia/gen/gen3_julia.py (refactored) +@@ -6,7 +6,7 @@ + # Copyright (C) 2020 by Archit Rungta + + +-from __future__ import unicode_literals # Needed for python2 ++ # Needed for python2 + + import hdr_parser, sys, re, os + from string import Template +@@ -15,7 +15,7 @@ + if sys.version_info[0] >= 3: + from io import StringIO + else: +- from cStringIO import StringIO ++ from io import StringIO + import os, shutil + + from parse_tree import * +@@ -40,7 +40,7 @@ + namespaces, _ = gen_tree(srcfiles) + + jl_code = StringIO() +- for name, ns in namespaces.items(): ++ for name, ns in list(namespaces.items()): + # cv_types.extend(ns.registered) + jl_code = StringIO() + nsname = '_'.join(name.split('::')[1:]) +@@ -48,13 +48,13 @@ + # Do not duplicate functions. This should prevent overwriting of Mat function by UMat functions + function_signatures = [] + if name != 'cv': +- for cname, cl in ns.classes.items(): ++ for cname, cl in list(ns.classes.items()): + cl.__class__ = ClassInfo +- for mname, fs in cl.methods.items(): ++ for mname, fs in list(cl.methods.items()): + for f in fs: + f.__class__ = FuncVariant + if f.mapped_name in function_signatures: +- print("Skipping entirely: ", f.name) ++ print(("Skipping entirely: ", f.name)) + continue + jl_code.write('\n%s' % f.get_complete_code(isalgo = cl.isalgorithm, ns=nsname)) + function_signatures.append(f.mapped_name) +@@ -62,7 +62,7 @@ + f.__class__ = FuncVariant + jl_code.write('\n%s' % f.get_complete_code(classname = cl.mapped_name, isalgo = cl.isalgorithm, iscons = True, ns=nsname)) + break +- for mname, fs in ns.funcs.items(): ++ for mname, fs in list(ns.funcs.items()): + for f in fs: + f.__class__ = FuncVariant + if f.mapped_name in function_signatures: +--- ./opencv_contrib-4.5.2/modules/reg/samples/reg_shift.py (original) ++++ ./opencv_contrib-4.5.2/modules/reg/samples/reg_shift.py (refactored) +@@ -17,4 +17,4 @@ + resMap = mappPyr.calculate(img1, img2) + mapShift = cv.reg.MapTypeCaster_toShift(resMap) + +-print(mapShift.getShift()) ++print((mapShift.getShift())) +--- ./opencv_contrib-4.5.2/modules/shape/misc/python/test/test_shape.py (original) ++++ ./opencv_contrib-4.5.2/modules/shape/misc/python/test/test_shape.py (refactored) +@@ -1,7 +1,7 @@ + #!/usr/bin/env python + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import os + +--- ./opencv_contrib-4.5.2/modules/optflow/samples/motempl.py (original) ++++ ./opencv_contrib-4.5.2/modules/optflow/samples/motempl.py (refactored) +@@ -34,11 +34,11 @@ + + cam = cv.VideoCapture(video_src) + if not cam.isOpened(): +- print("could not open video_src " + str(video_src) + " !\n") ++ print(("could not open video_src " + str(video_src) + " !\n")) + sys.exit(1) + ret, frame = cam.read() + if ret == False: +- print("could not read from " + str(video_src) + " !\n") ++ print(("could not read from " + str(video_src) + " !\n")) + sys.exit(1) + h, w = frame.shape[:2] + prev_frame = frame.copy() +--- ./opencv_contrib-4.5.2/modules/surface_matching/samples/ppf_load_match.py (original) ++++ ./opencv_contrib-4.5.2/modules/surface_matching/samples/ppf_load_match.py (refactored) +@@ -26,7 +26,7 @@ + print("Poses: ") + for i, result in enumerate(results): + #result.printPose() +- print("\n-- Pose to Model Index %d: NumVotes = %d, Residual = %f\n%s\n" % (result.modelIndex, result.numVotes, result.residual, result.pose)) ++ print(("\n-- Pose to Model Index %d: NumVotes = %d, Residual = %f\n%s\n" % (result.modelIndex, result.numVotes, result.residual, result.pose))) + if i == 0: + pct = cv.ppf_match_3d.transformPCPose(pc, result.pose) + cv.ppf_match_3d.writePLY(pct, "%sPCTrans.ply" % modelname) +--- ./opencv_contrib-4.5.2/modules/rgbd/misc/python/test/test_rgbd.py (original) ++++ ./opencv_contrib-4.5.2/modules/rgbd/misc/python/test/test_rgbd.py (refactored) +@@ -1,7 +1,7 @@ + #!/usr/bin/env python + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import os, numpy + +--- ./modules/ts/misc/summary.py (original) ++++ ./modules/ts/misc/summary.py (refactored) +@@ -26,7 +26,7 @@ + + if __name__ == "__main__": + if len(sys.argv) < 2: +- print >> sys.stderr, "Usage:\n", os.path.basename(sys.argv[0]), ".xml [.xml ...]" ++ print("Usage:\n", os.path.basename(sys.argv[0]), ".xml [.xml ...]", file=sys.stderr) + exit(0) + + parser = OptionParser() +@@ -177,7 +177,7 @@ + prevGroupName = None + needNewRow = True + lastRow = None +- for name in sorted(test_cases.keys(), key=alphanum_keyselector): ++ for name in sorted(list(test_cases.keys()), key=alphanum_keyselector): + cases = test_cases[name] + if needNewRow: + lastRow = tbl.newRow() +@@ -239,7 +239,7 @@ + val = getter(case, cases[0], options.units) + def getRegression(fn): + if fn and val: +- for j in reversed(range(i)) if reference < 0 else [reference]: ++ for j in reversed(list(range(i))) if reference < 0 else [reference]: + r = cases[j] + if r is not None and r.get("status") == 'run': + return fn(case, r, options.units) +@@ -273,7 +273,7 @@ + tbl.trimLastRow() + + if options.regressionsOnly: +- for r in reversed(range(len(tbl.rows))): ++ for r in reversed(list(range(len(tbl.rows)))): + for i in range(1, len(options.regressions) + 1): + val = tbl.rows[r].cells[len(tbl.rows[r].cells) - i].value + if val is not None and val < float(options.regressionsOnly): +--- ./opencv_contrib-4.5.2/modules/text/samples/deeptextdetection.py (original) ++++ ./opencv_contrib-4.5.2/modules/text/samples/deeptextdetection.py (refactored) +@@ -15,8 +15,8 @@ + quit() + + if not os.path.isfile('TextBoxes_icdar13.caffemodel') or not os.path.isfile('textbox.prototxt'): +- print " Model files not found in current directory. Aborting" +- print " See the documentation of text::TextDetectorCNN class to get download links." ++ print(" Model files not found in current directory. Aborting") ++ print(" See the documentation of text::TextDetectorCNN class to get download links.") + quit() + + img = cv.imread(str(sys.argv[1])) +--- ./opencv_contrib-4.5.2/modules/matlab/generator/gen_matlab.py (original) ++++ ./opencv_contrib-4.5.2/modules/matlab/generator/gen_matlab.py (refactored) +@@ -8,7 +8,7 @@ + + def update_file(fname, content): + if fname in updated_files: +- print('ERROR(gen_matlab.py): attemption to write file multiple times: {}'.format(fname)) ++ print(('ERROR(gen_matlab.py): attemption to write file multiple times: {}'.format(fname))) + return + updated_files.append(fname) + if os.path.exists(fname): +@@ -17,9 +17,9 @@ + if old_content == content: + #print('Up-to-date: {}'.format(fname)) + return +- print('Updating: {}'.format(fname)) ++ print(('Updating: {}'.format(fname))) + else: +- print('Writing: {}'.format(fname)) ++ print(('Writing: {}'.format(fname))) + with open(fname, 'wb') as f: + f.write(content) + +--- ./modules/ts/misc/xls-report.py (original) ++++ ./modules/ts/misc/xls-report.py (refactored) +@@ -74,7 +74,7 @@ + Finally, run the script. Use the --help option for usage information. + """ + +-from __future__ import division ++ + + import ast + import errno +@@ -86,7 +86,7 @@ + + from argparse import ArgumentParser + from glob import glob +-from itertools import ifilter ++ + + import xlwt + +@@ -136,7 +136,7 @@ + properties = run.properties.copy() + del properties['module_name'] + +- props_key = tuple(sorted(properties.iteritems())) # dicts can't be keys ++ props_key = tuple(sorted(properties.items())) # dicts can't be keys + + if props_key in self.__config_cache: + configuration = self.__config_cache[props_key] +@@ -156,7 +156,7 @@ + Collector.__format_config_cache_key(props_key)) + + else: +- same_config_props = [it[0] for it in self.__config_cache.iteritems() if it[1] == configuration] ++ same_config_props = [it[0] for it in self.__config_cache.items() if it[1] == configuration] + if len(same_config_props) > 0: + logging.warning('property set %s matches the same configuration %r as property set %s', + Collector.__format_config_cache_key(props_key), +@@ -183,7 +183,7 @@ + def match_func(properties): + for matcher in matchers: + if all(properties.get(name) == value +- for (name, value) in matcher['properties'].iteritems()): ++ for (name, value) in matcher['properties'].items()): + return matcher['name'] + + return None +@@ -221,7 +221,7 @@ + sheet_conf = {} + logging.debug('no sheet.conf for %s', sheet_path) + +- sheet_conf = dict(global_conf.items() + sheet_conf.items()) ++ sheet_conf = dict(list(global_conf.items()) + list(sheet_conf.items())) + + config_names = sheet_conf.get('configurations', []) + config_matchers = sheet_conf.get('configuration_matchers', []) +@@ -304,23 +304,23 @@ + + module_colors = sheet_conf.get('module_colors', {}) + module_styles = {module: xlwt.easyxf('pattern: pattern solid, fore_color {}'.format(color)) +- for module, color in module_colors.iteritems()} +- +- for module, tests in sorted(collector.tests.iteritems()): +- for ((test, param), configs) in sorted(tests.iteritems()): ++ for module, color in module_colors.items()} ++ ++ for module, tests in sorted(collector.tests.items()): ++ for ((test, param), configs) in sorted(tests.items()): + sheet.write(row, 0, module, module_styles.get(module, xlwt.Style.default_style)) + sheet.write(row, 1, test) + + param_list = param[1:-1].split(', ') if param.startswith('(') and param.endswith(')') else [param] + +- image_size = next(ifilter(re_image_size.match, param_list), None) ++ image_size = next(filter(re_image_size.match, param_list), None) + if image_size is not None: +- (image_width, image_height) = map(int, image_size.split('x', 1)) ++ (image_width, image_height) = list(map(int, image_size.split('x', 1))) + sheet.write(row, 2, image_width) + sheet.write(row, 3, image_height) + del param_list[param_list.index(image_size)] + +- data_type = next(ifilter(re_data_type.match, param_list), None) ++ data_type = next(filter(re_data_type.match, param_list), None) + if data_type is not None: + sheet.write(row, 4, data_type) + del param_list[param_list.index(data_type)] +--- ./opencv_contrib-4.5.2/modules/tracking/samples/tracker.py (original) ++++ ./opencv_contrib-4.5.2/modules/tracking/samples/tracker.py (refactored) +@@ -19,7 +19,7 @@ + while camera.isOpened(): + ok, image=camera.read() + if not ok: +- print 'no image to read' ++ print('no image to read') + break + + if not init_once: +@@ -27,7 +27,7 @@ + init_once = True + + ok, newbox = tracker.update(image) +- print ok, newbox ++ print(ok, newbox) + + if ok: + p1 = (int(newbox[0]), int(newbox[1])) +--- ./opencv_contrib-4.5.2/modules/surface_matching/samples/ppf_icp.py (original) ++++ ./opencv_contrib-4.5.2/modules/surface_matching/samples/ppf_icp.py (refactored) +@@ -20,8 +20,8 @@ + noise2 = np.random.normal(0.0, 1.0, height * width) + + x, y = np.meshgrid( +- range(-width//2, width//2), +- range(-height//2, height//2), ++ list(range(-width//2, width//2)), ++ list(range(-height//2, height//2)), + sparse=False, indexing='xy' + ) + z = np.zeros((height, width)) +@@ -45,8 +45,8 @@ + icp = cv.ppf_match_3d_ICP(100) + + I = np.eye(4) +-print("Unaligned error:\t%.6f" % np.linalg.norm(I - Rt)) ++print(("Unaligned error:\t%.6f" % np.linalg.norm(I - Rt))) + for i in range(3): + rotated_cloud[i] = np.matmul(Rt[0:3,0:3], cloud[i].T).T + Rt[:3,3].T + retval[i], residual[i], pose[i] = icp.registerModelToScene(rotated_cloud[i], cloud[i]) +- print("ICP error:\t\t%.6f" % np.linalg.norm(I - np.matmul(pose[0], Rt))) ++ print(("ICP error:\t\t%.6f" % np.linalg.norm(I - np.matmul(pose[0], Rt)))) +--- ./opencv_contrib-4.5.2/modules/tracking/samples/multitracker.py (original) ++++ ./opencv_contrib-4.5.2/modules/tracking/samples/multitracker.py (refactored) +@@ -25,7 +25,7 @@ + while camera.isOpened(): + ok, image=camera.read() + if not ok: +- print 'no image to read' ++ print('no image to read') + break + + if not init_once: +@@ -35,7 +35,7 @@ + init_once = True + + ok, boxes = tracker.update(image) +- print ok, boxes ++ print(ok, boxes) + + for newbox in boxes: + p1 = (int(newbox[0]), int(newbox[1])) +--- ./opencv_contrib-4.5.2/modules/text/samples/textdetection.py (original) ++++ ./opencv_contrib-4.5.2/modules/text/samples/textdetection.py (refactored) +@@ -31,7 +31,7 @@ + channels.append((255-channels[c])) + + # Apply the default cascade classifier to each independent channel (could be done in parallel) +-print("Extracting Class Specific Extremal Regions from "+str(len(channels))+" channels ...") ++print(("Extracting Class Specific Extremal Regions from "+str(len(channels))+" channels ...")) + print(" (...) this may take a while (...)") + for channel in channels: + +--- ./opencv_contrib-4.5.2/modules/structured_light/misc/python/test/test_structured_light.py (original) ++++ ./opencv_contrib-4.5.2/modules/structured_light/misc/python/test/test_structured_light.py (refactored) +@@ -1,7 +1,7 @@ + #!/usr/bin/env python + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import os, numpy + +--- ./opencv_contrib-4.5.2/modules/ximgproc/samples/edgeboxes_demo.py (original) ++++ ./opencv_contrib-4.5.2/modules/ximgproc/samples/edgeboxes_demo.py (refactored) +@@ -30,14 +30,14 @@ + boxes, scores = edge_boxes.getBoundingBoxes(edges, orimap) + + if len(boxes) > 0: +- boxes_scores = zip(boxes, scores) ++ boxes_scores = list(zip(boxes, scores)) + for b_s in boxes_scores: + box = b_s[0] + x, y, w, h = box + cv.rectangle(im, (x, y), (x+w, y+h), (0, 255, 0), 1, cv.LINE_AA) + score = b_s[1][0] + cv.putText(im, "{:.2f}".format(score), (x, y), cv.FONT_HERSHEY_PLAIN, 0.8, (255, 255, 255), 1, cv.LINE_AA) +- print("Box at (x,y)=({:d},{:d}); score={:f}".format(x, y, score)) ++ print(("Box at (x,y)=({:d},{:d}); score={:f}".format(x, y, score))) + + cv.imshow("edges", edges) + cv.imshow("edgeboxes", im) +--- ./opencv_contrib-4.5.2/samples/python2/lsd_lines_extraction.py (original) ++++ ./opencv_contrib-4.5.2/samples/python2/lsd_lines_extraction.py (refactored) +@@ -20,7 +20,7 @@ + img = cv.imread(fname) + + if img is None: +- print('Failed to load image file:', fname) ++ print(('Failed to load image file:', fname)) + sys.exit(1) + + gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) +--- ./opencv_contrib-4.5.2/modules/ximgproc/samples/edge_drawing.py (original) ++++ ./opencv_contrib-4.5.2/modules/ximgproc/samples/edge_drawing.py (refactored) +@@ -9,7 +9,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./opencv_contrib-4.5.2/modules/wechat_qrcode/samples/qrcode.py (original) ++++ ./opencv_contrib-4.5.2/modules/wechat_qrcode/samples/qrcode.py (refactored) +@@ -1,7 +1,7 @@ + import cv2 + import sys + +-print(sys.argv[0]) ++print((sys.argv[0])) + print('A demo program of WeChat QRCode Detector:') + camIdx = -1 + if len(sys.argv) > 1: +@@ -9,7 +9,7 @@ + camIdx = int(sys.argv[2]) if len(sys.argv)>2 else 0 + img = cv2.imread(sys.argv[1]) + else: +- print(" Usage: " + sys.argv[0] + " ") ++ print((" Usage: " + sys.argv[0] + " ")) + exit(0) + + # For python API generator, it follows the template: {module_name}_{class_name}, +@@ -32,7 +32,7 @@ + + if camIdx < 0: + res, points = detector.detectAndDecode(img) +- print(res,points) ++ print((res,points)) + else: + cap = cv2.VideoCapture(camIdx) + while True: +--- ./opencv_contrib-4.5.2/modules/optflow/src/learn_prior.py (original) ++++ ./opencv_contrib-4.5.2/modules/optflow/src/learn_prior.py (refactored) +@@ -51,8 +51,7 @@ + f.append(p) + else: + for root, subdirs, files in os.walk(p): +- f += map(lambda x: os.path.join(root, x), +- filter(lambda x: x.split('.')[-1] == 'flo', files)) ++ f += [os.path.join(root, x) for x in [x for x in files if x.split('.')[-1] == 'flo']] + return list(set(f)) + + +@@ -64,7 +63,7 @@ + else: + w = np.fromfile(f, np.int32, count=1)[0] + h = np.fromfile(f, np.int32, count=1)[0] +- print('Reading %dx%d flo file %s' % (w, h, flo)) ++ print(('Reading %dx%d flo file %s' % (w, h, flo))) + data = np.fromfile(f, np.float32, count=2 * w * h) + # Reshape data into 3D array (columns, rows, bands) + flow = np.reshape(data, (h, w, 2)) +@@ -93,15 +92,15 @@ + w1mean = sum(w1) / len(w1) + w2mean = sum(w2) / len(w2) + +-for i in xrange(len(w1)): ++for i in range(len(w1)): + w1[i] -= w1mean +-for i in xrange(len(w2)): ++for i in range(len(w2)): + w2[i] -= w2mean + + Q1 = sum([w1[i].reshape(-1, 1).dot(w1[i].reshape(1, -1)) +- for i in xrange(len(w1))]) / len(w1) ++ for i in range(len(w1))]) / len(w1) + Q2 = sum([w2[i].reshape(-1, 1).dot(w2[i].reshape(1, -1)) +- for i in xrange(len(w2))]) / len(w2) ++ for i in range(len(w2))]) / len(w2) + Q1 = np.matrix(Q1) + Q2 = np.matrix(Q2) + +@@ -113,7 +112,7 @@ + except np.linalg.linalg.LinAlgError: + mev = min(np.linalg.eig(Q1)[0]).real + assert (mev < 0) +- print('Q1', mev) ++ print(('Q1', mev)) + if -mev < 1e-6: + mev = -1e-6 + Q1 += (-mev * 1.000001) * np.identity(Q1.shape[0]) +@@ -125,7 +124,7 @@ + except np.linalg.linalg.LinAlgError: + mev = min(np.linalg.eig(Q2)[0]).real + assert (mev < 0) +- print('Q2', mev) ++ print(('Q2', mev)) + if -mev < 1e-6: + mev = -1e-6 + Q2 += (-mev * 1.000001) * np.identity(Q2.shape[0]) +@@ -144,12 +143,12 @@ + f.write(struct.pack('I', L1.shape[0])) + f.write(struct.pack('I', L1.shape[1])) + +-for i in xrange(L1.shape[0]): +- for j in xrange(L1.shape[1]): ++for i in range(L1.shape[0]): ++ for j in range(L1.shape[1]): + f.write(struct.pack('f', L1[i, j])) + +-for i in xrange(L2.shape[0]): +- for j in xrange(L2.shape[1]): ++for i in range(L2.shape[0]): ++ for j in range(L2.shape[1]): + f.write(struct.pack('f', L2[i, j])) + + b1 = L1.dot(w1mean.reshape(-1, 1)) +@@ -157,10 +156,10 @@ + + assert (L1.shape[0] == b1.shape[0]) + +-for i in xrange(b1.shape[0]): ++for i in range(b1.shape[0]): + f.write(struct.pack('f', b1[i, 0])) + +-for i in xrange(b2.shape[0]): ++for i in range(b2.shape[0]): + f.write(struct.pack('f', b2[i, 0])) + + f.close() +--- ./opencv_extra-4.5.2/testdata/dnn/layers/run.py (original) ++++ ./opencv_extra-4.5.2/testdata/dnn/layers/run.py (refactored) +@@ -20,7 +20,7 @@ + out_blob = net.blobs['output'].data[...]; + + if net.params.get('output'): +- print "Params count:", len(net.params['output']) ++ print("Params count:", len(net.params['output'])) + net.save(caffemodel_name) + + return out_blob +@@ -37,9 +37,9 @@ + inp_blob_name = proto_basename + ".input.npy" + inp_blob = np.load(inp_blob_name) if os.path.exists(inp_blob_name) else np.load('blob.npy') + +- print "\nGenerate data for:" +- print cfmod_basename, inp_blob.shape ++ print("\nGenerate data for:") ++ print(cfmod_basename, inp_blob.shape) + + out_blob = get_cafe_output(inp_blob, proto_filename, cfmod_basename) +- print out_blob.shape ++ print(out_blob.shape) + np.save(npy_filename, out_blob) +--- ./opencv_contrib-4.5.2/modules/julia/gen/gen3_cpp.py (original) ++++ ./opencv_contrib-4.5.2/modules/julia/gen/gen3_cpp.py (refactored) +@@ -5,7 +5,7 @@ + # of this distribution and at http://opencv.org/license.html + # Copyright (C) 2020 by Archit Rungta + +-from __future__ import unicode_literals # Needed for python2 ++ # Needed for python2 + + import hdr_parser, sys, re, os + from string import Template +@@ -17,7 +17,7 @@ + if sys.version_info[0] >= 3: + from io import StringIO + else: +- from cStringIO import StringIO ++ from io import StringIO + + + from parse_tree import * +@@ -203,7 +203,7 @@ + namespaces, default_values = gen_tree(srcfiles) + cpp_code = StringIO() + include_code = StringIO() +- nsi = sorted(namespaces.items(), key =lambda x: x[0]) ++ nsi = sorted(list(namespaces.items()), key =lambda x: x[0]) + + for name, ns in nsi: + cpp_code.write("using namespace %s;\n" % name.replace(".", "::")) +@@ -238,7 +238,7 @@ + + return final_order + +- sorted_cls = sort_classes(ns.classes.items()) ++ sorted_cls = sort_classes(list(ns.classes.items())) + for name, cl in sorted_cls: + cl.__class__ = ClassInfo + cpp_code.write(cl.get_cpp_code_header()) +@@ -251,7 +251,7 @@ + }; + """ % (cl.name.replace('.', '::'), cl.base.replace('.', '::'))) + +- for e1,e2 in ns.enums.items(): ++ for e1,e2 in list(ns.enums.items()): + # cpp_code.write('\n mod.add_bits<{0}>("{1}", jlcxx::julia_type("CppEnum"));'.format(e2[0], e2[1])) + enums.append(e2[0]) + enums.append(e2[1]) +@@ -262,13 +262,13 @@ + cpp_code.write(' mod.add_type<%s>("%s");\n' %(tp, normalize_class_name(tp))) + + +- for name, ns in namespaces.items(): ++ for name, ns in list(namespaces.items()): + + nsname = name.replace("::", "_") +- for name, cl in ns.classes.items(): ++ for name, cl in list(ns.classes.items()): + cl.__class__ = ClassInfo + cpp_code.write(cl.get_cpp_code_body()) +- for mname, fs in cl.methods.items(): ++ for mname, fs in list(cl.methods.items()): + for f in fs: + f.__class__ = FuncVariant + cpp_code.write('\n mod%s;' % f.get_complete_code(cl.name, cl.isalgorithm)) +@@ -276,7 +276,7 @@ + # cpp_code.write('\n %s; \n' % f.get_cons_code(cl.name, cl.mapped_name)) + + +- for mname, fs in ns.funcs.items(): ++ for mname, fs in list(ns.funcs.items()): + for f in fs: + f.__class__ = FuncVariant + cpp_code.write('\n mod%s;' % f.get_complete_code("", False)) +--- ./opencv_contrib-4.5.2/samples/python2/seeds.py (original) ++++ ./opencv_contrib-4.5.2/samples/python2/seeds.py (refactored) +@@ -20,7 +20,7 @@ + + + if __name__ == '__main__': +- print __doc__ ++ print(__doc__) + + try: + fn = sys.argv[1] +--- ./modules/ts/misc/trace_profiler.py (original) ++++ ./modules/ts/misc/trace_profiler.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + + import os + import sys +@@ -7,7 +7,7 @@ + from collections import deque + + try: +- long # Python 2 ++ int # Python 2 + except NameError: + long = int # Python 3 + +@@ -39,7 +39,7 @@ + pass + if sys.version_info[0] < 3: + try: +- return long(s) ++ return int(s) + except ValueError: + pass + return s +@@ -252,7 +252,7 @@ + self.tasks_list.sort(key=lambda x: x.beginTimestamp) + + parallel_for_location = None +- for (id, l) in self.locations.items(): ++ for (id, l) in list(self.locations.items()): + if l.name == 'parallel_for': + parallel_for_location = l.locationID + break +@@ -369,16 +369,16 @@ + dpprint(self.locations) + dpprint(calls) + +- calls_self_sum = {k: sum(v.selfTimes) for (k, v) in calls.items()} +- calls_total_sum = {k: sum(v.totalTimes) for (k, v) in calls.items()} +- calls_median = {k: median(v.selfTimes) for (k, v) in calls.items()} +- calls_sorted = sorted(calls.keys(), key=lambda x: calls_self_sum[x], reverse=True) +- +- calls_self_sum_IPP = {k: sum(v.selfTimesIPP) for (k, v) in calls.items()} +- calls_total_sum_IPP = {k: sum(v.totalTimesIPP) for (k, v) in calls.items()} +- +- calls_self_sum_OpenCL = {k: sum(v.selfTimesOpenCL) for (k, v) in calls.items()} +- calls_total_sum_OpenCL = {k: sum(v.totalTimesOpenCL) for (k, v) in calls.items()} ++ calls_self_sum = {k: sum(v.selfTimes) for (k, v) in list(calls.items())} ++ calls_total_sum = {k: sum(v.totalTimes) for (k, v) in list(calls.items())} ++ calls_median = {k: median(v.selfTimes) for (k, v) in list(calls.items())} ++ calls_sorted = sorted(list(calls.keys()), key=lambda x: calls_self_sum[x], reverse=True) ++ ++ calls_self_sum_IPP = {k: sum(v.selfTimesIPP) for (k, v) in list(calls.items())} ++ calls_total_sum_IPP = {k: sum(v.totalTimesIPP) for (k, v) in list(calls.items())} ++ ++ calls_self_sum_OpenCL = {k: sum(v.selfTimesOpenCL) for (k, v) in list(calls.items())} ++ calls_total_sum_OpenCL = {k: sum(v.totalTimesOpenCL) for (k, v) in list(calls.items())} + + if max_entries > 0 and len(calls_sorted) > max_entries: + calls_sorted = calls_sorted[:max_entries] +--- ./opencv_contrib-4.5.2/modules/matlab/generator/parse_tree.py (original) ++++ ./opencv_contrib-4.5.2/modules/matlab/generator/parse_tree.py (refactored) +@@ -3,10 +3,10 @@ + from filters import * + try: + # Python 2.7+ +- basestring ++ str + except NameError: + # Python 3.3+ +- basestring = str ++ str = str + + + valid_types = ( +@@ -99,7 +99,7 @@ + + def build(self, namespaces): + babel = Translator() +- for name, definitions in namespaces.items(): ++ for name, definitions in list(namespaces.items()): + class_tree = {} + methods = [] + constants = [] +@@ -353,7 +353,7 @@ + for node in tree['constants']: + yield (node['name'], node['default']) + if isinstance(tree, dict): +- for key, val in tree.items(): ++ for key, val in list(tree.items()): + for gen in constants(val): + yield gen + if isinstance(tree, list): +@@ -367,10 +367,10 @@ + Recursively convert a Python object graph to sequences (lists) + and mappings (dicts) of primitives (bool, int, float, string, ...) + """ +- if isinstance(obj, basestring): ++ if isinstance(obj, str): + return obj + elif isinstance(obj, dict): +- return dict((key, todict(val)) for key, val in obj.items()) ++ return dict((key, todict(val)) for key, val in list(obj.items())) + elif isinstance(obj, collections.Iterable): + return [todict(val) for val in obj] + elif hasattr(obj, '__dict__'): +--- ./opencv_extra-4.5.2/testdata/perf/append.py (original) ++++ ./opencv_extra-4.5.2/testdata/perf/append.py (refactored) +@@ -22,7 +22,7 @@ + if case.nodeName in tests: + del tests[case.nodeName] + +- for case in tests.items(): ++ for case in list(tests.items()): + fstorage.appendChild(case[1]) + + if tests: +@@ -39,7 +39,7 @@ + + if __name__ == "__main__": + if len(sys.argv) < 3: +- print "Usage:\n", os.path.basename(sys.argv[0]), ".xml .xml" ++ print("Usage:\n", os.path.basename(sys.argv[0]), ".xml .xml") + exit(0) + + processLogFile(sys.argv[1], sys.argv[2]) +--- ./opencv_contrib-4.5.2/modules/julia/gen/gen3_julia_cxx.py (original) ++++ ./opencv_contrib-4.5.2/modules/julia/gen/gen3_julia_cxx.py (refactored) +@@ -5,7 +5,7 @@ + # of this distribution and at http://opencv.org/license.html + # Copyright (C) 2020 by Archit Rungta + +-from __future__ import unicode_literals # Needed for python2 ++ # Needed for python2 + + import hdr_parser, sys, re, os + from string import Template +@@ -14,7 +14,7 @@ + if sys.version_info[0] >= 3: + from io import StringIO + else: +- from cStringIO import StringIO ++ from io import StringIO + import os, shutil + + from parse_tree import * +@@ -54,7 +54,7 @@ + if inp in jl_cpp_defmap[tp]: + out = jl_cpp_defmap[tp][inp] + elif inp != '': +- print(inp+" not found") ++ print((inp+" not found")) + # print(inp, tp, out) + return out + +@@ -164,30 +164,30 @@ + namespaces, _ = gen_tree(srcfiles) + + jl_code = StringIO() +- for name, ns in namespaces.items(): ++ for name, ns in list(namespaces.items()): + cv_types.extend(ns.registered) + jl_code = StringIO() + nsname = name +- for e1,e2 in ns.enums.items(): ++ for e1,e2 in list(ns.enums.items()): + # jl_code.write('\n const {0} = Int32'.format(e2[0])) + jl_code.write('\n const {0} = Int32 \n'.format(e2[1])) + + # Do not duplicate functions. This should prevent overwriting of Mat function by UMat functions + function_signatures = [] +- for cname, cl in ns.classes.items(): ++ for cname, cl in list(ns.classes.items()): + cl.__class__ = ClassInfo + jl_code.write(cl.get_jl_code()) +- for mname, fs in cl.methods.items(): ++ for mname, fs in list(cl.methods.items()): + for f in fs: + f.__class__ = FuncVariant + sign = (f.name, f.mapped_name, f.classname, [x.tp for x in f.inlist+f.optlist]) + if sign in function_signatures: +- print("Skipping entirely: ", f.name) ++ print(("Skipping entirely: ", f.name)) + continue + sign2 = (f.name, f.mapped_name, f.classname, [x.tp for x in f.inlist]) + gend = True + if sign2 in function_signatures: +- print("Skipping default declaration: ", f.name) ++ print(("Skipping default declaration: ", f.name)) + gend = False + jl_code.write('\n%s' % f.get_complete_code(classname = cl.mapped_name, isalgo = cl.isalgorithm, gen_default = gend, ns=nsname)) + function_signatures.append(sign) +@@ -195,17 +195,17 @@ + for f in cl.constructors: + f.__class__ = FuncVariant + jl_code.write('\n%s' % f.get_complete_code(classname = cl.mapped_name, isalgo = cl.isalgorithm, iscons = True, ns=nsname)) +- for mname, fs in ns.funcs.items(): ++ for mname, fs in list(ns.funcs.items()): + for f in fs: + f.__class__ = FuncVariant + sign = (f.name, f.mapped_name, f.classname, [x.tp for x in f.inlist+f.optlist]) + if sign in function_signatures: +- print("Skipping entirely: ", f.name) ++ print(("Skipping entirely: ", f.name)) + continue + gend = True + sign2 = (f.name, f.mapped_name, f.classname, [x.tp for x in f.inlist]) + if sign2 in function_signatures: +- print("Skipping default declaration: ", f.name) ++ print(("Skipping default declaration: ", f.name)) + gend = False + + jl_code.write('\n%s' % f.get_complete_code(gen_default = gend, ns=nsname)) +--- ./opencv_extra-4.5.2/testdata/perf/clean_regex.py (original) ++++ ./opencv_extra-4.5.2/testdata/perf/clean_regex.py (refactored) +@@ -20,7 +20,7 @@ + if case.nodeName == "#text": + continue + if expr.search(case.nodeName): +- print case.nodeName ++ print(case.nodeName) + fstorage.removeChild(case) + + if save_results: +@@ -35,8 +35,8 @@ + + if __name__ == "__main__": + if len(sys.argv) < 3: +- print "This script is used to remove entries from sanity xml" +- print " Usage:\n", os.path.basename(sys.argv[0]), ".xml " ++ print("This script is used to remove entries from sanity xml") ++ print(" Usage:\n", os.path.basename(sys.argv[0]), ".xml ") + exit(0) + + process(sys.argv[1], re.compile(sys.argv[2]), len(sys.argv) == 4) +--- ./opencv_contrib-4.5.2/modules/optflow/samples/optical_flow_benchmark.py (original) ++++ ./opencv_contrib-4.5.2/modules/optflow/samples/optical_flow_benchmark.py (refactored) +@@ -1,5 +1,5 @@ + #!/usr/bin/env python +-from __future__ import print_function ++ + import os, sys, shutil + import argparse + import json, re +@@ -47,9 +47,9 @@ + + def evaluate_sequence(sequence, algorithm, dataset, executable, img_files, gt_files, + state, state_path): +- if "eval_results" not in state[dataset][algorithm][-1].keys(): ++ if "eval_results" not in list(state[dataset][algorithm][-1].keys()): + state[dataset][algorithm][-1]["eval_results"] = {} +- elif sequence in state[dataset][algorithm][-1]["eval_results"].keys(): ++ elif sequence in list(state[dataset][algorithm][-1]["eval_results"].keys()): + return + + res = [] +@@ -127,13 +127,13 @@ + marker_idx = 0 + colors = ["b", "g", "r"] + color_idx = 0 +- for algo in state[dataset].keys(): ++ for algo in list(state[dataset].keys()): + for eval_instance in state[dataset][algo]: + name = algo + "--" + eval_instance["timestamp"] + average_time = 0.0 + average_error = 0.0 + num_elem = 0 +- for seq in eval_instance["eval_results"].keys(): ++ for seq in list(eval_instance["eval_results"].keys()): + for frame in eval_instance["eval_results"][seq]: + average_time += frame["time"] + average_error += frame["error"]["average"] +@@ -232,7 +232,7 @@ + algorithm_list = parse_sequence(args.algorithms) + dataset_list = parse_sequence(args.datasets) + for dataset in dataset_list: +- if dataset not in dataset_eval_functions.keys(): ++ if dataset not in list(dataset_eval_functions.keys()): + print("Error: unsupported dataset " + dataset) + sys.exit(1) + if dataset not in os.listdir(args.dataset_folder): +@@ -242,12 +242,12 @@ + sys.exit(1) + + for dataset in dataset_list: +- if dataset not in state.keys(): ++ if dataset not in list(state.keys()): + state[dataset] = {} + for algorithm in algorithm_list: +- if algorithm in state[dataset].keys(): ++ if algorithm in list(state[dataset].keys()): + last_eval_instance = state[dataset][algorithm][-1] +- if "finished" not in last_eval_instance.keys(): ++ if "finished" not in list(last_eval_instance.keys()): + print(("Continuing an unfinished evaluation of " + + algorithm + " started at " + last_eval_instance["timestamp"])) + else: +--- ./modules/js/generator/embindgen.py (original) ++++ ./modules/js/generator/embindgen.py (refactored) +@@ -67,14 +67,14 @@ + # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ############################################################################### + +-from __future__ import print_function ++ + import sys, re, os + from templates import * + + if sys.version_info[0] >= 3: + from io import StringIO + else: +- from cStringIO import StringIO ++ from io import StringIO + + + func_table = {} +@@ -96,7 +96,7 @@ + def makeWhiteList(module_list): + wl = {} + for m in module_list: +- for k in m.keys(): ++ for k in list(m.keys()): + if k in wl: + wl[k] += m[k] + else: +--- ./opencv_extra-4.5.2/testdata/dnn/tensorflow/generate_tf2_models.py (original) ++++ ./opencv_extra-4.5.2/testdata/dnn/tensorflow/generate_tf2_models.py (refactored) +@@ -37,7 +37,7 @@ + + assert(len(kwargs) == 1) + +- inputData = gen_data(next(iter(kwargs.values()))) ++ inputData = gen_data(next(iter(list(kwargs.values())))) + outputData = model(inputData) + + writeBlob(inputData, name + '_in') +--- ./opencv_extra-4.5.2/testdata/perf/clean_unused.py (original) ++++ ./opencv_extra-4.5.2/testdata/perf/clean_unused.py (refactored) +@@ -33,7 +33,7 @@ + + if __name__ == "__main__": + if len(sys.argv) < 3: +- print "Usage:\n", os.path.basename(sys.argv[0]), ".xml .backup.xml" ++ print("Usage:\n", os.path.basename(sys.argv[0]), ".xml .backup.xml") + exit(0) + + tests = parseLogFile(sys.argv[1]) +--- ./platforms/osx/build_docs.py (original) ++++ ./platforms/osx/build_docs.py (refactored) +@@ -3,13 +3,13 @@ + This script builds OpenCV docs for macOS. + """ + +-from __future__ import print_function ++ + import os, sys, multiprocessing, argparse, traceback + from subprocess import check_call, check_output, CalledProcessError, Popen + + # import common code + sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../ios')) +-from build_docs import DocBuilder ++from .build_docs import DocBuilder + + class OSXDocBuilder(DocBuilder): + +--- ./platforms/apple/cv_build_utils.py (original) ++++ ./platforms/apple/cv_build_utils.py (refactored) +@@ -3,7 +3,7 @@ + Common utilities. These should be compatible with Python 2 and 3. + """ + +-from __future__ import print_function ++ + import sys, re + from subprocess import check_call, check_output, CalledProcessError + +--- ./platforms/osx/run_tests.py (original) ++++ ./platforms/osx/run_tests.py (refactored) +@@ -3,12 +3,12 @@ + This script runs OpenCV.framework tests for OSX. + """ + +-from __future__ import print_function ++ + import os, os.path, sys, argparse, traceback, multiprocessing + + # import common code + sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../ios')) +-from run_tests import TestRunner ++from .run_tests import TestRunner + + MACOSX_DEPLOYMENT_TARGET='10.12' # default, can be changed via command line options or environment variable + +--- ./platforms/ios/build_docs.py (original) ++++ ./platforms/ios/build_docs.py (refactored) +@@ -3,7 +3,7 @@ + This script builds OpenCV docs for iOS. + """ + +-from __future__ import print_function ++ + import os, sys, multiprocessing, argparse, traceback + from subprocess import check_call, check_output, CalledProcessError, Popen + +--- ./platforms/apple/build_xcframework.py (original) ++++ ./platforms/apple/build_xcframework.py (refactored) +@@ -5,7 +5,7 @@ + """ + + import sys, os, argparse, pathlib, traceback, contextlib, shutil +-from cv_build_utils import execute, print_error, print_header, get_xcode_version, get_cmake_version ++from .cv_build_utils import execute, print_error, print_header, get_xcode_version, get_cmake_version + + if __name__ == "__main__": + +@@ -37,32 +37,32 @@ + + args, unknown_args = parser.parse_known_args() + if unknown_args: +- print("The following args are not recognized by this script and will be passed through to the ios/osx build_framework.py scripts: {}".format(unknown_args)) ++ print(("The following args are not recognized by this script and will be passed through to the ios/osx build_framework.py scripts: {}".format(unknown_args))) + + # Parse architectures from args + iphoneos_archs = args.iphoneos_archs + if not iphoneos_archs and not args.build_only_specified_archs: + # Supply defaults + iphoneos_archs = "armv7,arm64" +- print('Using iPhoneOS ARCHS={}'.format(iphoneos_archs)) ++ print(('Using iPhoneOS ARCHS={}'.format(iphoneos_archs))) + + iphonesimulator_archs = args.iphonesimulator_archs + if not iphonesimulator_archs and not args.build_only_specified_archs: + # Supply defaults + iphonesimulator_archs = "x86_64,arm64" +- print('Using iPhoneSimulator ARCHS={}'.format(iphonesimulator_archs)) ++ print(('Using iPhoneSimulator ARCHS={}'.format(iphonesimulator_archs))) + + macos_archs = args.macos_archs + if not macos_archs and not args.build_only_specified_archs: + # Supply defaults + macos_archs = "x86_64,arm64" +- print('Using MacOS ARCHS={}'.format(macos_archs)) ++ print(('Using MacOS ARCHS={}'.format(macos_archs))) + + catalyst_archs = args.macos_archs + if not catalyst_archs and not args.build_only_specified_archs: + # Supply defaults + catalyst_archs = "x86_64,arm64" +- print('Using Catalyst ARCHS={}'.format(catalyst_archs)) ++ print(('Using Catalyst ARCHS={}'.format(catalyst_archs))) + + # Build phase + +@@ -113,7 +113,7 @@ + # file will cause the xcodebuild command to fail. + with contextlib.suppress(FileNotFoundError): + shutil.rmtree(xcframework_path) +- print("Removed existing xcframework at {}".format(xcframework_path)) ++ print(("Removed existing xcframework at {}".format(xcframework_path))) + + xcframework_build_command = [ + "xcodebuild", +--- ./platforms/android/build-tests/test_cmake_build.py (original) ++++ ./platforms/android/build-tests/test_cmake_build.py (refactored) +@@ -100,7 +100,7 @@ + "-DOpenCV_DIR=%s" % self.opencv_cmake_path, + "-DCMAKE_TOOLCHAIN_FILE=%s" % self.getCMakeToolchain(), + self.srcdir +- ] + [ "-D{}={}".format(key, value) for key, value in self.cmake_vars.items() ] ++ ] + [ "-D{}={}".format(key, value) for key, value in list(self.cmake_vars.items()) ] + log.info("Executing: %s" % cmd) + retcode = subprocess.call(cmd) + self.assertEqual(retcode, 0, "cmake failed") +@@ -120,7 +120,7 @@ + + suite = unittest.TestSuite() + for libset in ["", "opencv_java"]: +- for abi, cmake_vars in abis.items(): ++ for abi, cmake_vars in list(abis.items()): + suite.addTest(TestCmakeBuild(libset, abi, cmake_vars, opencv_cmake_path, + os.path.join(workdir, "{}-{}".format(abi, "static" if libset == "" else "shared")))) + return suite +@@ -143,8 +143,8 @@ + if not 'ANDROID_HOME' in os.environ and 'ANDROID_SDK' in os.environ: + os.environ['ANDROID_HOME'] = os.environ["ANDROID_SDK"] + +- print("Using SDK: %s" % os.environ["ANDROID_SDK"]) +- print("Using NDK: %s" % os.environ["ANDROID_NDK"]) ++ print(("Using SDK: %s" % os.environ["ANDROID_SDK"])) ++ print(("Using NDK: %s" % os.environ["ANDROID_NDK"])) + + workdir = os.path.abspath(args.workdir) + if not os.path.exists(workdir): +--- ./opencv_contrib-4.5.2/samples/python2/video.py (original) ++++ ./opencv_contrib-4.5.2/samples/python2/video.py (refactored) +@@ -50,7 +50,7 @@ + self.frame_size = (w, h) + + if size is not None: +- w, h = map(int, size.split('x')) ++ w, h = list(map(int, size.split('x'))) + self.frame_size = (w, h) + self.bg = cv.resize(self.bg, self.frame_size) + +@@ -158,11 +158,11 @@ + else: + cap = cv.VideoCapture(source) + if 'size' in params: +- w, h = map(int, params['size'].split('x')) ++ w, h = list(map(int, params['size'].split('x'))) + cap.set(cv.CAP_PROP_FRAME_WIDTH, w) + cap.set(cv.CAP_PROP_FRAME_HEIGHT, h) + if cap is None or not cap.isOpened(): +- print 'Warning: unable to open video source: ', source ++ print('Warning: unable to open video source: ', source) + if fallback is not None: + return create_capture(fallback, None) + return cap +@@ -171,7 +171,7 @@ + import sys + import getopt + +- print __doc__ ++ print(__doc__) + + args, sources = getopt.getopt(sys.argv[1:], '', 'shotdir=') + args = dict(args) +@@ -179,7 +179,7 @@ + if len(sources) == 0: + sources = [ 0 ] + +- caps = map(create_capture, sources) ++ caps = list(map(create_capture, sources)) + shot_idx = 0 + while True: + imgs = [] +@@ -194,6 +194,6 @@ + for i, img in enumerate(imgs): + fn = '%s/shot_%d_%03d.bmp' % (shotdir, i, shot_idx) + cv.imwrite(fn, img) +- print fn, 'saved' ++ print(fn, 'saved') + shot_idx += 1 + cv.destroyAllWindows() +--- ./platforms/ios/run_tests.py (original) ++++ ./platforms/ios/run_tests.py (refactored) +@@ -3,7 +3,7 @@ + This script runs OpenCV.framework tests for iOS. + """ + +-from __future__ import print_function ++ + import glob, re, os, os.path, shutil, string, sys, argparse, traceback, multiprocessing + from subprocess import check_call, check_output, CalledProcessError + +--- ./opencv_contrib-4.5.2/modules/xphoto/samples/color_balance_benchmark.py (original) ++++ ./opencv_contrib-4.5.2/modules/xphoto/samples/color_balance_benchmark.py (refactored) +@@ -1,5 +1,5 @@ + #!/usr/bin/env python +-from __future__ import print_function ++ + import os, sys, argparse, json + import numpy as np + import scipy.io +@@ -111,7 +111,7 @@ + ' Algorithm Name \n', + ' Average Time \n'] + for stat in stat_list: +- if stat not in stat_dict.keys(): ++ if stat not in list(stat_dict.keys()): + print("Error: unsupported statistic " + stat) + sys.exit(1) + html_out += [' ' + +@@ -121,9 +121,9 @@ + ' \n', + ' \n'] + +- for algorithm in state.keys(): +- arr = [state[algorithm][file]["angular_error"] for file in state[algorithm].keys() if file>=img_range[0] and file<=img_range[1]] +- average_time = "%.2f ms" % np.mean([state[algorithm][file]["time"] for file in state[algorithm].keys() ++ for algorithm in list(state.keys()): ++ arr = [state[algorithm][file]["angular_error"] for file in list(state[algorithm].keys()) if file>=img_range[0] and file<=img_range[1]] ++ average_time = "%.2f ms" % np.mean([state[algorithm][file]["time"] for file in list(state[algorithm].keys()) + if file>=img_range[0] and file<=img_range[1]]) + html_out += [' \n', + ' ' + algorithm + '\n', +@@ -241,11 +241,11 @@ + + for algorithm in algorithm_list: + i = 0 +- if algorithm not in state.keys(): ++ if algorithm not in list(state.keys()): + state[algorithm] = {} + sz = len(img_files) + for file in img_files: +- if file not in state[algorithm].keys() and\ ++ if file not in list(state[algorithm].keys()) and\ + ((i>=img_range[0] and i= (2,7): +- unicode = str ++ str = str + if isinstance(value, str): + vstr = value +- elif isinstance(value, unicode): ++ elif isinstance(value, str): + vstr = str(value) + else: + try: +--- ./modules/python/src2/hdr_parser.py (original) ++++ ./modules/python/src2/hdr_parser.py (refactored) +@@ -1,6 +1,6 @@ + #!/usr/bin/env python + +-from __future__ import print_function ++ + import os, sys, re, string, io + + # the list only for debugging. The real list, used in the real OpenCV build, is specified in CMakeLists.txt +@@ -975,7 +975,7 @@ + # If function takes as one of arguments Mat or vector - we want to create the + # same declaration working with GpuMat + args = decl[3] +- has_mat = len(list(filter(lambda x: x[0] in {"Mat", "vector_Mat"}, args))) > 0 ++ has_mat = len(list([x for x in args if x[0] in {"Mat", "vector_Mat"}])) > 0 + if has_mat: + _, _, _, gpumat_decl = self.parse_stmt(stmt, token, mat="cuda::GpuMat", docstring=docstring) + decls.append(gpumat_decl) +@@ -984,7 +984,7 @@ + # If function takes as one of arguments Mat or vector - we want to create the + # same declaration working with UMat (this is important for T-Api access) + args = decl[3] +- has_mat = len(list(filter(lambda x: x[0] in {"Mat", "vector_Mat"}, args))) > 0 ++ has_mat = len(list([x for x in args if x[0] in {"Mat", "vector_Mat"}])) > 0 + if has_mat: + _, _, _, umat_decl = self.parse_stmt(stmt, token, mat="UMat", docstring=docstring) + decls.append(umat_decl) +--- ./opencv_contrib-4.5.2/modules/julia/gen/parse_tree.py (original) ++++ ./opencv_contrib-4.5.2/modules/julia/gen/parse_tree.py (refactored) +@@ -148,8 +148,8 @@ + bases_clear.append(bb) + bases = bases_clear + if len(bases) > 1: +- print("Note: Class %s has more than 1 base class (not supported by CxxWrap)" % (self.name,)) +- print(" Bases: ", " ".join(bases)) ++ print(("Note: Class %s has more than 1 base class (not supported by CxxWrap)" % (self.name,))) ++ print((" Bases: ", " ".join(bases))) + print(" Only the first base class will be used") + if len(bases) >= 1: + self.base = bases[0].replace('.', '::') +@@ -401,8 +401,8 @@ + mapped_name = '_'.join(classes+[barename]) + ns = namespaces[namespace] + if mapped_name in ns.consts: +- print("Generator error: constant %s (name=%s) already exists" \ +- % (name, name)) ++ print(("Generator error: constant %s (name=%s) already exists" \ ++ % (name, name))) + sys.exit(-1) + ns.consts[name] = mapped_name + +@@ -474,13 +474,13 @@ + add_func(decl) + # step 1.5 check if all base classes exist + # print(classes) +- for name, classinfo in classes.items(): ++ for name, classinfo in list(classes.items()): + if classinfo.base: + base = classinfo.base + # print(base) + if base not in classes: +- print("Generator error: unable to resolve base %s for %s" +- % (classinfo.base, classinfo.name)) ++ print(("Generator error: unable to resolve base %s for %s" ++ % (classinfo.base, classinfo.name))) + sys.exit(-1) + base_instance = classes[base] + classinfo.base = base +@@ -501,14 +501,14 @@ + res = classinfo.isalgorithm + processed[classinfo] = True + return res +- for name, classinfo in classes.items(): ++ for name, classinfo in list(classes.items()): + process_isalgorithm(classinfo) + +- for name, ns in namespaces.items(): ++ for name, ns in list(namespaces.items()): + if name.split('.')[-1] == '': + continue + ns.registered = [] +- for name, cl in ns.classes.items(): ++ for name, cl in list(ns.classes.items()): + registered_types.append(get_template_arg(name)) + ns.registered.append(cl.mapped_name) + nss, clss, bs = split_decl_name(name) +@@ -516,7 +516,7 @@ + type_paths["::".join(clss+[bs])] = [name.replace("::", ".")] + + +- for e1,e2 in ns.enums.items(): ++ for e1,e2 in list(ns.enums.items()): + registered_types.append(get_template_arg(e2[0])) + registered_types.append(get_template_arg(e2[0]).replace('::', '_')) #whyyy typedef + ns.registered.append(e2[1]) +--- ./platforms/osx/build_framework.py (original) ++++ ./platforms/osx/build_framework.py (refactored) +@@ -3,12 +3,12 @@ + The script builds OpenCV.framework for OSX. + """ + +-from __future__ import print_function ++ + import os, os.path, sys, argparse, traceback, multiprocessing + + # import common code + sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../ios')) +-from build_framework import Builder ++from .build_framework import Builder + sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../apple')) + from cv_build_utils import print_error, get_cmake_version + +--- ./modules/python/test/test_misc.py (original) ++++ ./modules/python/test/test_misc.py (refactored) +@@ -1,5 +1,5 @@ + #!/usr/bin/env python +-from __future__ import print_function ++ + + import ctypes + from functools import partial +--- ./opencv_contrib-4.5.2/samples/python2/common.py (original) ++++ ./opencv_contrib-4.5.2/samples/python2/common.py (refactored) +@@ -11,6 +11,7 @@ + import os + import itertools as it + from contextlib import contextmanager ++from functools import reduce + + image_extensions = ['.bmp', '.jpg', '.jpeg', '.png', '.tif', '.tiff', '.pbm', '.pgm', '.ppm'] + +@@ -70,7 +71,8 @@ + axis = np.cross(vt[0], vt[1]) + return axis * np.arctan2(s, c) + +-def draw_str(dst, (x, y), s): ++def draw_str(dst, xxx_todo_changeme, s): ++ (x, y) = xxx_todo_changeme + cv.putText(dst, s, (x+1, y+1), cv.FONT_HERSHEY_PLAIN, 1.0, (0, 0, 0), thickness = 2, lineType=cv.LINE_AA) + cv.putText(dst, s, (x, y), cv.FONT_HERSHEY_PLAIN, 1.0, (255, 255, 255), lineType=cv.LINE_AA) + +@@ -135,12 +137,12 @@ + + @contextmanager + def Timer(msg): +- print msg, '...', ++ print(msg, '...', end=' ') + start = clock() + try: + yield + finally: +- print "%.2f ms" % ((clock()-start)*1000) ++ print("%.2f ms" % ((clock()-start)*1000)) + + class StatValue: + def __init__(self, smooth_coef = 0.5): +@@ -201,11 +203,11 @@ + imgs -- images (must have same size and format) + ''' + imgs = iter(imgs) +- img0 = imgs.next() ++ img0 = next(imgs) + pad = np.zeros_like(img0) + imgs = it.chain([img0], imgs) + rows = grouper(w, imgs, pad) +- return np.vstack(map(np.hstack, rows)) ++ return np.vstack(list(map(np.hstack, rows))) + + def getsize(img): + h, w = img.shape[:2] +--- ./samples/dnn/fast_neural_style.py (original) ++++ ./samples/dnn/fast_neural_style.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/dnn/common.py (original) ++++ ./samples/dnn/common.py (refactored) +@@ -52,7 +52,7 @@ + if os.path.isfile(zoo): + fs = cv.FileStorage(zoo, cv.FILE_STORAGE_READ) + root = fs.root() +- for name in root.keys(): ++ for name in list(root.keys()): + model = root.getNode(name) + if model.getNode('sample').string() == sample: + aliases.append(name) +@@ -106,7 +106,7 @@ + except KeyError: + pass + +- print('File ' + filename + ' not found! Please specify a path to ' ++ print(('File ' + filename + ' not found! Please specify a path to ' + '/opencv_extra/testdata in OPENCV_DNN_TEST_DATA_PATH environment ' +- 'variable or pass a full path to model.') ++ 'variable or pass a full path to model.')) + exit(0) +--- ./opencv_contrib-4.5.2/modules/xphoto/samples/learn_color_balance.py (original) ++++ ./opencv_contrib-4.5.2/modules/xphoto/samples/learn_color_balance.py (refactored) +@@ -1,5 +1,5 @@ + #!/usr/bin/env python +-from __future__ import print_function ++ + import os, sys, argparse + import numpy as np + import scipy.io +@@ -31,7 +31,7 @@ + dst_model = [] + for tree_idx in range(num_trees): + #local group in the training data is additionally weighted by num_trees +- local_group_range = range(tree_idx*stride, min(tree_idx*stride+sz, len(inst))) ++ local_group_range = list(range(tree_idx*stride, min(tree_idx*stride+sz, len(inst)))) + X = num_trees * [inst[i][0] for i in local_group_range] + y_r = num_trees * [inst[i][1] for i in local_group_range] + y_g = num_trees * [inst[i][2] for i in local_group_range] +@@ -136,11 +136,11 @@ + gt = scipy.io.loadmat(gt_path) + base_gt_illuminants = [] + black_levels = [] +- if "groundtruth_illuminants" in gt.keys() and "darkness_level" in gt.keys(): ++ if "groundtruth_illuminants" in list(gt.keys()) and "darkness_level" in list(gt.keys()): + #NUS 8-camera dataset format + base_gt_illuminants = gt["groundtruth_illuminants"] + black_levels = len(base_gt_illuminants) * [gt["darkness_level"][0][0]] +- elif "real_rgb" in gt.keys(): ++ elif "real_rgb" in list(gt.keys()): + #Gehler-Shi dataset format + base_gt_illuminants = gt["real_rgb"] + black_levels = 87 * [0] + (len(base_gt_illuminants) - 87) * [129] +--- ./samples/dnn/dnn_model_runner/dnn_conversion/common/abstract_model.py (original) ++++ ./samples/dnn/dnn_model_runner/dnn_conversion/common/abstract_model.py (refactored) +@@ -8,11 +8,9 @@ + pass + + +-class Framework(object): ++class Framework(object, metaclass=ABCMeta): + in_blob_name = '' + out_blob_name = '' +- +- __metaclass__ = ABCMeta + + @abstractmethod + def get_name(self): +--- ./samples/dnn/mobilenet_ssd_accuracy.py (original) ++++ ./samples/dnn/mobilenet_ssd_accuracy.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + # Script to evaluate MobileNet-SSD object detection model trained in TensorFlow + # using both TensorFlow and OpenCV. Example: + # +--- ./samples/dnn/optical_flow.py (original) ++++ ./samples/dnn/optical_flow.py (refactored) +@@ -86,7 +86,7 @@ + config = '' + proto = open(args.proto).readlines() + for line in proto: +- for key, value in var.items(): ++ for key, value in list(var.items()): + tag = "$%s$" % key + line = line.replace(tag, str(value)) + config += line +--- ./modules/python/src2/gen2.py (original) ++++ ./modules/python/src2/gen2.py (refactored) +@@ -1,6 +1,6 @@ + #!/usr/bin/env python + +-from __future__ import print_function ++ + import hdr_parser, sys, re, os + from string import Template + from pprint import pprint +@@ -9,7 +9,7 @@ + if sys.version_info[0] >= 3: + from io import StringIO + else: +- from cStringIO import StringIO ++ from io import StringIO + + + forbidden_arg_types = ["void*"] +@@ -662,7 +662,7 @@ + defval0 = "0" + tp1 = tp.replace("*", "_ptr") + tp_candidates = [a.tp, normalize_class_name(self.namespace + "." + a.tp)] +- if any(tp in codegen.enums.keys() for tp in tp_candidates): ++ if any(tp in list(codegen.enums.keys()) for tp in tp_candidates): + defval0 = "static_cast<%s>(%d)" % (a.tp, 0) + + arg_type_info = simple_argtype_mapping.get(tp, ArgTypeInfo(tp, FormatStrings.object, defval0, True)) +@@ -1070,7 +1070,7 @@ + self.add_func(decl) + + # step 1.5 check if all base classes exist +- for name, classinfo in self.classes.items(): ++ for name, classinfo in list(self.classes.items()): + if classinfo.base: + chunks = classinfo.base.split('_') + base = '_'.join(chunks) +@@ -1100,7 +1100,7 @@ + res = classinfo.isalgorithm + processed[classinfo] = True + return res +- for name, classinfo in self.classes.items(): ++ for name, classinfo in list(self.classes.items()): + process_isalgorithm(classinfo) + + # step 2: generate code for the classes and their methods +--- ./samples/dnn/person_reid.py (original) ++++ ./samples/dnn/person_reid.py (refactored) +@@ -69,7 +69,7 @@ + count = 0 + + for i in range(0, len(path_list), batch_size): +- print('Feature Extraction for images in', img_dir, 'Batch:', count, '/', len(path_list)) ++ print(('Feature Extraction for images in', img_dir, 'Batch:', count, '/', len(path_list))) + batch = path_list[i : min(i + batch_size, len(path_list))] + imgs = read_data(batch) + inputs = preprocess(imgs, resize_h, resize_w) +--- ./samples/dnn/dnn_model_runner/dnn_conversion/pytorch/classification/py_to_py_resnet50_onnx.py (original) ++++ ./samples/dnn/dnn_model_runner/dnn_conversion/pytorch/classification/py_to_py_resnet50_onnx.py (refactored) +@@ -43,7 +43,7 @@ + + # get the path to the converted into ONNX PyTorch model + full_model_path = get_pytorch_onnx_model(original_model) +- print("PyTorch ResNet-50 model was successfully converted: ", full_model_path) ++ print(("PyTorch ResNet-50 model was successfully converted: ", full_model_path)) + + + if __name__ == "__main__": +--- ./samples/dnn/dnn_model_runner/dnn_conversion/common/test/model_test_pipeline.py (original) ++++ ./samples/dnn/dnn_model_runner/dnn_conversion/common/test/model_test_pipeline.py (refactored) +@@ -34,9 +34,9 @@ + model_dict = self._net_model.get_prepared_models() + + model_names = list(model_dict.keys()) +- print( ++ print(( + "The model {} was successfully obtained and converted to OpenCV {}".format(model_names[0], model_names[1]) +- ) ++ )) + + if cmd_args.test: + if not self._test_module_config.model: +@@ -92,14 +92,14 @@ + ): + log_path, logs_dir = self._configure_eval_log(formatted_exp_name) + +- print( ++ print(( + "===== Running evaluation of the model with the following params:\n" + "\t* val data location: {}\n" + "\t* log file location: {}\n".format( + self.test_config.img_root_dir, + log_path + ) +- ) ++ )) + + os.makedirs(logs_dir, exist_ok=True) + +--- ./samples/dnn/tf_text_graph_efficientdet.py (original) ++++ ./samples/dnn/tf_text_graph_efficientdet.py (refactored) +@@ -35,12 +35,12 @@ + + def createGraph(modelPath, outputPath, min_level, aspect_ratios, num_scales, + anchor_scale, num_classes, image_width, image_height): +- print('Min level: %d' % min_level) +- print('Anchor scale: %f' % anchor_scale) +- print('Num scales: %d' % num_scales) +- print('Aspect ratios: %s' % str(aspect_ratios)) +- print('Number of classes: %d' % num_classes) +- print('Input image size: %dx%d' % (image_width, image_height)) ++ print(('Min level: %d' % min_level)) ++ print(('Anchor scale: %f' % anchor_scale)) ++ print(('Num scales: %d' % num_scales)) ++ print(('Aspect ratios: %s' % str(aspect_ratios))) ++ print(('Number of classes: %d' % num_classes)) ++ print(('Input image size: %dx%d' % (image_width, image_height))) + + # Read the graph. + _inpNames = ['image_arrays'] +--- ./opencv_extra-4.5.2/testdata/dnn/download_models.py (original) ++++ ./opencv_extra-4.5.2/testdata/dnn/download_models.py (refactored) +@@ -1,6 +1,6 @@ + #!/usr/bin/env python + +-from __future__ import print_function ++ + import hashlib + import os + import sys +@@ -8,7 +8,7 @@ + import requests + + if sys.version_info[0] < 3: +- from urllib2 import urlopen ++ from urllib.request import urlopen + else: + from urllib.request import urlopen + +@@ -121,7 +121,7 @@ + response = session.get(URL, params = { 'id' : gid }, stream = True) + + def get_confirm_token(response): # in case of large files +- for key, value in response.cookies.items(): ++ for key, value in list(response.cookies.items()): + if key.startswith('download_warning'): + return value + return None +--- ./samples/dnn/dnn_model_runner/dnn_conversion/common/evaluation/classification/cls_data_fetcher.py (original) ++++ ./samples/dnn/dnn_model_runner/dnn_conversion/common/evaluation/classification/cls_data_fetcher.py (refactored) +@@ -8,12 +8,10 @@ + from ...test.configs.default_preprocess_config import PYTORCH_RSZ_HEIGHT, PYTORCH_RSZ_WIDTH + + +-class DataFetch(object): ++class DataFetch(object, metaclass=ABCMeta): + imgs_dir = '' + frame_size = 0 + bgr_to_rgb = False +- +- __metaclass__ = ABCMeta + + @abstractmethod + def preprocess(self, img): +--- ./samples/dnn/dnn_model_runner/dnn_conversion/tf/detection/py_to_py_ssd_mobilenet.py (original) ++++ ./samples/dnn/dnn_model_runner/dnn_conversion/tf/detection/py_to_py_ssd_mobilenet.py (refactored) +@@ -1,6 +1,6 @@ + import os + import tarfile +-import urllib ++import urllib.request, urllib.parse, urllib.error + + DETECTION_MODELS_URL = 'http://download.tensorflow.org/models/object_detection/' + +@@ -16,10 +16,10 @@ + try: + urllib.request.urlretrieve(model_link, tf_model_tar) + except Exception: +- print("TF {} was not retrieved: {}".format(model_name, model_link)) ++ print(("TF {} was not retrieved: {}".format(model_name, model_link))) + return + +- print("TF {} was retrieved.".format(model_name)) ++ print(("TF {} was retrieved.".format(model_name))) + + tf_model_tar = tarfile.open(tf_model_tar) + frozen_graph_path = "" +@@ -38,7 +38,7 @@ + tf_model_name = 'ssd_mobilenet_v1_coco_2017_11_17' + graph_extraction_dir = "./" + frozen_graph_path = extract_tf_frozen_graph(tf_model_name, graph_extraction_dir) +- print("Frozen graph path for {}: {}".format(tf_model_name, frozen_graph_path)) ++ print(("Frozen graph path for {}: {}".format(tf_model_name, frozen_graph_path))) + + + if __name__ == "__main__": +--- ./samples/python/_coverage.py (original) ++++ ./samples/python/_coverage.py (refactored) +@@ -5,7 +5,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + from glob import glob + import cv2 as cv +--- ./samples/dnn/dnn_model_runner/dnn_conversion/pytorch/classification/py_to_py_resnet50.py (original) ++++ ./samples/dnn/dnn_model_runner/dnn_conversion/pytorch/classification/py_to_py_resnet50.py (refactored) +@@ -80,15 +80,15 @@ + # OpenCV DNN inference + out = opencv_net.forward() + print("OpenCV DNN prediction: \n") +- print("* shape: ", out.shape) ++ print(("* shape: ", out.shape)) + + # get the predicted class ID + imagenet_class_id = np.argmax(out) + + # get confidence + confidence = out[0][imagenet_class_id] +- print("* class ID: {}, label: {}".format(imagenet_class_id, imagenet_labels[imagenet_class_id])) +- print("* confidence: {:.4f}".format(confidence)) ++ print(("* class ID: {}, label: {}".format(imagenet_class_id, imagenet_labels[imagenet_class_id]))) ++ print(("* confidence: {:.4f}".format(confidence))) + + + def get_pytorch_dnn_prediction(original_net, preproc_img, imagenet_labels): +@@ -100,15 +100,15 @@ + out = original_net(preproc_img) + + print("\nPyTorch model prediction: \n") +- print("* shape: ", out.shape) ++ print(("* shape: ", out.shape)) + + # get the predicted class ID + imagenet_class_id = torch.argmax(out, axis=1).item() +- print("* class ID: {}, label: {}".format(imagenet_class_id, imagenet_labels[imagenet_class_id])) ++ print(("* class ID: {}, label: {}".format(imagenet_class_id, imagenet_labels[imagenet_class_id]))) + + # get confidence + confidence = out[0][imagenet_class_id] +- print("* confidence: {:.4f}".format(confidence.item())) ++ print(("* confidence: {:.4f}".format(confidence.item()))) + + + def main(): +@@ -120,7 +120,7 @@ + + # read converted .onnx model with OpenCV API + opencv_net = cv2.dnn.readNetFromONNX(full_model_path) +- print("OpenCV model was successfully read. Layer IDs: \n", opencv_net.getLayerNames()) ++ print(("OpenCV model was successfully read. Layer IDs: \n", opencv_net.getLayerNames())) + + # get preprocessed image + input_img = get_preprocessed_img("../data/squirrel_cls.jpg") +--- ./samples/dnn/object_detection.py (original) ++++ ./samples/dnn/object_detection.py (refactored) +@@ -5,7 +5,7 @@ + import time + from threading import Thread + if sys.version_info[0] == 2: +- import Queue as queue ++ import queue as queue + else: + import queue + +@@ -63,11 +63,11 @@ + if 'model' in config: + print('TensorFlow Object Detection API config detected') + if 'ssd' in config['model'][0]: +- print('Preparing text graph representation for SSD model: ' + args.out_tf_graph) ++ print(('Preparing text graph representation for SSD model: ' + args.out_tf_graph)) + createSSDGraph(args.model, args.config, args.out_tf_graph) + args.config = args.out_tf_graph + elif 'faster_rcnn' in config['model'][0]: +- print('Preparing text graph representation for Faster-RCNN model: ' + args.out_tf_graph) ++ print(('Preparing text graph representation for Faster-RCNN model: ' + args.out_tf_graph)) + createFasterRCNNGraph(args.model, args.config, args.out_tf_graph) + args.config = args.out_tf_graph + +@@ -158,7 +158,7 @@ + confidences.append(float(confidence)) + boxes.append([left, top, width, height]) + else: +- print('Unknown output layer type: ' + lastLayer.type) ++ print(('Unknown output layer type: ' + lastLayer.type)) + exit() + + # NMS is used inside Region layer only on DNN_BACKEND_OPENCV for another backends we need NMS in sample +--- ./samples/python/_doc.py (original) ++++ ./samples/python/_doc.py (refactored) +@@ -6,7 +6,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + from glob import glob + +@@ -16,7 +16,7 @@ + loc = {} + try: + try: +- execfile(fn, loc) # Python 2 ++ exec(compile(open(fn, "rb").read(), fn, 'exec'), loc) # Python 2 + except NameError: + exec(open(fn).read(), loc) # Python 3 + except Exception: +--- ./opencv_contrib-4.5.2/modules/aruco/misc/pattern_generator/MarkerPrinterGUI.py (original) ++++ ./opencv_contrib-4.5.2/modules/aruco/misc/pattern_generator/MarkerPrinterGUI.py (refactored) +@@ -510,7 +510,7 @@ + self.delay = pDelay + self.displayShape = pDisplayShape + +- self.dictList = MarkerPrinter.arucoDictBytesList.keys() ++ self.dictList = list(MarkerPrinter.arucoDictBytesList.keys()) + + # GUI + self.window = tk.Tk() +--- ./samples/python/browse.py (original) ++++ ./samples/python/browse.py (refactored) +@@ -13,7 +13,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + import sys + PY3 = sys.version_info[0] == 3 + +@@ -45,7 +45,7 @@ + + + small = img +- for _i in xrange(3): ++ for _i in range(3): + small = cv.pyrDown(small) + + def onmouse(event, x, y, flags, param): +--- ./samples/dnn/tf_text_graph_mask_rcnn.py (original) ++++ ./samples/dnn/tf_text_graph_mask_rcnn.py (refactored) +@@ -42,12 +42,12 @@ + first_stage_nms_iou_threshold = float(config['first_stage_nms_iou_threshold'][0]) + first_stage_max_proposals = int(config['first_stage_max_proposals'][0]) + +-print('Number of classes: %d' % num_classes) +-print('Scales: %s' % str(scales)) +-print('Aspect ratios: %s' % str(aspect_ratios)) +-print('Width stride: %f' % width_stride) +-print('Height stride: %f' % height_stride) +-print('Features stride: %f' % features_stride) ++print(('Number of classes: %d' % num_classes)) ++print(('Scales: %s' % str(scales))) ++print(('Aspect ratios: %s' % str(aspect_ratios))) ++print(('Width stride: %f' % width_stride)) ++print(('Height stride: %f' % height_stride)) ++print(('Features stride: %f' % features_stride)) + + # Read the graph. + writeTextGraph(args.input, args.output, ['num_detections', 'detection_scores', 'detection_boxes', 'detection_classes', 'detection_masks']) +@@ -180,7 +180,7 @@ + 'SecondStageBoxPredictor/Reshape_1/Reshape', [1, -1], graph_def) + + # Replace Flatten subgraph onto a single node. +-for i in reversed(range(len(graph_def.node))): ++for i in reversed(list(range(len(graph_def.node)))): + if graph_def.node[i].op == 'CropAndResize': + graph_def.node[i].input.insert(1, 'detection_out') + +@@ -264,7 +264,7 @@ + assert(len(cropAndResizeNodesNames) == 1) + node.input = [cropAndResizeNodesNames[0]] + +-for i in reversed(range(len(graph_def.node))): ++for i in reversed(list(range(len(graph_def.node)))): + if graph_def.node[i].op == 'CropAndResize': + graph_def.node[i].input.insert(1, 'detection_out_final') + break +--- ./samples/dnn/tf_text_graph_common.py (original) ++++ ./samples/dnn/tf_text_graph_common.py (refactored) +@@ -206,7 +206,7 @@ + + def printAttr(d, indent): + indent = ' ' * indent +- for key, value in sorted(d.items(), key=lambda x:x[0].lower()): ++ for key, value in sorted(list(d.items()), key=lambda x:x[0].lower()): + value = value if isinstance(value, list) else [value] + for v in value: + if isinstance(v, dict): +@@ -237,7 +237,7 @@ + f.write(' op: \"%s\"\n' % node.op) + for inp in node.input: + f.write(' input: \"%s\"\n' % inp) +- for key, value in sorted(node.attr.items(), key=lambda x:x[0].lower()): ++ for key, value in sorted(list(node.attr.items()), key=lambda x:x[0].lower()): + f.write(' attr {\n') + f.write(' key: \"%s\"\n' % key) + f.write(' value {\n') +@@ -289,7 +289,7 @@ + + removedNodes = [] + +- for i in reversed(range(len(graph_def.node))): ++ for i in reversed(list(range(len(graph_def.node)))): + op = graph_def.node[i].op + name = graph_def.node[i].name + +@@ -305,7 +305,7 @@ + + # Remove references to removed nodes except Const nodes. + for node in graph_def.node: +- for i in reversed(range(len(node.input))): ++ for i in reversed(list(range(len(node.input)))): + if node.input[i] in removedNodes: + del node.input[i] + +--- ./samples/dnn/dnn_model_runner/dnn_conversion/tf/classification/py_to_py_mobilenet.py (original) ++++ ./samples/dnn/dnn_model_runner/dnn_conversion/tf/classification/py_to_py_mobilenet.py (refactored) +@@ -60,7 +60,7 @@ + swapRB=True, # BGR -> RGB + crop=True # center crop + ) +- print("Input blob shape: {}\n".format(input_blob.shape)) ++ print(("Input blob shape: {}\n".format(input_blob.shape))) + + return input_blob + +@@ -78,34 +78,34 @@ + # OpenCV DNN inference + out = opencv_net.forward() + print("OpenCV DNN prediction: \n") +- print("* shape: ", out.shape) ++ print(("* shape: ", out.shape)) + + # get the predicted class ID + imagenet_class_id = np.argmax(out) + + # get confidence + confidence = out[0][imagenet_class_id] +- print("* class ID: {}, label: {}".format(imagenet_class_id, imagenet_labels[imagenet_class_id])) +- print("* confidence: {:.4f}\n".format(confidence)) ++ print(("* class ID: {}, label: {}".format(imagenet_class_id, imagenet_labels[imagenet_class_id]))) ++ print(("* confidence: {:.4f}\n".format(confidence))) + + + def get_tf_dnn_prediction(original_net, preproc_img, imagenet_labels): + # inference + preproc_img = preproc_img.transpose(0, 2, 3, 1) +- print("TF input blob shape: {}\n".format(preproc_img.shape)) ++ print(("TF input blob shape: {}\n".format(preproc_img.shape))) + + out = original_net(preproc_img) + + print("\nTensorFlow model prediction: \n") +- print("* shape: ", out.shape) ++ print(("* shape: ", out.shape)) + + # get the predicted class ID + imagenet_class_id = np.argmax(out) +- print("* class ID: {}, label: {}".format(imagenet_class_id, imagenet_labels[imagenet_class_id])) ++ print(("* class ID: {}, label: {}".format(imagenet_class_id, imagenet_labels[imagenet_class_id]))) + + # get confidence + confidence = out[0][imagenet_class_id] +- print("* confidence: {:.4f}".format(confidence)) ++ print(("* confidence: {:.4f}".format(confidence))) + + + def main(): +@@ -123,7 +123,7 @@ + + # read frozen graph with OpenCV API + opencv_net = cv2.dnn.readNetFromTensorflow(full_pb_path) +- print("OpenCV model was successfully read. Model layers: \n", opencv_net.getLayerNames()) ++ print(("OpenCV model was successfully read. Model layers: \n", opencv_net.getLayerNames())) + + # get preprocessed image + input_img = get_preprocessed_img("../data/squirrel_cls.jpg") +--- ./samples/python/color_histogram.py (original) ++++ ./samples/python/color_histogram.py (refactored) +@@ -9,7 +9,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/dnn/tf_text_graph_faster_rcnn.py (original) ++++ ./samples/dnn/tf_text_graph_faster_rcnn.py (refactored) +@@ -41,12 +41,12 @@ + first_stage_nms_iou_threshold = float(config['first_stage_nms_iou_threshold'][0]) + first_stage_max_proposals = int(config['first_stage_max_proposals'][0]) + +- print('Number of classes: %d' % num_classes) +- print('Scales: %s' % str(scales)) +- print('Aspect ratios: %s' % str(aspect_ratios)) +- print('Width stride: %f' % width_stride) +- print('Height stride: %f' % height_stride) +- print('Features stride: %f' % features_stride) ++ print(('Number of classes: %d' % num_classes)) ++ print(('Scales: %s' % str(scales))) ++ print(('Aspect ratios: %s' % str(aspect_ratios))) ++ print(('Width stride: %f' % width_stride)) ++ print(('Height stride: %f' % height_stride)) ++ print(('Features stride: %f' % features_stride)) + + # Read the graph. + writeTextGraph(modelPath, outputPath, ['num_detections', 'detection_scores', 'detection_boxes', 'detection_classes']) +@@ -189,7 +189,7 @@ + + # Replace Flatten subgraph onto a single node. + cropAndResizeNodeName = '' +- for i in reversed(range(len(graph_def.node))): ++ for i in reversed(list(range(len(graph_def.node)))): + if graph_def.node[i].op == 'CropAndResize': + graph_def.node[i].input.insert(1, 'detection_out/clip_by_value') + cropAndResizeNodeName = graph_def.node[i].name +--- ./samples/dnn/download_models.py (original) ++++ ./samples/dnn/download_models.py (refactored) +@@ -1,7 +1,7 @@ + ''' + Helper module to download extra data from Internet + ''' +-from __future__ import print_function ++ + import os + import cv2 + import sys +@@ -16,7 +16,7 @@ + from pathlib import Path + from datetime import datetime + if sys.version_info[0] < 3: +- from urllib2 import urlopen ++ from urllib.request import urlopen + else: + from urllib.request import urlopen + import xml.etree.ElementTree as ET +@@ -217,7 +217,7 @@ + response = session.get(URL, params = { 'id' : self.gid }, stream = True) + + def get_confirm_token(response): # in case of large files +- for key, value in response.cookies.items(): ++ for key, value in list(response.cookies.items()): + if key.startswith('download_warning'): + return value + return None +@@ -329,7 +329,7 @@ + models = [] + with open(yaml_filepath, 'r') as stream: + data_loaded = yaml.safe_load(stream) +- for name, params in data_loaded.items(): ++ for name, params in list(data_loaded.items()): + load_info = params.get("load_info", None) + if load_info: + fname = os.path.basename(params.get("model")) +--- ./samples/python/coherence.py (original) ++++ ./samples/python/coherence.py (refactored) +@@ -10,7 +10,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + import sys + PY3 = sys.version_info[0] == 3 + +@@ -23,7 +23,7 @@ + def coherence_filter(img, sigma = 11, str_sigma = 11, blend = 0.5, iter_n = 4): + h, w = img.shape[:2] + +- for i in xrange(iter_n): ++ for i in range(iter_n): + print(i) + + gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) +--- ./platforms/android/build_sdk.py (original) ++++ ./platforms/android/build_sdk.py (refactored) +@@ -252,7 +252,7 @@ + cmd.extend(["-DBUILD_TESTS=ON", "-DINSTALL_TESTS=ON"]) + + cmake_vars.update(abi.cmake_vars) +- cmd += [ "-D%s='%s'" % (k, v) for (k, v) in cmake_vars.items() if v is not None] ++ cmd += [ "-D%s='%s'" % (k, v) for (k, v) in list(cmake_vars.items()) if v is not None] + cmd.append(self.opencvdir) + execute(cmd) + # full parallelism for C++ compilation tasks +@@ -413,9 +413,9 @@ + with open(cpath, 'r') as f: + cfg = f.read() + print("Package configuration:") +- print('=' * 80) +- print(cfg.strip()) +- print('=' * 80) ++ print(('=' * 80)) ++ print((cfg.strip())) ++ print(('=' * 80)) + + ABIs = None # make flake8 happy + exec(compile(cfg, cpath, 'exec')) +--- ./samples/python/edge.py (original) ++++ ./samples/python/edge.py (refactored) +@@ -11,7 +11,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import cv2 as cv + import numpy as np +--- ./samples/python/distrans.py (original) ++++ ./samples/python/distrans.py (refactored) +@@ -12,7 +12,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/dft.py (original) ++++ ./samples/python/dft.py (refactored) +@@ -9,7 +9,7 @@ + + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/contours.py (original) ++++ ./samples/python/contours.py (refactored) +@@ -10,7 +10,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + import sys + PY3 = sys.version_info[0] == 3 + +@@ -23,12 +23,12 @@ + def make_image(): + img = np.zeros((500, 500), np.uint8) + black, white = 0, 255 +- for i in xrange(6): ++ for i in range(6): + dx = int((i%2)*250 - 30) + dy = int((i/2.)*150) + + if i == 0: +- for j in xrange(11): ++ for j in range(11): + angle = (j+5)*np.pi/21 + c, s = np.cos(angle), np.sin(angle) + x1, y1 = np.int32([dx+100+j*10-80*c, dy+100-90*s]) +--- ./samples/python/camshift.py (original) ++++ ./samples/python/camshift.py (refactored) +@@ -23,7 +23,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + import sys + PY3 = sys.version_info[0] == 3 + +@@ -68,7 +68,7 @@ + bin_count = self.hist.shape[0] + bin_w = 24 + img = np.zeros((256, bin_count*bin_w, 3), np.uint8) +- for i in xrange(bin_count): ++ for i in range(bin_count): + h = int(self.hist[i]) + cv.rectangle(img, (i*bin_w+2, 255), ((i+1)*bin_w-2, 255-h), (int(180.0*i/bin_count), 255, 255), -1) + img = cv.cvtColor(img, cv.COLOR_HSV2BGR) +--- ./samples/python/calibrate.py (original) ++++ ./samples/python/calibrate.py (refactored) +@@ -14,7 +14,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./platforms/winpack_dldt/build_package.py (original) ++++ ./platforms/winpack_dldt/build_package.py (refactored) +@@ -288,7 +288,7 @@ + exec(compile(cfg, str(self.build_config_file), 'exec')) + log.info('DLDT processed build configuration script') + +- cmd += [ '-D%s=%s' % (k, v) for (k, v) in cmake_vars.items() if v is not None] ++ cmd += [ '-D%s=%s' % (k, v) for (k, v) in list(cmake_vars.items()) if v is not None] + if self.config.cmake_option_dldt: + cmd += self.config.cmake_option_dldt + +@@ -416,7 +416,7 @@ + cmake_vars['OPENCV_BUILD_PERF_TEST_MODULES_LIST'] = 'dnn' + cmake_vars['INSTALL_TESTS']='ON' + +- cmd += [ "-D%s=%s" % (k, v) for (k, v) in cmake_vars.items() if v is not None] ++ cmd += [ "-D%s=%s" % (k, v) for (k, v) in list(cmake_vars.items()) if v is not None] + if self.config.cmake_option: + cmd += self.config.cmake_option + +--- ./samples/python/deconvolution.py (original) ++++ ./samples/python/deconvolution.py (refactored) +@@ -31,7 +31,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/digits_video.py (original) ++++ ./samples/python/digits_video.py (refactored) +@@ -9,7 +9,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/asift.py (original) ++++ ./samples/python/asift.py (refactored) +@@ -20,7 +20,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/facedetect.py (original) ++++ ./samples/python/facedetect.py (refactored) +@@ -8,7 +8,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/dis_opt_flow.py (original) ++++ ./samples/python/dis_opt_flow.py (refactored) +@@ -14,7 +14,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/houghcircles.py (original) ++++ ./samples/python/houghcircles.py (refactored) +@@ -9,7 +9,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/feature_homography.py (original) ++++ ./samples/python/feature_homography.py (refactored) +@@ -23,7 +23,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/inpaint.py (original) ++++ ./samples/python/inpaint.py (refactored) +@@ -16,7 +16,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/gabor_threads.py (original) ++++ ./samples/python/gabor_threads.py (refactored) +@@ -15,7 +15,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/houghlines.py (original) ++++ ./samples/python/houghlines.py (refactored) +@@ -9,7 +9,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import cv2 as cv + import numpy as np +--- ./samples/python/kmeans.py (original) ++++ ./samples/python/kmeans.py (refactored) +@@ -11,7 +11,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/fitline.py (original) ++++ ./samples/python/fitline.py (refactored) +@@ -23,7 +23,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + import sys + PY3 = sys.version_info[0] == 3 + +@@ -52,7 +52,7 @@ + if PY3: + cur_func_name = next(dist_func_names) + else: +- cur_func_name = dist_func_names.next() ++ cur_func_name = next(dist_func_names) + + def update(_=None): + noise = cv.getTrackbarPos('noise', 'fit line') +@@ -92,7 +92,7 @@ + if PY3: + cur_func_name = next(dist_func_names) + else: +- cur_func_name = dist_func_names.next() ++ cur_func_name = next(dist_func_names) + if ch == 27: + break + +--- ./samples/python/floodfill.py (original) ++++ ./samples/python/floodfill.py (refactored) +@@ -15,7 +15,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/gaussian_mix.py (original) ++++ ./samples/python/gaussian_mix.py (refactored) +@@ -1,7 +1,7 @@ + #!/usr/bin/env python + + # Python 2/3 compatibility +-from __future__ import print_function ++ + import sys + PY3 = sys.version_info[0] == 3 + +@@ -16,7 +16,7 @@ + def make_gaussians(cluster_n, img_size): + points = [] + ref_distrs = [] +- for _i in xrange(cluster_n): ++ for _i in range(cluster_n): + mean = (0.1 + 0.8*random.rand(2)) * img_size + a = (random.rand(2, 2)-0.5)*img_size*0.1 + cov = np.dot(a.T, a) + img_size*0.05*np.eye(2) +@@ -52,7 +52,7 @@ + em.trainEM(points) + means = em.getMeans() + covs = em.getCovs() # Known bug: https://github.com/opencv/opencv/pull/4232 +- found_distrs = zip(means, covs) ++ found_distrs = list(zip(means, covs)) + print('ready!\n') + + img = np.zeros((img_size, img_size, 3), np.uint8) +--- ./samples/python/digits.py (original) ++++ ./samples/python/digits.py (refactored) +@@ -25,7 +25,7 @@ + + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/laplace.py (original) ++++ ./samples/python/laplace.py (refactored) +@@ -13,7 +13,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/digits_adjust.py (original) ++++ ./samples/python/digits_adjust.py (refactored) +@@ -14,7 +14,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + import sys + PY3 = sys.version_info[0] == 3 + +@@ -45,9 +45,9 @@ + print(".", end='') + return score + if pool is None: +- scores = list(map(f, xrange(kfold))) ++ scores = list(map(f, range(kfold))) + else: +- scores = pool.map(f, xrange(kfold)) ++ scores = pool.map(f, range(kfold)) + return np.mean(scores) + + +@@ -108,7 +108,7 @@ + err = cross_validate(KNearest, dict(k=k), samples, labels) + return k, err + best_err, best_k = np.inf, -1 +- for k, err in self.run_jobs(f, xrange(1, 9)): ++ for k, err in self.run_jobs(f, range(1, 9)): + if err < best_err: + best_err, best_k = err, k + print('k = %d, error: %.2f %%' % (k, err*100)) +--- ./samples/python/hist.py (original) ++++ ./samples/python/hist.py (refactored) +@@ -16,7 +16,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/lappyr.py (original) ++++ ./samples/python/lappyr.py (refactored) +@@ -13,7 +13,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + import sys + PY3 = sys.version_info[0] == 3 + +@@ -29,7 +29,7 @@ + def build_lappyr(img, leveln=6, dtype=np.int16): + img = dtype(img) + levels = [] +- for _i in xrange(leveln-1): ++ for _i in range(leveln-1): + next_img = cv.pyrDown(img) + img1 = cv.pyrUp(next_img, dstsize=getsize(img)) + levels.append(img-img1) +@@ -56,14 +56,14 @@ + + leveln = 6 + cv.namedWindow('level control') +- for i in xrange(leveln): ++ for i in range(leveln): + cv.createTrackbar('%d'%i, 'level control', 5, 50, nothing) + + while True: + _ret, frame = cap.read() + + pyr = build_lappyr(frame, leveln) +- for i in xrange(leveln): ++ for i in range(leveln): + v = int(cv.getTrackbarPos('%d'%i, 'level control') / 5) + pyr[i] *= v + res = merge_lappyr(pyr) +--- ./samples/python/logpolar.py (original) ++++ ./samples/python/logpolar.py (refactored) +@@ -11,7 +11,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/opencv_version.py (original) ++++ ./samples/python/opencv_version.py (refactored) +@@ -11,7 +11,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./platforms/ios/build_framework.py (original) ++++ ./platforms/ios/build_framework.py (refactored) +@@ -31,7 +31,7 @@ + Adding --dynamic parameter will build {framework_name}.framework as App Store dynamic framework. Only iOS 8+ versions are supported. + """ + +-from __future__ import print_function, unicode_literals ++ + import glob, os, os.path, shutil, string, sys, argparse, traceback, multiprocessing + from subprocess import check_call, check_output, CalledProcessError + from distutils.dir_util import copy_tree +--- ./samples/python/mser.py (original) ++++ ./samples/python/mser.py (refactored) +@@ -15,7 +15,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/kalman.py (original) ++++ ./samples/python/kalman.py (refactored) +@@ -29,7 +29,7 @@ + img_width = 500 + kalman = cv.KalmanFilter(2, 1, 0) + +- code = long(-1) ++ code = int(-1) + + cv.namedWindow("Kalman") + +--- ./samples/python/camera_calibration_show_extrinsics.py (original) ++++ ./samples/python/camera_calibration_show_extrinsics.py (refactored) +@@ -2,7 +2,7 @@ + # -*- coding: utf-8 -*- + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/demo.py (original) ++++ ./samples/python/demo.py (refactored) +@@ -5,7 +5,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + import sys + + # local modules +@@ -20,8 +20,8 @@ + import tkinter as tk # Python 3 + from tkinter.scrolledtext import ScrolledText + except ImportError: +- import Tkinter as tk # Python 2 +- from ScrolledText import ScrolledText ++ import tkinter as tk # Python 2 ++ from tkinter.scrolledtext import ScrolledText + + + #from IPython.Shell import IPShellEmbed +@@ -128,7 +128,7 @@ + else: + # Python 2 + module_globals = {} +- execfile(fn, module_globals) # noqa: F821 ++ exec(compile(open(fn, "rb").read(), fn, 'exec'), module_globals) # noqa: F821 + descr = module_globals.get('__doc__', 'no-description') + except Exception as e: + descr = str(e) +--- ./samples/dnn/tf_text_graph_ssd.py (original) ++++ ./samples/dnn/tf_text_graph_ssd.py (refactored) +@@ -95,9 +95,9 @@ + image_width, image_height) + + +- print('Scale: [%f-%f]' % (min_scale, max_scale)) +- print('Aspect ratios: %s' % str(aspect_ratios)) +- print('Reduce boxes in the lowest layer: %s' % str(reduce_boxes_in_lowest_layer)) ++ print(('Scale: [%f-%f]' % (min_scale, max_scale))) ++ print(('Aspect ratios: %s' % str(aspect_ratios))) ++ print(('Reduce boxes in the lowest layer: %s' % str(reduce_boxes_in_lowest_layer))) + elif 'multiscale_anchor_generator' in anchor_generator: + multiscale_anchor_generator = anchor_generator['multiscale_anchor_generator'][0] + min_level = int(multiscale_anchor_generator['min_level'][0]) +@@ -108,18 +108,18 @@ + num_layers = max_level - min_level + 1 + priors_generator = MultiscaleAnchorGenerator(min_level, aspect_ratios, + scales_per_octave, anchor_scale) +- print('Levels: [%d-%d]' % (min_level, max_level)) +- print('Anchor scale: %f' % anchor_scale) +- print('Scales per octave: %d' % scales_per_octave) +- print('Aspect ratios: %s' % str(aspect_ratios)) ++ print(('Levels: [%d-%d]' % (min_level, max_level))) ++ print(('Anchor scale: %f' % anchor_scale)) ++ print(('Scales per octave: %d' % scales_per_octave)) ++ print(('Aspect ratios: %s' % str(aspect_ratios))) + else: + print('Unknown anchor_generator') + exit(0) + +- print('Number of classes: %d' % num_classes) +- print('Number of layers: %d' % num_layers) +- print('box predictor: %s' % box_predictor) +- print('Input image size: %dx%d' % (image_width, image_height)) ++ print(('Number of classes: %d' % num_classes)) ++ print(('Number of layers: %d' % num_layers)) ++ print(('box predictor: %s' % box_predictor)) ++ print(('Input image size: %dx%d' % (image_width, image_height))) + + # Read the graph. + outNames = ['num_detections', 'detection_scores', 'detection_boxes', 'detection_classes'] +--- ./samples/python/common.py (original) ++++ ./samples/python/common.py (refactored) +@@ -5,7 +5,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + import sys + PY3 = sys.version_info[0] == 3 + +@@ -218,11 +218,11 @@ + if PY3: + img0 = next(imgs) + else: +- img0 = imgs.next() ++ img0 = next(imgs) + pad = np.zeros_like(img0) + imgs = it.chain([img0], imgs) + rows = grouper(w, imgs, pad) +- return np.vstack(map(np.hstack, rows)) ++ return np.vstack(list(map(np.hstack, rows))) + + def getsize(img): + h, w = img.shape[:2] +--- ./samples/python/lk_track.py (original) ++++ ./samples/python/lk_track.py (refactored) +@@ -19,7 +19,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/essential_mat_reconstr.py (original) ++++ ./samples/python/essential_mat_reconstr.py (refactored) +@@ -46,7 +46,7 @@ + keypoints2, descriptors2 = detector.detectAndCompute(cv.cvtColor(image2, cv.COLOR_BGR2GRAY), None) + + matcher = cv.FlannBasedMatcher(dict(algorithm=0, trees=5), dict(checks=32)) +- print('match with FLANN, size of descriptors', descriptors1.shape, descriptors2.shape) ++ print(('match with FLANN, size of descriptors', descriptors1.shape, descriptors2.shape)) + matches_vector = matcher.knnMatch(descriptors1, descriptors2, k=2) + + print('find good keypoints') +@@ -57,15 +57,15 @@ + pts1.append(keypoints1[m[0].queryIdx].pt) + pts2.append(keypoints2[m[0].trainIdx].pt) + pts1 = np.array(pts1); pts2 = np.array(pts2) +- print('points size', pts1.shape[0]) ++ print(('points size', pts1.shape[0])) + + print('Essential matrix RANSAC') + start = time.time() + E, inliers = cv.findEssentialMat(pts1, pts2, K, cv.RANSAC, 0.999, 1.0) +- print('RANSAC time', time.time() - start, 'seconds') +- print('Median error to epipolar lines', getEpipolarError ++ print(('RANSAC time', time.time() - start, 'seconds')) ++ print(('Median error to epipolar lines', getEpipolarError + (np.dot(np.linalg.inv(K).T, np.dot(E, np.linalg.inv(K))), pts1, pts2, inliers.squeeze()), +- 'number of inliers', inliers.sum()) ++ 'number of inliers', inliers.sum())) + + print('Decompose essential matrix') + R1, R2, t = cv.decomposeEssentialMat(E) +@@ -95,7 +95,7 @@ + best_cam_idx = np.array([len(obj_pts_per_cam[0]),len(obj_pts_per_cam[1]), + len(obj_pts_per_cam[2]),len(obj_pts_per_cam[3])]).argmax() + max_pts = len(obj_pts_per_cam[best_cam_idx]) +- print('Number of object points', max_pts) ++ print(('Number of object points', max_pts)) + + # filter object points to have reasonable depth + MAX_DEPTH = 6. +--- ./samples/python/stitching.py (original) ++++ ./samples/python/stitching.py (refactored) +@@ -9,7 +9,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/peopledetect.py (original) ++++ ./samples/python/peopledetect.py (refactored) +@@ -10,7 +10,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +@@ -40,7 +40,7 @@ + + default = [cv.samples.findFile('basketball2.png')] if len(sys.argv[1:]) == 0 else [] + +- for fn in it.chain(*map(glob, default + sys.argv[1:])): ++ for fn in it.chain(*list(map(glob, default + sys.argv[1:]))): + print(fn, ' - ',) + try: + img = cv.imread(fn) +--- ./samples/python/stereo_match.py (original) ++++ ./samples/python/stereo_match.py (refactored) +@@ -7,7 +7,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/text_skewness_correction.py (original) ++++ ./samples/python/text_skewness_correction.py (refactored) +@@ -21,7 +21,7 @@ + # load the image from disk + image = cv.imread(cv.samples.findFile(args["image"])) + if image is None: +- print("can't read image " + args["image"]) ++ print(("can't read image " + args["image"])) + sys.exit(-1) + gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY) + +@@ -48,7 +48,7 @@ + cv.putText(rotated, "Angle: {:.2f} degrees".format(angle), (10, 30), cv.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 255), 2) + + # show the output image +- print("[INFO] angle: {:.2f}".format(angle)) ++ print(("[INFO] angle: {:.2f}".format(angle))) + cv.imshow("Input", image) + cv.imshow("Rotated", rotated) + cv.waitKey(0) +--- ./samples/python/texture_flow.py (original) ++++ ./samples/python/texture_flow.py (refactored) +@@ -11,7 +11,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/grabcut.py (original) ++++ ./samples/python/grabcut.py (refactored) +@@ -28,7 +28,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./opencv_contrib-4.5.2/modules/aruco/misc/pattern_generator/MarkerPrinter.py (original) ++++ ./opencv_contrib-4.5.2/modules/aruco/misc/pattern_generator/MarkerPrinter.py (refactored) +@@ -1128,12 +1128,12 @@ + args = parser.parse_args() + + if(args.arucoDataFileName is not None): +- print("Generate aruco data to: " + args.arucoDataFileName) ++ print(("Generate aruco data to: " + args.arucoDataFileName)) + SaveArucoDictBytesList(args.arucoDataFileName) + + elif(args.list_dictionary): + print("List predefined aruco dictionary") +- for i in MarkerPrinter.arucoDictBytesList.keys(): ++ for i in list(MarkerPrinter.arucoDictBytesList.keys()): + print(i) + + elif(args.chess): +@@ -1148,7 +1148,7 @@ + except ValueError as e: + warnings.warn(str(e)) + else: +- print("Save chessboard marker with parms: " + \ ++ print(("Save chessboard marker with parms: " + \ + str({ \ + "fileName": args.fileName, \ + "sizeX": sizeX, \ +@@ -1158,7 +1158,7 @@ + "subSizeY": subSizeY, \ + "pageBorderX": pageBorderX, \ + "pageBorderY": pageBorderY, \ +- })) ++ }))) + + subSize = None + +@@ -1186,7 +1186,7 @@ + except ValueError as e: + warnings.warn(str(e)) + else: +- print("Save ArUco marker with parms: " + \ ++ print(("Save ArUco marker with parms: " + \ + str({ \ + "fileName": args.fileName, \ + "dictionary": args.dictionary, \ +@@ -1195,7 +1195,7 @@ + "borderBits": borderBits, \ + "pageBorderX": pageBorderX, \ + "pageBorderY": pageBorderY, \ +- })) ++ }))) + + # Gen + MarkerPrinter.GenArucoMarkerImage(args.fileName, args.dictionary, markerID, markerLength, borderBits=borderBits, pageBorder = (pageBorderX, pageBorderY)) +@@ -1215,7 +1215,7 @@ + except ValueError as e: + warnings.warn(str(e)) + else: +- print("Save ArUco grid marker with parms: " + \ ++ print(("Save ArUco grid marker with parms: " + \ + str({ \ + "fileName": args.fileName, \ + "dictionary": args.dictionary, \ +@@ -1229,7 +1229,7 @@ + "subSizeY": subSizeY, \ + "pageBorderX": pageBorderX, \ + "pageBorderY": pageBorderY, \ +- })) ++ }))) + + subSize = None + +@@ -1261,7 +1261,7 @@ + except ValueError as e: + warnings.warn(str(e)) + else: +- print("Save ChArUco marker with parms: " + \ ++ print(("Save ChArUco marker with parms: " + \ + str({ \ + "fileName": args.fileName, \ + "dictionary": args.dictionary, \ +@@ -1274,7 +1274,7 @@ + "subSizeY": subSizeY, \ + "pageBorderX": pageBorderX, \ + "pageBorderY": pageBorderY, \ +- })) ++ }))) + + subSize = None + +--- ./samples/python/lk_homography.py (original) ++++ ./samples/python/lk_homography.py (refactored) +@@ -21,7 +21,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/opt_flow.py (original) ++++ ./samples/python/opt_flow.py (refactored) +@@ -14,7 +14,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/tracker.py (original) ++++ ./samples/python/tracker.py (refactored) +@@ -8,7 +8,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import sys + +--- ./samples/python/squares.py (original) ++++ ./samples/python/squares.py (refactored) +@@ -7,7 +7,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + import sys + PY3 = sys.version_info[0] == 3 + +@@ -26,7 +26,7 @@ + img = cv.GaussianBlur(img, (5, 5), 0) + squares = [] + for gray in cv.split(img): +- for thrs in xrange(0, 255, 26): ++ for thrs in range(0, 255, 26): + if thrs == 0: + bin = cv.Canny(gray, 0, 50, apertureSize=5) + bin = cv.dilate(bin, None) +@@ -38,7 +38,7 @@ + cnt = cv.approxPolyDP(cnt, 0.02*cnt_len, True) + if len(cnt) == 4 and cv.contourArea(cnt) > 1000 and cv.isContourConvex(cnt): + cnt = cnt.reshape(-1, 2) +- max_cos = np.max([angle_cos( cnt[i], cnt[(i+1) % 4], cnt[(i+2) % 4] ) for i in xrange(4)]) ++ max_cos = np.max([angle_cos( cnt[i], cnt[(i+1) % 4], cnt[(i+2) % 4] ) for i in range(4)]) + if max_cos < 0.1: + squares.append(cnt) + return squares +--- ./samples/python/morphology.py (original) ++++ ./samples/python/morphology.py (refactored) +@@ -13,7 +13,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + import sys + PY3 = sys.version_info[0] == 3 + +@@ -46,8 +46,8 @@ + cur_mode = next(modes) + cur_str_mode = next(str_modes) + else: +- cur_mode = modes.next() +- cur_str_mode = str_modes.next() ++ cur_mode = next(modes) ++ cur_str_mode = next(str_modes) + + def update(dummy=None): + sz = cv.getTrackbarPos('op/size', 'morphology') +@@ -84,12 +84,12 @@ + if PY3: + cur_mode = next(modes) + else: +- cur_mode = modes.next() ++ cur_mode = next(modes) + if ch == ord('2'): + if PY3: + cur_str_mode = next(str_modes) + else: +- cur_str_mode = str_modes.next() ++ cur_str_mode = next(str_modes) + update() + + print('Done') +--- ./samples/python/drawing.py (original) ++++ ./samples/python/drawing.py (refactored) +@@ -7,7 +7,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/mouse_and_match.py (original) ++++ ./samples/python/mouse_and_match.py (refactored) +@@ -12,7 +12,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./modules/java/generator/gen_java.py (original) ++++ ./modules/java/generator/gen_java.py (refactored) +@@ -15,7 +15,7 @@ + class StringIO(io.StringIO): + def write(self, s): + if isinstance(s, str): +- s = unicode(s) # noqa: F821 ++ s = str(s) # noqa: F821 + return super(StringIO, self).write(s) + + SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +@@ -613,7 +613,7 @@ + moduleCppCode = StringIO() + package_path = os.path.join(output_java_path, module) + mkdir_p(package_path) +- for ci in sorted(self.classes.values(), key=lambda x: x.symbol_id): ++ for ci in sorted(list(self.classes.values()), key=lambda x: x.symbol_id): + if ci.name == "Mat": + continue + ci.initCodeStreams(self.Module) +@@ -1104,9 +1104,9 @@ + %s;\n\n""" % (",\n"+" "*12).join(["%s = %s" % (c.name, const_value(c.value)) for c in ci.private_consts]) + ) + if ci.consts: +- enumTypes = set(map(lambda c: c.enumType, ci.consts)) ++ enumTypes = set([c.enumType for c in ci.consts]) + grouped_consts = {enumType: [c for c in ci.consts if c.enumType == enumType] for enumType in enumTypes} +- for typeName in sorted(grouped_consts.keys(), key=lambda x: str(x) if x is not None else ""): ++ for typeName in sorted(list(grouped_consts.keys()), key=lambda x: str(x) if x is not None else ""): + consts = grouped_consts[typeName] + logging.info("%s", consts) + if typeName: +@@ -1310,7 +1310,7 @@ + + lines = doc.splitlines() + +- lines = list(map(lambda x: x[x.find('*'):].strip() if x.lstrip().startswith("*") else x, lines)) ++ lines = list([x[x.find('*'):].strip() if x.lstrip().startswith("*") else x for x in lines]) + + listInd = []; + indexDiff = 0; +@@ -1362,17 +1362,16 @@ + lines.append(" "*i + "") + i -= 1; + +- lines = list(map(lambda x: "* " + x[1:].strip() if x.startswith("*") and x != "*" else x, lines)) +- lines = list(map(lambda x: x if x.startswith("*") else "* " + x if x and x != "*" else "*", lines)) +- +- lines = list(map(lambda x: x +- .replace("@note", "Note:") +- , lines)) +- +- lines = list(map(lambda x: re.sub('@b ([\\w:]+?)\\b', '' + r'\1' + '', x), lines)) +- lines = list(map(lambda x: re.sub('@c ([\\w:]+?)\\b', '' + r'\1' + '', x), lines)) +- lines = list(map(lambda x: re.sub('`(.*?)`', "{@code " + r'\1' + '}', x), lines)) +- lines = list(map(lambda x: re.sub('@p ([\\w:]+?)\\b', '{@code ' + r'\1' + '}', x), lines)) ++ lines = list(["* " + x[1:].strip() if x.startswith("*") and x != "*" else x for x in lines]) ++ lines = list([x if x.startswith("*") else "* " + x if x and x != "*" else "*" for x in lines]) ++ ++ lines = list([x ++ .replace("@note", "Note:") for x in lines]) ++ ++ lines = list([re.sub('@b ([\\w:]+?)\\b', '' + r'\1' + '', x) for x in lines]) ++ lines = list([re.sub('@c ([\\w:]+?)\\b', '' + r'\1' + '', x) for x in lines]) ++ lines = list([re.sub('`(.*?)`', "{@code " + r'\1' + '}', x) for x in lines]) ++ lines = list([re.sub('@p ([\\w:]+?)\\b', '{@code ' + r'\1' + '}', x) for x in lines]) + + hasValues = False + for line in lines: +@@ -1428,7 +1427,7 @@ + + gen_dict_files = [] + +- print("JAVA: Processing OpenCV modules: %d" % len(config['modules'])) ++ print(("JAVA: Processing OpenCV modules: %d" % len(config['modules']))) + for e in config['modules']: + (module, module_location) = (e['name'], os.path.join(ROOT_DIR, e['location'])) + logging.info("\n=== MODULE: %s (%s) ===\n" % (module, module_location)) +@@ -1498,4 +1497,4 @@ + logging.info("No generated code for module: %s", module) + generator.finalize(jni_path) + +- print('Generated files: %d (updated %d)' % (total_files, updated_files)) ++ print(('Generated files: %d (updated %d)' % (total_files, updated_files))) +--- ./samples/python/tutorial_code/Histograms_Matching/histogram_equalization/EqualizeHist_Demo.py (original) ++++ ./samples/python/tutorial_code/Histograms_Matching/histogram_equalization/EqualizeHist_Demo.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import argparse + +--- ./samples/python/letter_recog.py (original) ++++ ./samples/python/letter_recog.py (refactored) +@@ -26,7 +26,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/tutorial_code/Histograms_Matching/back_projection/calcBackProject_Demo1.py (original) ++++ ./samples/python/tutorial_code/Histograms_Matching/back_projection/calcBackProject_Demo1.py (refactored) +@@ -1,5 +1,5 @@ +-from __future__ import print_function +-from __future__ import division ++ ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/video_v4l2.py (original) ++++ ./samples/python/video_v4l2.py (refactored) +@@ -15,7 +15,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/find_obj.py (original) ++++ ./samples/python/find_obj.py (refactored) +@@ -15,7 +15,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +@@ -68,7 +68,7 @@ + mkp2.append( kp2[m.trainIdx] ) + p1 = np.float32([kp.pt for kp in mkp1]) + p2 = np.float32([kp.pt for kp in mkp2]) +- kp_pairs = zip(mkp1, mkp2) ++ kp_pairs = list(zip(mkp1, mkp2)) + return p1, p2, list(kp_pairs) + + def explore_match(win, img1, img2, kp_pairs, status = None, H = None): +--- ./samples/python/tutorial_code/ImgTrans/HoughCircle/hough_circle.py (original) ++++ ./samples/python/tutorial_code/ImgTrans/HoughCircle/hough_circle.py (refactored) +@@ -14,7 +14,7 @@ + # Check if image is loaded fine + if src is None: + print ('Error opening image!') +- print ('Usage: hough_circle.py [image_name -- default ' + default_file + '] \n') ++ print(('Usage: hough_circle.py [image_name -- default ' + default_file + '] \n')) + return -1 + ## [load] + +--- ./samples/python/video_threaded.py (original) ++++ ./samples/python/video_threaded.py (refactored) +@@ -16,7 +16,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/tutorial_code/ImgTrans/SobelDemo/sobel_demo.py (original) ++++ ./samples/python/tutorial_code/ImgTrans/SobelDemo/sobel_demo.py (refactored) +@@ -28,7 +28,7 @@ + + # Check if image is loaded fine + if src is None: +- print ('Error opening image: ' + argv[0]) ++ print(('Error opening image: ' + argv[0])) + return -1 + ## [load] + +--- ./samples/python/tutorial_code/ImgTrans/canny_detector/CannyDetector_Demo.py (original) ++++ ./samples/python/tutorial_code/ImgTrans/canny_detector/CannyDetector_Demo.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import argparse + +--- ./samples/python/turing.py (original) ++++ ./samples/python/turing.py (refactored) +@@ -8,7 +8,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + import sys + PY3 = sys.version_info[0] == 3 + +@@ -45,7 +45,7 @@ + + def process_scale(a_lods, lod): + d = a_lods[lod] - cv.pyrUp(a_lods[lod+1]) +- for _i in xrange(lod): ++ for _i in range(lod): + d = cv.pyrUp(d) + v = cv.GaussianBlur(d*d, (3, 3), 0) + return np.sign(d), v +@@ -53,10 +53,10 @@ + scale_num = 6 + for frame_i in count(): + a_lods = [a] +- for i in xrange(scale_num): ++ for i in range(scale_num): + a_lods.append(cv.pyrDown(a_lods[-1])) + ms, vs = [], [] +- for i in xrange(1, scale_num): ++ for i in range(1, scale_num): + m, v = process_scale(a_lods, i) + ms.append(m) + vs.append(v) +--- ./samples/python/plane_ar.py (original) ++++ ./samples/python/plane_ar.py (refactored) +@@ -23,7 +23,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/tutorial_code/Histograms_Matching/back_projection/calcBackProject_Demo2.py (original) ++++ ./samples/python/tutorial_code/Histograms_Matching/back_projection/calcBackProject_Demo2.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/watershed.py (original) ++++ ./samples/python/watershed.py (refactored) +@@ -23,7 +23,7 @@ + + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/tutorial_code/ImgTrans/HoughLine/hough_lines.py (original) ++++ ./samples/python/tutorial_code/ImgTrans/HoughLine/hough_lines.py (refactored) +@@ -19,7 +19,7 @@ + # Check if image is loaded fine + if src is None: + print ('Error opening image!') +- print ('Usage: hough_lines.py [image_name -- default ' + default_file + '] \n') ++ print(('Usage: hough_lines.py [image_name -- default ' + default_file + '] \n')) + return -1 + ## [load] + +--- ./samples/python/tutorial_code/Histograms_Matching/histogram_comparison/compareHist_Demo.py (original) ++++ ./samples/python/tutorial_code/Histograms_Matching/histogram_comparison/compareHist_Demo.py (refactored) +@@ -1,5 +1,5 @@ +-from __future__ import print_function +-from __future__ import division ++ ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/Histograms_Matching/histogram_calculation/calcHist_Demo.py (original) ++++ ./samples/python/tutorial_code/Histograms_Matching/histogram_calculation/calcHist_Demo.py (refactored) +@@ -1,5 +1,5 @@ +-from __future__ import print_function +-from __future__ import division ++ ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/core/AddingImages/adding_images.py (original) ++++ ./samples/python/tutorial_code/core/AddingImages/adding_images.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + + import cv2 as cv + +@@ -12,7 +12,7 @@ + print(''' Simple Linear Blender + ----------------------- + * Enter alpha [0.0-1.0]: ''') +-input_alpha = float(raw_input().strip()) ++input_alpha = float(input().strip()) + if 0 <= alpha <= 1: + alpha = input_alpha + # [load] +--- ./samples/python/tutorial_code/ImgTrans/warp_affine/Geometric_Transforms_Demo.py (original) ++++ ./samples/python/tutorial_code/ImgTrans/warp_affine/Geometric_Transforms_Demo.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/dnn/virtual_try_on.py (original) ++++ ./samples/dnn/virtual_try_on.py (refactored) +@@ -157,7 +157,7 @@ + 'Left-shoe' : (255, 255, 0), + 'Right-shoe' : (255, 170, 0) + } +- color2label = {val: key for key, val in palette.items()} ++ color2label = {val: key for key, val in list(palette.items())} + head_labels = ['Hat', 'Hair', 'Sunglasses', 'Face', 'Pants', 'Skirt'] + + segm_image = cv.cvtColor(segm_image, cv.COLOR_BGR2RGB) +--- ./samples/python/tutorial_code/ShapeDescriptors/find_contours/findContours_demo.py (original) ++++ ./samples/python/tutorial_code/ShapeDescriptors/find_contours/findContours_demo.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tst_scene_render.py (original) ++++ ./samples/python/tst_scene_render.py (refactored) +@@ -2,7 +2,7 @@ + + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/tutorial_code/TrackingMotion/harris_detector/cornerHarris_Demo.py (original) ++++ ./samples/python/tutorial_code/TrackingMotion/harris_detector/cornerHarris_Demo.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/ShapeDescriptors/hull/hull_demo.py (original) ++++ ./samples/python/tutorial_code/ShapeDescriptors/hull/hull_demo.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/plane_tracker.py (original) ++++ ./samples/python/plane_tracker.py (refactored) +@@ -22,7 +22,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + import sys + PY3 = sys.version_info[0] == 3 + +@@ -104,7 +104,7 @@ + matches = [m[0] for m in matches if len(m) == 2 and m[0].distance < m[1].distance * 0.75] + if len(matches) < MIN_MATCH_COUNT: + return [] +- matches_by_id = [[] for _ in xrange(len(self.targets))] ++ matches_by_id = [[] for _ in range(len(self.targets))] + for m in matches: + matches_by_id[m.imgIdx].append(m) + tracked = [] +--- ./samples/python/tutorial_code/ShapeDescriptors/bounding_rotated_ellipses/generalContours_demo2.py (original) ++++ ./samples/python/tutorial_code/ShapeDescriptors/bounding_rotated_ellipses/generalContours_demo2.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/TrackingMotion/corner_subpixels/cornerSubPix_Demo.py (original) ++++ ./samples/python/tutorial_code/TrackingMotion/corner_subpixels/cornerSubPix_Demo.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/ImgTrans/distance_transformation/imageSegmentation.py (original) ++++ ./samples/python/tutorial_code/ImgTrans/distance_transformation/imageSegmentation.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/ImgTrans/remap/Remap_Demo.py (original) ++++ ./samples/python/tutorial_code/ImgTrans/remap/Remap_Demo.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/core/mat_operations/mat_operations.py (original) ++++ ./samples/python/tutorial_code/core/mat_operations/mat_operations.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import division ++ + import cv2 as cv + import numpy as np + +--- ./samples/python/tutorial_code/ShapeDescriptors/moments/moments_demo.py (original) ++++ ./samples/python/tutorial_code/ShapeDescriptors/moments/moments_demo.py (refactored) +@@ -1,5 +1,5 @@ +-from __future__ import print_function +-from __future__ import division ++ ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/ShapeDescriptors/point_polygon_test/pointPolygonTest_demo.py (original) ++++ ./samples/python/tutorial_code/ShapeDescriptors/point_polygon_test/pointPolygonTest_demo.py (refactored) +@@ -1,5 +1,5 @@ +-from __future__ import print_function +-from __future__ import division ++ ++ + import cv2 as cv + import numpy as np + +--- ./samples/python/tutorial_code/features2D/feature_detection/SURF_detection_Demo.py (original) ++++ ./samples/python/tutorial_code/features2D/feature_detection/SURF_detection_Demo.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/TrackingMotion/good_features_to_track/goodFeaturesToTrack_Demo.py (original) ++++ ./samples/python/tutorial_code/TrackingMotion/good_features_to_track/goodFeaturesToTrack_Demo.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/qrcode.py (original) ++++ ./samples/python/qrcode.py (refactored) +@@ -9,7 +9,7 @@ + + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/tutorial_code/features2D/feature_description/SURF_matching_Demo.py (original) ++++ ./samples/python/tutorial_code/features2D/feature_description/SURF_matching_Demo.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/core/discrete_fourier_transform/discrete_fourier_transform.py (original) ++++ ./samples/python/tutorial_code/core/discrete_fourier_transform/discrete_fourier_transform.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import sys + + import cv2 as cv +--- ./samples/python/tutorial_code/ShapeDescriptors/bounding_rects_circles/generalContours_demo1.py (original) ++++ ./samples/python/tutorial_code/ShapeDescriptors/bounding_rects_circles/generalContours_demo1.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/dnn/dnn_conversion/common/test/voc_segm_test.py (original) ++++ ./samples/python/tutorial_code/dnn/dnn_conversion/common/test/voc_segm_test.py (refactored) +@@ -7,7 +7,7 @@ + def test_segm_models(models_list, data_fetcher, eval_params, experiment_name, is_print_eval_params=True, + is_plot_acc=True): + if is_print_eval_params: +- print( ++ print(( + "===== Running evaluation of the classification models with the following params:\n" + "\t0. val data location: {}\n" + "\t1. val data labels: {}\n" +@@ -22,20 +22,20 @@ + eval_params.bgr_to_rgb, + eval_params.log + ) +- ) ++ )) + + accuracy_evaluator = SemSegmEvaluation(eval_params.log, eval_params.img_cls_file, eval_params.batch_size) + accuracy_evaluator.process(models_list, data_fetcher) + accuracy_array = np.array(accuracy_evaluator.general_fw_accuracy) + +- print( ++ print(( + "===== End of processing. Accuracy results:\n" + "\t1. max accuracy (top-5) for the original model: {}\n" + "\t2. max accuracy (top-5) for the DNN model: {}\n".format( + max(accuracy_array[:, 0]), + max(accuracy_array[:, 1]), + ) +- ) ++ )) + + if is_plot_acc: + plot_acc(accuracy_array, experiment_name) +--- ./samples/python/tutorial_code/core/mat_mask_operations/mat_mask_operations.py (original) ++++ ./samples/python/tutorial_code/core/mat_mask_operations/mat_mask_operations.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import sys + import time + +--- ./samples/python/tutorial_code/imgProc/Pyramids/pyramids.py (original) ++++ ./samples/python/tutorial_code/imgProc/Pyramids/pyramids.py (refactored) +@@ -24,7 +24,7 @@ + ## [load] + ## [loop] + while 1: +- rows, cols, _channels = map(int, src.shape) ++ rows, cols, _channels = list(map(int, src.shape)) + ## [show_image] + cv.imshow('Pyramids Demo', src) + ## [show_image] +--- ./samples/python/tutorial_code/highgui/trackbar/AddingImagesTrackbar.py (original) ++++ ./samples/python/tutorial_code/highgui/trackbar/AddingImagesTrackbar.py (refactored) +@@ -1,5 +1,5 @@ +-from __future__ import print_function +-from __future__ import division ++ ++ + import cv2 as cv + import argparse + +--- ./samples/python/tutorial_code/features2D/Homography/panorama_stitching_rotating_camera.py (original) ++++ ./samples/python/tutorial_code/features2D/Homography/panorama_stitching_rotating_camera.py (refactored) +@@ -2,7 +2,7 @@ + # -*- coding: utf-8 -*- + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/tutorial_code/core/file_input_output/file_input_output.py (original) ++++ ./samples/python/tutorial_code/core/file_input_output/file_input_output.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/tutorial_code/imgProc/threshold/threshold.py (original) ++++ ./samples/python/tutorial_code/imgProc/threshold/threshold.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import argparse + +--- ./samples/python/mosse.py (original) ++++ ./samples/python/mosse.py (refactored) +@@ -22,7 +22,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + import sys + PY3 = sys.version_info[0] == 3 + +@@ -58,7 +58,7 @@ + class MOSSE: + def __init__(self, frame, rect): + x1, y1, x2, y2 = rect +- w, h = map(cv.getOptimalDFTSize, [x2-x1, y2-y1]) ++ w, h = list(map(cv.getOptimalDFTSize, [x2-x1, y2-y1])) + x1, y1 = (x1+x2-w)//2, (y1+y2-h)//2 + self.pos = x, y = x1+0.5*(w-1), y1+0.5*(h-1) + self.size = w, h +@@ -73,7 +73,7 @@ + self.G = cv.dft(g, flags=cv.DFT_COMPLEX_OUTPUT) + self.H1 = np.zeros_like(self.G) + self.H2 = np.zeros_like(self.G) +- for _i in xrange(128): ++ for _i in range(128): + a = self.preprocess(rnd_warp(img)) + A = cv.dft(a, flags=cv.DFT_COMPLEX_OUTPUT) + self.H1 += cv.mulSpectrums(self.G, A, 0, conjB=True) +--- ./samples/python/tutorial_code/features2D/akaze_matching/AKAZE_match.py (original) ++++ ./samples/python/tutorial_code/features2D/akaze_matching/AKAZE_match.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/TrackingMotion/generic_corner_detector/cornerDetector_Demo.py (original) ++++ ./samples/python/tutorial_code/TrackingMotion/generic_corner_detector/cornerDetector_Demo.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/features2D/Homography/perspective_correction.py (original) ++++ ./samples/python/tutorial_code/features2D/Homography/perspective_correction.py (refactored) +@@ -2,7 +2,7 @@ + # -*- coding: utf-8 -*- + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/tutorial_code/imgProc/erosion_dilatation/morphology_1.py (original) ++++ ./samples/python/tutorial_code/imgProc/erosion_dilatation/morphology_1.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/imgProc/match_template/match_template.py (original) ++++ ./samples/python/tutorial_code/imgProc/match_template/match_template.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import sys + import cv2 as cv + +--- ./samples/python/tutorial_code/imgProc/changing_contrast_brightness_image/changing_contrast_brightness_image.py (original) ++++ ./samples/python/tutorial_code/imgProc/changing_contrast_brightness_image/changing_contrast_brightness_image.py (refactored) +@@ -1,5 +1,5 @@ +-from __future__ import print_function +-from __future__ import division ++ ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/imgProc/anisotropic_image_segmentation/anisotropic_image_segmentation.py (original) ++++ ./samples/python/tutorial_code/imgProc/anisotropic_image_segmentation/anisotropic_image_segmentation.py (refactored) +@@ -65,7 +65,7 @@ + + imgIn = cv.imread(args.input, cv.IMREAD_GRAYSCALE) + if imgIn is None: +- print('Could not open or find the image: {}'.format(args.input)) ++ print(('Could not open or find the image: {}'.format(args.input))) + exit(0) + + ## [main_extra] +--- ./samples/python/tutorial_code/video/background_subtraction/bg_sub.py (original) ++++ ./samples/python/tutorial_code/video/background_subtraction/bg_sub.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import argparse + +--- ./samples/python/tutorial_code/imgProc/changing_contrast_brightness_image/BasicLinearTransforms.py (original) ++++ ./samples/python/tutorial_code/imgProc/changing_contrast_brightness_image/BasicLinearTransforms.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + from builtins import input + import cv2 as cv + import numpy as np +@@ -28,8 +28,8 @@ + print(' Basic Linear Transforms ') + print('-------------------------') + try: +- alpha = float(input('* Enter the alpha value [1.0-3.0]: ')) +- beta = int(input('* Enter the beta value [0-100]: ')) ++ alpha = float(eval(input('* Enter the alpha value [1.0-3.0]: '))) ++ beta = int(eval(input('* Enter the beta value [0-100]: '))) + except ValueError: + print('Error, not a number') + ## [basic-linear-transform-parameters] +--- ./samples/python/video.py (original) ++++ ./samples/python/video.py (refactored) +@@ -30,7 +30,7 @@ + ''' + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +@@ -53,7 +53,7 @@ + self.frame_size = (w, h) + + if size is not None: +- w, h = map(int, size.split('x')) ++ w, h = list(map(int, size.split('x'))) + self.frame_size = (w, h) + self.bg = cv.resize(self.bg, self.frame_size) + +@@ -187,7 +187,7 @@ + else: + cap = cv.VideoCapture(source) + if 'size' in params: +- w, h = map(int, params['size'].split('x')) ++ w, h = list(map(int, params['size'].split('x'))) + cap.set(cv.CAP_PROP_FRAME_WIDTH, w) + cap.set(cv.CAP_PROP_FRAME_HEIGHT, h) + if cap is None or not cap.isOpened(): +--- ./samples/python/tutorial_code/features2D/feature_flann_matcher/SURF_FLANN_matching_Demo.py (original) ++++ ./samples/python/tutorial_code/features2D/feature_flann_matcher/SURF_FLANN_matching_Demo.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/objectDetection/cascade_classifier/objectDetection.py (original) ++++ ./samples/python/tutorial_code/objectDetection/cascade_classifier/objectDetection.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import argparse + +--- ./samples/python/tutorial_code/photo/hdr_imaging/hdr_imaging.py (original) ++++ ./samples/python/tutorial_code/photo/hdr_imaging/hdr_imaging.py (refactored) +@@ -1,5 +1,5 @@ +-from __future__ import print_function +-from __future__ import division ++ ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/imgProc/opening_closing_hats/morphology_2.py (original) ++++ ./samples/python/tutorial_code/imgProc/opening_closing_hats/morphology_2.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/imgProc/threshold_inRange/threshold_inRange.py (original) ++++ ./samples/python/tutorial_code/imgProc/threshold_inRange/threshold_inRange.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import argparse + +--- ./samples/python/tutorial_code/features2D/feature_homography/SURF_FLANN_matching_homography_Demo.py (original) ++++ ./samples/python/tutorial_code/features2D/feature_homography/SURF_FLANN_matching_homography_Demo.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/imgProc/morph_lines_detection/morph_lines_detection.py (original) ++++ ./samples/python/tutorial_code/imgProc/morph_lines_detection/morph_lines_detection.py (refactored) +@@ -27,7 +27,7 @@ + + # Check if image is loaded fine + if src is None: +- print ('Error opening image: ' + argv[0]) ++ print(('Error opening image: ' + argv[0])) + return -1 + + # Show source image +--- ./samples/python/tutorial_code/ml/py_svm_opencv/hogsvm.py (original) ++++ ./samples/python/tutorial_code/ml/py_svm_opencv/hogsvm.py (refactored) +@@ -70,4 +70,4 @@ + ####### Check Accuracy ######################## + mask = result==responses + correct = np.count_nonzero(mask) +-print(correct*100.0/result.size) ++print((correct*100.0/result.size)) +--- ./samples/python/tutorial_code/ml/non_linear_svms/non_linear_svms.py (original) ++++ ./samples/python/tutorial_code/ml/non_linear_svms/non_linear_svms.py (refactored) +@@ -1,4 +1,4 @@ +-from __future__ import print_function ++ + import cv2 as cv + import numpy as np + import random as rng +--- ./samples/python/tutorial_code/ml/introduction_to_pca/introduction_to_pca.py (original) ++++ ./samples/python/tutorial_code/ml/introduction_to_pca/introduction_to_pca.py (refactored) +@@ -1,5 +1,5 @@ +-from __future__ import print_function +-from __future__ import division ++ ++ + import cv2 as cv + import numpy as np + import argparse +--- ./samples/python/tutorial_code/videoio/video-input-psnr-ssim.py (original) ++++ ./samples/python/tutorial_code/videoio/video-input-psnr-ssim.py (refactored) +@@ -2,7 +2,7 @@ + # -*- coding: utf-8 -*- + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import numpy as np + import cv2 as cv +--- ./samples/python/stitching_detailed.py (original) ++++ ./samples/python/stitching_detailed.py (refactored) +@@ -6,7 +6,7 @@ + """ + + # Python 2/3 compatibility +-from __future__ import print_function ++ + + import argparse + from collections import OrderedDict +@@ -105,7 +105,7 @@ + parser.add_argument( + '--features', action='store', default=list(FEATURES_FIND_CHOICES.keys())[0], + help="Type of features used for images matching. The default is '%s'." % list(FEATURES_FIND_CHOICES.keys())[0], +- choices=FEATURES_FIND_CHOICES.keys(), ++ choices=list(FEATURES_FIND_CHOICES.keys()), + type=str, dest='features' + ) + parser.add_argument( +@@ -117,7 +117,7 @@ + parser.add_argument( + '--estimator', action='store', default=list(ESTIMATOR_CHOICES.keys())[0], + help="Type of estimator used for transformation estimation. The default is '%s'." % list(ESTIMATOR_CHOICES.keys())[0], +- choices=ESTIMATOR_CHOICES.keys(), ++ choices=list(ESTIMATOR_CHOICES.keys()), + type=str, dest='estimator' + ) + parser.add_argument( +@@ -133,7 +133,7 @@ + parser.add_argument( + '--ba', action='store', default=list(BA_COST_CHOICES.keys())[0], + help="Bundle adjustment cost function. The default is '%s'." % list(BA_COST_CHOICES.keys())[0], +- choices=BA_COST_CHOICES.keys(), ++ choices=list(BA_COST_CHOICES.keys()), + type=str, dest='ba' + ) + parser.add_argument( +@@ -171,7 +171,7 @@ + parser.add_argument( + '--seam', action='store', default=list(SEAM_FIND_CHOICES.keys())[0], + help="Seam estimation method. The default is '%s'." % list(SEAM_FIND_CHOICES.keys())[0], +- choices=SEAM_FIND_CHOICES.keys(), ++ choices=list(SEAM_FIND_CHOICES.keys()), + type=str, dest='seam' + ) + parser.add_argument( +@@ -182,7 +182,7 @@ + parser.add_argument( + '--expos_comp', action='store', default=list(EXPOS_COMP_CHOICES.keys())[0], + help="Exposure compensation method. The default is '%s'." % list(EXPOS_COMP_CHOICES.keys())[0], +- choices=EXPOS_COMP_CHOICES.keys(), ++ choices=list(EXPOS_COMP_CHOICES.keys()), + type=str, dest='expos_comp' + ) + parser.add_argument( +--- ./modules/objc/generator/gen_objc.py (original) ++++ ./modules/objc/generator/gen_objc.py (refactored) +@@ -1,6 +1,6 @@ + #!/usr/bin/env python + +-from __future__ import print_function, unicode_literals ++ + import sys, re, os.path, errno, fnmatch + import json + import logging +@@ -913,7 +913,7 @@ + mkdir_p(package_path) + extension_file = "%s/%s/%sExt.swift" % (output_objc_path, module, self.Module) + +- for ci in sorted(self.classes.values(), key=lambda x: x.symbol_id): ++ for ci in sorted(list(self.classes.values()), key=lambda x: x.symbol_id): + if ci.name == "Mat": + continue + ci.initCodeStreams(self.Module) +@@ -1265,7 +1265,7 @@ + if ci.consts: + enumTypes = set([c.enumType for c in ci.consts]) + grouped_consts = {enumType: [c for c in ci.consts if c.enumType == enumType] for enumType in enumTypes} +- for typeName in sorted(grouped_consts.keys(), key=lambda x: str(x) if x is not None else ""): ++ for typeName in sorted(list(grouped_consts.keys()), key=lambda x: str(x) if x is not None else ""): + consts = grouped_consts[typeName] + logging.info("%s", consts) + if typeName: +--- ./doc/pattern_tools/svgfig.py (original) ++++ ./doc/pattern_tools/svgfig.py (refactored) +@@ -21,13 +21,13 @@ + + if sys.version_info >= (3,0): + long = int +- basestring = (str,bytes) ++ str = (str,bytes) + + # Fix Python 2.x. + try: +- UNICODE_EXISTS = bool(type(unicode)) ++ UNICODE_EXISTS = bool(type(str)) + except NameError: +- unicode = lambda s: str(s) ++ str = lambda s: str(s) + + try: + xrange # Python 2 +@@ -37,8 +37,8 @@ + + if re.search("windows", platform.system(), re.I): + try: +- import _winreg +- _default_directory = _winreg.QueryValueEx(_winreg.OpenKey(_winreg.HKEY_CURRENT_USER, ++ import winreg ++ _default_directory = winreg.QueryValueEx(winreg.OpenKey(winreg.HKEY_CURRENT_USER, + r"Software\Microsoft\Windows\Current Version\Explorer\Shell Folders"), "Desktop")[0] + # tmpdir = _winreg.QueryValueEx(_winreg.OpenKey(_winreg.HKEY_CURRENT_USER, "Environment"), "TEMP")[0] + # if tmpdir[0:13] != "%USERPROFILE%": +@@ -63,7 +63,7 @@ + + def attr_preprocess(attr): + attrCopy = attr.copy() +- for name in attr.keys(): ++ for name in list(attr.keys()): + name_colon = re.sub("__", ":", name) + if name_colon != name: + attrCopy[name_colon] = attrCopy[name] +@@ -162,7 +162,7 @@ + obj = obj[i] + ti = ti[-1] + +- if isinstance(ti, (int, long, slice)): ++ if isinstance(ti, (int, slice)): + return obj.sub[ti] + else: + return obj.attr[ti] +@@ -176,7 +176,7 @@ + obj = obj[i] + ti = ti[-1] + +- if isinstance(ti, (int, long, slice)): ++ if isinstance(ti, (int, slice)): + obj.sub[ti] = value + else: + obj.attr[ti] = value +@@ -190,7 +190,7 @@ + obj = obj[i] + ti = ti[-1] + +- if isinstance(ti, (int, long, slice)): ++ if isinstance(ti, (int, slice)): + del obj.sub[ti] + else: + del obj.attr[ti] +@@ -244,7 +244,7 @@ + def __iter__(self): + return self + +- def next(self): ++ def __next__(self): + if not self.shown: + self.shown = True + if self.ti != (): +@@ -259,11 +259,11 @@ + self.iterators = [] + for i, s in enumerate(self.svg.sub): + self.iterators.append(self.__class__(s, self.ti + (i,), self.depth_limit)) +- for k, s in self.svg.attr.items(): ++ for k, s in list(self.svg.attr.items()): + self.iterators.append(self.__class__(s, self.ti + (k,), self.depth_limit)) + self.iterators = itertools.chain(*self.iterators) + +- return self.iterators.next() ++ return next(self.iterators) + ### end nested class + + def depth_first(self, depth_limit=None): +@@ -291,8 +291,8 @@ + output = [] + for ti, s in self: + show = False +- if isinstance(ti[-1], (int, long)): +- if isinstance(s, basestring): ++ if isinstance(ti[-1], int): ++ if isinstance(s, str): + show = text + else: + show = sub +@@ -346,8 +346,8 @@ + + for ti, s in self.depth_first(depth_limit): + show = False +- if isinstance(ti[-1], (int, long)): +- if isinstance(s, basestring): ++ if isinstance(ti[-1], int): ++ if isinstance(s, str): + show = text + else: + show = sub +@@ -361,7 +361,7 @@ + + return "\n".join(output) + +- def xml(self, indent=u" ", newl=u"\n", depth_limit=None, depth=0): ++ def xml(self, indent=" ", newl="\n", depth_limit=None, depth=0): + """Get an XML representation of the SVG. + + indent string used for indenting +@@ -372,34 +372,34 @@ + print svg.xml() + """ + attrstr = [] +- for n, v in self.attr.items(): ++ for n, v in list(self.attr.items()): + if isinstance(v, dict): +- v = u"; ".join([u"%s:%s" % (ni, vi) for ni, vi in v.items()]) ++ v = "; ".join(["%s:%s" % (ni, vi) for ni, vi in list(v.items())]) + elif isinstance(v, (list, tuple)): +- v = u", ".join(v) +- attrstr.append(u" %s=%s" % (n, repr(v))) +- attrstr = u"".join(attrstr) ++ v = ", ".join(v) ++ attrstr.append(" %s=%s" % (n, repr(v))) ++ attrstr = "".join(attrstr) + + if len(self.sub) == 0: +- return u"%s<%s%s />" % (indent * depth, self.t, attrstr) ++ return "%s<%s%s />" % (indent * depth, self.t, attrstr) + + if depth_limit is None or depth_limit > depth: + substr = [] + for s in self.sub: + if isinstance(s, SVG): + substr.append(s.xml(indent, newl, depth_limit, depth + 1) + newl) +- elif isinstance(s, basestring): +- substr.append(u"%s%s%s" % (indent * (depth + 1), s, newl)) ++ elif isinstance(s, str): ++ substr.append("%s%s%s" % (indent * (depth + 1), s, newl)) + else: + substr.append("%s%s%s" % (indent * (depth + 1), repr(s), newl)) +- substr = u"".join(substr) +- +- return u"%s<%s%s>%s%s%s" % (indent * depth, self.t, attrstr, newl, substr, indent * depth, self.t) ++ substr = "".join(substr) ++ ++ return "%s<%s%s>%s%s%s" % (indent * depth, self.t, attrstr, newl, substr, indent * depth, self.t) + + else: +- return u"%s<%s (%d sub)%s />" % (indent * depth, self.t, len(self.sub), attrstr) +- +- def standalone_xml(self, indent=u" ", newl=u"\n", encoding=u"utf-8"): ++ return "%s<%s (%d sub)%s />" % (indent * depth, self.t, len(self.sub), attrstr) ++ ++ def standalone_xml(self, indent=" ", newl="\n", encoding="utf-8"): + """Get an XML representation of the SVG that can be saved/rendered. + + indent string used for indenting +@@ -410,42 +410,42 @@ + top = self + else: + top = canvas(self) +- return u"""\ ++ return """\ + + + +-""" % encoding + (u"".join(top.__standalone_xml(indent, newl))) # end of return statement ++""" % encoding + ("".join(top.__standalone_xml(indent, newl))) # end of return statement + + def __standalone_xml(self, indent, newl): +- output = [u"<%s" % self.t] +- +- for n, v in self.attr.items(): ++ output = ["<%s" % self.t] ++ ++ for n, v in list(self.attr.items()): + if isinstance(v, dict): +- v = u"; ".join([u"%s:%s" % (ni, vi) for ni, vi in v.items()]) ++ v = "; ".join(["%s:%s" % (ni, vi) for ni, vi in list(v.items())]) + elif isinstance(v, (list, tuple)): +- v = u", ".join(v) +- output.append(u' %s="%s"' % (n, v)) ++ v = ", ".join(v) ++ output.append(' %s="%s"' % (n, v)) + + if len(self.sub) == 0: +- output.append(u" />%s%s" % (newl, newl)) ++ output.append(" />%s%s" % (newl, newl)) + return output + + elif self.t == "text" or self.t == "tspan" or self.t == "style": +- output.append(u">") ++ output.append(">") + + else: +- output.append(u">%s%s" % (newl, newl)) ++ output.append(">%s%s" % (newl, newl)) + + for s in self.sub: + if isinstance(s, SVG): + output.extend(s.__standalone_xml(indent, newl)) + else: +- output.append(unicode(s)) ++ output.append(str(s)) + + if self.t == "tspan": +- output.append(u"" % self.t) ++ output.append("" % self.t) + else: +- output.append(u"%s%s" % (self.t, newl, newl)) ++ output.append("%s%s" % (self.t, newl, newl)) + + return output + +@@ -622,17 +622,17 @@ + + def startElement(self, name, attr): + s = SVG(name) +- s.attr = dict(attr.items()) ++ s.attr = dict(list(attr.items())) + if len(self.stack) > 0: + last = self.stack[-1] + last.sub.append(s) + self.stack.append(s) + + def characters(self, ch): +- if not isinstance(ch, basestring) or self.all_whitespace.match(ch) is None: ++ if not isinstance(ch, str) or self.all_whitespace.match(ch) is None: + if len(self.stack) > 0: + last = self.stack[-1] +- if len(last.sub) > 0 and isinstance(last.sub[-1], basestring): ++ if len(last.sub) > 0 and isinstance(last.sub[-1], str): + last.sub[-1] = last.sub[-1] + "\n" + ch + else: + last.sub.append(ch) +@@ -642,7 +642,7 @@ + last = self.stack[-1] + if (isinstance(last, SVG) and last.t == "style" and + "type" in last.attr and last.attr["type"] == "text/css" and +- len(last.sub) == 1 and isinstance(last.sub[0], basestring)): ++ len(last.sub) == 1 and isinstance(last.sub[0], str)): + last.sub[0] = "" + + self.output = self.stack.pop() +@@ -659,7 +659,7 @@ + def set_func_name(f, name): + """try to patch the function name string into a function object""" + try: +- f.func_name = name ++ f.__name__ = name + except TypeError: + # py 2.3 raises: TypeError: readonly attribute + pass +@@ -679,13 +679,13 @@ + locals = {} # python 2.3's eval() won't accept None + + if callable(expr): +- if expr.func_code.co_argcount == 2: ++ if expr.__code__.co_argcount == 2: + return expr + +- elif expr.func_code.co_argcount == 1: ++ elif expr.__code__.co_argcount == 1: + split = lambda z: (z.real, z.imag) + output = lambda x, y: split(expr(x + y*1j)) +- set_func_name(output, expr.func_name) ++ set_func_name(output, expr.__name__) + return output + + else: +@@ -814,10 +814,10 @@ + def __repr__(self): + if self.trans is None: + return "" % len(self.d) +- elif isinstance(self.trans, basestring): ++ elif isinstance(self.trans, str): + return " %s>" % (len(self.d), self.trans) + else: +- return "" % (len(self.d), self.trans.func_name) ++ return "" % (len(self.d), self.trans.__name__) + + def __init__(self, *d, **kwds): + self.d = list(d) +@@ -827,7 +827,7 @@ + + self.trans = kwds["trans"]; del kwds["trans"] + if len(kwds) != 0: +- raise TypeError ("Fig() got unexpected keyword arguments %s" % kwds.keys()) ++ raise TypeError ("Fig() got unexpected keyword arguments %s" % list(kwds.keys())) + + def SVG(self, trans=None): + """Apply the transformation "trans" and return an SVG object. +@@ -837,7 +837,7 @@ + + if trans is None: + trans = self.trans +- if isinstance(trans, basestring): ++ if isinstance(trans, str): + trans = totrans(trans) + + output = SVG("g") +@@ -847,7 +847,7 @@ + + elif isinstance(s, Fig): + strans = s.trans +- if isinstance(strans, basestring): ++ if isinstance(strans, str): + strans = totrans(strans) + + if trans is None: +@@ -906,7 +906,7 @@ + if self.trans is None: + return "" % len(self.d) + else: +- return "" % (len(self.d), self.trans.func_name) ++ return "" % (len(self.d), self.trans.__name__) + + def __init__(self, xmin, xmax, ymin, ymax, *d, **kwds): + self.xmin, self.xmax, self.ymin, self.ymax = xmin, xmax, ymin, ymax +@@ -945,13 +945,13 @@ + self.text_attr = kwds["text_attr"]; del kwds["text_attr"] + self.axis_attr = kwds["axis_attr"]; del kwds["axis_attr"] + if len(kwds) != 0: +- raise TypeError ("Plot() got unexpected keyword arguments %s" % kwds.keys()) ++ raise TypeError ("Plot() got unexpected keyword arguments %s" % list(kwds.keys())) + + def SVG(self, trans=None): + """Apply the transformation "trans" and return an SVG object.""" + if trans is None: + trans = self.trans +- if isinstance(trans, basestring): ++ if isinstance(trans, str): + trans = totrans(trans) + + self.last_window = window(self.xmin, self.xmax, self.ymin, self.ymax, +@@ -1053,7 +1053,7 @@ + self.axis_attr.update(kwds["axis_attr"]); del kwds["axis_attr"] + + if len(kwds) != 0: +- raise TypeError( "Frame() got unexpected keyword arguments %s" % kwds.keys()) ++ raise TypeError( "Frame() got unexpected keyword arguments %s" % list(kwds.keys())) + + def SVG(self): + """Apply the window transformation and return an SVG object.""" +@@ -1119,7 +1119,7 @@ + attr = dict(svg.attr) + d = attr["d"] + del attr["d"] +- for key in attr.keys(): ++ for key in list(attr.keys()): + if not isinstance(key, str): + value = attr[key] + del attr[key] +@@ -1170,7 +1170,7 @@ + return "" % (len(self.d), self.attr) + + def __init__(self, d=[], **attr): +- if isinstance(d, basestring): ++ if isinstance(d, str): + self.d = self.parse(d) + else: + self.d = list(d) +@@ -1351,7 +1351,7 @@ + + def SVG(self, trans=None): + """Apply the transformation "trans" and return an SVG object.""" +- if isinstance(trans, basestring): ++ if isinstance(trans, str): + trans = totrans(trans) + + x, y, X, Y = None, None, None, None +@@ -1719,7 +1719,7 @@ + self.current = self.left + return self + +- def next(self): ++ def __next__(self): + current = self.current + if current is None: + raise StopIteration +@@ -1817,9 +1817,9 @@ + global coordinates. If local=True, return a Path in local coordinates + (which must be transformed again).""" + +- if isinstance(trans, basestring): ++ if isinstance(trans, str): + trans = totrans(trans) +- if isinstance(self.f, basestring): ++ if isinstance(self.f, str): + self.f = funcRtoR2(self.f) + + self.sample(trans) +@@ -1902,7 +1902,7 @@ + """Apply the transformation "trans" and return a Path object in + global coordinates. If local=True, return a Path in local coordinates + (which must be transformed again).""" +- if isinstance(trans, basestring): ++ if isinstance(trans, str): + trans = totrans(trans) + + if self.mode[0] == "L" or self.mode[0] == "l": +@@ -1917,7 +1917,7 @@ + mode = "S" + + vx, vy = [0.]*len(self.d), [0.]*len(self.d) +- for i in xrange(len(self.d)): ++ for i in range(len(self.d)): + inext = (i+1) % len(self.d) + iprev = (i-1) % len(self.d) + +@@ -2052,13 +2052,13 @@ + def __init__(self, x, y, d, **attr): + self.x = x + self.y = y +- self.d = unicode(d) ++ self.d = str(d) + self.attr = dict(self.defaults) + self.attr.update(attr) + + def SVG(self, trans=None): + """Apply the transformation "trans" and return an SVG object.""" +- if isinstance(trans, basestring): ++ if isinstance(trans, str): + trans = totrans(trans) + + X, Y = self.x, self.y +@@ -2082,7 +2082,7 @@ + def __init__(self, x, y, d, **attr): + self.x = x + self.y = y +- self.d = unicode(d) ++ self.d = str(d) + self.attr = dict(self.defaults) + self.attr.update(attr) + +@@ -2147,7 +2147,7 @@ + + def SVG(self, trans=None): + """Apply the transformation "trans" and return an SVG object.""" +- if isinstance(trans, basestring): ++ if isinstance(trans, str): + trans = totrans(trans) + + output = SVG("g", SVG("defs", self.symbol)) +@@ -2230,7 +2230,7 @@ + if isinstance(self.arrow_start, SVG): + defs.append(self.arrow_start) + line.attr["marker-start"] = "url(#%s)" % self.arrow_start["id"] +- elif isinstance(self.arrow_start, basestring): ++ elif isinstance(self.arrow_start, str): + defs.append(make_marker(self.arrow_start, "arrow_start")) + line.attr["marker-start"] = "url(#%s)" % self.arrow_start + else: +@@ -2240,7 +2240,7 @@ + if isinstance(self.arrow_end, SVG): + defs.append(self.arrow_end) + line.attr["marker-end"] = "url(#%s)" % self.arrow_end["id"] +- elif isinstance(self.arrow_end, basestring): ++ elif isinstance(self.arrow_end, str): + defs.append(make_marker(self.arrow_end, "arrow_end")) + line.attr["marker-end"] = "url(#%s)" % self.arrow_end + else: +@@ -2306,7 +2306,7 @@ + + def SVG(self, trans=None): + """Apply the transformation "trans" and return an SVG object.""" +- if isinstance(trans, basestring): ++ if isinstance(trans, str): + trans = totrans(trans) + + X1, Y1, X2, Y2 = self.x1, self.y1, self.x2, self.y2 +@@ -2326,7 +2326,7 @@ + if isinstance(self.arrow_start, SVG): + defs.append(self.arrow_start) + line.attr["marker-start"] = "url(#%s)" % self.arrow_start["id"] +- elif isinstance(self.arrow_start, basestring): ++ elif isinstance(self.arrow_start, str): + defs.append(make_marker(self.arrow_start, "arrow_start")) + line.attr["marker-start"] = "url(#%s)" % self.arrow_start + else: +@@ -2336,7 +2336,7 @@ + if isinstance(self.arrow_end, SVG): + defs.append(self.arrow_end) + line.attr["marker-end"] = "url(#%s)" % self.arrow_end["id"] +- elif isinstance(self.arrow_end, basestring): ++ elif isinstance(self.arrow_end, str): + defs.append(make_marker(self.arrow_end, "arrow_end")) + line.attr["marker-end"] = "url(#%s)" % self.arrow_end + else: +@@ -2515,40 +2515,40 @@ + """Converts numbers to a Unicode string, taking advantage of special + Unicode characters to make nice minus signs and scientific notation. + """ +- output = u"%g" % x +- +- if output[0] == u"-": +- output = u"\u2013" + output[1:] +- +- index = output.find(u"e") ++ output = "%g" % x ++ ++ if output[0] == "-": ++ output = "\u2013" + output[1:] ++ ++ index = output.find("e") + if index != -1: +- uniout = unicode(output[:index]) + u"\u00d710" ++ uniout = str(output[:index]) + "\u00d710" + saw_nonzero = False + for n in output[index+1:]: +- if n == u"+": ++ if n == "+": + pass # uniout += u"\u207a" +- elif n == u"-": +- uniout += u"\u207b" +- elif n == u"0": ++ elif n == "-": ++ uniout += "\u207b" ++ elif n == "0": + if saw_nonzero: +- uniout += u"\u2070" +- elif n == u"1": ++ uniout += "\u2070" ++ elif n == "1": + saw_nonzero = True +- uniout += u"\u00b9" +- elif n == u"2": ++ uniout += "\u00b9" ++ elif n == "2": + saw_nonzero = True +- uniout += u"\u00b2" +- elif n == u"3": ++ uniout += "\u00b2" ++ elif n == "3": + saw_nonzero = True +- uniout += u"\u00b3" +- elif u"4" <= n <= u"9": ++ uniout += "\u00b3" ++ elif "4" <= n <= "9": + saw_nonzero = True + if saw_nonzero: +- uniout += eval("u\"\\u%x\"" % (0x2070 + ord(n) - ord(u"0"))) ++ uniout += eval("u\"\\u%x\"" % (0x2070 + ord(n) - ord("0"))) + else: + uniout += n + +- if uniout[:2] == u"1\u00d7": ++ if uniout[:2] == "1\u00d7": + uniout = uniout[2:] + return uniout + +@@ -2651,7 +2651,7 @@ + + Normally only used internally. + """ +- if isinstance(trans, basestring): ++ if isinstance(trans, str): + trans = totrans(trans) + if trans is None: + f = self.f +@@ -2677,7 +2677,7 @@ + + def SVG(self, trans=None): + """Apply the transformation "trans" and return an SVG object.""" +- if isinstance(trans, basestring): ++ if isinstance(trans, str): + trans = totrans(trans) + + self.last_ticks, self.last_miniticks = self.interpret() +@@ -2692,7 +2692,7 @@ + if self.arrow_start != False and self.arrow_start is not None: + if isinstance(self.arrow_start, SVG): + defs.append(self.arrow_start) +- elif isinstance(self.arrow_start, basestring): ++ elif isinstance(self.arrow_start, str): + defs.append(make_marker(self.arrow_start, "arrow_start")) + else: + raise TypeError("arrow_start must be False/None or an id string for the new marker") +@@ -2700,7 +2700,7 @@ + if self.arrow_end != False and self.arrow_end is not None: + if isinstance(self.arrow_end, SVG): + defs.append(self.arrow_end) +- elif isinstance(self.arrow_end, basestring): ++ elif isinstance(self.arrow_end, str): + defs.append(make_marker(self.arrow_end, "arrow_end")) + else: + raise TypeError("arrow_end must be False/None or an id string for the new marker") +@@ -2709,7 +2709,7 @@ + + eps = _epsilon * (self.high - self.low) + +- for t, label in self.last_ticks.items(): ++ for t, label in list(self.last_ticks.items()): + (X, Y), (xhatx, xhaty), (yhatx, yhaty), angle = self.orient_tickmark(t, trans) + + if ((not self.arrow_start or abs(t - self.low) > eps) and +@@ -2735,7 +2735,7 @@ + + for t in self.last_miniticks: + skip = False +- for tt in self.last_ticks.keys(): ++ for tt in list(self.last_ticks.keys()): + if abs(t - tt) < eps: + skip = True + break +@@ -2764,7 +2764,7 @@ + elif self.labels == True: + format = unumber + +- elif isinstance(self.labels, basestring): ++ elif isinstance(self.labels, str): + format = lambda x: (self.labels % x) + + elif callable(self.labels): +@@ -2781,7 +2781,7 @@ + return {}, [] + + # Case 2: ticks is the number of desired ticks +- elif isinstance(ticks, (int, long)): ++ elif isinstance(ticks, int): + if ticks == True: + ticks = -10 + +@@ -2797,7 +2797,7 @@ + else: + return ticks, self.compute_logminiticks(self.logbase) + +- elif isinstance(self.miniticks, (int, long)): ++ elif isinstance(self.miniticks, int): + return ticks, self.regular_miniticks(self.miniticks) + + elif getattr(self.miniticks, "__iter__", False): +@@ -2818,7 +2818,7 @@ + eps = _epsilon * (self.high - self.low) + for x in ticks: + if format == unumber and abs(x) < eps: +- output[x] = u"0" ++ output[x] = "0" + else: + output[x] = format(x) + ticks = output +@@ -2834,7 +2834,7 @@ + else: + return ticks, self.compute_logminiticks(self.logbase) + +- elif isinstance(self.miniticks, (int, long)): ++ elif isinstance(self.miniticks, int): + return ticks, self.regular_miniticks(self.miniticks) + + elif getattr(self.miniticks, "__iter__", False): +@@ -2864,9 +2864,9 @@ + if N >= 0: + output = {} + x = self.low +- for i in xrange(N): ++ for i in range(N): + if format == unumber and abs(x) < eps: +- label = u"0" ++ label = "0" + else: + label = format(x) + output[x] = label +@@ -2900,7 +2900,7 @@ + for n in range(int(lowN), int(highN)+1): + x = n * granularity + if format == unumber and abs(x) < eps: +- label = u"0" ++ label = "0" + else: + label = format(x) + trial[x] = label +@@ -2911,7 +2911,7 @@ + return {v1: format(v1), v2: format(v2)} + else: + low_in_ticks, high_in_ticks = False, False +- for t in last_trial.keys(): ++ for t in list(last_trial.keys()): + if 1.*abs(t - self.low)/last_granularity < _epsilon: + low_in_ticks = True + if 1.*abs(t - self.high)/last_granularity < _epsilon: +@@ -2946,7 +2946,7 @@ + """ + output = [] + x = self.low +- for i in xrange(N): ++ for i in range(N): + output.append(x) + x += (self.high - self.low)/(N-1.) + return output +@@ -2958,7 +2958,7 @@ + """ + if len(original_ticks) < 2: + original_ticks = ticks(self.low, self.high) # XXX ticks is undefined! +- original_ticks = original_ticks.keys() ++ original_ticks = list(original_ticks.keys()) + original_ticks.sort() + + if self.low > original_ticks[0] + _epsilon or self.high < original_ticks[-1] - _epsilon: +@@ -2998,9 +2998,9 @@ + if N >= 0: + output = {} + x = self.low +- for i in xrange(N): ++ for i in range(N): + if format == unumber and abs(x) < eps: +- label = u"0" ++ label = "0" + else: + label = format(x) + output[x] = label +@@ -3019,12 +3019,12 @@ + output[x] = label + + for i in range(1, len(output)): +- keys = output.keys() ++ keys = list(output.keys()) + keys.sort() + keys = keys[::i] +- values = map(lambda k: output[k], keys) ++ values = [output[k] for k in keys] + if len(values) <= N: +- for k in output.keys(): ++ for k in list(output.keys()): + if k not in keys: + output[k] = "" + break +@@ -3117,13 +3117,13 @@ + ticks = Ticks.SVG(self, trans) # returns a + + if self.arrow_start != False and self.arrow_start is not None: +- if isinstance(self.arrow_start, basestring): ++ if isinstance(self.arrow_start, str): + func.attr["marker-start"] = "url(#%s)" % self.arrow_start + else: + func.attr["marker-start"] = "url(#%s)" % self.arrow_start.id + + if self.arrow_end != False and self.arrow_end is not None: +- if isinstance(self.arrow_end, basestring): ++ if isinstance(self.arrow_end, str): + func.attr["marker-end"] = "url(#%s)" % self.arrow_end + else: + func.attr["marker-end"] = "url(#%s)" % self.arrow_end.id +@@ -3179,7 +3179,7 @@ + + def interpret(self): + if self.exclude is not None and not (isinstance(self.exclude, (tuple, list)) and len(self.exclude) == 2 and +- isinstance(self.exclude[0], (int, long, float)) and isinstance(self.exclude[1], (int, long, float))): ++ isinstance(self.exclude[0], (int, float)) and isinstance(self.exclude[1], (int, float))): + raise TypeError("exclude must either be None or (low, high)") + + ticks, miniticks = Ticks.interpret(self) +@@ -3187,7 +3187,7 @@ + return ticks, miniticks + + ticks2 = {} +- for loc, label in ticks.items(): ++ for loc, label in list(ticks.items()): + if self.exclude[0] <= loc <= self.exclude[1]: + ticks2[loc] = "" + else: +@@ -3205,13 +3205,13 @@ + self.high = self.end + + if self.arrow_start != False and self.arrow_start is not None: +- if isinstance(self.arrow_start, basestring): ++ if isinstance(self.arrow_start, str): + line.attr["marker-start"] = "url(#%s)" % self.arrow_start + else: + line.attr["marker-start"] = "url(#%s)" % self.arrow_start.id + + if self.arrow_end != False and self.arrow_end is not None: +- if isinstance(self.arrow_end, basestring): ++ if isinstance(self.arrow_end, str): + line.attr["marker-end"] = "url(#%s)" % self.arrow_end + else: + line.attr["marker-end"] = "url(#%s)" % self.arrow_end.id +@@ -3461,7 +3461,7 @@ + self.last_ticks, self.last_miniticks = Ticks.interpret(self) + + ticksd = [] +- for t in self.last_ticks.keys(): ++ for t in list(self.last_ticks.keys()): + ticksd += Line(self.xmin, t, self.xmax, t).Path(trans).d + + miniticksd = [] +@@ -3513,7 +3513,7 @@ + self.last_ticks, self.last_miniticks = Ticks.interpret(self) + + ticksd = [] +- for t in self.last_ticks.keys(): ++ for t in list(self.last_ticks.keys()): + ticksd += Line(t, self.ymin, t, self.ymax).Path(trans).d + + miniticksd = [] +@@ -3568,9 +3568,9 @@ + self.last_yticks, self.last_yminiticks = Ticks.interpret(self) + + ticksd = [] +- for t in self.last_xticks.keys(): ++ for t in list(self.last_xticks.keys()): + ticksd += Line(t, self.ymin, t, self.ymax).Path(trans).d +- for t in self.last_yticks.keys(): ++ for t in list(self.last_yticks.keys()): + ticksd += Line(self.xmin, t, self.xmax, t).Path(trans).d + + miniticksd = [] +@@ -3615,7 +3615,7 @@ + + def SVG(self, trans=None): + """Apply the transformation "trans" and return an SVG object.""" +- if isinstance(trans, basestring): ++ if isinstance(trans, str): + trans = totrans(trans) # only once + + output = SVG("g") +@@ -3665,7 +3665,7 @@ + + def SVG(self, trans=None): + """Apply the transformation "trans" and return an SVG object.""" +- if isinstance(trans, basestring): ++ if isinstance(trans, str): + trans = totrans(trans) # only once + + output = SVG("g") diff --git a/opencv.spec b/opencv.spec new file mode 100644 index 0000000000000000000000000000000000000000..b5d9be2bfa80fc1930246188fa78ed012c18be86 --- /dev/null +++ b/opencv.spec @@ -0,0 +1,1282 @@ +%undefine __cmake_in_source_build +# Tests are disabled with gcc-11 +# See https://bugzilla.redhat.com/1944536 + +%bcond_with tests +%bcond_with ffmpeg +%bcond_without gstreamer +%bcond_with eigen2 +%bcond_without eigen3 +%bcond_without opencl +%ifarch %{ix86} x86_64 %{arm} +%bcond_without openni +%else +# we dont have openni in other archs +%bcond_with openni +%endif +%bcond_without tbb +%bcond_with cuda +%bcond_with xine +# Atlas need (missing: Atlas_CLAPACK_INCLUDE_DIR Atlas_CBLAS_LIBRARY Atlas_BLAS_LIBRARY Atlas_LAPACK_LIBRARY) +# LAPACK may use atlas or openblas since now it detect openblas, atlas is not used anyway, more info please +# check OpenCVFindLAPACK.cmake +%bcond_with atlas +%bcond_without openblas +%bcond_without gdcm +%bcond_without vtk + +%ifarch x86_64 +%bcond_without libmfx +%else +%bcond_with libmfx +%endif +%bcond_without clp +%bcond_without va +%bcond_without java +%bcond_without vulkan + +%define _lto_cflags %{nil} + +%global srcname opencv + +# If _cuda_version is unset +%if 0%{!?_cuda_version:1} && 0%{?with_cuda:1} +%global _cuda_version 11.2 +%global _cuda_rpm_version 11-2 +%global _cuda_prefix /usr/local/cuda-%{_cuda_version} +%bcond_without dnn_cuda +%endif + +Name: opencv +Version: 4.5.2 +%global javaver %(foo=%{version}; echo ${foo//./}) +%global abiver %(foo=%{version}; echo ${foo:0:3}) +Release: 3%{?dist} +Summary: Collection of algorithms for computer vision +# This is normal three clause BSD. +License: BSD +URL: https://opencv.org +# RUN opencv-clean.sh TO PREPARE TARBALLS FOR FEDORA +# +# Need to remove copyrighted lena.jpg images from tarball (rhbz#1295173) +# and SIFT/SURF from tarball, due to legal concerns. +# +Source0: %{name}-clean-%{version}.tar.gz +Source1: %{name}_contrib-clean-%{version}.tar.gz +Source2: %{name}_extra-clean-%{version}.tar.gz +Source3: face_landmark_model.dat.xz +# from https://github.com/opencv/ade/archive/v0.1.1f.zip +Source4: b624b995ec9c439cbc2e9e6ee940d3a2-v0.1.1f.zip +Source5: xorg.conf + +Patch0: opencv-4.1.0-install_3rdparty_licenses.patch +# Patch1: %%{name}-gcc11.patch +Patch2: opencv-py2-to-py3.patch + +BuildRequires: gcc-c++ +BuildRequires: libtool +BuildRequires: cmake >= 2.6.3 +BuildRequires: chrpath +%{?with_cuda: +BuildRequires: cuda-minimal-build-%{?_cuda_rpm_version} +BuildRequires: pkgconfig(cublas-%{?_cuda_version}) +BuildRequires: pkgconfig(cufft-%{?_cuda_version}) +BuildRequires: pkgconfig(nppc-%{?_cuda_version}) +%{?with_dnn_cuda:BuildRequires: libcudnn8-devel} +} +%{?with_eigen2:BuildRequires: eigen2-devel} +%{?with_eigen3:BuildRequires: eigen3-devel} +BuildRequires: libtheora-devel +BuildRequires: libvorbis-devel +%ifnarch s390 s390x +BuildRequires: libraw1394-devel +BuildRequires: libdc1394-devel +%endif +BuildRequires: jasper-devel +BuildRequires: libjpeg-devel +BuildRequires: libpng-devel +BuildRequires: libtiff-devel +BuildRequires: libGL-devel +BuildRequires: libv4l-devel +BuildRequires: OpenEXR-devel +%{?with_openni: +BuildRequires: openni-devel +BuildRequires: openni-primesense +} +%{?with_tbb: +BuildRequires: tbb-devel +} +BuildRequires: zlib-devel +BuildRequires: pkgconfig +BuildRequires: python3-devel +BuildRequires: python3-numpy +BuildRequires: pylint +BuildRequires: python3-flake8 +BuildRequires: swig >= 1.3.24 +%{?with_ffmpeg:BuildRequires: ffmpeg-devel >= 0.4.9} +%{?with_gstreamer:BuildRequires: gstreamer1-devel gstreamer1-plugins-base-devel} +%{?with_xine:BuildRequires: xine-lib-devel} +%{?with_opencl:BuildRequires: opencl-headers} +BuildRequires: libgphoto2-devel +BuildRequires: libwebp-devel +BuildRequires: tesseract-devel +BuildRequires: protobuf-devel +BuildRequires: gdal-devel +BuildRequires: glog-devel +#BuildRequires: doxygen +BuildRequires: python3-beautifulsoup4 +#for doc/doxygen/bib2xhtml.pl +#BuildRequires: perl-open +BuildRequires: gflags-devel +BuildRequires: libucil-devel +BuildRequires: qt5-qtbase-devel +BuildRequires: libGL-devel +BuildRequires: libGLU-devel +BuildRequires: hdf5-devel +BuildRequires: openjpeg2-devel +# Module opencv_ovis disabled because of incompatible OGRE3D version < 1.10 +# BuildRequires: ogre-devel +%{?with_vtk:BuildRequires: vtk-devel vtk-java vtk-qt} +%{?with_atlas:BuildRequires: atlas-devel} +#ceres-solver-devel push eigen3-devel and tbb-devel +%{?with_tbb: + %{?with_eigen3: +BuildRequires: ceres-solver-devel + } +} +%{?with_openblas: +BuildRequires: openblas-devel +BuildRequires: blas-devel +BuildRequires: lapack-devel +} +%{?with_gdcm:BuildRequires: gdcm-devel} +%{?with_libmfx:BuildRequires: libmfx-devel} +%{?with_clp:BuildRequires: coin-or-Clp-devel} +%{?with_va:BuildRequires: libva-devel} +%{?with_java: +BuildRequires: ant +BuildRequires: java-devel +} +%{?with_vulkan:BuildRequires: vulkan-headers} +%if %{with tests} +BuildRequires: xorg-x11-drv-dummy +BuildRequires: mesa-dri-drivers +%endif + +Requires: opencv-core%{_isa} = %{version}-%{release} + +%description +OpenCV means Intel® Open Source Computer Vision Library. It is a collection of +C functions and a few C++ classes that implement some popular Image Processing +and Computer Vision algorithms. + + +%package core +Summary: OpenCV core libraries +Provides: bundled(quirc) = 1.0 +Obsoletes: python2-%{name} < %{version}-%{release} + +%description core +This package contains the OpenCV C/C++ core libraries. + + +%package devel +Summary: Development files for using the OpenCV library +Requires: %{name}%{_isa} = %{version}-%{release} +Requires: %{name}-contrib%{_isa} = %{version}-%{release} + +%description devel +This package contains the OpenCV C/C++ library and header files, as well as +documentation. It should be installed if you want to develop programs that +will use the OpenCV library. You should consider installing opencv-doc +package. + + +%package doc +Summary: Documentation files +Requires: opencv-devel = %{version}-%{release} +BuildArch: noarch +Provides: %{name}-devel-docs = %{version}-%{release} +Obsoletes: %{name}-devel-docs < %{version}-%{release} + +%description doc +This package contains the OpenCV documentation, samples and examples programs. + + +%package -n python3-opencv +Summary: Python3 bindings for apps which use OpenCV +Requires: opencv%{_isa} = %{version}-%{release} +Requires: python3-numpy +%{?python_provide:%python_provide python3-%{srcname}} + +%description -n python3-opencv +This package contains Python3 bindings for the OpenCV library. + + +%package java +Summary: Java bindings for apps which use OpenCV +Requires: java-headless +Requires: javapackages-filesystem +Requires: %{name}-core%{_isa} = %{version}-%{release} + +%description java +This package contains Java bindings for the OpenCV library. + + +%package contrib +Summary: OpenCV contributed functionality + +%description contrib +This package is intended for development of so-called "extra" modules, contributed +functionality. New modules quite often do not have stable API, and they are not +well-tested. Thus, they shouldn't be released as a part of official OpenCV +distribution, since the library maintains binary compatibility, and tries +to provide decent performance and stability. + +%prep +%setup -q -a1 -a2 +%if 1 +# we don't use pre-built contribs except quirc +pushd 3rdparty +shopt -s extglob +rm -r !(openexr|openvx|quirc) +shopt -u extglob +popd &>/dev/null +%endif + +%patch0 -p1 -b .install_3rdparty_licenses +# %%patch1 -p1 -b .gcc11 +%patch2 -p1 + +pushd %{name}_contrib-%{version} +popd + +# Install face_landmark_model +mkdir -p .cache/data +install -pm 0644 %{SOURCE3} .cache/data +pushd .cache/data + xz -d face_landmark_model.dat.xz +popd + +# Install ADE, needed for opencv_gapi +mkdir -p .cache/ade +install -pm 0644 %{SOURCE4} .cache/ade/ + + +%build +# enabled by default if libraries are presents at build time: +# GTK, GSTREAMER, 1394, V4L, eigen3 +# non available on Fedora: FFMPEG, XINE +# disabling IPP because it is closed source library from intel +# CXXFLAGS="-std=c++11" +# export +%cmake \ + -DCMAKE_CXX_FLAGS="$CXXFLAGS -std=c++11" \ + -DCV_TRACE=OFF \ + -DWITH_IPP=OFF \ + -DWITH_ITT=OFF \ + -DWITH_QT=ON \ + -DWITH_OPENGL=ON \ +%if ! %{with tests} + -DBUILD_TESTS=OFF \ +%endif + -DOpenGL_GL_PREFERENCE=GLVND \ + -DWITH_GDAL=ON \ + -DWITH_OPENEXR=ON \ + -DWITH_UNICAP=ON \ + -DCMAKE_SKIP_RPATH=ON \ + -DWITH_CAROTENE=OFF \ +%ifarch x86_64 %{ix86} + -DCPU_BASELINE=SSE2 \ +%endif + -DENABLE_PRECOMPILED_HEADERS=OFF \ + -DCMAKE_BUILD_TYPE=ReleaseWithDebInfo \ + %{?with_java: -DBUILD_opencv_java=ON \ + -DOPENCV_JAR_INSTALL_PATH=%{_jnidir} } \ + %{!?with_java: -DBUILD_opencv_java=OFF } \ + %{?with_tbb: -DWITH_TBB=ON } \ + %{!?with_gstreamer: -DWITH_GSTREAMER=OFF } \ + %{!?with_ffmpeg: -DWITH_FFMPEG=OFF } \ + %{?with_cuda: \ + -DWITH_CUDA=ON \ + -DCUDA_TOOLKIT_ROOT_DIR=%{?_cuda_prefix} \ + -DCUDA_VERBOSE_BUILD=ON \ + -DCUDA_PROPAGATE_HOST_FLAGS=OFF \ + -DCUDA_NVCC_FLAGS="-Xcompiler -fPIC" \ + %{?with_dnn_cuda:-DOPENCV_DNN_CUDA=ON} \ + } \ + %{?with_openni: -DWITH_OPENNI=ON } \ + %{!?with_xine: -DWITH_XINE=OFF } \ + -DBUILD_DOCS=ON \ + -DBUILD_EXAMPLES=ON \ + -DBUILD_opencv_python2=OFF \ + -DINSTALL_C_EXAMPLES=ON \ + -DINSTALL_PYTHON_EXAMPLES=ON \ + -DPYTHON3_EXECUTABLE=%{__python3} \ + -DPYTHON3_PACKAGES_PATH=%{python3_sitearch} \ + -DENABLE_PYLINT=ON \ + -DBUILD_PROTOBUF=OFF \ + -DPROTOBUF_UPDATE_FILES=ON \ +%{?with_opencl: -DOPENCL_INCLUDE_DIR=%{_includedir}/CL } \ +%{!?with_opencl: -DWITH_OPENCL=OFF } \ + -DOPENCV_SKIP_PYTHON_LOADER=ON \ + -DOPENCV_EXTRA_MODULES_PATH=opencv_contrib-%{version}/modules \ + -DWITH_LIBV4L=ON \ + -DWITH_OPENMP=ON \ + -DOPENCV_CONFIG_INSTALL_PATH=%{_lib}/cmake/OpenCV \ + -DOPENCV_GENERATE_PKGCONFIG=ON \ + %{?with_gdcm: -DWITH_GDCM=ON } \ + %{?with_libmfx: -DWITH_MFX=ON } \ + %{?with_clp: -DWITH_CLP=ON } \ + %{?with_va: -DWITH_VA=ON } \ + %{!?with_vtk: -DWITH_VTK=OFF} \ + %{?with_vulkan: -DWITH_VULKAN=ON -DVULKAN_INCLUDE_DIRS=%{_includedir}/vulkan } \ + +%cmake_build + + +%install +%cmake_install + +rm -rf %{buildroot}%{_datadir}/OpenCV/licenses/ +%if %{with java} +ln -s -r %{buildroot}%{_jnidir}/libopencv_java%{javaver}.so %{buildroot}%{_jnidir}/libopencv_java.so +ln -s -r %{buildroot}%{_jnidir}/opencv-%{javaver}.jar %{buildroot}%{_jnidir}/opencv.jar +%endif + +# For compatibility with existing opencv.pc application +%{!?without_compat_openvc_pc: + ln -s opencv4.pc %{buildroot}%{_libdir}/pkgconfig/opencv.pc +} + + +%check +# Check fails since we don't support most video +# read/write capability and we don't provide a display +# ARGS=-V increases output verbosity +#ifnarch ppc64 +%if %{with tests} + cp %SOURCE5 . + if [ -x /usr/libexec/Xorg ]; then + Xorg=/usr/libexec/Xorg + else + Xorg=/usr/libexec/Xorg.bin + fi + $Xorg -noreset +extension GLX +extension RANDR +extension RENDER -logfile ./xorg.log -config ./xorg.conf -configdir . :99 & + export DISPLAY=:99 + LD_LIBRARY_PATH=%{_builddir}/%{name}-%{version}/build/lib:$LD_LIBARY_PATH %ctest || : +%endif +#endif + + +%ldconfig_scriptlets core + +%ldconfig_scriptlets contrib + +%ldconfig_scriptlets java + +%files +%doc README.md +%{_bindir}/opencv_* +%dir %{_datadir}/opencv4 +%{_datadir}/opencv4/haarcascades +%{_datadir}/opencv4/lbpcascades +%{_datadir}/opencv4/valgrind* +%{_datadir}/opencv4/quality + +%files core +%license LICENSE +%{_datadir}/licenses/opencv4/ +%{_libdir}/libopencv_calib3d.so.%{abiver}* +%{_libdir}/libopencv_core.so.%{abiver}* +%{_libdir}/libopencv_dnn.so.%{abiver}* +%{_libdir}/libopencv_features2d.so.%{abiver}* +%{_libdir}/libopencv_flann.so.%{abiver}* +%{_libdir}/libopencv_gapi.so.%{abiver}* +%{_libdir}/libopencv_highgui.so.%{abiver}* +%{_libdir}/libopencv_imgcodecs.so.%{abiver}* +%{_libdir}/libopencv_imgproc.so.%{abiver}* +%{_libdir}/libopencv_ml.so.%{abiver}* +%{_libdir}/libopencv_objdetect.so.%{abiver}* +%{_libdir}/libopencv_photo.so.%{abiver}* +%{_libdir}/libopencv_stitching.so.%{abiver}* +%{_libdir}/libopencv_video.so.%{abiver}* +%{_libdir}/libopencv_videoio.so.%{abiver}* + +%files devel +%dir %{_includedir}/opencv4 +%{_includedir}/opencv4/opencv2 +%{_libdir}/lib*.so +%{!?without_compat_openvc_pc: +%{_libdir}/pkgconfig/opencv.pc +} +%{_libdir}/pkgconfig/opencv4.pc +%{_libdir}/cmake/OpenCV/*.cmake + +%files doc +%{_datadir}/opencv4/samples + +%files -n python3-opencv +%exclude %{_bindir}/setup_vars_opencv4.sh +%{python3_sitearch}/cv2.cpython-3*.so + +%if %{with java} +%files java +%{_jnidir}/libopencv_java%{javaver}.so +%{_jnidir}/opencv-%{javaver}.jar +%{_jnidir}/libopencv_java.so +%{_jnidir}/opencv.jar +%endif + +%files contrib +%{_libdir}/libopencv_alphamat.so.%{abiver}* +%{_libdir}/libopencv_aruco.so.%{abiver}* +%{_libdir}/libopencv_bgsegm.so.%{abiver}* +%{_libdir}/libopencv_bioinspired.so.%{abiver}* +%{_libdir}/libopencv_ccalib.so.%{abiver}* +%{?with_cuda: +%{_libdir}/libopencv_cuda*.so.%{abiver}* +%{_libdir}/libopencv_cudev.so.%{abiver}* +} +%{_libdir}/libopencv_cvv.so.%{abiver}* +%{_libdir}/libopencv_datasets.so.%{abiver}* +%{_libdir}/libopencv_dnn_objdetect.so.%{abiver}* +%{_libdir}/libopencv_dnn_superres.so.%{abiver}* +%{_libdir}/libopencv_dpm.so.%{abiver}* +%{_libdir}/libopencv_face.so.%{abiver}* +%{_libdir}/libopencv_freetype.so.%{abiver}* +%{_libdir}/libopencv_fuzzy.so.%{abiver}* +%{_libdir}/libopencv_hdf.so.%{abiver}* +%{_libdir}/libopencv_hfs.so.%{abiver}* +%{_libdir}/libopencv_img_hash.so.%{abiver}* +%{_libdir}/libopencv_intensity_transform.so.%{abiver}* +%{_libdir}/libopencv_line_descriptor.so.%{abiver}* +%{_libdir}/libopencv_mcc.so.%{abiver}* +%{_libdir}/libopencv_optflow.so.%{abiver}* +%{_libdir}/libopencv_phase_unwrapping.so.%{abiver}* +%{_libdir}/libopencv_plot.so.%{abiver}* +%{_libdir}/libopencv_quality.so.%{abiver}* +%{_libdir}/libopencv_rapid.so.%{abiver}* +%{_libdir}/libopencv_reg.so.%{abiver}* +%{_libdir}/libopencv_rgbd.so.%{abiver}* +%{_libdir}/libopencv_saliency.so.%{abiver}* +%{_libdir}/libopencv_shape.so.%{abiver}* +%{_libdir}/libopencv_stereo.so.%{abiver}* +%{_libdir}/libopencv_structured_light.so.%{abiver}* +%{_libdir}/libopencv_superres.so.%{abiver}* +%{_libdir}/libopencv_surface_matching.so.%{abiver}* +%{_libdir}/libopencv_text.so.%{abiver}* +%{_libdir}/libopencv_tracking.so.%{abiver}* +%{_libdir}/libopencv_videostab.so.%{abiver}* +%if %{with vtk} +%{_libdir}/libopencv_viz.so.%{abiver}* +%endif +%{_libdir}/libopencv_wechat_qrcode.so.%{abiver}* +%{_libdir}/libopencv_ximgproc.so.%{abiver}* +%{_libdir}/libopencv_xobjdetect.so.%{abiver}* +%{_libdir}/libopencv_xphoto.so.%{abiver}* + +%changelog +* Tue Sep 14 2021 Wang Haitao - 4.5.2-3 +- port from fedora 34 +- add py2 to py3 patch +- delete opencv-extra-data, and test path + +* Sat Jun 19 2021 Jiri Kucera - 4.5.2-2 +- Rebuild for gdal & vtk + +* Sat Apr 03 2021 Nicolas Chauvet - 4.5.2-1 +- Update to 4.5.2 + +* Wed Mar 31 2021 Nicolas Chauvet - 4.5.1-8 +- Disable tests for now + +* Tue Mar 30 2021 Jonathan Wakely - 4.5.1-7 +- Rebuilt for removed libstdc++ symbol (#1937698) + +* Wed Feb 10 2021 Jiri Kucera - 4.5.1-6 +- Fix file lists + Based on comparison of `opencv-4.5.1/modules/` and + `opencv-4.5.1/opencv_contrib-4.5.1/modules/`, move some *.so's between core + and contrib rpms + +* Sun Jan 31 2021 Orion Poplawski - 4.5.1-5 +- Rebuild for VTK 9 + +* Wed Jan 27 2021 Tomas Popela - 4.5.1-4 +- Drop unused BR on SFML and disable VTK support on RHEL 8+ + +* Tue Jan 26 2021 Fedora Release Engineering - 4.5.1-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Tue Jan 12 14:20:57 CET 2021 Adrian Reber - 4.5.1-2 +- Rebuilt for protobuf 3.14 + +* Sat Jan 02 2021 Sérgio Basto - 4.5.1-1 +- Update to 4.5.1 + +* Fri Jan 01 2021 Richard Shaw - 4.5.0-4 +- Rebuild for OpenEXR 2.5.3. + +* Sat Dec 5 2020 Jeff Law - 4.5.0-3 +- Fix missing #include for gcc-11 + +* Fri Nov 6 22:47:45 CET 2020 Sandro Mani - 4.5.0-2 +- Rebuild (proj, gdal) + +* Thu Oct 15 2020 Sérgio Basto - 4.5.0-1 +- Update 4.5.0 + +* Wed Oct 07 2020 Sérgio Basto - 4.4.0-1 +- Update 4.4.0 +- opencv_vulkan.patch already applied in upstream + +* Thu Sep 24 2020 Adrian Reber - 4.3.0-9 +- Rebuilt for protobuf 3.13 + +* Fri Jul 24 2020 Nicolas Chauvet - 4.3.0-8 +- Rebuilt +- Fix cmake build +- Disable LTO on ppc64le +- Add undefine __cmake_in_source_build to allow build on Fedora < 33 + +* Sat Jul 11 2020 Jiri Vanek - 4.3.0-7 +- Rebuilt for JDK-11, see https://fedoraproject.org/wiki/Changes/Java11 + +* Fri Jun 26 2020 Orion Poplawski - 4.3.0-6 +- Rebuild for hdf5 1.10.6 + +* Tue Jun 23 2020 Adrian Reber - 4.3.0-5 +- Rebuilt for protobuf 3.12 + +* Sun Jun 21 2020 Sérgio Basto - 4.3.0-4 +- Readd flake8 build requirement +- Fix build because pangox has been retired for F33 so we need remove the BR + gtkglext +- Also remove all gtk stuff (we have to choose between gtk or qt when build opencv) + https://answers.opencv.org/question/215066/gtk-or-qt-when-build-opencv/ +- Doxygen requires gtk2, disabling for now + +* Sun Jun 14 2020 Adrian Reber +- Rebuilt for protobuf 3.12 + +* Tue Jun 02 2020 Orion Poplawski - 4.3.0-3 +- Run tests + +* Tue Jun 02 2020 Orion Poplawski - 4.3.0-2 +- Add upstream patches for VTK 9.0 support (bz#1840977) + +* Thu May 28 2020 Nicolas Chauvet - 4.3.0-1 +- Update to 4.3.0 + +* Thu May 28 2020 Charalampos Stratakis - 4.2.0-9 +- Remove flake8 build requirement + +* Tue May 26 2020 Miro Hrončok - 4.2.0-8 +- Rebuilt for Python 3.9 + +* Thu May 21 2020 Sandro Mani - 4.2.0-7 +- Rebuild (gdal) + +* Fri May 08 2020 Nicolas Chauvet - 4.2.0-6 +- Drop compat symlink for includes - rhbz#1830266 + +* Thu Mar 26 2020 Nicolas Chauvet - 4.2.0-5 +- Add without_compat_opencv_pc with conditional - rhbz#1816439 + +* Tue Mar 03 2020 Sandro Mani - 4.2.0-4 +- Rebuild (gdal) + +* Wed Jan 29 2020 Fedora Release Engineering - 4.2.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Wed Jan 29 2020 Nicolas Chauvet - 4.2.0-2 +- Backport patch for ppc64le + +* Tue Dec 31 2019 Nicolas Chauvet - 4.2.0-1 +- Update to 4.2.0 + +* Sat Dec 28 2019 Sandro Mani - 4.1.2-3 +- Rebuild (tesseract) + +* Thu Dec 19 2019 Orion Poplawski - 4.1.2-2 +- Rebuild for protobuf 3.11 + +* Thu Oct 17 2019 Nicolas Chauvet - 4.1.2-1.1 +- Fix include path +- Drop CPU baseline to SSE2 for x86 +- Add missing directory ownership +- Add symlinks for compatibility with older versions +- Restore deprecated headers for compat + +* Sat Oct 12 2019 Nicolas Chauvet - 4.1.2-1 +- Update to 4.1.2 + +* Fri Sep 13 2019 Nicolas Chauvet - 4.1.1-1 +- Update to 4.1.1 + +* Fri Sep 13 2019 Sérgio Basto - 4.1.0-1 +- Update opencv to 4.1.0 + +* Fri Sep 13 2019 Christopher N. Hesse - 4.1.0-0 +- Enable vulkan compute backend + +* Fri Sep 13 2019 Sérgio Basto - 3.4.6-9 +- Reenable pylint and vtk, they are working now. +* Wed Sep 11 2019 Mamoru TASAKA - 3.4.6-8 +- F-32: remove vtk gcdm dependency for now because they have broken dependency + (bug 1751406) + +* Mon Aug 19 2019 Miro Hrončok - 3.4.6-7 +- Rebuilt for Python 3.8 + +* Thu Jul 25 2019 Fedora Release Engineering - 3.4.6-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Thu Jun 27 2019 Jerry James - 3.4.6-5 +- Rebuild for coin-or package updates + +* Tue Jun 25 2019 Sérgio Basto - 3.4.6-4 +- cmake: use relative PATH on OPENCV_CONFIG_INSTALL_PATH, fixes rhbz #1721876 +- cmake: don't set ENABLE_PKG_CONFIG + +* Wed Jun 12 2019 Sérgio Basto - 3.4.6-3 +- Remove Obsoletes/Provides libopencv_java.so and use OPENCV_JAR_INSTALL_PATH + +* Sun Jun 09 2019 Sérgio Basto - 3.4.6-2 +- Fix cmakes location +- add BR: python3-beautifulsoup4 + +* Thu May 23 2019 Sérgio Basto - 3.4.6-1 +- Update to 3.4.6 + +* Mon May 20 2019 Sérgio Basto - 3.4.4-10 +- Try improve Java Bindings + +* Sun May 12 2019 Sérgio Basto - 3.4.4-9 +- Enable Java Bindings (contribution of Ian Wallace) +- Obsoletes python2-opencv to fix upgrade path + +* Wed Apr 10 2019 Richard Shaw - 3.4.4-8 +- Rebuild for OpenEXR 2.3.0. + +* Mon Mar 18 2019 Orion Poplawski +- Rebuild for vtk 8.2 + +* Sun Mar 03 2019 Sérgio Basto - 3.4.4-6 +- Reenable build with gdcm +- Opencl is fixed for ppc64le on F30 + +* Thu Feb 21 2019 Josef Ridky - 3.4.4-5 +- build without gdcm to fix FTBFS in F30+ (#1676289) + +* Fri Feb 01 2019 Fedora Release Engineering - 3.4.4-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Tue Jan 15 2019 Miro Hrončok - 3.4.4-3 +- Subpackage python2-opencv has been removed + See https://fedoraproject.org/wiki/Changes/Mass_Python_2_Package_Removal + +* Mon Dec 03 2018 Sérgio Basto - 3.4.4-2 +- Add the correct and upstreamed fix for support_YV12_too, pull request 13351 + which is merged + +* Sat Dec 01 2018 Sérgio Basto - 3.4.4-1 +- Update to 3.4.4 + +* Wed Nov 21 2018 Igor Gnatenko - 3.4.3-7 +- Rebuild for protobuf 3.6 + +* Tue Nov 13 2018 Sandro Mani - 3.4.3-6 +- Rebuild (tesseract) + +* Tue Oct 30 2018 Sérgio Basto - 3.4.3-5 +- Enable vtk should work with vtk-8.1.1 +- Add BR python Flake8 + +* Tue Oct 23 2018 Felix Kaechele - 3.4.3-4 +- enable building of dnn + +* Sat Oct 13 2018 Jerry James - 3.4.3-3 +- Rebuild for tbb 2019_U1 + +* Sun Sep 30 2018 Sérgio Basto - 3.4.3-2 +- Use GLVND libraries for OpenGL and GLX, setting OpenGL_GL_PREFERENCE=GLVND + +* Wed Sep 26 2018 Sérgio Basto - 3.4.3-1 +- Update to 3.4.3 +- Fix build on arm and s390x + +* Wed Sep 26 2018 Sérgio Basto - 3.4.2-1 +- Update to 3.4.2 + +* Fri Jul 13 2018 Fedora Release Engineering - 3.4.1-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Wed Jul 11 2018 Sérgio Basto - 3.4.1-5 +- Small fix to build with Pyhton-3.7 + +* Tue Jun 19 2018 Miro Hrončok - 3.4.1-4 +- Rebuilt for Python 3.7 + +* Mon Mar 26 2018 Iryna Shcherbina - 3.4.1-3 +- Update Python 2 dependency declarations to new packaging standards + (See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3) + +* Thu Mar 08 2018 Sérgio Basto - 3.4.1-2 +- Enable VA +- Do not use -f on rm because it silences errors +- Opencv sub-package don't need ldconfig because don't have any so + +* Thu Mar 01 2018 Josef Ridky - 3.4.1-1 +- Spec clean up (remove Group tag, add ldconfig scriptlets, escape macros in comments) +- Remove unused patch +- Add gcc and gcc-c++ requirements +- Rebase to version 3.4.1 + +* Sun Feb 18 2018 Sérgio Basto - 3.3.1-7 +- Rebuild for gdcm-2.8 + +* Fri Feb 09 2018 Igor Gnatenko - 3.3.1-6 +- Escape macros in %%changelog + +* Thu Feb 08 2018 Fedora Release Engineering - 3.3.1-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Fri Jan 26 2018 Sérgio Basto - 3.3.1-4 +- Enable Pylint +- Enable Clp (COIN-OR Linear Program Solver) +- Enable VA (Video Acceleration API for Linux) +- Enable OpenMP +- Provides and obsoletes for opencv-devel-docs +- BuildRequires perl-local do generate documentation without errors + +* Thu Jan 25 2018 Sérgio Basto - 3.3.1-3 +- Rename sub-package opencv-python3 to python3-opencv and other minor fixes in + python packaging +- Generate documentation +- Rename sub-package devel-docs to doc +- Cleanup some comments from opencv 2.4 packaging + +* Wed Jan 24 2018 Troy Dawson - 3.3.1-2 +- Update conditionals + +* Tue Nov 14 2017 Sérgio Basto - 3.3.1-1 +- Update to 3.3.1 +- Fix WARNING: Option ENABLE_SSE='OFF' is deprecated and should not be used anymore +- Behaviour of this option is not backward compatible +- Refer to 'CPU_BASELINE'/'CPU_DISPATCH' CMake options documentation +- Fix WARNING: Option ENABLE_SSE2='OFF' is deprecated and should not be used anymore +- Behaviour of this option is not backward compatible +- Refer to 'CPU_BASELINE'/'CPU_DISPATCH' CMake options documentation +- Update opencv to 3.3.0 +- Patch3 is already in source code +- Fix WARNING: Option ENABLE_SSE3='OFF' is deprecated and should not be used anymore +- Enable openblas +- Add conditonal to build with_gdcm +- Disable "Intel ITT support" because source is in 3rdparty/ directory + +* Sat Oct 28 2017 Sérgio Basto - 3.2.0-13 +- Require python3-numpy instead numpy for opencv-python3 (#1504555) + +* Sat Sep 02 2017 Sérgio Basto - 3.2.0-12 +- Fix 2 rpmlint errors + +* Sat Sep 02 2017 Sérgio Basto - 3.2.0-11 +- Enable libv4l1 to fix open a video (#1487816) + +* Mon Aug 28 2017 Sérgio Basto - 3.2.0-10 +- Better conditionals to enable openni only available in ix86, x86_64 and arm + +* Sun Aug 20 2017 Sérgio Basto - 3.2.0-9 +- Enable openni. +- Enable eigen3 except in ppc64le because fails to build in OpenCL headers. +- Documented why is not enabled atlas, openblas and vtk. + +* Sun Aug 20 2017 Sérgio Basto - 3.2.0-8 +- Reenable gstreamer +- Remove architecture checks for tbb and enable it, inspired on (#1262788) + +* Sun Aug 20 2017 Zbigniew Jędrzejewski-Szmek - 3.2.0-7 +- Add Provides for the old name without %%_isa + +* Sat Aug 19 2017 Zbigniew Jędrzejewski-Szmek - 3.2.0-6 +- Python 2 binary package renamed to python2-opencv + See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3 + +* Thu Aug 03 2017 Fedora Release Engineering - 3.2.0-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Thu Jul 27 2017 Fedora Release Engineering - 3.2.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Tue Jun 13 2017 Orion Poplawski - 3.2.0-3 +- Rebuild for protobuf 3.3.1 + +* Mon May 15 2017 Fedora Release Engineering - 3.2.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_27_Mass_Rebuild + +* Mon Feb 27 2017 Josef Ridky - 3.2.0-1 +- Rebase to the latest version (3.2.0) - #1408880 +- Remove unused BuildRequires and patches +- Remove copyrighted lena.jpg images and SIFT/SURF from tarball, due to legal concerns. +- Disable dnn module from opencv_contrib, due missing BuildRequired package in Fedora (protobuf-cpp) +- Disable tracking module from opencv_contrib, due disabling dnn module (is required by this module) +- Disable CAROTENE in compilation (caused error on arm and ppc64le) +- Fix syntax error in opencv_contrib test file (opencv-3.2.0-test-file-fix.patch) + +* Tue Feb 21 2017 Sandro Mani - 3.1.0-15 +- Rebuild (tesseract) + +* Sat Feb 11 2017 Fedora Release Engineering - 3.1.0-14 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Wed Feb 01 2017 Sandro Mani - 3.1.0-13 +- Rebuild (libwebp) + +* Thu Jan 26 2017 Orion Poplawski - 3.1.0-12 +- Rebuild for protobuf 3.2.0 + +* Mon Dec 19 2016 Miro Hrončok - 3.1.0-11 +- Rebuild for Python 3.6 + +* Sat Dec 03 2016 Rex Dieter - 3.1.0-10 +- rebuild (jasper) + +* Sat Nov 19 2016 Orion Poplawski - 3.1.0-9 +- Rebuild for protobuf 3.1.0 + +* Tue Jul 26 2016 Nicolas Chauvet - 3.1.0-8 +- Clean uneeded symbols until fixed upstream + +* Tue Jul 19 2016 Fedora Release Engineering - 3.1.0-7 +- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages + +* Fri May 27 2016 Till Maas - 3.1.0-6 +- Define %%srcname for python subpackages +- Fix whitespace + +* Mon May 09 2016 Sérgio Basto - 3.1.0-5 +- Don't clean unneeded symbols (as recommended by fedora-review), fix undefined + symbol: cvLoadImage in Unknown on line 0 on php-facedetect package. + +* Sat May 07 2016 Sérgio Basto - 3.1.0-4 +- Put all idefs and ifarchs outside the scope of rpm conditional builds, rather + than vice versa, as had organized some time ago, it seems to me more correct. +- Remove SIFT/SURF from source tarball in opencv_contrib, due to legal concerns +- Redo and readd OpenCV-2.4.4-pillow.patch . +- Add OpenCV-3.1-pillow.patch to apply only opencv_contrib . +- Add the %%python_provide macro (Packaging:Python guidelines). + +* Fri Apr 22 2016 Sérgio Basto - 3.1.0-3 +- Use always ON and OFF instead 0 and 1 in cmake command. +- Remove BUILD_TEST and TBB_LIB_DIR variables not used by cmake. +- Add BRs: tesseract-devel, protobuf-devel, glog-devel, doxygen, + gflags-devel, SFML-devel, libucil-devel, qt5-qtbase-devel, mesa-libGL-devel, + mesa-libGLU-devel and hdf5-devel. +- Remove BR: vtk-devel because VTK support is disabled. Incompatible + combination: OpenCV + Qt5 and VTK ver.6.2.0 + Qt4 +- Enable build with Qt5. +- Enable build with OpenGL. +- Enable build with UniCap. +- Also requires opencv-contrib when install opencv-devel (#1329790). + +* Wed Apr 20 2016 Sérgio Basto - 3.1.0-2 +- Add BR:libwebp-devel . +- Merge from 2.4.12.3 package: + Add aarch64 and ppc64le to list of architectures where TBB is supported (#1262788). + Use bcond tags to easily enable or disable modules. + Fix unused-direct-shlib-dependency in cmake with global optflags. + Added README.md with references to online documentation. + Investigation on the documentation, added a few notes. +- Update to 3.1.0 (Fri Mar 25 2016 Pavel Kajaba - 3.1.0-1) +- Added opencv_contrib (Thu Jul 09 2015 Sérgio Basto - + 3.0.0-2) +- Update to 3.0.0 (Fri Jun 05 2015 Jozef Mlich - 3.0.0-1) + +* Tue Mar 01 2016 Yaakov Selkowitz - 2.4.12.3-3 +- Fix FTBFS with GCC 6 (#1307821) + +* Thu Feb 04 2016 Fedora Release Engineering - 2.4.12.3-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Wed Dec 02 2015 Sérgio Basto - 2.4.12.3-1 +- Update opencv to 2.4.12.3 (#1271460). +- Add aarch64 and ppc64le to list of architectures where TBB is supported (#1262788). + +* Tue Jul 14 2015 Sérgio Basto - 2.4.11-5 +- Use bcond tags to easily enable or disable modules. +- Package review, more cleaning in the spec file. +- Fixed unused-direct-shlib-dependency in cmake with global optflags. +- Added README.md index.rst with references to online documentation. +- Investigation on the documentation, added a few notes. + +* Mon Jul 06 2015 Sérgio Basto - 2.4.11-4 +- Enable-gpu-module, rhbz #1236417, thanks to Rich Mattes. +- Deleted the global gst1 because it is no longer needed. + +* Thu Jun 25 2015 Sérgio Basto - 2.4.11-3 +- Fix license tag + +* Wed Jun 17 2015 Fedora Release Engineering - 2.4.11-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Mon May 11 2015 Sérgio Basto - 2.4.11-1 +- Update to 2.4.11 . +- Dropped patches 0, 10, 11, 12, 13 and 14 . + +* Sat Apr 11 2015 Rex Dieter 2.4.9-6 +- rebuild (gcc5) + +* Mon Feb 23 2015 Rex Dieter 2.4.9-5 +- rebuild (gcc5) + +* Tue Nov 25 2014 Rex Dieter 2.4.9-4 +- rebuild (openexr) + +* Sun Aug 17 2014 Fedora Release Engineering - 2.4.9-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Fri Jul 25 2014 Rex Dieter 2.4.9-2 +- backport support for GStreamer 1 (#1123078) + +* Thu Jul 03 2014 Nicolas Chauvet - 2.4.9-1 +- Update to 2.4.9 + +* Sat Jun 07 2014 Fedora Release Engineering - 2.4.7-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Sat Apr 26 2014 Rex Dieter 2.4.7-6 +- revert pkgcmake2 patch (#1070428) + +* Fri Jan 17 2014 Nicolas Chauvet - 2.4.7-5 +- Fix opencv_ocl isn't part of -core + +* Thu Jan 16 2014 Christopher Meng - 2.4.7-4 +- Enable OpenCL support. +- SPEC small cleanup. + +* Wed Nov 27 2013 Rex Dieter 2.4.7-3 +- rebuild (openexr) + +* Mon Nov 18 2013 Rex Dieter 2.4.7-2 +- OpenCV cmake configuration broken (#1031312) + +* Wed Nov 13 2013 Nicolas Chauvet - 2.4.7-1 +- Update to 2.4.7 + +* Sun Sep 08 2013 Rex Dieter 2.4.6.1-2 +- rebuild (openexr) + +* Wed Jul 24 2013 Nicolas Chauvet - 2.4.6.1-1 +- Update to 2.4.6.1 + +* Thu May 23 2013 Nicolas Chauvet - 2.4.5-1 +- Update to 2.4.5-clean +- Spec file clean-up +- Split core libraries into a sub-package + +* Sat May 11 2013 François Cami - 2.4.4-3 +- change project URL. + +* Tue Apr 02 2013 Tom Callaway - 2.4.4-2 +- make clean source without SIFT/SURF + +* Sat Mar 23 2013 Nicolas Chauvet - 2.4.4-1 +- Update to 2.4.4a +- Fix tbb-devel architecture conditionals + +* Sun Mar 10 2013 Rex Dieter 2.4.4-0.2.beta +- rebuild (OpenEXR) + +* Mon Feb 18 2013 Nicolas Chauvet - 2.4.4-0.1.beta +- Update to 2.4.4 beta +- Drop python-imaging also from requires +- Drop merged patch for additionals codecs +- Disable the java binding for now (untested) + +* Fri Jan 25 2013 Honza Horak - 2.4.3-7 +- Do not build with 1394 libs in rhel + +* Mon Jan 21 2013 Adam Tkac - 2.4.3-6 +- rebuild due to "jpeg8-ABI" feature drop + +* Sun Jan 20 2013 Nicolas Chauvet - 2.4.3-5 +- Add more FourCC for gstreamer - rhbz#812628 +- Allow to use python-pillow - rhbz#895767 + +* Mon Nov 12 2012 Nicolas Chauvet - 2.4.3-3 +- Switch Build Type to ReleaseWithDebInfo to avoid -03 + +* Sun Nov 04 2012 Nicolas Chauvet - 2.4.3-2 +- Disable SSE3 and allow --with sse3 build conditional. +- Disable gpu module as we don't build cuda +- Update to 2.4.3 + +* Fri Jul 20 2012 Fedora Release Engineering - 2.4.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Mon Jul 09 2012 Honza Horak - 2.4.2-1 +- Update to 2.4.2 + +* Fri Jun 29 2012 Honza Horak - 2.4.1-2 +- Fixed cmake script for generating opencv.pc file +- Fixed OpenCVConfig script file + +* Mon Jun 04 2012 Nicolas Chauvet - 2.4.1-1 +- Update to 2.4.1 +- Rework dependencies - rhbz#828087 + Re-enable using --with tbb,openni,eigen2,eigen3 + +* Tue Feb 28 2012 Fedora Release Engineering - 2.3.1-8 +- Rebuilt for c++ ABI breakage + +* Mon Jan 16 2012 Nicolas Chauvet - 2.3.1-7 +- Update gcc46 patch for ARM FTBFS + +* Fri Jan 13 2012 Fedora Release Engineering - 2.3.1-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Mon Dec 05 2011 Adam Jackson 2.3.1-5 +- Rebuild for new libpng + +* Thu Oct 20 2011 Nicolas Chauvet - 2.3.1-4 +- Rebuilt for tbb silent ABI change + +* Mon Oct 10 2011 Nicolas Chauvet - 2.3.1-3 +- Update to 2.3.1a + +* Mon Sep 26 2011 Dan Horák - 2.3.1-2 +- openni is exclusive for x86/x86_64 + +* Fri Aug 19 2011 Nicolas Chauvet - 2.3.1-1 +- Update to 2.3.1 +- Add BR openni-devel python-sphinx +- Remove deprecated cmake options +- Add --with cuda conditional (wip) +- Disable make test (unavailable) + +* Thu May 26 2011 Nicolas Chauvet - 2.2.0-6 +- Backport fixes from branch 2.2 to date + +* Tue May 17 2011 Nicolas Chauvet - 2.2.0-5 +- Re-enable v4l on f15 +- Remove unused cmake options + +* Tue Feb 08 2011 Fedora Release Engineering - 2.2.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Wed Feb 02 2011 Nicolas Chauvet - 2.2.0-2 +- Fix with gcc46 +- Disable V4L as V4L1 is disabled for Fedora 15 + +* Thu Jan 06 2011 Nicolas Chauvet - 2.2.0-1 +- Update to 2.2.0 +- Disable -msse and -msse2 on x86_32 + +* Wed Aug 25 2010 Rex Dieter - 2.1.0-5 +- -devel: include OpenCVConfig.cmake (#627359) + +* Thu Jul 22 2010 Dan Horák - 2.1.0-4 +- TBB is available only on x86/x86_64 and ia64 + +* Wed Jul 21 2010 David Malcolm - 2.1.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild + +* Fri Jun 25 2010 Nicolas Chauvet - 2.1.0-2 +- Move samples from main to -devel +- Fix spurious permission +- Add BR tbb-devel +- Fix CFLAGS + +* Fri Apr 23 2010 Nicolas Chauvet - 2.1.0-1 +- Update to 2.1.0 +- Update libdir patch + +* Tue Apr 13 2010 Karel Klic - 2.0.0-10 +- Fix nonstandard executable permissions + +* Tue Mar 09 2010 Karel Klic - 2.0.0-9 +- apply the previously added patch + +* Mon Mar 08 2010 Karel Klic - 2.0.0-8 +- re-enable testing on CMake build system +- fix memory corruption in the gaussian random number generator + +* Sat Feb 27 2010 Haïkel Guémar - 2.0.0-7 +- replaced BR unicap-devel by libucil-devel (unicap split) + +* Thu Feb 25 2010 Haïkel Guémar - 2.0.0-6 +- use cmake build system +- applications renamed to opencv_xxx instead of opencv-xxx +- add devel-docs subpackage #546605 +- add OpenCVConfig.cmake +- enable openmp build +- enable old SWIG based python wrappers +- opencv package is a good boy and use global instead of define + +* Tue Feb 16 2010 Karel Klic - 2.0.0-5 +- Set CXXFLAXS without -match=i386 for i386 architecture #565074 + +* Sat Jan 09 2010 Rakesh Pandit - 2.0.0-4 +- Updated opencv-samples-Makefile (Thanks Scott Tsai) #553697 + +* Wed Jan 06 2010 Karel Klic - 2.0.0-3 +- Fixed spec file issues detected by rpmlint + +* Sun Dec 06 2009 Haïkel Guémar - 2.0.0-2 +- Fix autotools scripts (missing LBP features) - #544167 + +* Fri Nov 27 2009 Haïkel Guémar - 2.0.0-1 +- Updated to 2.0.0 +- Removed upstream-ed patches +- Ugly hack (added cvconfig.h) +- Disable %%check on ppc64 + +* Thu Sep 10 2009 Karsten Hopp - 1.1.0-0.7.pre1 +- fix build on s390x where we don't have libraw1394 and devel + +* Thu Jul 30 2009 Haïkel Guémar - 1.1.0.0.6.pre1 +- Fix typo I introduced that prevented build on i386/i586 + +* Thu Jul 30 2009 Haïkel Guémar - 1.1.0.0.5.pre1 +- Added 1394 libs and unicap support + +* Sat Jul 25 2009 Fedora Release Engineering - 1.1.0-0.4.pre1 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Thu Jul 16 2009 kwizart < kwizart at gmail.com > - 1.1.0-0.3.pre1 +- Build with gstreamer support - #491223 +- Backport gcc43 fix from trunk + +* Thu Jul 16 2009 kwizart < kwizart at gmail.com > - 1.1.0-0.2.pre1 +- Fix FTBFS #511705 + +* Fri Apr 24 2009 kwizart < kwizart at gmail.com > - 1.1.0-0.1.pre1 +- Update to 1.1pre1 +- Disable CXXFLAGS hardcoded optimization +- Add BR: python-imaging, numpy +- Disable make check failure for now + +* Wed Apr 22 2009 kwizart < kwizart at gmail.com > - 1.0.0-14 +- Fix for gcc44 +- Enable BR jasper-devel +- Disable ldconfig run on python modules (uneeded) +- Prevent timestamp change on install + +* Thu Feb 26 2009 Fedora Release Engineering - 1.0.0-13 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Mon Dec 29 2008 Rakesh Pandit - 1.0.0-12 +- fix URL field + +* Fri Dec 19 2008 Ralf Corsépius - 1.0.0-11 +- Adopt latest python spec rules. +- Rebuild for Python 2.6 once again. + +* Sat Nov 29 2008 Ignacio Vazquez-Abrams - 1.0.0-10 +- Rebuild for Python 2.6 + +* Thu May 22 2008 Tom "spot" Callaway - 1.0.0-9 +- fix license tag + +* Sun May 11 2008 Ralf Corsépius - 1.0.0-8 +- Adjust library order in opencv.pc.in (BZ 445937). + +* Mon Feb 18 2008 Fedora Release Engineering - 1.0.0-7 +- Autorebuild for GCC 4.3 + +* Sun Feb 10 2008 Ralf Corsépius - 1.0.0-6 +- Rebuild for gcc43. + +* Tue Aug 28 2007 Fedora Release Engineering - 1.0.0-5 +- Rebuild for selinux ppc32 issue. + +* Wed Aug 22 2007 Ralf Corsépius - 1.0.0-4 +- Mass rebuild. + +* Thu Mar 22 2007 Ralf Corsépius - 1.0.0-3 +- Fix %%{_datadir}/opencv/samples ownership. +- Adjust timestamp of cvconfig.h.in to avoid re-running autoheader. + +* Thu Mar 22 2007 Ralf Corsépius - 1.0.0-2 +- Move all of the python module to pyexecdir (BZ 233128). +- Activate the testsuite. + +* Mon Dec 11 2006 Ralf Corsépius - 1.0.0-1 +- Upstream update. + +* Mon Dec 11 2006 Ralf Corsépius - 0.9.9-4 +- Remove python-abi. + +* Thu Oct 05 2006 Christian Iseli 0.9.9-3 +- rebuilt for unwind info generation, broken in gcc-4.1.1-21 + +* Thu Sep 21 2006 Ralf Corsépius - 0.9.9-2 +- Stop configure.in from hacking CXXFLAGS. +- Activate testsuite. +- Let *-devel require pkgconfig. + +* Thu Sep 21 2006 Ralf Corsépius - 0.9.9-1 +- Upstream update. +- Don't BR: autotools. +- Install samples' Makefile as GNUmakefile. + +* Thu Sep 21 2006 Ralf Corsépius - 0.9.7-18 +- Un'%%ghost *.pyo. +- Separate %%{pythondir} from %%{pyexecdir}. + +* Thu Sep 21 2006 Ralf Corsépius - 0.9.7-17 +- Rebuild for FC6. +- BR: libtool. + +* Fri Mar 17 2006 Simon Perreault - 0.9.7-16 +- Rebuild. + +* Wed Mar 8 2006 Simon Perreault - 0.9.7-15 +- Force a re-run of Autotools by calling autoreconf. + +* Wed Mar 8 2006 Simon Perreault - 0.9.7-14 +- Added build dependency on Autotools. + +* Tue Mar 7 2006 Simon Perreault - 0.9.7-13 +- Changed intrinsics patch so that it matches upstream. + +* Tue Mar 7 2006 Simon Perreault - 0.9.7-12 +- More intrinsics patch fixing. + +* Tue Mar 7 2006 Simon Perreault - 0.9.7-11 +- Don't do "make check" because it doesn't run any tests anyway. +- Back to main intrinsics patch. + +* Tue Mar 7 2006 Simon Perreault - 0.9.7-10 +- Using simple intrinsincs patch. + +* Tue Mar 7 2006 Simon Perreault - 0.9.7-9 +- Still more fixing of intrinsics patch for Python bindings on x86_64. + +* Tue Mar 7 2006 Simon Perreault - 0.9.7-8 +- Again fixed intrinsics patch so that Python modules build on x86_64. + +* Tue Mar 7 2006 Simon Perreault - 0.9.7-7 +- Fixed intrinsics patch so that it works. + +* Tue Mar 7 2006 Simon Perreault - 0.9.7-6 +- Fixed Python bindings location on x86_64. + +* Mon Mar 6 2006 Simon Perreault - 0.9.7-5 +- SSE2 support on x86_64. + +* Mon Mar 6 2006 Simon Perreault - 0.9.7-4 +- Rebuild + +* Sun Oct 16 2005 Simon Perreault - 0.9.7-3 +- Removed useless sample compilation makefiles/project files and replaced them + with one that works on Fedora Core. +- Removed shellbang from Python modules. + +* Mon Oct 10 2005 Simon Perreault - 0.9.7-2 +- Made FFMPEG dependency optional (needs to be disabled for inclusion in FE). + +* Mon Oct 10 2005 Simon Perreault - 0.9.7-1 +- Initial package. diff --git a/opencv_contrib-clean-4.5.2.tar.gz b/opencv_contrib-clean-4.5.2.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..fbe2ee2bf8da6f59c01ba64c743ea2468d6c048d Binary files /dev/null and b/opencv_contrib-clean-4.5.2.tar.gz differ diff --git a/xorg.conf b/xorg.conf new file mode 100644 index 0000000000000000000000000000000000000000..39bc48ac77322256a24c5b1eeddbc173c313e52d --- /dev/null +++ b/xorg.conf @@ -0,0 +1,135 @@ +# This xorg configuration file is meant to be used +# to start a dummy X11 server for graphical testing. + +Section "ServerFlags" + Option "DontVTSwitch" "true" + Option "AllowMouseOpenFail" "true" + Option "PciForceNone" "true" + Option "AutoEnableDevices" "false" + Option "AutoAddDevices" "false" +EndSection + +Section "InputDevice" + Identifier "dummy_mouse" + Option "CorePointer" "true" + Driver "void" +EndSection + +Section "InputDevice" + Identifier "dummy_keyboard" + Option "CoreKeyboard" "true" + Driver "void" +EndSection + +Section "Device" + Identifier "dummy_videocard" + Driver "dummy" + Option "ConstantDPI" "true" + #VideoRam 4096000 + #VideoRam 256000 + VideoRam 192000 +EndSection + +Section "Monitor" + Identifier "dummy_monitor" + HorizSync 5.0 - 1000.0 + VertRefresh 5.0 - 200.0 + #This can be used to get a specific DPI, but only for the default resolution: + #DisplaySize 508 317 + #NOTE: the highest modes will not work without increasing the VideoRam + # for the dummy video card. + Modeline "32768x32768" 15226.50 32768 35800 39488 46208 32768 32771 32781 32953 + Modeline "32768x16384" 7516.25 32768 35544 39192 45616 16384 16387 16397 16478 + Modeline "16384x8192" 2101.93 16384 16416 24400 24432 8192 8390 8403 8602 + Modeline "8192x4096" 424.46 8192 8224 9832 9864 4096 4195 4202 4301 + Modeline "5496x1200" 199.13 5496 5528 6280 6312 1200 1228 1233 1261 + Modeline "5280x1080" 169.96 5280 5312 5952 5984 1080 1105 1110 1135 + Modeline "5280x1200" 191.40 5280 5312 6032 6064 1200 1228 1233 1261 + Modeline "5120x3200" 199.75 5120 5152 5904 5936 3200 3277 3283 3361 + Modeline "4800x1200" 64.42 4800 4832 5072 5104 1200 1229 1231 1261 + Modeline "3840x2880" 133.43 3840 3872 4376 4408 2880 2950 2955 3025 + Modeline "3840x2560" 116.93 3840 3872 4312 4344 2560 2622 2627 2689 + Modeline "3840x2048" 91.45 3840 3872 4216 4248 2048 2097 2101 2151 + Modeline "3840x1080" 100.38 3840 3848 4216 4592 1080 1081 1084 1093 + Modeline "3600x1200" 106.06 3600 3632 3984 4368 1200 1201 1204 1214 + Modeline "3288x1080" 39.76 3288 3320 3464 3496 1080 1106 1108 1135 + Modeline "2048x2048" 49.47 2048 2080 2264 2296 2048 2097 2101 2151 + Modeline "2048x1536" 80.06 2048 2104 2312 2576 1536 1537 1540 1554 + Modeline "2560x1600" 47.12 2560 2592 2768 2800 1600 1639 1642 1681 + Modeline "2560x1440" 42.12 2560 2592 2752 2784 1440 1475 1478 1513 + Modeline "1920x1440" 69.47 1920 1960 2152 2384 1440 1441 1444 1457 + Modeline "1920x1200" 26.28 1920 1952 2048 2080 1200 1229 1231 1261 + Modeline "1920x1080" 23.53 1920 1952 2040 2072 1080 1106 1108 1135 + Modeline "1680x1050" 20.08 1680 1712 1784 1816 1050 1075 1077 1103 + Modeline "1600x1200" 22.04 1600 1632 1712 1744 1200 1229 1231 1261 + Modeline "1600x900" 33.92 1600 1632 1760 1792 900 921 924 946 + Modeline "1440x900" 30.66 1440 1472 1584 1616 900 921 924 946 + ModeLine "1366x768" 72.00 1366 1414 1446 1494 768 771 777 803 + Modeline "1280x1024" 31.50 1280 1312 1424 1456 1024 1048 1052 1076 + Modeline "1280x800" 24.15 1280 1312 1400 1432 800 819 822 841 + Modeline "1280x768" 23.11 1280 1312 1392 1424 768 786 789 807 + Modeline "1360x768" 24.49 1360 1392 1480 1512 768 786 789 807 + Modeline "1024x768" 18.71 1024 1056 1120 1152 768 786 789 807 + Modeline "768x1024" 19.50 768 800 872 904 1024 1048 1052 1076 + + + #common resolutions for android devices (both orientations): + Modeline "800x1280" 25.89 800 832 928 960 1280 1310 1315 1345 + Modeline "1280x800" 24.15 1280 1312 1400 1432 800 819 822 841 + Modeline "720x1280" 30.22 720 752 864 896 1280 1309 1315 1345 + Modeline "1280x720" 27.41 1280 1312 1416 1448 720 737 740 757 + Modeline "768x1024" 24.93 768 800 888 920 1024 1047 1052 1076 + Modeline "1024x768" 23.77 1024 1056 1144 1176 768 785 789 807 + Modeline "600x1024" 19.90 600 632 704 736 1024 1047 1052 1076 + Modeline "1024x600" 18.26 1024 1056 1120 1152 600 614 617 631 + Modeline "536x960" 16.74 536 568 624 656 960 982 986 1009 + Modeline "960x536" 15.23 960 992 1048 1080 536 548 551 563 + Modeline "600x800" 15.17 600 632 688 720 800 818 822 841 + Modeline "800x600" 14.50 800 832 880 912 600 614 617 631 + Modeline "480x854" 13.34 480 512 560 592 854 873 877 897 + Modeline "848x480" 12.09 848 880 920 952 480 491 493 505 + Modeline "480x800" 12.43 480 512 552 584 800 818 822 841 + Modeline "800x480" 11.46 800 832 872 904 480 491 493 505 + #resolutions for android devices (both orientations) + #minus the status bar + #38px status bar (and width rounded up) + Modeline "800x1242" 25.03 800 832 920 952 1242 1271 1275 1305 + Modeline "1280x762" 22.93 1280 1312 1392 1424 762 780 783 801 + Modeline "720x1242" 29.20 720 752 856 888 1242 1271 1276 1305 + Modeline "1280x682" 25.85 1280 1312 1408 1440 682 698 701 717 + Modeline "768x986" 23.90 768 800 888 920 986 1009 1013 1036 + Modeline "1024x730" 22.50 1024 1056 1136 1168 730 747 750 767 + Modeline "600x986" 19.07 600 632 704 736 986 1009 1013 1036 + Modeline "1024x562" 17.03 1024 1056 1120 1152 562 575 578 591 + Modeline "536x922" 16.01 536 568 624 656 922 943 947 969 + Modeline "960x498" 14.09 960 992 1040 1072 498 509 511 523 + Modeline "600x762" 14.39 600 632 680 712 762 779 783 801 + Modeline "800x562" 13.52 800 832 880 912 562 575 578 591 + Modeline "480x810" 12.59 480 512 552 584 810 828 832 851 + Modeline "848x442" 11.09 848 880 920 952 442 452 454 465 + Modeline "480x762" 11.79 480 512 552 584 762 779 783 801 +EndSection + +Section "Screen" + Identifier "dummy_screen" + Device "dummy_videocard" + Monitor "dummy_monitor" + DefaultDepth 24 + SubSection "Display" + Viewport 0 0 + Depth 24 + #Modes "32768x32768" "32768x16384" "16384x8192" "8192x4096" "5120x3200" "3840x2880" "3840x2560" "3840x2048" "2048x2048" "2560x1600" "1920x1440" "1920x1200" "1920x1080" "1600x1200" "1680x1050" "1600x900" "1400x1050" "1440x900" "1280x1024" "1366x768" "1280x800" "1024x768" "1024x600" "800x600" "320x200" + Modes "5120x3200" "3840x2880" "3840x2560" "3840x2048" "2048x2048" "2560x1600" "1920x1440" "1920x1200" "1920x1080" "1600x1200" "1680x1050" "1600x900" "1400x1050" "1440x900" "1280x1024" "1366x768" "1280x800" "1024x768" "1024x600" "800x600" "320x200" + #Virtual 32000 32000 + #Virtual 16384 8192 + Virtual 8192 4096 + #Virtual 5120 3200 + EndSubSection +EndSection + +Section "ServerLayout" + Identifier "dummy_layout" + Screen "dummy_screen" + InputDevice "dummy_mouse" + InputDevice "dummy_keyboard" +EndSection