Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
vpMomentObject.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
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 https://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 */
37#ifndef _vpMomentObject_h_
38#define _vpMomentObject_h_
39
40#include <cstdlib>
41#include <utility>
42#include <visp3/core/vpImage.h>
43#include <visp3/core/vpMath.h>
44#include <visp3/core/vpMoment.h>
45#include <visp3/core/vpPoint.h>
46
48
217class VISP_EXPORT vpMomentObject
218{
219public:
223 typedef enum
224 {
225 DENSE_FULL_OBJECT = 0,
227 DENSE_POLYGON = 1,
230 DISCRETE = 2,
231 } vpObjectType;
232
236 typedef enum
237 {
238 BLACK = 0,
239 WHITE = 1,
240 } vpCameraImgBckGrndType;
241
242 bool flg_normalize_intensity; // To scale the intensity of each individual
243 // pixel in the image by the maximum intensity
244 // value present in it
245
246 // Constructors
247 explicit vpMomentObject(unsigned int order);
248 vpMomentObject(const vpMomentObject &srcobj);
257 virtual ~vpMomentObject();
258
259 void fromImage(const vpImage<unsigned char> &image, unsigned char threshold,
260 const vpCameraParameters &cam); // Binary version
261 void fromImage(const vpImage<unsigned char> &image, const vpCameraParameters &cam, vpCameraImgBckGrndType bg_type,
262 bool normalize_with_pix_size = true); // Photometric version
263
264 void fromVector(std::vector<vpPoint> &points);
265 const std::vector<double> &get() const;
266 double get(unsigned int i, unsigned int j) const;
267
271 vpObjectType getType() const { return type; }
272
277 unsigned int getOrder() const { return order - 1; }
278
279 // Constructor helpers
280 void init(unsigned int orderinp);
281 void init(const vpMomentObject &objin);
282
283 friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentObject &v);
289 static void printWithIndices(const vpMomentObject &momobj, std::ostream &os);
294 void setType(vpObjectType input_type) { this->type = input_type; }
295
300 static vpMatrix convertTovpMatrix(const vpMomentObject &momobj);
301
302protected:
303 unsigned int order;
305 std::vector<double> values;
306 void set(unsigned int i, unsigned int j, const double &value_ij);
307 void cacheValues(std::vector<double> &cache, double x, double y);
308
309private:
310 void cacheValues(std::vector<double> &cache, double x, double y, double IntensityNormalized);
311 double calc_mom_polygon(unsigned int p, unsigned int q, const std::vector<vpPoint> &points);
312};
313
314#endif
Generic class defining intrinsic camera parameters.
Definition of the vpImage class member functions.
Definition vpImage.h:135
Implementation of a matrix and operations on matrices.
Definition vpMatrix.h:152
Class for generic objects.
unsigned int getOrder() const
unsigned int order
vpObjectType type
void setType(vpObjectType input_type)
std::vector< double > values
vpObjectType getType() const