OpenCV + Python | Multiple object tracking
I'm working on a project and I really can't reach a solution. My goal is to track some circular objects of the same color (red) in a video. My current pipeline is:
- Convert each frame from BGR to HSV
- Threshold the image using inRange() function
- Some morph operations like erode(), dilate(), blur()
- Find contours and then some infos like area, centroid etc...
- Draw contours on the original frame
- Save the new centroid position in every frame (in a python dictionary)
The problems are:
- The result is a little noisy
- I can't give an identity to each object (there are problems when two object come in contact, or when an object disappears and then reappears etc...)
I would be grateful if someone has some suggestions on what's the best way to procees and how can I change pipeline (e.g. using Kalman Filter, Camshift or other algorithms). I'm not a CV expert, so please be patient. Thanks a lot