-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added benchmarking for various methods
Added robustness to save data as time progresses to prevent restart from a given point
- Loading branch information
MosNicholas
committed
Apr 22, 2016
1 parent
7180414
commit c5c130a
Showing
3 changed files
with
95 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ | |
*.pyc | ||
*.csv | ||
*.pem | ||
*.jpg | ||
|
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,35 @@ | ||
from random import randint | ||
import time | ||
import os | ||
from moviepy.editor import VideoFileClip | ||
|
||
DATA_FOLDER = 'data' | ||
RAW_VIDEO_FOLDER = os.path.join(DATA_FOLDER, 'raw') | ||
movie_path = os.path.join(RAW_VIDEO_FOLDER, 'hitch_hiker.mp4') | ||
video = VideoFileClip(movie_path) | ||
fps = video.fps | ||
first_frame = int(23 * fps) + 1 | ||
num_trials = 2000 | ||
|
||
def v1(): | ||
t1 = time.time() | ||
for i in xrange(first_frame, first_frame+num_trials): | ||
index_a = randint(4, 8) | ||
index_b = randint(4, index_a) | ||
v1 = video.subclip(i/fps, (i + index_a + 2)/fps) | ||
v2 = video.subclip((i + index_b)/fps, (i + 10)/fps) | ||
t2 = time.time() | ||
return float(t2 - t1)/num_trials | ||
|
||
def v2(): | ||
t1 = time.time() | ||
for i in xrange(first_frame, first_frame+num_trials): | ||
frames = [video.get_frame(j/fps) for j in xrange(i, i+10)] | ||
index_a = randint(4, 8) | ||
index_b = randint(4, index_a) | ||
f1 = frames[:index_a + 1] | ||
f2 = frames[index_b:] | ||
t2 = time.time() | ||
return float(t2 - t1)/num_trials | ||
|
||
|