From 03121b152e5252beb3696eb121d5de96ac2acb92 Mon Sep 17 00:00:00 2001
From: Olegs NIKISINS <onikisins@italix03.idiap.ch>
Date: Mon, 12 Mar 2018 15:44:41 +0100
Subject: [PATCH] Updated BATL HLDI, load and annotations methods

---
 bob/pad/face/database/batl.py | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/bob/pad/face/database/batl.py b/bob/pad/face/database/batl.py
index 986dc7f0..6a3fda6a 100644
--- a/bob/pad/face/database/batl.py
+++ b/bob/pad/face/database/batl.py
@@ -28,7 +28,8 @@ class BatlPadFile(PadFile):
                  reference_stream_type="color",
                  warp_to_reference=True,
                  convert_to_rgb=False,
-                 crop=None):
+                 crop=None,
+                 video_data_only=True):
 
         """
         Parameters
@@ -58,6 +59,7 @@ class BatlPadFile(PadFile):
         self.warp_to_reference = warp_to_reference  # True
         self.convert_to_rgb = convert_to_rgb  # False
         self.crop = crop  # None
+        self.video_data_only = video_data_only # return video data only if True
 
 
     def load(self, directory=None, extension='.hdf5', frame_selector=FrameSelector(selection_style='all')):
@@ -74,6 +76,11 @@ class BatlPadFile(PadFile):
         for modality in data.keys():
             if modality != 'rppg':
                 data[modality] = frame_selector(data[modality])
+
+        if self.video_data_only:
+
+            data = data['video']
+
         return data
 
 
@@ -241,18 +248,18 @@ class BatlPadDatabase(PadDatabase):
 
         if not os.path.isfile(file_path): # no file with annotations
 
-            video = f.f.load(self, directory=self.original_directory,
-                             extension=self.original_extension,
-                             modality="color", # TODO: this parameter is currently missing in bob.db.batl, add it there
-                             reference_stream_type="color",
-                             warp_to_reference=False,
-                             convert_to_rgb=False,
-                             crop=None,
-                             max_frames=None)
+            video = f.f.load(directory=self.original_directory,
+                           extension=self.original_extension,
+                           modality="color", # TODO: this parameter is currently missing in bob.db.batl, add it there
+                           reference_stream_type="color",
+                           warp_to_reference=False,
+                           convert_to_rgb=False,
+                           crop=None,
+                           max_frames=None)['video']
 
             annotations = {}
 
-            for idx, image in enumerate(video):
+            for idx, image in enumerate(video.as_array()):
 
                 frame_annotations = detect_face_landmarks_in_image(image, method = self.landmark_detect_method)
 
-- 
GitLab