From 780b28040fe1e814d2deac5b8a481d0a8aded189 Mon Sep 17 00:00:00 2001 From: sof Date: Wed, 4 Sep 2024 15:55:29 +0200 Subject: [PATCH] Convert Matcher_factory into a fx --- .../action_cam_mapper/feature_matcher.py | 23 +++++++++---------- .../action_cam_mapper/gaze_mapper.py | 8 +++---- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/pupil_labs/action_cam_mapper/feature_matcher.py b/src/pupil_labs/action_cam_mapper/feature_matcher.py index 30d34fc4..4228e9ce 100755 --- a/src/pupil_labs/action_cam_mapper/feature_matcher.py +++ b/src/pupil_labs/action_cam_mapper/feature_matcher.py @@ -348,15 +348,14 @@ def get_correspondences( return correspondences -class ImageMatcherFactory: # refactor into fx - def get_matcher(self, image_matcher, image_matcher_parameters): - if image_matcher.lower() == "loftr": - return LOFTRImageMatcher(**image_matcher_parameters) - elif image_matcher.lower() == "disk_lightglue": - return DISKLightGlueImageMatcher(**image_matcher_parameters) - elif image_matcher.lower() == "efficient_loftr": - return EfficientLoFTRImageMatcher(**image_matcher_parameters) - elif image_matcher.lower() == "dedode_lightglue": - return DeDoDeLightGlueImageMatcher(**image_matcher_parameters) - else: - raise ValueError("Invalid image matcher", image_matcher) +def get_matcher(image_matcher, image_matcher_parameters): + if image_matcher.lower() == "loftr": + return LOFTRImageMatcher(**image_matcher_parameters) + elif image_matcher.lower() == "disk_lightglue": + return DISKLightGlueImageMatcher(**image_matcher_parameters) + elif image_matcher.lower() == "efficient_loftr": + return EfficientLoFTRImageMatcher(**image_matcher_parameters) + elif image_matcher.lower() == "dedode_lightglue": + return DeDoDeLightGlueImageMatcher(**image_matcher_parameters) + else: + raise ValueError("Invalid image matcher", image_matcher) diff --git a/src/pupil_labs/action_cam_mapper/gaze_mapper.py b/src/pupil_labs/action_cam_mapper/gaze_mapper.py index 87420e25..68d05fa0 100755 --- a/src/pupil_labs/action_cam_mapper/gaze_mapper.py +++ b/src/pupil_labs/action_cam_mapper/gaze_mapper.py @@ -4,12 +4,11 @@ import cv2 as cv import numpy as np import pandas as pd -from feature_matcher import ImageMatcherFactory +from feature_matcher import get_matcher from tqdm import tqdm from utils import VideoHandler -# logger=logging.getLogger(__name__) class EgocentricMapper: def __init__( self, @@ -28,6 +27,7 @@ def __init__( alternative_fov=[145, 76], logging_level="ERROR", ): + self.neon_video = VideoHandler(neon_video_path) self.alt_video = VideoHandler(alternative_video_path) @@ -44,9 +44,7 @@ def __init__( self.neon_gaze = pd.read_csv(neon_gaze_csv) # @ 200Hz self.alt_gaze = self._create_alternative_gaze_df() - self.image_matcher = ImageMatcherFactory().get_matcher( - image_matcher, image_matcher_parameters - ) + self.image_matcher = get_matcher(image_matcher, image_matcher_parameters) self.output_dir = Path(output_dir or Path(neon_video_path).parent)