2013-05-18 66 views
2

使用OpenCV的C++接口如何我可以編寫代碼來設置和重置ROI 對於例如:如果我需要一個像如何OpenCV的C++接口管理ROI

-> Load image 
-> SetImageRoi 
-> Do some processing on ROI region 
-> Reset ROI 
-> Do some operation on entire image 

的代碼在這種情況下,我怎麼能管理與C++接口?

在此先感謝....

回答

6

這裏有你所需要的步驟:

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

您好感謝答覆...... – Haris