Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use this library to model background? #8

Open
jackyfriend opened this issue Mar 6, 2019 · 2 comments
Open

How to use this library to model background? #8

jackyfriend opened this issue Mar 6, 2019 · 2 comments
Assignees
Labels

Comments

@jackyfriend
Copy link

Hello, this library is just a lbp-like descriptors, but I want to know how to use them to update backgrounds? How to use them together with KDE or MoG? Thank you!

@andrewssobral
Copy link
Collaborator

Hello @jackyfriend ,
We are sorry for our delayed feedback to you.
Yes, this library can be easily integrated with the bgslibrary for background-foreground separation.
You need:

  1. First, capture the frame and apply the desired LBP descriptor to the input image (frame)
  2. Get the texture image (the output image of the LBP descriptor) and use it as input image of your desired background subtraction algorithm.
    You can do it with any background subtraction algorithm of the bgslibrary.
    Please, let us know if it's clear for you.

@andrewssobral
Copy link
Collaborator

@jackyfriend just a bit of code to show you an example:
References:
https://github.com/andrewssobral/bgslibrary/blob/master/Demo.cpp
https://github.com/carolinepacheco/lbplibrary/blob/master/Main.cpp

...
LBP *lbp;
lbp = new XCSLBP;

while (key != 's')
{
  // Capture frame-by-frame
  capture >> img_input;
  frame_counter += 1;

  if (img_input.empty()) break;

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

  cv::Mat img_gray;
  cv::cvtColor(img_input, img_gray, CV_BGR2GRAY);
  imshow("gray", img_gray);

  cv::Mat img_lbp;
  lbp->run(img_gray, img_lbp);
  cv::normalize(img_lbp, img_lbp, 0, 255, cv::NORM_MINMAX, CV_8UC1);
  cv::imshow("lbp", img_lbp);

  cv::Mat img_mask;
  cv::Mat img_bkgmodel;
  try
  {
    // use `img_lbp` instead of `img_input`
    bgs->process(img_lbp, img_mask, img_bkgmodel); // by default, it shows automatically the foreground mask image

    //if(!img_mask.empty())
    //  cv::imshow("Foreground", img_mask);
    //  do something
  }
  catch (std::exception& e)
  {
    std::cout << "Exception occurred" << std::endl;
    std::cout << e.what() << std::endl;
  }

  key = cv::waitKey(33);
}
delete lbp;
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants