Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 #ifndef _map_location_alg_h_
00026 #define _map_location_alg_h_
00027 
00028 #include <iri_map_location/MapLocationConfig.h>
00029 #include "mutex.h"
00030 
00031 #include <opencv/cvwimage.h>
00032 #include <opencv/highgui.h>
00033 
00034 
00035 
00036 
00037 
00038 
00039 static const char WINDOW[] = "Image window";
00040 
00046 class MapLocationAlgorithm
00047 {
00048   protected:
00055     CMutex alg_mutex_;
00056 
00057     
00058     std::string mapPath;
00059     std::string logoPath;
00060     std::string logo2Path;
00061     cv::Mat mapImage;
00062     cv::Mat logoImage;
00063     cv::Mat logo2Image;
00064     
00065     int t;
00066 
00067     
00068     std::vector< CvScalar         > colorList;
00069     std::vector< std::string      > textList;    
00070     std::vector< CvScalar         > currentColor;
00071     std::vector< std::string      > currentText;
00072     std::vector< std::vector<int> > locations;    
00073 
00074     void initialize();
00075     cv::Mat loadImage(std::string const imagePath, int mode);
00076     void loadCaption();
00077     void loadLocations();
00078 
00079     void initText(cv::Size * textSize, CvFont * font, int const fontFace, double const fontScale, float const fontShare, int const fontThickness, int const fontLineType, std::vector<std::string> const text);
00080     void drawCircle(int x, int y, int r,  CvScalar color);    
00081     void showImage();
00082 
00083   public:
00090     typedef iri_map_location::MapLocationConfig Config;
00091 
00098     Config config_;
00099 
00108     MapLocationAlgorithm(void);
00109 
00115     void lock(void) { alg_mutex_.enter(); };
00116 
00122     void unlock(void) { alg_mutex_.exit(); };
00123 
00131     bool try_enter(void) { return alg_mutex_.try_enter(); };
00132 
00144     void config_update(Config& new_cfg, uint32_t level=0);
00145 
00146     
00147     
00148     cv::Mat image;
00149     cv::Mat getImage();
00150     void loadFiles();
00151     void mapIteration();
00152     void logoIteration();
00153     void addLocation(float xpos, float ypos, int colorindex);
00154     void addLocationWithCode(int code);
00155     
00156     std::string path;
00157 
00164     ~MapLocationAlgorithm(void);
00165 };
00166 
00167 #endif