Guest User

Untitled

a guest
Jan 21st, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. pixels = fileSizeBytes / 2;
  2. heightPx = 3040;
  3. widthPx = 4096;
  4.  
  5. cudaMalloc(&d_inp, pixels*4*sizeof(ushort));
  6. d_img = d_inp + pixels;
  7.  
  8. cudaMemcpy(d_inp, h_img , pixels*sizeof(ushort), cudaMemcpyHostToDevice);
  9.  
  10. dim3 block(widthPx/16, heightPx/16);
  11. dim3 threads(16,16);
  12. bayerRG <<<block,threads>>>(d_img, d_inp, widthPx,heightPx);
  13.  
  14. cudaMemcpy(gpu_output, d_img, pixels*3*sizeof(ushort), cudaMemcpyDeviceToHost);
  15.  
  16. cv::Mat outputMat_16UC3CUDA = cv::Mat( 3040, 4096, CV_16UC3, gpu_output );
  17.  
  18. __global__ void bayerRG(ushort *d_img, ushort *d_inp, uint width, uint height)
  19. {
  20. uint x = (blockIdx.x* blockDim.x + threadIdx.x);
  21. uint y = (blockIdx.y* blockDim.y + threadIdx.y);
  22. uint img_i = y * width*3 + x*3; //3 channels in image
  23. uint inp_i = (y*width +x); //1 channel in input
  24.  
  25. d_img[img_i] = d_inp[inp_i];
  26. d_img[img_i + 1] = d_inp[inp_i];
  27. d_img[img_i + 2] = d_inp[inp_i];
  28. }
Add Comment
Please, Sign In to add comment