Skip to content

Commit 92f6818

Browse files
committed
Merge pull request #317 from floe/registration-hd
allow supplying an external Frame for the depth buffer
2 parents 24d6139 + dafca2e commit 92f6818

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

examples/protonect/include/libfreenect2/registration.h

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

4646
// undistort/register a whole image
47-
void apply(const Frame* rgb, const Frame* depth, Frame* undistorted, Frame* registered, const bool enable_filter = true) const;
47+
void apply(const Frame* rgb, const Frame* depth, Frame* undistorted, Frame* registered, const bool enable_filter = true, Frame* bigdepth = 0) const;
4848

4949
private:
5050
void distort(int mx, int my, float& dx, float& dy) const;

examples/protonect/src/registration.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void Registration::apply( int dx, int dy, float dz, float& cx, float &cy) const
8484
cx = rx * color.fx + color.cx;
8585
}
8686

87-
void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorted, Frame *registered, const bool enable_filter) const
87+
void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorted, Frame *registered, const bool enable_filter, Frame *bigdepth) const
8888
{
8989
// Check if all frames are valid and have the correct size
9090
if (!rgb || !depth || !undistorted || !registered ||
@@ -123,7 +123,7 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte
123123

124124
// initializing the depth_map with values outside of the Kinect2 range
125125
if(enable_filter){
126-
filter_map = new float[size_filter_map];
126+
filter_map = bigdepth ? (float*)bigdepth->data : new float[size_filter_map];
127127
p_filter_map = filter_map + offset_filter_map;
128128

129129
for(float *it = filter_map, *end = filter_map + size_filter_map; it != end; ++it){
@@ -210,7 +210,7 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte
210210
*registered_data = (z - min_z) / z > filter_tolerance ? 0 : *(rgb_data + c_off);
211211
}
212212

213-
delete[] filter_map;
213+
if (!bigdepth) delete[] filter_map;
214214
}
215215
else
216216
{

0 commit comments

Comments
 (0)