/usr/include/x86_64-linux-gnu/visp3/core/vpMomentCInvariant.h is in libvisp-core-dev 3.0.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 | /****************************************************************************
*
* This file is part of the ViSP software.
* Copyright (C) 2005 - 2015 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://visp.inria.fr for more information.
*
* This software was developed at:
* Inria Rennes - Bretagne Atlantique
* Campus Universitaire de Beaulieu
* 35042 Rennes Cedex
* France
*
* 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:
* Descriptor for various invariants used to drive space roations around X and Y axis.
*
* Authors:
* Filip Novotny
*
*****************************************************************************/
/*!
\file vpMomentCInvariant.h
\brief Descriptor for various invariants used to drive space roations around X and Y axis.
*/
#ifndef __MOMENTCINVARIANT_H__
#define __MOMENTCINVARIANT_H__
#include <visp3/core/vpMoment.h>
#include <visp3/core/vpMomentDatabase.h>
class vpMomentCentered;
class vpMomentBasic;
/*!
\class vpMomentCInvariant
\ingroup group_core_moments
This class defines several 2D (translation+rotation+scale) invariants for both symmetric and non-symmetric objects.
These moment-based invariants are described in the following papers \cite Chaumette04a, \cite Tahri05z.
The descriptions for the invariants \f$C_1\f$ to \f$C_{10}\f$ can be found in \cite Chaumette04a and for invariants \f$P_x\f$,\f$P_y\f$,\f$S_x\f$,\f$S_y\f$ in \cite Tahri05z.
These invariants are classicaly used in visual servoing to control the out-of-plane rotations.
The C-type or P-type invariants are used for non-symmetric objects whereas the S-type invariants are used for symmetric objects.
For most cases of non-symmetric objects, (\f$C_4\f$,\f$C_6\f$) or (\f$P_x\f$,\f$P_y\f$) couples are widely used to control x and y rotations.
For symmetric objects \f$S_x\f$ and \f$S_y\f$ are the only choice.
There are 14 translation+rotation+scale invariants (10 C-type, 2 P-type and 2 S-type) that can be accessed from by vpMomentCInvariant::get
or any of the get shortcuts.
The example below shows how to retrieve the \f$C_2\f$ invariant:
\code
#include <visp3/core/vpMomentObject.h>
#include <visp3/core/vpPoint.h>
#include <visp3/core/vpMomentCInvariant.h>
#include <visp3/core/vpMomentCommon.h>
#include <iostream>
int main()
{
vpPoint p;
std::vector<vpPoint> vec_p;
p.set_x(6); p.set_y(-1); // coordinates in meters in the image plane (vertex 1)
vec_p.push_back(p);
p.set_x(2); p.set_y(3); // coordinates in meters in the image plane (vertex 2)
vec_p.push_back(p);
p.set_x(0); p.set_y(1.2); // coordinates in meters in the image plane (vertex 1)
vec_p.push_back(p);
p.set_x(-7); p.set_y(-4); // coordinates in meters in the image plane (vertex 2)
vec_p.push_back(p);
vpMomentObject obj(5); // Create an image moment object with 5 as maximum order
obj.setType(vpMomentObject::DISCRETE); // Discrete mode for object
obj.fromVector(vec_p);
//initialisation with default values
vpMomentCommon db(vpMomentCommon::getSurface(obj),vpMomentCommon::getMu3(obj),vpMomentCommon::getAlpha(obj),1.);
bool success;
db.updateAll(obj); // Update AND compute all moments
//get C-invariant
const vpMomentCInvariant& C = static_cast<const vpMomentCInvariant&>(db.get("vpMomentCInvariant",success));
if(success)
std::cout << C.get(1) << std:: endl; // print C2 invariant
else
std::cout << "vpMomentCInvariant not found." << std::endl;
return 0;
}
\endcode
vpMomentCInvariant depends on vpMomentCentered (see vpMomentDatabase and vpMomentCommon).
*/
class VISP_EXPORT vpMomentCInvariant : public vpMoment {
private:
std::vector<double> I;
std::vector<double> II;
std::vector<double> c;
std::vector<double> s;
double K;
void computeI(const vpMomentCentered& momentCentered, std::vector<double>& I);
/* To calculate Sx and Sy from normalized moments */
void calcSxSy(double& sx, double& sy) const;
void calcSxSyNormalized(double& sx, double& sy) const;
std::vector<double> cn; // same as s above but calculated from normalized moments
std::vector<double> sn; // same as c above but calculated from normalized moments
double In1; // same as I1 in Sx,Sy formulae but calculated from normalized moments
bool flg_sxsynormalization_;
public:
vpMomentCInvariant(bool flg_sxsynormalization = false);
/*!
Shorcut for getting the value of \f$C_1\f$.
*/
double C1() const { return values[0]; }
/*!
Shorcut for getting the value of \f$C_2\f$.
*/
double C2() const { return values[1]; }
/*!
Shorcut for getting the value of \f$C_3\f$.
*/
double C3() const { return values[2]; }
/*!
Shorcut for getting the value of \f$C_4\f$.
*/
double C4() const { return values[3]; }
/*!
Shorcut for getting the value of \f$C_5\f$.
*/
double C5() const { return values[4]; }
/*!
Shorcut for getting the value of \f$C_6\f$.
*/
double C6() const { return values[5]; }
/*!
Shorcut for getting the value of \f$C_7\f$.
*/
double C7() const { return values[6]; }
/*!
Shorcut for getting the value of \f$C_8\f$.
*/
double C8() const { return values[7]; }
/*!
Shorcut for getting the value of \f$C_9\f$.
*/
double C9() const { return values[8]; }
/*!
Shorcut for getting the value of \f$C_{10}\f$.
*/
double C10() const { return values[9]; }
void compute();
/*!
Gets the desired invariant.
\param i given index. For invariants from C1 to C10 the corresponding index is from 0 to 9. For \f$S_x\f$,\f$S_y\f$ the indexes are 10,11 and for \f$P_x\f$,\f$P_y\f$ they are 12,13.
*/
double get(unsigned int i) const { return values[i]; }
/*!
Access to partial invariant c (see [2]).
*/
double getC(unsigned int i) const {return c[i];}
/*!
Access to partial invariants. The index convention is the same as in [1].
*/
double getI(unsigned int index) const {return I[index];}
/*!
Print the moment invariants used to obtain the actual visual features
*/
void printInvariants(std::ostream& os) const;
/*!
Access to partial invariant I (see [2]).
*/
double getII(unsigned int i) const {return II[i];}
/*!
Access to partial invariant K (see [2]).
*/
double getK() const {return K;}
/*!
Access to partial invariant S (see [2]).
*/
double getS(unsigned int i) const {return s[i];}
/*!
Moment name.
*/
const char* name() const {return "vpMomentCInvariant";}
/*!
Print partial invariant.
*/
void printI(unsigned int index);
/*!
Shorcut for getting the value of \f$P_x\f$.
*/
double Px(){ return values[12]; }
/*!
Shorcut for getting the value of\f$P_y\f$.
*/
double Py(){ return values[13]; }
/*!
Shorcut for getting the value of \f$S_x\f$.
*/
double Sx() const { return values[10]; }
/*!
Shorcut for getting the value of \f$S_y\f$.
*/
double Sy() const { return values[11]; }
/*!
* Getters for I
* (calculated from normalized 2nd and 3ord order moments)
*/
double getIn1() const {return In1;}
/*!
* Getter for c
* (calculated from normalized 2nd and 3ord order moments)
*/
double getCN(unsigned int i) const {return cn[i];}
/*!
* Getter for s
* (calculated from normalized 2nd and 3ord order moments)
*/
double getSN(unsigned int i) const {return sn[i];}
/*!
* To know if Sx and Sy were calculated from normalized moments or not
*/
bool isSxSyfromNormalizedMoments() const {return flg_sxsynormalization_;};
/*!
* To get all the invariant values as a whole.
*/
inline const std::vector<double>& getMomentVector() const { return values; }
friend VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentCInvariant& v);
};
#endif
|