Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "ObjectProperties.h"
00016
00017
00018
00019
00020
00021 #define THIS ObjectProperties
00022
00023 using namespace puma2;
00024
00025
00026
00027 THIS::THIS( std::string name )
00028 {
00029 m_Name=name;
00030 m_Type="";
00031 m_MeanHistogram=0;
00032 }
00033
00034
00035 THIS::~THIS()
00036 {
00037 if (m_MeanHistogram) {
00038 delete m_MeanHistogram;
00039 }
00040 for ( unsigned i=0; i < m_ImageProperties.size(); i++)
00041 {
00042 if ( m_ImageProperties[i] ) { delete m_ImageProperties[i]; }
00043 }
00044 }
00045
00046
00047 THIS::THIS(const ObjectProperties& other)
00048 {
00049 m_MeanHistogram=0;
00050 *this = other;
00051 }
00052
00053
00054 THIS& THIS::operator=(const ObjectProperties& other)
00055 {
00056
00057 if (m_MeanHistogram) {
00058 delete m_MeanHistogram;
00059 }
00060 for ( unsigned i=0; i < m_ImageProperties.size(); i++)
00061 {
00062 if ( m_ImageProperties[i] ) { delete m_ImageProperties[i]; }
00063 }
00064 m_ImageProperties.clear();
00065
00066
00067 m_Name = other.m_Name;
00068 m_Type = other.m_Type;
00069 m_MeanHistogram = new HistogramUV( *(other.m_MeanHistogram) );
00070
00071 for ( unsigned i=0; i < other.m_ImageProperties.size(); i++)
00072 {
00073 m_ImageProperties.push_back( new ImageProperties( *(other.m_ImageProperties[i]) ) );
00074 }
00075
00076 return *this;
00077 }
00078
00079 void THIS::addImageProperties( ImageProperties* imageProperties )
00080 {
00081 m_ImageProperties.push_back( imageProperties );
00082 if (!m_MeanHistogram) {
00083 m_MeanHistogram=new HistogramUV( imageProperties->getHistogram()->getBinSize() );
00084 }
00085 m_MeanHistogram->add( *(imageProperties->getHistogram()) );
00086 }
00087
00088 void THIS::deleteImageProperties( std::string name )
00089 {
00090 std::vector<ImageProperties*> newImageProperties;
00091
00092 for ( unsigned i=0; i<m_ImageProperties.size(); i++ )
00093 {
00094 if ( m_ImageProperties[i]->getName() == name )
00095 {
00096 delete m_ImageProperties[i];
00097 }
00098 else
00099 {
00100 newImageProperties.push_back( m_ImageProperties[i] );
00101 }
00102 }
00103
00104 m_ImageProperties = newImageProperties;
00105 }
00106
00107 void THIS::deleteImageProperties( int index )
00108 {
00109 std::vector<ImageProperties*> newImageProperties;
00110
00111 for ( unsigned i=0; i<m_ImageProperties.size(); i++ )
00112 {
00113 if ( i == index )
00114 {
00115 delete m_ImageProperties[i];
00116 }
00117 else
00118 {
00119 newImageProperties.push_back( m_ImageProperties[i] );
00120 }
00121 }
00122
00123 m_ImageProperties = newImageProperties;
00124 }
00125
00126 const ImageProperties* THIS::getImageProperties( std::string name ) const
00127 {
00128 for ( unsigned i=0; i<m_ImageProperties.size(); i++ )
00129 {
00130 if ( m_ImageProperties[i]->getName() == name )
00131 {
00132 return m_ImageProperties[i];
00133 }
00134 }
00135 return 0;
00136 }
00137
00138 std::vector<std::string> THIS::getImageNames()
00139 {
00140 std::vector<std::string> result;
00141 result.reserve( m_ImageProperties.size() );
00142
00143 for ( unsigned i=0; i<m_ImageProperties.size(); i++ )
00144 {
00145 result.push_back( m_ImageProperties[i]->getName() );
00146
00147 }
00148
00149
00150 return result;
00151 }
00152
00153
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197 void THIS::printOn( std::ostream& strm )
00198 {
00199 unsigned size=m_ImageProperties.size();
00200
00201 strm << "Object name: " << m_Name << std::endl;
00202 strm << "Object type: " << m_Type << std::endl;
00203 strm << "# of images: " << size << std::endl << std::endl;
00204
00205 strm << "Number keypoints in images:";
00206 for ( unsigned i=0; i < size; i++)
00207 {
00208 strm << " " << m_ImageProperties[i]->getKeyPoints()->size();
00209 }
00210
00211 strm << std::endl << std::endl;
00212
00213 strm << "Histogram:" << std::endl;
00214 m_MeanHistogram->printOn( strm );
00215 strm << std::endl << std::endl;
00216 }
00217
00218 #undef THIS