DriveWorks SDK Reference
4.0.0 Release
For Test and Development only

Image.h
Go to the documentation of this file.
1 // This code contains NVIDIA Confidential Information and is disclosed
3 // under the Mutual Non-Disclosure Agreement.
4 //
5 // Notice
6 // ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
7 // NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
8 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
9 // MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10 //
11 // NVIDIA Corporation assumes no responsibility for the consequences of use of such
12 // information or for any infringement of patents or other rights of third parties that may
13 // result from its use. No license is granted by implication or otherwise under any patent
14 // or patent rights of NVIDIA Corporation. No third party distribution is allowed unless
15 // expressly authorized by NVIDIA. Details are subject to change without notice.
16 // This code supersedes and replaces all information previously supplied.
17 // NVIDIA Corporation products are not authorized for use as critical
18 // components in life support devices or systems without express written approval of
19 // NVIDIA Corporation.
20 //
21 // Copyright (c) 2016-2021 NVIDIA Corporation. All rights reserved.
22 //
23 // NVIDIA Corporation and its licensors retain all intellectual property and proprietary
24 // rights in and to this software and related documentation and any modifications thereto.
25 // Any use, reproduction, disclosure or distribution of this software and related
26 // documentation without an express license agreement from NVIDIA Corporation is
27 // strictly prohibited.
28 //
30 
50 #ifndef DW_IMAGE_IMAGE_H_
51 #define DW_IMAGE_IMAGE_H_
52 
53 #include <dw/core/Config.h>
54 #include <dw/core/base/Exports.h>
55 #include <dw/core/base/Types.h>
56 #include <dw/core/base/Status.h>
58 
59 // Forward defines from GL
60 // Note: GL defines the specific bitdepth of these types
61 // so it is safe to declare then here without including GL.h
62 typedef uint32_t GLenum;
63 typedef uint32_t GLuint;
64 
65 #if (defined(__cplusplus) && (defined(LINUX) || defined(VIBRANTE)))
66 #pragma GCC diagnostic push
67 #pragma GCC diagnostic ignored "-Wold-style-cast"
68 #endif
69 
70 #include <cuda_runtime.h>
71 
72 #if (defined(__cplusplus) && (defined(LINUX) || defined(VIBRANTE)))
73 #pragma GCC diagnostic pop
74 #endif
75 
76 #ifdef VIBRANTE
77 #include <sys/time.h>
78 #include <nvmedia_image.h>
79 #endif
80 
81 #ifdef __cplusplus
82 extern "C" {
83 #endif
84 
85 #define DW_MAX_IMAGE_PLANES 3
86 
88 typedef enum dwImageType {
91 #ifdef VIBRANTE
93 #endif
94 
97  DW_IMAGE_GL = 0xFF
98 } dwImageType;
99 
100 typedef struct dwImageObject* dwImageHandle_t;
101 typedef struct dwImageObject const* dwConstImageHandle_t;
102 
104 typedef enum dwImageFormat {
107 
108  // Interleaved formats
110 
116 
120 
125 
130 
132 
133  // interleaved YUV444 format
136 
137  // Planar formats
142 
145 
148 
154 
155  // planar YUV 444
158 
164 
165 } dwImageFormat;
166 
168 typedef enum {
175 
177 
179 typedef struct dwImageDataLines
180 {
181  uint32_t bytesPerLine;
182 
185 
187  uint8_t* topLineData;
188  uint8_t* bottomLineData;
190 
192 typedef enum {
193 
197 
200 
203 
205 
207 typedef struct dwImageMetaData
208 {
210  uint32_t flags;
211 
221  float32_t wbGain[4];
223  uint32_t msbPosition;
224 
227 
234 
236 
238 typedef struct dwImageProperties
239 {
243  uint32_t width;
245  uint32_t height;
247  dwImageFormat format;
253 
255 typedef struct dwImageCPU
256 {
260  size_t pitch[DW_MAX_IMAGE_PLANES];
262  uint8_t* data[DW_MAX_IMAGE_PLANES];
265 } dwImageCPU;
266 
268 typedef struct dwImageCUDA
269 {
273  size_t pitch[DW_MAX_IMAGE_PLANES]; // pitch in bytes
275  void* dptr[DW_MAX_IMAGE_PLANES];
277  cudaArray_t array[DW_MAX_IMAGE_PLANES];
280 } dwImageCUDA;
281 
282 #ifdef VIBRANTE
283 typedef struct dwImageNvMedia
285 {
289  NvMediaImage* img;
293 #endif
294 
307 dwStatus dwImage_create(dwImageHandle_t* image,
308  dwImageProperties properties,
309  dwContextHandle_t ctx);
310 
328 dwStatus dwImage_createAndBindBuffer(dwImageHandle_t* const image,
329  dwImageProperties properties,
330  void* buffersIn[DW_MAX_IMAGE_PLANES],
331  size_t pitches[DW_MAX_IMAGE_PLANES], size_t const bufferCount,
332  dwContextHandle_t const ctx);
333 
349 dwStatus dwImage_createAndBindCUDAArray(dwImageHandle_t* const image,
350  dwImageProperties properties,
351  cudaArray_t const buffers[DW_MAX_IMAGE_PLANES], size_t const bufferCount,
352  dwContextHandle_t const ctx);
353 
354 #ifdef VIBRANTE
355 
365 dwStatus dwImage_createAndBindNvMedia(dwImageHandle_t* image, NvMediaImage* nvmImage);
366 #endif
367 
378 dwStatus dwImage_destroy(dwImageHandle_t const image);
379 
380 // specifiers
381 
392 dwStatus dwImage_getProperties(dwImageProperties* const properties, dwConstImageHandle_t const image);
393 
404 dwStatus dwImage_getTimestamp(dwTime_t* const timestamp, dwConstImageHandle_t const image);
405 
416 dwStatus dwImage_setTimestamp(dwTime_t const timestamp, dwImageHandle_t const image);
417 
429 dwStatus dwImage_getMetaData(dwImageMetaData* const metaData, dwConstImageHandle_t const image);
430 
443 dwStatus dwImage_getCPU(dwImageCPU** const imageCPU, dwImageHandle_t image);
444 
456 dwStatus dwImage_getCUDA(dwImageCUDA** const imageCUDA, dwImageHandle_t image);
457 
458 #ifdef VIBRANTE
459 
471 dwStatus dwImage_getNvMedia(dwImageNvMedia** imageNvMedia, dwImageHandle_t image);
472 #endif
473 
484 dwStatus dwImage_getPixelType(dwTrivialDataType* const type, dwImageFormat const format);
485 
496 dwStatus dwImage_getPlaneCount(size_t* const planeCount, dwImageFormat const format);
497 
517 dwStatus dwImage_copyConvert(dwImageHandle_t const output, dwConstImageHandle_t const input, dwContextHandle_t const context);
518 
539 dwStatus dwImage_copyConvertAsync(dwImageHandle_t const output, dwConstImageHandle_t const input, cudaStream_t const stream, dwContextHandle_t const context);
540 
554  dwImageCUDA const* const srcImage,
555  uint32_t const planeIdx);
556 
569 DW_API_PUBLIC dwStatus dwImageCUDA_mapToROI(dwImageCUDA* const dstImg, dwImageCUDA const* const srcImg, dwRect const roi);
570 
587 DW_API_PUBLIC dwStatus dwImage_getDataLayout(size_t* const elementSize,
588  size_t* const planeCount,
589  uint32_t planeChannelCount[DW_MAX_IMAGE_PLANES],
590  dwVector2ui planeSize[DW_MAX_IMAGE_PLANES],
591  dwImageProperties const* const prop);
592 
593 #ifdef __cplusplus
594 }
595 #endif
596 
598 #endif // DW_IMAGE_IMAGE_H_
NVIDIA DriveWorks API: Core Types
uint32_t frameSequenceNumber
Holds a frame sequence number, that is, a monotonically increasing frame counter. ...
Definition: Image.h:226
Defines an NvMedia image.
Definition: Image.h:284
DW_API_PUBLIC dwStatus dwImage_copyConvert(dwImageHandle_t const output, dwConstImageHandle_t const input, dwContextHandle_t const context)
Converts CUDA or NvMedia images by copying into an output image, following the properties in the outp...
Image contains valid sensor settings information, such as exposure, gain, whitebalance, etc.
Definition: Image.h:199
dwImageMemoryType memoryLayout
Memory layout type.
Definition: Image.h:251
DW_API_PUBLIC dwStatus dwImageCUDA_mapToROI(dwImageCUDA *const dstImg, dwImageCUDA const *const srcImg, dwRect const roi)
Returns a dwImageCUDA that is mapped to a region of interest in the data of the srcImg.
uint8_t * topLineData
pointer to the beginning of top and bottom lines
Definition: Image.h:187
DW_API_PUBLIC dwStatus dwImage_getCUDA(dwImageCUDA **const imageCUDA, dwImageHandle_t image)
Retrieves the dwImageCUDA of a dwImageHandle_t.
float float32_t
Specifies POD types.
Definition: Types.h:70
struct dwImageObject * dwImageHandle_t
Definition: Image.h:100
dwTrivialDataType
Specifies a type indicator of the underlying trivial data type.
Definition: Types.h:103
dwVector2ui embeddedDataSize
this defines the number of rows before and after the image
Definition: Image.h:184
Defines a rectangle.
Definition: Types.h:189
DW_API_PUBLIC dwStatus dwImage_getNvMedia(dwImageNvMedia **imageNvMedia, dwImageHandle_t image)
Retrieves the dwImageNvMedia of a dwImageHandle_t.
#define DW_MAX_IMAGE_PLANES
Definition: Image.h:85
Container for data lines from the camera.
Definition: Image.h:179
DW_API_PUBLIC dwStatus dwImage_createAndBindNvMedia(dwImageHandle_t *image, NvMediaImage *nvmImage)
Creates a dwImageHandle_t based on an nvmedia image.
DW_API_PUBLIC dwStatus dwImage_getTimestamp(dwTime_t *const timestamp, dwConstImageHandle_t const image)
Retrieves the timestamp of acquisition of a dwImageHandle_t.
uint32_t msbPosition
Specifies the msb of the pixel data.
Definition: Image.h:223
uint32_t GLuint
Definition: Image.h:63
dwImageProperties prop
Specifies the properites of the image.
Definition: Image.h:258
uint32_t GLenum
Definition: Image.h:62
dwImageMetaDataFlags
Flags defining the meta information available in an image.
Definition: Image.h:192
Defines a CUDA image.
Definition: Image.h:268
uint32_t width
Specifies the width of the image in pixels.
Definition: Image.h:243
for debayered images
Definition: Image.h:163
dwImageType type
Specifies the type of image.
Definition: Image.h:241
DW_API_PUBLIC dwStatus dwImage_getCPU(dwImageCPU **const imageCPU, dwImageHandle_t image)
Retrieves the dwImageCPU of a dwImageHandle_t.
DW_API_PUBLIC dwStatus dwImage_getMetaData(dwImageMetaData *const metaData, dwConstImageHandle_t const image)
Retrieves the metadata of a dwImageHandle_t.
DW_API_PUBLIC dwStatus dwImage_getProperties(dwImageProperties *const properties, dwConstImageHandle_t const image)
Retrieves the properties of a dwImageHandle_t.
pitch linear memory layout
Definition: Image.h:172
dwImageDataLines dataLines
embedded data lines.
Definition: Image.h:233
uint8_t * bottomLineData
Definition: Image.h:188
dwImageMetaData meta
additional meta information stored with the image. Not all images might provide it ...
Definition: Image.h:249
DW_API_PUBLIC dwStatus dwImageCUDA_getPlaneAsImage(dwImageCUDA *const planeImage, dwImageCUDA const *const srcImage, uint32_t const planeIdx)
Returns a specific plane of a CUDA image as its own single-plane CUDA image.
dwTime_t timestamp_us
Specifies the time, in microseconds, when the image was acquired.
Definition: Image.h:291
Normal formats.
Definition: Image.h:106
If an image was extracted from a camera, additional embedded data lines might be provided The data li...
Definition: Image.h:196
uint32_t flags
combination of multiple flags &#39;dwImageMetaDataFlags&#39; defining which of the meta fields are valid ...
Definition: Image.h:210
This type is provided here for completeness only.
Definition: Image.h:97
Image contains valid frame sequence number.
Definition: Image.h:202
dwImageProperties prop
Holds image properties.
Definition: Image.h:287
dwTime_t timestamp_us
Specifies the time, in microseconds, when the image was acquired.
Definition: Image.h:279
dwStatus
Status definition.
Definition: Status.h:180
dwImageFormat
Format of the image represented as DW_IMAGE_FORMAT_COLORSPACE(_PIXELTYPE)(_PIXELORDER) ...
Definition: Image.h:104
DW_API_PUBLIC dwStatus dwImage_getPixelType(dwTrivialDataType *const type, dwImageFormat const format)
Retrieves dwTrivialDataType associated with a specific format.
block memory layout
Definition: Image.h:174
int64_t dwTime_t
Specifies a timestamp unit, in microseconds.
Definition: Types.h:82
uint32_t bytesPerLine
Definition: Image.h:181
struct dwImageObject const * dwConstImageHandle_t
Definition: Image.h:101
DW_API_PUBLIC dwStatus dwImage_setTimestamp(dwTime_t const timestamp, dwImageHandle_t const image)
Sets the timestamp of a dwImageHandle_t.
float32_t analogGain
Specifies the analog Gain.
Definition: Image.h:215
NvMediaImage * img
Holds the pointer to the NvMedia image.
Definition: Image.h:289
dwImageType
Specifies the image type.
Definition: Image.h:88
DW_API_PUBLIC dwStatus dwImage_getDataLayout(size_t *const elementSize, size_t *const planeCount, uint32_t planeChannelCount[DW_MAX_IMAGE_PLANES], dwVector2ui planeSize[DW_MAX_IMAGE_PLANES], dwImageProperties const *const prop)
Returns the expected data layout of an image given its properties.
float32_t conversionGain
Specifies the conversion Gain.
Definition: Image.h:217
DW_API_PUBLIC dwStatus dwImage_destroy(dwImageHandle_t const image)
Destroys the image handle and frees any memory created by dwImage_create().
dwImageProperties prop
Defines the properties of the image.
Definition: Image.h:271
Defines a two-element unsigned-integer vector.
Definition: Types.h:312
RAW for images directly from sensory.
Definition: Image.h:161
struct dwContextObject * dwContextHandle_t
Context handle.
Definition: Context.h:79
NVIDIA DriveWorks API: Core Methods
dwTime_t timestamp_us
Specifies the time, in microseconds, when the image was acquired.
Definition: Image.h:264
Additional meta information stored with each image.
Definition: Image.h:207
DW_API_PUBLIC dwStatus dwImage_create(dwImageHandle_t *image, dwImageProperties properties, dwContextHandle_t ctx)
Creates and allocates resources for a dwImageHandle_t based on the properties passed as input...
the default memory layout for a given image type, can be either pitch or block
Definition: Image.h:170
uint32_t height
Specifies the height of the image in pixels.
Definition: Image.h:245
float32_t exposureTime
Specifies the exposure time (microsecond)
Definition: Image.h:213
DW_API_PUBLIC dwStatus dwImage_createAndBindCUDAArray(dwImageHandle_t *const image, dwImageProperties properties, cudaArray_t const buffers[DW_MAX_IMAGE_PLANES], size_t const bufferCount, dwContextHandle_t const ctx)
Creates a dwImageHandle_t based on the properties passed and binds a cudaArray_t to it...
YUV encoding formats from camera.
Definition: Image.h:150
dwImageMemoryType
Specifies memory type layout.
Definition: Image.h:168
DW_API_PUBLIC dwStatus dwImage_copyConvertAsync(dwImageHandle_t const output, dwConstImageHandle_t const input, cudaStream_t const stream, dwContextHandle_t const context)
Converts CUDA or NvMedia images by copying into an output image, following the properties in the outp...
DW_API_PUBLIC dwStatus dwImage_getPlaneCount(size_t *const planeCount, dwImageFormat const format)
Retrieves number of planes of the image format.
#define DW_API_PUBLIC
Definition: Exports.h:54
dwImageFormat format
Specifies the format of the image.
Definition: Image.h:247
float32_t digitalGain
Specifies the digital Gain.
Definition: Image.h:219
NVIDIA DriveWorks API: Core Status Methods
Defines the properties of the image.
Definition: Image.h:238
DW_API_PUBLIC dwStatus dwImage_createAndBindBuffer(dwImageHandle_t *const image, dwImageProperties properties, void *buffersIn[DW_MAX_IMAGE_PLANES], size_t pitches[DW_MAX_IMAGE_PLANES], size_t const bufferCount, dwContextHandle_t const ctx)
Creates a dwImageHandle_t based on the properties passed and binds a memory buffer provided by the ap...
NVIDIA DriveWorks API: Core Exports
Defines a CPU-based image.
Definition: Image.h:255