|
1 | 1 | /*
|
2 |
| -* Software License Agreement (BSD License) |
3 |
| -* |
4 |
| -* Point Cloud Library (PCL) - www.pointclouds.org |
5 |
| -* Copyright (c) 2015-, Open Perception, Inc. |
6 |
| -* |
7 |
| -* All rights reserved. |
8 |
| -* |
9 |
| -* Redistribution and use in source and binary forms, with or without |
10 |
| -* modification, are permitted provided that the following conditions |
11 |
| -* are met: |
12 |
| -* |
13 |
| -* * Redistributions of source code must retain the above copyright |
14 |
| -* notice, this list of conditions and the following disclaimer. |
15 |
| -* * Redistributions in binary form must reproduce the above |
16 |
| -* copyright notice, this list of conditions and the following |
17 |
| -* disclaimer in the documentation and/or other materials provided |
18 |
| -* with the distribution. |
19 |
| -* * Neither the name of the copyright holder(s) nor the names of its |
20 |
| -* contributors may be used to endorse or promote products derived |
21 |
| -* from this software without specific prior written permission. |
22 |
| -* |
23 |
| -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
24 |
| -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
25 |
| -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
26 |
| -* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
27 |
| -* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
28 |
| -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
29 |
| -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
30 |
| -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
31 |
| -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
32 |
| -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
33 |
| -* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
34 |
| -* POSSIBILITY OF SUCH DAMAGE. |
35 |
| -* |
36 |
| -*/ |
| 2 | + * Software License Agreement (BSD License) |
| 3 | + * |
| 4 | + * Point Cloud Library (PCL) - www.pointclouds.org |
| 5 | + * Copyright (c) 2015-, Open Perception, Inc. |
| 6 | + * |
| 7 | + * All rights reserved. |
| 8 | + * |
| 9 | + * Redistribution and use in source and binary forms, with or without |
| 10 | + * modification, are permitted provided that the following conditions |
| 11 | + * are met: |
| 12 | + * |
| 13 | + * * Redistributions of source code must retain the above copyright |
| 14 | + * notice, this list of conditions and the following disclaimer. |
| 15 | + * * Redistributions in binary form must reproduce the above |
| 16 | + * copyright notice, this list of conditions and the following |
| 17 | + * disclaimer in the documentation and/or other materials provided |
| 18 | + * with the distribution. |
| 19 | + * * Neither the name of the copyright holder(s) nor the names of its |
| 20 | + * contributors may be used to endorse or promote products derived |
| 21 | + * from this software without specific prior written permission. |
| 22 | + * |
| 23 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 24 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 25 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 26 | + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 27 | + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 28 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 29 | + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 30 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 31 | + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 32 | + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| 33 | + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 34 | + * POSSIBILITY OF SUCH DAMAGE. |
| 35 | + * |
| 36 | + */ |
37 | 37 |
|
38 | 38 | #ifndef PCL_IO_FREENECT2_GRABBER_H
|
39 | 39 | #define PCL_IO_FREENECT2_GRABBER_H
|
|
55 | 55 |
|
56 | 56 | #include <limits>
|
57 | 57 |
|
58 |
| - |
59 | 58 | namespace pcl
|
60 | 59 | {
|
61 |
| - enum processor |
62 |
| - { |
63 |
| - CPU, OPENCL, OPENGL |
64 |
| - }; |
65 |
| - |
66 |
| - class PCL_EXPORTS k4w2Grabber : public Grabber |
67 |
| - { |
68 |
| - public: |
69 |
| - typedef |
70 |
| - void (sig_cb_k4w2_point_cloud_rgb) |
71 |
| - (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr&); |
72 |
| - |
73 |
| - k4w2Grabber(processor p = CPU, std::string serial = std::string()); |
74 |
| - virtual |
75 |
| - ~k4w2Grabber() throw(); |
76 |
| - |
77 |
| - virtual bool |
78 |
| - isRunning() const; |
79 |
| - |
80 |
| - virtual void |
81 |
| - start(); |
82 |
| - |
83 |
| - virtual void |
84 |
| - stop(); |
85 |
| - |
86 |
| - virtual std::string |
87 |
| - getName() const |
88 |
| - { |
89 |
| - return (std::string("K4W2Grabber")); |
90 |
| - } |
91 |
| - |
92 |
| - virtual std::string |
93 |
| - getDeviceSerialNumber() const |
94 |
| - { |
95 |
| - return dev_->getSerialNumber(); |
96 |
| - } |
97 |
| - |
98 |
| - virtual float |
99 |
| - getFramesPerSecond() const; |
100 |
| - |
101 |
| - private: |
102 |
| - void |
103 |
| - run(); |
104 |
| - |
105 |
| - void prepareMake3D(const libfreenect2::Freenect2Device::IrCameraParams & depth_p); |
106 |
| - |
107 |
| - // Signals to indicate whether new clouds are available |
108 |
| - boost::signals2::signal<sig_cb_k4w2_point_cloud_rgb>* point_cloud_rgb_signal_; |
109 |
| - |
110 |
| - boost::thread thread_; |
111 |
| - |
112 |
| - bool is_running_; |
113 |
| - |
114 |
| - /// Indicates whether there are subscribers for PointXYZRGBA signal, |
115 |
| - /// computed and stored on start() |
116 |
| - bool need_xyzrgb_; |
117 |
| - |
118 |
| - EventFrequency frequency_; |
119 |
| - mutable boost::mutex fps_mutex_; |
120 |
| - |
121 |
| - libfreenect2::Registration* registration_ = 0; |
122 |
| - |
123 |
| - libfreenect2::Freenect2 freenect2_; |
124 |
| - libfreenect2::Freenect2Device * dev_ = 0; |
125 |
| - libfreenect2::SyncMultiFrameListener * listener_ = 0; |
126 |
| - libfreenect2::PacketPipeline * pipeline_ = 0; |
127 |
| - libfreenect2::FrameMap frames_; |
128 |
| - libfreenect2::Frame undistorted_, registered_, big_mat_; |
129 |
| - Eigen::Matrix<float,512,1> colmap_; |
130 |
| - Eigen::Matrix<float,424,1> rowmap_; |
131 |
| - std::string serial_; |
132 |
| - int map_[512 * 424]; |
133 |
| - float qnan_; |
134 |
| - }; |
| 60 | + enum processor |
| 61 | + { |
| 62 | + CPU, OPENCL, OPENGL |
| 63 | + }; |
| 64 | + |
| 65 | +class PCL_EXPORTS k4w2Grabber : public Grabber |
| 66 | +{ |
| 67 | + public: |
| 68 | + typedef |
| 69 | + void (sig_cb_k4w2_point_cloud_rgb) |
| 70 | + (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr&); |
| 71 | + |
| 72 | + k4w2Grabber(processor p = CPU, std::string serial = std::string()); |
| 73 | + virtual |
| 74 | + ~k4w2Grabber() throw(); |
| 75 | + |
| 76 | + virtual bool |
| 77 | + isRunning() const; |
| 78 | + |
| 79 | + virtual void |
| 80 | + start(); |
| 81 | + |
| 82 | + virtual void |
| 83 | + stop(); |
| 84 | + |
| 85 | + virtual std::string |
| 86 | + getName() const |
| 87 | + { |
| 88 | + return (std::string("K4W2Grabber")); |
| 89 | + } |
| 90 | + |
| 91 | + virtual std::string |
| 92 | + getDeviceSerialNumber() const |
| 93 | + { |
| 94 | + return dev_->getSerialNumber(); |
| 95 | + } |
| 96 | + |
| 97 | + virtual float |
| 98 | + getFramesPerSecond() const; |
| 99 | + |
| 100 | + private: |
| 101 | + void |
| 102 | + run(); |
| 103 | + |
| 104 | + void prepareMake3D(const libfreenect2::Freenect2Device::IrCameraParams & depth_p); |
| 105 | + |
| 106 | + // Signals to indicate whether new clouds are available |
| 107 | + boost::signals2::signal<sig_cb_k4w2_point_cloud_rgb>* point_cloud_rgb_signal_; |
| 108 | + |
| 109 | + boost::thread thread_; |
| 110 | + |
| 111 | + bool is_running_; |
| 112 | + |
| 113 | + /// Indicates whether there are subscribers for PointXYZRGBA signal, |
| 114 | + /// computed and stored on start() |
| 115 | + bool need_xyzrgb_; |
| 116 | + |
| 117 | + EventFrequency frequency_; |
| 118 | + mutable boost::mutex fps_mutex_; |
| 119 | + |
| 120 | + libfreenect2::Registration* registration_ = 0; |
| 121 | + |
| 122 | + libfreenect2::Freenect2 freenect2_; |
| 123 | + libfreenect2::Freenect2Device * dev_ = 0; |
| 124 | + libfreenect2::SyncMultiFrameListener * listener_ = 0; |
| 125 | + libfreenect2::PacketPipeline * pipeline_ = 0; |
| 126 | + libfreenect2::FrameMap frames_; |
| 127 | + libfreenect2::Frame undistorted_, registered_, big_mat_; |
| 128 | + Eigen::Matrix<float,512,1> colmap_; |
| 129 | + Eigen::Matrix<float,424,1> rowmap_; |
| 130 | + std::string serial_; |
| 131 | + int map_[512 * 424]; |
| 132 | + float qnan_; |
| 133 | +}; |
135 | 134 | }
|
136 | 135 |
|
137 | 136 | #endif // PCL_IO_FREENECT2_GRABBER_H
|
0 commit comments