Android OpenCV Edge Detection

androidimage processingopencv

I am using OpenCV on Android for doing number plate recognition. As part of the process I am using Canny edge detection to find the edges within the image. The problem I am having is that the horizontal edges within the image are not being detected as solid lines. The problems is that because the lines are not solid I cannot detect it as one contour

This is the image that I am running the edge detection on

enter image description here

This is the result of the edge detection. As you can see the vertical edges of the number plate have been detected as solid lines but the horizontals are dotted.

enter image description here

Here is my code

        org.opencv.imgproc.Imgproc.Canny(snapshot.getImage(), dst,
            Configurator.PlateDetectCannyThreshold1,
            Configurator.PlateDetectCannyThreshold2,
            Configurator.PlateDetectCannyApperture);
    List<Mat> contours = new Vector<Mat>();
    org.opencv.imgproc.Imgproc.findContours(dst, contours, new Mat(),
            org.opencv.imgproc.Imgproc.CV_RETR_LIST,
            org.opencv.imgproc.Imgproc.CV_CHAIN_APPROX_SIMPLE,
            new org.opencv.core.Point(0, 0));

Best Answer

I ran into similar problem when i implement document edge detection and used Morphology to dilate the edge for better detection:

 Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_DILATE, new Size(3,3), new Point(1,1));
 Imgproc.dilate(mIntermediateMat, mIntermediateMat, kernel);