Video Stabilization for Embedded Systems - User Guide - Preparing the image

From RidgeRun Developer Wiki



Previous: User Guide/Selecting the cutoff frequency Index Next: User Guide/Setting up the stabilizer





This page provides a basic description of the Image class and it's configuration parameters.

Image attributes

The Image class contains the following attributes to describe a video frame. Each of them with its corresponding getter (ex. GetFormat).

Format

Type: Format enum
This attribute describes the format of the frame held by the data buffer. The following formats are supported:
  • RGBA

Height

Type: vector of unsigned integers
This attribute specifies the height of the frame for each of the image planes. Currently only one plane is supported with format RGBA.

Width

Type: vector of unsigned integers
This attribute specifies the width of the frame for each of the image planes. Currently only one plane is supported with format RGBA.

Stride

Type: vector of unsigned integers
This attribute specifies the width of the frame for each of the image planes. Currently only one plane is supported with format RGBA.

Size

Type: unsigned integer
This attribute specifies the total size of the memory buffer pointed by data. Therefore, it includes all image planes

Data

Type: shared pointer to unsigned char
This is a pointer to the memory that holds the frame data.

Image configuration

The Image class contains a configuration method Configure that sets all of it's attributes with the following signature:

RuntimeError Configure(Image::Format image_format,
    std::vector<unsigned int> image_height,
    std::vector<unsigned int> image_width,
    std::vector<unsigned int> image_stride,
    std::shared_ptr<unsigned char> image_data,
    unsigned int image_size);

As you can see, this class is made to be a wrapper for a user provided memory buffer. Given this, it is especially important to correctly create the buffer. If creating a buffer from scratch, the following portion of code avoids problems with the deleter of the shared pointer.

std::shared_ptr<unsigned char> buffer(new unsigned char[size](), [](unsigned char *p) { delete[] p; });

Finally, an example of how to create and configure a complete RGBA image (1 image plane) from scratch would be the following:

  unsigned int height = 1080;
  unsigned int width = 1920;
  unsigned int stride = 1920;
  unsigned int size = height * stride;
  std::shared_ptr<unsigned char> buffer(new unsigned char[size](), [](unsigned char *p) { delete[] p; });
  rr::Image image;
  rr::RuntimeError status = image.Configure(rr::Image::RGBA, {height}, {width}, {stride}, buffer, size);

Remember to use the same height, width, stride and size for the output image in the video stabilizer.


Previous: User Guide/Selecting the cutoff frequency Index Next: User Guide/Setting up the stabilizer