|
PanoWeave
|
Stitches multiple camera images into a single spherical panorama using Basalt calibration data. More...
#include <panoweave.hpp>
Public Member Functions | |
| Stitcher () | |
| Constructs an empty Stitcher object. | |
| Stitcher (const std::string &calibration_filepath) | |
| Constructs a Stitcher object with the specified calibration file. | |
| Stitcher (const std::string &calibration_filepath, ScalarT depth) | |
| Constructs a Stitcher object with the specified calibration file and uniform depth. | |
| Stitcher (const std::string &calibration_filepath, const cv::Mat &depth) | |
| Constructs a Stitcher object with the specified calibration file and per-point depth. | |
| ~Stitcher () | |
| Destructor for the Stitcher class. | |
| void | loadCalibration (const std::string &calibration_filepath) |
| Loads camera calibration data from the specified file. | |
| const basalt::Calibration< ScalarT > & | calibration () const |
| Returns a read-only reference to the calibration data. | |
| void | setDepth (ScalarT depth) |
| Sets a uniform depth for the panorama. | |
| void | setDepth (const cv::Mat &depth) |
| Sets a per-point depth map for the panorama. | |
| cv::Size | resolution () const |
| Get the current output resolution for the panorama. | |
| cv::Size | resolution (const cv::Size &resolution) |
| Set the output resolution for the panorama. | |
| cv::Size | resolution (int width, int height) |
| Set the output resolution for the panorama. | |
| int | width () const |
| Get the current output width for the panorama. | |
| int | width (int width) |
| Set the output width for the panorama. | |
| int | height () const |
| Get the current output height for the panorama. | |
| int | height (int height) |
| Set the output height for the panorama. | |
| CvFovT | fov () const |
| Get the current field of view (FOV) for the panorama. | |
| CvFovT | fov (CvFovT fov) |
| Set the field of view (FOV) for the panorama. | |
| CvFovT | fov (ScalarT fov_x, ScalarT fov_y) |
| Set the field of view (FOV) for the panorama. | |
| ScalarT | fovX () const |
| Get the current horizontal field of view (FOV) for the panorama. | |
| ScalarT | fovX (ScalarT fov) |
| Set the horizontal field of view (FOV) for the panorama. | |
| ScalarT | fovY () const |
| Get the current vertical field of view (FOV) for the panorama. | |
| ScalarT | fovY (ScalarT fov) |
| Set the vertical field of view (FOV) for the panorama. | |
| ScalarT | vignetteThreshold () const |
| Get the current vignette threshold. | |
| ScalarT | vignetteThreshold (ScalarT threshold) |
| Set the vignette threshold used to generate vignette maps. | |
| bool | useMaskAsVignette () const |
| Gets whether the mask is used as vignette. | |
| bool | useMaskAsVignette (bool use) |
| Sets whether to use the mask as vignette. | |
| CvAffine3T | transform () const |
| Get the current transformation from body to calibration coordinate system. | |
| CvAffine3T | transform (const CvAffine3T &transform) |
| Set the transformation from body to calibration coordinate system. | |
| CvAffine3T | transform (const CvAffine3T::Mat4 &affine) |
| Set the transformation using an affine matrix. | |
| CvAffine3T | transform (const CvAffine3T::Mat3 &rotation, const CvAffine3T::Vec3 &translation=CvAffine3T::Vec3(0, 0, 0)) |
| Set the transformation using rotation matrix and translation vector. | |
| CvAffine3T | transform (const CvAffine3T::Vec3 &rotation, const CvAffine3T::Vec3 &translation=CvAffine3T::Vec3(0, 0, 0)) |
| Set the transformation using a rotation vector and translation vector. | |
| void | stitch (const std::vector< cv::Mat > &images, const std::vector< ScalarT > &exposure, cv::Mat &pano) |
| Stitches the provided input images into a single panoramic image. | |
| void | stitch (const std::vector< cv::Mat > &images, cv::Mat &pano) |
| Stitches the provided input images into a single panoramic image. | |
| void | stitch (const std::vector< cv::Mat > &images, const std::vector< ScalarT > &exposure, ScalarT depth, cv::Mat &pano) |
| Stitches the provided input images into a single panoramic image. | |
| void | stitch (const std::vector< cv::Mat > &images, const std::vector< ScalarT > &exposure, const cv::Mat &depth, cv::Mat &pano) |
| Stitches the provided input images into a single panoramic image. | |
| bool | buildInternals () |
| Builds all necessary internal data structures required for stitching. | |
Private Member Functions | |
| bool | buildMaps () |
| Builds the lookup tables and initial proximity-based weights. | |
| void | buildVignettes () |
| Builds the vignette maps. | |
| void | buildMask () |
| Builds the masks and finalizes the weights. | |
| void | buildMirrors () |
| Builds the vignette map and weight mirrors for multi-channel images. | |
Stitches multiple camera images into a single spherical panorama using Basalt calibration data.
The Stitcher supports setting resolution, field of view, depth, and transformation of the spherical camera. Depth values can be provided as a uniform scalar or a per-pixel depth map to cover simple or complex use cases. Exposure times of the input images can optionally be used to adjust the input images to a common exposure. Images with one (mono), three (BGR, RGB), or four (BGRA, RGBA) channels are supported without extra configuration.
Example usage:
| panoweave::Stitcher::Stitcher | ( | ) |
| panoweave::Stitcher::Stitcher | ( | const std::string & | calibration_filepath | ) |
Constructs a Stitcher object with the specified calibration file.
Loads camera calibration data from the given file path.
| calibration_filepath | Path to the camera calibration data file. |
| std::runtime_error | If the file cannot be opened or the data is invalid. |
| panoweave::Stitcher::Stitcher | ( | const std::string & | calibration_filepath, |
| ScalarT | depth ) |
Constructs a Stitcher object with the specified calibration file and uniform depth.
Loads camera calibration and sets a uniform depth value.
| calibration_filepath | Path to the camera calibration data file. |
| depth | Uniform depth value. |
| std::runtime_error | If the file cannot be opened or the data is invalid. |
| panoweave::Stitcher::Stitcher | ( | const std::string & | calibration_filepath, |
| const cv::Mat & | depth ) |
Constructs a Stitcher object with the specified calibration file and per-point depth.
Loads camera calibration and sets a per-point depth map.
| calibration_filepath | Path to the camera calibration data file. |
| depth | Per-point depth map. |
| std::runtime_error | If the file cannot be opened or the data is invalid. |
| panoweave::Stitcher::~Stitcher | ( | ) |
Destructor for the Stitcher class.
Uses the default destructor.
| bool panoweave::Stitcher::buildInternals | ( | ) |
Builds all necessary internal data structures required for stitching.
Calls the individual build functions for maps, vignettes, mask, and mirrors as needed.
|
private |
Builds the lookup tables and initial proximity-based weights.
Generates a spherical point cloud based on the current resolution and field of view, transforms the points using the current transformation, and builds the mapping tables and initial proximity-based weights in the calibration.
|
private |
Builds the masks and finalizes the weights.
Generates masks from vignette maps and applies them to normalize and combine the proximity-based weights. Updates the vignette maps if the mask is used as vignette.
|
private |
Builds the vignette map and weight mirrors for multi-channel images.
Generates multi-channel versions of the vignette maps and weights to support multi-channel images.
|
private |
Builds the vignette maps.
Generates vignette maps based on the current vignette threshold and calibration data.
| const basalt::Calibration< ScalarT > & panoweave::Stitcher::calibration | ( | ) | const |
Returns a read-only reference to the calibration data.
| CvFovT panoweave::Stitcher::fov | ( | ) | const |
Get the current field of view (FOV) for the panorama.
| CvFovT panoweave::Stitcher::fov | ( | CvFovT | fov | ) |
Set the field of view (FOV) for the panorama.
The FOV must be in the range (0, 2*Pi] for horizontal and (0, Pi] for vertical.
| fov | Desired FOV. |
| CvFovT panoweave::Stitcher::fov | ( | ScalarT | fov_x, |
| ScalarT | fov_y ) |
Set the field of view (FOV) for the panorama.
Overload accepting horizontal and vertical FOV as separate parameters.
| fov_x | Desired horizontal FOV. |
| fov_y | Desired vertical FOV. |
| ScalarT panoweave::Stitcher::fovX | ( | ) | const |
Get the current horizontal field of view (FOV) for the panorama.
| ScalarT panoweave::Stitcher::fovX | ( | ScalarT | fov | ) |
Set the horizontal field of view (FOV) for the panorama.
The horizontal FOV must be in the range (0, 2*Pi].
| fov | Desired horizontal FOV. |
| ScalarT panoweave::Stitcher::fovY | ( | ) | const |
Get the current vertical field of view (FOV) for the panorama.
| ScalarT panoweave::Stitcher::fovY | ( | ScalarT | fov | ) |
Set the vertical field of view (FOV) for the panorama.
The vertical FOV must be in the range (0, Pi].
| fov | Desired vertical FOV. |
| int panoweave::Stitcher::height | ( | ) | const |
Get the current output height for the panorama.
| int panoweave::Stitcher::height | ( | int | height | ) |
Set the output height for the panorama.
| height | Desired height. |
| void panoweave::Stitcher::loadCalibration | ( | const std::string & | calibration_filepath | ) |
Loads camera calibration data from the specified file.
Reads calibration parameters from a Basalt calibration.json file.
| calibration_filepath | Path to the camera calibration data file. |
| std::runtime_error | If the file cannot be opened or the data is invalid. |
| cv::Size panoweave::Stitcher::resolution | ( | ) | const |
Get the current output resolution for the panorama.
| cv::Size panoweave::Stitcher::resolution | ( | const cv::Size & | resolution | ) |
Set the output resolution for the panorama.
| resolution | Desired resolution. |
| cv::Size panoweave::Stitcher::resolution | ( | int | width, |
| int | height ) |
Set the output resolution for the panorama.
Overload accepting width and height as separate parameters.
| width | Desired width. |
| height | Desired height. |
| void panoweave::Stitcher::setDepth | ( | const cv::Mat & | depth | ) |
Sets a per-point depth map for the panorama.
The depth map provides depth information for each point in the panorama. Its resolution must match the output resolution of the panorama.
| depth | Per-point depth map. |
| void panoweave::Stitcher::setDepth | ( | ScalarT | depth | ) |
Sets a uniform depth for the panorama.
Uses the same depth value for all points in the panorama.
| depth | Uniform depth value. |
| void panoweave::Stitcher::stitch | ( | const std::vector< cv::Mat > & | images, |
| const std::vector< ScalarT > & | exposure, | ||
| const cv::Mat & | depth, | ||
| cv::Mat & | pano ) |
Stitches the provided input images into a single panoramic image.
Overload for stitching with a per-point depth map.
| images | Vector of input images to be stitched. |
| exposure | Vector of exposure values corresponding to each input image. |
| depth | Per-point depth map to be used for all points. |
| pano | Output panoramic image. |
| void panoweave::Stitcher::stitch | ( | const std::vector< cv::Mat > & | images, |
| const std::vector< ScalarT > & | exposure, | ||
| cv::Mat & | pano ) |
Stitches the provided input images into a single panoramic image.
Exposure values are used to correct the brightness of each input image and adjust the overall exposure of the panorama. Internal data structures are built or rebuilt as necessary before stitching.
| images | Vector of input images to be stitched. |
| exposure | Vector of exposure values corresponding to each input image. |
| pano | Output panoramic image. |
| void panoweave::Stitcher::stitch | ( | const std::vector< cv::Mat > & | images, |
| const std::vector< ScalarT > & | exposure, | ||
| ScalarT | depth, | ||
| cv::Mat & | pano ) |
Stitches the provided input images into a single panoramic image.
Overload for stitching with a uniform depth value.
| images | Vector of input images to be stitched. |
| exposure | Vector of exposure values corresponding to each input image. |
| depth | Uniform depth value to be used for all points. |
| pano | Output panoramic image. |
| void panoweave::Stitcher::stitch | ( | const std::vector< cv::Mat > & | images, |
| cv::Mat & | pano ) |
Stitches the provided input images into a single panoramic image.
Overload for stitching without exposure correction.
| images | Vector of input images to be stitched. |
| pano | Output panoramic image. |
| CvAffine3T panoweave::Stitcher::transform | ( | ) | const |
Get the current transformation from body to calibration coordinate system.
| CvAffine3T panoweave::Stitcher::transform | ( | const CvAffine3T & | transform | ) |
Set the transformation from body to calibration coordinate system.
This transformation is applied to spherical points before projecting them into camera views. The Basalt calibration coordinate system is either the IMU or the first camera coordinate system, depending on the calibration type.
| transform | Desired transformation. |
| CvAffine3T panoweave::Stitcher::transform | ( | const CvAffine3T::Mat3 & | rotation, |
| const CvAffine3T::Vec3 & | translation = CvAffine3T::Vec3(0, 0, 0) ) |
Set the transformation using rotation matrix and translation vector.
| rotation | Desired rotation matrix. |
| translation | Desired translation vector. |
| CvAffine3T panoweave::Stitcher::transform | ( | const CvAffine3T::Mat4 & | affine | ) |
Set the transformation using an affine matrix.
| affine | Desired affine transformation matrix. |
| CvAffine3T panoweave::Stitcher::transform | ( | const CvAffine3T::Vec3 & | rotation, |
| const CvAffine3T::Vec3 & | translation = CvAffine3T::Vec3(0, 0, 0) ) |
Set the transformation using a rotation vector and translation vector.
| rotation | Desired rotation vector (axis-angle, Rodrigues). |
| translation | Desired translation vector. |
| bool panoweave::Stitcher::useMaskAsVignette | ( | ) | const |
Gets whether the mask is used as vignette.
| bool panoweave::Stitcher::useMaskAsVignette | ( | bool | use | ) |
Sets whether to use the mask as vignette.
If set to true, the mask will replace the vignette maps. This is useful when vignette correction is not desired (for example, if vignetting calibration quality is insufficient), and the mask should define valid pixel regions instead.
| use | True to use the mask as vignette, false otherwise. |
| ScalarT panoweave::Stitcher::vignetteThreshold | ( | ) | const |
Get the current vignette threshold.
| ScalarT panoweave::Stitcher::vignetteThreshold | ( | ScalarT | threshold | ) |
Set the vignette threshold used to generate vignette maps.
The vignette maps are used to compensate for lens vignetting in input images. Values should be in the range [0.0, 1.0]. A lower threshold means pixels farther from the center are considered valid.
| threshold | Desired vignette threshold. |
| int panoweave::Stitcher::width | ( | ) | const |
Get the current output width for the panorama.
| int panoweave::Stitcher::width | ( | int | width | ) |
Set the output width for the panorama.
| width | Desired width. |