Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpMomentObject.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 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 */
33
38#ifndef VP_MOMENT_OBJECT_H
39#define VP_MOMENT_OBJECT_H
40
41#include <cstdlib>
42#include <utility>
43#include <visp3/core/vpConfig.h>
44#include <visp3/core/vpImage.h>
45#include <visp3/core/vpMath.h>
46#include <visp3/core/vpMoment.h>
47#include <visp3/core/vpPoint.h>
48
51
224class VISP_EXPORT vpMomentObject
225{
226public:
230 typedef enum
231 {
238 } vpObjectType;
239
243 typedef enum
244 {
245 BLACK = 0,
246 WHITE = 1,
247 } vpCameraImgBckGrndType;
248
249 bool flg_normalize_intensity; // To scale the intensity of each individual
250 // pixel in the image by the maximum intensity
251 // value present in it
252
253 // Constructors
254 VP_EXPLICIT vpMomentObject(unsigned int order);
255 vpMomentObject(const vpMomentObject &srcobj);
264 virtual ~vpMomentObject();
265
266#if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98)
268#endif
269
270 void fromImage(const vpImage<unsigned char> &image, unsigned char threshold,
271 const vpCameraParameters &cam); // Binary version
272 void fromImage(const vpImage<unsigned char> &image, const vpCameraParameters &cam, vpCameraImgBckGrndType bg_type,
273 bool normalize_with_pix_size = true); // Photometric version
274
275 void fromVector(std::vector<vpPoint> &points);
276 const std::vector<double> &get() const;
277 double get(unsigned int i, unsigned int j) const;
278
282 vpObjectType getType() const { return type; }
283
288 unsigned int getOrder() const { return order - 1; }
289
290 // Constructor helpers
291 void init(unsigned int orderinp);
292 void init(const vpMomentObject &objin);
293
294 friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentObject &v);
300 static void printWithIndices(const vpMomentObject &momobj, std::ostream &os);
305 void setType(vpObjectType input_type) { this->type = input_type; }
306
311 static vpMatrix convertTovpMatrix(const vpMomentObject &momobj);
312
313protected:
314 unsigned int order;
316 std::vector<double> values;
317 void set(unsigned int i, unsigned int j, const double &value_ij);
318 void cacheValues(std::vector<double> &cache, double x, double y);
319
320private:
321 void cacheValues(std::vector<double> &cache, double x, double y, double IntensityNormalized);
322 double calc_mom_polygon(unsigned int p, unsigned int q, const std::vector<vpPoint> &points);
323};
324END_VISP_NAMESPACE
325
326#endif
Generic class defining intrinsic camera parameters.
Definition of the vpImage class member functions.
Definition vpImage.h:131
Implementation of a matrix and operations on matrices.
Definition vpMatrix.h:175
Class for generic objects.
unsigned int getOrder() const
VP_EXPLICIT vpMomentObject(unsigned int order)
unsigned int order
void cacheValues(std::vector< double > &cache, double x, double y)
vpObjectType type
void setType(vpObjectType input_type)
void set(unsigned int i, unsigned int j, const double &value_ij)
vpMomentObject & operator=(const vpMomentObject &)=default
@ BLACK
Black background.
@ WHITE
Not functional right now.
const std::vector< double > & get() const
std::vector< double > values
vpObjectType getType() const
void fromImage(const vpImage< unsigned char > &image, unsigned char threshold, const vpCameraParameters &cam)
void fromVector(std::vector< vpPoint > &points)