Skip to content

Commit bad8fae

Browse files
committed
api: Add a function to configure depth processors
Since direct access to depth processors is removed, add Freenect2Device::setConfiguration() to allow users to configure depth processors. This design is consistent with IrCameraParams also being processed in Freenect2Device.
1 parent f6e227d commit bad8fae

File tree

4 files changed

+29
-20
lines changed

4 files changed

+29
-20
lines changed

include/internal/libfreenect2/depth_packet_processor.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <stdint.h>
3434

3535
#include <libfreenect2/config.h>
36+
#include <libfreenect2/libfreenect2.hpp>
3637
#include <libfreenect2/frame_listener.hpp>
3738
#include <libfreenect2/packet_processor.h>
3839

@@ -54,17 +55,7 @@ typedef PacketProcessor<DepthPacket> BaseDepthPacketProcessor;
5455
class DepthPacketProcessor : public BaseDepthPacketProcessor
5556
{
5657
public:
57-
/** Configuration of depth processing. */
58-
struct Config
59-
{
60-
float MinDepth;
61-
float MaxDepth;
62-
63-
bool EnableBilateralFilter; ///< Whether to run the bilateral filter.
64-
bool EnableEdgeAwareFilter; ///< Whether to run the edge aware filter.
65-
66-
Config();
67-
};
58+
typedef Freenect2Device::Config Config;
6859

6960
/** Parameters of depth processing. */
7061
struct Parameters

include/libfreenect2/libfreenect2.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,18 @@ class LIBFREENECT2_API Freenect2Device
8282
float fx, fy, cx, cy, k1, k2, k3, p1, p2;
8383
};
8484

85+
/** Configuration of depth processing. */
86+
struct Config
87+
{
88+
float MinDepth;
89+
float MaxDepth;
90+
91+
bool EnableBilateralFilter; ///< Whether to run the bilateral filter.
92+
bool EnableEdgeAwareFilter; ///< Whether to run the edge aware filter.
93+
94+
Config();
95+
};
96+
8597
virtual ~Freenect2Device();
8698

8799
virtual std::string getSerialNumber() = 0;
@@ -91,6 +103,7 @@ class LIBFREENECT2_API Freenect2Device
91103
virtual Freenect2Device::IrCameraParams getIrCameraParams() = 0;
92104
virtual void setColorCameraParams(const Freenect2Device::ColorCameraParams &params) = 0;
93105
virtual void setIrCameraParams(const Freenect2Device::IrCameraParams &params) = 0;
106+
virtual void setConfiguration(const Config &config) = 0;
94107

95108
virtual void setColorFrameListener(libfreenect2::FrameListener* rgb_frame_listener) = 0;
96109
virtual void setIrAndDepthFrameListener(libfreenect2::FrameListener* ir_frame_listener) = 0;

src/depth_packet_processor.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,6 @@
3232
namespace libfreenect2
3333
{
3434

35-
DepthPacketProcessor::Config::Config() :
36-
MinDepth(0.5f),
37-
MaxDepth(4.5f),
38-
EnableBilateralFilter(true),
39-
EnableEdgeAwareFilter(true)
40-
{
41-
42-
}
43-
4435
DepthPacketProcessor::Parameters::Parameters()
4536
{
4637
ab_multiplier = 0.6666667f;

src/libfreenect2.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ class Freenect2DeviceImpl : public Freenect2Device
252252
virtual Freenect2Device::IrCameraParams getIrCameraParams();
253253
virtual void setColorCameraParams(const Freenect2Device::ColorCameraParams &params);
254254
virtual void setIrCameraParams(const Freenect2Device::IrCameraParams &params);
255+
virtual void setConfiguration(const Freenect2Device::Config &config);
255256

256257
int nextCommandSeq();
257258

@@ -606,6 +607,19 @@ void Freenect2DeviceImpl::setIrCameraParams(const Freenect2Device::IrCameraParam
606607
}
607608
}
608609

610+
Freenect2Device::Config::Config() :
611+
MinDepth(0.5f),
612+
MaxDepth(4.5f),
613+
EnableBilateralFilter(true),
614+
EnableEdgeAwareFilter(true) {}
615+
616+
void Freenect2DeviceImpl::setConfiguration(const Freenect2Device::Config &config)
617+
{
618+
DepthPacketProcessor *proc = pipeline_->getDepthPacketProcessor();
619+
if (proc != 0)
620+
proc->setConfiguration(config);
621+
}
622+
609623
void Freenect2DeviceImpl::setColorFrameListener(libfreenect2::FrameListener* rgb_frame_listener)
610624
{
611625
// TODO: should only be possible, if not started

0 commit comments

Comments
 (0)