build-model.C

Go to the documentation of this file.
00001 /*!@file SceneUnderstanding/build-model.C Build a 3D model */
00002 
00003 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2003   //
00004 // by the University of Southern California (USC) and the iLab at USC.  //
00005 // See http://iLab.usc.edu for information about this project.          //
00006 // //////////////////////////////////////////////////////////////////// //
00007 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00008 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00009 // in Visual Environments, and Applications'' by Christof Koch and      //
00010 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00011 // pending; application number 09/912,225 filed July 23, 2001; see      //
00012 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00013 // //////////////////////////////////////////////////////////////////// //
00014 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00015 //                                                                      //
00016 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00017 // redistribute it and/or modify it under the terms of the GNU General  //
00018 // Public License as published by the Free Software Foundation; either  //
00019 // version 2 of the License, or (at your option) any later version.     //
00020 //                                                                      //
00021 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00022 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00023 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00024 // PURPOSE.  See the GNU General Public License for more details.       //
00025 //                                                                      //
00026 // You should have received a copy of the GNU General Public License    //
00027 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00028 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00029 // Boston, MA 02111-1307 USA.                                           //
00030 // //////////////////////////////////////////////////////////////////// //
00031 // Primary maintainer for this file: Lior Elazary <elazary@usc.edu>
00032 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/plugins/SceneUnderstanding/build-model.C $
00033 // $Id: build-model.C 13051 2010-03-25 01:29:33Z lior $
00034 
00035 
00036 #include "GUI/ViewPort3D.H"
00037 #include "Util/log.H"
00038 #include "Util/WorkThreadServer.H"
00039 #include "Util/JobWithSemaphore.H"
00040 #include "Component/ModelManager.H"
00041 #include "Raster/GenericFrame.H"
00042 #include "Image/Layout.H"
00043 #include "Image/MatrixOps.H"
00044 #include "Image/DrawOps.H"
00045 #include "Image/FilterOps.H"
00046 #include "Image/MathOps.H"
00047 #include "Image/PixelsTypes.H"
00048 #include "Image/ColorOps.H"
00049 #include "Media/FrameSeries.H"
00050 #include "Transport/FrameInfo.H"
00051 #include "GUI/XWinManaged.H"
00052 #include "GUI/ImageDisplayStream.H"
00053 
00054 #include <stdlib.h>
00055 #include <math.h>
00056 #include <fcntl.h>
00057 
00058 void drawAir (void) {
00059   //int stencil;
00060 
00061   ///* Find out current stencil function. */
00062   //glGetIntegerv (GL_STENCIL_FUNC, &stencil);
00063   //
00064   ///* Describe airplane using simple concave polygons.
00065   // * See `airplane-blueprint' for details. */
00066   //glStencilFunc (stencil, 1, 0xf);
00067   glBegin (GL_POLYGON); /*nose*/
00068   glEdgeFlag (1);
00069   glVertex3f (0,-1, 10); 
00070   glEdgeFlag (0);
00071   glVertex3f (2, 0,  4);
00072   glEdgeFlag (1);
00073   glVertex3f (-2, 0,  4);  
00074   glEnd ();
00075 
00076   glEdgeFlag (1);
00077   ////glStencilFunc (stencil, 2, 0xf);
00078   //glBegin (GL_POLYGON); /*tail*/
00079   //glEdgeFlag (1);
00080   //glVertex3f ( 1, 0, -3);
00081   //glVertex3f ( 3, 0, -4);
00082   //glVertex3f ( 3, 0, -5);  
00083   //glVertex3f (-3, 0, -5);
00084   //glVertex3f (-3, 0, -4);
00085   //glEdgeFlag (0);
00086   //glVertex3f (-1, 0, -3);
00087   //glEnd ();
00088 
00089   //glBegin (GL_POLYGON); /*body 1/2*/
00090   //glEdgeFlag (0);
00091   //glVertex3f ( 2, 0,  4);
00092   //glEdgeFlag (1);
00093   //glVertex3f ( 2, 0, -.5);
00094   //glVertex3f ( 2, 0, -1);
00095   //glEdgeFlag (0);
00096   //glVertex3f ( 1, 0, -1);
00097   //glEdgeFlag (1);
00098   //glVertex3f (-1, 0, -1);
00099   //glVertex3f (-2, 0, -1);
00100   //glEdgeFlag (0);
00101   //glVertex3f (-2, 0, -.5);
00102   //glVertex3f (-2, 0,  4);
00103   //glEnd ();
00104   
00105   //glBegin (GL_POLYGON); /*body 2/2*/
00106   //glEdgeFlag (1);
00107   //glVertex3f ( 1, 0, -1);
00108   //glEdgeFlag (0);
00109   //glVertex3f ( 1, 0, -3);
00110   //glEdgeFlag (1);
00111   //glVertex3f (-1, 0, -3);
00112   //glEdgeFlag (0);
00113   //glVertex3f (-1, 0, -1);
00114   //glEnd ();
00115   //
00116   //glBegin (GL_POLYGON); /*left wingtip*/
00117   //glEdgeFlag (1);
00118   //glVertex3f ( 8, 0,  1);
00119   //glVertex3f ( 8, 0, -1);
00120   //glVertex3f ( 5, 0, -1);
00121   //glEdgeFlag (0);
00122   //glVertex3f ( 5, 0, -.5);
00123   //glEnd ();
00124   //
00125   //glBegin (GL_POLYGON); /*left wing*/
00126   //glEdgeFlag (1);
00127   //glVertex3f ( 2, 0,  4);
00128   //glEdgeFlag (0);
00129   //glVertex3f ( 8, 0,  1);
00130   //glEdgeFlag (1);
00131   //glVertex3f ( 5, 0, -.5);
00132   //glEdgeFlag (0);
00133   //glVertex3f ( 2, 0, -.5);
00134   //glEnd ();
00135   //
00136   //glBegin (GL_POLYGON); /*right wingtip*/
00137   //glEdgeFlag (1);
00138   //glVertex3f (-5, 0, -.5);
00139   //glVertex3f (-5, 0, -1);
00140   //glVertex3f (-8, 0, -1);
00141   //glEdgeFlag (0);
00142   //glVertex3f (-8, 0,  1);
00143   //glEnd ();
00144 
00145   //glBegin (GL_POLYGON); /*right wing*/
00146   //glEdgeFlag (0);
00147   //glVertex3f (-2, 0,  4);
00148   //glEdgeFlag (1);
00149   //glVertex3f (-2, 0, -.5);
00150   //glEdgeFlag (0);
00151   //glVertex3f (-5, 0, -.5);
00152   //glEdgeFlag (1);
00153   //glVertex3f (-8, 0,  1);
00154   //glEnd ();
00155   //
00156   ///* Create rotated coordinate system for left flap. */
00157   //glPushMatrix ();
00158   //glTranslatef (2, 0, -.5);
00159   //glRotatef (0, 1, 0, 0);
00160   //
00161   ////glStencilFunc (stencil, 3, 0xf);
00162   //glBegin (GL_POLYGON); /*left flap*/
00163   //glEdgeFlag (1);
00164   //glVertex3f ( 3, 0,  0);
00165   //glVertex3f ( 0, 0,  0);
00166   //glVertex3f ( 0, 0, -1);
00167   //glVertex3f ( 3, 0, -1);
00168   //glEnd ();
00169   //glPopMatrix ();
00170   //
00171   ///* Create rotated coordinate system for right flap. */
00172   //glPushMatrix ();
00173   //glTranslatef ( -2, 0, -.5);
00174   //glRotatef (0, 1, 0, 0);
00175   //
00176   ////glStencilFunc (stencil, 4, 0xf);
00177   //glBegin (GL_POLYGON); /* right flap */
00178   //glEdgeFlag (1);
00179   //glVertex3f (-3, 0,  0);
00180   //glVertex3f ( 0, 0,  0);
00181   //glVertex3f ( 0, 0, -1);
00182   //glVertex3f (-3, 0, -1);
00183   //glEnd ();
00184   //glPopMatrix ();
00185 
00186   ///* Create coordinate system for tail wing. */
00187   //glPushMatrix ();
00188   //glTranslatef (0, 0, -4.5);
00189 
00190   ////glStencilFunc (stencil, 5, 0xf); /*tail wing*/
00191   //glBegin (GL_POLYGON);
00192   //glEdgeFlag (0);
00193   //glVertex3f (0, 0,   0);
00194   //glEdgeFlag (1);
00195   //glVertex3f (0, 1,   1.5);
00196   //glVertex3f (0, 0,   3);
00197   //glEnd ();
00198   //glBegin (GL_POLYGON);
00199   //glEdgeFlag (1);
00200   //glVertex3f (0, 0,    0);
00201   //glEdgeFlag (0);
00202   //glVertex3f (0, 2.5,  0);
00203   //glEdgeFlag (1);
00204   //glVertex3f (0, 3,   .5);
00205   //glEdgeFlag (0);
00206   //glVertex3f (0, 1,   1.5);
00207   //glEnd ();
00208   //glBegin (GL_POLYGON);
00209   //glEdgeFlag (1);
00210   //glVertex3f (0, 2.5,  0);
00211   //glVertex3f (0, 2.5, -.5);
00212   //glVertex3f (0, 3,   -.5);
00213   //glEdgeFlag (0);
00214   //glVertex3f (0, 3,   .5);
00215   //glEnd ();
00216 
00217   ///* Create coordinate system for rudder. */
00218   //glRotatef (0, 0, 1, 0);
00219   //
00220   ////glStencilFunc (stencil, 6, 0xf);
00221   //glBegin (GL_POLYGON); /*rudder*/
00222   //glEdgeFlag (1);
00223   //glVertex3f (0, 0,    0);
00224   //glVertex3f (0, 2.5,  0);
00225   //glVertex3f (0, 2.5, -1);
00226   //glVertex3f (0, 0,   -1);
00227   //glEnd ();
00228   //glPopMatrix ();
00229   //
00230   ////glStencilFunc (stencil, 7, 0xf);
00231   //glBegin (GL_POLYGON); /*cockpit right front*/
00232   //glEdgeFlag (1);
00233   //glVertex3f ( 0, -1, 10);
00234   //glVertex3f (-2,  0,  4);
00235   //glVertex3f ( 0,  1.5,5);
00236   //glEnd ();
00237   ////glStencilFunc (stencil, 8, 0xf);
00238   //glBegin (GL_POLYGON); /*cockpit left front*/
00239   //glEdgeFlag (1);
00240   //glVertex3f ( 0, -1, 10);
00241   //glVertex3f ( 0,  1.5, 5);
00242   //glVertex3f ( 2,  0,   4);
00243   //glEnd ();
00244   ////glStencilFunc (stencil, 9, 0xf);
00245   //glBegin (GL_POLYGON); /*cockpit left back*/
00246   //glEdgeFlag (1);
00247   //glVertex3f ( 0,  1.5, 5);
00248   //glVertex3f ( 2,  0,   4);
00249   //glVertex3f ( 1,  0,  -1);
00250   //glEnd ();
00251   ////glStencilFunc (stencil, 10, 0xf);
00252   //glBegin (GL_POLYGON); /*cockpit right back*/
00253   //glEdgeFlag (1);
00254   //glVertex3f (-2,  0,   4);
00255   //glVertex3f ( 0,  1.5, 5);
00256   //glVertex3f (-1,  0,  -1);
00257   //glEnd ();
00258   ////glStencilFunc (stencil, 11, 0xf);
00259   //glBegin (GL_POLYGON); /*cocpit top*/
00260   //glEdgeFlag (1);
00261   //glVertex3f ( 0,  1.5, 5);
00262   //glEdgeFlag (0);
00263   //glVertex3f (-1,  0,  -1);
00264   //glEdgeFlag (1);
00265   //glVertex3f ( 1,  0,  -1);
00266   //glEnd ();
00267 }
00268 
00269 void tridisplay()
00270 // this function is used to display the polygon using triangles
00271 // it is not efficient or neat but it is necessary because the
00272 // assignment asks for a polygon drawn with triangles and without
00273 // diagonals
00274 //
00275 // this function produces the same result as redisplay() with GL_LINE_LOOP
00276 
00277 {
00278   glClear(GL_COLOR_BUFFER_BIT); 
00279 
00280   glBegin(GL_TRIANGLES);
00281   
00282   glColor3f(0.3,0.3,0.3);//navy
00283   glVertex2f(-0.5,0.0);
00284   glColor3f(0.0,0.0,1.0);//blue
00285   glVertex2f(0.0,-1.0);
00286   glEdgeFlag(GL_FALSE);
00287   glVertex2f(0.5,0.0);
00288   
00289   glEdgeFlag(GL_TRUE);
00290   glVertex2f(0.5,0.0);
00291   glColor3f(0.0,1.0,0.0);//green
00292   glVertex2f(0.497,0.052);
00293   glEdgeFlag(GL_FALSE);  
00294   glVertex2f(0.489,0.104);
00295 
00296   glEdgeFlag(GL_TRUE);
00297   glVertex2f(0.489,0.104);
00298   glVertex2f(0.476,0.155);
00299   glEdgeFlag(GL_FALSE);
00300   glVertex2f(0.457,0.203);
00301 
00302   glEdgeFlag(GL_TRUE);
00303   glVertex2f(0.457,0.203);
00304   glVertex2f(0.433,0.25);
00305   glEdgeFlag(GL_FALSE);
00306   glVertex2f(0.405,0.294);
00307 
00308   glEdgeFlag(GL_TRUE);
00309   glVertex2f(0.405,0.294);
00310   glVertex2f(0.372,0.335);
00311   glColor3f(1.0,0.0,0.0);//red
00312   glEdgeFlag(GL_FALSE);
00313   glVertex2f(0.335,0.372);
00314 
00315   glEdgeFlag(GL_TRUE);
00316   glVertex2f(0.335,0.372);
00317   glVertex2f(0.294,0.405);
00318   glEdgeFlag(GL_FALSE);
00319   glVertex2f(0.25,0.433);
00320 
00321   glEdgeFlag(GL_TRUE);
00322   glVertex2f(0.25,0.433);
00323   glVertex2f(0.203,0.457);
00324   glEdgeFlag(GL_FALSE);
00325   glVertex2f(0.155,0.476);
00326 
00327   glEdgeFlag(GL_TRUE);
00328   glVertex2f(0.155,0.476);
00329   glVertex2f(0.104,0.489);
00330   glEdgeFlag(GL_FALSE);
00331   glVertex2f(0.052,0.497);
00332 
00333   glEdgeFlag(GL_TRUE);
00334   glVertex2f(0.052,0.497);
00335   glVertex2f(0.0,0.5);
00336   glColor3f(0.5,0.0,0.5);//purple
00337   glEdgeFlag(GL_FALSE);
00338   glVertex2f(-0.052,0.497);
00339 
00340   glEdgeFlag(GL_TRUE);
00341   glVertex2f(-0.052,0.497);
00342   glVertex2f(-0.104,0.489);
00343   glEdgeFlag(GL_FALSE);
00344   glVertex2f(-0.155,0.476);
00345 
00346   glEdgeFlag(GL_TRUE);
00347   glVertex2f(-0.155,0.476);
00348   glVertex2f(-0.203,0.457);
00349   glEdgeFlag(GL_FALSE);
00350   glVertex2f(-0.25,0.433);
00351 
00352   glEdgeFlag(GL_TRUE);
00353   glVertex2f(-0.25,0.433);
00354   glVertex2f(-0.294,0.405);
00355   glEdgeFlag(GL_FALSE);
00356   glVertex2f(-0.335,0.372);
00357 
00358   glEdgeFlag(GL_TRUE);
00359   glVertex2f(-0.335,0.372);
00360   glVertex2f(-0.372,0.335);
00361   glEdgeFlag(GL_FALSE);
00362   glVertex2f(-0.404,0.294);
00363 
00364   glEdgeFlag(GL_TRUE);
00365   glVertex2f(-0.404,0.294);
00366   glVertex2f(-0.433,0.25);
00367   glEdgeFlag(GL_FALSE);
00368   glVertex2f(-0.457,0.203);
00369 
00370   glEdgeFlag(GL_TRUE);
00371   glVertex2f(-0.457,0.203);
00372   glVertex2f(-0.476,0.155);
00373   glEdgeFlag(GL_FALSE);
00374   glVertex2f(-0.489,0.104);
00375 
00376   glEdgeFlag(GL_TRUE);
00377   glVertex2f(-0.489,0.104);
00378   glVertex2f(-0.497,0.052);
00379   glEdgeFlag(GL_FALSE);
00380   glVertex2f(-0.5,0.0);
00381   glEdgeFlag(GL_TRUE);
00382   
00383   glEnd();
00384   
00385   glFlush();
00386 }
00387 
00388 
00389 Point2D<int> getMouseClick(nub::ref<OutputFrameSeries> &ofs)
00390 {
00391   const nub::soft_ref<ImageDisplayStream> ids =
00392     ofs->findFrameDestType<ImageDisplayStream>();
00393 
00394   const rutz::shared_ptr<XWinManaged> uiwin =
00395     ids.is_valid()
00396     ? ids->getWindow("InputEdges")
00397     : rutz::shared_ptr<XWinManaged>();
00398 
00399   if (uiwin.is_valid())
00400     return uiwin->getLastMouseClick();
00401   else
00402     return Point2D<int>(-1,-1);
00403 }
00404 
00405 int getKey(nub::ref<OutputFrameSeries> &ofs)
00406 {
00407   const nub::soft_ref<ImageDisplayStream> ids =
00408     ofs->findFrameDestType<ImageDisplayStream>();
00409 
00410   const rutz::shared_ptr<XWinManaged> uiwin =
00411     ids.is_valid()
00412     ? ids->getWindow("InputEdges")
00413     : rutz::shared_ptr<XWinManaged>();
00414   if (uiwin.is_valid())
00415     return uiwin->getLastKeyPress();
00416   else
00417     return -1;
00418 }
00419 
00420 void saveToDisk(const std::vector<Point2D<float> >& contour, const char* filename)
00421 {
00422   int fd;
00423 
00424   if ((fd = creat(filename, 0644)) == -1)
00425     LFATAL("Can not open %s for saving\n", filename);
00426 
00427   int ret;
00428   size_t size = contour.size();
00429   ret = write(fd, (char *) &size, sizeof(size_t));
00430 
00431   for(uint i=0; i<contour.size(); i++)
00432     ret = write(fd, (char *) &contour[i], sizeof(Point2D<float>));
00433 
00434   close(fd);
00435 }
00436 
00437 std::vector<Point2D<float> > readFromDisk(const char* filename)
00438 {
00439 
00440   int fd;
00441   if ((fd = open(filename, 0, 0644)) == -1)
00442     return std::vector<Point2D<float> >();
00443 
00444   int ret;
00445   printf("Reading from %s\n", filename);
00446 
00447   //Read the number of entries in the db
00448   size_t size;
00449   ret = read(fd, (char *) &size, sizeof(size));
00450 
00451   std::vector<Point2D<float> > contour(size);
00452   for(uint i=0; i<size; i++)
00453     ret = read(fd, (char *) &contour[i], sizeof(Point2D<float>));
00454 
00455   close(fd);
00456 
00457   return contour;
00458 }
00459 
00460 
00461 
00462 
00463 
00464 int main(int argc, char *argv[]){
00465 
00466   ModelManager manager("Test Viewport");
00467 
00468   nub::ref<OutputFrameSeries> ofs(new OutputFrameSeries(manager));
00469   manager.addSubComponent(ofs);
00470 
00471   nub::ref<InputFrameSeries> ifs(new InputFrameSeries(manager));
00472   manager.addSubComponent(ifs);
00473 
00474 
00475   // Parse command-line:
00476   if (manager.parseCommandLine(argc, argv, "", 0, 0) == false) return(1);
00477   // let's get all our ModelComponent instances started:
00478   manager.start();
00479 
00480   ifs->startStream();
00481 
00482   ViewPort3D vp(320,240); //, true, false, true);
00483   //vp.setWireframeMode(true);
00484   //vp.setLightsMode(false);
00485   //vp.setFeedbackMode(true);
00486 
00487   std::vector<Point2D<int> > polygon;
00488   std::vector<Point2D<float> > contour;
00489   std::vector<Point2D<float> > bodyContour = readFromDisk("body.dat");
00490   std::vector<Point2D<float> > roll1Contour = readFromDisk("roll1.dat");
00491   std::vector<Point2D<float> > roll2Contour = readFromDisk("roll2.dat");
00492 
00493   //vp.setCamera(Point3D<float>(0,150,354), Point3D<float>(20,00,0));
00494   //double trans[3][4] = {
00495   //  {0.999113, 0.007695, 0.041394, 6.445829},
00496   //  {0.006331, -0.999436, 0.032987, -4.874230},
00497   //  {0.041625, -0.032696, -0.998598, 182.532963}};
00498   //vp.setCamera(trans);
00499   float x = -130;
00500   while(1)
00501   {
00502     vp.setCamera(Point3D<float>(0,0,0), Point3D<float>(0,0,0));
00503     Image< PixRGB<byte> > inputImg;
00504     const FrameState is = ifs->updateNext();
00505     if (is == FRAME_COMPLETE)
00506       break;
00507     GenericFrame input = ifs->readFrame();
00508     if (!input.initialized())
00509       break;
00510     inputImg = input.asRgb();
00511 
00512     int key = getKey(ofs);
00513     if (key != -1)
00514     {
00515       LINFO("key %i", key);
00516       switch(key)
00517       {
00518         case 98: //up
00519           x += 1;
00520           break;
00521         case 104: //down
00522           x -= 1;
00523           break;
00524         case 39: //s
00525           saveToDisk(contour, "body.dat");
00526           break;
00527       }
00528       LINFO("X=%f\n", x);
00529     }
00530 
00531     vp.initFrame();
00532 
00533     //vp.drawGround(Point2D<float>(1000,1000),
00534     //    PixRGB<byte>(255,255,255));
00535 
00536     std::vector<Point2D<float> > triangles = vp.triangulate(contour);
00537 
00538     //vp.drawBox(
00539     //    Point3D<float>(0,0,x),
00540     //    Point3D<float>(0,0,0),
00541     //    Point3D<float>(41.5, 41.5, 0.001),
00542     //    PixRGB<byte>(255,255,255));
00543 
00544     
00545     //glTranslatef(0.0F, 0.0F,-130);
00546     //glBegin(GL_TRIANGLES);
00547     //for(uint i=0; i<triangles.size(); i++)
00548     //{
00549     //  glVertex3f(triangles[i].i, triangles[i].j,0.0f);                        // Top Right Of The Quad (Top)
00550     //}
00551     //glEnd();
00552 
00553     glTranslatef(0.0F, 0,-130-25.0F);
00554     glRotatef(x, 0,1,0);
00555     if (true)
00556     {
00557       vp.drawExtrudedContour(bodyContour,
00558           Point3D<float>(0,0,0),
00559           Point3D<float>(0,0,0),
00560           50.0F,
00561           PixRGB<byte>(256,256,0));
00562 
00563     }
00564 
00565     Point2D<int> loc = getMouseClick(ofs);
00566     if (loc.isValid())
00567     {
00568       polygon.push_back(loc);
00569 
00570       float x = loc.i - (inputImg.getWidth()/2);
00571       float y = -1*(loc.j - (inputImg.getHeight()/2));
00572       LINFO("Click at %i %i (%f,%f)\n", loc.i, loc.j, x, y);
00573       contour.push_back(Point2D<float>(x/2.72289,y/2.72289));
00574     }
00575 
00576 
00577     Image<PixRGB<byte> > img = flipVertic(vp.getFrame()) + inputImg;
00578     //Image<PixRGB<byte> > img = inputImg;
00579 
00580     //std::vector<ViewPort3D::Line> lines = vp.getFrameLines();
00581     //for(uint i=0; i<lines.size(); i++)
00582     //{
00583     //  LINFO("Line %f %f  %f %f", 
00584     //      lines[i].p1.i, lines[i].p1.j, 
00585     //      lines[i].p2.i, lines[i].p2.j);
00586     //}
00587 
00588     Image<PixRGB<byte> > renderImg = flipVertic(vp.getFrame());
00589     //img = renderImg;
00590     for(uint i=0; i<img.size(); i++)
00591       if (renderImg[i] != PixRGB<byte>(0,0,0))
00592         img[i] = renderImg[i];
00593 
00594     ofs->writeRGB(img, "ViewPort3D", FrameInfo("ViewPort3D", SRC_POS));
00595     ofs->writeRGB(inputImg, "Input", FrameInfo("Input", SRC_POS));
00596 
00597     Image<float> mag, ori, lum;
00598     lum = luminance(renderImg);
00599     gradientSobel(lum, mag, ori);
00600     inplaceNormalize(mag, 0.0F, 255.0F);
00601     ofs->writeRGB(toRGB(mag), "RenderEdges", FrameInfo("RenderEdges", SRC_POS));
00602 
00603     lum = luminance(inputImg);
00604     gradientSobel(lum, mag, ori);
00605     inplaceNormalize(mag, 0.0F, 255.0F);
00606     ofs->writeRGB(toRGB(mag), "InputEdges", FrameInfo("InputEdges", SRC_POS));
00607 
00608 
00609     usleep(10000);
00610   }
00611 
00612 
00613   exit(0);
00614 
00615 }
00616 
00617 
00618 
Generated on Sun May 8 08:41:08 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3