IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
peak_icv_metadata_conversion.hpp
Go to the documentation of this file.
1
11#pragma once
12
15#include <peak_icv_c/types/peak_icv_image.h>
16#include <cstring>
17
18namespace peak
19{
20namespace icv
21{
22namespace detail
23{
24inline peak_icv_capture_information CreateCCaptureInformationFromMetadata(const peak::common::Metadata& metadata)
25{
26 peak_icv_capture_information captureInformationC{};
27
29 {
30 captureInformationC.relative_timestamp = metadata.GetValueByKey<peak::common::MetadataKey::DeviceTimestamp>();
31 }
32 else
33 {
34 captureInformationC.relative_timestamp = 0;
35 }
37 {
38 captureInformationC.binning_factor.x = metadata.GetValueByKey<peak::common::MetadataKey::BinningHorizontal>();
39 }
40 else
41 {
42 captureInformationC.binning_factor.x = 1;
43 }
45 {
46 captureInformationC.binning_factor.y = metadata.GetValueByKey<peak::common::MetadataKey::BinningVertical>();
47 }
48 else
49 {
50 captureInformationC.binning_factor.y = 1;
51 }
53 {
54 auto roi = metadata.GetValueByKey<peak::common::MetadataKey::Roi>();
55 captureInformationC.region_of_interest.x = roi.GetX();
56 captureInformationC.region_of_interest.y = roi.GetY();
57 captureInformationC.region_of_interest.width = roi.GetWidth();
58 captureInformationC.region_of_interest.height = roi.GetHeight();
59 }
60 else
61 {
62 captureInformationC.region_of_interest.x = 0;
63 captureInformationC.region_of_interest.y = 0;
64 captureInformationC.region_of_interest.width = 0;
65 captureInformationC.region_of_interest.height = 0;
66 }
68 {
69 captureInformationC.exposure_time = metadata.GetValueByKey<peak::common::MetadataKey::DeviceExposureTime>();
70 }
71 else
72 {
73 captureInformationC.exposure_time = 0;
74 }
76 {
77 const auto exposureTimeSeq = metadata.GetValueByKey<peak::common::MetadataKey::DeviceExposureTimeSequence>();
78
79 if (exposureTimeSeq.size() > 4)
80 {
81 throw peak::icv::NotSupportedException("Exposure time sequence has to be smaller than or equal to 4.");
82 }
83
84 captureInformationC.exposure_time_a = 0;
85 captureInformationC.exposure_time_b = 0;
86 captureInformationC.exposure_time_c = 0;
87 captureInformationC.exposure_time_d = 0;
88
89 std::memcpy(&captureInformationC.exposure_time_a, exposureTimeSeq.data(), exposureTimeSeq.size() * sizeof(double));
90 }
91 else
92 {
93 captureInformationC.exposure_time_a = 0;
94 captureInformationC.exposure_time_b = 0;
95 captureInformationC.exposure_time_c = 0;
96 captureInformationC.exposure_time_d = 0;
97 }
99 {
100 captureInformationC.gain = metadata.GetValueByKey<peak::common::MetadataKey::DeviceGain>();
101 }
102 else
103 {
104 captureInformationC.gain = 0;
105 }
107 {
108 const auto gainSeq = metadata.GetValueByKey<peak::common::MetadataKey::DeviceGainSequence>();
109
110 if (gainSeq.size() > 4)
111 {
112 throw peak::icv::NotSupportedException("Exposure time sequence has to be smaller than or equal to 4.");
113 }
114
115 captureInformationC.gain_a = 0;
116 captureInformationC.gain_b = 0;
117 captureInformationC.gain_c = 0;
118 captureInformationC.gain_d = 0;
119
120 std::memcpy(&captureInformationC.gain_a, gainSeq.data(), gainSeq.size() * sizeof(double));
121 }
122 else
123 {
124 captureInformationC.gain_a = 0;
125 captureInformationC.gain_b = 0;
126 captureInformationC.gain_c = 0;
127 captureInformationC.gain_d = 0;
128 }
129
130 return captureInformationC;
131}
132
133inline peak_icv_capture_information CreateCCaptureInformationFromMetadata(
134 peak::common::Metadata metadata, const peak::common::Size& imageSize)
135{
137 {
139 peak::common::RectangleU{ 0, 0, imageSize.GetWidth(), imageSize.GetHeight() });
140 }
142}
143} // namespace detail
144} // namespace icv
145} // namespace peak
Type-safe container for image acquisition metadata.
void SetValueByKey(T &&value)
Stores a value using a strongly typed metadata key.
bool HasEntryByKey() const
Checks if a known key is stored in the metadata.
detail::MetadataKeyTraits< metadataKey >::type GetValueByKey() const
Retrieves the value of a strongly typed metadata key.
A generic rectangle defined by a point and a size.
Represents a two-dimensional size with non-negative width and height.
constexpr T GetWidth() const
Returns the width.
constexpr T GetHeight() const
Returns the height.
Occurs when a requested operation is not implemented or supported (e.g., exporting to an unsupported ...
@ Roi
Region of interest applied to the image.
@ DeviceGain
Device gain the image was captured with.
@ DeviceExposureTime
Device exposure time the image was captured with.
@ BinningHorizontal
Horizontal pixel binning factor.
@ DeviceExposureTimeSequence
Device exposure time sequence the image was captured with.
@ DeviceTimestamp
Device-provided image acquisition timestamp in nanoseconds.
@ DeviceGainSequence
Device gain sequence the image was captured with.
@ BinningVertical
Vertical pixel binning factor.
peak_icv_capture_information CreateCCaptureInformationFromMetadata(const peak::common::Metadata &metadata)