/usr/include/visp/vpFeatureLine.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 307 308 309 310 311 312 313 | /****************************************************************************
*
* $Id: vpFeatureLine.h 4056 2013-01-05 13:04: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 line visual feature.
*
* Authors:
* Eric Marchand
*
*****************************************************************************/
#ifndef vpFeatureLine_H
#define vpFeatureLine_H
/*!
\file vpFeatureLine.h
\brief Class that defines 2D line visual feature
*/
#include <visp/vpMatrix.h>
#include <visp/vpBasicFeature.h>
#include <visp/vpHomogeneousMatrix.h>
#include <visp/vpRGBa.h>
/*!
\class vpFeatureLine
\ingroup VsFeature2
\brief Class that defines a 2D line visual feature \f$ s\f$ which is
composed by two parameters that are \f$ \rho \f$ and \f$ \theta \f$,
the polar coordinates of a line.
In this class, the equation of the line in the image plane is given by :
\f[ x \; cos(\theta) + y \; sin(\theta) -\rho = 0 \f] Here
\f$ x \f$ and \f$ y \f$ are the coordinates of a point belonging to
the line and they are given in meter. The following image shows the
meanings of the distance \f$\rho\f$ and the angle \f$\theta\f$.
\image html vpFeatureLine.gif
\image latex vpFeatureLine.ps width=10cm
You have to note that the \f$ \theta \f$ angle has its value between
\f$ -\pi \f$ and \f$ \pi \f$ and that the \f$ \rho \f$ distance can
be positive or negative. The conventions are illustrated by the
image above.
The visual features can be set easily from an instance of the
classes vpLine, vpMeLine or vpCylinder. For more precision see the
class vpFeatureBuilder.
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 line feature \f$(\rho,\theta)\f$ that correspond to
the 2D equation of a line in the image plan. To control six
degrees of freedom, at least four other features must be considered
like two other line features for example. First we create a current
(\f$s\f$) 2D line 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/vpFeatureLine.h>
#include <visp/vpServo.h>
int main()
{
vpServo task; // Visual servoing task
vpFeatureLine sd; //The desired line feature.
//Sets the desired features rho and theta
double rhod = 0;
double thetad = 0;
//Sets the parameters which describe the equation of a plan in the camera frame : AX+BY+CZ+D=0.
//The line described by the features belongs to this plan.
//Normally two plans are needed to describe a line. But to compute the interaction matrix only
//one equation of the two plans is needed.
//Notes that the Dd value must not be equal to zero !
double Ad = 0;
double Bd = 0;
double Cd = 1;
double Dd = -1;
//Set the line feature thanks to the desired parameters.
sd.buildfrom(rhod, thetad, Ad,Bd, Cd, Dd);
vpFeatureLine s; //The current line feature.
//Sets the current features rho and theta
double rho; //You have to compute the value of rho.
double theta; //You have to compute the value of theta.
//Set the line feature thanks to the current parameters.
s.buildfrom(rho, theta);
//In this case the parameters A, B, C, D are not needed 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 line feature to the task
task.addFeature(s, sd);
// Control loop
for ( ; ; ) {
// The new parameters rho and theta must be computed here.
// Update the current line visual feature
s.buildfrom(rho, theta);
// 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 line visual feature, compute the corresponding error vector \f$(s-s^*)\f$ and finally build the interaction matrix \f$L_s\f$.
\code
#include <visp/vpFeatureLine.h>
#include <visp/vpMatrix.h>
int main()
{
vpFeatureLine sd; //The desired line feature.
//Sets the desired features rho and theta
double rhod = 0;
double thetad = 0;
//Sets the parameters which describe the equation of a plan in the camera frame : AX+BY+CZ+D=0.
double Ad = 0;
double Bd = 0;
double Cd = 1;
double Dd = -1;
//Set the line feature thanks to the desired parameters.
sd.buildfrom(rhod, thetad, Ad,Bd, Cd, Dd);
vpFeatureLine s; //The current line feature.
//Sets the current features rho and theta
double rho; //You have to compute the value of rho.
double theta; //You have to compute the value of theta.
//Sets the parameters which describe the equation of a plan in the camera frame : AX+BY+CZ+D=0.
double A; //You have to compute the value of A.
double B; //You have to compute the value of B.
double C; //You have to compute the value of C.
double D; //You have to compute the value of D. D must not be equal to zero !
//Set the line feature thanks to the current parameters.
s.buildfrom(rho, theta, A, B, C, D);
// Compute the interaction matrix L_s for the current line feature
vpMatrix L = s.interaction();
// You can also compute the interaction matrix L_s for the desired line feature
// The corresponding line of code is : vpMatrix L = sd.interaction();
// Compute the error vector (s-sd) for the line feature
s.error(s_star);
}
\endcode
*/
class VISP_EXPORT vpFeatureLine : public vpBasicFeature
{
/*!
attributes and members directly related to the vpBasicFeature needs
other functionalities ar useful but not mandatory
*/
private:
//! FeatureLine depth (required to compute the interaction matrix)
//! equation of a plane
double A,B,C,D ;
public:
void init() ;
vpFeatureLine() ;
virtual ~vpFeatureLine() { if (flags != NULL) delete [] flags; }
public:
void setRhoTheta(const double rho, const double theta) ;
void setABCD(const double A, const double B,
const double C, const double D) ;
// void buildFrom(const vpLine &l) ;
// void buildFrom(const vpCylinder &c, const int l) ;
void buildFrom(const double rho, const double theta) ;
void buildFrom(const double rho, const double theta,
const double A, const double B,
const double C, const double D) ;
/*!
Return the \f$ \rho \f$ subset value of the visual feature \f$ s \f$.
*/
double getRho() const { return s[0] ; }
/*!
Return the \f$ \theta \f$ subset value of the visual feature \f$ s \f$.
*/
double getTheta() const { return s[1] ; }
public:
/*!
Function used to select the \f$ \rho \f$ subset of the line visual feature.
This function is to use in conjunction with interaction() in order to compute the interaction matrix associated to \f$ \rho \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
vpFeatureLine s;
vpServo task;
...
// Add the (rho) subset features from the 2D line
task.addFeature(s, vpFeatureLine::selectRho());
\endcode
*/
inline static unsigned int selectRho() { return FEATURE_LINE[0] ; }
/*!
Function used to select the \f$ \theta \f$ subset of the line visual feature.
This function is to use in conjunction with interaction() in order to compute the interaction matrix associated to \f$ \theta \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
vpFeatureLine s;
vpServo task;
...
// Add the (rho) subset features from the 2D line
task.addFeature(s, vpFeatureLine::selectTheta());
\endcode
*/
inline static unsigned int selectTheta() { return FEATURE_LINE[1] ; }
vpMatrix interaction(const unsigned int select = FEATURE_ALL);
vpColVector error(const vpBasicFeature &s_star,
const unsigned int select = FEATURE_ALL) ;
//vpColVector error(const int select = FEATURE_ALL) ;
void print(const unsigned int select= FEATURE_ALL) const ;
vpFeatureLine *duplicate() const ;
public:
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 ;
} ;
#endif
/*
* Local variables:
* c-basic-offset: 2
* End:
*/
|