Filter¶
filter_frame ¶
filter_frame(motion_frame, filtertype, threshold, kernel_size)
Applies a threshold filter and then a median filter (of kernel_sizexkernel_size) to an image or videoframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
motion_frame
|
array(uint8)
|
Input motion image. |
required |
filtertype
|
str
|
'Regular' turns all values below |
required |
threshold
|
float
|
A number in the range of 0 to 1. Eliminates pixel values less than given threshold. |
required |
kernel_size
|
int
|
Size of structuring element. |
required |
Returns:
| Type | Description |
|---|---|
|
np.array(uint8): The filtered frame. |
Source code in musicalgestures/_filter.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
filter_frame_ffmpeg ¶
filter_frame_ffmpeg(filename, cmd, color, blur, filtertype, threshold, kernel_size, use_median, invert=False)
Builds an FFmpeg filter-complex string for frame differencing, thresholding and optional median filtering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the input video file (used to derive frame dimensions). |
required |
cmd
|
list
|
Base FFmpeg command list to which extra inputs are appended in-place. |
required |
color
|
bool
|
If True, use gbrp pixel format; otherwise gray. |
required |
blur
|
str
|
'Average' applies a 10×10 box blur before differencing; 'None' skips it. |
required |
filtertype
|
str
|
'Regular' thresholds frame differences; 'Binary' binarises them; 'Blob' erodes. |
required |
threshold
|
float
|
Pixel-value threshold in the range 0–1. |
required |
kernel_size
|
int
|
Radius for the median or erosion filter. |
required |
use_median
|
bool
|
If True, apply a median filter after thresholding. |
required |
invert
|
bool
|
If True, negate the output. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
|
tuple[list, str]: Updated |
Source code in musicalgestures/_filter.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |