1
$\begingroup$

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:

![image description](/upfiles/1416629511823866.jpg)

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:

enter image description here

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:

enter image description here

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:

enter image description here

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?

$\endgroup$
1

1 Answer 1

1
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ Thank you for your attention,but it seems that is available in OpenCV 3,and I have to use OpenCV_2.4.8.2 in developing Application for Android. $\endgroup$ Nov 26, 2014 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.