From 90ec651bd751cfdfac869e524468b63a669e2d17 Mon Sep 17 00:00:00 2001 From: Vadim Levin Date: Tue, 3 Mar 2020 10:29:00 +0300 Subject: [PATCH] test: Add test to verify correct mat substitution into the template in header parser --- modules/python/test/test_umat.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/modules/python/test/test_umat.py b/modules/python/test/test_umat.py index c76ddd4..32db5d0 100644 --- a/modules/python/test/test_umat.py +++ b/modules/python/test/test_umat.py @@ -4,8 +4,22 @@ from __future__ import print_function import numpy as np import cv2 as cv +import os + from tests_common import NewOpenCVTests + +def load_exposure_seq(path): + images = [] + times = [] + with open(os.path.join(path, 'list.txt'), 'r') as list_file: + for line in list_file.readlines(): + name, time = line.split() + images.append(cv.imread(os.path.join(path, name))) + times.append(1. / float(time)) + return images, times + + class UMat(NewOpenCVTests): def test_umat_construct(self): @@ -82,5 +96,22 @@ class UMat(NewOpenCVTests): # for data, data_umat in zip(p1_mask_err, p1_mask_err_umat): # self.assertTrue(np.allclose(data, data_umat)) + def test_umat_merge_mertens(self): + if self.extraTestDataPath is None: + self.fail('Test data is not available') + + test_data_path = os.path.join(self.extraTestDataPath, 'cv', 'hdr') + + images, _ = load_exposure_seq(os.path.join(test_data_path, 'exposures')) + + merge = cv.createMergeMertens() + mat_result = merge.process(images) + + umat_images = [cv.UMat(img) for img in images] + umat_result = merge.process(umat_images) + + self.assertTrue(np.allclose(umat_result.get(), mat_result)) + + if __name__ == '__main__': NewOpenCVTests.bootstrap() -- 2.7.4