diff --git a/include/libfreenect2/registration.h b/include/libfreenect2/registration.h index 453ba8903..c36e7abeb 100644 --- a/include/libfreenect2/registration.h +++ b/include/libfreenect2/registration.h @@ -47,7 +47,7 @@ class LIBFREENECT2_API Registration void apply(int dx, int dy, float dz, float& cx, float &cy) const; // undistort/register a whole image - void apply(const Frame* rgb, const Frame* depth, Frame* undistorted, Frame* registered, const bool enable_filter = true, Frame* bigdepth = 0) const; + void apply(const Frame* rgb, const Frame* depth, Frame* undistorted, Frame* registered, const bool enable_filter = true, Frame* bigdepth = 0, int* color_depth_map = 0) const; // compute point XYZ RGB from undistored and registered frames void getPointXYZRGB (const Frame* undistorted, const Frame* registered, int r, int c, float& x, float& y, float& z, float& rgb) const; diff --git a/src/registration.cpp b/src/registration.cpp index 7e4175456..c89cb09c3 100644 --- a/src/registration.cpp +++ b/src/registration.cpp @@ -100,9 +100,10 @@ void Registration::apply( int dx, int dy, float dz, float& cx, float &cy) const * @param [out] registered Image color image for the depth data (512x424). * @param enable_filter Use a depth buffer to remove pixels which are not visible to both cameras. * @param [out] bigdepth If not \c NULL, mapping of depth onto colors (1920x1082 'float' frame). + * @param [out] color_depth_map If not \c NULL, map (512x424) for storing the color offset for each depth pixel. * @note The \a bigdepth frame has a blank top and bottom row. */ -void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorted, Frame *registered, const bool enable_filter, Frame *bigdepth) const +void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorted, Frame *registered, const bool enable_filter, Frame *bigdepth, int *color_depth_map) const { // Check if all frames are valid and have the correct size if (!rgb || !depth || !undistorted || !registered || @@ -136,7 +137,7 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte float *p_filter_map = NULL; // map for storing the color offset for each depth pixel - int *depth_to_c_off = new int[size_depth]; + int *depth_to_c_off = color_depth_map ? color_depth_map : new int[size_depth]; int *map_c_off = depth_to_c_off; // initializing the depth_map with values outside of the Kinect2 range @@ -247,7 +248,7 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte *registered_data = c_off < 0 ? 0 : *(rgb_data + c_off); } } - delete[] depth_to_c_off; + if (!color_depth_map) delete[] depth_to_c_off; } /**