/usr/include/visp/vpFeaturePoint.h is in libvisp-dev 2.8.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | /****************************************************************************
*
* $Id: vpFeaturePoint.h 4233 2013-05-02 13:46:42Z fspindle $
*
* This file is part of the ViSP software.
* Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* ("GPL") version 2 as published by the Free Software Foundation.
* See the file LICENSE.txt at the root directory of this source
* distribution for additional information about the GNU GPL.
*
* For using ViSP with software that can not be combined with the GNU
* GPL, please contact INRIA about acquiring a ViSP Professional
* Edition License.
*
* See http://www.irisa.fr/lagadic/visp/visp.html for more information.
*
* This software was developed at:
* INRIA Rennes - Bretagne Atlantique
* Campus Universitaire de Beaulieu
* 35042 Rennes Cedex
* France
* http://www.irisa.fr/lagadic
*
* If you have questions regarding the use of this file, please contact
* INRIA at visp@inria.fr
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
*
* Description:
* 2D point visual feature.
*
* Authors:
* Eric Marchand
*
*****************************************************************************/
#ifndef vpFeaturePoint_H
#define vpFeaturePoint_H
/*!
\file vpFeaturePoint.h
\brief Class that defines 2D point visual feature
*/
#include <visp/vpMatrix.h>
#include <visp/vpBasicFeature.h>
#include <visp/vpPoint.h>
#include <visp/vpHomogeneousMatrix.h>
#include <visp/vpRGBa.h>
/*!
\class vpFeaturePoint
\ingroup VsFeature2
\brief Class that defines a 2D point visual feature \f$ s\f$ which
is composed by two parameters that are the cartesian coordinates \f$
x \f$ and \f$ y \f$.
In this class \f$ x \f$ and \f$ y \f$ are the 2D coordinates in the
image plane and are given in meter. \f$ Z \f$ which is the 3D
coordinate representing the depth is also a parameter of the
point. It is needed during the computation of the interaction matrix
\f$ L \f$.
The visual features can be set easily from an instance of the
classes vpPoint, vpDot or vpDot2. For more precision see the
vpFeatureBuilder class.
Once the values of the visual features are set, the interaction()
method allows to compute the interaction matrix \f$ L \f$ associated
to the visual feature, while the error() method computes the error
vector \f$(s - s^*)\f$ between the current visual feature and the
desired one.
The code below shows how to create a eye-in hand visual servoing
task using a 2D point feature \f$(x,y)\f$ that correspond to the 2D
coordinates of a point in the image plane. To control six degrees
of freedom, at least four other features must be considered like two
other point features for example. First we create a current
(\f$s\f$) 2D point feature. Then we set the task to use the
interaction matrix associated to the current feature \f$L_s\f$. And
finally we compute the camera velocity \f$v=-\lambda \; L_s^+ \;
(s-s^*)\f$. The current feature \f$s\f$ is updated in the while()
loop.
\code
#include <visp/vpFeaturePoint.h>
#include <visp/vpServo.h>
int main()
{
vpServo task; // Visual servoing task
vpFeaturePoint sd; //The desired point feature.
//Set the desired features x and y
double xd = 0;
double yd = 0;
//Set the depth of the point in the camera frame.
double Zd = 1;
//Set the point feature thanks to the desired parameters.
sd.buildFrom(xd, yd, Zd);
vpFeaturePoint s; //The current point feature.
//Set the current features x and y
double x; //You have to compute the value of x.
double y; //You have to compute the value of y.
double Z; //You have to compute the value of Z.
//Set the point feature thanks to the current parameters.
s.buildFrom(x, y, Z);
//In this case the parameter Z is not necessary because the interaction matrix is computed
//with the desired visual feature.
// Set eye-in-hand control law.
// The computed velocities will be expressed in the camera frame
task.setServo(vpServo::EYEINHAND_CAMERA);
// Interaction matrix is computed with the desired visual features sd
task.setInteractionMatrixType(vpServo::DESIRED);
// Add the 2D point feature to the task
task.addFeature(s, sd);
// Control loop
for ( ; ; ) {
// The new parameters x and y must be computed here.
// Update the current point visual feature
s.buildFrom(x, y, Z);
// compute the control law
vpColVector v = task.computeControlLaw(); // camera velocity
}
return 0;
}
\endcode
If you want to build your own control law, this other example shows how
to create a current (\f$s\f$) and desired (\f$s^*\f$) 2D point visual
feature, compute the corresponding error vector \f$(s-s^*)\f$ and finally
build the interaction matrix \f$L_s\f$.
\code
#include <visp/vpFeaturePoint.h>
#include <visp/vpMatrix.h>
int main()
{
vpFeaturePoint sd; //The desired point feature.
//Set the desired features x and y
double xd = 0;
double yd = 0;
//Set the depth of the point in the camera frame.
double Zd = 1;
//Set the point feature thanks to the desired parameters.
sd.buildFrom(xd, yd, Zd);
vpFeaturePoint s; //The current point feature.
//Set the current features x and y
double x; //You have to compute the value of x.
double y; //You have to compute the value of y.
double Z; //You have to compute the value of Z.
//Set the point feature thanks to the current parameters.
s.buildFrom(x, y, Z);
// Compute the interaction matrix L_s for the current point feature
vpMatrix L = s.interaction();
// You can also compute the interaction matrix L_s for the desired point feature
// The corresponding line of code is : vpMatrix L = sd.interaction();
// Compute the error vector (s-sd) for the point feature
s.error(s_star);
}
\endcode
An other fully explained example is given in the \ref tutorial-ibvs.
*/
class VISP_EXPORT vpFeaturePoint : public vpBasicFeature
{
private:
//! FeaturePoint depth (required to compute the interaction matrix)
//! default Z = 1m
double Z ;
public:
void init() ;
vpFeaturePoint() ;
//! Destructor.
virtual ~vpFeaturePoint() { if (flags != NULL) delete [] flags; }
/*
section Set coordinates
*/
void buildFrom(const double x, const double y, const double Z) ;
void set_x(const double x) ;
void set_y(const double y) ;
void set_Z(const double Z) ;
void set_xyZ(const double x, const double y, const double Z) ;
double get_x() const ;
double get_y() const ;
double get_Z() const ;
/*
vpBasicFeature method instantiation
*/
// feature selection
/*!
Function used to select the \f$ x \f$ subset of the point visual feature.
This function is to use in conjunction with interaction() in order to compute the interaction matrix associated to \f$ x \f$.
This function is also useful in the vpServo class to indicate that a subset of the visual feature is to use in the control law:
\code
vpFeaturePoint s;
vpServo task;
...
// Add the (x) subset features from the 2D point
task.addFeature(s, vpFeaturePoint::selectX());
\endcode
*/
inline static unsigned int selectX() { return FEATURE_LINE[0] ; }
/*!
Function used to select the \f$ y \f$ subset of the point visual feature.
This function is to use in conjunction with interaction() in order to compute the interaction matrix associated to \f$ y \f$.
This function is also useful in the vpServo class to indicate that a subset of the visual feature is to use in the control law:
\code
vpFeaturePoint s;
vpServo task;
...
// Add the (y) subset features from the 2D point
task.addFeature(s, vpFeaturePoint::selectY());
\endcode
*/
inline static unsigned int selectY() { return FEATURE_LINE[1] ; }
vpMatrix interaction(const unsigned int select = FEATURE_ALL);
vpColVector error(const vpBasicFeature &s_star,
const unsigned int select = FEATURE_ALL) ;
void print(const unsigned int select = FEATURE_ALL ) const ;
vpFeaturePoint *duplicate() const ;
void display(const vpCameraParameters &cam,
const vpImage<unsigned char> &I,
const vpColor &color=vpColor::green,
unsigned int thickness=1) const ;
void display(const vpCameraParameters &cam,
const vpImage<vpRGBa> &I,
const vpColor &color=vpColor::green,
unsigned int thickness=1) const ;
/*!
@name Deprecated functions
*/
typedef enum
{
X = 1, // x coordinates
Y = 2 // y coordinates
} vpFeaturePointType;
//! Compute the error between a visual features and zero
vpColVector error(const unsigned int select = FEATURE_ALL) ;
} ;
#endif
/*
* Local variables:
* c-basic-offset: 2
* End:
*/
|