Commit 41174ca7e9c0ee0d0ad737b8907d51d08f52f859

Moved separateObjects.hs into its own repository (objectSeparator)
separateObjects.hs
(0 / 42)
  
1{-# LANGUAGE ParallelListComp, RecordWildCards, DeriveDataTypeable #-}
2module Main where
3import CV.Image
4import CV.Video
5import CV.ColourUtils
6import Control.Monad
7import qualified CV.ImageMath as IM
8import CV.ImageMathOp
9import Utils.List
10import Data.Function
11import Data.List
12import System.Console.CmdArgs
13
14
15main = do
16 Just bkg <- loadColorImage "bkg.png"
17 let file = "video-kameraA.mp4"
18 cap <- captureFromFile file
19 let frameRate = getFrameRate cap
20 frameSize = getFrameSize cap
21 print ("Rate",frameRate,"Size",frameSize)
22 --writer <- createVideoWriter "movement.avi" MPG4 frameRate frameSize False
23 let noFrames = getNumberOfFrames cap
24 captureLoop n = do
25 print ("Frame",getFrameNumber cap,"/",noFrames)
26 frame <- getFrame cap
27 let diffImage = calcDiff bkg frame
28 saveImage ("frames/"++show n++".png") diffImage
29 -- writeFrame writer diffImage
30 if n<=0
31 then return ()
32 else captureLoop (n-1)
33 captureLoop noFrames
34
35calcDiff bkg frame =
36 let bgkLAB = convertTo cvRGBtoLAB 3 bkg
37 frameLAB = convertTo cvRGBtoLAB 3 frame
38 in stretchHistogram $ IM.absDiff (getChannel 3 bgkLAB) (getChannel 3 frameLAB) #+
39 IM.absDiff (getChannel 2 bgkLAB) (getChannel 2 frameLAB)
40
41
42