Skip to content

Commit

Permalink
Trying to change branch from master to 3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ieliz committed Aug 14, 2020
1 parent 735511b commit 63c3cdf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/tracking/src/gtrTracker.cpp
Expand Up @@ -75,7 +75,9 @@ class TrackerGOTURNModel : public TrackerModel{
public:
TrackerGOTURNModel(TrackerGOTURN::Params){}
Rect2d getBoundingBox(){ return boundingBox_; }
void setBoudingBox(Rect2d boundingBox){ boundingBox_ = boundingBox; }
void setBoudingBox(Rect2d boundingBox) {
boundingBox_ = boundingBox & Rect2d(Point(0, 0), image_.size());;
}
Mat getImage(){ return image_; }
void setImage(const Mat& image){ image.copyTo(image_); }
protected:
Expand Down Expand Up @@ -137,6 +139,11 @@ bool TrackerGOTURNImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
targetPatchRect.x = (float)(prevCenter.x - prevBB.width*padTargetPatch / 2.0 + targetPatchRect.width);
targetPatchRect.y = (float)(prevCenter.y - prevBB.height*padTargetPatch / 2.0 + targetPatchRect.height);

targetPatchRect.width = std::min(targetPatchRect.width, (float)prevFrame.cols);
targetPatchRect.height = std::min(targetPatchRect.height, (float)prevFrame.rows);
targetPatchRect.x = std::max(-prevFrame.cols * 0.5f, std::min(targetPatchRect.x, prevFrame.cols * 1.5f));
targetPatchRect.y = std::max(-prevFrame.rows * 0.5f, std::min(targetPatchRect.y, prevFrame.rows * 1.5f));

copyMakeBorder(prevFrame, prevFramePadded, (int)targetPatchRect.height, (int)targetPatchRect.height, (int)targetPatchRect.width, (int)targetPatchRect.width, BORDER_REPLICATE);
targetPatch = prevFramePadded(targetPatchRect).clone();

Expand Down
20 changes: 20 additions & 0 deletions modules/tracking/test/test_trackers.cpp
Expand Up @@ -567,6 +567,26 @@ TEST_P(DistanceAndOverlap, Scaled_Data_CSRT)
test.run();
}

TEST(GOTURN, memory_usage)
{
cv::Rect2d roi(145, 70, 85, 85);
cv::Mat frame;
cv::Ptr<cv::Tracker> tracker = cv::TrackerGOTURN::create();
string folder = cvtest::TS::ptr()->get_data_path() + "tracking/david/data/david.webm";
cv::VideoCapture video( folder );
video >> frame;
tracker->init(frame, roi);
for (;; ) {
video >> frame;
if (frame.empty())
break;
tracker->update(frame, roi);
if (roi.width > frame.cols || roi.height > frame.rows)
{
FAIL() << "GOTURN tracker memory test failed: tracker trying to allocate too much memory";
}
}
}

INSTANTIATE_TEST_CASE_P( Tracking, DistanceAndOverlap, TESTSET_NAMES);

Expand Down

0 comments on commit 63c3cdf

Please sign in to comment.