CVR-Lib last update 20 Sep 2009

cvrLocation.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1998 - 2004
00003  * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany
00004  *
00005  *
00006  * This file is part of the Computer Vision and Robotics Library (CVR-Lib)
00007  *
00008  * The CVR-Lib is free software; you can redistribute it and/or
00009  * modify it under the terms of the BSD License.
00010  *
00011  * All rights reserved.
00012  *
00013  * Redistribution and use in source and binary forms, with or without
00014  * modification, are permitted provided that the following conditions are met:
00015  *
00016  * 1. Redistributions of source code must retain the above copyright notice,
00017  *    this list of conditions and the following disclaimer.
00018  *
00019  * 2. Redistributions in binary form must reproduce the above copyright notice,
00020  *    this list of conditions and the following disclaimer in the documentation
00021  *    and/or other materials provided with the distribution.
00022  *
00023  * 3. Neither the name of the authors nor the names of its contributors may be
00024  *    used to endorse or promote products derived from this software without
00025  *    specific prior written permission.
00026  *
00027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00028  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00029  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00030  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00031  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00032  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00033  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00034  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00035  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00036  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00037  * POSSIBILITY OF SUCH DAMAGE.
00038  */
00039 
00040 
00041 
00042 /**
00043  * \file   cvrLocation.h
00044  *         Definition of cvr::location which is an interest point in
00045  *         an image and circular neighborhood.
00046  *
00047  *         Global read/write methods to iostream and ostream operators are
00048  *         provided as well.
00049  * \author Pablo Alvarado
00050  * \date   07.01.2002
00051  *
00052  * $Id: cvrLocation.h,v 1.4 2005/01/03 16:09:05 alvarado Exp $
00053  */
00054 
00055 #ifndef _CVR_LOCATION_H_
00056 #define _CVR_LOCATION_H_
00057 
00058 #include "cvrPoint.h"
00059 
00060 namespace cvr {
00061 
00062   /**
00063    * The location class specifies an interest point and a small
00064    * surrounding region in an image or channel.  It is mainly used in
00065    * the extraction of local descriptors.  There are some functors to
00066    * extract the important or salient locations in an image, for
00067    * example cvr::pyramidLocationSearch.
00068    *
00069    * A locations is represented by its position in an image or channel,
00070    * an orientation and a radius.
00071    *
00072    */
00073   class location {
00074   public:
00075     /**
00076      * default constructor
00077      */
00078     location();
00079 
00080     /**
00081      * Constructor
00082      * @param pos position of the center point of the location
00083      * @param ang angle of the location (in radians)
00084      * @param rad radius or size of the location
00085      */
00086     location(const ipoint& pos,const float& ang,const float& rad);
00087 
00088     /**
00089      * Constructor
00090      * @param pos position of the center point of the location
00091      * @param ang angle of the location (in radians)
00092      * @param rad radius or size of the location
00093      */
00094     location(const fpoint& pos,const float& ang,const float& rad);
00095 
00096     /**
00097      * copy constructor
00098      */
00099     location(const location& other);
00100 
00101     /**
00102      * copy operator
00103      */
00104     location& copy(const location& other);
00105 
00106     /**
00107      * alias for copy operator
00108      */
00109     location& operator=(const location& other);
00110 
00111     /**
00112      * operator ==
00113      */
00114     bool operator==(const location& p) const;
00115 
00116     /**
00117      * operator !=
00118      */
00119     bool operator!=(const location& p) const;
00120 
00121     /**
00122      * Comparison operator: less than.
00123      *
00124      * A location is smaller than another one if its radius is smaller, or
00125      * in case of equal radii, if the position is smaller, i.e. if it has
00126      * smaller y-coordinate, or in case of equal y-position, if it has
00127      * smaller x-coordinate.
00128      */
00129     bool operator<(const location& other);
00130 
00131     /**
00132      * Comparison operator: greater than.
00133      *
00134      * A location is greater than another one if its radius is greater, or
00135      * in case of equal radii, if the position is greater, i.e. if it has
00136      * greater y-coordinate, or in case of equal y-position, if it has
00137      * greater x-coordinate.
00138      */
00139     bool operator>(const location& other);
00140 
00141     /**
00142      * Multiply the radius and position with the given factor
00143      *
00144      * @param factor scaling factor for radius and position.
00145      */
00146     location& scale(const float& factor);
00147 
00148     /**
00149      * Multiply the other location's radius and position with the
00150      * given factor and leave the result here.
00151      *
00152      * @param other location to be scaled
00153      * @param factor scaling factor for radius and position.
00154      */
00155     location& scale(const location& other,const float& factor);
00156 
00157     /**
00158      * Shift the location by the given point.
00159      *
00160      * @param shft shift the position by this offset
00161      */
00162     location& shift(const ipoint& shft);
00163 
00164     /**
00165      * Shift the location by the given point
00166      *
00167      * @param shft shift the position by this offset
00168      */
00169     location& shift(const fpoint& shft);
00170 
00171     /**
00172      * Shift the other location by the given point and leave the result here
00173      *
00174      * @param other location to be shifted
00175      * @param shft shift the position of \c other by this offset
00176      */
00177     location& shift(const location& other,const ipoint& shft);
00178 
00179     /**
00180      * Shift the other location by the given point and leave the result here
00181      *
00182      * @param other location to be shifted
00183      * @param shft shift the position of \c other by this offset
00184      */
00185     location& shift(const location& other,const fpoint& shft);
00186 
00187     /**
00188      * Rotate the location by adding the given angle in radians to the
00189      * actual angle.
00190      *
00191      * @param ang rotation angle
00192      */
00193     location& rotate(const float& ang);
00194 
00195     /**
00196      * Rotate the location by adding the given angle in radians to the
00197      * angle of the other location and leave the result here.
00198      *
00199      * @param other location to be rotated
00200      * @param ang rotation angle
00201      */
00202     location& rotate(const location& other,const float& ang);
00203 
00204     /**
00205      * Check if the given point can be considered within the location, i.e.
00206      * if ||p-position||_L2 < radius
00207      *
00208      * @param p query point
00209      */
00210     bool contains(const ipoint& p) const;
00211 
00212     /**
00213      * Check if the given point can be considered within the location, i.e.
00214      * if ||p-position||_L2 < radius
00215      *
00216      * @param p query point
00217      */
00218     bool contains(const fpoint& p) const;
00219 
00220     /**
00221      * returns the distance between the borders of two
00222      * locations or zero if they overlap or one of the locations
00223      * lies inside the other one.
00224      */
00225     float distance(const location& other);
00226 
00227     /**
00228      * Position of the location.
00229      */
00230     fpoint position;
00231 
00232     /**
00233      * Angle in radians of the location.  It is usually given for
00234      * the image coordinates, i.e. for a left coordinate system, in which
00235      * positive angles are given clock-wise.
00236      */
00237     float angle;
00238 
00239     /**
00240      * Radius or size of the location
00241      */
00242     float radius;
00243   };
00244 
00245   /**
00246    * Read a location from the ioHandler
00247    */
00248   bool read(ioHandler& handler,
00249             location& mat,
00250             const bool complete=true);
00251 
00252   /**
00253    * Write a location into the ioHandler
00254    */
00255   bool write(ioHandler& handler,
00256              const location& mat,
00257              const bool complete=true);
00258 
00259 }
00260 
00261 namespace std {
00262   ostream& operator<<(ostream& s,
00263                       const cvr::location& loc);
00264 }
00265 
00266 #endif
00267 
00268 

Generated on Sun Sep 20 22:08:00 2009 for CVR-Lib by Doxygen 1.5.8