CropRobotFromImage.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::CropRobotFromImage
17 * @author Julian Zimmer ( urdbu at student dot kit dot edu )
18 * @date 2018
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#ifndef _ARMARX_COMPONENT_VisionX_CropRobotFromImage_H
24#define _ARMARX_COMPONENT_VisionX_CropRobotFromImage_H
25
26
27#include <VirtualRobot/Robot.h>
28
30
31#include <RobotAPI/interface/core/RobotState.h>
34
37
38#include "MaskRobotInImage.h"
39
42//#include <VisionX/interface/components/CropRobotFromImageInterface.h>
43#include <mutex>
44
45#include <Eigen/Core>
46
47#include <VisionX/interface/components/Calibration.h>
48#include <VisionX/interface/components/PointCloudAndImageAndCalibrationProviderInterface.h>
49
50namespace armarx
51{
52 /**
53 * @class CropRobotFromImagePropertyDefinitions
54 * @brief
55 */
57 {
58 public:
61 {
63 "providerName", "ImageProvider", "Name of the image provider that should be used");
65 "RobotStateComponentName",
66 "RobotStateComponent",
67 "Name of the robot state component that should be used");
69 "cameraFrameName", "DepthCameraSim", "The source frame name");
70
71 defineOptionalProperty<float>("filterColorR",
72 0.f,
73 "The red value of the background color that has to be "
74 "different from the robots color. Range 0.f to 255.f");
75 defineOptionalProperty<float>("filterColorG",
76 177.f,
77 "The green value of the background color that has to be "
78 "different from the robots color. Range 0.f to 255.f");
79 defineOptionalProperty<float>("filterColorB",
80 64.f,
81 "The blue value of the background color that has to be "
82 "different from the robots color. Range 0.f to 255.f");
83
84 defineOptionalProperty<float>("collisionModelInflationMargin",
85 0.f,
86 "When the collision model is used for the offscreen "
87 "rendering, it will be inflated by this margin.");
88
89 defineOptionalProperty<int>("dilationStrength",
90 0,
91 "The strength of the dilation after the masking, which can "
92 "thicken the part that is cut from the image.");
93
95 "flipImages",
96 1,
97 "Boolean that indicates, if the rendered image should be flipped. This is needed "
98 "e.g. when camera nodes ending on 'Sim' are used.");
100 "useFullModel",
101 1,
102 "Boolean that indicates, if the full model should be used during the offscreen "
103 "rendering. Otherwise the collision model will be used.");
104
105
107 "numResultImages", 1, "The number of images processed and provided.");
108 }
109 };
110
111 /**
112 * @defgroup Component-CropRobotFromImage CropRobotFromImage
113 * @ingroup VisionX-Components
114 * A description of the component CropRobotFromImage.
115 *
116 * @class CropRobotFromImage
117 * @ingroup Component-CropRobotFromImage
118 * @brief Brief description of class CropRobotFromImage.
119 *
120 * Detailed description of class CropRobotFromImage.
121 */
123 virtual public visionx::ImageProcessor,
124 virtual public visionx::StereoCalibrationProcessorInterface
125 {
126
127 public:
128 /**
129 * @see armarx::ManagedIceObject::getDefaultName()
130 */
131 virtual std::string
132 getDefaultName() const override
133 {
134 return "CropRobotFromImage";
135 }
136
137 visionx::StereoCalibration
138 getStereoCalibration(const Ice::Current& c = Ice::emptyCurrent) override
139 {
140 return stereoCalibration;
141 }
142
143 bool
144 getImagesAreUndistorted(const Ice::Current& c = Ice::emptyCurrent) override
145 {
146 return imagesAreUndistorted;
147 }
148
149 std::string
150 getReferenceFrame(const Ice::Current& c = Ice::emptyCurrent) override
151 {
152 return referenceFrame;
153 }
154
155 /*
156 void setStereoCalibration(visionx::StereoCalibration stereoCalibration, bool imagesAreUndistorted, const std::string& referenceFrame)
157 {
158 this->stereoCalibration = stereoCalibration;
159 this->imagesAreUndistorted = imagesAreUndistorted;
160 this->referenceFrame = referenceFrame;
161 //calibrationPrx->reportStereoCalibrationChanged(this->stereoCalibration, this->imagesAreUndistorted, this->referenceFrame);
162 }
163 */
164
165
166 protected:
167 void process() override;
168
169 void onInitImageProcessor() override;
170 void onConnectImageProcessor() override;
171 void onDisconnectImageProcessor() override;
172 void onExitImageProcessor() override;
173 /**
174 * @see PropertyUser::createPropertyDefinitions()
175 */
177
178 private:
179 int width;
180 int height;
181
182 float fov;
183
184 int dilationStrength;
185
186 std::mutex mutex;
187
188 bool flipImages;
189 bool useFullModel;
190 float collisionModelInflationMargin;
191
192 visionx::ImageProviderInfo imageProviderInfo;
193
194
195 std::string providerName;
196 std::string cameraFrameName;
197
198 int numImages, numResultImages;
199 CByteImage** images;
200 //CByteImage** result;
201
202 visionx::MonocularCalibration depthCameraCalibration;
203
204 VirtualRobot::RobotPtr localRobot;
205
206 MaskRobotInImage* maskRobot;
207
208 float backgroundR;
209 float backgroundG;
210 float backgroundB;
211
212 RobotStateComponentInterfacePrx robotStateComponent;
213
214
215 visionx::StereoCalibration stereoCalibration;
216 bool imagesAreUndistorted;
217 //StereoCalibrationInterfacePrx calibrationPrx;
218 std::string referenceFrame;
219 };
220} // namespace armarx
221
222#endif
constexpr T c
Brief description of class CropRobotFromImage.
std::string getReferenceFrame(const Ice::Current &c=Ice::emptyCurrent) override
void onConnectImageProcessor() override
Implement this method in the ImageProcessor in order execute parts when the component is fully initia...
void onExitImageProcessor() override
Exit the ImapeProcessor component.
visionx::StereoCalibration getStereoCalibration(const Ice::Current &c=Ice::emptyCurrent) override
virtual armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void process() override
Process the vision component.
void onInitImageProcessor() override
Setup the vision component.
bool getImagesAreUndistorted(const Ice::Current &c=Ice::emptyCurrent) override
void onDisconnectImageProcessor() override
Implement this method in the ImageProcessor in order execute parts when the component looses network ...
virtual std::string getDefaultName() const override
A brief description.
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)
ImageProcessorPropertyDefinitions(std::string prefix)
The ImageProcessor class provides an interface for access to ImageProviders via Ice and shared memory...
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx
ArmarX headers.