# roipoly matlab function equivalent in OpenCV

I am converting a matlab code into C++ using OpenCV libraries.

**Can anyone tell me roipoly matlab function equivalent in OpenCV??**

**Or how to get the same functionality using OpenCV?**

```
BW = roipoly(I, c, r)
```

BW = roipoly(I, c, r) returns the ROI specified by the polygon described by vectors c and r, which specify the column and row indices of each vertex, respectively. c and r are of same size.

In my case I want to extract **triangular roi** from the image, so c and r are of size 3x1.

Can anyone tell me how to do this in C++ using OpenCV??