ViSP  2.8.0
vpBasicFeature.cpp
1 /****************************************************************************
2  *
3  * $Id: vpBasicFeature.cpp 4056 2013-01-05 13:04:42Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2013 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  * Visual feature.
36  *
37  * Authors:
38  * Eric Marchand
39  * Nicolas Mansard
40  *
41  *****************************************************************************/
42 
43 
44 
45 #include <visp/vpBasicFeature.h>
46 
47 const unsigned int vpBasicFeature::FEATURE_LINE [32] =
48  {
49  (unsigned int)(1 << 0), (unsigned int)(1 << 1),
50  (unsigned int)(1 << 2), (unsigned int)(1 << 3),
51  (unsigned int)(1 << 4), (unsigned int)(1 << 5),
52  (unsigned int)(1 << 6), (unsigned int)(1 << 7),
53  (unsigned int)(1 << 8), (unsigned int)(1 << 9),
54  (unsigned int)(1 << 10), (unsigned int)(1 << 11),
55  (unsigned int)(1 << 12), (unsigned int)(1 << 13),
56  (unsigned int)(1 << 14), (unsigned int)(1 << 15),
57  (unsigned int)(1 << 16), (unsigned int)(1 << 17),
58  (unsigned int)(1 << 18), (unsigned int)(1 << 19),
59  (unsigned int)(1 << 20), (unsigned int)(1 << 21),
60  (unsigned int)(1 << 22), (unsigned int)(1 << 23),
61  (unsigned int)(1 << 24), (unsigned int)(1 << 25),
62  (unsigned int)(1 << 26), (unsigned int)(1 << 27),
63  (unsigned int)(1 << 28), (unsigned int)(1 << 29),
64  (unsigned int)(1 << 30), (unsigned int)(1 << 31)
65  };
66 const unsigned int vpBasicFeature::FEATURE_ALL = 0xffff;
67 
74 {
75 // featureLine[0] = 0x1 ;
76 // featureLine[1] = 0x2 ;
77 // featureLine[2] = 0x4 ;
78 // featureLine[3] = 0x8 ;
79 // featureLine[4] = 0x10 ;
80 // featureLine[5] = 0x20 ;
81 // featureLine[6] = 0x40 ;
82 // featureLine[7] = 0x80 ;
83  //vpTRACE("0x%x", this);
85  flags = NULL;
86 }
87 
89 unsigned int
90 vpBasicFeature::getDimension(unsigned int select) const
91 {
92  unsigned int dim = 0 ;
93  if(dim_s>31)
94  return dim_s;
95  for (unsigned int i=0 ; i < s.getRows() ; i++)
96  {
97  // printf("%x %x %d \n",select, featureLine[i], featureLine[i] & select);
98  if (FEATURE_LINE[i] & select) dim +=1 ;
99  }
100  return dim ;
101 }
102 
105  vpBasicFeature::get_s(const unsigned int select) const
106 {
107  vpColVector state(0),stateLine(1);
108  // if s is higher than the possible selections (photometry), send back the whole vector
109  if(dim_s > 31)
110  return s;
111 
112  for(unsigned int i=0;i<dim_s;++i)
113  {
114  if(FEATURE_LINE[i] & select)
115  {
116  stateLine[0] = s[i];
117  state.stackMatrices(stateLine);
118  }
119  }
120  return state ;
121 }
122 
124 {
125  if (flags != NULL)
126  {
127  for (unsigned int i = 0; i < nbParameters; i++)
128  flags[i] = false;
129  }
130 }
131 
134 {
135  if (flags != NULL)
136  {
137  for (unsigned int i = 0; i < nbParameters; i++)
138  flags[i] = true;
139  }
140 }
141 
144  const unsigned int select)
145 {
146  vpColVector e(0),eLine(1);
147  if (dim_s <= 31)
148  {
149  for(unsigned int i=0;i<dim_s;++i){
150  if(FEATURE_LINE[i] & select)
151  {
152  eLine[0] = s[i] - s_star[i];
153  e.stackMatrices(eLine);
154  //std::cout << "dim_s <= 31"<<std::endl;
155  }
156  }
157  }
158  else
159  {
160  e.resize(dim_s);
161  vpColVector sd = s_star.get_s();
162  e = s - sd;
163  }
164 
165  return e ;
166 }
167 
168 /*
169  * Local variables:
170  * c-basic-offset: 4
171  * End:
172  */
void setFlags()
Set feature flags to true to prevent warning when re-computing the interaction matrix without having ...
bool * flags
Ensure that all the parameters needed to compute the iteraction matrix are set.
static const unsigned int FEATURE_ALL
unsigned int getDimension(const unsigned int select=FEATURE_ALL) const
Get the feature vector dimension.
unsigned int dim_s
Dimension of the visual feature.
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.
class that defines what is a visual feature
static const unsigned int FEATURE_LINE[32]
static vpMatrix stackMatrices(const vpMatrix &A, const vpMatrix &B)
Stack two Matrices C = [ A B ]^T.
Definition: vpMatrix.cpp:2263
vpBasicFeatureDeallocatorType deallocate
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Definition: vpColVector.h:72
unsigned int getRows() const
Return the number of rows of the matrix.
Definition: vpMatrix.h:157
vpColVector get_s(unsigned int select=FEATURE_ALL) const
Get the feature vector .
unsigned int nbParameters
Number of parameters needed to compute the interaction matrix.
vpColVector s
State of the visual feature.