forked from happyhorseskull/you-can-datamosh-on-linux
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added vector motion moshing with python
- Loading branch information
1 parent
6af48ea
commit 22a2217
Showing
4 changed files
with
96 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import numpy as np | ||
|
||
|
||
average_length = 10 | ||
|
||
|
||
def average(frames): | ||
if not frames: | ||
return [] | ||
return np.mean(np.array([x for x in frames if x != []]), axis=0).tolist() | ||
|
||
|
||
def mosh_frames(frames): | ||
return [average(frames[i + 1 - average_length: i + 1]) for i in range(len(frames))] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
def mosh_frames(frames): | ||
for frame in frames: | ||
if not frame: | ||
continue | ||
|
||
for row in frame: | ||
for col in row: | ||
# col contains the horizontal and vertical components of the vector | ||
col[0] = 0 | ||
|
||
return frames |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters