SimulationViewerNerdCam.H
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 SIMULATIONVIEWERNERDCAM_H_DEFINED
00039 #define SIMULATIONVIEWERNERDCAM_H_DEFINED
00040
00041 #include "Component/ModelParam.H"
00042 #include "Component/OptionManager.H"
00043 #include "Image/ArrayData.H"
00044 #include "Image/Image.H"
00045 #include "Image/ImageSet.H"
00046 #include "Image/Pixels.H"
00047 #include "Image/Point2DT.H"
00048 #include "Media/MediaSimEvents.H"
00049 #include "Neuro/NeuroSimEvents.H"
00050 #include "Neuro/Brain.H"
00051 #include "Neuro/SimulationViewer.H"
00052 #include "Neuro/SpatialMetrics.H"
00053 #include "Neuro/VisualCortex.H"
00054 #include "Neuro/WTAwinner.H"
00055 #include "Simulation/SimEvents.H"
00056 #include "Transport/FrameInfo.H"
00057 #include "Transport/FrameOstream.H"
00058 #include "Util/SimTime.H"
00059 #include "rutz/shared_ptr.h"
00060 #include <fstream>
00061 #include <fcntl.h>
00062 #include <cerrno>
00063 #include <cstdio>
00064
00065 class Brain;
00066 class FrameOstream;
00067
00068
00069
00070
00071
00072
00073
00074 class SimulationViewerNerdCam : public SimulationViewer {
00075 public:
00076
00077
00078
00079
00080
00081
00082
00083
00084 SimulationViewerNerdCam(OptionManager& mgr,
00085 const std::string& descrName = "NerdCam Interface",
00086 const std::string& tagName = "NerdCam");
00087
00088 virtual ~SimulationViewerNerdCam();
00089
00090
00091
00092 virtual void reset1();
00093
00094
00095 void init(const ushort baseSizeX,const ushort baseSizeY);
00096
00097
00098
00099 protected:
00100
00101 SIMCALLBACK_DECLARE(SimulationViewerNerdCam, SimEventInputFrame);
00102
00103
00104
00105 SIMCALLBACK_DECLARE(SimulationViewerNerdCam, SimEventClockTick);
00106
00107
00108 SIMCALLBACK_DECLARE(SimulationViewerNerdCam, SimEventWTAwinner);
00109
00110
00111 SIMCALLBACK_DECLARE(SimulationViewerNerdCam, SimEventSaveOutput);
00112
00113
00114 virtual void save1(const ModelComponentSaveInfo& sinfo);
00115
00116
00117 Image< PixRGB<byte> > getTraj(SimEventQueue& q);
00118
00119
00120 void saveResults(const nub::ref<FrameOstream>& ofs, SimEventQueue& q);
00121
00122
00123 virtual void start2();
00124
00125 void writeStatusPage() const;
00126
00127 void writeChannelPage() const;
00128
00129 void drawTime(Image< PixRGB<byte> >& image) const;
00130
00131 void lockFile(const std::string fileName, int &fd, struct flock &fl) const;
00132
00133 void unlockFile(const std::string fileName, const int fd,
00134 struct flock &fl) const;
00135
00136 void nlog(const std::string logData) const;
00137
00138 void drawDateTime(Image< PixRGB<byte> >& image) const;
00139
00140 void drawFOA();
00141
00142 void linkFOAs();
00143
00144 Image< PixRGB<byte> > drawMegaCombo(SimEventQueue& q) const;
00145
00146 void drawMaskOutline(Image< PixRGB<byte> >& traj,
00147 const Image<byte> mask,
00148 const PixRGB<byte>& col,
00149 const int thick,
00150 const Point2D<int>& pos,
00151 const int radius) const;
00152
00153
00154 nub::ref<SpatialMetrics> itsMetrics;
00155
00156
00157 NModelParam< PixRGB<byte> > itsColorBoring;
00158
00159 NModelParam< PixRGB<byte> > itsColorLink;
00160
00161 NModelParam< PixRGB<byte> > itsColorNormal ;
00162
00163 OModelParam<std::string> itsConfigFile;
00164
00165
00166 OModelParam<Dims> itsCropFOA;
00167 OModelParam<bool> itsDisplayAdditive;
00168 OModelParam<bool> itsDisplayBoring;
00169 OModelParam<bool> itsDisplayFOA;
00170 OModelParam<bool> itsDisplayFOALinks;
00171 OModelParam<bool> itsDisplayHighlights;
00172 OModelParam<bool> itsDisplayPatch;
00173 OModelParam<bool> itsDisplaySMmodulate;
00174 OModelParam<bool> itsDisplayTime;
00175
00176
00177 NModelParam<int> itsFOApsiz;
00178
00179 NModelParam<int> itsFOAthick;
00180
00181 NModelParam<int> itsFOAlinkThick;
00182 OModelParam<bool> itsMegaCombo;
00183 NModelParam<float> itsWarp3Dpitch;
00184 NModelParam<float> itsWarp3Dyaw;
00185 NModelParam<float> itsWarp3DpitchRate;
00186 NModelParam<float> itsWarp3DyawRate;
00187 NModelParam<float> itsWarp3DpitchMax;
00188 NModelParam<float> itsWarp3DyawMax;
00189
00190 OModelParam<bool> itsUseLargerDrawings;
00191
00192 private:
00193
00194 Image<byte> itsCumFOAmask;
00195
00196 WTAwinner itsCurrFOA;
00197
00198 Image<byte> itsCurrFOAmask;
00199
00200 SimTime itsCurrTime;
00201
00202 Dims itsDims3D;
00203
00204 ImageSet< PixRGB<byte> > itsMultiTraj;
00205
00206 WTAwinner itsPrevFOA;
00207
00208 Image< PixRGB<byte> > itsTraj;
00209
00210 Image< PixRGB<float> > itsInput;
00211
00212 Image<float> itsSalMap;
00213
00214 std::string itsOutputMotionImage;
00215
00216 std::string itsOutputSalMapImage;
00217
00218 std::string itsOutput3DImage;
00219
00220 std::string itsOutputMegaImage;
00221
00222 std::string itsOutputTrajImage;
00223
00224 std::string itsWebPageFile;
00225
00226 std::string itsStatusFile;
00227
00228 std::string itsStatusHeader;
00229
00230 std::string itsStatusFooter;
00231
00232 std::string itsChannelFile;
00233
00234 std::string itsBaseURL;
00235
00236 std::string itsBaseName;
00237
00238 std::string itsLogFile;
00239
00240 std::string itsStartTime;
00241
00242 unsigned long itsTotalFrames;
00243
00244 mutable float itsPitch3D;
00245
00246 mutable float itsYaw3D;
00247
00248 float itsMotionThreshold;
00249
00250 ushort itsBaseSizeX;
00251
00252 ushort itsBaseSizeY;
00253
00254 ushort itsComboSizeX;
00255
00256 ushort itsComboSizeY;
00257
00258 ushort its3DSizeX;
00259
00260 ushort its3DSizeY;
00261
00262 bool itsHasNewInput;
00263
00264 bool itsInit;
00265 };
00266
00267 #endif
00268
00269
00270
00271
00272
00273