Visual Servoing Platform version 3.5.0
vpMomentObject.h
1/****************************************************************************
2 *
3 * ViSP, open source Visual Servoing Platform software.
4 * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5 *
6 * This software is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 * See the file LICENSE.txt at the root directory of this source
11 * distribution for additional information about the GNU GPL.
12 *
13 * For using ViSP with software that can not be combined with the GNU
14 * GPL, please contact Inria about acquiring a ViSP Professional
15 * Edition License.
16 *
17 * See http://visp.inria.fr for more information.
18 *
19 * This software was developed at:
20 * Inria Rennes - Bretagne Atlantique
21 * Campus Universitaire de Beaulieu
22 * 35042 Rennes Cedex
23 * France
24 *
25 * If you have questions regarding the use of this file, please contact
26 * Inria at visp@inria.fr
27 *
28 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30 *
31 * Description:
32 * Object input structure used by moments.
33 *
34 * Authors:
35 * Filip Novotny
36 * Manikandan Bakthavatchalam
37 *****************************************************************************/
42#ifndef _vpMomentObject_h_
43#define _vpMomentObject_h_
44
45#include <cstdlib>
46#include <utility>
47#include <visp3/core/vpImage.h>
48#include <visp3/core/vpMath.h>
49#include <visp3/core/vpMoment.h>
50#include <visp3/core/vpPoint.h>
51
53
222class VISP_EXPORT vpMomentObject
223{
224public:
228 typedef enum {
229 DENSE_FULL_OBJECT = 0,
231 DENSE_POLYGON = 1,
234 DISCRETE = 2,
235 } vpObjectType;
236
240 typedef enum {
241 BLACK = 0,
242 WHITE = 1,
243 } vpCameraImgBckGrndType;
244
245 bool flg_normalize_intensity; // To scale the intensity of each individual
246 // pixel in the image by the maximum intensity
247 // value present in it
248
249 // Constructors
250 explicit vpMomentObject(unsigned int order);
251 vpMomentObject(const vpMomentObject &srcobj);
260 virtual ~vpMomentObject();
261
262 void fromImage(const vpImage<unsigned char> &image, unsigned char threshold,
263 const vpCameraParameters &cam); // Binary version
264 void fromImage(const vpImage<unsigned char> &image, const vpCameraParameters &cam, vpCameraImgBckGrndType bg_type,
265 bool normalize_with_pix_size = true); // Photometric version
266
267 void fromVector(std::vector<vpPoint> &points);
268 const std::vector<double> &get() const;
269 double get(unsigned int i, unsigned int j) const;
270
274 vpObjectType getType() const { return type; }
275
280 unsigned int getOrder() const { return order - 1; }
281
282 // Constructor helpers
283 void init(unsigned int orderinp);
284 void init(const vpMomentObject &objin);
285
286 friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentObject &v);
292 static void printWithIndices(const vpMomentObject &momobj, std::ostream &os);
297 void setType(vpObjectType input_type) { this->type = input_type; }
298
303 static vpMatrix convertTovpMatrix(const vpMomentObject &momobj);
304
305protected:
306 unsigned int order;
308 std::vector<double> values;
309 void set(unsigned int i, unsigned int j, const double &value_ij);
310 void cacheValues(std::vector<double> &cache, double x, double y);
311
312private:
313 void cacheValues(std::vector<double> &cache, double x, double y, double IntensityNormalized);
314 double calc_mom_polygon(unsigned int p, unsigned int q, const std::vector<vpPoint> &points);
315};
316
317#endif
Generic class defining intrinsic camera parameters.
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:154
Class for generic objects.
unsigned int getOrder() const
unsigned int order
vpObjectType type
void setType(vpObjectType input_type)
bool flg_normalize_intensity
std::vector< double > values
vpObjectType getType() const