0

I use MSER algorithm with opencv and find some rectangle parts then I want to blur that inside rectangle. my renctangles are vector like (x, y, width, height) but using dilate or erode need inputarray src. how can i transform vector to inputarray src?

here is my code.

vector< vector< Point> > contours;
vector< Rect> bboxes;
Rect MserROI;
Ptr< MSER> mser = MSER::create(21, (int)(0.00002*textImg.cols*textImg.rows), (int)(0.05*textImg.cols*textImg.rows), 1, 0.7);
mser->detectRegions(textImg, contours, bboxes);

for (int i = 0; i < bboxes.size(); i++)
{
    cout << bboxes[i] << '\n';
    rectangle(inImg, bboxes[i], CV_RGB(0, 0, 0));
    MserROI = bboxes[i];
    dilate(MserROI, Mser_dil, Mat(), Point(-1, -1), 2) //error
}

1 Answers1

0

I infer that you want to blur the part of the image that inside the rectangle. If that's the case, then you need to correct the way you're declaring your ROI.

If 'inImg' is a Mat, then you can declare your ROI as follows:

for (int i = 0; i < bboxes.size(); i++)
{
    rectangle(inImg, bboxes[i], CV_RGB(0, 0, 0));
    Mat MserROIimg=inImg(bboxes[i]);        
    dilate(MserROI, Mser_dil, Mat(), Point(-1, -1), 2) //error
}

In your code, you haven't mentioned where you've declared Mser_dil, but if your error is pertaining to ROI declaration, then this should work for you

Saransh Kejriwal
  • 2,467
  • 5
  • 15
  • 39