Source code for Movie

# CellTracking.py
# By MW, Jun 2013
# GPLv3+
#
# Module containing the movie class

import imp, logging
Cells = imp.load_source("Cells", './bin/Movies/Cells/Cells.py')

[docs]class Movie : """Class representing a movie""" def __init__(self) : self.Channels = imp.load_source("Channels", './bin/Movies/Channels/Channels.py') # Loading the Movie class self.Cells = Cells.Cells(self)
[docs] def get_frame_nb(self) : """Function that returns the number of frames of the Loader""" channels = self.Channels.get_channels_dict() if len(channels) > 0 : return channels.values()[0].get_frame_nb() else : logging.error("No channel has been instanciated yet. Sorry")
[docs] def get_frame(self, index, channel, rgb=True) : """Return a frame (as a CV object) given its index and the channel where it comes from in the player. If rgb==True, the image is converted to rgb if needed: dimensions become: (size_x, size_y, 3)""" return self.Channels.get_channel(channel).get_frame(index, rgb)
[docs] def get_size(self) : channels = self.Channels.get_channels_dict() if len(channels) > 0 : return channels.values()[0].get_size() else : logging.error("No channel has been instanciated yet. Sorry")
[docs] def get_save_dict(self) : """Returns a documented object to save the movie""" dic = {} dic['channels'] = self.Channels.get_save_dict() dic['cells'] = self.Cells.get_save_dict() return {'descr' : 'Contains everything needed to instanciate a movie', 'value' : dic}
[docs] def load_save_dict(self, dic) : self.Channels.load_save_dict(dic['value']['channels']) self.Cells.load_save_dict(dic['value']['cells'])