RGBDHandLocalizer.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::RGBDHandLocalizer
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
28#include <math.h>
29
30#include <Eigen/Geometry>
31
32#include <pcl/filters/crop_box.h>
33
34#include <opencv2/opencv.hpp>
35
38
40#include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
43
47#include <VisionX/interface/components/ObjectLocalizerInterfaces.h>
50
51#include "bloblabeler.h"
52#include <Image/ImageProcessor.h>
53#include <Image/IplImageAdaptor.h>
55#include <MemoryX/interface/observers/ObjectMemoryObserverInterface.h>
56#include <MemoryX/interface/workingmemory/WorkingMemoryUpdaterBase.h>
57
58namespace visionx
59{
60 /**
61 * @class RGBDHandLocalizerPropertyDefinitions
62 * @brief
63 */
65 {
66 public:
69 {
70 defineOptionalProperty<std::string>("providerName", "OpenNIPointCloudProvider", "");
72 "RobotStateComponentProxyName", "RobotStateComponent", "");
73 defineOptionalProperty<std::string>("HandNameInRobotModel", "TCP R", "");
74 defineOptionalProperty<std::string>("HandNameInMemory", "handright3aRGBD", "");
75 defineOptionalProperty<std::string>("SensorFrameName", "DepthCamera", "");
77 "RightHandNameViewSelection", "handright3a", "Name of the normal hand");
78 defineOptionalProperty<std::string>("MarkerName", "Marker R", "");
80 "DebugDrawerTopicName",
81 "DebugDrawerUpdates",
82 "Name of the debug drawer topic that should be used");
83
85 "PrimitiveCalibrationOnStart",
86 true,
87 "If true the component calibrates itself in a primitive way.");
88 defineOptionalProperty<float>("MarkerRadiusMM", 10, "");
89
90 defineOptionalProperty<float>("uncertaintyMM", 100, "");
91 //Green
92 defineOptionalProperty<int>("hueMin", 48, "");
93 defineOptionalProperty<int>("hueMax", 90, "");
94
95 defineOptionalProperty<int>("satMin", 50, "");
96 defineOptionalProperty<int>("satMax", 255, "");
97
98 defineOptionalProperty<int>("valMin", 105, "");
99 defineOptionalProperty<int>("valMax", 255, "");
100 }
101 };
102
103 /**
104 * @defgroup Component-RGBDHandLocalizer RGBDHandLocalizer
105 * @ingroup VisionX-Components
106 * A description of the component RGBDHandLocalizer.
107 *
108 * @class RGBDHandLocalizer
109 * @ingroup Component-RGBDHandLocalizer
110 * @brief Brief description of class RGBDHandLocalizer.
111 *
112 * Detailed description of class RGBDHandLocalizer.
113 */
115
116 virtual public PointCloudAndImageProcessor,
117 virtual public ObjectLocalizerPointCloudAndImageInterface
118 {
119 public:
120 /**
121 * @see armarx::ManagedIceObject::getDefaultName()
122 */
123 std::string
124 getDefaultName() const override
125 {
126 return "RGBDHandLocalizer";
127 }
128
129 memoryx::ObjectLocalizationResultList
130 localizeObjectClasses(const memoryx::ObjectClassNameList&, const Ice::Current&) override;
131
132 protected:
133 /**
134 * @see PropertyUser::createPropertyDefinitions()
135 */
137
138 void process() override;
139
140 void onInitPointCloudAndImageProcessor() override;
143 void onExitPointCloudAndImageProcessor() override;
144
145 private:
146 CByteImage** images;
147 int numImages;
148 std::string providerName;
149 armarx::RobotStateComponentInterfacePrx robotStatePrx = nullptr;
151 getFramedPosition(pcl::PointCloud<pcl::PointXYZRGBA>::Ptr, int x, int y);
153 armarx::FramedPosePtr realHandPose = nullptr;
154 CByteImage** result;
155
156 int calibrationCounter = 0;
157 Eigen::Vector3f calibrationSum = Eigen::Vector3f::Zero();
158
159 std::mutex positionLock;
160 armarx::DebugDrawerInterfacePrx debugDrawerTopic;
161 pcl::CropBox<pcl::PointXYZRGBA> cropper;
162
163 std::string sensorFrameName;
164 std::string markerFrameName;
165 std::string handFrameName;
166
167 // PointCloudAndImageProcessor interface
168 void calcPositions(cv::Mat& binaryImage,
169 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr pointcloud,
170 std::vector<Eigen::Vector3f>& medianCoordinates);
171 void cropFilter(pcl::PointCloud<pcl::PointXYZRGBA>::Ptr input,
172 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr output,
173 float uncertaintyMM,
174 Eigen::Vector3f guessMM);
175 };
176} // namespace visionx
std::string timestamp()
Default component property definition container.
Definition Component.h:70
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
The FramedPosition class.
Definition FramedPose.h:158
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)
The PointCloudAndImageProcessor class provides an interface for access to PointCloudProviders and Ima...
Brief description of class RGBDHandLocalizer.
void onDisconnectPointCloudAndImageProcessor() override
Implement this method in the PointCloudAndImageProcessor in order to execute parts when the component...
void onConnectPointCloudAndImageProcessor() override
Implement this method in your PointCloudAndImageProcessor in order execute parts when the component i...
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void process() override
Process the vision component.
void onInitPointCloudAndImageProcessor() override
Setup the vision component.
memoryx::ObjectLocalizationResultList localizeObjectClasses(const memoryx::ObjectClassNameList &, const Ice::Current &) override
void onExitPointCloudAndImageProcessor() override
Exit the ImapeProcessor component.
std::string getDefaultName() const override
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
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
IceInternal::Handle< TimestampVariant > TimestampVariantPtr
IceInternal::Handle< FramedPose > FramedPosePtr
Definition FramedPose.h:272
ArmarX headers.