KLGImageProvider.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::KLGImageProvider
17 * @author Markus Grotz ( markus dot grotz at 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#pragma once
24
25
26#include <Eigen/Core>
27
28#include <opencv2/opencv.hpp>
29
31#include <ArmarXCore/interface/observers/ObserverInterface.h>
32
33#include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
34
36#include <VisionX/interface/components/RGBDImageProvider.h>
39
40namespace armarx
41{
42 /**
43 * @class KLGImageProviderPropertyDefinitions
44 * @brief
45 */
48 {
49 public:
52 {
53 defineOptionalProperty<std::string>("DebugObserverName",
54 "DebugObserver",
55 "Name of the topic the DebugObserver listens on");
57 "DebugDrawerTopicName", "DebugDrawerUpdates", "Name of the DebugDrawerTopic");
58
60 "FileName", "VisionX/examples/point_clouds/", "path to the klg log file");
61 defineOptionalProperty<bool>("Rewind", true, "loop through the point clouds");
62
63 defineOptionalProperty<Eigen::Vector2i>("Dimensions", Eigen::Vector2i(640, 480), "")
64 .map("320x240", Eigen::Vector2i(320, 240))
65 .map("640x480", Eigen::Vector2i(640, 480))
66 .map("320x240", Eigen::Vector2i(320, 240))
67 .map("640x480", Eigen::Vector2i(640, 480))
68 .map("800x600", Eigen::Vector2i(800, 600))
69 .map("768x576", Eigen::Vector2i(768, 576))
70 .map("1024x768", Eigen::Vector2i(1024, 768))
71 .map("1024x1024", Eigen::Vector2i(1024, 1024))
72 .map("1280x960", Eigen::Vector2i(1280, 960))
73 .map("1600x1200", Eigen::Vector2i(1600, 1200));
74
75
77 "ReferenceFrameName", "DepthCamera", "Optional reference frame name.");
78 }
79 };
80
81 /**
82 * @defgroup Component-KLGImageProvider KLGImageProvider
83 * @ingroup VisionX-Components
84 * A description of the component KLGImageProvider.
85 *
86 * @class KLGImageProvider
87 * @ingroup Component-KLGImageProvider
88 * @brief Brief description of class KLGImageProvider.
89 *
90 * Adds support for the klg format used by ElasticFusion
91 */
94 virtual public visionx::RGBDCapturingImageProviderInterface
95 {
96 public:
97 /**
98 * @see armarx::ManagedIceObject::getDefaultName()
99 */
100 static std::string GetDefaultName();
101 std::string getDefaultName() const override;
102
103 visionx::StereoCalibration
104 getStereoCalibration(const Ice::Current& c = Ice::emptyCurrent) override
105 {
106 visionx::StereoCalibration stereoCalibration;
107
108 Eigen::Vector2i dimensions = getProperty<Eigen::Vector2i>("Dimensions");
109
110 visionx::CameraParameters RGBCameraIntrinsics;
111 RGBCameraIntrinsics.distortion = {0, 0, 0};
112 RGBCameraIntrinsics.focalLength = {525.0, 525.0};
113 RGBCameraIntrinsics.height = dimensions(1);
114 RGBCameraIntrinsics.principalPoint = {dimensions(0) / 2.0f, dimensions(1) / 2.0f};
115 RGBCameraIntrinsics.rotation =
116 visionx::tools::convertEigenMatToVisionX(Eigen::Matrix3f::Identity());
117 RGBCameraIntrinsics.translation =
118 visionx::tools::convertEigenVecToVisionX(Eigen::Vector3f::Zero());
119 RGBCameraIntrinsics.width = dimensions(0);
120
121 visionx::CameraParameters DepthCameraIntrinsics;
122 DepthCameraIntrinsics.distortion = {0, 0, 0};
123 DepthCameraIntrinsics.focalLength = {525.0, 525.0};
124 DepthCameraIntrinsics.height = dimensions(1);
125 DepthCameraIntrinsics.principalPoint = {dimensions(0) / 2.0f, dimensions(1) / 2.0f};
126 DepthCameraIntrinsics.rotation =
127 visionx::tools::convertEigenMatToVisionX(Eigen::Matrix3f::Identity());
128 DepthCameraIntrinsics.translation = {0.075, 0, 0};
129 DepthCameraIntrinsics.width = dimensions(0);
130
131
132 stereoCalibration.calibrationLeft = visionx::tools::createDefaultMonocularCalibration();
133 stereoCalibration.calibrationRight =
135 stereoCalibration.calibrationLeft.cameraParam = RGBCameraIntrinsics;
136 stereoCalibration.calibrationRight.cameraParam = DepthCameraIntrinsics;
137 stereoCalibration.rectificationHomographyLeft =
138 visionx::tools::convertEigenMatToVisionX(Eigen::Matrix3f::Zero());
139 stereoCalibration.rectificationHomographyRight =
140 visionx::tools::convertEigenMatToVisionX(Eigen::Matrix3f::Zero());
141
142
143 return stereoCalibration;
144 }
145
146 bool
147 getImagesAreUndistorted(const Ice::Current& c = Ice::emptyCurrent) override
148 {
149 return true;
150 }
151
152 std::string
153 getReferenceFrame(const Ice::Current& c = Ice::emptyCurrent) override
154 {
155 return getProperty<std::string>("ReferenceFrameName");
156 }
157
158 protected:
159 void onInitCapturingImageProvider() override;
160
161 void onExitCapturingImageProvider() override;
162
163 void onStartCapture(float frameRate) override;
164
165 void onStopCapture() override;
166
167 bool capture(void** ppImageBuffers) override;
168
169
170 /**
171 * @see PropertyUser::createPropertyDefinitions()
172 */
174
175 private:
176 DebugDrawerInterfacePrx debugDrawer;
177 DebugObserverInterfacePrx debugObserver;
178
179 CByteImage** rgbImages;
180
181 int32_t currentFrame;
182 int32_t totalFrames;
183 FILE* fp;
184 bool doRewind;
185
186 cv::Mat depthBuffer;
187 };
188} // namespace armarx
constexpr T c
Property< PropertyType > getProperty(const std::string &name)
Brief description of class KLGImageProvider.
std::string getReferenceFrame(const Ice::Current &c=Ice::emptyCurrent) override
visionx::StereoCalibration getStereoCalibration(const Ice::Current &c=Ice::emptyCurrent) override
void onStartCapture(float frameRate) override
This is called when the image provider capturing has been started.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
bool getImagesAreUndistorted(const Ice::Current &c=Ice::emptyCurrent) override
void onStopCapture() override
This is called when the image provider capturing has been stopped.
void onExitCapturingImageProvider() override
This is called when the Component::onExitComponent() setup is called.
static std::string GetDefaultName()
void onInitCapturingImageProvider() override
This is called when the Component::onInitComponent() is called.
std::string getDefaultName() const override
Retrieve default name of component.
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 CapturingImageProvider provides a callback function to trigger the capturing of images with diffe...
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
visionx::types::Vec convertEigenVecToVisionX(Eigen::VectorXf v)
visionx::types::Mat convertEigenMatToVisionX(Eigen::MatrixXf m)
MonocularCalibration createDefaultMonocularCalibration()
Creates a MonocularCalibration with all parameters set to a neutral value.
ArmarX headers.