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 #include "Component/ModelManager.H"
00039 #include "Component/OptionManager.H"
00040 #include "Controllers/PID.H"
00041 #include "Corba/Objects/CMap.H"
00042 #include "Devices/FrameGrabberConfigurator.H"
00043 #include "Devices/sc8000.H"
00044 #include "GUI/XWinManaged.H"
00045 #include "Image/ColorOps.H"
00046 #include "Image/CutPaste.H"
00047 #include "Image/DrawOps.H"
00048 #include "Image/Image.H"
00049 #include "Image/MathOps.H"
00050 #include "Image/Pixels.H"
00051 #include "Image/ShapeOps.H"
00052 #include "Image/Transforms.H"
00053 #include "Image/fancynorm.H"
00054 #include "Neuro/SaliencyMap.H"
00055 #include "Neuro/VisualCortex.H"
00056 #include "Neuro/WTAwinner.H"
00057 #include "Neuro/WinnerTakeAll.H"
00058 #include "RCBot/Motion/MotionEnergy.H"
00059 #include "Raster/Raster.H"
00060 #include "Transport/FrameIstream.H"
00061 #include "Util/Timer.H"
00062 #include "Util/Types.H"
00063 #include "Util/log.H"
00064 #include <math.h>
00065
00066 #define UP_KEY 98
00067 #define DOWN_KEY 104
00068 #define LEFT_KEY 100
00069 #define RIGHT_KEY 102
00070
00071 XWinManaged window(Dims(256, 256), -1, -1, "Test Output 1");
00072 XWinManaged window1(Dims(256, 256), -1, -1, "S Map");
00073 XWinManaged window2(Dims(256, 256), -1, -1, "S Map");
00074
00075 #define sml 0
00076 #define delta_min 3
00077 #define delta_max 4
00078 #define level_min 0
00079 #define level_max 2
00080 #define maxdepth (level_max + delta_max + 1)
00081 #define normtyp (VCXNORM_MAXNORM)
00082
00083
00084 int main(int argc, char **argv)
00085 {
00086 MYLOGVERB = LOG_DEBUG;
00087
00088 CORBA::ORB_ptr orb = CORBA::ORB_init(argc,argv,"omniORB4");
00089
00090
00091 ModelManager manager("Track Features");
00092
00093
00094 nub::soft_ref<FrameGrabberConfigurator>
00095 gbc(new FrameGrabberConfigurator(manager));
00096 manager.addSubComponent(gbc);
00097
00098
00099 if (manager.parseCommandLine(argc, (const char **)argv, "", 0, 0) == false) return(1);
00100
00101
00102 nub::soft_ref<FrameIstream> gb = gbc->getFrameGrabber();
00103 if (gb.get() == NULL)
00104 LFATAL("You need to select a frame grabber type via the "
00105 "--fg-type=XX command-line option for this program "
00106 "to be useful -- ABORT");
00107
00108
00109
00110 manager.start();
00111
00112
00113
00114 gb->startStream();
00115
00116
00117
00118 int key = 0;
00119
00120 double time = 0;
00121
00122
00123 int fr = 0;
00124 Image<float> cmap[8];
00125
00126 CMapThreads cmap_th(orb);
00127
00128 int cmapFrames[8];
00129 for(int i=0; i<8; i++)
00130 cmapFrames[i]=0;
00131
00132 std::vector<float> bias[8];
00133 while(key != 24){
00134
00135
00136
00137 Image< PixRGB<byte> > ima = gb->readRGB();
00138
00139
00140 Image<byte> lum = luminance(ima);
00141 Image<byte> rImg, gImg, bImg, yImg;
00142 getRGBY(ima, rImg, gImg, bImg, yImg, (byte)25);
00143
00144
00145 Point2D<int> location = window.getLastMouseClick();
00146 if (location.isValid()){
00147 LINFO("Click at at %i %i", location.i, location.j);
00148 Dims WindowDims = window.getDims();
00149
00150 float newi = (float)location.i * (float)ima.getWidth()/(float)WindowDims.w();
00151 float newj = (float)location.j * (float)ima.getHeight()/(float)WindowDims.h();
00152 location.i = (int)newi;
00153 location.j = (int)newj;
00154
00155 LINFO("Getting bias from at at %i %i", location.i, location.j);
00156 bias[0] = cmap_th.getBias(cmap[0], lum, Gaussian5, 0.0, 1.0, cmapFrames[0], location);
00157 bias[1] = cmap_th.getBias(cmap[1], rImg, Gaussian5, 0.0, 1.0, cmapFrames[1], location);
00158 bias[2] = cmap_th.getBias(cmap[2], gImg, Gaussian5, 0.0, 1.0, cmapFrames[2], location);
00159 bias[3] = cmap_th.getBias(cmap[3], bImg, Gaussian5, 0.0, 1.0, cmapFrames[3], location);
00160
00161 bias[4] = cmap_th.getBias(cmap[4], lum, Oriented5, 0.0, 1.0, cmapFrames[4], location);
00162 bias[5] = cmap_th.getBias(cmap[5], lum, Oriented5, 45.0, 1.0, cmapFrames[5], location);
00163 bias[6] = cmap_th.getBias(cmap[6], lum, Oriented5, 90.0, 1.0, cmapFrames[6], location);
00164 bias[7] = cmap_th.getBias(cmap[7], lum, Oriented5, 135.0, 1.0, cmapFrames[7], location);
00165
00166 }
00167
00168
00169
00170 LINFO("Bias size %"ZU, bias[0].size());
00171 if (bias[0].size() == 6){
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186 }
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201 Image<float> sminput;
00202
00203 for (int i=0; i< 8; i++){
00204 if (cmap[i].initialized()){
00205 if (sminput.initialized())
00206 sminput += cmap[i];
00207 else
00208 sminput = cmap[i];
00209 }
00210 }
00211
00212
00213 LINFO("Frames %i: %i %i %i %i %i %i %i %i\n",
00214 fr, cmapFrames[0], cmapFrames[1],cmapFrames[2],
00215 cmapFrames[3],cmapFrames[4],cmapFrames[5],
00216 cmapFrames[6],cmapFrames[7]);
00217
00218 Point2D<int> winner(-1, -1); float maxval;
00219 if (sminput.initialized()){
00220 findMax(sminput, winner, maxval);
00221 LINFO("Max %f at %i %i\n", maxval, winner.i, winner.j);
00222 if (winner.isValid())
00223 drawDisk(ima, winner, 10, PixRGB<byte>(255, 0, 0));
00224
00225 window1.drawImage(rescale(sminput, 256, 256));
00226 }
00227
00228
00229 window.drawImage(rescale(ima, 256, 256));
00230
00231 time += 0.1;
00232 fr++;
00233 }
00234
00235
00236
00237
00238 manager.stop();
00239 return 0;
00240 }
00241
00242
00243
00244
00245
00246
00247