38 #include <pcl/pcl_config.h> 40 #ifndef PCL_IO_PCD_GRABBER_H_ 41 #define PCL_IO_PCD_GRABBER_H_ 43 #include <pcl/common/io.h> 44 #include <pcl/io/grabber.h> 45 #include <pcl/io/file_grabber.h> 46 #include <pcl/common/time_trigger.h> 49 #include <pcl/conversions.h> 52 #include <pcl/io/openni_camera/openni_image.h> 53 #include <pcl/io/openni_camera/openni_image_rgb24.h> 54 #include <pcl/io/openni_camera/openni_depth_image.h> 70 PCDGrabberBase (
const std::string& pcd_file,
float frames_per_second,
bool repeat);
77 PCDGrabberBase (
const std::vector<std::string>& pcd_files,
float frames_per_second,
bool repeat);
128 getFramesPerSecond () const;
136 getCloudAt (
size_t idx,
138 Eigen::Vector4f &origin,
139 Eigen::Quaternionf &orientation) const;
147 publish (const
pcl::
PCLPointCloud2& blob, const
Eigen::Vector4f& origin, const
Eigen::Quaternionf& orientation, const
std::
string& file_name) const = 0;
150 struct PCDGrabberImpl;
151 PCDGrabberImpl* impl_;
159 PCDGrabber (
const std::string& pcd_path,
float frames_per_second = 0,
bool repeat =
false);
160 PCDGrabber (
const std::vector<std::string>& pcd_files,
float frames_per_second = 0,
bool repeat =
false);
169 const boost::shared_ptr< const pcl::PointCloud<PointT> >
170 operator[] (
size_t idx)
const;
178 publish (
const pcl::PCLPointCloud2& blob,
const Eigen::Vector4f& origin,
const Eigen::Quaternionf& orientation,
const std::string& file_name)
const;
180 boost::signals2::signal<void (const boost::shared_ptr<const pcl::PointCloud<PointT> >&)>* signal_;
184 boost::signals2::signal<void (const boost::shared_ptr<openni_wrapper::DepthImage>&)>* depth_image_signal_;
185 boost::signals2::signal<void (const boost::shared_ptr<openni_wrapper::Image>&)>* image_signal_;
186 boost::signals2::signal<void (const boost::shared_ptr<openni_wrapper::Image>&,
const boost::shared_ptr<openni_wrapper::DepthImage>&,
float constant)>* image_depth_image_signal_;
191 template<
typename Po
intT>
195 signal_ = createSignal<void (const boost::shared_ptr<const pcl::PointCloud<PointT> >&)>();
198 depth_image_signal_ = createSignal <void (const boost::shared_ptr<openni_wrapper::DepthImage>&)> ();
199 image_signal_ = createSignal <void (const boost::shared_ptr<openni_wrapper::Image>&)> ();
200 image_depth_image_signal_ = createSignal <void (const boost::shared_ptr<openni_wrapper::Image>&,
const boost::shared_ptr<openni_wrapper::DepthImage>&,
float constant)> ();
205 template<
typename Po
intT>
207 :
PCDGrabberBase (pcd_files, frames_per_second, repeat), signal_ ()
209 signal_ = createSignal<void (const boost::shared_ptr<const pcl::PointCloud<PointT> >&)>();
212 depth_image_signal_ = createSignal <void (const boost::shared_ptr<openni_wrapper::DepthImage>&)> ();
213 image_signal_ = createSignal <void (const boost::shared_ptr<openni_wrapper::Image>&)> ();
214 image_depth_image_signal_ = createSignal <void (const boost::shared_ptr<openni_wrapper::Image>&,
const boost::shared_ptr<openni_wrapper::DepthImage>&,
float constant)> ();
219 template<
typename Po
intT>
const boost::shared_ptr< const pcl::PointCloud<PointT> >
223 Eigen::Vector4f origin;
224 Eigen::Quaternionf orientation;
225 getCloudAt (idx, blob, origin, orientation);
234 template <
typename Po
intT>
size_t 237 return (numFrames ());
241 template<
typename Po
intT>
void 249 signal_->operator () (cloud);
250 if (file_name_signal_->num_slots() > 0)
251 file_name_signal_->operator()(file_name);
258 boost::shared_ptr<xn::DepthMetaData> depth_meta_data (
new xn::DepthMetaData);
259 depth_meta_data->AllocateData (cloud->
width, cloud->
height);
260 XnDepthPixel* depth_map = depth_meta_data->WritableData ();
262 for (uint32_t i = 0; i < cloud->
height; ++i)
263 for (uint32_t j = 0; j < cloud->
width; ++j)
265 depth_map[k] =
static_cast<XnDepthPixel
> ((*cloud)[k].z * 1000);
269 boost::shared_ptr<openni_wrapper::DepthImage> depth_image (
new openni_wrapper::DepthImage (depth_meta_data, 0.075f, 525, 0, 0));
270 if (depth_image_signal_->num_slots() > 0)
271 depth_image_signal_->operator()(depth_image);
274 std::vector<pcl::PCLPointField> fields;
276 if (rgba_index == -1)
280 rgba_index = fields[rgba_index].offset;
282 boost::shared_ptr<xn::ImageMetaData> image_meta_data (
new xn::ImageMetaData);
283 image_meta_data->AllocateData (cloud->
width, cloud->
height, XN_PIXEL_FORMAT_RGB24);
284 XnRGB24Pixel* image_map = image_meta_data->WritableRGB24Data ();
286 for (uint32_t i = 0; i < cloud->
height; ++i)
288 for (uint32_t j = 0; j < cloud->
width; ++j)
292 memcpy (&rgb, reinterpret_cast<const char*> (&cloud->
points[k]) + rgba_index, sizeof (
RGB));
293 image_map[k].nRed =
static_cast<XnUInt8
> (rgb.r);
294 image_map[k].nGreen =
static_cast<XnUInt8
> (rgb.g);
295 image_map[k].nBlue =
static_cast<XnUInt8
> (rgb.b);
301 if (image_signal_->num_slots() > 0)
302 image_signal_->operator()(image);
304 if (image_depth_image_signal_->num_slots() > 0)
305 image_depth_image_signal_->operator()(image, depth_image, 1.0f / 525.0f);
void fromPCLPointCloud2(const pcl::PCLPointCloud2 &msg, pcl::PointCloud< PointT > &cloud, const MsgFieldMap &field_map)
Convert a PCLPointCloud2 binary data blob into a pcl::PointCloud<T> object using a field_map...
PCDGrabberBase(const PCDGrabberBase &src)
Copy constructor.
int getFieldIndex(const pcl::PCLPointCloud2 &cloud, const std::string &field_name)
Get the index of a specified field (i.e., dimension/channel)
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
boost::signals2::signal< void(const boost::shared_ptr< const pcl::PointCloud< PointT > > &)> * signal_
boost::signals2::signal< void(const boost::shared_ptr< openni_wrapper::DepthImage > &)> * depth_image_signal_
boost::signals2::signal< void(const boost::shared_ptr< openni_wrapper::Image > &)> * image_signal_
Grabber interface for PCL 1.x device drivers.
PCDGrabber(const std::string &pcd_path, float frames_per_second=0, bool repeat=false)
const boost::shared_ptr< const pcl::PointCloud< PointT > > operator[](size_t idx) const
operator[] Returns the idx-th cloud in the dataset, without bounds checking.
uint32_t height
The point cloud height (if organized as an image-structure).
This class provides methods to fill a depth or disparity image.
bool isOrganized() const
Return whether a dataset is organized (e.g., arranged in a structured grid).
boost::shared_ptr< PointCloud< PointT > > Ptr
Eigen::Vector4f sensor_origin_
Sensor acquisition pose (origin/translation).
A structure representing RGB color information.
uint32_t width
The point cloud width (if organized as an image-structure).
virtual ~PCDGrabber()
Virtual destructor.
FileGrabber provides a container-style interface for grabbers which operate on fixed-size input...
Eigen::Quaternionf sensor_orientation_
Sensor acquisition pose (rotation).
Base class for PCD file grabber.
This class provides methods to fill a RGB or Grayscale image buffer from underlying RGB24 image...
boost::signals2::signal< void(const boost::shared_ptr< openni_wrapper::Image > &, const boost::shared_ptr< openni_wrapper::DepthImage > &, float constant)> * image_depth_image_signal_
PointCloud represents the base class in PCL for storing collections of 3D points. ...
boost::signals2::signal< void(const std::string &)> * file_name_signal_
size_t size() const
size Returns the number of clouds currently loaded by the grabber
A point structure representing Euclidean xyz coordinates, and the RGB color.
virtual void publish(const pcl::PCLPointCloud2 &blob, const Eigen::Vector4f &origin, const Eigen::Quaternionf &orientation, const std::string &file_name) const