Homepage Demos Overview Downloads Tutorials Reference
Credits

cmv_types.h

Go to the documentation of this file.
00001 /*========================================================================
00002     cmv_types.h : Base types for CMVision2
00003   ------------------------------------------------------------------------
00004     Copyright (C) 1999-2002  James R. Bruce
00005     School of Computer Science, Carnegie Mellon University
00006   ------------------------------------------------------------------------
00007     This software is distributed under the GNU General Public License,
00008     version 2.  If you do not have a copy of this licence, visit
00009     www.gnu.org, or write: Free Software Foundation, 59 Temple Place,
00010     Suite 330 Boston, MA 02111-1307 USA.  This program is distributed
00011     in the hope that it will be useful, but WITHOUT ANY WARRANTY,
00012     including MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00013     ========================================================================*/
00014 
00015 #ifndef __CMVISION_TYPES_H__
00016 #define __CMVISION_TYPES_H__
00017 
00018 #include "colors.h"
00019 
00020 namespace CMVision{
00021 
00022 typedef unsigned char uchar;
00023 
00024 // uncomment if your compiler supports the "restrict" keyword
00025 // #define restrict __restrict__
00026 #define restrict
00027 
00028 template <class pixel>
00029 class image{
00030 public:
00031   pixel *buf;
00032   int width,height,row_stride;
00033 };
00034 
00035 template <class pixel>
00036 class image_idx{
00037 public:
00038   pixel *buf;
00039   int width,height,row_stride;
00040 };
00041 
00042 template <class element>
00043 class image_yuv {
00044 public:
00045   element *buf_y,*buf_u,*buf_v;
00046   int width,height;
00047   int row_stride; // number of elements to skip to move one row in buf_[yuv]
00048 };
00049 
00050 #define CMV_PARAM <class pixel,class vimage,class threshold>
00051 #define CMV_TEM template CMV_PARAM
00052 
00053 #define CMV_NONE ((unsigned)(-1))
00054 
00055 /*
00056 // Options for level of processing
00057 //   use enable()/disable() to change 
00058 #define CMV_THRESHOLD      0x01
00059 #define CMV_COLOR_AVERAGES 0x02
00060 #define CMV_DUAL_THRESHOLD 0x04
00061 #define CMV_DENSITY_MERGE  0x08
00062 
00063 #define CMV_VALID_OPTIONS  0x0F
00064 */
00065 
00066 template <class cclass>
00067 class run{
00068 public:
00069   short x,y,width;    // location and width of run
00070   cclass color;       // which color(s) this run represents
00071   int parent,next;    // parent run and next run in run list
00072 };
00073 
00074 template <class cclass>
00075 class run_mini{
00076 public:
00077   short x,y,width;    // location and width of run
00078   cclass color;       // which color(s) this run represents
00079   short parent,next;  // parent run and next run in run list
00080 };
00081 
00082 struct region{
00083   int color;         // id of the color
00084   int x1,y1,x2,y2;   // bounding box (x1,y1) - (x2,y2)
00085   float cen_x,cen_y; // centroid
00086   int area;          // occupied area in pixels
00087   int run_start;     // first run index for this region
00088   int iterator_id;   // id to prevent duplicate hits by an iterator
00089   region *next;      // next region in list
00090 };
00091 
00092 struct region_small{
00093   short color;       // id of the color
00094   short x1,y1,x2,y2; // bounding box (x1,y1) - (x2,y2)
00095   short iterator_id; // id to prevent duplicate hits by an iterator
00096   float cen_x,cen_y; // centroid
00097   int area;          // occupied area in pixels
00098   int run_start;     // first run index for this region
00099   region *next;      // next region in list
00100 };
00101 
00102 struct region_tiny{
00103   uchar color;       // id of the color
00104   uchar x1,y1,x2,y2; // bounding box (x1,y1) - (x2,y2)
00105   float cen_x,cen_y; // centroid
00106   short area;        // occupied area in pixels
00107   short run_start;   // first run index for this region
00108   short iterator_id; // id to prevent duplicate hits by an iterator
00109   region *next;      // next region in list
00110 };
00111 
00112 struct color_class_state{
00113   color_class_state() : list(), num(), min_area(), total_area(), merge_threshold(), color(), name() {}
00114   color_class_state(const color_class_state& c) : list(c.list), num(c.num), min_area(c.min_area), total_area(c.total_area), merge_threshold(c.merge_threshold), color(c.color), name(c.name) {}
00115   color_class_state operator=(const color_class_state& c) { list=c.list; num=c.num; min_area=c.min_area; total_area=c.total_area; merge_threshold=c.merge_threshold; color=c.color; name=c.name; return *this;}
00116   region *list;          // head of region list for this color
00117   int num;               // number of regions of this color
00118   int min_area;          // minimum area for a meaningful region
00119   int total_area;        // total area covered by color
00120   float merge_threshold; // minimum density of merged region
00121   rgb color;             // example color (such as used in test output)
00122   char *name;            // color's meaningful name (e.g. orange ball, goal)
00123 };
00124 
00125 } // namespace
00126 
00127 #endif

Tekkotsu v2.2.1
Generated Tue Nov 23 16:36:37 2004 by Doxygen 1.3.9.1