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 std::string
101 getDefaultName() const override
102 {
103 return "KLGImageProvider";
104 }
105
106 visionx::StereoCalibration
107 getStereoCalibration(const Ice::Current& c = Ice::emptyCurrent) override
108 {
109 visionx::StereoCalibration stereoCalibration;
110
111 Eigen::Vector2i dimensions = getProperty<Eigen::Vector2i>("Dimensions");
112
113 visionx::CameraParameters RGBCameraIntrinsics;
114 RGBCameraIntrinsics.distortion = {0, 0, 0};
115 RGBCameraIntrinsics.focalLength = {525.0, 525.0};
116 RGBCameraIntrinsics.height = dimensions(1);
117 RGBCameraIntrinsics.principalPoint = {dimensions(0) / 2.0f, dimensions(1) / 2.0f};
118 RGBCameraIntrinsics.rotation =
119 visionx::tools::convertEigenMatToVisionX(Eigen::Matrix3f::Identity());
120 RGBCameraIntrinsics.translation =
121 visionx::tools::convertEigenVecToVisionX(Eigen::Vector3f::Zero());
122 RGBCameraIntrinsics.width = dimensions(0);
123
124 visionx::CameraParameters DepthCameraIntrinsics;
125 DepthCameraIntrinsics.distortion = {0, 0, 0};
126 DepthCameraIntrinsics.focalLength = {525.0, 525.0};
127 DepthCameraIntrinsics.height = dimensions(1);
128 DepthCameraIntrinsics.principalPoint = {dimensions(0) / 2.0f, dimensions(1) / 2.0f};
129 DepthCameraIntrinsics.rotation =
130 visionx::tools::convertEigenMatToVisionX(Eigen::Matrix3f::Identity());
131 DepthCameraIntrinsics.translation = {0.075, 0, 0};
132 DepthCameraIntrinsics.width = dimensions(0);
133
134
135 stereoCalibration.calibrationLeft = visionx::tools::createDefaultMonocularCalibration();
136 stereoCalibration.calibrationRight =
138 stereoCalibration.calibrationLeft.cameraParam = RGBCameraIntrinsics;
139 stereoCalibration.calibrationRight.cameraParam = DepthCameraIntrinsics;
140 stereoCalibration.rectificationHomographyLeft =
141 visionx::tools::convertEigenMatToVisionX(Eigen::Matrix3f::Zero());
142 stereoCalibration.rectificationHomographyRight =
143 visionx::tools::convertEigenMatToVisionX(Eigen::Matrix3f::Zero());
144
145
146 return stereoCalibration;
147 }
148
149 bool
150 getImagesAreUndistorted(const Ice::Current& c = Ice::emptyCurrent) override
151 {
152 return true;
153 }
154
155 std::string
156 getReferenceFrame(const Ice::Current& c = Ice::emptyCurrent) override
157 {
158 return getProperty<std::string>("ReferenceFrameName");
159 }
160
161 protected:
162 void onInitCapturingImageProvider() override;
163
164 void onExitCapturingImageProvider() override;
165
166 void onStartCapture(float frameRate) override;
167
168 void onStopCapture() override;
169
170 bool capture(void** ppImageBuffers) override;
171
172
173 /**
174 * @see PropertyUser::createPropertyDefinitions()
175 */
177
178 private:
179 DebugDrawerInterfacePrx debugDrawer;
180 DebugObserverInterfacePrx debugObserver;
181
182 CByteImage** rgbImages;
183
184 int32_t currentFrame;
185 int32_t totalFrames;
186 FILE* fp;
187 bool doRewind;
188
189 cv::Mat depthBuffer;
190 };
191} // 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.
void onInitCapturingImageProvider() override
This is called when the Component::onInitComponent() is called.
std::string getDefaultName() const override
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.