Skip to content

Pylon::CAviWriter#

Module: Image Handling Support

Supports writing AVI files.

#include <pylon/AviWriter.h>

Public Functions#

Name
CAviWriter()
Creates an AVI writer object.
virtual ~CAviWriter()
Destroys the AVI writer object.
virtual void Open(const String_t & filename, double framesPerSecondPlayback, EPixelType pixelType, uint32_t width, uint32_t height, EImageOrientation orientation =ImageOrientation_BottomUp, SAviCompressionOptions * pCompressionOptions =NULL)
Opens an AVI file for writing.
virtual bool IsOpen()
Returns the open state of the AVI file.
virtual void Close()
Closes the AVI file.
virtual void Add(const IImage & image, EKeyFrameSelection keyFrameSelection =KeyFrameSelection_Auto)
Adds the image to the AVI file.
virtual void Add(const void * pBuffer, size_t bufferSize, EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EImageOrientation orientation, EKeyFrameSelection keyFrameSelection =KeyFrameSelection_Auto)
Adds the image to the AVI file.
virtual bool CanAddWithoutConversion(EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EImageOrientation orientation)
Can be used to check whether the given image is added to the AVI file without prior conversion when Add() is called.
virtual bool CanAddWithoutConversion(const IImage & image)
Can be used to check whether the given image is added to the AVI file without prior conversion when Add() is called.
virtual size_t GetCountOfAddedImages() const
Provides access to the number of images that have been added to the AVI file.
virtual size_t GetImageDataBytesWritten() const
Provides access to the number of image data bytes written to the AVI file.

Protected Functions#

Name
CLock & GetLock()
Provides access to the lock used for synchronizing the access to the AVI writer.

Public Functions Documentation#

function CAviWriter#

CAviWriter()

Creates an AVI writer object.

Error Safety:

Does not throw C++ exceptions.

function ~CAviWriter#

virtual ~CAviWriter()

Destroys the AVI writer object.

Error Safety:

Does not throw C++ exceptions.

function Open#

virtual void Open(
    const String_t & filename,
    double framesPerSecondPlayback,
    EPixelType pixelType,
    uint32_t width,
    uint32_t height,
    EImageOrientation orientation =ImageOrientation_BottomUp,
    SAviCompressionOptions * pCompressionOptions =NULL
)

Opens an AVI file for writing.

Parameters:

  • filename Name and path of the image.
  • framesPerSecondPlayback The frame rate of the AVI file when shown in a media player.
  • pixelType The pixel type of the image in the AVI file.
  • width The number of pixels in a row.
  • height The number of rows of the image.
  • orientation The vertical orientation of the image data in the AVI file.
  • pCompressionOptions Compression can be enabled by passing compression options. See SAviCompressionOptions.

Precondition:

  • The AVI file is closed.
  • The pixelType is either PixelType_Mono8, PixelType_BGR8packed or PixelType_BGRA8packed
  • The width value must be > 0 and < _I32_MAX.
  • The height value must be > 0 and < _I32_MAX.

Error Safety:

Throws an exception if the AVI file cannot be opened. Throws an exception if the preconditions are not met.

Thread Safety:

This method is synchronized using the lock provided by GetLock().

If a file with the same filename already exists, it will be overwritten.

function IsOpen#

virtual bool IsOpen()

Returns the open state of the AVI file.

Return: Returns true if open.

Error Safety:

Does not throw C++ exceptions.

Thread Safety:

This method is synchronized using the lock provided by GetLock().

function Close#

virtual void Close()

Closes the AVI file.

Error Safety:

Does not throw C++ exceptions.

Thread Safety:

This method is synchronized using the lock provided by GetLock().

function Add#

virtual void Add(
    const IImage & image,
    EKeyFrameSelection keyFrameSelection =KeyFrameSelection_Auto
)

Adds the image to the AVI file.

Parameters:

  • image The image to add, e.g. a CPylonImage, CPylonBitmapImage, or Grab Result Smart Pointer object.
  • keyFrameSelection Can be used to control key frame selection for compressed images if needed.

Precondition:

Error Safety:

Throws an exception if the image cannot be added.

Thread Safety:

This method is synchronized using the lock provided by GetLock().

Converts the image to the correct format if required.

The image is automatically converted to the format passed when opening the file if needed. The image is also converted if the stride of the passed image is not aligned to 4 byte. The image is also converted if the orientation of the passed image does mot match the value passed when opening the AVI file.

If more control over the conversion is required, the CImageFormatConverter class can be used to convert other images with a CPylonBitmapImage object as target. The CPylonBitmapImage object can then be added to the AVI file.

function Add#

virtual void Add(
    const void * pBuffer,
    size_t bufferSize,
    EPixelType pixelType,
    uint32_t width,
    uint32_t height,
    size_t paddingX,
    EImageOrientation orientation,
    EKeyFrameSelection keyFrameSelection =KeyFrameSelection_Auto
)

Adds the image to the AVI file.

Parameters:

  • pBuffer The pointer to the buffer of the image.
  • bufferSize The size of the buffer in byte.
  • pixelType The pixel type of the image to save.
  • width The number of pixels in a row of the image to save.
  • height The number of rows of the image to save.
  • paddingX The number of extra data bytes at the end of each line.
  • orientation The vertical orientation of the image in the image buffer.
  • keyFrameSelection Can be used to control key frame selection for compressed images if needed.

Precondition:

Error Safety:

Throws an exception if the image cannot be added.

Thread Safety:

This method is synchronized using the lock provided by GetLock().

Converts the image to the correct format if required.

See Add( const Image&) for more details.

function CanAddWithoutConversion#

virtual bool CanAddWithoutConversion(
    EPixelType pixelType,
    uint32_t width,
    uint32_t height,
    size_t paddingX,
    EImageOrientation orientation
)

Can be used to check whether the given image is added to the AVI file without prior conversion when Add() is called.

Parameters:

  • pixelType The pixel type of the image to save.
  • width The number of pixels in a row of the image to save.
  • height The number of rows of the image to save.
  • paddingX The number of extra data bytes at the end of each row.
  • orientation The vertical orientation of the image data in the AVI file.

Return: Returns true if the image is added to the AVI stream without prior conversion when Add() is called. Returns false if the image is automatically converted when Add() is called. Returns false if the image cannot be added at all. See the preconditions of Add() for more information.

Error Safety:

Does not throw C++ exceptions.

function CanAddWithoutConversion#

virtual bool CanAddWithoutConversion(
    const IImage & image
)

Can be used to check whether the given image is added to the AVI file without prior conversion when Add() is called.

Parameters:

Return: Returns true if the image is added to the AVI stream without prior conversion when Add() is called. Returns false if the image is automatically converted when Add() is called. Returns false if the image cannot be added at all. See the preconditions of Add() for more information.

Error Safety:

Does not throw C++ exceptions.

function GetCountOfAddedImages#

virtual size_t GetCountOfAddedImages() const

Provides access to the number of images that have been added to the AVI file.

Return: Returns the number of images that have been added to the AVI file. Returns 0 if no AVI file has been written yet.

Error Safety:

Does not throw C++ exceptions.

function GetImageDataBytesWritten#

virtual size_t GetImageDataBytesWritten() const

Provides access to the number of image data bytes written to the AVI file.

Return: Returns the number of image data bytes that have been written to the AVI file. Returns 0 if no AVI File has been written yet. This size does not include the sizes of the AVI file header and AVI file index.

Error Safety:

Does not throw C++ exceptions.

This value is updated with each call to AviWriter::Add().

Depending on the used image format and codec, about 5 KB of header information and padding bytes are written to the AVI file. Furthermore, 24 additional bytes are needed per image for chunk header and index entry data.

Protected Functions Documentation#

function GetLock#

CLock & GetLock()

Provides access to the lock used for synchronizing the access to the AVI writer.

Error Safety:

Does not throw C++ exceptions.