ChannelBase represents the various computational modules in VisualCortex. More...
#include <Channels/ChannelBase.H>
Public Member Functions | |
ChannelBase (OptionManager &mgr, const std::string &descrName, const std::string &tagName, const VisualFeature vs) | |
Default constructor. See ModelComponent.H. | |
virtual | ~ChannelBase () |
Virtual destructor ensures proper destruction of derived classes. | |
virtual void | reset1 () |
Kill our caches. | |
virtual void | accept (ChannelVisitor &v) |
Default version calls visitChannelBase() on the ChannelVisitor. | |
VisualFeature functions | |
VisualFeature | visualFeature () const |
Get the visual feature. | |
virtual bool | isHomogeneous () const |
Is the channel homogeneous? | |
ParamMap functions | |
Subclasses should be sure to call ChannelBase's version of these functions within their own implementations, so that ChannelBase's parameters (such as its weights) are properly handled. This interface is different from that provided by ModelComponent, as here we only save a subset of all of the Channel's parameters, that are useful, e.g., for object recognition or feature-based attention biasing. Some of the values saved here may not even be ModelParam parameters. | |
virtual void | readFrom (const ParamMap &pmap) |
Read params from the ParamMap. | |
virtual void | writeTo (ParamMap &pmap) const |
Write params to the ParamMap. | |
Input functions | |
See documentation on InputFrame for multiple ways in which an InputFrame can be constructed. | |
void | input (const InputFrame &inframe) |
Send a full-blown InputFrame to the channel. | |
Access functions | |
virtual bool | outputAvailable () const =0 |
Query whether the channel is ready to give yield valid output. | |
virtual Dims | getMapDims () const =0 |
Return the dimensions of the output image. | |
bool | hasInput () const |
Check if we've received any input images yet. | |
Dims | getInputDims () const |
Return the dimensions of the most recent input image. | |
virtual uint | numSubmaps () const =0 |
Return the number of feature maps represented by this channel. | |
virtual Image< float > | getSubmap (const uint index) const =0 |
Get the feature map at the given index. | |
virtual Image< float > | getRawCSmap (const uint idx) const |
get raw CS map; part of getSubmap() | |
virtual std::string | getSubmapName (const uint index) const =0 |
Get the name/description of the feature map at the given index. | |
virtual std::string | getSubmapNameShort (const uint index) const =0 |
Get the name/description of the feature map at the given index, short version. | |
virtual void | getFeatures (const Point2D< int > &locn, std::vector< float > &mean) const =0 |
virtual void | getFeaturesBatch (std::vector< Point2D< int > * > *locn, std::vector< std::vector< float > > *mean, int *count) const =0 |
virtual Image< float > | getOutput ()=0 |
The output will be the size of the feature map level in the pyramid. | |
virtual void | saveResults (const nub::ref< FrameOstream > &ofs) |
Save our various maps using a FrameOstream. | |
virtual void | killCaches () |
Subclasses override this to clear any caches they may maintain. | |
Protected Member Functions | |
virtual void | doInput (const InputFrame &inframe)=0 |
Subclasses override this implementation of the input() function. | |
void | setInputDims (const Dims &dims) |
ChannelBase represents the various computational modules in VisualCortex.
Definition at line 63 of file ChannelBase.H.
ChannelBase::ChannelBase | ( | OptionManager & | mgr, | |
const std::string & | descrName, | |||
const std::string & | tagName, | |||
const VisualFeature | vs | |||
) |
Default constructor. See ModelComponent.H.
mgr | our ModelManager (see ModelManager.H) | |
descrName | descriptive name for human usage | |
tagName | name for ParamMap usage | |
vs | The VisualFeature implemented by the channel |
Definition at line 57 of file ChannelBase.C.
References ModelComponent::init().
ChannelBase::~ChannelBase | ( | ) | [virtual] |
Virtual destructor ensures proper destruction of derived classes.
Definition at line 68 of file ChannelBase.C.
void ChannelBase::accept | ( | ChannelVisitor & | v | ) | [virtual] |
Default version calls visitChannelBase() on the ChannelVisitor.
Reimplemented in ComplexChannel, SingleChannel, and SpectralResidualChannel.
Definition at line 83 of file ChannelBase.C.
References ChannelVisitor::visitChannelBase().
Referenced by setSubmapAlgorithmBiased().
virtual void ChannelBase::doInput | ( | const InputFrame & | inframe | ) | [protected, pure virtual] |
Subclasses override this implementation of the input() function.
This will be called by one of the input() methods. For efficiency reasons (e.g. network bandwidth in parallel code), it is possible that the color or luminance input may be null, although the code should be wired up properly so that given subclasses do not receive a null input that they in fact need. Subclasses should be sure to ASSERT that any used inputs are non-null.
Implemented in CIELabChannel, ColorChannel, CompositeColorChannel, ContourChannel, DepthChannel, DepthMotionChannel, DirectFeedChannel, MultiDirectFeedChannel, DirectionOpticalFlowChannel, DirectionSpatioTemporalChannel, DisparityChannel, DKLcolorChannel, DummyChannel, EndPointChannel, EntropyChannel, FlickerChannel, FlickerNBackChannel, FoeMSTChannel, ForegroundDetectionChannel, H2SVChannel, HueChannel, ImagizeColorChannel, InformationChannel, IntensityBandChannel, JunctionChannel, LJunctionChannel, MichelsonChannel, MotionChannel, MotionOpticalFlowChannel, MotionSpatioTemporalChannel, MSTChannel, MultiColorBandChannel, MultiConvolveChannel, MultiSpectralResidualChannel, ObjDetChannel, OrientationChannel, PN03contrastChannel, RawVisualCortex, RGBConvolveChannel, ScorrChannel, SIFTChannel, SingleChannel, SobelChannel, SOColorChannel, SoxChannel, SpectralResidualChannel, StereoChannel, TcorrChannel, TJunctionChannel, VarianceChannel, XJunctionChannel, and ZeroChannel.
Referenced by input().
Dims ChannelBase::getInputDims | ( | ) | const |
Return the dimensions of the most recent input image.
Will LFATAL() if hasInput() is false.
Definition at line 150 of file ChannelBase.C.
References Dims::isEmpty().
Referenced by RawVisualCortex::combineOutputs(), IntegerRawVisualCortex::combineOutputsInt(), DirectFeedChannel::doInput(), TemplateMatchChannel::findBestMatch(), SingleChannel::getMapDims(), SpectralResidualChannel::getMapDims(), ContourChannel::getMapDims(), ObjDetChannel::getMapDims(), ZeroChannel::getMapDims(), ForegroundDetectionChannel::getMapDims(), IntegerSimpleChannel::getMapDims(), and SoxChannel::getNonlinearResponse().
virtual Dims ChannelBase::getMapDims | ( | ) | const [pure virtual] |
Return the dimensions of the output image.
Implemented in ComplexChannel, ContourChannel, DirectFeedChannel, DummyChannel, ForegroundDetectionChannel, IntegerComplexChannel, IntegerSimpleChannel, ObjDetChannel, SingleChannel, SingleSvChannel, SpectralResidualChannel, and ZeroChannel.
virtual Image<float> ChannelBase::getOutput | ( | ) | [pure virtual] |
The output will be the size of the feature map level in the pyramid.
(I.e., the size of the output is given by getMapDims().
Implemented in ComplexChannel, ContourChannel, DirectFeedChannel, EntropyChannel, ForegroundDetectionChannel, InformationChannel, IntegerComplexChannel, IntegerRawVisualCortex, IntegerSimpleChannel, MichelsonChannel, MotionOpticalFlowChannel, MotionSpatioTemporalChannel, ObjDetChannel, OrientationChannel, PN03contrastChannel, ScorrChannel, SIFTChannel, SingleChannel, SobelChannel, SpectralResidualChannel, TcorrChannel, VarianceChannel, and ZeroChannel.
Referenced by ChannelMaps::ChannelMaps().
get raw CS map; part of getSubmap()
Reimplemented in ComplexChannel, DirectionSpatioTemporalChannel, ForegroundDetectionChannel, IntegerComplexChannel, IntegerSimpleChannel, and SingleChannel.
Definition at line 161 of file ChannelBase.H.
Get the feature map at the given index.
This function is intended to be implemented by subclasses so that it recurses into any nested channels, mapping nested submaps into a linear sequence of indices.
Implemented in ComplexChannel, ContourChannel, DirectFeedChannel, ForegroundDetectionChannel, HueChannel, IntegerComplexChannel, IntegerSimpleChannel, ObjDetChannel, SingleChannel, SpectralResidualChannel, and ZeroChannel.
virtual std::string ChannelBase::getSubmapName | ( | const uint | index | ) | const [pure virtual] |
Get the name/description of the feature map at the given index.
This function is intended to be implemented by subclasses so that it recurses into any nested channels, mapping nested submaps into a linear sequence of indices. The output of this function is intended only to be human-readable (e.g. for labeling image displays), and does not have to follow any particular parseable syntax.
Implemented in ComplexChannel, ContourChannel, DirectFeedChannel, ForegroundDetectionChannel, HueChannel, IntegerComplexChannel, IntegerSimpleChannel, ObjDetChannel, SingleChannel, SingleSvChannel, SpectralResidualChannel, and ZeroChannel.
virtual std::string ChannelBase::getSubmapNameShort | ( | const uint | index | ) | const [pure virtual] |
Get the name/description of the feature map at the given index, short version.
Implemented in ComplexChannel, ContourChannel, IntegerComplexChannel, IntegerSimpleChannel, ObjDetChannel, SingleChannel, SingleSvChannel, SpectralResidualChannel, and ZeroChannel.
bool ChannelBase::hasInput | ( | ) | const |
Check if we've received any input images yet.
Definition at line 143 of file ChannelBase.C.
References Dims::isNonEmpty().
Referenced by ObjDetChannel::getMapDims(), ZeroChannel::getMapDims(), ForegroundDetectionChannel::getMapDims(), SingleChannel::getOutput(), and DescriptorVec::setFovea().
void ChannelBase::input | ( | const InputFrame & | inframe | ) |
Send a full-blown InputFrame to the channel.
Definition at line 131 of file ChannelBase.C.
References doInput(), GVX_ERR_CONTEXT, killCaches(), rutz::sfmt(), and ModelComponent::tagName().
Referenced by OrientationChannel::doInput(), MultiDirectFeedChannel::doInput(), and RawVisualCortex::getVCOutput().
bool ChannelBase::isHomogeneous | ( | ) | const [virtual] |
Is the channel homogeneous?
A homogeneous channel is one whose subchannels (and their subs) have identical VisualFeatures, and those are also identical to our VisualFeature. Default implementation returns true.
Reimplemented in ComplexChannel, IntegerComplexChannel, and SpectralResidualChannel.
Definition at line 97 of file ChannelBase.C.
void ChannelBase::killCaches | ( | ) | [virtual] |
Subclasses override this to clear any caches they may maintain.
Subclasses must be sure to explicitly call their base class's version of this function!. This function will be called by ChannelBase when a new input image is received, or when new parameters are read from a ParamMap, etc. Subclasses may also call this function when they know that caches may have become invalid. Calling this explicitly after you have obtained the output from a channel may save you some memory.
Reimplemented in ComplexChannel, ContourChannel, DirectFeedChannel, IntegerComplexChannel, IntegerSimpleChannel, SingleChannel, SoxChannel, and SpectralResidualChannel.
Definition at line 167 of file ChannelBase.C.
Referenced by input(), readFrom(), and reset1().
virtual uint ChannelBase::numSubmaps | ( | ) | const [pure virtual] |
Return the number of feature maps represented by this channel.
Implemented in ComplexChannel, ContourChannel, DirectFeedChannel, ForegroundDetectionChannel, HueChannel, IntegerComplexChannel, IntegerSimpleChannel, ObjDetChannel, SingleChannel, SpectralResidualChannel, and ZeroChannel.
Referenced by IntegerRawVisualCortex::getChannelOutputMap(), SingleSvChannel::getSubmapName(), and SingleSvChannel::getSubmapNameShort().
virtual bool ChannelBase::outputAvailable | ( | ) | const [pure virtual] |
Query whether the channel is ready to give yield valid output.
In some cases (e.g. with motion channels), it may take several input frames before the channel is fully initialized.
Implemented in ComplexChannel, ContourChannel, DirectFeedChannel, DirectionOpticalFlowChannel, DummyChannel, EntropyChannel, ForegroundDetectionChannel, InformationChannel, IntegerComplexChannel, IntegerSimpleChannel, MichelsonChannel, ObjDetChannel, PN03contrastChannel, ScorrChannel, SIFTChannel, SingleChannel, SobelChannel, SpectralResidualChannel, TcorrChannel, VarianceChannel, and ZeroChannel.
Referenced by ChannelMaps::ChannelMaps().
void ChannelBase::readFrom | ( | const ParamMap & | pmap | ) | [virtual] |
Read params from the ParamMap.
Reimplemented in ComplexChannel, DirectFeedChannel, GaborChannel, IntegerComplexChannel, IntegerSimpleChannel, SingleChannel, and SpectralResidualChannel.
Definition at line 106 of file ChannelBase.C.
References ModelComponent::descriptiveName(), ParamMap::getStringParam(), ParamMap::hasParam(), and killCaches().
void ChannelBase::reset1 | ( | ) | [virtual] |
Kill our caches.
Reimplemented from ModelComponent.
Reimplemented in DirectFeedChannel, FlickerChannel, FlickerNBackChannel, IntegerFlickerChannel, IntegerSimpleChannel, SingleChannel, and SingleOpponentChannel.
Definition at line 74 of file ChannelBase.C.
References killCaches().
void ChannelBase::saveResults | ( | const nub::ref< FrameOstream > & | ofs | ) | [virtual] |
Save our various maps using a FrameOstream.
The default implementation is a no-op; subclasses can override to do something interesting
Reimplemented in ComplexChannel, ContourChannel, IntegerComplexChannel, IntegerRawVisualCortex, IntegerSimpleChannel, RawVisualCortex, SingleChannel, and SpectralResidualChannel.
Definition at line 160 of file ChannelBase.C.
VisualFeature ChannelBase::visualFeature | ( | ) | const |
Get the visual feature.
Definition at line 90 of file ChannelBase.C.
References NModelParam< T >::getVal().
Referenced by EndPointChannel::buildSubChans(), LJunctionChannel::buildSubChans(), FoeMSTChannel::buildSubChans(), XJunctionChannel::buildSubChans(), TJunctionChannel::buildSubChans(), SingleChannelBeo::handleInput(), ComplexChannel::isHomogeneous(), IntegerComplexChannel::isHomogeneous(), RawVisualCortex::start1(), IntegerRawVisualCortex::start1(), JetSpecFiller::visitComplexChannel(), JetFiller::visitSingleChannel(), and JetSpecFiller::visitSingleChannel().
void ChannelBase::writeTo | ( | ParamMap & | pmap | ) | const [virtual] |
Write params to the ParamMap.
Reimplemented in ComplexChannel, DirectFeedChannel, GaborChannel, IntegerComplexChannel, IntegerSimpleChannel, SingleChannel, and SpectralResidualChannel.
Definition at line 123 of file ChannelBase.C.
References ModelComponent::descriptiveName(), and ParamMap::putStringParam().