opencv tip, Rect bounding
Sometimes, it causes memory error or unexpected result when we set lager rect size than image.
It is very annoying to always check.
But this tip is very simple and easy.
Plz see the code and result.
It is very annoying to always check.
But this tip is very simple and easy.
Plz see the code and result.
cv::Rect bounds(0,0,100,100); cv::Rect roi(10,10,40,40); Rect boundedRect = (roi & bounds); cout << "x = " << boundedRect.x << endl; cout << "y = " << boundedRect.y << endl; cout << "width = " << boundedRect.width << endl; cout << "height = " << boundedRect.height << endl; cv::Rect roi2(-10,10,40,40); Rect boundedRect2 = (roi2 & bounds); cout << boundedRect << endl; cv::Rect roi3(-10,-10,400,40); cout << (roi3 & bounds) << endl;...