本文整理汇总了C++中CvTracks::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ CvTracks::erase方法的具体用法?C++ CvTracks::erase怎么用?C++ CvTracks::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvTracks
的用法示例。
在下文中一共展示了CvTracks::erase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cvUpdateTracks
//.........这里部分代码省略.........
}
}
// Clustering
for (j=0; j<nTracks; j++)
{
unsigned int c = AT(j);
if (c)
{
list<CvTrack*> tt; tt.push_back(T(j));
list<CvBlob*> bb;
getClusterForTrack(j, close, nBlobs, nTracks, blobs, tracks, bb, tt);
// Select track
CvTrack *track;
unsigned int area = 0;
for (list<CvTrack*>::const_iterator it=tt.begin(); it!=tt.end(); ++it)
{
CvTrack *t = *it;
unsigned int a = (t->maxx-t->minx)*(t->maxy-t->miny);
if (a>area)
{
area = a;
track = t;
}
}
// Select blob
CvBlob *blob;
area = 0;
//cout << "Matching blobs: ";
for (list<CvBlob*>::const_iterator it=bb.begin(); it!=bb.end(); ++it)
{
CvBlob *b = *it;
//cout << b->label << " ";
if (b->area>area)
{
area = b->area;
blob = b;
}
}
//cout << endl;
// Update track
//cout << "Matching: track=" << track->id << ", blob=" << blob->label << endl;
track->label = blob->label;
track->centroid = blob->centroid;
track->minx = blob->minx;
track->miny = blob->miny;
track->maxx = blob->maxx;
track->maxy = blob->maxy;
if (track->inactive)
track->active = 0;
track->inactive = 0;
// Others to inactive
for (list<CvTrack*>::const_iterator it=tt.begin(); it!=tt.end(); ++it)
{
CvTrack *t = *it;
if (t!=track)
{
//cout << "Inactive: track=" << t->id << endl;
t->inactive++;
t->label = 0;
}
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
for (CvTracks::iterator jt=tracks.begin(); jt!=tracks.end();)
if ((jt->second->inactive>=thInactive)||((jt->second->inactive)&&(thActive)&&(jt->second->active<thActive)))
{
delete jt->second;
tracks.erase(jt++);
}
else
{
jt->second->lifetime++;
if (!jt->second->inactive)
jt->second->active++;
++jt;
}
}
catch (...)
{
delete[] close;
throw; // TODO: OpenCV style.
}
delete[] close;
__CV_END__;
}
示例2: cvUpdateTracks
//.........这里部分代码省略.........
track->inactive++;
track->label=0;
// Create new tracks
for (i=0; i<nBlobs; i++)
{
if (C(i, j))
{
maxTrackID++;
CvBlob *blob = B(i);
CvTrack *track = new CvTrack;
track->id = maxTrackID;
track->label = blob->label;
track->minx = blob->minx;
track->miny = blob->miny;
track->maxx = blob->maxx;
track->maxy = blob->maxy;
track->centroid = blob->centroid;
track->inactive = 0;
t.insert(CvIDTrack(maxTrackID, track));
}
}
}
else // if (c == 0)
{
// Inactive track
CvTrack *track = T(j);
track->inactive++;
track->label = 0;
}
}
// Run over blobs:
for (i=0; i<nBlobs; i++)
{
//unsigned int c = C(i, nTracks);
unsigned int c = AB(i);
if (c == 0)
{
// New track
maxTrackID++;
CvBlob *blob = B(i);
CvTrack *track = new CvTrack;
track->id = maxTrackID;
track->label = blob->label;
track->minx = blob->minx;
track->miny = blob->miny;
track->maxx = blob->maxx;
track->maxy = blob->maxy;
track->centroid = blob->centroid;
track->inactive = 0;
t.insert(CvIDTrack(maxTrackID, track));
}
else if (c > 1)
{
// Tracks joins
// New track
maxTrackID++;
CvBlob *blob = B(i);
CvTrack *track = new CvTrack;
track->id = maxTrackID;
track->label = blob->label;
track->minx = blob->minx;
track->miny = blob->miny;
track->maxx = blob->maxx;
track->maxy = blob->maxy;
track->centroid = blob->centroid;
track->inactive = 0;
t.insert(CvIDTrack(maxTrackID, track));
// Others tracks inactives
for (j=0; j<nTracks; j++)
{
T(j)->inactive++;
T(j)->label = 0;
}
}
}
for (CvTracks::iterator jt=t.begin(); jt!=t.end();)
if (jt->second->inactive>=thInactive)
{
delete jt->second;
t.erase(jt++);
}
else
++jt;
}
catch (...)
{
delete[] close;
throw; // TODO: OpenCV style.
}
delete[] close;
__END__;
}