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