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 
29 
30 #include "PointCloudProvider.h"
32 
33 #include <mutex>
34 
35 namespace visionx
36 {
37 
40  {
41  public:
44  {
45  defineOptionalProperty<float>("framerate", 30.0f, "framerate for the point clouds").setMin(0.0f).setMax(60.0f);
46  defineOptionalProperty<bool>("isEnabled", true, "enable the capturing process immediately");
47  }
48  };
49 
50 
51 
57  virtual public PointCloudProvider,
58  virtual public CapturingPointCloudProviderInterface
59  {
60  public:
61  // ================================================================== //
62  // == CapturingPointCloudProvider ice interface ========================== //
63  // ================================================================== //
71  void startCapture(const Ice::Current& c = Ice::emptyCurrent) override;
72 
81  void startCaptureForNumFrames(int numFrames, const Ice::Current& c = Ice::emptyCurrent) override;
82 
87  void stopCapture(const Ice::Current& c = Ice::emptyCurrent) override;
88 
89 
96  void changeFrameRate(Ice::Float framesPerSecond, const Ice::Current& c = Ice::emptyCurrent) override;
97 
98 
99  bool isCaptureEnabled(const Ice::Current& c = Ice::emptyCurrent) override;
100 
101 
102  protected:
103 
104  // ================================================================== //
105  // == Interface of PointCloudProvider ================================= //
106  // ================================================================== //
113  virtual void onInitCapturingPointCloudProvider() = 0;
114 
119 
126  virtual void onExitCapturingPointCloudProvider() = 0;
127 
140  virtual void onStartCapture(float framesPerSecond) = 0;
141 
147  virtual void onStopCapture() = 0;
148 
154  virtual bool doCapture() = 0;
155 
156  // ================================================================== //
157  // == Utility methods for PointCloudProviders ============================ //
158  // ================================================================== //
164  void setPointCloudSyncMode(ImageSyncMode pointCloudSyncMode);
165 
169  ImageSyncMode getPointCloudSyncMode();
170 
171 
172  // ================================================================== //
173  // == RunningComponent implementation =============================== //
174  // ================================================================== //
178  void onInitPointCloudProvider() override;
179 
183  void onConnectPointCloudProvider() override;
184 
188  void onExitPointCloudProvider() override;
189 
193  virtual void capture();
194 
195  protected:
200 
204  ImageSyncMode pointCloudSyncMode;
205 
209  mutable std::mutex captureMutex;
210 
214  float frameRate;
215 
220 
224  std::atomic_bool captureEnabled;
225 
230  };
231 }
232 
visionx::CapturingPointCloudProvider::pointCloudSyncMode
ImageSyncMode pointCloudSyncMode
Point cloud synchronization information.
Definition: CapturingPointCloudProvider.h:204
visionx::CapturingPointCloudProvider::onStopCapture
virtual void onStopCapture()=0
This is called when the point cloud provider capturing has been stopped.
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:918
visionx::CapturingPointCloudProvider::startCaptureForNumFrames
void startCaptureForNumFrames(int numFrames, const Ice::Current &c=Ice::emptyCurrent) override
Starts point cloud capturing.
Definition: CapturingPointCloudProvider.cpp:50
visionx::CapturingPointCloudProvider::onInitCapturingPointCloudProvider
virtual void onInitCapturingPointCloudProvider()=0
This is called when the Component::onInitComponent() is called.
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::CapturingPointCloudProvider::onInitPointCloudProvider
void onInitPointCloudProvider() override
Definition: CapturingPointCloudProvider.cpp:90
visionx::CapturingPointCloudProvider::setPointCloudSyncMode
void setPointCloudSyncMode(ImageSyncMode pointCloudSyncMode)
Sets the point cloud synchronization mode.
Definition: CapturingPointCloudProvider.cpp:190
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
visionx::CapturingPointCloudProvider::isCaptureEnabled
bool isCaptureEnabled(const Ice::Current &c=Ice::emptyCurrent) override
Definition: CapturingPointCloudProvider.cpp:81
visionx::CapturingPointCloudProvider::onStartCapture
virtual void onStartCapture(float framesPerSecond)=0
This is called when the point cloud provider capturing has been started.
PointCloudProvider.h
visionx::CapturingPointCloudProvider::onExitPointCloudProvider
void onExitPointCloudProvider() override
Definition: CapturingPointCloudProvider.cpp:132
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
RunningTask.h
visionx::CapturingPointCloudProvider::onExitCapturingPointCloudProvider
virtual void onExitCapturingPointCloudProvider()=0
This is called when the Component::onExitComponent() setup is called.
visionx::CapturingPointCloudProvider::captureMutex
std::mutex captureMutex
mutex for capturing for proper exit
Definition: CapturingPointCloudProvider.h:209
visionx::CapturingPointCloudProvider::capture
virtual void capture()
Definition: CapturingPointCloudProvider.cpp:147
visionx::CapturingPointCloudProviderPropertyDefinitions::CapturingPointCloudProviderPropertyDefinitions
CapturingPointCloudProviderPropertyDefinitions(std::string prefix)
Definition: CapturingPointCloudProvider.h:42
visionx::CapturingPointCloudProvider::captureEnabled
std::atomic_bool captureEnabled
Indicates that capturing is enabled and running.
Definition: CapturingPointCloudProvider.h:224
visionx::CapturingPointCloudProvider::frameRate
float frameRate
Required frame rate.
Definition: CapturingPointCloudProvider.h:214
visionx::CapturingPointCloudProviderPropertyDefinitions
Definition: CapturingPointCloudProvider.h:38
visionx::PointCloudProviderPropertyDefinitions
Definition: PointCloudProvider.h:43
visionx::CapturingPointCloudProvider::captureTask
armarx::RunningTask< CapturingPointCloudProvider >::pointer_type captureTask
Capture thread.
Definition: CapturingPointCloudProvider.h:199
visionx::CapturingPointCloudProvider::startCapture
void startCapture(const Ice::Current &c=Ice::emptyCurrent) override
Starts point cloud capturing.
Definition: CapturingPointCloudProvider.cpp:37
visionx::CapturingPointCloudProvider
The CapturingPointCloudProvider provides a callback function to trigger the capturing of point clouds...
Definition: CapturingPointCloudProvider.h:56
visionx::CapturingPointCloudProvider::changeFrameRate
void changeFrameRate(Ice::Float framesPerSecond, const Ice::Current &c=Ice::emptyCurrent) override
set a new frame rate
Definition: CapturingPointCloudProvider.cpp:73
visionx::CapturingPointCloudProvider::fpsCounter
FPSCounter fpsCounter
FPS manager.
Definition: CapturingPointCloudProvider.h:219
visionx::CapturingPointCloudProvider::getPointCloudSyncMode
ImageSyncMode getPointCloudSyncMode()
Returns the point cloud sync mode.
Definition: CapturingPointCloudProvider.cpp:197
visionx::CapturingPointCloudProvider::onConnectPointCloudProvider
void onConnectPointCloudProvider() override
Definition: CapturingPointCloudProvider.cpp:116
IceUtil::Handle
Definition: forward_declarations.h:29
visionx::CapturingPointCloudProvider::numFramesToCapture
int numFramesToCapture
Number of frames to capture.
Definition: CapturingPointCloudProvider.h:229
visionx::CapturingPointCloudProvider::doCapture
virtual bool doCapture()=0
Main capturing function.
visionx::CapturingPointCloudProvider::onStartCapturingPointCloudProvider
virtual void onStartCapturingPointCloudProvider()
This is called when the Component::onConnectComponent() setup is called.
Definition: CapturingPointCloudProvider.h:118
FPSCounter.h
visionx::PointCloudProvider
PointCloudProvider abstract class defines a component which provide point clouds via ice or shared me...
Definition: PointCloudProvider.h:60
visionx::FPSCounter
The FPSCounter class provides methods for calculating the frames per second (FPS) count in periodic t...
Definition: FPSCounter.h:36
visionx::CapturingPointCloudProvider::stopCapture
void stopCapture(const Ice::Current &c=Ice::emptyCurrent) override
Stops point cloud capturing.
Definition: CapturingPointCloudProvider.cpp:63