如何使用 OpenCV C++ 接口(interface)编写设置和重置 ROI 的代码 例如:如果我需要像这样编码
-> Load image
-> SetImageRoi
-> Do some processing on ROI region
-> Reset ROI
-> Do some operation on entire image
在这种情况下,我如何使用 C++ 接口(interface)进行管理?
提前致谢....
最佳答案
以下是您需要的步骤:
// 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);
关于c++ - OpenCV C++ 接口(interface)如何管理 ROI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16621983/