A few weeks ago we wrote <a href="http://sandbox.arrayfire.com/creating-a-simple-corner-detector-with-arrayfire/">Writing a Simple Corner Detector with ArrayFire</a>. In that post, we discussed a little bit about the new features that we are working on for ArrayFire. Some of these new computer vision features will be available in the next release of ArrayFire.

For the next release, ArrayFire will have a complete set to start with feature tracking, including FAST for feature detection [1], ORB for description [2] and a Hamming distance matcher. We will also include a dedicated version of the Harris corner detector [3], even though it can be written using existing ArrayFire functions. This implementation is straightforward, easy to use and will have better performance.

For this post, we will share some of our current benchmarks for <strong>Harris</strong> corner detector and <strong>FAST</strong> feature detector. We compare the performance of our implementation of these functions against the same functions in OpenCV, which is currently one of the best code references for computer vision.

The results shown below were all generated with an <strong>Intel Sandy Bridge Xeon processor with 32 cores</strong> for OpenCV CPU implementation and an <strong>NVIDIA Tesla K20C</strong> GPU for OpenCV CUDA and ArrayFire CUDA implementations.

Software used for benchmarking included <strong>ArrayFire development version</strong> and <strong>OpenCV 2.4.9 with SSE and CUDA</strong> support.
<h3>Feature Detection Benchmarks</h3>
We first start with some benchmarks of the Harris corner detector. The run times for OpenCV's CUDA implementation at larger sizes are not included because it runs out of memory at larger image sizes. Note that the horizontal axes of all graphs are in logarithmic scale. 

The following graphs depict the speedup of ArrayFire CUDA and OpenCV CUDA implementations over OpenCV CPU implementation.

<iframe src="//docs.google.com/a/sandbox.arrayfire.com/spreadsheets/d/1OqbdY8B8K7z6_trW2qB1lseDREGzVe7V1OJKsPnmUC4/gviz/chartiframe?oid=1713785027" width="600" height="371" frameborder="0" scrolling="no" seamless=""></iframe>

<iframe src="//docs.google.com/a/sandbox.arrayfire.com/spreadsheets/d/1OqbdY8B8K7z6_trW2qB1lseDREGzVe7V1OJKsPnmUC4/gviz/chartiframe?oid=1883059785" width="600" height="371" frameborder="0" scrolling="no" seamless=""></iframe>

The horizontal axis for Harris detector is the number of pixels, while that of FAST detector is number of features detected. This was done because the Harris score is calculated for all the pixels before eliminating the pixels whose score falls below a certain threshold. The score for FAST features are detected by progressively eliminating pixels that do not fit various criteria. The FAST scores are only calculated once the features have been detected. This results in the time taken for Harris to scale with the number of pixels, while the times taken for FAST scales with the number of features detected.
<h3>Feature Detection Samples</h3>
In this section, we show the images with the detected features plotted on them for both ArrayFire and OpenCV. There are many variables that influence the results, including among others, rounding and empirically defined constants. For these reasons, we can not expect two implementations to be perfectly equal to each other. Even though ArrayFire and OpenCV implementations do not give the exact same results, they provide features that are very similar.

The following set of images include samples for the Harris corner detector with ArrayFire, immediately followed by OpenCV.

&nbsp;

<a href="http://sandbox.arrayfire.com/wp-content/uploads/2014/06/harris_arrayfire.png"><img class="alignnone wp-image-5886 size-full" src="http://sandbox.arrayfire.com/wp-content/uploads/2014/06/harris_arrayfire.png" alt="ArrayFire Harris" width="512" height="512" /></a>
<a href="http://sandbox.arrayfire.com/wp-content/uploads/2014/06/harris_opencv.png"><img class="alignnone wp-image-5887 size-full" src="http://sandbox.arrayfire.com/wp-content/uploads/2014/06/harris_opencv.png" alt="OpenCV Harris" width="512" height="512" /></a>

The following images show the similarities in the FAST implementations, first with ArrayFire followed by OpenCV.

<a href="http://sandbox.arrayfire.com/wp-content/uploads/2014/06/fast_arrayfire.png"><img class="alignnone size-full wp-image-5888" src="http://sandbox.arrayfire.com/wp-content/uploads/2014/06/fast_arrayfire.png" alt="ArrayFire FAST" width="512" height="512" /></a>

<a href="http://sandbox.arrayfire.com/wp-content/uploads/2014/06/fast_opencv.png"><img class="alignnone size-full wp-image-5889" src="http://sandbox.arrayfire.com/wp-content/uploads/2014/06/fast_opencv.png" alt="OpenCV FAST" width="512" height="512" /></a>
<h3>Discussion</h3>
By looking at the previous graphs, the advantage of using GPUs for computer vision applications over CPUs is made very clear, as we can get speedups of more than <strong>10 times</strong> for the FAST features detector.

Comparing OpenCV's CUDA implementation, we see that in almost all cases we are already at least as good as better. For Harris detector, ArrayFire is <strong>4 times faster</strong> than OpenCV's GPU implementation at smaller sizes before evening out. At larger sizes OpenCV CUDA implementation runs out of GPU memory and fails to detect any features.

For FAST, ArrayFire is up to <strong>3 times faster</strong> than OpenCV's CUDA implementation. ArrayFire is consistently at least <strong>2 times faster</strong> and is slower for only one image.

However, this is not yet the final version, we are still working on improving performance. We can assure that these numbers will be even more impressive when we make release these algorithms to the public.

If you can not wait until the release and want to get a taste of what is coming, please, contact us at <a href="mailto:sales@arrayfire.com">sales@arrayfire.com</a>, we will be happy to discuss on how you can get the latest features of ArrayFire before the release!

Stay tuned for the upcoming news on our new set of computer vision functions.
<h3>References</h3>
[1] Rosten, Edward, and Tom Drummond. "Machine learning for high-speed corner detection." Computer Vision–ECCV 2006. Springer Berlin Heidelberg, 2006. 430-443.
[2] Rublee, Ethan, et al. "ORB: an efficient alternative to SIFT or SURF." Computer Vision (ICCV), 2011 IEEE International Conference on. IEEE, 2011.
[3] Harris, Chris, and Mike Stephens. "A combined corner and edge detector." Alvey vision conference. Vol. 15. 1988.