Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpMomentObject.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Object input structure used by moments.
32  *
33  * Authors:
34  * Filip Novotny
35  * Manikandan Bakthavatchalam
36  *****************************************************************************/
41 #ifndef __MOMENTOBJECT_H__
42 #define __MOMENTOBJECT_H__
43 
44 #include <visp3/core/vpImage.h>
45 #include <visp3/core/vpMoment.h>
46 #include <visp3/core/vpPoint.h>
47 #include <visp3/core/vpMath.h>
48 #include <cstdlib>
49 #include <utility>
50 
51 class vpCameraParameters;
52 
205 class VISP_EXPORT vpMomentObject
206 {
207 public:
208 
212  typedef enum{
213  DENSE_FULL_OBJECT = 0,
214  DENSE_POLYGON = 1,
215  DISCRETE = 2,
216  } vpObjectType;
217 
221  typedef enum{
222  BLACK = 0,
223  WHITE = 1,
224  } vpCameraImgBckGrndType;
225 
226  bool flg_normalize_intensity; // To scale the intensity of each individual pixel in the image by the maximum intensity value present in it
227 
228  // Constructors
229  vpMomentObject(unsigned int order);
230  vpMomentObject(const vpMomentObject& srcobj);
238  virtual ~vpMomentObject();
239 
240  void fromImage(const vpImage<unsigned char>& image,unsigned char threshold, const vpCameraParameters& cam); // Binary version
241  void fromImage(const vpImage<unsigned char>& image, const vpCameraParameters& cam, vpCameraImgBckGrndType bg_type, bool normalize_with_pix_size = true); // Photometric version
242 
243  void fromVector(std::vector<vpPoint>& points);
244  const std::vector<double>& get() const;
245  double get(unsigned int i,unsigned int j) const;
246 
250  vpObjectType getType() const {return type;}
251 
256  unsigned int getOrder() const {return order-1;}
257 
258  // Constructor helpers
259  void init(unsigned int orderinp);
260  void init(const vpMomentObject& objin);
261 
262  friend VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentObject& v);
268  static void printWithIndices(const vpMomentObject& momobj, std::ostream& os);
273  void setType(vpObjectType input_type){this->type=input_type;}
274 
279  static vpMatrix convertTovpMatrix(const vpMomentObject& momobj);
280 
281 protected:
282  unsigned int order;
284  std::vector<double> values;
285  void set(unsigned int i, unsigned int j, const double& value_ij);
286  void cacheValues(std::vector<double>& cache,double x, double y);
287 
288 private:
289  void cacheValues(std::vector<double>& cache,double x, double y, double IntensityNormalized);
290  double calc_mom_polygon(unsigned int p, unsigned int q, const std::vector<vpPoint>& points);
291 
292 };
293 
294 #endif
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:97
Class for generic objects.
Generic class defining intrinsic camera parameters.
bool flg_normalize_intensity
unsigned int order
std::vector< double > values
vpObjectType getType() const
vpObjectType type
void setType(vpObjectType input_type)
unsigned int getOrder() const