Giter Club home page Giter Club logo

video-labeler's Introduction

The idea behind the video-labeler is to tag time-window and point-activities.

  • Point-Activity: happens at a single point on a timeline (....TAG......TAG.....)
  • Time-Window: happens between two point on a timeline (...FIRST_TAG.....SECOND_TAG......)

Download following files:

https://sourceforge.net/projects/mpv-player-windows/files/

Tested and stable version (windows):

  • mpv-dev-x86_64-v3-20240211-git-f5c4f0b
  • mpv-x86_64-v3-20240211-git-f5c4f0b
  • 02.11.2024 stable version

Insert it into your python environment\Script. It should looks following:

Requirements

pip install -r requirements.txt

Folder Structure

├── data 
│   ├── .csv
│   └── .csv
├── videos 
│   ├── .mp4
│   ├── .avi
│   └── .                                   all types supported by mpv player
├── Hotkeys.png                             (if created)
├── commands_mpv.json                       (setting for mpv player)
├── label_shortcuts.json                    (hotkeys for labeling)
├── settings.json                           (hotkeys and settings for the app)
├── requirements.txt
└── video_labeler.py                        (run this to start)

Start app (Video Labeler)

python video_labeler.py

Class Description

  • Labeler
    • Check the init(). Loading and init everything. This class especially load all the .json files and set all the hotkeys. Also to bring everything together
  • ActivityHandler
    • Time-Window and Point-Activities are implemented within this class. Any new activities should be done here. Also populating the data-table.
  • AppFunctions
    • Any function that can be set up within settings.json is within this class.
  • HotkeyPlotter
    • Plotting an overview named Hotkeys.png. Also checks for duplicated Hotkeys. Marked as red inside image.
  • Layout
    • Creating all the widgets.
  • Logger
    • Handling logging-window (bottom left of the app).
  • MouseEventHandler
    • Any mouse-event that needs to be handled is done here.
---
title: Classes within video_labeler.py
---
classDiagram
    Labeler <|-- ActivityHandler
    Labeler <|-- AppFunctions
    Labeler <|-- HotkeyPlotter
    Labeler <|-- Layout
    Labeler <|-- Logger
    Labeler <|-- MouseEventHandler
    Labeler : settings()
    Labeler : commands_mpv()
    Labeler : label_shortcuts()
    Labeler : observe_time_position()
    Labeler : _slider_time_change()
    Labeler : _handle_label_shortcuts()
    Labeler : _handle_commands_mpv()
    class ActivityHandler{
        populate_data_table_point_activity()
        populate_data_table_time_window()
        _get_saved_time_window()
        _handle_first_time_window()
        _handle_second_time_window()
    }
    class AppFunctions{
        delete_selected_rows()
        plot_hotkeys()
        sort_data_table()
        update_video_table()
        load_csv_data()
        write_csv_data()
        _csv_load_rows()
        _csv_write_rows()  
    }
    class HotkeyPlotter{
        load_and_plot()
        _check_for_duplicates()
        _load_files()
        _make_colors()
        _plot_hotkeys()
    }
    class Layout{
        create_app_window()
        create_data_table()
        create_logger()
        create_mpv_player()
        create_second_column_video_layout()
        create_splitter()
        create_style()
        create_time_slider()
        create_video_table()
    }
    class Logger{
        write_logger()
        get_logging_idx()
        _clear_logger()
        _remove_too_many_logs()
    }
    class MouseEventHandler{
        close_app()
        data_table_click()
        splitter_click()
        splitter_move()
        video_table_click()
    }
Loading

.json-Files as Configurations

Take care of duplicated Hotkeys within .json-Files.


commands_mpv.json

examples1

examples2

Every hotkey for the MPV-Player can be set here. Similar to mpv.commands(**kwargs). Single commands are STRINGS multiple commands are LISTS

EXAMPLE

{
  "SPACE": ["cycle", "pause"],
  "right": "frame-step",
  "left": "frame-back-step",
  "up": ["multiply", "speed", "1.1"],
  "down": ["multiply", "speed", "1/1.1"],
  ".": "frame-step",
  ",": "frame-back-step",
  "+": ["add", "video-zoom", "0.1"],
  "-": ["add", "video-zoom", "-0.1"],
  "Shift+up": ["add", "video-pan-y", "0.1"],
  "Shift+right": ["add", "video-pan-x", "-0.1"],
  "Shift+left": ["add", "video-pan-x", "0.1"],
  "Shift+down": ["add", "video-pan-y", "-0.1"],
  "BACKSPACE": ["set", "speed", "1.0"]
}

label_shortcuts.json

time_window and point_activities available.

EXAMPLE

{
  "time_window": {
    "Ctrl+Q": "Running",
    "Ctrl+W": "Running",
    "Ctrl+E": "Running",
    "Ctrl+R": "Walking",
    "V": "Walking"
  },
  "point_activity": {
    "P": "StepLeft",
    "Q": "StepRight",
    "W": "StepRight",
    "E": "StepRight",
    "R": "StepRight", # DUPLICATED (AVOID) USE plot_hotkeys() to find duplicates
    "R": "SETTPER", # DUPLICATED (AVOID) USE plot_hotkeys() to find duplicates
    "Z": "StepRight",
    "U": "StepRight",
    "I": "StepRight"
  }
}

settings.json

Any method from AppFunctions (video_labeler.py) can be accessed with "()" at the end of the values.

  • "log_max" is for the Logger. Defines what max. number of logs should be shown.
  • "style" https://pypi.org/project/qt-material/ changing the them of the app.
  • "width_height" initial width:height
  • plot_hotkeys() creates Hotkeys.png with all shortcuts. Also shows if there are duplicated values
  • update_video_table() If there are always new incoming videos within the folder "videos" probably you will need this function.
  • sort_data_table() sorts all the values within the data_table by "STIME"

plot_hotkeys()

EXAMPLE

{
  "X": "delete_selected_rows()",
  "CTRL+S": "write_csv_data()",
  "S": "sort_data_table()",
  "L": "update_video_table()",
  "M": "plot_hotkeys()",
  "dark_amber.xml": "style",
  "1600:800": "width_height",
  "12": "log_max"
}

Create executable (.exe)

All dependencies are split out from the executable (app will be faster, but a folder with dependencies).

Terminal:

pip install pyinstaller
cd src
pyinstaller video_labeler.py

Just one file as executable (app will be slower, but only one file to execute).

Terminal:

pip install pyinstaller
cd src
pyinstaller video_labeler.py --onefile

This will create a "build" and a "dist" folder. Go to dist folder. There you will find the executable.

video-labeler's People

Contributors

vitalikstud avatar vladislabv avatar

Stargazers

 avatar

Watchers

 avatar  avatar

video-labeler's Issues

write_csv_data() delete checking data_table_changed parameter

Hallo Vitali,

bin gerade am Schreiben des Usermanuals und habe an eine komische Sache gestoßen. Und zwar, die Funtion mit Ctrl+S wird nun dann aufgerufen, wenn ich mindestens eine Zeile lösche, sonst ist der Parameter self.data_table_changed ist False.

Das muss weg, da ich kein Problem sehe dem User an einem beliebigen Zeitpunkt die Möglichkeit zu geben, das Progress zu speichern, egal hat er grundsätzlich was geändert oder nicht.

Play / Progress Bar of the Video Player is buggy

Hey Vitali,

ich habe es mir etwas getestet, und erstmal positives, wir brauchen soweit ich verstehe explizit kein MPV Player mehr. Sehr schön! Wie hast du das hinbekommen?

Zum Bug:

wenn ich mir ein .mp4 Video angucke, startet es halt normal, wenn über die Hälfte der Videolänge bin und möchte mir nun zum Anfang springen, geht es über den Progress Bar gar nicht.

Also wenn ich klicke auf eine Position die hinter dem Playpunkt liegt, springt es kurz dorthin und wiederzurück, so dass ich nach vorne ein Video abspielen lassen kann.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.