count the time of detected object on video on java with OpenCV

asked 2015-09-29 11:27:28 -0600

shofwan gravatar image

Let say I've been able to detect object for each frame on a video.

The object features are:

  • The center of the object (an opencv.core.Point)
  • the size of object (number of pixel area)
  • an outbox (opencv.core.Rect) of the object

What I want to know is, can we count the time of object occurred by using OpenCV?

For addition, I'm using opencv.video.BackgroundSubtractorMOG2 (with learning rate=0) and Imgproc.findContours for detecting any object of each frame.

Right now I'm on my way to do that without any libraries (and that's pretty hard for me). what I will do:

  1. save all the objects for each frame (with List or something).
  2. compare all the objects from previous frame with all the object from current frame.
  3. Comparing based on similarity of the center point and size of the object (I think that's enough).
  4. If find some object that similar, increase the time of that object occurred, plus update that object's feature
  5. if an object (on previous frame) didn't occur on current frame, delete it.

Maybe some people will think this is related to object tracking like this, but I think that will be an overkill and make things more complicated.

Any help related to this problem will be appreciated (event though it's not from OpenCV).

edit retag flag offensive close merge delete