#ifndef __TRACKER_H_
#define __TRACKER_H_

#include "ipl.h"
#include "cv.h"

#define MAX_COUNT (7)

/* this code extracted and ported from sample windows application on
 * implementing condensation in opencv.  (original source code:
 * visl.technion.ac.il/projects/2001w30/docs/OpenCV) */

typedef struct {

	int count;
	IplImage *image[MAX_COUNT];

} CvImageGroup;

/* tracks stuff the image, and modifies that IplImage with the new
 * tracked silhouette */
void tracker(IplImage* image);

// helper functions

void initTracker();
void initFilter();

void transform(IplImage *image);
void applyCamShift(IplImage *image, bool initialize);
void rectang(IplImage *img, CvRect Rect, int color);
bool set_hist_dims(int c_dims, int *dims);
bool set_thresh(int channel, int min_val, int max_val);
bool set_min_ch_val(int channel, int val);
bool set_max_ch_val(int channel, int val);
bool set_window(CvRect _window);
void update_histogram(IplImage *src_image);
IplImage *hist_pre_color(IplImage *src_image);
IplImage *trackobj_pre_color(IplImage *image);
CvImageGroup *hist_color_transform(IplImage *src_image);
CvImageGroup *color_transform(IplImage *image);
CvImageGroup *hist_post_color(CvImageGroup *src_image);
CvImageGroup *trackobj_post_color(CvImageGroup *image);
void calc_histogram(CvImageGroup *image);
IplImage *calc_back_project(CvImageGroup *image);
void track_object(IplImage *src_image);
void trackobj_find(IplImage *image);
CvImageGroup *trackobj_color_transform(IplImage *src_image);
void CondProbDens(CvConDensation *CD, float *Measurement);
void CheckBackProject(IplImage *image);
IplImage *get_back_project();

// cv image group
void operatorEqualsInt(int _count);
void copyImage(IplImage *src);
IplImage **get_group();

#endif
