FastMatchTemplate.h
Go to the documentation of this file.
00001 #ifndef FastMatchTemplate_h
00002 #define FastMatchTemplate_h
00003 /***************************************************************************
00004  *            FastMatchTemplate.h
00005  *
00006  *
00007  *  Copyright  2010  Tristen Georgiou
00008  *  tristen_georgiou@hotmail.com
00009  ****************************************************************************/
00010 
00011 /*
00012  *  This program is free software; you can redistribute it and/or modify
00013  *  it under the terms of the GNU General Public License as published by
00014  *  the Free Software Foundation; either version 2 of the License, or
00015  *  (at your option) any later version.
00016  *
00017  *  This program is distributed in the hope that it will be useful,
00018  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *  GNU General Public License for more details.
00021  *
00022  *  You should have received a copy of the GNU General Public License
00023  *  along with this program; if not, write to the Free Software
00024  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00025 
00026 
00027     How fast match template works:
00028     1. Both target and source image are down sampled numDownPyrs times
00029     2. cvMatchTemplate() function is called on shrunken images
00030        (uses CCORR_NORMED algorithm)
00031     3. The numMaxima best locations are found
00032     4. For each point where a maxima was located:
00033        a) Original source image is searched at point +/- searchExpansion
00034           pixels in both x and y direction
00035     5. If match score is above matchPercentage then the location and score is
00036        saved in the foundPointsList and confidencesList, respectively
00037     6. If findMultipleTargets is true, an attempt will be made to find up to
00038        numMaxima targets
00039     7. (Optional) The targets can be drawn to a color version of the source
00040        image using the DrawFoundTargets() function
00041  */
00042 
00043 #include <stdio.h>
00044 #include <opencv/cv.h>
00045 
00046 using namespace cv;
00047 using namespace std;
00048 
00049 /*=============================================================================
00050   FastMatchTemplate
00051   Performs a fast match template
00052   Returns: true on success, false on failure
00053   Parameters:
00054     source - source image (where we are searching)
00055     target - target image (what we are searching for)
00056     foundPointsList - contains a list of the points where the target was found
00057     confidencesList - contains a list of the confidence value (0-100) for each
00058                       found target
00059     matchPercentage - the minimum required match score to consider the target
00060                       found
00061     findMultipleTargets - if set to true, the function will attempt to find a
00062                           maximum of numMaxima targets
00063     numMaxima - the maximum number of search locations to try before exiting
00064                 (i.e. when image is down-sampled and searched, we collect the
00065                 best numMaxima locations - those with the highest confidence -
00066                 and search the original image at these locations)
00067     numDownPyrs - the number of times to down-sample the image (only increase
00068                   this number if your images are really large)
00069     searchExpansion - The original source image is searched at the top locations
00070                       with +/- searchExpansion pixels in both the x and y
00071                       directions
00072 */
00073 bool
00074 FastMatchTemplate(const Mat&      source,
00075                   const Mat&      target,
00076                   vector<Point>*  foundPointsList,
00077                   vector<double>* confidencesList,
00078                   int             matchPercentage = 55,
00079                   bool            findMultipleTargets = true,
00080                   int             numMaxima = 10,
00081                   int             numDownPyrs = 2,
00082                   int             searchExpansion = 15);
00083 
00084 /*=============================================================================
00085   MultipleMaxLoc
00086   Searches an image for multiple maxima
00087   Assumes a single channel, floating point image
00088   Parameters:
00089     image - the input image, generally the result from a cvMatchTemplate call
00090     locations - array of CvPoint (pass in a NULL point)
00091     numMaxima - the maximum number of best match maxima to locate
00092 */
00093 void
00094 MultipleMaxLoc(const Mat& image,
00095                Point**    locations,
00096                int        numMaxima);
00097 
00098 /*=============================================================================
00099   DrawFoundTargets
00100   Draws a rectangle of dimension size, at the given positions in the list,
00101   in the given RGB color space
00102   Parameters:
00103     image - a color image to draw on
00104     size - the size of the rectangle to draw
00105     pointsList - a list of points where a rectangle should be drawn
00106     confidencesList - a list of the confidences associated with the points
00107     red - the red value (0-255)
00108     green - the green value (0-255)
00109     blue - the blue value (0-255)
00110 */
00111 void
00112 DrawFoundTargets(Mat*                  image,
00113                  const Size&           size,
00114                  const vector<Point>&  pointsList,
00115                  const vector<double>& confidencesList,
00116                  int                   red   = 0,
00117                  int                   green = 255,
00118                  int                   blue  = 0);
00119 
00120 #endif


fast_match_template
Author(s): Tristen Georgiou, Dejan Pangercic (for ROS and modifications)
autogenerated on Mon Oct 6 2014 08:23:34