c++ - how to use openCV as a motion detector (not looking for video output) -
i'm new c++ , have been doing lot of research opencv. i'm making motion detector using webcam , trying use trigger function (kind of listener). don't need kind of visual video in application. need sense motion , give output boolean instance.
i more familiar java has written in c++, no wrappers, no converters.
can please point me in write direction. maybe tutorial or suggestion of should up. different library should use rather opencv.
as starting point, i'd recommend using basic image subtraction take there.
the basic algorithm is:
firstframe = readframe() firstframegrey = converttogreyscale(firstframe) // makes image b&w while true secondframe = readframe() secondframegrey = converttogreyscale(secondframe) difference = sub(firstframegrey, secondframegrey) threshold() // perform morphological operations erosion() dilation() findcontours() // loop on contours , try filtering based off of area, perimeter etc. // filtration allow detect significant changes. // update frame firstframegrey = secondframegrey for morphological operations, experiment different values , see results get.
more info on thresholding
this tutorial explains how perform morphological operations.
contours info can found here along area api
the algorithm should self explanatory , opencv has methods named.
Comments
Post a Comment