Visitar URL original
Refactor VideoProcessor class by C-Achard · Pull Request #3358 · DeepLabCut/DeepLabCut · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3e47c96
Sort and stringify video list
C-Achard Jun 5, 2026
108beba
Convert video paths to strings for vp calls
C-Achard Jun 5, 2026
257a8c9
Revert "Sort and stringify video list"
C-Achard Jun 9, 2026
902aa1d
Add tests for VideoProcessorCV
C-Achard Jun 9, 2026
d3ed1b4
Turn VideoProcessor into ABC with abstract methods
C-Achard Jun 9, 2026
bffcb92
Use clip properties for height/width/fps
C-Achard Jun 9, 2026
f338f3c
Add properties and docs to video processor
C-Achard Jun 9, 2026
f18d166
Avoid str() casts when calling vp
C-Achard Jun 9, 2026
31f8985
Initialize video attrs and switch to logging
C-Achard Jun 9, 2026
203b131
Change logging to exception
C-Achard Jun 9, 2026
ef1d2e2
Test VideoProcessorCV accepts Path and stores str
C-Achard Jun 9, 2026
f0d4fd4
Add type annotations to VideoProcessor.__init__
C-Achard Jun 9, 2026
17de1f4
Address review comments
C-Achard Jun 10, 2026
09dd8b4
Refactor VideoProcessor API to video_fps/h/w
C-Achard Jun 10, 2026
5e24647
Mark legacy VideoProcessor accessors as deprecated
C-Achard Jun 10, 2026
84c60a2
Disable deprecated decorator on FPS property
C-Achard Jun 10, 2026
df89520
Comment on deprecations
C-Achard Jun 10, 2026
fbb6352
Fix incorrect property usage
C-Achard Jun 10, 2026
f07ba9e
Rename VideoProcessor.video_fps to fps
C-Achard Jun 11, 2026
06a7521
Rename VideoProcessor h/w to height/width
C-Achard Jun 12, 2026
8e86e02
Fix missing renaming of properties in make_labeled_video
C-Achard Jun 15, 2026
1496ff2
Merge branch 'main' into cy/fix-video-reader-set-error
MMathisLab Jun 25, 2026
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
Prev Previous commit
Next Next commit
Address review comments
Annotate fps, sh, and sw with None-aware union types and change sh/sw defaults from empty strings to None. Update logic to check for None rather than empty strings, and make fname/sname setters convert None or empty input to an empty string to avoid storing literal 'None'. Also guard frame writes by ensuring svid is set before calling write (prevents attempts to write when output video is not initialized). These changes improve type correctness and robustness when optional values are omitted.
  • Loading branch information
C-Achard committed Jun 10, 2026
commit 17de1f469a97b258fcd4d622d2c2d95e411f967c
14 changes: 7 additions & 7 deletions deeplabcut/utils/video_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def __init__(
fname: str = "",
Comment thread
C-Achard marked this conversation as resolved.
Resolved
sname: str = "",
nframes: int = -1,
fps: float = None,
fps: float | None = None,
codec: str = "X264",
sh: int = "",
sw: int = "",
sh: int | None = None,
sw: int | None = None,
):
self._fname = None
self._sname = None
Expand All @@ -71,7 +71,7 @@ def __init__(
self.sh = 0
self.sw = 0
if self.sname != "":
if sh == "" and sw == "":
if sh is None and sw is None:
self.sh = self.h
self.sw = self.w
else:
Expand Down Expand Up @@ -99,15 +99,15 @@ def fname(self):

@fname.setter
def fname(self, value):
self._fname = str(value)
self._fname = "" if value in (None, "") else str(value)

@property
def sname(self):
return self._sname

@sname.setter
def sname(self, value):
self._sname = str(value)
self._sname = "" if value in (None, "") else str(value)

@property
def height(self):
Expand Down Expand Up @@ -257,7 +257,7 @@ def save_frame(self, frame):
``None`` frames. Non-``None`` frames are converted from RGB to BGR
before being passed to OpenCV.
"""
if frame is not None:
if frame is not None and self.svid is not None:
self.svid.write(np.flip(frame, 2))

Comment thread
C-Achard marked this conversation as resolved.
Resolved
def close(self):
Expand Down