00001
00002
00003
00004 #ifndef _XVMOTIONSEG_H_
00005 #define _XVMOTIONSEG_H_
00006
00007 #include <XVSegmentation.h>
00008
00009 #define DEFAULT_THRESHOLD 50
00010
00011 inline bool THRESHOLD_CHECK(const u_char pix){ return pix < 100 ? true : false; }
00012
00013 template <class T>
00014 class ThresholdTable : public ScalarTable<T, u_char>{
00015
00016 protected:
00017
00018 int thresh;
00019
00020 virtual u_char computePixelValue(T pixel){
00021 return (u_char)(pixel > thresh ? pixel : 255);
00022 }
00023
00024 public:
00025
00026 ThresholdTable(int t = DEFAULT_THRESHOLD);
00027 };
00028
00029 template <class T>
00030 class XVMotionSeg : public XVSegmentation<T, u_char>{
00031
00032 protected:
00033
00034 XVImageScalar<T> prev;
00035
00036 void init(const XVImageScalar<T>, int, ThresholdTable<T> * table = NULL);
00037
00038 public:
00039
00040 XVMotionSeg(int, int, int thresh = DEFAULT_THRESHOLD,
00041 ThresholdTable<T> * table = NULL);
00042
00043 XVMotionSeg(const XVImageScalar<T>,
00044 int thresh = DEFAULT_THRESHOLD,
00045 ThresholdTable<T> * table = NULL);
00046
00047 virtual void segment(const XVImageBase<T> &, XVImageScalar<u_char> &);
00048 };
00049
00050 #endif