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 MSTCHANNEL_C_DEFINED
00039 #define MSTCHANNEL_C_DEFINED
00040
00041 #include "Channels/MSTChannel.H"
00042
00043 #include "Channels/ChannelOpts.H"
00044 #include "Channels/ComplexChannel.H"
00045 #include "Channels/DirectionChannel.H"
00046 #include "Channels/MotionChannel.H"
00047 #include "Component/OptionManager.H"
00048 #include "Image/FilterOps.H"
00049 #include "Util/sformat.H"
00050 #include "rutz/trace.h"
00051
00052
00053
00054
00055 MSTChannel::MSTChannel(OptionManager& mgr,
00056 nub::soft_ref<MotionChannel> oc,
00057 const VisualFeature vs,
00058 const int r0, const int r1, const int r2,
00059 const int r3, const int r4, const int r5,
00060 const int r6, const int r7) :
00061 SingleChannel(mgr, "MSTChannel", "MSTChannel", vs,
00062 rutz::shared_ptr< PyrBuilder<float> >(NULL)),
00063 itsFull(vs == FOEMST ? &OPT_EFullImplementation :
00064 (ModelOptionDef*) 0,
00065 this),
00066 itsDelta(vs == FOEMST ? &OPT_EndPointChannelDelta :
00067 (ModelOptionDef*) 0,
00068 this),
00069 itsOriChan(oc),
00070 R0(r0), R1(r1), R2(r2), R3(r3), R4(r4), R5(r5), R6(r6), R7(r7)
00071 {
00072 GVX_TRACE(__PRETTY_FUNCTION__);
00073 itsTakeAbs.setVal(true);
00074
00075 setDescriptiveName(sformat("MST(%d%d%d%d%d%d%d%d)",
00076 r0, r1, r2, r3, r4, r5, r6, r7));
00077
00078 setTagName(sformat("MST_%d%d%d%d%d%d%d%d",
00079 r0, r1, r2, r3, r4, r5, r6, r7));
00080 LINFO("***mst**");
00081 }
00082
00083
00084 MSTChannel::~MSTChannel()
00085 {
00086 GVX_TRACE(__PRETTY_FUNCTION__);
00087 }
00088
00089
00090 void MSTChannel::doInput(const InputFrame& inframe)
00091 {
00092 GVX_TRACE(__PRETTY_FUNCTION__);
00093
00094 ASSERT(itsOriChan.get() != 0);
00095 const uint num = itsOriChan->getModelParamVal<uint>("NumDirections");
00096 ASSERT(num == 4);
00097
00098 LINFO("**doing input in *mst**");
00099
00100
00101
00102 const ImageSet<float>& ori0_pyr =
00103 dynCast<SingleChannel>(itsOriChan->subChan(0))->pyramid(0);
00104 const ImageSet<float>& ori45_pyr =
00105 dynCast<SingleChannel>(itsOriChan->subChan(1))->pyramid(0);
00106 const ImageSet<float>& ori90_pyr =
00107 dynCast<SingleChannel>(itsOriChan->subChan(2))->pyramid(0);
00108 const ImageSet<float>& ori135_pyr =
00109 dynCast<SingleChannel>(itsOriChan->subChan(3))->pyramid(0);
00110
00111 ImageSet<float> result(ori0_pyr.size());
00112 SingleChannel::killCaches();
00113 SingleChannel::setClipPyramid(inframe.clipMask());
00114
00115 const bool R[8] = { (bool)R0, (bool)R1, (bool)R2, (bool)R3, (bool)R4,
00116 (bool)R5, (bool)R6, (bool)R7 };
00117
00118 const uint dx = itsDelta.getVal();
00119 const uint dy = itsDelta.getVal();
00120
00121
00122
00123
00124
00125
00126 if (itsFull.getVal())
00127 {
00128
00129 for (uint i = 0; i < ori0_pyr.size(); i ++)
00130 result[i] = MSTFilterFull(ori0_pyr[i], ori45_pyr[i],
00131 ori90_pyr[i], ori135_pyr[i],
00132 R, dx, dy);
00133 }
00134 else
00135 {
00136 for (uint i = 0; i < ori0_pyr.size(); i ++)
00137 result[i] = MSTFilterPartial(ori0_pyr[i], ori45_pyr[i],
00138 ori90_pyr[i], ori135_pyr[i],
00139 R, dx, dy);
00140 }
00141
00142 SingleChannel::storePyramid(result, inframe.time());
00143 }
00144
00145
00146
00147
00148
00149
00150
00151 #endif // MSTCHANNEL_C_DEFINED