int main(int argc, const char** argv) {
	if(argc<2)
		return 1;
	const char* file = argv[1];

	//char file[] = "F:\\video\\CDnet2014\\badWeather\\badWeather\\skating\\input\\*.jpg";
	vector<string> vec = FindAllFile(file,true);
	vector<string>::iterator iter = vec.begin();
	string strPicNameOutput = file;
	vector<string> strPicNameInputSplit;
	split(strPicNameOutput,string("\\"),&strPicNameInputSplit);
	strPicNameInputSplit.erase(strPicNameInputSplit.end() - 1);
	strPicNameInputSplit.erase(strPicNameInputSplit.end() - 1);
	strPicNameInputSplit[strPicNameInputSplit.size() - 2] = "results";
	strPicNameOutput="";
	for (vector<string>::const_iterator iter = strPicNameInputSplit.begin();
		iter != strPicNameInputSplit.end(); iter++){
			strPicNameOutput += *iter;
			strPicNameOutput += "\\";
	}
	cout<<strPicNameOutput<<endl;
	int num = 1;
	char picName[64] = {0};
	strPicNameOutput = strPicNameOutput.append("bin%06d.png");
	IplImage* frame = cvLoadImage((*iter).c_str(),0);
	if(frame == NULL)
		return 1;

	//********************************************************************

    help();
	
    cv::Mat  oCurrSegmMask, oCurrReconstrBGImg,oCurrResizeInputFrame;
   
    oCurrSegmMask.create(cvGetSize(frame),CV_8UC1);
    oCurrReconstrBGImg.create(cvGetSize(frame),CV_8UC1);
    cv::Mat oSequenceROI(cvGetSize(frame),CV_8UC1,cv::Scalar_<uchar>(255)); // for optimal results, pass a constrained ROI to the algorithm (ex: for CDnet, use ROI.bmp)
    BackgroundSubtractorSuBSENSE oBGSAlg;
	cv::Mat oCurrInputFrame(frame);
    oBGSAlg.initialize(oCurrInputFrame,oSequenceROI);
	IplImage* writeImageFg,*writeImageBg;

	//********************************************************************
	while(iter != vec.end()){
		sprintf(picName,strPicNameOutput.c_str(),num);
		cout<<num<<"  "<<*iter<<endl;
		num++;
		frame = cvLoadImage((*iter++).c_str(),0);
		if(frame == NULL)
			break;
		//********************************************************************
		oCurrInputFrame = cv::Mat(frame);
        oBGSAlg(oCurrInputFrame,oCurrSegmMask,100.0/*,double(k<=100)*/); // lower rate in the early frames helps bootstrap the model when foreground is present
        oBGSAlg.getBackgroundImage(oCurrReconstrBGImg);
		/*imshow("input",oCurrInputFrame);
		imshow("segmentation mask",oCurrSegmMask);
		imshow("reconstructed background",oCurrReconstrBGImg);*/
		writeImageFg = &oCurrSegmMask.operator IplImage();
		//********************************************************************
		cvSaveImage(picName,writeImageFg);
		if(frame)
			cvReleaseImage(&frame);
		cvWaitKey(1);
	}
	if(frame)
		cvReleaseImage(&frame);
    return 0;
}