Subtract¶
mg_subtract ¶
mg_subtract(self, color=True, filtertype=None, threshold=0.05, blur=False, curves=0.15, use_median=False, kernel_size=5, bg_img=None, bg_color='#000000', target_name=None, overwrite=True)
Renders background subtraction using ffmpeg.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color
|
bool
|
If False the input is converted to grayscale at the start of the process. This can significantly reduce render time. Defaults to True. |
True
|
filtertype
|
str
|
'Regular' turns all values below |
None
|
threshold
|
float
|
Eliminates pixel values less than given threshold. Ranges from 0 to 1. Defaults to 0.05. |
0.05
|
blur
|
bool
|
Whether to apply a smartblur ffmpeg filter or not. Defaults to False. |
False
|
curves
|
int
|
Apply curves and equalisation threshold filter to subtract the background. Ranges from 0 to 1. Defaults to 0.15. |
0.15
|
use_median
|
bool
|
If True the algorithm applies a median filter on the thresholded frame-difference stream. Defaults to False. |
False
|
kernel_size
|
int
|
Size of the median filter (if |
5
|
bg_img
|
str
|
Path to a background image (.png) that needs to be subtracted from the video. If set to None, it uses an average image of all frames in the video. Defaults to None. |
None
|
bg_color
|
str
|
Set the background color in the video file in hex value. Defaults to '#000000' (black). |
'#000000'
|
target_name
|
str
|
Target output name for the subtracted video. Defaults to None. |
None
|
overwrite
|
bool
|
Whether to allow overwriting existing files or to automatically increment target filenames to avoid overwriting. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
MgVideo |
MgVideo
|
A MgVideo pointing to the subtracted video, also stored as |
Source code in musicalgestures/_subtract.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |