DriveWorks SDK Reference

| 0.6.67 Release

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-2017 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 
46 #ifndef DW_IMAGE_IMAGE_H__
47 #define DW_IMAGE_IMAGE_H__
48 
49 #include <dw/core/Config.h>
50 #include <dw/core/Exports.h>
51 #include <dw/core/Types.h>
52 #include <dw/core/Status.h>
53 #include <dw/core/Context.h>
54 
55 // Forward defines from GL
56 // Note: GL defines the specific bitdepth of these types
57 // so it is safe to declare then here without including GL.h
58 typedef uint32_t GLenum;
59 typedef uint32_t GLuint;
60 
61 #if (defined LINUX || VIBRANTE)
62 #pragma GCC diagnostic push
63 #pragma GCC diagnostic ignored "-Wold-style-cast"
64 #endif
65 
66 #include <cuda_runtime.h>
67 
68 #if (defined LINUX || VIBRANTE)
69 #pragma GCC diagnostic pop
70 #endif
71 
72 #ifdef VIBRANTE
73 #include <nvmedia_image.h>
74 #endif
75 
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79 
80 #define DW_MAX_IMAGE_PLANES 3
81 
83 typedef enum dwImageType {
87 #ifdef VIBRANTE
89 #endif
90 } dwImageType;
91 
93 typedef enum dwImagePixelFormat {
95 
100  DW_IMAGE_R = 1000,
109  DW_IMAGE_RGB = 2000,
117  DW_IMAGE_RCB = 2100,
123  DW_IMAGE_RCC = 2200,
124 
131 
132  // DEPRECATED: DW_IMAGE_SRGB_PLANAR_FP16_NORM = 5000,
133  // use: DW_IMAGE_RGB, planeCount=3, pxlType=DW_TYPE_FLOAT16 instead
134 
154 
159  DW_IMAGE_RAW = 10000
160 
162 
164 typedef enum {
168 
170 typedef struct dwImageDataLines {
171  uint32_t bytesPerLine;
172 
175 
177  uint8_t* topLineData;
178  uint8_t* bottomLineData;
180 
182 typedef enum {
183 
187 
190 
192 
194 typedef struct dwImageMetaData {
195 
197  int32_t flags;
198 
208  float32_t wbGain[4];
209 
216 
218 
220 typedef struct dwImageProperties {
222  dwImageType type;
224  uint32_t width;
226  uint32_t height;
232  uint32_t planeCount;
233 
237 
239 typedef struct dwImageCPU {
243  size_t pitch[DW_MAX_IMAGE_PLANES];
245  uint8_t *data[DW_MAX_IMAGE_PLANES];
248 } dwImageCPU;
249 
251 typedef struct dwImageGL {
260 } dwImageGL;
261 
263 typedef struct dwImageCUDA {
267  dwImageCUDAMemoryType layout;
269  size_t pitch[DW_MAX_IMAGE_PLANES]; // pitch in bytes
271  void *dptr[DW_MAX_IMAGE_PLANES];
273  cudaArray_t array[DW_MAX_IMAGE_PLANES];
276 } dwImageCUDA;
277 
278 #ifdef VIBRANTE
279 typedef struct dwImageNvMedia {
284  NvMediaImage *img;
288 #endif
289 
301 
311 
325  dwImageCUDAMemoryType layout);
326 
336 
349  GLenum target);
350 
360 
361 #ifdef VIBRANTE
362 
375  const dwContextHandle_t context);
376 
385 #endif
386 
398 DW_API_PUBLIC dwStatus dwImage_getDataLayout(size_t *elementSize,
399  uint32_t planeChannelCount[DW_MAX_IMAGE_PLANES],
400  dwVector2ui planeSize[DW_MAX_IMAGE_PLANES],
401  const dwImageProperties *prop);
412 DW_API_PUBLIC dwStatus dwImageGL_setupTexture(dwImageGL* glImg, const uint8_t* data, int32_t level,
413  uint32_t depth);
414 
429  void *devicePtr,
430  uint32_t width,
431  uint32_t height,
432  size_t pitchInBytes,
433  dwImagePixelFormat pixelFormat);
434 
447  const dwImageCUDA *srcImage,
448  uint32_t planeIdx);
449 
450 #ifdef VIBRANTE
451 
460 DW_API_PUBLIC dwStatus dwImageNvMedia_setFromImage(dwImageNvMedia *dstImage, const NvMediaImage *srcImage);
461 #endif
462 
475 
488 #ifdef __cplusplus
489 }
490 #endif
491 
493 #endif // DW_IMAGE_IMAGE_H__
dwTrivialDataType pxlType
Specifies the pixel type of the image.
Definition: Image.h:230
Defines an NvMedia image.
Definition: Image.h:280
Image contains valid sensor settings information, such as exposure, gain, whitebalance, etc.
Definition: Image.h:189
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.
uint8_t * topLineData
pointer to the beginning of top and bottom lines
Definition: Image.h:177
NVIDIA DriveWorks API: Core Types
dwImageCUDAMemoryType
Specifies the CUDA memory type.
Definition: Image.h:164
int32_t flags
combination of multiple flags dwImageMetaDataFlags defining which of the meta fields are valid ...
Definition: Image.h:197
float float32_t
Specifies POD types.
Definition: Types.h:77
dwTrivialDataType
Specifies a type indicator of the underlying trivial data type.
Definition: Types.h:104
dwVector2ui embeddedDataSize
this defines the number of rows before and after the image
Definition: Image.h:174
Defines a rectangle.
Definition: Types.h:151
#define DW_MAX_IMAGE_PLANES
Definition: Image.h:80
Container for data lines from the camera.
Definition: Image.h:170
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 dwImageCUDA_destroy(dwImageCUDA *cudaImage)
Deallocates data in a dwImageCUDA.
GLuint tex
Specifies the OpenGL texture handle.
Definition: Image.h:255
DW_API_PUBLIC dwStatus dwImageGL_destroy(dwImageGL *glImage)
Destroys the texture in a dwImageGL.
uint32_t GLuint
Definition: Image.h:59
dwImageProperties prop
Specifies the properites of the image.
Definition: Image.h:241
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...
uint32_t GLenum
Definition: Image.h:58
dwImageMetaDataFlags
Flags defining the meta information available in an image.
Definition: Image.h:182
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.
Defines a CUDA image.
Definition: Image.h:263
uint32_t width
Specifies the width of the image in pixels.
Definition: Image.h:224
uint64_t dwTime_t
Specifies a timestamp unit, in microseconds.
Definition: Types.h:89
dwImageType type
Specifies the type of image.
Definition: Image.h:222
NVIDIA DriveWorks API: Core Methods
dwImageDataLines dataLines
embedded data lines.
Definition: Image.h:215
uint8_t * bottomLineData
Definition: Image.h:178
dwImagePixelFormat
Specifies the pixel format of the image.
Definition: Image.h:93
dwImageMetaData meta
additional meta information stored with the image. Not all images might provide it ...
Definition: Image.h:235
dwTime_t timestamp_us
Specifies the time, in microseconds, when the image was acquired.
Definition: Image.h:286
NVIDIA DriveWorks API: Core Exports
If an image was extracted from a camera, additional embedded data lines might be provided The data li...
Definition: Image.h:186
dwImageProperties prop
Holds image properties.
Definition: Image.h:282
dwTime_t timestamp_us
Specifies the time, in microseconds, when the image was acquired.
Definition: Image.h:275
dwStatus
Status definition.
Definition: Status.h:167
DW_API_PUBLIC dwStatus dwImageCPU_create(dwImageCPU *cpuImage, const dwImageProperties *prop)
Allocates memory for the data of a dwImageCPU based on the dwImageProperties.
uint32_t bytesPerLine
Definition: Image.h:171
GLenum target
Specifies the OpenGL texture target.
Definition: Image.h:257
dwTime_t timestamp_us
Specifies the time, in microseconds, when the image was acquired.
Definition: Image.h:259
float32_t analogGain
Specifies the analog Gain.
Definition: Image.h:202
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.
dwImageCUDAMemoryType layout
Defines the memory layout of the image.
Definition: Image.h:267
NvMediaImage * img
Holds the pointer to the NvMedia image.
Definition: Image.h:284
dwImageType
Specifies the image type.
Definition: Image.h:83
uint32_t planeCount
Specifies the plane count of the image. For interleaved images the plane count is 1...
Definition: Image.h:232
float32_t conversionGain
Specifies the conversion Gain.
Definition: Image.h:204
DW_API_PUBLIC dwStatus dwImageNvMedia_destroy(dwImageNvMedia *nvmImage)
Destroys the texture in a dwImageNvMedia.
dwImageProperties prop
Defines the properties of the image.
Definition: Image.h:265
Defines a two-element unsigned-integer vector.
Definition: Types.h:219
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.
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.
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.
Defines a GL texture image.
Definition: Image.h:251
struct dwContextObject * dwContextHandle_t
Context handle.
Definition: Context.h:78
DW_API_PUBLIC dwStatus dwImageCPU_destroy(dwImageCPU *cpuImage)
Deallocates data in a dwImageCPU.
dwTime_t timestamp_us
Specifies the time, in microseconds, when the image was acquired.
Definition: Image.h:247
Additional meta information stored with each image.
Definition: Image.h:194
dwImagePixelFormat pxlFormat
Specifies the pixel format of the image.
Definition: Image.h:228
uint32_t height
Specifies the height of the image in pixels.
Definition: Image.h:226
float32_t exposureTime
Specifies the exposure time (microsecond)
Definition: Image.h:200
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 dwImageCUDAMemoryTy...
DW_API_PUBLIC dwStatus dwImageNvMedia_setFromImage(dwImageNvMedia *dstImage, const NvMediaImage *srcImage)
Fills dwImageNvMedia struct based on the contents of NvMediaImage.
#define DW_API_PUBLIC
Definition: Exports.h:76
dwImageProperties prop
Specifies the properties of the image.
Definition: Image.h:253
float32_t digitalGain
Specifies the digital Gain.
Definition: Image.h:206
NVIDIA DriveWorks API: Core Status Methods
Defines the properties of the image.
Definition: Image.h:220
Defines a CPU-based image.
Definition: Image.h:239