From ce2aed19d689e38c4dde55da2e368f698e30f578 Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Mon, 28 Nov 2022 17:33:54 +0100 Subject: Adding a new ArUcoSetFactory class. --- src/argaze/ArUcoMarkers/ArUcoSetFactory.py | 21 +++++++++++++++++++++ src/argaze/ArUcoMarkers/__init__.py | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/argaze/ArUcoMarkers/ArUcoSetFactory.py (limited to 'src') diff --git a/src/argaze/ArUcoMarkers/ArUcoSetFactory.py b/src/argaze/ArUcoMarkers/ArUcoSetFactory.py new file mode 100644 index 0000000..230c9b3 --- /dev/null +++ b/src/argaze/ArUcoMarkers/ArUcoSetFactory.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +import json + +from argaze.ArUcoMarkers import ArUcoPlan, ArUcoCube + +class ArUcoSetFactory(): + """Define class to build specific ArUco markers set.""" + + @classmethod + def make(self, configuration_filepath): + + with open(configuration_filepath) as configuration_file: + + # Deserialize .json + configuration = json.load(configuration_file) + + # Load set type + set_type = configuration['type'] + + return eval(f'{set_type}.{set_type}')(configuration_filepath) \ No newline at end of file diff --git a/src/argaze/ArUcoMarkers/__init__.py b/src/argaze/ArUcoMarkers/__init__.py index 73d0851..af43673 100644 --- a/src/argaze/ArUcoMarkers/__init__.py +++ b/src/argaze/ArUcoMarkers/__init__.py @@ -2,4 +2,4 @@ .. include:: README.md """ __docformat__ = "restructuredtext" -__all__ = ['ArUcoMarkersDictionary', 'ArUcoMarker', 'ArUcoBoard', 'ArUcoCamera', 'ArUcoTracker', 'ArUcoSet', 'ArUcoPlan', 'ArUcoCube', ] \ No newline at end of file +__all__ = ['ArUcoMarkersDictionary', 'ArUcoMarker', 'ArUcoBoard', 'ArUcoCamera', 'ArUcoTracker', 'ArUcoSet', 'ArUcoPlan', 'ArUcoCube', 'ArUcoSetFactory'] \ No newline at end of file -- cgit v1.1