DriveWorks SDK Reference
5.8.83 Release
For Test and Development only

Image Scaling

This section explains how to utilize the ImageTransformation module to downscale an image's ROI.

Creating an Image

To create an image for where the output should be copied:

dwImageProperties imgProperties{};
imgProperties.width /= 2;
imgProperties.height /= 2;
dwImage_create(&imageSmall, imgProperties, m_context);
DW_API_PUBLIC dwStatus dwSensorCamera_getImageProperties(dwImageProperties *const imageProperties, dwCameraOutputType const outputType, dwSensorHandle_t const sensor)
Gets information about the image properties for a given 'dwCameraImageOutputType'.
@ DW_CAMERA_OUTPUT_NATIVE_PROCESSED
processed images (usually be YUV420 planar or RGB planar)
Definition: Camera.h:80
#define DW_NULL_HANDLE
Definition: Types.h:96
struct dwImageObject * dwImageHandle_t
Definition: Image.h:110
DW_API_PUBLIC dwStatus dwImage_create(dwImageHandle_t *const image, dwImageProperties properties, dwContextHandle_t const ctx)
Creates and allocates resources for a dwImageHandle_t based on the properties passed as input.
Defines the properties of the image.
Definition: Image.h:397

Initializing the ImageTransformation Module

The dwImageTransformationHandle_t handle initializes the ImageTransformation module with the following parameters:

For a complete description of all parameters, please refer to dwImageTransformationParameters.

dwImageTransformationHandle_t imageTransformationEngine = DW_NULL_HANDLE;
params.ignoreAspectRatio = false;
dwImageTransformation_initialize(&imageTransformationEngine, params, context);
dwImageTransformation_setInterpolationMode(m_interpolation, imageTransformationEngine);
bool ignoreAspectRatio
Boolean indicating whether the aspect ratio of the input image should be kept (false) or the image sh...
DW_API_PUBLIC dwStatus dwImageTransformation_initialize(dwImageTransformationHandle_t *handle, dwImageTransformationParameters params, dwContextHandle_t context)
Initializes an Image Transformation Engine.
struct dwImageTransformationObject * dwImageTransformationHandle_t
DW_API_PUBLIC dwStatus dwImageTransformation_setBorderMode(dwImageProcessingBorderMode mode, dwImageTransformationHandle_t obj)
Sets the border mode used by the APIs of Image Transformation.
DW_API_PUBLIC dwStatus dwImageTransformation_setInterpolationMode(dwImageProcessingInterpolation mode, dwImageTransformationHandle_t obj)
Sets the interpolation mode used by the APIs of Image Transformation.
@ DW_IMAGEPROCESSING_BORDER_MODE_ZERO

Performing the Transformation

dwImageTransformation_copyFullImage(imageSmall, imageInput, imageTransformationEngine);
DW_API_PUBLIC dwStatus dwImageTransformation_copyFullImage(dwImageHandle_t const outputImage, dwImageHandle_t const inputImage, dwImageTransformationHandle_t const obj)
Resizes the input image and copies the result into the previously allocated output image,...

Releasing the Handle

To release the handle:

dwImageTransformation_release(imageTransformationEngine);
DW_API_PUBLIC dwStatus dwImageTransformation_release(dwImageTransformationHandle_t handle)
Releases an Image Transformation Engine.

To see a full demonstration of this workflow, please refer to Image Transformation Sample.