#include "highgui.h"
#include <opencv\cv.h>
#include "cv.h"
#include <cv.h>
#include <cvaux.h>
#include <highgui.h>
#include <ml.h>
using namespace cv;
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define ROAD "H:\kc.jpg"
#define WIN1 "win1"
#define WIDTH 300
#define HEIGHT 300
int mouse_x,mouse_y;
int pointset[8];
void point(int mouseevent, int x, int y, int flags, void* param) ;
void getPoint(const char* win) ;
void get_four_points(int *pointset,IplImage* crw);
void PerspectiveTrans(IplImage* src, IplImage* dst,int* pointset ,CvMat *transmat);
void invert_to_binary(IplImage* img);
template<class T> class Image {
public:
IplImage* imgp;
Image(IplImage* img=0) {imgp=img;}
~Image(){imgp=0;}
inline T* operator[](const int rowIndx) {return ((T *)(imgp->imageData + rowIndx*imgp->widthStep));}
};
typedef Image<unsigned char> BwImage;
void cvThin (IplImage* src, IplImage* dst, int iterations)
{
cvCopyImage(src, dst);
BwImage dstdat(dst);
IplImage* t_image = cvCloneImage(src);
BwImage t_dat(t_image);
for (int n = 0; n < iterations; n++)
for (int s = 0; s <= 1; s++)
{
cvCopyImage(dst, t_image);
for (int i = 0; i < src->height; i++)
for (int j = 0; j < src->width; j++)
if (t_dat[i][j])
{
int a = 0, b = 0;
int d[8][2] = {
#include "highgui.h"
#include <opencv\cv.h>
#in