test-BeoMap.C

Go to the documentation of this file.
00001 /*!@file BeoSub/test-BeoMap.C Test frame grabbing and X display */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00005 // 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/BeoSub/test-BeoMap.C $
00035 // $Id: test-BeoMap.C 9412 2008-03-10 23:10:15Z farhan $
00036 //
00037 #include "BeoSub/BeoMap.H"
00038 #include "Component/ModelManager.H"
00039 #include "Devices/FrameGrabberConfigurator.H"
00040 #include "GUI/XWindow.H"
00041 #include "Image/Image.H"
00042 #include "Image/ImageSet.H"
00043 #include "Image/Pixels.H"
00044 #include "Image/ShapeOps.H"
00045 #include "Raster/Raster.H"
00046 #include "SIFT/VisualObject.H"
00047 #include "SIFT/VisualObjectMatch.H"
00048 #include "Transport/FrameIstream.H"
00049 #include "Util/Timer.H"
00050 #include "Util/Types.H"
00051 #include "Util/log.H"
00052 
00053 
00054 #include <cstdio>
00055 #include <cstdlib>
00056 #include <cstring>
00057 #include <iostream>
00058 
00059 #define SCALE 2
00060 #define RUNTIME 80
00061 
00062 #define CUT_THRESHOLD 1.2
00063 
00064 // these are gains to decide cutting positions.
00065 //#define MAP_CUT_CONST_RIGHT 1.2
00066 //#define MAP_CUT_CONST_LEFT 0.8
00067 
00068 
00069 #define SIZE_THRESH 200
00070 
00071 
00072 void makePanorama(const char* nam1);
00073 
00074 //#define NAVG 20
00075 
00076 /*! This simple executable tests video frame grabbing through the
00077   video4linux driver (see V4Lgrabber.H) or the IEEE1394 (firewire)
00078   grabber (see IEEE1394grabber.H). Selection of the grabber type is
00079   made via the --fg-type=XX command-line option. */
00080 
00081 
00082 int globalcounter(0);
00083 int pw(0);
00084 int ph(0);
00085 
00086 Image< PixRGB<byte> > im3;
00087 bool cut = false;
00088 //
00089 // this structure is for putting the coordinates
00090 // of an input image stitched within a map.
00091 //
00092 /*
00093 typedef struct{
00094   int leftedge;
00095   int rightedge;
00096   int upperedge;
00097   int loweredge;
00098 }mapedge;
00099 
00100 mapedge medge;
00101 */
00102 int main(const int argc, const char **argv)
00103 {
00104 
00105   // instantiate a model manager:
00106   ModelManager manager("Frame Grabber Tester");
00107 
00108   // Instantiate our various ModelComponents:
00109   nub::soft_ref<FrameGrabberConfigurator>
00110     gbc(new FrameGrabberConfigurator(manager));
00111   manager.addSubComponent(gbc);
00112 
00113   // make an object for window frame.
00114   XWindow win;
00115   XWindow win2(Dims(2000,2000));
00116 
00117 
00118   BeoMap bm(1.2,200,true);
00119 
00120 
00121 
00122   // let's get all our ModelComponent instances started:
00123   manager.start();
00124 
00125   Timer tim;// uint64 t[NAVG]; int frame = 0;
00126 
00127   int count = 0;
00128   char* buf = new char[9999];
00129   char* buf2 = new char[9999];
00130 
00131   //ImageSet< PixRGB<byte> > images;
00132   // int input(0);
00133   bool first=true;
00134   Timer tim2(1000000);
00135 
00136   while(1) {
00137 
00138     count++;
00139     tim.reset();
00140 
00141     //sprintf(buf, "./images/inputframe%d.png", 1+count*SCALE);
00142     sprintf(buf, "/lab/beobot/take/saliency/images/frame%d.png", 441+count*SCALE);
00143     //sprintf(buf, "./images/frame%d.png", 251+count*SCALE);
00144 
00145 
00146 
00147     Image< PixRGB<byte> > ima= Raster::ReadRGB(buf);;
00148 
00149     if(first) {
00150       Raster::WriteRGB(ima, "./resultimg/result.png");
00151       first=false;
00152     }
00153     else {
00154       //makePanorama(buf);
00155       bm.makePanorama(buf, "./resultimg/result.png");
00156     }
00157     win.drawImage(ima);
00158     sprintf(buf2, "./resultimg/result.png");
00159     Image< PixRGB<byte> > ima2= Raster::ReadRGB(buf2);;
00160 
00161 
00162     win2.drawImage(ima2);
00163 
00164     //sleep(1);
00165 
00166     if(count > RUNTIME)break;
00167   }
00168   uint64 t = tim2.get();
00169   LINFO("The total run time is  %.3fms", float(t) * 0.001F);
00170 
00171 
00172     // stop all our ModelComponents
00173   manager.stop();
00174 
00175   return 0;
00176 }
00177 
00178 
00179 /*
00180 function that that given the current position in the map and target position, tells you where to turn
00181 
00182 */
00183 void findTargetDir(Point2D<int> current, Point2D<int> previous, Point2D<int> target)
00184 {
00185   //check if the target falls on the same line as the submarine
00186   if(current.i == previous.i)//vertical line
00187   {
00188     if(target.i == current.i) //they fall on the same line
00189       {
00190         if(current.j > previous.j && target.j > current.j)
00191           {
00192             printf("target is straight ahead\n");
00193           }
00194         else
00195           {
00196             printf("target is behind\n");
00197           }
00198       }
00199     else
00200       {
00201         if((current.j > previous.j && target.i < current.i)|| (current.j < previous.j && target.i > current.i))
00202           {
00203             printf("target is on the right\n");
00204           }
00205         else if((current.j > previous.j && target.i > current.i)||(current.j < previous.j && target.i < current.i))
00206           {
00207             printf("target is on the left\n");
00208           }
00209 
00210       }
00211 
00212   }
00213   else
00214     {
00215       //get the slope
00216       float slope = (current.j-previous.j)/(current.i - previous.i);
00217       float slopeTarget =  (current.j-target.j)/(current.i - target.i);
00218       if(slope == slopeTarget) // target fall on the same line
00219         {
00220           if((target.i - previous.i)/(current.i-previous.i) < 1 )
00221             {
00222               printf("target is behind\n");
00223 
00224             }
00225           else
00226             {
00227               printf("target is straight ahead\n");
00228 
00229             }
00230 
00231         }
00232       else
00233         {
00234 
00235 
00236         }
00237 
00238 
00239     }
00240 
00241 
00242 
00243 }
00244 
00245 
00246 
00247 // ######################################################################
00248 /* So things look consistent in everyone's emacs... */
00249 /* Local Variables: */
00250 /* indent-tabs-mode: nil */
00251 /* End: */
00252 
00253 
00254 /*void makePanorama(const char* nam1)
00255 {
00256 
00257 
00258   ImageSet< PixRGB<byte> > images;
00259 
00260 
00261   Image< PixRGB<byte> > im1 = Raster::ReadRGB(nam1);
00262   images.push_back(im1);
00263   rutz::shared_ptr<VisualObject> vo1(new VisualObject(nam1, "", im1));
00264   LINFO("keypoint extractions completed for input image (%d keypoints)", vo1->numKeypoints());
00265 
00266 
00267   std::vector<SIFTaffine> affines;
00268   SIFTaffine comboaff; // default constructor is identity
00269   affines.push_back(comboaff);
00270   int minx = 0, miny = 0, maxx = im1.getWidth()-1, maxy = im1.getHeight()-1;
00271   bool modMinX = false,modMaxX = false,modMinY = false,modMaxY = false;
00272   for (int i = 1; i < 2; i ++)
00273   {
00274       const char *nam2 = "./resultimg/result.png";
00275       Image< PixRGB<byte> > im2 = Raster::ReadRGB(nam2);
00276       images.push_back(im2);
00277       // LINFO("just before initializing im2");
00278       rutz::shared_ptr<VisualObject> vo2;
00279       //  LINFO("asd");
00280       LINFO("Pass #%d\n", globalcounter);
00281 
00282 
00283       if(!cut){
00284          rutz::shared_ptr<VisualObject> votemp( new VisualObject(nam2, "", im2));
00285         vo2 = votemp;
00286       }
00287       else{
00288         rutz::shared_ptr<VisualObject> votemp( new VisualObject(nam2, "", im3));
00289         vo2 = votemp;
00290       }
00291 
00292 
00293 
00294 
00295 
00296       LINFO("keypoint extractions completed for map (%d keypoints)", vo2->numKeypoints());
00297 
00298 
00299        maxx = im2.getWidth()-1, maxy = im2.getHeight()-1;
00300       // compute the matching keypoints:
00301       //Timer tim(1000000);
00302       VisualObjectMatch match(vo1, vo2, VOMA_SIMPLE);
00303       LINFO("%d keypoints matched at pass %d", match.size(), globalcounter);
00304 
00305 
00306       //uint64 t = tim.get();
00307 
00308       //      LINFO("Found %u matches between %s and %s in %.3fms",
00309       //           match.size(), nam1, nam2, float(t) * 0.001F);
00310 
00311       // let's prune the matches:
00312       //uint np =
00313       match.prune();
00314       //LINFO("Pruned %u outlier matches.", np);
00315 
00316       // show our final affine transform:
00317       SIFTaffine aff = match.getSIFTaffine();
00318       std::cerr<<aff;
00319 
00320       // compose with the previous affines and store:
00321       comboaff = comboaff.compose(aff);
00322       affines.push_back(comboaff);
00323 
00324       // update panorama boundaries, using the inverse combo aff to
00325       // find the locations of the four corners of our image in the
00326       // panorama:
00327       if (comboaff.isInversible() == false) LFATAL("Oooops, singular affine!");
00328       SIFTaffine iaff = comboaff.inverse();
00329       const float ww = float(im2.getWidth() - 1);
00330       const float hh = float(im2.getHeight() - 1);
00331       float xx, yy; int x, y;
00332 
00333       iaff.transform(0.0F, 0.0F, xx, yy); x = int(xx); y = int(yy);
00334       if (x < minx) {minx = x; modMinX = true;}
00335       if (x > maxx) {maxx = x; modMaxX = true;}
00336       if (y < miny) {miny = y; modMinY = true;}
00337       if (y > maxy) {maxy = y; modMaxY = true;}
00338 
00339       iaff.transform(ww, 0.0F, xx, yy); x = int(xx); y = int(yy);
00340       if (x < minx) {minx = x; modMinX = true;}
00341       if (x > maxx) {maxx = x; modMaxX = true;}
00342       if (y < miny) {miny = y; modMinY = true;}
00343       if (y > maxy) {maxy = y; modMaxY = true;}
00344 
00345 
00346       iaff.transform(0.0F, hh, xx, yy); x = int(xx); y = int(yy);
00347       if (x < minx) {minx = x; modMinX = true;}
00348       if (x > maxx) {maxx = x; modMaxX = true;}
00349       if (y < miny) {miny = y; modMinY = true;}
00350       if (y > maxy) {maxy = y; modMaxY = true;}
00351 
00352 
00353       iaff.transform(ww, hh, xx, yy); x = int(xx); y = int(yy);
00354       if (x < minx) {minx = x; modMinX = true;}
00355       if (x > maxx) {maxx = x; modMaxX = true;}
00356       if (y < miny) {miny = y; modMinY = true;}
00357       if (y > maxy) {maxy = y; modMaxY = true;}
00358 
00359       //LINFO("modMinX %d, modMaxX %d, modMinY %d, modMaxY %d",modMinX, modMaxX, modMinY, modMaxY);
00360       // get ready for next pair:
00361       im1 = im2; vo1 = vo2; nam1 = nam2;
00362     }
00363 
00364   // all right, allocate the panorama:
00365   //LINFO("x = [%d .. %d], y = [%d .. %d]", minx, maxx, miny, maxy);
00366   int w = maxx - minx + 1, h = maxy - miny + 1;
00367 
00368 
00369   if(globalcounter==0){
00370     pw=w;
00371     ph=h;
00372   }
00373 
00374   //
00375   // if the map size is within acceptable range.
00376   //
00377   if(w <= pw && h <= ph)
00378     {
00379 
00380       //LINFO("Allocating %dx%d panorama...", w, h);
00381   if (w < 2 || h < 2) LFATAL("Oooops, panorama too small!");
00382   Image< PixRGB<byte> > pano(w, h, ZEROS);
00383   Image< PixRGB<byte> >::iterator p = pano.beginw();
00384 
00385   int minStitchedX=0, maxStitchedX=0, minStitchedY=0, maxStitchedY=0, counterStitching = 0;
00386   int minStitchedX2=0, maxStitchedX2=0, minStitchedY2=0, maxStitchedY2=0, counterStitching2 = 0;
00387   // let's stitch the images into the panorama. This code is similar
00388   // to that in VisualObjectMatch::getTransfTestImage() but modified
00389   // for a large panorama and many images:
00390 
00391 
00392   for (int j = 0; j < h; j ++)
00393     for (int i = 0; i < w; i ++)
00394       {
00395         // compute the value that should go into the current panorama
00396         // pixel based on all the images and affines; this is very
00397         // wasteful and may be optimized later:
00398         PixRGB<int> val(0); uint n = 0U;
00399         //LINFO("images.size is %d",images.size());
00400         for (uint k = 0; k < images.size(); k ++)
00401           {
00402             // get transformed coordinates for image k:
00403             float u, v;
00404             affines[k].transform(float(i + minx), float(j + miny), u, v);
00405             //            LINFO("K is %d, i+minx is %d, i+miny is %d, u is %f, v is %f",k,i+minx,i+miny,u,v);
00406             // if we are within bounds of image k, accumulate the pix value:
00407             if (images[k].coordsOk(u, v))
00408               {
00409                 val += PixRGB<int>(images[k].getValInterp(u, v));
00410                 //the if-else statement below gathers the min/max coordinates on the resulting image the input image is.
00411                 if(k == 0 && counterStitching == 0)
00412                   {
00413                     minStitchedX = maxStitchedX = i;
00414                     minStitchedY = maxStitchedY = j;
00415                     counterStitching++;
00416                   }
00417                 else if(k==0)
00418                   {
00419                     if(minStitchedX > i)
00420                       minStitchedX = i;
00421                     if(maxStitchedX < i)
00422                       maxStitchedX = i;
00423                     if(minStitchedY > j)
00424                       minStitchedY = j;
00425                     if(maxStitchedY < j)
00426                       maxStitchedY = j;
00427                     counterStitching++;
00428                   }
00429                 if(counterStitching2 == 0)
00430                   {
00431                     minStitchedX2 = maxStitchedX2 = i;
00432                     minStitchedY2 = maxStitchedY2 = j;
00433                     counterStitching2++;
00434                   }
00435                 else
00436                   {
00437                     if(minStitchedX2 > i)
00438                       minStitchedX2 = i;
00439                     if(maxStitchedX2 < i)
00440                       maxStitchedX2 = i;
00441                     if(minStitchedY2 > j)
00442                       minStitchedY2 = j;
00443                     if(maxStitchedY2 < j)
00444                       maxStitchedY2 = j;
00445                     counterStitching2++;
00446                   }
00447 
00448                 ++ n;
00449               }
00450           }
00451 
00452         if (n > 0) *p = PixRGB<byte>(val / n);
00453 
00454         ++ p;
00455       }
00456 
00457   LINFO("Pixel coordinates of the area Stitched: xmin %d, xmax %d, ymin %d, ymax %d",minStitchedX, maxStitchedX, minStitchedY, maxStitchedY);
00458   LINFO("Pixel coordinates of the area Stitched: xmin2 %d, xmax2 %d, ymin2 %d, ymax2 %d",minStitchedX2, maxStitchedX2, minStitchedY2, maxStitchedY2);
00459 
00460 
00461   //if(maxStitchedX2 + 10 < w &&maxStitchedY2+10 < h){
00462   Image< PixRGB<byte> > pano2((maxStitchedX2+10<w)?maxStitchedX2+10:w, (maxStitchedY2+10<h)?maxStitchedY2+10:h, ZEROS);
00463   for(int i = 0; i < pano2.getWidth(); i++)
00464     for(int j = 0; j<pano2.getHeight(); j++)
00465       {
00466         pano2.setVal(i,j,pano.getVal(i,j));
00467 
00468       }
00469   //  }
00470 
00471     // w = maxStitchedX2+1;
00472     // h = maxStitchedY2+1;
00473   if(  (pano2.getHeight()*pano2.getWidth() / (float)((maxStitchedX - minStitchedX+1)*(maxStitchedY - minStitchedY+1)) >= CUT_THRESHOLD )
00474     {
00475       //  LINFO("GO CUT THE MAP!\n");
00476 
00477       //
00478       // Simple map cutting algorithm.
00479       //
00480       // Coded on Feb/8/2006.
00481 
00482 
00483       //LINFO("===================================================\n");
00484 
00485         // calculate cutting position.
00486 
00487         medge.rightedge = maxStitchedX + SIZE_THRESH;
00488         medge.leftedge = minStitchedX - SIZE_THRESH;
00489         medge.upperedge = minStitchedY - SIZE_THRESH;
00490         medge.loweredge = maxStitchedY + SIZE_THRESH;
00491 
00492         if( (pano2.getWidth() - medge.rightedge) < 20){
00493           medge.rightedge = -1; // -1 means dont cut a map.
00494         }
00495 
00496         if(medge.leftedge < 20){
00497           medge.leftedge = -1; // -1 means dont cut a map.
00498         }
00499 
00500         if( (medge.upperedge) <= 20){
00501           medge.upperedge = -1; // -1 means dont cut a map.
00502         }
00503 
00504         if( (pano2.getHeight() - medge.loweredge) < 20){
00505           medge.loweredge = -1; // -1 means dont cut a map.
00506         }
00507 
00508 
00509         LINFO("minX %d , maxX %d, minY %d, maxY %d", minStitchedX, maxStitchedX, minStitchedY, maxStitchedY);
00510 
00511 
00512                 if(medge.upperedge > 0) LINFO("UPPER-SIDE :  %d \n", medge.upperedge);
00513         else LINFO("UPPER-SIDE : No cut");
00514 
00515 
00516                 if(medge.rightedge > 0) LINFO("RIGHT-SIDE :  %d \n", medge.rightedge);
00517                 else LINFO("RIGHT-SIDE : No cut");
00518 
00519                 if(medge.leftedge > 0) LINFO("LEFT-SIDE :  %d \n", medge.leftedge);
00520                 else LINFO("LEFT-SIDE : No cut");
00521 
00522 
00523 
00524                 if(medge.loweredge > 0) LINFO("LOWER-SIDE :  %d \n", medge.loweredge);
00525                 else LINFO("LOWER-SIDE : No cut");
00526 
00527                 LINFO("Map size : (Xsize, Ysize) = (%d, %d)\n", w, h);
00528 
00529         //        LINFO("===================================================\n");
00530 
00531                 int widthtmp(pano2.getWidth()); int hswitch(0);
00532 
00533 
00534         ///////////////////////////////////////////////////////////////////////////////
00535         //////// X-Direction cut.
00536 
00537         if((medge.rightedge != -1) && (medge.leftedge != -1)){
00538           im3.resize(widthtmp = (medge.rightedge+1) - medge.leftedge, pano2.getHeight());
00539           //LINFO("size of im3 is %d,%d",im3.getWidth(), im3.getHeight());
00540           for(int i = 0; i<im3.getWidth();i++)
00541             for(int j = 0; j <im3.getHeight();j++)
00542               {
00543                 im3.setVal(i,j,pano2.getVal(i+medge.leftedge, j));
00544               }
00545           cut = true;
00546           hswitch = 1;
00547         }
00548         else if((medge.rightedge != -1) && (medge.leftedge==-1))
00549           {
00550             im3.resize(widthtmp = (medge.rightedge+1), pano2.getHeight());
00551             //  LINFO("size of im3 is %d,%d",im3.getWidth(), im3.getHeight());
00552             for(int i = 0; i<im3.getWidth();i++)
00553               for(int j = 0; j <im3.getHeight();j++)
00554                 {
00555                   im3.setVal(i,j,pano2.getVal(i, j));
00556                 }
00557             cut = true;
00558             hswitch = 2;
00559           }
00560         else if((medge.rightedge == -1) && (medge.leftedge!=-1))
00561           {
00562             im3.resize(widthtmp = (pano2.getWidth()-medge.leftedge-1), pano2.getHeight());
00563             //LINFO("size of im3 is %d,%d",im3.getWidth(), im3.getHeight());
00564             for(int i = 0; i<im3.getWidth();i++)
00565               for(int j = 0; j <im3.getHeight();j++)
00566                 {
00567                   im3.setVal(i,j,pano2.getVal(i+medge.leftedge, j));
00568                 }
00569             cut = true;
00570             hswitch = 3;
00571           }
00572         else{
00573           cut = false;
00574           hswitch = 0;
00575           widthtmp = pano2.getWidth();
00576         }
00577 
00578         ///////////////////////////////////////////////////////////////////////////////
00579         //////// Y-Direction cut.
00580 
00581         if((medge.upperedge != -1) && (medge.loweredge != -1)){// upper lower both cut.
00582           im3.resize(widthtmp, medge.loweredge - medge.upperedge );
00583           //LINFO("size of im3 is %d,%d",im3.getWidth(), im3.getHeight());
00584           for(int i = 0; i<im3.getWidth();i++)
00585             for(int j = 0; j <im3.getHeight();j++)
00586               {
00587                 if(hswitch == 0)// left right no cut
00588                   im3.setVal(i,j,pano2.getVal(i, j+medge.upperedge));
00589                 if(hswitch == 1)// left right both cut
00590                   im3.setVal(i,j,pano2.getVal(i+medge.leftedge, j+medge.upperedge));
00591                 if(hswitch == 2)// left no cut, right cut
00592                   im3.setVal(i,j,pano2.getVal(i, j+medge.upperedge));
00593                 if(hswitch == 3)// left cut right no cut.
00594                   im3.setVal(i,j,pano2.getVal(i+medge.leftedge, j+medge.upperedge));
00595               }
00596           cut = true;
00597         }
00598         else if((medge.upperedge != -1) && (medge.loweredge==-1)){//  upper cut lower no cut
00599             im3.resize(widthtmp, pano2.getHeight() - medge.upperedge);
00600             //LINFO("size of im3 is %d,%d",im3.getWidth(), im3.getHeight());
00601             for(int i = 0; i<im3.getWidth();i++)
00602               for(int j = 0; j <im3.getHeight();j++)
00603                 {
00604                   //  im3.setVal(i,j,pano.getVal(i, j));
00605                   if(hswitch == 0)// left right no cut
00606                     im3.setVal(i,j,pano2.getVal(i, j+medge.upperedge));
00607                   if(hswitch == 1)// left right both cut
00608                     im3.setVal(i,j,pano2.getVal(i+medge.leftedge, j+medge.upperedge));
00609                   if(hswitch == 2)// left no cut, right cut
00610                     im3.setVal(i,j,pano2.getVal(i, j+medge.upperedge));
00611                   if(hswitch == 3)// left cut right no cut.
00612                     im3.setVal(i,j,pano2.getVal(i+medge.leftedge, j+medge.upperedge));
00613                 }
00614             cut = true;
00615           }
00616         else if((medge.upperedge == -1) && (medge.loweredge !=-1)){// upper no cut lower cut
00617             im3.resize(widthtmp, medge.loweredge+1);
00618             //LINFO("size of im3 is %d,%d",im3.getWidth(), im3.getHeight());
00619             for(int i = 0; i<im3.getWidth();i++)
00620               for(int j = 0; j <im3.getHeight();j++)
00621                 {
00622                   //          im3.setVal(i,j,pano.getVal(i+medge.leftedge, j));
00623                                     //  im3.setVal(i,j,pano.getVal(i, j));
00624                   if(hswitch == 0)// left right no cut
00625                     im3.setVal(i,j,pano2.getVal(i, j));
00626                   if(hswitch == 1)// left right both cut
00627                     im3.setVal(i,j,pano2.getVal(i+medge.leftedge, j));
00628                   if(hswitch == 2)// left no cut, right cut
00629                     im3.setVal(i,j,pano2.getVal(i, j));
00630                   if(hswitch == 3)// left cut right no cut.
00631                     im3.setVal(i,j,pano2.getVal(i+medge.leftedge, j));
00632                 }
00633             cut = true;
00634           }
00635         else{
00636           cut = false;
00637         }
00638 
00639 
00640 
00641         ///////////
00642 
00643     }
00644   else
00645     {
00646       cut = false;
00647     }
00648 
00649 
00650   //  pano.resize(maxStitchedX2+1, maxStitchedY2+1,false);
00651   // save final panorama:
00652   //pano = rescale(pano, maxStitchedX2+1, maxStitchedY2+1);
00653 
00654   Raster::WriteRGB(pano2, "./resultimg/result.png");
00655   // LINFO("Done.");
00656 
00657   // to avid making a map extremely big.
00658   pw = (int)(pano2.getWidth()*1.5);//w*1.5);
00659   ph = (int)(pano2.getHeight()*1.5);//h*1.5);
00660   globalcounter++;
00661     }
00662 }
00663 */
Generated on Sun May 8 08:40:20 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3