Back to Jetson Inference

Jetson Inference: jetson

docs/html/imageFormat_8h_source.html

latest23.0 KB
Original Source

| | Jetson Inference

DNN Vision Library |

imageFormat.h

Go to the documentation of this file.

1 /*

2 * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.

3 *

4 * Permission is hereby granted, free of charge, to any person obtaining a

5 * copy of this software and associated documentation files (the "Software"),

6 * to deal in the Software without restriction, including without limitation

7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,

8 * and/or sell copies of the Software, and to permit persons to whom the

9 * Software is furnished to do so, subject to the following conditions:

10 *

11 * The above copyright notice and this permission notice shall be included in

12 * all copies or substantial portions of the Software.

13 *

14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL

17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER

20 * DEALINGS IN THE SOFTWARE.

21 */

22

23 #ifndef __IMAGE_FORMAT_H_

24 #define __IMAGE_FORMAT_H_

25

26

27 // include vector types (float4, float3, uchar4, uchar3, ect.)

28 #include "cudaUtility.h"

29

30

49 enum imageFormat

50 {

51// RGB

52IMAGE_RGB8=0,

53IMAGE_RGBA8,

54IMAGE_RGB32F,

55IMAGE_RGBA32F,

57// BGR

58IMAGE_BGR8,

59IMAGE_BGRA8,

60IMAGE_BGR32F,

61IMAGE_BGRA32F,

63// YUV

64IMAGE_YUYV,

65IMAGE_YUY2=IMAGE_YUYV,

66IMAGE_YVYU,

67IMAGE_UYVY,

68IMAGE_I420,

69IMAGE_YV12,

70IMAGE_NV12,

72// Bayer

73IMAGE_BAYER_BGGR,

74IMAGE_BAYER_GBRG,

75IMAGE_BAYER_GRBG,

76IMAGE_BAYER_RGGB,

78// grayscale

79IMAGE_GRAY8,

80IMAGE_GRAY32F,

82// extras

83IMAGE_COUNT,

84IMAGE_UNKNOWN=999,

85IMAGE_DEFAULT=IMAGE_RGBA32F

86 };

87

97 enum imageBaseType

98 {

99IMAGE_UINT8,

100IMAGE_FLOAT

101 };

102

108 inline imageBaseType imageFormatBaseType( imageFormat format );

109

115 inline const char* imageFormatToStr( imageFormat format );

116

123 inline imageFormat imageFormatFromStr( const char* str );

124

130 inline size_t imageFormatChannels( imageFormat format );

131

145 inline size_t imageFormatDepth( imageFormat format );

146

151 inline size_t imageFormatSize( imageFormat format, size_t width, size_t height );

152

161 inline bool imageFormatIsRGB( imageFormat format );

162

171 inline bool imageFormatIsBGR( imageFormat format );

172

181 inline bool imageFormatIsYUV( imageFormat format );

182

190 inline bool imageFormatIsGray( imageFormat format );

191

200 inline bool imageFormatIsBayer( imageFormat format );

201

209 inline void imageFormatErrorMsg( const char* module, const char* function, imageFormat format );

210

211

217

219

220 // get the IMAGE_RGB* formats from uchar3/uchar4/float3/float4

221 template<typename T> inline imageFormat imageFormatFromType();

222

223 template<> inline imageFormat imageFormatFromType<uchar3>();

224 template<> inline imageFormat imageFormatFromType<uchar4>();

225 template<> inline imageFormat imageFormatFromType<float3>();

226 template<> inline imageFormat imageFormatFromType<float4>();

227

228 // templated version of base type / vector type

229 template<imageFormat format> struct imageFormatType;

230

231 template<> struct imageFormatType<IMAGE_RGB8> { typedef uint8_t Base; typedef uchar3 Vector; };

232 template<> struct imageFormatType<IMAGE_RGBA8> { typedef uint8_t Base; typedef uchar4 Vector; };

233

234 template<> struct imageFormatType<IMAGE_RGB32F> { typedef float Base; typedef float3 Vector; };

235 template<> struct imageFormatType<IMAGE_RGBA32F> { typedef float Base; typedef float4 Vector; };

236

238

239 // inline implementations

240 #include "imageFormat.inl"

241

242

243 #endif

244

imageFormatFromType< float4 >

imageFormat imageFormatFromType< float4 >()

IMAGE_BAYER_RGGB

@ IMAGE_BAYER_RGGB

8-bit Bayer RGGB (‘'bayer-rggb’`)

Definition: imageFormat.h:76

IMAGE_UYVY

@ IMAGE_UYVY

YUV UYVY 4:2:2 packed (‘'uyvy’`)

Definition: imageFormat.h:67

IMAGE_YV12

@ IMAGE_YV12

YUV YV12 4:2:0 planar (‘'yv12’`)

Definition: imageFormat.h:69

IMAGE_RGBA32F

@ IMAGE_RGBA32F

float4 RGBA32F (‘'rgba32f’`)

Definition: imageFormat.h:55

IMAGE_RGB8

@ IMAGE_RGB8

uchar3 RGB8 (‘'rgb8’`)

Definition: imageFormat.h:52

imageFormatFromType< uchar3 >

imageFormat imageFormatFromType< uchar3 >()

imageFormatType< IMAGE_RGB8 >::Vector

uchar3 Vector

Definition: imageFormat.h:231

imageFormatFromType

imageFormat imageFormatFromType()

imageFormatType< IMAGE_RGBA8 >::Vector

uchar4 Vector

Definition: imageFormat.h:232

IMAGE_GRAY8

@ IMAGE_GRAY8

uint8 grayscale (‘'gray8’`)

Definition: imageFormat.h:79

imageFormatDepth

size_t imageFormatDepth(imageFormat format)

Get the pixel bit depth (in bits, not bytes).

cudaUtility.h

IMAGE_DEFAULT

@ IMAGE_DEFAULT

Default format (IMAGE_RGBA32F)

Definition: imageFormat.h:85

imageFormatFromType< float3 >

imageFormat imageFormatFromType< float3 >()

IMAGE_YUY2

@ IMAGE_YUY2

Duplicate of YUYV (‘'yuy2’`)

Definition: imageFormat.h:65

imageFormatIsBayer

bool imageFormatIsBayer(imageFormat format)

Check if an image format is one of the Bayer formats.

IMAGE_UINT8

@ IMAGE_UINT8

Definition: imageFormat.h:99

imageBaseType

imageBaseType

The imageBaseType enum is used to identify the base data type of an imageFormat - either uint8 or flo...

Definition: imageFormat.h:97

imageFormatFromType< uchar4 >

imageFormat imageFormatFromType< uchar4 >()

imageFormatIsRGB

bool imageFormatIsRGB(imageFormat format)

Check if an image format is one of the RGB/RGBA formats.

imageFormatErrorMsg

void imageFormatErrorMsg(const char *module, const char *function, imageFormat format)

Print out an error message that the image format isn't supported.

IMAGE_GRAY32F

@ IMAGE_GRAY32F

float grayscale (‘'gray32f’`)

Definition: imageFormat.h:80

imageFormatFromStr

imageFormat imageFormatFromStr(const char *str)

Parse an imageFormat enum from a string.

IMAGE_FLOAT

@ IMAGE_FLOAT

Definition: imageFormat.h:100

imageFormatIsBGR

bool imageFormatIsBGR(imageFormat format)

Check if an image format is one of the BGR/BGRA formats.

imageFormatChannels

size_t imageFormatChannels(imageFormat format)

Get the number of image channels in each format.

IMAGE_BGR32F

@ IMAGE_BGR32F

float3 BGR32F (‘'bgr32f’`)

Definition: imageFormat.h:60

imageFormatIsYUV

bool imageFormatIsYUV(imageFormat format)

Check if an image format is one of the YUV formats.

imageFormatToStr

const char * imageFormatToStr(imageFormat format)

Convert an imageFormat enum to a string.

IMAGE_BAYER_GRBG

@ IMAGE_BAYER_GRBG

8-bit Bayer GRBG (‘'bayer-grbg’`)

Definition: imageFormat.h:75

IMAGE_BGR8

@ IMAGE_BGR8

uchar3 BGR8 (‘'bgr8’`)

Definition: imageFormat.h:58

imageFormatType< IMAGE_RGBA32F >::Vector

float4 Vector

Definition: imageFormat.h:235

IMAGE_YVYU

@ IMAGE_YVYU

YUV YVYU 4:2:2 packed (‘'yvyu’`)

Definition: imageFormat.h:66

IMAGE_RGB32F

@ IMAGE_RGB32F

float3 RGB32F (‘'rgb32f’`)

Definition: imageFormat.h:54

imageFormatBaseType

imageBaseType imageFormatBaseType(imageFormat format)

Get the base type of an image format (uint8 or float).

imageFormatType< IMAGE_RGB32F >::Base

float Base

Definition: imageFormat.h:234

IMAGE_BGRA32F

@ IMAGE_BGRA32F

float4 BGRA32F (‘'bgra32f’`)

Definition: imageFormat.h:61

IMAGE_BAYER_BGGR

@ IMAGE_BAYER_BGGR

8-bit Bayer BGGR (‘'bayer-bggr’`)

Definition: imageFormat.h:73

IMAGE_COUNT

@ IMAGE_COUNT

The number of image formats.

Definition: imageFormat.h:83

imageFormatSize

size_t imageFormatSize(imageFormat format, size_t width, size_t height)

Compute the size of an image (in bytes)

IMAGE_NV12

@ IMAGE_NV12

YUV NV12 4:2:0 planar (‘'nv12’`)

Definition: imageFormat.h:70

IMAGE_YUYV

@ IMAGE_YUYV

YUV YUYV 4:2:2 packed (‘'yuyv’`)

Definition: imageFormat.h:64

imageFormatType< IMAGE_RGB32F >::Vector

float3 Vector

Definition: imageFormat.h:234

IMAGE_I420

@ IMAGE_I420

YUV I420 4:2:0 planar (‘'i420’`)

Definition: imageFormat.h:68

imageFormatType

Definition: imageFormat.h:229

IMAGE_BAYER_GBRG

@ IMAGE_BAYER_GBRG

8-bit Bayer GBRG (‘'bayer-gbrg’`)

Definition: imageFormat.h:74

imageFormatIsGray

bool imageFormatIsGray(imageFormat format)

Check if an image format is one of the grayscale formats.

IMAGE_RGBA8

@ IMAGE_RGBA8

uchar4 RGBA8 (‘'rgba8’`)

Definition: imageFormat.h:53

IMAGE_BGRA8

@ IMAGE_BGRA8

uchar4 BGRA8 (‘'bgra8’`)

Definition: imageFormat.h:59

imageFormatType< IMAGE_RGBA8 >::Base

uint8_t Base

Definition: imageFormat.h:232

imageFormatType< IMAGE_RGBA32F >::Base

float Base

Definition: imageFormat.h:235

imageFormat

imageFormat

The imageFormat enum is used to identify the pixel format and colorspace of an image.

Definition: imageFormat.h:49

IMAGE_UNKNOWN

@ IMAGE_UNKNOWN

Unknown/undefined format.

Definition: imageFormat.h:84

imageFormatType< IMAGE_RGB8 >::Base

uint8_t Base

Definition: imageFormat.h:231