opencv-0.0.2.1: Haskell binding to OpenCV-3.x

Safe HaskellNone
LanguageHaskell2010

OpenCV.Video.MotionAnalysis

Contents

Synopsis

BackgroundSubtractor

class BackgroundSubtractor a where Source #

Minimal complete definition

bgSubApply, getBackgroundImage

Methods

bgSubApply Source #

Arguments

:: PrimMonad m 
=> a (PrimState m) 
-> Double

The value between 0 and 1 that indicates how fast the background model is learnt. Negative parameter value makes the algorithm to use some automatically chosen learning rate. 0 means that the background model is not updated at all, 1 means that the background model is completely reinitialized from the last frame.

-> Mat (S [h, w]) channels depth

Next video frame.

-> m (Mat (S [h, w]) (S 1) (S Word8))

The output foreground mask as an 8-bit binary image.

getBackgroundImage Source #

Arguments

:: PrimMonad m 
=> a (PrimState m) 
-> m (Mat (S [h, w]) channels depth)

The output background image.

Instances

BackgroundSubtractor (BackgroundSubtractorMOG2 *) Source # 

Methods

bgSubApply :: PrimMonad m => BackgroundSubtractorMOG2 * (PrimState m) -> Double -> Mat (S [DS Nat] ((DS Nat ': h) ((DS Nat ': w) [DS Nat]))) channels depth -> m (Mat (S [DS Nat] ((DS Nat ': h) ((DS Nat ': w) [DS Nat]))) (S Nat 1) (S * Word8)) Source #

getBackgroundImage :: PrimMonad m => BackgroundSubtractorMOG2 * (PrimState m) -> m (Mat (S [DS Nat] ((DS Nat ': h) ((DS Nat ': w) [DS Nat]))) channels depth) Source #

BackgroundSubtractor (BackgroundSubtractorKNN *) Source # 

Methods

bgSubApply :: PrimMonad m => BackgroundSubtractorKNN * (PrimState m) -> Double -> Mat (S [DS Nat] ((DS Nat ': h) ((DS Nat ': w) [DS Nat]))) channels depth -> m (Mat (S [DS Nat] ((DS Nat ': h) ((DS Nat ': w) [DS Nat]))) (S Nat 1) (S * Word8)) Source #

getBackgroundImage :: PrimMonad m => BackgroundSubtractorKNN * (PrimState m) -> m (Mat (S [DS Nat] ((DS Nat ': h) ((DS Nat ': w) [DS Nat]))) channels depth) Source #

Background subtractors

data BackgroundSubtractorKNN s Source #

Example:

carAnim :: Animation (ShapeT [240, 320]) ('S 3) ('S Word8)
carAnim = carOverhead

mog2Anim :: IO (Animation (ShapeT [240, 320]) ('S 3) ('S Word8))
mog2Anim = do
    mog2 <- newBackgroundSubtractorMOG2 Nothing Nothing Nothing
    forM carOverhead $ (delay, img) -> do
      fg <- bgSubApply mog2 0.1 img
      fgBgr <- exceptErrorIO $ pureExcept $ cvtColor gray bgr fg
      pure (delay, fgBgr)

Original:

Foreground:

newBackgroundSubtractorKNN Source #

Arguments

:: PrimMonad m 
=> Maybe Int32

Length of the history.

-> Maybe Double

Threshold on the squared distance between the pixel and the sample to decide whether a pixel is close to that sample. This parameter does not affect the background update.

-> Maybe Bool

If True, the algorithm will detect shadows and mark them. It decreases the speed a bit, so if you do not need this feature, set the parameter to False.

-> m (BackgroundSubtractorKNN (PrimState m)) 

newBackgroundSubtractorMOG2 Source #

Arguments

:: PrimMonad m 
=> Maybe Int32

Length of the history.

-> Maybe Double

Threshold on the squared Mahalanobis distance between the pixel and the model to decide whether a pixel is well described by the background model. This parameter does not affect the background update.

-> Maybe Bool

If True, the algorithm will detect shadows and mark them. It decreases the speed a bit, so if you do not need this feature, set the parameter to False.

-> m (BackgroundSubtractorMOG2 (PrimState m))