简体   繁体   English

Android OpenCV边缘检测

[英]Android OpenCV Edge Detection

I am using OpenCV on Android for doing number plate recognition. 我在Android上使用OpenCV进行车牌识别。 As part of the process I am using Canny edge detection to find the edges within the image. 作为过程的一部分,我使用Canny边缘检测来查找图像中的边缘。 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 这是我正在运行边缘检测的图像

在此输入图像描述

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. 如您所见,号牌的垂直边缘已被检测为实线,但水平线是虚线。

在此输入图像描述

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));

I ran into similar problem when i implement document edge detection and used Morphology to dilate the edge for better detection: 当我实现文档边缘检测并使用Morphology扩展边缘以便更好地检测时,我遇到了类似的问题:

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

A quick and dirty solution would be using morphological closing operation as described here . 一个快速和肮脏的解决办法是使用如所描述的形态学闭运算这里

Morphological closing operation helps filling small gaps. 形态学关闭操作有助于填补小空白。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM