Git Product home page Git Product logo

opticalflowtoolkit's Introduction

OPTICAL FLOW TOOLKIT v0.1

RUOTENG LI

20 July 2016

996.icu LICENSE

This toolkit is a python implementation for read, write, calculate, and visualize KITTI 2012 Optical Flow, which contains 200 training and 200 test image pairs each. Ground truth has been aquired by accumulating 3D point clouds from a 360 degree Velodyne HDL-64 Laserscanner according to Andreas Geiger [].

File description:

=================

  • lib/kittitool.py : toolkit for KITTI optical flow dataset
  • demo.py : demonstration on read and visualize KITTI optical flow data
  • lib/flowlib.py : library for manipulate optical flow ...

1. Pre-Requisite:

  1. Python2.7
  2. Numpy and Scipy
  3. Matplotlib
  4. pypng package

2. Installation:

2.1 Installing Python and Pip

You may want to get started on a Unix environment such as Ubuntu, or Linux OS, and use pip to manage python package installation. pip installation guide Briefly for Linux user:

python get-pip.py

2.2 Install Scipy Numpy

sudo pip install scipy
sudo pip install numpy

2.3 Install Matplotlib

pip install matplotlib

2.4 Install PyPng

sudo pip install pypng

3. Usage

python demo.py

4. Scripts for Training Loss Visualization

In your terminal, locate the root directory of this repository, type the following

cd scripts/
python plot_loss.py <YOUR TRAINING LOG FILE>

The plot will be saved with the same name of your logfile in .png format.

5. Scripts for Data Manipulation

5.1 random_crop.py

This program crops the original image data set into small patches specified by the input, by default the size is 384x512 (px). Please make sure that your input image is larger than the patches you want to get. The cropping distribution is uniform across the entire image.

python random_crop.py <name_of_dataset> <number_of_patches> --height <height_of_output_patch> --width <width_of_output_patch>

The patches will be generated at folder and the following files will be generated for CNN training:

  • flo_list.txt
  • img1_list.txt
  • img2_list.txt

5.2 create_filelist

This program create three file lists that containing all the paths of the images/flow files from a dataset. The output of this program will be one single file "filelist.txt" that contains the file path you want to search in the dataset.

python create_filelist.py <file_format> --input_dir <path_of_dataset> --output_dir <output_path>

5.3 crop_flow.py

This program crops the image files and flow files from a dataset at a specific location.

python crop_flow.py <input_dir> <output_dir> <x> <y> <height_of_patch> <width_of_patch> --image_format <format_of_image> --flow_format <format_of_flow>

5.4 segment_flow.py

This script segment the flow into 9 classes according to the flow orientation. Each 45 degree will be recognized into one class starting from 0 degree on x axis.

python segment_flow.py <format_of_flowfile> <input_directory> --output_dir <output_directory>

opticalflowtoolkit's People

Contributors

emited avatar liruoteng avatar ravikt avatar tiotao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opticalflowtoolkit's Issues

Rgb2floFiles

Hi,Thanks for your sharing!
I want to change a color optical flow image(3 channels) to .flo files ,so that i can evaluate it with my own .flo
files,Did you write the function before?Thank you very much!

How can I calculate the optical flow between two frames?

Hi, thanks for your contribution, but I have a question about how can I calculate the dense optical flows between two different Image frames, or this script only used for optical flow results' visualization? Thanks a lot!

Asking for help.

Hello, ruoteng. Recently, I'm trying to reproduce Flownet2 in tensorflow. So, the coding implementation of AAE(average angular error) and AEE(average endpoint error) are what I need.I forked your rep(OpticalFlowTookkit) cause it is awesome and helpful, but there are some questions confused me at line 181 in flowlib.py.

def flow_error(tu, tv, u, v):
    """
    Calculate average end point error
    :param tu: ground-truth horizontal flow map
    :param tv: ground-truth vertical flow map
    :param u:  estimated horizontal flow map
    :param v:  estimated vertical flow map

Now, I have a numpy array(named ground_truth) converted from ground truth .flo file, which has shape of [1024, 436, 2].So, the param tu equals ground_truth[ : , : , 0] and param tv equals ground_truth[ : , : , 1], Is my understanding right? And can I get AAE by canceling the annotation in function flow_error?
what's more, I have an implementation by myself, I ALSO have no idea if it's understanding right.

def get_AEE(labels, predictions):
    num_sample, height, width , _= predictions.shape.as_list()
    squared_difference = tf.square(tf.subtract(predictions, labels))
    #此处axis很重要,有batch的四维数组的axis必须是 3 , 三维数组得是 2
    loss = tf.reduce_sum(squared_difference, 3, keep_dims=True)
    loss = tf.sqrt(loss)
    return tf.reduce_sum(loss) / (num_sample*height*width)

Thanks very much! Any suggestion will help.

License

Hi,
I was planning to develop an optical flow library for Python.
I was wondering if you don't mind that I use your flowlib.py file to do so. If you agree, could you license the file?

Thanks in advance

'Namespace' object has no attribute 'dump_root'

data/prepare_train_data.py 的94行是不是写错了?dump_example函数的参数没有传进去吧?
Parallel(n_jobs=args.num_threads)(delayed(dump_example)(n) for n in range(data_loader.num_train))

Warping image type error

There's a type error between image and flow when in warping warp_image line 395

TypeError: Cannot cast ufunc add output from dtype('float64') to dtype('int64') with casting rule 'same_kind'

Can fix by adding fl = fl.astype('int64')

no png

There is no module named png in the flowlib of lib.

A Problem of png Files

Hi, @liruoteng
thank you for your sharing, I installed OpticalFlowToolkit according to your instructions. I successfully visualized the. flo file and converted it to png file, but I encountered a problem, I found the lower part of the picture was covered. I am not sure what this is. Can you help me?
myplot_first second
myplot_frame1 frame2

error while test about unix time

I0627 14:53:11.230944 24143 net.cpp:460] conv1 <- input
I0627 14:53:11.230948 24143 net.cpp:417] conv1 -> conv1
*** Aborted at 1498546391 (unix time) try "date -d @1498546391" if you are using GNU date ***
PC: @ 0x7f67d21d704d caffe::CuDNNConvolutionLayer<>::LayerSetUp()
*** SIGFPE (@0x7f67d21d704d) received by PID 24143 (TID 0x7f67d2eda740) from PID 18446744072939728973; stack trace: ***
@ 0x7f67d05c54b0 (unknown)
@ 0x7f67d21d704d caffe::CuDNNConvolutionLayer<>::LayerSetUp()
@ 0x7f67d212999e caffe::Net<>::Init()
@ 0x7f67d212ba63 caffe::Net<>::Net()
@ 0x408be7 test()
@ 0x4072f0 main
@ 0x7f67d05b0830 __libc_start_main
@ 0x407a59 _start
@ 0x0 (unknown)

The resulting FLOW is stored in flownets-pred-NNNNNNN.flo

I have run make -j 5 all tools successfully, but when I run ./demo_flownet.py S data/0000000-img0.ppm data/0000000-img1.ppm, this error happened, and there is no .flo result. How can I solve it?

Demo file crahes

Hi liruoteng!
I'm currently trying to display the .flo files.
To do so i went throught your nice toolikt, got it setup on my desk and unfortunately I get the following error while launching the "python demo.py" :

Traceback (most recent call last):
File "demo.py", line 12, in
flow = kittitool.flow_read(flow_file)
AttributeError: 'module' object has no attribute 'flow_read'

Thanks in advance for your support :D !
Cheers

Does this code work with python 3?

I would like to use this software as part of an existing project in python 3. Is this likely to work without significant modifications?

Thank you in advance.

KITTI example folder not found

The current repo does not seem to have the KITTI example, only the MIddlebury folder, under data/example.

demo.py tries to load in a PNG file instead of a .flow file for KITTI.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.