DirectionSpatioTemporalChannel.C
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 DIRECTIONSPATIOTEMPORALCHANNEL_C_DEFINED
00039 #define DIRECTIONSPATIOTEMPORALCHANNEL_C_DEFINED
00040
00041 #include "Channels/DirectionSpatioTemporalChannel.H"
00042
00043 #include "Channels/ChannelOpts.H"
00044 #include "Component/OptionManager.H"
00045 #include "Image/ImageSetOps.H"
00046 #include "Image/MathOps.H"
00047 #include "Util/sformat.H"
00048 #include "rutz/compat_cmath.h"
00049 #include "rutz/trace.h"
00050 #include "Raster/Raster.H"
00051 #include "Image/ShapeOps.H"
00052
00053
00054
00055
00056
00057
00058
00059 DirectionSpatioTemporalChannel::DirectionSpatioTemporalChannel
00060 (OptionManager& mgr,
00061 const uint dirIndex,
00062 const uint speedIndex,
00063 const double direction,
00064 const double speed,
00065 const PyramidType type):
00066 SingleChannel(mgr, "", "", MOTIONSPATIOTEMPORAL,
00067 rutz::make_shared
00068 (new SpatioTemporalEnergyPyrBuilder<float>
00069 (Oriented5, direction, speed))),
00070 itsDirIndex("DirectionChannelDirectionIndex", this, dirIndex),
00071 itsSpeedIndex("DirectionChannelSpeedIndex", this, speedIndex),
00072 itsDirection("DirectionChannelDirection", this, direction),
00073 itsSpeed("DirectionChannelSpeed", this, direction)
00074 {
00075
00076
00077
00078 GVX_TRACE(__PRETTY_FUNCTION__);
00079
00080
00081
00082
00083
00084 itsSpatioTemporalPyrBuilder.reset
00085 (new SpatioTemporalEnergyPyrBuilder<float>
00086 (Oriented5, direction, speed));
00087
00088 setDescriptiveName(sformat("DirectionSpeed(%d,%f)", int(direction), speed));
00089 setTagName(sformat("dir_%d_sp_%d", dirIndex, speedIndex));
00090 }
00091
00092
00093 void DirectionSpatioTemporalChannel::start1()
00094 {
00095 GVX_TRACE(__PRETTY_FUNCTION__);
00096 itsLevelSpec.setVal(LevelSpec(0,1,0,0,4) );
00097 SingleChannel::start1();
00098 }
00099
00100
00101 void DirectionSpatioTemporalChannel::start2()
00102 {
00103 GVX_TRACE(__PRETTY_FUNCTION__);
00104 }
00105
00106
00107 DirectionSpatioTemporalChannel::~DirectionSpatioTemporalChannel()
00108 {
00109 GVX_TRACE(__PRETTY_FUNCTION__);
00110 }
00111
00112
00113 ImageSet<float> DirectionSpatioTemporalChannel::
00114 computePyramid(const Image<float>& bwimg,
00115 const rutz::shared_ptr<PyramidCache<float> >& cache)
00116 {
00117 GVX_TRACE(__PRETTY_FUNCTION__);
00118
00119
00120 itsSpatioTemporalEnergy =
00121 itsSpatioTemporalPyrBuilder->build(bwimg);
00122 ImageSet<float> py = itsSpatioTemporalEnergy;
00123
00124 return py;
00125 }
00126
00127
00128 void DirectionSpatioTemporalChannel::doInput(const InputFrame& inframe)
00129 {
00130 GVX_TRACE(__PRETTY_FUNCTION__);
00131
00132 if (!this->started())
00133 CLFATAL("must be start()-ed before using receiving any input");
00134
00135 ASSERT(inframe.grayFloat().initialized());
00136
00137
00138 Image<byte> image(inframe.grayFloat());
00139
00140 setClipPyramid(inframe.clipMask());
00141
00142 itsSpatioTemporalEnergy =
00143 itsSpatioTemporalPyrBuilder->build(image);
00144
00145 if(itsSpatioTemporalEnergy.size() != 0)
00146 storePyramid(itsSpatioTemporalEnergy, inframe.time());
00147 }
00148
00149
00150 void DirectionSpatioTemporalChannel::setMTfeatureMap(Image<float> mtFeat)
00151 {
00152 itsMTfeatureMap = mtFeat;
00153 }
00154
00155
00156 Image<float> DirectionSpatioTemporalChannel::getRawCSmap(const uint idx) const
00157 {
00158
00159 Image<float> res = downSize(itsMTfeatureMap, getMapDims());
00160 Image<float> tres = maxNormalize(res, MAXNORMMIN, MAXNORMMAX,
00161 itsNormType.getVal());
00162
00163
00164
00165
00166
00167 return itsMTfeatureMap;
00168 }
00169
00170
00171 ImageSet<float> DirectionSpatioTemporalChannel::getSpatioTemporalEnergy()
00172 {
00173 return itsSpatioTemporalPyrBuilder->getSpatioTemporalEnergy();
00174 }
00175
00176
00177
00178
00179
00180
00181
00182 #endif // DIRECTIONSPATIOTEMPORALCHANNEL_C_DEFINED