MCPcopy Create free account
hub / github.com/Smorodov/Multitarget-tracker / Initialize

Method Initialize

src/Tracker/staple/staple_tracker.cpp:495–603  ·  view source on GitHub ↗

\brief STAPLE_TRACKER::tracker_staple_initialize \param im \param region

Source from the content-addressed store, hash-verified

493/// \param region
494///
495void STAPLE_TRACKER::Initialize(const cv::Mat &im, cv::Rect region)
496{
497 int n = im.channels();
498 if (n == 1)
499 m_cfg.grayscale_sequence = true;
500
501 // xxx: only support 3 channels, TODO: fix updateHistModel
502 //assert(!cfg.grayscale_sequence);
503
504 m_cfg.init_pos.x = region.x + region.width / 2.0f;
505 m_cfg.init_pos.y = region.y + region.height / 2.0f;
506
507 m_cfg.target_sz.width = region.width;
508 m_cfg.target_sz.height = region.height;
509
510 initializeAllAreas(im);
511
512 pos = m_cfg.init_pos;
513 target_sz = m_cfg.target_sz;
514
515 // patch of the target + padding
516 cv::Mat patch_padded;
517 getSubwindow(im, pos, norm_bg_area, bg_area, patch_padded);
518
519 // initialize hist model
520 updateHistModel(true, patch_padded);
521
522 CalculateHann(cf_response_size, hann_window);
523
524 // gaussian-shaped desired response, centred in (1,1)
525 // bandwidth proportional to target size
526 float output_sigma = sqrt(static_cast<float>(norm_target_sz.width * norm_target_sz.height)) * m_cfg.output_sigma_factor / m_cfg.hog_cell_size;
527
528 cv::Mat y;
529 gaussianResponse(cf_response_size, output_sigma, y);
530 cv::dft(y, yf);
531
532 // SCALE ADAPTATION INITIALIZATION
533 if (m_cfg.scale_adaptation)
534 {
535 // Code from DSST
536 scale_factor = 1;
537 base_target_sz = target_sz; // xxx
538 float scale_sigma = sqrt(static_cast<float>(m_cfg.num_scales)) * m_cfg.scale_sigma_factor;
539
540 cv::Mat ys = cv::Mat(1, m_cfg.num_scales, CV_32FC2);
541 for (int i = 0; i < m_cfg.num_scales; i++)
542 {
543 cv::Vec2f val((i + 1) - ceil(m_cfg.num_scales/2.0f), 0.f);
544 val[0] = exp(-0.5f * (val[0] * val[0]) / (scale_sigma * scale_sigma));
545 ys.at<cv::Vec2f>(i) = val;
546
547 // SS = (1:p.num_scales) - ceil(p.num_scales/2);
548 // ys = exp(-0.5 * (ss.^2) / scale_sigma^2);
549 }
550
551 cv::dft(ys, ysf, cv::DFT_ROWS);
552 //std::cout << ysf << std::endl;

Callers

nothing calls this directly

Calls 7

sqrtFunction · 0.85
ceilFunction · 0.85
expFunction · 0.85
cosFunction · 0.85
powFunction · 0.85
logFunction · 0.85
floorFunction · 0.85

Tested by

no test coverage detected