Skip to content

Possible issue in GlobalMotionCompensation.cpp #14

Description

@arnaud-nt2i

@viplix3 Hi!
Thanks again for your work.

I have been playing with GMC algos and there seeme to be a pb in
HomographyMatrix OpenCV_VideoStab_GMC::apply(const cv::Mat &frame_raw, const std::vector<Detection> &detections) {}
https://github.com/viplix3/BoTSORT-cpp/blob/4185b005e34d49c6c9e5cdf2dbde70ed11f70a0f/botsort/src/GlobalMotionCompensation.cpp#L571C21-L571C21

according to the PR that added Masking to opencv/videostab/src/global_motion.cpp : https://github.com/opencv/opencv_contrib/pull/2052 :
The mask video must contain black (0 values) for parts, which are ignored during stabilization.

Or, the code is doing the opposite :

cv::Mat mask = cv::Mat::zeros(frame.size(), CV_8U);
mask(rect) = 255; and then
_keypoint_motion_estimator->setFrameMask(mask);

So I am wondering if Keypoints for BasedMotionEstimator are only taken on detection and not on background ...
By the way, there should be a clamp before mask(rect) = 255; : clampRectInplace(rect, width, height);
with a function added in utils.h :

inline void clampRectInplace(cv::Rect &roi, int maxW, int maxH)
{
roi.x = std::max(0, std::min(roi.x, maxW));
roi.y = std::max(0, std::min(roi.y, maxH));
roi.width = std::max(0, std::min(roi.width, maxW - roi.x));
roi.height = std::max(0, std::min(roi.height, maxH - roi.y));
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions