pipesourcefilters.h

来自「VC视频对象的跟踪提取原代码(vc视频监控源码)」· C头文件 代码 · 共 1,086 行 · 第 1/2 页

H
1,086
字号
	{	    in = source1 = s1;	    source2 = s2;	    threshold = thresh;	}};/******************/class SimpleDiffSource : public PipeSource /// (nts) was ImageSource{protected:    ImageSource *source1;    ImageSource *source2;public:    realno threshold;    unsigned int no_marked;    protected:    inline Image *recalc()	{	    return source1->get_current()->		simple_difference(source2->get_current(), threshold,				  &no_marked, current);	}    public:    inline Image *refresh()	{	    if ((source1->get_current() == NULL) ||		(source2->get_current() == NULL))		return NULL;	    else		return current = recalc();	}    inline virtual Image *get_next()	{//  	    // frame_id++;//  	    if ((source1->get_next() == NULL) || (source2->get_next() == NULL))//  		return NULL;//  	    else	    frame_count++;	    return get_current();  //  automatically follow in's new frame_id	}        inline Image *get_current()	{	    // match frame id to parents' frame id	    if ((current != NULL) &&                   // we have a valid image		(current->get_frame_id() ==		 MAX(source1->get_source_frame_id(),		     source2->get_source_frame_id()))) // and are up to date ?	    {		// then do not spend any CPU time on re-calculating		return current;	    }	    source1->get_current();           // recursive update as necessary	    source2->get_current();           // recursive update as necessary	    current = recalc();	    current->set_frame_id(MAX(source1->get_source_frame_id(),				      source2->get_source_frame_id()));	    current->set_frame_time_in_ms(MAX(source1->get_source_frame_time_in_ms(),					      source2->get_source_frame_time_in_ms()));	    return current;	}        SimpleDiffSource(ImageSource *s1, ImageSource *s2, realno thresh = -1)	: PipeSource(s1) ///, PipeSource(s2)	{	    in = source1 = s1;	    source2 = s2;	    threshold = thresh;	}};/******************/class BlendSource : public PipeSource /// (nts) was ImageSource{protected:    ImageSource *source1;    ImageSource *source2;    int a;    int b;        inline Image *recalc()	{	    return source1->get_current()->image_blend		(source2->get_current(), a, b, current);	}    public:    inline Image *refresh()	{	    if ((source1->get_current() == NULL) ||		(source2->get_current() == NULL))		return NULL;	    else		return current = recalc();	}        inline virtual Image *get_next()	{//  	    // frame_id++;//  	    if ((source1->get_next() == NULL) || (source2->get_next() == NULL))//  		return NULL;//  	    else	    frame_count++;	    return get_current();  //  automatically follow in's new frame_id	}        inline Image *get_current()	{	    // match frame id to parents' frame id	    if ((current != NULL) &&                   // we have a valid image		(current->get_frame_id() ==		 MAX(source1->get_source_frame_id(),		     source2->get_source_frame_id()))) // and are up to date ?	    {		// then do not spend any CPU time on re-calculating		return current;	    }	    source1->get_current();           // recursive update as necessary	    source2->get_current();           // recursive update as necessary	    current = recalc();	    current->set_frame_id(MAX(source1->get_source_frame_id(),				      source2->get_source_frame_id()));	    current->set_frame_time_in_ms(MAX(source1->get_source_frame_time_in_ms(),					      source2->get_source_frame_time_in_ms()));	    return current;	}        BlendSource(ImageSource *s1, ImageSource *s2,		int param_a = 1, int param_b = 1)	: PipeSource(s1) ///, PipeSource(s2)	{	    in = source1 = s1;	    source2 = s2;	    a = param_a;	    b = param_b;	}};/******************/class VFlipSource : public PipeSource{protected:    inline Image *recalc()	{	    return in->get_current()->flip_vertically(current);	}    public:    VFlipSource(ImageSource *source) : PipeSource(source)	{	    in = source;//	    refresh();	}};/******************/// SkipSource// sample an input ImageSource or PipeSource// pass on frames {start_frame + {0, n, 2n, ...}}class SkipSource : public PipeSource /// (nts) was ImageSource{    protected:        ImageSource *src;    PipeSource *in;    unsigned int skip;        inline Image *recalc()	{	    if (src != NULL)  // we are derived from an ImageSource		return src->get_current();  // ignore our PipeSource	    else		return in->get_current();	}    public:        inline virtual Image *get_next()	{  	    if (src != NULL)	    {		// we are derived from an ImageSource		unsigned int count;		for (count = 0; count < skip; count++)		    current = src->get_next(); // ignoring our PipeSource		current->set_frame_id(get_source_frame_id());		current->set_frame_time_in_ms(get_source_frame_time_in_ms());	    }  	    else	    {		unsigned int count;		for (count = 0; count < skip; count++)		    current = in->get_next();		current->set_frame_id(in->get_source_frame_id());		current->set_frame_time_in_ms(in->get_source_frame_time_in_ms());	    }	    frame_count++;	    return current;	}        inline virtual void clean_up()	{	    current = NULL;	    in = NULL;	}        virtual unsigned int get_xdim() const	{	    if (src != NULL)  // we are derived from an ImageSource		return src->get_xdim(); // ignore our PipeSource	    else		return in->get_xdim();	}        virtual unsigned int get_ydim() const	{	    if (src != NULL)  // we are derived from an ImageSource		return src->get_ydim(); // ignore our PipeSource	    else		return in->get_ydim();	}        SkipSource(unsigned int n, ImageSource *source) : PipeSource(source)	{	    src = source;	    in = new PipeSource(src, true);	    skip = n;	}        SkipSource(unsigned int n, PipeSource *source) : PipeSource(source)	{	    src = NULL;  // we are not derived from an ImageSource	    in = source;	    skip = n;	}        ~SkipSource()	{	    current = NULL;	    delete in;	}    };// RepeatSource// temporally re-sample an input ImageSource// pass on each frame n timesclass RepeatSource : public PipeSource /// (nts) was ImageSource{    protected:        ImageSource *in;    frame_id_t repeat;    frame_id_t count;    public:        RepeatSource(frame_id_t the_repeat, ImageSource *source) : PipeSource(source)	{	    in = source;	    repeat = the_repeat;	    count = 0;	}        inline virtual Image *get_next() 	{ 	    if (frame_count == 0)	    {		// first image: get it from the source		current = in->get_current();   // NB no check here (could be NULL)	    }	    else		if (frame_count % repeat == 0)		{		    // we have shown the image `repeat' times: get next image from the source		    current = in->get_next();   // NB no check here (could be NULL)		}	    	    // adjust frame id according to current	    current->set_frame_id(in->get_source_frame_id());	    current->set_frame_time_in_ms(in->get_source_frame_time_in_ms());	    frame_count = (frame_count + 1) % MAX_FRAME_ID;	    	    return current;	}    //     inline void clean_up()// 	{// 	    current = NULL;// 	    in = NULL;// 	}        ~RepeatSource()	{	    current = NULL;	    delete in;	}};/******************/// commented out by nts --- Feb 2001//  // SingleImageSource//  // first call to get_next returns an image//  // subsequent calls return NULL////  class SingleImageSource : public ImageSource//  {//  public://    //      SingleImageSource(Image *frame) : ImageSource(frame, 0)//  	{//  	    // nothing//  	}//    //      inline virtual Image *get_next()//  	{//	    frame_count++;//  	    if (frame_number++ == 0)//  		return current;//  	    return NULL;//  	}//  };/******************/class ConcatSource : public PipeSource /// (nts) was ImageSource{protected:        ImageSource **in_array;    unsigned int no_sources;    unsigned int current_source;    public:        ConcatSource(ImageSource *s1, ImageSource *s2) : PipeSource(s1)	{ 	    in_array = new ImageSource*[2]; 	    in_array[0] = s1;	    in_array[1] = s2;	    no_sources = 2;	    current_source = 0;	    // this has been done already:  in = in_array[0];	}        ConcatSource(ImageSource **the_in_array,		 unsigned int the_no_sources) : PipeSource(the_in_array[0])	{	    in_array = the_in_array;	    no_sources = the_no_sources;	    current_source = 0;	    // this has been done already:  in = in_array[0];	}        inline virtual Image *get_next()	{	    if (current_source >= no_sources)		return NULL;	    Image *curr_img = in_array[current_source]->get_next();	    if ((curr_img == NULL) && (current_source + 1 < no_sources))	    {		// proceed to next image source		current_source++;		in = in_array[current_source];		curr_img = in_array[current_source]->get_next();	    }	    	    if (curr_img != NULL)	    {		if (current == NULL)		    current = curr_img->virtual_copy();				if (curr_img->get_image_type() != current->get_image_type())		{		    cerror << "ConcatSource: cannot concat different image types "			   << endl;		    exit(1);		}		if (current->get_data() != curr_img->get_data())		{		    current->set_data(curr_img->get_data());		    // FIXME: possible problem with ``own_data = true;'' in set_data() ???		}		current->set_frame_id(in->get_source_frame_id());		current->set_frame_time_in_ms(in->get_source_frame_time_in_ms());	    }	    	    frame_count++;	    return current;	}    //      Image *get_current()//  	{//  	    // FIXME: might not work.//  	    in->get_current();                 // recursive update as necessary//  	    return current;           // NB no checking for in's frame id here!//  	}        inline void clean_up()	{	    in_array = NULL;	    current = NULL;	}        ~ConcatSource()	{	    for (unsigned int i = 0; i < no_sources; i++)		delete in_array[i];	    delete [] in_array;	}    };/******************/class GammaCorrectSource: public PipeSource{public:        GammaCorrectMap gamma_map;    protected:    inline Image *recalc() 	{	    return in->get_current()->map_intensities(gamma_map,current);	}    public:    GammaCorrectSource(ImageSource *source, realno gamma_value)	: PipeSource(source), gamma_map(gamma_value)	{	    in = source;//	    refresh();	}};////   Colour Filtering to Grey8Image --- PipeSource i/face  ////  nts Feb 2001class ColourFilterSource: public PipeSource{    protected:    ColourFilteringMethod CF_method;        inline Image *recalc()	{	    return in->get_current()->ColourFilter(current,CF_method);	}    public:     inline Image *refresh()	{ 	    if (get_current() == NULL)		return NULL;	    else		return current = recalc();	}    inline virtual Image *get_next()	{ //  	    // frame_id++;//  	    if (in->get_next() == NULL)//  		return NULL;//  	    else	    frame_count++;	    return get_current();  //  automatically follow in's new frame_id	}        ColourFilterSource (ImageSource *source,			ColourFilteringMethod method = CF_METHOD_Y_709)	: PipeSource(source)	{	    in = source;	    CF_method = method;	}};#ifdef HSV////   HSV32Source: generate `HSV32Image's --- PipeSource i/face  ////  nts Apr 2001class HSV32Source: public PipeSource{    protected:    inline Image *recalc()	{	    return in->get_current()->to_HSV32(current);	}    public:     inline Image *refresh()	{ 	    if (get_current() == NULL)		return NULL;	    else		return current = recalc();	}        inline virtual Image *get_next()	{ //  	    // frame_id++;//  	    if (in->get_next() == NULL)//  		return NULL;//  	    else	    frame_count++;	    return get_current();  //  automatically follow in's new frame_id	}        HSV32Source (ImageSource *source) : PipeSource(source)	{	    in = source;	}};#endif  // ifdef HSV} // namespace ReadingPeopleTracker#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?