Point Cloud Library (PCL) 1.12.0
Loading...
Searching...
No Matches
oni_grabber.h
1/*
2 * Software License Agreement (BSD License)
3 *
4 * Point Cloud Library (PCL) - www.pointclouds.org
5 * Copyright (c) 2011-2012, Willow Garage, Inc.
6 * Copyright (c) 2012-, Open Perception, Inc.
7 *
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 *
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer in the documentation and/or other materials provided
19 * with the distribution.
20 * * Neither the name of the copyright holder(s) nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#pragma once
39
40#include <pcl/memory.h>
41#include <pcl/pcl_config.h>
42#include <pcl/pcl_macros.h>
43
44#ifdef HAVE_OPENNI
45
46#include <pcl/point_cloud.h>
47#include <pcl/io/grabber.h>
48#include <pcl/io/openni_camera/openni_driver.h>
49#include <pcl/io/openni_camera/openni_device_oni.h>
50#include <pcl/io/openni_camera/openni_image.h>
51#include <pcl/io/openni_camera/openni_depth_image.h>
52#include <pcl/io/openni_camera/openni_ir_image.h>
53#include <string>
54#include <pcl/common/synchronizer.h>
55
56namespace pcl
57{
58 struct PointXYZ;
59 struct PointXYZRGB;
60 struct PointXYZRGBA;
61 struct PointXYZI;
62
63 /** \brief A simple ONI grabber.
64 * \author Suat Gedikli
65 * \ingroup io
66 */
67 class PCL_EXPORTS ONIGrabber : public Grabber
68 {
69 public:
70 //define callback signature typedefs
80
81 /** \brief constructor
82 * \param[in] file_name the path to the ONI file
83 * \param[in] repeat whether the play back should be in an infinite loop or not
84 * \param[in] stream whether the playback should be in streaming mode or in triggered mode.
85 */
86 ONIGrabber (const std::string& file_name, bool repeat, bool stream);
87
88 /** \brief destructor never throws an exception */
90
91 /** \brief For devices that are streaming, the streams are started by calling this method.
92 * Trigger-based devices, just trigger the device once for each call of start.
93 */
94 void
95 start () override;
96
97 /** \brief For devices that are streaming, the streams are stopped.
98 * This method has no effect for triggered devices.
99 */
100 void
101 stop () override;
102
103 /** \brief returns the name of the concrete subclass.
104 * \return the name of the concrete driver.
105 */
106 std::string
107 getName () const override;
108
109 /** \brief Indicates whether the grabber is streaming or not. This value is not defined for triggered devices.
110 * \return true if grabber is running / streaming. False otherwise.
111 */
112 bool
113 isRunning () const override;
114
115 /** \brief returns the frames pre second. 0 if it is trigger based. */
116 float
117 getFramesPerSecond () const override;
118
119 /** \brief Check if there is any data left in the ONI file to process. */
120 inline bool
121 hasDataLeft ()
122 {
123 return (device_->hasDataLeft ());
124 }
125
126 protected:
127 /** \brief internal OpenNI (openni_wrapper) callback that handles image streams */
128 void
130
131 /** \brief internal OpenNI (openni_wrapper) callback that handles depth streams */
132 void
134
135 /** \brief internal OpenNI (openni_wrapper) callback that handles IR streams */
136 void
138
139 /** \brief internal callback that handles synchronized image + depth streams */
140 void
143
144 /** \brief internal callback that handles synchronized IR + depth streams */
145 void
148
149 /** \brief internal method to assemble a point cloud object */
152
153 /** \brief internal method to assemble a point cloud object */
157
158 /** \brief internal method to assemble a point cloud object */
162
163 /** \brief internal method to assemble a point cloud object */
167
168 /** \brief synchronizer object to synchronize image and depth streams*/
170
171 /** \brief synchronizer object to synchronize IR and depth streams*/
173
174 /** \brief the actual openni device*/
176 std::string rgb_frame_id_;
177 std::string depth_frame_id_;
179 unsigned image_width_;
181 unsigned depth_width_;
186 boost::signals2::signal<sig_cb_openni_image >* image_signal_;
187 boost::signals2::signal<sig_cb_openni_depth_image >* depth_image_signal_;
188 boost::signals2::signal<sig_cb_openni_ir_image >* ir_image_signal_;
189 boost::signals2::signal<sig_cb_openni_image_depth_image>* image_depth_image_signal_;
190 boost::signals2::signal<sig_cb_openni_ir_depth_image>* ir_depth_image_signal_;
191 boost::signals2::signal<sig_cb_openni_point_cloud >* point_cloud_signal_;
192 boost::signals2::signal<sig_cb_openni_point_cloud_i >* point_cloud_i_signal_;
193 boost::signals2::signal<sig_cb_openni_point_cloud_rgb >* point_cloud_rgb_signal_;
194 boost::signals2::signal<sig_cb_openni_point_cloud_rgba >* point_cloud_rgba_signal_;
195
196 public:
198 };
199
200} // namespace
201#endif // HAVE_OPENNI
pcl::shared_ptr< DepthImage > Ptr
pcl::shared_ptr< DeviceONI > Ptr
pcl::shared_ptr< IRImage > Ptr
pcl::shared_ptr< Image > Ptr
Iterator class for point clouds with or without given indices.
Grabber interface for PCL 1.x device drivers.
Definition grabber.h:60
A simple ONI grabber.
Definition oni_grabber.h:68
pcl::PointCloud< pcl::PointXYZI >::Ptr convertToXYZIPointCloud(const openni_wrapper::IRImage::Ptr &image, const openni_wrapper::DepthImage::Ptr &depth_image) const
internal method to assemble a point cloud object
unsigned depth_height_
unsigned depth_width_
unsigned image_height_
boost::signals2::signal< sig_cb_openni_point_cloud_rgb > * point_cloud_rgb_signal_
openni_wrapper::OpenNIDevice::CallbackHandle ir_callback_handle
ONIGrabber(const std::string &file_name, bool repeat, bool stream)
constructor
void(const pcl::PointCloud< pcl::PointXYZ >::ConstPtr &) sig_cb_openni_point_cloud
Definition oni_grabber.h:76
Synchronizer< openni_wrapper::Image::Ptr, openni_wrapper::DepthImage::Ptr > rgb_sync_
synchronizer object to synchronize image and depth streams
boost::signals2::signal< sig_cb_openni_depth_image > * depth_image_signal_
void(const pcl::PointCloud< pcl::PointXYZRGB >::ConstPtr &) sig_cb_openni_point_cloud_rgb
Definition oni_grabber.h:77
pcl::PointCloud< pcl::PointXYZRGB >::Ptr convertToXYZRGBPointCloud(const openni_wrapper::Image::Ptr &image, const openni_wrapper::DepthImage::Ptr &depth_image) const
internal method to assemble a point cloud object
void(const openni_wrapper::IRImage::Ptr &) sig_cb_openni_ir_image
Definition oni_grabber.h:73
openni_wrapper::OpenNIDevice::CallbackHandle image_callback_handle
openni_wrapper::DeviceONI::Ptr device_
the actual openni device
void irDepthImageCallback(const openni_wrapper::IRImage::Ptr &image, const openni_wrapper::DepthImage::Ptr &depth_image)
internal callback that handles synchronized IR + depth streams
~ONIGrabber() noexcept
destructor never throws an exception
boost::signals2::signal< sig_cb_openni_ir_depth_image > * ir_depth_image_signal_
void(const openni_wrapper::DepthImage::Ptr &) sig_cb_openni_depth_image
Definition oni_grabber.h:72
std::string rgb_frame_id_
boost::signals2::signal< sig_cb_openni_image > * image_signal_
void imageDepthImageCallback(const openni_wrapper::Image::Ptr &image, const openni_wrapper::DepthImage::Ptr &depth_image)
internal callback that handles synchronized image + depth streams
Synchronizer< openni_wrapper::IRImage::Ptr, openni_wrapper::DepthImage::Ptr > ir_sync_
synchronizer object to synchronize IR and depth streams
void(const openni_wrapper::IRImage::Ptr &, const openni_wrapper::DepthImage::Ptr &, float) sig_cb_openni_ir_depth_image
Definition oni_grabber.h:75
unsigned image_width_
boost::signals2::signal< sig_cb_openni_point_cloud > * point_cloud_signal_
void(const openni_wrapper::Image::Ptr &) sig_cb_openni_image
Definition oni_grabber.h:71
void(const pcl::PointCloud< pcl::PointXYZI >::ConstPtr &) sig_cb_openni_point_cloud_i
Definition oni_grabber.h:79
void irCallback(openni_wrapper::IRImage::Ptr ir_image, void *cookie)
internal OpenNI (openni_wrapper) callback that handles IR streams
openni_wrapper::OpenNIDevice::CallbackHandle depth_callback_handle
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr convertToXYZRGBAPointCloud(const openni_wrapper::Image::Ptr &image, const openni_wrapper::DepthImage::Ptr &depth_image) const
internal method to assemble a point cloud object
boost::signals2::signal< sig_cb_openni_point_cloud_rgba > * point_cloud_rgba_signal_
void(const openni_wrapper::Image::Ptr &, const openni_wrapper::DepthImage::Ptr &, float) sig_cb_openni_image_depth_image
Definition oni_grabber.h:74
void(const pcl::PointCloud< pcl::PointXYZRGBA >::ConstPtr &) sig_cb_openni_point_cloud_rgba
Definition oni_grabber.h:78
boost::signals2::signal< sig_cb_openni_ir_image > * ir_image_signal_
void imageCallback(openni_wrapper::Image::Ptr image, void *cookie)
internal OpenNI (openni_wrapper) callback that handles image streams
std::string depth_frame_id_
void depthCallback(openni_wrapper::DepthImage::Ptr depth_image, void *cookie)
internal OpenNI (openni_wrapper) callback that handles depth streams
boost::signals2::signal< sig_cb_openni_image_depth_image > * image_depth_image_signal_
boost::signals2::signal< sig_cb_openni_point_cloud_i > * point_cloud_i_signal_
pcl::PointCloud< pcl::PointXYZ >::Ptr convertToXYZPointCloud(const openni_wrapper::DepthImage::Ptr &depth) const
internal method to assemble a point cloud object
shared_ptr< PointCloud< PointT > > Ptr
shared_ptr< const PointCloud< PointT > > ConstPtr
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Definition memory.h:63
Defines functions, macros and traits for allocating and using memory.
float4 PointXYZRGB
Definition internal.hpp:60
Defines all the PCL and non-PCL macros used.