161 uint32_t quality = 0;
175 double min = 0, max = 0, inc = 0;
177 return { min, max, inc };
189static inline std::vector<PEAK_IPL_VIDEO_ENCODER> GetSupportedEncodersForAContainer(
PEAK_IPL_VIDEO_CONTAINER container)
195 std::vector<PEAK_IPL_VIDEO_ENCODER> encoders(length);
198 container, encoders.data(), &length);
217 std::vector<PixelFormatName> formats(sizeOfData);
239 return std::unique_ptr<MJPEGEncoder>(
new MJPEGEncoder());
304 m_handle, option, value, count, outCount);
388static inline std::vector<PEAK_IPL_VIDEO_CONTAINER> GetSupportedContainersForAnEncoder(
PEAK_IPL_VIDEO_ENCODER encoder)
394 std::vector<PEAK_IPL_VIDEO_CONTAINER> containers(length);
397 encoder, containers.data(), &length);
416 return std::unique_ptr<AVIContainer>(
new AVIContainer());
418 throw InvalidArgumentException(
"The supplied container is not a valid value!");
443 m_handle = other.m_handle;
444 other.m_handle =
nullptr;
445 m_encoder = std::move(other.m_encoder);
446 m_container = std::move(other.m_container);
451 m_handle = other.m_handle;
452 other.m_handle =
nullptr;
453 m_encoder = std::move(other.m_encoder);
454 m_container = std::move(other.m_container);
472 void Open(
const std::string& fileName, std::shared_ptr<container::IContainer> container,
473 std::shared_ptr<encoder::IEncoder> encoder)
475 if (!container || !encoder)
482 &m_handle, fileName.c_str(), container->Id(), encoder->Id());
485 m_container = container;
487 m_encoder->SetHandle(m_handle);
488 m_container->SetHandle(m_handle);
501 void Open(
const std::string& fileName)
505 Open(fileName, std::move(container), std::move(encoder));
554 if (m_encoder ==
nullptr)
560 m_handle, ImageBackendAccessor::BackendHandle(image));
595 uint64_t numFramesEncoded{};
598 return numFramesEncoded;
607 uint64_t numFramesDropped{};
610 return numFramesDropped;
666 int32_t minQueueSize{}, maxQueueSize{};
671 return {minQueueSize, maxQueueSize, 1};
712 std::shared_ptr<encoder::IEncoder> m_encoder{};
713 std::shared_ptr<container::IContainer> m_container{};
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:40
The exception thrown when passing an invalid parameter to a function.
Definition peak_ipl_exception.hpp:59
Range support and convenience class.
Definition peak_ipl_range.hpp:31
Writes images to a file in the form of a video.
Definition peak_ipl_video_writer.hpp:430
void Open(const std::string &fileName, std::shared_ptr< container::IContainer > container, std::shared_ptr< encoder::IEncoder > encoder)
Open the VideoWriter and sets up a container and an encoder. The file is created upon receiving the f...
Definition peak_ipl_video_writer.hpp:472
VideoWriter(const VideoWriter &)=delete
VideoWriter(VideoWriter &&other) noexcept
Definition peak_ipl_video_writer.hpp:441
Range< int32_t > QueueSizeRange()
Get the range of the queue size.
Definition peak_ipl_video_writer.hpp:664
void Open(const std::string &fileName)
Open the VideoWriter with AVI container and mjpeg encoder. The file is created upon receiving the fir...
Definition peak_ipl_video_writer.hpp:501
void WaitUntilFrameDone(int32_t timeout_ms)
Wait until frame processing is done.
Definition peak_ipl_video_writer.hpp:692
std::shared_ptr< encoder::IEncoder > Encoder() const
Get the used encoder.
Definition peak_ipl_video_writer.hpp:575
void SetQueueSize(int32_t queueSize)
Set the internal queue size of the video writer.
Definition peak_ipl_video_writer.hpp:639
std::shared_ptr< container::IContainer > Container() const
Get the used container.
Definition peak_ipl_video_writer.hpp:584
void WaitUntilQueueEmpty(int32_t timeout_ms)
Wait until the queue is empty.
Definition peak_ipl_video_writer.hpp:703
VideoWriter & operator=(VideoWriter &&other) noexcept
Definition peak_ipl_video_writer.hpp:449
int32_t NumBuffersQueued()
Get the count of the currently queued buffers, which are waiting to be processed.
Definition peak_ipl_video_writer.hpp:678
void ResetFrameCounters()
Reset compressed and dropped frame counters.
Definition peak_ipl_video_writer.hpp:628
void Append(const Image &image)
Append an image to the opened video.
Definition peak_ipl_video_writer.hpp:552
bool IsOpen() const
Check if the VideoWriter is already open.
Definition peak_ipl_video_writer.hpp:517
uint64_t NumFramesDropped() const
Get the dropped frames in the video stream.
Definition peak_ipl_video_writer.hpp:605
void Close()
Close the opened VideoWriter.
Definition peak_ipl_video_writer.hpp:532
VideoWriter & operator=(const VideoWriter &)=delete
uint64_t FileSize() const
Get the file size of the video in bytes.
Definition peak_ipl_video_writer.hpp:617
uint64_t NumFramesEncoded() const
Get the encoded frames in the video stream.
Definition peak_ipl_video_writer.hpp:593
~VideoWriter()
Definition peak_ipl_video_writer.hpp:433
int32_t QueueSize()
Get the internal queue size of the video writer.
Definition peak_ipl_video_writer.hpp:650
VideoWriter & operator<<(const Image &image)
Append an image to the opened video.
Definition peak_ipl_video_writer.hpp:565
AVI container specialization of IContainer. Create the container with the according Create function.
Definition peak_ipl_video_writer.hpp:335
friend std::unique_ptr< IContainer > Create(PEAK_IPL_VIDEO_CONTAINER container)
Factory to create an encoder.
Definition peak_ipl_video_writer.hpp:234
AVIContainer(const AVIContainer &)=delete
PEAK_IPL_VIDEO_CONTAINER Id() override
Get the current type of the container.
Definition peak_ipl_video_writer.hpp:350
void SetFramerate(double fps)
Set the frame rate for the opened video.
Definition peak_ipl_video_writer.hpp:364
AVIContainer & operator=(AVIContainer &&)=default
double GetFramerate()
Get the frame rate for the opened video.
Definition peak_ipl_video_writer.hpp:376
AVIContainer & operator=(const AVIContainer &)=delete
AVIContainer(AVIContainer &&)=default
Container Interface Class.
Definition peak_ipl_video_writer.hpp:255
PEAK_IPL_VIDEO_HANDLE m_handle
Definition peak_ipl_video_writer.hpp:259
void GetOption(PEAK_IPL_VIDEO_CONTAINER_OPTION option, void *value, size_t count, size_t *outCount)
Gets an option of the container.
Definition peak_ipl_video_writer.hpp:300
virtual ~IContainer()=default
void OptionRange(PEAK_IPL_VIDEO_CONTAINER_OPTION option, void *min, void *max, void *inc)
Receive the range for an option of the container.
Definition peak_ipl_video_writer.hpp:320
virtual PEAK_IPL_VIDEO_CONTAINER Id()=0
void SetOption(PEAK_IPL_VIDEO_CONTAINER_OPTION option, const void *value, size_t count)
Sets an option on the container.
Definition peak_ipl_video_writer.hpp:281
void SetHandle(PEAK_IPL_VIDEO_HANDLE handle)
Definition peak_ipl_video_writer.hpp:260
Encoder Interface Class.
Definition peak_ipl_video_writer.hpp:38
virtual ~IEncoder()=default
void SetHandle(PEAK_IPL_VIDEO_HANDLE handle)
Definition peak_ipl_video_writer.hpp:44
void OptionRange(PEAK_IPL_VIDEO_ENCODER_OPTION option, void *min, void *max, void *inc)
Receive the range for an option of the encoder.
Definition peak_ipl_video_writer.hpp:102
PEAK_IPL_VIDEO_HANDLE m_handle
Definition peak_ipl_video_writer.hpp:42
virtual PEAK_IPL_VIDEO_ENCODER Id()=0
void GetOption(PEAK_IPL_VIDEO_ENCODER_OPTION option, void *value, size_t count, size_t *outCount)
Gets an option of the encoder.
Definition peak_ipl_video_writer.hpp:83
void SetOption(PEAK_IPL_VIDEO_ENCODER_OPTION option, const void *value, size_t count)
Sets an option on the encoder.
Definition peak_ipl_video_writer.hpp:65
JPEG encoder specialization of IEncoder. Create the encoder with the according Create function.
Definition peak_ipl_video_writer.hpp:117
friend std::unique_ptr< IEncoder > Create(PEAK_IPL_VIDEO_ENCODER encoder)
Factory to create an encoder.
Definition peak_ipl_video_writer.hpp:234
MJPEGEncoder & operator=(const MJPEGEncoder &)=delete
void SetQuality(uint32_t quality)
Sets the quality for the jpeg encoder.
Definition peak_ipl_video_writer.hpp:147
MJPEGEncoder(MJPEGEncoder &&)=default
MJPEGEncoder(const MJPEGEncoder &)=delete
PEAK_IPL_VIDEO_ENCODER Id() override
Get the current type of the encoder.
Definition peak_ipl_video_writer.hpp:133
Range< double > QualityRange()
Gets the quality range for the jpeg encoder.
Definition peak_ipl_video_writer.hpp:173
MJPEGEncoder & operator=(MJPEGEncoder &&)=default
uint32_t GetQuality()
Gets the quality for the jpeg encoder.
Definition peak_ipl_video_writer.hpp:159
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:182
The "peak::ipl" namespace contains the whole image processing library.
Definition peak_ipl_binning.hpp:23
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Queue_SetSize(PEAK_IPL_VIDEO_HANDLE videoHandle, int32_t size)
Set the internal queue size of the video writer.
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Container_GetOption(PEAK_IPL_VIDEO_HANDLE videoHandle, PEAK_IPL_VIDEO_ENCODER_OPTION option, void *value, size_t count, size_t *outCount)
Gets an option of the container.
uint16_t PEAK_IPL_VIDEO_ENCODER
Definition peak_ipl_backend.h:250
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Encoder_GetOption(PEAK_IPL_VIDEO_HANDLE videoHandle, PEAK_IPL_VIDEO_ENCODER_OPTION option, void *value, size_t count, size_t *outCount)
Sets an option of the encoder.
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Queue_GetQueued(PEAK_IPL_VIDEO_HANDLE videoHandle, int32_t *queued)
Get the count of the currently queued buffers.
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Video_GetEncodedFrames(PEAK_IPL_VIDEO_HANDLE videoHandle, uint64_t *numFrames)
Gets the number of encoded frames in the video stream.
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Encoder_OptionRange(PEAK_IPL_VIDEO_HANDLE videoHandle, PEAK_IPL_VIDEO_ENCODER_OPTION option, void *min, void *max, void *inc)
Receive the range for an option of the encoder.
@ PEAK_IPL_VIDEO_CONTAINER_AVI
Definition peak_ipl_backend.h:241
uint16_t PEAK_IPL_VIDEO_CONTAINER_OPTION
Definition peak_ipl_backend.h:262
uint16_t PEAK_IPL_VIDEO_CONTAINER
Definition peak_ipl_backend.h:243
PEAK_IPL_C_API PEAK_IPL_VideoWriter_GetSupportedEncodersForAContainer(PEAK_IPL_VIDEO_CONTAINER container, PEAK_IPL_VIDEO_ENCODER *encoders, size_t *size)
Get the supported encoders for a container.
@ PEAK_IPL_VIDEO_ENCODER_OPTION_QUALITY
Definition peak_ipl_backend.h:254
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Video_Close(PEAK_IPL_VIDEO_HANDLE videoHandle)
Close the video stream.
uint16_t PEAK_IPL_VIDEO_ENCODER_OPTION
Definition peak_ipl_backend.h:256
@ PEAK_IPL_VIDEO_CONTAINER_OPTION_FRAMERATE
Definition peak_ipl_backend.h:260
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Video_WaitUntilFrameDone(PEAK_IPL_VIDEO_HANDLE videoHandle, int32_t timeout_ms)
Wait until frame processing is done.
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Queue_GetSize(PEAK_IPL_VIDEO_HANDLE videoHandle, int32_t *size)
Get the internal queue size of the video writer.
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Video_GetFileSize(PEAK_IPL_VIDEO_HANDLE videoHandle, uint64_t *fileSize)
Gets the file size of the video.
struct PEAK_IPL_VIDEO * PEAK_IPL_VIDEO_HANDLE
Definition peak_ipl_backend.h:373
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Video_Open(PEAK_IPL_VIDEO_HANDLE *videoHandle, const char *filePath, PEAK_IPL_VIDEO_CONTAINER container, PEAK_IPL_VIDEO_ENCODER encoder)
Open a video stream.
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Video_WaitUntilQueueEmpty(PEAK_IPL_VIDEO_HANDLE videoHandle, int32_t timeout_ms)
Wait until the queue is empty.
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Video_GetDroppedFrames(PEAK_IPL_VIDEO_HANDLE videoHandle, uint64_t *numFrames)
Gets the number of dropped frames in the video stream.
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Container_SetOption(PEAK_IPL_VIDEO_HANDLE videoHandle, PEAK_IPL_VIDEO_CONTAINER_OPTION option, const void *value, size_t count)
Sets an option on the container.
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Encoder_SetOption(PEAK_IPL_VIDEO_HANDLE videoHandle, PEAK_IPL_VIDEO_ENCODER_OPTION option, const void *value, size_t count)
Sets an option on the encoder.
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Container_OptionRange(PEAK_IPL_VIDEO_HANDLE videoHandle, PEAK_IPL_VIDEO_ENCODER_OPTION option, void *min, void *max, void *inc)
Receive the range for an option of the container.
int8_t PEAK_IPL_BOOL8
Definition peak_ipl_backend.h:41
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Video_ResetFrameCounters(PEAK_IPL_VIDEO_HANDLE videoHandle)
Reset compressed and dropped frame counters.
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Encoder_GetSupportedPixelFormats(PEAK_IPL_VIDEO_ENCODER encoder, PEAK_IPL_PIXEL_FORMAT *pixelFormatList, size_t *pixelFormatListSize)
Get the supported pixelformats for an encoder.
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Video_Append(PEAK_IPL_VIDEO_HANDLE videoHandle, PEAK_IPL_IMAGE_HANDLE imageHandle)
Append an image to the video stream.
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_backend.h:26
int32_t PEAK_IPL_PIXEL_FORMAT
Definition peak_ipl_backend.h:180
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Queue_GetRange(PEAK_IPL_VIDEO_HANDLE videoHandle, int32_t *minSize, int32_t *maxSize)
Get the possible range of the internal queue size.
PEAK_IPL_C_API PEAK_IPL_VideoWriter_Video_IsOpen(PEAK_IPL_VIDEO_HANDLE videoHandle, PEAK_IPL_BOOL8 *isOpen)
Check if the video stream is open.
@ PEAK_IPL_VIDEO_ENCODER_MJPEG
Definition peak_ipl_backend.h:248
PEAK_IPL_C_API PEAK_IPL_VideoWriter_GetSupportedContainersForAnEncoder(PEAK_IPL_VIDEO_ENCODER encoder, PEAK_IPL_VIDEO_CONTAINER *containers, size_t *size)
Get the supported containers for an encoder.
#define PEAK_IPL_C_ABI_PREFIX
Definition peak_ipl_dll_defines.h:16