	// ------------------------threads start -----------------------------------
	//-----------------Thread----------------------------
	HANDLE a_thread;
    DWORD a_threadId;
    DWORD thread_result;
	// --------------------------threads end ----------------------------------

	// Additions
	char filenames[40];
	char buffer[20];
	//Count available webcams
	bool cam_flag=TRUE; 
	while(cam_flag){
		capture0 = cvCaptureFromCAM(connected_cams+camera_offset);
		if(capture0)
			connected_cams++;
		else
			cam_flag=FALSE;
	}
	printf("Connected_cams=%d\n",connected_cams);

	if(connected_cams>(0+camera_offset)){
		storage = cvCreateMemStorage(0);
		capture0 = cvCaptureFromCAM(0+camera_offset);	
		//---------------------Capture Properties--------------------------------
		cvSetCaptureProperty( capture0, CV_CAP_PROP_FRAME_WIDTH, capture_width);
		cvSetCaptureProperty( capture0, CV_CAP_PROP_FRAME_HEIGHT,capture_height);
		cvNamedWindow( "Video", 1 );
		cvGrabFrame( capture0 );
		frame0 = cvRetrieveFrame( capture0 );
	}//if(connected_cams>(0+camera_offset))
	if(connected_cams>(1+camera_offset)){
		capture1 = cvCaptureFromCAM(1+camera_offset);
		//---------------------Capture Properties--------------------------------
		cvSetCaptureProperty( capture1, CV_CAP_PROP_FRAME_WIDTH,  capture_width);
		cvSetCaptureProperty( capture1, CV_CAP_PROP_FRAME_HEIGHT, capture_height  );
		//cvNamedWindow( "cam1", 1 );
	}//if(connected_cams>(1+camera_offset))
	
	
	if(connected_cams>(1+camera_offset)){
		big_image=cvCreateImage(cvSize(capture_width,capture_height+capture_height),frame0->depth,frame0->nChannels); 
	}
	else
		if(connected_cams>(0+camera_offset)){
			big_image=cvCreateImage(cvSize(capture_width,capture_height),frame0->depth,frame0->nChannels); 
		}
