DriveWorks SDK Reference

| 0.6.67 Release

Image

Detailed Description

Defines image abstractions, and streamer and format conversion APIs.

Data Structures

struct  dwImageCPU
 Defines a CPU-based image. More...
 
struct  dwImageCUDA
 Defines a CUDA image. More...
 
struct  dwImageDataLines
 Container for data lines from the camera. More...
 
struct  dwImageGL
 Defines a GL texture image. More...
 
struct  dwImageNvMedia
 Defines an NvMedia image. More...
 
struct  dwImageProperties
 Defines the properties of the image. More...
 

Modules

 Image Converter
 Defines the image conversion functions in the SDK, such as for converting YUV to RGBA.
 
 Image Streamer
 Defines the image streamer function, enabling streaming images between different APIs.
 

Macros

#define DW_MAX_IMAGE_PLANES   3
 

Typedefs

typedef uint32_t GLenum
 
typedef uint32_t GLuint
 

Enumerations

enum  dwImageCUDAMemoryType {
  DW_IMAGE_CUDA_PITCH,
  DW_IMAGE_CUDA_BLOCK
}
 Specifies the CUDA memory type. More...
 
enum  dwImageMetaDataFlags {
  DW_IMAGE_FLAGS_EMBEDDED_LINES = (1 << 2),
  DW_IMAGE_FLAGS_SENSOR_SETTINGS = (1 << 3)
}
 Flags defining the meta information available in an image. More...
 
enum  dwImagePixelFormat {
  DW_IMAGE_PIXEL_FORMAT_UNKNOWN = 0,
  DW_IMAGE_R = 1000,
  DW_IMAGE_RGB = 2000,
  DW_IMAGE_RCB = 2100,
  DW_IMAGE_RCC = 2200,
  DW_IMAGE_RGBA = 3000,
  DW_IMAGE_YUV420 = 6000,
  DW_IMAGE_YUV422 = 6100,
  DW_IMAGE_RAW = 10000
}
 Specifies the pixel format of the image. More...
 
enum  dwImageType {
  DW_IMAGE_CPU = 0,
  DW_IMAGE_GL,
  DW_IMAGE_CUDA,
  DW_IMAGE_NVMEDIA
}
 Specifies the image type. More...
 

Functions

DW_API_PUBLIC dwStatus dwImage_getDataLayout (size_t *elementSize, uint32_t planeChannelCount[DW_MAX_IMAGE_PLANES], dwVector2ui planeSize[DW_MAX_IMAGE_PLANES], const dwImageProperties *prop)
 Returns the expected data layout of an image given its properties. More...
 
DW_API_PUBLIC dwStatus dwImageCPU_create (dwImageCPU *cpuImage, const dwImageProperties *prop)
 Allocates memory for the data of a dwImageCPU based on the dwImageProperties. More...
 
DW_API_PUBLIC dwStatus dwImageCPU_destroy (dwImageCPU *cpuImage)
 Deallocates data in a dwImageCPU. More...
 
DW_API_PUBLIC dwStatus dwImageCPU_mapToROI (dwImageCPU *dstImg, const dwImageCPU *srcImg, dwRect roi)
 Returns a dwImageCPU that is mapped to a region of interest in the data of the srcImg. More...
 
DW_API_PUBLIC dwStatus dwImageCUDA_create (dwImageCUDA *cudaImage, const dwImageProperties *prop, dwImageCUDAMemoryType layout)
 Allocates memory for the data of a dwImageCUDA based on the dwImageProperties and dwImageCUDAMemoryType memory layout. More...
 
DW_API_PUBLIC dwStatus dwImageCUDA_destroy (dwImageCUDA *cudaImage)
 Deallocates data in a dwImageCUDA. More...
 
DW_API_PUBLIC dwStatus dwImageCUDA_getPlaneAsImage (dwImageCUDA *planeImage, const dwImageCUDA *srcImage, uint32_t planeIdx)
 Returns a specific plane of a CUDA image as its own single-plane CUDA image. More...
 
DW_API_PUBLIC dwStatus dwImageCUDA_mapToROI (dwImageCUDA *dstImg, const dwImageCUDA *srcImg, dwRect roi)
 Returns a dwImageCUDA that is mapped to a region of interest in the data of the srcImg. More...
 
DW_API_PUBLIC dwStatus dwImageCUDA_setFromPitch (dwImageCUDA *result, void *devicePtr, uint32_t width, uint32_t height, size_t pitchInBytes, dwImagePixelFormat pixelFormat)
 Fill out given dwImageCUDA structure from a raw pointer. More...
 
DW_API_PUBLIC dwStatus dwImageGL_create (dwImageGL *glImage, const dwImageProperties *prop, GLenum target)
 Generates a texture for a dwImageGL based on the dwImageProperties for a GL target. More...
 
DW_API_PUBLIC dwStatus dwImageGL_destroy (dwImageGL *glImage)
 Destroys the texture in a dwImageGL. More...
 
DW_API_PUBLIC dwStatus dwImageGL_setupTexture (dwImageGL *glImg, const uint8_t *data, int32_t level, uint32_t depth)
 Sets up the texture defined in glImg->prop.tex from pixels stored in data. More...
 
DW_API_PUBLIC dwStatus dwImageNvMedia_create (dwImageNvMedia *nvmImage, const dwImageProperties *prop, const dwContextHandle_t context)
 Sets up an NvMediaImage based on the dwImageProperties for the NvMediaDevice in the current dwContext. More...
 
DW_API_PUBLIC dwStatus dwImageNvMedia_destroy (dwImageNvMedia *nvmImage)
 Destroys the texture in a dwImageNvMedia. More...
 
DW_API_PUBLIC dwStatus dwImageNvMedia_setFromImage (dwImageNvMedia *dstImage, const NvMediaImage *srcImage)
 Fills dwImageNvMedia struct based on the contents of NvMediaImage. More...
 

Data Structure Documentation

◆ dwImageCPU

struct dwImageCPU
Data Fields
uint8_t * data[DW_MAX_IMAGE_PLANES] Specifies the raw image data.
size_t pitch[DW_MAX_IMAGE_PLANES] Specifies the pitch of the image in bytes.
dwImageProperties prop Specifies the properites of the image.
dwTime_t timestamp_us Specifies the time, in microseconds, when the image was acquired.

◆ dwImageCUDA

struct dwImageCUDA
Data Fields
cudaArray_t array[DW_MAX_IMAGE_PLANES] Holds the CUDA image plane data.
void * dptr[DW_MAX_IMAGE_PLANES] Holds the pointer to the image planes.
dwImageCUDAMemoryType layout Defines the memory layout of the image.
size_t pitch[DW_MAX_IMAGE_PLANES] Defines the pitch of each plane in bytes.
dwImageProperties prop Defines the properties of the image.
dwTime_t timestamp_us Specifies the time, in microseconds, when the image was acquired.

◆ dwImageDataLines

struct dwImageDataLines
Data Fields
uint8_t * bottomLineData
uint32_t bytesPerLine
dwVector2ui embeddedDataSize this defines the number of rows before and after the image
uint8_t * topLineData pointer to the beginning of top and bottom lines

◆ dwImageGL

struct dwImageGL
Data Fields
dwImageProperties prop Specifies the properties of the image.
GLenum target Specifies the OpenGL texture target.
GLuint tex Specifies the OpenGL texture handle.
dwTime_t timestamp_us Specifies the time, in microseconds, when the image was acquired.

◆ dwImageMetaData

struct dwImageMetaData
Data Fields
float32_t analogGain Specifies the analog Gain.
float32_t conversionGain Specifies the conversion Gain.
dwImageDataLines dataLines embedded data lines.

This is where the meta data defined above are parsed from A RAW image coming from a sensor often contains this information arranged as extra lines before and after the image. The full image is stored in a buffer structured as [TOP DATA][IMAGE][BOTTOM DATA] (top * W) + (H * W) + (bott * W)

float32_t digitalGain Specifies the digital Gain.
float32_t exposureTime Specifies the exposure time (microsecond)
int32_t flags combination of multiple flags dwImageMetaDataFlags defining which of the meta fields are valid
float32_t wbGain[4] Specifies the sensor white balance gains : R(0) G1(1) G2(2) B(3)

◆ dwImageNvMedia

struct dwImageNvMedia
Data Fields
NvMediaImage * img Holds the pointer to the NvMedia image.
dwImageProperties prop Holds image properties.
dwTime_t timestamp_us Specifies the time, in microseconds, when the image was acquired.

◆ dwImageProperties

struct dwImageProperties
Data Fields
uint32_t height Specifies the height of the image in pixels.
dwImageMetaData meta additional meta information stored with the image. Not all images might provide it
uint32_t planeCount Specifies the plane count of the image. For interleaved images the plane count is 1.
dwImagePixelFormat pxlFormat Specifies the pixel format of the image.
dwTrivialDataType pxlType Specifies the pixel type of the image.
dwImageType type Specifies the type of image.
uint32_t width Specifies the width of the image in pixels.

Macro Definition Documentation

◆ DW_MAX_IMAGE_PLANES

#define DW_MAX_IMAGE_PLANES   3

Definition at line 80 of file Image.h.

Typedef Documentation

◆ GLenum

typedef uint32_t GLenum

Definition at line 58 of file Image.h.

◆ GLuint

typedef uint32_t GLuint

Definition at line 59 of file Image.h.

Enumeration Type Documentation

◆ dwImageCUDAMemoryType

Specifies the CUDA memory type.

Enumerator
DW_IMAGE_CUDA_PITCH 
DW_IMAGE_CUDA_BLOCK 

Definition at line 164 of file Image.h.

◆ dwImageMetaDataFlags

Flags defining the meta information available in an image.

Enumerator
DW_IMAGE_FLAGS_EMBEDDED_LINES 

If an image was extracted from a camera, additional embedded data lines might be provided The data lines are stored before and after the actual image content in memory.

DW_IMAGE_FLAGS_SENSOR_SETTINGS 

Image contains valid sensor settings information, such as exposure, gain, whitebalance, etc.

Definition at line 182 of file Image.h.

◆ dwImagePixelFormat

Specifies the pixel format of the image.

Enumerator
DW_IMAGE_PIXEL_FORMAT_UNKNOWN 
DW_IMAGE_R 
    Grayscale Image
    1 plane, 1 channel, WxH plane size
    
DW_IMAGE_RGB 
    planar: R0R1R2...G0G1G2...B0B1B2... (3 planes)
              WxH     WxH      WxH      plane size
               1       1       1        chnl count
    interl: R0G0B0R1G1B1R2G2B2...       (1 plane)
    eaved            WxH                plane size
                      3                 chnl count
    
DW_IMAGE_RCB 
    planar: R0R1R2...C0C1C2...B0B1B2... (3 planes)
              WxH     WxH      WxH      plane size
               1       1        1       chnl count
    NOTE: For CUDA RCB image, 3 planes have to be
    consecutive in device memory
    
DW_IMAGE_RCC 
    Red Clear Clear-Red Image, demoisaiced of
    an RCCC raw image.
    Same layout as DW_IMAGE_RGB
    
DW_IMAGE_RGBA 
    interl: R0G0B0A0R1G1B1A1R2G2B2A2... (1 plane)
    eaved            WxH                plane size
                      4                 chnl count
    
DW_IMAGE_YUV420 
    planar: Y0Y1Y2...U0U1U2...V0V1V2... (3 planes)
              WxH    W/2xH/2  W/2xH/2   plane size
               1        1        1      chnl count
    semi-p: Y0Y1Y2...U0V0U1V1U2V2...    (2 planes)
              WxH      W/2xH/2          plane size
               1         2              chnl count
    
DW_IMAGE_YUV422 
    planar: Y0Y1Y2...U0U1U2...V0V1V2... (3 planes)
              WxH   (W/2)xH  (W/2)xH    plane size
               1       1        1       chnl count
    semi-p: Y0Y1Y2...U0V0U1V1U2V2...    (2 planes)
              WxH        (W/2)xH        plane size
               1           2            chnl count
    
DW_IMAGE_RAW 
    RAW sensor data, single value per pixel.
    1 plane, 1 channel, WxH plane size
    

Definition at line 93 of file Image.h.

◆ dwImageType

Specifies the image type.

Enumerator
DW_IMAGE_CPU 
DW_IMAGE_GL 
DW_IMAGE_CUDA 
DW_IMAGE_NVMEDIA 

Definition at line 83 of file Image.h.

Function Documentation

◆ dwImage_getDataLayout()

DW_API_PUBLIC dwStatus dwImage_getDataLayout ( size_t *  elementSize,
uint32_t  planeChannelCount[DW_MAX_IMAGE_PLANES],
dwVector2ui  planeSize[DW_MAX_IMAGE_PLANES],
const dwImageProperties prop 
)

Returns the expected data layout of an image given its properties.

The byte size for plane i's row is:

elementSize*planeChannelCount[i]*planeWidth[i]
Parameters
[out]elementSizeSize in bytes of the pixel type
[out]planeChannelCountNumber of channels within each plane
[out]planeSizeSize of each plane
[in]propA pointer to the image properties to compute data layout from.

◆ dwImageCPU_create()

DW_API_PUBLIC dwStatus dwImageCPU_create ( dwImageCPU cpuImage,
const dwImageProperties prop 
)

Allocates memory for the data of a dwImageCPU based on the dwImageProperties.

All variables in the struct will be automatically initialized. Timestamp is 0 by default.

Parameters
[out]cpuImageA pointer to the dwImageCPU struct. The data pointed by it will be allocated
[in]propProperties of the dwImageCPU.
Returns
DW_SUCCESS, DW_INVALID_ARGUMENT

◆ dwImageCPU_destroy()

DW_API_PUBLIC dwStatus dwImageCPU_destroy ( dwImageCPU cpuImage)

Deallocates data in a dwImageCPU.

Parameters
[in]cpuImageA pointer to the dwImageCPU struct.
Returns
DW_SUCCESS, DW_INVALID_ARGUMENT

◆ dwImageCPU_mapToROI()

DW_API_PUBLIC dwStatus dwImageCPU_mapToROI ( dwImageCPU dstImg,
const dwImageCPU srcImg,
dwRect  roi 
)

Returns a dwImageCPU that is mapped to a region of interest in the data of the srcImg.

NOTE: only single plane images are supported.

Parameters
[out]dstImgA pointer to the dwImageCPU containing the roi. NOTE: the properties will reflect the size of the roi. (NOTE: this is not a copy)
[in]srcImgA pointer to the source dwImageCPU.
[in]roiA dwRect specifying the coordinates of the region of interest.
Returns
DW_SUCCESS, DW_INVALID_ARGUMENT

◆ dwImageCUDA_create()

DW_API_PUBLIC dwStatus dwImageCUDA_create ( dwImageCUDA cudaImage,
const dwImageProperties prop,
dwImageCUDAMemoryType  layout 
)

Allocates memory for the data of a dwImageCUDA based on the dwImageProperties and dwImageCUDAMemoryType memory layout.

All variables in the struct will be automatically initialized. Timestamp is 0 by default.

Parameters
[out]cudaImageA pointer to the dwImageCUDA struct. The data pointed by either the device pointer (for DW_IMAGE_CUDA_PITCH layout) or (for DW_IMAGE_CUDA_BLOCK layout) will be allocated
[in]propProperties of the dwImageCUDA.
[in]layoutthe CUDA memory layout.
Returns
DW_SUCCESS, DW_INVALID_ARGUMENT, DW_CUDA_ERROR

◆ dwImageCUDA_destroy()

DW_API_PUBLIC dwStatus dwImageCUDA_destroy ( dwImageCUDA cudaImage)

Deallocates data in a dwImageCUDA.

Parameters
[in]cudaImageA pointer to the dwImageCUDA struct.
Returns
DW_SUCCESS, DW_INVALID_ARGUMENT, DW_CUDA_ERROR

◆ dwImageCUDA_getPlaneAsImage()

DW_API_PUBLIC dwStatus dwImageCUDA_getPlaneAsImage ( dwImageCUDA planeImage,
const dwImageCUDA srcImage,
uint32_t  planeIdx 
)

Returns a specific plane of a CUDA image as its own single-plane CUDA image.

No data is copied, only the pointers are duplicated.

Parameters
[out]planeImagedwImageCUDA to be filled with a single plane from srcImage
[in]srcImageSource image to extract plane from
[in]planeIdxIndex of the plane to extract
Returns
DW_INVALID_ARGUMENT - if planeImage or srcImage are NULL, or if planeIdx is invalid
DW_SUCCESS

◆ dwImageCUDA_mapToROI()

DW_API_PUBLIC dwStatus dwImageCUDA_mapToROI ( dwImageCUDA dstImg,
const dwImageCUDA srcImg,
dwRect  roi 
)

Returns a dwImageCUDA that is mapped to a region of interest in the data of the srcImg.

NOTE: only single plane images are supported.

Parameters
[out]dstImgA pointer to the dwImageCUDA containing the roi. NOTE: the properties will reflect the size of the roi. (NOTE: this is not a copy)
[in]srcImgA pointer to the source dwImageCUDA.
[in]roiA dwRect specifying the coordinates of the region of interest.
Returns
DW_SUCCESS, DW_INVALID_ARGUMENT

◆ dwImageCUDA_setFromPitch()

DW_API_PUBLIC dwStatus dwImageCUDA_setFromPitch ( dwImageCUDA result,
void *  devicePtr,
uint32_t  width,
uint32_t  height,
size_t  pitchInBytes,
dwImagePixelFormat  pixelFormat 
)

Fill out given dwImageCUDA structure from a raw pointer.

Parameters
[out]resultdwImageCUDA struct to be set up
[in]devicePtrpointer into device memory
[in]widthWidth of the image at devicePtr in pixels
[in]heightHeight of the image at devicePtr in pixels
[in]pitchInBytesPitch in bytes of the image at devicePtr
[in]pixelFormatFormat of the pixels representing the image
Returns
DW_INVALID_ARGUMENT - if result or devicePtr are NULL
DW_SUCCESS

◆ dwImageGL_create()

DW_API_PUBLIC dwStatus dwImageGL_create ( dwImageGL glImage,
const dwImageProperties prop,
GLenum  target 
)

Generates a texture for a dwImageGL based on the dwImageProperties for a GL target.

. All variables in the struct will be automatically initialized. Timestamp is 0 by default.

Parameters
[out]glImageA pointer to the dwImageGL struct. The tex pointed by it will be generated, if valid prop
[in]propProperties of the dwImageGL.
[in]targetGL target (usually GL_TEXTURE_2D).
Returns
DW_SUCCESS, DW_INVALID_ARGUMENT, DW_GL_ERROR

◆ dwImageGL_destroy()

DW_API_PUBLIC dwStatus dwImageGL_destroy ( dwImageGL glImage)

Destroys the texture in a dwImageGL.

Parameters
[in]glImageA pointer to the dwImageGL struct.
Returns
DW_SUCCESS, DW_INVALID_ARGUMENT, DW_GL_ERROR

◆ dwImageGL_setupTexture()

DW_API_PUBLIC dwStatus dwImageGL_setupTexture ( dwImageGL glImg,
const uint8_t *  data,
int32_t  level,
uint32_t  depth 
)

Sets up the texture defined in glImg->prop.tex from pixels stored in data.

Parameters
[in]glImgA pointer to the dwImageGl struct.
[in]dataA pointer to the image data in cpu memory.
[in]levelLevel at which the texture data has to be set. Should be 0 if texture is not MIPMAP.
[in]depthTexel depth in case of a texture3D, should be 0 if 2D.
Returns
DW_SUCCESS, DW_INVALID_ARGUMENT, DW_GL_ERROR

◆ dwImageNvMedia_create()

DW_API_PUBLIC dwStatus dwImageNvMedia_create ( dwImageNvMedia nvmImage,
const dwImageProperties prop,
const dwContextHandle_t  context 
)

Sets up an NvMediaImage based on the dwImageProperties for the NvMediaDevice in the current dwContext.

All variables in the struct will be automatically initialized. Timestamp is 0 by default.

Parameters
[out]nvmImageA pointer to the dwImageNvMedia struct. The NvMediaImage pointed by it will be created, if the properties are valid.
[in]propA Pointer to the properties of the dwImageNvMedia.
[in]contextCurrent dwContext, contains current NvMediaDevice.
Returns
DW_SUCCESS, DW_INVALID_ARGUMENT, DW_NVMEDIA_ERROR

◆ dwImageNvMedia_destroy()

DW_API_PUBLIC dwStatus dwImageNvMedia_destroy ( dwImageNvMedia nvmImage)

Destroys the texture in a dwImageNvMedia.

Parameters
[in]nvmImageA pointer to the dwImageNvMedia struct.
Returns
DW_SUCCESS, DW_INVALID_ARGUMENT, DW_NVMEDIA_ERROR

◆ dwImageNvMedia_setFromImage()

DW_API_PUBLIC dwStatus dwImageNvMedia_setFromImage ( dwImageNvMedia dstImage,
const NvMediaImage *  srcImage 
)

Fills dwImageNvMedia struct based on the contents of NvMediaImage.

Parameters
[out]dstImagedwImageNvMedia to be filled from srcImage
[in]srcImageSource image
Returns
DW_INVALID_ARGUMENT - if srcImage or dstImage are NULL
DW_SUCCESS