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

Method Initialize

src/Tracker/dat/dat_tracker.cpp:29–83  ·  view source on GitHub ↗

\brief DAT_TRACKER::tracker_dat_initialize \param I \param region

Source from the content-addressed store, hash-verified

27/// \param region
28///
29void DAT_TRACKER::Initialize(const cv::Mat &im, cv::Rect region)
30{
31 double cx = region.x + double(region.width - 1) / 2.0;
32 double cy = region.y + double(region.height - 1) / 2.0;
33 double w = region.width;
34 double h = region.height;
35
36 cv::Point target_pos(round(cx),round(cy));
37 cv::Size target_sz(round(w),round(h));
38
39 scale_factor_ = std::min(1.0, round(10.0 * double(cfg.img_scale_target_diagonal) / cv::norm(cv::Point(target_sz.width,target_sz.height))) / 10.0);
40 target_pos.x = target_pos.x * scale_factor_; target_pos.y = target_pos.y * scale_factor_;
41 target_sz.width = target_sz.width * scale_factor_; target_sz.height = target_sz.height * scale_factor_;
42
43 cv::Mat img;
44 cv::resize(im, img, cv::Size(), scale_factor_, scale_factor_);
45 switch (cfg.color_space) {
46 case 1: //1rgb
47 if (img.channels() == 1)
48 {
49 cv::cvtColor(img, img, cv::COLOR_GRAY2BGR);
50 }
51 break;
52 case 2: //2lab
53 cv::cvtColor(img, img, cv::COLOR_BGR2Lab);
54 break;
55 case 3: //3hsv
56 cv::cvtColor(img, img, cv::COLOR_BGR2HSV);
57 break;
58 case 4: //4gray
59 if (img.channels() == 3)
60 {
61 cv::cvtColor(img, img, cv::COLOR_BGR2GRAY);
62 }
63 break;
64 default:
65 std::cout << "int_variable does not equal any of the above cases" << std::endl;
66 }
67 cv::Size surr_sz(floor(cfg.surr_win_factor * target_sz.width),
68 floor(cfg.surr_win_factor * target_sz.height));
69 cv::Rect surr_rect = pos2rect(target_pos, surr_sz, img.size());
70 cv::Rect obj_rect_surr = pos2rect(target_pos, target_sz, img.size());
71 obj_rect_surr.x -= surr_rect.x;
72 obj_rect_surr.y -= surr_rect.y;
73 cv::Mat surr_win = getSubwindow(img, target_pos, surr_sz);
74 cv::Mat prob_map;
75 getForegroundBackgroundProbs(surr_win, obj_rect_surr, cfg.num_bins, cfg.bin_mapping, prob_lut_, prob_map);
76
77 prob_lut_distractor_ = prob_lut_.clone();
78 prob_lut_masked_ = prob_lut_.clone();
79 adaptive_threshold_ = getAdaptiveThreshold(prob_map, obj_rect_surr);
80
81 target_pos_history_.push_back(cv::Point(target_pos.x / scale_factor_, target_pos.y / scale_factor_));
82 target_sz_history_.push_back(cv::Size(target_sz.width / scale_factor_, target_sz.height / scale_factor_));
83}
84
85///
86/// \brief DAT_TRACKER::tracker_dat_update

Callers 2

RectUpdateMethod · 0.45
CTrackerMethod · 0.45

Calls 5

roundFunction · 0.85
floorFunction · 0.85
cloneMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected