GPU TV-L1 Optical Flow with ArrayFire

Update 1: LibJacket has been renamed to  ArrayFire.

Update 2: Huang Chao-Hui was nice enough to port the LibJacket code mentioned here to ArrayFire – see his work here.

As one of my Computer Vision class projects, I decided to implement optical flow, because I wanted to learn more about optical flow, and also I wanted to code it on the GPU (because I love GPU programming!).

One of the more successful approaches to optical flow is  total variation L1 regularization (TV-L1).  Pock et al‘s An Improved Algorithm for TV-L1 Optical Flow [Paper] describes a clever duality based method to solving L1 regularization image optical flow. These [slides] offer a nice intro to variational methods and applications. Kudos to Pock et al and their work!

GPU4Vision hosts the reference MATLAB implementation: [download] of the algorithm in the above paper (bundled in their Matlab Toolbox). Having this as a reference, I chose to re-implement this code in LibJacket, because it makes porting MATLAB code into GPU C++ code incredibly easy!

TV-L1 Optical Flow running on the GPU via LibJacket

While the ultimate goal is an OpenCL or CUDA custom implementation (coming here soon!), I decided to start with AccelerEyes LibJacket, because it super easy to translate from MATLAB M scripts to LibJacket C++ GPU code. I made use of what I learned earlier about combining LibJacket and OpenCV (see Image Processing with LibJacket and OpenCV) for this project.

Performance: Using the same configuration settings for both my LibJacket version and the MATLAB version, there is over an order of magnitude improvement in speed, making this fairly complex algorithm capapble of real-time performance.

It’s still a work in progress (a.k.a, probably still bugs), but I’m glad to share it as open source software! [source code] Enjoy!

 

Middlebury “rubber whale” image sequence

2 thoughts on “GPU TV-L1 Optical Flow with ArrayFire”

Leave a Comment