From dafca2ea2c76b9e57e9989d982f79eb4f3c0c59b Mon Sep 17 00:00:00 2001 From: Florian Echtler Date: Thu, 9 Jul 2015 22:28:05 +0200 Subject: [PATCH] allow supplying an external Frame for the depth buffer --- examples/protonect/include/libfreenect2/registration.h | 2 +- examples/protonect/src/registration.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/protonect/include/libfreenect2/registration.h b/examples/protonect/include/libfreenect2/registration.h index 2fe65a531..04ec2064b 100644 --- a/examples/protonect/include/libfreenect2/registration.h +++ b/examples/protonect/include/libfreenect2/registration.h @@ -44,7 +44,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) const; + void apply(const Frame* rgb, const Frame* depth, Frame* undistorted, Frame* registered, const bool enable_filter = true, Frame* bigdepth = 0) const; private: void distort(int mx, int my, float& dx, float& dy) const; diff --git a/examples/protonect/src/registration.cpp b/examples/protonect/src/registration.cpp index c658b9b09..f0f440db6 100644 --- a/examples/protonect/src/registration.cpp +++ b/examples/protonect/src/registration.cpp @@ -84,7 +84,7 @@ void Registration::apply( int dx, int dy, float dz, float& cx, float &cy) const cx = rx * color.fx + color.cx; } -void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorted, Frame *registered, const bool enable_filter) const +void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorted, Frame *registered, const bool enable_filter, Frame *bigdepth) const { // Check if all frames are valid and have the correct size if (!rgb || !depth || !undistorted || !registered || @@ -123,7 +123,7 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte // initializing the depth_map with values outside of the Kinect2 range if(enable_filter){ - filter_map = new float[size_filter_map]; + filter_map = bigdepth ? (float*)bigdepth->data : new float[size_filter_map]; p_filter_map = filter_map + offset_filter_map; 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 *registered_data = (z - min_z) / z > filter_tolerance ? 0 : *(rgb_data + c_off); } - delete[] filter_map; + if (!bigdepth) delete[] filter_map; } else {