IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
peak_icv_hdr.hpp
Go to the documentation of this file.
1
11#pragma once
12
14#include <peak_icv_c/algorithms/hdr/peak_icv_hdr.h>
15#include <utility>
16
17namespace peak
18{
19namespace icv
20{
21namespace experimental
22{
23
38enum class HDRAlgorithm
39{
48 Debevec = 0,
49};
50
86{
87public:
96 explicit HDR();
97
98 ~HDR() override;
99
110 PEAK_COMMON_NO_DISCARD HDRAlgorithm GetAlgorithm() const;
111
142 void EstimateResponseCurve(const std::vector<Image>& images) const;
143
173 PEAK_COMMON_NO_DISCARD Image Process(const std::vector<Image>& images) const;
174
175private:
176 friend peak::common::detail::BackendAccessor<HDR>;
177
178 PEAK_COMMON_NO_DISCARD detail::handle_of_t<HDR> GetHandle() const override;
179
180 peak_icv_hdr_handle m_handle{};
181};
182
183inline HDR::HDR()
184{
186 return PEAK_ICV_C_ABI_PREFIX peak_icv_HDR_Create(&m_handle);
187 });
188}
189
190inline HDR::~HDR()
191{
192 if (m_handle != nullptr)
193 {
194 std::ignore = PEAK_ICV_C_ABI_PREFIX peak_icv_HDR_Destroy(m_handle);
195 }
196}
197
198inline HDRAlgorithm HDR::GetAlgorithm() const
199{
200 peak_icv_hdr_algorithm algorithm;
201
203 return PEAK_ICV_C_ABI_PREFIX peak_icv_HDR_GetAlgorithm(m_handle, &algorithm);
204 });
206 return static_cast<HDRAlgorithm>(algorithm);
207}
208
209inline detail::handle_of_t<HDR> HDR::GetHandle() const
210{
211 return m_handle;
213
214inline void HDR::EstimateResponseCurve(const std::vector<Image>& images) const
215{
216 if (images.size() == 0)
217 {
218 throw NotPossibleException("Number of input images has to be greater than 0.");
219 }
221 std::vector<peak_icv_image_handle> imageHandles;
222 imageHandles.reserve(images.size());
223 std::transform(images.begin(), images.end(), std::back_inserter(imageHandles), [](const auto& image) {
224 return peak::common::detail::BackendAccessor<Image>::BackendHandle(image);
225 });
226
228 return PEAK_ICV_C_ABI_PREFIX peak_icv_HDR_EstimateResponseCurve(m_handle, imageHandles.data(), imageHandles.size());
229 });
230}
231
232inline Image HDR::Process(const std::vector<Image>& images) const
233{
234 if (images.empty())
235 {
236 throw NotPossibleException("Input image vector cannot be empty.");
237 }
238
239 std::vector<peak_icv_image_handle> imageHandles;
240 imageHandles.reserve(images.size());
241 std::transform(images.begin(), images.end(), std::back_inserter(imageHandles), [](const peak::icv::Image& image) {
242 return peak::common::detail::BackendAccessor<Image>::BackendHandle(image);
243 });
244
245 peak_common_pixel_format outputPixelFormat;
247 return PEAK_ICV_C_ABI_PREFIX peak_icv_HDR_Process_GetOutputPixelFormat(
248 m_handle, peak::common::detail::CppPixelFormatToCPixelFormat(images.at(0).GetPixelFormat()), &outputPixelFormat);
249 });
250
251 Image outputImage{ peak::common::detail::CPixelFormatToCppPixelFormat(outputPixelFormat), images.at(0).GetSize() };
252 auto* const outputImageHandle = peak::common::detail::BackendAccessor<Image>::BackendHandle(outputImage);
253
255 return PEAK_ICV_C_ABI_PREFIX peak_icv_HDR_Process(m_handle, imageHandles.data(), imageHandles.size(), outputImageHandle);
256 });
257
258 return outputImage;
259}
260
261} // namespace experimental
262} // namespace icv
263} // namespace peak
For detailed information about the use of ids_peak_icv Image refer to the Image Guide.
Occurs when an operation cannot be performed due to logical constraints (e.g., camera calibration wit...
Performs High Dynamic Range (HDR) image reconstruction.
HDR()
Constructs an HDR processing object.
void EstimateResponseCurve(const std::vector< Image > &images) const
Estimates the Camera Response Curve (CRC) from a set of input images.
HDRAlgorithm GetAlgorithm() const
Returns the HDR algorithm used by this object.
Image Process(const std::vector< Image > &images) const
Generates an HDR image from the specified input images.
HDRAlgorithm
Specifies the HDR reconstruction algorithm.
@ Debevec
Debevec HDR reconstruction algorithm.
constexpr peak_common_pixel_format CppPixelFormatToCPixelFormat(PixelFormat pixelFormat) noexcept
constexpr PixelFormat CPixelFormatToCppPixelFormat(peak_common_pixel_format pixelFormat) noexcept
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
peak::common::detail::c_type_of_t< Type > * handle_of_t