Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
io
image.h
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Copyright (c) 2011 Willow Garage, Inc.
5
*
6
* All rights reserved.
7
*
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions
10
* are met:
11
*
12
* * Redistributions of source code must retain the above copyright
13
* notice, this list of conditions and the following disclaimer.
14
* * Redistributions in binary form must reproduce the above
15
* copyright notice, this list of conditions and the following
16
* disclaimer in the documentation and/or other materials provided
17
* with the distribution.
18
* * Neither the name of the copyright holder(s) nor the names of its
19
* contributors may be used to endorse or promote products derived
20
* from this software without specific prior written permission.
21
*
22
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
* POSSIBILITY OF SUCH DAMAGE.
34
*
35
*/
36
37
#pragma once
38
39
#include <pcl/io/image_metadata_wrapper.h>
40
#include <
pcl/memory.h
>
41
#include <pcl/pcl_config.h>
42
#include <
pcl/pcl_macros.h
>
43
44
#include <chrono>
45
46
namespace
pcl
47
{
48
namespace
io
49
{
50
51
/**
52
* @brief Image interface class providing an interface to fill a RGB or Grayscale image buffer.
53
* @param[in] image_metadata
54
* @ingroup io
55
*/
56
class
PCL_EXPORTS
Image
57
{
58
public
:
59
using
Ptr
= shared_ptr<Image>;
60
using
ConstPtr
= shared_ptr<const Image>;
61
62
using
Clock
= std::chrono::high_resolution_clock;
63
using
Timestamp
= std::chrono::high_resolution_clock::time_point;
64
65
enum
Encoding
66
{
67
BAYER_GRBG
,
68
YUV422
,
69
RGB
70
};
71
72
Image
(
FrameWrapper::Ptr
image_metadata)
73
:
wrapper_
(std::move(image_metadata))
74
,
timestamp_
(
Clock
::now ())
75
{}
76
77
Image
(
FrameWrapper::Ptr
image_metadata,
Timestamp
time)
78
:
wrapper_
(std::move(image_metadata))
79
,
timestamp_
(time)
80
{}
81
82
/**
83
* @brief virtual Destructor that never throws an exception.
84
*/
85
inline
virtual
~Image
() =
default
;
86
87
/**
88
* @param[in] input_width width of input image
89
* @param[in] input_height height of input image
90
* @param[in] output_width width of desired output image
91
* @param[in] output_height height of desired output image
92
* @return whether the resizing is supported or not.
93
*/
94
virtual
bool
95
isResizingSupported
(
unsigned
input_width,
unsigned
input_height,
96
unsigned
output_width,
unsigned
output_height)
const
= 0;
97
98
/**
99
* @brief fills a user given buffer with the RGB values, with an optional nearest-neighbor down sampling and an optional subregion
100
* @param[in] width desired width of output image.
101
* @param[in] height desired height of output image.
102
* @param[in,out] rgb_buffer the output RGB buffer.
103
* @param[in] rgb_line_step optional line step in bytes to allow the output in a rectangular subregion of the output buffer.
104
*/
105
virtual
void
106
fillRGB
(
unsigned
width,
unsigned
height,
unsigned
char
* rgb_buffer,
unsigned
rgb_line_step = 0)
const
= 0;
107
108
/**
109
* @brief returns the encoding of the native data.
110
* @return encoding
111
*/
112
virtual
Encoding
113
getEncoding
()
const
= 0;
114
115
/**
116
* @brief fills a user given buffer with the raw values.
117
* @param[in,out] rgb_buffer
118
*/
119
virtual
void
120
fillRaw
(
unsigned
char
* rgb_buffer)
const
121
{
122
memcpy (rgb_buffer,
wrapper_
->getData (),
wrapper_
->getDataSize ());
123
}
124
125
/**
126
* @brief fills a user given buffer with the gray values, with an optional nearest-neighbor down sampling and an optional subregion
127
* @param[in] width desired width of output image.
128
* @param[in] height desired height of output image.
129
* @param[in,out] gray_buffer the output gray buffer.
130
* @param[in] gray_line_step optional line step in bytes to allow the output in a rectangular subregion of the output buffer.
131
*/
132
virtual
void
133
fillGrayscale
(
unsigned
width,
unsigned
height,
unsigned
char
* gray_buffer,
134
unsigned
gray_line_step = 0)
const
= 0;
135
136
/**
137
* @return width of the image
138
*/
139
unsigned
140
getWidth
()
const
141
{
142
return
(
wrapper_
->getWidth ());
143
}
144
145
/**
146
* @return height of the image
147
*/
148
unsigned
149
getHeight
()
const
150
{
151
return
(
wrapper_
->getHeight ());
152
}
153
154
/**
155
* @return frame id of the image.
156
* @note frame ids are ascending, but not necessarily synchronized with other streams
157
*/
158
unsigned
159
getFrameID
()
const
160
{
161
return
(
wrapper_
->getFrameID ());
162
}
163
164
/**
165
* @return the timestamp of the image
166
* @note the time value is not synchronized with the system time
167
*/
168
std::uint64_t
169
getTimestamp
()
const
170
{
171
return
(
wrapper_
->getTimestamp ());
172
}
173
174
175
/**
176
* @return the timestamp of the image
177
* @note the time value *is* synchronized with the system time.
178
*/
179
Timestamp
180
getSystemTimestamp
()
const
181
{
182
return
(
timestamp_
);
183
}
184
185
// Get a const pointer to the raw depth buffer
186
const
void
*
187
getData
()
188
{
189
return
(
wrapper_
->getData ());
190
}
191
192
// Data buffer size in bytes
193
int
194
getDataSize
()
const
195
{
196
return
(
wrapper_
->getDataSize ());
197
}
198
199
// Size of each row, including any padding
200
inline
unsigned
201
getStep
()
const
202
{
203
return
(
getDataSize
() /
getHeight
());
204
}
205
206
protected
:
207
FrameWrapper::Ptr
wrapper_
;
208
Timestamp
timestamp_
;
209
};
210
211
}
// namespace
212
}
213
pcl::io::FrameWrapper::Ptr
shared_ptr< FrameWrapper > Ptr
Definition
image_metadata_wrapper.h:56
pcl::io::Image::getSystemTimestamp
Timestamp getSystemTimestamp() const
Definition
image.h:180
pcl::io::Image::getWidth
unsigned getWidth() const
Definition
image.h:140
pcl::io::Image::timestamp_
Timestamp timestamp_
Definition
image.h:208
pcl::io::Image::Encoding
Encoding
Definition
image.h:66
pcl::io::Image::BAYER_GRBG
@ BAYER_GRBG
Definition
image.h:67
pcl::io::Image::RGB
@ RGB
Definition
image.h:69
pcl::io::Image::YUV422
@ YUV422
Definition
image.h:68
pcl::io::Image::isResizingSupported
virtual bool isResizingSupported(unsigned input_width, unsigned input_height, unsigned output_width, unsigned output_height) const =0
pcl::io::Image::Image
Image(FrameWrapper::Ptr image_metadata, Timestamp time)
Definition
image.h:77
pcl::io::Image::Ptr
shared_ptr< Image > Ptr
Definition
image.h:59
pcl::io::Image::getFrameID
unsigned getFrameID() const
Definition
image.h:159
pcl::io::Image::getStep
unsigned getStep() const
Definition
image.h:201
pcl::io::Image::ConstPtr
shared_ptr< const Image > ConstPtr
Definition
image.h:60
pcl::io::Image::getHeight
unsigned getHeight() const
Definition
image.h:149
pcl::io::Image::getTimestamp
std::uint64_t getTimestamp() const
Definition
image.h:169
pcl::io::Image::fillGrayscale
virtual void fillGrayscale(unsigned width, unsigned height, unsigned char *gray_buffer, unsigned gray_line_step=0) const =0
fills a user given buffer with the gray values, with an optional nearest-neighbor down sampling and a...
pcl::io::Image::wrapper_
FrameWrapper::Ptr wrapper_
Definition
image.h:207
pcl::io::Image::~Image
virtual ~Image()=default
virtual Destructor that never throws an exception.
pcl::io::Image::Timestamp
std::chrono::high_resolution_clock::time_point Timestamp
Definition
image.h:63
pcl::io::Image::Image
Image(FrameWrapper::Ptr image_metadata)
Definition
image.h:72
pcl::io::Image::fillRGB
virtual void fillRGB(unsigned width, unsigned height, unsigned char *rgb_buffer, unsigned rgb_line_step=0) const =0
fills a user given buffer with the RGB values, with an optional nearest-neighbor down sampling and an...
pcl::io::Image::getData
const void * getData()
Definition
image.h:187
pcl::io::Image::Clock
std::chrono::high_resolution_clock Clock
Definition
image.h:62
pcl::io::Image::getDataSize
int getDataSize() const
Definition
image.h:194
pcl::io::Image::fillRaw
virtual void fillRaw(unsigned char *rgb_buffer) const
fills a user given buffer with the raw values.
Definition
image.h:120
pcl::io::Image::getEncoding
virtual Encoding getEncoding() const =0
returns the encoding of the native data.
memory.h
Defines functions, macros and traits for allocating and using memory.
pcl::io
Definition
io.h:517
pcl
Definition
convolution.h:46
pcl_macros.h
Defines all the PCL and non-PCL macros used.