Skip to content

Commit

Permalink
Updated readme, added directory initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
hacoo committed Mar 6, 2016
1 parent 4924dac commit c199ee2
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 31 deletions.
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,56 @@
# framebooster
Video framerate booster using motion field transfer

Framebooster is a optical-flow based video frame interpolator. Given
a video, it will interpolate every other frame -- resulting in a video
with the frame rate doubled. It is written in Python with OpenCV.

Setup:

This program requires Python 3 and OpenCV. See http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html
for details on installing OpenCV.

Framebooster uses the Large Displacement Optical Flow (LDOF) to calculate
optical flows. LDOF must be installed if you want to calculate optical
flows using this program.

LDOF is freely available precompiled or from source, and can be found here:

http://lmb.informatik.uni-freiburg.de/resources/software.php

Once you have the the LDOF binary executable, simply point framebooster.py
to it using the --ldof-path option.


Running framebooster:

example:

> ./framebooster.py -i "videos/example.mp4" --ldof-path="denseflow/ldof"
This would generate output video in the local directory, out.avi.

For help, run:

> ./framebooster.py --help
Framebooster may be run with the following options:

-i : The input video file path.

-o : The output video file path.

--calc-flows / --no-calc-flows : Turns optical flow calculation on
or off. If turned off, flows will not be recomputed, the program
will look for precomputed flows in the forward/ and backward/
directories.

--ldof-path : Path to the ldof executable (default: ./denseflow/ldof)

--clean/--no-clean : Deletes frames and flows from the backward,
forward, and frames directories before running. By default,
this flag is set off.

--nframes : If set to 0 (default), will process the whole input
video. Otherwise, only the first n frames are processed.


46 changes: 16 additions & 30 deletions frameboost.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@

@click.command()
@click.option("-i", type = click.Path(exists=True),
default="./footage/p480/pizzaratshort.avi",
default="./in.avi",
help="Input video path")
@click.option("-o", type = click.Path(),
default="./output/out",
default="./out",
help="Output video path")
@click.option("--calc-flows/--no-calc-flows",
default=True,
Expand All @@ -52,11 +52,8 @@
help = "Number of frames to process. 0 will process whole video")






def start(i, o, calc_flows, ldof_path, clean, nframes):
set_up_directories()
if clean:
clean_directories()

Expand All @@ -71,30 +68,8 @@ def start(i, o, calc_flows, ldof_path, clean, nframes):
ldof_path)

forward = ut.load_forward_flows(frames, "./forward")
ut.view_frame_by_frame(forward)

backward = ut.load_backward_flows(frames, "./backward")
ut.view_frame_by_frame(backward)


ut.view_frame_by_frame(frames)
# forward = [flo.load_flo("./denseflow/frame4forward.flo"),
# flo.load_flo("./denseflow/frame5forward.flo"),
# flo.load_flo("./denseflow/frame6forward.flo")]
# ut.view_frame_by_frame(forward)
# forward = [cv2.GaussianBlur(f, (7,7), 8) for f in forward]
# backward = [flo.load_flo("./denseflow/frame4backward.flo"),
# flo.load_flo("./denseflow/frame5backward.flo"),
# flo.load_flo("./denseflow/frame6backward.flo")]

# backward= [cv2.GaussianBlur(b, (7,7), 8) for b in backward]
# ut.view_frame_by_frame(backward)
# frames = [cv2.imread("./frame4.ppm"),
# cv2.imread("./frame5.ppm"),
# cv2.imread("./frame6.ppm"),
# cv2.imread("./frame7.ppm")]
# ut.view_frame_by_frame(frames)


(interleaved, iflows) = bst.interpolate_frames_occlusions(frames,
forward,
backward)
Expand All @@ -107,9 +82,20 @@ def start(i, o, calc_flows, ldof_path, clean, nframes):
def clean_directories():
""" Clean out working directories to prepare for a run """
for dir in ["frames", "backward", "forward"]:
files = glob.glob(dir+"/*")
files = glob.glob(dir+"/*.ppm")
for f in files:
os.remove(f)
files = glob.glob(dir+"/*.flo")
for f in files:
os.remove(f)


def set_up_directories():
""" make sure needed directories are present. """
for dir in ["./frames", "./forward", "./backward"]:
if not os.path.exists(dir):
os.makedirs(dir)


if __name__ == '__main__':
start()

0 comments on commit c199ee2

Please sign in to comment.