Skip to content

Commit

Permalink
Convert Matcher_factory into a fx
Browse files Browse the repository at this point in the history
  • Loading branch information
soflc committed Sep 4, 2024
1 parent 6a817e8 commit 780b280
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
23 changes: 11 additions & 12 deletions src/pupil_labs/action_cam_mapper/feature_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 3 additions & 5 deletions src/pupil_labs/action_cam_mapper/gaze_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)

Expand All @@ -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)

Expand Down

0 comments on commit 780b280

Please sign in to comment.