ResultImageFuser.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::ArmarXObjects::ResultImageFuser
19 * @author Markus Grotz ( markus dot grotz at kit dot edu )
20 * @date 2015
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25#pragma once
26
27#include <mutex>
28
29#include <Eigen/Core>
30
35
37#include <VisionX/interface/core/ImageProviderInterface.h>
39
40namespace armarx
41{
42
43 inline std::vector<std::string>
44 splitter(std::string const& propertyValue)
45 {
46 std::vector<std::string> result = Split(propertyValue, ",");
47 return result;
48 }
49
50 inline Eigen::Vector3i
51 extractColorValue(std::string propertyValue)
52 {
53 int number = (int)strtol(&propertyValue.c_str()[1], NULL, 16);
54
55 int r = number >> 16;
56 int g = number >> 8 & 0xFF;
57 int b = number & 0xFF;
58
59 return Eigen::Vector3i(r, g, b);
60 }
61
62 /**
63 * @class ResultImageFuserPropertyDefinitions
64 * @brief
65 */
68 {
69 public:
72 {
73 defineOptionalProperty<int>("width", 640, "image width");
74 defineOptionalProperty<int>("height", 480, "image height");
75 defineOptionalProperty<int>("numImages", 1, "number of images");
78 "colorMask",
79 extractColorValue("#FFFFFF"),
80 "image color that should be used as alpha channel")
81 .setFactory(f);
82 PropertyDefinition<std::vector<std::string>>::PropertyFactoryFunction g = &splitter;
84 "imageProviders",
85 splitter("TestImageProvider"),
86 "comma separated list of image providers")
87 .setFactory(g);
88 }
89 };
90
91 /**
92 * @class ResultImageFuser
93 *
94 * @ingroup VisionX-Components
95 * @brief A brief description
96 *
97 *
98 * Detailed Description
99 */
101 {
102 public:
103 /**
104 * @see armarx::ManagedIceObject::getDefaultName()
105 */
106 std::string
107 getDefaultName() const override
108 {
109 return "ResultImageFuser";
110 }
111
112 // void setResultImageProviders(std::string imageProviders, const Ice::Current& c = Ice::emptyCurrent);
113
114 protected:
115 /**
116 * @see visionx::ImageProviderBase::onInitImageProvider()
117 */
118 void onInitCapturingImageProvider() override;
119
120 /**
121 * @see visionx::ImageProviderBase::onExitImageProvider()
122 */
123 void onExitCapturingImageProvider() override;
124
125 /**
126 * @see visionx::ImageProviderBase::onStartCapture(float frameRate)
127 */
128 void onStartCapture(float frameRate) override;
129
130 /**
131 * @see visionx::ImageProviderBase::onStopCapture()
132 */
133 void onStopCapture() override;
134
135 /**
136 * @see visionx::ImageProviderBase::capture()
137 */
138 bool capture(void** ppImages) override;
139
140 /**
141 * @see PropertyUser::createPropertyDefinitions()
142 */
144
145 private:
146 void setResultImageProviders(std::vector<std::string> imageProviders);
147
148 void pollImageProviders();
149
150 int bytesPerPixel;
151 int width;
152 int height;
153 int numImages;
154 std::mutex imageMutex;
155
156 Eigen::Vector3i colorMask;
157 std::map<std::string, CByteImage**> imageSources;
158 std::map<std::string, bool> imageAvailable;
159
160
162 };
163} // namespace armarx
IceUtil::Handle< PeriodicTask< T > > pointer_type
Shared pointer type for convenience.
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)
PropertyDefinition defines a property that will be available within the PropertyUser.
std::function< PropertyType(std::string)> PropertyFactoryFunction
A brief description.
void onStartCapture(float frameRate) override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onExitCapturingImageProvider() override
void onInitCapturingImageProvider() override
std::string getDefaultName() const override
The CapturingImageProvider provides a callback function to trigger the capturing of images with diffe...
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::vector< std::string > Split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
std::vector< std::string > splitter(std::string const &propertyValue)
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Eigen::Vector3i extractColorValue(std::string propertyValue)
ArmarX headers.