AzureKinectIRImageProvider.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::AzureKinectIRImageProvider
17 * @author Christoph Pohl <christoph.pohl@kit.edu>
18 * @author Christian R. G. Dreher <c.dreher@kit.edu>
19 * @date 2019
20 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21 * GNU General Public License
22 */
23
24
25#pragma once
26
27#include <chrono>
28#include <condition_variable>
29#include <mutex>
30
31#include <Eigen/Core>
32
33#include <opencv2/opencv.hpp>
34
38#include <ArmarXCore/interface/observers/ObserverInterface.h>
39
40#include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
41
45#include <VisionX/interface/components/RGBDImageProvider.h>
46
47#include <k4a/k4a.h>
48#include <k4a/k4a.hpp>
49
50namespace visionx
51{
52 /// @class AzureKinectIRImageProviderPropertyDefinitions
59
60 /**
61 * @defgroup Component-AzureKinectIRImageProvider AzureKinectIRImageProvider
62 * @ingroup VisionX-Components
63 * Provides support for Intel RealSense cameras for ArmarX.
64 *
65 * @class AzureKinectIRImageProvider
66 * @ingroup Component-AzureKinectIRImageProvider
67 * @brief Brief description of class AzureKinectIRImageProvider.
68 */
70 virtual public visionx::StereoCalibrationCaptureProviderInterface,
72 {
73 public:
74 /**
75 * @see armarx::ManagedIceObject::getDefaultName()
76 */
77 static std::string GetDefaultName();
78 std::string getDefaultName() const override;
79
80 std::string getReferenceFrame(const Ice::Current& current) override;
81
82 StereoCalibration getStereoCalibration(const Ice::Current& current) override;
83
84 bool getImagesAreUndistorted(const Ice::Current& current) override;
85
86 protected:
87 /**
88 * @see PropertyUser::createPropertyDefinitions()
89 */
91
92 // ManagedIceObject interface
93
94 protected:
95 bool
96 hasSharedMemorySupport(const Ice::Current& c = Ice::emptyCurrent) override
97 {
98 return true;
99 }
100
101 void onInitCapturingImageProvider() override;
102
103 void onExitCapturingImageProvider() override;
104
105 void onStartCapture(float frames_per_second) override;
106
107 void onStopCapture() override;
108
109 bool capture(void** pp_image_buffers) override;
110
111 // Gets the dimensions of the color images that the color camera will produce for a
112 // given color resolution.
113 static inline std::pair<int, int>
114 GetColorDimensions(const k4a_color_resolution_t resolution)
115 {
116 switch (resolution)
117 {
118 case K4A_COLOR_RESOLUTION_720P:
119 return {1280, 720};
120 case K4A_COLOR_RESOLUTION_2160P:
121 return {3840, 2160};
122 case K4A_COLOR_RESOLUTION_1440P:
123 return {2560, 1440};
124 case K4A_COLOR_RESOLUTION_1080P:
125 return {1920, 1080};
126 case K4A_COLOR_RESOLUTION_3072P:
127 return {4096, 3072};
128 case K4A_COLOR_RESOLUTION_1536P:
129 return {2048, 1536};
130
131 default:
132 throw std::logic_error("Invalid color dimensions value!");
133 }
134 }
135
136 // Gets the dimensions of the depth images that the depth camera will produce for a
137 // given depth mode.
138 static inline std::pair<int, int>
139 GetDepthDimensions(const k4a_depth_mode_t depth_mode)
140 {
141 switch (depth_mode)
142 {
143 case K4A_DEPTH_MODE_NFOV_2X2BINNED:
144 return {320, 288};
145 case K4A_DEPTH_MODE_NFOV_UNBINNED:
146 return {640, 576};
147 case K4A_DEPTH_MODE_WFOV_2X2BINNED:
148 return {512, 512};
149 case K4A_DEPTH_MODE_WFOV_UNBINNED:
150 return {1024, 1024};
151 case K4A_DEPTH_MODE_PASSIVE_IR:
152 return {1024, 1024};
153
154 default:
155 throw std::logic_error("Invalid depth dimensions value!");
156 }
157 }
158
159 static std::string
160 VersionToString(const k4a_version_t& version)
161 {
162 std::stringstream s;
163 s << version.major << "." << version.minor << "." << version.iteration;
164 return s.str();
165 }
166
167 private:
168 visionx::CByteImageUPtr resultIRImage;
169
170 k4a::device device;
171 k4a_device_configuration_t config;
172 k4a::calibration k4aCalibration;
173 k4a::transformation transformation;
174 std::pair<int, int> depthDim;
175 };
176} // namespace visionx
constexpr T c
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Brief description of class AzureKinectIRImageProvider.
bool hasSharedMemorySupport(const Ice::Current &c=Ice::emptyCurrent) override
static std::pair< int, int > GetDepthDimensions(const k4a_depth_mode_t depth_mode)
void onStartCapture(float frames_per_second) override
This is called when the image provider capturing has been started.
static std::pair< int, int > GetColorDimensions(const k4a_color_resolution_t resolution)
virtual armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
static std::string VersionToString(const k4a_version_t &version)
bool getImagesAreUndistorted(const Ice::Current &current) 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.
std::string getReferenceFrame(const Ice::Current &current) override
StereoCalibration getStereoCalibration(const Ice::Current &current) override
void onInitCapturingImageProvider() override
This is called when the Component::onInitComponent() is called.
std::string getDefaultName() const override
Retrieve default name of component.
The CapturingImageProvider provides a callback function to trigger the capturing of images with diffe...
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
ArmarX headers.
std::unique_ptr< CByteImage > CByteImageUPtr