aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2023-07-05 08:43:49 +0200
committerThéo de la Hogue2023-07-05 08:43:49 +0200
commit9d17503829fcfbffcd52f3d822c80291bd1bed19 (patch)
tree1dceab1a1e20b98d38f53d958f1fc9a477fec2a5
parent9e0c55061137e5be053bb837449c8eb413086428 (diff)
downloadargaze-9d17503829fcfbffcd52f3d822c80291bd1bed19.zip
argaze-9d17503829fcfbffcd52f3d822c80291bd1bed19.tar.gz
argaze-9d17503829fcfbffcd52f3d822c80291bd1bed19.tar.bz2
argaze-9d17503829fcfbffcd52f3d822c80291bd1bed19.tar.xz
Assessing aruco detection time.
-rw-r--r--src/argaze/ArUcoMarkers/ArUcoDetector.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/argaze/ArUcoMarkers/ArUcoDetector.py b/src/argaze/ArUcoMarkers/ArUcoDetector.py
index b9ee077..723bc26 100644
--- a/src/argaze/ArUcoMarkers/ArUcoDetector.py
+++ b/src/argaze/ArUcoMarkers/ArUcoDetector.py
@@ -11,6 +11,7 @@ from typing import TypeVar, Tuple
from dataclasses import dataclass, field
import json
from collections import Counter
+import time
from argaze.ArUcoMarkers import ArUcoMarkersDictionary, ArUcoMarker, ArUcoOpticCalibrator
@@ -175,18 +176,27 @@ class ArUcoDetector():
return output
- def detect_markers(self, image: numpy.array):
+ def detect_markers(self, image: numpy.array) -> int:
"""Detect all ArUco markers into an image.
.. danger:: DON'T MIRROR IMAGE
It makes the markers detection to fail.
+
+ Returns:
+ - time: marker detection time in ms
"""
# Reset detected markers data
self.__detected_markers, self.__detected_markers_corners, self.__detected_markers_ids = {}, [], []
+ # Store marker detection start date
+ detection_start = time.time()
+
# Detect markers into gray picture
self.__detected_markers_corners, self.__detected_markers_ids, _ = aruco.detectMarkers(cv.cvtColor(image, cv.COLOR_BGR2GRAY), self.dictionary.markers, parameters = self.parameters.internal)
+
+ # Assess marker detection time in ms
+ detection_time = int((time.time() - detection_start) * 1e3)
# Is there detected markers ?
if len(self.__detected_markers_corners) > 0:
@@ -203,7 +213,7 @@ class ArUcoDetector():
marker.corners = self.__detected_markers_corners[i]
- # No pose estimation: call estimate_pose to get one
+ # No pose estimation: call estimate_markers_pose to get one
marker.translation = numpy.empty([0])
marker.rotation = numpy.empty([0])
marker.points = numpy.empty([0])
@@ -212,6 +222,8 @@ class ArUcoDetector():
self.__detected_ids.append(marker_id)
+ return detection_time
+
def estimate_markers_pose(self, markers_ids: list = []):
"""Estimate pose of current detected markers or of given markers id list."""