2017-07-30 18:52:27 +08:00
|
|
|
#!/usr/bin/env python
|
2017-12-11 17:55:03 +08:00
|
|
|
import cv2 as cv
|
2017-07-30 18:52:27 +08:00
|
|
|
|
|
|
|
from tests_common import NewOpenCVTests
|
|
|
|
|
|
|
|
class stitching_test(NewOpenCVTests):
|
|
|
|
|
|
|
|
def test_simple(self):
|
|
|
|
|
|
|
|
img1 = self.get_sample('stitching/a1.png')
|
|
|
|
img2 = self.get_sample('stitching/a2.png')
|
|
|
|
|
2018-11-11 00:53:48 +08:00
|
|
|
stitcher = cv.Stitcher.create(cv.Stitcher_PANORAMA)
|
2017-09-03 19:17:15 +08:00
|
|
|
(_result, pano) = stitcher.stitch((img1, img2))
|
2017-07-30 18:52:27 +08:00
|
|
|
|
2017-12-11 17:55:03 +08:00
|
|
|
#cv.imshow("pano", pano)
|
|
|
|
#cv.waitKey()
|
2017-07-30 18:52:27 +08:00
|
|
|
|
|
|
|
self.assertAlmostEqual(pano.shape[0], 685, delta=100, msg="rows: %r" % list(pano.shape))
|
|
|
|
self.assertAlmostEqual(pano.shape[1], 1025, delta=100, msg="cols: %r" % list(pano.shape))
|
2017-09-03 20:01:25 +08:00
|
|
|
|
2018-12-19 02:49:16 +08:00
|
|
|
class stitching_detail_test(NewOpenCVTests):
|
|
|
|
|
|
|
|
def test_simple(self):
|
|
|
|
img = self.get_sample('stitching/a1.png')
|
|
|
|
finder= cv.ORB.create()
|
|
|
|
imgFea = cv.detail.computeImageFeatures2(finder,img)
|
|
|
|
self.assertIsNotNone(imgFea)
|
|
|
|
|
|
|
|
matcher = cv.detail_BestOf2NearestMatcher(False, 0.3)
|
|
|
|
self.assertIsNotNone(matcher)
|
|
|
|
matcher = cv.detail_AffineBestOf2NearestMatcher(False, False, 0.3)
|
|
|
|
self.assertIsNotNone(matcher)
|
|
|
|
matcher = cv.detail_BestOf2NearestRangeMatcher(2, False, 0.3)
|
|
|
|
self.assertIsNotNone(matcher)
|
|
|
|
estimator = cv.detail_AffineBasedEstimator()
|
|
|
|
self.assertIsNotNone(estimator)
|
|
|
|
estimator = cv.detail_HomographyBasedEstimator()
|
|
|
|
self.assertIsNotNone(estimator)
|
|
|
|
|
|
|
|
adjuster = cv.detail_BundleAdjusterReproj()
|
|
|
|
self.assertIsNotNone(adjuster)
|
|
|
|
adjuster = cv.detail_BundleAdjusterRay()
|
|
|
|
self.assertIsNotNone(adjuster)
|
|
|
|
adjuster = cv.detail_BundleAdjusterAffinePartial()
|
|
|
|
self.assertIsNotNone(adjuster)
|
|
|
|
adjuster = cv.detail_NoBundleAdjuster()
|
|
|
|
self.assertIsNotNone(adjuster)
|
|
|
|
|
|
|
|
compensator=cv.detail.ExposureCompensator_createDefault(cv.detail.ExposureCompensator_NO)
|
|
|
|
self.assertIsNotNone(compensator)
|
|
|
|
compensator=cv.detail.ExposureCompensator_createDefault(cv.detail.ExposureCompensator_GAIN)
|
|
|
|
self.assertIsNotNone(compensator)
|
|
|
|
compensator=cv.detail.ExposureCompensator_createDefault(cv.detail.ExposureCompensator_GAIN_BLOCKS)
|
|
|
|
self.assertIsNotNone(compensator)
|
|
|
|
|
|
|
|
seam_finder = cv.detail.SeamFinder_createDefault(cv.detail.SeamFinder_NO)
|
|
|
|
self.assertIsNotNone(seam_finder)
|
|
|
|
seam_finder = cv.detail.SeamFinder_createDefault(cv.detail.SeamFinder_NO)
|
|
|
|
self.assertIsNotNone(seam_finder)
|
|
|
|
seam_finder = cv.detail.SeamFinder_createDefault(cv.detail.SeamFinder_VORONOI_SEAM)
|
|
|
|
self.assertIsNotNone(seam_finder)
|
|
|
|
|
|
|
|
seam_finder = cv.detail_GraphCutSeamFinder("COST_COLOR")
|
|
|
|
self.assertIsNotNone(seam_finder)
|
|
|
|
seam_finder = cv.detail_GraphCutSeamFinder("COST_COLOR_GRAD")
|
|
|
|
self.assertIsNotNone(seam_finder)
|
|
|
|
seam_finder = cv.detail_DpSeamFinder("COLOR")
|
|
|
|
self.assertIsNotNone(seam_finder)
|
|
|
|
seam_finder = cv.detail_DpSeamFinder("COLOR_GRAD")
|
|
|
|
self.assertIsNotNone(seam_finder)
|
|
|
|
|
|
|
|
blender = cv.detail.Blender_createDefault(cv.detail.Blender_NO)
|
|
|
|
self.assertIsNotNone(blender)
|
|
|
|
blender = cv.detail.Blender_createDefault(cv.detail.Blender_FEATHER)
|
|
|
|
self.assertIsNotNone(blender)
|
|
|
|
blender = cv.detail.Blender_createDefault(cv.detail.Blender_MULTI_BAND)
|
|
|
|
self.assertIsNotNone(blender)
|
|
|
|
|
|
|
|
timelapser = cv.detail.Timelapser_createDefault(cv.detail.Timelapser_AS_IS);
|
|
|
|
self.assertIsNotNone(timelapser)
|
|
|
|
timelapser = cv.detail.Timelapser_createDefault(cv.detail.Timelapser_CROP);
|
|
|
|
self.assertIsNotNone(timelapser)
|
|
|
|
|
2017-09-03 20:01:25 +08:00
|
|
|
if __name__ == '__main__':
|
|
|
|
NewOpenCVTests.bootstrap()
|