Verified Commit 11d1177d authored by Tobias WEBER's avatar Tobias WEBER
Browse files

get meta data from tof scan file

parent 0fe654b3
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <fstream>
#include <string> #include <string>
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
...@@ -52,8 +53,10 @@ namespace gil = boost::gil; ...@@ -52,8 +53,10 @@ namespace gil = boost::gil;
bool convert_tof(const fs::path& tof_file, const fs::path& out_file) bool convert_tof(const fs::path& tof_file, const fs::path& out_file)
{ {
// tof file data type for counts
using t_data = std::uint32_t; using t_data = std::uint32_t;
// total image, summing over all channels
gil::gray16_image_t total_png(PSD_WIDTH, PSD_HEIGHT); gil::gray16_image_t total_png(PSD_WIDTH, PSD_HEIGHT);
auto total_view = gil::view(total_png); auto total_view = gil::view(total_png);
...@@ -72,6 +75,7 @@ bool convert_tof(const fs::path& tof_file, const fs::path& out_file) ...@@ -72,6 +75,7 @@ bool convert_tof(const fs::path& tof_file, const fs::path& out_file)
const t_data* data = reinterpret_cast<const t_data*>(file.data()); const t_data* data = reinterpret_cast<const t_data*>(file.data());
// image of a tof channel
gil::gray16_image_t png(PSD_WIDTH, PSD_HEIGHT); gil::gray16_image_t png(PSD_WIDTH, PSD_HEIGHT);
auto view = gil::view(png); auto view = gil::view(png);
...@@ -103,12 +107,35 @@ bool convert_tof(const fs::path& tof_file, const fs::path& out_file) ...@@ -103,12 +107,35 @@ bool convert_tof(const fs::path& tof_file, const fs::path& out_file)
if(counts) if(counts)
{ {
//std::cout << "Channel " << t << ": " << std::dec << counts << std::endl; //std::cout << "Channel " << t << ": " << std::dec << counts << std::endl;
// write channel image
gil::write_view(png_file, view, gil::png_tag()); gil::write_view(png_file, view, gil::png_tag());
} }
} }
// write total image
std::string total_png_file = out_file.string() + ".png"; std::string total_png_file = out_file.string() + ".png";
gil::write_view(total_png_file, total_view, gil::png_tag()); gil::write_view(total_png_file, total_view, gil::png_tag());
// meta information at the end of the file
std::size_t size = fs::file_size(tof_file);
std::ptrdiff_t size_rest = size - PSD_WIDTH*PSD_HEIGHT*TOF_COUNT*sizeof(t_data);
if(size_rest > 0)
{
ios::mapped_file_source file(tof_file,
size_rest,
PSD_WIDTH*PSD_HEIGHT*TOF_COUNT*sizeof(t_data));
if(file.is_open())
{
const char* data = reinterpret_cast<const char*>(file.data());
std::string txt_file = out_file.string() + ".txt";
std::ofstream ofstr_txt(txt_file);
ofstr_txt.write(data, size_rest);
}
}
return true; return true;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment