00001 /*!@file Video/VideoFormat.H definitions of possible image grabbing modes */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2003 // 00005 // by the University of Southern California (USC) and the iLab at USC. // 00006 // See http://iLab.usc.edu for information about this project. // 00007 // //////////////////////////////////////////////////////////////////// // 00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00010 // in Visual Environments, and Applications'' by Christof Koch and // 00011 // Laurent Itti, California Institute of Technology, 2001 (patent // 00012 // pending; application number 09/912,225 filed July 23, 2001; see // 00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00014 // //////////////////////////////////////////////////////////////////// // 00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00016 // // 00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00018 // redistribute it and/or modify it under the terms of the GNU General // 00019 // Public License as published by the Free Software Foundation; either // 00020 // version 2 of the License, or (at your option) any later version. // 00021 // // 00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00025 // PURPOSE. See the GNU General Public License for more details. // 00026 // // 00027 // You should have received a copy of the GNU General Public License // 00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00030 // Boston, MA 02111-1307 USA. // 00031 // //////////////////////////////////////////////////////////////////// // 00032 // 00033 // Primary maintainer for this file: Laurent Itti <itti@usc.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Video/VideoFormat.H $ 00035 // $Id: VideoFormat.H 12660 2010-01-26 02:14:54Z beobot $ 00036 // 00037 00038 #ifndef VIDEO_VIDEOFORMAT_H_DEFINED 00039 #define VIDEO_VIDEOFORMAT_H_DEFINED 00040 00041 #include <string> 00042 00043 class Dims; 00044 00045 //! VideoFrame formats. Not all may be supported by various hardware. 00046 /*! See VideoFrame.H for functions using those modes. If you add modes 00047 here, be sure to update convertToString() and convertFromString() 00048 in VideoFormat.C. 00049 00050 See http://www.fourcc.org/ for useful descriptions of various YUV 00051 encoding formats. 00052 */ 00053 enum VideoFormat 00054 { 00055 VIDFMT_GREY = 0, // format: [ grey(8) ] 00056 VIDFMT_RAW = 1, 00057 VIDFMT_RGB555 = 2, // format: [ (1) r(5) g(5) b(5) ] 00058 VIDFMT_RGB565 = 3, // format: [ r(5) g(6) b(5) ] 00059 VIDFMT_RGB24 = 4, // format: [ r(8) g(8) b(8) ] 00060 VIDFMT_RGB32 = 5, // format: [ r(8) g(8) b(8) ] 00061 VIDFMT_YUV24 = 6, // formt: [ Y(8) U(8) V(8) ] layout-compatible with PixVideoYUV<byte> 00062 VIDFMT_YUYV = 7, // format: [ Y0(8) U0(8) Y1(8) V0(8) ] 00063 VIDFMT_UYVY = 8, // format: [ U0(8) Y0(8) V0(8) Y1(8) ] 00064 VIDFMT_YUV444 = 9, // format: [ U0(8) Y0(8) V0(8) U1(8) Y1(8) V1(8) ] (a.k.a. IYU2) 00065 VIDFMT_YUV422 = 10, // format: same as VIDFMT_UYVY 00066 VIDFMT_YUV411 = 11, // format: [ U(8) Y0(8) Y1(8) V(8) Y2(8) Y3(8) ] 00067 VIDFMT_YUV420 = 12, // does this exist? 00068 VIDFMT_YUV410 = 13, // does this exist? 00069 VIDFMT_YUV444P = 14, 00070 VIDFMT_YUV422P = 15, 00071 VIDFMT_YUV411P = 16, 00072 VIDFMT_YUV420P = 17, 00073 VIDFMT_YUV410P = 18, 00074 VIDFMT_HM12 = 19, 00075 00076 // format: bayer, last to letter represents the bayer format 00077 // for example, "GB" means the 1st row and first two componets are 00078 // green and blue value 00079 VIDFMT_BAYER_GB = 20, 00080 VIDFMT_BAYER_BG = 21, 00081 VIDFMT_BAYER_GR = 22, 00082 VIDFMT_BAYER_RG = 23, 00083 00084 // 12 bits depth bayer mode 00085 VIDFMT_BAYER_GB12 = 24, 00086 VIDFMT_BAYER_BG12 = 25, 00087 VIDFMT_BAYER_GR12 = 26, 00088 VIDFMT_BAYER_RG12 = 27, 00089 VIDFMT_MJPEG = 28, 00090 00091 // KEEP THIS ITEM LAST: 00092 VIDFMT_AUTO = 29 // auto selection of best mode 00093 }; 00094 00095 //! Conversion from VideoFormat to string 00096 /*! Use it, for example, if you got a grabmode as text from the 00097 command line and need to convert that to a VideoFormat value for the 00098 constructor. Text strings should match the symbolic names of the 00099 VideoFormat enum, minus the "VIDFMT_" prefix. */ 00100 std::string convertToString(const VideoFormat val); 00101 //! Conversion from string to VideoFormat 00102 /*! The names used in the definition of the enum VideoFormat 00103 (minus the "VIDFMT_" prefix) will be returned. 00104 00105 The string is checked in a case-insensitive manner, so 00106 e.g. "YUV420P", "yuv420p", and "YuV420p" will all translate to 00107 VIDMFT_YUV420P. 00108 */ 00109 void convertFromString(const std::string& str, VideoFormat& val); 00110 00111 //! Check if the given mode is a simple packed pixel mode. 00112 /*! If false, the mode might be planar, or might be a "complex" packed 00113 mode that has values represented by less than a full byte 00114 (e.g. VIDFMT_RGB555 or VIDFMT_RGB565). */ 00115 bool isSimplePackedMode(const VideoFormat vidformat); 00116 00117 //! Get the width of a scanline in the given video format. 00118 /*! This returns some multiple of the image width for packed formats, 00119 and returns -1 for planar formats (indicating that the video frame 00120 storage is not just a series of scanlines for that format). */ 00121 int getScanlineWidth(const VideoFormat vidformat, 00122 const int imgwidth); 00123 00124 //! Get the bytes-per-pixel for the given mode as a rational number (numer/denom) 00125 void getBytesPerPixelForMode(const VideoFormat vidformat, 00126 unsigned int* numer, 00127 unsigned int* denom); 00128 00129 //! Get the size (in bytes) of a frame in the given video format. 00130 /*! This will return a valid result for any video format, whether it 00131 is planar or packed. */ 00132 unsigned int getFrameSize(const VideoFormat vidformat, 00133 const Dims& imgdims); 00134 00135 #endif // VIDEO_VIDEOFORMAT_H_DEFINED 00136 00137 // ###################################################################### 00138 /* So things look consistent in everyone's emacs... */ 00139 /* Local Variables: */ 00140 /* indent-tabs-mode: nil */ 00141 /* End: */