Click here to load reader

Foreground detection using gaussian mixture models matlab

Embed Size (px)

Citation preview

  • ForegrounddetectionusingGaussianmixturemodels expandallinpage

    collapseall

    vision.ForegroundDetectorSystemobject

    Package:vision

    DescriptionTheForegroundDetectorSystemobjectcomparesacolororgrayscalevideoframetoabackgroundmodeltodeterminewhetherindividualpixelsarepartofthebackgroundortheforeground.Itthencomputesaforegroundmask.Byusingbackgroundsubtraction,youcandetectforegroundobjectsinanimagetakenfromastationarycamera.

    Note:StartinginR2016b,insteadofusingthestepmethodtoperformtheoperationdefinedbytheSystemobject,youcancalltheobjectwitharguments,asifitwereafunction.Forexample,y=step(obj,x)andy=obj(x)performequivalentoperations.

    Constructiondetector=vision.ForegroundDetectorreturnsaforegrounddetectorSystemobject,detector.Givenaseriesofeithergrayscaleorcolorvideoframes,theobjectcomputesandreturnstheforegroundmaskusingGaussianmixturemodels(GMM).

    detector=vision.ForegroundDetector(Name,Value)returnsaforegrounddetectorSystemobject,detector,witheachspecifiedpropertynamesettothespecifiedvalue.NamecanalsobeapropertynameandValueisthecorrespondingvalue.YoucanspecifyseveralnamevaluepairargumentsinanyorderasName1,Value1,,NameN,ValueN.

    CodeGenerationSupport

    SupportsMATLAB Functionblock:No

    UsingMATLABhosttarget:Generatesplatformdependentlibrary

    NotusingMATLABhosttarget:GeneratesportableCcode

    SystemObjectsinMATLABCodeGeneration.

    CodeGenerationSupport,UsageNotes,andLimitations.

    Properties

    Adaptlearningrate,specifiedasthecommaseparatedpairconsistingof'AdaptLearningRate'andalogicalscalar'true'or'false'.ThispropertyenablestheobjecttoadaptthelearningrateduringtheperiodspecifiedbytheNumTrainingFramesproperty.Whenyousetthispropertytotrue,theobjectsetstheLearningRatepropertyto1/(currentframenumber).Whenyousetthispropertytofalse,theLearningRatepropertymustbesetateachtimestep.

    Numberofinitialvideoframesfortrainingbackgroundmodel,specifiedasthecommaseparatedpairconsistingof'NumTrainingFrames'andaninteger.WhenyousettheAdaptLearningRatetofalse,thispropertywillnotbeavailable.

    Learningrateforparameterupdates,specifiedasthecommaseparatedpairconsistingof'LearningRate'andanumericscalar.Specifythelearningratetoadaptmodelparameters.Thispropertycontrolshowquicklythemodeladaptstochangingconditions.Setthispropertyappropriatelytoensurealgorithmstability.

    AdaptLearningRateAdaptlearningrate'true'(default)|'false'

    NumTrainingFramesNumberofinitialvideoframesfortrainingbackgroundmodel150(default)|integer

    LearningRateLearningrateforparameterupdates0.005(default)|numericscalar

    javascript:void(0);javascript:void(0);http://www.mathworks.com/help/vision/gs/use-system-objects-in-matlab-code-generation.htmlhttp://www.mathworks.com/help/vision/ug/code-generation-support-usage-notes-and-limitations-for-functions-classes-and-system-objects.htmlhttp://www.mathworks.com/help/vision/ref/vision.foregrounddetector-class.html#bsy_s0n-5http://www.mathworks.com/help/vision/ref/vision.foregrounddetector-class.html#bsy_s0n-5

  • collapseall

    WhenyousetAdaptLearningRatetotrue,theLearningRatepropertytakeseffectonlyafterthetrainingperiodspecifiedbyNumTrainingFramesisover.

    WhenyousettheAdaptLearningRatetofalse,thispropertywillnotbeavailable.Thispropertyistunable.

    Thresholdtodeterminebackgroundmodel,specifiedasthecommaseparatedpairconsistingof'MinimumBackgroundRatio'andanumericscalar.Setthispropertytorepresenttheminimumoftheaprioriprobabilitiesforpixelstobeconsideredbackgroundvalues.Multimodalbackgroundscannotbehandled,ifthisvalueistoosmall.

    NumberofGaussianmodesinthemixturemodel

    NumberofGaussianmodesinthemixturemodel,specifiedasthecommaseparatedpairconsistingof'NumGaussians'andapositiveinteger.Typicallythisvalueis3,4or5.Setthisvalueto3orgreatertobeabletomodelmultiplebackgroundmodes.

    Initialmixturemodelvariance,specifiedasthecommaseparatedpairconsistingof'InitialVariance'andasanumericscalarorthe'Auto'charactervector.

    ImageDataType InitialVariance

    double/single (30/255)^2

    uint8 30^2

    Thispropertyappliestoallcolorchannelsforcolorinputs.

    Methodsclone Createforegrounddetectorwithsamepropertyvalues

    getNumInputs Numberofexpectedinputstostepmethod

    getNumOutputs Numberofoutputsfromstepmethod

    isLocked Lockedstatusforinputattributesandnontunableproperties

    release Allowpropertyvalueandinputcharacteristicschanges

    reset ResettheGMMmodeltoitsinitialstate

    step DetectforegroundusingGaussianmixturemodels

    Examples

    Createsystemobjectstoreadfile.

    videoSource=vision.VideoFileReader('viptraffic.avi',...'ImageColorSpace','Intensity','VideoOutputDataType','uint8');

    Settingframesto5becauseitisashortvideo.Setinitialstandarddeviation.

    MinimumBackgroundRatioThresholdtodeterminebackgroundmodel0.7(default)|numericscalar

    NumGaussiansNumberofGaussianmodesinthemixturemodel5(default)|positiveinteger

    InitialVarianceInitialmixturemodelvariance'Auto'(default)|numericscalar

    DetectMovingCarsInVideo

    OpenScript

    javascript:void(0);http://www.mathworks.com/help/vision/ref/vision.foregrounddetector-class.html#bsy_s0n-5http://www.mathworks.com/help/vision/ref/vision.foregrounddetector-class.html#bsy_s0n-5http://www.mathworks.com/help/vision/ref/vision.foregrounddetector-class.html#bsy_s0n-5http://www.mathworks.com/help/vision/ref/vision.foregrounddetector.clone.htmlhttp://www.mathworks.com/help/vision/ref/vision.foregrounddetector.getnuminputs.htmlhttp://www.mathworks.com/help/vision/ref/vision.foregrounddetector.getnumoutputs.htmlhttp://www.mathworks.com/help/vision/ref/vision.foregrounddetector.islocked.htmlhttp://www.mathworks.com/help/vision/ref/vision.foregrounddetector.release.htmlhttp://www.mathworks.com/help/vision/ref/vision.foregrounddetector.reset.htmlhttp://www.mathworks.com/help/vision/ref/vision.foregrounddetector.step.htmlmatlab:openExample('vision/TrackCarsExample')

  • detector=vision.ForegroundDetector(...'NumTrainingFrames',5,...'InitialVariance',30*30);

    Performblobanalysis.

    blob=vision.BlobAnalysis(...'CentroidOutputPort',false,'AreaOutputPort',false,...'BoundingBoxOutputPort',true,...'MinimumBlobAreaSource','Property','MinimumBlobArea',250);

    Insertaborder.

    shapeInserter=vision.ShapeInserter('BorderColor','White');

    Playresults.Drawboundingboxesaroundcars.

    videoPlayer=vision.VideoPlayer();while~isDone(videoSource)frame=step(videoSource);fgMask=step(detector,frame);bbox=step(blob,fgMask);out=step(shapeInserter,frame,bbox);step(videoPlayer,out);end

    Releaseobjects.

    release(videoPlayer);release(videoSource);

  • References[1]P.Kaewtrakulpong,R.Bowden,AnImprovedAdaptiveBackgroundMixtureModelforRealtimeTrackingwithShadowDetection,InProc.2ndEuropeanWorkshoponAdvancedVideoBasedSurveillanceSystems,AVBS01,VIDEOBASEDSURVEILLANCESYSTEMS:ComputerVisionandDistributedProcessing(September2001)

    [2]Stauffer,C.andGrimson,W.E.L,AdaptiveBackgroundMixtureModelsforRealTimeTracking,ComputerVisionandPatternRecognition,IEEEComputerSocietyConferenceon,Vol.2(06August1999),pp.2246252Vol.2.

    MoreAbout