OpenCV: Brox Optical Flow Sample, possible fix
I had some fun getting OpenCV with CUDA support and the demo to work that required OpenGL that for some yet unknown reason would not connect in properly. So I thought I would share my experience.
First of compile OpenCV with CUDA
You can also enable OpenGL, but this didn’t work for me yet it did enable the #define HAVE_OPENGL compile it up and copy out the brox example and make the following corrections, aka #defeine out the OPENGL window parts.
To note you may need to #undef HAVE_OPENGL. For a full easy run source you can get from here
Reference: Body of code taken from OpenCV Sample
Left – Forward Optical flow, Right – Backward Optical flow
Some interesting performance info for computation of Brox Optical Flow it took 0.01s, but the Image Copy to GPU took 6.485s [e.g. GpuMat d_frame0(frame0Gray) ]. This was on a laptop spec of i7 (8 thread), 10gb ram, GeForce GT540M 1GB. I will try on another machine sometime see if can get a faster performance specifically in image copy.
Note:
- There may be a better way to overcome the OpenGL requirement this was just a quick work around
- NVIDIA CUDA compiler does not currently support Visual Studio 2012 therefore for CUDA you need to use 2010.
Stuart James ...