test_wrap_cuda_debayer_display.C
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 #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
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
00077 f = CudaImage<float>(i,GLOBAL_DEVICE_MEMORY,deviceNum);
00078 res_cuda = cuda_1_debayer(f);
00079
00080
00081
00082
00083
00084
00085
00086
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
00097
00098
00099 cudaGetComponents(res_cuda,res_cuda_r_only,res_cuda_g_only,res_cuda_b_only);
00100
00101
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
00115 }
00116
00117
00118
00119 int main(int argc, char **argv)
00120 {
00121 bayer_test(argc,argv);
00122 }