EnvVisualCortex.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 NEURO_ENVVISUALCORTEX_H_DEFINED
00039 #define NEURO_ENVVISUALCORTEX_H_DEFINED
00040
00041 #include "Component/ModelComponent.H"
00042 #include "Component/ModelParam.H"
00043 #include "Envision/env_params.h"
00044 #include "Envision/env_types.h"
00045 #include "Envision/env_visual_cortex.h"
00046 #include "Image/Image.H"
00047 #include "Image/LevelSpec.H"
00048 #include "Image/Pixels.H"
00049 #include "rutz/shared_ptr.h"
00050
00051 class WorkThreadServer;
00052
00053 extern const ModelOptionDef OPT_EvcMaxnormType;
00054 extern const ModelOptionDef OPT_EvcScaleBits;
00055 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00056 extern const ModelOptionDef OPT_EvcNumDirections;
00057 extern const ModelOptionDef OPT_EvcMotionThresh;
00058 extern const ModelOptionDef OPT_EvcFlickerThresh;
00059 extern const ModelOptionDef OPT_EvcMultiScaleFlicker;
00060 extern const ModelOptionDef OPT_EvcShowMemStats;
00061 #endif
00062 extern const ModelOptionDef OPT_EvcNumOrientations;
00063 extern const ModelOptionDef OPT_EvcType;
00064 extern const ModelOptionDef OPT_EvcColorSmoothing;
00065 extern const ModelOptionDef OPT_EvcOutputFactor;
00066
00067
00068
00069 class EnvVisualCortexBase : public ModelComponent
00070 {
00071 public:
00072
00073 EnvVisualCortexBase(OptionManager& mgr, const std::string& descrName = "EnvVisualCortexBase",
00074 const std::string& tagName = "EnvVisualCortexBase");
00075
00076
00077 virtual ~EnvVisualCortexBase();
00078
00079
00080 inline env_size_t getMapLevel() const;
00081
00082
00083
00084
00085
00086 virtual void input(const Image<PixRGB<byte> >& rgbin) = 0;
00087
00088 inline byte getIweight();
00089 inline byte getCweight();
00090 inline byte getOweight();
00091 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00092 inline byte getFweight();
00093 inline byte getMweight();
00094 #endif
00095
00096
00097 inline const struct env_params& getParams() const;
00098
00099 inline bool getColorSmoothing() const;
00100 inline void setColorSmoothing(bool val);
00101
00102 inline void setIweight(byte val);
00103 inline void setCweight(byte val);
00104 inline void setOweight(byte val);
00105 inline void setNumOrientations(byte val);
00106
00107 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00108 inline void setFweight(byte val);
00109 inline void setMweight(byte val);
00110 inline void setFthresh(byte val);
00111 inline void setMthresh(byte val);
00112 inline void setMultiScaleFlicker(bool val);
00113 inline void setNumDirections(byte val);
00114 #endif
00115
00116 #ifdef ENV_WITH_VISIT_CHANNEL
00117 inline void setSubmapPreProc(int (*submapPreProc)(const char* tagName,
00118 env_size_t clev, env_size_t slev, struct env_image *submap,
00119 const struct env_image *center, const struct env_image *surround));
00120
00121
00122 inline void setSubmapPostNormProc(int (*submapPostNormProc)(const char* tagName,
00123 env_size_t clev, env_size_t slev, struct env_image *submap,
00124 const struct env_image *center, const struct env_image *surround));
00125
00126 inline void setSubmapPostProc(int (*submapPostProc)(const char* tagName,
00127 struct env_image *cmap));
00128 #endif
00129
00130 protected:
00131 virtual void paramChanged(ModelParamBase* const param, const bool valueChanged,
00132 ParamClient::ChangeStatus* status);
00133 virtual void start1();
00134 virtual void stop2();
00135
00136
00137 NModelParam<byte> itsIweight;
00138 NModelParam<byte> itsCweight;
00139 NModelParam<byte> itsOweight;
00140 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00141 NModelParam<byte> itsFweight;
00142 NModelParam<byte> itsMweight;
00143 #endif
00144 OModelParam<bool> itsMultithreaded;
00145 OModelParam<std::string> itsMaxnormType;
00146 OModelParam<byte> itsScaleBits;
00147 OModelParam<byte> itsNumOrientations;
00148 OModelParam<bool> itsColorSmoothing;
00149 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00150 OModelParam<byte> itsNumDirections;
00151 OModelParam<byte> itsMotionThresh;
00152 OModelParam<byte> itsFlickerThresh;
00153 OModelParam<int> itsRangeThresh;
00154 OModelParam<bool> itsMultiScaleFlicker;
00155 OModelParam<bool> itsShowMemStats;
00156 #endif
00157 OModelParam<LevelSpec> itsLevelSpec;
00158 OModelParam<std::string> itsType;
00159
00160 struct env_params envp;
00161 struct env_visual_cortex ivc;
00162 env_size_t npixels;
00163 int framenum;
00164 Image<PixRGB<byte> > itsPrevRgb;
00165 rutz::shared_ptr<WorkThreadServer> itsThreadServer;
00166 };
00167
00168
00169
00170 class EnvVisualCortex : public EnvVisualCortexBase
00171 {
00172 public:
00173
00174 EnvVisualCortex(OptionManager& mgr, const std::string& descrName = "EnvVisualCortex",
00175 const std::string& tagName = "EnvVisualCortex");
00176
00177
00178 virtual ~EnvVisualCortex();
00179
00180
00181
00182 virtual void input(const Image<PixRGB<byte> >& rgbin);
00183
00184 inline Image<byte> getVCXmap() const;
00185
00186 inline Image<byte> getImap() const;
00187 inline Image<byte> getCmap() const;
00188 inline Image<byte> getOmap() const;
00189 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00190 inline Image<byte> getFmap() const;
00191 inline Image<byte> getMmap() const;
00192 #endif
00193
00194 protected:
00195 Image<byte> itsVCXmap;
00196
00197 Image<byte> itsImap;
00198 Image<byte> itsCmap;
00199 Image<byte> itsOmap;
00200 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00201 Image<byte> itsFmap;
00202 Image<byte> itsMmap;
00203 #endif
00204
00205 private:
00206 intg32 chanmi, chanma;
00207 intg32 vcxmi, vcxma;
00208 };
00209
00210
00211
00212 class EnvVisualCortexFloat : public EnvVisualCortexBase
00213 {
00214 public:
00215
00216 EnvVisualCortexFloat(OptionManager& mgr, const std::string& descrName = "EnvVisualCortexFloat",
00217 const std::string& tagName = "EnvVisualCortexFloat");
00218
00219
00220 virtual ~EnvVisualCortexFloat();
00221
00222
00223
00224 virtual void input(const Image<PixRGB<byte> >& rgbin);
00225
00226 inline Image<float> getVCXmap() const;
00227
00228 inline Image<float> getImap() const;
00229 inline Image<float> getCmap() const;
00230 inline Image<float> getOmap() const;
00231 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00232 inline Image<float> getFmap() const;
00233 inline Image<float> getMmap() const;
00234 #endif
00235
00236 protected:
00237 OModelParam<float> itsOutputFactor;
00238
00239 Image<float> itsVCXmap;
00240 Image<float> itsImap;
00241 Image<float> itsCmap;
00242 Image<float> itsOmap;
00243 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00244 Image<float> itsFmap;
00245 Image<float> itsMmap;
00246 #endif
00247 };
00248
00249
00250
00251
00252
00253 env_size_t EnvVisualCortexBase::getMapLevel() const { return this->envp.output_map_level; }
00254 byte EnvVisualCortexBase::getIweight() { return envp.chan_i_weight; }
00255 byte EnvVisualCortexBase::getCweight() { return envp.chan_c_weight; }
00256 byte EnvVisualCortexBase::getOweight() { return envp.chan_o_weight; }
00257 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00258 byte EnvVisualCortexBase::getFweight() { return envp.chan_f_weight; }
00259 byte EnvVisualCortexBase::getMweight() { return envp.chan_m_weight; }
00260 #endif
00261 const struct env_params& EnvVisualCortexBase::getParams() const { return envp; }
00262 bool EnvVisualCortexBase::getColorSmoothing() const { return itsColorSmoothing.getVal(); }
00263 void EnvVisualCortexBase::setIweight(byte val) { envp.chan_i_weight = val; }
00264 void EnvVisualCortexBase::setCweight(byte val) { envp.chan_c_weight = val; }
00265 void EnvVisualCortexBase::setOweight(byte val) { envp.chan_o_weight = val; }
00266 void EnvVisualCortexBase::setNumOrientations(byte val) { envp.num_orientations = val; }
00267
00268 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00269 void EnvVisualCortexBase::setFweight(byte val) { envp.chan_f_weight = val; }
00270 void EnvVisualCortexBase::setMweight(byte val) { envp.chan_m_weight = val; }
00271 void EnvVisualCortexBase::setFthresh(byte val) { envp.flicker_thresh = val; }
00272 void EnvVisualCortexBase::setMthresh(byte val) { envp.motion_thresh = val; }
00273 void EnvVisualCortexBase::setMultiScaleFlicker(bool val) { envp.multiscale_flicker = val ? 1 : 0; }
00274 void EnvVisualCortexBase::setNumDirections(byte val) { envp.num_motion_directions = val; }
00275 #endif
00276
00277 void EnvVisualCortexBase::setColorSmoothing(bool val) { itsColorSmoothing.setVal(val); }
00278
00279 #ifdef ENV_WITH_VISIT_CHANNEL
00280 void EnvVisualCortexBase::setSubmapPreProc(int (*submapPreProc)(const char* tagName,
00281 env_size_t clev, env_size_t slev, struct env_image *submap,
00282 const struct env_image *center, const struct env_image *surround))
00283 { envp.submapPreProc = submapPreProc; }
00284
00285 void EnvVisualCortexBase::setSubmapPostNormProc(int (*submapPostNormProc)(const char* tagName,
00286 env_size_t clev, env_size_t slev, struct env_image *submap,
00287 const struct env_image *center, const struct env_image *surround))
00288 { envp.submapPostNormProc = submapPostNormProc; }
00289
00290 void EnvVisualCortexBase::setSubmapPostProc(int (*submapPostProc)(const char* tagName,
00291 struct env_image *cmap))
00292 { envp.submapPostProc = submapPostProc; }
00293 #endif
00294
00295
00296
00297
00298
00299 Image<byte> EnvVisualCortex::getVCXmap() const { return itsVCXmap; }
00300 Image<byte> EnvVisualCortex::getImap() const { return itsImap; }
00301 Image<byte> EnvVisualCortex::getCmap() const { return itsCmap; }
00302 Image<byte> EnvVisualCortex::getOmap() const { return itsOmap; }
00303 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00304 Image<byte> EnvVisualCortex::getFmap() const { return itsFmap; }
00305 Image<byte> EnvVisualCortex::getMmap() const { return itsMmap; }
00306 #endif
00307
00308
00309
00310
00311 Image<float> EnvVisualCortexFloat::getVCXmap() const { return itsVCXmap; }
00312 Image<float> EnvVisualCortexFloat::getImap() const { return itsImap; }
00313 Image<float> EnvVisualCortexFloat::getCmap() const { return itsCmap; }
00314 Image<float> EnvVisualCortexFloat::getOmap() const { return itsOmap; }
00315 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00316 Image<float> EnvVisualCortexFloat::getFmap() const { return itsFmap; }
00317 Image<float> EnvVisualCortexFloat::getMmap() const { return itsMmap; }
00318 #endif
00319
00320
00321
00322
00323
00324
00325
00326
00327 #endif // NEURO_ENVVISUALCORTEX_H_DEFINED