51 #include "ophTriMesh.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/TriangleMesh/Dice_TriMesh.xml";
63 if (!Hologram->
readConfig(conf_file.c_str())) {
64 std::cerr <<
"Fail to load Config file : " << conf_file << std::endl;
69 std::string tm_file = proj_dir +
"/../dataset/Dice/TriangleMesh/dice.ply";
71 std::cerr <<
"Fail to load Triangle Mesh file : " << tm_file << 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 +
"tm_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 +
"tm_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;
ivec2 & getEncodeSize(void)
Function for getting encode size.
Real generateHologram(uint SHADING_FLAG)
Hologram generation.
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.
Openholo Triangular Mesh based CGH generation.
bool loadMeshData(const char *fileName, const char *ext)
Mesh data load.
virtual bool saveAsOhc(const char *fname)
Function to write OHC file
bool readConfig(const char *fname)
Triangular mesh basc CGH configuration file load.
unsigned long release(void)
Call release() when reference is finished.