SaliencyCMapMT.H
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
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef SALIENCYMT_H_DEFINED
00039 #define SALIENCYMT_H_DEFINED
00040
00041 #include "Image/OpenCVUtil.H"
00042 #include "Component/ModelComponent.H"
00043 #include "Component/ModelParam.H"
00044 #include "Image/ColorOps.H"
00045 #include "Image/Image.H"
00046 #include "Image/ImageSet.H"
00047 #include "Image/MathOps.H"
00048 #include "Image/DrawOps.H"
00049 #include "Image/FilterOps.H"
00050 #include "Image/Pixels.H"
00051 #include "Image/PyramidOps.H"
00052 #include "Image/ShapeOps.H"
00053 #include "Image/Transforms.H"
00054 #include "Image/fancynorm.H"
00055 #include "Util/Types.H"
00056 #include "Image/colorDefs.H"
00057 #include "Corba/Objects/CMapSK.hh"
00058 #include "Corba/ImageOrbUtil.H"
00059
00060 #include <pthread.h>
00061 #include <cstdlib>
00062 #include <unistd.h>
00063 #include <list>
00064
00065
00066
00067 #ifndef LocalCMapServer
00068
00069 #endif
00070
00071
00072 struct jobData
00073 {
00074 jobData() { };
00075
00076 jobData(const int jt, const PyramidType pt, const float w,
00077 const float ori = 0.0F) :
00078 jobType(jt), ptyp(pt), weight(w), orientation(ori) { }
00079
00080 int jobType;
00081 PyramidType ptyp;
00082 float weight;
00083 float orientation;
00084 };
00085
00086 struct biasData
00087 {
00088 CMap::BiasSeq redgreen;
00089 CMap::BiasSeq blueyellow;
00090 CMap::BiasSeq skinhue;
00091 CMap::BiasSeq ori0;
00092 CMap::BiasSeq ori45;
00093 CMap::BiasSeq ori90;
00094 CMap::BiasSeq ori135;
00095 CMap::BiasSeq intensity;
00096 CMap::BiasSeq flicker;
00097 };
00098
00099
00100
00101 class SaliencyMT : public ModelComponent
00102 {
00103 public:
00104
00105
00106 #define RETINA 1
00107 #define WINNER 2
00108 #define LUMINANCE 3
00109 #define REDGREEN 4
00110 #define BLUEYELLOW 5
00111 #define ORI0 6
00112 #define ORI45 7
00113 #define ORI90 8
00114 #define ORI135 9
00115 #define CMAP 10
00116 #define FLICKER 11
00117 #define INTENSITY 12
00118 #define SKINHUE 13
00119
00120
00121
00122
00123
00124
00125 SaliencyMT(OptionManager& mgr, CORBA::ORB_ptr orb, short saliencyMapLevel,
00126 const std::string& descrName = "SaliencyMT",
00127 const std::string& tagName = "SaliencyMT");
00128
00129
00130 ~SaliencyMT();
00131
00132
00133
00134
00135
00136
00137
00138
00139 void newInput(const Image< PixRGB<byte> > img);
00140
00141
00142 bool outputReady();
00143
00144
00145 Image<float> getOutput();
00146
00147
00148 Image<float> getSMap(Image< PixRGB<byte> > img);
00149
00150
00151 void computeCMAP();
00152
00153
00154
00155 void setBias(int type, std::vector<float> &bias);
00156
00157
00158 void setBiasSM(bool val);
00159
00160
00161 void getBias(Image<PixRGB<byte> > &img, std::vector<float> &bias, int type, Point2D<int> &loc);
00162
00163
00164 int nCmapObj;
00165
00166 CORBA::Object_ptr CMap_ref[100];
00167
00168
00169 void setSaliencyMapLevel(const short saliencyMapLevel);
00170
00171 Image<float> cmaps[14];
00172
00173 void setSMBias(ImageSet<float> &bias);
00174
00175 protected:
00176 OModelParam<uint> itsNumThreads;
00177
00178 void start1();
00179 void stop2();
00180
00181
00182 CMap_ptr getCmapRef();
00183
00184 private:
00185 Image< PixRGB<byte> > colima;
00186 Image<float> lum;
00187 Image<byte> r, g, b, y;
00188 Image<float> prev;
00189 Image<float> outmap;
00190 Image<float> skinima;
00191 bool gotLum, gotRGBY, gotSkin;
00192
00193 std::list<jobData> jobQueue;
00194 uint jobsTodo;
00195
00196
00197 pthread_t *worker;
00198 pthread_mutex_t jobLock, mapLock, jobStatusLock;
00199 pthread_cond_t jobCond;
00200 pthread_cond_t jobDone;
00201 uint numWorkers;
00202
00203
00204 biasData cmapBias;
00205 bool biasSM;
00206 ImageSet<float> SMBias;
00207
00208 };
00209
00210 #endif
00211
00212
00213
00214
00215
00216