opencvc++接口如何管理ROI

How OpenCV C++ Interface Manage ROI

本文关键字:管理 ROI 接口 何管理 opencvc++      更新时间:2023-10-16

使用OpenCV c++接口如何编写设置和重置ROI的代码例如:如果我需要像

这样的代码
-> Load image
-> SetImageRoi
-> Do some processing on ROI region
-> Reset ROI
-> Do some operation on entire image 

在这种情况下,我如何使用c++接口进行管理?

Thanks in advance....

以下是您需要的步骤:

// 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);