3 #include <Image/ByteImage.h>
4 #include <Image/FloatImage.h>
21 scaleX = std::tan(fovH *
M_PI / 180.0 / 2.0) * 2.0;
22 scaleY = std::tan(fovV *
M_PI / 180.0 / 2.0) * 2.0;
27 const float fovH = 180.0 /
M_PI * 2.0 * std::atan(width / (2.0 * fx));
28 const float fovV = 180.0 /
M_PI * 2.0 * std::atan(height / (2.0 * fy));
35 result->width = images[0]->width;
36 result->height = images[0]->height;
37 result->header.stamp = imageMetaInfo->timeProvided;
38 result->points.resize(images[0]->width * images[0]->height);
39 result->is_dense =
true;
43 const size_t width =
static_cast<size_t>(images[0]->width);
44 const size_t height =
static_cast<size_t>(images[0]->height);
45 const float halfWidth = (width / 2.0);
46 const float halfHeight = (height / 2.0);
47 const auto& image0Data = images[0]->pixels;
48 const auto& image1Data = images[1]->pixels;
50 for (
size_t j = 0; j < height; j++)
52 for (
size_t i = 0; i < width; i++)
54 auto coord = j * width + i;
59 PointL& p = result->points.at(coord);
60 auto index = 3 * (coord);
61 p.r = image0Data[
index + 0];
62 p.g = image0Data[
index + 1];
63 p.b = image0Data[
index + 2];
67 p.x = p.y = p.z = std::numeric_limits<float>::quiet_NaN();
71 p.z =
static_cast<float>(
value);
73 p.x = -1.0 * (i - halfWidth) / width * p.z * scaleX;
74 p.y = (halfHeight - j) / height * p.z * scaleY;
79 auto& image2Data = images[2]->pixels;
81 if (images[2]->bytesPerPixel == 3)
83 p.label =
static_cast<unsigned int>(image2Data[
index + 0] + (image2Data[
index + 1] << 8) + (image2Data[
index + 2] << 16));
87 p.label =
static_cast<unsigned int>(image2Data[coord]);