Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions musicalgestures/_eulerian.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ def _open_writer():
process = _open_reader()
writer = _open_writer()

lowpass1 = None
lowpass2 = None
lowpass1: "list | None" = None
lowpass2: "list | None" = None
# IIR cutoffs derived from the requested band
r1 = freq_high * 2.0 / fps
r2 = freq_low * 2.0 / fps
Expand All @@ -188,6 +188,8 @@ def _open_writer():
lowpass2 = [lvl.copy() for lvl in pyr]
filtered = [np.zeros_like(lvl) for lvl in pyr]
else:
# built together on the first frame, above, and used together here
assert lowpass1 is not None and lowpass2 is not None
for k in range(len(pyr)):
lowpass1[k] = (1 - r1) * lowpass1[k] + r1 * pyr[k]
lowpass2[k] = (1 - r2) * lowpass2[k] + r2 * pyr[k]
Expand Down
1 change: 1 addition & 0 deletions musicalgestures/_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def dense(
next_frame = cv2.cvtColor(cv2.resize(frame2, size), cv2.COLOR_BGR2GRAY)

if _use_gpu:
assert farneback_gpu is not None # created under the same flag above
gpu_next_frame.upload(next_frame)
gpu_flow_result = farneback_gpu.calc(gpu_prev_frame, gpu_next_frame, None)
flow = gpu_flow_result.download()
Expand Down
20 changes: 16 additions & 4 deletions musicalgestures/_pose.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,10 @@ def mg_pose_waterfall(self: "musicalgestures.MgVideo", style: str = 'trajectorie
overwrite=overwrite, style=style, connections=c.get('connections'),
n_samples=n_samples, markers=markers, color_by=color_by, cmap=cmap,
dpi=dpi, elev=elev, azim=azim, lw=lw, axes=axes, crop=crop)
self.pose_waterfall_figure = mgf
# a figure that could not be built is not a result: leaving the attribute
# absent keeps `hasattr` honest, where storing None would not
if mgf is not None:
self.pose_waterfall_figure = mgf
return mgf


Expand Down Expand Up @@ -1014,7 +1017,10 @@ def mg_pose_segments(self: "musicalgestures.MgVideo", segments: list | None = No
c['data'], c['names'], c.get('connections'), c['width'], c['height'], c['fps'],
target_name, overwrite=overwrite, segments=segments, n_bins=n_bins, cmap=cmap,
dpi=dpi, ncols=ncols)
self.pose_segments_figure = mgf
# a figure that could not be built is not a result: leaving the attribute
# absent keeps `hasattr` honest, where storing None would not
if mgf is not None:
self.pose_segments_figure = mgf
return mgf


Expand Down Expand Up @@ -1065,7 +1071,10 @@ def mg_pose_center(self: "musicalgestures.MgVideo", save_data: bool = True, dpi:
pd.DataFrame(cols).to_csv(os.path.splitext(target_name)[0] + '.csv', index=False)
except Exception as e:
print(f'Warning: could not save CSV: {e}')
self.pose_centered_figure = mgf
# a figure that could not be built is not a result: leaving the attribute
# absent keeps `hasattr` honest, where storing None would not
if mgf is not None:
self.pose_centered_figure = mgf
return mgf


Expand Down Expand Up @@ -1103,7 +1112,10 @@ def mg_pose_distance(self: "musicalgestures.MgVideo", dpi: int = 200, target_nam

mgf = render_pose_distance(c['data'], c['names'], c['width'], c['height'], c['fps'],
target_name, overwrite=overwrite, dpi=dpi)
self.pose_distance_figure = mgf
# a figure that could not be built is not a result: leaving the attribute
# absent keeps `hasattr` honest, where storing None would not
if mgf is not None:
self.pose_distance_figure = mgf
return mgf


Expand Down
Loading