Skip to content

Commit

Permalink
Merge pull request Smorodov#58 from Nuzhny007/master
Browse files Browse the repository at this point in the history
Fix bug with tracking a targets biggest than half frame size
  • Loading branch information
Smorodov authored Nov 21, 2017
2 parents 00b6d7f + 16d4725 commit 41c61f0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Tracker/track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,15 @@ void CTrack::RectUpdate(
#ifdef USE_OCV_KCF
if (!dataCorrect)
{
cv::Size roiSize(currFrame.cols / 2, currFrame.rows / 2);
cv::Size roiSize(std::max(2 * m_predictionRect.width, currFrame.cols / 2), std::min(2 * m_predictionRect.height, currFrame.rows / 2));
if (roiSize.width > currFrame.cols)
{
roiSize.width = currFrame.cols;
}
if (roiSize.height > currFrame.rows)
{
roiSize.height = currFrame.rows;
}
cv::Point roiTL(m_predictionRect.x + m_predictionRect.width / 2 - roiSize.width / 2, m_predictionRect.y + m_predictionRect.height / 2 - roiSize.height / 2);
cv::Rect roiRect(roiTL, roiSize);
Clamp(roiRect.x, roiRect.width, currFrame.cols);
Expand Down

0 comments on commit 41c61f0

Please sign in to comment.