ImagePropertiesCV.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *  ImagePropertiesCV.h
00003  *
00004  *  (C) 2007 AG Aktives Sehen <agas@uni-koblenz.de>
00005  *           Universitaet Koblenz-Landau
00006  *
00007  *  Additional information:
00008  *  $Id: $
00009  *******************************************************************************/
00010 
00011 #ifndef ImagePropertiesCV_H
00012 #define ImagePropertiesCV_H
00013 
00014 #include <vector>
00015 #include <opencv2/highgui/highgui.hpp>
00016 #include <ros/ros.h>
00017 
00018 #include "../KeyPointExtraction/KeyPoint.h"
00019 //#include "Workers/ImageHelpers/ImageMaskCV.h"
00020 #include "../KeyPointExtraction/ImageMaskCV.h"
00021 
00022 #include "Workers/Math/Point2D.h"
00023 
00024 // include headers that implement an archive in binary format
00025 #include <boost/archive/binary_iarchive.hpp>
00026 #include <boost/archive/binary_oarchive.hpp>
00027 #include <boost/archive/text_iarchive.hpp>
00028 #include <boost/archive/text_oarchive.hpp>
00029 
00030 #include "Architecture/Serializer/cvmat_serialization.h"
00031 
00037 class ImagePropertiesCV
00038 {
00039 public:
00040 
00041     ImagePropertiesCV();
00042 
00044     ImagePropertiesCV ( std::string name, cv::Mat* imageY, cv::Mat* imageUV, ImageMaskCV* imageMask=0 );
00045 
00046     ImagePropertiesCV ( const ImagePropertiesCV& other );
00047 
00049     ~ImagePropertiesCV();
00050 
00051     ImagePropertiesCV& operator= ( const ImagePropertiesCV& other );
00052 
00054     void applyMask();
00055     void traceOutline();
00056     void extractKeyPoints();
00057 
00059     void calculateProperties();
00060 
00061     // GETTER FUNCTIONS
00062 
00063     std::string getName() const { return m_Name; }
00064 
00065     cv::Mat* getImageY() const { return m_ImageY; }
00066 
00067     cv::Mat* getImageUV() const { return m_ImageUV; }
00068 
00069     cv::Mat* getMaskedImageY() const { return m_MaskedImageY; }
00070 
00071     cv::Mat* getMaskedImageUV() const { return m_MaskedImageUV; }
00072 
00073     ImageMaskCV* getImageMask() const { return m_ImageMask; }
00074 
00075     std::vector< KeyPoint >* getKeyPoints() const { return m_KeyPoints; }
00076 
00077     std::vector<Point2D>* getOutline() const { return m_Outline; }
00078 
00079     std::vector<Point2D> getBoundingBox() const;
00080 
00081     Point2D getCenter() const { return m_Center; }
00082 
00083     // SERIALIZATION
00084 
00085     template<class Archive>
00086     void save(Archive & ar, const unsigned int version) const
00087     {
00088         unsigned x = 12;
00089         ar & x;
00090         ar & m_Name;
00091 
00092         ar & m_ImageY;
00093         ar & m_ImageUV;
00094 
00095         if ( m_ImageMask )
00096         {
00097             bool b = true;
00098             ar & b;
00099             int width = m_ImageMask->getWidth();
00100             ar & width;
00101             int height = m_ImageMask->getHeight();
00102             ar & height;
00103 
00104             ar & boost::serialization::make_array(m_ImageMask->getData(), m_ImageMask->getWidth()*m_ImageMask->getHeight());
00105         }
00106         else
00107         {
00108             bool b = false;
00109             ar & b;
00110         }
00111     }
00112 
00113     template<class Archive>
00114     void load(Archive & ar, const unsigned int version_b)
00115     {
00116         clear();
00117 
00118         unsigned version;
00119         ar & version;
00120 
00121         if ( version != 12 )
00122         {
00123           throw "File has wrong version number.";
00124         }
00125 
00126         ar & m_Name;
00127 
00128         m_ImageY = new cv::Mat();
00129         m_ImageUV = new cv::Mat();
00130 
00131         ar & m_ImageY;
00132         ar & m_ImageUV;
00133 
00134         bool hasMask;
00135         ar & hasMask;
00136 
00137         if ( hasMask )
00138         {
00139           int width;
00140           int height;
00141           ar & width;
00142           ar & height;
00143 
00144           // TODO check this for correct behavior
00145           m_ImageMask = new ImageMaskCV( width, height);
00146           ar & boost::serialization::make_array(m_ImageMask->getData(), width*height);
00147         }
00148         else
00149         {
00150           m_ImageMask = NULL;
00151         }
00152 
00153         calculateProperties();
00154     }
00155 
00156     BOOST_SERIALIZATION_SPLIT_MEMBER()
00157 
00158     private:
00159 
00160         void clear();
00161     void deleteAll();
00162 
00164     std::string m_Name;
00165     cv::Mat* m_ImageY;
00166     cv::Mat* m_ImageUV;
00167     ImageMaskCV* m_ImageMask;
00168     ImageMaskCV* m_ImageMaskWithBorder;
00169 
00171     cv::Mat* m_MaskedImageY;
00172     cv::Mat* m_MaskedImageUV;
00173     std::vector< KeyPoint >* m_KeyPoints;
00174     std::vector<Point2D>* m_Outline;
00175     Point2D m_Center;
00176 
00177     int m_Border;
00178 };
00179 
00180 BOOST_CLASS_VERSION(ImagePropertiesCV, 12)
00181 
00182 #endif


or_libs
Author(s): raphael
autogenerated on Mon Oct 6 2014 02:53:18