diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/argaze/ArFeatures.py | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py index 03082e6..6c9eab1 100644 --- a/src/argaze/ArFeatures.py +++ b/src/argaze/ArFeatures.py @@ -645,6 +645,10 @@ class ArFrame(): total_time += aoi_scan_step_analysis_time + if times['heatmap']: + + total_time += times['heatmap'] + times['total'] = total_time # Return look data @@ -1274,7 +1278,10 @@ class ArEnvironment(): return detection_time, exceptions def look(self, timestamp: int|float, gaze_position: GazeFeatures.GazePosition): - """Project timestamped gaze position into each frame.""" + """Project timestamped gaze position into each frame. + + .. warning:: detect_and_project method needs to be called first. + """ # Can't use camera frame when it is locked if self.__camera_frame_lock.locked(): @@ -1317,6 +1324,41 @@ class ArEnvironment(): # Unlock camera frame exploitation self.__camera_frame_lock.release() + def map(self): + """Project camera frame background into aoi frames background. + + .. warning:: detect_and_project method needs to be called first. + """ + + # Can't use camera frame when it is locked + if self.__camera_frame_lock.locked(): + return + + # Lock camera frame exploitation + self.__camera_frame_lock.acquire() + + # Project image if possible + for aoi_frame in self.aoi_frames: + + # Is aoi frame projected into camera frame ? + try: + + aoi_2d = self.camera_frame.aoi_2d_scene[aoi_frame.name] + + # Apply perspective transform algorithm to fill aoi frame background + width, height = aoi_frame.size + destination = numpy.float32([[0, height],[width, height],[width, 0],[0, 0]]) + mapping = cv2.getPerspectiveTransform(aoi_2d.astype(numpy.float32), destination) + aoi_frame.background = cv2.warpPerspective(self.camera_frame.background, mapping, (width, height)) + + # Ignore missing aoi frame projection + except KeyError: + + pass + + # Unlock camera frame exploitation + self.__camera_frame_lock.release() + def to_json(self, json_filepath): """Save environment to .json file.""" |