Mech-Eye API
2.6.0
API reference documentation for Mech-Eye Industrial 3D Camera
Toggle main menu visibility
Loading...
Searching...
No Matches
deprecated
MechEyeFrame.hpp
1
/*******************************************************************************
2
*BSD 3-Clause License
3
*
4
*Copyright (c) 2016-2025, Mech-Mind Robotics Technologies Co., Ltd.
5
*All rights reserved.
6
*
7
*Redistribution and use in source and binary forms, with or without
8
*modification, are permitted provided that the following conditions are met:
9
*
10
*1. Redistributions of source code must retain the above copyright notice, this
11
* list of conditions and the following disclaimer.
12
*
13
*2. Redistributions in binary form must reproduce the above copyright notice,
14
* this list of conditions and the following disclaimer in the documentation
15
* and/or other materials provided with the distribution.
16
*
17
*3. Neither the name of the copyright holder nor the names of its
18
* contributors may be used to endorse or promote products derived from
19
* this software without specific prior written permission.
20
*
21
*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
*AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
*IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
*DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25
*FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
*DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
*SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28
*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29
*OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
*OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
******************************************************************************/
32
33
#pragma once
34
#include <cstdint>
35
#include <memory>
36
#include <vector>
37
#include <stdexcept>
38
#include "api_global.h"
39
#include "MechEyeDataType.h"
40
41
namespace
mmind {
42
namespace
api {
43
44
template
<
typename
ElementType>
45
class
Frame
;
46
50
struct
ElementDepth
51
{
52
float
d
{0};
53
};
54
58
struct
ElementColor
59
{
60
uint8_t
b
{0};
61
uint8_t
g
{0};
62
uint8_t
r
{0};
63
};
64
68
struct
ElementPointXYZ
69
{
70
float
x
{0};
71
float
y
{0};
72
float
z
{0};
73
};
74
78
struct
ElementPointXYZBGR
79
{
80
float
x
{0};
81
float
y
{0};
82
float
z
{0};
83
uint8_t
b
{0};
84
uint8_t
g
{0};
85
uint8_t
r
{0};
86
};
87
88
typedef
Frame<ElementColor> ColorMap;
89
90
typedef
Frame<ElementDepth> DepthMap;
91
92
typedef
Frame<ElementPointXYZ> PointXYZMap;
93
94
typedef
Frame<ElementPointXYZBGR> PointXYZBGRMap;
95
99
template
<
typename
ElementType>
100
class
Frame
101
{
102
public
:
106
Frame
() : _width(0), _height(0), _pData(nullptr) {}
110
~Frame
() {}
111
115
inline
uint32_t
width
()
const
{
return
_width; }
116
120
inline
uint32_t
height
()
const
{
return
_height; }
121
125
inline
bool
empty
()
const
{
return
!_pData; }
126
130
inline
const
ElementType*
data
()
const
{
return
_pData.get(); }
131
135
inline
ElementType*
data
()
136
{
137
return
const_cast<
ElementType*
>
(
static_cast<
const
Frame<ElementType>
&
>
(*this).data());
138
}
139
145
inline
const
ElementType&
operator[]
(std::size_t n)
const
146
{
147
if
(n >= _height * _width || !_pData)
148
throw
std::out_of_range(
"invalid subscript"
);
149
ElementType*
data
= _pData.get();
150
return
data
[n];
151
}
152
158
inline
ElementType&
operator[]
(std::size_t n)
159
{
160
return
const_cast<
ElementType&
>
(
static_cast<
const
Frame<ElementType>
&
>
(*this)[n]);
161
}
162
170
const
ElementType&
at
(uint32_t row, uint32_t col)
const
171
{
172
if
(row >= _height || col >= _width || !_pData)
173
throw
std::out_of_range(
"invalid subscript"
);
174
ElementType*
data
= _pData.get();
175
return
data
[row * _width + col];
176
}
177
185
ElementType&
at
(uint32_t row, uint32_t col)
186
{
187
return
const_cast<
ElementType&
>
(
static_cast<
const
Frame<ElementType>
&
>
(*this).at(row, col));
188
}
189
196
void
resize
(uint32_t
width
, uint32_t
height
)
197
{
198
if
(_width ==
width
&& _height ==
height
)
199
return
;
200
201
_width =
width
;
202
_height =
height
;
203
_pData.reset(
new
ElementType[_width * _height], [](ElementType* p) {
delete
[] p; });
204
}
205
209
void
release
()
210
{
211
_pData.reset();
212
_width = 0;
213
_height = 0;
214
}
215
216
private
:
217
uint32_t _width;
218
uint32_t _height;
219
std::shared_ptr<ElementType> _pData;
220
};
221
222
class
LineBatch
223
{
224
public
:
225
LineBatch() : _lineCount(0), _columnCount(0) {}
226
~LineBatch() {}
227
228
const
Frame<float>
& depth()
const
{
return
_depth; }
229
Frame<float>
& depth() {
return
_depth; }
230
231
const
Frame<unsigned char>
& intensity()
const
{
return
_intensity; }
232
Frame<unsigned char>
& intensity() {
return
_intensity; }
233
234
const
Frame<unsigned int>
& encoder()
const
{
return
_encoder; }
235
Frame<unsigned int>
& encoder() {
return
_encoder; }
236
237
const
Frame<long long>
& frameId()
const
{
return
_frameId; }
238
Frame<long long>
& frameId() {
return
_frameId; }
239
240
void
setLineCount(uint32_t lineCount) { _lineCount = lineCount; }
241
uint32_t lineCount()
const
{
return
_lineCount; }
242
uint32_t columnCount()
const
{
return
_columnCount; }
243
244
float
depthAt(uint32_t row, uint32_t col)
const
{
return
_depth.
at
(row, col); }
245
unsigned
char
intensityAt(uint32_t row, uint32_t col)
const
{
return
_intensity.at(row, col); }
246
unsigned
int
encoderAt(uint32_t row, uint32_t col)
const
{
return
_encoder.at(row, col); }
247
long
long
frameIdAt(uint32_t row, uint32_t col)
const
{
return
_frameId.at(row, col); }
248
249
void
resize(uint32_t width, uint32_t height)
250
{
251
_columnCount = width;
252
_lineCount = height;
253
_depth.resize(_columnCount, _lineCount);
254
_intensity.resize(_columnCount, _lineCount);
255
_encoder.resize(1, _lineCount);
256
_frameId.resize(1, _lineCount);
257
}
258
259
private
:
260
Frame<float>
_depth;
261
Frame<unsigned char>
_intensity;
262
Frame<unsigned int>
_encoder;
263
Frame<long long>
_frameId;
264
uint32_t _lineCount;
265
uint32_t _columnCount;
266
};
267
268
}
// namespace api
269
}
// namespace mmind
mmind::api::Frame
Definition of data structure in device capturing image.
Definition
MechEyeFrame.hpp:101
mmind::api::Frame::width
uint32_t width() const
Definition
MechEyeFrame.hpp:115
mmind::api::Frame::operator[]
const ElementType & operator[](std::size_t n) const
Definition
MechEyeFrame.hpp:145
mmind::api::Frame::empty
bool empty() const
Definition
MechEyeFrame.hpp:125
mmind::api::Frame::height
uint32_t height() const
Definition
MechEyeFrame.hpp:120
mmind::api::Frame::release
void release()
Definition
MechEyeFrame.hpp:209
mmind::api::Frame::resize
void resize(uint32_t width, uint32_t height)
Definition
MechEyeFrame.hpp:196
mmind::api::Frame::at
ElementType & at(uint32_t row, uint32_t col)
Definition
MechEyeFrame.hpp:185
mmind::api::Frame::at
const ElementType & at(uint32_t row, uint32_t col) const
Definition
MechEyeFrame.hpp:170
mmind::api::Frame::data
ElementType * data()
Definition
MechEyeFrame.hpp:135
mmind::api::Frame::data
const ElementType * data() const
Definition
MechEyeFrame.hpp:130
mmind::api::Frame::~Frame
~Frame()
Definition
MechEyeFrame.hpp:110
mmind::api::Frame::Frame
Frame()
Definition
MechEyeFrame.hpp:106
mmind::api::Frame::operator[]
ElementType & operator[](std::size_t n)
Definition
MechEyeFrame.hpp:158
mmind::api::ElementColor
Element in ColorMap.
Definition
MechEyeFrame.hpp:59
mmind::api::ElementColor::r
uint8_t r
Red channel.
Definition
MechEyeFrame.hpp:62
mmind::api::ElementColor::b
uint8_t b
Blue channel.
Definition
MechEyeFrame.hpp:60
mmind::api::ElementColor::g
uint8_t g
Green channel.
Definition
MechEyeFrame.hpp:61
mmind::api::ElementDepth
Element in DepthMap.
Definition
MechEyeFrame.hpp:51
mmind::api::ElementDepth::d
float d
Depth channel, unit: mm.
Definition
MechEyeFrame.hpp:52
mmind::api::ElementPointXYZBGR
Element in PointXYZBGRMap.
Definition
MechEyeFrame.hpp:79
mmind::api::ElementPointXYZBGR::r
uint8_t r
Red channel.
Definition
MechEyeFrame.hpp:85
mmind::api::ElementPointXYZBGR::g
uint8_t g
Green channel.
Definition
MechEyeFrame.hpp:84
mmind::api::ElementPointXYZBGR::b
uint8_t b
Blue channel.
Definition
MechEyeFrame.hpp:83
mmind::api::ElementPointXYZBGR::y
float y
Y channel, unit: mm.
Definition
MechEyeFrame.hpp:81
mmind::api::ElementPointXYZBGR::x
float x
X channel, unit: mm.
Definition
MechEyeFrame.hpp:80
mmind::api::ElementPointXYZBGR::z
float z
Z channel, unit: mm.
Definition
MechEyeFrame.hpp:82
mmind::api::ElementPointXYZ
Element in PointXYZMap.
Definition
MechEyeFrame.hpp:69
mmind::api::ElementPointXYZ::x
float x
X channel, unit: mm.
Definition
MechEyeFrame.hpp:70
mmind::api::ElementPointXYZ::z
float z
Z channel, unit: mm.
Definition
MechEyeFrame.hpp:72
mmind::api::ElementPointXYZ::y
float y
Y channel, unit: mm.
Definition
MechEyeFrame.hpp:71
Generated by
1.17.0