#ifdef _CH_
#define WIN32
#error "The file needs cvaux, which is not wrapped yet. Sorry"
#endif
#ifndef _EiC
#include "cv.h"
#include "cxcore.h"
#include "cvaux.h"
#include "highgui.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <float.h>
#include <limits.h>
#include <time.h>
#include <ctype.h>
#endif
static CvMemStorage* storage;
//static double color;
static CvSize imgSize;
static CvSize tmplSize;
static CvSeq* contour;
static CvSeq* biggest;
static CvCapture* capture = 0;
static int isHandOpen = 1;
//static double color;
static CvScalar color;
static IplImage *img;
static IplImage *tmpImg;
static IplImage *conv;
static IplImage *H;
static IplImage *S;
static IplImage *V;
static IplImage *tmpH1;
static IplImage *tmpS1;
static IplImage *tmpH2;
static IplImage *tmpS2;
static IplImage *tmpH3;
static IplImage *tmpS3;
static IplImage *openHandTmpl, *closedHandTmpl;
static IplImage *openGrayHandTmpl, *closedGrayHandTmpl;
static IplImage *openscaledTmpl, *closedscaledTmpl;
static IplImage *openMatchResult, *closedMatchResult;
FILE *output;
void handDetect( IplImage *img);
static int numImg = 10;
char *names[] = { "./images/test01.jpg", "./images/test02.jpg", "./images/test03.jpg", "./images/test04.jpg", "./images/test05.jpg",
"../images/test06.jpg", "./images/test07.jpg", "./images/test08.jpg", "./images/test09.jpg", "./images/test10.jpg"};
char *resultsiamge[] = {"result01.jpg","result02.jpg","result03.jpg","result04.jpg","result05.jpg","result06.jpg","result07.jpg",
"result08.jpg","result09.jpg","result10.jpg"};
int main( int argc, char** argv )
{
int i = 0;
char filename[80];
storage = cvCreateMemStorage(0);
#ifdef DEBUG
cvNamedWindow( "Template1", 1 );
cvNamedWindow( "Template2", 1 );
cvNamedWindow( "Comp Results1", 1 );
cvNamedWindow( "Comp Results2", 1 );
cvNamedWindow( "Skin Detection", 1 );
#endif
openHandTmpl = cvLoadImage("openHandTmpl.jpg",1);
closedHandTmpl = cvLoadImage("closedHandTmpl.jpg",1);
// Convert form RGB to GRAY
tmplSize.width = openHandTmpl->width;
tmplSize.height = openHandTmpl->height;
openGrayHandTmpl = cvCreateImage( tmplSize, IPL_DEPTH_8U, 1);
cvCvtColor( openHandTmpl, openGrayHandTmpl, CV_BGR2GRAY );
tmplSize.width = closedHandTmpl->width;
tmplSize.height = closedHandTmpl->height;
closedGrayHandTmpl = cvCreateImage( tmplSize, IPL_DEPTH_8U, 1);
cvCvtColor( closedHandTmpl, closedGrayHandTmpl, CV_BGR2GRAY );
cvNamedWindow("source",1);
cvMoveWindow("source",0,0);
cvNamedWindow( "Results", 1 );
cvMoveWindow("Results",400,300);
cvAddSearchPath("