test_wrap_cuda_debayer_display.C

Go to the documentation of this file.
00001 /*!@file CUDA/test_wrap_cuda_debayer_display.C Testing CudaImageDisplayGL.C */
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 
00034 
00035 
00036 #include "Image/Image.H"
00037 #include "Image/ImageSet.H"
00038 #include "Image/Pixels.H"
00039 #include "Image/ColorOps.H"
00040 #include "Raster/Raster.H"
00041 #include "CUDA/CudaImage.H"
00042 #include "CUDA/wrap_c_cuda.h"
00043 #include "CUDA/cutil.h"
00044 #include "CUDA/CudaColorOps.H"
00045 #include "CUDA/CudaDevices.H"
00046 #include "CUDA/CudaImageSet.H"
00047 #include "CUDA/CudaImageSetOps.H"
00048 #include "CUDA/CUDAdebayer.H"
00049 #include "Util/fpu.H"
00050 #include <cmath>
00051 #include <fstream>
00052 #include <sys/time.h>
00053 #include "CUDA/CudaImageDisplayGL.H"
00054 // ######################################################################
00055 
00056 
00057 void bayer_test(int argc,char **argv)
00058 {
00059   //Variable allocations
00060   Image<float> i = Raster::ReadFloat(argv[1]);
00061   int deviceNum = 0 ;
00062   CudaDevices::displayProperties(deviceNum);
00063   CudaImage<PixRGB<float> > res_cuda;
00064   CudaImage<float> f;
00065   CudaImage<float> res_cuda_r_only;
00066   CudaImage<float> res_cuda_g_only;
00067   CudaImage<float> res_cuda_b_only;
00068   Image<PixRGB<float> > res_cuda_r;
00069   Image<PixRGB<float> > res_cuda_g;
00070   Image<PixRGB<float> > res_cuda_b;
00071   cudaEvent_t start,stop;
00072   cudaEventCreate(&start);
00073   cudaEventCreate(&stop);
00074   cudaEventRecord(start,0);
00075 
00076   //Getting the Debayerd Image
00077   f =        CudaImage<float>(i,GLOBAL_DEVICE_MEMORY,deviceNum);
00078   res_cuda = cuda_1_debayer(f);
00079   // cuda_init_layout(nDesired,layoutW,layoutH);
00080   // for(int i=0;i<nDesired;i++)
00081   //   {
00082   //     cuda_generate_layout(f[i],i,startX,startY,sizeX,sizeY);
00083   //   }
00084 
00085 
00086   //iDispGL(res_cuda,argc,argv,0,0,1920,1080,1.0);
00087 
00088   cudaEventRecord(stop,0);
00089   cudaEventSynchronize(stop);
00090   float elapsedTime;
00091   cudaEventElapsedTime(&elapsedTime,start,stop);
00092   printf("Elasped Time GPU in ms for 1 iteration : %f\n",elapsedTime);
00093   cudaEventDestroy(start);
00094   cudaEventDestroy(stop);
00095 
00096   //Printing the images
00097 
00098   //Get color components
00099   cudaGetComponents(res_cuda,res_cuda_r_only,res_cuda_g_only,res_cuda_b_only);
00100 
00101   //Make R,0,0 from r only
00102   Image<float> zero(res_cuda.getDims(),ZEROS);
00103 
00104   res_cuda_r = makeRGB(res_cuda_r_only.exportToImage(),zero,zero);
00105   res_cuda_g = makeRGB(zero,res_cuda_g_only.exportToImage(),zero);
00106   res_cuda_b = makeRGB(zero,zero,res_cuda_b_only.exportToImage());
00107 
00108   Raster::WriteRGB(res_cuda_r,"test_gpu_r.ppm");
00109   Raster::WriteRGB(res_cuda_g,"test_gpu_g.ppm");
00110   Raster::WriteRGB(res_cuda_b,"test_gpu_b.ppm");
00111   //##############################################################
00112   Image<PixRGB<float> > res_copy_cuda = res_cuda.exportToImage();
00113   Raster::WriteRGB(res_copy_cuda,"test_gpu.ppm");
00114   //imageDisplayGL(res_cuda.getAryPtr(),argc,argv);
00115 }
00116 
00117 
00118 
00119 int main(int argc, char **argv)
00120 {
00121   bayer_test(argc,argv);
00122 }
Generated on Sun May 8 08:40:37 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3