Fawkes API  Fawkes Development Version
colorspaces.h
00001 
00002 /***************************************************************************
00003  *  colorspaces.h - This header defines utility functions to deal with
00004  *                  color spaces
00005  *
00006  *  Generated: Tue Feb 23 13:49:38 2005
00007  *  Copyright  2005  Tim Niemueller [www.niemueller.de]
00008  *
00009  ****************************************************************************/
00010 
00011 /*  This program is free software; you can redistribute it and/or modify
00012  *  it under the terms of the GNU General Public License as published by
00013  *  the Free Software Foundation; either version 2 of the License, or
00014  *  (at your option) any later version. A runtime exception applies to
00015  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00016  *
00017  *  This program is distributed in the hope that it will be useful,
00018  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *  GNU Library General Public License for more details.
00021  *
00022  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00023  */
00024 
00025 #ifndef __FIREVISION_UTILS_COLOR_COLORSPACES_H_
00026 #define __FIREVISION_UTILS_COLOR_COLORSPACES_H_
00027 
00028 #include <sys/types.h>
00029 
00030 namespace firevision {
00031 #if 0 /* just to make Emacs auto-indent happy */
00032 }
00033 #endif
00034 
00035 /** Color spaces.
00036  * Color spaces have their name for historical reasons, but the proper
00037  * name would be buffer format. A colorspace defines a particular layout
00038  * of a memory buffer containing an image (or point cloud).
00039  */
00040 typedef enum {
00041   CS_UNKNOWN            =  0,   /**< Unknown color space */
00042   RGB                   =  1,   /**< RGB, three bytes per pixel, one byte per color, ordered
00043                                  * line by line */
00044   YUV411_PACKED         =  2,   /**< YUV image with 4:1:1 sampling, byte order U Y0 Y1 V Y2 Y3 */
00045   YUV411_PLANAR         =  3,   /**< YUV image with 4:1:1 sampling, first Y plane, then U then V plane */
00046   YUY2                  =  4,   /**< YUV image with 4:2:2 sampling, byte order Y0 U Y1 V */
00047   BGR                   =  5,   /**< RGB, 3 bytes per pixel, one byte per color, ordererd
00048                                  * line by line, pixels orderd B G R */
00049   YUV422_PACKED         =  6,   /**< YUV image with 4:2:2 sampling, byte order U Y0 V Y1 */
00050   YUV422_PLANAR         =  7,   /**< YUV image with 4:2:2 sampling, first Y plane, then U then V plane */
00051   GRAY8                 =  8,   /**< plain gray buffer, one byte per pixel */
00052   RGB_WITH_ALPHA        =  9,   /**< RGB with alpha, 4 bytes per pixel, byte order R G B A */
00053   BGR_WITH_ALPHA        = 10,   /**< RGB with alpha, 4 bytes per pixel, byte order B G R A */
00054   BAYER_MOSAIC_RGGB     = 11,   /**< Image has RGGB bayer pattern */
00055   BAYER_MOSAIC_GBRG     = 12,   /**< Image has GBRG bayer pattern */
00056   BAYER_MOSAIC_GRBG     = 13,   /**< Image has GRBG bayer pattern */
00057   BAYER_MOSAIC_BGGR     = 14,   /**< Image has BGGR bayer pattern */
00058   RAW16                 = 15,   /**< Raw image, 2 bytes per pixel, format depends on camera */
00059   RAW8                  = 16,   /**< Raw image, 1 byte per pixel, format depends on camera */
00060   MONO8                 = 17,   /**< Like GRAY8 */
00061   MONO16                = 18,   /**< Gray-scale image, 2 bytes per pixel */
00062   YUV444_PACKED         = 19,   /**< Full sampled YUV, byte order Y U V */
00063   YVU444_PACKED         = 20,   /**< Full sampled YUV, byte order Y V U */
00064   YVY2                  = 21,   /**< YUV image with 4:2:2 sampling, byte order Y0 V Y1 U */
00065   YUV422_PLANAR_QUARTER = 22,   /**< YUV 422 image in planar format, but only quarter of the image,
00066                                  * used for scale-conversion target, buffer is YUV422_PLANAR formatted. */
00067   CARTESIAN_3D_FLOAT    = 23,   /**< 3D coordinates in a packed format. Row major
00068                                  * (x,y,z) tuples, values as float in meters */
00069   CARTESIAN_3D_DOUBLE   = 24,   /**< 3D coordinates in a packed format. Row major
00070                                  * (x,y,z) tuples, values as double in meters */
00071   CARTESIAN_3D_FLOAT_RGB = 25,  /**< 3D coordinates in a packed format. Row major
00072                                  * (x,y,z, C) tuples, values as float in meters. C is a float
00073                                  * representing the color as RGB data packed as (r,g,b,I) with
00074                                  * r, g, b being one unsigned byte each and I is ignored. */
00075   COLORSPACE_N          = 26    /**< number of colorspaces */
00076 } colorspace_t;
00077 
00078 
00079 size_t           colorspace_buffer_size(colorspace_t cspace, unsigned int width, unsigned int height);
00080 colorspace_t     colorspace_by_name(const char *colorspace);
00081 const char *     colorspace_to_string(colorspace_t colorspace);
00082 unsigned char *  malloc_buffer(colorspace_t colorspace, unsigned int width, unsigned int height);
00083 
00084 } // end namespace firevision
00085 
00086 #endif