Foreground Detector - how do I save/load an existing background model?

3 views (last 30 days)
Hi all, I am trying to come up with a way of saving and re-loading the Gaussian mixture model generated by the vision.ForegroundDetector. Basically I want to be able to:
  • Run the foreground detector
  • Train it on an empty scene to learn the background of the scene
  • SAVE this trained foreground detector so that I can use it in the future without re-training
  • LOAD this trained foreground detector and use it on new data.
Would anyone have any idea how this can be done? I have tried saving and loading a trained foreground detector instance to/from a .mat file, but all this does it copy the public properties, and does not appear to save the trained model. If I can't get this to work I will need to completely change my approach, this is literally the last step in what I am needing to do. Your help would be really, really appreciated.

Accepted Answer

Birju Patel
Birju Patel on 14 Oct 2014
Hi,
You'll need to execute:
feature('SystemObjectsFullSaveLoad',1);
to enable the save/load to work correctly for vision.ForegroundDetector. You should use that command right before you call SAVE on the vision.ForegroundDetector object.
Also, you should save the “locked” object (i.e. do not call release prior to saving). You can execute the isLocked method on the vision.ForegroundDetector object to check if it's locked or not.
Hope that helps.
  3 Comments
Keir Bowater
Keir Bowater on 7 Apr 2018
Birju, has feature('SystemObjectsFullSaveLoad',1) been deprecated in more recent versions of MATLAB? I searched the documentation and couldn't find any new function to allow the same thing. If I run feature('SystemObjectsFullSaveLoad',1);, MATLAB throws an error: Error using feature Feature SystemObjectsFullSaveLoad not found.
Birju Patel
Birju Patel on 16 Apr 2018
Hi Keir,
You don't need to enable the SystemObjectsFullSaveLoad feature any longer. Saving and loading the vision.ForegroundDetector should work without it.
The command errors out now because that feature keyword has been removed.
Birju

Sign in to comment.

More Answers (0)

Categories

Find more on Computer Vision Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!