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
38 class CByteImage;
39 class CVisualTargetLocator;
40 class CColorParameterSet;
41 
42 namespace visionx
43 {
46  {
47  public:
50  {
51  defineOptionalProperty<std::string>(
52  "ColorParameterFile",
53  "VisionX/examples/colors.txt",
54  "The color parameter file configures the colors used for segmentable recognition "
55  "(usually colors.txt)");
56  defineOptionalProperty<bool>(
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.");
61  defineOptionalProperty<bool>(
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  */
112  {
115  }
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
DebugDrawerComponent.h
RemoteRobot.h
visionx::ObjectLocalizerProcessor::resultImages
CByteImage ** resultImages
Definition: ObjectLocalizerProcessor.h:431
visionx::BigBowlLocalizationPropertyDefinitions
Definition: BigBowlLocalization.h:44
visionx::BigBowlLocalization::onConnectObjectLocalizerProcessor
void onConnectObjectLocalizerProcessor() override
Initialize stuff here?
Definition: BigBowlLocalization.cpp:74
GfxTL::Vec3d
VectorXD< 3, double > Vec3d
Definition: VectorXD.h:737
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::BigBowlLocalizationPropertyDefinitions::BigBowlLocalizationPropertyDefinitions
BigBowlLocalizationPropertyDefinitions(std::string prefix)
Definition: BigBowlLocalization.h:48
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
visionx::BigBowlLocalization::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: BigBowlLocalization.h:111
visionx::BigBowlLocalization::onInitObjectLocalizerProcessor
void onInitObjectLocalizerProcessor() override
Definition: BigBowlLocalization.cpp:61
visionx::BigBowlLocalization::localizeObjectClasses
memoryx::ObjectLocalizationResultList localizeObjectClasses(const std::vector< std::string > &objectClassNames, CByteImage **cameraImages, armarx::MetaInfoSizeBasePtr imageMetaInfo, CByteImage **resultImages) override
localize one or both hand markers
Definition: BigBowlLocalization.cpp:152
visionx::BigBowlLocalization
BigBowlLocalization uses the CVisualTargetLocator of IVT in order to recognize and localize the marke...
Definition: BigBowlLocalization.h:102
visionx::ObjectLocalizerProcessor::imageMetaInfo
armarx::MetaInfoSizeBasePtr imageMetaInfo
Definition: ObjectLocalizerProcessor.h:432
IceInternal::Handle
Definition: forward_declarations.h:8
visionx::BigBowlLocalization::initRecognizer
bool initRecognizer() override
Initializes segmentable recognition.
Definition: BigBowlLocalization.cpp:94
ObjectLocalizerProcessor.h
visionx::BigBowlLocalization::getDefaultName
std::string getDefaultName() const override
Definition: BigBowlLocalization.h:121
visionx::ObjectLocalizerProcessor::cameraImages
CByteImage * cameraImages[2]
Definition: ObjectLocalizerProcessor.h:429
visionx::BigBowlLocalization::onExitObjectLocalizerProcessor
void onExitObjectLocalizerProcessor() override
Definition: BigBowlLocalization.cpp:88
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:79
visionx::BigBowlLocalization::addObjectClass
bool addObjectClass(const memoryx::EntityPtr &objectClassEntity, const memoryx::GridFileManagerPtr &fileManager) override
ObjectLocalizerProcessor interface: The addObjectClass method needs to be implemented by any ObjectLo...
Definition: BigBowlLocalization.h:152
memoryx::GridFileManagerPtr
std::shared_ptr< GridFileManager > GridFileManagerPtr
Definition: AbstractEntityWrapper.h:33
IceUtil::Handle< class PropertyDefinitionContainer >
visionx::ObjectLocalizerProcessorPropertyDefinitions
Definition: ObjectLocalizerProcessor.h:78
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:35
visionx::BigBowlLocalization::BigBowlLocalization
BigBowlLocalization()
Definition: BigBowlLocalization.cpp:54
visionx::BigBowlLocalization::debugDrawerPrx
armarx::DebugDrawerInterfacePrx debugDrawerPrx
Definition: BigBowlLocalization.h:199
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19
visionx::ObjectLocalizerProcessor
ObjectLocalizerProcessor.
Definition: ObjectLocalizerProcessor.h:128