Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(1->0) Add RecordingSession data structure and integrate with Labels #1260

Open
wants to merge 24 commits into
base: liezl/add-camera-group
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
014356f
Add `RecordingSession` data structure
roomrys Apr 4, 2023
6dc00c9
Add converter for `CameraCluster`
roomrys Apr 5, 2023
e70291b
Non-functional clean-up
roomrys Apr 5, 2023
f6ce081
Merge branch 'liezl/add-camera-group' into liezl/acg-add-recording-se…
roomrys Apr 6, 2023
98e772d
[wip] Add maps between `Video` and camera classes
roomrys Apr 6, 2023
6df8dbd
Make `RecordingSession` hashable
roomrys Apr 6, 2023
e46091e
Add `Camcorder`->`Video`` map in `RecordingSession` and tests
roomrys Apr 6, 2023
39b24e5
Enhance `__getitem__` method to retrieve linked `Video`<->`Camcorder`
roomrys Apr 6, 2023
f4cf7f6
Finish adding access methods/maps
roomrys Apr 7, 2023
fdca4f2
Remove unused fixture
roomrys Apr 7, 2023
6ab0725
Merge branch 'liezl/add-camera-group' into liezl/acg-add-recording-se…
roomrys Apr 10, 2023
6a9b727
Merge branch 'liezl/add-camera-group' into liezl/acg-add-recording-se…
roomrys Apr 11, 2023
220a3bf
Integrate recording session and labels (#1271)
roomrys Apr 15, 2023
96d21a0
Merge branch 'liezl/add-camera-group' into liezl/acg-add-recording-se…
roomrys Apr 27, 2023
8ff9364
Merge branch 'liezl/add-camera-group' into liezl/acg-add-recording-se…
roomrys Jul 20, 2023
348a656
Merge branch 'liezl/add-camera-group' of https://github.com/talmolab/…
Sep 26, 2023
c8ee7bb
Merge base
roomrys Sep 29, 2023
4c7c435
Fix typehinting
roomrys Sep 29, 2023
8d6aa4e
Add error handling for incorrect input type
roomrys Sep 29, 2023
9c21530
Remove unused imports
roomrys Sep 29, 2023
611ab39
Remove unused and organize imports
roomrys Sep 29, 2023
99d3228
Do not overwrite `camera_cluser` attr if already set
roomrys Sep 29, 2023
48d415d
Swap arguments in `isinstance`
roomrys Sep 29, 2023
24a9e82
Merge branch 'liezl/add-camera-group' of https://github.com/talmolab/…
roomrys Oct 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions sleap/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,14 @@ def add_submenu_choices(menu, title, options, key):
fileMenu, "replace videos", "Replace Videos...", self.commands.replaceVideo
)

fileMenu.addSeparator()
add_menu_item(
fileMenu,
"add session",
"Add Recording Session...",
self.commands.addSession,
)

fileMenu.addSeparator()
add_menu_item(fileMenu, "save", "Save", self.commands.saveProject)
add_menu_item(fileMenu, "save as", "Save As...", self.commands.saveProjectAs)
Expand Down
40 changes: 39 additions & 1 deletion sleap/gui/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class which inherits from `AppCommand` (or a more specialized class such as
import attr
import cv2
import numpy as np
from qtpy import QtCore, QtGui, QtWidgets
from qtpy import QtCore, QtWidgets, QtGui
from qtpy.QtWidgets import QMessageBox, QProgressDialog

from sleap.gui.dialogs.delete import DeleteDialog
from sleap.gui.dialogs.filedialog import FileDialog
Expand All @@ -52,6 +53,7 @@ class which inherits from `AppCommand` (or a more specialized class such as
from sleap.gui.state import GuiState
from sleap.gui.suggestions import VideoFrameSuggestions
from sleap.instance import Instance, LabeledFrame, Point, PredictedInstance, Track
from sleap.io.cameras import RecordingSession
from sleap.io.convert import default_analysis_filename
from sleap.io.dataset import Labels
from sleap.io.format.adaptor import Adaptor
Expand Down Expand Up @@ -430,6 +432,10 @@ def removeVideo(self):
"""Removes selected video from project."""
self.execute(RemoveVideo)

def addSession(self):
"""Shows gui for adding `RecordingSession`s to the project."""
self.execute(AddSession)

def openSkeletonTemplate(self):
"""Shows gui for loading saved skeleton into project."""
self.execute(OpenSkeleton, template=True)
Expand Down Expand Up @@ -1918,6 +1924,38 @@ def ask(context: CommandContext, params: dict) -> bool:
return True


class AddSession(EditCommand):
# topics = [UpdateTopic.session]

@staticmethod
def do_action(context: CommandContext, params: dict):

camera_calibration = params["camera_calibration"]
session = RecordingSession.load(filename=camera_calibration)

# Add session
context.labels.add_session(session)

# Load if no video currently loaded
if context.state["session"] is None:
context.state["session"] = session

@staticmethod
def ask(context: CommandContext, params: dict) -> bool:
"""Shows gui for adding video to project."""
filters = ["Camera calibration (*.toml)"]
filename, selected_filter = FileDialog.open(
context.app,
dir=None,
caption="Select camera calibration...",
filter=";;".join(filters),
)

params["camera_calibration"] = filename

return len(filename) > 0


class OpenSkeleton(EditCommand):
topics = [UpdateTopic.skeleton]

Expand Down
Loading
Loading