Skip to content
Snippets Groups Projects
Commit 9c12e2c3 authored by Anjith GEORGE's avatar Anjith GEORGE
Browse files

Merge branch 'bob9' into 'master'

Replace FrameCOntainer

See merge request !5
parents 222a93a8 38727f2e
No related branches found
No related tags found
1 merge request!5Replace FrameCOntainer
Pipeline #51901 passed
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import pkg_resources import pkg_resources
import numpy import numpy as np
from sqlalchemy import Table, Column, Integer, String, Boolean, Sequence, ForeignKey from sqlalchemy import Table, Column, Integer, String, Boolean, Sequence, ForeignKey
from sqlalchemy.orm import backref from sqlalchemy.orm import backref
...@@ -11,8 +11,10 @@ from sqlalchemy.ext.declarative import declarative_base ...@@ -11,8 +11,10 @@ from sqlalchemy.ext.declarative import declarative_base
from bob.db.base import File from bob.db.base import File
from bob.db.base.sqlalchemy_migration import Enum, relationship from bob.db.base.sqlalchemy_migration import Enum, relationship
from bob.bio.video import VideoLikeContainer
from bob.io.stream import StreamFile from bob.io.stream import StreamFile
from bob.bio.video import FrameContainer import bob.ip.stereo # It defines some streams operations (eg warp) that could be needed.
from .attack_dictionaries import idiap_type_id_config, idiap_subtype_id_config, idiap_pai_id_config from .attack_dictionaries import idiap_type_id_config, idiap_subtype_id_config, idiap_pai_id_config
...@@ -129,57 +131,31 @@ class VideoFile(Base, File): ...@@ -129,57 +131,31 @@ class VideoFile(Base, File):
------- -------
dict: dict:
Dictionary where the key is the stream and Dictionary where the key is the stream and
value is the data (i.e a FrameContainer). value is the data (i.e a VideoLikeContainer).
""" """
def convert_arrays_to_frame_container(data):
""" Convert an input into Frame Container. Inputs is an iterable.
.. warning:: This function already exists in ``bob.pad.face`` !
Parameters
----------
data: :py:class:`numpy.ndarray`
Array containing the data, where the first dimension is the frame
Returns
-------
bob.bio.video:FrameContainer
FrameContainer containing the frames data.
"""
frame_container = FrameContainer()
for idx, item in enumerate(data):
frame_container.add(idx, item)
return frame_container
stream_config_path = pkg_resources.resource_filename('bob.io.stream', 'config/idiap_face_streams.json') stream_config_path = pkg_resources.resource_filename('bob.io.stream', 'config/idiap_face_streams.json')
camera_config_path = pkg_resources.resource_filename('bob.ip.stereo', 'config/idiap_face_calibration.json') camera_config_path = pkg_resources.resource_filename('bob.ip.stereo', 'config/idiap_face_calibration.json')
file_path = self.make_path(directory, extension) file_path = self.make_path(directory, extension)
ret = {} ret = {}
assert isinstance(streams, dict) assert isinstance(streams, dict)
# set source stream_file = StreamFile(file_path, stream_config_path)
stream_file.set_camera_configs(camera_config_path) # bob.ip.stereo adds this method to StreamFile
stream_file = StreamFile(file_path, stream_config_path, camera_config_path)
for name, video in streams.items():
video.set_source(stream_file)
# load and process
for name, video in streams.items():
step = video.shape[0] // n_frames for name, stream in streams.items():
stream.set_source(stream_file)
step = stream.shape[0] // n_frames
# load data in format <frame, channel, height, width> # load data in format <frame, channel, height, width>
data = video.load(slice(0, video.shape[0], step)) data = stream.load(slice(0, stream.shape[0], step))
# remove the empty dimension if there is only one channel # remove the empty dimension if there is only one channel
if data.shape[1] == 1: if data.shape[1] == 1:
data = data[:, 0, :, :] data = data[:, 0, :, :]
ret[name] = convert_arrays_to_frame_container(data) ret[name] = VideoLikeContainer(data, range(data.shape[0])) # Keep a trace of the indices in the original array ?
return ret return ret
......
...@@ -30,26 +30,30 @@ requirements: ...@@ -30,26 +30,30 @@ requirements:
- bob.db.base - bob.db.base
- bob.io.base - bob.io.base
- bob.bio.video - bob.bio.video
- future
- matplotlib
- numpy
- scikit-image
- bob.io.stream - bob.io.stream
- scipy - bob.ip.stereo
- six - future
- sqlalchemy - matplotlib {{ matplotlib }}
- numpy {{ numpy }}
- scikit-image {{ scikit_image }}
- scipy {{ scipy }}
- six {{ six }}
- sqlalchemy {{ sqlalchemy }}
- dask {{ dask }}
- distributed {{ distributed }}
run: run:
- python - {{ pin_compatible('python') }}
- setuptools - {{ pin_compatible('setuptools') }}
- future - future
- matplotlib - {{ pin_compatible('matplotlib') }}
- numpy >=1.10 - {{ pin_compatible('numpy') }}
- scikit-image - {{ pin_compatible('scikit-image') }}
- bob.ip.stereo - {{ pin_compatible('scipy') }}
- bob.io.stream - {{ pin_compatible('sqlalchemy') }}
- scipy - {{ pin_compatible('six') }}
- six - {{ pin_compatible('dask') }}
- sqlalchemy - {{ pin_compatible('distributed') }}
test: test:
imports: imports:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment