DriveWorks SDK Reference
5.4.5418 Release
For Test and Development only

Image.h
Go to the documentation of this file.
1 //
3 // Notice
4 // ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
5 // NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
6 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
7 // MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 //
9 // NVIDIA CORPORATION & AFFILIATES assumes no responsibility for the consequences of use of such
10 // information or for any infringement of patents or other rights of third parties that may
11 // result from its use. No license is granted by implication or otherwise under any patent
12 // or patent rights of NVIDIA CORPORATION & AFFILIATES. No third party distribution is allowed unless
13 // expressly authorized by NVIDIA. Details are subject to change without notice.
14 // This code supersedes and replaces all information previously supplied.
15 // NVIDIA CORPORATION & AFFILIATES products are not authorized for use as critical
16 // components in life support devices or systems without express written approval of
17 // NVIDIA CORPORATION & AFFILIATES.
18 //
19 // SPDX-FileCopyrightText: Copyright (c) 2016-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
20 // SPDX-License-Identifier: LicenseRef-NvidiaProprietary
21 //
22 // NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
23 // property and proprietary rights in and to this material, related
24 // documentation and any modifications thereto. Any use, reproduction,
25 // disclosure or distribution of this material and related documentation
26 // without an express license agreement from NVIDIA CORPORATION or
27 // its affiliates is 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 #include <nvmedia_isp_stat.h>
80 #endif
81 
82 #ifdef __cplusplus
83 extern "C" {
84 #endif
85 
86 #define DW_MAX_IMAGE_PLANES 3
87 #define DW_ISP_MAX_COLOR_COMPONENT (4U)
88 
90 #define DW_MAX_NUM_TEMPERATURES 4
91 
93 typedef enum dwImageType {
96 #ifdef VIBRANTE
98 #endif
99 
102  DW_IMAGE_GL = 0xFF
103 } dwImageType;
104 
105 typedef struct dwImageObject* dwImageHandle_t;
106 typedef struct dwImageObject const* dwConstImageHandle_t;
107 typedef struct dwImageAllocationAttrList* dwImageAllocationAttrListHandle_t;
108 
110 typedef struct dwImagePool
111 {
112  dwImageHandle_t* images;
113  size_t imageCount;
114 } dwImagePool;
115 
117 typedef enum dwImageFormat {
120 
121  // Interleaved formats
123 
129 
133 
138 
143 
145 
146  // interleaved YUV444 format
149 
150  // Planar formats
155 
158 
161 
167 
168  // planar YUV 444
171 
177 
178 } dwImageFormat;
179 
181 typedef enum {
188 
190 
192 typedef struct dwImageDataLines
193 {
194  uint32_t bytesPerLine;
195 
198 
200  uint8_t* topLineData;
201  uint8_t* bottomLineData;
203 
205 typedef enum {
206 
211 
214 
217 
221 
225 
228 
231 
234 
237 
241 
243 {
251 
254 {
257 
260 
263 
266 
268  float32_t wbGain[4];
269 
272 
275 
278 
281 
284 
287 
295  float32_t sensorTempCelsius[DW_MAX_NUM_TEMPERATURES];
297 
298 typedef struct dwImageRawProperties
299 {
301  uint32_t msbPosition;
302 
307 
309  uint32_t rawBitDataType;
311 
313 typedef struct dwImageMetaData
314 {
316  uint32_t flags;
317 
319  float32_t exposureTime
320  DW_DEPRECATED("This structure variable is deprecated and will be removed in the next major release. Please use the new variable in sensorStatistics in this struct");
321 
323  float32_t analogGain
324  DW_DEPRECATED("This structure variable is deprecated and will be removed in the next major release. Please use the new variable in sensorStatistics in this struct");
325 
327  float32_t conversionGain
328  DW_DEPRECATED("This structure variable is deprecated and will be removed in the next major release. Please use the new variable in sensorStatistics in this struct");
329 
331  float32_t digitalGain
332  DW_DEPRECATED("This structure variable is deprecated and will be removed in the next major release. Please use the new variable in sensorStatistics in this struct");
333 
335  float32_t wbGain[4] DW_DEPRECATED("This structure variable is deprecated and will be removed in the next major release. Please use the new variable in sensorStatistics in this struct");
336 
338  uint32_t msbPosition
339  DW_DEPRECATED("This structure variable is deprecated and will be removed in the next major release. Please use the new variable in rawProperties in this struct");
340 
343 
350 
351  // Holds properties unique to raw images
353 
354  // All paramters from here are read-only
355 
358 
360  dwImageSplineControlPoint gtmSplineControlPoint[18U];
361 
363  dwImageAllocationAttrListHandle_t allocAttrs;
365 
367 typedef struct dwImageProperties
368 {
372  uint32_t width;
374  uint32_t height;
376  dwImageFormat format;
382 
384 typedef struct dwImageCPU
385 {
389  size_t pitch[DW_MAX_IMAGE_PLANES];
391  uint8_t* data[DW_MAX_IMAGE_PLANES];
394 } dwImageCPU;
395 
397 typedef struct dwImageCUDA
398 {
402  size_t pitch[DW_MAX_IMAGE_PLANES]; // pitch in bytes
404  void* dptr[DW_MAX_IMAGE_PLANES];
406  cudaArray_t array[DW_MAX_IMAGE_PLANES];
409 } dwImageCUDA;
410 
411 #ifdef VIBRANTE
412 typedef struct dwImageNvMedia
414 {
418  NvMediaImage* img
419  DW_DEPRECATED("NvMediaImage is deprecated and will be removed in the next major release.");
423 #endif
424 
437 dwStatus dwImage_create(dwImageHandle_t* const image,
438  dwImageProperties properties,
439  dwContextHandle_t const ctx);
440 
458 dwStatus dwImage_createAndBindBuffer(dwImageHandle_t* const image,
459  dwImageProperties properties,
460  void* const buffersIn[DW_MAX_IMAGE_PLANES],
461  size_t const pitches[DW_MAX_IMAGE_PLANES], size_t const bufferCount,
462  dwContextHandle_t const ctx);
463 
479 dwStatus dwImage_createAndBindCUDAArray(dwImageHandle_t* const image,
480  dwImageProperties properties,
481  cudaArray_t const buffers[DW_MAX_IMAGE_PLANES], size_t const bufferCount,
482  dwContextHandle_t const ctx);
483 
484 #ifdef VIBRANTE
485 
495 dwStatus dwImage_createAndBindNvMedia(dwImageHandle_t* image, NvMediaImage* nvmImage);
496 #endif
497 
508 dwStatus dwImage_destroy(dwImageHandle_t const image);
509 
510 // specifiers
511 
522 dwStatus dwImage_getProperties(dwImageProperties* const properties, dwConstImageHandle_t const image);
523 
534 dwStatus dwImage_getTimestamp(dwTime_t* const timestamp, dwConstImageHandle_t const image);
535 
546 dwStatus dwImage_setTimestamp(dwTime_t const timestamp, dwImageHandle_t const image);
547 
559 dwStatus dwImage_getMetaData(dwImageMetaData* const metaData, dwConstImageHandle_t const image);
560 
571 dwStatus dwImage_setMetaData(dwImageMetaData const* const metaData, dwImageHandle_t const image);
572 
585 dwStatus dwImage_getCPU(dwImageCPU** const imageCPU, dwImageHandle_t const image);
586 
598 dwStatus dwImage_getCUDA(dwImageCUDA** const imageCUDA, dwImageHandle_t const image);
599 
600 #ifdef VIBRANTE
601 
613 dwStatus dwImage_getNvMedia(dwImageNvMedia** imageNvMedia, dwImageHandle_t image);
614 #endif
615 
626 dwStatus dwImage_getPixelType(dwTrivialDataType* const type, dwImageFormat const format);
627 
638 dwStatus dwImage_getPlaneCount(size_t* const planeCount, dwImageFormat const format);
639 
659 dwStatus dwImage_copyConvert(dwImageHandle_t const output, dwConstImageHandle_t const input, dwContextHandle_t const context);
660 
681 dwStatus dwImage_copyConvertAsync(dwImageHandle_t const output, dwConstImageHandle_t const input, cudaStream_t const stream, dwContextHandle_t const context);
682 
696  dwImageCUDA const* const srcImage,
697  uint32_t const planeIdx);
698 
711 DW_API_PUBLIC dwStatus dwImageCUDA_mapToROI(dwImageCUDA* const dstImg, dwImageCUDA const* const srcImg, dwRect const roi);
712 
729 DW_API_PUBLIC dwStatus dwImage_getDataLayout(size_t* const elementSize,
730  size_t* const planeCount,
731  uint32_t planeChannelCount[DW_MAX_IMAGE_PLANES],
732  dwVector2ui planeSize[DW_MAX_IMAGE_PLANES],
733  dwImageProperties const* const prop);
734 
735 #ifdef __cplusplus
736 }
737 #endif
738 
740 #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:342
Defines an NvMedia image.
Definition: Image.h:413
Holds a flag to determine whether or not the control info is valid. If no ISP processing occurs this ...
Definition: Image.h:227
DW_API_PUBLIC dwStatus dwImage_createAndBindBuffer(dwImageHandle_t *const image, dwImageProperties properties, void *const buffersIn[DW_MAX_IMAGE_PLANES], size_t const 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...
Image contains valid sensor temperature info.
Definition: Image.h:239
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:213
dwImageMemoryType memoryLayout
Memory layout type.
Definition: Image.h:380
float32_t x
Holds X coordinate of the control point.
Definition: Image.h:245
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:200
float32_t conversionGain
Specifies the conversion Gain.
Definition: Image.h:262
Sensor statistics associated with the image.
Definition: Image.h:253
float float32_t
Specifies POD types.
Definition: Types.h:70
struct dwImageObject * dwImageHandle_t
Definition: Image.h:105
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:197
Defines a rectangle.
Definition: Types.h:191
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:86
Container for data lines from the camera.
Definition: Image.h:192
Holds a flag to indicating if the luminance is calibrated.
Definition: Image.h:230
DW_API_PUBLIC dwStatus dwImage_createAndBindNvMedia(dwImageHandle_t *image, NvMediaImage *nvmImage)
Creates a dwImageHandle_t based on an nvmedia image.
By default CUDA images are created in vidmem on DGPU, this flag forces CUDA image to sysmem Note manu...
Definition: Image.h:220
DW_API_PUBLIC dwStatus dwImage_getTimestamp(dwTime_t *const timestamp, dwConstImageHandle_t const image)
Retrieves the timestamp of acquisition of a dwImageHandle_t.
struct dwImageAllocationAttrList * dwImageAllocationAttrListHandle_t
Definition: Image.h:107
float32_t cct
Holds the correlated color temperature.
Definition: Image.h:280
float32_t rawImageMidTone
Holds the midtone value of the raw image.
Definition: Image.h:286
DW_API_PUBLIC dwStatus dwImage_getCUDA(dwImageCUDA **const imageCUDA, dwImageHandle_t const image)
Retrieves the dwImageCUDA of a dwImageHandle_t.
float32_t y
Holds Y coordinate of the control point.
Definition: Image.h:247
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...
uint32_t GLuint
Definition: Image.h:63
dwImageProperties prop
Specifies the properites of the image.
Definition: Image.h:387
uint32_t GLenum
Definition: Image.h:62
Specifies a pool of images.
Definition: Image.h:110
dwImageMetaDataFlags
Flags defining the meta information available in an image.
Definition: Image.h:205
Defines a CUDA image.
Definition: Image.h:397
uint32_t width
Specifies the width of the image in pixels.
Definition: Image.h:372
for debayered images
Definition: Image.h:176
dwImageType type
Specifies the type of image.
Definition: Image.h:370
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:185
float32_t brightnessKey
Holds the scene brightness key.
Definition: Image.h:283
dwImageDataLines dataLines
embedded data lines.
Definition: Image.h:349
float32_t digitalGain
Specifies the digital Gain.
Definition: Image.h:265
uint8_t * bottomLineData
Definition: Image.h:201
float64_t luminanceCalibrationFactor
Holds luminance constant (aperture^2/Kc) value for calibrated camera.
Definition: Image.h:274
dwImageMetaData meta
additional meta information stored with the image. Not all images might provide it ...
Definition: Image.h:378
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:421
double float64_t
Definition: Types.h:71
Normal formats.
Definition: Image.h:119
If an image was extracted from a camera, additional embedded data lines might be provided The data li...
Definition: Image.h:210
uint32_t flags
combination of multiple flags &#39;dwImageMetaDataFlags&#39; defining which of the meta fields are valid ...
Definition: Image.h:316
This type is provided here for completeness only.
Definition: Image.h:102
Image contains valid frame sequence number.
Definition: Image.h:216
Image contains details of raw order descriptor.
Definition: Image.h:224
dwImageProperties prop
Holds image properties.
Definition: Image.h:416
dwImageHandle_t * images
Definition: Image.h:112
dwTime_t timestamp_us
Specifies the time, in microseconds, when the image was acquired.
Definition: Image.h:408
uint32_t rawFormatDescriptor
Describes the raw order and used when explicitly creating a DW_IMAGE_NVMEDIA if DW_IMAGE_FLAGS_HAS_RA...
Definition: Image.h:306
dwStatus
Status definition.
Definition: Status.h:180
dwImageFormat
Format of the image represented as DW_IMAGE_FORMAT_COLORSPACE(_PIXELTYPE)(_PIXELORDER) ...
Definition: Image.h:117
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:187
int64_t dwTime_t
Specifies a timestamp unit, in microseconds.
Definition: Types.h:82
uint32_t bytesPerLine
Definition: Image.h:194
#define DW_DEPRECATED(msg)
Definition: Exports.h:66
struct dwImageObject const * dwConstImageHandle_t
Definition: Image.h:106
DW_API_PUBLIC dwStatus dwImage_setTimestamp(dwTime_t const timestamp, dwImageHandle_t const image)
Sets the timestamp of a dwImageHandle_t.
dwImageType
Specifies the image type.
Definition: Image.h:93
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.
uint32_t rawBitDataType
Describes the raw pixel depth, specified like the above format descriptor by NVM_SURF_ATTR_BITS_PER_C...
Definition: Image.h:309
DW_API_PUBLIC dwStatus dwImage_getCPU(dwImageCPU **const imageCPU, dwImageHandle_t const image)
Retrieves the dwImageCPU of a dwImageHandle_t.
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:400
uint8_t numTemperatures
Holds the number of active temperatures.
Definition: Image.h:291
Defines a two-element unsigned-integer vector.
Definition: Types.h:315
dwImageSensorStatistics sensorStatistics
Holds info on sensor statistics at the time of the image capture.
Definition: Image.h:357
RAW for images directly from sensory.
Definition: Image.h:174
#define DW_MAX_NUM_TEMPERATURES
should be the same as the DEVBLK_CDI_MAX_NUM_TEMPERATURES in NvSIPLCDICommon.h of NvSIPL ...
Definition: Image.h:90
dwImageRawProperties rawProperties
Definition: Image.h:352
#define DW_ISP_MAX_COLOR_COMPONENT
Definition: Image.h:87
uint32_t msbPosition
Specifies the msb of the pixel data.
Definition: Image.h:301
float32_t analogGain
Specifies the analog Gain.
Definition: Image.h:259
float32_t alpha
Holds power factor for isp statistics compression. Valid range: [0.5, 1.0].
Definition: Image.h:271
struct dwContextObject * dwContextHandle_t
Context handle.
Definition: Context.h:79
NVIDIA DriveWorks API: Core Methods
float32_t exposureTime
Specifies the exposure time (microsecond)
Definition: Image.h:256
dwTime_t timestamp_us
Specifies the time, in microseconds, when the image was acquired.
Definition: Image.h:393
Additional meta information stored with each image.
Definition: Image.h:313
float64_t slope
Holds slope of the spline curve at the control point.
Definition: Image.h:249
the default memory layout for a given image type, can be either pitch or block
Definition: Image.h:183
uint32_t height
Specifies the height of the image in pixels.
Definition: Image.h:374
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:163
size_t imageCount
Definition: Image.h:113
dwImageMemoryType
Specifies memory type layout.
Definition: Image.h:181
DW_API_PUBLIC dwStatus dwImage_setMetaData(dwImageMetaData const *const metaData, dwImageHandle_t const image)
Sets the metadata of a dwImageHandle_t.
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.
Holds the total white balance gains, which includes both sensor channel and ISP gains.
Definition: Image.h:233
Image contains valid global tone map block.
Definition: Image.h:236
#define DW_API_PUBLIC
Definition: Exports.h:54
dwImageAllocationAttrListHandle_t allocAttrs
Allocation attributes used by internal drivers.
Definition: Image.h:363
dwImageFormat format
Specifies the format of the image.
Definition: Image.h:376
NVIDIA DriveWorks API: Core Status Methods
Defines the properties of the image.
Definition: Image.h:367
NVIDIA DriveWorks API: Core Exports
Defines a CPU-based image.
Definition: Image.h:384