问题
How can I detect direction and number of objects using Emgu?
Objects are moving in all directions (2D); and a camera is seeing these objects (on a 2D surface). Object may have little differences in shape but are similar enough.
Thanks
回答1:
- Invoke
cvAbsDiff
on successive frames (may be on eachn
-th and(n - gap)
-th frame) to detect changes and use thresholding in order to get a changes mask - For each frame call
cvUpdateMotionHistory
and pass obtained mask as an argument - To get motion segments (objects) and their orientation:
- call
cvCalcMotionGradient
passing motion history accumulated by previous calls - Split motion into segments by
cvSegmentMotion
and for each segment calculate angle usingcvCalcGlobalOrientation
- call
Similar steps are coded in motempl.c
example distributed within OpenCV library.
Update
I thought that they've implemented almost complete OpenCV binding and differencies in interface are the result of adding OOP. For instance here is an AbsDiff method. However motion related stuff has different structure. Use MotionInfo
method to get motion angle as in this example (which I found with google search).
来源:https://stackoverflow.com/questions/5880311/how-can-i-detect-direction-and-number-of-objects-using-emgu