#pragma once

#define OF_ADDON_USING_OFXVECTORMATH
#define OF_ADDON_USING_OFXOPENCV

#include "ofMain.h"
#include "ofAddons.h"

#include "cardDef.h"
#include "contourAnalyser.h"

class cvCardAnalysis{
	
	public:		
		void setup(int cardW, int cardH);
		void getCardAsCvImage(card &theCard, ofxCvGrayscaleImage &videoFrame);
		void getCardAsCvImage(card &theCard, ofxCvGrayscaleImage &videoFrame, ofxCvColorImage &videoFrameColor);  // default params?
		
		// get the data into storage: 
		void copyCardDataIntoCardImage(cardImageSet & cardToUpdate);
	
		void dynamicThreshold(int threshold = 128);
		void calculateHuMoments(card &theCard, bool bUseThresholdedFrame = true);
		void calculateCardProperties(card &theCard);  // face card, etc?
	
		//------------------------------
		int cardWarpW;
		int cardWarpH;
		
		ofxCvGrayscaleImage		cardImg;
		ofxCvColorImage			cardImgColor;				// needed for red detection 
		ofxCvGrayscaleImage		thresholdedFrame;
		ofxCvGrayscaleImage		thresholdedFrameDilated;	// needed for faceCard detection 
		ofxCvGrayscaleImage		cannyImage;	
		
		ofxCvColorImage			cardImgColorHighRes;		// YA! 
		ofxCvGrayscaleImage		cardImgGrayscaleHighRes;	// YA! 
		ofxCvGrayscaleImage		cardImgGrayscaleHighResBlobs;		// YA! 
		ofxCvColorImage			cardImgColorHighResBlobs;
		ofxCvColorImage			cardImgColorHighResResult;
	
		
		unsigned char *			cornerPixels;
		ofxCvGrayscaleImage		cornerMaskedImage;			// needed for red detection 
		ofxCvGrayscaleImage		cornerMaskedImageHighRes;	// needed for images...
		ofxCvGrayscaleImage		cornerImage;				// needed for red detection 
		
		unsigned char *			cornerAsColorTest;
		ofTexture				cornerAsColorTex;
	
		unsigned char * threshPixels; 
	
		ofxCvContourFinder		contourFinder;
		contourAnalyser			CA;
	
	
};

