Detecting merging blobs ofxCV

Is there any code already out there that can detect one two blobs or labels have merged? I am trying to detect when one object touches the other.

Maybe check if the new blob (5) has an area similar to those blobs which have dissapeared (0 and 1)?

1 Like

you could try using ofxCv::RectTracker which allows you to know when a blob/label is not existing anymore, but it is still alive (can still be queried) until it’s persistence time runs out.

label 1 and 0 would still return a position but that position does not change anymore.
label 5 would return a very young age, so you know it’s new.
label 5’s position would be close to the middle of position 1 and 0.

		bool existsCurrent(unsigned int label) const;
		bool existsPrevious(unsigned int label) const;
		int getAge(unsigned int label) const;
		int getLastSeen(unsigned int label) const;

Thanks for the help! The area solution is working well. However the merged blob is not always a “new label”, sometimes it is a label that existed previously, has died, and just re-emerges. I’m using RectTracker, and the getNewLabels() only gives me labels that have never existed previously. How can I detect these labels that are new but have existed previously?