Commit 90ec651b authored by Vadim Levin's avatar Vadim Levin

test: Add test to verify correct mat substitution into the template in header parser

parent 0aa5391c
...@@ -4,8 +4,22 @@ from __future__ import print_function ...@@ -4,8 +4,22 @@ from __future__ import print_function
import numpy as np import numpy as np
import cv2 as cv import cv2 as cv
import os
from tests_common import NewOpenCVTests 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): class UMat(NewOpenCVTests):
def test_umat_construct(self): def test_umat_construct(self):
...@@ -82,5 +96,22 @@ class UMat(NewOpenCVTests): ...@@ -82,5 +96,22 @@ class UMat(NewOpenCVTests):
# for data, data_umat in zip(p1_mask_err, p1_mask_err_umat): # for data, data_umat in zip(p1_mask_err, p1_mask_err_umat):
# self.assertTrue(np.allclose(data, data_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__': if __name__ == '__main__':
NewOpenCVTests.bootstrap() NewOpenCVTests.bootstrap()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment