2#include "Design/Headers/MaterialRaster.h"
3#include "Design/Headers/ImageFactory.h"
4#include "Design/Headers/Camera.h"
5#include "Design/Headers/SelectionController.h"
6#include "Base/Headers/MatrixFunctions.h"
7#include "Base/Headers/VectorFunctions.hpp"
8#include "Base/Headers/RGBColor.h"
9#include <opencv2/stitching.hpp>
10#include <opencv2/core/hal/interface.h>
40 if (background_color !=
RGBColor(255, 255, 255, 255))
56 m_stitcher->setFeaturesMatcher(
new cv::detail::BestOf2NearestMatcher(
true));
57 m_stitcher->setBundleAdjuster(
new cv::detail::BundleAdjusterRay());
83 if (status == cv::Stitcher::Status::OK)
88 uint8_t* pixelPtr = (uint8_t*)pano.data;
89 int cn = pano.channels();
90 for (
int i = 0; i < pano.rows; i++)
92 for (
int j = 0; j < pano.cols; j++)
94 for (
int dim = 0; dim < 3; dim++)
95 new_pixels[(i * pano.cols + j) * 4 + dim] = pixelPtr[(i * pano.cols + j) * 3 + dim];
127 uint04 index_size = size[X] * size[Y];
129 for (
uint04 i = 0; i < index_size; i++)
131 for (
uint04 n = 0; n < 3; n++)
132 new_pixels[3 * i + n] = pixels[4 * i + n];
134 cv::Mat mat(cv::Size(size[X], size[Y]), CV_8UC3, (
void*)new_pixels.ptr(), cv::Mat::AUTO_STEP);
135 imgs.push_back(mat.clone());
The equivelent of std::vector but with a bit more control.
void addImageUncompressed(const StringView &id, const Buffer< uint01 > &uncompressed, bool clear_other)
Adds an uncompressed (raw ARGB) image to the cache.
static ImageFactory & DefaultFactory()
Returns the singleton default ImageFactory instance.
Base class for painting pixels at a time into a 2D texture.
MaterialRasterBase(const RasterInfo &raster_info)
Constructs the base raster with the given raster configuration.
Creates rasters for converting points and directions into 2D images.
Templated logic for doing matrix multiplication.
A MaterialRasterBase implementation that uses OpenCV for image stitching and raster compositing.
cv::Ptr< cv::Stitcher > m_stitcher
The OpenCV stitcher instance.
void clearRaster()
Clears all accumulated images from the stitching buffer.
String m_image_id
The unique image identifier.
OpenCVImageRaster(const String &image_id, const Vector< 2, uint04 > &size, const RGBColor &background_color)
Constructs an OpenCVImageRaster with a background color.
const String & imageID() const override
Gets the unique image identifier for this raster.
OpenCVImageRaster(const String &image_id, const Vector< 2, uint04 > &size)
Constructs an OpenCVImageRaster with the given image ID and size.
void setup()
Initializes the stitcher and creates the initial blank image.
std::vector< cv::Mat > imgs
Accumulated images awaiting stitching.
void setUnsetColor(RGBColor color)
Sets the color used for unset pixels.
void updateImage() override
Stitches all accumulated images and updates the raster output.
Vector< 2, uint04 > m_size
The pixel dimensions of the output raster.
void addImageBuffer(const Buffer< uint01 > &pixels, const Vector< 2, uint04 > &size, const Matrix< fltp08 > &camera_matrix) override
Adds an image buffer to the stitching queue.
A MaterialRasterFactory implementation that creates OpenCV-based raster instances.
static MaterialRasterFactory * s_default_raster_factory
The default raster factory instance.
virtual MaterialRasterBase * createRaster(const String &image_id, const RasterInfo &info)
Creates a new OpenCVImageRaster instance.
Represents a color in the RGB space with optional alpha transparency.
The core String class for the NDEVR API.
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Stores information for painting pixels at a time into a 2D texture used with MaterialRaster.