本文整理汇总了C++中TrackList::update方法的典型用法代码示例。如果您正苦于以下问题:C++ TrackList::update方法的具体用法?C++ TrackList::update怎么用?C++ TrackList::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TrackList
的用法示例。
在下文中一共展示了TrackList::update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: track
int track(string videopath){
cout<<"start track "<<videopath<<endl;
QString outpath=QString::fromStdString(videopath);
int dotpos=outpath.indexOf('.');
int strlen=outpath.length();
outpath=outpath.replace(dotpos,strlen-dotpos,".infrared.track");
cout<<"outpath is "<<outpath.toStdString()<<endl;
ofstream out(outpath.toStdString());
VideoCapture cap(videopath);
if(!cap.isOpened()) // check if we succeeded
return -1;
Mat roi,fg,gray,bin;
namedWindow("video input",CV_WINDOW_NORMAL);
namedWindow("foreground mask",CV_WINDOW_NORMAL);
int frameNum=0;
BackgroundSubtractorSuBSENSE bgs;
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
RNG rng(12345);
for(;;frameNum++)
{
Mat frame;
cap >> frame; // get a new frame from camera
if(frame.empty()){
break;
}
resize(frame,frame,Size(0,0),1.0/sqrt(speedUp),1.0/sqrt(speedUp));
//init
if(frameNum==0){
fg.create(frame.size(),CV_8UC1);
roi.create(frame.size(),CV_8UC1);
roi.setTo(255);
bgs.initialize(frame,roi);
bin.create(frame.size(),CV_8UC1);
cvtColor(frame,gray,CV_BGR2GRAY);
threshold(gray,bin,thresh,255,THRESH_BINARY);
}//detect
else{
// bgs(frame,fg,double(frameNum<=100));
cvtColor(frame,gray,CV_BGR2GRAY);
threshold(gray,bin,thresh,255,THRESH_BINARY);
cout<<"thresh="<<thresh<<endl;
// fg=fg|bin;
fg=bin;
// vector<vector<Point> > contours0;
Mat img=fg.clone();
Mat kernel=cv::getStructuringElement(cv::MORPH_ELLIPSE,cv::Size(minObjectSize,minObjectSize));
cv::morphologyEx(img,img,MORPH_OPEN,kernel);
contours.clear();
findContours( img, contours, hierarchy, CV_RETR_EXTERNAL, CHAIN_APPROX_SIMPLE);
// contours.resize(contours0.size());
// for( size_t k = 0; k < contours0.size(); k++ )
// approxPolyDP(Mat(contours0[k]), contours[k], 3, true);
/// Get the moments
vector<Moments> mu(contours.size() );
for( int i = 0; i < contours.size(); i++ )
{ mu[i] = moments( contours[i], false ); }
/// Get the mass centers:
vector<Point2f> mc( contours.size() );
Measurements m;
for( int i = 0; i < contours.size(); i++ )
{
mc[i] = Point2f( mu[i].m10/mu[i].m00 , mu[i].m01/mu[i].m00 );
// mc[i][0]=mc[i][0]/img.rows;
// mc[i][1]=mc[i][1]/img.cols;
m.emplace_back(Measurement(mc[i].x,mc[i].y));
}
/// Draw contours
Mat drawing = frame;
for( int i = 0; i< contours.size(); i++ )
{
Scalar color = Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );
drawContours( drawing, contours, i, color, 2, 8, hierarchy, 0, Point() );
circle( drawing, mc[i], 4, color, -1, 8, 0 );
}
for ( const auto & x : m )
{
const int r = 5;
// draw measurement
circle(drawing, Point(x(0), x(1)), 2*r, Scalar(0, 0, 0));
line(drawing, Point(x(0) - r, x(1) - r), Point(x(0) + r, x(1) + r), Scalar(0, 0, 0) );
line(drawing, Point(x(0) - r, x(1) + r), Point(x(0) + r, x(1) - r), Scalar(0, 0, 0) );
}
tracker.track(m);
tracklist.update(tracker,out,frameNum);
for ( const auto & filter : tracker.filters() )
{
const GNNTracker::StateSpaceVector s = filter.state();
//.........这里部分代码省略.........