50 using Vec = BaseVector<float>;
52 ModelToImage::ModelToImage(
55 int width,
int height,
56 float minZ,
float maxZ,
57 int minHorizontenAngle,
int maxHorizontalAngle,
58 int minVerticalAngle,
int maxVerticalAngle,
59 bool imageOptimization,
66 m_coordinateSystem = system;
69 m_minHAngle = minHorizontenAngle;
70 m_maxHAngle = maxHorizontalAngle;
71 m_minVAngle = minVerticalAngle;
72 m_maxVAngle = maxVerticalAngle;
78 minHorizontenAngle, maxHorizontalAngle,
79 minVerticalAngle, maxVerticalAngle,
80 imageOptimization, system);
86 ModelToImage::~ModelToImage()
93 cout <<
timestamp <<
"Initializting DepthListMatrix with dimensions " << m_width <<
" x " << m_height << endl;
95 for(
int i = 0; i < m_height; i++)
97 mat.
pixels.emplace_back(vector<vector<PanoramaPoint> >());
98 for(
int j = 0; j < m_width; j++)
100 mat.
pixels[i].push_back(vector<PanoramaPoint>());
105 size_t n_points = m_points->numPoints();
106 floatArr points = m_points->getPointArray();
114 for(
int i = 0; i < n_points; i++)
116 Vec ppt(points[3 * i], points[3 * i + 1], points[3 * i + 2]);
118 m_projection->project(
120 ppt.
x, ppt.
y, ppt.
z);
145 cout <<
timestamp <<
"Computing depth image. Image dimensions: " << m_width <<
" x " << m_height << endl;
148 for(
int i = 0; i < m_height; i++)
150 img.
pixels.emplace_back(vector<float>());
151 for(
int j = 0; j < m_width; j++)
153 img.
pixels[i].push_back(0.0f);
159 size_t n_points = m_points->numPoints();
160 floatArr points = m_points->getPointArray();
168 for(
int i = 0; i < n_points; i++)
170 m_projection->project(
172 points[3 * i], points[3 * i + 1], points[3 * i + 2]);
185 img.
pixels[img_y][img_x] = range;
192 void ModelToImage::writePGM(
string filename,
float cutoff)
196 computeDepthImage(img);
199 float min_r = std::min(m_minZ, img.
minRange);
200 float max_r = std::min(m_maxZ, img.
maxRange);
201 float interval = max_r - min_r;
203 cout << min_r <<
" " << max_r <<
" " << interval << endl;
208 out << img.
pixels[0].size() <<
" " << img.
pixels.size() <<
" 255" << endl;
210 for(
int i = 0; i < img.
pixels.size(); i++)
212 for(
int j = 0; j < img.
pixels[i].size(); j++)
214 int val = img.
pixels[i][j];
223 val = (int)((
float)(val - min_r) / interval * 255);