How to keep track of different contours in opencv python

≯℡__Kan透↙ 提交于 2019-12-03 09:14:40

What kind of objects are you trying to track? If it's easy to distinguish them you can try to collect some features of objects and check whether object with similar features appeared earlier. It's hard to tell what kind of features will be the best in your situation, but you may try following:

  • contour size, area and length (or ratio: area/length or some other)
  • convex hull of object and it length (same as above - you may try ratio as well)
  • object colour (average colour) - if lighting can change consider using only H channel from HSV color space
  • some more complicated - "sum" of edges inside object (use some edge detector on object and just calculate sum of the result image)

Other solution is to use more powerfull tool designed for such task - object tracker. In one of my projects i'm using TLD tracker and it works fine, another option is to use CMT tracker, which might be better for you, because it's written in Python. Note that for tracking multiple objects you will need multiple tracker objects (or find tracker which is capable of tracking multiple different objects).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!