Segmentation Fault in findContours()
I tried all the solutions given on stack-overflow but nothing works. I have a competition in a month and need this piece of code working ASAP. Help me P.S. If i comment out findcontours() the function runs without a segmentation fault.
vector<RotatedRect> findTextAreas(Mat image)
{
Mat kernel = getStructuringElement(MORPH_CROSS, Size(3, 3));
Mat dilated;
dilate(image, dilated, Mat(), cv::Point(-1, -1), 12);
imshow("Dilated", dilated);
waitKey(1000);
vector<vector<Point> > contours;
waitKey(1000);
findContours(dilated, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);**
vector<RotatedRect> areas(contours.size());
for (auto contour : contours)
{
auto box = minAreaRect(contour);
if (box.size.width < 20 || box.size.height < 20)
continue;
double prop = box.angle < -45 ? box.size.height / box.size.width : box.size.width / box.size.height;
if (prop < 2)
continue;
areas.push_back(box);
}
return areas;
}