andrewssobral/bgslibrary

short learning background first, without updating that

Open

#185 opened on Jul 27, 2020

View on GitHub
 (2 comments) (0 reactions) (1 assignee)C++ (738 forks)github user discovery
help wantedquestion

Repository metrics

Stars
 (2,270 stars)
PR merge metrics
 (PR metrics pending)

Description

Hi, thank for your amazing lib first

I have a factory rail that at first moments (first 10 second) i want to learn background and then extract objects on it, for my video multicue was good but i found that it is updating background model in each frame is there any other algorithm that just build bkg model base on first seconds?

I'm using c++, this is process method of multicue, i have commented UpdateModel_Par(); but it made no difference

void MultiCue::process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &img_bgmodel)
{
  init(img_input, img_output, img_bgmodel);

  //--STep1: Background Modeling--//
  //IplImage* frame = &IplImage(img_input);
  IplImage* frame = new IplImage(img_input);
  IplImage* result_image = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 3);
  cvSetZero(result_image);
  if (g_iFrameCount <= g_iTrainingPeriod) {
    BackgroundModeling_Par(frame);
    g_iFrameCount++;
  }
  //--Step2: Background Subtraction--//
  else {
    g_bForegroundMapEnable = FALSE;

    ForegroundExtraction(frame);
    UpdateModel_Par();

    //Get BGS Results
    GetForegroundMap(result_image, NULL);
  }
  delete frame;

  img_background = cv::Mat::zeros(img_input.size(), img_input.type());
  img_foreground = cv::cvarrToMat(result_image, TRUE);
  cvReleaseImage(&result_image);

#ifndef MEX_COMPILE_FLAG
  if (showOutput)
    cv::imshow(algorithmName + "_FG", img_foreground);
#endif

  img_foreground.copyTo(img_output);
  img_background.copyTo(img_bgmodel);

  firstTime = false;
}

Contributor guide