【问题标题】:Recognition Russian plate with a different character height in one line OpenALPR在一行中识别具有不同字符高度的俄罗斯车牌 OpenALPR
【发布时间】:2018-05-15 08:20:17
【问题描述】:

我对俄罗斯车牌有疑问。当我想用 openalpr 工具对字符进行分类时,我得到以下信息:

OCR 剪切了我上面的数字片段。我使用以下参数为这个国家/地区生成新的 .conf 文件:

char_analysis_min_pct = 0.29
char_analysis_height_range = 0.20
char_analysis_height_step_size = 0.10
char_analysis_height_num_steps = 6

segmentation_min_speckle_height_percent = 0.3
segmentation_min_box_width_px = 6
segmentation_min_charheight_percent = 0.1;
segmentation_max_segment_width_percent_vs_average = 1.95;

plate_width_mm= 520
plate_height_mm = 112

multiline = 1

char_height_mm = 58
char_width_mm = 44

char_whitespace_top_mm = 18
char_whitespace_bot_mm = 18

template_max_width_px = 300
template_max_height_px = 64

; Higher sensitivity means less lines
plateline_sensitivity_vertical = 10
plateline_sensitivity_horizontal = 45

; Regions smaller than this will be disqualified
min_plate_size_width_px = 65
min_plate_size_height_px = 18

; Results with fewer or more characters will be discarded
postprocess_min_characters = 8
postprocess_max_characters = 9

;detector_file= eu.xml
ocr_language = lamh

;Override for postprocess letters/numbers regex.
postprocess_regex_letters = [A,B,C,E,H,K,M,O,P,T,X,Y]
postprocess_regex_numbers = [0-9]

; Whether the plate is always dark letters on light background, light letters on dark background, or both
; value can be either always, never, or auto
invert = auto

有人知道怎么解决吗?

开始我使用了来自这个存储库https://github.com/KostyaKulakov/Russian_System_of_ANPR的OCR文件

谢谢。

【问题讨论】:

  • 你应该先提取区域然后做OCR
  • 另外,能发原图吗?
  • @Link 我使用了来自存储库 OpenALPR openalpr-utils-classifychars 的工具,所以这个工具在运行 OCR 之前提取区域。我在帖子中添加了原始照片的链接。
  • OpenALPR 是必须的吗?一旦你有了上面提供的图像,识别字符就不难了,因为它都很干净。当您必须从整车图像/视频中提取车牌时,问题就来了。那么,您拥有的所有图像都像上面发布的那样吗?我这样说是为了以另一种方式解决问题,也是因为我从未使用过这种实用程序。这一切都是自动的,而我可以提供的“解决方案”更多的是手动..
  • @Link 我需要打开 ALPR,因为我为我的使用系统构建了车牌检测。我必须将俄罗斯车牌标准添加到 OpenALPR 引擎,因为有时我有来自俄罗斯的客人。所以,我需要提取带有字母和数字的瓦片来训练 OCR。当我使用欧洲标准板时,一切都很好。当我使用俄罗斯时,我遇到了上述情况。

标签: opencv ocr openalpr


【解决方案1】:

也许是这样的?

import cv2
import numpy as np

image = cv2.imread('plate.png')
# cv2.imshow('original', image)

gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# cv2.imshow('gray', gray)

ret, thresh = cv2.threshold(gray, 60, 255, cv2.THRESH_BINARY_INV)
cv2.imshow('thresh', thresh)

blur = cv2.medianBlur(thresh, 1)

kernel = np.ones((10, 20), np.uint8)
img_dilation = cv2.dilate(blur, kernel, iterations=1)
cv2.imshow('dilated', img_dilation)

im2, ctrs, hier = cv2.findContours(img_dilation.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

# sort contours
sorted_ctrs = sorted(ctrs, key=lambda ctr: cv2.boundingRect(ctr)[0])

for i, ctr in enumerate(sorted_ctrs):
    # Get bounding box
    x, y, w, h = cv2.boundingRect(ctr)

    # Getting ROI
    roi = image[y:y + h, x:x + w]

    if (h > 50 and w > 50) and h < 200:

        # show ROI
        # cv2.imshow('segment no:'+str(i),roi)
        cv2.rectangle(image, (x, y), (x + w, y + h), (255, 255, 255), 1)
        # cv2.waitKey(0)

        cv2.imwrite('{}.png'.format(i), roi)

cv2.imshow('marked areas', image)
cv2.waitKey(0)

这将为您节省所有需要的投资回报率...

(最后一张图片可以再次分割)

... 并对每个字符进行 OCR。在我看来,这可能比对整个图像进行 OCR 更容易。

如果您对每个图像进行一些阈值处理并添加一个 IDK 5 像素边框,那么所有过程都会更容易。

【讨论】:

    猜你喜欢
    • 2010-10-27
    • 2016-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多