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 
00011 #include "colors.h"
00012 
00013 namespace CMVision{
00014 
00015   //typedef unsigned char uchar;
00016 
00017 // uncomment if your compiler supports the "restrict" keyword
00018 // #define restrict __restrict__
00019 #define restrict
00020 
00021 template <class pixel>
00022 class image{
00023 public:
00024   pixel *buf;
00025   int width,height,row_stride;
00026 };
00027 
00028 template <class pixel>
00029 class image_idx{
00030 public:
00031   pixel *buf;
00032   int width,height,row_stride;
00033 };
00034 
00035 template <class element>
00036 class image_yuv {
00037 public:
00038   element *buf_y,*buf_u,*buf_v;
00039   int width,height;
00040   int row_stride; // number of elements to skip to move one row in buf_[yuv] (handle row interleaving)
00041   int col_stride; // number of elements to move one column in buf_[yuv] (handle pixel interleaving)
00042 };
00043 
00044 #define CMV_PARAM <class pixel,class vimage,class threshold>
00045 #define CMV_TEM template CMV_PARAM
00046 
00047 #define CMV_NONE ((unsigned)(-1))
00048 
00049 /*
00050 // Options for level of processing
00051 //   use enable()/disable() to change 
00052 #define CMV_THRESHOLD      0x01
00053 #define CMV_COLOR_AVERAGES 0x02
00054 #define CMV_DUAL_THRESHOLD 0x04
00055 #define CMV_DENSITY_MERGE  0x08
00056 
00057 #define CMV_VALID_OPTIONS  0x0F
00058 */
00059 
00060 template <class cclass>
00061 class run{
00062 public:
00063   short x,y,width;    // location and width of run
00064   cclass color;       // which color(s) this run represents
00065   int parent,next;    // parent run and next run in run list
00066 };
00067 
00068 template <class cclass>
00069 class run_mini{
00070 public:
00071   short x,y,width;    // location and width of run
00072   cclass color;       // which color(s) this run represents
00073   short parent,next;  // parent run and next run in run list
00074 };
00075 
00076 struct region{
00077   int color;         // id of the color
00078   int x1,y1,x2,y2;   // bounding box (x1,y1) - (x2,y2)
00079   float cen_x,cen_y; // centroid
00080   int area;          // occupied area in pixels
00081   int run_start;     // first run index for this region
00082   int iterator_id;   // id to prevent duplicate hits by an iterator
00083   region *next;      // next region in list
00084 };
00085 
00086 struct region_small{
00087   short color;       // id of the color
00088   short x1,y1,x2,y2; // bounding box (x1,y1) - (x2,y2)
00089   short iterator_id; // id to prevent duplicate hits by an iterator
00090   float cen_x,cen_y; // centroid
00091   int area;          // occupied area in pixels
00092   int run_start;     // first run index for this region
00093   region *next;      // next region in list
00094 };
00095 
00096 struct region_tiny{
00097   uchar color;       // id of the color
00098   uchar x1,y1,x2,y2; // bounding box (x1,y1) - (x2,y2)
00099   float cen_x,cen_y; // centroid
00100   short area;        // occupied area in pixels
00101   short run_start;   // first run index for this region
00102   short iterator_id; // id to prevent duplicate hits by an iterator
00103   region *next;      // next region in list
00104 };
00105 
00106 struct color_class_state{
00107   color_class_state() : list(), num(), min_area(), total_area(), merge_threshold(), color(), name() {}
00108   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) {}
00109   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;}
00110   region *list;          // head of region list for this color
00111   int num;               // number of regions of this color
00112   int min_area;          // minimum area for a meaningful region
00113   int total_area;        // total area covered by color
00114   float merge_threshold; // minimum density of merged region
00115   rgb color;             // example color (such as used in test output)
00116   char *name;            // color's meaningful name (e.g. orange ball, goal)
00117 };
00118 
00119 } // namespace
00120 
00121 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:37 2016 by Doxygen 1.6.3