DriveWorks SDK Reference
4.0.0 Release
For Test and Development only

Color Correction Interface

Detailed Description

Module providing color correction of the camera view.

Data Structures

struct  dwColorCorrectParameters
 Configuration parameters of the color correction module. More...
 

Typedefs

typedef struct dwColorCorrectObject * dwColorCorrectHandle_t
 Handles representing the Color Correction interface. More...
 

Functions

DW_API_PUBLIC dwStatus dwColorCorrect_correctByReferenceView (dwImageHandle_t image, uint32_t curCameraIdx, float32_t factor, dwColorCorrectHandle_t obj)
 Applies global color correction on the given image. More...
 
DW_API_PUBLIC dwStatus dwColorCorrect_getCUDAStream (cudaStream_t *stream, dwColorCorrectHandle_t obj)
 Returns the CUDA stream on which the calculations of the color correction are executed. More...
 
DW_API_PUBLIC dwStatus dwColorCorrect_initializeFromProjectionMap (dwColorCorrectHandle_t *obj, dwContextHandle_t ctx, const uint32_t cameraCount, const dwVector2f *pProjToGroundMap, const dwColorCorrectParameters *params)
 Creates and initializes the color correction module using the existing reprojection matrix that reprojects cameras onto a common plane (i.e., groundplane) and then extracts color information based on the overlapping regions. More...
 
DW_API_PUBLIC dwStatus dwColorCorrect_initializeFromRig (dwColorCorrectHandle_t *obj, const dwColorCorrectParameters *parameters, dwRigHandle_t rigConfig, dwContextHandle_t ctx)
 Creates and initializes the color correction module using dwRig. More...
 
DW_API_PUBLIC dwStatus dwColorCorrect_release (dwColorCorrectHandle_t obj)
 This method releases all resources associated with a color_correct object. More...
 
DW_API_PUBLIC dwStatus dwColorCorrect_reset (dwColorCorrectHandle_t obj)
 This method resets all resources associated with a color_correct object. More...
 
DW_API_PUBLIC dwStatus dwColorCorrect_setCUDAStream (cudaStream_t stream, dwColorCorrectHandle_t obj)
 Sets the CUDA stream to run the required calculations of the color correction. More...
 
DW_API_PUBLIC dwStatus dwColorCorrect_setReferenceCameraView (const dwImageHandle_t referenceImage, uint32_t cameraIdx, dwColorCorrectHandle_t obj)
 This method adds reference view to color correction; the color of all the other views are corrected based on this view. More...
 

Data Structure Documentation

◆ dwColorCorrectParameters

struct dwColorCorrectParameters
Data Fields
uint32_t cameraHeight Height of the images from camera to be corrected. Must be even.
uint32_t cameraWidth Width of the images from camera to be corrected. Must be even.
uint32_t projectionHeight Height of the internally constructed projection image to perform color correction.

If 0 specified, default of 128 is used.

uint32_t projectionWidth Width of the internally constructed projection image to perform color correction.

If 0 specified, default of 256 is used.

Typedef Documentation

◆ dwColorCorrectHandle_t

typedef struct dwColorCorrectObject* dwColorCorrectHandle_t

Handles representing the Color Correction interface.

Definition at line 61 of file ColorCorrection.h.

Function Documentation

◆ dwColorCorrect_correctByReferenceView()

DW_API_PUBLIC dwStatus dwColorCorrect_correctByReferenceView ( dwImageHandle_t  image,
uint32_t  curCameraIdx,
float32_t  factor,
dwColorCorrectHandle_t  obj 
)

Applies global color correction on the given image.

This function does correction based on statistic data collected from the whole reprojected topview.

Parameters
[in,out]imageImage to correct. The color correction happens in-place.
[in]curCameraIdxCamera index of the given image in the specified rig.
[in]factorBlending weight, float number between [0.f, 1.f]
0.f means using the original image and no color correction
1.f means using full weight of reference color.
[in]objHandle to the color_correct class.
Returns
DW_INVALID_HANDLE - if provided color correct handle is invalid, i.e null or of wrong type .
DW_INVALID_ARGUMENT - if input image is NULL, color correct handle is null, cameraIdx is invalid, the size of the input image differs from the size passed during initialization, reference image format is not DW_IMAGE_MEMORY_TYPE_PITCH, reference image pixel format is not DW_IMAGE_YUV420 or reference image pixel type is not DW_TYPE_UINT8 or DW_TYPE_INT8.
DW_SUCCESS - Global color correction is applied successfully
Note
Input/Output image is YUV420p. Before calling this function, ensure that you already added the reference view by calling dwColorCorrect_addCameraView.

◆ dwColorCorrect_getCUDAStream()

DW_API_PUBLIC dwStatus dwColorCorrect_getCUDAStream ( cudaStream_t *  stream,
dwColorCorrectHandle_t  obj 
)

Returns the CUDA stream on which the calculations of the color correction are executed.

Parameters
[out]streamPointer to the CUDA stream to return.
[in]objHandle to the color_correct class.
Returns
DW_INVALID_ARGUMENT - if provided color correct handle or stream are NULL.
DW_INVALID_HANDLE - if provided color correct handle is invalid, i.e null or of wrong type .
DW_SUCCESS - CUDA stream is set successfully

◆ dwColorCorrect_initializeFromProjectionMap()

DW_API_PUBLIC dwStatus dwColorCorrect_initializeFromProjectionMap ( dwColorCorrectHandle_t obj,
dwContextHandle_t  ctx,
const uint32_t  cameraCount,
const dwVector2f pProjToGroundMap,
const dwColorCorrectParameters params 
)

Creates and initializes the color correction module using the existing reprojection matrix that reprojects cameras onto a common plane (i.e., groundplane) and then extracts color information based on the overlapping regions.

Parameters
[out]objThe module handle is returned here.
[in]ctxHandle to the context under which it is created.
[in]cameraCountNumber of cameras to correct.
[in]pProjToGroundMapAn array of pixel maps mapping from ground plane into each camera's image plane.
The given float array contains cameraCount*projectionWidth*projectionHeight*2 float numbers.
Start address of the k-th camera's data is camera[k] = pProjToGroundMap + k*projectWidth*projectHeight*2.
Each float pair at index (i,j) for a camera k represents a pixel coordinate in camera's image plane at position:
x = pProjToGroundMap[camera[k] + (j * projectionWidth + i) * 2], y = pProjToGroundMap[camera[k] + (j * projectionWidth + i) * 2 + 1]
Out(k, i, j) = CameraSpaceImage(k, x, y) is a ground plane projection image of the k-th camera.
[in]paramsConfiguration parameters of the camera system to set up correction algorithms.
Returns
DW_NOT_AVAILABLE - if creation of color correction handle failed.
DW_INVALID_ARGUMENT - if color correct handle is NULL.
DW_SUCCESS - color correct handle is created successfully
Note
cameraWidth/cameraHeight must have an even value because the calculation is based on YUV420 (U/V plane is downsampled)
*

◆ dwColorCorrect_initializeFromRig()

DW_API_PUBLIC dwStatus dwColorCorrect_initializeFromRig ( dwColorCorrectHandle_t obj,
const dwColorCorrectParameters parameters,
dwRigHandle_t  rigConfig,
dwContextHandle_t  ctx 
)

Creates and initializes the color correction module using dwRig.

All camera relationships are extracted from the provided rig. Color correction is performed by reprojecting all cameras onto a common plane (i.e., groundplane) and then by extracting color information based on the overlapping regions.

Parameters
[out]objThe module handle is returned here.
[in]parametersConfiguration parameters of the camera system to setup correction algorithms.
[in]rigConfigAn opening dwRig handle.
[in]ctxHandle to the context under which it is created.
Returns
DW_INVALID_HANDLE - if provided color rigconfig handle is invalid, i.e null or of wrong type
DW_NOT_AVAILABLE - if creation of color correction handle failed.
DW_INVALID_ARGUMENT - if color correct handle or parameters are NULL.
DW_SUCCESS - color correct handle is created successfully
Note
cameraWidth/cameraHeight must have an even value because the calculation is based on YUV420 (U/V plane is downsampled).

◆ dwColorCorrect_release()

DW_API_PUBLIC dwStatus dwColorCorrect_release ( dwColorCorrectHandle_t  obj)

This method releases all resources associated with a color_correct object.

Parameters
[in]objThe object handle to release.
Returns
DW_SUCCESS - color correct handle is released successfully
Note
This method renders the handle unusable.

◆ dwColorCorrect_reset()

DW_API_PUBLIC dwStatus dwColorCorrect_reset ( dwColorCorrectHandle_t  obj)

This method resets all resources associated with a color_correct object.

Parameters
[in]objThe object handle to release.
Returns
DW_INVALID_ARGUMENT - if provided color correct handle is NULL.
DW_SUCCESS - color correct handle is reset successfully

◆ dwColorCorrect_setCUDAStream()

DW_API_PUBLIC dwStatus dwColorCorrect_setCUDAStream ( cudaStream_t  stream,
dwColorCorrectHandle_t  obj 
)

Sets the CUDA stream to run the required calculations of the color correction.

Parameters
[in]streamCUDA stream that is used during color correction.
[in]objHandle to the color_correct class.
Returns
DW_INVALID_ARGUMENT - if provided color correct handle is NULL.
DW_INVALID_HANDLE - if provided color correct handle is invalid, i.e null or of wrong type .
DW_SUCCESS - CUDA stream is set successfully

◆ dwColorCorrect_setReferenceCameraView()

DW_API_PUBLIC dwStatus dwColorCorrect_setReferenceCameraView ( const dwImageHandle_t  referenceImage,
uint32_t  cameraIdx,
dwColorCorrectHandle_t  obj 
)

This method adds reference view to color correction; the color of all the other views are corrected based on this view.

The reference image is not modified.

Parameters
[in]cameraIdxIndex of the reference camera in the provided camera rig.
[in]referenceImageImage of the reference camera.
[in]objHandle to the color_correct class.
Returns
DW_INVALID_HANDLE - if provided color correct handle is invalid, i.e null or of wrong type .
DW_INVALID_ARGUMENT - if given color correct handle is NULL, reference image is NULL, cameraIdx is invalid, the size of the input image differs from the size passed during initialization, reference image format is not DW_IMAGE_MEMORY_TYPE_PITCH, reference image pixel format is not DW_IMAGE_YUV420 or reference image pixel type is not DW_TYPE_UINT8 or DW_TYPE_INT8.
DW_SUCCESS - reference camera view is set successfully