16#include <peak_icv_c/algorithms/preprocessing/peak_icv_image_converter.h>
213 static constexpr int moduleVersion{ 1 };
214 static constexpr auto outputPixelFormatKey{
"OutputPixelFormat" };
217 bool m_enabled{
true };
218 peak_icv_image_converter_handle m_handle{};
224 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ImageConverter_Create(&m_handle);
230 if (m_handle !=
nullptr)
232 std::ignore = PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ImageConverter_Destroy(m_handle);
238 m_outputPixelFormat = other.m_outputPixelFormat;
239 m_enabled = other.m_enabled;
240 std::swap(m_handle, other.m_handle);
247 m_outputPixelFormat = other.m_outputPixelFormat;
248 m_enabled = other.m_enabled;
249 std::swap(m_handle, other.m_handle);
258 archive.
SetInt(
"Version", moduleVersion);
265 const auto version = archive.
GetInt(
"Version");
274 m_outputPixelFormat = format;
279 return m_outputPixelFormat;
299 return "PixelFormatConversion";
318 if (inputFormat == m_outputPixelFormat)
323 auto*
const inputImageHandle = peak::common::detail::BackendAccessor<peak::icv::Image>::BackendHandle(inputImage);
327 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ImageConverter_Convert(
328 m_handle, inputImageHandle,
static_cast<peak_common_pixel_format
>(m_outputPixelFormat), &outputHandle);
331 return peak::common::Any(peak::common::detail::BackendAccessor<peak::icv::Image>::CreateInstance(outputHandle));
337 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ImageConverter_ReleaseBuffers(m_handle);
A type-erased container for any copyable value.
T & AnyCast()
Casts the stored value to the specified type.
Interface for a hierarchical key-value archive system.
virtual void SetBool(const std::string &key, bool value)=0
Stores a boolean value.
virtual void SetInt(const std::string &key, int64_t value)=0
Stores a 64-bit signed integer.
virtual int64_t GetInt(const std::string &key) const =0
Retrieves a 64-bit signed integer by key.
virtual std::string GetString(const std::string &key) const =0
Retrieves a string value by key.
virtual bool GetBool(const std::string &key) const =0
Retrieves a boolean value by key.
virtual void SetString(const std::string &key, const std::string &value)=0
Stores a UTF-8 string.
For detailed information about the use of ids_peak_icv Image refer to the Image Guide.
peak::common::PixelFormat GetPixelFormat() const
Provides the pixel format of the image.
Interface for a module used within a pipeline.
#define PEAK_COMMON_NO_DISCARD
Compatability macro for the nodiscard attribute.
PixelFormat
Enum listing all supported pixel formats and their internal IDs.
@ RGB8
RGB 8-Bit pixel format.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
void ValidateVersion(int64_t version, const std::string &moduleName)
peak_icv_image * peak_icv_image_handle