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 #endif
00061 extern const ModelOptionDef OPT_EvcNumOrientations;
00062 extern const ModelOptionDef OPT_EvcLevelSpec;
00063 extern const ModelOptionDef OPT_EvcType;
00064 extern const ModelOptionDef OPT_EvcColorSmoothing;
00065 extern const ModelOptionDef OPT_EvcOutputFactor;
00066
00067 class EnvVisualCortex : public ModelComponent
00068 {
00069 public:
00070 EnvVisualCortex(OptionManager& mgr,
00071 const std::string& descrName = "EnvVisualCortex",
00072 const std::string& tagName = "EnvVisualCortex");
00073
00074 virtual ~EnvVisualCortex();
00075
00076 env_size_t getMapLevel() const { return this->envp.output_map_level; }
00077
00078 void input(const Image<PixRGB<byte> >& rgbin);
00079
00080 Image<byte> getVCXmap() const { return itsVCXmap; }
00081
00082 Image<float> getVCXmapFloat() const {
00083
00084
00085 return itsVCXmap * itsOutputFactor.getVal();
00086 }
00087
00088 Image<byte> getImap() const { return itsImap; }
00089 Image<byte> getCmap() const { return itsCmap; }
00090 Image<byte> getOmap() const { return itsOmap; }
00091 byte getIweight() { return envp.chan_i_weight; }
00092 byte getCweight() { return envp.chan_c_weight; }
00093 byte getOweight() { return envp.chan_o_weight; }
00094 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00095 Image<byte> getFmap() const { return itsFmap; }
00096 Image<byte> getMmap() const { return itsMmap; }
00097 byte getFweight() { return envp.chan_f_weight; }
00098 byte getMweight() { return envp.chan_m_weight; }
00099 #endif
00100
00101 const struct env_params& getParams() const { return envp; }
00102
00103 bool getColorSmoothing() const { return itsColorSmoothing.getVal(); }
00104
00105 void setIweight(byte val) { envp.chan_i_weight = val; }
00106 void setCweight(byte val) { envp.chan_c_weight = val; }
00107 void setOweight(byte val) { envp.chan_o_weight = val; }
00108
00109 void setNumOrientations(byte val) { envp.num_orientations = val; }
00110
00111 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00112 void setFweight(byte val) { envp.chan_f_weight = val; }
00113 void setMweight(byte val) { envp.chan_m_weight = val; }
00114
00115 void setFthresh(byte val) { envp.flicker_thresh = val; }
00116 void setMthresh(byte val) { envp.motion_thresh = val; }
00117
00118 void setMultiScaleFlicker(bool val) { envp.multiscale_flicker = val ? 1 : 0; }
00119
00120 void setNumDirections(byte val) { envp.num_motion_directions = val; }
00121 #endif
00122
00123 void setColorSmoothing(bool val) { itsColorSmoothing.setVal(val); }
00124
00125 #ifdef ENV_WITH_VISIT_CHANNEL
00126 void setSubmapPreProc(int (*submapPreProc)(const char* tagName,
00127 env_size_t clev, env_size_t slev, struct env_image *submap,
00128 const struct env_image *center, const struct env_image *surround))
00129 { envp.submapPreProc = submapPreProc; }
00130
00131 void setSubmapPostNormProc(int (*submapPostNormProc)(const char* tagName,
00132 env_size_t clev, env_size_t slev, struct env_image *submap,
00133 const struct env_image *center, const struct env_image *surround))
00134 { envp.submapPostNormProc = submapPostNormProc; }
00135 void setSubmapPostProc(int (*submapPostProc)(const char* tagName,
00136 struct env_image *cmap))
00137 { envp.submapPostProc = submapPostProc; }
00138 #endif
00139
00140 private:
00141 virtual void paramChanged(ModelParamBase* const param,
00142 const bool valueChanged,
00143 ParamClient::ChangeStatus* status);
00144
00145 virtual void start1();
00146
00147 virtual void stop2();
00148
00149
00150 NModelParam<byte> itsIweight;
00151 NModelParam<byte> itsCweight;
00152 NModelParam<byte> itsOweight;
00153 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00154 NModelParam<byte> itsFweight;
00155 NModelParam<byte> itsMweight;
00156 #endif
00157
00158 OModelParam<bool> itsMultithreaded;
00159 OModelParam<std::string> itsMaxnormType;
00160 OModelParam<byte> itsScaleBits;
00161 OModelParam<byte> itsNumOrientations;
00162 OModelParam<bool> itsColorSmoothing;
00163 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00164 OModelParam<byte> itsNumDirections;
00165 OModelParam<byte> itsMotionThresh;
00166 OModelParam<byte> itsFlickerThresh;
00167 OModelParam<int> itsRangeThresh;
00168 OModelParam<bool> itsMultiScaleFlicker;
00169 #endif
00170 OModelParam<LevelSpec> itsLevelSpec;
00171
00172 OModelParam<std::string> itsType;
00173 OModelParam<float> itsOutputFactor;
00174
00175 struct env_params envp;
00176 struct env_visual_cortex ivc;
00177
00178 env_size_t npixels;
00179
00180 int framenum;
00181
00182 intg32 chanmi, chanma;
00183 intg32 vcxmi, vcxma;
00184
00185 Image<byte> itsVCXmap;
00186
00187 Image<byte> itsImap;
00188 Image<byte> itsCmap;
00189 Image<byte> itsOmap;
00190 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00191 Image<byte> itsFmap;
00192 Image<byte> itsMmap;
00193 #endif
00194
00195 Image<PixRGB<byte> > itsPrevRgb;
00196
00197 rutz::shared_ptr<WorkThreadServer> itsThreadServer;
00198 };
00199
00200
00201
00202
00203
00204
00205
00206
00207 #endif // NEURO_ENVVISUALCORTEX_H_DEFINED