#ifndef _FASTTRACKERPROCESSOR_H_
#define _FASTTRACKERPROCESSOR_H_

#include "Processor.h"
#include "CornerDetector.h"
#include <im.h>
#include <im_image.h>
#include <QObject>

class QAction;
class FASTTrackerPropertiesWidget;

class FASTTrackerProcessor : public QObject, public Processor
{
	Q_OBJECT

public:
	static const int MAX_FEATURES = 100;

public:
	FASTTrackerProcessor();
	~FASTTrackerProcessor();

	inline int getThreshold() const { return _cornerDetector->getThreshold(); }
	inline void setThreshold( int threshold ) { _cornerDetector->setThreshold( threshold ); }

	inline bool isCannyEnabled() const { return _enableCanny; }
	inline void setCannyEnabled( bool on ) { _enableCanny = on; }

	inline float getCannyStdDev() const { return _cannyStdDev; }
	inline void setCannyStdDev( float stddev ) { _cannyStdDev = stddev; }

	inline int getCannyLower() const { return _cannyLowerThreshold; }
	inline void setCannyLower( int value ) { _cannyLowerThreshold = value; }

	inline int getCannyUpper() const { return _cannyUpperThreshold; }
	inline void setCannyUpper( int value ) { _cannyUpperThreshold = value; }

	virtual void resize( int width, int height );
	virtual void process( const unsigned char* original, unsigned char* processed );
	virtual QWidget* getPropertiesWidget( QWidget* parent );
	virtual void setupToolBar( QToolBar* toolBar );

	virtual void decorateGL( Canvas* canvas );
	virtual bool onMousePress( Canvas* canvas, int x, int y );
	virtual bool onMouseRelease( Canvas* canvas, int x, int y );

private slots:
	void on_actionDetectFeatures_triggered();

private:
	int _width;
	int _height;

	bool _enableCanny;
	float _cannyStdDev;
	int _cannyLowerThreshold;
	int _cannyUpperThreshold;
	CornerDetector *_cornerDetector;

	imImage* _grayImage;
	imImage* _binaryImage;

	QAction* _actionDetectFeatures;
	FASTTrackerPropertiesWidget* _widget;
};

#endif