[go: up one dir, main page]

CN109426814B - Method, system and equipment for positioning and identifying specific plate of invoice picture - Google Patents

Method, system and equipment for positioning and identifying specific plate of invoice picture Download PDF

Info

Publication number
CN109426814B
CN109426814B CN201710724450.9A CN201710724450A CN109426814B CN 109426814 B CN109426814 B CN 109426814B CN 201710724450 A CN201710724450 A CN 201710724450A CN 109426814 B CN109426814 B CN 109426814B
Authority
CN
China
Prior art keywords
invoice
picture
identified
area
image
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710724450.9A
Other languages
Chinese (zh)
Other versions
CN109426814A (en
Inventor
武晨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
SF Technology Co Ltd
Original Assignee
SF Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by SF Technology Co Ltd filed Critical SF Technology Co Ltd
Priority to CN201710724450.9A priority Critical patent/CN109426814B/en
Publication of CN109426814A publication Critical patent/CN109426814A/en
Application granted granted Critical
Publication of CN109426814B publication Critical patent/CN109426814B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/22Image preprocessing by selection of a specific region containing or referencing a pattern; Locating or processing of specific regions to guide the detection or recognition
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/24Aligning, centring, orientation detection or correction of the image
    • G06V10/243Aligning, centring, orientation detection or correction of the image by compensating for image skew or non-uniform image deformations
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/25Determination of region of interest [ROI] or a volume of interest [VOI]
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/26Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion
    • G06V10/267Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion by performing operations on regions, e.g. growing, shrinking or watersheds
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/26Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion
    • G06V10/273Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion removing elements interfering with the pattern to be recognised
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/48Extraction of image or video features by mapping characteristic values of the pattern into a parameter space, e.g. Hough transformation

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Theoretical Computer Science (AREA)
  • Image Analysis (AREA)
  • Character Input (AREA)

Abstract

本发明涉及一种发票图片特定板块的定位、识别方法、系统、设备。该发票图片特定板块的定位、识别方法,包括:获取发票图片;确定待识别发票信息;根据待识别发票信息,对其所在发票图片的区域定位、分割,获得待识别发票信息图片;对待识别发票信息图片的文字内容进行识别,获取待识别发票信息。由于识别之前,直接针对目标进行定位、切割,故每一识别内容所对应的发票信息,清楚明了,开创新的实现了自动每一识别发票,填补了本技术领域的空白,具有广阔的应用前景。从根本上解决了现有图像识别算法只能无差别地识别发票图片中的每一个字符,但是无法将所需发票信息区分出来的弊端。使发票信息的获取真正实现了自动化。

Figure 201710724450

The invention relates to a positioning and identification method, system and equipment for a specific plate of an invoice picture. The method for locating and identifying the specific section of the invoice picture includes: obtaining the invoice picture; The text content of the information picture is recognized to obtain the invoice information to be recognized. Before the recognition, the target is directly positioned and cut, so the invoice information corresponding to each recognition content is clear and clear, and it is innovative to realize the automatic recognition of each invoice, which fills the gap in this technical field and has broad application prospects. . It fundamentally solves the disadvantage that the existing image recognition algorithm can only recognize each character in the invoice picture indiscriminately, but cannot distinguish the required invoice information. The acquisition of invoice information is truly automated.

Figure 201710724450

Description

一种发票图片特定板块的定位、识别方法、系统、设备A positioning and identification method, system, and equipment for a specific section of an invoice image

技术领域technical field

本发明涉及发票,尤其涉及一种发票图片特定板块的定位、识别方法、系统、设备。The invention relates to invoices, in particular to a positioning and identification method, system and equipment for a specific plate of an invoice picture.

背景技术Background technique

处理发票报销是公司财务部门的一项非常重要的工作,工作人员需要获取每张发票中的票号序列、公司名称、开票日期、金额和税额等信息进行下一步的验证等工作。工作繁重。Processing invoice reimbursement is a very important task for the company's financial department. Staff need to obtain information such as the invoice number sequence, company name, invoice date, amount, and tax amount in each invoice for further verification and other work. Heavy work.

而传统的图像识别算法虽然能逐行无差别地识别发票图片中的每一个字,每一个符号,但是并不能识别出,哪一个字段是发票编号,哪一个字段是日期,哪一个字段是金额等。Although the traditional image recognition algorithm can identify every word and every symbol in the invoice picture line by line without distinction, it cannot recognize which field is the invoice number, which field is the date, and which field is the amount. wait.

因此,现在针对发票信息的获取仍然只能通过人为完成。Therefore, the acquisition of invoice information can only be done manually.

发明内容Contents of the invention

为了解决上述技术问题,本发明的目的在于提供一种发票图片特定板块的定位、识别方法、系统、设备。In order to solve the above-mentioned technical problems, the object of the present invention is to provide a method, system and equipment for locating and identifying a specific section of an invoice image.

根据本发明的一个方面,提供了一种发票图片特定板块的定位、识别方法,包括:According to one aspect of the present invention, a method for locating and identifying a specific section of an invoice image is provided, including:

获取发票图片;Get the picture of the invoice;

确定待识别发票信息;Determine the invoice information to be identified;

根据待识别发票信息,对其所在发票图片的区域定位、分割,获得待识别发票信息图片;According to the invoice information to be identified, locate and segment the area of the invoice picture where it is located, and obtain the image of the invoice information to be identified;

对待识别发票信息图片的文字内容进行识别,获取待识别发票信息。Identify the text content of the image of the invoice information to be identified, and obtain the invoice information to be identified.

本发明通过任何简单的方法获得左右待处理发票的图片,然后通过一些图像处理方法将所有图片中以各种位置、各种旋转角度、各种亮度情况的发票有效区域截取并摆正,进而结合逻辑处理,采用Canny轮廓检测、图像文本检测、颜色检测、提取“行、列”的方法精确地定位到一张图片中每一个待识别的区域,并截取成为一个个的碎片,分别进行识别。由自动获取发票信息替代原人为方式。不但准确度高,而且大大提高了效率。The present invention obtains the pictures of the left and right invoices to be processed by any simple method, and then intercepts and straightens the effective areas of the invoices in all pictures at various positions, various rotation angles, and various brightness conditions through some image processing methods, and then combines Logical processing, using Canny contour detection, image text detection, color detection, and extraction of "rows and columns" to accurately locate each area to be recognized in a picture, and intercept them into fragments for recognition separately. The original manual method is replaced by automatically obtaining invoice information. Not only the accuracy is high, but also the efficiency is greatly improved.

进一步的,待识别发票信息包括票号序列、公司名称、开票日期、金额和税额。Further, the invoice information to be identified includes invoice number sequence, company name, invoice date, amount and tax amount.

进一步的,获取发票图片之后包括截取发票有效区域。Further, after obtaining the invoice image, it includes intercepting the effective area of the invoice.

进一步的,截取发票有效区域之前包括:摆正发票图片。Further, before intercepting the effective area of the invoice, it includes: aligning the invoice picture.

进一步的,摆正发票图片包括:Further, the straightened invoice pictures include:

利用openCV的HoughLine算法检测发票图片中所有的线条;Use openCV's HoughLine algorithm to detect all the lines in the invoice image;

计算每条线的偏转角度;Calculate the deflection angle for each line;

出现最多次的旋转角度为该图片的偏转角度;The rotation angle that appears most times is the deflection angle of the picture;

根据偏转角度旋转所述图片,摆正发票图片。Rotate the picture according to the deflection angle to straighten the picture of the invoice.

进一步的,截取发票有效区域包括:Further, intercepting the effective area of the invoice includes:

提取该发票图片中发票有效区域的轮廓;Extract the outline of the effective area of the invoice in the invoice image;

基于该轮廓分割得到发票有效区域的图片。A picture of the effective area of the invoice is obtained based on the contour segmentation.

进一步的,得到发票有效区域的图片之后执行步骤包括通过SIFT算法,判断发票票头的位置是否在图片的上方,否则,则上下翻转所述图片。其中,SIFT是一种电脑视觉的算法用来侦测与描述影像中的局部性特征。Further, after obtaining the picture of the effective area of the invoice, the execution step includes using the SIFT algorithm to determine whether the position of the invoice head is above the picture, otherwise, flipping the picture upside down. Among them, SIFT is a computer vision algorithm used to detect and describe local features in images.

进一步的,提取该发票图片中发票有效区域的轮廓,包括:Further, the outline of the effective area of the invoice in the invoice image is extracted, including:

分别计算发票图片的每一像素列的像素值之和、每一像素行的像素值之和,得到两个向量;Calculate the sum of the pixel values of each pixel column and the sum of the pixel values of each pixel row of the invoice image respectively to obtain two vectors;

将两个向量相乘,得到二维数组;Multiply two vectors to get a two-dimensional array;

将这个二维数组转换成对应的灰度图片;Convert this two-dimensional array into the corresponding grayscale image;

过滤并去除发票图片中的横线和竖线,得到发票有效区域的轮廓。Filter and remove the horizontal and vertical lines in the invoice image to obtain the outline of the effective area of the invoice.

具体为:Specifically:

分别计算带有未去除背景的整张发票图片的每一像素列的像素值之和、每一像素行的像素值之和,得到两个向量(这里计算的像素行或列之和都是针对包括背景的一整张图片来计算的,因为程序并不知道发票有效区域的轮廓在哪里,而程序需要通过计算像素行列和、相乘、去横线等这些步骤才能找到发票有效区域的轮廓在哪里);Calculate the sum of the pixel values of each pixel column and the sum of the pixel values of each pixel row of the entire invoice image with no background removed to obtain two vectors (the sum of the pixel rows or columns calculated here is for It is calculated by including a whole picture of the background, because the program does not know where the outline of the effective area of the invoice is, and the program needs to find the outline of the effective area of the invoice by calculating the pixel row and column sum, multiplying, and removing horizontal lines. where);

将两个向量相乘,得到二维数组;Multiply two vectors to get a two-dimensional array;

将这个二维数组转换成对应的灰度图片(将所有的值按照比例归一化到0到255的范围,从0到255的每个值依次表示从白色到不同等级的灰色再到黑色的灰度值);Convert this two-dimensional array into a corresponding grayscale image (normalize all values to the range of 0 to 255 in proportion, each value from 0 to 255 represents from white to different levels of gray to black in turn grayscale value);

通过openCV工具包中的cv2.morphologyEx功能(定向过滤图片中的某种形态)定向过滤图片中的横线和竖线(通过改变参数来决定过滤哪种形态),去除图片中的横线和竖线,得到发票有效区域的轮廓。Through the cv2.morphologyEx function in the openCV toolkit (directed filtering of a certain form in the picture), the horizontal and vertical lines in the picture are directional filtered (by changing the parameters to determine which form to filter), and the horizontal and vertical lines in the picture are removed. line to get the outline of the effective area of the invoice.

上述方法确保提取发票的有效区域能够不受发票有效区域在照片的位置角度,明暗程度,图片光线阴影等干扰因素的影响,精确地截取出发票的有效区域。The above method ensures that the effective area of the invoice can be extracted without being affected by interference factors such as the position angle of the effective area of the invoice in the photo, the degree of light and shade, light and shadow of the picture, and the effective area of the invoice can be accurately intercepted.

进一步的,对待识别发票信息所在区域定位、分割包括:Further, the positioning and segmentation of the area where the invoice information is to be identified includes:

利用Canny算法获取与预设定位模板匹配的区域及匹配区域的顶点坐标;Use the Canny algorithm to obtain the area matching the preset positioning template and the vertex coordinates of the matching area;

根据匹配区域的顶点坐标,获取待识别发票信息所在区域图片;According to the vertex coordinates of the matching area, obtain the image of the area where the invoice information to be identified is located;

提取所述区域图片内待识别发票信息文字的像素,并进行逆向二值化处理;Extract the pixel of the invoice information text to be recognized in the image of the area, and perform reverse binarization processing;

计算所述区域图片行和列的像素值之和,将其与区分文字与空隙的预设门限值比对,判断并分割出待识别发票信息图片。Calculate the sum of the pixel values of the rows and columns of the image in the area, compare it with the preset threshold value for distinguishing characters and gaps, and judge and segment the image of the invoice information to be recognized.

进一步的,利用Canny算法获取与预设定位模板匹配的区域及匹配区域的顶点坐标,包括:Further, the Canny algorithm is used to obtain the area matching the preset positioning template and the vertex coordinates of the matching area, including:

截取待识别发票信息所在区域的部分图片;Capture some pictures of the area where the invoice information to be identified is located;

对该部分图片进行缩放,得到多张缩放图;Scale the part of the picture to get multiple zoomed pictures;

将多张缩放图及预设定位模板输入Canny算法进行运算,得出与预设定位模板匹配的区域及匹配区域的顶点坐标。Input multiple zoom images and preset positioning templates into the Canny algorithm for calculation, and obtain the area matching the preset positioning template and the vertex coordinates of the matching area.

通过多张缩放图均与定位模板进行轮廓匹配,进行匹配区域的定位,定位精度高。The contour matching of multiple zoom images and the positioning template is performed to locate the matching area, and the positioning accuracy is high.

定位匹配区域并得到匹配区域的顶点坐标后,根据匹配区域与获取待识别发票信息所在区域图片的位置关系,定位获取待识别发票信息所在区域图片。After locating the matching area and obtaining the vertex coordinates of the matching area, according to the positional relationship between the matching area and the image of the area where the invoice information to be identified is obtained, locate and acquire the image of the area where the invoice information to be identified is obtained.

其中,缩放的比例参数为0.8-1.2。Wherein, the scaling parameter is 0.8-1.2.

进一步的,计算所述区域图片行和列的像素值之和,将其与门限值比对,判断并分割出待识别发票信息图片包括:Further, calculating the sum of the pixel values of the row and column of the image in the area, comparing it with the threshold value, judging and segmenting the invoice information image to be identified includes:

计算所述区域图片每一个像素行的像素值之和,根据像素行的门限值判断并分割出待识别发票信息所在行区域图片;Calculate the sum of the pixel values of each pixel row of the region picture, judge and segment the row region picture where the invoice information to be identified is located according to the threshold value of the pixel row;

计算行区域图片每一像素列的像素值之和,根据像素列的门限值判断并分割出待识别发票信息图片。Calculate the sum of the pixel values of each pixel column in the row area picture, judge and segment the invoice information picture to be recognized according to the threshold value of the pixel column.

其中,上述门限值需要根据这个图片中每一行或列的文字数量和图片噪声多少决定,实际操作中首先将每个像素行或列的像素值之和都输出出来,然后开发人员查看没有文字的像素行或列和有文字的像素行或列的像素和的值的大致临界值为多少,即为门限值。Among them, the above threshold needs to be determined according to the amount of text in each row or column of the picture and the amount of noise in the picture. In actual operation, the sum of the pixel values of each pixel row or column is first output, and then the developer checks if there is no text. The approximate critical value of the value of the sum of pixels in the pixel row or column and the pixel row or column with text is the threshold value.

其中,像素行的门限值为14000,像素列的门限值为4000。Wherein, the threshold value of the pixel row is 14000, and the threshold value of the pixel column is 4000.

根据本发明的另一个方面,提供了一种发票图片特定板块的定位、识别系统,包括:According to another aspect of the present invention, a positioning and identification system for a specific block of an invoice image is provided, including:

获取发票图片的采集单元;Acquisition unit for obtaining invoice pictures;

根据待识别发票信息,对其所在发票图片的区域定位、分割,获得待识别发票信息图片的定位单元;According to the invoice information to be identified, locate and segment the area of the invoice image where it is located, and obtain the positioning unit of the image of the invoice information to be identified;

对待识别发票信息图片的文字内容进行识别,获取待识别发票信息的识别单元。Recognize the text content of the picture of the invoice information to be recognized, and obtain the recognition unit of the invoice information to be recognized.

进一步的,待识别发票信息包括票号序列、公司名称、开票日期、金额和税额。Further, the invoice information to be identified includes invoice number sequence, company name, invoice date, amount and tax amount.

该系统为基于上述发票图片特定板块的定位、识别方法的系统,其截取发票有效区域、对待识别发票信息所在区域定位、分割及对待识别发票信息图片的文字内容进行识别,获取待识别发票信息等步骤如发票图片特定板块的定位、识别方法部分所述。The system is based on the positioning and identification method of the above-mentioned specific section of the invoice picture, which intercepts the effective area of the invoice, locates and divides the area where the invoice information to be identified is located, and identifies the text content of the image of the invoice information to be identified, and obtains the invoice information to be identified, etc. The steps are as described in the positioning and identification methods of the specific section of the invoice image.

根据本发明的另一个方面,提供了一种发票图片特定板块的定位、识别设备,包括存储有计算机程序的计算机可读介质,所述程序被运行用于执行:According to another aspect of the present invention, a device for locating and identifying a specific block of an invoice image is provided, comprising a computer-readable medium storing a computer program, the program being run to perform:

获取发票图片;Get the picture of the invoice;

确定待识别发票信息;Determine the invoice information to be identified;

根据待识别发票信息,对其所在发票图片的区域定位、分割,获得待识别发票信息图片;According to the invoice information to be identified, locate and segment the area of the invoice picture where it is located, and obtain the image of the invoice information to be identified;

对待识别发票信息图片的文字内容进行识别,获取待识别发票信息。Identify the text content of the image of the invoice information to be identified, and obtain the invoice information to be identified.

该设备为基于上述发票图片特定板块的定位、识别方法的设备,其截取发票有效区域、对待识别发票信息所在区域定位、分割及对待识别发票信息图片的文字内容进行识别,获取待识别发票信息等步骤如发票图片特定板块的定位、识别方法部分所述。The device is based on the positioning and identification method of the above-mentioned specific section of the invoice picture, which intercepts the effective area of the invoice, locates and divides the area where the invoice information to be identified is located, and identifies the text content of the image of the invoice information to be identified, and obtains the invoice information to be identified, etc. The steps are as described in the positioning and identification methods of the specific section of the invoice image.

与现有技术相比,本发明具有以下有益效果:Compared with the prior art, the present invention has the following beneficial effects:

1、本发明示例的发票图片特定板块的定位、识别方法,根据待识别发票信息,对其所在发票图片的区域定位、分割,获得待识别发票信息图片;对待识别发票信息图片的文字内容进行识别,获取待识别发票信息。由于识别之前,直接针对目标进行定位、切割,故每一识别内容所对应的发票信息,清楚明了,开创新的实现了自动每一识别发票,填补了本技术领域的空白,具有广阔的应用前景。1. The positioning and identification method of the specific plate of the invoice picture of the example of the present invention, according to the invoice information to be identified, locate and segment the area of the invoice picture where it is located, and obtain the image of the invoice information to be identified; identify the text content of the image of the invoice information to be identified , to obtain the invoice information to be recognized. Before the identification, the target is directly positioned and cut, so the invoice information corresponding to each identification content is clear and clear. It is innovative and realizes the automatic identification of each invoice, which fills the gap in this technical field and has broad application prospects. .

2、本发明示例的发票图片特定板块的定位、识别方法,提取发票的有效区域能够不受发票有效区域在照片的位置角度,明暗程度,图片光线阴影等干扰因素的影响,精确地截取出发票的有效区域;而且进一步检测发票的偏转角度,并摆正图片。进而结合逻辑处理,采用Canny轮廓检测、图像文本检测、颜色检测、提取行、列的方法精确地定位到一张图片中每一个待识别的区域,并截取成为一个个的碎片,分别进行识别。确保定位精确,识别准确。2. The method for locating and identifying the specific plate of the invoice picture in the example of the present invention can extract the effective area of the invoice without being affected by interference factors such as the position angle of the effective area of the invoice in the photo, the degree of light and shade, the light and shadow of the picture, and the invoice can be accurately intercepted The effective area; and further detect the deflection angle of the invoice, and straighten the picture. Furthermore, combined with logical processing, the methods of Canny contour detection, image text detection, color detection, and row and column extraction are used to accurately locate each area to be recognized in a picture, and intercept each area to be recognized separately. Ensure accurate positioning and accurate identification.

3、本发明示例的发票图片特定板块的定位、识别系统,通过采集单元获取发票图片;通过定位单元,根据待识别发票信息,对其所在发票图片的区域定位、分割,获得待识别发票信息图片;通过识别单元对待识别发票信息图片的文字内容进行识别,获取待识别发票信息,由于待识别发票信息明确,其所在发票的位置明确,故先通过实现确定待识别的发票信息,然后对该发票信息所在区域进行定位、切割获得具有待识别信息内容的图片,然后通过对该图片识别获得相应发票信息,故每一识别过程所所对应的识别信息明确,从根本上解决了现有图像识别算法只能无差别地识别发票图片中的每一个字符,但是无法将所需发票信息区分出来的弊端。使发票信息的获取真正实现了自动化。3. The positioning and identification system of the specific plate of the invoice picture in the example of the present invention obtains the invoice picture through the acquisition unit; through the positioning unit, according to the invoice information to be identified, the area of the invoice picture where it is located is positioned and segmented to obtain the invoice information picture to be identified ; Identify the text content of the invoice information picture to be identified by the identification unit, and obtain the invoice information to be identified. Since the information of the invoice to be identified is clear and the position of the invoice is clear, the invoice information to be identified is first determined through implementation, and then the invoice information is determined. The area where the information is located is located and cut to obtain a picture with information content to be identified, and then the corresponding invoice information is obtained by identifying the image, so the identification information corresponding to each identification process is clear, which fundamentally solves the problem of existing image identification algorithms. It can only identify each character in the invoice picture without distinction, but cannot distinguish the required invoice information. The acquisition of invoice information is truly automated.

4、本发明示例的发票图片特定板块的定位、识别设备,存储、被运行用于执行下述程序:获取发票图片;确定待识别发票信息;根据待识别发票信息,对其所在发票图片的区域定位、分割,获得待识别发票信息图片;对待识别发票信息图片的文字内容进行识别,获取待识别发票信息。仅需发票图片,通过运行上述程序即可自动识别发票信息,无需人工识别,不但保证了准确度,而且也大大提高了效率。4. The positioning and identification equipment of the specific plate of the invoice image in the example of the present invention is stored and operated to perform the following procedures: obtain the invoice image; determine the invoice information to be identified; according to the invoice information to be identified, identify the area of the invoice image Locate and segment to obtain the image of the invoice information to be identified; identify the text content of the image of the invoice information to be identified to obtain the invoice information to be identified. Only the invoice picture is needed, and the invoice information can be automatically identified by running the above program without manual identification, which not only ensures the accuracy, but also greatly improves the efficiency.

附图说明Description of drawings

图1为本发明的实施例一获取的初始发票图片示意图;Fig. 1 is a schematic diagram of an initial invoice picture obtained in Embodiment 1 of the present invention;

图2为本发明的实施例一摆正的发票图片示意图;Fig. 2 is a schematic diagram of an invoice picture in Embodiment 1 of the present invention;

图3为本发明的实施例一摆正发票图片的有效区域示意图;Fig. 3 is a schematic diagram of an effective area for straightening an invoice picture in Embodiment 1 of the present invention;

图4为本发明的实施例一摆正、未颠倒的发票有效区域的示意图;Fig. 4 is a schematic diagram of an invoice valid area that is straightened and not reversed according to Embodiment 1 of the present invention;

图5为本发明的实施例一待识别发票信息公司名称的示意图;Fig. 5 is a schematic diagram of the name of the company whose invoice information is to be identified according to an embodiment of the present invention;

图6为本发明的实施例一定位模板示意图;6 is a schematic diagram of a positioning template according to an embodiment of the present invention;

图7为本发明的实施例一与定位模板匹配程度最高的缩放图;Fig. 7 is a zoomed-in diagram with the highest degree of matching with the positioning template according to Embodiment 1 of the present invention;

图8为本发明的实施例一待识别发票信息公司名称所在区域的示意图;Fig. 8 is a schematic diagram of the area where the company name of the invoice information to be identified is located according to Embodiment 1 of the present invention;

图9为本发明的实施例一待识别发票信息公司名称所在行示意图;Fig. 9 is a schematic diagram of the line where the company name of the invoice information to be identified is located according to the embodiment of the present invention;

图10为本发明的实施例一待识别发票信息公司名称图片示意图。Fig. 10 is a schematic diagram of a picture of the company name of the invoice information to be recognized in Embodiment 1 of the present invention.

具体实施方式Detailed ways

为了更好的了解本发明的技术方案,下面结合具体实施例对本发明作进一步说明。In order to better understand the technical solutions of the present invention, the present invention will be further described below in conjunction with specific examples.

实施例一:Embodiment one:

本实施例提供了一种发票图片特定板块的定位、识别方法,以增值税发票为例进行阐述,该方法包括:This embodiment provides a method for locating and identifying a specific section of an invoice picture, taking a value-added tax invoice as an example, and the method includes:

S1、从增值税发票图片中提取并摆正发票有效区域:S1. Extract and straighten the effective area of the invoice from the VAT invoice picture:

发票图片往往是人们在各种不确定的实际条件下拍摄的,所以发票的有效区域在图片中的位置,背景图样,光线,清晰度和发票的旋转角度都是不固定的,这样的情况是无法直接调用图像识别的程序来识别的,所以需要首先定位每一个目标的精确位置将它们分别截取成为单独的碎片在拿去识别。Invoice pictures are often taken by people under various uncertain actual conditions, so the position of the effective area of the invoice in the picture, the background pattern, light, clarity and the rotation angle of the invoice are not fixed. Such a situation is It is impossible to directly call the image recognition program to identify, so it is necessary to first locate the precise position of each target and intercept them into individual fragments for identification.

S1.1、获取发票图片,如图1所示;S1.1. Obtain the picture of the invoice, as shown in Figure 1;

S1.2、读取发票图片,利用openCV的HoughLine算法检测发票图片中所有的线条;计算每条线的偏转角度;找到出现最多次的旋转角度,即为该图片的偏转角度;根据偏转角度逆向旋转图片进而得到摆正的图片,如图2所示;S1.2. Read the invoice picture, use openCV's HoughLine algorithm to detect all the lines in the invoice picture; calculate the deflection angle of each line; find the most frequent rotation angle, which is the deflection angle of the picture; reverse according to the deflection angle Rotate the picture to obtain a straightened picture, as shown in Figure 2;

S1.3、针对摆正的发票图片,首先提取所有细节的轮廓,计算每一像素列的像素值之和,再计算每一像素行的像素值之和,两个向量相乘成为二维数组(可当做二维图片处理);去除这个图片中的横线和竖线进而完全地分割发票区域和背景,获得摆正发票图片的有效区域轮廓,截取,得到发票有效区域的图片,如图3所示,具体为:S1.3. For the straightened invoice image, first extract the contours of all details, calculate the sum of the pixel values of each pixel column, and then calculate the sum of the pixel values of each pixel row, and multiply the two vectors to form a two-dimensional array (It can be treated as a two-dimensional image); remove the horizontal and vertical lines in the image to completely divide the invoice area and background, obtain the outline of the effective area of the invoice image, intercept, and obtain the image of the effective area of the invoice, as shown in Figure 3 As shown, specifically:

提取该摆正发票图片的发票有效区域的轮廓:Extract the outline of the valid area of the invoice that squares the invoice image:

分别计算带有未去除背景的整张发票图片的每一像素列的像素值之和、每一像素行的像素值之和,得到两个向量(这里计算的像素行或列之和都是针对包括背景的一整张图片来计算的,因为程序并不知道发票有效区域的轮廓在哪里,而程序需要通过计算像素行列和、相乘、去横线等这些步骤才能找到发票有效区域的轮廓在哪里);Calculate the sum of the pixel values of each pixel column and the sum of the pixel values of each pixel row of the entire invoice image with no background removed to obtain two vectors (the sum of the pixel rows or columns calculated here is for It is calculated by including a whole picture of the background, because the program does not know where the outline of the effective area of the invoice is, and the program needs to find the outline of the effective area of the invoice by calculating the pixel row and column sum, multiplying, and removing horizontal lines. where);

将两个向量相乘,得到二维数组;Multiply two vectors to get a two-dimensional array;

将这个二维数组转换成对应的灰度图片(将所有的值按照比例归一化到0到255的范围,从0到255的每个值依次表示从白色到不同等级的灰色再到黑色的灰度值);Convert this two-dimensional array into a corresponding grayscale image (normalize all values to the range of 0 to 255 in proportion, each value from 0 to 255 represents from white to different levels of gray to black in turn grayscale value);

通过openCV工具包中的cv2.morphologyEx功能(定向过滤图片中的某种形态)定向过滤图片中的横线和竖线(通过改变参数来决定过滤哪种形态),去除图片中的横线和竖线得到发票有效区域轮廓;Through the cv2.morphologyEx function in the openCV toolkit (directed filtering of a certain form in the picture), the horizontal and vertical lines in the picture are directional filtered (by changing the parameters to determine which form to filter), and the horizontal and vertical lines in the picture are removed. Line to get the outline of the effective area of the invoice;

S1.4、通过SIFT算法,找到发票票头的位置是否图片的上方,若否,则将图片上下翻转,最终得到没有偏转角度、未颠倒的只有发票有效区域的发票图片,如图4所示。S1.4. Through the SIFT algorithm, find out whether the position of the invoice head is above the picture. If not, flip the picture up and down, and finally get an invoice picture with no deflection angle and no upside down, only the valid area of the invoice, as shown in Figure 4 .

S2、根据待识别发票信息,对其所在发票图片的区域定位、分割,获得待识别发票信息图片:S2. According to the invoice information to be identified, locate and segment the area of the invoice picture where it is located, and obtain the image of the invoice information to be identified:

S2.1、确定待识别发票信息:公司名称,如图5所示;S2.1. Determine the invoice information to be identified: company name, as shown in Figure 5;

S2.2、根据待识别发票信息,确定定位模板,如图6所示,由于待识别发票信息在发票中的位置固定,可以根据不同的识别信息确定不同的定位模板;S2.2. Determine the positioning template according to the invoice information to be identified, as shown in Figure 6, since the position of the invoice information to be identified in the invoice is fixed, different positioning templates can be determined according to different identification information;

S2.3利用定位模板对整张图进行模板匹配,确定其在发票图片的大体位置,截取待识别发票信息所在区域的部分图片,本发明有目的地定位增值税发票中关注的板块,自动检测过滤掉不需要的区域;S2.3 Use the positioning template to perform template matching on the entire picture, determine its general position in the invoice picture, and intercept part of the picture in the area where the invoice information to be identified is located. The present invention purposefully locates the concerned plate in the value-added tax invoice, and automatically detects it. filter out unwanted areas;

S2.4、对该公司名称信息所在区域的部分图片从比例参数0.8到1.2倍进行10步缩放,获得10张缩放图;S2.4. Perform 10-step zooming on some pictures in the area where the company name information is located from 0.8 to 1.2 times the scale parameter, and obtain 10 zoomed pictures;

S2.5、运算获得这10张图和定位模板的Canny轮廓图,然后从这10张图中通过模板匹配找到与模板相似的区域,同时计算匹配程度,保留匹配程度最高的那张缩放图,如图7所示和匹配区域的位置四个顶点坐标;S2.5. Obtain these 10 pictures and the Canny contour map of the positioning template through calculation, and then find the area similar to the template through template matching from these 10 pictures, and calculate the matching degree at the same time, and keep the zoomed picture with the highest matching degree, as shown in the figure The four vertex coordinates of the position shown in 7 and the matching area;

S2.6、根据上述得到的四个坐标,框出这四行内容的区域,如图8所示;S2.6. According to the four coordinates obtained above, frame the area of the four lines of content, as shown in Figure 8;

S2.7、对框出区域的图像提取所有公司名称文字的像素,再进行逆向二值化(灰度值大于零的像素转化为白色255),得到的是背景为黑色,字为灰色的图像。计算每一个像素行的像素值之和,根据一定的门限值14000,进行文字行与空隙的区分,若像素值之和大于14000的区域为文字行,小于14000的像素行为空隙,由此判断并分割出图像中有字的三行,截取第一行为进一步目标,如图9所示。S2.7. Extract all the pixels of the company name text from the image in the framed area, and then perform reverse binarization (pixels with a gray value greater than zero are converted to white 255), and an image with a black background and gray characters is obtained . Calculate the sum of the pixel values of each pixel line, and distinguish between text lines and gaps based on a certain threshold value of 14,000. If the sum of pixel values is greater than 14,000, it is a text line, and the pixel value is less than 14,000. And segment the three lines with words in the image, intercept the first line for further target, as shown in Figure 9.

S2.8、再对上图计算每一像素列的像素值之和,根据门限值4000,判断并分割出文字区域,进而得到了公司名称区域的图片,如图10所示;S2.8. Calculate the sum of the pixel values of each pixel column in the above figure, judge and segment the text area according to the threshold value of 4000, and then obtain the picture of the company name area, as shown in Figure 10;

S3、对待识别发票信息图片的文字内容可以采用目前开源的识别打印的汉字串和数字串的工具,比如google的tesseract工具包,通过在程序中调用这个工具包的识别功能可以直接输出图片内容,进行识别,即获取了待识别发票信息。S3. The text content of the invoice information picture to be recognized can use the current open source tools for recognizing printed Chinese character strings and number strings, such as Google's tesseract toolkit. By calling the recognition function of this toolkit in the program, the picture content can be directly output. Identifying means obtaining the invoice information to be identified.

获取待识别发票信息。Obtain the invoice information to be recognized.

本发明能够用于精确定位增值税发票的特定目标区域,将目标板块一一截取成为目标碎片分别用于识别,能够有效辅助提高发票识别的准确率。The present invention can be used to accurately locate a specific target area of a value-added tax invoice, intercept target plates one by one into target fragments for identification, and can effectively assist in improving the accuracy of invoice identification.

本实施例的一种发票图片特定板块的定位、识别系统,包括:A positioning and identification system for a specific block of an invoice picture in this embodiment includes:

获取发票图片的采集单元;Acquisition unit for obtaining invoice pictures;

根据待识别发票信息,对其所在发票图片的区域定位、分割,获得待识别发票信息图片的定位单元;According to the invoice information to be identified, locate and segment the area of the invoice image where it is located, and obtain the positioning unit of the image of the invoice information to be identified;

对待识别发票信息图片的文字内容进行识别,获取待识别发票信息的识别单元。Recognize the text content of the picture of the invoice information to be recognized, and obtain the recognition unit of the invoice information to be recognized.

本实施例的一种发票图片特定板块的定位、识别设备,包括存储有计算机程序的计算机可读介质,所述程序被运行用于执行:A device for locating and identifying a specific section of an invoice picture in this embodiment includes a computer-readable medium storing a computer program, and the program is run to execute:

获取发票图片;Get the picture of the invoice;

确定待识别发票信息;Determine the invoice information to be identified;

根据待识别发票信息,对其所在发票图片的区域定位、分割,获得待识别发票信息图片;According to the invoice information to be identified, locate and segment the area of the invoice picture where it is located, and obtain the image of the invoice information to be identified;

对待识别发票信息图片的文字内容进行识别,获取待识别发票信息。Identify the text content of the image of the invoice information to be identified, and obtain the invoice information to be identified.

实施例二:Embodiment two:

本实施例与实施例一相同的特征不再赘述,本实施例与实施例一不同的特征在于:The features of this embodiment that are the same as those of Embodiment 1 will not be described in detail. The features of this embodiment that are different from Embodiment 1 are:

本实施例的一种发票图片特定板块的定位、识别方法中,In the method for locating and identifying a specific section of an invoice picture in this embodiment,

S2、根据待识别发票信息,对其所在发票图片的区域定位、分割,获得待识别发票信息图片:S2. According to the invoice information to be identified, locate and segment the area of the invoice picture where it is located, and obtain the image of the invoice information to be identified:

S2.1、确定待识别发票信息:票号序列;S2.1. Determine the invoice information to be identified: the invoice number sequence;

S2.2、根据待识别发票信息,确定定位模板;S2.2. Determine the positioning template according to the invoice information to be identified;

S2.3、利用定位模板对整张图进行模板匹配,确定其在发票图片的大体位置,截取待识别发票信息所在区域的部分图片;S2.3. Use the positioning template to perform template matching on the entire image, determine its general position in the invoice image, and intercept part of the image in the area where the invoice information is to be identified;

S2.4、对该待识别发票信息所在区域的部分图片从比例参数0.8到1.2倍进行10步缩放,获得10张缩放图;S2.4. Perform 10-step zooming on the part of the picture in the area where the invoice information to be identified is located from 0.8 to 1.2 times the scale parameter, and obtain 10 zooming pictures;

S2.5、运算获得这10张图和定位模板的Canny轮廓图,然后从这10张图中通过模板匹配找到与模板相似的区域,同时计算匹配程度,保留匹配程度最高的那张缩放图和匹配区域的位置四个顶点坐标;S2.5. Obtain these 10 pictures and the Canny contour map of the positioning template through calculation, and then find the area similar to the template through template matching from these 10 pictures, and calculate the matching degree at the same time, and keep the zoomed picture and matching area with the highest matching degree The four vertex coordinates of the position;

S2.6、根据上述得到的四个坐标,框出这四行内容的区域;S2.6. According to the four coordinates obtained above, frame the area of the four lines of content;

S2.7、对框出区域的图像提取所有待识别发票信息文字的像素,再进行逆向二值化(灰度值大于零的像素转化为白色255),得到的是背景为黑色,字为灰色的图像。计算每一个像素行的像素值之和,根据一定的门限值进行文字行与空隙的区分,若像素值之和大于门限值的区域为文字行,小于门限值的像素行为空隙,由此判断并分割出图像中有字的行,截取目标所在行图片。S2.7. Extract all the pixels of the invoice information text to be recognized from the image in the framed area, and then perform reverse binarization (pixels with a gray value greater than zero are converted to white 255), and the background is black, and the text is gray. Image. Calculate the sum of the pixel values of each pixel row, and distinguish between text rows and gaps according to a certain threshold value. If the sum of pixel values is greater than the threshold value, the region is a text row, and the pixels smaller than the threshold value act as gaps. This judges and divides the line with words in the image, and intercepts the picture of the line where the target is located.

S2.8、再对上图计算每一像素列的像素值之和,根据门限值,判断并分割出文字区域,进而得到了票号序列区域的图片;S2.8. Calculate the sum of the pixel values of each pixel column in the above figure, judge and segment the text area according to the threshold value, and then obtain the picture of the ticket number sequence area;

S3、对待识别发票信息图片的文字内容进行识别,获取待识别发票信息。S3. Identify the text content of the image of the invoice information to be identified, and obtain the invoice information to be identified.

实施例三:Embodiment three:

本实施例与实施例一相同的特征不再赘述,本实施例与实施例一不同的特征在于:The features of this embodiment that are the same as those of Embodiment 1 will not be described in detail. The features of this embodiment that are different from Embodiment 1 are:

本实施例的一种发票图片特定板块的定位、识别方法中,In the method for locating and identifying a specific section of an invoice picture in this embodiment,

S2、根据待识别发票信息,对其所在发票图片的区域定位、分割,获得待识别发票信息图片:S2. According to the invoice information to be identified, locate and segment the area of the invoice picture where it is located, and obtain the image of the invoice information to be identified:

S2.1、确定待识别发票信息:开票日期;S2.1. Determine the invoice information to be identified: date of invoice;

S2.2、根据待识别发票信息,确定定位模板;S2.2. Determine the positioning template according to the invoice information to be identified;

S2.3、利用定位模板对整张图进行模板匹配,确定其在发票图片的大体位置,截取待识别发票信息所在区域的部分图片;S2.3. Use the positioning template to perform template matching on the entire image, determine its general position in the invoice image, and intercept part of the image in the area where the invoice information is to be identified;

S2.4、对该待识别发票信息所在区域的部分图片从比例参数0.8到1.2倍进行15步缩放,获得15张缩放图;S2.4. Perform 15 steps of zooming in on the part of the picture in the area where the invoice information to be identified is located from 0.8 to 1.2 times the scale parameter, and obtain 15 zoomed pictures;

S2.5、运算获得这15张图和定位模板的Canny轮廓图,然后从这10张图中通过模板匹配找到与模板相似的区域,同时计算匹配程度,保留匹配程度最高的那张缩放图和匹配区域的位置四个顶点坐标;S2.5. Obtain these 15 pictures and the Canny contour map of the positioning template, and then find the area similar to the template through template matching from these 10 pictures, and calculate the matching degree at the same time, and keep the zoomed picture and matching area with the highest matching degree The four vertex coordinates of the position;

S2.6、根据上述得到的四个坐标,框出这四行内容的区域;S2.6. According to the four coordinates obtained above, frame the area of the four lines of content;

S2.7、对框出区域的图像提取所有待识别发票信息文字的像素,再进行逆向二值化,得到的是背景为黑色,字为灰色的图像。计算每一个像素行的像素值之和,根据一定的门限值进行文字行与空隙的区分,若像素值之和大于门限值的区域为文字行,小于门限值的像素行为空隙,由此判断并分割出图像中有字的行,截取目标所在行图片。S2.7. Extract all the pixels of the text of the invoice information to be recognized from the image in the framed area, and then perform reverse binarization to obtain an image with a black background and gray text. Calculate the sum of the pixel values of each pixel row, and distinguish between text rows and gaps according to a certain threshold value. If the sum of pixel values is greater than the threshold value, the region is a text row, and the pixels smaller than the threshold value act as gaps. This judges and divides the line with words in the image, and intercepts the picture of the line where the target is located.

S2.8、再对上图计算每一像素列的像素值之和,根据门限值,判断并分割出文字区域,进而得到了开票日期区域的图片;S2.8. Calculate the sum of the pixel values of each pixel column in the above figure, judge and segment the text area according to the threshold value, and then obtain the picture of the billing date area;

S3、对待识别发票信息图片的文字内容进行识别,获取待识别发票信息。S3. Identify the text content of the image of the invoice information to be identified, and obtain the invoice information to be identified.

实施例四:Embodiment four:

本实施例与实施例一相同的特征不再赘述,本实施例与实施例一不同的特征在于:The features of this embodiment that are the same as those of Embodiment 1 will not be described in detail. The features of this embodiment that are different from Embodiment 1 are:

本实施例的一种发票图片特定板块的定位、识别方法中,In the method for locating and identifying a specific section of an invoice picture in this embodiment,

S2、根据待识别发票信息,对其所在发票图片的区域定位、分割,获得待识别发票信息图片:S2. According to the invoice information to be identified, locate and segment the area of the invoice picture where it is located, and obtain the image of the invoice information to be identified:

S2.1、确定待识别发票信息:金额;S2.1. Determine the invoice information to be identified: amount;

S2.2、根据待识别发票信息,确定定位模板;S2.2. Determine the positioning template according to the invoice information to be identified;

S2.3、利用定位模板对整张图进行模板匹配,确定其在发票图片的大体位置,截取待识别发票信息所在区域的部分图片;S2.3. Use the positioning template to perform template matching on the entire image, determine its general position in the invoice image, and intercept part of the image in the area where the invoice information is to be identified;

S2.4、对该待识别发票信息所在区域的部分图片从比例参数0.8到1.2倍进行10步缩放,获得10张缩放图;S2.4. Perform 10-step zooming on the part of the picture in the area where the invoice information to be identified is located from 0.8 to 1.2 times the scale parameter, and obtain 10 zooming pictures;

S2.5、运算获得这10张图和定位模板的Canny轮廓图,然后从这10张图中通过模板匹配找到与模板相似的区域,同时计算匹配程度,保留匹配程度最高的那张缩放图和匹配区域的位置四个顶点坐标;S2.5. Obtain these 10 pictures and the Canny contour map of the positioning template through calculation, and then find the area similar to the template through template matching from these 10 pictures, and calculate the matching degree at the same time, and keep the zoomed picture and matching area with the highest matching degree The four vertex coordinates of the position;

S2.6、根据上述得到的四个坐标,框出这四行内容的区域;S2.6. According to the four coordinates obtained above, frame the area of the four lines of content;

S2.7、对框出区域的图像提取所有待识别发票信息文字的像素,再进行逆向二值化,得到的是背景为黑色,字为灰色的图像。计算每一个像素行的像素值之和,根据一定的门限值进行文字行与空隙的区分,若像素值之和大于门限值的区域为文字行,小于门限值的像素行为空隙,由此判断并分割出图像中有字的行,截取目标所在行图片。S2.7. Extract all the pixels of the text of the invoice information to be recognized from the image in the framed area, and then perform reverse binarization to obtain an image with a black background and gray text. Calculate the sum of the pixel values of each pixel row, and distinguish between text rows and gaps according to a certain threshold value. If the sum of pixel values is greater than the threshold value, the region is a text row, and the pixels smaller than the threshold value act as gaps. This judges and divides the line with words in the image, and intercepts the picture of the line where the target is located.

S2.8、再对上图计算每一像素列的像素值之和,根据门限值,判断并分割出文字区域,进而得到了金额区域的图片;S2.8. Calculate the sum of the pixel values of each pixel column in the above figure, judge and segment the text area according to the threshold value, and then obtain the picture of the amount area;

S3、对待识别发票信息图片的文字内容进行识别,获取待识别发票信息。S3. Identify the text content of the image of the invoice information to be identified, and obtain the invoice information to be identified.

实施例五:Embodiment five:

本实施例与实施例一相同的特征不再赘述,本实施例与实施例一不同的特征在于:The features of this embodiment that are the same as those of Embodiment 1 will not be described in detail. The features of this embodiment that are different from Embodiment 1 are:

本实施例的一种发票图片特定板块的定位、识别方法中,In the method for locating and identifying a specific section of an invoice picture in this embodiment,

S2、根据待识别发票信息,对其所在发票图片的区域定位、分割,获得待识别发票信息图片:S2. According to the invoice information to be identified, locate and segment the area of the invoice picture where it is located, and obtain the image of the invoice information to be identified:

S2.1、确定待识别发票信息:税额;S2.1. Determine the invoice information to be identified: tax amount;

S2.2、根据待识别发票信息,确定定位模板;S2.2. Determine the positioning template according to the invoice information to be identified;

S2.3、利用定位模板对整张图进行模板匹配,确定其在发票图片的大体位置,截取待识别发票信息所在区域的部分图片;S2.3. Use the positioning template to perform template matching on the entire image, determine its general position in the invoice image, and intercept part of the image in the area where the invoice information is to be identified;

S2.4、对该待识别发票信息所在区域的部分图片从比例参数0.8到1.2倍进行10步缩放,获得10张缩放图;S2.4. Perform 10-step zooming on the part of the picture in the area where the invoice information to be identified is located from 0.8 to 1.2 times the scale parameter, and obtain 10 zooming pictures;

S2.5、运算获得这10张图和定位模板的Canny轮廓图,然后从这10张图中通过模板匹配找到与模板相似的区域,同时计算匹配程度,保留匹配程度最高的那张缩放图和匹配区域的位置四个顶点坐标;S2.5. Obtain these 10 pictures and the Canny contour map of the positioning template through calculation, and then find the area similar to the template through template matching from these 10 pictures, and calculate the matching degree at the same time, and keep the zoomed picture and matching area with the highest matching degree The four vertex coordinates of the position;

S2.6、根据上述得到的四个坐标,框出这四行内容的区域;S2.6. According to the four coordinates obtained above, frame the area of the four lines of content;

S2.7、对框出区域的图像提取所有待识别发票信息文字的像素,再进行逆向二值化,得到的是背景为黑色,字为灰色的图像。计算每一个像素行的像素值之和,根据一定的门限值进行文字行与空隙的区分,若像素值之和大于门限值的区域为文字行,小于门限值的像素行为空隙,由此判断并分割出图像中有字的行,截取目标所在行图片。S2.7. Extract all the pixels of the text of the invoice information to be recognized from the image in the framed area, and then perform reverse binarization to obtain an image with a black background and gray text. Calculate the sum of the pixel values of each pixel row, and distinguish between text rows and gaps according to a certain threshold value. If the sum of pixel values is greater than the threshold value, the region is a text row, and the pixels smaller than the threshold value act as gaps. This judges and divides the line with words in the image, and intercepts the picture of the line where the target is located.

S2.8、再对上图计算每一像素列的像素值之和,根据门限值,判断并分割出文字区域,进而得到了税额区域的图片;S2.8. Calculate the sum of the pixel values of each pixel column in the above figure, judge and segment the text area according to the threshold value, and then obtain the picture of the tax amount area;

S3、对待识别发票信息图片的文字内容进行识别,获取待识别发票信息。S3. Identify the text content of the image of the invoice information to be identified, and obtain the invoice information to be identified.

以上描述仅为本申请的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本申请中所涉及的发明范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离所述发明构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本申请中公开的(但不限于)具有类似功能。The above description is only a preferred embodiment of the present application and an illustration of the applied technical principles. Those skilled in the art should understand that the scope of the invention involved in this application is not limited to the technical solution formed by the specific combination of the above-mentioned technical features, but should also cover the technical solution formed by the above-mentioned technical features without departing from the inventive concept. Other technical solutions formed by any combination of or equivalent features thereof. For example, the features described above have similar functions to those disclosed (but not limited to) in this application.

Claims (11)

1.一种发票图片特定板块的定位、识别方法,其特征是,包括:1. A method for positioning and identifying a specific section of an invoice picture, characterized in that it comprises: 获取发票图片;Get the picture of the invoice; 确定待识别发票信息;Determine the invoice information to be identified; 根据待识别发票信息,确定定位模板,不同的待识别信息对应不同的定位模板,所述待识别发票信息包括票号序列、公司名称、开票日期、金额和税额;According to the invoice information to be identified, a positioning template is determined, and different information to be identified corresponds to different positioning templates, and the invoice information to be identified includes a sequence of ticket numbers, a company name, an invoice date, an amount and a tax amount; 利用定位模板对发票图片进行模板匹配,确定其在发票图片的位置,截取待识别发票信息所在区域的部分图片;Use the positioning template to perform template matching on the invoice picture, determine its position in the invoice picture, and intercept part of the picture in the area where the invoice information is to be identified; 对所述待识别信息所在区域的部分图片进行缩放,获得缩放图;Scaling part of the pictures in the area where the information to be identified is located to obtain a zoomed picture; 利用Canny算法获取所述缩放图与确定的所述定位模板匹配的区域及匹配区域的顶点坐标;Using the Canny algorithm to obtain the region where the zoom map matches the determined positioning template and the vertex coordinates of the matching region; 根据匹配区域的顶点坐标,获取待识别发票信息所在区域图片;According to the vertex coordinates of the matching area, obtain the image of the area where the invoice information to be identified is located; 提取所述区域图片内待识别发票信息文字的像素,并进行逆向二值化处理;Extract the pixel of the invoice information text to be recognized in the image of the area, and perform reverse binarization processing; 计算所述区域图片行和列的像素值之和,将其与区分文字与空隙的预设门限值比对,判断并分割出待识别发票信息图片;Calculate the sum of the pixel values of the row and column of the image in the area, compare it with the preset threshold value for distinguishing text and gaps, judge and segment the image of the invoice information to be identified; 对待识别发票信息图片的文字内容进行识别,获取待识别发票信息。Identify the text content of the image of the invoice information to be identified, and obtain the invoice information to be identified. 2.根据权利要求1所述的发票图片特定板块的定位、识别方法,其特征是,获取发票图片之后执行步骤包括截取发票有效区域。2. The method for locating and identifying a specific section of an invoice image according to claim 1, wherein the step of executing after obtaining the invoice image includes intercepting the effective area of the invoice. 3.根据权利要求2所述的发票图片特定板块的定位、识别方法,其特征是,截取发票有效区域之前包括:摆正发票图片。3. The method for locating and identifying a specific section of an invoice picture according to claim 2, wherein the method of intercepting the effective area of the invoice includes: aligning the invoice picture. 4.根据权利要求3所述的发票图片特定板块的定位、识别方法,其特征是,摆正发票图片包括:4. The positioning and identification method of the specific plate of the invoice picture according to claim 3, characterized in that, the straightening of the invoice picture comprises: 利用openCV的HoughLine算法检测发票图片中所有的线条;Use openCV's HoughLine algorithm to detect all the lines in the invoice image; 计算每条线的偏转角度;Calculate the deflection angle for each line; 出现最多次的旋转角度为该图片的偏转角度;The rotation angle that appears most times is the deflection angle of the picture; 根据偏转角度旋转所述图片,摆正发票图片。Rotate the picture according to the deflection angle to straighten the picture of the invoice. 5.根据权利要求3所述的发票图片特定板块的定位、识别方法,其特征是,截取发票有效区域包括:5. The method for locating and identifying a specific section of an invoice picture according to claim 3, wherein the intercepting the effective area of an invoice comprises: 提取该发票图片中发票有效区域的轮廓;Extract the outline of the effective area of the invoice in the invoice image; 基于该轮廓分割得到发票有效区域的图片。A picture of the effective area of the invoice is obtained based on the contour segmentation. 6.根据权利要求5所述的发票图片特定板块的定位、识别方法,其特征是,提取该发票图片中发票有效区域的轮廓,包括:6. The method for positioning and identifying the specific plate of the invoice picture according to claim 5, wherein extracting the outline of the effective area of the invoice in the invoice picture comprises: 分别计算发票图片的每一像素列的像素值之和、每一像素行的像素值之和,得到两个向量;Calculate the sum of the pixel values of each pixel column and the sum of the pixel values of each pixel row of the invoice image respectively to obtain two vectors; 将两个向量相乘,得到二维数组;Multiply two vectors to get a two-dimensional array; 将这个二维数组转换成对应的灰度图片;Convert this two-dimensional array into the corresponding grayscale image; 过滤并去除发票图片中的横线和竖线,得到发票有效区域的轮廓。Filter and remove the horizontal and vertical lines in the invoice image to obtain the outline of the effective area of the invoice. 7.根据权利要求6所述的发票图片特定板块的定位、识别方法,其特征是,得到发票有效区域的图片之后执行步骤包括通过SIFT算法,判断发票票头的位置是否在图片的上方,否则,则上下翻转所述图片。7. The positioning and identification method of the specific plate of the invoice picture according to claim 6, wherein the step of executing after obtaining the picture of the effective area of the invoice includes passing through the SIFT algorithm to determine whether the position of the invoice head is above the picture, otherwise , flips the image upside down. 8.根据权利要求1所述的发票图片特定板块的定位、识别方法,其特征是,利用Canny算法获取与预设定位模板匹配的区域及匹配区域的顶点坐标,包括:8. The positioning and identification method of the specific plate of the invoice picture according to claim 1, wherein the method for locating and identifying the specific plate of the invoice image is characterized in that, using the Canny algorithm to obtain the area matched with the preset positioning template and the vertex coordinates of the matching area, including: 截取待识别发票信息所在区域的部分图片;Capture some pictures of the area where the invoice information to be identified is located; 对该部分图片进行缩放,得到多张缩放图;Scale the part of the picture to get multiple zoomed pictures; 将多张缩放图及预设定位模板输入Canny算法进行运算,得出与预设定位模板匹配的区域及匹配区域的顶点坐标。Input multiple zoom images and preset positioning templates into the Canny algorithm for calculation, and obtain the area matching the preset positioning template and the vertex coordinates of the matching area. 9.根据权利要求1所述的发票图片特定板块的定位、识别方法,其特征是,计算所述区域图片行和列的像素值之和,将其与门限值比对,判断并分割出待识别发票信息图片包括:9. The method for locating and identifying a specific plate of an invoice picture according to claim 1, wherein the sum of the pixel values of the row and column of the area picture is calculated, compared with a threshold value, judged and segmented out The picture of the invoice information to be recognized includes: 计算所述区域图片每一个像素行的像素值之和,根据像素行的门限值判断并分割出待识别发票信息所在行区域图片;Calculate the sum of the pixel values of each pixel row of the region picture, judge and segment the row region picture where the invoice information to be identified is located according to the threshold value of the pixel row; 计算行区域图片每一像素列的像素值之和,根据像素列的门限值判断并分割出待识别发票信息图片。Calculate the sum of the pixel values of each pixel column in the row area picture, judge and segment the invoice information picture to be recognized according to the threshold value of the pixel column. 10.一种发票图片特定板块的定位、识别系统,其特征是,包括:10. A positioning and identification system for a specific section of an invoice image, characterized in that it includes: 获取发票图片的采集单元;Acquisition unit for obtaining invoice pictures; 根据待识别发票信息,对其所在发票图片的区域定位、分割,获得待识别发票信息图片的定位单元;According to the invoice information to be identified, locate and segment the area of the invoice image where it is located, and obtain the positioning unit of the image of the invoice information to be identified; 对待识别发票信息图片的文字内容进行识别,获取待识别发票信息的识别单元;Recognize the text content of the image of the invoice information to be identified, and obtain the identification unit of the invoice information to be identified; 对待识别发票信息所在区域定位、分割包括所述定位单元具体用于:The positioning and segmentation of the area where the invoice information to be identified includes the positioning unit is specifically used for: 根据待识别发票信息,确定定位模板,不同的待识别信息对应不同的定位模板,所述待识别发票信息包括票号序列、公司名称、开票日期、金额和税额;According to the invoice information to be identified, a positioning template is determined, and different information to be identified corresponds to different positioning templates, and the invoice information to be identified includes a sequence of ticket numbers, a company name, an invoice date, an amount and a tax amount; 利用定位模板对发票图片进行模板匹配,确定其在发票图片的位置,截取待识别发票信息所在区域的部分图片;Use the positioning template to perform template matching on the invoice picture, determine its position in the invoice picture, and intercept part of the picture in the area where the invoice information is to be identified; 对所述待识别信息所在区域的部分图片进行缩放,获得缩放图;Scaling part of the pictures in the area where the information to be identified is located to obtain a zoomed picture; 利用Canny算法获取所述缩放图与确定的所述定位模板匹配的区域及匹配区域的顶点坐标;Using the Canny algorithm to obtain the region where the zoom map matches the determined positioning template and the vertex coordinates of the matching region; 根据匹配区域的顶点坐标,获取待识别发票信息所在区域图片;According to the vertex coordinates of the matching area, obtain the image of the area where the invoice information to be identified is located; 提取所述区域图片内待识别发票信息文字的像素,并进行逆向二值化处理;Extract the pixel of the invoice information text to be recognized in the image of the area, and perform reverse binarization processing; 计算所述区域图片行和列的像素值之和,将其与区分文字与空隙的预设门限值比对,判断并分割出待识别发票信息图片。Calculate the sum of the pixel values of the rows and columns of the image in the area, compare it with the preset threshold value for distinguishing characters and gaps, and judge and segment the image of the invoice information to be recognized. 11.一种发票图片特定板块的定位、识别设备,其特征是,包括存储有计算机程序的计算机可读介质,所述程序被运行用于执行:11. A device for locating and identifying a specific block of an invoice image, characterized in that it includes a computer-readable medium storing a computer program, and the program is run to execute: 获取发票图片;Get the picture of the invoice; 确定待识别发票信息;Determine the invoice information to be identified; 根据待识别发票信息,对其所在发票图片的区域定位、分割,获得待识别发票信息图片;According to the invoice information to be identified, locate and segment the area of the invoice picture where it is located, and obtain the image of the invoice information to be identified; 对待识别发票信息图片的文字内容进行识别,获取待识别发票信息;Identify the text content of the image of the invoice information to be identified, and obtain the invoice information to be identified; 对待识别发票信息所在区域定位、分割包括:The positioning and segmentation of the area where the invoice information is to be identified includes: 根据待识别发票信息,确定定位模板,不同的待识别信息确定不同的定位模板,所述待识别发票信息包括票号序列、公司名称、开票日期、金额和税额;According to the invoice information to be identified, a positioning template is determined, and different positioning templates are determined for different information to be identified, and the invoice information to be identified includes a sequence of ticket numbers, a company name, an invoice date, an amount and a tax amount; 利用定位模板对发票图片进行模板匹配,确定其在发票图片的位置,截取待识别发票信息所在区域的部分图片;Use the positioning template to perform template matching on the invoice picture, determine its position in the invoice picture, and intercept part of the picture in the area where the invoice information is to be identified; 对所述待识别信息所在区域的部分图片进行缩放,获得缩放图;Scaling part of the pictures in the area where the information to be identified is located to obtain a zoomed picture; 利用Canny算法获取所述缩放图与确定的所述定位模板匹配的区域及匹配区域的顶点坐标;Using the Canny algorithm to obtain the region where the zoom map matches the determined positioning template and the vertex coordinates of the matching region; 根据匹配区域的顶点坐标,获取待识别发票信息所在区域图片;According to the vertex coordinates of the matching area, obtain the image of the area where the invoice information to be identified is located; 提取所述区域图片内待识别发票信息文字的像素,并进行逆向二值化处理;Extract the pixel of the invoice information text to be recognized in the image of the area, and perform reverse binarization processing; 计算所述区域图片行和列的像素值之和,将其与区分文字与空隙的预设门限值比对,判断并分割出待识别发票信息图片。Calculate the sum of the pixel values of the rows and columns of the image in the area, compare it with the preset threshold value for distinguishing characters and gaps, and judge and segment the image of the invoice information to be recognized.
CN201710724450.9A 2017-08-22 2017-08-22 Method, system and equipment for positioning and identifying specific plate of invoice picture Active CN109426814B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710724450.9A CN109426814B (en) 2017-08-22 2017-08-22 Method, system and equipment for positioning and identifying specific plate of invoice picture

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710724450.9A CN109426814B (en) 2017-08-22 2017-08-22 Method, system and equipment for positioning and identifying specific plate of invoice picture

Publications (2)

Publication Number Publication Date
CN109426814A CN109426814A (en) 2019-03-05
CN109426814B true CN109426814B (en) 2023-02-24

Family

ID=65498246

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710724450.9A Active CN109426814B (en) 2017-08-22 2017-08-22 Method, system and equipment for positioning and identifying specific plate of invoice picture

Country Status (1)

Country Link
CN (1) CN109426814B (en)

Families Citing this family (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110598686B (en) * 2019-09-17 2023-08-04 携程计算机技术(上海)有限公司 Invoice identification method, system, electronic device and medium
CN110751088A (en) * 2019-10-17 2020-02-04 深圳金蝶账无忧网络科技有限公司 Data processing method and related equipment
CN110796082B (en) * 2019-10-29 2020-11-24 上海眼控科技股份有限公司 Nameplate text detection method and device, computer equipment and storage medium
CN111444793A (en) * 2020-03-13 2020-07-24 安诚迈科(北京)信息技术有限公司 Bill recognition method, equipment, storage medium and device based on OCR
CN113469161B (en) * 2020-03-31 2024-07-19 顺丰科技有限公司 A method, device and storage medium for processing logistics orders
CN111489246A (en) * 2020-04-09 2020-08-04 贵州爱信诺航天信息有限公司 Electronic integrated posting system for value-added tax invoice
CN111931784B (en) * 2020-09-17 2021-01-01 深圳壹账通智能科技有限公司 Bill recognition method, system, computer device and computer-readable storage medium
CN112257629A (en) * 2020-10-29 2021-01-22 广联达科技股份有限公司 Text information identification method and device for construction drawing
CN112257712B (en) * 2020-10-29 2024-02-27 湖南星汉数智科技有限公司 Train ticket image alignment method and device, computer device and computer readable storage medium
WO2022172698A1 (en) * 2021-02-09 2022-08-18 ソニーセミコンダクタソリューションズ株式会社 Information processing apparatus, mobile apparatus, and communication system
CN112732955A (en) * 2021-03-31 2021-04-30 国网浙江省电力有限公司 Financial certificate storage and recording method in standard cost accounting
CN114255335A (en) * 2021-11-23 2022-03-29 携程计算机技术(上海)有限公司 Electronic invoice recognition method, system, electronic device and medium
CN114821608A (en) * 2022-04-19 2022-07-29 中国工商银行股份有限公司 Image recognition method, image recognition device and computer-readable storage medium
CN115439853A (en) * 2022-08-30 2022-12-06 中国银联股份有限公司 An electronic bill text recognition method, device, electronic equipment and storage medium
CN118072336B (en) * 2024-01-08 2024-08-13 北京三维天地科技股份有限公司 Fixed format card and form structured recognition method based on OpenCV

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101464951A (en) * 2007-12-21 2009-06-24 北大方正集团有限公司 Image recognition method and system
CN103488999A (en) * 2013-09-11 2014-01-01 东华大学 Invoice data recording method
CN103617415A (en) * 2013-11-19 2014-03-05 北京京东尚科信息技术有限公司 Device and method for automatically identifying invoice
CN104112128A (en) * 2014-06-19 2014-10-22 中国工商银行股份有限公司 Digital image processing system applied to bill image character recognition and method
CN105045780A (en) * 2015-07-15 2015-11-11 广州敦和信息技术有限公司 Method and device for identifying semantic information of invoice brief notes
KR101615306B1 (en) * 2015-08-10 2016-04-25 (주)이씨에이시스템 A COD recognition system that recognizes the characters on the COD and detects the COD
CN105528604A (en) * 2016-01-31 2016-04-27 华南理工大学 Bill automatic identification and processing system based on OCR
CN105631393A (en) * 2014-11-06 2016-06-01 阿里巴巴集团控股有限公司 Information recognition method and device
CN106845469A (en) * 2017-01-24 2017-06-13 深圳怡化电脑股份有限公司 A kind of Paper Currency Identification and device

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4003428B2 (en) * 2001-10-10 2007-11-07 セイコーエプソン株式会社 Check processing apparatus and check processing method
US8254658B2 (en) * 2007-08-03 2012-08-28 Bank Of America Corporation Payee detection
US20160162995A1 (en) * 2014-12-04 2016-06-09 Siemens Technology And Services Pvt. Ltd. Method and system for duplicate invoice entry detection
CN105654072B (en) * 2016-03-24 2019-03-01 哈尔滨工业大学 A system and method for automatic text extraction and recognition of low-resolution medical bill images

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101464951A (en) * 2007-12-21 2009-06-24 北大方正集团有限公司 Image recognition method and system
CN103488999A (en) * 2013-09-11 2014-01-01 东华大学 Invoice data recording method
CN103617415A (en) * 2013-11-19 2014-03-05 北京京东尚科信息技术有限公司 Device and method for automatically identifying invoice
CN104112128A (en) * 2014-06-19 2014-10-22 中国工商银行股份有限公司 Digital image processing system applied to bill image character recognition and method
CN105631393A (en) * 2014-11-06 2016-06-01 阿里巴巴集团控股有限公司 Information recognition method and device
CN105045780A (en) * 2015-07-15 2015-11-11 广州敦和信息技术有限公司 Method and device for identifying semantic information of invoice brief notes
KR101615306B1 (en) * 2015-08-10 2016-04-25 (주)이씨에이시스템 A COD recognition system that recognizes the characters on the COD and detects the COD
CN105528604A (en) * 2016-01-31 2016-04-27 华南理工大学 Bill automatic identification and processing system based on OCR
CN106845469A (en) * 2017-01-24 2017-06-13 深圳怡化电脑股份有限公司 A kind of Paper Currency Identification and device

Also Published As

Publication number Publication date
CN109426814A (en) 2019-03-05

Similar Documents

Publication Publication Date Title
CN109426814B (en) Method, system and equipment for positioning and identifying specific plate of invoice picture
CN111474184B (en) AOI character defect detection method and device based on industrial machine vision
CN106960208B (en) Method and system for automatically segmenting and identifying instrument liquid crystal number
CN105067638B (en) Tire fetal membrane face character defect inspection method based on machine vision
CN103258198B (en) Character extracting method in a kind of form document image
CN110163219B (en) Object Detection Method Based on Image Edge Recognition
CN110399875A (en) A general table information extraction method based on deep learning and pixel projection
CN108133216B (en) Nixie tube reading identification method capable of realizing decimal point reading based on machine vision
CN109409355B (en) Novel transformer nameplate identification method and device
CN103258201B (en) A kind of form lines extracting method of amalgamation of global and local message
CN118275449B (en) Copper strip surface defect detection method, device and equipment
CN108615058A (en) A kind of method, apparatus of character recognition, equipment and readable storage medium storing program for executing
CN106097368A (en) A kind of recognition methods in veneer crack
CN111259878A (en) Method and equipment for detecting text
CN108921858A (en) A kind of recognition methods of automatic detection lifting lug position
CN107085728A (en) Method and system for effectively scoring probes in images using a vision system
WO2019061659A1 (en) Method and device for removing eyeglasses from facial image, and storage medium
CN114677552A (en) Fingerprint detail database labeling method and system for deep learning
CN110288040B (en) Image similarity judging method and device based on topology verification
CN105678737A (en) Digital image corner point detection method based on Radon transform
CN109753981B (en) A method and device for image recognition
US10395090B2 (en) Symbol detection for desired image reconstruction
CN108764230A (en) A kind of bank's card number automatic identifying method based on convolutional neural networks
WO2024001051A1 (en) Spatial omics single cell data acquisition method and apparatus, and electronic device
CN108647713B (en) Embryo boundary identification and laser track fitting method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant