5 #include <Image/ByteImage.h>
6 #include <Image/FloatImage.h>
19 scaleX = std::tan(fovH *
M_PI / 180.0 / 2.0) * 2.0;
20 scaleY = std::tan(fovV *
M_PI / 180.0 / 2.0) * 2.0;
26 const float fovH = 180.0 /
M_PI * 2.0 * std::atan(width / (2.0 * fx));
27 const float fovV = 180.0 /
M_PI * 2.0 * std::atan(height / (2.0 * fy));
33 armarx::MetaInfoSizeBasePtr imageMetaInfo,
35 pcl::PointCloud<pcl::PointXYZRGBL>::Ptr& result)
38 result->width = images[0]->width;
39 result->height = images[0]->height;
40 result->header.stamp = imageMetaInfo->timeProvided;
41 result->points.resize(images[0]->width * images[0]->height);
42 result->is_dense =
true;
45 const size_t width =
static_cast<size_t>(images[0]->width);
46 const size_t height =
static_cast<size_t>(images[0]->height);
47 const float halfWidth = (width / 2.0);
48 const float halfHeight = (height / 2.0);
49 const auto& image0Data = images[0]->pixels;
50 const auto& image1Data = images[1]->pixels;
52 for (
size_t j = 0; j < height; j++)
54 for (
size_t i = 0; i < width; i++)
56 auto coord = j * width + i;
60 image1Data[3 * coord + 0], image1Data[3 * coord + 1], image1Data[3 * coord + 2]);
62 PointL& p = result->points.at(coord);
63 auto index = 3 * (coord);
64 p.r = image0Data[
index + 0];
65 p.g = image0Data[
index + 1];
66 p.b = image0Data[
index + 2];
70 p.x = p.y = p.z = std::numeric_limits<float>::quiet_NaN();
74 p.z =
static_cast<float>(
value);
76 p.x = -1.0 * (i - halfWidth) / width * p.z * scaleX;
77 p.y = (halfHeight - j) / height * p.z * scaleY;
82 auto& image2Data = images[2]->pixels;
84 if (images[2]->bytesPerPixel == 3)
86 p.label =
static_cast<unsigned int>(image2Data[
index + 0] +
87 (image2Data[
index + 1] << 8) +
88 (image2Data[
index + 2] << 16));
92 p.label =
static_cast<unsigned int>(image2Data[coord]);