int main(int argc, char **argv)
{
  std::cout << "Using OpenCV " << CV_MAJOR_VERSION << "." << CV_MINOR_VERSION << "." << CV_SUBMINOR_VERSION << std::endl;

  /* Open video file */
  CvCapture *capture = 0;
  capture = cvCaptureFromAVI("dataset/jakomali.mp4"); //video.avi
  if(!capture){
    std::cerr << "Cannot open video!" << std::endl;
    return 1;
  }
  
  /* Background Subtraction Algorithm */
  IBGS *bgs;
  bgs = new PixelBasedAdaptiveSegmenter;
  
  /* Blob Tracking Algorithm */
  cv::Mat img_blob;
  BlobTracking* blobTracking;
  blobTracking = new BlobTracking;

  /* Vehicle Counting Algorithm */
  VehicleCouting* vehicleCouting;
  vehicleCouting = new VehicleCouting;

  std::cout << "Press 'q' to quit..." << std::endl;
  int key = 0;
  IplImage *frame;
  while(key != 'q')
  {
    frame = cvQueryFrame(capture);
    if(!frame) break;

    cv::Mat img_input(frame);
    //cv::imshow("Input", img_input); // input video

    cv::Mat img_mask;
    bgs->process(img_input, img_mask);
    
    if(!img_mask.empty())
    {
      // Perform blob tracking
      blobTracking->process(img_input, img_mask, img_blob);

      // Perform vehicle counting
      vehicleCouting->setInput(img_blob);
      vehicleCouting->setTracks(blobTracking->getTracks());
      vehicleCouting->process();
    }

    key = cvWaitKey(1);
  }

  delete vehicleCouting;
  delete blobTracking;
  delete bgs;

  cvDestroyAllWindows();
  cvReleaseCapture(&capture);
  
  return 0;
}
int main(int argc, char **argv)
{
	CvCapture *capture = 0;
	capture = cvCaptureFromAVI("./dataset/video.avi");
	if(!capture)
	{
		std::cerr << "Cannot open video!" << std::endl;
		return 1;
	}
  
	cascade = (CvHaarClassifierCascade*) cvLoad("cars3.xml");
	storage = cvCreateMemStorage(0);
	assert(cascade && storage && capture);

	ofstream myfile;
	myfile.open ("Statistics.dat");
	
	int resize_factor = 100; // 50% of original image
	int sec=0;				 // Storing time temporarily 
	char buff[DTTMSZ];		 // Buffer of size 10 for storing seconds

	sec=atoi(getDtTm(buff)); // Storing corrent time

	IplImage *frame_aux = cvQueryFrame(capture);
	IplImage *frame = cvCreateImage(cvSize((int)((frame_aux->width*resize_factor)/100) , (int)((frame_aux->height*resize_factor)/100)), frame_aux->depth, frame_aux->nChannels);
  
	// Initializing Background Subtraction Methods
	IBGS *bgs;
	bgs = new PixelBasedAdaptiveSegmenter;
    
	// Initializing Blob Tracking 
	cv::Mat img_blob;
	BlobTracking* blobTracking;
	blobTracking = new BlobTracking;

	// Initializing Vehicle Counting Algorithm
	VehicleCouting* vehicleCouting;
	vehicleCouting = new VehicleCouting;

	int key = 0;
	while(key != 'q')
	{
		frame_aux = cvQueryFrame(capture);
		if(!frame_aux) break;

		cvResize(frame_aux, frame);

		cv::Mat img_input(frame);
		cv::imshow("input", img_input);

		// bgs->process(...) method internally shows the foreground mask image
		cv::Mat img_mask;
		bgs->process(img_input, img_mask);
    
		if(!img_mask.empty())
		{
			// Blob tracking each frame
			blobTracking->process(img_input, img_mask, img_blob);

			// Vehicle counting in each frame
			vehicleCouting->setInput(img_blob);
			vehicleCouting->setTracks(blobTracking->getTracks());
			vehicleCouting->process();
		
			// Haar Classification
			detect(frame);

			//Writing data to a file
			myfile <<(((atoi(getDtTm(buff))-sec)< 0) ?(atoi(getDtTm(buff))+ 60 -sec):(atoi(getDtTm(buff))-sec))<< "\t" <<(vehicleCouting->countAB +vehicleCouting->countBA) << "\n" ;
		}

		key = cvWaitKey(1);
	}

	delete vehicleCouting;
	delete blobTracking;
	delete bgs;

	cvDestroyAllWindows();
	cvReleaseCapture(&capture);
	cvReleaseHaarClassifierCascade(&cascade);
	cvReleaseMemStorage(&storage);
	cvReleaseImage(&frame);
	myfile.close();

	return 0;
}
Ejemplo n.º 3
0
int mainDemo2()
{
  std::cout << "Using OpenCV " << CV_MAJOR_VERSION << "." << CV_MINOR_VERSION << "." << CV_SUBMINOR_VERSION << std::endl;

  /* Background Subtraction Methods */
  IBGS *bgs;

  /*** Default Package ***/
  bgs = new FrameDifferenceBGS;
//  bgs = new StaticFrameDifferenceBGS;
  //bgs = new WeightedMovingMeanBGS;
  //bgs = new WeightedMovingVarianceBGS;
  //bgs = new MixtureOfGaussianV1BGS;
  //bgs = new MixtureOfGaussianV2BGS;
  //bgs = new AdaptiveBackgroundLearning;
  //bgs = new AdaptiveSelectiveBackgroundLearning;
  //bgs = new GMG;
  
  /*** DP Package (thanks to Donovan Parks) ***/
  //bgs = new DPAdaptiveMedianBGS;
  //bgs = new DPGrimsonGMMBGS;
  //bgs = new DPZivkovicAGMMBGS;
  //bgs = new DPMeanBGS;
  //bgs = new DPWrenGABGS;
  //bgs = new DPPratiMediodBGS;
  //bgs = new DPEigenbackgroundBGS;
  //bgs = new DPTextureBGS;

  /*** TB Package (thanks to Thierry Bouwmans, Fida EL BAF and Zhenjie Zhao) ***/
  //bgs = new T2FGMM_UM;
  //bgs = new T2FGMM_UV;
  //bgs = new T2FMRF_UM;
  //bgs = new T2FMRF_UV;
  //bgs = new FuzzySugenoIntegral;
  //bgs = new FuzzyChoquetIntegral;

  /*** JMO Package (thanks to Jean-Marc Odobez) ***/
  //bgs = new MultiLayerBGS;

  /*** PT Package (thanks to Martin Hofmann, Philipp Tiefenbacher and Gerhard Rigoll) ***/
  //bgs = new PixelBasedAdaptiveSegmenter;

  /*** LB Package (thanks to Laurence Bender) ***/
  //bgs = new LBSimpleGaussian;
  //bgs = new LBFuzzyGaussian;
  //bgs = new LBMixtureOfGaussians;
  //bgs = new LBAdaptiveSOM;
  //bgs = new LBFuzzyAdaptiveSOM;

  /*** LBP-MRF Package (thanks to Csaba Kertész) ***/
  //bgs = new LbpMrf;

  /*** AV Package (thanks to Lionel Robinault and Antoine Vacavant) ***/
  //bgs = new VuMeter;

  /*** EG Package (thanks to Ahmed Elgammal) ***/
  //bgs = new KDE;
  
  /*** DB Package (thanks to Domenico Daniele Bloisi) ***/
  //bgs = new IndependentMultimodalBGS;

  /*** SJN Package (thanks to SeungJong Noh) ***/
  //bgs = new SJN_MultiCueBGS;

  /*** BL Package (thanks to Benjamin Laugraud) ***/
  //bgs = new SigmaDeltaBGS;

  /*** PL Package (thanks to Pierre-Luc) ***/
//  bgs = new SuBSENSEBGS();
  //bgs = new LOBSTERBGS();

  int frameNumber = 1;
  int key = 0;
  cvNamedWindow("input",0);
  while(key != 'q')
  {

    std::stringstream ss;
    ss << frameNumber;
    std::string fileName = "../qt_bgslibrary/frames/" + ss.str() + ".png";
    std::cout << "reading " << fileName << std::endl;

    cv::Mat img_input = cv::imread(fileName, CV_LOAD_IMAGE_COLOR);
    
    if (img_input.empty())
      break;

    cv::imshow("input", img_input);

    cv::Mat img_mask;
    cv::Mat img_bkgmodel;
    std::cout<<" process start ..............."<<std::endl;
    bgs->process(img_input, img_mask, img_bkgmodel); // by default, it shows automatically the foreground mask image
    std::cout<<" process end ..............."<<std::endl;
    //if(!img_mask.empty())
    //  cv::imshow("Foreground", img_mask);
    //  do something
    
    key = cvWaitKey(33);
    frameNumber++;
  }
  cvWaitKey(0);
  delete bgs;

  cvDestroyAllWindows();

  return 0;
}
Ejemplo n.º 4
0
int main(int argc, char **argv)
{
  CvCapture *capture = 0;
  int resize_factor = 100;

  if(argc > 1)
  {
    std::cout << "Openning: " << argv[1] << std::endl;
    capture = cvCaptureFromAVI(argv[1]);
  }
  else
  {
    capture = cvCaptureFromCAM(0);
    resize_factor = 50; // set size = 50% of original image
  }

  if(!capture)
  {
    std::cerr << "Cannot initialize video!" << std::endl;
    return 1;
  }
  
  IplImage *frame_aux = cvQueryFrame(capture);
  IplImage *frame = cvCreateImage(cvSize((int)((frame_aux->width*resize_factor)/100) , (int)((frame_aux->height*resize_factor)/100)), frame_aux->depth, frame_aux->nChannels);
  cvResize(frame_aux, frame);

  /* Background Subtraction Methods */
  IBGS *bgs;

  /*** Default Package ***/
  bgs = new FrameDifferenceBGS;
  //bgs = new StaticFrameDifferenceBGS;
  //bgs = new WeightedMovingMeanBGS;
  //bgs = new WeightedMovingVarianceBGS;
  //bgs = new MixtureOfGaussianV1BGS;
  //bgs = new MixtureOfGaussianV2BGS;
  //bgs = new AdaptiveBackgroundLearning;
  //bgs = new GMG;
  
  /*** DP Package (adapted from Donovan Parks) ***/
  //bgs = new DPAdaptiveMedianBGS;
  //bgs = new DPGrimsonGMMBGS;
  //bgs = new DPZivkovicAGMMBGS;
  //bgs = new DPMeanBGS;
  //bgs = new DPWrenGABGS;
  //bgs = new DPPratiMediodBGS;
  //bgs = new DPEigenbackgroundBGS;
  //bgs = new DPTextureBGS;

  /*** TB Package (adapted from Thierry Bouwmans) ***/
  //bgs = new T2FGMM_UM;
  //bgs = new T2FGMM_UV;
  //bgs = new T2FMRF_UM;
  //bgs = new T2FMRF_UV;
  //bgs = new FuzzySugenoIntegral;
  //bgs = new FuzzyChoquetIntegral;

  /*** JMO Package (adapted from Jean-Marc Odobez) ***/
  //bgs = new MultiLayerBGS;

  /*** PT Package (adapted from Hofmann) ***/
  //bgs = new PixelBasedAdaptiveSegmenter;

  /*** LB Package (adapted from Laurence Bender) ***/
  //bgs = new LBSimpleGaussian;
  //bgs = new LBFuzzyGaussian;
  //bgs = new LBMixtureOfGaussians;
  //bgs = new LBAdaptiveSOM;
  //bgs = new LBFuzzyAdaptiveSOM;

  /*** LBP-MRF Package (adapted from Csaba Kertész) ***/
  //bgs = new LbpMrf;

  /*** AV Package (adapted from Antoine Vacavant) ***/
  //bgs = new VuMeter;

  /*** EG Package (adapted from Ahmed Elgammal) ***/
  //bgs = new KDE;

  int key = 0;
  while(key != 'q')
  {
    frame_aux = cvQueryFrame(capture);
    if(!frame_aux) break;

    cvResize(frame_aux, frame);
    
    cv::Mat img_input(frame);
    cv::imshow("input", img_input);

    cv::Mat img_mask;
    cv::Mat img_bkgmodel;
    bgs->process(img_input, img_mask, img_bkgmodel); // automatically shows the foreground mask image
    
    //if(!img_mask.empty())
    //  do something
    
    key = cvWaitKey(33);
  }

  delete bgs;

  cvDestroyAllWindows();
  cvReleaseCapture(&capture);
  
  return 0;
}
Ejemplo n.º 5
0
void MainWindow::on_pushButton_3_clicked()
{
    //run programe
    IBGS *bgs;
    int i=ui->comboBox->currentIndex();
    qDebug()<<"select bgs "<<i;
    /*** Default Package ***/
    if(i==0) bgs = new FrameDifferenceBGS;
    if(i==1) bgs = new StaticFrameDifferenceBGS;
    if(i==2) bgs = new WeightedMovingMeanBGS;
    if(i==3) bgs = new WeightedMovingVarianceBGS;
    if(i==4) bgs = new MixtureOfGaussianV1BGS;
    if(i==5) bgs = new MixtureOfGaussianV2BGS;
    if(i==6) bgs = new AdaptiveBackgroundLearning;
    if(i==7) bgs = new AdaptiveSelectiveBackgroundLearning;
    if(i==8) bgs = new GMG;

    /*** DP Package (thanks to Donovan Parks) ***/
    if(i==9) bgs = new DPAdaptiveMedianBGS;
    if(i==10) bgs = new DPGrimsonGMMBGS;
    if(i==11) bgs = new DPZivkovicAGMMBGS;
    if(i==12) bgs = new DPMeanBGS;
    if(i==13) bgs = new DPWrenGABGS;
    if(i==14) bgs = new DPPratiMediodBGS;
    if(i==15) bgs = new DPEigenbackgroundBGS;
    if(i==16) bgs = new DPTextureBGS;

    /*** TB Package (thanks to Thierry Bouwmans, Fida EL BAF and Zhenjie Zhao) ***/
    if(i==17) bgs = new T2FGMM_UM;
    if(i==18) bgs = new T2FGMM_UV;
    if(i==19) bgs = new T2FMRF_UM;
    if(i==20) bgs = new T2FMRF_UV;
    if(i==21) bgs = new FuzzySugenoIntegral;
    if(i==22) bgs = new FuzzyChoquetIntegral;

    /*** JMO Package (thanks to Jean-Marc Odobez) ***/
    if(i==23) bgs = new MultiLayerBGS;

    /*** PT Package (thanks to Martin Hofmann, Philipp Tiefenbacher and Gerhard Rigoll) ***/
    //       if(i==24) bgs = new PixelBasedAdaptiveSegmenter;

    /*** LB Package (thanks to Laurence Bender) ***/
    if(i==25) bgs = new LBSimpleGaussian;
    if(i==26) bgs = new LBFuzzyGaussian;
    if(i==27) bgs = new LBMixtureOfGaussians;
    if(i==28) bgs = new LBAdaptiveSOM;
    if(i==29) bgs = new LBFuzzyAdaptiveSOM;

    /*** LBP-MRF Package (thanks to Csaba Kertész) ***/
    if(i==30) bgs = new LbpMrf;

    /*** AV Package (thanks to Lionel Robinault and Antoine Vacavant) ***/
    if(i==31) bgs = new VuMeter;

    /*** EG Package (thanks to Ahmed Elgammal) ***/
    if(i==32) bgs = new KDE;

    /*** DB Package (thanks to Domenico Daniele Bloisi) ***/
    if(i==33) bgs = new IndependentMultimodalBGS;

    /*** SJN Package (thanks to SeungJong Noh) ***/
    if(i==34) bgs = new SJN_MultiCueBGS;

    /*** BL Package (thanks to Benjamin Laugraud) ***/
    if(i==35) bgs = new SigmaDeltaBGS;

    /*** PL Package (thanks to Pierre-Luc) ***/
    if(i==36) bgs = new SuBSENSEBGS();
    if(i==37) bgs = new LOBSTERBGS();

    int temporalRoi[2];
    temporalRoi[0]=ui->spinBox->value();
    temporalRoi[1]=ui->spinBox_2->value();
    qDebug()<<"from to: "<<temporalRoi[0]<<" "<<temporalRoi[1];

    QString prefix=ui->lineEdit_3->text();
    QString suffix=ui->comboBox_2->currentText();
    int format=ui->spinBox_3->value();

    qDebug()<<"prefix "<<prefix;
    qDebug()<<"suffix "<<suffix;
    qDebug()<<"format "<<format;

    QString CDNetDir=ui->lineEdit->text();
    QString VideoPath=ui->lineEdit_2->text();

    qDebug()<<"CDNet Dir "<<CDNetDir;
    qDebug()<<"VideoPath "<<VideoPath;

    if(CDNetDir.isEmpty())   return;

    int frameNumber = temporalRoi[0];
    int key = 0;
    cvNamedWindow("input",0);
    QString fileName;
    //       QString qformat=QString("%%1d").arg(format);
    //       qDebug()<<"qformat "<<qformat;
    //       const char *cformat=qformat.toStdString().data();

    QString numstr;
    QTextStream out(&numstr);
    out.setFieldAlignment(QTextStream::AlignRight);
    out.setFieldWidth(format);
    out.setPadChar(QLatin1Char('0'));
    out<<frameNumber;

    //        QString numstr=QString::sprintf(cformat,frameNumber);
    fileName=CDNetDir+"/"+prefix+numstr+suffix;
    qDebug()<<"fileName "<<fileName;

    settings->setValue("/Folder/CDNetDir",CDNetDir);
    settings->setValue("/Folder/from",temporalRoi[0]);
    settings->setValue("/Folder/to",temporalRoi[1]);
    settings->setValue("/Folder/prefix",prefix);
    settings->setValue("/Folder/suffix",suffix);

    settings->sync();

    while(key != 'q')
    {
        if(frameNumber>temporalRoi[1])  break;

        out.flush();
        numstr.clear();
        out<<frameNumber;
        fileName=CDNetDir+"/"+prefix+numstr+suffix;
        qDebug()<<frameNumber<<" fileName "<<fileName;

        std::string filename =fileName.toStdString();
        std::cout << "reading " << filename << std::endl;

        cv::Mat img_input = cv::imread(filename, CV_LOAD_IMAGE_COLOR);

        if (img_input.empty())
            break;

        cv::imshow("input", img_input);

        cv::Mat img_mask;
        cv::Mat img_bkgmodel;
        std::cout<<" process start ..............."<<std::endl;
        bgs->process(img_input, img_mask, img_bkgmodel); // by default, it shows automatically the foreground mask image
        std::cout<<" process end ..............."<<std::endl;
        //if(!img_mask.empty())
        //  cv::imshow("Foreground", img_mask);
        //  do something

        key = cvWaitKey(33);
        frameNumber++;
    }
    delete bgs;
    cvDestroyAllWindows();

    qDebug()<<"exit ..................";
}
Ejemplo n.º 6
0
int main(int argc, char **argv)
{
  std::cout << "Using OpenCV " << CV_MAJOR_VERSION << "." << CV_MINOR_VERSION << "." << CV_SUBMINOR_VERSION << std::endl;

  CvCapture *capture = 0;
  int resize_factor = 100;

  if(argc > 1)
  {
    std::cout << "Openning: " << argv[1] << std::endl;
    capture = cvCaptureFromAVI(argv[1]);
  }
  else
  {
    capture = cvCaptureFromCAM(0);
    resize_factor = 50; // set size = 50% of original image
  }

  if(!capture)
  {
    std::cerr << "Cannot initialize video!" << std::endl;
    return -1;
  }
  
  IplImage *frame_aux = cvQueryFrame(capture);
  IplImage *frame = cvCreateImage(cvSize((int)((frame_aux->width*resize_factor)/100) , (int)((frame_aux->height*resize_factor)/100)), frame_aux->depth, frame_aux->nChannels);
  cvResize(frame_aux, frame);

  /* Background Subtraction Methods */
  IBGS *bgs;

  /*** Default Package ***/
  bgs = new FrameDifferenceBGS;
  //bgs = new StaticFrameDifferenceBGS;
  //bgs = new WeightedMovingMeanBGS;
  //bgs = new WeightedMovingVarianceBGS;
  //bgs = new MixtureOfGaussianV1BGS;
  //bgs = new MixtureOfGaussianV2BGS;
  //bgs = new AdaptiveBackgroundLearning;
  //bgs = new AdaptiveSelectiveBackgroundLearning;
  //bgs = new GMG;
  
  /*** DP Package (thanks to Donovan Parks) ***/
  //bgs = new DPAdaptiveMedianBGS;
  //bgs = new DPGrimsonGMMBGS;
  //bgs = new DPZivkovicAGMMBGS;
  //bgs = new DPMeanBGS;
  //bgs = new DPWrenGABGS;
  //bgs = new DPPratiMediodBGS;
  //bgs = new DPEigenbackgroundBGS;
  //bgs = new DPTextureBGS;

  /*** TB Package (thanks to Thierry Bouwmans, Fida EL BAF and Zhenjie Zhao) ***/
  //bgs = new T2FGMM_UM;
  //bgs = new T2FGMM_UV;
  //bgs = new T2FMRF_UM;
  //bgs = new T2FMRF_UV;
  //bgs = new FuzzySugenoIntegral;
  //bgs = new FuzzyChoquetIntegral;

  /*** JMO Package (thanks to Jean-Marc Odobez) ***/
  //bgs = new MultiLayerBGS;

  /*** PT Package (thanks to Martin Hofmann, Philipp Tiefenbacher and Gerhard Rigoll) ***/
  //bgs = new PixelBasedAdaptiveSegmenter;

  /*** LB Package (thanks to Laurence Bender) ***/
  //bgs = new LBSimpleGaussian;
  //bgs = new LBFuzzyGaussian;
  //bgs = new LBMixtureOfGaussians;
  //bgs = new LBAdaptiveSOM;
  //bgs = new LBFuzzyAdaptiveSOM;

  /*** LBP-MRF Package (thanks to Csaba Kertész) ***/
  //bgs = new LbpMrf;

  /*** AV Package (thanks to Lionel Robinault and Antoine Vacavant) ***/
  //bgs = new VuMeter;

  /*** EG Package (thanks to Ahmed Elgammal) ***/
  //bgs = new KDE;
  
  /*** DB Package (thanks to Domenico Daniele Bloisi) ***/
  //bgs = new IndependentMultimodalBGS;

  /*** SJN Package (thanks to SeungJong Noh) ***/
  //bgs = new SJN_MultiCueBGS;

  /*** BL Package (thanks to Benjamin Laugraud) ***/
  //bgs = new SigmaDeltaBGS;

  int key = 0;
  while(key != 'q')
  {
    frame_aux = cvQueryFrame(capture);
    if(!frame_aux) break;

    cvResize(frame_aux, frame);
    
    cv::Mat img_input(frame);
    cv::imshow("input", img_input);

    cv::Mat img_mask;
    cv::Mat img_bkgmodel;
    bgs->process(img_input, img_mask, img_bkgmodel); // by default, it shows automatically the foreground mask image
    
    //if(!img_mask.empty())
    //  cv::imshow("Foreground", img_mask);
    //  do something
    
    key = cvWaitKey(33);
  }

  delete bgs;

  cvDestroyAllWindows();
  cvReleaseCapture(&capture);

  return 0;
}
Ejemplo n.º 7
0
void start(VideoFolder videoFolder, uint bgsMethodId){
	cout << "staring bgs..." << endl;
	const imgRange range = videoFolder.getRange();
	//注意:一定要略微扩大处理范围
	const uint fromIdx = range.first - 10;;
	const uint toIdx = range.second;
	const string runTimePath = videoFolder.runTimeFile();
	
	cout << "imgRange From " << fromIdx << " to " << toIdx << endl;

	/* Background Subtraction Methods */
	IBGS *bgs;
	switch(bgsMethodId){

  /*** Default Package ***/
        case 1:
            bgs = new FrameDifferenceBGS;
            break;
        case 2:
            bgs = new StaticFrameDifferenceBGS;break;
        case 3:
            bgs = new WeightedMovingMeanBGS;break;
        case 4:
            bgs = new WeightedMovingVarianceBGS;break;
        case 5:
            bgs = new MixtureOfGaussianV1BGS;break;
        case 6:
            bgs = new MixtureOfGaussianV2BGS;break;
        case 7:
            bgs = new AdaptiveBackgroundLearning;break;
        case 8:
            bgs = new AdaptiveSelectiveBackgroundLearning;break;
        case 9:
            bgs = new GMG;break;

      /*** DP Package (thanks to Donovan Parks) ***/
        case 10:
            bgs = new DPAdaptiveMedianBGS;break;
        case 11:
            bgs = new DPGrimsonGMMBGS;break;
        case 12:
            bgs = new DPZivkovicAGMMBGS;break;
        case 13:
            bgs = new DPMeanBGS;break;
        case 14:
            bgs = new DPWrenGABGS;break;
        case 15:
            bgs = new DPPratiMediodBGS;break;
        case 16:
            bgs = new DPEigenbackgroundBGS;break;
        case 17:
            bgs = new DPTextureBGS;break;

      /*** TB Package (thanks to Thierry Bouwmans, Fida EL BAF and Zhenjie Zhao) ***/
        case 18:
            bgs = new T2FGMM_UM;break;
        case 19:
            bgs = new T2FGMM_UV;break;
        case 20:
            bgs = new T2FMRF_UM;break;
        case 21:
            bgs = new T2FMRF_UV;break;
        case 22:
            bgs = new FuzzySugenoIntegral;break;
        case 23:
            bgs = new FuzzyChoquetIntegral;break;

      /*** JMO Package (thanks to Jean-Marc Odobez) ***/
        case 24:
            bgs = new MultiLayerBGS;break;

      /*** PT Package (thanks to Martin Hofmann, Philipp Tiefenbacher and Gerhard Rigoll) ***/
        //case 25:
          //  bgs = new PixelBasedAdaptiveSegmenter;break;

      /*** LB Package (thanks to Laurence Bender) ***/
        case 25:
            bgs = new LBSimpleGaussian;break;
        case 26:
            bgs = new LBFuzzyGaussian;break;
        case 27:
            bgs = new LBMixtureOfGaussians;break;
        case 28:
            bgs = new LBAdaptiveSOM;break;
        case 29:
            bgs = new LBFuzzyAdaptiveSOM;break;

      /*** LBP-MRF Package (thanks to Csaba Kertész) ***/
        case 30:
            bgs = new LbpMrf;break;

      /*** AV Package (thanks to Lionel Robinault and Antoine Vacavant) ***/
        case 31:
            bgs = new VuMeter;break;

      /*** EG Package (thanks to Ahmed Elgammal) ***/
        case 32:
            bgs = new KDE;break;

      /*** DB Package (thanks to Domenico Daniele Bloisi) ***/
        case 33:
            bgs = new IndependentMultimodalBGS;break;

      /*** SJN Package (thanks to SeungJong Noh) ***/
        case 34:
            bgs = new SJN_MultiCueBGS;break;

      /*** BL Package (thanks to Benjamin Laugraud) ***/
        case 35:
            bgs = new SigmaDeltaBGS;break;

      /*** PL Package (thanks to Pierre-Luc) ***/
        case 36:
            bgs = new SuBSENSEBGS();break;
        case 37:
            bgs = new LOBSTERBGS();break;
        default:break;
    }

	ull allTime = 0;

	for (uint t = fromIdx; t <= toIdx; ++t){
		cout << "imgIdx " << t << endl;
		//bgs(videoFolder.inputFrame(t), videoFolder.binaryFrame(t), videoFolder.bgmodelFrame(t), bgsMethodId);
		const string imageFromPath = videoFolder.inputFrame(t);
		const string imageToPath = videoFolder.binaryFrame(t);
		const string bgmodelPath = videoFolder.bgmodelFrame(t);

		if(bgsMethodId < 1 || bgsMethodId > 37){
  		cerr << "bgsMethodId not found!" << endl;
  		return;
  		}

	  	cout << "bgsMethodId is " << bgsMethodId << endl;
	  	cout << "imageFromPath is " << imageFromPath << endl;
	  	cout << "imageToPath is " << imageToPath << endl;
	  	cout << "bgmodelPath is " << bgmodelPath << endl;

	 	cv::Mat img_input;
	 	cv::Mat img_mask;
	 	cv::Mat img_bgmodel;

		img_input = cv::imread(imageFromPath);

		cout << "starting bgs process..." << endl;
		
		ull begin = getSystemTime();
		bgs->process(img_input, img_mask, img_bgmodel); // by default, it shows automatically the foreground mask image
		ull end = getSystemTime();

		allTime += (end - begin);		
  
		cout << "single process done!" << endl; 

		//if(!img_mask.empty())
		//	cv::imshow("Foreground", img_mask);

		 //  do something
		    
		if(!img_mask.empty()){
		    cv::imwrite(imageToPath,img_mask);
		    cout << "save mask..." << endl;
		}


		if(!img_bgmodel.empty()){
		    cv::imwrite(bgmodelPath,img_bgmodel);
		    cout << "save bgmodel" << endl;
	    }
	}
	
	double averageTime = (allTime*1.0) / toIdx;
	ofstream ofile(runTimePath, ios::out);
	ofile << averageTime;
	ofile.close();
}