ViSP  2.10.0
vpFeatureSegment.h
1 /****************************************************************************
2  *
3  * $Id: vpFeatureThetaU.h 3530 2012-01-03 10:52:12Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Segment visual feature.
36  *
37  * Authors:
38  * Filip Novotny
39  * Fabien Spindler
40  *
41  *****************************************************************************/
42 
43 
44 #ifndef vpFeatureSegment_H
45 #define vpFeatureSegment_H
46 
52 #include <visp/vpMatrix.h>
53 #include <visp/vpPoint.h>
54 #include <visp/vpBasicFeature.h>
55 #include <visp/vpRGBa.h>
56 #include <visp/vpFeatureException.h>
57 
76 class VISP_EXPORT vpFeatureSegment : public vpBasicFeature
77 {
78 public:
79  //empty constructor
80  vpFeatureSegment(bool normalized=false);
81 
84  // change values of the segment
85  void buildFrom(const double x1, const double y1, const double Z1, const double x2, const double y2, const double Z2);
86 
87  void display(const vpCameraParameters &cam,
88  const vpImage<unsigned char> &I,
89  const vpColor &color=vpColor::green,
90  unsigned int thickness=1) const ;
91  void display(const vpCameraParameters &cam,
92  const vpImage<vpRGBa> &I,
93  const vpColor &color=vpColor::green,
94  unsigned int thickness=1) const ;
96  vpFeatureSegment *duplicate() const ;
97  // compute the error between two visual features from a subset
98  // a the possible features
99  vpColVector error(const vpBasicFeature &s_star,
100  const unsigned int select = FEATURE_ALL) ;
101 
107  inline double getXc() const { return s[0] ; }
108 
114  inline double getYc() const { return s[1] ; }
115 
122  inline double getL() const { return s[2] ; }
123 
129  inline double getAlpha() const { return s[3] ;}
130 
137  inline double getZ1() const { return Z1_ ;}
138 
145  inline double getZ2() const { return Z2_ ;}
146 
147  // Basic construction.
148  void init() ;
149 
150  // compute the interaction matrix from a subset a the possible features
151  vpMatrix interaction(const unsigned int select = FEATURE_ALL);
152 
153  void print(const unsigned int select= FEATURE_ALL) const ;
154 
158  bool isNormalized() { return normalized_; };
159 
182  inline static unsigned int selectXc() { return FEATURE_LINE[0] ; }
183 
207  inline static unsigned int selectYc() { return FEATURE_LINE[1] ; }
208 
232  inline static unsigned int selectL() { return FEATURE_LINE[2] ; }
233 
257  inline static unsigned int selectAlpha() { return FEATURE_LINE[3] ; }
258 
264  void setNormalized(bool normalized) { normalized_ = normalized; };
273  inline void setXc(const double val){
274  s[0] = xc_ = val;
275  flags[0] = true;
276  }
285  inline void setYc(const double val){
286  s[1] = yc_ = val;
287  flags[1] = true;
288  }
296  inline void setL(const double val){
297  s[2] = l_ = val;
298  flags[2] = true;
299  }
307  inline void setAlpha(const double val){
308  s[3] = alpha_ = val;
309  cos_a_ = cos(val);
310  sin_a_ = sin(val);
311  flags[3] = true;
312  }
313 
325  inline void setZ1(const double val)
326  {
327  Z1_ = val;
328 
329  if (Z1_ < 0)
330  {
331  vpERROR_TRACE("Point is behind the camera ") ;
332  std::cout <<"Z1 = " << Z1_ << std::endl ;
333 
335  "Point Z1 is behind the camera ")) ;
336  }
337 
338  if (fabs(Z1_) < 1e-6)
339  {
340  vpERROR_TRACE("Point Z1 coordinates is null ") ;
341  std::cout <<"Z1 = " << Z1_ << std::endl ;
342 
344  "Point Z1 coordinates is null")) ;
345  }
346 
347  flags[4] = true;
348  }
349 
361  inline void setZ2(const double val)
362  {
363  Z2_ = val;
364 
365  if (Z2_ < 0)
366  {
367  vpERROR_TRACE("Point Z2 is behind the camera ") ;
368  std::cout <<"Z2 = " << Z2_ << std::endl ;
369 
371  "Point Z2 is behind the camera ")) ;
372  }
373 
374  if (fabs(Z2_) < 1e-6)
375  {
376  vpERROR_TRACE("Point Z2 coordinates is null ") ;
377  std::cout <<"Z2 = " << Z2_ << std::endl ;
378 
380  "Point Z2 coordinates is null")) ;
381  }
382 
383  flags[5] = true;
384  }
385 
386 
387 private:
388  double xc_;
389  double yc_;
390  double l_;
391  double alpha_;
392  double Z1_;
393  double Z2_;
394  double cos_a_;
395  double sin_a_;
396  bool normalized_;
397 } ;
398 
399 #endif
400 
Definition of the vpMatrix class.
Definition: vpMatrix.h:98
static unsigned int selectL()
double getZ1() const
void setAlpha(const double val)
#define vpERROR_TRACE
Definition: vpDebug.h:395
virtual void print(const unsigned int select=FEATURE_ALL) const =0
Print the name of the feature.
~vpFeatureSegment()
Destructor. Does nothing.
static unsigned int selectYc()
Class to define colors available for display functionnalities.
Definition: vpColor.h:125
static unsigned int selectAlpha()
double getZ2() const
virtual vpColVector error(const vpBasicFeature &s_star, const unsigned int select=FEATURE_ALL)
Compute the error between two visual features from a subset of the possible features.
static const vpColor green
Definition: vpColor.h:170
void setL(const double val)
void setZ1(const double val)
class that defines what is a visual feature
void setZ2(const double val)
Class that defines a 2D segment visual features. This class allow to consider two sets of visual feat...
Error that can be emited by the vpBasicFeature class and its derivates.
virtual vpMatrix interaction(const unsigned int select=FEATURE_ALL)=0
Compute the interaction matrix from a subset of the possible features.
double getAlpha() const
Generic class defining intrinsic camera parameters.
virtual void init()=0
double getL() const
void setYc(const double val)
void setNormalized(bool normalized)
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Definition: vpColVector.h:72
double getYc() const
virtual vpBasicFeature * duplicate() const =0
double getXc() const
virtual void display(const vpCameraParameters &cam, const vpImage< unsigned char > &I, const vpColor &color=vpColor::green, unsigned int thickness=1) const =0
static unsigned int selectXc()
void setXc(const double val)