﻿Original code has been submitted by Liu Liu. Here is the copyright.
----------------------------------------------------------------------------------
   An OpenCV Implementation of SURF
   Further Information Refer to "SURF: Speed-Up Robust Feature"
   Author: Liu Liu
   liuliu.1987+opencv@gmail.com

   There are still serveral lacks for this experimental implementation:

   1. The interpolation of sub-pixel mentioned in article was not implemented
      yet;

   2. A comparision with original libSurf.so shows that the hessian detector is
      not a 100% match to their implementation;

   3. Due to above reasons, I recommanded the original one for study and reuse;

   However, the speed of this implementation is something comparable to original
   one.

   Copyright© 2008, Liu Liu All rights reserved.

   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are met:

   * Redistributions of source code must retain the above copyright notice, this
     list of conditions and the following disclaimer.

   * Redistributions in binary form must reproduce the above copyright notice,
     this list of conditions and the following disclaimer in the documentation
     and/or other materials provided with the distribution.

   * The name of Contributor may not be used to endorse or promote products
     derived from this software without specific prior written permission.

   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


The following changes have been made, comparing to the original contribution:
----------------------------------------------------------------------------------
   
   1. A lot of small optimizations, less memory allocations, got rid of global
      buffers

   2. Reversed order of cvGetQuadrangleSubPix and cvResize calls; probably less
      accurate, but much faster
   
   3. The descriptor computing part (which is most expensive) is threaded using
      OpenMP (subpixel-accurate keypoint localization and scale estimation are
      still TBD)

   KeyPoint position and scale interpolation has been implemented as described in
   the Brown and Lowe paper cited by the SURF paper.

   The sampling step along the x and y axes of the image for the determinant of the
   Hessian is now the same for each layer in an octave. While this increases the
   computation time, it ensures that a true 3x3x3 neighbourhood exists, with
   samples calculated at the same position in the layers above and below. This
   results in improved maxima detection and non-maxima suppression, and I think it
   is consistent with the description in the SURF paper.

   The wavelet size sampling interval has also been made consistent. The wavelet
   size at the first layer of the first octave is now 9 instead of 7. Along with
   regular position sampling steps, this makes location and scale interpolation
   easy. I think this is consistent with the SURF paper and original
   implementation.

   The scaling of the wavelet parameters has been fixed to ensure that the patterns
   are symmetric around the centre. Previously the truncation caused by integer
   division in the scaling ratio caused a bias towards the top left of the wavelet,
   resulting in inconsistent keypoint positions.

   The matrices for the determinant and trace of the Hessian are now reused in each
   octave.

   The extraction of the patch of pixels surrounding a keypoint used to build a
   descriptor has been simplified.

   KeyPoint descriptor normalisation has been changed from normalising each 4x4
   cell (resulting in a descriptor of magnitude 16) to normalising the entire
   descriptor to magnitude 1.

   The default number of octaves has been increased from 3 to 4 to match the
   original SURF binary default. The increase in computation time is minimal since
   the higher octaves are sampled sparsely.

   The default number of layers per octave has been reduced from 3 to 2, to prevent
   redundant calculation of similar sizes in consecutive octaves.  This decreases
   computation time. The number of features extracted may be less, however the
   additional features were mostly redundant.

   The radius of the circle of gradient samples used to assign an orientation has
   been increased from 4 to 6 to match the description in the SURF paper. This is
   now defined by ORI_RADIUS, and could be made into a parameter.

   The size of the sliding window used in orientation assignment has been reduced
   from 120 to 60 degrees to match the description in the SURF paper. This is now
   defined by ORI_WIN, and could be made into a parameter.

   Other options like  HAAR_SIZE0, HAAR_SIZE_INC, SAMPLE_STEP0, ORI_SEARCH_INC,
   ORI_SIGMA and DESC_SIGMA have been separated from the code and documented. These
   could also be made into parameters.

   Modifications by Ian Mahon
