Fawkes API  Fawkes Development Version
colorspaces.h
1 
2 /***************************************************************************
3  * colorspaces.h - This header defines utility functions to deal with
4  * color spaces
5  *
6  * Generated: Tue Feb 23 13:49:38 2005
7  * Copyright 2005 Tim Niemueller [www.niemueller.de]
8  *
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version. A runtime exception applies to
15  * this software (see LICENSE.GPL_WRE file mentioned below for details).
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Library General Public License for more details.
21  *
22  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
23  */
24 
25 #ifndef _FIREVISION_UTILS_COLOR_COLORSPACES_H_
26 #define _FIREVISION_UTILS_COLOR_COLORSPACES_H_
27 
28 #include <sys/types.h>
29 
30 namespace firevision {
31 
32 /** Color spaces.
33  * Color spaces have their name for historical reasons, but the proper
34  * name would be buffer format. A colorspace defines a particular layout
35  * of a memory buffer containing an image (or point cloud).
36  */
37 typedef enum {
38  CS_UNKNOWN = 0, /**< Unknown color space */
39  RGB = 1, /**< RGB, three bytes per pixel, one byte per color, ordered
40  * line by line */
41  YUV411_PACKED = 2, /**< YUV image with 4:1:1 sampling, byte order U Y0 Y1 V Y2 Y3 */
42  YUV411_PLANAR = 3, /**< YUV image with 4:1:1 sampling, first Y plane, then U then V plane */
43  YUY2 = 4, /**< YUV image with 4:2:2 sampling, byte order Y0 U Y1 V */
44  BGR = 5, /**< RGB, 3 bytes per pixel, one byte per color, ordererd
45  * line by line, pixels orderd B G R */
46  YUV422_PACKED = 6, /**< YUV image with 4:2:2 sampling, byte order U Y0 V Y1 */
47  YUV422_PLANAR = 7, /**< YUV image with 4:2:2 sampling, first Y plane, then U then V plane */
48  GRAY8 = 8, /**< plain gray buffer, one byte per pixel */
49  RGB_WITH_ALPHA = 9, /**< RGB with alpha, 4 bytes per pixel, byte order R G B A */
50  BGR_WITH_ALPHA = 10, /**< RGB with alpha, 4 bytes per pixel, byte order B G R A */
51  BAYER_MOSAIC_RGGB = 11, /**< Image has RGGB bayer pattern */
52  BAYER_MOSAIC_GBRG = 12, /**< Image has GBRG bayer pattern */
53  BAYER_MOSAIC_GRBG = 13, /**< Image has GRBG bayer pattern */
54  BAYER_MOSAIC_BGGR = 14, /**< Image has BGGR bayer pattern */
55  RAW16 = 15, /**< Raw image, 2 bytes per pixel, format depends on camera */
56  RAW8 = 16, /**< Raw image, 1 byte per pixel, format depends on camera */
57  MONO8 = 17, /**< Like GRAY8 */
58  MONO16 = 18, /**< Gray-scale image, 2 bytes per pixel */
59  YUV444_PACKED = 19, /**< Full sampled YUV, byte order Y U V */
60  YVU444_PACKED = 20, /**< Full sampled YUV, byte order Y V U */
61  YVY2 = 21, /**< YUV image with 4:2:2 sampling, byte order Y0 V Y1 U */
62  YUV422_PLANAR_QUARTER = 22, /**< YUV 422 image in planar format, but only quarter of the image,
63  * used for scale-conversion target, buffer is YUV422_PLANAR formatted. */
64  CARTESIAN_3D_FLOAT = 23, /**< 3D coordinates in a packed format. Row major
65  * (x,y,z) tuples, values as float in meters */
66  CARTESIAN_3D_DOUBLE = 24, /**< 3D coordinates in a packed format. Row major
67  * (x,y,z) tuples, values as double in meters */
68  CARTESIAN_3D_FLOAT_RGB = 25, /**< 3D coordinates in a packed format. Row major
69  * (x,y,z, C) tuples, values as float in meters. C is a float
70  * representing the color as RGB data packed as (r,g,b,I) with
71  * r, g, b being one unsigned byte each and I is ignored. */
72 
73  RGB_PLANAR = 26, /**< RGB with three successive planes of R, G, and B each */
74  YUV420_PLANAR = 27, /**< YUV 4:2:0 in planar format */
75  RGB_FLOAT = 28, /**< RGB, 12 bytes per pixel, 4 byte per color, ordered, line by line */
76  BGR_FLOAT = 29, /**< BGR, 12 bytes per pixel, 4 byte per color, ordered, line by line */
77  COLORSPACE_N = 30 /**< number of colorspaces */
78 } colorspace_t;
79 
80 size_t colorspace_buffer_size(colorspace_t cspace, unsigned int width, unsigned int height);
81 colorspace_t colorspace_by_name(const char *colorspace);
82 const char * colorspace_to_string(colorspace_t colorspace);
83 unsigned char *malloc_buffer(colorspace_t colorspace, unsigned int width, unsigned int height);
84 
85 } // end namespace firevision
86 
87 #endif