51 #include "ophDepthMap.h" 53 namespace fs = std::experimental::filesystem;
59 std::string proj_dir = fs::current_path().generic_string();
60 std::string conf_file = proj_dir +
"/../dataset/Dice/DepthMap/Dice_DepthMap.xml";
63 if (!Hologram->
readConfig(conf_file.c_str())) {
64 std::cerr <<
"Fail to load Config file : " << conf_file << std::endl;
69 std::string dm_path = proj_dir +
"/../dataset/Dice/DepthMap";
70 if (!Hologram->
readImageDepth(dm_path.c_str(),
"dice_rgb",
"dice_depth")) {
71 std::cerr <<
"Fail to load DepthMap file : " << dm_path << std::endl;
83 std::string res_path =
"./result/";
84 if (!fs::exists(res_path)) {
85 fs::create_directories(res_path);
89 time_t cur_time = time(
nullptr);
93 localtime_s(&local, &cur_time);
95 localtime_r(&cur_time, &local);
100 sprintf_s(buff,
"%4d%02d%02d-%02d%02d%02d",
101 local.tm_year + 1900, local.tm_mon + 1, local.tm_mday,
102 local.tm_hour, local.tm_min, local.tm_sec);
104 sprintf(buff,
"%4d%02d%02d-%02d%02d%02d",
105 local.tm_year + 1900, local.tm_mon + 1, local.tm_mday,
106 local.tm_hour, local.tm_min, local.tm_sec);
109 std::string ohc_file = res_path +
"dm_sample_" + std::string(buff) +
".ohc";
110 if (!Hologram->
saveAsOhc(ohc_file.c_str())) {
111 std::cerr <<
"Fail to save OHC file : " << ohc_file << std::endl;
122 std::string bmp_file = res_path +
"dm_sample_" + std::string(buff) +
".bmp";
123 if (!Hologram->
save(bmp_file.c_str())) {
124 std::cerr <<
"Fail to save BMP file : " << bmp_file << std::endl;
bool readImageDepth(const char *source_folder, const char *img_prefix, const char *depth_img_prefix)
Read image and depth map.
void SetMode(unsigned int mode)
bool save(const char *fname, uint8_t bitsperpixel=8, uchar *src=nullptr, uint px=0, uint py=0)
Function for saving image files.
bool readConfig(const char *fname)
Read parameters from a config file. (*.xml)
This class generates CGH based on depth map.
virtual void encoding(unsigned int ENCODE_FLAG)
virtual bool saveAsOhc(const char *fname)
Function to write OHC file
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.