Detecting text lines in image by means of Hough Transform In my Android App,I have to detect text lines in images.I want to use Hough Transform to detect lines.You can see an image below: 



I got edges in image by canny filter,then I applied Hough Transform on canny image:

Size size = canny.size();
Mat lines = new Mat();
int lineGap = 20;
double sum1 = 0;
Imgproc.HoughLinesP(canny, lines, 1, Math.PI / 180, 100, size.width / 2.f, lineGap);


Result for above image, looks like this:



You can see three text lines are detected.So I added line's thickness by applying dilate on canny image:

Mat dilate = new Mat();
Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,10));
Imgproc.dilate(canny, dilate, kernel);
int lineGap = 20;
double sum1 = 0;
Imgproc.HoughLinesP(dilate, lines, 1, Math.PI / 180, 100, size.width / 2.f, lineGap);


I drew detected lines on empty black background.Result is shown below:



You can see number of detected text lines is decreased,although I had added thickness of lines and did not change amount of minLineLength or maxLineGap,also when I apply dilation no white pixel remove from image!

Again I added thickness of lines by doing dilation with kernel of size(30,30):

Mat dilate = new Mat();
Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(30,30));
Imgproc.dilate(canny, dilate, kernel);
int lineGap = 20;
double sum1 = 0;
Imgproc.HoughLinesP(dilate, lines, 1, Math.PI / 180, 100, size.width / 2.f, lineGap);


Result is:



Now my question is:
Why in each level when I add number of white pixels (by dilation) and do not change minLineLength or maxLineGap,Hough Transform do not detect some lines that were detected in previous level with less white pixels?
OpenCV now has a text detection module included. You might want to take a look at it:

Detector: http://docs.opencv.org/master/modules/objdetect/doc/erfilter.html
Recognizer: http://docs.opencv.org/trunk/modules/text/doc/ocr.html