I'm migrating an old test application from the OpenCV C interface to the new C++ interface (I wish to learn it). What's the equivalent, using the C++ interface, of cvSetImageROI
and cvResetImageROI
? I couldn't find it in the documentation.
Asked
Active
Viewed 2.2k times
2 Answers
30
Actually, it's right on the docs. Shame on me.
//Make a rectangle
Rect roi(10, 20, 100, 50);
//Point a cv::Mat header at it (no allocation is done)
Mat image_roi = image(roi)

Vitor Py
- 5,145
- 4
- 39
- 62
-
To answer a question on made on my answer (now deleted), let's say you have a valid `cv::Mat` named `my_mat`. To convert it to an `IplImage*` all you need to do is a cast operation: `IplImage* img = &(IplImage)my_mat;` – karlphillip Aug 12 '11 at 16:49
-
1@karlphillip Using `IplImage* img = &(IplImage)my_mat;` raises me the following warning: `warning C4238: nonstandard extension used : class rvalue used as lvalue`. Is this normal? (VS2005) – Vitor Py Aug 12 '11 at 19:53
-
2It's best to do `IplImage img = (IplImage)my_mat;` and then pass `&img` whenever you need to use a memory pointer to it. – karlphillip Aug 12 '11 at 20:19
-
The link to *docs* does not work. Can you please post the actual documentation instead of a blog link? – Nawaz Jan 25 '18 at 08:28
-
@Nawaz That was the link to OpenCV documentation six and half years ago when that question was answered. I haven't touched OpenCV in a long time and I can't point you to the current docs, unfortunately. – Vitor Py Jan 26 '18 at 09:27
-
@VitorPy: I've found it myself. Thanks. – Nawaz Jan 26 '18 at 10:49