CapturingPointCloudProvider.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package VisionX::Core
19 * @author David Gonzalez Aguirre (david dot gonzalez at kit dot edu)
20 * @date 2014
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25#pragma once
26
27
28#include <mutex>
29
31
33
34#include "PointCloudProvider.h"
35
36namespace visionx
37{
38
41 {
42 public:
45 {
46 defineOptionalProperty<float>("framerate", 30.0f, "framerate for the point clouds")
47 .setMin(0.0f)
48 .setMax(60.0f);
50 "isEnabled", true, "enable the capturing process immediately");
51 }
52 };
53
54 /**
55 * The CapturingPointCloudProvider provides a callback function to trigger
56 * the capturing of point clouds with different synchronization modes.
57 */
59 virtual public PointCloudProvider,
60 virtual public CapturingPointCloudProviderInterface
61 {
62 public:
63 // ================================================================== //
64 // == CapturingPointCloudProvider ice interface ========================== //
65 // ================================================================== //
66 /**
67 * Starts point cloud capturing.
68 *
69 *
70 * @throw visionx::PointCloudProviderResolutionNotSupportedException
71 * @throw visionx::PointCloudProviderStartingCaptureFailedException
72 */
73 void startCapture(const Ice::Current& c = Ice::emptyCurrent) override;
74
75 /**
76 * Starts point cloud capturing.
77 *
78 * @param numFrames Automatically stop capture after this amount of captured frames
79 *
80 * @throw visionx::PointCloudProviderResolutionNotSupportedException
81 * @throw visionx::PointCloudProviderStartingCaptureFailedException
82 */
83 void startCaptureForNumFrames(int numFrames,
84 const Ice::Current& c = Ice::emptyCurrent) override;
85
86 /**
87 * Stops point cloud capturing. The Capturing can be started again by re-calling
88 * startCapture(...).
89 */
90 void stopCapture(const Ice::Current& c = Ice::emptyCurrent) override;
91
92
93 /**
94 * set a new frame rate
95 *
96 * @param framesPerSecond Frames per second to capture.
97 * @throw visionx::PointCloudProviderFrameRateNotSupportedException
98 */
99 void changeFrameRate(Ice::Float framesPerSecond,
100 const Ice::Current& c = Ice::emptyCurrent) override;
101
102
103 bool isCaptureEnabled(const Ice::Current& c = Ice::emptyCurrent) override;
104
105
106 protected:
107 // ================================================================== //
108 // == Interface of PointCloudProvider ================================= //
109 // ================================================================== //
110 /**
111 * This is called when the Component::onInitComponent() is called.
112 *
113 * Implement this method in the PointCloudProvider in order to setup its
114 * parameters. Use this to set the Point cloud format.
115 */
117
118 /**
119 * This is called when the Component::onConnectComponent() setup is called
120 */
121 virtual void
125
126 /**
127 * This is called when the Component::onExitComponent() setup is called
128 *
129 * Implement this method in the PointCloudProvider in order clean up right
130 * before terminating.
131 */
133
134 /**
135 * This is called when the point cloud provider capturing has been started.
136 *
137 * Implement this method in the PointCloudProvider in order to reset
138 * prvider's state.
139 *
140 * @param framesPerSecond capturing fps
141 *
142 * @throw visionx::PointCloudProviderResolutionNotSupportedException
143 * @throw visionx::PointCloudProviderFrameRateNotSupportedException
144 * @throw visionx::PointCloudProviderStartingCaptureFailedException
145 */
146 virtual void onStartCapture(float framesPerSecond) = 0;
147
148 /**
149 * This is called when the point cloud provider capturing has been stopped.
150 *
151 * Implement this method in the PointCloudProvider in order to clean up after stopping.
152 */
153 virtual void onStopCapture() = 0;
154
155 /**
156 * Main capturing function.
157 *
158 * @param ppPointCloudBuffers Point cloud pointer array where the captured point clouds need to be copied into
159 */
160 virtual bool doCapture() = 0;
161
162 // ================================================================== //
163 // == Utility methods for PointCloudProviders ============================ //
164 // ================================================================== //
165 /**
166 * Sets the point cloud synchronization mode
167 *
168 * @param pointCloudSyncMode point cloud synchronization mode
169 */
170 void setPointCloudSyncMode(ImageSyncMode pointCloudSyncMode);
171
172 /**
173 * Returns the point cloud sync mode
174 */
175 ImageSyncMode getPointCloudSyncMode();
176
177
178 // ================================================================== //
179 // == RunningComponent implementation =============================== //
180 // ================================================================== //
181 /**
182 * @see Component::onInitComponent()
183 */
184 void onInitPointCloudProvider() override;
185
186 /**
187 * @see Component::onConnectComponent()
188 */
189 void onConnectPointCloudProvider() override;
190
191 /**
192 * @see Component::onExitComponent()
193 */
194 void onExitPointCloudProvider() override;
195
196 /**
197 * @see capture method issued by RunningTask
198 */
199 virtual void capture();
200
201 protected:
202 /**
203 * Capture thread
204 */
206
207 /**
208 * Point cloud synchronization information
209 */
210 ImageSyncMode pointCloudSyncMode;
211
212 /**
213 * mutex for capturing for proper exit
214 */
215 mutable std::mutex captureMutex;
216
217 /**
218 * Required frame rate
219 */
221
222 /**
223 * FPS manager
224 */
226
227 /**
228 * Indicates that capturing is enabled and running
229 */
230 std::atomic_bool captureEnabled;
231
232 /**
233 * Number of frames to capture
234 */
236 };
237} // namespace visionx
constexpr T c
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
The CapturingPointCloudProvider provides a callback function to trigger the capturing of point clouds...
virtual void onStopCapture()=0
This is called when the point cloud provider capturing has been stopped.
virtual void onInitCapturingPointCloudProvider()=0
This is called when the Component::onInitComponent() is called.
ImageSyncMode pointCloudSyncMode
Point cloud synchronization information.
ImageSyncMode getPointCloudSyncMode()
Returns the point cloud sync mode.
bool isCaptureEnabled(const Ice::Current &c=Ice::emptyCurrent) override
virtual void onExitCapturingPointCloudProvider()=0
This is called when the Component::onExitComponent() setup is called.
void stopCapture(const Ice::Current &c=Ice::emptyCurrent) override
Stops point cloud capturing.
void startCapture(const Ice::Current &c=Ice::emptyCurrent) override
Starts point cloud capturing.
std::atomic_bool captureEnabled
Indicates that capturing is enabled and running.
void setPointCloudSyncMode(ImageSyncMode pointCloudSyncMode)
Sets the point cloud synchronization mode.
void startCaptureForNumFrames(int numFrames, const Ice::Current &c=Ice::emptyCurrent) override
Starts point cloud capturing.
virtual void onStartCapture(float framesPerSecond)=0
This is called when the point cloud provider capturing has been started.
void changeFrameRate(Ice::Float framesPerSecond, const Ice::Current &c=Ice::emptyCurrent) override
set a new frame rate
std::mutex captureMutex
mutex for capturing for proper exit
int numFramesToCapture
Number of frames to capture.
virtual bool doCapture()=0
Main capturing function.
armarx::RunningTask< CapturingPointCloudProvider >::pointer_type captureTask
Capture thread.
virtual void onStartCapturingPointCloudProvider()
This is called when the Component::onConnectComponent() setup is called.
The FPSCounter class provides methods for calculating the frames per second (FPS) count in periodic t...
Definition FPSCounter.h:37
PointCloudProvider abstract class defines a component which provide point clouds via ice or shared me...
ArmarX headers.