#ifdef _CH_
#pragma package <opencv>
#endif

#ifndef _EiC
#include "cv.h"
#include "cvaux.h"
#include "highgui.h"
#endif

#include "feature.h"
#include <vector>
#include <math.h>

#include "redFeature.h"
#define eohbins 6

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

redFeature::redFeature() {

}

redFeature::redFeature(int d) {

}

redFeature::~redFeature() {

}

int redFeature::calcValue(IplImage *input, IplImage **bins, IplImage *red, IplImage *CumulativeIntensities) {

	int sum=0;
	
	//get 4 points for integral image calculation
	int Ax=offsetX;
	int Ay=offsetY;
	int Dx=width*scaleX + offsetX;
	int Dy=height*scaleY + offsetY;
	int Bx=Ax;
	int By=Dy;
	int Cx=Dx;
	int Cy=Ay;
	
	float A=((float*)(red->imageData + red->widthStep*Ay))[Ax];
	float B=((float*)(red->imageData + red->widthStep*By))[Bx];
	float C=((float*)(red->imageData + red->widthStep*Cy))[Cx];
	float D=((float*)(red->imageData + red->widthStep*Dy))[Dx];
	sum=A+D-C-B;

	return sum;
}

#ifdef _EiC
main(1,"redfeature.cpp");
#endif