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
42 
44 #include <VisionX/interface/core/ImageProviderInterface.h>
46 
48 
49 namespace visionx
50 {
51 
54  {
55  public:
58  {
59  defineRequiredProperty<std::string>("ImageProviderName",
60  "Name of the ImageProviderComponent");
61  defineOptionalProperty<unsigned int>(
62  "ImageProviderChannel", 0, "The image channel to use");
63  defineOptionalProperty<std::string>(
64  "DebugDrawerTopicName",
65  "DebugDrawerUpdates",
66  "Name of the debug drawer topic that should be used");
67  }
68  };
69 
73  {
74  public:
75  /**
76  * @see armarx::ManagedIceObject::getDefaultName()
77  */
78  std::string
79  getDefaultName() const override
80  {
81  return "SimpleEpisodicMemoryImageConnector";
82  }
83 
84  /**
85  * @see PropertyUser::createPropertyDefinitions()
86  */
88 
89  protected:
90  // ImageProcessor interface
91  void onInitImageProcessor() override;
92  void onConnectImageProcessor() override;
93  void onDisconnectImageProcessor() override;
94  void onExitImageProcessor() override;
95  void process() override;
96 
97  private:
98  void checkForNewImages();
99 
100  // Meta (Properties)
101  std::string m_image_provider_id;
102  unsigned int m_image_provider_channel;
104  visionx::ImageProviderInfo m_image_provider_info;
105  armarx::MetaInfoSizeBase::PointerType m_image_meta_info;
106  IceUtil::Time m_timestamp_last_image;
107 
108  // ImageBuffer und ImageInformations
109  CByteImage** m_input_image_buf;
110  CByteImage* m_input_image;
111  std::mutex m_input_image_mutex;
112 
113  unsigned int num_of_received_images;
114 
115  // Threads and program flow information
116  const unsigned int m_periodic_task_interval = 100;
118  m_periodic_task;
119  bool
120  m_image_received; // Is true, if new images are available (when mode is 'FromTopic' this also means that corresponding keypoints are available)
121  };
122 } // namespace visionx
visionx::SimpleEpisodicMemoryImageConnector::onInitImageProcessor
void onInitImageProcessor() override
Setup the vision component.
Definition: SimpleEpisodicMemoryImageConnector.cpp:43
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::SimpleEpisodicMemoryImageConnectorPropertyDefinitions::SimpleEpisodicMemoryImageConnectorPropertyDefinitions
SimpleEpisodicMemoryImageConnectorPropertyDefinitions(std::string prefix)
Definition: SimpleEpisodicMemoryImageConnector.h:56
visionx::ImageProcessor
The ImageProcessor class provides an interface for access to ImageProviders via Ice and shared memory...
Definition: ImageProcessor.h:98
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
PeriodicTask.h
visionx::ImageProviderInfo
Definition: ImageProcessor.h:479
visionx::SimpleEpisodicMemoryImageConnector::process
void process() override
Process the vision component.
Definition: SimpleEpisodicMemoryImageConnector.cpp:108
ImageProcessor.h
visionx::SimpleEpisodicMemoryImageConnector
Definition: SimpleEpisodicMemoryImageConnector.h:70
armarx::ProxyType
ProxyType
Definition: ProxyPropertyDefinition.h:40
visionx::SimpleEpisodicMemoryImageConnectorPropertyDefinitions
Definition: SimpleEpisodicMemoryImageConnector.h:52
visionx::SimpleEpisodicMemoryImageConnector::getDefaultName
std::string getDefaultName() const override
Definition: SimpleEpisodicMemoryImageConnector.h:79
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
memoryx::SimpleEpisodicMemoryConnector
Definition: SimpleEpisodicMemoryConnector.h:34
Component.h
visionx::SimpleEpisodicMemoryImageConnector::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: SimpleEpisodicMemoryImageConnector.cpp:36
visionx::SimpleEpisodicMemoryImageConnector::onDisconnectImageProcessor
void onDisconnectImageProcessor() override
Implement this method in the ImageProcessor in order execute parts when the component looses network ...
Definition: SimpleEpisodicMemoryImageConnector.cpp:85
IceUtil::Handle< class PropertyDefinitionContainer >
visionx::ImageProcessorPropertyDefinitions
Definition: ImageProcessor.h:61
visionx::SimpleEpisodicMemoryImageConnector::onExitImageProcessor
void onExitImageProcessor() override
Exit the ImapeProcessor component.
Definition: SimpleEpisodicMemoryImageConnector.cpp:103
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:60
Logging.h
SimpleEpisodicMemoryConnector.h