360toPerspective/cpp/src/Slicer360ToPerspective.cpp

35 lines
1 KiB
C++
Raw Normal View History

2023-04-30 14:42:10 +02:00
#include <Slicer360ToPerspective.hpp>
2023-05-01 00:31:24 +02:00
#include <frame_conversions.hpp>
2023-04-30 14:42:10 +02:00
Slicer360ToPerspective::Slicer360ToPerspective()
{
2023-05-01 00:31:24 +02:00
}
Image Slicer360ToPerspective::ComputeCoverage(int width, bool raw)
{
int height = width/2;
Image coverage(width, height, 1);
// Compute the coverage of the 360-degree image by the cameras added to the slicer.
for(int i = 0; i < height; i++) {
for(int j = 0; j < width; j++) {
// Compute view vector in inertial frame from equirectangular coordinates
Eigen::Vector3d ray_dir_sph = equirectangular2sph(i, j, width, height);
Eigen::Vector3d ray_dir_cart = sph2cart(ray_dir_sph);
int count = 0;
for(Camera const& camera : cameras)
{
if(camera.IsPointVisibleInertialFrame(ray_dir_cart))
count++;
}
coverage.SetPixelValue(i, j, 0, count);
}
}
if(raw)
return coverage;
else
return coverage.Normalized().Colorized(Image::Colormap::PARULA);
}