0
번호 인식을 시도 중입니다. 그러나 윤곽을 찾은 후에. 그림에서와 같이 숫자 0,6,8에 대한 기본 경계 상자 안의 경계 상자를 얻습니다. 이미지 처리의 초기 단계를 도와주세요. 그룹 사각형을 사용해 보았지만 작동하지 않습니다. 아래 코드를 확인하십시오. 고맙습니다.번호 인식 용 경계 상자 안의 경계 상자 제거
이미지 : 플래그를 사용하는 http://tinypic.com/r/1twx05/5
int main()
{
Mat inimage, gray;
inimage = imread("sample.jpg");
cvtColor(inimage, gray, COLOR_BGR2GRAY);
GaussianBlur(gray, gray, Size(5,5), 0);
adaptiveThreshold(gray, gray, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY_INV, 11, 0);
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
findContours(gray, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0));
vector<vector<Point> > contours_poly(contours.size());
vector<Rect> boundRect(contours.size());
for(int i = 0; i < contours.size(); i++)
{
approxPolyDP(Mat(contours[i]), contours_poly[i], 3, true);
boundRect[i] = boundingRect(Mat(contours_poly[i]));
}
//groupRectangles(boundRect, 1, 0.2);
Scalar color = Scalar(0,0,255);
for(int i = 0; i< contours.size(); i++)
{
//drawContours(inimage, contours_poly, i, color, 1, 8, vector<Vec4i>(), 0, Point());
rectangle(inimage, boundRect[i].tl(), boundRect[i].br(), color, 1, 8, 0);
}
namedWindow("Contours", CV_WINDOW_AUTOSIZE);
imshow("Contours", inimage);
waitKey(0);
return 0;
}