Reputation:
I am converting some old OpenCV code using the C api to the new C++ API in OpenCV 2.3. I am wondering what the method is to replace the cvGetSubRect
call is?
I have the following, cvGetSubRect(some_cv_mat_pointer, another_cv_mat_pointer, some_cv_rect);
What is the equivalent to this in the C++ api?
Upvotes: 3
Views: 1087
Reputation: 96109
You create an roi on the source image which gives you a new image - there is no actual pixel copying it all happens automatically
Mat image(.....) // original image
Rect roi(10, 20, 100, 50); // shape of roi
Mat image_roi = image(roi); /// really a window into image, copy it if you need to change it
http://opencv.willowgarage.com/documentation/cpp/c++_cheatsheet.html
Upvotes: 4