Kaveh Shahbazian
Kaveh Shahbazian

Reputation: 13523

How can I detect direction and number of objects using Emgu?

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

Upvotes: 1

Views: 3188

Answers (1)

Andrey Sboev
Andrey Sboev

Reputation: 7682

  1. Invoke cvAbsDiff on successive frames (may be on each n-th and (n - gap)-th frame) to detect changes and use thresholding in order to get a changes mask
  2. For each frame call cvUpdateMotionHistory and pass obtained mask as an argument
  3. To get motion segments (objects) and their orientation:
    1. call cvCalcMotionGradient passing motion history accumulated by previous calls
    2. Split motion into segments by cvSegmentMotion and for each segment calculate angle using cvCalcGlobalOrientation

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).

Upvotes: 3

Related Questions