使用 OpenCV C++ 接口我如何编写代码来设置和重置 ROI 例如:如果我需要像这样的代码
-> Load image
-> SetImageRoi
-> Do some processing on ROI region
-> Reset ROI
-> Do some operation on entire image
在这种情况下,如何使用 c++ 接口进行管理?
提前致谢....
以下是您需要的步骤:
// Load image
cv::Mat image = cv::imread("image_filname");
// SetImageRoi
cv::Rect roi(x, y, width, height);
cv::Mat image_roi = image(roi);
// note: this assignment does not copy data
// image and image_roi now share data
// Do some processing on ROI region
process(image_roi);
// any changes to image_roi will also be in image
// Reset ROI
// -- nothing required
// Do some operation on entire image
operations(image);