A financial electronic bill management method and system
Patent Information
- Application Number
- CN202510239504.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-03
- Publication Date
- 2026-10-16
AI Technical Summary
[0004]针对现有技术所存在的上述缺点,本发明提供了一种财政电子票据管理方法及系统,能够有效解决现有技术中难以针对纸质票据进行标准化管理的问题
[0050] 1. This invention can convert images of paper tickets into qualified images, and verify the size standards and number of stamps on the paper tickets during the conversion process, thereby screening out valid tickets that meet the standards. It can also intelligently recognize the image of the paper ticket, determine the top edge of the ticket and adjust the image orientation, thereby avoiding the reversed images of qualified tickets during management. In addition, this invention can identify the elliptical outline of the supervisory seal in the qualified image, and set a preset axis ratio and standard value based on the fixed standard of the supervisory seal, and scale the image proportionally to ensure that the ticket size meets the specifications.
Smart Images

Figure CN122928614A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of management system technology, specifically to a method and system for managing electronic fiscal invoices. Background Technology
[0002] Fiscal receipts are legally binding documents printed, issued, and managed uniformly by the national finance department or its authorized units, used for public finance activities such as government non-tax revenue collection, fund transfer settlement, and financial management. Their core functions are to regulate the flow of fiscal funds, ensure the safety of public funds, and serve as an important basis for financial accounting and auditing supervision. The difference between fiscal receipts and electronic invoices is that fiscal receipts are managed by the finance department and used for non-tax revenue and public fund settlement; electronic invoices are managed by the tax department and involve commercial transactions.
[0003] For corporate finance departments, a large number of invoices are handled in daily work. These invoices include not only electronic invoices but also paper invoices. Existing invoice management methods and systems are usually designed for electronic invoices. The management of paper invoices—especially in the initial verification of paper invoices and the conversion to electronic versions—still relies on manual labor, resulting in fragmented invoice management and an inability to integrate management. Summary of the Invention
[0004] In view of the above-mentioned shortcomings of the existing technology, the present invention provides a method and system for managing electronic fiscal invoices, which can effectively solve the problem of the difficulty in standardizing the management of paper invoices in the existing technology.
[0005] To achieve the above objectives, the present invention provides the following technical solution:
[0006] This invention provides a method for managing electronic fiscal invoices, comprising at least the following steps:
[0007] Step 1: Obtain scanned images of paper tickets, verify the standardized dimensions of the scanned images, and crop the scanned images that meet the standardized dimensions, retaining the ticket area;
[0008] Step 2: Record the image corresponding to the ticket area as the target image, construct multiple linear arrays and long side analysis lines parallel to the long side of the target image, determine the number of stamps based on the distribution of the long side analysis lines and the number of red pixels on the long side analysis lines, and filter out the target images with a stamp count of 2.
[0009] Step 3: Construct multiple linear arrays of short-side analysis lines parallel to the short side of the target image. Determine the central region based on the distribution of the short-side analysis lines and the number of red pixels on the short-side analysis lines. Combine the distribution of red pixels in the central region to determine the top edge of the target image.
[0010] Step 4: Construct a positioning coordinate system. Draw two straight lines perpendicular to the top edge in the central area and call them positioning lines. Use the two red pixels outside the positioning lines as positioning pixels. Determine the target ellipse based on the positioning pixels. Based on the ratio of the major axis and minor axis of the target ellipse, remove target images whose ratios do not meet the standard.
[0011] The target image that meets the standard is scaled so that the major and minor axes of the target ellipse are equal to the preset values. The scaled target image is recorded as a qualified image.
[0012] The anchor point edges and anchor points for alignment management are determined based on the top edge of the target image and the center point of the target ellipse.
[0013] Furthermore, the standardized size verification process is as follows:
[0014] The scanned image is converted to grayscale to obtain a grayscale scan image. The part corresponding to the background area in the grayscale scan image is removed, and the area corresponding to the ticket part is retained and recorded as the verification area.
[0015] Draw multiple constraint rectangles that cover the verification area. The constraint rectangle with the smallest area is designated as the rectangle to be verified. Multiple standard aspect ratios PT are preset. f Where f is the index of the standard aspect ratio, the aspect ratio of the rectangle to be verified is calculated to obtain the aspect ratio PT′, and then substituted into the formula γ=Π(PT′). f The evaluation result γ is obtained by performing calculations in (′).
[0016] When the evaluation result γ is 0, the scanned image is cropped to retain the rectangular region to be kerneled; when the evaluation result γ is 1, the scanned image is marked as an abnormal ticket.
[0017] in:
[0018] PTf′ is a single alignment value, calculated using the following formula:
[0019] V is the preset ratio difference threshold.
[0020] Furthermore, the process of obtaining the verification area is as follows:
[0021] The scanned image is converted to grayscale to obtain a grayscale scan image. A background grayscale range is preset. The background grayscale range corresponds to the range of grayscale values of the background area in the scanned image. Points in the grayscale scan image whose grayscale values are within the range of the background grayscale range are recorded as background points to be kerneled.
[0022] Extract any background point to be analyzed and record it as the analysis point to be analyzed. Construct the shortest line segment from the analysis point to the edge of the grayscale scan image and record it as the judgment line segment. Obtain the total number of pixels passed by the judgment line segment and record it as the total judgment value. Obtain the number of background points to be analyzed among the pixels passed by the judgment line segment and record it as the judgment quantity value.
[0023] The judgment parameter is obtained by dividing the judgment quantity value by the total judgment value. When the judgment parameter is greater than or equal to the preset judgment threshold, the point to be analyzed is recorded as a background pixel.
[0024] Remove all background pixels from the grayscale scan image to obtain the remaining pixels. Remove the discrete points of the remaining pixels from the grayscale scan image and retain the region with the largest outline, which is recorded as the verification region.
[0025] Furthermore, the process for determining the number of seals is as follows:
[0026] The image of the ticket to be processed is denoted as the target image. A Cartesian coordinate system is constructed using a set of long and short sides in the target image as the horizontal and vertical axes, denoted as the reference coordinate system. Multiple straight lines traversing the target image are drawn and denoted as the long-side analysis lines (Line). h , where h is the index of the long side analysis line;
[0027] The number of red pixels in the target image located on each long side analysis line is denoted as the red distribution value of the corresponding long side analysis line. h Construct the first red distribution sequence {red h The first red distribution sequence is split into multiple regional sequences containing only consecutive non-zero red distribution values. The number of regional sequences is recorded as the number of stamps.
[0028] Furthermore, the process for determining the central region is as follows:
[0029] Construct multiple short-side analysis lines Line′ that traverse the target image in the reference coordinate system. g Where g is the index of the short-side analysis line, the red distribution value red′ of each short-side analysis line is obtained. g Construct the second red distribution sequence {red′ g The second red distribution sequence is split into multiple regional sequences.
[0030] Calculate the average value of the red distribution value red′g in each region sequence to obtain the distribution judgment value of the corresponding region sequence. Divide the distribution judgment value by the median of the short side analysis line number to obtain the centering judgment value. When the centering judgment value is greater than the preset judgment threshold, the corresponding region sequence is recorded as the target sequence.
[0031] Obtain the subscripts corresponding to the two endpoints of the target sequence as the region boundary values, denote the short side analysis line corresponding to the region boundary values as the region edge line, and denote the region between the two region edge lines as the central region.
[0032] Furthermore, the process for determining the top edge of the target image is as follows:
[0033] Let the two longer sides of the target image be long side A and long side B, and let the intersection of the long side analysis line and the short side analysis line in the central region be the region scatter point POINT. i , where i is the index of the scatter point in the region. A circular region is drawn with the scatter point in the region as the center and the preset unit radius R as the radius. The number of red pixels in the circular region is counted as the intersection value of the scatter point in the region.
[0034] Set the area scatter points POINT i The distance between the device and its long side A and long side B is represented by DP. i A DP i B ;
[0035] Substitute into the formula Calculations are performed in the process;
[0036] Obtain the top judgment values corresponding to long side A and long side B respectively. POINT i ' represents a scatter plot of a region. i The corresponding intersection value is used, with the longer side having the smaller top judgment value as the top edge of the target image.
[0037] Furthermore, the scaling and adjustment process of the target image is as follows:
[0038] Construct another Cartesian coordinate system in the target image, denoted as the positioning coordinate system. The horizontal axis of the positioning coordinate system is parallel to the top edge of the target image. It has a preset unit length and assigns a pixel coordinate to each pixel in the target image.
[0039] Mark the central region in the positioning coordinate system. Draw any two straight lines perpendicular to the horizontal axis of the coordinate system within the central region and call them positioning lines. Obtain multiple red pixels on each positioning line and take the two pixels located on the outside as positioning pixels. Determine an ellipse based on the pixel coordinates of the four positioning pixels and call it the target ellipse. Obtain the major axis width and minor axis width of the target ellipse.
[0040] Calculate the ratio between the major axis width and the minor axis width and compare it with the preset axis length ratio. If the ratio between the major axis width and the minor axis width is not equal to the preset axis length ratio, mark the target image as an unqualified document and remove it.
[0041] When the ratio between the major axis width and the minor axis width is equal to the preset axis length ratio, the target image is scaled proportionally so that the major axis width is equal to the preset major axis standard value and the minor axis width is equal to the preset minor axis standard value.
[0042] A fiscal electronic invoice management system includes an invoice verification unit:
[0043] Based on the image optical character recognition algorithm, qualified images are converted into electronic versions, and electronic tickets and electronic paper tickets are uniformly recorded as target electronic tickets;
[0044] The image of the target electronic ticket is denoted as the ticket image. The anchor point of the ticket image is obtained. A rectangular area is drawn with the anchor point as the center and denoted as the distinguishing rectangle. The length and width of the distinguishing rectangle are preset values. An ellipse is constructed with the anchor point as the center point and denoted as the distinguishing ellipse. The major axis of the distinguishing ellipse is parallel to the long side of the ticket image, and the minor axis is parallel to the short side of the ticket image. The lengths of the major and minor axes of the distinguishing ellipse are preset values.
[0045] The region between the distinguishing rectangle and the distinguishing ellipse is called the distinguishing image, and the number of red pixels in the distinguishing image is recorded as the distinguishing value.
[0046] There is a preset distinction threshold. When the number of distinctions is greater than the distinction threshold, the corresponding target electronic invoice is marked as a tax electronic invoice. When the number of distinctions is less than or equal to the distinction threshold, the corresponding target electronic invoice is marked as a fiscal electronic invoice.
[0047] A computer device includes a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of the method described above.
[0048] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described above.
[0049] The technical solution provided by this invention has the following advantages compared with the known prior art:
[0050] 1. This invention can convert images of paper tickets into qualified images, and verify the size standards and number of stamps on the paper tickets during the conversion process, thereby screening out valid tickets that meet the standards. It can also intelligently recognize the image of the paper ticket, determine the top edge of the ticket and adjust the image orientation, thereby avoiding the reversed images of qualified tickets during management. In addition, this invention can identify the elliptical outline of the supervisory seal in the qualified image, and set a preset axis ratio and standard value based on the fixed standard of the supervisory seal, and scale the image proportionally to ensure that the ticket size meets the specifications.
[0051] 2. This invention can distinguish between fiscal electronic invoices and tax electronic invoices, making it convenient for managers to classify and manage different types of invoices. Moreover, this invention can not only distinguish between electronic invoices, but also between electronic paper invoices, thus expanding the scope of invoice management and making it more suitable for entities that need to manage multiple types of invoices. Attached Figure Description
[0052] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are merely some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without any creative effort.
[0053] Figure 1 This is an overall module block diagram of the present invention. Detailed Implementation
[0054] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0055] The present invention will be further described below with reference to embodiments.
[0056] See Figure 1 A method and system for managing electronic fiscal invoices, comprising at least the following steps:
[0057] S1: A complete image of the paper invoice is captured using an image acquisition device and recorded as a scanned image. The scanned image undergoes standardized verification to determine whether the paper invoice conforms to the fiscal size standards, thereby filtering out non-compliant invoices and retaining those that meet the standards. Specifically:
[0058] The scanned image is converted to grayscale to obtain a grayscale scan image, so that each pixel in the grayscale scan image corresponds to a grayscale value. The number of pixels corresponding to different grayscale values is recorded as the grayscale value of the corresponding grayscale value. A background grayscale range is preset, which corresponds to the range of grayscale values of the background area in the scanned image. Points in the grayscale scan image whose grayscale values are within the range of the background grayscale range are recorded as background points to be kerneled.
[0059] Extract any background point to be analyzed and record it as the analysis point to be analyzed. Construct the shortest line segment from the analysis point to the edge of the grayscale scan image and record it as the judgment line segment. Obtain the total number of pixels passed by the judgment line segment and record it as the total judgment value. Obtain the number of background points to be analyzed among the pixels passed by the judgment line segment and record it as the judgment quantity value. Calculate the judgment quantity value and divide it by the total judgment value to obtain the judgment parameter. When the judgment parameter is greater than or equal to the preset judgment threshold, record the analysis point to be analyzed as a background pixel.
[0060] It should be noted that when taking a complete image of the paper ticket, it should be placed on a solid color background so that the paper ticket can be distinguished from the background, making it easier for the image recognition algorithm to capture the outline of the paper ticket. The solid color background should be chosen to be significantly different from the color of the paper ticket.
[0061] Remove all background pixels from the grayscale scan image to obtain the remaining pixels (the remaining pixels refer to all non-background pixels). Remove the discrete points of the remaining pixels in the grayscale scan image and retain the largest contour area as the verification area.
[0062] Draw multiple constraint rectangles that cover the verification area. The constraint rectangle with the smallest area is designated as the rectangle to be verified. Multiple standard aspect ratios PT are preset. f Where f is the index of the standard aspect ratio, the aspect ratio of the rectangle to be verified is calculated to obtain the aspect ratio PT′, and then substituted into the formula γ=Π(PT′). f The calculation is performed in ') to obtain the evaluation result γ. When the evaluation result γ is 0, the scanned image is recorded as the invoice image and cropped, retaining the rectangular area to be verified. When the evaluation result γ is 1, the scanned image is marked as an abnormal invoice and manually verified. Where: PT f ′ represents a single alignment value, calculated using the following formula: V is the preset ratio difference threshold.
[0063] It should be noted that the standard aspect ratio is based on the current standard size of the invoice. Officially issued paper invoices must be printed and manufactured in strict accordance with the standard. Therefore, their aspect ratio is usually a fixed value. By comparing the aspect ratio, we can make a preliminary judgment on whether the paper invoice is compliant, so as to remove unqualified invoices in the early stage of scanning and converting paper invoices into electronic invoices.
[0064] S2: Further process different invoice images, removing invalid invoices and retaining valid invoices, including:
[0065] The image of the ticket to be processed is denoted as the target image. A Cartesian coordinate system is constructed using a set of long and short sides in the target image as the horizontal and vertical axes, denoted as the reference coordinate system. Multiple straight lines parallel to the long sides of the target image are drawn and denoted as the long side analysis lines. hWhere h is the index of the long-side analysis line, multiple long-side analysis lines are set in a linear array and run through the target image, and the number of red pixels in the target image located on each long-side analysis line is recorded as the red distribution value of the corresponding long-side analysis line. h Thus, the first red distribution sequence {red} is constructed. h The first red distribution sequence is split into multiple regional sequences containing only continuous non-zero red distribution values. That is, the red distribution values in the regional sequences are all greater than 0 and the subscripts are continuous. The number of regional sequences is recorded as the number of stamps. When the number of stamps is equal to 2, the target image is recorded as a valid ticket. When the number of stamps is not equal to 2 (usually less than 2), the target image is recorded as an invalid ticket.
[0066] It should be noted that compliant invoices issued in accordance with regulations must contain two types of seals: the supervisor's seal and the issuing unit's seal. These two seals are distributed at the top and bottom of the target image. When the long side analysis line is evenly distributed in the target image, it will intersect with the two seals and form two sets of continuous intersecting lines, which are represented as a series of regions in S2 (i.e., each series of regions corresponds to one seal). Therefore, the number of seals in the target image can be determined by the number of series of regions, thereby determining whether the invoice is valid.
[0067] S3: Determine the orientation of the target image based on the distribution of red pixels in the target image, where:
[0068] In the reference coordinate system, construct multiple straight lines parallel to the short side of the target image, denoted as the short side analysis lines Line′. g Where g is the index of the short-side analysis line, multiple short-side analysis lines are arranged in a linear array and run through the target image, and the red distribution value red′g of each short-side analysis line is obtained, thereby constructing a second red distribution sequence {red′g}. g}, split the second red distribution sequence into multiple regional sequences, and calculate the red distribution value red′ in each regional sequence. g The average of the subscripts is used to obtain the distribution judgment value of the corresponding region sequence. The distribution judgment value is divided by the median of the short side analysis line number to obtain the centering judgment value. When the centering judgment value is greater than the preset judgment threshold, the corresponding region sequence is recorded as the target sequence.
[0069] It should be noted that the supervisory seal on fiscal receipts that meet printing standards is centered in the subject line of the receipt. Therefore, the distribution position of the corresponding seal can be determined by identifying the distribution of elements in the regional sequence. Since the fiscal supervisory seal is centered, the subscripts of the elements in the corresponding regional sequence should conform to a symmetrical distribution, with the center point of symmetry being the median of the sequence number of the short side analysis line.
[0070] Obtain the subscripts corresponding to the two endpoints of the target sequence as the region boundary values, and denote the short side analysis line corresponding to the region boundary value as the region edge line (the corresponding short side analysis line can be determined based on the subscript). Denote the region between the two region edge lines as the central region (the central region corresponds to the region where the supervisor's seal is located on the bill, and this region only contains the supervisor's seal).
[0071] Let the two longer sides of the target image be long side A and long side B, and let the intersection of the long side analysis line and the short side analysis line in the central region be the region scatter point POINT. i Where i is the index of the scatter point, a circular region is drawn with the scatter point as the center and a preset unit radius R as the radius. The number of red pixels within the circular region is counted as the intersection value of the scatter points. Let the scatter point be POINT. i The distance between the device and its long side A and long side B is represented by DP. i A DP i B Substitute into the formula The calculations are performed to obtain the top judgment values corresponding to long side A and long side B, respectively. (The top judgment value reflects the distribution trend of red pixels relative to the long side; the closer the red pixels are to the long side, the smaller their top judgment value.) Where POINT... i ' represents a scatter plot of a region. i The corresponding intersection value is used as the top edge of the target image, with the longer side having the smaller top judgment value. The orientation of the target image is then adjusted so that its top edge is at the top.
[0072] It should be noted that on standard paper tickets, the supervisor's seal is centered and located at the top of the ticket. Therefore, the top edge of the supervisor's seal can be considered as the top edge of the paper ticket. By selecting the longer side with the smaller top judgment value, the top edge of the paper ticket can be located, thus standardizing the placement of paper tickets for further analysis in subsequent processes.
[0073] S4: Scale the target image after adjustment to conform to the preset size standard, where:
[0074] Construct another Cartesian coordinate system in the target image, denoted as the positioning coordinate system. The horizontal axis of the positioning coordinate system is parallel to the top edge of the target image. It has a preset unit length (the unit length is a fixed value, that is, the number of pixels between two pixels with a distance of unit length is fixed). Thus, each pixel in the target image can be assigned a pixel coordinate.
[0075] Mark the central region in the positioning coordinate system. Draw any two straight lines perpendicular to the horizontal axis of the coordinate system within the central region (excluding the region's edge line). Record these as positioning lines. Obtain multiple red pixels on each positioning line and take the two outermost pixels as positioning pixels. Determine an ellipse based on the pixel coordinates of the four positioning pixels and record it as the target ellipse (if the target ellipse cannot be determined, record the ticket as unqualified). Obtain the major axis width and minor axis width of the target ellipse.
[0076] Calculate the ratio between the major axis width and the minor axis width and compare it with the preset axis ratio. When the ratio between the major axis width and the minor axis width is not equal to the preset axis ratio, mark the target image as an unqualified document and remove it. When the ratio between the major axis width and the minor axis width is equal to the preset axis ratio, scale the target image proportionally so that the major axis width is equal to the preset major axis standard value and the minor axis width is equal to the preset minor axis standard value. Record the scaled target image as a qualified image.
[0077] It should be noted that determining the position of an ellipse based on four-point coordinates is a standard technique in analytic geometry, which will not be elaborated upon here. Since the official seals on paper documents have a unified standard, the scanned images of different paper documents can be processed using the outline pattern of the seal (the outer outline of the seal is an ellipse of a fixed shape and size, with a major axis of 31mm and a minor axis of 21mm). The images of different paper documents are resized based on the outline of the seal to ensure uniformity in image size, facilitating standardized management and identification.
[0078] Furthermore, the center point of the target ellipse is obtained as the anchor point, and the top edge of the qualified image is obtained as the anchor edge. When summarizing and managing multiple qualified images, it is ensured that the anchor edges of each qualified image are on the same straight line and the anchor points coincide.
[0079] By using anchor points and edge lines, the image positions corresponding to paper tickets can be further fixed, thereby standardizing the management and storage of images of each paper ticket and ensuring that the stored images of each paper ticket are uniformly aligned based on the anchor points, so as to facilitate rapid scanning in subsequent processing.
[0080] A fiscal electronic invoice management system includes:
[0081] The invoice verification unit converts qualified images into electronic versions based on the optical character recognition (OCR) algorithm, and records the electronic invoices and the electronic versions of paper invoices together as the target electronic invoices.
[0082] It should be noted that the target electronic invoice in this invention does not refer to an invoice that is electronic at the time of issuance, but rather to an invoice whose final storage format is electronic. The target electronic invoice can be either an electronic invoice or a scanned and converted electronic paper invoice. In other words, the fiscal electronic invoice management system in this invention can not only distinguish between electronic invoices, but also between electronic paper invoices, thus expanding the scope of invoice management and making it more suitable for entities that need to manage multiple types of invoices.
[0083] Based on the analysis of the content of the target electronic invoices, they are divided into tax invoices and fiscal invoices, among which:
[0084] The image of the target electronic invoice is denoted as the invoice image. The anchor point of the invoice image is obtained. A rectangular area is drawn with the anchor point as the center and denoted as the distinguishing rectangle. The length and width of the distinguishing rectangle are preset values (in a specific embodiment, the length and width are 32mm and 22mm, respectively). An ellipse is constructed with the anchor point as the center and denoted as the distinguishing ellipse. The major axis of the distinguishing ellipse is parallel to the long side of the invoice image, and the minor axis is parallel to the short side of the invoice image. The lengths of the major and minor axes of the distinguishing ellipse are preset values (in a specific embodiment, the major and minor axes are 16mm and 11mm, respectively). The area between the distinguishing rectangle and the distinguishing ellipse is denoted as the distinguishing image. The number of red pixels in the distinguishing image is counted and denoted as the distinguishing quantity value. A distinguishing threshold is preset. When the distinguishing quantity value is greater than the distinguishing threshold, the corresponding target electronic invoice is marked as a tax electronic invoice. When the distinguishing quantity value is less than or equal to the distinguishing threshold, the corresponding target electronic invoice is marked as a fiscal electronic invoice.
[0085] Extract and archive electronic fiscal receipts.
[0086] It should be noted that the determination of the anchor point follows the steps outlined in the fiscal electronic invoice management method, and will not be elaborated upon here. By distinguishing the area corresponding to the rectangle as the location of the supervisory seal, and the area corresponding to the ellipse as the location of the supervisory seal, the ellipse within the distinguishing rectangle is removed, thus retaining the textual information related to the type of supervisory seal. Generally, the number and content of text on the supervisory seals of tax invoices and fiscal invoices differ, while the content of each type of supervisory seal remains unchanged. Therefore, the type of invoice can be distinguished by the textual information data within the supervisory seal, and further, the type of invoice can be distinguished by the number of red pixels within the distinguishing image.
[0087] A computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps in the above method.
[0088] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method.
[0089] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions will not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for managing electronic fiscal invoices, characterized in that, Includes the following steps: Step 1: Obtain scanned images of paper tickets, verify the standardized dimensions of the scanned images, and crop the scanned images that meet the standardized dimensions, retaining the ticket area; Step 2: Record the image corresponding to the ticket area as the target image, construct multiple linear arrays and long side analysis lines parallel to the long side of the target image, determine the number of stamps based on the distribution of the long side analysis lines and the number of red pixels on the long side analysis lines, and filter out the target images with a stamp count of 2. Step 3: Construct multiple linear arrays of short-side analysis lines parallel to the short side of the target image. Determine the central region based on the distribution of the short-side analysis lines and the number of red pixels on the short-side analysis lines. Combine the distribution of red pixels in the central region to determine the top edge of the target image. Step 4: Construct a positioning coordinate system. Draw two straight lines perpendicular to the top edge in the central area and call them positioning lines. Use the two red pixels outside the positioning lines as positioning pixels. Determine the target ellipse based on the positioning pixels. Based on the ratio of the major axis and minor axis of the target ellipse, remove target images whose ratios do not meet the standard. The target image that meets the standard is scaled so that the major and minor axes of the target ellipse are equal to the preset values. The scaled target image is recorded as a qualified image. The anchor point edges and anchor points for alignment management are determined based on the top edge of the target image and the center point of the target ellipse.
2. The method for managing electronic fiscal invoices according to claim 1, characterized in that, The standardized size verification process is as follows: The scanned image is converted to grayscale to obtain a grayscale scan image. The part corresponding to the background area in the grayscale scan image is removed, and the area corresponding to the ticket part is retained and recorded as the verification area. Draw multiple constraint rectangles that cover the verification area. The constraint rectangle with the smallest area is designated as the rectangle to be verified. Multiple standard aspect ratios PT are preset. f Where f is the index of the standard aspect ratio, the aspect ratio of the rectangle to be verified is calculated to obtain the aspect ratio PT′, and then substituted into the formula γ=Π(PT′). f The evaluation result γ is obtained by performing calculations in (′). When the evaluation result γ is 0, the scanned image is cropped to retain the rectangular region to be kerneled; when the evaluation result γ is 1, the scanned image is marked as an abnormal ticket. in: PTf′ is a single alignment value, calculated using the following formula: V is the preset ratio difference threshold.
3. The method for managing electronic fiscal invoices according to claim 2, characterized in that, The process for obtaining the verification area is as follows: The scanned image is converted to grayscale to obtain a grayscale scan image. A background grayscale range is preset. The background grayscale range corresponds to the range of grayscale values of the background area in the scanned image. Points in the grayscale scan image whose grayscale values are within the range of the background grayscale range are recorded as background points to be kerneled. Extract any background point to be analyzed and record it as the analysis point to be analyzed. Construct the shortest line segment from the analysis point to the edge of the grayscale scan image and record it as the judgment line segment. Obtain the total number of pixels passed by the judgment line segment and record it as the total judgment value. Obtain the number of background points to be analyzed among the pixels passed by the judgment line segment and record it as the judgment quantity value. The judgment parameter is obtained by dividing the judgment quantity value by the total judgment value. When the judgment parameter is greater than or equal to the preset judgment threshold, the point to be analyzed is recorded as a background pixel. Remove all background pixels from the grayscale scan image to obtain the remaining pixels. Remove the discrete points of the remaining pixels from the grayscale scan image and retain the region with the largest outline, which is recorded as the verification region.
4. The method for managing electronic fiscal invoices according to claim 1, characterized in that, The process for determining the number of seals is as follows: The image of the ticket to be processed is denoted as the target image. A Cartesian coordinate system is constructed using a set of long and short sides in the target image as the horizontal and vertical axes, denoted as the reference coordinate system. Multiple straight lines traversing the target image are drawn and denoted as the long-side analysis lines (Line). h , where h is the index of the long side analysis line; The number of red pixels in the target image located on each long side analysis line is denoted as the red distribution value of the corresponding long side analysis line. h Construct the first red distribution sequence {red h The first red distribution sequence is split into multiple regional sequences containing only consecutive non-zero red distribution values. The number of regional sequences is recorded as the number of stamps.
5. A method for managing electronic fiscal invoices according to claim 4, characterized in that, The process for determining the central region is as follows: Construct multiple short-side analysis lines Line′ that traverse the target image in the reference coordinate system. g Where g is the index of the short-side analysis line, the red distribution value red′ of each short-side analysis line is obtained. g Construct the second red distribution sequence {red′ g The second red distribution sequence is split into multiple regional sequences. Calculate the average value of the red distribution value red′g in each region sequence to obtain the distribution judgment value of the corresponding region sequence. Divide the distribution judgment value by the median of the short side analysis line number to obtain the centering judgment value. When the centering judgment value is greater than the preset judgment threshold, the corresponding region sequence is recorded as the target sequence. Obtain the subscripts corresponding to the two endpoints of the target sequence as the region boundary values, denote the short side analysis line corresponding to the region boundary values as the region edge line, and denote the region between the two region edge lines as the central region.
6. The method for managing electronic fiscal invoices according to claim 5, characterized in that, The process for determining the top edge of the target image is as follows: Let the two longer sides of the target image be long side A and long side B, and let the intersection of the long side analysis line and the short side analysis line in the central region be the region scatter point POINT. i , where i is the index of the scatter point in the region. A circular region is drawn with the scatter point in the region as the center and the preset unit radius R as the radius. The number of red pixels in the circular region is counted as the intersection value of the scatter point in the region. Set the area scatter points POINT i The distance between the device and its long side A and long side B is represented by DP. i A DP i B ; Substitute into the formula Calculations are performed in the process; Obtain the top judgment values corresponding to long side A and long side B respectively. POINT i ' represents a scatter plot of a region. i The corresponding intersection value is used, with the longer side having the smaller top judgment value as the top edge of the target image.
7. A method for managing electronic fiscal invoices according to claim 6, characterized in that, The scaling and adjustment process for the target image is as follows: Construct another Cartesian coordinate system in the target image, denoted as the positioning coordinate system. The horizontal axis of the positioning coordinate system is parallel to the top edge of the target image. It has a preset unit length and assigns a pixel coordinate to each pixel in the target image. Mark the central region in the positioning coordinate system. Draw any two straight lines perpendicular to the horizontal axis of the coordinate system within the central region and call them positioning lines. Obtain multiple red pixels on each positioning line and take the two pixels located on the outside as positioning pixels. Determine an ellipse based on the pixel coordinates of the four positioning pixels and call it the target ellipse. Obtain the major axis width and minor axis width of the target ellipse. Calculate the ratio between the major axis width and the minor axis width and compare it with the preset axis length ratio. If the ratio between the major axis width and the minor axis width is not equal to the preset axis length ratio, mark the target image as an unqualified document and remove it. When the ratio between the major axis width and the minor axis width is equal to the preset axis length ratio, the target image is scaled proportionally so that the major axis width is equal to the preset major axis standard value and the minor axis width is equal to the preset minor axis standard value.
8. A fiscal electronic invoice management system, applied to the fiscal electronic invoice management method according to any one of claims 1-7, characterized in that, Includes a document verification unit: Based on the image optical character recognition algorithm, qualified images are converted into electronic versions, and electronic tickets and electronic paper tickets are uniformly recorded as target electronic tickets; The image of the target electronic ticket is denoted as the ticket image. The anchor point of the ticket image is obtained. A rectangular area is drawn with the anchor point as the center and denoted as the distinguishing rectangle. The length and width of the distinguishing rectangle are preset values. An ellipse is constructed with the anchor point as the center point and denoted as the distinguishing ellipse. The major axis of the distinguishing ellipse is parallel to the long side of the ticket image, and the minor axis is parallel to the short side of the ticket image. The lengths of the major and minor axes of the distinguishing ellipse are preset values. The region between the distinguishing rectangle and the distinguishing ellipse is called the distinguishing image, and the number of red pixels in the distinguishing image is recorded as the distinguishing value. There is a preset distinction threshold. When the number of distinctions is greater than the distinction threshold, the corresponding target electronic invoice is marked as a tax electronic invoice. When the number of distinctions is less than or equal to the distinction threshold, the corresponding target electronic invoice is marked as a fiscal electronic invoice.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.