Skip to content

Commit b87c28f

Browse files
author
arch
committed
add option to set tracker algorithm
1 parent 61d59b8 commit b87c28f

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

docs/app/docs/user-guide/config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Config Files:
2626
- `max_playback_fps` (int): Limit the max player speed in the tracking preview window (0 = disable limit)
2727
- `preview_scaling` (float): Set the preview image scaling factor. With a value of `1.0`, the window should fill the height or width of the screen depending on the aspect ratio of the video.
2828
- `projection`: (str): Set the video type. All available options can be obtained from the `projection.yaml` file. Each root keys represent an option. Available Options: `'flat'` = 2D Videos, `'vr_he_sbs'` = 3D VR Side-By-Side Video
29+
- `tracker`: (str) Specify the tracker algorithm. Available options are `'MIL'`, `'KCF'`, `'CSRT'`.
2930

3031
#### `hyperparameter.yaml`
3132

funscript_editor/algorithms/videotracker.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from threading import Thread
88
from queue import Queue
9+
from funscript_editor.utils.config import SETTINGS
910

1011
import numpy as np
1112

@@ -66,9 +67,23 @@ def result(self) -> tuple:
6667
return self.queue_out.get()
6768

6869

70+
def __setup_tracker(self) -> None:
71+
""" Setup the tracker specified in the config """
72+
if SETTINGS['tracker'].upper() == 'MIL':
73+
self.__logger.info("Start MIL Tracker")
74+
self.tracker = cv2.TrackerMIL_create()
75+
elif SETTINGS['tracker'].upper() == 'KCF':
76+
self.__logger.info("Start KCF Tracker")
77+
self.tracker = cv2.TrackerKCF_create()
78+
else:
79+
# falback is CSRT tracker
80+
self.__logger.info("Start CSRT Tracker")
81+
self.tracker = cv2.TrackerCSRT_create()
82+
83+
6984
def run(self) -> None:
7085
""" The Video Tracker Thread Function """
71-
self.tracker = cv2.TrackerCSRT_create() # NOTE: you can change this to your favorite tracker
86+
self.__setup_tracker()
7287
frame_heigt, frame_width = self.first_frame.shape[:2]
7388

7489
dh, dw = int(frame_heigt*self.limit_searchspace['h']), int(frame_width*self.limit_searchspace['w'])

funscript_editor/config/settings.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ preview_scaling: 0.6
2727
# - 'flat': 2D Videos
2828
# - 'vr_he_sbs': 3D VR Side-By-Side Video
2929
projection: 'vr_he_sbs'
30+
31+
# Specify the tracker algorithm. Available options are 'MIL', 'KCF', 'CSRT'.
32+
tracker: 'CSRT'

funscript_editor/data/ffmpegstream.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ def run(self) -> None:
279279
'-'
280280
]
281281

282+
self.logger.info("Open FFmpeg Stream")
282283
pipe = sp.Popen(
283284
command,
284285
stdout = sp.PIPE,

0 commit comments

Comments
 (0)