Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

cmv_types.h

Go to the documentation of this file.
00001 #ifndef __CMVISION_TYPES_H__
00002 #define __CMVISION_TYPES_H__
00003 
00004 /*! @file
00005 * @brief Base types for #CMVision
00006 * @author James R. Bruce, School of Computer Science, Carnegie Mellon University
00007 *
00008 * Licensed under the <a href="../gpl-2.0.txt">GNU GPL version 2</a>
00009 *
00010 * $Author: ejt $
00011 * $Name: tekkotsu-4_0 $
00012 * $Revision: 1.7 $
00013 * $State: Exp $
00014 * $Date: 2007/08/14 18:24:07 $
00015 */
00016 
00017 #include "colors.h"
00018 
00019 namespace CMVision{
00020 
00021   //typedef unsigned char uchar;
00022 
00023 // uncomment if your compiler supports the "restrict" keyword
00024 // #define restrict __restrict__
00025 #define restrict
00026 
00027 template <class pixel>
00028 class image{
00029 public:
00030   pixel *buf;
00031   int width,height,row_stride;
00032 };
00033 
00034 template <class pixel>
00035 class image_idx{
00036 public:
00037   pixel *buf;
00038   int width,height,row_stride;
00039 };
00040 
00041 template <class element>
00042 class image_yuv {
00043 public:
00044   element *buf_y,*buf_u,*buf_v;
00045   int width,height;
00046   int row_stride; // number of elements to skip to move one row in buf_[yuv] (handle row interleaving)
00047   int col_stride; // number of elements to move one column in buf_[yuv] (handle pixel interleaving)
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 v4.0
Generated Thu Nov 22 00:54:51 2007 by Doxygen 1.5.4