39 #include <visp3/core/vpColorDepthConversion.h>
45 #include <visp3/core/vpMath.h>
46 #include <visp3/core/vpMeterPixelConversion.h>
47 #include <visp3/core/vpPixelMeterConversion.h>
51 #ifndef DOXYGEN_SHOULD_SKIP_THIS
65 #if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98)
81 #if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98)
82 from_point = { from_point, 0, 3 };
84 return { extrinsics_params * from_point, 0, 3 };
88 return vpColVector(extrinsics_params * from_point, 0, 3);
101 #if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98)
121 #if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98)
122 double x { 0. }, y { 0. };
124 return { x * depth, y * depth, depth };
126 double x = 0., y = 0.;
157 const vpImage<uint16_t> &I_depth,
double depth_scale,
double depth_min,
double depth_max,
162 depth_intrinsics, color_intrinsics, color_M_depth, depth_M_color, from_pixel);
183 const uint16_t *data,
double depth_scale,
double depth_min,
double depth_max,
double depth_width,
187 #if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98)
191 const auto min_point = deproject(color_intrinsics, from_pixel, depth_min);
192 const auto min_transformed_point = transform(depth_M_color, min_point);
193 auto start_pixel = project(depth_intrinsics, min_transformed_point);
194 start_pixel = adjust2DPointToBoundary(start_pixel, depth_width, depth_height);
197 const auto max_point = deproject(color_intrinsics, from_pixel, depth_max);
198 const auto max_transformed_point = transform(depth_M_color, max_point);
199 auto end_pixel = project(depth_intrinsics, max_transformed_point);
200 end_pixel = adjust2DPointToBoundary(end_pixel, depth_width, depth_height);
204 for (
auto curr_pixel = start_pixel; curr_pixel.inSegment(start_pixel, end_pixel) && (curr_pixel != end_pixel);
205 curr_pixel = curr_pixel.nextInSegment(start_pixel, end_pixel)) {
206 const auto depth = depth_scale * data[
static_cast<int>((curr_pixel.get_v() * depth_width) + curr_pixel.get_u())];
207 bool stop_for_loop =
false;
208 if (std::fabs(depth) <= std::numeric_limits<double>::epsilon()) {
209 stop_for_loop =
true;
211 if (!stop_for_loop) {
212 const auto point = deproject(depth_intrinsics, curr_pixel, depth);
213 const auto transformed_point = transform(color_M_depth, point);
214 const auto projected_pixel = project(color_intrinsics, transformed_point);
216 const auto new_dist =
vpMath::sqr(projected_pixel.get_v() - from_pixel.
get_v()) +
218 if ((new_dist < min_dist) || (min_dist < 0)) {
220 depth_pixel = curr_pixel;
229 const vpColVector min_point = deproject(color_intrinsics, from_pixel, depth_min);
230 const vpColVector min_transformed_point = transform(depth_M_color, min_point);
231 vpImagePoint start_pixel = project(depth_intrinsics, min_transformed_point);
232 start_pixel = adjust2DPointToBoundary(start_pixel, depth_width, depth_height);
235 const vpColVector max_point = deproject(color_intrinsics, from_pixel, depth_max);
236 const vpColVector max_transformed_point = transform(depth_M_color, max_point);
237 vpImagePoint end_pixel = project(depth_intrinsics, max_transformed_point);
238 end_pixel = adjust2DPointToBoundary(end_pixel, depth_width, depth_height);
241 double min_dist = -1.;
242 for (
vpImagePoint curr_pixel = start_pixel; curr_pixel.
inSegment(start_pixel, end_pixel) && curr_pixel != end_pixel;
243 curr_pixel = curr_pixel.
nextInSegment(start_pixel, end_pixel)) {
244 const double depth = depth_scale * data[
static_cast<int>(curr_pixel.get_v() * depth_width + curr_pixel.get_u())];
246 bool stop_for_loop =
false;
247 if (std::fabs(depth) <= std::numeric_limits<double>::epsilon()) {
248 stop_for_loop =
true;
250 if (!stop_for_loop) {
251 const vpColVector point = deproject(depth_intrinsics, curr_pixel, depth);
252 const vpColVector transformed_point = transform(color_M_depth, point);
253 const vpImagePoint projected_pixel = project(color_intrinsics, transformed_point);
257 if (new_dist < min_dist || min_dist < 0) {
259 depth_pixel = curr_pixel;
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
static vpImagePoint projectColorToDepth(const vpImage< uint16_t > &I_depth, double depth_scale, double depth_min, double depth_max, const vpCameraParameters &depth_intrinsics, const vpCameraParameters &color_intrinsics, const vpHomogeneousMatrix &color_M_depth, const vpHomogeneousMatrix &depth_M_color, const vpImagePoint &from_pixel)
Implementation of an homogeneous matrix and operations on such kind of matrices.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
vpImagePoint nextInSegment(const vpImagePoint &start, const vpImagePoint &end) const
bool inSegment(const vpImagePoint &start, const vpImagePoint &end) const
Definition of the vpImage class member functions.
unsigned int getWidth() const
Type * bitmap
points toward the bitmap
unsigned int getHeight() const
static double sqr(double x)
static T clamp(const T &v, const T &lower, const T &upper)
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)