40 #include <visp3/core/vpDisplay.h>
41 #include <visp3/core/vpImagePoint.h>
42 #include <visp3/core/vpMath.h>
43 #include <visp3/core/vpMeterPixelConversion.h>
44 #include <visp3/visual_features/vpBasicFeature.h>
45 #include <visp3/visual_features/vpFeatureSegment.h>
48 #include <visp3/core/vpException.h>
51 #include <visp3/core/vpDebug.h>
80 : xc_(0), yc_(0), l_(0), alpha_(0), Z1_(0), Z2_(0), cos_a_(0), sin_a_(0), normalized_(normalized)
191 if (
flags[i] ==
false) {
194 vpTRACE(
"Warning !!! The interaction matrix is computed but xc "
198 vpTRACE(
"Warning !!! The interaction matrix is computed but Yc "
202 vpTRACE(
"Warning !!! The interaction matrix is computed but l was "
206 vpTRACE(
"Warning !!! The interaction matrix is computed but alpha "
210 vpTRACE(
"Warning !!! The interaction matrix is computed but Z1 "
214 vpTRACE(
"Warning !!! The interaction matrix is computed but Z2 "
218 vpTRACE(
"Problem during the reading of the variable flags");
225 double lambda1 = (Z1_ - Z2_) / (Z1_ * Z2_);
226 double lambda2 = (Z1_ + Z2_) / (2 * Z1_ * Z2_);
233 double lambda = -lambda1 * ln;
234 double Zn_inv = lambda2 * ln;
235 double lc = cos_a_ / ln;
236 double ls = sin_a_ / ln;
237 double xnalpha = xn * cos_a_ + yn * sin_a_;
238 double lnc = cos_a_ * ln;
239 double lns = sin_a_ * ln;
243 Lxn[0][0] = -Zn_inv + lambda * xn * cos_a_;
244 Lxn[0][1] = lambda * xn * sin_a_;
245 Lxn[0][2] = lambda1 * (xn * xnalpha - cos_a_ / 4.);
246 Lxn[0][3] = sin_a_ * cos_a_ / 4 / ln - xn * xnalpha * sin_a_ / ln;
247 Lxn[0][4] = -ln * (1. + lc * lc / 4.) + xn * xnalpha * cos_a_ / ln;
254 Lyn[0][0] = lambda * yn * cos_a_;
255 Lyn[0][1] = -Zn_inv + lambda * yn * sin_a_;
256 Lyn[0][2] = lambda1 * (yn * xnalpha - sin_a_ / 4.);
257 Lyn[0][3] = ln * (1 + ls * ls / 4.) - yn * xnalpha * sin_a_ / ln;
258 Lyn[0][4] = -sin_a_ * cos_a_ / 4 / ln + yn * xnalpha * cos_a_ / ln;
265 Lln[0][0] = lambda * lnc;
266 Lln[0][1] = lambda * lns;
267 Lln[0][2] = -(Zn_inv + lambda * xnalpha);
268 Lln[0][3] = -yn - xnalpha * sin_a_;
269 Lln[0][4] = xn + xnalpha * cos_a_;
277 Lalpha[0][0] = -lambda1 * sin_a_ * l_;
278 Lalpha[0][1] = lambda1 * cos_a_ * l_;
279 Lalpha[0][2] = lambda1 * (xc_ * sin_a_ - yc_ * cos_a_);
280 Lalpha[0][3] = (-xc_ * sin_a_ * sin_a_ + yc_ * cos_a_ * sin_a_) / l_;
281 Lalpha[0][4] = (xc_ * cos_a_ * sin_a_ - yc_ * cos_a_ * cos_a_) / l_;
289 Lxc[0][0] = -lambda2;
291 Lxc[0][2] = lambda2 * xc_ - lambda1 * l_ * cos_a_ / 4.;
292 Lxc[0][3] = xc_ * yc_ + l_ * l_ * cos_a_ * sin_a_ / 4.;
293 Lxc[0][4] = -(1 + xc_ * xc_ + l_ * l_ * cos_a_ * cos_a_ / 4.);
301 Lyc[0][1] = -lambda2;
302 Lyc[0][2] = lambda2 * yc_ - lambda1 * l_ * sin_a_ / 4.;
303 Lyc[0][3] = 1 + yc_ * yc_ + l_ * l_ * sin_a_ * sin_a_ / 4.;
304 Lyc[0][4] = -xc_ * yc_ - l_ * l_ * cos_a_ * sin_a_ / 4.;
311 Ll[0][0] = lambda1 * cos_a_;
312 Ll[0][1] = lambda1 * sin_a_;
313 Ll[0][2] = lambda2 * l_ - lambda1 * (xc_ * cos_a_ + yc_ * sin_a_);
314 Ll[0][3] = l_ * (xc_ * cos_a_ * sin_a_ + yc_ * (1 + sin_a_ * sin_a_));
315 Ll[0][4] = -l_ * (xc_ * (1 + cos_a_ * cos_a_) + yc_ * cos_a_ * sin_a_);
321 Lalpha[0][0] = -lambda1 * sin_a_ / l_;
322 Lalpha[0][1] = lambda1 * cos_a_ / l_;
323 Lalpha[0][2] = lambda1 * (xc_ * sin_a_ - yc_ * cos_a_) / l_;
324 Lalpha[0][3] = -xc_ * sin_a_ * sin_a_ + yc_ * cos_a_ * sin_a_;
325 Lalpha[0][4] = xc_ * cos_a_ * sin_a_ - yc_ * cos_a_ * cos_a_;
364 exc[0] = xc_ - s_star[0];
370 eyc[0] = yc_ - s_star[1];
376 eL[0] = l_ - s_star[2];
382 eAlpha[0] = alpha_ - s_star[3];
383 while (eAlpha[0] < -M_PI)
384 eAlpha[0] += 2 * M_PI;
385 while (eAlpha[0] > M_PI)
386 eAlpha[0] -= 2 * M_PI;
421 std::cout <<
"vpFeatureSegment: (";
424 std::cout <<
"xn = ";
426 std::cout <<
"xc = ";
427 std::cout <<
s[0] <<
"; ";
431 std::cout <<
"yn = ";
433 std::cout <<
"yc = ";
434 std::cout <<
s[1] <<
"; ";
438 std::cout <<
"ln = ";
441 std::cout <<
s[2] <<
"; ";
446 std::cout <<
")" << std::endl;
476 unsigned int thickness)
const
490 double x1 = x - (l / 2.) * cos_a_;
491 double x2 = x + (l / 2.) * cos_a_;
493 double y1 = y - (l / 2.) * sin_a_;
494 double y2 = y + (l / 2.) * sin_a_;
514 unsigned int thickness)
const
528 double x1 = x - (l / 2.) * cos_a_;
529 double x2 = x + (l / 2.) * cos_a_;
531 double y1 = y - (l / 2.) * sin_a_;
532 double y2 = y + (l / 2.) * sin_a_;
560 double l = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
561 double x_c = (x1 + x2) / 2.;
562 double y_c = (y1 + y2) / 2.;
563 double alpha = atan2(y1 - y2, x1 - x2);
class that defines what is a visual feature
vpColVector s
State of the visual feature.
unsigned int nbParameters
Number of parameters needed to compute the interaction matrix.
unsigned int dim_s
Dimension of the visual feature.
static const unsigned int FEATURE_LINE[32]
vpBasicFeatureDeallocatorType deallocate
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
void resize(unsigned int i, bool flagNullify=true)
Class to define RGB colors available for display functionalities.
static const vpColor cyan
static const vpColor yellow
static void displayCircle(const vpImage< unsigned char > &I, const vpImageCircle &circle, const vpColor &color, bool fill=false, unsigned int thickness=1)
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1, bool segment=true)
Class that defines a 2D segment visual features. This class allow to consider two sets of visual feat...
void display(const vpCameraParameters &cam, const vpImage< unsigned char > &I, const vpColor &color=vpColor::green, unsigned int thickness=1) const VP_OVERRIDE
vpColVector error(const vpBasicFeature &s_star, unsigned int select=FEATURE_ALL) VP_OVERRIDE
static unsigned int selectAlpha()
void print(unsigned int select=FEATURE_ALL) const VP_OVERRIDE
static unsigned int selectXc()
void setAlpha(double val)
static unsigned int selectYc()
vpFeatureSegment * duplicate() const VP_OVERRIDE
Feature duplication.
VP_EXPLICIT vpFeatureSegment(bool normalized=false)
vpFeatureSegment & buildFrom(const double &x1, const double &y1, const double &Z1, const double &x2, const double &y2, const double &Z2)
vpMatrix interaction(unsigned int select=FEATURE_ALL) VP_OVERRIDE
static unsigned int selectL()
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static double deg(double rad)
Implementation of a matrix and operations on matrices.
void stack(const vpMatrix &A)
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)