Skip to content

Commit bfadac8

Browse files
committed
Merge pull request #441 from giacomodabisias/master
add external allocation parameter for color offset map
2 parents 67aad5a + 020088e commit bfadac8

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

include/libfreenect2/registration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class LIBFREENECT2_API Registration
5050
void apply(int dx, int dy, float dz, float& cx, float &cy) const;
5151

5252
// undistort/register a whole image
53-
void apply(const Frame* rgb, const Frame* depth, Frame* undistorted, Frame* registered, const bool enable_filter = true, Frame* bigdepth = 0) const;
53+
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;
5454

5555
// compute point XYZ RGB from undistored and registered frames
5656
void getPointXYZRGB (const Frame* undistorted, const Frame* registered, int r, int c, float& x, float& y, float& z, float& rgb) const;

src/registration.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,10 @@ void RegistrationImpl::apply( int dx, int dy, float dz, float& cx, float &cy) co
130130
* @param [out] registered Image color image for the depth data (512x424).
131131
* @param enable_filter Use a depth buffer to remove pixels which are not visible to both cameras.
132132
* @param [out] bigdepth If not \c NULL, mapping of depth onto colors (1920x1082 'float' frame).
133+
* @param [out] color_depth_map If not \c NULL, map (512x424) for storing the color offset for each depth pixel.
133134
* @note The \a bigdepth frame has a blank top and bottom row.
134135
*/
135-
void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorted, Frame *registered, const bool enable_filter, Frame *bigdepth) const
136+
void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorted, Frame *registered, const bool enable_filter, Frame *bigdepth, int *color_depth_map) const
136137
{
137138
impl_->apply(rgb, depth, undistorted, registered, enable_filter, bigdepth);
138139
}
@@ -171,7 +172,7 @@ void RegistrationImpl::apply(const Frame *rgb, const Frame *depth, Frame *undist
171172
float *p_filter_map = NULL;
172173

173174
// map for storing the color offset for each depth pixel
174-
int *depth_to_c_off = new int[size_depth];
175+
int *depth_to_c_off = color_depth_map ? color_depth_map : new int[size_depth];
175176
int *map_c_off = depth_to_c_off;
176177

177178
// initializing the depth_map with values outside of the Kinect2 range
@@ -282,7 +283,7 @@ void RegistrationImpl::apply(const Frame *rgb, const Frame *depth, Frame *undist
282283
*registered_data = c_off < 0 ? 0 : *(rgb_data + c_off);
283284
}
284285
}
285-
delete[] depth_to_c_off;
286+
if (!color_depth_map) delete[] depth_to_c_off;
286287
}
287288

288289
/**

0 commit comments

Comments
 (0)