51 #include "ophLightField.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/LightField/Dice_LightField.xml";
63 if (!Hologram->
readConfig(conf_file.c_str())) {
64 std::cerr <<
"Fail to load Config file : " << conf_file << std::endl;
69 std::string lf_path = proj_dir +
"/../dataset/Dice/LightField";
70 if (Hologram->
loadLF(lf_path.c_str(),
"bmp") < 0) {
71 std::cerr <<
"Fail to load Light Field files : " << lf_path << std::endl;
79 std::string res_path =
"./result/";
80 if (!fs::exists(res_path)) {
81 fs::create_directories(res_path);
85 time_t cur_time = time(
nullptr);
89 localtime_s(&local, &cur_time);
91 localtime_r(&cur_time, &local);
96 sprintf_s(buff,
"%4d%02d%02d-%02d%02d%02d",
97 local.tm_year + 1900, local.tm_mon + 1, local.tm_mday,
98 local.tm_hour, local.tm_min, local.tm_sec);
100 sprintf(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);
105 std::string ohc_file = res_path +
"lf_sample_" + std::string(buff) +
".ohc";
106 if (!Hologram->
saveAsOhc(ohc_file.c_str())) {
107 std::cerr <<
"Fail to save OHC file : " << ohc_file << std::endl;
119 std::string bmp_file = res_path +
"lf_sample_" + std::string(buff) +
".bmp";
120 if (!Hologram->
save(bmp_file.c_str(), 8,
nullptr, m_vecEncodeSize[
_X], m_vecEncodeSize[
_Y])) {
121 std::cerr <<
"Fail to save BMP file : " << bmp_file << std::endl;
bool readConfig(const char *fname)
Light Field based CGH configuration file load.
ivec2 & getEncodeSize(void)
Function for getting encode size.
Openholo Light Field based CGH generation.
void generateHologram()
Hologram generation.
void normalize(void)
Normalization function to save as image file after hologram creation.
void encoding(unsigned int ENCODE_FLAG)
Encoding Functions.
bool save(const char *fname, uint8_t bitsperpixel=8, uchar *src=nullptr, uint px=0, uint py=0)
Function for saving image files.
virtual bool saveAsOhc(const char *fname)
Function to write OHC file
unsigned long release(void)
Call release() when reference is finished.
int loadLF(const char *directory, const char *exten)
Light Field images load.