ObjectProperties.cpp
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *  ObjectProperties.cpp
00003  *
00004  *  (C) 2008 AG Aktives Sehen <agas@uni-koblenz.de>
00005  *           Universitaet Koblenz-Landau
00006  *
00007  *  Information on Code Review state:
00008  *  Author: <initials>; DevelTest: Date; Reviewer: Initials; Review: Date; State: NOK
00009  *
00010  *  Additional information:
00011  *  $Id: ObjectProperties.cpp 31722 2009-04-23 12:48:01Z sisuthie $
00012  *******************************************************************************/
00013 
00014 
00015 #include "ObjectProperties.h"
00016 
00017 // TODO
00018 //#include "Architecture/Serializer/ExtendedOutStream.h"
00019 //#include "Architecture/Serializer/ExtendedInStream.h"
00020 
00021 #define THIS ObjectProperties
00022 
00023 using namespace puma2;
00024 // using namespace NIHCL_NS; // TODO get rid of this
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     //delete old data
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     //copy new data
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 //     TRACE_INFO( m_ImageProperties[i]->getName() )
00147   }
00148 
00149 
00150   return result;
00151 }
00152 
00153 
00155 
00156 //THIS::THIS( ExtendedInStream& extStrm )
00157 //{
00158 //    unsigned version = 0;
00159 //    extStrm >> version;
00160 
00161 //    if ( version != 12 )
00162 //    {
00163 //      throw "File has wrong version number.";
00164 //    }
00165 
00166 //    m_MeanHistogram = 0;
00167 
00168 //    extStrm >> m_Name;
00169 //    extStrm >> m_Type;
00170 //    unsigned size;
00171 //    extStrm >> size;
00172 //    m_ImageProperties.reserve( size );
00173 //    for ( unsigned i=0; i < size; i++)
00174 //    {
00175 //        ImageProperties* imageProperties=new ImageProperties( extStrm );
00176 //        addImageProperties( imageProperties );
00177 //    }
00178 //}
00179 
00180 
00181 //void THIS::storer( ExtendedOutStream& extStrm )
00182 //{
00183 //    extStrm << unsigned(12);
00184 
00185 //    extStrm << m_Name;
00186 //    extStrm << m_Type;
00187 
00188 //    unsigned size=m_ImageProperties.size();
00189 //    extStrm << size;
00190 //    for ( unsigned i=0; i < size; i++)
00191 //    {
00192 //        m_ImageProperties[i]->storer( extStrm );
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


obj_rec_gui
Author(s): AGAS/agas@uni-koblenz.de
autogenerated on Mon Oct 6 2014 02:53:43