Test paper area identification method, device, equipment and storage medium

Through the segmentation model and rotated rectangle fitting technology, the problems of low efficiency of traditional manual marking and sensitivity to noise of image processing methods are solved, the accurate identification and correction of test paper areas is achieved, and the reliability of subsequent automated scoring and data analysis is improved.

CN118447046BActive Publication Date: 2024-10-18JIHUA LAB
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202410903182.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-08
Publication Date
2024-10-18
Estimated Expiration
2044-07-08

AI Technical Summary

Technical Problem

Traditional test paper processing relies on manual operations, which results in long-time grading, low efficiency, and manual scoring is prone to errors. Existing image processing methods do not handle noise, uneven lighting, blur, and complex backgrounds well, affecting the accurate identification of test paper areas.

Method used

Obtain the test paper image to be recognized, input it into the pre-built segmentation model to obtain the mask image, fit the minimum circumscribed rectangle and rotation matrix, perform rotation restoration, and use perspective transformation to restore the mask image to the original test paper image to ensure the rectangular outline accurate extraction.

Benefits of technology

It improves the accuracy of test paper area detection and identification, corrects extreme situations in network prediction, ensures accurate extraction of test paper content, and provides reliable data support for automated scoring and data analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118447046B_ABST
    Figure CN118447046B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of image recognition technology, and in particular to a method, device, equipment and storage medium for identifying a test paper area. The method comprises: inputting a test paper image to be identified into a segmentation model to obtain multiple test paper mask images, and selecting a preprocessed mask image from them; fitting the minimum circumscribed rectangle of the preprocessed mask image, and confirming the fitting corner point information; inputting the test paper image to be identified into a size recognition model to obtain the size information of the test paper image to be identified; confirming the rotation angle according to the fitting corner point information and the size information, and rotating and restoring the preprocessed mask image according to the rotation matrix and the rotation angle to obtain a restored mask image; judging whether the fitting contour of the restored mask image is a rectangle, and if so, restoring the restored mask image to the test paper image to be identified based on perspective transformation; the method disclosed in the present application can effectively identify extreme situations that may occur in network prediction, and restore the test paper area through rotation and distortion correction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image recognition technology, and in particular to a method, device, equipment and storage medium for recognizing a test paper area. Background Art

[0002] Traditional examination paper processing relies on manual operations. Although some educational institutions have begun to adopt automated grading systems, due to cost and implementation limitations, most schools still rely on traditional manual grading methods. The manual grading process includes reviewing examination papers, recording and calculating scores, etc., which results in long grading time and low grading efficiency. Furthermore, when grading manually, the probability of scoring errors is relatively high, and sometimes a second proofreading is required, further reducing the efficiency of examination paper processing.

[0003] In view of the above problems, it is particularly important to develop an effective test paper document detection and extraction system. The detection, extraction and correction of the test paper area is the prerequisite for subsequent downstream tasks such as test paper OCR recognition and scoring.

[0004] Traditional image processing methods such as edge detection and Hough transform are often used to assist in the recognition and correction of scanned test paper images; however, edge detection algorithms are highly sensitive to image quality, and image noise and poor scanning quality will significantly affect their performance; and although the Hough transform performs well in detecting regular graphics, it has a high computational cost when processing complex or deformed images, and has limited recognition effects on non-linear elements; in addition, existing detection methods do not handle uneven lighting, blurred images, or unclear document edges well, which can easily lead to boundary detection errors, and the accuracy of document extraction is greatly reduced in cases where the background is complex or the color is close to the document.

[0005] It can be seen that the existing technology still needs to be improved and enhanced. Summary of the invention

[0006] In order to overcome the shortcomings of the prior art, the purpose of the present invention is to provide a method, device, equipment and storage medium for identifying the test paper area, which can effectively correct the extreme situations that may occur in the network prediction, and restore the test paper area through rotation and distortion correction, so as to ensure that the test paper content can be accurately extracted, and provide data support for subsequent automated scoring and data analysis.

[0007] The first aspect of the present invention provides a method for identifying a test paper area, comprising: obtaining a test paper image to be identified, inputting the test paper image to be identified into a pre-constructed segmentation model to obtain multiple test paper mask images; selecting a pre-processed mask image from the multiple test paper mask images; fitting the minimum circumscribed rectangle of the pre-processed mask image, confirming four fitting corner points of the fitted minimum circumscribed rectangle and four fitting corner point coordinates corresponding to the four fitting corner points respectively; pre-constructing a size recognition model, inputting the test paper image to be identified into the pre-constructed size recognition model to obtain size information of the test paper image to be identified; obtaining a rotation matrix of the pre-processed mask image, confirming a rotation angle according to the four fitting corner point coordinates and the size information, and performing rotation restoration on the pre-processed mask image according to the rotation matrix and the rotation angle to obtain a restored mask image; fitting the contour of the restored mask image, and determining whether the fitted contour is a rectangle, if so, obtaining four restored corner point coordinates, and restoring the restored mask image to the test paper image to be identified based on perspective transformation according to the four restored corner point coordinates.

[0008] Optionally, in a first implementation of the first aspect of the present invention, the step of obtaining the test paper image to be identified, inputting the test paper image to be identified into a pre-built segmentation model, and obtaining a plurality of test paper mask images specifically includes: obtaining the test paper image to be identified fed back by a camera device, and selecting six search points from the test paper image to be identified based on a preset selection rule; combining the six search points to obtain three search point groups, and configuring attribute labels for the three search point groups respectively; inputting the three search point groups and the corresponding attribute labels into a segmentation model constructed based on an EdgeSAM network, respectively, to obtain a plurality of output images, each output image corresponding to a confidence score; and selecting four output images with different confidence scores as test paper mask images based on the edge information of the output images.

[0009] Optionally, in a second implementation of the first aspect of the present invention, the selecting a preprocessed mask image from multiple test paper mask images specifically includes: fitting the circumscribed rectangles of four test paper mask images respectively, and calculating the areas of the circumscribed rectangles respectively to obtain four area calculation results; sorting the four test paper mask images from small to large based on the confidence scores, and sorting the four mask images from small to large based on the area calculation results; if the test paper mask image with the highest confidence score matches the test paper mask image with the largest circumscribed rectangle area, then selecting the test paper mask image with the second lowest confidence score as the preprocessed mask image; otherwise, selecting the test paper mask image with the highest confidence score as the preprocessed mask image.

[0010] Optionally, in a third embodiment of the first aspect of the present invention, the minimum bounding rectangle of the preprocessed mask image is fitted, and the four fitting corner points of the fitted minimum bounding rectangle and the four fitting corner point coordinates corresponding to the four fitting corner points are confirmed, specifically including: fitting the minimum bounding rectangle of the preprocessed mask image, and respectively calculating the sum of the horizontal coordinates and the vertical coordinates of the four fitting corner points in the minimum bounding rectangle to obtain four first coordinate calculation results; the one with the smallest first coordinate calculation result is set as the upper left fitting corner point, and the one with the largest first coordinate calculation result is set as the lower right fitting corner point; among the remaining two fitting corner points, if the horizontal coordinate of any fitting corner point is greater than the horizontal coordinate of the upper left fitting corner point and the vertical coordinate is less than the vertical coordinate of the lower right fitting corner point, then the fitting corner point is set as the upper right fitting corner point, and the other fitting corner point is set as the lower left fitting corner point; extract the coordinates of the upper left fitting corner point, the lower right fitting corner point, the upper right fitting corner point and the lower left fitting corner point.

[0011] Optionally, in a fourth embodiment of the first aspect of the present invention, the pre-constructed size recognition model inputs the test paper image to be identified into the pre-constructed size recognition model to obtain size information of the test paper image to be identified, specifically including: acquiring historical test paper acquisition images, and performing data enhancement processing and division processing on the historical test paper acquisition images in sequence to obtain a training set and a test set; respectively inputting the training set and the test set into the AlexNet network model for training to obtain a size recognition model; inputting the test paper image to be identified into the size recognition model to obtain size information of the test paper image to be identified, wherein the size information includes A4 or A8.

[0012] Optionally, in a fifth implementation of the first aspect of the present invention, the rotation matrix of the pre-processed mask image is obtained, the rotation angle is confirmed according to the coordinates of the four fitting corner points and the size information, and the pre-processed mask image is rotated and restored according to the rotation matrix and the rotation angle to obtain the restored mask image, specifically including: when the size information of the test paper image to be identified is A4, if the horizontal coordinate of the upper left fitting corner point is greater than the horizontal coordinate of the lower left fitting corner point, the rotation angle is the angle return value of the minAreaRect function; if the horizontal coordinate of the upper left fitting corner point is less than the horizontal coordinate of the lower left fitting corner point, the rotation angle is The rotation angle is the angle return value of the minAreaRect function minus 90°; when the size information of the test paper image to be identified is A8, if the horizontal coordinate of the upper left fitting corner point is greater than the horizontal coordinate of the lower left fitting corner point, the rotation angle is the angle return value of the inAreaRect function minus 90°; if the horizontal coordinate of the upper left fitting corner point is less than the horizontal coordinate of the lower left fitting corner point, the rotation angle is the angle return value of the minAreaRect function; obtain the rotation matrix of the preprocessed mask image, rotate and restore the preprocessed mask image according to the rotation matrix and the rotation angle, and obtain the restored mask image.

[0013] Optionally, in a sixth implementation of the first aspect of the present invention, the contour of the mask image after fitting and restoration is determined, and if so, the coordinates of four restored corner points are obtained, and the restored mask image is restored to the test paper image to be identified based on the perspective transformation according to the four restored corner point coordinates, specifically including: fitting the contour of the mask image after restoration, and determining whether the fitted contour is a rectangle according to the number of vertices of the fitted contour; if so, respectively calculating the sum of the horizontal and vertical coordinates of the four restored corner points in the fitted contour to obtain four second coordinate calculation results; setting the one with the smallest second coordinate calculation result as the upper left restored corner point, and setting the second coordinate The one with the largest calculation result is the lower right restored corner point; among the remaining two restored corner points, if the horizontal coordinate of any restored corner point is greater than the horizontal coordinate of the upper left restored corner point and the vertical coordinate is less than the vertical coordinate of the lower right restored corner point, then the restored corner point is set as the upper right restored corner point, and the other restored corner point is set as the lower left restored corner point; extract the coordinates of the upper left restored corner point, the lower right restored corner point, the upper right restored corner point and the lower left restored corner point; obtain the distortion matrix based on the getPerspectiveTransform distortion function, and restore the restored mask image to the test paper image to be recognized based on the perspective transformation according to the distortion matrix, the coordinates of the four restored corner points and the coordinates of the four fitted corner points.

[0014] The second aspect of the present invention provides a device for identifying a test paper area, comprising: a segmentation module, used to obtain a test paper image to be identified, input the test paper image to be identified into a pre-built segmentation model, and obtain multiple test paper mask images; a selection module, used to select a pre-processed mask image from multiple test paper mask images; a fitting module, used to fit the minimum circumscribed rectangle of the pre-processed mask image, confirm four fitting corner points of the fitted minimum circumscribed rectangle and four fitting corner point coordinates corresponding to the four fitting corner points respectively; a size recognition module, used to pre-build a size recognition model, input the test paper image to be identified into a pre-built segmentation model, and obtain multiple test paper mask images; a selection module, used to select a pre-processed mask image from the ... pre-processed mask image; a fitting module, used to fit the minimum circumscribed rectangle of the pre-processed mask image, confirm four fitting corner points of the fitted minimum circumscribed rectangle and four fitting corner point coordinates corresponding to the four fitting corner points respectively; a selection module, used to select a pre-processed mask image from the pre-processed mask image; a selection module, used to select a into the pre-built size recognition model to obtain the size information of the test paper image to be recognized; a rotation module is used to obtain the rotation matrix of the pre-processed mask image, confirm the rotation angle according to the coordinates of the four fitting corner points and the size information, and rotate and restore the pre-processed mask image according to the rotation matrix and the rotation angle to obtain the restored mask image; a restoration module is used to fit the contour of the restored mask image and determine whether the fitted contour is a rectangle. If so, the coordinates of the four restored corner points are obtained, and the restored mask image is restored to the test paper image to be recognized based on the perspective transformation according to the coordinates of the four restored corner points.

[0015] The third aspect of the present invention provides a device for identifying an area of ​​an examination paper, the device comprising: a memory and at least one processor, the memory storing instructions; at least one of the processors calling the instructions in the memory so that the device for identifying an area of ​​an examination paper executes each step of the method for identifying an area of ​​an examination paper described in any one of the above items.

[0016] A fourth aspect of the present invention provides a computer-readable storage medium having instructions stored thereon, and when the instructions are executed by a processor, the various steps of any of the above-mentioned methods for identifying a test paper area are implemented.

[0017] In the technical solution of the present invention, multiple test paper mask images are obtained through a segmentation model, and a preprocessed mask image is selected from the test paper mask images, which can effectively correct extreme situations that may occur in network prediction and improve the accuracy of the test paper area detection and recognition process; further, by obtaining the coordinates of the four fitting corner points of the preprocessed mask image, test papers placed randomly in all directions can be restored through rotation and distortion correction, ensuring that the test paper area can be accurately extracted subsequently, providing data support for subsequent automated scoring and data analysis. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 A first flow chart of a method for identifying a test paper area provided by an embodiment of the present invention;

[0019] Figure 2 A second flow chart of the method for identifying a test paper area provided by an embodiment of the present invention;

[0020] Figure 3 A third flow chart of the method for identifying a test paper area provided by an embodiment of the present invention;

[0021] Figure 4 A fourth flow chart of the method for identifying a test paper area provided by an embodiment of the present invention;

[0022] Figure 5 A fifth flow chart of the method for identifying a test paper area provided by an embodiment of the present invention;

[0023] Figure 6 A sixth flow chart of the method for identifying a test paper area provided by an embodiment of the present invention;

[0024] Figure 7 A seventh flow chart of the method for identifying a test paper area provided by an embodiment of the present invention;

[0025] Figure 8 A schematic diagram of the structure of a device for identifying a test paper area provided by an embodiment of the present invention;

[0026] Fig. 9 A schematic diagram of the structure of a test paper area recognition device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0027] The present invention provides a method, device, equipment and storage medium for identifying an area of ​​a test paper. The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0028] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 , an embodiment of the method for identifying the test paper area in the embodiment of the present invention includes:

[0029] 101. Obtain a test paper image to be identified, input the test paper image to be identified into a pre-built segmentation model, and obtain a plurality of test paper mask images;

[0030] In this embodiment, the mask image may also be referred to as a mask image, which is a binary image in which pixels are marked as black (0) or white (1); these values ​​are used to represent the shapes, positions or attributes of different regions or objects in the image; in test paper processing, the mask image is mainly used to identify and extract specific information on the test paper, such as the correct or incorrect marks marked by the teacher; by applying the mask image, key information in the test paper, such as the marking results, specific question areas, etc., can be easily isolated and extracted.

[0031] 102. Selecting a preprocessed mask image from a plurality of test paper mask images;

[0032] In this embodiment, the preprocessed mask image is one, and the preprocessed mask image is the best one among multiple test paper mask images.

[0033] 103. Fitting a minimum circumscribed rectangle of the preprocessed mask image, and confirming four fitting corner points of the fitted minimum circumscribed rectangle and four fitting corner point coordinates respectively corresponding to the four fitting corner points;

[0034] In this embodiment, fitting the minimum bounding rectangle of the pre-processed mask image helps to more accurately locate the position and shape of the object, thus facilitating subsequent processing.

[0035] 104. Pre-constructing a size recognition model, inputting the test paper image to be recognized into the pre-constructed size recognition model, and obtaining size information of the test paper image to be recognized;

[0036] 105. Obtain a rotation matrix of the preprocessed mask image, confirm the rotation angle according to the coordinates of the four fitting corner points and the size information, and perform rotation restoration on the preprocessed mask image according to the rotation matrix and the rotation angle to obtain a restored mask image;

[0037] In this embodiment, the rotation of the test paper area in the pre-processed mask image can be confirmed based on the coordinates of the four fitting corner points and the size information, and the rotation angle can be confirmed based on the rotation.

[0038] 106. Fitting the contour of the restored mask image and determining whether the fitted contour is a rectangle. If so, obtaining the coordinates of four restored corner points, and restoring the restored mask image to the test paper image to be recognized based on the perspective transformation according to the coordinates of the four restored corner points;

[0039] In this embodiment, if the fitted contour is not a rectangle, step 101 to step 105 are executed again until the fitted contour is a rectangle.

[0040] The present application discloses a method for identifying test paper areas. A plurality of test paper mask images are obtained through a segmentation model, and a preprocessed mask image is selected from the test paper mask images, which can effectively correct extreme situations that may occur in network prediction and improve the accuracy of the test paper area detection and identification process; further, by obtaining the coordinates of the four fitting corner points of the preprocessed mask image, test papers placed randomly in all directions can be restored through rotation and distortion correction, ensuring that the test paper area can be accurately extracted subsequently, providing data support for subsequent automated scoring and data analysis.

[0041] See also Figure 2 , a second embodiment of the method for identifying a test paper area in an embodiment of the present invention includes:

[0042] 201. Obtain the image of the test paper to be identified fed back by the camera device, and select six search points from the image of the test paper to be identified based on a preset selection rule;

[0043] In this embodiment, since the length and width of the test paper image to be identified fed back by the camera device are fixed, taking into account that the test paper area is generally located in the central position of the image, and based on multiple adjustments in engineering experience, six search points are finally selected, and their positions are (width / / 2+170, height / / 2+100), (width / / 2-200, height / / 2-100), (width / / 2+170, height / / 2-100), (width / / 2-100, height / / 2+100), (width / / 2+200, height / / 2-100), (width / / 2-300, height / / 2+100), where width is the width of the test paper image to be identified, height is the length of the test paper image to be identified, and the unit is px, i.e., the number of pixels.

[0044] 202. Combine the six search points to obtain three search point groups, and configure attribute labels for the three search point groups respectively;

[0045] A search point group is a group of selected pixel points in image processing, which are used as reference points for initialization to guide subsequent image analysis or processing processes. In this embodiment, the first search point and the second search point are combined as the first search point group, the third search point and the fourth search point are combined as the second search point group, and the fifth search point and the sixth search point are combined as the third search point group. According to the positions of the three search point groups, attribute labels are configured for the three search point groups respectively, and the attribute labels can be 1 or 0, where 1 represents a foreground pixel and 0 represents a background pixel.

[0046] 203. Input the three search point groups and the corresponding attribute labels into the segmentation model constructed based on the EdgeSAM network respectively to obtain multiple output images, each of which corresponds to a confidence score;

[0047] In this embodiment, a segmentation model is constructed based on the EdgeSAM network. The EdgeSAM network model is a deep learning model, which may be used to segment or classify images to generate a specific type of output. Specifically, by receiving a search point group as input or reference information and generating multiple test paper mask images with different confidence scores based on these points, these mask images can be regarded as segmentations or identifications of different areas in the test paper image (such as text, graphics, blanks, etc.). Each mask image corresponds to a different confidence level, which helps to more comprehensively understand and analyze the structure and content of the test paper.

[0048] 204. Based on edge information of the output image, four output images with different confidence scores are selected as test paper mask images;

[0049] In this embodiment, the continuous mask objects are segmented according to the edge information in the output image, such as the regional consistency feature and the color texture feature, so as to obtain four output images with different confidence scores.

[0050] See also Figure 3 , a third embodiment of the method for identifying a test paper area in an embodiment of the present invention includes:

[0051] 301. Fit the circumscribed rectangles of the mask images of the four test papers respectively, and calculate the areas of the circumscribed rectangles respectively to obtain four area calculation results;

[0052] In this embodiment, the edge information of the test paper mask image can be obtained by an edge detection algorithm, and then the contour of the test paper mask image can be extracted by a contour search algorithm, and then the area of ​​the circumscribed rectangle can be calculated according to the searched contour.

[0053] 302. Sort the four test paper mask images from small to large based on the confidence scores, and sort the four mask images from small to large based on the area calculation results;

[0054] 303. If the test paper mask image with the highest confidence score matches the test paper mask image with the largest circumscribed rectangle area, the test paper mask image with the second lowest confidence score is selected as the preprocessing mask image; otherwise, the test paper mask image with the largest confidence score is selected as the preprocessing mask image;

[0055] In this embodiment, among the four test paper mask images and corresponding confidence scores output by the EdgeSAM network model, the ideal situation is that the test paper mask image with the highest confidence score presents the best effect and has the largest area. However, there may be a situation where the edge contour of the test paper mask image with the highest confidence score is not a rectangle. At this time, it is necessary to settle for the second best, that is, select the test paper mask image with the second largest confidence score as the preprocessing mask image.

[0056] See also Figure 4 The fourth embodiment of the method for identifying the test paper area in the embodiment of the present invention includes:

[0057] 401. Fitting a minimum bounding rectangle of the preprocessed mask image, and respectively calculating the sum of the abscissa and ordinate of four fitting corner points in the minimum bounding rectangle to obtain four first coordinate calculation results;

[0058] In this embodiment, edge information of the preprocessed mask image may be acquired by an edge detection algorithm, and then the contour of the preprocessed mask image may be extracted by a contour search algorithm, and then the area of ​​the minimum circumscribed rectangle may be calculated according to the searched contour.

[0059] 402. The one with the smallest first coordinate calculation result is set as the upper left fitting corner point, and the one with the largest first coordinate calculation result is set as the lower right fitting corner point;

[0060] 403. Among the remaining two fitting corner points, if the abscissa of any fitting corner point is greater than the abscissa of the upper left fitting corner point and the ordinate is less than the ordinate of the lower right fitting corner point, then the fitting corner point is set as the upper right fitting corner point and the other fitting corner point is set as the lower left fitting corner point;

[0061] 404. Extract the coordinates of the upper left fitting corner point, the lower right fitting corner point, the upper right fitting corner point, and the lower left fitting corner point;

[0062] In this embodiment, the coordinates corresponding to the four fitting corner points may be obtained through an image processing algorithm.

[0063] See also Figure 5 The fifth embodiment of the method for identifying the test paper area in the embodiment of the present invention includes:

[0064] 501. Obtain historical test paper collection images, and perform data enhancement processing and division processing on the historical test paper collection images in sequence to obtain a training set and a test set;

[0065] In this embodiment, data enhancement processing can be achieved by performing operations such as translation and flipping on the captured image of the history test paper. Regarding the translation operation, it involves moving the row elements a certain distance in a specified direction on the image plane. The translation operation can be used to adjust the position of the row elements to make them more consistent with the overall layout or correct the offset caused by the shooting angle; the flipping operation is to mirror the row elements along their vertical or horizontal axis, which helps to correct direction errors caused by the shooting angle or document placement, so that the direction of the row elements is consistent with expectations.

[0066] In this embodiment, the historical test paper collected images after data enhancement processing are divided according to a division ratio of 8:2.

[0067] 502. Input the training set and the test set into the AlexNet network model for training respectively to obtain a size recognition model;

[0068] 503. Input the test paper image to be identified into a size recognition model to obtain size information of the test paper image to be identified, wherein the size information includes A4 or A8.

[0069] See also Figure 6 The sixth embodiment of the method for identifying the test paper area in the embodiment of the present invention includes:

[0070] 601. When the size information of the test paper image to be recognized is A4, if the abscissa of the upper left fitting corner point is greater than the abscissa of the lower left fitting corner point, the rotation angle is the angle return value of the minAreaRect function; if the abscissa of the upper left fitting corner point is less than the abscissa of the lower left fitting corner point, the rotation angle is the angle return value of the minAreaRect function minus 90°;

[0071] In this embodiment, the minAreaRect function is generally used to calculate the minimum area rectangle surrounding a set of points. The function not only returns the vertex coordinates of the rectangle, but also returns the rotation angle (in degrees) of the rectangle. The meaning of the angle return value is: the rotation angle of the rectangle relative to the horizontal axis (or a reference axis). This angle is used to describe the direction or orientation of the rectangle on the image plane. If the rectangle is horizontal (that is, the long side is parallel to the horizontal axis), the angle may be 0 degrees or 180 degrees (depending on the definition and order of the rectangle vertices); if the rectangle is rotated relative to the horizontal axis, the angle value will be between 0 and 180 degrees.

[0072] 602. When the size information of the test paper image to be recognized is A8, if the abscissa of the upper left fitting corner point is greater than the abscissa of the lower left fitting corner point, the rotation angle is the angle return value of the minAreaRect function minus 90°; if the abscissa of the upper left fitting corner point is less than the abscissa of the lower left fitting corner point, the rotation angle is the angle return value of the minAreaRect function;

[0073] 603. Obtain a rotation matrix of the preprocessed mask image, and perform rotation restoration on the preprocessed mask image according to the rotation matrix and the rotation angle to obtain a restored mask image;

[0074] In this embodiment, the expression of the rotation matrix is:

[0075] ;

[0076] M is the rotation matrix, where , , θ is the rotation angle, and are the horizontal and vertical coordinates of the rotation center, respectively, which is (width / 2, height / 2)S here, S is the scaling factor, the default is 1; width is the width of the restored mask image, and height is the height of the restored mask image.

[0077] See also Figure 7 The seventh embodiment of the method for identifying the test paper area in the embodiment of the present invention includes:

[0078] 701. Fitting the contour of the restored mask image, and judging whether the fitted contour is a rectangle according to the number of vertices of the fitted contour;

[0079] In this embodiment, the outer contour point set is obtained through the cv2.findContours library function to realize the contour fitting of the restored mask image; since a rectangle has four vertices, it is first checked whether the fitted contour has four vertices, and then it can be checked whether these four vertices are close to a right angle, that is, whether their internal angles are close to 90 degrees. If so, it indicates that the fitted contour is a rectangle, that is, the number and shape of the vertices are used to check whether the fitted contour is a rectangle.

[0080] 702. If yes, then respectively calculate the sum of the horizontal coordinates and the vertical coordinates of the four restored corner points in the fitted contour to obtain four second coordinate calculation results;

[0081] 703. The one with the smallest second coordinate calculation result is set as the upper left restoration corner point, and the one with the largest second coordinate calculation result is set as the lower right restoration corner point;

[0082] 704. Among the remaining two restored corner points, if the abscissa of any restored corner point is greater than the abscissa of the upper left restored corner point and the ordinate is less than the ordinate of the lower right restored corner point, then the restored corner point is set as the upper right restored corner point and the other restored corner point is set as the lower left restored corner point;

[0083] 705. Extract the coordinates of the upper left restoration corner point, the lower right restoration corner point, the upper right restoration corner point, and the lower left restoration corner point;

[0084] In this embodiment, the coordinates corresponding to the four restored corner points can be obtained through an image processing algorithm.

[0085] 706. Obtain the distortion matrix based on the getPerspectiveTransform distortion function, and restore the restored mask image to the test paper image to be recognized based on the perspective transformation according to the distortion matrix, the four restored corner point coordinates and the four fitted corner point coordinates;

[0086] In this embodiment, perspective transformation is applied to restore the restored mask image to the test paper image to be identified; perspective transformation is a technology that can correct the deformation of the image caused by perspective projection. It can convert the image from one perspective to another, and is usually used to correct the tilt, distortion or perspective deformation in the image.

[0087] In this embodiment, the perspective transformation matrix can be calculated by the following formula:

[0088] ;

[0089] in, , , i=0, 1, 2, 3, src is the vertex coordinates of the circumscribed rectangle in the preprocessed mask image, dst is the vertex coordinates of the circumscribed rectangle in the restored mask image, ti is a scaling factor used to ensure the homogeneous coordinate form of the result; therefore, according to the distortion matrix, the four restored corner point coordinates and the four fitted corner point coordinates, the restored mask image can be restored to the test paper image to be recognized.

[0090] The above describes the method for identifying the test paper area in the embodiment of the present invention. The following describes the device for identifying the test paper area in the embodiment of the present invention. Figure 8 , an embodiment of the device for identifying the test paper area in the embodiment of the present invention includes:

[0091] The segmentation module 801 is used to obtain the test paper image to be identified, input the test paper image to be identified into a pre-built segmentation model, and obtain multiple test paper mask images;

[0092] A selection module 802 is used to select a pre-processed mask image from a plurality of test paper mask images;

[0093] A fitting module 803 is used to fit the minimum bounding rectangle of the preprocessed mask image, and to confirm four fitting corner points of the fitted minimum bounding rectangle and four fitting corner point coordinates respectively corresponding to the four fitting corner points;

[0094] The size recognition module 804 is used to pre-build a size recognition model, input the test paper image to be recognized into the pre-built size recognition model, and obtain the size information of the test paper image to be recognized;

[0095] The rotation module 805 is used to obtain the rotation matrix of the pre-processed mask image, confirm the rotation angle according to the coordinates of the four fitting corner points and the size information, and perform rotation restoration on the pre-processed mask image according to the rotation matrix and the rotation angle to obtain a restored mask image;

[0096] The restoration module 806 is used to fit the contour of the restored mask image and determine whether the fitted contour is a rectangle. If so, the coordinates of four restored corner points are obtained, and the restored mask image is restored to the test paper image to be identified based on the perspective transformation according to the coordinates of the four restored corner points.

[0097] above Figure 8 The apparatus for identifying the test paper area in the embodiment of the present invention is described in detail from the perspective of modular functional entities, and the apparatus for identifying the test paper area in the embodiment of the present invention is described in detail from the perspective of hardware processing.

[0098] Fig. 9It is a schematic diagram of the structure of a test paper area recognition device provided by an embodiment of the present invention. The test paper area recognition device 900 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 910 (for example, one or more processors) and a memory 920, and one or more storage media 930 (for example, one or more mass storage devices) storing application programs 933 or data 932. Among them, the memory 920 and the storage medium 930 can be short-term storage or permanent storage. The program stored in the storage medium 930 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the test paper area recognition device 900. Furthermore, the processor 910 can be configured to communicate with the storage medium 930, and execute a series of instruction operations in the storage medium 930 on the test paper area recognition device 900 to implement the steps of the test paper area recognition method provided in the above-mentioned method embodiments.

[0099] The identification device 900 for the test paper area may also include one or more power supplies 940, one or more wired or wireless network interfaces 950, one or more input and output interfaces 960, and / or one or more operating systems 931, such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art will appreciate that the identification device structure for the test paper area shown in the present application does not constitute a limitation on the identification device based on the test paper area, and may include more or less components than shown in the figure, or combine certain components, or arrange components differently.

[0100] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions are executed on a computer, the computer executes the steps of the method for identifying the test paper area.

[0101] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described system, device, or unit can refer to the corresponding process in the aforementioned method embodiment and will not be repeated here.

[0102] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the whole or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.

[0103] Finally, it should be noted that the above description is only a preferred example of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for identifying a test paper area, characterized in that: include: Obtaining a test paper image to be identified, inputting the test paper image to be identified into a pre-built segmentation model to obtain a plurality of test paper mask images; Specifically, the image of the test paper to be identified fed back by the camera device is obtained, and six search points are selected from the image of the test paper to be identified based on a preset selection rule; Combining the six search points to obtain three search point groups, and configuring attribute labels for the three search point groups respectively; The three search point groups and their corresponding attribute labels are respectively input into the segmentation model built based on the EdgeSAM network to obtain multiple output images, each of which corresponds to a confidence score; Based on the edge information of the output image, four output images with different confidence scores are selected as test paper mask images; Selecting a preprocessed mask image from a plurality of test paper mask images; Specifically, the circumscribed rectangles of the mask images of the four test papers are fitted respectively, and the areas of the circumscribed rectangles are calculated respectively to obtain four area calculation results; Sort the four test paper mask images from small to large based on the confidence scores, and sort the four mask images from small to large based on the area calculation results; If the test paper mask image with the highest confidence score matches the test paper mask image with the largest circumscribed rectangle area, the test paper mask image with the second lowest confidence score is selected as the preprocessing mask image; otherwise, the test paper mask image with the largest confidence score is selected as the preprocessing mask image; Fitting a minimum bounding rectangle of the preprocessed mask image, and confirming four fitting corner points of the fitted minimum bounding rectangle and four fitting corner point coordinates respectively corresponding to the four fitting corner points; Pre-constructing a size recognition model, inputting the test paper image to be recognized into the pre-constructed size recognition model, and obtaining size information of the test paper image to be recognized; Obtaining the rotation matrix of the pre-processed mask image, confirming the rotation angle according to the coordinates of the four fitting corner points and the size information, and performing rotation restoration on the pre-processed mask image according to the rotation matrix and the rotation angle to obtain a restored mask image; Fit the contour of the restored mask image and determine whether the fitted contour is a rectangle. If so, obtain the coordinates of four restored corner points. According to the coordinates of the four restored corner points, restore the restored mask image to the test paper image to be identified based on perspective transformation.

2. A method for identifying a test paper area according to claim 1, characterized in that: The step of fitting the minimum bounding rectangle of the preprocessed mask image and confirming four fitting corner points of the fitted minimum bounding rectangle and four fitting corner point coordinates respectively corresponding to the four fitting corner points specifically includes: Fitting the minimum bounding rectangle of the preprocessed mask image, and respectively calculating the sum of the abscissa and ordinate of the four fitting corner points in the minimum bounding rectangle, to obtain four first coordinate calculation results; The one with the smallest first coordinate calculation result is set as the upper left fitting corner point, and the one with the largest first coordinate calculation result is set as the lower right fitting corner point; Of the remaining two fitting corner points, if the abscissa of any fitting corner point is greater than the abscissa of the upper left fitting corner point and the ordinate is less than the ordinate of the lower right fitting corner point, then the fitting corner point is set as the upper right fitting corner point and the other fitting corner point is set as the lower left fitting corner point. Extract the coordinates of the upper left fitting corner, lower right fitting corner, upper right fitting corner, and lower left fitting corner.

3. A method for identifying a test paper area according to claim 2, characterized in that: The pre-built size recognition model inputs the test paper image to be recognized into the pre-built size recognition model to obtain the size information of the test paper image to be recognized, specifically including: Acquire historical test paper collection images, perform data enhancement processing and division processing on the historical test paper collection images in sequence, and obtain a training set and a test set; The training set and the test set are respectively input into the AlexNet network model for training to obtain a size recognition model; The test paper image to be identified is input into the size recognition model to obtain the size information of the test paper image to be identified, and the size information includes A4 or A8.

4. A method for identifying a test paper area according to claim 3, characterized in that: The method of obtaining a rotation matrix of the pre-processed mask image, confirming the rotation angle according to the coordinates of the four fitting corner points and the size information, and performing rotation restoration on the pre-processed mask image according to the rotation matrix and the rotation angle to obtain the restored mask image specifically includes: When the size information of the test paper image to be recognized is A4, if the horizontal coordinate of the upper left fitting corner point is greater than that of the lower left fitting corner point, the rotation angle is the angle return value of the minAreaRect function; if the horizontal coordinate of the upper left fitting corner point is less than that of the lower left fitting corner point, the rotation angle is the angle return value of the minAreaRect function minus 90°; When the size information of the test paper image to be recognized is A8, if the horizontal coordinate of the upper left fitting corner point is greater than the horizontal coordinate of the lower left fitting corner point, the rotation angle is the angle return value of the minAreaRect function minus 90°; if the horizontal coordinate of the upper left fitting corner point is less than the horizontal coordinate of the lower left fitting corner point, the rotation angle is the angle return value of the minAreaRect function; The rotation matrix of the preprocessed mask image is obtained, and the preprocessed mask image is rotated and restored according to the rotation matrix and the rotation angle to obtain a restored mask image.

5. A method for identifying a test paper area according to claim 1, characterized in that: The contour of the mask image after fitting and restoration is determined to be a rectangle. If so, the coordinates of four restored corner points are obtained. According to the coordinates of the four restored corner points, the restored mask image is restored to the test paper image to be identified based on perspective transformation, which specifically includes: Fitting the contour of the restored mask image, and judging whether the fitted contour is a rectangle according to the number of vertices of the fitted contour; If so, the sum of the horizontal coordinates and the vertical coordinates of the four restored corner points in the fitted contour are calculated respectively to obtain four second coordinate calculation results; The one with the smallest second coordinate calculation result is set as the upper left restoration corner point, and the one with the largest second coordinate calculation result is set as the lower right restoration corner point; Among the remaining two restored corner points, if the horizontal coordinate of any restored corner point is greater than the horizontal coordinate of the upper left restored corner point and the vertical coordinate is less than the vertical coordinate of the lower right restored corner point, then the restored corner point is set as the upper right restored corner point and the other restored corner point is set as the lower left restored corner point; Extract the coordinates of the upper left restored corner point, the lower right restored corner point, the upper right restored corner point, and the lower left restored corner point; The distortion matrix is ​​obtained based on the getPerspectiveTransform distortion function. According to the distortion matrix, the coordinates of the four restored corner points and the coordinates of the four fitted corner points, the restored mask image is restored to the test paper image to be recognized based on the perspective transformation.

6. A device for identifying a test paper area, characterized in that: The identification device is used to implement each step of the method for identifying the test paper area according to any one of claims 1 to 5, and the identification device includes: A segmentation module is used to obtain the test paper image to be identified, input the test paper image to be identified into a pre-built segmentation model, and obtain multiple test paper mask images; A selection module, used for selecting a pre-processed mask image from a plurality of test paper mask images; A fitting module, used for fitting the minimum bounding rectangle of the preprocessed mask image, and confirming four fitting corner points of the fitted minimum bounding rectangle and four fitting corner point coordinates respectively corresponding to the four fitting corner points; A size recognition module is used to pre-build a size recognition model, input the test paper image to be recognized into the pre-built size recognition model, and obtain the size information of the test paper image to be recognized; A rotation module is used to obtain a rotation matrix of the pre-processed mask image, confirm the rotation angle according to the coordinates of the four fitting corner points and the size information, and perform rotation restoration on the pre-processed mask image according to the rotation matrix and the rotation angle to obtain a restored mask image; The restoration module is used to fit the contour of the restored mask image and determine whether the fitted contour is a rectangle. If so, the coordinates of four restored corner points are obtained. According to the coordinates of the four restored corner points, the restored mask image is restored to the test paper image to be identified based on perspective transformation.

7. A device for identifying a test paper area, characterized in that: The test paper area recognition device comprises: a memory and at least one processor, wherein the memory stores instructions; At least one of the processors calls the instructions in the memory to enable the test paper area identification device to perform each step of the test paper area identification method as described in any one of claims 1-5.

8. A computer-readable storage medium having instructions stored thereon, characterized in that: When the instructions are executed by the processor, the various steps of the method for identifying the test paper area as described in any one of claims 1-5 are implemented.

Citation Information

Patent Citations

  • A method and a device for automatic statistical analysis of test paper scores based on M-CNN

    CN109389173A

  • Chinese test paper layout analysis method and system

    CN111860444A

  • Table recognition restoration method based on deep learning and image processing

    CN112364834A

  • Test paper correction method and device, storage medium and electronic equipment

    CN113112511A

  • Plane scanning image-oriented user customization intention understanding method and system

    CN117746018A