CapturingImageProvider.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 Kai Welke (kai dot welke at kit dot edu)
20  * @date 2012
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #pragma once
26 
27 
29 
32 
33 #include <mutex>
34 
35 namespace visionx
36 {
38  {
39  public:
42  {
43  defineOptionalProperty<float>("FPS", 30.0f, "Frames per second with that the capture function is called.");
44  }
45 
46  };
47 
53  virtual public ImageProvider,
54  virtual public CapturingImageProviderInterface
55  {
56  public:
57  // ================================================================== //
58  // == CapturingImageProvider ice interface ========================== //
59  // ================================================================== //
68  void startCapture(float framesPerSecond,
69  const Ice::Current& c = Ice::emptyCurrent) override;
70 
75  void stopCapture(const Ice::Current& c = Ice::emptyCurrent) override;
76 
77  protected:
78 
79  // ================================================================== //
80  // == Interface of ImageProvider ================================= //
81  // ================================================================== //
88  virtual void onInitCapturingImageProvider() = 0;
89 
93  virtual void onStartCapturingImageProvider() { }
94 
101  virtual void onExitCapturingImageProvider() = 0;
102 
114  virtual void onStartCapture(float framesPerSecond) = 0;
115 
122  virtual void onStopCapture() = 0;
123 
130  virtual bool capture(void** ppImageBuffers) = 0;
131 
132  // ================================================================== //
133  // == Utility methods for ImageProviders ============================ //
134  // ================================================================== //
140  void setImageSyncMode(ImageSyncMode imageSyncMode);
141 
145  ImageSyncMode getImageSyncMode();
146 
153  {
155  }
156 
157  // ================================================================== //
158  // == RunningComponent implementation =============================== //
159  // ================================================================== //
163  void onInitImageProvider() override;
164 
168  void onConnectImageProvider() override;
169 
173  void onExitImageProvider() override;
174 
178  virtual void capture();
179 
180  protected:
185 
189  ImageSyncMode imageSyncMode;
190 
194  std::mutex captureMutex;
198  float frameRate;
199 
204 
209  };
210 }
211 
visionx::CapturingImageProvider::onStartCapture
virtual void onStartCapture(float framesPerSecond)=0
This is called when the image provider capturing has been started.
armarx::IceSharedMemoryProvider::getScopedWriteLock
SharedMemoryScopedWriteLockPtr getScopedWriteLock() const
Retrieve scoped lock for writing to the memory.
Definition: IceSharedMemoryProvider.h:156
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::CapturingImageProvider::frameRate
float frameRate
Required frame rate.
Definition: CapturingImageProvider.h:198
visionx::CapturingImageProvider::onInitCapturingImageProvider
virtual void onInitCapturingImageProvider()=0
This is called when the Component::onInitComponent() is called.
visionx::CapturingImageProvider::onExitImageProvider
void onExitImageProvider() override
Definition: CapturingImageProvider.cpp:92
visionx::CapturingImageProvider::onInitImageProvider
void onInitImageProvider() override
Definition: CapturingImageProvider.cpp:63
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
visionx::CapturingImageProvider::captureTask
armarx::RunningTask< CapturingImageProvider >::pointer_type captureTask
Capture thread.
Definition: CapturingImageProvider.h:184
visionx::CapturingImageProvider::stopCapture
void stopCapture(const Ice::Current &c=Ice::emptyCurrent) override
Stops image capturing.
Definition: CapturingImageProvider.cpp:53
armarx::SharedMemoryScopedWriteLockPtr
std::shared_ptr< SharedMemoryScopedWriteLock > SharedMemoryScopedWriteLockPtr
Definition: SharedMemoryProvider.h:46
RunningTask.h
visionx::CapturingImageProvider::onStartCapturingImageProvider
virtual void onStartCapturingImageProvider()
This is called when the Component::onConnectComponent() setup is called.
Definition: CapturingImageProvider.h:93
visionx::ImageProvider::sharedMemoryProvider
armarx::IceSharedMemoryProvider< unsigned char >::pointer_type sharedMemoryProvider
shared memory provider
Definition: ImageProvider.h:256
visionx::CapturingImageProvider::fpsCounter
FPSCounter fpsCounter
FPS manager.
Definition: CapturingImageProvider.h:203
visionx::CapturingImageProvider::imageSyncMode
ImageSyncMode imageSyncMode
Image synchronization information.
Definition: CapturingImageProvider.h:189
visionx::CapturingImageProvider::captureEnabled
bool captureEnabled
Indicates that capturing is enabled and running.
Definition: CapturingImageProvider.h:208
visionx::CapturingImageProvider::capture
virtual void capture()
Definition: CapturingImageProvider.cpp:106
visionx::CapturingImageProvider
The CapturingImageProvider provides a callback function to trigger the capturing of images with diffe...
Definition: CapturingImageProvider.h:52
visionx::CapturingImageProvider::onExitCapturingImageProvider
virtual void onExitCapturingImageProvider()=0
This is called when the Component::onExitComponent() setup is called.
visionx::CapturingImageProvider::onConnectImageProvider
void onConnectImageProvider() override
Definition: CapturingImageProvider.cpp:81
visionx::ImageProvider
ImageProvider abstract class defines a component which provide images via ice or shared memory.
Definition: ImageProvider.h:66
visionx::CapturingImageProvider::setImageSyncMode
void setImageSyncMode(ImageSyncMode imageSyncMode)
Sets the image synchronization mode.
Definition: CapturingImageProvider.cpp:166
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
IceUtil::Handle
Definition: forward_declarations.h:29
visionx::CapturingImageProviderPropertyDefinitions
Definition: CapturingImageProvider.h:37
armarx::ComponentPropertyDefinitions::ComponentPropertyDefinitions
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition: Component.cpp:37
visionx::CapturingImageProvider::startCapture
void startCapture(float framesPerSecond, const Ice::Current &c=Ice::emptyCurrent) override
Starts image capturing.
Definition: CapturingImageProvider.cpp:40
visionx::CapturingImageProvider::getImageSyncMode
ImageSyncMode getImageSyncMode()
Returns the image sync mode.
Definition: CapturingImageProvider.cpp:171
ImageProvider.h
visionx::CapturingImageProvider::onStopCapture
virtual void onStopCapture()=0
This is called when the image provider capturing has been stopped.
FPSCounter.h
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
visionx::CapturingImageProvider::getScopedWriteLock
armarx::SharedMemoryScopedWriteLockPtr getScopedWriteLock()
Retrieve scoped lock for writing to the memory.
Definition: CapturingImageProvider.h:152
visionx::CapturingImageProvider::captureMutex
std::mutex captureMutex
mutex for capturing for proper exit
Definition: CapturingImageProvider.h:194
visionx::FPSCounter
The FPSCounter class provides methods for calculating the frames per second (FPS) count in periodic t...
Definition: FPSCounter.h:36
visionx::CapturingImageProviderPropertyDefinitions::CapturingImageProviderPropertyDefinitions
CapturingImageProviderPropertyDefinitions(std::string prefix)
Definition: CapturingImageProvider.h:40