Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How do you properly track contours?

I think I just need some clarification. I have code to find contours in the live camera preview and I want to track each contour with an ID. I'm using this code for each contour to create the tracker.

 Rect rect = Imgproc.boundingRect(contour);
 Rect2d rect2d = new Rect2d(rect.x, rect.y, rect.width, rect.height);
 multiTracker.add(TrackerMOSSE.create(), ingray, rect2d);

Since this is happening every frame obviously it is creating a new tracker every single frame and just keeps adding even if the contour is actually the same object between frames. Is there a way to check if the contour is already tracked?

How do you properly track contours?

I think I just need some clarification. I have code to find contours in the live camera preview and I want to track each contour with an ID. I'm using this code for each contour to create the tracker.

 Rect rect = Imgproc.boundingRect(contour);
 Rect2d rect2d = new Rect2d(rect.x, rect.y, rect.width, rect.height);
 multiTracker.add(TrackerMOSSE.create(), ingray, rect2d);

Since this is happening every frame obviously it is creating a new tracker every single frame and just keeps adding even if the contour is actually of the same object between frames. Is there a way to check if the contour contour/object is already tracked?