IDS peak genericC++
v1.9.0
Loading...
Searching...
No Matches
peak_bufferpart_converter_ipl.hpp
Go to the documentation of this file.
1
11
#pragma once
12
13
14
#include <peak_ipl/peak_ipl.hpp>
15
#include <
peak/data_stream/peak_data_stream.hpp
>
16
#include <
peak/device/peak_device.hpp
>
17
#include <
peak/peak_buffer_converter.hpp
>
18
19
#include <cassert>
20
21
22
namespace
peak
23
{
24
41
template
<>
42
inline
peak::ipl::Image
BufferPartTo
(
const
std::shared_ptr<peak::core::BufferPart>& part)
43
{
44
if
(part ==
nullptr
)
45
{
46
throw
core::InvalidArgumentException
(
"The given buffer is a nullptr!"
);
47
}
48
49
const
auto
partType = part->Type();
50
51
if
(partType ==
core::BufferPartType::Image2D
|| partType ==
core::BufferPartType::ConfidenceMap
|| partType ==
core::BufferPartType::Image3D
)
52
{
53
assert(part->FormatNamespace() !=
static_cast<
uint64_t
>
(
core::PixelFormatNamespace::IIDC
)
54
&& part->FormatNamespace() !=
static_cast<
uint64_t
>
(
core::PixelFormatNamespace::Custom
));
55
56
const
size_t
height = part->Height();
57
const
size_t
width = part->Width();
58
const
size_t
byteCount = part->Size();
59
uint8_t* firstPixelPtr =
static_cast<
uint8_t*
>
(part->BasePtr());
60
61
return
peak::ipl::Image(
static_cast<
peak::ipl::PixelFormatName
>
(part->Format()),
62
firstPixelPtr, byteCount, width, height, part->ParentBuffer()->Timestamp_ns());
63
}
64
else
65
{
66
throw
core::InvalidCastException
(
"BufferPart has no image data."
);
67
}
68
}
69
70
}
/* namespace peak */
peak::core::InvalidArgumentException
The exception thrown for passing an invalid argument to a function.
Definition
peak_exception.hpp:74
peak::core::InvalidCastException
The exception thrown for trying to apply an invalid cast.
Definition
peak_exception.hpp:82
peak::core::BufferPartType::Image3D
@ Image3D
peak::core::BufferPartType::ConfidenceMap
@ ConfidenceMap
peak::core::BufferPartType::Image2D
@ Image2D
peak::core::PixelFormatNamespace::Custom
@ Custom
peak::core::PixelFormatNamespace::IIDC
@ IIDC
peak
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition
peak_dynamic_loader.h:33
peak::BufferPartTo
peak::ipl::Image BufferPartTo(const std::shared_ptr< peak::core::BufferPart > &part)
Converts a core::BufferPart into a peak::ipl::Image.
Definition
peak_bufferpart_converter_ipl.hpp:42
peak_buffer_converter.hpp
peak_data_stream.hpp
peak_device.hpp
peak
converters
peak_bufferpart_converter_ipl.hpp
Generated on Wed Aug 28 2024 - ©
IDS Imaging Development Systems GmbH