In the <a href="http://sandbox.arrayfire.com/computer-vision-arrayfire-part-1/">Part 1</a> of this series, we talked about upcoming feature detection algorithms in the ArrayFire library. In this post we show case some of the preliminary results of Feature Description and matching that are under development in the ArrayFire library. Feature description is done using the ORB feature descriptor[1]. The descriptors are matched against a database of features using Hamming distance as the metric.

The results we show in this blog use the same hardware and software used in the previous blog:
<ul>
	<li>Intel Sandy Bridge Xeon processor with 32 cores (for OpenCV CPU implementation)</li>
	<li>NVIDIA Tesla K20C (for OpenCV and ArrayFire CUDA implementations)</li>
	<li>ArrayFire development version</li>
	<li>OpenCV version 2.4.9</li>
</ul>



<h3>Feature Description and Matching Benchmarks</h3>
In Part 1 we showed that feature detection with FAST[2] scales with respect to to the number of features detected. While ORB uses FAST for the feature detection step, it performs additional computations to calculate Harris Corner scores as well as orientation of the features[3]. This results in ORB scaling with the number pixels (meaning it is not bottlenecked by FAST). 

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

The Hamming matcher benchmarks are shown below. For benchmarking purposes, we used a set of 500 descriptors as test descriptors (e.g., number of descriptors extracted from an image), being matched to a database containing 500 to 5 million descriptors, each step increasing by an order of magnitude.

<iframe src="//docs.google.com/a/sandbox.arrayfire.com/spreadsheets/d/1OqbdY8B8K7z6_trW2qB1lseDREGzVe7V1OJKsPnmUC4/gviz/chartiframe?oid=1730737789" width="600" height="371" frameborder="0" scrolling="no" seamless=""></iframe>
<h3>Descriptor Matching Samples</h3>
In this section we show an image matching of the Lena image with a 90 degrees rotation of Lena. The top set uses ArrayFire and the bottom set uses OpenCV. There is also a green rectangle around the matched pictures, that indicated the homography of the detected object.
<p style="text-align: center;"><em>ORB with ArrayFire, 21.6X speedup over CPU code.</em>
<a href="http://sandbox.arrayfire.com/wp-content/uploads/2014/07/orb_lena_arrayfire.png"><img class="alignnone size-full wp-image-6194" src="http://sandbox.arrayfire.com/wp-content/uploads/2014/07/orb_lena_arrayfire.png" alt="ArrayFire ORB" width="1024" height="512" /></a></p>
<p style="text-align: center;"><em>ORB with OpenCV for CUDA, 16.4X speedup over CPU code.</em>
<a href="http://sandbox.arrayfire.com/wp-content/uploads/2014/07/orb_lena_opencv.png"><img class="alignnone size-full wp-image-6195" src="http://sandbox.arrayfire.com/wp-content/uploads/2014/07/orb_lena_opencv.png" alt="OpenCV ORB" width="1024" height="512" /></a></p>

<h3>Discussion</h3>
We see that there is a clear advantage using GPUs over CPUs when it comes to processing time, as stated before in Part 1. By using GPUs, it is possible to do descriptor extraction more than <strong>20 times</strong> faster than with a CPU. Similarly, we can achieve average speedup of about <strong>25 times</strong> for descriptor matching using hamming distance.

These are preliminary values. This function is still under development. Please inquire with technical@arrayfire.com if you are interested in trying out our upcoming Computer Vision functions in ArrayFire.
<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] http://docs.opencv.org/trunk/doc/py_tutorials/py_feature2d/py_orb/py_orb.html