From 82af55525fd05f42b4b11d73461c007389bdc77d Mon Sep 17 00:00:00 2001 From: Lukas Weber <32765578+lukasalexanderweber@users.noreply.github.com> Date: Tue, 9 Aug 2022 07:14:35 +0200 Subject: [PATCH] Improve affine stitcher (#20) --- README.md | 2 +- stitching/cli/stitch.py | 2 +- stitching/stitcher.py | 14 +++++--------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index e83964c..8b4945c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # stitching -A Python package for fast and robust Image Stitching. +A Python package for fast and robust Image Stitching. Based on opencv's [stitching module](https://github.com/opencv/opencv/tree/4.x/modules/stitching) diff --git a/stitching/cli/stitch.py b/stitching/cli/stitch.py index 9ff2825..4b21137 100644 --- a/stitching/cli/stitch.py +++ b/stitching/cli/stitch.py @@ -53,7 +53,7 @@ action="store", default=500, help="Number of features to be detected per image. " - "Only used for the detectors \'orb\' and \'sift'\. " + "Only used for the detectors 'orb' and 'sift'. " "The default is 500.", type=int, ) diff --git a/stitching/stitcher.py b/stitching/stitcher.py index f0f65a7..7445c20 100644 --- a/stitching/stitcher.py +++ b/stitching/stitcher.py @@ -48,7 +48,7 @@ def __init__(self, **kwargs): self.initialize_stitcher(**kwargs) def initialize_stitcher(self, **kwargs): - self.settings = Stitcher.DEFAULT_SETTINGS.copy() + self.settings = self.DEFAULT_SETTINGS.copy() self.validate_kwargs(kwargs) self.settings.update(kwargs) @@ -240,10 +240,9 @@ def create_final_panorama(self): panorama, _ = self.blender.blend() return panorama - @staticmethod - def validate_kwargs(kwargs): + def validate_kwargs(self, kwargs): for arg in kwargs: - if arg not in Stitcher.DEFAULT_SETTINGS: + if arg not in self.DEFAULT_SETTINGS: raise StitchingError("Invalid Argument: " + arg) @@ -257,8 +256,5 @@ class AffineStitcher(Stitcher): "compensator": "no", } - def initialize_stitcher(self, **kwargs): - affine_defaults = AffineStitcher.AFFINE_DEFAULTS.copy() - self.validate_kwargs(kwargs) - affine_defaults.update(kwargs) - super().initialize_stitcher(**affine_defaults) + DEFAULT_SETTINGS = Stitcher.DEFAULT_SETTINGS.copy() + DEFAULT_SETTINGS.update(AFFINE_DEFAULTS)