You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: musicalgestures/_blurfaces.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -80,6 +80,7 @@ def mg_blurfaces(self,
80
80
save_data=True,
81
81
data_format='csv',
82
82
color=(0, 0, 0),
83
+
use_gpu=True,
83
84
target_name=None,
84
85
overwrite=False):
85
86
"""
@@ -101,6 +102,7 @@ def mg_blurfaces(self,
101
102
save_data (bool, optional): Whether to save the scaled coordinates of the face mask (time (ms), x1, y1, x2, y2) for each frame to a file. Defaults to True.
102
103
data_format (str, optional): Specifies format of blur_faces-data. Accepted values are 'csv', 'tsv' and 'txt'. For multiple output formats, use list, e.g. ['csv', 'txt']. Defaults to 'csv'.
103
104
color (tuple, optional): Customized color of the rectangle boxes. Defaults to black (0, 0, 0).
105
+
use_gpu (bool, optional): Whether to attempt GPU (CUDA) acceleration for face detection. Falls back to CPU automatically if CUDA is unavailable. Defaults to True.
104
106
target_name (str, optional): Target output name. Defaults to None (which assumes that the input filename with the suffix "_blurred" should be used).
105
107
overwrite (bool, optional): Whether to allow overwriting existing files or to automatically increment target filenames to avoid overwriting. Defaults to False.
Copy file name to clipboardExpand all lines: musicalgestures/_flow.py
+75-3Lines changed: 75 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -47,6 +47,7 @@ def dense(
47
47
angle_of_view=0,
48
48
scaledown=1,
49
49
skip_empty=False,
50
+
use_gpu=True,
50
51
target_name=None,
51
52
overwrite=False):
52
53
"""
@@ -68,6 +69,7 @@ def dense(
68
69
angle_of_view (int, optional): angle of view of camera, for reporting flow in meters per second. Defaults to 0.
69
70
scaledown (int, optional): factor to scaledown frame size of the video. Defaults to 1.
70
71
skip_empty (bool, optional): If True, repeats previous frame in the output when encounters an empty frame. Defaults to False.
72
+
use_gpu (bool, optional): Whether to attempt GPU (CUDA) acceleration using `cv2.cuda.FarnebackOpticalFlow`. Falls back to CPU automatically if CUDA is unavailable or the required OpenCV CUDA modules are not installed. Defaults to True.
71
73
target_name (str, optional): Target output name for the video. Defaults to None (which assumes that the input filename with the suffix "_flow_dense" should be used).
72
74
overwrite (bool, optional): Whether to allow overwriting existing files or to automatically increment target filenames to avoid overwriting. Defaults to False.
of_win_size (tuple, optional): Size of the search window at each pyramid level. Defaults to (15, 15).
300
336
of_max_level (int, optional): 0-based maximal pyramid level number. If set to 0, pyramids are not used (single level), if set to 1, two levels are used, and so on. If pyramids are passed to input then the algorithm will use as many levels as pyramids have but no more than `maxLevel`. Defaults to 2.
301
337
of_criteria (tuple, optional): Specifies the termination criteria of the iterative search algorithm (after the specified maximum number of iterations criteria.maxCount or when the search window moves by less than criteria.epsilon). Defaults to (cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 10, 0.03).
338
+
use_gpu (bool, optional): Whether to attempt GPU (CUDA) acceleration using `cv2.cuda.SparsePyrLKOpticalFlow`. Falls back to CPU automatically if CUDA is unavailable or the required OpenCV CUDA modules are not installed. Defaults to True.
302
339
target_name (str, optional): Target output name for the video. Defaults to None (which assumes that the input filename with the suffix "_flow_sparse" should be used).
303
340
overwrite (bool, optional): Whether to allow overwriting existing files or to automatically increment target filenames to avoid overwriting. Defaults to False.
304
341
@@ -330,6 +367,24 @@ def sparse(
330
367
height=int(vidcap.get(cv2.CAP_PROP_FRAME_HEIGHT))
331
368
length=int(vidcap.get(cv2.CAP_PROP_FRAME_COUNT))
332
369
370
+
# Determine whether to use GPU-accelerated sparse optical flow
0 commit comments