Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include "image_impl.hpp"
using voltu::internal::ImageImpl;
ImageImpl::ImageImpl(const ftl::rgbd::Frame& f, ftl::codecs::Channel c)
: frame_(f), channel_(c)
{
}
ImageImpl::~ImageImpl()
{
}
voltu::ImageData ImageImpl::getHost()
{
cv::Mat m = frame_.get<cv::Mat>(channel_);
voltu::ImageData r;
r.data = m.data;
r.width = m.cols;
r.height = m.rows;
r.pitch = m.step;
if (m.type() == CV_8UC4)
{
r.format = voltu::ImageFormat::kBGRA8;
}
else if (m.type() == CV_32F)
{
r.format = voltu::ImageFormat::kFloat32;
}
return r;
}
voltu::ImageData ImageImpl::getDevice()
{
cv::cuda::GpuMat m = frame_.get<cv::cuda::GpuMat>(channel_);
voltu::ImageData r;
r.data = m.data;
r.width = m.cols;
r.height = m.rows;
r.pitch = m.step;
if (m.type() == CV_8UC4)
{
r.format = voltu::ImageFormat::kBGRA8;
}
else if (m.type() == CV_32F)
{
r.format = voltu::ImageFormat::kFloat32;
}
return r;
}
bool ImageImpl::isDevice()
{
return true;
}
voltu::Channel ImageImpl::getChannel()
{
switch (channel_)
{
case ftl::codecs::Channel::Colour : return voltu::Channel::kColour;
case ftl::codecs::Channel::Depth : return voltu::Channel::kDepth;
default: return voltu::Channel::kInvalid;
}
}
std::string ImageImpl::getName()
{
return std::to_string(frame_.frameset()) + std::string("-") + std::to_string(frame_.source());
}
voltu::Intrinsics ImageImpl::getIntrinsics()
{
auto raw = frame_.getLeft();
voltu::Intrinsics result;
result.width = raw.width;
result.height = raw.height;
result.principle_x = raw.cx;
result.principle_y = raw.cy;
result.focal_x = raw.fx;
result.focal_y = raw.fy;
return result;
}
voltu::StereoIntrinsics ImageImpl::getStereoIntrinsics()
{
auto raw = frame_.getLeft();
voltu::StereoIntrinsics result;
result.width = raw.width;
result.height = raw.height;
result.principle_x = raw.cx;
result.principle_y = raw.cy;
result.focal_x = raw.fx;
result.focal_y = raw.fy;
result.min_depth = raw.minDepth;
result.max_depth = raw.maxDepth;
result.baseline = raw.baseline;
return result;
}
Eigen::Matrix4d ImageImpl::getPose()
{
return frame_.getPose();
}
int64_t ImageImpl::getTimestamp()
{
return frame_.timestamp();
}
int ImageImpl::getCameraNumber()
{
return frame_.source();
}
uint32_t ImageImpl::getUniqueId()
{
return frame_.id().id;
}