ViSP  2.9.0
vpFeatureMomentDatabase.cpp
1 /****************************************************************************
2  *
3  * $Id: vpFeatureMomentDatabase.cpp 4574 2014-01-09 08:48:51Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Pseudo-database used to handle dependencies between moment features.
36  *
37  * Authors:
38  * Filip Novotny
39  *
40  *****************************************************************************/
41 
42 #include <visp/vpFeatureMomentDatabase.h>
43 #include <visp/vpFeatureMoment.h>
44 #include <typeinfo>
45 #include <iostream>
46 #include <visp/vpConfig.h>
47 
53 void vpFeatureMomentDatabase::add(vpFeatureMoment& featureMoment,char* name){
54  featureMomentsDataBase.insert(std::pair<const char*,vpFeatureMoment*>((const char*)name,&featureMoment));
55 }
56 
64 vpFeatureMoment& vpFeatureMomentDatabase::get(const char* type, bool& found){
65  std::map<const char*,vpFeatureMoment*,vpFeatureMomentDatabase::cmp_str>::const_iterator it = featureMomentsDataBase.find(type);
66 
67  found = (it!=featureMomentsDataBase.end());
68  return *(it->second);
69 }
70 
77 void vpFeatureMomentDatabase::updateAll(double A, double B, double C)
78 {
79  std::map<const char*,vpFeatureMoment*,vpFeatureMomentDatabase::cmp_str>::const_iterator itr;
80 #ifdef VISP_HAVE_OPENMP
81  std::vector<vpFeatureMoment*> values;
82  values.reserve(featureMomentsDataBase.size());
83  for(itr = featureMomentsDataBase.begin(); itr != featureMomentsDataBase.end(); itr++){
84  values.push_back((*itr).second);
85  }
86  unsigned int i_;
87  #pragma omp parallel for shared(A,B,C)
88  for(int i=0;i<(int)values.size();i++){
89  i_ = static_cast<unsigned int>(i);
90  values[i_]->update(A,B,C);
91  }
92 #else
93  for(itr = featureMomentsDataBase.begin(); itr != featureMomentsDataBase.end(); itr++){
94  (*itr).second->update(A,B,C);
95  }
96 #endif
97 }
98 
99 /*
100 std::ostream & operator<<(std::ostream & os, const vpFeatureMomentDatabase& m){
101  std::map<const char*,vpMoment*,vpFeatureMomentDatabase::cmp_str>::const_iterator itr;
102  os << "{";
103 
104  for(itr = m.featureMoments.begin(); itr != m.featureMoments.end(); itr++){
105  os << (*itr).first << ": [" << *((*itr).second) << "],";
106  }
107  os << "}";
108 
109  return os;
110 }*/
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)