Openholo  v4.2
Open Source Digital Holographic Library
ophPAS_GPU.h
Go to the documentation of this file.
1 #ifndef __ophPAS_GPU_h
2 #define __ophPAS_GPU_h
3 
4 #include "ophGen.h"
5 #include <cuda.h>
6 using namespace oph;
7 
8 #define PI (3.14159265358979323846f)
9 #define M2_PI (PI*2.0)
10 #define RADIANS (PI/180.0) // Angle in radians
11 // DEGREE*asin(mytheta)
12 #define DEGREE2 (180./PI) // sin(RADIANS*DEGREE*asin(mytheta))
13 
14 #define NUMTBL 1024
15 #define NUMTBL2 (NUMTBL-1)
16 #define MAX_STR_LEN 4000
17 
18 #define FFT_SEGMENT_SIZE 64
19 
20 
21 
22 
23 struct constValue {
24  int* cf_cx;
25  int* cf_cy;
26  float* xc;
27  float* yc;
28 
29  float* costbl;
30  float* sintbl;
31  float cx, cy, cz, amplitude;
32  int segx, segy, segn;
33 
34 
35 };
36 
37 
38 class GEN_DLL ophPAS_GPU : public ophGen
39 {
40 private:
41  OphPointCloudConfig pc_config;
42  OphPointCloudData pc_data;
43  constValue val_d;
44 
45  int n_points;
46 public:
47  explicit ophPAS_GPU();
48 protected:
49  virtual ~ophPAS_GPU();
50 
51 public:
52 
53 
54 
55  bool readConfig(const char* fname);
56  int loadPoint(const char* _filename);
57 
58  //int saveAsImg(const char * fname, uint8_t bitsperpixel, void* src, int pic_width, int pic_height); // À̹ÌÁö ÀúÀå
59  int save(const char * fname, uint8_t bitsperpixel, uchar* src, uint px, uint py);
60  void save(const char* fname);
61 
62  //util
63  char* trim(char *s); // ¹®ÀÚ¿­ ÁÂ¿ì °ø¹é ¸ðµÎ »èÁ¦ ÇÔ¼ö char* ltrim(char *s); // ¹®ÀÚ¿­ ÁÂÃø °ø¹é Á¦°Å ÇÔ¼ö char* rtrim(char* s); // ¹®ÀÚ¿­ ¿ìÃø °ø¹é Á¦°Å ÇÔ¼ö //void PASCalcuation(long voxnum, unsigned char *cghfringe, VoxelStruct* h_vox, CGHEnvironmentData* _CGHE); void PASCalculation(long voxnum, unsigned char * cghfringe, OphPointCloudData *data, OphPointCloudConfig& conf); //void PAS(long voxelnum, struct VoxelStruct *voxel, double *m_pHologram, CGHEnvironmentData* _CGHE); void PAS(long voxelnum, OphPointCloudData *data, double *m_pHologram, OphPointCloudConfig& conf); void DataInit(int segsize, int cghwidth, int cghheight, float xiinter, float etainter); void DataInit(OphPointCloudConfig& conf); void MemoryRelease(void); void generateHologram(); void PASCalculation_GPU(long voxnum, unsigned char * cghfringe, OphPointCloudData *data, OphPointCloudConfig& conf); void CalcSpatialFrequency(float cx, float cy, float cz, float amp, int segnumx, int segnumy, int segsize, int hsegsize, float sf_base, float * xc, float * yc, float * sf_cx, float * sf_cy, int * pp_cx, int * pp_cy, int * cf_cx, int * cf_cy, float xiint, float etaint, OphPointCloudConfig& conf); void CalcCompensatedPhase(float cx, float cy, float cz, float amp, int segnumx, int segnumy, int segsize, int hsegsize, float sf_base, float *xc, float *yc, int *cf_cx, int *cf_cy, float *COStbl, float *SINtbl, float **inRe, float **inIm, OphPointCloudConfig& conf); void RunFFTW(int segnumx, int segnumy, int segsize, int hsegsize, float **inRe, float **inIm, fftw_complex *in, fftw_complex *out, fftw_plan *plan, double *pHologram, OphPointCloudConfig& conf); void encodeHologram(const vec2 band_limit, const vec2 spectrum_shift); void encoding(unsigned int ENCODE_FLAG); double *m_pHologram; float* m_COStbl; float* m_SINtbl; int m_segSize; int m_hsegSize; int m_dsegSize; int m_segNumx; int m_segNumy; int m_hsegNumx; int m_hsegNumy; float *m_SFrequency_cx; float *m_SFrequency_cy; int *m_PickPoint_cx; int *m_PickPoint_cy; int *m_Coefficient_cx; int *m_Coefficient_cy; float *m_xc; float *m_yc; unsigned char* cgh_fringe; float m_sf_base; float *m_inReHost; float *m_inImHost; fftw_complex *m_in, *m_out; fftw_plan m_plan; float **m_inRe; float **m_inIm; float *m_inRe_h; float *m_inIm_h; float m_cx; float m_cy; float m_cz; float m_amp; ivec3 se; }; extern "C" { void cuda_Wrapper_phaseCalc(float* inRe, float* inIm, constValue val, float& cx, float& cy, float& cz, float& amp, ivec3& seg); } #endif // !__ophPAS_h
64  char* ltrim(char *s); // ¹®ÀÚ¿­ ÁÂÃø °ø¹é Á¦°Å ÇÔ¼ö char* rtrim(char* s); // ¹®ÀÚ¿­ ¿ìÃø °ø¹é Á¦°Å ÇÔ¼ö //void PASCalcuation(long voxnum, unsigned char *cghfringe, VoxelStruct* h_vox, CGHEnvironmentData* _CGHE); void PASCalculation(long voxnum, unsigned char * cghfringe, OphPointCloudData *data, OphPointCloudConfig& conf); //void PAS(long voxelnum, struct VoxelStruct *voxel, double *m_pHologram, CGHEnvironmentData* _CGHE); void PAS(long voxelnum, OphPointCloudData *data, double *m_pHologram, OphPointCloudConfig& conf); void DataInit(int segsize, int cghwidth, int cghheight, float xiinter, float etainter); void DataInit(OphPointCloudConfig& conf); void MemoryRelease(void); void generateHologram(); void PASCalculation_GPU(long voxnum, unsigned char * cghfringe, OphPointCloudData *data, OphPointCloudConfig& conf); void CalcSpatialFrequency(float cx, float cy, float cz, float amp, int segnumx, int segnumy, int segsize, int hsegsize, float sf_base, float * xc, float * yc, float * sf_cx, float * sf_cy, int * pp_cx, int * pp_cy, int * cf_cx, int * cf_cy, float xiint, float etaint, OphPointCloudConfig& conf); void CalcCompensatedPhase(float cx, float cy, float cz, float amp, int segnumx, int segnumy, int segsize, int hsegsize, float sf_base, float *xc, float *yc, int *cf_cx, int *cf_cy, float *COStbl, float *SINtbl, float **inRe, float **inIm, OphPointCloudConfig& conf); void RunFFTW(int segnumx, int segnumy, int segsize, int hsegsize, float **inRe, float **inIm, fftw_complex *in, fftw_complex *out, fftw_plan *plan, double *pHologram, OphPointCloudConfig& conf); void encodeHologram(const vec2 band_limit, const vec2 spectrum_shift); void encoding(unsigned int ENCODE_FLAG); double *m_pHologram; float* m_COStbl; float* m_SINtbl; int m_segSize; int m_hsegSize; int m_dsegSize; int m_segNumx; int m_segNumy; int m_hsegNumx; int m_hsegNumy; float *m_SFrequency_cx; float *m_SFrequency_cy; int *m_PickPoint_cx; int *m_PickPoint_cy; int *m_Coefficient_cx; int *m_Coefficient_cy; float *m_xc; float *m_yc; unsigned char* cgh_fringe; float m_sf_base; float *m_inReHost; float *m_inImHost; fftw_complex *m_in, *m_out; fftw_plan m_plan; float **m_inRe; float **m_inIm; float *m_inRe_h; float *m_inIm_h; float m_cx; float m_cy; float m_cz; float m_amp; ivec3 se; }; extern "C" { void cuda_Wrapper_phaseCalc(float* inRe, float* inIm, constValue val, float& cx, float& cy, float& cz, float& amp, ivec3& seg); } #endif // !__ophPAS_h
65  char* rtrim(char* s); // ¹®ÀÚ¿­ ¿ìÃø °ø¹é Á¦°Å ÇÔ¼ö //void PASCalcuation(long voxnum, unsigned char *cghfringe, VoxelStruct* h_vox, CGHEnvironmentData* _CGHE); void PASCalculation(long voxnum, unsigned char * cghfringe, OphPointCloudData *data, OphPointCloudConfig& conf); //void PAS(long voxelnum, struct VoxelStruct *voxel, double *m_pHologram, CGHEnvironmentData* _CGHE); void PAS(long voxelnum, OphPointCloudData *data, double *m_pHologram, OphPointCloudConfig& conf); void DataInit(int segsize, int cghwidth, int cghheight, float xiinter, float etainter); void DataInit(OphPointCloudConfig& conf); void MemoryRelease(void); void generateHologram(); void PASCalculation_GPU(long voxnum, unsigned char * cghfringe, OphPointCloudData *data, OphPointCloudConfig& conf); void CalcSpatialFrequency(float cx, float cy, float cz, float amp, int segnumx, int segnumy, int segsize, int hsegsize, float sf_base, float * xc, float * yc, float * sf_cx, float * sf_cy, int * pp_cx, int * pp_cy, int * cf_cx, int * cf_cy, float xiint, float etaint, OphPointCloudConfig& conf); void CalcCompensatedPhase(float cx, float cy, float cz, float amp, int segnumx, int segnumy, int segsize, int hsegsize, float sf_base, float *xc, float *yc, int *cf_cx, int *cf_cy, float *COStbl, float *SINtbl, float **inRe, float **inIm, OphPointCloudConfig& conf); void RunFFTW(int segnumx, int segnumy, int segsize, int hsegsize, float **inRe, float **inIm, fftw_complex *in, fftw_complex *out, fftw_plan *plan, double *pHologram, OphPointCloudConfig& conf); void encodeHologram(const vec2 band_limit, const vec2 spectrum_shift); void encoding(unsigned int ENCODE_FLAG); double *m_pHologram; float* m_COStbl; float* m_SINtbl; int m_segSize; int m_hsegSize; int m_dsegSize; int m_segNumx; int m_segNumy; int m_hsegNumx; int m_hsegNumy; float *m_SFrequency_cx; float *m_SFrequency_cy; int *m_PickPoint_cx; int *m_PickPoint_cy; int *m_Coefficient_cx; int *m_Coefficient_cy; float *m_xc; float *m_yc; unsigned char* cgh_fringe; float m_sf_base; float *m_inReHost; float *m_inImHost; fftw_complex *m_in, *m_out; fftw_plan m_plan; float **m_inRe; float **m_inIm; float *m_inRe_h; float *m_inIm_h; float m_cx; float m_cy; float m_cz; float m_amp; ivec3 se; }; extern "C" { void cuda_Wrapper_phaseCalc(float* inRe, float* inIm, constValue val, float& cx, float& cy, float& cz, float& amp, ivec3& seg); } #endif // !__ophPAS_h
66 
67 
68 
69  //void PASCalcuation(long voxnum, unsigned char *cghfringe, VoxelStruct* h_vox, CGHEnvironmentData* _CGHE);
70  void PASCalculation(long voxnum, unsigned char * cghfringe, OphPointCloudData *data, OphPointCloudConfig& conf);
71  //void PAS(long voxelnum, struct VoxelStruct *voxel, double *m_pHologram, CGHEnvironmentData* _CGHE);
72  void PAS(long voxelnum, OphPointCloudData *data, double *m_pHologram, OphPointCloudConfig& conf);
73  void DataInit(int segsize, int cghwidth, int cghheight, float xiinter, float etainter);
74  void DataInit(OphPointCloudConfig& conf);
75  void MemoryRelease(void);
76 
77  void generateHologram();
78  void PASCalculation_GPU(long voxnum, unsigned char * cghfringe, OphPointCloudData *data, OphPointCloudConfig& conf);
79 
80 
81  void CalcSpatialFrequency(float cx, float cy, float cz, float amp, int segnumx, int segnumy, int segsize, int hsegsize, float sf_base, float * xc, float * yc, float * sf_cx, float * sf_cy, int * pp_cx, int * pp_cy, int * cf_cx, int * cf_cy, float xiint, float etaint, OphPointCloudConfig& conf);
82 
83  void CalcCompensatedPhase(float cx, float cy, float cz, float amp, int segnumx, int segnumy, int segsize, int hsegsize, float sf_base, float *xc, float *yc, int *cf_cx, int *cf_cy, float *COStbl, float *SINtbl, float **inRe, float **inIm, OphPointCloudConfig& conf);
84 
85  void RunFFTW(int segnumx, int segnumy, int segsize, int hsegsize, float **inRe, float **inIm, fftw_complex *in, fftw_complex *out, fftw_plan *plan, double *pHologram, OphPointCloudConfig& conf);
86 
87  void encodeHologram(const vec2 band_limit, const vec2 spectrum_shift);
88 
89  void encoding(unsigned int ENCODE_FLAG);
90 
91 
92  double *m_pHologram;
93 
94  float* m_COStbl;
95  float* m_SINtbl;
96 
97  int m_segSize;
104 
111  float *m_xc;
112  float *m_yc;
113  unsigned char* cgh_fringe;
114 
115  float m_sf_base;
116  float *m_inReHost;
117  float *m_inImHost;
118  fftw_complex *m_in, *m_out;
119  fftw_plan m_plan;
120 
121  float **m_inRe;
122  float **m_inIm;
123  float *m_inRe_h;
124  float *m_inIm_h;
125 
126  float m_cx;
127  float m_cy;
128  float m_cz;
129  float m_amp;
130 
132 };
133 
134 extern "C"
135 {
136  void cuda_Wrapper_phaseCalc(float* inRe, float* inIm, constValue val,
137  float& cx, float& cy, float& cz, float& amp, ivec3& seg);
138 
139 }
140 
141 
142 
143 #endif // !__ophPAS_h
int m_hsegNumy
Definition: ophPAS_GPU.h:103
ENCODE_FLAG
Definition: ophGen.h:84
float m_cy
Definition: ophPAS_GPU.h:127
ivec3 se
Definition: ophPAS_GPU.h:131
float * m_COStbl
Definition: ophPAS_GPU.h:94
float * m_inImHost
Definition: ophPAS_GPU.h:117
float * xc
Definition: ophPAS_GPU.h:26
float * m_SFrequency_cx
Definition: ophPAS_GPU.h:105
float m_cx
Definition: ophPAS_GPU.h:126
double * m_pHologram
Definition: ophPAS_GPU.h:92
float * m_inIm_h
Definition: ophPAS_GPU.h:124
int * cf_cx
Definition: ophPAS_GPU.h:24
float m_amp
Definition: ophPAS_GPU.h:129
unsigned char uchar
Definition: typedef.h:64
int m_segNumy
Definition: ophPAS_GPU.h:101
float * m_yc
Definition: ophPAS_GPU.h:112
int * m_Coefficient_cy
Definition: ophPAS_GPU.h:110
int m_hsegNumx
Definition: ophPAS_GPU.h:102
fftw_plan m_plan
Definition: ophPAS_GPU.h:119
int m_dsegSize
Definition: ophPAS_GPU.h:99
float cz
Definition: ophPAS_GPU.h:31
float * m_inReHost
Definition: ophPAS_GPU.h:116
int * m_PickPoint_cy
Definition: ophPAS_GPU.h:108
float m_sf_base
Definition: ophPAS_GPU.h:115
int * m_Coefficient_cx
Definition: ophPAS_GPU.h:109
float ** m_inIm
Definition: ophPAS_GPU.h:122
float * yc
Definition: ophPAS_GPU.h:27
float m_cz
Definition: ophPAS_GPU.h:128
#define GEN_DLL
Definition: ophGen.h:61
structure for 2-dimensional Real type vector and its arithmetic.
Definition: vec.h:66
unsigned char * cgh_fringe
Definition: ophPAS_GPU.h:113
float * sintbl
Definition: ophPAS_GPU.h:30
float ** m_inRe
Definition: ophPAS_GPU.h:121
float * m_inRe_h
Definition: ophPAS_GPU.h:123
Configuration for Point Cloud.
Definition: ophGen.h:555
float * costbl
Definition: ophPAS_GPU.h:29
structure for 3-dimensional integer vector and its arithmetic.
Definition: ivec.h:386
Data for Point Cloud.
Definition: ophGen.h:582
fftw_complex * m_out
Definition: ophPAS_GPU.h:118
float * m_SINtbl
Definition: ophPAS_GPU.h:95
float * m_xc
Definition: ophPAS_GPU.h:111
int * m_PickPoint_cx
Definition: ophPAS_GPU.h:107
void cuda_Wrapper_phaseCalc(float *inRe, float *inIm, constValue val, float &cx, float &cy, float &cz, float &amp, ivec3 &seg)
Definition: Bitmap.h:49
float * m_SFrequency_cy
Definition: ophPAS_GPU.h:106
int * cf_cy
Definition: ophPAS_GPU.h:25
unsigned int uint
Definition: typedef.h:62
int m_hsegSize
Definition: ophPAS_GPU.h:98
Definition: ophGen.h:76
int m_segSize
Definition: ophPAS_GPU.h:97
int m_segNumx
Definition: ophPAS_GPU.h:100