Go to the documentation of this file.
34 #ifndef MULTISENSE_ROS_CAMERA_UTILITIES_H
35 #define MULTISENSE_ROS_CAMERA_UTILITIES_H
41 #include <Eigen/Geometry>
43 #include <opencv2/opencv.hpp>
46 #include <sensor_msgs/CameraInfo.h>
48 #include <multisense_lib/MultiSenseChannel.hh>
49 #include <multisense_lib/MultiSenseTypes.hh>
87 const T &
data() const noexcept
103 template <
typename T>
109 const uint8_t *lumaP =
reinterpret_cast<const uint8_t*
>(luma.
imageDataP);
110 const uint8_t *chromaP =
reinterpret_cast<const uint8_t*
>(chroma.
imageDataP);
112 const size_t luma_offset = (v * luma.
width) + u;
113 const size_t chroma_offset = 2 * (((v/2) * (luma.
width/2)) + (u/2));
115 const float px_y =
static_cast<float>(lumaP[luma_offset]);
116 const float px_cb =
static_cast<float>(chromaP[chroma_offset+0]) - 128.0
f;
117 const float px_cr =
static_cast<float>(chromaP[chroma_offset+1]) - 128.0
f;
119 float px_r = px_y + 1.402f * px_cr;
120 float px_g = px_y - 0.34414f * px_cb - 0.71414f * px_cr;
121 float px_b = px_y + 1.772f * px_cb;
123 if (px_r < 0.0
f) px_r = 0.0f;
124 else if (px_r > 255.0
f) px_r = 255.0f;
125 if (px_g < 0.0
f) px_g = 0.0f;
126 else if (px_g > 255.0
f) px_g = 255.0f;
127 if (px_b < 0.0
f) px_b = 0.0f;
128 else if (px_b > 255.0
f) px_b = 255.0f;
130 return Eigen::Matrix<T, 3, 1>{
static_cast<T
>(px_b),
static_cast<T
>(px_g),
static_cast<T
>(px_r)};
144 bool scale_calibration);
153 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
167 Eigen::Matrix4d
Q()
const;
179 Eigen::Vector3d
aux_T()
const;
184 Eigen::Vector3f
reproject(
size_t u,
size_t v,
double d)
const;
189 static Eigen::Vector3f
reproject(
size_t u,
192 const sensor_msgs::CameraInfo &left_camera_info,
193 const sensor_msgs::CameraInfo &right_camera_info);
211 const sensor_msgs::CameraInfo &aux_camera_info);
237 sensor_msgs::CameraInfo
auxCameraInfo(
const std::string& frame_id,
240 sensor_msgs::CameraInfo
auxCameraInfo(
const std::string& frame_id,
243 size_t height)
const;
245 std::shared_ptr<RectificationRemapT>
leftRemap()
const;
246 std::shared_ptr<RectificationRemapT>
rightRemap()
const;
276 double borderClipValue,
284 cv::Vec3b
interpolateColor(
const Eigen::Vector2f &pixel,
const cv::Mat &image);
sensor_msgs::CameraInfo aux_camera_info_
Eigen::Matrix4d q_matrix_
cv::Vec3b interpolateColor(const Eigen::Vector2f &pixel, const cv::Mat &image)
Given a floating point pixel location, determine its average color using all neighboring pixels.
Eigen::Vector3f reproject(size_t u, size_t v, double d) const
Reproject disparity values into 3D.
crl::multisense::image::Config config_
BufferWrapper(crl::multisense::Channel *driver, const T &data)
crl::multisense::image::Config config() const
static constexpr size_t S30_AUX_CAM_WIDTH
virtual Status releaseCallbackBuffer(void *referenceP)=0
const crl::multisense::image::Calibration calibration_
bool validAux() const
Determine if the Aux calibration is valid.
double T() const
Translation which transforms points from the rectified left camera frame into the recified right came...
const T & data() const noexcept
sensor_msgs::CameraInfo right_camera_info_
bool clipPoint(const BorderClip &borderClipType, double borderClipValue, size_t height, size_t width, size_t u, size_t v)
Determine if a pixel should be clipped given the provided parameters.
const crl::multisense::system::DeviceInfo & device_info_
bool validRight() const
Determine if the Right calibration is valid.
Eigen::Matrix4d Q() const
Q stereo reprojection matrix see: https://docs.opencv.org/4.3.0/d9/d0c/group__calib3d....
crl::multisense::Channel * driver_
sensor_msgs::CameraInfo rightCameraInfo(const std::string &frame_id, const ros::Time &stamp) const
static constexpr size_t S30_AUX_CAM_HEIGHT
EIGEN_MAKE_ALIGNED_OPERATOR_NEW StereoCalibrationManager(const crl::multisense::image::Config &config, const crl::multisense::image::Calibration &calibration, const crl::multisense::system::DeviceInfo &device_info)
std::shared_ptr< RectificationRemapT > leftRemap() const
OperatingResolutionT operatingStereoResolution() const
Get the current main stereo pair operating resolution. This resolution applies for both the mono and ...
constexpr Eigen::Matrix< T, 3, 1 > ycbcrToBgr(const crl::multisense::image::Header &luma, const crl::multisense::image::Header &chroma, size_t u, size_t v)
sensor_msgs::CameraInfo left_camera_info_
void updateConfig(const crl::multisense::image::Config &config)
std::shared_ptr< RectificationRemapT > rightRemap() const
OperatingResolutionT operatingAuxResolution() const
Get the current aux camera operating resolution. This resolution applies for just the mono topics....
sensor_msgs::CameraInfo auxCameraInfo(const std::string &frame_id, const ros::Time &stamp, const OperatingResolutionT &resolution) const
sensor_msgs::CameraInfo leftCameraInfo(const std::string &frame_id, const ros::Time &stamp) const
BufferWrapper operator=(const BufferWrapper &)=delete
sensor_msgs::CameraInfo makeCameraInfo(const crl::multisense::image::Config &config, const crl::multisense::image::Calibration::Data &calibration, const crl::multisense::system::DeviceInfo &device_info, bool scale_calibration)
RectificationRemapT makeRectificationRemap(const crl::multisense::image::Config &config, const crl::multisense::image::Calibration::Data &calibration, const crl::multisense::system::DeviceInfo &device_info)
std::shared_ptr< RectificationRemapT > left_remap_
std::shared_ptr< RectificationRemapT > right_remap_
Eigen::Vector3d aux_T() const
Translation which transforms points from the rectified left camera frame into the rectified aux camer...
Eigen::Vector2f rectifiedAuxProject(const Eigen::Vector3f &left_rectified_point) const
Project points corresponding to disparity measurements in the left rectified image frame into the aux...
Eigen::Matrix4d makeQ(const crl::multisense::image::Config &config, const crl::multisense::image::Calibration &calibration, const crl::multisense::system::DeviceInfo &device_info)
static bool isValidReprojectedPoint(const Eigen::Vector3f &pt, const float squared_max_range)
Check if a reprojected point falls within a valid range.