\brief RectUpdate \param region \param dataCorrect \param prevFrame \param currFrame
| 669 | /// \param currFrame |
| 670 | /// |
| 671 | void CTrack::RectUpdate(const CRegion& region, |
| 672 | bool dataCorrect, |
| 673 | cv::UMat prevFrame, |
| 674 | cv::UMat currFrame) |
| 675 | { |
| 676 | bool wasTracked = false; |
| 677 | cv::RotatedRect trackedRRect; |
| 678 | |
| 679 | auto Clamp = [](int& v, int& size, int hi) -> int |
| 680 | { |
| 681 | int res = 0; |
| 682 | |
| 683 | if (size < 1) |
| 684 | size = 0; |
| 685 | |
| 686 | if (v < 0) |
| 687 | { |
| 688 | res = v; |
| 689 | v = 0; |
| 690 | return res; |
| 691 | } |
| 692 | else if (v + size > hi - 1) |
| 693 | { |
| 694 | res = v; |
| 695 | v = hi - 1 - size; |
| 696 | if (v < 0) |
| 697 | { |
| 698 | size += v; |
| 699 | v = 0; |
| 700 | } |
| 701 | res -= v; |
| 702 | return res; |
| 703 | } |
| 704 | return res; |
| 705 | }; |
| 706 | |
| 707 | auto UpdateRRect = [&](cv::Rect prevRect, cv::Rect newRect) |
| 708 | { |
| 709 | m_predictionRect.center.x += newRect.x - prevRect.x; |
| 710 | m_predictionRect.center.y += newRect.y - prevRect.y; |
| 711 | m_predictionRect.size.width *= newRect.width / static_cast<float>(prevRect.width); |
| 712 | m_predictionRect.size.height *= newRect.height / static_cast<float>(prevRect.height); |
| 713 | }; |
| 714 | |
| 715 | auto InitTracker = [&](cv::Rect& roiRect, bool reinit) |
| 716 | { |
| 717 | bool inited = false; |
| 718 | cv::Rect brect = dataCorrect ? region.m_brect : m_predictionRect.boundingRect(); |
| 719 | roiRect.x = 0; |
| 720 | roiRect.y = 0; |
| 721 | roiRect.width = currFrame.cols; |
| 722 | roiRect.height = currFrame.rows; |
| 723 | |
| 724 | switch (m_externalTrackerForLost) |
| 725 | { |
| 726 | case tracking::TrackNone: |
| 727 | break; |
| 728 |