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 virtual std::string getDefaultName() const override;
78
79 std::string getReferenceFrame(const Ice::Current& current) override;
80
81 StereoCalibration getStereoCalibration(const Ice::Current& current) override;
82
83 bool getImagesAreUndistorted(const Ice::Current& current) override;
84
85 protected:
86 /**
87 * @see PropertyUser::createPropertyDefinitions()
88 */
90
91 // ManagedIceObject interface
92
93 protected:
94 bool
95 hasSharedMemorySupport(const Ice::Current& c = Ice::emptyCurrent) override
96 {
97 return true;
98 }
99
100 void onInitCapturingImageProvider() override;
101
102 void onExitCapturingImageProvider() override;
103
104 void onStartCapture(float frames_per_second) override;
105
106 void onStopCapture() override;
107
108 bool capture(void** pp_image_buffers) override;
109
110 // Gets the dimensions of the color images that the color camera will produce for a
111 // given color resolution.
112 static inline std::pair<int, int>
113 GetColorDimensions(const k4a_color_resolution_t resolution)
114 {
115 switch (resolution)
116 {
117 case K4A_COLOR_RESOLUTION_720P:
118 return {1280, 720};
119 case K4A_COLOR_RESOLUTION_2160P:
120 return {3840, 2160};
121 case K4A_COLOR_RESOLUTION_1440P:
122 return {2560, 1440};
123 case K4A_COLOR_RESOLUTION_1080P:
124 return {1920, 1080};
125 case K4A_COLOR_RESOLUTION_3072P:
126 return {4096, 3072};
127 case K4A_COLOR_RESOLUTION_1536P:
128 return {2048, 1536};
129
130 default:
131 throw std::logic_error("Invalid color dimensions value!");
132 }
133 }
134
135 // Gets the dimensions of the depth images that the depth camera will produce for a
136 // given depth mode.
137 static inline std::pair<int, int>
138 GetDepthDimensions(const k4a_depth_mode_t depth_mode)
139 {
140 switch (depth_mode)
141 {
142 case K4A_DEPTH_MODE_NFOV_2X2BINNED:
143 return {320, 288};
144 case K4A_DEPTH_MODE_NFOV_UNBINNED:
145 return {640, 576};
146 case K4A_DEPTH_MODE_WFOV_2X2BINNED:
147 return {512, 512};
148 case K4A_DEPTH_MODE_WFOV_UNBINNED:
149 return {1024, 1024};
150 case K4A_DEPTH_MODE_PASSIVE_IR:
151 return {1024, 1024};
152
153 default:
154 throw std::logic_error("Invalid depth dimensions value!");
155 }
156 }
157
158 static std::string
159 VersionToString(const k4a_version_t& version)
160 {
161 std::stringstream s;
162 s << version.major << "." << version.minor << "." << version.iteration;
163 return s.str();
164 }
165
166 private:
167 visionx::CByteImageUPtr resultIRImage;
168
169 k4a::device device;
170 k4a_device_configuration_t config;
171 k4a::calibration k4aCalibration;
172 k4a::transformation transformation;
173 std::pair<int, int> depthDim;
174 };
175} // 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.
virtual std::string getDefaultName() const override
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