SimpleEpisodicMemoryImageConnector.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package VisionX::ArmarXObjects::SimpleEpisodicMemoryImageConnector
17  * @author Fabian Peller ( fabian dot peller-konrad at kit dot edu )
18  * @date 2020
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 #pragma once
23 
25 
26 // STD/STL
27 #include <memory>
28 #include <mutex>
29 #include <string>
30 #include <vector>
31 
32 // IVT
33 #include <Image/ByteImage.h>
34 
35 // Ice
36 #include <Ice/Current.h>
37 #include <IceUtil/Time.h>
38 
39 // ArmarX
45 #include <VisionX/interface/core/ImageProviderInterface.h>
46 
47 namespace visionx
48 {
49 
52  {
53  public:
56  {
57  defineRequiredProperty<std::string>("ImageProviderName", "Name of the ImageProviderComponent");
58  defineOptionalProperty<unsigned int>("ImageProviderChannel", 0, "The image channel to use");
59  defineOptionalProperty<std::string>("DebugDrawerTopicName", "DebugDrawerUpdates", "Name of the debug drawer topic that should be used");
60  }
61  };
62 
63 
67  {
68  public:
69  /**
70  * @see armarx::ManagedIceObject::getDefaultName()
71  */
72  std::string getDefaultName() const override
73  {
74  return "SimpleEpisodicMemoryImageConnector";
75  }
76 
77  /**
78  * @see PropertyUser::createPropertyDefinitions()
79  */
81 
82  protected:
83  // ImageProcessor interface
84  void onInitImageProcessor() override;
85  void onConnectImageProcessor() override;
86  void onDisconnectImageProcessor() override;
87  void onExitImageProcessor() override;
88  void process() override;
89 
90  private:
91  void checkForNewImages();
92 
93  // Meta (Properties)
94  std::string m_image_provider_id;
95  unsigned int m_image_provider_channel;
97  visionx::ImageProviderInfo m_image_provider_info;
98  armarx::MetaInfoSizeBase::PointerType m_image_meta_info;
99  IceUtil::Time m_timestamp_last_image;
100 
101  // ImageBuffer und ImageInformations
102  CByteImage** m_input_image_buf;
103  CByteImage* m_input_image;
104  std::mutex m_input_image_mutex;
105 
106  unsigned int num_of_received_images;
107 
108  // Threads and program flow information
109  const unsigned int m_periodic_task_interval = 100;
111  bool m_image_received; // Is true, if new images are available (when mode is 'FromTopic' this also means that corresponding keypoints are available)
112  };
113 }
visionx::SimpleEpisodicMemoryImageConnector::onInitImageProcessor
void onInitImageProcessor() override
Setup the vision component.
Definition: SimpleEpisodicMemoryImageConnector.cpp:41
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::SimpleEpisodicMemoryImageConnectorPropertyDefinitions::SimpleEpisodicMemoryImageConnectorPropertyDefinitions
SimpleEpisodicMemoryImageConnectorPropertyDefinitions(std::string prefix)
Definition: SimpleEpisodicMemoryImageConnector.h:54
visionx::ImageProcessor
The ImageProcessor class provides an interface for access to ImageProviders via Ice and shared memory...
Definition: ImageProcessor.h:87
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
PeriodicTask.h
visionx::ImageProviderInfo
Definition: ImageProcessor.h:466
visionx::SimpleEpisodicMemoryImageConnector::process
void process() override
Process the vision component.
Definition: SimpleEpisodicMemoryImageConnector.cpp:101
ImageProcessor.h
visionx::SimpleEpisodicMemoryImageConnector
Definition: SimpleEpisodicMemoryImageConnector.h:64
armarx::ProxyType
ProxyType
Definition: ProxyPropertyDefinition.h:41
visionx::SimpleEpisodicMemoryImageConnectorPropertyDefinitions
Definition: SimpleEpisodicMemoryImageConnector.h:50
visionx::SimpleEpisodicMemoryImageConnector::getDefaultName
std::string getDefaultName() const override
Definition: SimpleEpisodicMemoryImageConnector.h:72
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
memoryx::SimpleEpisodicMemoryConnector
Definition: SimpleEpisodicMemoryConnector.h:35
Component.h
visionx::SimpleEpisodicMemoryImageConnector::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: SimpleEpisodicMemoryImageConnector.cpp:35
visionx::SimpleEpisodicMemoryImageConnector::onDisconnectImageProcessor
void onDisconnectImageProcessor() override
Implement this method in the ImageProcessor in order execute parts when the component looses network ...
Definition: SimpleEpisodicMemoryImageConnector.cpp:80
IceUtil::Handle< class PropertyDefinitionContainer >
visionx::ImageProcessorPropertyDefinitions
Definition: ImageProcessor.h:61
visionx::SimpleEpisodicMemoryImageConnector::onExitImageProcessor
void onExitImageProcessor() override
Exit the ImapeProcessor component.
Definition: SimpleEpisodicMemoryImageConnector.cpp:97
ImageUtil.h
visionx::SimpleEpisodicMemoryImageConnector::onConnectImageProcessor
void onConnectImageProcessor() override
Implement this method in the ImageProcessor in order execute parts when the component is fully initia...
Definition: SimpleEpisodicMemoryImageConnector.cpp:57
Logging.h
SimpleEpisodicMemoryConnector.h