aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2022-11-09 17:42:31 +0100
committerThéo de la Hogue2022-11-09 17:42:31 +0100
commit59ce34081a63ae7af1372c828775ac2a5e1e210e (patch)
tree5816f5a254e413869f336ea58d8919716db313c4
parentceb215e32567c69aa4be25f094f08f6adfb95d90 (diff)
downloadargaze-59ce34081a63ae7af1372c828775ac2a5e1e210e.zip
argaze-59ce34081a63ae7af1372c828775ac2a5e1e210e.tar.gz
argaze-59ce34081a63ae7af1372c828775ac2a5e1e210e.tar.bz2
argaze-59ce34081a63ae7af1372c828775ac2a5e1e210e.tar.xz
Fixing many errors due to major class rewriting.
-rw-r--r--src/argaze/ArUcoMarkers/ArUcoMarkersDictionary.py22
-rw-r--r--src/argaze/ArUcoMarkers/ArUcoTracker.py4
-rw-r--r--src/argaze/AreaOfInterest/AOI3DScene.py8
-rw-r--r--src/argaze/AreaOfInterest/AOIFeatures.py26
-rw-r--r--src/argaze/DataStructures.py22
-rw-r--r--src/argaze/TobiiGlassesPro2/TobiiEntities.py10
-rw-r--r--src/argaze/TobiiGlassesPro2/TobiiNetworkInterface.py4
-rw-r--r--src/argaze/TobiiGlassesPro2/TobiiVideo.py8
-rw-r--r--src/argaze/utils/aruco_calibration_board_export.py2
-rw-r--r--src/argaze/utils/aruco_markers_export.py7
-rw-r--r--src/argaze/utils/tobii_segment_aruco_aoi_edit.py14
-rw-r--r--src/argaze/utils/tobii_segment_aruco_aoi_export.py6
-rw-r--r--src/argaze/utils/tobii_stream_aruco_aoi_display.py18
13 files changed, 77 insertions, 74 deletions
diff --git a/src/argaze/ArUcoMarkers/ArUcoMarkersDictionary.py b/src/argaze/ArUcoMarkers/ArUcoMarkersDictionary.py
index 3b23acb..016c0b5 100644
--- a/src/argaze/ArUcoMarkers/ArUcoMarkersDictionary.py
+++ b/src/argaze/ArUcoMarkers/ArUcoMarkersDictionary.py
@@ -37,7 +37,7 @@ class ArUcoMarkersDictionary():
if all_aruco_markers_dictionaries.get(name, None) is None:
raise NameError(f'Bad ArUco markers dictionary name: {name}')
- self.name = name
+ self.__name = name
dict_name_split = name.split('_')
@@ -79,15 +79,13 @@ class ArUcoMarkersDictionary():
self.__number = int(dict_name_split[2])
- self.__aruco_dict = aruco.Dictionary_get(all_aruco_markers_dictionaries[self.name])
+ self.__aruco_dict = aruco.Dictionary_get(all_aruco_markers_dictionaries[self.__name])
- def create_marker(self, i, dpi=300) -> numpy.array:
- """Create a marker image."""
-
- marker = numpy.zeros((dpi, dpi, 1), dtype="uint8")
- aruco.drawMarker(self.__aruco_dict, i, dpi, marker, 1)
+ @property
+ def name(self)-> str:
+ """Get dictionary name."""
- return numpy.repeat(marker, 3).reshape(dpi, dpi, 3)
+ return self.__name
@property
def markers(self)-> aruco.Dictionary:
@@ -107,6 +105,14 @@ class ArUcoMarkersDictionary():
return self.__number
+ def create_marker(self, i, dpi=300) -> numpy.array:
+ """Create a marker image."""
+
+ marker = numpy.zeros((dpi, dpi, 1), dtype="uint8")
+ aruco.drawMarker(self.__aruco_dict, i, dpi, marker, 1)
+
+ return numpy.repeat(marker, 3).reshape(dpi, dpi, 3)
+
def export_as_png(self, destination_folder, dpi, i):
"""Save one marker into a .png file."""
diff --git a/src/argaze/ArUcoMarkers/ArUcoTracker.py b/src/argaze/ArUcoMarkers/ArUcoTracker.py
index ef095f2..a1aba70 100644
--- a/src/argaze/ArUcoMarkers/ArUcoTracker.py
+++ b/src/argaze/ArUcoMarkers/ArUcoTracker.py
@@ -43,7 +43,7 @@ ArUcoTrackerParameters = [
]
"""All parameters are detailled on [opencv page](https://docs.opencv.org/4.x/d1/dcd/structcv_1_1aruco_1_1DetectorParameters.html)"""
-ArUcoMarker = TypeVar('ArUcoMarker', bound="ArUcoMarker")
+ArUcoMarkerType = TypeVar('ArUcoMarker', bound="ArUcoMarker")
# Type definition for type annotation convenience
class ArUcoTracker():
@@ -143,7 +143,7 @@ class ArUcoTracker():
self.__tracked_ids.append(marker_id)
@property
- def tracked_markers(self) -> dict[ArUcoMarker]:
+ def tracked_markers(self) -> dict[ArUcoMarkerType]:
"""Access to tracked markers dictionary."""
return self.__tracked_markers
diff --git a/src/argaze/AreaOfInterest/AOI3DScene.py b/src/argaze/AreaOfInterest/AOI3DScene.py
index 37bc1e2..ba0c18c 100644
--- a/src/argaze/AreaOfInterest/AOI3DScene.py
+++ b/src/argaze/AreaOfInterest/AOI3DScene.py
@@ -24,10 +24,10 @@ K0 = numpy.array([[1., 0., 1.], [0., 1., 1.], [0., 0., 1.]])
D0 = numpy.array([0.0, 0.0, 0.0, 0.0, 0.0])
"""Define a zero distorsion matrix."""
-Self = TypeVar('Self', bound="AOI3DScene")
+AOI3DSceneType = TypeVar('AOI3DScene', bound="AOI3DScene")
# Type definition for type annotation convenience
-AOI2DScene = TypeVar('AOI2DScene', bound="AOI2DScene")
+AOI2DSceneType = TypeVar('AOI2DScene', bound="AOI2DScene")
# Type definition for type annotation convenience
@dataclass
@@ -141,7 +141,7 @@ class AOI3DScene(AOIFeatures.AOIScene):
file.write('s off\n')
file.write(vertices_ids + '\n')
- def vision_cone(self, cone_radius, cone_height, cone_tip=[0., 0., 0.], cone_direction=[0., 0., 1.]) -> Tuple[Self, Self]:
+ def vision_cone(self, cone_radius, cone_height, cone_tip=[0., 0., 0.], cone_direction=[0., 0., 1.]) -> Tuple[AOI3DSceneType, AOI3DSceneType]:
"""Get AOI which are inside and out a given cone field.
.. note:: By default
@@ -196,7 +196,7 @@ class AOI3DScene(AOIFeatures.AOIScene):
return aoi2D_scene
- def transform(self, T=T0, R=D0) -> Self:
+ def transform(self, T=T0, R=D0) -> AOI3DSceneType:
"""Translate and/or rotate 3D scene."""
aoi3D_scene = AOI3DScene()
diff --git a/src/argaze/AreaOfInterest/AOIFeatures.py b/src/argaze/AreaOfInterest/AOIFeatures.py
index 9c04095..28747e0 100644
--- a/src/argaze/AreaOfInterest/AOIFeatures.py
+++ b/src/argaze/AreaOfInterest/AOIFeatures.py
@@ -11,7 +11,7 @@ import numpy
from shapely.geometry import Polygon
from shapely.geometry.point import Point
-SelfArea = TypeVar('Self', bound="AreaOfInterest")
+AreaOfInterestType = TypeVar('AreaOfInterest', bound="AreaOfInterest")
# Type definition for type annotation convenience
@dataclass
@@ -39,14 +39,14 @@ class AreaOfInterest(numpy.ndarray):
return self.mean(axis=0)
- def clockwise(self) -> SelfArea:
+ def clockwise(self) -> AreaOfInterestType:
"""Get area points in clocwise order.
.. warning::
Available for 2D AOI only."""
- assert(self.dimension() == 2)
+ assert(self.dimension == 2)
- O = self.center()
+ O = self.center
OP = (self - O) / numpy.linalg.norm(self - O)
angles = numpy.arctan2(OP[:, 1], OP[:, 0])
@@ -57,7 +57,7 @@ class AreaOfInterest(numpy.ndarray):
.. warning::
Available for 2D AOI only."""
- assert(self.dimension() == 2)
+ assert(self.dimension == 2)
return mpath.Path(self).contains_points([tuple(gaze_position)])[0]
@@ -66,7 +66,7 @@ class AreaOfInterest(numpy.ndarray):
.. warning::
Available for 2D AOI only."""
- assert(self.dimension() == 2)
+ assert(self.dimension == 2)
Src = self.clockwise()
Src_origin = Src[0]
@@ -87,7 +87,7 @@ class AreaOfInterest(numpy.ndarray):
.. warning::
Available for 2D AOI only."""
- assert(self.dimension() == 2)
+ assert(self.dimension == 2)
Src = numpy.array([[0., 0.], [1., 0.], [1., 1.], [0., 1.]]).astype(numpy.float32)
@@ -108,7 +108,7 @@ class AreaOfInterest(numpy.ndarray):
.. warning::
Available for 2D AOI only."""
- assert(self.dimension() == 2)
+ assert(self.dimension == 2)
self_polygon = Polygon(self)
gaze_circle = Point(gaze_position).buffer(gaze_position.accuracy)
@@ -132,7 +132,7 @@ class AreaOfInterest(numpy.ndarray):
.. warning::
Available for 2D AOI only."""
- assert(self.dimension() == 2)
+ assert(self.dimension == 2)
if len(self) > 1:
@@ -143,10 +143,10 @@ class AreaOfInterest(numpy.ndarray):
cv.line(frame, A, B, color, border_size)
# Draw center
- center_pixel = numpy.rint(self.center()).astype(int)
+ center_pixel = numpy.rint(self.center).astype(int)
cv.circle(frame, center_pixel, 1, color, -1)
-SelfScene = TypeVar('Self', bound="AOIScene")
+AOISceneType = TypeVar('AOIScene', bound="AOIScene")
# Type definition for type annotation convenience
@dataclass
@@ -218,7 +218,7 @@ class AOIScene():
return max_bounds - min_bounds
- def copy(self, exclude=[]) -> SelfScene:
+ def copy(self, exclude=[]) -> AOISceneType:
"""Copy scene partly excluding aoi by name."""
scene_copy = type(self)()
@@ -245,7 +245,7 @@ class TimeStampedAOIScenes(DataStructures.TimeStampedBuffer):
def __setitem__(self, ts, scene):
"""Force value to inherit from AOIScene."""
- assert(type(value).__bases__[0] == AOIScene)
+ assert(type(scene).__bases__[0] == AOIScene)
super().__setitem__(ts, scene)
diff --git a/src/argaze/DataStructures.py b/src/argaze/DataStructures.py
index e93dc9f..2a8aed1 100644
--- a/src/argaze/DataStructures.py
+++ b/src/argaze/DataStructures.py
@@ -9,13 +9,13 @@ import pandas
import matplotlib.pyplot as mpyplot
import matplotlib.patches as mpatches
-TimeStamp = TypeVar('TimeStamp', int, float)
+TimeStampType = TypeVar('TimeStamp', int, float)
"""Type definition for timestamp as integer or float values."""
-Data = TypeVar('Data')
+DataType = TypeVar('Data')
"""Type definition for data to store anything in time."""
-Self = TypeVar('Self', bound="TimeStampedBuffer")
+TimeStampedBufferType = TypeVar('TimeStampedBuffer', bound="TimeStampedBuffer")
# Type definition for type annotation convenience
class TimeStampedBuffer(collections.OrderedDict):
@@ -40,7 +40,7 @@ class TimeStampedBuffer(collections.OrderedDict):
return super(TimeStampedBuffer, cls).__new__(cls)
- def __setitem__(self, ts: TimeStamp, data: Data):
+ def __setitem__(self, ts: TimeStampType, data: DataType):
"""Store data at given timestamp."""
assert(type(ts) == int or type(ts) == float)
@@ -52,23 +52,23 @@ class TimeStampedBuffer(collections.OrderedDict):
return json.dumps(self, default=vars)
- def append(self, timestamped_buffer: Self):
+ def append(self, timestamped_buffer: TimeStampedBufferType):
"""Append a timestamped buffer."""
for ts, value in timestamped_buffer.items():
self[ts] = value
- def get_first(self) -> Tuple[TimeStamp, Data]:
+ def get_first(self) -> Tuple[TimeStampType, DataType]:
"""Easing access to first item."""
return list(self.items())[0]
- def pop_first(self) -> Tuple[TimeStamp, Data]:
+ def pop_first(self) -> Tuple[TimeStampType, DataType]:
"""Easing FIFO access mode."""
return self.popitem(last=False)
- def pop_first_until(self, ts: TimeStamp) -> Tuple[TimeStamp, Data]:
+ def pop_first_until(self, ts: TimeStampType) -> Tuple[TimeStampType, DataType]:
"""Pop all item until a given timestamped value and return the last poped item."""
# get last timestamp before given timestamp
@@ -85,17 +85,17 @@ class TimeStampedBuffer(collections.OrderedDict):
return popep_ts, poped_value
- def get_last(self) -> Tuple[TimeStamp, Data]:
+ def get_last(self) -> Tuple[TimeStampType, DataType]:
"""Easing access to last item."""
return list(self.items())[-1]
- def pop_last(self) -> Tuple[TimeStamp, Data]:
+ def pop_last(self) -> Tuple[TimeStampType, DataType]:
"""Easing FIFO access mode."""
return self.popitem(last=True)
- def get_last_before(self, ts) -> Tuple[TimeStamp, Data] | None:
+ def get_last_before(self, ts) -> Tuple[TimeStampType, DataType] | None:
"""Retreive last item timestamp before a given timestamp value."""
ts_list = list(self.keys())
diff --git a/src/argaze/TobiiGlassesPro2/TobiiEntities.py b/src/argaze/TobiiGlassesPro2/TobiiEntities.py
index 4516b2e..404f6d0 100644
--- a/src/argaze/TobiiGlassesPro2/TobiiEntities.py
+++ b/src/argaze/TobiiGlassesPro2/TobiiEntities.py
@@ -27,7 +27,7 @@ TOBII_SEGMENT_INFO_FILENAME = "segment.json"
TOBII_SEGMENT_VIDEO_FILENAME = "fullstream.mp4"
TOBII_SEGMENT_DATA_FILENAME = "livedata.json.gz"
-Datetime = TypeVar('datetime', bound="datetime")
+DatetimeType = TypeVar('datetime', bound="datetime")
# Type definition for type annotation convenience
class TobiiSegment:
@@ -81,13 +81,13 @@ class TobiiSegment:
return self.__end_timestamp
@property
- def start_date(self) -> Datetime:
+ def start_date(self) -> DatetimeType:
"""Get the date when the segment has started."""
return self.__start_date
@property
- def stop_date(self) -> Datetime:
+ def stop_date(self) -> DatetimeType:
"""Get the date when the segment has stopped."""
return self.__stop_date
@@ -149,7 +149,7 @@ class TobiiRecording:
return self.__name
@property
- def creation_date(self) -> Datetime:
+ def creation_date(self) -> DatetimeType:
"""Get date when the recording has been done."""
return self.__creation_date
@@ -275,7 +275,7 @@ class TobiiProject:
return self.__name
@property
- def creation_date(self) -> Datetime:
+ def creation_date(self) -> DatetimeType:
"""Get date when the project has been created."""
return self.__creation_date
diff --git a/src/argaze/TobiiGlassesPro2/TobiiNetworkInterface.py b/src/argaze/TobiiGlassesPro2/TobiiNetworkInterface.py
index 1576975..c65b121 100644
--- a/src/argaze/TobiiGlassesPro2/TobiiNetworkInterface.py
+++ b/src/argaze/TobiiGlassesPro2/TobiiNetworkInterface.py
@@ -29,7 +29,7 @@ except ImportError:
socket.IPPROTO_IPV6 = 41
-Socket = TypeVar('socket', bound="socket")
+SocketType = TypeVar('socket', bound="socket")
# Type definition for type annotation convenience
class TobiiNetworkInterface():
@@ -67,7 +67,7 @@ class TobiiNetworkInterface():
self.__peer = (self.address, self.udpport)
- def make_socket(self) -> Socket:
+ def make_socket(self) -> SocketType:
"""Create a socket to enable network communication."""
iptype = socket.AF_INET
diff --git a/src/argaze/TobiiGlassesPro2/TobiiVideo.py b/src/argaze/TobiiGlassesPro2/TobiiVideo.py
index cf1d995..665f3d3 100644
--- a/src/argaze/TobiiGlassesPro2/TobiiVideo.py
+++ b/src/argaze/TobiiGlassesPro2/TobiiVideo.py
@@ -14,10 +14,10 @@ import cv2 as cv
import av
import numpy
-Self = TypeVar('Self', bound="TobiiVideoFrame")
+TobiiVideoFrameType = TypeVar('TobiiVideoFrame', bound="TobiiVideoFrame")
# Type definition for type annotation convenience
-Stream = TypeVar('av.stream', bound="av.stream")
+AvStreamType = TypeVar('av.stream.Stream', bound="av.stream.Stream")
# Type definition for type annotation convenience
@dataclass
@@ -38,7 +38,7 @@ class TobiiVideoFrame():
self.height, self.width = self.matrix.shape[:2]
- def copy(self) -> Self:
+ def copy(self) -> TobiiVideoFrameType:
"""Copy tobii video frame."""
return TobiiVideoFrame(self.matrix.copy())
@@ -91,7 +91,7 @@ class TobiiVideoSegment():
return self.__height
@property
- def stream(self) -> Stream:
+ def stream(self) -> AvStreamType:
"""Video stream."""
return self.__stream
diff --git a/src/argaze/utils/aruco_calibration_board_export.py b/src/argaze/utils/aruco_calibration_board_export.py
index 42d75c1..43653b1 100644
--- a/src/argaze/utils/aruco_calibration_board_export.py
+++ b/src/argaze/utils/aruco_calibration_board_export.py
@@ -15,7 +15,7 @@ def main():
parser.add_argument('square_size', metavar='SQUARE_SIZE', type=int, default=5, help='square size (cm)')
parser.add_argument('marker_size', metavar='MARKER_SIZE', type=int, default=3, help='marker size (cm)')
parser.add_argument('-o', '--output', metavar='OUT', type=str, default='.', help='destination path')
- parser.add_argument('-d', '--dictionary', metavar='DICT', type=ArUcoMarkersDictionary.ArUcoMarkersDictionary, default='DICT_ARUCO_ORIGINAL', help='aruco marker dictionnary (DICT_4X4_50, DICT_4X4_100, DICT_4X4_250, DICT_4X4_1000, DICT_5X5_50, DICT_5X5_100, DICT_5X5_250, DICT_5X5_1000, DICT_6X6_50, DICT_6X6_100, DICT_6X6_250, DICT_6X6_1000, DICT_7X7_50, DICT_7X7_100, DICT_7X7_250, DICT_7X7_1000, DICT_ARUCO_ORIGINAL,DICT_APRILTAG_16h5, DICT_APRILTAG_25h9, DICT_APRILTAG_36h10, DICT_APRILTAG_36h11)')
+ parser.add_argument('-d', '--dictionary', metavar='DICT', type=ArUcoMarkersDictionary.ArUcoMarkersDictionary, default='DICT_ARUCO_ORIGINAL', help='aruco marker dictionnary (DICT_4X4_50, DICT_4X4_100, DICT_4X4_250, DICT_4X4_1000, DICT_5X5_50, DICT_5X5_100, DICT_5X5_250, DICT_5X5_1000, DICT_6X6_50, DICT_6X6_100, DICT_6X6_250, DICT_6X6_1000, DICT_7X7_50, DICT_7X7_100, DICT_7X7_250, DICT_7X7_1000, DICT_ARUCO_ORIGINAL, DICT_APRILTAG_16h5, DICT_APRILTAG_25h9, DICT_APRILTAG_36h10, DICT_APRILTAG_36h11)')
parser.add_argument('-r', '--resolution', metavar='RES', type=int, default=50, help='picture resolution in dpi')
args = parser.parse_args()
diff --git a/src/argaze/utils/aruco_markers_export.py b/src/argaze/utils/aruco_markers_export.py
index 78c996f..ce68761 100644
--- a/src/argaze/utils/aruco_markers_export.py
+++ b/src/argaze/utils/aruco_markers_export.py
@@ -11,7 +11,7 @@ def main():
# manage arguments
parser = argparse.ArgumentParser(description=main.__doc__)
parser.add_argument('-o', '--output', metavar='OUT', type=str, default='.', help='destination path')
- parser.add_argument('-d', '--dictionary', metavar='DICT', type=str, default='DICT_ARUCO_ORIGINAL', help='aruco marker dictionnary (DICT_4X4_50, DICT_4X4_100, DICT_4X4_250, DICT_4X4_1000, DICT_5X5_50, DICT_5X5_100, DICT_5X5_250, DICT_5X5_1000, DICT_6X6_50, DICT_6X6_100, DICT_6X6_250, DICT_6X6_1000, DICT_7X7_50, DICT_7X7_100, DICT_7X7_250, DICT_7X7_1000, DICT_ARUCO_ORIGINAL,DICT_APRILTAG_16h5, DICT_APRILTAG_25h9, DICT_APRILTAG_36h10, DICT_APRILTAG_36h11)')
+ parser.add_argument('-d', '--dictionary', metavar='DICT', type=ArUcoMarkersDictionary.ArUcoMarkersDictionary, default='DICT_ARUCO_ORIGINAL', help='aruco marker dictionnary (DICT_4X4_50, DICT_4X4_100, DICT_4X4_250, DICT_4X4_1000, DICT_5X5_50, DICT_5X5_100, DICT_5X5_250, DICT_5X5_1000, DICT_6X6_50, DICT_6X6_100, DICT_6X6_250, DICT_6X6_1000, DICT_7X7_50, DICT_7X7_100, DICT_7X7_250, DICT_7X7_1000, DICT_ARUCO_ORIGINAL, DICT_APRILTAG_16h5, DICT_APRILTAG_25h9, DICT_APRILTAG_36h10, DICT_APRILTAG_36h11)')
parser.add_argument('-r', '--resolution', metavar='RES', type=int, default=300, help='picture resolution in dpi')
args = parser.parse_args()
@@ -20,11 +20,8 @@ def main():
os.makedirs(args.output)
print(f'{args.output} folder created')
- # create aruco markers dictionary
- aruco_markers_dict = ArUcoMarkersDictionary.ArUcoMarkersDictionary(args.dictionary)
-
# export markers
- aruco_markers_dict.export_all(args.output, args.resolution)
+ args.dictionary.export_all(args.output, args.resolution)
if __name__ == '__main__':
diff --git a/src/argaze/utils/tobii_segment_aruco_aoi_edit.py b/src/argaze/utils/tobii_segment_aruco_aoi_edit.py
index f25138c..57ac756 100644
--- a/src/argaze/utils/tobii_segment_aruco_aoi_edit.py
+++ b/src/argaze/utils/tobii_segment_aruco_aoi_edit.py
@@ -26,7 +26,7 @@ def main():
parser.add_argument('-r', '--time_range', metavar=('START_TIME', 'END_TIME'), nargs=2, type=float, default=(0., None), help='start and end time (in second)')
parser.add_argument('-c', '--camera_calibration', metavar='CAM_CALIB', type=str, default=None, help='json camera calibration filepath')
parser.add_argument('-p', '--aruco_tracker_configuration', metavar='TRACK_CONFIG', type=str, default=None, help='json aruco tracker configuration filepath')
- parser.add_argument('-md', '--marker_dictionary', metavar='MARKER_DICT', type=str, default='DICT_ARUCO_ORIGINAL', help='aruco marker dictionnary (DICT_4X4_50, DICT_4X4_100, DICT_4X4_250, DICT_4X4_1000, DICT_5X5_50, DICT_5X5_100, DICT_5X5_250, DICT_5X5_1000, DICT_6X6_50, DICT_6X6_100, DICT_6X6_250, DICT_6X6_1000, DICT_7X7_50, DICT_7X7_100, DICT_7X7_250, DICT_7X7_1000, DICT_ARUCO_ORIGINAL,DICT_APRILTAG_16h5, DICT_APRILTAG_25h9, DICT_APRILTAG_36h10, DICT_APRILTAG_36h11)')
+ parser.add_argument('-md', '--marker_dictionary', metavar='MARKER_DICT', type=ArUcoMarkersDictionary.ArUcoMarkersDictionary, default='DICT_ARUCO_ORIGINAL', help='aruco marker dictionnary (DICT_4X4_50, DICT_4X4_100, DICT_4X4_250, DICT_4X4_1000, DICT_5X5_50, DICT_5X5_100, DICT_5X5_250, DICT_5X5_1000, DICT_6X6_50, DICT_6X6_100, DICT_6X6_250, DICT_6X6_1000, DICT_7X7_50, DICT_7X7_100, DICT_7X7_250, DICT_7X7_1000, DICT_ARUCO_ORIGINAL, DICT_APRILTAG_16h5, DICT_APRILTAG_25h9, DICT_APRILTAG_36h10, DICT_APRILTAG_36h11)')
parser.add_argument('-ms', '--marker_size', metavar='MARKER_SIZE', type=float, default=6, help='aruco marker size (cm)')
parser.add_argument('-mi', '--marker_id_scene', metavar='MARKER_ID_SCENE', type=json.loads, help='{"marker": "aoi scene filepath"} dictionary')
parser.add_argument('-o', '--output', metavar='OUT', type=str, default=None, help='destination folder path (segment folder by default)')
@@ -37,9 +37,9 @@ def main():
# Manage markers id to track
if args.marker_id_scene == None:
- print(f'Track any Aruco markers from the {args.marker_dictionary} dictionary')
+ print(f'Track any Aruco markers from the {args.marker_dictionary.name} dictionary')
else:
- print(f'Track Aruco markers {list(args.marker_id_scene.keys())} from the {args.marker_dictionary} dictionary')
+ print(f'Track Aruco markers {list(args.marker_id_scene.keys())} from the {args.marker_dictionary.name} dictionary')
# Manage destination path
destination_path = '.'
@@ -76,7 +76,7 @@ def main():
# Load a tobii segment video
tobii_segment_video = tobii_segment.load_video()
- print(f'Video properties:\n\tduration: {tobii_segment_video.get_duration()/1e6} s\n\twidth: {tobii_segment_video.get_width()} px\n\theight: {tobii_segment_video.get_height()} px')
+ print(f'Video properties:\n\tduration: {tobii_segment_video.duration/1e6} s\n\twidth: {tobii_segment_video.width} px\n\theight: {tobii_segment_video.height} px')
# Create aruco camera
aruco_camera = ArUcoCamera.ArUcoCamera()
@@ -100,7 +100,7 @@ def main():
aruco_tracker.load_configuration_file(args.aruco_tracker_configuration)
- print(f'ArUcoTracker configuration for {aruco_tracker.get_markers_dictionay().get_markers_format()} markers detection:')
+ print(f'ArUcoTracker configuration for {args.marker_dictionary.name} markers detection:')
aruco_tracker.print_configuration()
load_configuration_file()
@@ -133,7 +133,7 @@ def main():
# Display first frame
video_ts, video_frame = tobii_segment_video.get_frame(0)
- cv.imshow(f'Segment {tobii_segment.get_id()} ArUco marker editor', video_frame.matrix)
+ cv.imshow(f'Segment {tobii_segment.id} ArUco marker editor', video_frame.matrix)
# Init mouse interaction variables
pointer = (0, 0)
@@ -217,7 +217,7 @@ def main():
aruco_tracker.draw(visu_frame.matrix)
# Project 3D scene on each video frame and the visualisation frame
- if aruco_tracker.get_markers_number():
+ if aruco_tracker.markers_number():
# Write detected marker ids
cv.putText(visu_frame.matrix, f'Detected markers: {aruco_tracker.get_markers_ids()}', (20, visu_frame.height - 40), cv.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv.LINE_AA)
diff --git a/src/argaze/utils/tobii_segment_aruco_aoi_export.py b/src/argaze/utils/tobii_segment_aruco_aoi_export.py
index cd1a6b6..7d4931e 100644
--- a/src/argaze/utils/tobii_segment_aruco_aoi_export.py
+++ b/src/argaze/utils/tobii_segment_aruco_aoi_export.py
@@ -27,7 +27,7 @@ def main():
parser.add_argument('-r', '--time_range', metavar=('START_TIME', 'END_TIME'), nargs=2, type=float, default=(0., None), help='start and end time (in second)')
parser.add_argument('-c', '--camera_calibration', metavar='CAM_CALIB', type=str, default=None, help='json camera calibration filepath')
parser.add_argument('-p', '--aruco_tracker_configuration', metavar='TRACK_CONFIG', type=str, default=None, help='json aruco tracker configuration filepath')
- parser.add_argument('-md', '--marker_dictionary', metavar='MARKER_DICT', type=str, default='DICT_ARUCO_ORIGINAL', help='aruco marker dictionnary (DICT_4X4_50, DICT_4X4_100, DICT_4X4_250, DICT_4X4_1000, DICT_5X5_50, DICT_5X5_100, DICT_5X5_250, DICT_5X5_1000, DICT_6X6_50, DICT_6X6_100, DICT_6X6_250, DICT_6X6_1000, DICT_7X7_50, DICT_7X7_100, DICT_7X7_250, DICT_7X7_1000, DICT_ARUCO_ORIGINAL,DICT_APRILTAG_16h5, DICT_APRILTAG_25h9, DICT_APRILTAG_36h10, DICT_APRILTAG_36h11)')
+ parser.add_argument('-md', '--marker_dictionary', metavar='MARKER_DICT', type=ArUcoMarkersDictionary.ArUcoMarkersDictionary, default='DICT_ARUCO_ORIGINAL', help='aruco marker dictionnary (DICT_4X4_50, DICT_4X4_100, DICT_4X4_250, DICT_4X4_1000, DICT_5X5_50, DICT_5X5_100, DICT_5X5_250, DICT_5X5_1000, DICT_6X6_50, DICT_6X6_100, DICT_6X6_250, DICT_6X6_1000, DICT_7X7_50, DICT_7X7_100, DICT_7X7_250, DICT_7X7_1000, DICT_ARUCO_ORIGINAL, DICT_APRILTAG_16h5, DICT_APRILTAG_25h9, DICT_APRILTAG_36h10, DICT_APRILTAG_36h11)')
parser.add_argument('-ms', '--marker_size', metavar='MARKER_SIZE', type=float, default=6, help='aruco marker size (cm)')
parser.add_argument('-mi', '--marker_id_scene', metavar='MARKER_ID_SCENE', type=json.loads, help='{"marker": "aoi scene filepath"} dictionary')
parser.add_argument('-o', '--output', metavar='OUT', type=str, default=None, help='destination folder path (segment folder by default)')
@@ -78,7 +78,7 @@ def main():
# Load a tobii segment video
tobii_segment_video = tobii_segment.load_video()
- print(f'Video properties:\n\tduration: {tobii_segment_video.get_duration()/1e6} s\n\twidth: {tobii_segment_video.get_width()} px\n\theight: {tobii_segment_video.get_height()} px')
+ print(f'Video properties:\n\tduration: {tobii_segment_video.duration/1e6} s\n\twidth: {tobii_segment_video.width} px\n\theight: {tobii_segment_video.height} px')
# Load a tobii segment data
tobii_segment_data = tobii_segment.load_data()
@@ -193,7 +193,7 @@ def main():
aruco_tracker.draw(visu_frame.matrix)
# When no marker is detected, no AOI scene projection can't be done
- if aruco_tracker.get_markers_number() == 0:
+ if aruco_tracker.markers_number() == 0:
ts_aois_scenes[round(video_ts_ms)] = AOIFeatures.EmptyAOIScene()
diff --git a/src/argaze/utils/tobii_stream_aruco_aoi_display.py b/src/argaze/utils/tobii_stream_aruco_aoi_display.py
index 77f3c7b..dbe1c5f 100644
--- a/src/argaze/utils/tobii_stream_aruco_aoi_display.py
+++ b/src/argaze/utils/tobii_stream_aruco_aoi_display.py
@@ -24,7 +24,7 @@ def main():
parser.add_argument('-t', '--tobii_ip', metavar='TOBII_IP', type=str, default=None, help='tobii glasses ip')
parser.add_argument('-c', '--camera_calibration', metavar='CAM_CALIB', type=str, default=None, help='json camera calibration filepath')
parser.add_argument('-p', '--aruco_tracker_configuration', metavar='TRACK_CONFIG', type=str, default=None, help='json aruco tracker configuration filepath')
- parser.add_argument('-md', '--marker_dictionary', metavar='MARKER_DICT', type=str, default='DICT_ARUCO_ORIGINAL', help='aruco marker dictionnary (DICT_4X4_50, DICT_4X4_100, DICT_4X4_250, DICT_4X4_1000, DICT_5X5_50, DICT_5X5_100, DICT_5X5_250, DICT_5X5_1000, DICT_6X6_50, DICT_6X6_100, DICT_6X6_250, DICT_6X6_1000, DICT_7X7_50, DICT_7X7_100, DICT_7X7_250, DICT_7X7_1000, DICT_ARUCO_ORIGINAL,DICT_APRILTAG_16h5, DICT_APRILTAG_25h9, DICT_APRILTAG_36h10, DICT_APRILTAG_36h11)')
+ parser.add_argument('-md', '--marker_dictionary', metavar='MARKER_DICT', type=ArUcoMarkersDictionary.ArUcoMarkersDictionary, default='DICT_ARUCO_ORIGINAL', help='aruco marker dictionnary (DICT_4X4_50, DICT_4X4_100, DICT_4X4_250, DICT_4X4_1000, DICT_5X5_50, DICT_5X5_100, DICT_5X5_250, DICT_5X5_1000, DICT_6X6_50, DICT_6X6_100, DICT_6X6_250, DICT_6X6_1000, DICT_7X7_50, DICT_7X7_100, DICT_7X7_250, DICT_7X7_1000, DICT_ARUCO_ORIGINAL,DICT_APRILTAG_16h5, DICT_APRILTAG_25h9, DICT_APRILTAG_36h10, DICT_APRILTAG_36h11)')
parser.add_argument('-ms', '--marker_size', metavar='MARKER_SIZE', type=float, default=6, help='aruco marker size (cm)')
parser.add_argument('-mi', '--marker_id_scene', metavar='MARKER_ID_SCENE', type=json.loads, help='{"marker": "aoi scene filepath"} dictionary')
parser.add_argument('-w', '--window', metavar='DISPLAY', type=bool, default=True, help='enable window display', action=argparse.BooleanOptionalAction)
@@ -32,9 +32,9 @@ def main():
# Manage markers id to track
if args.marker_id_scene == None:
- print(f'Track any Aruco markers from the {args.marker_dictionary} dictionary')
+ print(f'Track any Aruco markers from the {args.marker_dictionary.name} dictionary')
else:
- print(f'Track Aruco markers {list(args.marker_id_scene.keys())} from the {args.marker_dictionary} dictionary')
+ print(f'Track Aruco markers {list(args.marker_id_scene.keys())} from the {args.marker_dictionary.name} dictionary')
# Create tobii controller (with auto discovery network process if no ip argument is provided)
print("Looking for a Tobii Glasses Pro 2 device ...")
@@ -83,7 +83,7 @@ def main():
aruco_tracker.load_configuration_file(args.aruco_tracker_configuration)
- print(f'ArUcoTracker configuration for {aruco_tracker.get_markers_dictionay().get_markers_format()} markers detection:')
+ print(f'ArUcoTracker configuration for {args.marker_dictionary.name} markers detection:')
aruco_tracker.print_configuration()
# Load AOI 3D scene for each marker and create a AOI 2D scene and frame when a 'Visualisation_Plan' AOI exist
@@ -192,10 +192,10 @@ def main():
# Track markers with pose estimation and draw them
aruco_tracker.track(video_frame.matrix)
- aruco_tracker.draw(visu_frame.matrix)
+ aruco_tracker.draw_tracked_markers(visu_frame.matrix)
# When no marker is detected, no AOI scene projection can't be done
- if aruco_tracker.get_markers_number() == 0:
+ if aruco_tracker.tracked_markers_number == 0:
ts_aois_scenes[round(video_ts_ms)] = AOIFeatures.EmptyAOIScene()
@@ -205,7 +205,7 @@ def main():
aoi2D_dict = {}
# Project 3D scene on each video frame and the visualisation frame
- for (i, marker_id) in enumerate(aruco_tracker.get_markers_ids()):
+ for marker_id, marker in aruco_tracker.tracked_markers.items():
# Copy 3D scene related to detected marker
aoi3D_scene = aoi3D_scene_selector(marker_id)
@@ -214,7 +214,7 @@ def main():
continue
# Transform scene into camera referential
- aoi3D_camera = aoi3D_scene.transform(aruco_tracker.get_marker_translation(i), aruco_tracker.get_marker_rotation(i))
+ aoi3D_camera = aoi3D_scene.transform(marker.translation, marker.rotation)
# Get aoi inside vision cone field
cone_vision_height_cm = 200 # cm
@@ -227,7 +227,7 @@ def main():
# DON'T APPLY CAMERA DISTORSION : it projects points which are far from the frame into it
# This hack isn't realistic but as the gaze will mainly focus on centered AOI, where the distorsion is low, it is acceptable.
- aoi2D_video_scene = aoi3D_scene.project(aruco_tracker.get_marker_translation(i), aruco_tracker.get_marker_rotation(i), aruco_camera.get_K())
+ aoi2D_video_scene = aoi3D_scene.project(marker.translation, marker.rotation, aruco_camera.K)
# Store each 2D aoi for further scene merging
for name, aoi in aoi2D_video_scene.items():