IDS peak genericC++ v1.10.0
Loading...
Searching...
No Matches
peak_bufferpart_converter_ipl.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
13
14#include <peak_ipl/peak_ipl.hpp>
18
19#include <cassert>
20
21
22namespace peak
23{
24
41template <>
42inline 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
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 */
The exception thrown for passing an invalid argument to a function.
Definition peak_exception.hpp:74
The exception thrown for trying to apply an invalid cast.
Definition peak_exception.hpp:82
@ Image3D
Definition peak_buffer_part.hpp:40
@ ConfidenceMap
Definition peak_buffer_part.hpp:44
@ Image2D
Definition peak_buffer_part.hpp:36
@ Custom
Definition peak_buffer.hpp:67
@ IIDC
Definition peak_buffer.hpp:63
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_dynamic_loader.h:33
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