如何从图像中识别车辆牌照/车牌(ANPR)?

时间:2022-08-11 09:02:11

I have a web site that allows users to upload images of cars and I would like to put a privacy filter in place to detect registration plates on the vehicle and blur them.

我有一个网站,允许用户上传汽车的图像,我想放置一个隐私过滤器来检测车辆上的登记牌并模糊它们。

The blurring is not a problem but is there a library or component (open source preferred) that will help with finding a licence within a photo?

模糊不是问题,但有没有一个库或组件(首选开源)有助于在照片中找到许可证?

Caveats;

  1. I know nothing is perfect and image recognition of this type will provide false positive and negatives.
  2. 我知道没有什么是完美的,这种类型的图像识别将提供误报和否定。

  3. I appreciate that we could ask the user to select the area to blur and we will do this as well, but the question is specifically about finding that data programmatically; so answers such as 'get a person to check every image' is not helpful.
  4. 我感谢我们可以要求用户选择要模糊的区域,我们也会这样做,但问题是关于以编程方式查找数据;所以诸如“让一个人检查每个图像”之类的答案是没有用的。

  5. This software method is called 'Automatic Number Plate Recognition' in the UK but I cannot see any implementations of it as libraries.
  6. 这种软件方法在英国被称为“自动车牌识别”,但我看不到它作为库的任何实现。

  7. Any language is great although .Net is preferred.
  8. 虽然.Net是首选,但任何语言都很棒。

12 个解决方案

#1


I coded a C# version based on JAVA ANPR, but I changed the awt library functions with OpenCV. You can check it at http://anprmx.codeplex.com

我编写了一个基于JAVA ANPR的C#版本,但我用OpenCV更改了awt库函数。您可以在http://anprmx.codeplex.com上查看

#2


EDIT: I wrote a Python script for this.

编辑:我为此编写了一个Python脚本。

As your objective is blurring (for privacy protection), you basically need a high recall detector as a first step. Here's how to go about doing this. The included code hints use OpenCV with Python.

由于您的目标是模糊(用于隐私保护),您基本上需要一个高召回检测器作为第一步。这是如何做到这一点。包含的代码提示使用OpenCV和Python。

  1. Convert to Grayscale.
  2. 转换为灰度。

  3. Apply Gaussian Blur.

    应用高斯模糊。

    img = cv2.imread('input.jpg',1)
    img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    img_gray = cv2.GaussianBlur(img_gray, (5,5), 0)  
    

Let the input image be the following.

让输入图像如下。

如何从图像中识别车辆牌照/车牌(ANPR)?

  1. Apply Sobel Filter to detect vertical edges.
  2. 应用Sobel滤镜检测垂直边缘。

  3. Threshold the resultant image using strict threshold or OTSU's binarization.

    使用严格阈值或OTSU的二值化阈值来生成图像。

    cv2.Sobel(image, -1, 1, 0)
    cv2.threshold() 
    
  4. Apply a Morphological Closing operation using suitable structuring element. (I used 16x4 as structuring element)

    使用合适的结构元素应用形态学关闭操作。 (我使用16x4作为结构元素)

    se = cv2.getStructuringElement(cv2.MORPH_RECT,(16,4))
    cv2.morphologyEx(image, cv2.MORPH_CLOSE, se)  
    

Resultant Image after Step 5.

步骤5之后的结果图像。

如何从图像中识别车辆牌照/车牌(ANPR)?

  1. Find external contours of this image.

    查找此图像的外部轮廓。

    cv2.findContours(image, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) 
    
  2. For each contour, find the minAreaRect() bounding it.

    对于每个轮廓,找到绑定它的minAreaRect()。

  3. Select rectangles based on aspect ratio, minimum and maximum area, and angle with the horizontal. (I used 2.2 <= Aspect Ratio <= 8, 500 <= Area <=15000, and angle <= 45 degrees)
  4. 根据纵横比,最小和最大面积以及与水平面的角度选择矩形。 (我用2.2 <=纵横比<= 8,500 <=面积<= 15000,角度<= 45度)

All minAreaRect()s are shown in orange and the one which satisfies our criteria is in green.

所有minAreaRect()都以橙色显示,满足我们标准的是绿色。

如何从图像中识别车辆牌照/车牌(ANPR)?

  1. There may be false positives after this step, to filter it, use edge density. Edge Density is defined as the number of white pixels/total number of pixels in a rectangle. Set a threshold for edge density. (I used 0.5)
  2. 在此步骤之后可能存在误报,过滤它,使用边缘密度。边缘密度定义为矩形中的白色像素数/总像素数。设置边缘密度的阈值。 (我用了0.5)

如何从图像中识别车辆牌照/车牌(ANPR)?

  1. Blur the detected regions.
  2. 模糊检测到的区域。

如何从图像中识别车辆牌照/车牌(ANPR)?

You can apply other filters you deem suitable to increase recall and precision. The detection can also be trained using HOG+SVM to increase precision.

您可以应用您认为合适的其他过滤器来提高召回率和精确度。也可以使用HOG + SVM训练检测以提高精度。

#3


There is a new, open source library on GitHub that does ANPR for US and European plates. It looks pretty accurate and it should do exactly what you need (recognize the plate regions). Here is the GitHub project: https://github.com/openalpr/openalpr

GitHub上有一个新的开源库,用于处理美国和欧洲板块的ANPR。它看起来非常准确,它应该完全符合您的需要(识别板块区域)。这是GitHub项目:https://github.com/openalpr/openalpr

#4


I came across this one that is written in java javaANPR, I am looking for a c# library as well.

我遇到过这个用java javaANPR编写的,我也在寻找一个c#库。

I would like a system where I can point a video camera at some sailing boats, all of which have large, identifiable numbers on them, and have it identify the boats and send a tweet when they sail past a video camera.

我想要一个系统,我可以在一些帆船上指出一个摄像机,所有这些帆船上都有大量可识别的数字,并让它识别船只并在它们通过摄像机时发送一条推文。

#5


I have done some googling about this a couple of months ago. There are quite a few papers about this topic, but I never found any concrete open-source implementation. There are a lot of commercial implementations though, but none of them with a price quote, so they're probably pretty expensive.

几个月前我在Google上做了一些谷歌搜索。有很多关于这个主题的论文,但我从来没有找到任何具体的开源实现。虽然有很多商业实施,但没有一个带有报价,所以它们可能相当昂贵。

#6


try this Simple Automatic Number Plate Recognition System

试试这个简单的自动车牌识别系统

http://opos.codeplex.com/

Open source and written with C#

开源并用C#编写

#7


Have a look at Java ANPR. Free license plate recognition...

看看Java ANPR。免费车牌识别......

#8


Yes I use gocr at http://jocr.sourceforge.net/ its a commandline application which you could execute from your application. I use it in a couple of my applications.

是的我在http://jocr.sourceforge.net/使用gocr它是一个可以从你的应用程序执行的命令行应用程序。我在几个应用程序中使用它。

#9


High performance ANPR Library - http://www.dtksoft.com/dtkanpr.php. This is commercial, but they provide trial key.

高性能ANPR库 - http://www.dtksoft.com/dtkanpr.php。这是商业广告,但它们提供试用密钥。

#10


http://licenseplate.sourceforge.net Python (I have not tested it)

http://licenseplate.sourceforge.net Python(我还没有测试过)

#11


It maybe work looking at Character recoqnition software as there are many libraries out there that perform the same thing. I reading an image and storing it. Micrsoft office is able to read tiff files and return alphanumerics

它可能是在查看Character recoqnition软件,因为有许多库可以执行相同的操作。我正在阅读图像并存储它。 Micrsoft办公室能够读取tiff文件并返回字母数字

#12


The blurring is not a problem but is there a library or component (open source preferred) that will help with finding a licence within a photo?

模糊不是问题,但有没有一个库或组件(首选开源)有助于在照片中找到许可证?

Ans: The CARMEN FreeFlow ANPR Software engine (Commerical)

Ans:CARMEN FreeFlow ANPR软件引擎(商业)

#1


I coded a C# version based on JAVA ANPR, but I changed the awt library functions with OpenCV. You can check it at http://anprmx.codeplex.com

我编写了一个基于JAVA ANPR的C#版本,但我用OpenCV更改了awt库函数。您可以在http://anprmx.codeplex.com上查看

#2


EDIT: I wrote a Python script for this.

编辑:我为此编写了一个Python脚本。

As your objective is blurring (for privacy protection), you basically need a high recall detector as a first step. Here's how to go about doing this. The included code hints use OpenCV with Python.

由于您的目标是模糊(用于隐私保护),您基本上需要一个高召回检测器作为第一步。这是如何做到这一点。包含的代码提示使用OpenCV和Python。

  1. Convert to Grayscale.
  2. 转换为灰度。

  3. Apply Gaussian Blur.

    应用高斯模糊。

    img = cv2.imread('input.jpg',1)
    img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    img_gray = cv2.GaussianBlur(img_gray, (5,5), 0)  
    

Let the input image be the following.

让输入图像如下。

如何从图像中识别车辆牌照/车牌(ANPR)?

  1. Apply Sobel Filter to detect vertical edges.
  2. 应用Sobel滤镜检测垂直边缘。

  3. Threshold the resultant image using strict threshold or OTSU's binarization.

    使用严格阈值或OTSU的二值化阈值来生成图像。

    cv2.Sobel(image, -1, 1, 0)
    cv2.threshold() 
    
  4. Apply a Morphological Closing operation using suitable structuring element. (I used 16x4 as structuring element)

    使用合适的结构元素应用形态学关闭操作。 (我使用16x4作为结构元素)

    se = cv2.getStructuringElement(cv2.MORPH_RECT,(16,4))
    cv2.morphologyEx(image, cv2.MORPH_CLOSE, se)  
    

Resultant Image after Step 5.

步骤5之后的结果图像。

如何从图像中识别车辆牌照/车牌(ANPR)?

  1. Find external contours of this image.

    查找此图像的外部轮廓。

    cv2.findContours(image, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) 
    
  2. For each contour, find the minAreaRect() bounding it.

    对于每个轮廓,找到绑定它的minAreaRect()。

  3. Select rectangles based on aspect ratio, minimum and maximum area, and angle with the horizontal. (I used 2.2 <= Aspect Ratio <= 8, 500 <= Area <=15000, and angle <= 45 degrees)
  4. 根据纵横比,最小和最大面积以及与水平面的角度选择矩形。 (我用2.2 <=纵横比<= 8,500 <=面积<= 15000,角度<= 45度)

All minAreaRect()s are shown in orange and the one which satisfies our criteria is in green.

所有minAreaRect()都以橙色显示,满足我们标准的是绿色。

如何从图像中识别车辆牌照/车牌(ANPR)?

  1. There may be false positives after this step, to filter it, use edge density. Edge Density is defined as the number of white pixels/total number of pixels in a rectangle. Set a threshold for edge density. (I used 0.5)
  2. 在此步骤之后可能存在误报,过滤它,使用边缘密度。边缘密度定义为矩形中的白色像素数/总像素数。设置边缘密度的阈值。 (我用了0.5)

如何从图像中识别车辆牌照/车牌(ANPR)?

  1. Blur the detected regions.
  2. 模糊检测到的区域。

如何从图像中识别车辆牌照/车牌(ANPR)?

You can apply other filters you deem suitable to increase recall and precision. The detection can also be trained using HOG+SVM to increase precision.

您可以应用您认为合适的其他过滤器来提高召回率和精确度。也可以使用HOG + SVM训练检测以提高精度。

#3


There is a new, open source library on GitHub that does ANPR for US and European plates. It looks pretty accurate and it should do exactly what you need (recognize the plate regions). Here is the GitHub project: https://github.com/openalpr/openalpr

GitHub上有一个新的开源库,用于处理美国和欧洲板块的ANPR。它看起来非常准确,它应该完全符合您的需要(识别板块区域)。这是GitHub项目:https://github.com/openalpr/openalpr

#4


I came across this one that is written in java javaANPR, I am looking for a c# library as well.

我遇到过这个用java javaANPR编写的,我也在寻找一个c#库。

I would like a system where I can point a video camera at some sailing boats, all of which have large, identifiable numbers on them, and have it identify the boats and send a tweet when they sail past a video camera.

我想要一个系统,我可以在一些帆船上指出一个摄像机,所有这些帆船上都有大量可识别的数字,并让它识别船只并在它们通过摄像机时发送一条推文。

#5


I have done some googling about this a couple of months ago. There are quite a few papers about this topic, but I never found any concrete open-source implementation. There are a lot of commercial implementations though, but none of them with a price quote, so they're probably pretty expensive.

几个月前我在Google上做了一些谷歌搜索。有很多关于这个主题的论文,但我从来没有找到任何具体的开源实现。虽然有很多商业实施,但没有一个带有报价,所以它们可能相当昂贵。

#6


try this Simple Automatic Number Plate Recognition System

试试这个简单的自动车牌识别系统

http://opos.codeplex.com/

Open source and written with C#

开源并用C#编写

#7


Have a look at Java ANPR. Free license plate recognition...

看看Java ANPR。免费车牌识别......

#8


Yes I use gocr at http://jocr.sourceforge.net/ its a commandline application which you could execute from your application. I use it in a couple of my applications.

是的我在http://jocr.sourceforge.net/使用gocr它是一个可以从你的应用程序执行的命令行应用程序。我在几个应用程序中使用它。

#9


High performance ANPR Library - http://www.dtksoft.com/dtkanpr.php. This is commercial, but they provide trial key.

高性能ANPR库 - http://www.dtksoft.com/dtkanpr.php。这是商业广告,但它们提供试用密钥。

#10


http://licenseplate.sourceforge.net Python (I have not tested it)

http://licenseplate.sourceforge.net Python(我还没有测试过)

#11


It maybe work looking at Character recoqnition software as there are many libraries out there that perform the same thing. I reading an image and storing it. Micrsoft office is able to read tiff files and return alphanumerics

它可能是在查看Character recoqnition软件,因为有许多库可以执行相同的操作。我正在阅读图像并存储它。 Micrsoft办公室能够读取tiff文件并返回字母数字

#12


The blurring is not a problem but is there a library or component (open source preferred) that will help with finding a licence within a photo?

模糊不是问题,但有没有一个库或组件(首选开源)有助于在照片中找到许可证?

Ans: The CARMEN FreeFlow ANPR Software engine (Commerical)

Ans:CARMEN FreeFlow ANPR软件引擎(商业)