aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/argaze/utils/contexts/TobiiProGlasses2.py55
1 files changed, 33 insertions, 22 deletions
diff --git a/src/argaze/utils/contexts/TobiiProGlasses2.py b/src/argaze/utils/contexts/TobiiProGlasses2.py
index c71a622..ec2fb6f 100644
--- a/src/argaze/utils/contexts/TobiiProGlasses2.py
+++ b/src/argaze/utils/contexts/TobiiProGlasses2.py
@@ -350,6 +350,7 @@ class LiveStream(ArFeatures.LiveProcessingContext):
self.__calibration_status = None
self.__calibration_id = None
+ self.__recording_status = None
self.__recording_id = None
self.__configuration = {}
@@ -897,7 +898,9 @@ class LiveStream(ArFeatures.LiveProcessingContext):
def calibrate(self):
"""Handle whole Tobii glasses calibration process."""
+ # Reset calibration
self.__calibration_status = None
+ self.__calibration_id = None
# Calibration have to be done for a project and a participant
if self.__project_id is None or self.__participant_id is None:
@@ -948,7 +951,8 @@ class LiveStream(ArFeatures.LiveProcessingContext):
def create_recording(self, name: str = '', notes: str = ''):
"""Create a new recording on the Tobii interface's SD Card."""
- # Reset recording id
+ # Reset recording
+ self.__recording_status = None
self.__recording_id = None
# Recording have to be done for a participant
@@ -971,36 +975,29 @@ class LiveStream(ArFeatures.LiveProcessingContext):
def __wait_for_recording_status(self, recording_id, status_array=['init', 'starting', 'recording', 'pausing', 'paused', 'stopping', 'stopped', 'done', 'stale', 'failed']):
- return self.__wait_for_status('/api/recordings/' + recording_id + '/status', 'rec_state', status_array)
+ return self.__wait_for_status('/api/recordings/' + self.__recording_id + '/status', 'rec_state', status_array)
- def start_recording(self) -> bool:
+ def start_recording(self):
"""Start recording."""
self.__post_request('/api/recordings/' + self.__recording_id + '/start')
- return self.__wait_for_recording_status(self.__recording_id, ['recording']) == 'recording'
+ self.__recording_status = self.__wait_for_recording_status(self.__recording_id, ['recording'])
- def stop_recording(self) -> bool:
+ def stop_recording(self):
"""Stop recording."""
self.__post_request('/api/recordings/' + self.__recording_id + '/stop')
- return self.__wait_for_recording_status(self.__recording_id, ['done']) == "done"
+ self.__recording_status = self.__wait_for_recording_status(self.__recording_id, ['done'])
- def pause_recording(self) -> bool:
+ def pause_recording(self):
"""Pause recording."""
self.__post_request('/api/recordings/' + self.__recording_id + '/pause')
- return self.__wait_for_recording_status(self.__recording_id, ['paused']) == "paused"
-
- def is_recording(self) -> bool:
- """Is it recording?"""
-
- rec_status = self.get_system_status()['sys_recording']
-
- if rec_status != {}:
- if rec_status['rec_state'] == "recording":
- return True
+ self.__recording_status = self.__wait_for_recording_status(self.__recording_id, ['paused'])
- return False
+ def get_recording_status(self) -> str:
+
+ return self.__recording_status
def get_recordings(self) -> str:
"""Get all recordings' id."""
@@ -1074,12 +1071,27 @@ class LiveStream(ArFeatures.LiveProcessingContext):
else:
- self.__battery_level = (0, 0, 255)
+ text_color = (0, 0, 255)
if self.__battery_level > 0:
cv2.putText(image, f'Battery {self.__battery_level}%', (width - 220, 40), cv2.FONT_HERSHEY_SIMPLEX, 1, text_color, 1, cv2.LINE_AA)
+ # Display recording status
+ if self.__recording_status is None:
+
+ circle_color = (0, 0, 0)
+
+ elif self.__recording_status == 'recording':
+
+ circle_color = (0, 0, 255)
+
+ else:
+
+ circle_color = (0, 127, 127)
+
+ cv2.circle(image, (int(width/2) - 40, 25), 20, circle_color, -1)
+
return image
class PostProcessing(ArFeatures.PostProcessingContext):
@@ -1393,10 +1405,9 @@ class PostProcessing(ArFeatures.PostProcessingContext):
image = next(self.__video_file.decode(self.__video_file.streams.video[0]))
ts = int(image.time * 1e3)
- except Exception as e:
+ except Exception:
- # DEBUG
- print("DECODE ERROR:", e)
+ raise StopIteration
# Ignore image after required end timestamp
if self.end != None: