Loading...
Searching...
No Matches
depth_sense_grabber_impl.h
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2014-, Open Perception, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder(s) nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#pragma once
#include <pcl/common/time.h>
#include <pcl/io/buffers.h>
#include <pcl/io/depth_sense_grabber.h>
#include <DepthSense.hxx>
#include <memory>
#include <mutex>
namespace pcl
{
namespace io
{
namespace depth_sense
{
struct DepthSenseGrabberImpl
{
/// Parent grabber
DepthSenseGrabber* p_;
/// Serial number of the device captured by this grabber
std::string device_id_;
bool is_running_;
int confidence_threshold_;
DepthSenseGrabber::TemporalFilteringType temporal_filtering_type_;
std::shared_ptr<DepthSense::ProjectionHelper> projection_;
using sig_cb_depth_sense_point_cloud = DepthSenseGrabber::sig_cb_depth_sense_point_cloud;
using sig_cb_depth_sense_point_cloud_rgba = DepthSenseGrabber::sig_cb_depth_sense_point_cloud_rgba;
/// Signal to indicate whether new XYZ cloud is available
boost::signals2::signal<sig_cb_depth_sense_point_cloud>* point_cloud_signal_;
/// Signal to indicate whether new XYZRGBA cloud is available
boost::signals2::signal<sig_cb_depth_sense_point_cloud_rgba>* point_cloud_rgba_signal_;
/// Indicates whether there are subscribers for PointXYZ signal. This is
/// computed and stored on start()
bool need_xyz_;
/// Indicates whether there are subscribers for PointXYZRGBA signal. This
/// is computed and stored on start()
bool need_xyzrgba_;
EventFrequency frequency_;
mutable std::mutex fps_mutex_;
/// Temporary buffer to store color data
std::vector<std::uint8_t> color_data_;
std::shared_ptr<pcl::io::Buffer<float> > depth_buffer_;
static const int FRAMERATE = 30;
static const int WIDTH = 320;
static const int HEIGHT = 240;
static const int SIZE = WIDTH * HEIGHT;
static const int COLOR_WIDTH = 640;
static const int COLOR_HEIGHT = 480;
static const int COLOR_SIZE = COLOR_WIDTH * COLOR_HEIGHT;
DepthSenseGrabberImpl (DepthSenseGrabber* parent, const std::string& device_id);
~DepthSenseGrabberImpl () noexcept;
void
start ();
void
stop ();
float
getFramesPerSecond () const;
void
setConfidenceThreshold (int threshold);
void
enableTemporalFiltering (DepthSenseGrabber::TemporalFilteringType type, std::size_t window_size);
void
setCameraParameters (const DepthSense::StereoCameraParameters& parameters);
void
configureDepthNode (DepthSense::DepthNode node) const;
void
configureColorNode (DepthSense::ColorNode node) const;
/** A callback for processing depth data.
*
* It is supposed to be called from the DepthSense::Context thread that
* is managed by DepthSenseDeviceManager. */
void
onDepthDataReceived (DepthSense::DepthNode node, DepthSense::DepthNode::NewSampleReceivedData data);
/** A callback for processing color data.
*
* It is supposed to be called from the DepthSense::Context thread that
* is managed by DepthSenseDeviceManager. */
void
onColorDataReceived (DepthSense::ColorNode node, DepthSense::ColorNode::NewSampleReceivedData data);
template <typename Point> void
computeXYZ (PointCloud<Point>& cloud);
};
}
}
}
pcl::DepthSenseGrabber
Grabber for DepthSense devices (e.g.
Definition depth_sense_grabber.h:57
pcl::DepthSenseGrabber::sig_cb_depth_sense_point_cloud
void(const pcl::PointCloud< pcl::PointXYZ >::ConstPtr &) sig_cb_depth_sense_point_cloud
Definition depth_sense_grabber.h:64
pcl::DepthSenseGrabber::sig_cb_depth_sense_point_cloud_rgba
void(const pcl::PointCloud< pcl::PointXYZRGBA >::ConstPtr &) sig_cb_depth_sense_point_cloud_rgba
Definition depth_sense_grabber.h:65
pcl::DepthSenseGrabber::TemporalFilteringType
TemporalFilteringType
Definition depth_sense_grabber.h:73
pcl::EventFrequency
A helper class to measure frequency of a certain event.
Definition time.h:133
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition point_cloud.h:174
time.h
Define methods for measuring time spent in code blocks.
pcl::io::depth_sense
Definition depth_sense_device_manager.h:56
pcl::io
Definition io.h:517
pcl
Definition convolution.h:46
pcl::io::depth_sense::DepthSenseGrabberImpl::stop
void stop()
pcl::io::depth_sense::DepthSenseGrabberImpl::SIZE
static const int SIZE
Definition depth_sense_grabber_impl.h:101
pcl::io::depth_sense::DepthSenseGrabberImpl::sig_cb_depth_sense_point_cloud_rgba
DepthSenseGrabber::sig_cb_depth_sense_point_cloud_rgba sig_cb_depth_sense_point_cloud_rgba
Definition depth_sense_grabber_impl.h:75
pcl::io::depth_sense::DepthSenseGrabberImpl::getFramesPerSecond
float getFramesPerSecond() const
pcl::io::depth_sense::DepthSenseGrabberImpl::need_xyzrgba_
bool need_xyzrgba_
Indicates whether there are subscribers for PointXYZRGBA signal.
Definition depth_sense_grabber_impl.h:88
pcl::io::depth_sense::DepthSenseGrabberImpl::point_cloud_signal_
boost::signals2::signal< sig_cb_depth_sense_point_cloud > * point_cloud_signal_
Signal to indicate whether new XYZ cloud is available.
Definition depth_sense_grabber_impl.h:78
pcl::io::depth_sense::DepthSenseGrabberImpl::frequency_
EventFrequency frequency_
Definition depth_sense_grabber_impl.h:90
pcl::io::depth_sense::DepthSenseGrabberImpl::configureColorNode
void configureColorNode(DepthSense::ColorNode node) const
pcl::io::depth_sense::DepthSenseGrabberImpl::onDepthDataReceived
void onDepthDataReceived(DepthSense::DepthNode node, DepthSense::DepthNode::NewSampleReceivedData data)
A callback for processing depth data.
pcl::io::depth_sense::DepthSenseGrabberImpl::confidence_threshold_
int confidence_threshold_
Definition depth_sense_grabber_impl.h:69
pcl::io::depth_sense::DepthSenseGrabberImpl::~DepthSenseGrabberImpl
~DepthSenseGrabberImpl() noexcept
pcl::io::depth_sense::DepthSenseGrabberImpl::start
void start()
pcl::io::depth_sense::DepthSenseGrabberImpl::color_data_
std::vector< std::uint8_t > color_data_
Temporary buffer to store color data.
Definition depth_sense_grabber_impl.h:94
pcl::io::depth_sense::DepthSenseGrabberImpl::enableTemporalFiltering
void enableTemporalFiltering(DepthSenseGrabber::TemporalFilteringType type, std::size_t window_size)
pcl::io::depth_sense::DepthSenseGrabberImpl::p_
DepthSenseGrabber * p_
Parent grabber.
Definition depth_sense_grabber_impl.h:62
pcl::io::depth_sense::DepthSenseGrabberImpl::setCameraParameters
void setCameraParameters(const DepthSense::StereoCameraParameters &parameters)
pcl::io::depth_sense::DepthSenseGrabberImpl::device_id_
std::string device_id_
Serial number of the device captured by this grabber.
Definition depth_sense_grabber_impl.h:65
pcl::io::depth_sense::DepthSenseGrabberImpl::fps_mutex_
std::mutex fps_mutex_
Definition depth_sense_grabber_impl.h:91
pcl::io::depth_sense::DepthSenseGrabberImpl::depth_buffer_
std::shared_ptr< pcl::io::Buffer< float > > depth_buffer_
Definition depth_sense_grabber_impl.h:96
pcl::io::depth_sense::DepthSenseGrabberImpl::need_xyz_
bool need_xyz_
Indicates whether there are subscribers for PointXYZ signal.
Definition depth_sense_grabber_impl.h:84
pcl::io::depth_sense::DepthSenseGrabberImpl::sig_cb_depth_sense_point_cloud
DepthSenseGrabber::sig_cb_depth_sense_point_cloud sig_cb_depth_sense_point_cloud
Definition depth_sense_grabber_impl.h:74
pcl::io::depth_sense::DepthSenseGrabberImpl::onColorDataReceived
void onColorDataReceived(DepthSense::ColorNode node, DepthSense::ColorNode::NewSampleReceivedData data)
A callback for processing color data.
pcl::io::depth_sense::DepthSenseGrabberImpl::HEIGHT
static const int HEIGHT
Definition depth_sense_grabber_impl.h:100
pcl::io::depth_sense::DepthSenseGrabberImpl::setConfidenceThreshold
void setConfidenceThreshold(int threshold)
pcl::io::depth_sense::DepthSenseGrabberImpl::FRAMERATE
static const int FRAMERATE
Definition depth_sense_grabber_impl.h:98
pcl::io::depth_sense::DepthSenseGrabberImpl::WIDTH
static const int WIDTH
Definition depth_sense_grabber_impl.h:99
pcl::io::depth_sense::DepthSenseGrabberImpl::point_cloud_rgba_signal_
boost::signals2::signal< sig_cb_depth_sense_point_cloud_rgba > * point_cloud_rgba_signal_
Signal to indicate whether new XYZRGBA cloud is available.
Definition depth_sense_grabber_impl.h:80
pcl::io::depth_sense::DepthSenseGrabberImpl::COLOR_HEIGHT
static const int COLOR_HEIGHT
Definition depth_sense_grabber_impl.h:103
pcl::io::depth_sense::DepthSenseGrabberImpl::computeXYZ
void computeXYZ(PointCloud< Point > &cloud)
pcl::io::depth_sense::DepthSenseGrabberImpl::COLOR_WIDTH
static const int COLOR_WIDTH
Definition depth_sense_grabber_impl.h:102
pcl::io::depth_sense::DepthSenseGrabberImpl::COLOR_SIZE
static const int COLOR_SIZE
Definition depth_sense_grabber_impl.h:104
pcl::io::depth_sense::DepthSenseGrabberImpl::temporal_filtering_type_
DepthSenseGrabber::TemporalFilteringType temporal_filtering_type_
Definition depth_sense_grabber_impl.h:70
pcl::io::depth_sense::DepthSenseGrabberImpl::is_running_
bool is_running_
Definition depth_sense_grabber_impl.h:67
pcl::io::depth_sense::DepthSenseGrabberImpl::projection_
std::shared_ptr< DepthSense::ProjectionHelper > projection_
Definition depth_sense_grabber_impl.h:72
pcl::io::depth_sense::DepthSenseGrabberImpl::configureDepthNode
void configureDepthNode(DepthSense::DepthNode node) const
pcl::io::depth_sense::DepthSenseGrabberImpl::DepthSenseGrabberImpl
DepthSenseGrabberImpl(DepthSenseGrabber *parent, const std::string &device_id)