Openholo  v1.0
Open Source Digital Holographic Library
ophDepthMap_GPU.h
Go to the documentation of this file.
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install, copy or use the software.
7 //
8 //
9 // License Agreement
10 // For Open Source Digital Holographic Library
11 //
12 // Openholo library is free software;
13 // you can redistribute it and/or modify it under the terms of the BSD 2-Clause license.
14 //
15 // Copyright (C) 2017-2024, Korea Electronics Technology Institute. All rights reserved.
16 // E-mail : contact.openholo@gmail.com
17 // Web : http://www.openholo.org
18 //
19 // Redistribution and use in source and binary forms, with or without modification,
20 // are permitted provided that the following conditions are met:
21 //
22 // 1. Redistribution's of source code must retain the above copyright notice,
23 // this list of conditions and the following disclaimer.
24 //
25 // 2. Redistribution's in binary form must reproduce the above copyright notice,
26 // this list of conditions and the following disclaimer in the documentation
27 // and/or other materials provided with the distribution.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the copyright holder or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 // This software contains opensource software released under GNU Generic Public License,
41 // NVDIA Software License Agreement, or CUDA supplement to Software License Agreement.
42 // Check whether software you use contains licensed software.
43 //
44 //M*/
45 
53 #ifndef __ophDepthMap_GPU_h
54 #define __ophDepthMap_GPU_h
55 
56 #include "ophDepthMap.h"
57 
58 #define __DEBUG_LOG_GPU_SPEC_
59 
60 /* CUDA Library Include */
61 #include <cuda_runtime.h>
62 #include <cufft.h>
63 static void HandleError(cudaError_t err,
64  const char *file,
65  int line) {
66  if (err != cudaSuccess) {
67  printf("%s in %s at line %d\n", cudaGetErrorString(err),
68  file, line);
69  exit(EXIT_FAILURE);
70  }
71 }
72 #define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ ))
73 
74 
75 #define HANDLE_NULL( a ) {if (a == NULL) { \
76  printf( "Host memory failed in %s at line %d\n", \
77  __FILE__, __LINE__ ); \
78  exit( EXIT_FAILURE );}}
79 cufftDoubleComplex *u_o_gpu_;
80 cufftDoubleComplex *u_complex_gpu_;
81 cufftDoubleComplex *k_temp_d_;
82 
83 cudaStream_t stream_;
84 
85 extern "C"
86 {
99  void cudaFFT(CUstream_st* stream, int nx, int ny, cufftDoubleComplex* in_filed, cufftDoubleComplex* output_field, int direction);
100 
101 
102  //void cudaCropFringe(CUstream_st* stream, int nx, int ny, cufftDoubleComplex* in_field, cufftDoubleComplex* out_field, int cropx1, int cropx2, int cropy1, int cropy2);
103 
123  void cudaDepthHoloKernel(CUstream_st* stream, int pnx, int pny, cufftDoubleComplex* u_o_gpu_, unsigned char* img_src_gpu, unsigned char* dimg_src_gpu, Real* depth_index_gpu,
124  int dtr, Real rand_phase_val_a, Real rand_phase_val_b, Real carrier_phase_delay_a, Real carrier_phase_delay_b, int flag_change_depth_quan, unsigned int default_depth_quan);
125 
143  void cudaPropagation_AngularSpKernel(CUstream_st* stream_, int pnx, int pny, cufftDoubleComplex* input_d, cufftDoubleComplex* u_complex,
144  Real ppx, Real ppy, Real ssx, Real ssy, Real lambda, Real params_k, Real propagation_dist);
145 
146  //void cudaGetFringe(CUstream_st* stream, int pnx, int pny, cufftDoubleComplex* in_field, cufftDoubleComplex* out_field, int sig_locationx, int sig_locationy,
147  // Real ssx, Real ssy, Real ppx, Real ppy, Real PI);
148 
165  void cudaChangeDepthQuanKernel(CUstream_st* stream_, int pnx, int pny, Real* depth_index_gpu, unsigned char* dimg_src_gpu,
166  int dtr, Real d1, Real d2, Real params_num_of_depth, Real params_far_depthmap, Real params_near_depthmap);
167 
170 }
171 
172 
173 
174 #endif
cufftDoubleComplex * u_o_gpu_
void cudaPropagation_AngularSpKernel(CUstream_st *stream_, int pnx, int pny, cufftDoubleComplex *input_d, cufftDoubleComplex *u_complex, Real ppx, Real ppy, Real ssx, Real ssy, Real lambda, Real params_k, Real propagation_dist)
Angular spectrum propagation method for GPU implementation.
cufftDoubleComplex * u_complex_gpu_
void cudaFFT(CUstream_st *stream, int nx, int ny, cufftDoubleComplex *in_filed, cufftDoubleComplex *output_field, int direction)
Convert data from the spatial domain to the frequency domain using 2D FFT on GPU. ...
void cudaChangeDepthQuanKernel(CUstream_st *stream_, int pnx, int pny, Real *depth_index_gpu, unsigned char *dimg_src_gpu, int dtr, Real d1, Real d2, Real params_num_of_depth, Real params_far_depthmap, Real params_near_depthmap)
Quantize depth map on the GPU, only when the number of depth quantization is not the default value (i...
float Real
Definition: typedef.h:55
cufftDoubleComplex * k_temp_d_
void cudaDepthHoloKernel(CUstream_st *stream, int pnx, int pny, cufftDoubleComplex *u_o_gpu_, unsigned char *img_src_gpu, unsigned char *dimg_src_gpu, Real *depth_index_gpu, int dtr, Real rand_phase_val_a, Real rand_phase_val_b, Real carrier_phase_delay_a, Real carrier_phase_delay_b, int flag_change_depth_quan, unsigned int default_depth_quan)
Find each depth plane of the input image and apply carrier phase delay to it on GPU.
cudaStream_t stream_