DriveWorks SDK Reference
3.0.4260 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-2019 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 
49 #ifndef DW_IMAGE_IMAGE_H_
50 #define DW_IMAGE_IMAGE_H_
51 
52 #include <dw/core/Config.h>
53 #include <dw/core/Exports.h>
54 #include <dw/core/Types.h>
55 #include <dw/core/Status.h>
56 #include <dw/core/Context.h>
57 
58 // Forward defines from GL
59 // Note: GL defines the specific bitdepth of these types
60 // so it is safe to declare then here without including GL.h
61 typedef uint32_t GLenum;
62 typedef uint32_t GLuint;
63 
64 #if (defined(__cplusplus) && (defined(LINUX) || defined(VIBRANTE)))
65 #pragma GCC diagnostic push
66 #pragma GCC diagnostic ignored "-Wold-style-cast"
67 #endif
68 
69 #include <cuda_runtime.h>
70 
71 #if (defined(__cplusplus) && (defined(LINUX) || defined(VIBRANTE)))
72 #pragma GCC diagnostic pop
73 #endif
74 
75 #ifdef VIBRANTE
76 #include <sys/time.h>
77 #include <nvmedia_image.h>
78 #endif
79 
80 #ifdef __cplusplus
81 extern "C" {
82 #endif
83 
84 #define DW_MAX_IMAGE_PLANES 3
85 
87 typedef enum dwImageType {
90 #ifdef VIBRANTE
92 #endif
93 
96  DW_IMAGE_GL = 0xFF
97 } dwImageType;
98 
99 typedef struct dwImageObject* dwImageHandle_t;
100 typedef struct dwImageObject const* dwConstImageHandle_t;
101 
103 typedef enum dwImageFormat {
106 
107  // Interleaved formats
109 
115 
119 
124 
129 
131 
132  // interleaved YUV444 format
135 
136  // Planar formats
141 
144 
147 
152 
153  // planar YUV 444
156 
162 
163 } dwImageFormat;
164 
166 typedef enum {
174 
176 typedef struct dwImageDataLines
177 {
178  uint32_t bytesPerLine;
179 
182 
184  uint8_t* topLineData;
185  uint8_t* bottomLineData;
187 
189 typedef enum {
190 
194 
197 
200 
202 
204 typedef struct dwImageMetaData
205 {
206 
208  int32_t flags;
209 
219  float32_t wbGain[4];
221  uint32_t msbPosition;
222 
225 
232 
234 
236 typedef struct dwImageProperties
237 {
241  uint32_t width;
243  uint32_t height;
245  dwImageFormat format;
251 
253 typedef struct dwImageCPU
254 {
258  size_t pitch[DW_MAX_IMAGE_PLANES];
260  uint8_t* data[DW_MAX_IMAGE_PLANES];
263 } dwImageCPU;
264 
266 typedef struct dwImageCUDA
267 {
271  size_t pitch[DW_MAX_IMAGE_PLANES]; // pitch in bytes
273  void* dptr[DW_MAX_IMAGE_PLANES];
275  cudaArray_t array[DW_MAX_IMAGE_PLANES];
278 } dwImageCUDA;
279 
280 #ifdef VIBRANTE
281 typedef struct dwImageNvMedia
283 {
287  NvMediaImage* img;
291 #endif
292 
305 dwStatus dwImage_create(dwImageHandle_t* image,
306  dwImageProperties properties,
307  dwContextHandle_t ctx);
308 
326 dwStatus dwImage_createAndBindBuffer(dwImageHandle_t* image,
327  dwImageProperties properties,
328  void* buffersIn[DW_MAX_IMAGE_PLANES],
329  size_t pitches[DW_MAX_IMAGE_PLANES], size_t bufferCount,
330  dwContextHandle_t ctx);
331 
347 dwStatus dwImage_createAndBindCUDAArray(dwImageHandle_t* image,
348  dwImageProperties properties,
349  cudaArray_t buffers[], size_t bufferCount,
350  dwContextHandle_t ctx);
351 
352 #ifdef VIBRANTE
353 
363 dwStatus dwImage_createAndBindNvMedia(dwImageHandle_t* image, NvMediaImage* nvmImage);
364 #endif
365 
376 dwStatus dwImage_destroy(dwImageHandle_t image);
377 
378 // specifiers
379 
390 dwStatus dwImage_getProperties(dwImageProperties* properties, dwConstImageHandle_t image);
391 
402 dwStatus dwImage_getTimestamp(dwTime_t* timestamp, dwConstImageHandle_t image);
403 
414 dwStatus dwImage_setTimestamp(dwTime_t timestamp, dwImageHandle_t image);
415 
427 dwStatus dwImage_getMetaData(dwImageMetaData* metaData, dwConstImageHandle_t image);
428 
441 dwStatus dwImage_getCPU(dwImageCPU** imageCPU, dwImageHandle_t image);
442 
454 dwStatus dwImage_getCUDA(dwImageCUDA** imageCUDA, dwImageHandle_t image);
455 
456 #ifdef VIBRANTE
457 
469 dwStatus dwImage_getNvMedia(dwImageNvMedia** imageNvMedia, dwImageHandle_t image);
470 #endif
471 
482 dwStatus dwImage_getPixelType(dwTrivialDataType* type, const dwImageFormat format);
483 
494 dwStatus dwImage_getPlaneCount(size_t* planeCount, const dwImageFormat format);
495 
515 dwStatus dwImage_copyConvert(dwImageHandle_t output, dwConstImageHandle_t input, dwContextHandle_t context);
516 
537 dwStatus dwImage_copyConvertAsync(dwImageHandle_t output, dwConstImageHandle_t input, cudaStream_t stream, dwContextHandle_t context);
538 
552  const dwImageCUDA* srcImage,
553  uint32_t planeIdx);
554 
568 
584 DW_API_PUBLIC dwStatus dwImage_getDataLayout(size_t* elementSize,
585  size_t* planeCount,
586  uint32_t planeChannelCount[DW_MAX_IMAGE_PLANES],
587  dwVector2ui planeSize[DW_MAX_IMAGE_PLANES],
588  const dwImageProperties* prop);
589 
590 #ifdef __cplusplus
591 }
592 #endif
593 
595 #endif // DW_IMAGE_IMAGE_H_
uint32_t frameSequenceNumber
Holds a frame sequence number, that is, a monotonically increasing frame counter. ...
Definition: Image.h:224
Defines an NvMedia image.
Definition: Image.h:282
Image contains valid sensor settings information, such as exposure, gain, whitebalance, etc.
Definition: Image.h:196
dwImageMemoryType memoryLayout
Memory layout type.
Definition: Image.h:249
uint8_t * topLineData
pointer to the beginning of top and bottom lines
Definition: Image.h:184
NVIDIA DriveWorks API: Core Types
int32_t flags
combination of multiple flags &#39;dwImageMetaDataFlags&#39; defining which of the meta fields are valid ...
Definition: Image.h:208
float float32_t
Specifies POD types.
Definition: Types.h:70
struct dwImageObject * dwImageHandle_t
Definition: Image.h:99
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:181
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:84
Container for data lines from the camera.
Definition: Image.h:176
DW_API_PUBLIC dwStatus dwImage_createAndBindNvMedia(dwImageHandle_t *image, NvMediaImage *nvmImage)
Creates a dwImageHandle_t based on an nvmedia image.
uint32_t msbPosition
Specifies the msb of the pixel data.
Definition: Image.h:221
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.
DW_API_PUBLIC dwStatus dwImage_getProperties(dwImageProperties *properties, dwConstImageHandle_t image)
Retrieves the properties of a dwImageHandle_t.
uint32_t GLuint
Definition: Image.h:62
dwImageProperties prop
Specifies the properites of the image.
Definition: Image.h:256
uint32_t GLenum
Definition: Image.h:61
dwImageMetaDataFlags
Flags defining the meta information available in an image.
Definition: Image.h:189
DW_API_PUBLIC dwStatus dwImage_copyConvertAsync(dwImageHandle_t output, dwConstImageHandle_t input, cudaStream_t stream, dwContextHandle_t context)
Converts CUDA or NvMedia images by copying into an output image, following the properties in the outp...
Defines a CUDA image.
Definition: Image.h:266
uint32_t width
Specifies the width of the image in pixels.
Definition: Image.h:241
for debayered images
Definition: Image.h:161
dwImageType type
Specifies the type of image.
Definition: Image.h:239
DW_API_PUBLIC dwStatus dwImage_getTimestamp(dwTime_t *timestamp, dwConstImageHandle_t image)
Retrieves the timestamp of acquisition of a dwImageHandle_t.
NVIDIA DriveWorks API: Core Methods
pitch linear memory layout
Definition: Image.h:170
dwImageDataLines dataLines
embedded data lines.
Definition: Image.h:231
uint8_t * bottomLineData
Definition: Image.h:185
DW_API_PUBLIC dwStatus dwImage_getCPU(dwImageCPU **imageCPU, dwImageHandle_t image)
Retrieves the dwImageCPU of a dwImageHandle_t.
dwImageMetaData meta
additional meta information stored with the image. Not all images might provide it ...
Definition: Image.h:247
dwTime_t timestamp_us
Specifies the time, in microseconds, when the image was acquired.
Definition: Image.h:289
DW_API_PUBLIC dwStatus dwImage_getPlaneCount(size_t *planeCount, const dwImageFormat format)
Retrieves number of planes of the image format.
DW_API_PUBLIC dwStatus dwImage_createAndBindCUDAArray(dwImageHandle_t *image, dwImageProperties properties, cudaArray_t buffers[], size_t bufferCount, dwContextHandle_t ctx)
Creates a dwImageHandle_t based on the properties passed and binds a cudaArray_t to it...
Normal formats.
Definition: Image.h:105
If an image was extracted from a camera, additional embedded data lines might be provided The data li...
Definition: Image.h:193
This type is provided here for completeness only.
Definition: Image.h:96
Image contains valid frame sequence number.
Definition: Image.h:199
dwImageProperties prop
Holds image properties.
Definition: Image.h:285
dwTime_t timestamp_us
Specifies the time, in microseconds, when the image was acquired.
Definition: Image.h:277
DW_API_PUBLIC dwStatus dwImage_getPixelType(dwTrivialDataType *type, const dwImageFormat format)
Retrieves dwTrivialDataType associated with a specific format.
dwStatus
Status definition.
Definition: Status.h:166
dwImageFormat
Format of the image represented as DW_IMAGE_FORMAT_COLORSPACE(_PIXELTYPE)(_PIXELORDER) ...
Definition: Image.h:103
block memory layout
Definition: Image.h:172
int64_t dwTime_t
Specifies a timestamp unit, in microseconds.
Definition: Types.h:82
uint32_t bytesPerLine
Definition: Image.h:178
struct dwImageObject const * dwConstImageHandle_t
Definition: Image.h:100
float32_t analogGain
Specifies the analog Gain.
Definition: Image.h:213
NvMediaImage * img
Holds the pointer to the NvMedia image.
Definition: Image.h:287
dwImageType
Specifies the image type.
Definition: Image.h:87
DW_API_PUBLIC dwStatus dwImage_destroy(dwImageHandle_t image)
Destroys the image handle and frees any memory created by dwImage_create().
float32_t conversionGain
Specifies the conversion Gain.
Definition: Image.h:215
DW_API_PUBLIC dwStatus dwImage_getCUDA(dwImageCUDA **imageCUDA, dwImageHandle_t image)
Retrieves the dwImageCUDA of a dwImageHandle_t.
dwImageProperties prop
Defines the properties of the image.
Definition: Image.h:269
Defines a two-element unsigned-integer vector.
Definition: Types.h:312
RAW for images directly from sensory.
Definition: Image.h:159
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.
struct dwContextObject * dwContextHandle_t
Context handle.
Definition: Context.h:80
DW_API_PUBLIC dwStatus dwImage_createAndBindBuffer(dwImageHandle_t *image, dwImageProperties properties, void *buffersIn[DW_MAX_IMAGE_PLANES], size_t pitches[DW_MAX_IMAGE_PLANES], size_t bufferCount, dwContextHandle_t ctx)
Creates a dwImageHandle_t based on the properties passed and binds a memory buffer provided by the ap...
dwTime_t timestamp_us
Specifies the time, in microseconds, when the image was acquired.
Definition: Image.h:262
Additional meta information stored with each image.
Definition: Image.h:204
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...
DW_API_PUBLIC dwStatus dwImage_getMetaData(dwImageMetaData *metaData, dwConstImageHandle_t image)
Retrieves the metadata of a dwImageHandle_t.
the default memory layout for a given image type, can be either pitch or block
Definition: Image.h:168
uint32_t height
Specifies the height of the image in pixels.
Definition: Image.h:243
float32_t exposureTime
Specifies the exposure time (microsecond)
Definition: Image.h:211
YUV encoding formats from camera.
Definition: Image.h:149
NVIDIA DriveWorks API: Core Exports
dwImageMemoryType
Specifies memory type layout.
Definition: Image.h:166
DW_API_PUBLIC dwStatus dwImage_setTimestamp(dwTime_t timestamp, dwImageHandle_t image)
Sets the timestamp of a dwImageHandle_t.
DW_API_PUBLIC dwStatus dwImage_copyConvert(dwImageHandle_t output, dwConstImageHandle_t input, dwContextHandle_t context)
Converts CUDA or NvMedia images by copying into an output image, following the properties in the outp...
#define DW_API_PUBLIC
Definition: Exports.h:56
dwImageFormat format
Specifies the format of the image.
Definition: Image.h:245
float32_t digitalGain
Specifies the digital Gain.
Definition: Image.h:217
NVIDIA DriveWorks API: Core Status Methods
Defines the properties of the image.
Definition: Image.h:236
DW_API_PUBLIC dwStatus dwImage_getDataLayout(size_t *elementSize, size_t *planeCount, 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.
Defines a CPU-based image.
Definition: Image.h:253