MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / fillDepthImage

Method fillDepthImage

io/src/image_depth.cpp:209–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209void
210pcl::io::DepthImage::fillDepthImage (unsigned width, unsigned height, float* depth_buffer, unsigned line_step) const
211{
212 if (width > wrapper_->getWidth () || height > wrapper_->getHeight ())
213 THROW_IO_EXCEPTION ("upsampling not supported: %d x %d -> %d x %d", wrapper_->getWidth (), wrapper_->getHeight (), width, height);
214
215 if (wrapper_->getWidth () % width != 0 || wrapper_->getHeight () % height != 0)
216 THROW_IO_EXCEPTION ("downsampling only supported for integer scale: %d x %d -> %d x %d", wrapper_->getWidth (), wrapper_->getHeight (), width, height);
217
218 if (line_step == 0)
219 line_step = width * static_cast<unsigned> (sizeof (float));
220
221 // padding skip for destination image
222 unsigned bufferSkip = line_step - width * static_cast<unsigned> (sizeof (float));
223
224 // step and padding skip for source image
225 unsigned xStep = wrapper_->getWidth () / width;
226 unsigned ySkip = (wrapper_->getHeight () / height - 1) * wrapper_->getWidth ();
227
228 // Fill in the depth image data, converting mm to m
229 float bad_point = std::numeric_limits<float>::quiet_NaN ();
230 unsigned depthIdx = 0;
231
232 const auto* inputBuffer = static_cast<const unsigned short*> (wrapper_->getData ());
233
234 for (unsigned yIdx = 0; yIdx < height; ++yIdx, depthIdx += ySkip)
235 {
236 for (unsigned xIdx = 0; xIdx < width; ++xIdx, depthIdx += xStep, ++depth_buffer)
237 {
238 /// @todo Different values for these cases
239 unsigned short pixel = inputBuffer[depthIdx];
240 if (pixel == 0 || pixel == no_sample_value_ || pixel == shadow_value_)
241 *depth_buffer = bad_point;
242 else
243 {
244 *depth_buffer = static_cast<unsigned short>( pixel ) * 0.001f; // millimeters to meters
245 }
246 }
247 // if we have padding
248 if (bufferSkip > 0)
249 {
250 char* cBuffer = reinterpret_cast<char*> (depth_buffer);
251 depth_buffer = reinterpret_cast<float*> (cBuffer + bufferSkip);
252 }
253 }
254}
255
256void
257pcl::io::DepthImage::fillDisparityImage (unsigned width, unsigned height, float* disparity_buffer, unsigned line_step) const

Callers

nothing calls this directly

Calls 3

getWidthMethod · 0.45
getHeightMethod · 0.45
getDataMethod · 0.45

Tested by

no test coverage detected