Visual Servoing Platform  version 3.0.0
vpFeatureMomentDatabase.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2015 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  * Pseudo-database used to handle dependencies between moment features.
32  *
33  * Authors:
34  * Filip Novotny
35  *
36  *****************************************************************************/
37 
38 #include <visp3/visual_features/vpFeatureMomentDatabase.h>
39 #include <visp3/visual_features/vpFeatureMoment.h>
40 #include <typeinfo>
41 #include <iostream>
42 #include <visp3/core/vpConfig.h>
43 
49 void vpFeatureMomentDatabase::add(vpFeatureMoment& featureMoment,char* name){
50  featureMomentsDataBase.insert(std::pair<const char*,vpFeatureMoment*>((const char*)name,&featureMoment));
51 }
52 
60 vpFeatureMoment& vpFeatureMomentDatabase::get(const char* type, bool& found){
61  std::map<const char*,vpFeatureMoment*,vpFeatureMomentDatabase::cmp_str>::const_iterator it = featureMomentsDataBase.find(type);
62 
63  found = (it!=featureMomentsDataBase.end());
64  return *(it->second);
65 }
66 
73 void vpFeatureMomentDatabase::updateAll(double A, double B, double C)
74 {
75  std::map<const char*,vpFeatureMoment*,vpFeatureMomentDatabase::cmp_str>::const_iterator itr;
76 #ifdef VISP_HAVE_OPENMP
77  std::vector<vpFeatureMoment*> values;
78  values.reserve(featureMomentsDataBase.size());
79  for(itr = featureMomentsDataBase.begin(); itr != featureMomentsDataBase.end(); itr++){
80  values.push_back((*itr).second);
81  }
82  unsigned int i_;
83  #pragma omp parallel for shared(A,B,C)
84  for(int i=0;i<(int)values.size();i++){
85  i_ = static_cast<unsigned int>(i);
86  values[i_]->update(A,B,C);
87  }
88 #else
89  for(itr = featureMomentsDataBase.begin(); itr != featureMomentsDataBase.end(); itr++){
90  (*itr).second->update(A,B,C);
91  }
92 #endif
93 }
94 
95 /*
96 std::ostream & operator<<(std::ostream & os, const vpFeatureMomentDatabase& m){
97  std::map<const char*,vpMoment*,vpFeatureMomentDatabase::cmp_str>::const_iterator itr;
98  os << "{";
99 
100  for(itr = m.featureMoments.begin(); itr != m.featureMoments.end(); itr++){
101  os << (*itr).first << ": [" << *((*itr).second) << "],";
102  }
103  os << "}";
104 
105  return os;
106 }*/
This class defines shared system methods/attributes for 2D moment features but no functional code...
virtual void updateAll(double A=0.0, double B=0.0, double C=1.0)
vpFeatureMoment & get(const char *type, bool &found)