BigBowlLocalization.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::Component
19 * @author David Schiebener (schiebener 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// VisionX
28#include <VirtualRobot/VirtualRobot.h>
29
31
32#include <Image/StereoMatcher.h>
33// RobotAPI
36
37// forward declarations
38class CByteImage;
39class CVisualTargetLocator;
40class CColorParameterSet;
41
42namespace visionx
43{
46 {
47 public:
50 {
52 "ColorParameterFile",
53 "VisionX/examples/colors.txt",
54 "The color parameter file configures the colors used for segmentable recognition "
55 "(usually colors.txt)");
57 "ShowSegmentedResultImages",
58 true,
59 "Decide whether to calculate color-segmented images with the marker color and show "
60 "them as result images. Causes small additional computational effort.");
62 "UseVision",
63 true,
64 "You can switch off the use of the camera images. The returned pose will then just "
65 "be taken from the forward kinematics.");
66
67 defineOptionalProperty<ObjectColor>("BlobColor", eOrange, "")
68 .map("Blue", eBlue)
69 .map("Blue2", eBlue2)
70 .map("Blue3", eBlue3)
71 .map("Colored", eColored)
72 .map("Green", eGreen)
73 .map("Green2", eGreen2)
74 .map("Green3", eGreen3)
75 .map("Orange", eOrange)
76 .map("Orange2", eOrange2)
77 .map("Orange3", eOrange3)
78 .map("Red", eRed)
79 .map("Red2", eRed2)
80 .map("Red3", eRed3)
81 .map("Skin", eSkin)
82 .map("White", eWhite)
83 .map("Yellow", eYellow)
84 .map("Yellow2", eYellow2)
85 .map("Yellor3", eYellow3);
86
87 defineOptionalProperty<int>("nMinPixelsPerRegion", 450, "");
88 defineOptionalProperty<double>("dMaxEpipolarDiff", 10, "");
89 defineOptionalProperty<double>("dMinFilledRatio", 0.55, "");
90 defineOptionalProperty<double>("dMaxSideRatio", 1.4, "");
91 defineOptionalProperty<double>("dMinSize", 1150, "");
92 defineOptionalProperty<double>("dMaxSize", 2200, "");
93 }
94 };
95
96 /**
97 * BigBowlLocalization uses the CVisualTargetLocator of IVT in order to recognize and localize the marker balls at the hands of the robot.
98 * The returned hand pose takes the offset from marker to TCP into account, which is defined in the robot model file.
99 * The marker color is read from PriorKnowledge and CommonStorage via MemoryX.
100 * The hand localization is invoked automatically by the working memory if the object has been requested there.
101 */
103 {
104 public:
106
107 /**
108 * @see PropertyUser::createPropertyDefinitions()
109 */
116
117 /**
118 * @see Component::getDefaultName()
119 */
120 std::string
121 getDefaultName() const override
122 {
123 return "BigBowlLocalization";
124 }
125
126 protected:
127 /**
128 * @see ObjectLocalizerProcessor::onInitObjectLocalizerProcessor()
129 */
130 void onInitObjectLocalizerProcessor() override;
131
132 /**
133 * Initialize stuff here?
134 *
135 * @see ObjectLocalizerProcessor::onConnectObjectLocalizerProcessor()
136 */
137 void onConnectObjectLocalizerProcessor() override;
138
139 /**
140 * @see ObjectLocalizerProcessor::onExitObjectLocalizerProcessor()
141 */
142 void onExitObjectLocalizerProcessor() override;
143
144 /**
145 * Initializes segmentable recognition
146 *
147 * @return success
148 */
149 bool initRecognizer() override;
150
151 bool
152 addObjectClass(const memoryx::EntityPtr& objectClassEntity,
153 const memoryx::GridFileManagerPtr& fileManager) override
154 {
155 return true;
156 }
157
158 /**
159 * localize one or both hand markers
160 *
161 * @param objectClassNames is ignored here
162 * @param cameraImages the two input images
163 * @param resultImages the two result images. are provided if result images are enabled.
164 *
165 * @return list of object instances
166 */
167 memoryx::ObjectLocalizationResultList
168 localizeObjectClasses(const std::vector<std::string>& objectClassNames,
169 CByteImage** cameraImages,
170 armarx::MetaInfoSizeBasePtr imageMetaInfo,
171 CByteImage** resultImages) override;
172
173
174 private:
175 void drawCrossInImage(CByteImage* image, Eigen::Vector3f point, bool leftCamera);
176
177 int locateBowl(CByteImage** cameraImages, Vec3d& bowlPosition, CByteImage** resultImages);
178
179 // decides whether images or forward kinematic will be used
180 bool useVision;
181
182 // locator for the tracking balls
183 CVisualTargetLocator* visualTargetLocator;
184 ObjectColor objectColor;
185
186 // remote robot for the orientation
187 armarx::RobotStateComponentInterfacePrx robotStateComponent;
188 VirtualRobot::RobotPtr localRobot;
189
190 // visualization
191 bool showSegmentedResultImages;
192 CColorParameterSet* colorParameterSet;
193 int imageCounter;
194
195
196 CStereoMatcher* stereoMatcher;
197
198 protected:
200 };
201} // namespace visionx
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
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)
bool initRecognizer() override
Initializes segmentable recognition.
armarx::DebugDrawerInterfacePrx debugDrawerPrx
memoryx::ObjectLocalizationResultList localizeObjectClasses(const std::vector< std::string > &objectClassNames, CByteImage **cameraImages, armarx::MetaInfoSizeBasePtr imageMetaInfo, CByteImage **resultImages) override
localize one or both hand markers
void onConnectObjectLocalizerProcessor() override
Initialize stuff here?
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
std::string getDefaultName() const override
bool addObjectClass(const memoryx::EntityPtr &objectClassEntity, const memoryx::GridFileManagerPtr &fileManager) override
ObjectLocalizerProcessor interface: The addObjectClass method needs to be implemented by any ObjectLo...
armarx::MetaInfoSizeBasePtr imageMetaInfo
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
IceInternal::Handle< Entity > EntityPtr
Typedef of EntityPtr as IceInternal::Handle<Entity> for convenience.
Definition Entity.h:45
std::shared_ptr< GridFileManager > GridFileManagerPtr
ArmarX headers.