Paging method and device, computing equipment, readable storage medium and program product

The paging position of the image is determined through optical character recognition and clustering algorithms, and the paging process of the image to be processed is solved, which solves the problem of inaccurate character recognition after scaling of paper test papers, and improves the accuracy of the recognition results.

CN119888747APending Publication Date: 2025-04-25BEIJING FLYING ELEPHANT PLANET TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411970232.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

In the field of machine marking, the scaling processing of paper test papers leads to inaccurate character recognition results, and there is a problem of information loss.

Method used

By obtaining the pending image containing multi-page content, the character position information is obtained using an optical character recognition algorithm, and the line character set is clustered to determine the horizontal coordinate of the image paging, and then the image is paved using vertical segmentation lines.

Benefits of technology

This method effectively reduces the loss of information in the character recognition algorithm during input, improves the accuracy of character recognition results, and makes the recognition results more coherent and accurate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119888747A_ABST
    Figure CN119888747A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a paging method and device. The paging method comprises the steps that a to-be-processed image containing multiple pages of content is acquired; identifying the to-be-processed image by using an optical character identification algorithm to obtain position information of each character contained in the to-be-processed image; according to the position information of each character, determining characters belonging to the same row in the to-be-processed image to obtain a plurality of row character sets; clustering the plurality of row character sets based on a clustering algorithm to obtain a clustering center; according to the abscissa of the clustering center, obtaining an image paging abscissa; based on the image paging abscissa, determining a segmentation line perpendicular to an abscissa axis where the image paging abscissa is located; and performing paging processing on the to-be-processed image by using the segmentation line to obtain a target image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present specification relate to the field of image processing technology, and in particular to a paging method, apparatus, computing device, readable storage medium, and program product. Background Art

[0002] With the different developments in science and technology, businesses in many fields are becoming more and more automated, bringing great convenience to people's lives. For example, areas such as machine customer service, machine grading, and machine question and answer have greatly realized automated businesses and reduced human intervention. For the field of machine grading, it is necessary to convert paper test papers into images for character recognition, and score the test questions in the test papers based on the character recognition results. However, the size of the paper test paper is too large. Before character recognition, the image carrying the paper test paper needs to be scaled to a fixed size that can be accepted by the character recognition algorithm so that the scaled test paper can be recognized. However, the characters in the scaled image are blurred and it is easy to lose information, making the character recognition results inaccurate.

[0003] Therefore, a paging method is urgently needed to reduce the information loss of the input character recognition algorithm and improve the accuracy of the character recognition results. Summary of the invention

[0004] In view of this, an embodiment of the present specification provides a paging method. One or more embodiments of the present specification also relate to a paging device, a computing device, a computer-readable storage medium and a computer program to solve the technical defects existing in the prior art.

[0005] According to a first aspect of an embodiment of this specification, a paging method is provided, including: Get the image to be processed containing multiple pages of content; Recognize the image to be processed by using an optical character recognition algorithm to obtain position information of each character contained in the image to be processed; According to the position information of each character, characters belonging to the same row in the image to be processed are determined to obtain a plurality of row character sets; Clustering the plurality of row character sets based on a clustering algorithm to obtain cluster centers; According to the abscissa of the cluster center, the abscissa of the image page is obtained; Based on the image page horizontal coordinate, determining a segmentation line perpendicular to the horizontal coordinate axis where the image page horizontal coordinate is located; The image to be processed is processed by paging using the segmentation line to obtain a target image.

[0006] According to a second aspect of an embodiment of this specification, a paging device is provided, including: An acquisition module is configured to acquire an image to be processed containing multiple pages of content; A recognition module is configured to recognize the image to be processed by using an optical character recognition algorithm to obtain position information of each character contained in the image to be processed; A first determination module is configured to determine the characters belonging to the same row in the image to be processed according to the position information of each character, and obtain a plurality of row character sets; A clustering module is configured to cluster the plurality of row character sets based on a clustering algorithm to obtain a cluster center; An obtaining module is configured to obtain the image paging horizontal coordinate according to the horizontal coordinate of the cluster center; A second determination module is configured to determine, based on the image page horizontal coordinate, a segmentation line perpendicular to the horizontal coordinate axis where the image page horizontal coordinate is located; The paging module is configured to perform paging processing on the image to be processed by using the segmentation line to obtain a target image.

[0007] According to a third aspect of an embodiment of this specification, a computing device is provided, including: Memory and processor; The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions. When the computer executable instructions are executed by the processor, the steps of the above-mentioned paging method are implemented.

[0008] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the instructions are executed by a processor, the steps of the above-mentioned paging method are implemented.

[0009] According to a fifth aspect of the embodiments of this specification, a computer program is provided, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the above-mentioned paging method.

[0010] At least one embodiment of the present specification can achieve the following beneficial effects: by acquiring an image to be processed containing multiple pages of content, an optical character recognition algorithm can be used to recognize the image to be processed, so that several row character sets of characters belonging to the same row in the image to be processed can be determined based on the position information of each character in the image to be processed obtained by recognition, and several row character sets can be clustered based on a clustering algorithm, and the image paging horizontal coordinate can be determined based on the horizontal coordinate of the obtained cluster center, and a dividing line perpendicular to the horizontal coordinate axis can be determined based on the image paging horizontal coordinate, so that the dividing line can be used to perform paging processing on the image to be processed to obtain a paging target image. This enables the character recognition algorithm to perform character recognition on the paging target image page by page, thereby improving the accuracy of the character recognition result. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] Figure 1 A flow chart of a paging method provided in an embodiment of this specification; Figure 2 It is a schematic diagram of an abnormal line in a composition paper provided in an embodiment of the present specification; Figure 3 This is a schematic diagram of paging when some pages of a multi-page content have no characters provided by an embodiment of this specification; Figure 4 It is a process flow chart of a paging method provided in an embodiment of this specification; Figure 5 It is a structural schematic diagram of a paging device provided in an embodiment of this specification; Figure 6 It is a structural block diagram of a computing device provided in an embodiment of this specification. DETAILED DESCRIPTION

[0012] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.

[0013] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.

[0014] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0015] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0016] First, the terms involved in one or more embodiments of this specification are explained.

[0017] Optical Character Recognition (OCR): is a technology that converts printed or handwritten text from images such as pictures and scans into a machine-readable format. OCR technology can capture characters printed on paper through electronic devices such as scanners or digital cameras, and then use pattern recognition technology to translate the shapes of these characters into computer text. It can be understood that OCR technology can convert text in paper documents into editable and searchable text formats.

[0018] Clustering: It is a very important unsupervised learning method in the field of data mining and machine learning. The purpose of clustering is to divide the samples in the data set into several groups (or "clusters") according to certain standards without pre-labeling or classification information, so that the samples in the same cluster have a high degree of similarity, while the samples in different clusters have a low degree of similarity. Clustering is the process of automatically grouping according to the characteristics of the data itself.

[0019] Keystone correction: is an image processing technology used to correct image shape distortion caused by improper shooting angle or position, so that the image is transformed from a trapezoid or other irregular shape to a rectangle to eliminate errors and deformations in the image. Keystone correction technology is widely used in computer vision, machine vision, image processing and other fields. Keystone correction can transform a trapezoidal distorted image into a rectangular distorted image by performing a perspective transformation on the image, thereby eliminating the tilt and distortion in the image.

[0020] Directly using A3-sized test papers for grading may fail to achieve the expected recognition results due to the poor effect of OCR technology. The input image size of OCR technology is often fixed, and the input image needs to be scaled to a fixed size before using OCR. A3-sized test paper images are larger than A4 images, and when scaled to a fixed size, the degree of reduction is greater and the information in the image is more distorted, resulting in poor recognition results using OCR technology. In order to more effectively recognize the text content in A3 test papers, it is necessary to split the A3 image into two A4 pages, and then recognize the split A4 images separately.

[0021] Generally speaking, in order to divide an A3 image into two A4 pages, the center line of the image or a line perpendicular to the upper edge of the image corresponding to a fixed coordinate is usually used as the dividing line to divide the A3 image into pages. However, the styles of A3 test papers used by various schools are varied, and the composition paper may be tilted or offset due to printing offset, or the paper is not in the center when taking a photo. If the pages are divided according to the center line or a line perpendicular to the upper edge of the image corresponding to a fixed coordinate, the text information in a page of the image after paging is easily lost, reducing the accuracy of the recognition result.

[0022] In this specification, a paging method is provided. This specification also relates to a paging device, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.

[0023] See also Figure 1 , Figure 1 This is a flow chart of a paging method provided in an embodiment of this specification. From a program perspective, the execution subject of the process can be a program installed on a server or a paging platform. From a hardware perspective, the execution subject of the process can be a server or a paging platform that can paging images containing multiple pages of content. Figure 1 As shown, the specific steps include the following steps.

[0024] Step 102: Acquire an image to be processed containing multiple pages of content.

[0025] In the embodiments of this specification, the multi-page content may represent at least two pages of test paper content. The multi-page content may include Chinese reading test content, Chinese composition test content, mathematics application test content, English composition test content, etc. The multi-page content may include the content on the front and back of a test paper; it may also include the content of multiple different test papers. The image to be processed may be obtained by scanning the multi-page content; it may also be obtained by taking pictures of the multi-page content using a camera device, which is not specifically limited here.

[0026] Step 104: using an optical character recognition algorithm to recognize the image to be processed, and obtaining position information of each character contained in the image to be processed.

[0027] In the embodiments of this specification, an optical character recognition algorithm can be used to recognize character information such as text, punctuation marks, English words, letters, special symbols, etc. in the image to be processed. The position information can be the coordinate position information of the character in the image to be processed, specifically, it can be the coordinate information of the center of the character box where the character is located. The position information can also be composed of the coordinate information of the upper left corner of the character box where the character is located, the width of the character box, and the height of the character box. The character box can be a regional box used to select individual characters during the character recognition process. In practical applications, the optical character recognition algorithm can be at least one of template matching, feature extraction, neural network, Transformers, CTC and other algorithms.

[0028] In practical applications, a rectangular coordinate system can be established with the upper left corner of the image to be processed as the origin of the coordinate system; or, a rectangular coordinate system can be established with the center point of the image to be processed as the origin of the coordinate system; or, a rectangular coordinate system can be established with any point such as the lower left corner, upper right corner, or lower right corner of the image to be processed as the origin of the coordinate system; the right direction can be used as the positive axis of the horizontal coordinate, and the lower direction can be used as the positive axis of the vertical coordinate; or, the left direction can be used as the positive axis of the horizontal coordinate, and the upper direction can be used as the positive axis of the vertical coordinate; or, the right direction can be used as the positive axis of the horizontal coordinate, and the upper direction can be used as the positive axis of the vertical coordinate; or, the left direction can be used as the positive axis of the horizontal coordinate, and the upper direction can be used as the positive axis of the vertical coordinate; or, the left direction can be used as the positive axis of the horizontal coordinate, and the lower direction can be used as the positive axis of the vertical coordinate. A rectangular coordinate system is established for the image to be processed so that the coordinate position of each character in the image to be processed can be determined. The establishment of a rectangular coordinate system can be based on actual needs and is not specifically limited here. The rectangular coordinate system can be divided into scales according to pixel points. Specifically, one pixel point can represent one scale, or two pixels can represent one scale, etc.

[0029] In practical applications, if the position information is composed of the coordinate information of the upper left corner of the character box where the character is located, the width of the character box, and the height of the character box, it can be output in a preset format, such as in the format of an (x, y, w, h) integer array, and represents the position information of the character. x can represent the horizontal coordinate value of the upper left corner of the character box in the image to be processed; y can represent the vertical coordinate value of the upper left corner of the character box in the image to be processed; w can represent the width value of the character box; h can represent the height value of the character box.

[0030] If the position information is the coordinate position information of the character in the image to be processed, it can be represented by an integer data group (cx, cy) in a preset format, where cx can represent the horizontal coordinate value of the center of the character box where the character is located in the image to be processed. Specifically, it can be calculated and determined based on cx=w / 2+x; cy can represent the vertical coordinate value of the center of the character box where the character is located in the image to be processed. Specifically, it can be calculated and determined based on cy=h / 2+y.

[0031] Step 106: According to the position information of each character, characters belonging to the same row in the image to be processed are determined to obtain a plurality of row character sets.

[0032] In the embodiments of this specification, a row character set represents a set of several characters belonging to the same row. A row character set may include position information of one or more characters.

[0033] In practical applications, characters belonging to the same row can be determined based on the values ​​representing the ordinates in the position information of the characters. Specifically, characters with similar ordinate values ​​can be determined as characters in the same row. Specifically, the differences in the ordinates of the characters in the same row are all less than or equal to the first preset threshold. It can be understood that if the values ​​of the ordinates of two adjacent characters are relatively close, but the difference in the values ​​of the abscissas is large, the two adjacent characters may not be determined as characters in the same row. Specifically, if the difference in the abscissas of the two adjacent characters among the characters with multiple ordinate differences less than or equal to the first preset threshold is greater than the preset abscissa difference, it can be determined that the two characters do not belong to the same row.

[0034] In actual applications, after determining multiple first character sets in which the difference in the vertical coordinates of each character is less than or equal to a first preset threshold value based on the vertical coordinates of each character in the above manner, it is possible to determine whether the difference in the horizontal coordinates of adjacent characters is greater than the preset horizontal coordinate difference for the horizontal coordinates of each character in the first character set. If it is greater than the preset horizontal coordinate difference, it can be determined that the adjacent characters belong to different rows, so that the first character set can be divided secondary based on the horizontal coordinate to obtain multiple second character sets, and the multiple second character sets can be determined as several row character sets.

[0035] Step 108: clustering the plurality of row character sets based on a clustering algorithm to obtain cluster centers.

[0036] In the embodiments of this specification, the clustering algorithm can be at least one of the algorithms for clustering such as K-means clustering, K-center points, Gaussian mixture model, X-means, GMeans, etc. The number of cluster centers obtained by clustering can be pre-set based on the number of page numbers contained in the page content of the image to be processed, so that a pre-set number of cluster centers can be obtained based on the clustering algorithm. The cluster center can be specifically represented by coordinate information. In practical applications, the row center information of several row character sets can be determined, and clustering is performed based on several row centers to obtain the cluster center. The row center information represents the coordinate information of the center of a row of characters corresponding to the row character set in the image to be processed.

[0037] Step 110: Obtain the image page horizontal coordinate according to the horizontal coordinate of the cluster center.

[0038] In the embodiments of the present specification, the image paging horizontal coordinate can represent the horizontal coordinate of the paging position of the image paging, and the image can be paging according to the coordinate value represented by the image paging horizontal coordinate. If the image to be processed includes multiple pages arranged horizontally, for example, the image to be processed includes page A and page B, page A is located on the left side of page B, and page B is located on the right side of page A. The image paging horizontal coordinates of the two adjacent pages can be determined by calculating the mean of the horizontal coordinates of the cluster centers of the two adjacent pages in the image to be processed, so that the two adjacent pages in the image to be processed can be paging based on the image paging horizontal coordinates, thereby improving the accuracy of paging the image to be processed.

[0039] In practical applications, if the image to be processed includes multiple pages of content arranged vertically, for example, the image to be processed includes page C and page D, page C is located on the upper side of page D; page D is located on the lower side of page C. For multiple pages of content arranged vertically, the image can be paged based on the image paging ordinate, and the image paging ordinate can be obtained by processing the ordinate of the cluster center. The image paging ordinate can represent the ordinate of the paging position of the image paging, and the image can be paged according to the coordinate value represented by the image paging ordinate. Specifically, the paging ordinates of two adjacent pages can be determined by calculating the mean ordinate of the cluster centers of adjacent pages in the image to be processed, so that the adjacent pages in the image to be processed can be paged based on the image paging ordinate, thereby improving the accuracy of paging the image to be processed.

[0040] As another implementation, if the image to be processed includes multiple pages of content arranged vertically, the image to be processed may be rotated 90°, so that the rotated image to be processed may be processed according to the horizontal coordinate of the image paging.

[0041] Step 112: Based on the image page horizontal coordinate, determine a segmentation line perpendicular to the horizontal coordinate axis where the image page horizontal coordinate is located.

[0042] In the embodiment of the present specification, the horizontal axis may be the horizontal axis in a rectangular coordinate system established based on the image to be processed. The dividing line may be a line used to divide the image to be processed into pages, or may be a line segment represented by position information.

[0043] The method of determining the dividing line, specifically, can first determine the point of the image page horizontal coordinate on the horizontal axis, for example, the image page horizontal coordinate is x=2430, the point (2430,0) on the horizontal axis can be determined; then the point is used as a reference point to make a vertical line perpendicular to the horizontal axis, the point can be included in the vertical line, and the vertical line is used as the vertical dividing line, and the vertical dividing line is parallel to the vertical axis. It can be understood that the values ​​of the horizontal coordinates of each point on the dividing line are the same as the values ​​corresponding to the image page horizontal coordinates.

[0044] Specifically, the method of determining the segmentation line can also determine multiple coordinate points whose horizontal coordinate values ​​are the values ​​of the horizontal coordinate of the image page based on the horizontal coordinate of the image page, connect the multiple coordinate points, and obtain the segmentation line for paging the image to be processed, and the number of the multiple coordinate points is at least 2. Continuing with the above example, the coordinate points (2430,0), (2430,100), (2430,1000) and (2430,1750) can be obtained, and the four coordinate points are connected to obtain the segmentation line.

[0045] In practical applications, if the dividing line is determined based on the image paging ordinate, specifically, the point of the image paging ordinate on the ordinate axis can be determined first; then the point is used as a reference point to make a vertical line perpendicular to the ordinate axis, and the point is included in the vertical line. The vertical line is used as a horizontal dividing line, and the horizontal dividing line can be parallel to the horizontal axis. It can be understood that the values ​​of the ordinates of each point on the dividing line are the same as the values ​​corresponding to the image paging ordinate. Similarly, multiple coordinate points whose ordinate values ​​are the values ​​of the image paging ordinate can be determined based on the image paging ordinate, and the multiple coordinate points can be connected to obtain a dividing line for paging the image to be processed.

[0046] Step 114: using the segmentation lines to perform paging processing on the image to be processed to obtain a target image.

[0047] In the embodiments of this specification, the target image may be one or more. Among the multiple pages of content in the image to be processed, some pages may have character information, while others may not; or all pages may have character information. If only one page among all pages in the image to be processed has character information, the target image obtained after paging may be one, and the other pages without character information after paging may be discarded or retained; if there are multiple pages in the image to be processed that all have character information, the target image may be multiple images corresponding to the multiple pages.

[0048] In practical applications, after obtaining the target image, the size of the target image can be adjusted so that the size of the adjusted target image can meet the fixed size specified by the character recognition algorithm, so that the character recognition algorithm can be used to recognize the characters in the adjusted target image. The character recognition algorithm can also be used to directly recognize the characters in the target image without adjusting the size of the target image. On the one hand, the character recognition algorithm recognizes the multiple pages of content in the image to be processed page by page, avoiding the loss or distortion of information caused by scaling the test paper that is too large, thereby improving the accuracy of character recognition. On the other hand, by determining the horizontal coordinate of the page paging to determine the dividing line to paginate the image, it is avoided that there are missing characters in the target image after paging, which helps to ensure the consistency of the context information after recognition, so that the test content can be machine-scored or manually scored based on the coherent context information in the recognition result to improve the scoring accuracy.

[0049] It should be understood that the order of some steps in the methods described in one or more embodiments of this specification can be interchanged according to actual needs, or some steps can be omitted or deleted.

[0050] Figure 1 The method in the embodiment can obtain an image to be processed containing multiple pages of content, and can use an optical character recognition algorithm to recognize the image to be processed, so that according to the position information of each character in the image to be processed obtained by recognition, several row character sets of characters belonging to the same row in the image to be processed can be determined, and several row character sets can be clustered based on a clustering algorithm. The image paging horizontal coordinate can be determined according to the horizontal coordinate of the obtained cluster center, and a dividing line perpendicular to the horizontal coordinate axis can be determined according to the image paging horizontal coordinate, so that the dividing line can be used to perform paging processing on the image to be processed to obtain a paging target image. This enables the character recognition algorithm to perform character recognition on the paging target image page by page, thereby improving the accuracy of the character recognition result.

[0051] based on Figure 1 The method, the embodiments of this specification also provide some specific implementation methods of the method, which are described below.

[0052] As an implementation manner, optionally, before using the optical character recognition algorithm to recognize the image to be processed in the embodiments of this specification, the following steps may also be included: Correcting the image to be processed to obtain a corrected image to be processed; The step of using an optical character recognition algorithm to recognize the image to be processed to obtain position information of each character contained in the image to be processed may specifically include: The corrected image to be processed is recognized using the optical character recognition algorithm to obtain position information of each character contained in the corrected image to be processed.

[0053] In the embodiments of this specification, a preset image correction method can be used to correct the image to be processed, so that the photographed object or scanned object contained in the image to be processed can be restored to the effect of being viewed directly from the front. The preset image correction method can specifically include at least one of the image correction methods such as trapezoidal correction, geometric transformation, affine transformation, nonlinear transformation, a method for correcting an image based on image features, and a method for correcting an image based on a deep learning model. It is understandable that a rectangular coordinate system can be established in the corrected image to be processed so that the position information of each character in the corrected image to be processed can be identified.

[0054] In practical applications, before correcting the image to be processed, the image to be processed may also be subjected to denoising. Specifically, the undesired random signals in the process of acquiring the image to be processed may be removed, thereby avoiding the image quality degradation caused by the presence of noise, affecting the visual effect and subsequent character recognition processing. The server may remove the noise in the image to be processed by using spatial domain filters, frequency domain filters, wavelet transforms, and the like.

[0055] In practical applications, the server can crop the image to be processed before correcting it. Specifically, the edge line of the paper in the image to be processed can be detected, and the background area outside the edge of the paper in the image to be processed can be removed; or, the background area of ​​the image to be processed can be cropped during the correction of the image to be processed; or, the background area of ​​the image to be processed can be cropped after the correction of the image to be processed, thereby reducing the impact of external factors on character recognition and improving the accuracy of character recognition. It is understandable that the establishment of the coordinate system can also be established on the basis of the corrected and cropped image to be processed, so as to be able to recognize each character contained in the corrected and cropped image to be processed and obtain the position information of each character.

[0056] In the embodiments of this specification, the processed image can be corrected to avoid tilt of the photographed object or the scanned object in the image, which affects the optical character recognition algorithm's recognition of the positions of each character in the image, thereby improving the accuracy of the recognition results of the character positions.

[0057] As an implementation manner, optionally, the image to be processed in the embodiment of this specification includes a paper image carrying multiple pages of content; and the correcting the image to be processed to obtain the corrected image to be processed may specifically include: Converting the image to be processed into a grayscale image; Detecting the grayscale image using an edge detection function to obtain contour information of the paper image; Determine four corner point information of the paper image from the outline information; The paper image is mapped into a rectangle based on the four corner point information by using a perspective transformation function to obtain the corrected image to be processed.

[0058] In the embodiments of this specification, the step of converting the image to be processed from a color image to a grayscale image can be implemented by an image processing library provided in a programming language. Specifically, the programming language of at least one image processing library such as Pillow library, OpenCV library, HTML5 CanvasAPI, etc. can be used to convert the color image to a grayscale image. Exemplarily, the OpenCV library can be used to read the image to be processed and convert the image to be processed into a grayscale image.

[0059] In the embodiments of this specification, the edge detection function can be at least one of the algorithms such as Sobel operator, Prewitt operator, Canny edge detection, Laplacian operator, LoG, etc. Specifically, the grayscale image may include paper carrying test information, and the edge detection function can be used to detect the edge of the paper in the grayscale image to obtain the outline of the paper or the paper area in the grayscale image. Exemplarily, the Canny edge detection function can be used to detect the edge of the composition paper contained in the grayscale image to determine the outline of the composition paper in the grayscale image. In practical applications, the edge detection function can also be a packaged function in the image processing library, such as the Canny algorithm packaged in cv2.findContours contained in the OpenCV library.

[0060] In the embodiments of this specification, contour estimation functions such as cv2.approxPolyDP, cv2.cornerHarris, cv2.goodFeaturesToTrack and other functions can be used to calculate the corner point information of the four corner points of the paper image through the contour information of the paper image. The corner point information may include the coordinate information of the corner point in the grayscale image.

[0061] In practical applications, the four corner point information can be transformed in perspective using functions such as cv2.getPerspectiveTransform and cv2.warpPerspective, so that the irregularly shaped paper image can be mapped into a rectangular paper image, and then the rectangular paper image can be determined as the corrected image to be processed. This allows the tilt of the paper in the image to be processed to be corrected, and the paper portion can be intercepted through the edge detection algorithm, or the background portion outside the paper portion can be cropped to effectively prevent interference from the background portion, which is beneficial for recognizing the characters in the corrected image to be processed and improving the display effect of the paginated image.

[0062] As an implementation manner, optionally, the position information of each character in the embodiment of this specification at least includes the vertical coordinate of each character; and determining the characters belonging to the same row in the image to be processed according to the position information of each character may specifically include: For any two characters among the characters, determining whether a first difference between the vertical coordinates of the any two characters is less than or equal to a first preset threshold; If the first difference is less than or equal to the first preset threshold, it is determined that the arbitrary two characters belong to the same row.

[0063] In the embodiments of this specification, the position information may represent the coordinate information of the character in the image to be processed. The first difference may be an absolute value obtained by calculating the difference between the vertical coordinates of any two characters in the image to be processed; or it may be an absolute value obtained by calculating the difference between the vertical coordinates of any two characters in the corrected image to be processed. The first preset threshold may be obtained based on expert experience or by analyzing historical data.

[0064] In practical applications, the method for obtaining the position information of characters may be, specifically, to use the optical character recognition (OCR) algorithm to recognize the image to be processed, and obtain the rectangular frame position representing the area of ​​each character in the image to be processed; the rectangular frame position includes the coordinates of the upper left corner of the rectangular frame, the height of the rectangular frame, and the width of the rectangular frame; the horizontal coordinate of each character is determined by calculating the sum of half the width of the rectangular frame and the horizontal coordinate of the upper left corner of the rectangular frame; the vertical coordinate of each character is determined by calculating the sum of half the height of the rectangular frame and the vertical coordinate of the upper left corner of the rectangular frame; and the position information of each character is determined based on the horizontal coordinate and the vertical coordinate.

[0065] In practical applications, after the OCR algorithm recognizes the image to be processed, it can return the rectangular box position (boundingbox, bbox) of each character in the image to be processed. The returned form can be the (x, y, w, h) integer array shown above, where x and y can represent the horizontal and vertical coordinates of the upper left corner of the bbox, and w and h can represent the width and height of the bbox. The server can calculate the coordinates (cx, cy) of the center of each character based on the bbox of each character output by the OCR algorithm. Specifically, it can be calculated based on the above calculation formulas for cx and cy, which will not be repeated here.

[0066] In practical applications, the first preset threshold can also be based on the formula th=h max *p is used for calculation, th can represent the first preset threshold, h max It can represent the width value of the character corresponding to the maximum width of the bbox of each character in the image to be processed; p can represent the percentage of a line, and the specific value range can be [0.5,0.8], and the value range can be obtained based on expert experience. If the calculation result of th is a non-integer, the value corresponding to th can be processed by rounding up to obtain the corresponding first preset threshold. Characters belonging to the same line should satisfy that the difference in the vertical coordinates is less than or equal to the first preset threshold. For example, the position information of character 1 is (cx1, cy1), and the position information of character 2 is (cx2, cy2). If |cy1-cy2|<=th, it can be determined that characters 1 and 2 belong to the same line.

[0067] In actual applications, multiple characters whose ordinate differences satisfy a first preset threshold can also be arranged from small to large according to the values ​​of the abscissas, and it is calculated whether the difference in the abscissas of adjacent characters is less than or equal to the preset abscissa difference. If the difference in the abscissas of adjacent characters is less than or equal to the preset abscissa difference, the two adjacent abscissas can be determined to belong to the same row. If the difference in the abscissas of two adjacent characters is greater than the preset abscissa difference, it can be determined that the character with the larger abscissa value is in another row. For example, the order of characters arranged from small to large is character 1, character 2, character 3, character 4, and character 5. By determining through the abscissas that the abscissa difference between character 1 and character 2, the abscissa difference between character 2 and character 3, and the abscissa difference between character 4 and character 5 are all less than or equal to the preset abscissa difference, but the abscissa difference between character 3 and character 4 is greater than the preset abscissa difference, it can be determined that characters 1, 2, and 3 belong to the same row, it can be determined that character 4 and character 3 do not belong to the same row, and it can be determined that character 4 and character 5 belong to the same row. The preset horizontal coordinate difference value can be determined based on expert experience or based on the blank width between each page in the multi-page content of the image to be processed. For example, if the blank width between pages is one tenth of the width of the image to be processed, the preset horizontal coordinate difference value can be set to one tenth of the width of the image to be processed. In this way, clustering processing can be performed based on the determined characters in each row, reducing the computational complexity of clustering, reducing the time consumed by clustering, and thus improving the paging efficiency.

[0068] As an implementation manner, optionally, before clustering the plurality of row character sets based on a clustering algorithm in the embodiments of this specification, the following may also be included: For any row of character sets among the plurality of row of character sets, determining whether the number of characters included in the any row of character sets is less than or equal to a preset number; If the number of characters included in the arbitrary row character set is less than or equal to the preset number, the arbitrary row character set is removed from the plurality of row character sets to obtain a modified plurality of row character sets; The clustering of the plurality of row character sets based on a clustering algorithm to obtain cluster centers may specifically include: The corrected sets of characters in multiple rows are clustered based on the clustering algorithm to obtain the cluster center.

[0069] In the embodiments of this specification, the preset number can be obtained based on expert experience, can be determined based on historical data, or can be determined based on the number of words that can be filled in a line of paper of the image to be processed. For example, a line is 20 words, half a line is 10 words, and the difference between the center of a line and the center of a half line is approximately 5 words. The preset number can be determined to be 5 words or 3 words.

[0070] In the embodiment of the present specification, if the number of characters contained in any row character set is greater than the preset number, the arbitrary row character set can be retained in a number of row character sets. Thus, the character set with a small number of characters can be eliminated based on the relationship between the number of characters contained in the row character set and the preset number, so as to avoid the influence of the row character set with a small number of characters on the clustering result, thereby avoiding the offset of the segmentation line caused by the offset of the clustering result, improving the accuracy of the paging result, and improving the accuracy of the clustering result.

[0071] In the embodiment of the present specification, the modified several line character sets are clustered based on the clustering algorithm to obtain the cluster center. Specifically, the line center of each line of the modified several line character sets is calculated, and the line center is used to represent the position of all characters in the line. Clustering is performed based on the line center corresponding to the modified several line character sets to obtain the cluster center. Therefore, it is not necessary to input the position information of all characters in the modified several line character sets into the clustering algorithm, but the coordinates of the line center corresponding to the modified several line character sets are input into the clustering algorithm to reduce the amount of data input into the clustering algorithm, speed up the speed of obtaining the cluster center, and improve the paging efficiency.

[0072] The row center can represent the center of a row of characters corresponding to the row character set. The row center can be specifically obtained by averaging the horizontal coordinate values ​​of each character in the row character set, and taking the average value of the horizontal coordinates as the average value of the row center; since the difference between the vertical coordinates of each character in the row character set is small, the vertical coordinate of any character in the row character set can be used as the vertical coordinate of the row center; the average value can also be calculated as the vertical coordinate of the row center; the vertical coordinate of the character corresponding to the smallest vertical coordinate value in the row character set can also be used as the vertical coordinate of the row center; the vertical coordinate of the character corresponding to the largest vertical coordinate value in the row character set can also be used as the vertical coordinate of the row center. The method of obtaining the vertical coordinate of the row center is not specifically limited here.

[0073] As an implementation mode, optionally, the method described in the embodiments of this specification may also include: Obtaining the width and height of the image to be processed; Determining an initial cluster center based on the width and height of the image to be processed; Calculate the mean of the horizontal coordinate information of each character in the arbitrary row of character set to obtain the row center horizontal coordinate corresponding to the arbitrary row of character set; The determining whether the number of characters included in the character set of any row is less than or equal to a preset number may specifically include: It is determined whether a second difference between the horizontal coordinate of the row center and the horizontal coordinate of the initial cluster center is greater than or equal to a second preset threshold.

[0074] In the embodiments of the present specification, the number of initial cluster centers can be determined based on the number of pages contained in the image to be processed. For example, by identifying and determining that the number of pages in the image to be processed is 2, the number of initial cluster centers can be set to 2. Further, the initial cluster centers can be determined based on the number of cluster centers and the width and height of the image to be processed; the initial cluster centers can also be determined based on the number of cluster centers and the width and height of the image to be processed after correction. For example, the cluster center is set to 2, the width of the image to be processed is img_w, and the height of the image to be processed is img_h. By img_w>img_h, it can be determined that the paper in the image to be processed is a left and right page of paper, and the coordinates of the initial cluster center of the left page can be determined to be left_center=(img_w*0.25, img_h / 2); the coordinates of the initial cluster center of the right page are right_center=(img_w*0.75, img_h / 2). It can be understood that the values ​​in the coordinates of the initial cluster center are all positive numbers. Specifically, the calculation results can be processed using a rounding-up function or a rounding-down function, and the integers can be used as the final coordinates of the initial cluster center.

[0075] The row center horizontal coordinate in the embodiment of this specification may also be obtained by using an OCR algorithm to directly output the mark value of the row center line of each row in the image to be processed after recognition. In this way, the row center horizontal coordinate may also be obtained.

[0076] In the embodiments of the present specification, the second difference can be obtained by performing a difference calculation based on the horizontal coordinates of the initial cluster centers and the row centers corresponding to the row character set in the image to be processed; it can also be obtained by performing a difference calculation based on the horizontal coordinates of the initial cluster centers and the row centers corresponding to the row character set in the corrected image to be processed.

[0077] As an implementation method, the second difference can be calculated based on the formula x_gap=abs(chx-c1x), where x_gap can represent the second difference, abs can represent the absolute value of the calculation result, chx can represent the central horizontal coordinate of the row center corresponding to any row character set, and c1x can represent the horizontal coordinate of the initial cluster center.

[0078] The second preset threshold may be determined based on the width of a preset number of characters, or may be determined based on expert experience, or may be determined based on historical data, which is not specifically limited here.

[0079] As another implementation, the second preset threshold value can also be determined in the following manner: According to the formula Calculating a second preset threshold; represents a second preset threshold; Indicates the width of the character with the largest width in the character set of the plurality of rows; represents the rounding function; Indicates the number of characters contained in the row character set with the largest number of characters among the plurality of row character sets; represents the range coefficient, and its value is [0.1, 0.3]. The range coefficient can be an empirical value. It can be understood that if the value of x_gap is greater than or equal to the threshold th_gap, the row character set corresponding to the value of x_gap can be removed from the plurality of row character sets.

[0080] In an embodiment of the present specification, if the second difference between the horizontal coordinate of the row center and the horizontal coordinate of the initial cluster center is greater than or equal to a second preset threshold, it can be determined that the row corresponding to the arbitrary row character set is an abnormal row in the image to be processed, and the arbitrary row character set can be eliminated from several row character sets; if the second difference between the horizontal coordinate of the row center and the horizontal coordinate of the initial cluster center is less than the second preset threshold, the arbitrary row character set can be retained from several row character sets.

[0081] To clearly illustrate the filtering of abnormal rows, Figure 2 Schematic diagram of an abnormal line in a composition paper provided in an embodiment of this specification. Figure 2 As shown, the image to be processed may include composition paper; the row framed by the black rectangular frame 21 may be an abnormal row whose second difference between the horizontal coordinate of the center of the row character set and the horizontal coordinate of the initial clustering center is greater than or equal to the second preset threshold value. Other rows may represent normal rows, and the row character sets corresponding to the normal rows may be retained. The white dot 22 may represent the first clustering center obtained by directly clustering several row character sets without removing abnormal rows; the dotted line 23 may represent the segmentation line obtained based on the first clustering center; the black dot 24 may represent the second clustering center obtained by clustering several corrected row character sets; the solid line 25 may represent the segmentation line obtained based on the second clustering center.

[0082] It should be noted that Figure 2 In the schematic diagram shown in , the specific text is blurred in order to protect the content of the composition, such as adding a horizontal line to cover the text content. In practical applications, the image to be processed is a normal image that has not been blurred, and the image to be processed contains clear text information, such as an image obtained by scanning or taking a photo of a test paper.

[0083] In an embodiment of the present specification, row character sets whose second difference between the horizontal coordinate of the row center and the horizontal coordinate of the initial cluster center in several row character sets is greater than or equal to a second preset threshold can be eliminated, so that clustering processing can be performed based on the corrected row character sets, avoiding the influence of abnormal rows on the clustering results, and further avoiding the influence on the paging results, thereby improving the accuracy of paging.

[0084] As an implementation manner, optionally, before clustering the plurality of row character sets based on a clustering algorithm in the embodiments of this specification, the following may also be included: Obtaining page number information of the multiple pages of content; Determining the number of pages of content contained in the image to be processed according to the page number information; Determining the number of pages as a parameter value representing the number of cluster centers in the clustering algorithm; The clustering of the plurality of row character sets based on a clustering algorithm specifically includes: According to the parameter values, the plurality of row character sets are clustered based on the clustering algorithm.

[0085] In the embodiments of this specification, the page information can be code number information or other character information in the page number part. The number of pages can be determined based on the number of code numbers represented in the page information. Before clustering, the parameter representing the number of cluster centers in the clustering algorithm can be set so that the corresponding number of cluster centers can be obtained. For example, if the page information obtained is "7 / 8" and "8 / 8", it can be determined that the image to be processed contains two pages, and the parameter value representing the number of cluster centers in the clustering algorithm is set to 2. Alternatively, if the page information obtained is "7 / 8", "8 / 8", "7 / 8", and "8 / 8", it can be determined that the image to be processed contains four pages, and the parameter value representing the number of cluster centers in the clustering algorithm is set to 4.

[0086] As an implementation manner, optionally, the cluster centers described in the embodiment of this specification are two cluster centers; and obtaining the image paging horizontal coordinates according to the horizontal coordinates of the cluster centers may specifically include: Determine whether a third difference between the horizontal coordinates of the two cluster centers is greater than or equal to a third preset threshold; If the third difference is greater than or equal to the third preset threshold, the average value of the horizontal coordinates of the two cluster centers is determined as the image paging horizontal coordinate.

[0087] In the embodiments of this specification, the third difference value can be obtained by performing a difference calculation based on the horizontal coordinates of the two cluster centers in the image to be processed, or can be obtained by performing a difference calculation based on the horizontal coordinates of the two cluster centers in the corrected image to be processed. The third preset threshold value can be obtained based on expert experience, or can be determined based on historical data. It can also be determined based on the paper information in the image to be processed. For example, if the width of the image to be processed is img_w, the sum of the widths of the blanks on both sides is img_w*0.1, and the width of the blank in the middle is img_w*0.1, the third preset threshold value can be determined as img_w*0.5.

[0088] In practical applications, it is also possible to determine whether the third difference is greater than or equal to the third preset threshold based on the formula abs(c2x-c3x)>=img_w*c_th, where abs can represent the absolute value of the calculation result; c2x and c3x can represent the horizontal coordinates of the two cluster centers; the calculation result of img_w*c_th can represent the third preset threshold, img_w represents the width of the image to be processed, and c_th represents the effective coefficient, which can be in the range of [0.25,0.5] and can be determined based on empirical values. It can be determined that s=(c1x+c2x) / 2, and s can represent the horizontal coordinate of the image paging.

[0089] As an implementation mode, optionally, the method described in the embodiments of this specification may also include: If the third difference is less than the third preset threshold, a reference horizontal coordinate of the reference line is obtained; the reference horizontal coordinate of the reference line is the product of the width of the image to be processed and a reference coefficient; the value of the reference coefficient is [0.4, 0.6]; Determine whether the average value of the horizontal coordinates of the two cluster centers is less than or equal to the reference horizontal coordinate; If the average value of the horizontal coordinates of the two cluster centers is less than or equal to the reference horizontal coordinate, the horizontal coordinate corresponding to the character with the largest horizontal coordinate among the characters is determined as the image paging horizontal coordinate; If the average value of the horizontal coordinates of the two cluster centers is greater than the reference horizontal coordinate, the horizontal coordinate corresponding to the character with the smallest horizontal coordinate among the characters is determined as the image paging horizontal coordinate.

[0090] In the embodiments of this specification, the horizontal coordinate of the reference line can be determined based on the product of the width of the image to be processed and the reference coefficient; it can also be determined based on the product of the width of the image to be processed after correction and the reference coefficient. It can be understood that the coordinates of the cluster center and the coordinates of the reference line are obtained in the same coordinate system, that is, the coordinates of the cluster center are the coordinates in the corrected image to be processed, and the coordinates of the reference line are also the coordinates in the corrected image to be processed. The horizontal coordinate corresponding to the character with the largest horizontal coordinate can represent the horizontal coordinate value with the largest value in the horizontal coordinate of the upper right corner or lower right corner of the bbox of each character obtained by OCR. The horizontal coordinate corresponding to the character with the smallest horizontal coordinate can represent the horizontal coordinate value with the smallest value in the horizontal coordinate of the upper left corner or lower left corner of the bbox of each character obtained by OCR.

[0091] In the embodiments of this specification, if the third difference is less than the third preset threshold, it can indicate that only one of the two pages of content in the image to be processed contains characters. If the average value of the abscissas of the two clustering centers is less than or equal to the reference abscissa, it can be determined that the left page in the image to be processed has characters and the right page does not have characters. To improve the accuracy of the recognition result, the maximum value of the abscissas of the characters in the left page can be used as the pagination abscissa to determine the corresponding dividing line. Thus, it can be ensured that after the image to be processed is paginated using this dividing line, the target image containing the content of the left page can also include the rightmost character corresponding to the maximum abscissa value, thereby avoiding the lack of characters in the left page image obtained after pagination based on the dividing line. For example, the reference abscissa is 0.5img_w, and the minimum abscissa value is max(x_i), where i can represent iterating through all the bounding boxes of the text. If 0.5img_w > s, it can indicate that the right page does not have characters, and it is determined that s = max(x_i).

[0092] In the embodiments of this specification, if the average value of the abscissas of the two clustering centers is greater than the reference abscissa, it can be determined that the right page in the image to be processed has characters and the left page does not have characters. To improve the accuracy of the recognition result, the minimum value of the abscissas of the characters in the right page can be used as the pagination abscissa to determine the corresponding dividing line. Thus, it can be ensured that after the image to be processed is paginated using this dividing line, the target image containing the content of the right page can also include the leftmost character corresponding to the minimum abscissa value, thereby avoiding the lack of characters in the right page image obtained after pagination based on the dividing line. For example, the reference abscissa is 0.5img_w, and the minimum abscissa value is min(x_i), where i can represent iterating through all the bounding boxes of the text. If 0.5img_w < s, it can indicate that the left page does not have characters, and it is determined that s = min(x_i).

[0093] In practical applications, the width and height of the corrected image to be processed can be the same as those of the image to be processed; they can also be smaller than the width and height of the image to be processed; it can also be that the width of the corrected image to be processed is smaller than the width of the image to be processed while the height is the same; or it can be that the height of the corrected image to be processed is smaller than the height of the image to be processed while the width is the same.

[0094] To more clearly illustrate the situation where some pages in the multi-page content do not have characters, taking the example where the left page has characters and the right page has no characters in the two-page content as an example, Figure 3It is a schematic diagram of paging when some pages of a multi-page content do not have characters provided by an embodiment of this specification. The white dots 31 can represent the two cluster centers obtained after clustering in the above manner; the dotted line 32 can be a dividing line determined based on the cluster centers; the character "?" framed by the black line frame 33 can represent the character with the largest horizontal coordinate among all the characters in the image; the solid line 34 can represent a dividing line determined based on the horizontal coordinate of the "?" character. Based on Figure 3 It can be seen from the example that if the processed image is paged according to the dotted line 32, the recognition result of the target image after paged will be incoherent and inaccurate, affecting the final scoring result. However, if the processed image is paged according to the solid line 33, there will be no missing characters, and the recognized characters will also be characters with coherent contexts, which can improve the accuracy of the scoring results based on character scoring.

[0095] It should be noted that Figure 3 In the schematic diagram shown in , the specific text is blurred in order to protect the content of the composition, such as adding a horizontal line to cover the text content. In practical applications, the image to be processed is a normal image that has not been blurred, and the image to be processed contains clear text information, such as an image obtained by scanning or taking a photo of a test paper.

[0096] It will be appreciated that the same characters mentioned above have the same physical meanings.

[0097] The following combination Figure 4 , taking the application of the paging method provided in this specification in the composition test as an example, the paging method is further explained. Figure 4 It is a processing flow chart of a paging method provided in an embodiment of this specification, which specifically includes the following steps.

[0098] Step 402: Obtain an image to be processed that includes multiple pages of composition test questions.

[0099] Step 404: Correct the image to be processed to obtain a corrected image to be processed.

[0100] Step 406: using an optical character recognition algorithm to recognize the corrected image to be processed, and obtaining position information of each character contained in the corrected image to be processed.

[0101] Step 408: According to the position information of each character, characters belonging to the same row in the corrected image to be processed are determined to obtain a plurality of row character sets.

[0102] Step 410: Calculate the average of the horizontal coordinate information of each character in each row character set to obtain the row center horizontal coordinates corresponding to several row character sets.

[0103] Step 412: Determine whether the number of characters included in any row of the character set is less than or equal to a preset number.

[0104] If yes, then execute step 414: remove the arbitrary row character set from the plurality of row character sets.

[0105] If not, execute step 416: retain the arbitrary row character set.

[0106] Step 418: Obtain a plurality of corrected line character sets.

[0107] Step 420: clustering the corrected sets of characters in a row based on a clustering algorithm to obtain cluster centers.

[0108] Step 422: Obtain the image page horizontal coordinate according to the horizontal coordinate of the cluster center in the corrected image to be processed.

[0109] Step 424: Based on the image page horizontal coordinate, determine a segmentation line perpendicular to the horizontal coordinate axis where the image page horizontal coordinate is located.

[0110] Step 426: Use the segmentation line to perform paging processing on the corrected image to be processed to obtain a plurality of pages of composition paper after paging.

[0111] In the embodiment of the present specification, the paginated multi-page composition paper is two horizontal pages, and the pagination can be based on the horizontal coordinates of the cluster centers; the paginated multi-page composition paper is two vertical pages, and the pagination can be based on the vertical coordinates of the cluster centers. If multiple composition papers are in one image to be processed, the image to be processed may include multiple horizontal and vertical pages. Specifically, the image pagination horizontal coordinate for vertical pagination can be determined based on the horizontal coordinates of two adjacent cluster centers in the horizontal direction; the image pagination vertical coordinate for horizontal pagination can be determined based on the vertical coordinates of two adjacent cluster centers in the vertical direction, and then multiple segmentation lines can be obtained based on the image pagination horizontal coordinate and the image pagination vertical coordinate to paginate the multiple pages of composition paper. The pagination method in the embodiment of the present specification can be applied to composition papers with three pages or more.

[0112] In actual applications, the paginated multi-page composition paper can be input into the OCR algorithm in the order of page numbers so that the OCR algorithm can recognize the composition content and facilitate the subsequent scoring of the composition through algorithms or models such as semantic recognition.

[0113] In addition, the above steps have similar or identical technical features to the aforementioned paging method, and reference may be made to the aforementioned description, which will not be repeated here.

[0114] The various technical features in the above embodiments can be combined arbitrarily as long as there is no conflict or contradiction between the combinations of features. However, due to space limitations, they are not described one by one. Therefore, any combination of the various technical features in the above embodiments also falls within the scope of this specification.

[0115] By acquiring an image to be processed containing multiple pages of content, an optical character recognition algorithm can be used to recognize the image to be processed, so that several row character sets of characters belonging to the same row in the image to be processed can be determined based on the position information of each character in the image to be processed obtained by recognition, and several row character sets can be clustered based on a clustering algorithm. The image paging horizontal coordinate can be determined based on the horizontal coordinate of the obtained cluster center, and a dividing line perpendicular to the horizontal coordinate axis can be determined based on the image paging horizontal coordinate, so that the dividing line can be used to perform paging processing on the image to be processed to obtain a paging target image. This allows the character recognition algorithm to perform character recognition on the paging target image page by page, thereby improving the accuracy of the character recognition result.

[0116] Corresponding to the above method embodiment, this specification also provides a paging device embodiment, Figure 5 Schematic diagram of a paging device provided in an embodiment of this specification. Figure 5 As shown, the device comprises: The acquisition module 502 is configured to acquire an image to be processed containing multiple pages of content; The recognition module 504 is configured to recognize the image to be processed by using an optical character recognition algorithm to obtain position information of each character contained in the image to be processed; A first determination module 506 is configured to determine characters belonging to the same row in the image to be processed according to the position information of each character, and obtain a plurality of row character sets; The clustering module 508 is configured to cluster the plurality of row character sets based on a clustering algorithm to obtain cluster centers; The obtaining module 510 is configured to obtain the image page horizontal coordinate according to the horizontal coordinate of the cluster center; The second determining module 512 is configured to determine, based on the image page horizontal coordinate, a segmentation line perpendicular to the horizontal coordinate axis where the image page horizontal coordinate is located; The paging module 514 is configured to perform paging processing on the image to be processed using the segmentation line to obtain a target image.

[0117] based on Figure 5 The present specification also provides some specific implementation schemes of the method, which are described below.

[0118] Optionally, the device may also be configured as: Correcting the image to be processed to obtain a corrected image to be processed; The step of using an optical character recognition algorithm to recognize the image to be processed to obtain position information of each character contained in the image to be processed specifically includes: The corrected image to be processed is recognized using the optical character recognition algorithm to obtain position information of each character contained in the corrected image to be processed.

[0119] Optionally, the image to be processed includes a paper image carrying multiple pages of content; the device may also be configured as follows: Converting the image to be processed into a grayscale image; Detecting the grayscale image using an edge detection function to obtain contour information of the paper image; Determine four corner point information of the paper image from the outline information; The paper image is mapped into a rectangle based on the four corner point information by using a perspective transformation function to obtain the corrected image to be processed.

[0120] Optionally, the position information of each character at least includes the vertical coordinate of each character; and the determining module may be specifically configured as follows: For any two characters among the characters, determining whether a first difference between the vertical coordinates of the any two characters is less than or equal to a first preset threshold; If the first difference is less than or equal to the first preset threshold, it is determined that the arbitrary two characters belong to the same row.

[0121] Optionally, the device may also be configured as: For any row of character sets among the plurality of row of character sets, determining whether the number of characters included in the any row of character sets is less than or equal to a preset number; If the number of characters included in the arbitrary row character set is less than or equal to the preset number, the arbitrary row character set is removed from the plurality of row character sets to obtain a modified plurality of row character sets; The clustering of the plurality of row character sets based on a clustering algorithm to obtain cluster centers specifically includes: The corrected sets of characters in multiple rows are clustered based on the clustering algorithm to obtain the cluster center.

[0122] Optionally, the device may also be configured as: Obtaining the width and height of the image to be processed; Determining an initial cluster center based on the width and height of the image to be processed; Calculate the mean of the horizontal coordinate information of each character in the arbitrary row of character set to obtain the row center horizontal coordinate corresponding to the arbitrary row of character set; The determining whether the number of characters included in the arbitrary line character set is less than or equal to a preset number specifically includes: It is determined whether a second difference between the horizontal coordinate of the row center and the horizontal coordinate of the initial cluster center is greater than or equal to a second preset threshold.

[0123] Optionally, the device may also be configured as: The second preset threshold is calculated according to the formula; represents the second preset threshold; represents the width of the character with the largest width in the said plurality of row character sets; represents the rounding function; represents the number of characters contained in the row character set with the largest number of characters in the said plurality of row character sets; represents the range coefficient, which is [0.1,0.3].

[0124] Optionally, the device may also be configured as: Obtaining page number information of the multiple pages of content; Determining the number of pages of content contained in the image to be processed according to the page number information; Determining the number of pages as a parameter value representing the number of cluster centers in the clustering algorithm; The clustering of the plurality of row character sets based on a clustering algorithm specifically includes: According to the parameter values, the plurality of row character sets are clustered based on the clustering algorithm.

[0125] Optionally, the cluster centers are two cluster centers; and the device may also be configured as: Determine whether a third difference between the horizontal coordinates of the two cluster centers is greater than or equal to a third preset threshold; If the third difference is greater than or equal to the third preset threshold, the average value of the horizontal coordinates of the two cluster centers is determined as the image paging horizontal coordinate.

[0126] Optionally, the device may also be configured as: If the third difference is less than the third preset threshold, a reference horizontal coordinate of the reference line is obtained; the reference horizontal coordinate of the reference line is the product of the width of the image to be processed and a reference coefficient; the value of the reference coefficient is [0.4, 0.6]; Determine whether the average value of the horizontal coordinates of the two cluster centers is less than or equal to the reference horizontal coordinate; If the average value of the horizontal coordinates of the two cluster centers is less than or equal to the reference horizontal coordinate, the horizontal coordinate corresponding to the character with the largest horizontal coordinate among the characters is determined as the image paging horizontal coordinate; If the average value of the horizontal coordinates of the two cluster centers is greater than the reference horizontal coordinate, the horizontal coordinate corresponding to the character with the smallest horizontal coordinate among the characters is determined as the image paging horizontal coordinate.

[0127] The above is a schematic scheme of a paging device of this embodiment. It should be noted that the technical scheme of the paging device and the technical scheme of the paging method described above are of the same concept, and the details not described in detail in the technical scheme of the paging device can be found in the description of the technical scheme of the paging method described above.

[0128] Figure 6 6 is a block diagram of a computing device provided in an embodiment of the present specification. The components of the computing device 600 include but are not limited to a memory 610 and a processor 620. The processor 620 is connected to the memory 610 via a bus 630, and the database 650 is used to store data.

[0129] The computing device 600 also includes an access device 640 that enables the computing device 600 to communicate via one or more networks 660. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 640 may include one or more of any type of network interface (e.g., a network interface card (NIC)) that is wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a world-wide interoperability for microwave access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, and a near field communication (NFC).

[0130] In one embodiment of the present specification, the above components of the computing device 600 and Figure 5 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 6The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.

[0131] The computing device 600 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or a personal computer (PC). The computing device 600 may also be a mobile or stationary server.

[0132] The processor 620 is used to execute the following computer executable instructions, which implement the steps of the above-mentioned paging method when executed by the processor.

[0133] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above-mentioned paging method belong to the same concept, and the details of the technical scheme of the computing device not described in detail can all be referred to the description of the technical scheme of the above-mentioned paging method.

[0134] An embodiment of the present specification further provides a computer-readable storage medium storing computer-executable instructions, which can implement the steps of the above-mentioned paging method when executed by a processor.

[0135] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the paging method described above are of the same concept, and the details not described in detail in the technical scheme of the storage medium can be found in the description of the technical scheme of the paging method described above.

[0136] An embodiment of the present specification further provides a computer program, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the above-mentioned paging method.

[0137] The above is a schematic solution of a computer program of this embodiment. It should be noted that the technical solution of the computer program and the technical solution of the paging method described above are of the same concept, and the details of the technical solution of the computer program not described in detail can be found in the description of the technical solution of the paging method described above.

[0138] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0139] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0140] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.

[0141] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0142] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is only limited by the claims and their full scope and equivalents.

Claims

1. A paging method, characterized in that: include: Get the image to be processed containing multiple pages of content; Recognize the image to be processed by using an optical character recognition algorithm to obtain position information of each character contained in the image to be processed; According to the position information of each character, characters belonging to the same row in the image to be processed are determined to obtain a plurality of row character sets; Clustering the plurality of row character sets based on a clustering algorithm to obtain cluster centers; According to the abscissa of the cluster center, the abscissa of the image page is obtained; Based on the image page horizontal coordinate, determining a segmentation line perpendicular to the horizontal coordinate axis where the image page horizontal coordinate is located; The image to be processed is processed by paging using the segmentation line to obtain a target image.

2. The method according to claim 1, characterized in that Before the optical character recognition algorithm is used to recognize the image to be processed, the method further includes: Correcting the image to be processed to obtain a corrected image to be processed; The step of using an optical character recognition algorithm to recognize the image to be processed to obtain position information of each character contained in the image to be processed specifically includes: The corrected image to be processed is recognized using the optical character recognition algorithm to obtain position information of each character contained in the corrected image to be processed.

3. The method according to claim 2, characterized in that The image to be processed includes a paper image carrying multiple pages of content; and the correcting the image to be processed to obtain a corrected image to be processed specifically includes: Converting the image to be processed into a grayscale image; Detecting the grayscale image using an edge detection function to obtain contour information of the paper image; Determine four corner point information of the paper image from the outline information; The paper image is mapped into a rectangle based on the four corner point information by using a perspective transformation function to obtain the corrected image to be processed.

4. The method according to claim 1, characterized in that: The position information of each character at least includes the ordinate of each character; and determining the characters belonging to the same row in the image to be processed according to the position information of each character specifically includes: For any two characters among the characters, determining whether a first difference between the vertical coordinates of the any two characters is less than or equal to a first preset threshold; If the first difference is less than or equal to the first preset threshold, it is determined that the arbitrary two characters belong to the same row.

5. The method according to claim 1, characterized in that Before clustering the plurality of row character sets based on a clustering algorithm, the method further includes: For any row of character sets among the plurality of row of character sets, determining whether the number of characters included in the any row of character sets is less than or equal to a preset number; If the number of characters included in the arbitrary row character set is less than or equal to the preset number, the arbitrary row character set is removed from the plurality of row character sets to obtain a modified plurality of row character sets; The clustering of the plurality of row character sets based on a clustering algorithm to obtain cluster centers specifically includes: The corrected sets of characters in multiple rows are clustered based on the clustering algorithm to obtain the cluster center.

6. The method according to claim 5, characterized in that The method further comprises: Obtaining the width and height of the image to be processed; Determining an initial cluster center based on the width and height of the image to be processed; Calculate the mean of the horizontal coordinate information of each character in the arbitrary row of character set to obtain the row center horizontal coordinate corresponding to the arbitrary row of character set; The determining whether the number of characters included in the arbitrary line character set is less than or equal to a preset number specifically includes: It is determined whether a second difference between the horizontal coordinate of the row center and the horizontal coordinate of the initial cluster center is greater than or equal to a second preset threshold.

7. The method according to claim 6, characterized in that The second preset threshold is determined as follows: According to the formula Calculating a second preset threshold; represents a second preset threshold; Indicates the width of the character with the largest width in the character set of the plurality of rows; represents the rounding function; Indicates the number of characters contained in the row character set with the largest number of characters among the plurality of row character sets; Represents the range coefficient, and its value is [0.1,0.3].

8. The method according to claim 1, characterized in that Before clustering the plurality of row character sets based on a clustering algorithm, the method further includes: Obtaining page number information of the multiple pages of content; Determining the number of pages of content contained in the image to be processed according to the page number information; Determining the number of pages as a parameter value representing the number of cluster centers in the clustering algorithm; The clustering of the plurality of row character sets based on a clustering algorithm specifically includes: According to the parameter values, the plurality of row character sets are clustered based on the clustering algorithm.

9. The method according to claim 1, characterized in that: The cluster centers are two cluster centers; and obtaining the image paging horizontal coordinates according to the horizontal coordinates of the cluster centers specifically includes: Determine whether a third difference between the horizontal coordinates of the two cluster centers is greater than or equal to a third preset threshold; If the third difference is greater than or equal to the third preset threshold, the average value of the horizontal coordinates of the two cluster centers is determined as the image paging horizontal coordinate.

10. The method according to claim 9, characterized in that The method further comprises: If the third difference is less than the third preset threshold, a reference horizontal coordinate of the reference line is obtained; the reference horizontal coordinate of the reference line is the product of the width of the image to be processed and a reference coefficient; the value of the reference coefficient is [0.4, 0.6]; Determine whether the average value of the horizontal coordinates of the two cluster centers is less than or equal to the reference horizontal coordinate; If the average value of the horizontal coordinates of the two cluster centers is less than or equal to the reference horizontal coordinate, the horizontal coordinate corresponding to the character with the largest horizontal coordinate among the characters is determined as the image paging horizontal coordinate; If the average value of the horizontal coordinates of the two cluster centers is greater than the reference horizontal coordinate, the horizontal coordinate corresponding to the character with the smallest horizontal coordinate among the characters is determined as the image paging horizontal coordinate.

11. A paging device, characterized in that: include: An acquisition module is configured to acquire an image to be processed containing multiple pages of content; A recognition module is configured to recognize the image to be processed by using an optical character recognition algorithm to obtain position information of each character contained in the image to be processed; A first determination module is configured to determine the characters belonging to the same row in the image to be processed according to the position information of each character, and obtain a plurality of row character sets; A clustering module is configured to cluster the plurality of row character sets based on a clustering algorithm to obtain a cluster center; An obtaining module is configured to obtain the image paging horizontal coordinate according to the horizontal coordinate of the cluster center; A second determination module is configured to determine, based on the image page horizontal coordinate, a segmentation line perpendicular to the horizontal coordinate axis where the image page horizontal coordinate is located; The paging module is configured to perform paging processing on the image to be processed by using the segmentation line to obtain a target image.

12. A computing device, characterized in that: include: Memory and processor; The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions. When the computer executable instructions are executed by the processor, the steps of the paging method according to any one of claims 1 to 10 are implemented.

13. A computer-readable storage medium, characterized in that: It stores computer executable instructions, which, when executed by a processor, implement the steps of the paging method described in any one of claims 1 to 10.

14. A computer program product, characterized in that The invention comprises a computer program / instruction, which implements the steps of the paging method according to any one of claims 1 to 10 when executed by a processor.