00001 /*!@file Neuro/NeuroSimEvents.C SimEvent derivatives for neuro modules */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005 // 00005 // by the University of Southern California (USC) and the iLab at USC. // 00006 // See http://iLab.usc.edu for information about this project. // 00007 // //////////////////////////////////////////////////////////////////// // 00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00010 // in Visual Environments, and Applications'' by Christof Koch and // 00011 // Laurent Itti, California Institute of Technology, 2001 (patent // 00012 // pending; application number 09/912,225 filed July 23, 2001; see // 00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00014 // //////////////////////////////////////////////////////////////////// // 00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00016 // // 00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00018 // redistribute it and/or modify it under the terms of the GNU General // 00019 // Public License as published by the Free Software Foundation; either // 00020 // version 2 of the License, or (at your option) any later version. // 00021 // // 00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00025 // PURPOSE. See the GNU General Public License for more details. // 00026 // // 00027 // You should have received a copy of the GNU General Public License // 00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00030 // Boston, MA 02111-1307 USA. // 00031 // //////////////////////////////////////////////////////////////////// // 00032 // 00033 // Primary maintainer for this file: Laurent Itti <itti@usc.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Neuro/NeuroSimEvents.C $ 00035 // $Id: NeuroSimEvents.C 14762 2011-05-03 01:13:16Z siagian $ 00036 // 00037 00038 #include "Neuro/NeuroSimEvents.H" 00039 #include "Component/ParamMap.H" 00040 #include "Channels/ChannelMaps.H" 00041 #include "Channels/IntegerRawVisualCortex.H" 00042 #include "Channels/RawVisualCortex.H" 00043 #include "Util/sformat.H" 00044 #include "Image/MathOps.H" 00045 #include "Neuro/VisualBuffer.H" 00046 #include "Neuro/VisualCortex.H" 00047 #include "Neuro/VisualCortexEyeMvt.H" 00048 #include "Psycho/EyeData.H" 00049 #include "Psycho/HandData.H" 00050 #include "Transport/FrameOstream.H" 00051 #include "SpaceVariant/SpaceVariantTransforms.H" 00052 00053 // ###################################################################### 00054 SimEventWTAwinner::SimEventWTAwinner(SimModule* src, const WTAwinner w, 00055 const uint s) : 00056 SimEvent(src), itsWinner(w), itsShiftNum(s) 00057 { } 00058 00059 SimEventWTAwinner::~SimEventWTAwinner() 00060 { } 00061 00062 std::string SimEventWTAwinner::toString() const 00063 { 00064 return SimEvent::toString() + 00065 sformat(", winner[%u]=(%d, %d) %.3fmV%s", itsShiftNum, 00066 itsWinner.p.i, itsWinner.p.j, 00067 itsWinner.sv * 1000.0, itsWinner.boring ? " [boring]" : ""); 00068 } 00069 00070 const WTAwinner& SimEventWTAwinner::winner() const 00071 { return itsWinner; } 00072 00073 uint SimEventWTAwinner::shiftNum() const 00074 { return itsShiftNum; } 00075 00076 // ###################################################################### 00077 SimEventTargetsHit::SimEventTargetsHit(SimModule* src, const int numhit) : 00078 SimEvent(src), itsNumHits(numhit) 00079 { } 00080 00081 SimEventTargetsHit::~SimEventTargetsHit() 00082 { } 00083 00084 std::string SimEventTargetsHit::toString() const 00085 { return SimEvent::toString() + sformat(", %d hits", itsNumHits); } 00086 00087 int SimEventTargetsHit::numHits() const 00088 { return itsNumHits; } 00089 00090 // ###################################################################### 00091 SimEventRetinaImage::SimEventRetinaImage(SimModule* src, 00092 const InputFrame& ifr, 00093 const Rectangle& rawinprect, 00094 const Point2D<int> offset) : 00095 SimEvent(src), itsFrame(ifr), itsRawInputRectangle(rawinprect), 00096 itsOffset(offset), itsRetTransform(/*NULL*/), itsMapTransform(/*NULL*/) 00097 { } 00098 00099 SimEventRetinaImage::SimEventRetinaImage(SimModule* src, 00100 const InputFrame& ifr, 00101 const Rectangle& rawinprect, 00102 const Point2D<int> offset, 00103 rutz::shared_ptr<SpaceVariantTransform> rettransform, 00104 rutz::shared_ptr<SpaceVariantTransform> maptransform) : 00105 SimEvent(src), itsFrame(ifr), itsRawInputRectangle(rawinprect),itsOffset(offset), 00106 itsRetTransform(rettransform), itsMapTransform(maptransform) 00107 { } 00108 00109 SimEventRetinaImage::~SimEventRetinaImage() 00110 { } 00111 00112 std::string SimEventRetinaImage::toString() const 00113 { 00114 return SimEvent::toString() + 00115 sformat(", [%dx%d] t=%.1fms", itsFrame.colorByte().getWidth(), 00116 itsFrame.colorByte().getHeight(), itsFrame.time().msecs()); 00117 } 00118 00119 const InputFrame& SimEventRetinaImage::frame() const 00120 { return itsFrame; } 00121 00122 const Rectangle& SimEventRetinaImage::rawInputRectangle() const 00123 { return itsRawInputRectangle; } 00124 00125 Point2D<int> 00126 SimEventRetinaImage::rawToRetinal(const Point2D<int>& rawpos) const 00127 { return rawpos + itsOffset; } 00128 00129 const Dims& SimEventRetinaImage::getRawInputDims() const 00130 { if (itsRetTransform.is_valid()) 00131 return itsRetTransform->getCTDims(); 00132 else 00133 return itsFrame.getDims(); 00134 } 00135 00136 Point2D<int> 00137 SimEventRetinaImage::retinalToRaw(const Point2D<int>& retpos) const 00138 { return retpos - itsOffset; } 00139 00140 Point2D<int> SimEventRetinaImage::center() const 00141 { return Point2D<int>(itsFrame.getWidth() / 2, itsFrame.getHeight() / 2); } 00142 00143 const Point2D<int>& SimEventRetinaImage::offset() const 00144 { return itsOffset; } 00145 00146 rutz::shared_ptr<SpaceVariantTransform> SimEventRetinaImage::getRetTransform() const 00147 { return itsRetTransform; }; 00148 00149 rutz::shared_ptr<SpaceVariantTransform> SimEventRetinaImage::getMapTransform() const 00150 { return itsMapTransform; }; 00151 00152 // ###################################################################### 00153 SimEventVisualCortexOutput:: 00154 SimEventVisualCortexOutput(SimModule* src, const Image<float>& vcout) : 00155 SimEvent(src), itsMap(vcout) 00156 { } 00157 00158 SimEventVisualCortexOutput::~SimEventVisualCortexOutput() 00159 { } 00160 00161 std::string SimEventVisualCortexOutput::toString() const 00162 { 00163 return SimEvent::toString() + 00164 sformat(", [%dx%d]", itsMap.getWidth(), itsMap.getHeight()); 00165 } 00166 00167 const Image<float> SimEventVisualCortexOutput::vco(const float factor) const 00168 { 00169 Image<float> ret = itsMap; 00170 if (factor == 0.0F) inplaceNormalize(ret, 0.0F, 255.0F); 00171 else if (factor != 1.0F) ret *= factor; 00172 return ret; 00173 } 00174 00175 // ###################################################################### 00176 SimEventGistOutput:: 00177 SimEventGistOutput(SimModule* src, const Image<float>& gout) : 00178 SimEvent(src), itsGistVector(gout) 00179 { } 00180 00181 SimEventGistOutput::~SimEventGistOutput() 00182 { } 00183 00184 std::string SimEventGistOutput::toString() const 00185 { 00186 return SimEvent::toString() + 00187 sformat(", [%dx%d]", itsGistVector.getWidth(), itsGistVector.getHeight()); 00188 } 00189 00190 const Image<float> SimEventGistOutput::gv() const 00191 { return itsGistVector; } 00192 00193 // ###################################################################### 00194 SimEventSaliencyMapOutput:: 00195 SimEventSaliencyMapOutput(SimModule* src, const Image<float>& smout, const int maplevel) : 00196 SimEvent(src), itsMap(smout), itsMapLevel(maplevel) 00197 { } 00198 00199 SimEventSaliencyMapOutput::~SimEventSaliencyMapOutput() 00200 { } 00201 00202 std::string SimEventSaliencyMapOutput::toString() const 00203 { 00204 return SimEvent::toString() + 00205 sformat(", [%dx%d]", itsMap.getWidth(), itsMap.getHeight()); 00206 } 00207 00208 const Image<float> SimEventSaliencyMapOutput::sm(const float factor) const 00209 { 00210 Image<float> ret = itsMap; 00211 if (factor == 0.0F) inplaceNormalize(ret, 0.0F, 255.0F); 00212 else if (factor != 1.0F) ret *= factor; 00213 return ret; 00214 } 00215 00216 Point2D<int> SimEventSaliencyMapOutput::smToOrig(const Point2D<int>& p) const 00217 { 00218 return Point2D<int>((p.i << itsMapLevel), (p.j << itsMapLevel)); 00219 } 00220 00221 Point2D<int> SimEventSaliencyMapOutput::origToSm(const Point2D<int>& p) const 00222 { 00223 return Point2D<int>((p.i >> itsMapLevel), (p.j >> itsMapLevel)); 00224 } 00225 00226 // // ###################################################################### 00227 // SimEventMTfeatureMapOutput:: 00228 // SimEventMTfeatureMapOutput(SimModule* src, std::vector< Image<float> > mtFeat) : 00229 // SimEvent(src), itsMTfeatures(mtFeat) 00230 // { } 00231 00232 // SimEventMTfeatureMapOutput::~SimEventMTfeatureMapOutput() 00233 // { } 00234 00235 // std::string SimEventMTfeatureMapOutput::toString() const 00236 // { 00237 // return SimEvent::toString() + 00238 // sformat(", number of directions: %d", itsMTfeatures.size()); 00239 // } 00240 00241 // const std::vector<Image<float> > 00242 // SimEventMTfeatureMapOutput::mtFeatures() const 00243 // { 00244 // return itsMTfeatures; 00245 // } 00246 00247 // ###################################################################### 00248 SimEventTaskRelevanceMapOutput:: 00249 SimEventTaskRelevanceMapOutput(SimModule* src, const Image<float>& trmout) : 00250 SimEvent(src), itsMap(trmout) 00251 { } 00252 00253 SimEventTaskRelevanceMapOutput::~SimEventTaskRelevanceMapOutput() 00254 { } 00255 00256 std::string SimEventTaskRelevanceMapOutput::toString() const 00257 { 00258 return SimEvent::toString() + 00259 sformat(", [%dx%d]", itsMap.getWidth(), itsMap.getHeight()); 00260 } 00261 00262 const Image<float> SimEventTaskRelevanceMapOutput:: 00263 trm(const float factor) const 00264 { 00265 Image<float> ret = itsMap; 00266 if (factor == 0.0F) inplaceNormalize(ret, 0.0F, 255.0F); 00267 else if (factor != 1.0F) ret *= factor; 00268 return ret; 00269 } 00270 00271 // ###################################################################### 00272 SimEventAttentionGuidanceMapOutput:: 00273 SimEventAttentionGuidanceMapOutput(SimModule* src, const Image<float>& agmout) : 00274 SimEvent(src), itsMap(1) 00275 { itsMap[0] = agmout; } 00276 00277 SimEventAttentionGuidanceMapOutput:: 00278 SimEventAttentionGuidanceMapOutput(SimModule* src, const ImageSet<float>& agmout) : 00279 SimEvent(src), itsMap(agmout) 00280 { } 00281 00282 SimEventAttentionGuidanceMapOutput::~SimEventAttentionGuidanceMapOutput() 00283 { } 00284 00285 std::string SimEventAttentionGuidanceMapOutput::toString() const 00286 { 00287 return SimEvent::toString() + 00288 sformat(", [%dx%dx%d]", itsMap[0].getWidth(), itsMap[0].getHeight(), itsMap.size()); 00289 } 00290 00291 uint SimEventAttentionGuidanceMapOutput::numMaps() const 00292 { return itsMap.size(); } 00293 00294 const Image<float> SimEventAttentionGuidanceMapOutput::agm(const float factor, const uint pos) const 00295 { 00296 Image<float> ret; 00297 if (pos < itsMap.size()){ 00298 ret = itsMap[pos]; 00299 if (factor == 0.0F) inplaceNormalize(ret, 0.0F, 255.0F); 00300 else if (factor != 1.0F) ret *= factor; 00301 } 00302 return ret; 00303 } 00304 00305 const ImageSet<float> SimEventAttentionGuidanceMapOutput::allAgm(const float factor) const 00306 { 00307 if (factor == 1.0) 00308 return itsMap; 00309 else 00310 { 00311 ImageSet<float> ret = itsMap; 00312 for (uint ii = 0; ii < ret.size(); ++ii) 00313 { 00314 if (factor == 0.0F) inplaceNormalize(ret[ii], 0.0F, 255.0F); 00315 else ret[ii] *= factor; 00316 } 00317 return ret; 00318 } 00319 } 00320 00321 // ###################################################################### 00322 SimEventAttentionGateOutput:: 00323 SimEventAttentionGateOutput(SimModule* src, 00324 const Image<float>& agout, 00325 const Image<float>& lamout, 00326 const Image<float>& camout, 00327 const unsigned int lamframe) : 00328 SimEvent(src), itsMap(agout), itsLastAttMap(lamout), itsCurrAttMap(camout), 00329 itsLastFrame(lamframe) 00330 { } 00331 00332 SimEventAttentionGateOutput::~SimEventAttentionGateOutput() 00333 { } 00334 00335 std::string SimEventAttentionGateOutput::toString() const 00336 { 00337 return SimEvent::toString() + 00338 sformat(", [%dx%d]", itsMap.getWidth(), itsMap.getHeight()); 00339 } 00340 00341 const Image<float> SimEventAttentionGateOutput:: 00342 ag(const float factor) const 00343 { 00344 Image<float> ret = itsMap; 00345 if (factor == 0.0F) inplaceNormalize(ret, 0.0F, 255.0F); 00346 else if (factor != 1.0F) ret *= factor; 00347 return ret; 00348 } 00349 00350 const Image<float> SimEventAttentionGateOutput:: 00351 lam(const float factor) const 00352 { 00353 Image<float> ret = itsLastAttMap; 00354 if (factor == 0.0F) inplaceNormalize(ret, 0.0F, 255.0F); 00355 else if (factor != 1.0F) ret *= factor; 00356 return ret; 00357 } 00358 00359 const Image<float> SimEventAttentionGateOutput:: 00360 cam(const float factor) const 00361 { 00362 Image<float> ret = itsCurrAttMap; 00363 if (factor == 0.0F) inplaceNormalize(ret, 0.0F, 255.0F); 00364 else if (factor != 1.0F) ret *= factor; 00365 return ret; 00366 } 00367 00368 const unsigned int SimEventAttentionGateOutput::lamFrame() const 00369 { return itsLastFrame; } 00370 00371 // ###################################################################### 00372 SimEventAttentionGateStageTwoSegments:: 00373 SimEventAttentionGateStageTwoSegments(SimModule* src, 00374 const Image<bool>& candidates, 00375 const SimEventAttentionGateStageTwoObjects& obj, 00376 const int segnum) : 00377 SimEvent(src), itsCandidates(candidates), itsObjects(obj), 00378 itsSegmentNum(segnum) 00379 { } 00380 00381 SimEventAttentionGateStageTwoSegments::~SimEventAttentionGateStageTwoSegments() 00382 {} 00383 00384 const Image<bool> SimEventAttentionGateStageTwoSegments::candidates() const 00385 { return itsCandidates; } 00386 00387 const SimEventAttentionGateStageTwoObjects 00388 SimEventAttentionGateStageTwoSegments::obj() const 00389 { return itsObjects; } 00390 00391 const int SimEventAttentionGateStageTwoSegments::segnum() const 00392 { return itsSegmentNum; } 00393 00394 // ###################################################################### 00395 SimEventShapeEstimatorOutput:: 00396 SimEventShapeEstimatorOutput(SimModule* src, 00397 const Image<float>& winmap, 00398 const Image<byte>& objmask, 00399 const Image<byte>& iormask, 00400 const Image<float>& smoothmask, 00401 const Image<float>& cumsmoothmask, 00402 const std::string& winlabel, 00403 const bool isshaped) : 00404 SimEvent(src), itsWinningMap(winmap), itsObjMask(objmask), 00405 itsIORmask(iormask), itsSmoothMask(smoothmask), 00406 itsCumSmoothMask(cumsmoothmask), itsWinLabel(winlabel), 00407 itsIsShaped(isshaped) 00408 { } 00409 00410 SimEventShapeEstimatorOutput::~SimEventShapeEstimatorOutput() 00411 { } 00412 00413 std::string SimEventShapeEstimatorOutput::toString() const 00414 { 00415 return SimEvent::toString() + 00416 sformat("Winning map: %s [%dx%d], Smooth mask: [%dx%d]", 00417 itsWinLabel.c_str(), 00418 itsObjMask.getWidth(), itsObjMask.getHeight(), 00419 itsSmoothMask.getWidth(), itsSmoothMask.getHeight()); 00420 } 00421 00422 const Image<float>& SimEventShapeEstimatorOutput::winningMap() const 00423 { return itsWinningMap; } 00424 00425 const Image<byte>& SimEventShapeEstimatorOutput::objectMask() const 00426 { return itsObjMask; } 00427 00428 const Image<byte>& SimEventShapeEstimatorOutput::iorMask() const 00429 { return itsIORmask; } 00430 00431 const Image<float>& SimEventShapeEstimatorOutput::smoothMask() const 00432 { return itsSmoothMask; } 00433 00434 Image<float> SimEventShapeEstimatorOutput::cumSmoothMask() const 00435 { 00436 Image<float> result(itsCumSmoothMask); 00437 inplaceClamp(result, 0.4F /*CLAMP*/, 1.0F); 00438 return result; 00439 } 00440 00441 Image<float> SimEventShapeEstimatorOutput::negCumSmoothMask() const 00442 { 00443 Image<float> result(itsCumSmoothMask * (-1.0F) + 1.0F); 00444 inplaceClamp(result, 1.0F-0.4F /*CLAMP*/, 1.0F); 00445 return result; 00446 } 00447 00448 const std::string& SimEventShapeEstimatorOutput::winningLabel() const 00449 { return itsWinLabel; } 00450 00451 uint SimEventShapeEstimatorOutput::objectArea() const 00452 { 00453 const double scale = itsSmoothMask.getSize() / itsObjMask.getSize(); 00454 return uint(sum(itsObjMask) / 255.0 * scale); 00455 } 00456 00457 bool SimEventShapeEstimatorOutput::isShaped() const 00458 { return itsIsShaped; } 00459 00460 // ###################################################################### 00461 SimEventSaccadeStatus:: 00462 SimEventSaccadeStatus(SimModule* src, const Point2D<int>& pos, 00463 const SaccadeState state, 00464 const SaccadeState prevState, 00465 const bool blinkState, 00466 const bool prevBlinkState) : 00467 SimEvent(src), itsPosition(pos), 00468 itsState(state), itsPrevState(prevState), 00469 itsBlinkState(blinkState), itsPrevBlinkState(prevBlinkState) 00470 { } 00471 00472 SimEventSaccadeStatus::~SimEventSaccadeStatus() 00473 { } 00474 00475 std::string SimEventSaccadeStatus::toString() const 00476 { 00477 return SimEvent::toString() + 00478 sformat(" %s (%d,%d) Unk:%s Fix:%s Sac:%s Bli:%s Smo:%s", 00479 saccadeBodyPartName(bodyPart()), 00480 itsPosition.i, itsPosition.j, 00481 transientStatusToStr(unknownStatus()), 00482 transientStatusToStr(fixationStatus()), 00483 transientStatusToStr(saccadeStatus()), 00484 transientStatusToStr(blinkStatus()), 00485 transientStatusToStr(smoothPursuitStatus())); 00486 } 00487 00488 const Point2D<int>& SimEventSaccadeStatus::position() const 00489 { return itsPosition; } 00490 00491 TransientStatus SimEventSaccadeStatus::unknownStatus() const 00492 { return transientStatus(itsPrevState == SACSTATE_UNK, 00493 itsState == SACSTATE_UNK); } 00494 00495 TransientStatus SimEventSaccadeStatus::fixationStatus() const 00496 { return transientStatus(itsPrevState == SACSTATE_FIX, 00497 itsState == SACSTATE_FIX); } 00498 00499 TransientStatus SimEventSaccadeStatus::saccadeStatus() const 00500 { return transientStatus(itsPrevState == SACSTATE_SAC, 00501 itsState == SACSTATE_SAC); } 00502 00503 TransientStatus SimEventSaccadeStatus::blinkStatus() const 00504 { return transientStatus(itsPrevBlinkState, itsBlinkState); } 00505 00506 TransientStatus SimEventSaccadeStatus::smoothPursuitStatus() const 00507 { return transientStatus(itsPrevState == SACSTATE_SMO, 00508 itsState == SACSTATE_SMO); } 00509 00510 00511 // ###################################################################### 00512 SimEventSaccadeStatusEye:: 00513 SimEventSaccadeStatusEye(SimModule* src, const Point2D<int>& pos, 00514 const SaccadeState state, 00515 const SaccadeState prevState, 00516 const bool blinkState, 00517 const bool prevBlinkState) : 00518 SimEventSaccadeStatus(src, pos, state, prevState, blinkState, prevBlinkState) 00519 { } 00520 00521 SimEventSaccadeStatusEye::~SimEventSaccadeStatusEye() 00522 { } 00523 00524 SaccadeBodyPart SimEventSaccadeStatusEye::bodyPart() const 00525 { return SaccadeBodyPartEye; } 00526 00527 // ###################################################################### 00528 SimEventSaccadeStatusHead:: 00529 SimEventSaccadeStatusHead(SimModule* src, const Point2D<int>& pos, 00530 const SaccadeState state, 00531 const SaccadeState prevState, 00532 const bool blinkState, 00533 const bool prevBlinkState) : 00534 SimEventSaccadeStatus(src, pos, state, prevState, blinkState, prevBlinkState) 00535 { } 00536 00537 SimEventSaccadeStatusHead::~SimEventSaccadeStatusHead() 00538 { } 00539 00540 SaccadeBodyPart SimEventSaccadeStatusHead::bodyPart() const 00541 { return SaccadeBodyPartHead; } 00542 00543 // ###################################################################### 00544 SimEventEyeTrackerData:: 00545 SimEventEyeTrackerData(SimModule* src, rutz::shared_ptr<EyeData> d, 00546 const uint trackernum, 00547 const std::string& trackerfname, 00548 const PixRGB<byte>& trackercolor, 00549 const PixPerDeg& ppd, const SimTime samplingrate) : 00550 SimEvent(src), itsData(d), itsTrackerNum(trackernum), 00551 itsTrackerFname(trackerfname), itsTrackerColor(trackercolor), itsPpd(ppd), 00552 itsHz(samplingrate) 00553 { } 00554 00555 SimEventEyeTrackerData::~SimEventEyeTrackerData() 00556 { } 00557 00558 rutz::shared_ptr<EyeData> SimEventEyeTrackerData::data() const 00559 { return itsData; } 00560 00561 uint SimEventEyeTrackerData::trackerNum() const 00562 { return itsTrackerNum; } 00563 00564 std::string SimEventEyeTrackerData::trackerFilename() const 00565 { return itsTrackerFname; } 00566 00567 PixRGB<byte> SimEventEyeTrackerData::trackerColor() const 00568 { return itsTrackerColor; } 00569 00570 PixPerDeg SimEventEyeTrackerData::trackerPpd() const 00571 { return itsPpd; } 00572 00573 SimTime SimEventEyeTrackerData::trackerHz() const 00574 { return itsHz; } 00575 00576 // ###################################################################### 00577 SimEventHandTrackerData:: 00578 SimEventHandTrackerData(SimModule* src, rutz::shared_ptr<HandData> d, 00579 const uint trackernum, 00580 const std::string& trackerfname, 00581 const PixRGB<byte>& trackercolor, 00582 const SimTime samplingrate) : 00583 SimEvent(src), itsData(d), itsTrackerNum(trackernum), 00584 itsTrackerFname(trackerfname), itsTrackerColor(trackercolor), 00585 itsHz(samplingrate) 00586 { } 00587 00588 SimEventHandTrackerData::~SimEventHandTrackerData() 00589 { } 00590 00591 rutz::shared_ptr<HandData> SimEventHandTrackerData::data() const 00592 { return itsData; } 00593 00594 uint SimEventHandTrackerData::trackerNum() const 00595 { return itsTrackerNum; } 00596 00597 std::string SimEventHandTrackerData::trackerFilename() const 00598 { return itsTrackerFname; } 00599 00600 PixRGB<byte> SimEventHandTrackerData::trackerColor() const 00601 { return itsTrackerColor; } 00602 00603 SimTime SimEventHandTrackerData::trackerHz() const 00604 { return itsHz; } 00605 00606 // ###################################################################### 00607 SimReqVCXchanVis:: 00608 SimReqVCXchanVis(SimModule* src, rutz::shared_ptr<ChannelVisitor> vis) : 00609 SimReq(src), itsVisitor(vis) 00610 { } 00611 00612 SimReqVCXchanVis::~SimReqVCXchanVis() 00613 { } 00614 00615 void SimReqVCXchanVis::preProcessing(RawVisualCortex *vcx) 00616 { } 00617 00618 rutz::shared_ptr<ChannelVisitor> SimReqVCXchanVis::visitor() const 00619 { return itsVisitor; } 00620 00621 void SimReqVCXchanVis::postProcessing(RawVisualCortex *vcx) 00622 { } 00623 00624 // ###################################################################### 00625 SimEventObjectToBias:: 00626 SimEventObjectToBias(SimModule* src, const std::string& objName) : 00627 SimEvent(src), itsObjName(objName) 00628 { } 00629 00630 SimEventObjectToBias::~SimEventObjectToBias() 00631 { } 00632 00633 const std::string& SimEventObjectToBias::name() const 00634 { return itsObjName; } 00635 00636 // ###################################################################### 00637 SimEventTargetMask:: 00638 SimEventTargetMask(SimModule* src, const Image<byte>& tmask) : 00639 SimEvent(src), itsMask(tmask) 00640 { } 00641 00642 SimEventTargetMask::~SimEventTargetMask() 00643 { } 00644 00645 std::string SimEventTargetMask::toString() const 00646 { 00647 return SimEvent::toString() + sformat(", [%dx%d]", itsMask.getWidth(), itsMask.getHeight()); 00648 } 00649 00650 const Image<byte> SimEventTargetMask::mask() const 00651 { return itsMask; } 00652 00653 // ###################################################################### 00654 SimReqVCXfeatures:: 00655 SimReqVCXfeatures(SimModule* src, const Point2D<int>& loc) : 00656 SimReq(src), itsLoc(loc), itsFeatures() 00657 { } 00658 00659 SimReqVCXfeatures::~SimReqVCXfeatures() 00660 { } 00661 00662 std::string SimReqVCXfeatures::toString() const 00663 { 00664 return SimReq::toString() + sformat(", [%d,%d]", itsLoc.i, itsLoc.j); 00665 } 00666 00667 const Point2D<int>& SimReqVCXfeatures::loc() const 00668 { return itsLoc; } 00669 00670 std::vector<float>& SimReqVCXfeatures::features() 00671 { return itsFeatures; } 00672 00673 // ###################################################################### 00674 SimReqVCXmaps::SimReqVCXmaps(SimModule* src) : 00675 SimReq(src), itsChannelMaps(0) 00676 { } 00677 00678 SimReqVCXmaps::~SimReqVCXmaps() 00679 { } 00680 00681 rutz::shared_ptr<ChannelMaps> SimReqVCXmaps::channelmaps() const 00682 { return itsChannelMaps; } 00683 00684 void SimReqVCXmaps::populateChannelMaps(RawVisualCortex *vcx) 00685 { 00686 // are we being handled by several respondents? 00687 if (itsChannelMaps.is_valid()) LFATAL("I can only be handled by one respondent"); 00688 00689 itsChannelMaps = rutz::make_shared(new ChannelMaps(vcx)); 00690 } 00691 00692 void SimReqVCXmaps::populateChannelMaps(IntegerRawVisualCortex *vcx) 00693 { 00694 // are we being handled by several respondents? 00695 if (itsChannelMaps.is_valid()) LFATAL("I can only be handled by one respondent"); 00696 00697 itsChannelMaps = rutz::make_shared(new ChannelMaps(vcx)); 00698 } 00699 00700 void SimReqVCXmaps::populateChannelMaps(EnvVisualCortexFloat *vcx) 00701 { 00702 // are we being handled by several respondents? 00703 if (itsChannelMaps.is_valid()) LFATAL("I can only be handled by one respondent"); 00704 00705 itsChannelMaps = rutz::make_shared(new ChannelMaps(vcx)); 00706 } 00707 00708 void SimReqVCXmaps::populateChannelMaps(VisualCortexEyeMvt *vcx) 00709 { 00710 // are we being handled by several respondents? 00711 if (itsChannelMaps.is_valid()) LFATAL("I can only be handled by one respondent"); 00712 00713 itsChannelMaps = rutz::make_shared(new ChannelMaps(NamedImage<float>(vcx->getOutput(), "SaliencyMap"))); 00714 } 00715 00716 // ###################################################################### 00717 SimEventVisualBufferOutput:: 00718 SimEventVisualBufferOutput(SimModule* src, const Image<float>& buf, const int smlev, 00719 const Dims& smdims, const Point2D<int>& retoff) : 00720 SimEvent(src), itsVisualBuffer(buf), itsSMlev(smlev), itsSMdims(smdims), itsRetinaOffset(retoff) 00721 { } 00722 00723 SimEventVisualBufferOutput::~SimEventVisualBufferOutput() 00724 { } 00725 00726 std::string SimEventVisualBufferOutput::toString() const 00727 { 00728 return SimEvent::toString() + sformat(", [%dx%d]", itsVisualBuffer.getWidth(), itsVisualBuffer.getHeight()); 00729 } 00730 00731 const Image<float>& SimEventVisualBufferOutput::buffer() const 00732 { return itsVisualBuffer; } 00733 00734 const Dims& SimEventVisualBufferOutput::smdims() const 00735 { return itsSMdims; } 00736 00737 int SimEventVisualBufferOutput::smlev() const 00738 { return itsSMlev; } 00739 00740 Point2D<int> SimEventVisualBufferOutput::retinalToBuffer(const Point2D<int>& p) const 00741 { 00742 return retinalToVisualBuffer(p, itsRetinaOffset, itsSMlev, itsSMdims, itsVisualBuffer.getDims()); 00743 } 00744 00745 Point2D<int> SimEventVisualBufferOutput::bufferToRetinal(const Point2D<int>& p) const 00746 { 00747 return visualBufferToRetinal(p, itsRetinaOffset, itsSMlev, itsSMdims, itsVisualBuffer.getDims()); 00748 00749 } 00750 00751 // ###################################################################### 00752 /* So things look consistent in everyone's emacs... */ 00753 /* Local Variables: */ 00754 /* mode: c++ */ 00755 /* indent-tabs-mode: nil */ 00756 /* End: */