1 #include <ophPointCloud.h> 2 #include <ophDepthMap.h> 3 #include <ophTriMesh.h> 4 #include <ophLightField.h> 17 case 0:
name =
"Phase";
break;
18 case 1:
name =
"Amplitude";
break;
19 case 2:
name =
"Real";
break;
20 case 3:
name =
"Imaginary";
break;
21 default:
name =
"Unknown";
26 void ex_PointCloud(
const char* conf,
const char* input,
unsigned int flag,
unsigned int encode,
unsigned int mode)
28 printf(
"===== ex_PointCloud START =====\n");
38 char buf[PATH_MAX] = { 0, };
39 sprintf(buf,
"Result/PointCloud_%s_%s.bmp", diff.c_str(),
encodeToString(encode).c_str());
42 printf(
"====== ex_PointCloud END ======\n");
45 void ex_DepthMap(
const char* conf,
char* p[3],
unsigned int encode,
unsigned int mode)
47 printf(
"====== ex_DepthMap START ======\n");
56 char buf[PATH_MAX] = { 0, };
57 sprintf(buf,
"Result/DepthMap_%s.bmp",
encodeToString(encode).c_str());
60 printf(
"====== ex_DepthMap END ======\n");
63 void ex_LightField(
const char* conf,
const char* input,
unsigned int encode,
unsigned int mode)
65 printf(
"====== ex_LightField START ======\n");
69 Hologram->
loadLF(input,
"bmp");
71 ((
ophGen*)Hologram)->encoding(encode);
74 char buf[PATH_MAX] = { 0, };
75 sprintf(buf,
"Result/LightField_%s.bmp",
encodeToString(encode).c_str());
78 printf(
"====== ex_LightField END ======\n");
81 void ex_TriMesh(
const char* conf,
const char* input,
unsigned int encode,
unsigned int mode)
83 printf(
"====== ex_TriMesh START ======\n");
92 char buf[PATH_MAX] = { 0, };
93 sprintf(buf,
"Result/TriMesh_%s.bmp",
encodeToString(encode).c_str());
97 printf(
"====== ex_TriMesh END ======\n");
100 void ex_WRP(
const char* conf,
const char* input,
unsigned int encode,
unsigned int mode)
102 printf(
"====== ex_WRP START ======\n");
108 ((
ophGen*)Hologram)->encoding(encode);
111 char buf[PATH_MAX] = { 0, };
112 sprintf(buf,
"Result/WRP_%s.bmp",
encodeToString(encode).c_str());
116 printf(
"====== ex_WRP END ======\n");
119 int main(
int argc,
char* argv[])
121 printf(
"====== Openholo Test main V0.1 ======\n");
122 char config[PATH_MAX] = { 0, };
123 char input[PATH_MAX] = { 0, };
131 printf(
"argc : %d ", argc);
133 for (
int i = 1; i < argc; i++) {
134 if (!strcmp(
"-a", argv[i])) {
135 alg = atoi(argv[i + 1]);
136 printf(
"alg = %d \n", alg);
138 else if (!strcmp(
"-c", argv[i])) {
139 strcpy(config, argv[i + 1]);
140 printf(
"config = %s \n", config);
142 else if (!strcmp(
"-i", argv[i])) {
144 for (
int j = 0; j < 3; j++) {
145 p[j] =
new char[12 *
sizeof(argv[i + 1])];
146 strcpy(p[j], argv[i + j + 1]);
149 else if (alg >= 0 && alg < 5) {
150 strcpy(input, argv[i + 1]);
153 printf(
"Invalid input path.\n");
157 else if (!strcmp(
"-e", argv[i])) {
158 encode = atoi(argv[i + 1]);
159 printf(
"encode = %u \n", encode);
161 else if (!strcmp(
"-m", argv[i])) {
162 if (atoi(argv[i + 1]) == 0)
167 else if (atoi(argv[i + 1]) == 1)
169 printf(
"precision = %d\n", atoi(argv[i + 1]));
171 else if (!strcmp(
"-p", argv[i])) {
172 if (atoi(argv[i + 1]) == 0)
174 else if (atoi(argv[i + 1]) == 1)
176 printf(
"mode = %d\n", atoi(argv[i + 1]));
178 else if (!strcmp(
"-f", argv[i])) {
179 flag = atoi(argv[i + 1]);
180 printf(
"flag = %d\n", flag);
184 unsigned int select = (
unsigned int)alg;
187 case 0:
ex_PointCloud(config, input, flag, encode, mode);
break;
188 case 1:
ex_DepthMap(config, p, encode, mode);
break;
190 case 3:
ex_TriMesh(config, input, encode, mode);
break;
191 case 4:
ex_WRP(config, input, encode, mode);
break;
192 default: printf(
"Invalid algorithm selected.\n");
194 printf(
"====== Openholo Test main V0.1 END ======\n");
OphConfig & getContext(void)
Function for getting the current context.
void ex_LightField(const char *conf, const char *input, unsigned int encode, unsigned int mode)
string encodeToString(unsigned int enc)
bool readImageDepth(const char *source_folder, const char *img_prefix, const char *depth_img_prefix)
Read image and depth map.
bool readConfig(const char *fname)
Light Field based CGH configuration file load.
void ex_WRP(const char *conf, const char *input, unsigned int encode, unsigned int mode)
Openholo Light Field based CGH generation.
Real generateHologram(uint SHADING_FLAG)
Hologram generation.
void generateHologram()
Hologram generation.
virtual bool readConfig(const char *fname)
load to configuration file.
void SetMode(unsigned int mode)
void ex_PointCloud(const char *conf, const char *input, unsigned int flag, unsigned int encode, unsigned int mode)
void normalize(void)
Normalization function to save as image file after hologram creation.
virtual void encoding(unsigned int ENCODE_FLAG)
bool save(const char *fname, uint8_t bitsperpixel=8, uchar *src=nullptr, uint px=0, uint py=0)
Function for saving image files.
int loadPointCloud(const char *pc_file)
override
bool readConfig(const char *cfg_file)
Import Specification Config File(*.config) file.
virtual int loadPointCloud(const char *pc_file)
load to point cloud data.
Openholo Triangular Mesh based CGH generation.
bool readConfig(const char *fname)
Read parameters from a config file. (*.xml)
int main(int argc, char *argv[])
void ex_TriMesh(const char *conf, const char *input, unsigned int encode, unsigned int mode)
Openholo Point Cloud based Compter-generated holography.
virtual void encoding(unsigned int ENCODE_FLAG, unsigned int SSB_PASSBAND)
bool loadMeshData(const char *fileName, const char *ext)
Mesh data load.
This class generates CGH based on depth map.
virtual void encoding(unsigned int ENCODE_FLAG)
void ex_DepthMap(const char *conf, char *p[3], unsigned int encode, unsigned int mode)
bool readConfig(const char *fname)
Triangular mesh basc CGH configuration file load.
Real generateHologram(void)
Generate a hologram, main funtion. When the calculation is finished, the angular spectrum is performe...
unsigned long release(void)
Call release() when reference is finished.
Real generateHologram(uint diff_flag=PC_DIFF_RS)
Generate a hologram, main funtion.
int loadLF(const char *directory, const char *exten)
Light Field images load.
void generateHologram(void)
Generate a hologram, main funtion.