# solving intersected blobs

This topic is 2142 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm doing a blob tracking algorithm, and I have a problem. I'm having two lists of objects and blobs, where objects save the number of blobs that has been process every frame. When two blobs are merged, I check for that. I wanted to have a list of objects that save the total numbers of blobs even if the the blobs are merged together.
The current problem is when two blobs merges, I can have a list of objects that have the previous number of separated blobs, that is ok, but when in the next frame the two merged blobs, gets separated, the code keeps adding a one object at time.

 void Tracker::ProcessObjects( ) { if(m_Objs.empty()) { for(std::list<Blob>::iterator iter = m_Blobs.begin(); iter!=m_Blobs.end(); iter++) { Obj * obj = new Obj(m_iTrackerId++, iter->m_Pos, 0); m_Objs.push_back(*obj); } } else { double x, y, xT, yT, dist; std::list<Blob>::iterator blob = m_Blobs.end(); for(std::list<Obj>::iterator iter = m_Objs.begin(); iter!=m_Objs.end(); iter++) { dist = 327680000; for(std::list<Blob>::iterator iter2 = m_Blobs.begin(); iter2!=m_Blobs.end(); iter2++) { double _dist = iter->m_Pos.distance(iter2->m_Pos); if(_dist<=200 && _dist<dist) // threshold hard coded, distance between obj and blob used for update! { blob = iter2; dist = _dist; } } if(blob != m_Blobs.end()) { blob->bUsed = true; // if this already true, indicator for a merge state, update obj to be merged state iter->m_Pos = blob->m_Pos; } else { iter->m_not_found++; } } for(std::list<Blob>::iterator iter = m_Blobs.begin(); iter!=m_Blobs.end(); iter++) { if(!iter->bUsed ) { Obj * obj = new Obj(m_iTrackerId++, iter->m_Pos, 0); m_Objs.push_back(*obj); } else { std::cout<<"do nothing"<<std::endl; } } }