#include <opencv/cv.h>
extern "C"
{
#include <opencv/highgui.h>
}
#include <cmath>
#include <iostream>
#define DEBUG
#include "../libseemicro/seemicro.h"

using namespace std;
using namespace seemicro;


int main(int argc, char** argv)
{
	if(argc != 2 && argc != 3)
	{
		cerr << "Call me as: " << argv[0] << " <inputimage> [<outputimage>]\n";
		return 1;
	}
	DEBUGLEVEL = 3;
	ImageFile i(argv[1]);
	GrayModule g(i);
	PolarModule p(g, 100, 100);
	CannyModule c(p);

	g.processFrame();
//	cvSmooth(g.img, g.img, CV_GAUSSIAN, 3, 3);
	p.processFrame(NULL);
	c.processFrame();

	if(argc==2)
	{
	  cvNamedWindow("canny", 1);
	  cvShowImage("canny", c.img);
	  cvNamedWindow(argv[0], 1);
	  cvShowImage(argv[0], p.img);
          cvWaitKey();
	}
	else cvSaveImage(argv[2], p.img);

	cvDestroyWindow(argv[0]);
	return 0;
}

