Example #1
0
    def store(self, filename, app, settings=None):
        """Store the source into a file. It calls a function in the 'savers'
        dictionary by the suffix of a filename.

        Arguments:
        filename -- a name of a file (include a path where the data will be
        stored)
        app -- a reference to the main application

        Keywords:
        settings -- an optional argument where may be stored some users'
        setting information

        """
        suffix = utils.get_filename_suffix(filename)
        if suffix is None and self.type.default_saver is not None:
            suffix = self.type.default_saver
            filename += "." + suffix
        saver = self.type.savers.get(suffix)
        if saver is None:
            app.show_message_dialog(
                    "Cannot save '.{0}' file".format(suffix),
                    gtk.MESSAGE_WARNING)
            return

        correct, settings = saver(self.data, filename, app, settings)
        if correct:
            self.name = filename
            self.settings = settings
            self.stored = True
Example #2
0
def load_source(filename, app, settings=None):
    """Load the source from a file. It calls a function in the 'loaders'
    dictionary by the suffix of a filename.

    Arguments:
    filename -- a name of a file where are data stored
    app -- a reference to the main application

    Keywords:
    settings -- an optional argument where may be stored some users' setting
    information

    """

    # TODO: Catch IOError
    suffix = utils.get_filename_suffix(filename)
    loader = datatypes.get_loader_by_suffix(suffix)
    if loader is None:
        return None

    data, settings = loader(filename, app, settings)
    if data is None:
        return None
    return Source(
        filename, datatypes.get_type_by_suffix(suffix), data, True, settings)
Example #3
0
def load_source(filename, app, settings=None):
    """Load the source from a file. It calls a function in the 'loaders'
    dictionary by the suffix of a filename.

    Arguments:
    filename -- a name of a file where are data stored
    app -- a reference to the main application

    Keywords:
    settings -- an optional argument where may be stored some users' setting
    information

    """

    # TODO: Catch IOError
    suffix = utils.get_filename_suffix(filename)
    loader = datatypes.get_loader_by_suffix(suffix)
    if loader is None:
        return None

    data, settings = loader(filename, app, settings)
    if data is None:
        return None
    return Source(filename, datatypes.get_type_by_suffix(suffix), data, True,
                  settings)
Example #4
0
    def store(self, filename, app, settings=None):
        """Store the source into a file. It calls a function in the 'savers'
        dictionary by the suffix of a filename.

        Arguments:
        filename -- a name of a file (include a path where the data will be
        stored)
        app -- a reference to the main application

        Keywords:
        settings -- an optional argument where may be stored some users'
        setting information

        """
        suffix = utils.get_filename_suffix(filename)
        if suffix is None and self.type.default_saver is not None:
            suffix = self.type.default_saver
            filename += "." + suffix
        saver = self.type.savers.get(suffix)
        if saver is None:
            app.show_message_dialog("Cannot save '.{0}' file".format(suffix),
                                    gtk.MESSAGE_WARNING)
            return

        correct, settings = saver(self.data, filename, app, settings)
        if correct:
            self.name = filename
            self.settings = settings
            self.stored = True
Example #5
0
output_dir = '../data/KTH_jpg_0'
assert not os.path.isdir(output_dir), "The output dir exists."
os.mkdir(output_dir)

list_classes = os.listdir(input_video_dir)
if '.DS_Store' in list_classes:
    list_classes.remove('.DS_Store')

for cls in list_classes:
    path_cls = os.path.join(input_video_dir, cls)
    output_path_cls = os.path.join(output_dir, cls)
    os.mkdir(output_path_cls)
    list_videos = os.listdir(path_cls)
    for video_path in list_videos:
        capture = cv2.VideoCapture(os.path.join(path_cls, video_path))
        v_name, v_suffix = get_filename_suffix(video_path)
        v_count, v_fps, v_weight, v_hight = get_prop(capture)

        output_jpg_folder = os.path.join(output_path_cls, v_name)
        os.mkdir(output_jpg_folder)

        count = 0
        i = 0
        retaining = True
        print(v_name)
        while (count < v_count and retaining):
            retaining, frame = capture.read()
            if frame is None:
                continue

            cv2.imwrite(filename=os.path.join(output_jpg_folder,