Answer sheet recognition method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202211430183.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-15
- Publication Date
- 2026-09-11
- Estimated Expiration
- 2042-11-15
AI Technical Summary
[0005]本发明提供一种答题卡识别方法、装置、电子设备和存储介质,用以解决现有技术中同步头定位方法对于定位元素的要求较高,以及抗干扰能力较差的缺陷,降低了对于定位元素的要求,增强了定位过程的抗干扰能力,实现了定位准确度和识别精确度的提升
Smart Images

Figure CN115908846B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a method, apparatus, electronic device, and storage medium for recognizing answer sheets. Background Technology
[0002] With the development of technology, most large-scale examinations now adopt online marking to improve marking efficiency. Online marking systems can use scanning and image processing technologies to read the objective question information filled in on the answer sheet, thereby enabling online marking of the objective questions on the answer sheet.
[0003] Before online marking can be conducted, the answer sheet needs to be located and the filled-in information points on the answer sheet need to be identified. Currently, answer sheet location mostly relies on synchronization header location technology, which uses multiple predefined horizontal and vertical synchronization headers, as well as the indexes of the filled-in information points corresponding to the horizontal and vertical synchronization headers, to locate the answer sheet and identify the filled-in information points.
[0004] However, the above positioning method requires the identification of all horizontal and vertical synchronization heads, and all filling information must be located in the intersection area of the horizontal and vertical synchronization heads. In other words, it has high requirements for positioning elements and poor anti-interference ability. Summary of the Invention
[0005] This invention provides a method, apparatus, electronic device, and storage medium for answer sheet recognition, which addresses the shortcomings of existing synchronous head positioning methods, such as high requirements for positioning elements and poor anti-interference capabilities. It reduces the requirements for positioning elements, enhances the anti-interference capability of the positioning process, and improves positioning accuracy and recognition precision.
[0006] This invention provides a method for recognizing answer sheets, comprising:
[0007] Determine the template image and scanned image of the answer sheet to be identified, wherein the template image includes a positioning box;
[0008] Contour detection is performed on the scanned image to obtain multiple contour patterns. Each contour pattern is matched with the positioning box, and based on the successfully matched contour patterns and the positioning boxes, the transformation matrix between the scanned image and the template image is determined.
[0009] Based on the transformation matrix, the scanned image is transformed to obtain a scanned positioning image, and the answer sheet is recognized based on the scanned positioning image.
[0010] According to the answer sheet recognition method provided by the present invention, determining the transformation matrix between the scanned image and the template image based on the successfully matched contour graphic and the positioning box includes:
[0011] Based on the corner coordinates of the successfully matched contour graphic and the corner coordinates of the positioning box, the transformation matrix between the scanned image and the template image is determined.
[0012] According to the answer sheet recognition method provided by the present invention, the matching of each contour graphic with the positioning box includes:
[0013] Based on the area of each contour graphic and the area of the positioning frame, determine the area difference between each contour graphic and the positioning frame;
[0014] Based on the coordinates of the center point of each contour graphic and the coordinate range of the positioning box, the positional relationship between the center point of each contour graphic and the positioning box is determined.
[0015] If the area difference between any contour graphic and the positioning frame is less than or equal to the area threshold, and the positional relationship indicates that the center point of any contour graphic is within the coordinate range of the positioning frame, then the contour graphic is determined to be successfully matched with the positioning frame.
[0016] According to an answer sheet recognition method provided by the present invention, the method further includes determining the positional relationship between the center point of each contour graphic and the positioning frame based on the coordinates of the center point of each contour graphic and the coordinate range of the positioning frame, and then further includes:
[0017] If the area difference between any contour graphic and the positioning frame is greater than an area threshold, and / or the positional relationship indicates that the center point of any contour graphic is outside the coordinate range of the positioning frame, then it is determined that any contour graphic fails to match the positioning frame.
[0018] If the contour pattern fails to match the positioning box, the binarization threshold is updated, and based on the updated binarization threshold, contour detection is performed on the scanned image to obtain multiple new contour patterns. Each new contour pattern is matched with the positioning box until a match is successful or the number of matching rounds reaches the upper limit.
[0019] According to the answer sheet recognition method provided by the present invention, the template image further includes positioning detection points;
[0020] The step of recognizing the answer sheet based on the scanned positioning image further includes:
[0021] Based on the coordinates of the positioning detection points, the positioning detection coordinate range in the scanned positioning image and the average gray value of the positioning detection coordinate range are determined.
[0022] Based on the average gray value and the gray value threshold, the positioning accuracy and recognition precision are determined, and based on the positioning accuracy and the recognition precision, the transformation matrix and the filled content obtained from the answer sheet recognition are adjusted respectively.
[0023] According to the answer sheet recognition method provided by the present invention, the scanned image is subjected to contour detection based on an updated binarization threshold to obtain multiple new contour patterns, including:
[0024] The scanned image is processed to obtain a grayscale image;
[0025] Based on the updated binarization threshold, the scanned grayscale image is binarized, and contour detection is performed on the binarized scanned grayscale image to obtain multiple new contour patterns.
[0026] According to the answer sheet recognition method provided by the present invention, the method further includes matching each new contour graphic with the positioning box, and then:
[0027] If the number of matching rounds reaches the upper limit of the number of rounds, update the positioning frame;
[0028] Match each new outline graphic with the updated positioning box;
[0029] If the new contour graphics fail to match the updated positioning boxes, the scanned image is determined to be faulty.
[0030] The present invention also provides an answer sheet recognition device, comprising:
[0031] An image determination unit is used to determine a template image and a scanned image of the answer sheet to be identified, wherein the template image includes a positioning box;
[0032] The positioning box matching unit is used to perform contour detection on the scanned image to obtain multiple contour patterns, match each contour pattern with the positioning box, and determine the transformation matrix between the scanned image and the template image based on the successfully matched contour patterns and the positioning boxes.
[0033] The positioning and recognition unit is used to perform coordinate system transformation on the scanned image based on the transformation matrix to obtain a scanned positioning image, and to perform answer sheet recognition based on the scanned positioning image.
[0034] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the answer sheet recognition method as described above.
[0035] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the answer sheet recognition method as described above.
[0036] The answer sheet recognition method, device, electronic device, and storage medium provided by this invention match multiple contour graphics of a scanned image obtained from contour detection with positioning boxes in a template image. Based on the successfully matched contour graphics and positioning boxes, a transformation matrix between the scanned image and the template image is determined. Coordinate system transformation is performed based on this transformation matrix, and answer sheet recognition is performed based on the transformed scanned positioning image. The coordinate system transformation completes the coordinate space transformation from the scanned image to the template image, realizing answer sheet positioning. This overcomes the shortcomings of traditional positioning methods, such as high requirements for positioning elements and poor anti-interference ability. It reduces the requirements for positioning elements, enhances the anti-interference ability of the positioning process, and improves positioning accuracy and recognition precision. Attached Figure Description
[0037] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0038] Figure 1 This is a flowchart illustrating the answer sheet recognition method provided by the present invention;
[0039] Figure 2 This is one of the flowcharts illustrating the positioning frame matching process provided by the present invention;
[0040] Figure 3 This is the second flowchart illustrating the positioning frame matching process provided by the present invention;
[0041] Figure 4 This is a flowchart illustrating the positioning and detection process provided by the present invention;
[0042] Figure 5 This is a schematic flowchart of the contour detection process provided by the present invention;
[0043] Figure 6 This is the third flowchart illustrating the positioning frame matching process provided by the present invention;
[0044] Figure 7 This is a schematic diagram of the structure of the answer sheet recognition device provided by the present invention;
[0045] Figure 8 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0046] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0047] Most current answer sheet positioning methods use synchronization header positioning technology, which defines a series of squares in the answer sheet template. The squares distributed horizontally are called horizontal synchronization headers, and the squares distributed vertically are called vertical synchronization headers. The information points to be filled are all located in the overlapping area of the horizontal synchronization headers and the vertical synchronization headers. In addition, it is also necessary to define the index of each information point in the horizontal direction (horizontal synchronization header) and the vertical direction (vertical synchronization header).
[0048] During the scanning process, all positioning elements (horizontal synchronization head and vertical synchronization head) must first be identified. Then, based on the predefined indexes of each filling information point corresponding to the horizontal and vertical synchronization heads, the corresponding horizontal and vertical synchronization heads, as well as the overlapping coordinate range of the horizontal and vertical synchronization heads, are searched to identify the filling information points.
[0049] However, in practical applications, the number of synchronization heads on the answer sheet is often large, and the synchronization head positioning method needs to identify all positioning elements and requires that each filling information point be located within the overlapping area of the horizontal and vertical synchronization heads. If it exceeds the overlapping area, the identification will fail. In other words, this method has high requirements for positioning elements and its anti-interference ability is poor.
[0050] To address this issue, the present invention provides an answer sheet recognition method. This method aims to match the contour graphic of a scanned image with the positioning box in a template image. Using the successfully matched contour graphic and positioning box, a transformation matrix between the scanned image and the template image is determined. Based on this transformation matrix, the answer sheet is located, completing the coordinate space transformation from the scanned image to the template image. This achieves coordinate system unification and overcomes the shortcomings of traditional positioning methods, such as high requirements for positioning elements and poor anti-interference capabilities. The method reduces the requirements for positioning elements, enhances the anti-interference capability of the positioning process, and improves positioning accuracy and recognition precision.
[0051] Figure 1 This is a flowchart illustrating the answer sheet recognition method of the present invention, as shown below. Figure 1 As shown, this method, applied to an online marking system, enables precise answer sheet positioning and accurate identification of marked information points, thus contributing to improved marking efficiency and accuracy. The method includes:
[0052] Step 110: Determine the template image and scanned image of the answer sheet to be recognized. The template image includes a positioning box.
[0053] Specifically, before recognizing the answer sheet, it is first necessary to determine the answer sheet to be recognized, as well as its corresponding template image and scanned image. The template image here is the image of the predefined answer sheet template, which can be obtained by taking a picture with a camera, by scanning, or by downloading from the network. This embodiment of the invention does not make specific limitations on this.
[0054] The answer sheet template includes a positioning frame and filling information points. The filling information points can be understood as filling in options, which can be filling in options for objective questions or filling in options to indicate whether the candidate is absent. The positioning frame is a black border set around the filling options, usually rectangular. There can be one or more, and the specific number can be determined with reference to the number of filling information points, for example, it can be 1, 2, 3, etc.
[0055] Since the template image corresponds to the answer sheet template, it also contains positioning boxes and filling information points. The answer sheet to be identified is the paper manuscript formed by printing the answer sheet template and filling in the answers by the student; the scanned image is the answer sheet image obtained by scanning the answer sheet to be identified using a scanning device.
[0056] In this embodiment of the invention, the positioning frame can be used as a positioning element for answer sheet positioning and correction. Compared with the traditional solution, this greatly reduces the number of positioning elements and lowers the requirements for positioning elements, thus achieving a dual improvement in answer sheet positioning accuracy and positioning efficiency.
[0057] Step 120: Perform contour detection on the scanned image to obtain multiple contour patterns, match each contour pattern with the bounding box, and determine the transformation matrix between the scanned image and the template image based on the successfully matched contour patterns and bounding boxes.
[0058] Specifically, in step 110, after obtaining the template image and scanned image of the answer sheet to be recognized, step 120 can be executed. Based on the matching between the outline of the scanned image and the positioning box in the template image, the correspondence between the two types of images of the answer sheet to be recognized is determined. This process may specifically include the following steps:
[0059] First, contour detection can be performed on the scanned image of the answer sheet to be recognized to detect the contour of the scanned image, thereby obtaining multiple contour graphics of the scanned image. The contour detection process here can be implemented with the help of conventional contour detection models and contour detection algorithms.
[0060] It is worth noting that, considering that the positioning frame is set outside the answer sheet where the options are filled in, it is the outer border. Therefore, in order to improve the efficiency of contour detection and speed up the matching process, in this embodiment of the invention, when performing contour detection on the scanned image, it is possible to select to perform first-level contour detection, that is, only detect the outer contour of the scanned image, so as to obtain multiple contour graphics.
[0061] Here, using a table as an example, the process of first-level contour detection is briefly explained:
[0062] Tables typically contain outer and inner borders. Performing a first-level outline detection on a table means only detecting the outermost borders of the table. In other words, only the table's border lines are detected, while the inner borders are ignored.
[0063] Subsequently, the contour graphics of the scanned image obtained by contour detection can be matched with the positioning boxes in the template image. Specifically, based on the information of each contour graphic and the information of the positioning box, each contour graphic is matched with the positioning box respectively. That is, the correspondence between the two is determined by using the area, coordinates, range, etc. of each contour graphic and the positioning box, i.e. whether each contour graphic of the scanned image corresponds to the positioning box in the template image.
[0064] Furthermore, if, based on the information from the contour graphics and the positioning boxes, it is determined that any contour graphic in the scanned image corresponds to a positioning box in the template image, then the match can be considered successful. Conversely, if any contour graphic does not correspond to a positioning box, then the match can be considered unsuccessful.
[0065] Subsequently, based on the successfully matched contour graphic and the positioning box, the transformation matrix between the scanned image and the template image can be determined. That is, the correspondence between the scanned image and the template image can be determined based on the information of the successfully matched contour graphic and the information of the positioning box. Specifically, the transformation matrix between the scanned image and the template image can be determined using the coordinates of the successfully matched contour graphic and the coordinates of the positioning box. This transformation matrix represents the correspondence between the coordinates of the two, and the answer sheet can be located based on this correspondence.
[0066] Step 130: Based on the transformation matrix, perform coordinate system transformation on the scanned image to obtain the scanned positioning image, and perform answer sheet recognition based on the scanned positioning image.
[0067] Specifically, after obtaining the transformation matrix between the scanned image and the template image in step 120, step 130 can be executed to locate the answer sheet using this transformation matrix, thereby obtaining the scanned positioning image and performing answer sheet recognition. The specific process includes:
[0068] First, based on the transformation matrix between the scanned image and the template image, the coordinate system of the scanned image can be transformed into the coordinate system of the template image, thereby unifying the coordinate systems of the two types of images and completing the coordinate space transformation from the scanned image to the template image. This enables the positioning of the answer sheet in the scanned image and yields the scanned positioning image.
[0069] Then, the answer sheet can be recognized in the scanned positioning image to identify the fill-in information points in the scanned positioning image, thereby obtaining the fill-in content in the scanned positioning image. Specifically, this process can be carried out by recognizing the information points in the scanned positioning image based on the coordinates of the fill-in information points in the template image, thereby obtaining the fill-in content. That is, the fill-in information point images can be determined from the scanned positioning image by referring to the coordinates of the fill-in information points, and then the information points of each fill-in information point image can be recognized to obtain the fill-in content in the scanned positioning image.
[0070] In this embodiment of the invention, the transformation matrix between the scanned image and the template image is used to locate the answer sheet. This not only corrects the scanned image and corrects its variations (stretching, rotation, translation, distortion, etc.) during the scanning process, ensuring positioning accuracy, but also provides crucial assistance for the accurate identification of subsequent filling information points.
[0071] The answer sheet recognition method provided by this invention matches multiple contour graphics of the scanned image obtained by contour detection with the positioning boxes in the template image. Based on the successfully matched contour graphics and positioning boxes, a transformation matrix between the scanned image and the template image is determined. Coordinate system transformation is performed based on this transformation matrix, and answer sheet recognition is performed based on the transformed scanned positioning image. The coordinate system transformation completes the coordinate space transformation from the scanned image to the template image, realizing answer sheet positioning. This overcomes the shortcomings of traditional positioning methods, such as high requirements for positioning elements and poor anti-interference ability. It reduces the requirements for positioning elements, enhances the anti-interference ability of the positioning process, and improves the positioning accuracy and recognition precision.
[0072] Based on the above embodiments, in step 120, determining the transformation matrix between the scanned image and the template image based on the successfully matched contour graphic and positioning box includes:
[0073] Based on the corner coordinates of the successfully matched contour graphic and the corner coordinates of the positioning box, the transformation matrix between the scanned image and the template image is determined.
[0074] Specifically, step 120, which involves determining the transformation matrix between the scanned image and the template image based on the successfully matched contour graphic and the positioning box, includes the following steps:
[0075] First, it is necessary to determine the four corner points and their coordinates of the successfully matched contour graphic, as well as the four corner points and their coordinates of the positioning box. The corner points here are the points where the information changes drastically in the corresponding contour graphic or positioning box, i.e., extreme points. In this embodiment of the invention, the four corner points are distributed in the upper left, lower left, upper right and lower right positions of the corresponding contour graphic or positioning box.
[0076] Subsequently, the corner coordinates of the corresponding contour graphic and the corner coordinates of the positioning box can be used to establish the correspondence between the scanned image and the template image. This correspondence can be represented by a transformation matrix, that is, the transformation matrix between the scanned image and the template image can be determined by the coordinates of the four corner points in the corresponding contour graphic and the four corner points in the positioning box.
[0077] Specifically, in this embodiment of the invention, the transformation matrix between the two types of images can be a perspective transformation matrix. That is, based on the perspective transformation matrix, the scanned image can be transformed by perspective to achieve anomaly correction of the scanned image and answer sheet positioning.
[0078] In this embodiment of the invention, perspective transformation can correct image variations caused by scanning anomalies, laying the foundation for accurate identification of information points. At the same time, it can also realize coordinate system transformation, completing the coordinate space transformation from the scanned image to the template image, achieving precise positioning of the answer sheet, reducing the requirements for positioning elements, and improving the anti-interference ability of the positioning process.
[0079] Based on the above embodiments, Figure 2 This is one of the flowcharts illustrating the positioning frame matching process provided by the present invention, such as... Figure 2 As shown, in step 120, matching is performed on each contour graphic and the positioning box, including:
[0080] Step 210: Based on the area of each contour graphic and the area of the positioning box, determine the area difference between each contour graphic and the positioning box.
[0081] Step 220: Based on the coordinates of the center point of each contour graphic and the coordinate range of the positioning box, determine the positional relationship between the center point of each contour graphic and the positioning box.
[0082] Step 230: If the area difference between any contour graphic and the positioning box is less than or equal to the area threshold, and the positional relationship indicates that the center point of the contour graphic is within the coordinate range of the positioning box, then the contour graphic and the positioning box are determined to be successfully matched.
[0083] Specifically, step 120, the process of matching each contour graphic with the positioning box, may include the following steps:
[0084] Step 210: First, it is necessary to determine the area of each contour graphic and the area of the positioning box in the template image, and then calculate the area difference between each contour graphic and the positioning box based on these two.
[0085] Step 220: At the same time, the coordinates of the center point of each contour graphic and the coordinate range of the positioning box can be determined. The coordinate range can be obtained by the coordinates of the four vertices of the positioning box. Then, by referring to the coordinates of the center point of each contour graphic and the coordinate range of the positioning box, the positional relationship between the center point of each contour graphic and the positioning box can be determined, that is, whether the center point of each contour graphic falls within the coordinate range of the positioning box.
[0086] Step 230, further, if the area difference between any contour graphic in the scanned image and the positioning box is less than or equal to the area threshold, and the positional relationship indicates that the center point of the contour graphic is within the coordinate range of the positioning box, that is, if the areas of the two are close and the center points are not far apart, it can be determined that the two correspond, that is, the contour graphic and the positioning box are successfully matched.
[0087] Correspondingly, if the area difference between the outline graphic and the positioning box is greater than the area threshold, and / or the positional relationship indicates that the center point of the outline graphic is outside the coordinate range of the positioning box, that is, if the area difference between the two is large, and / or the center point is far apart, it can be determined that the two do not correspond, that is, the outline graphic and the positioning box fail to match. At this time, the next outline graphic can be selected to continue to match with the positioning box until the match is successful, or all outline graphics fail to match with the positioning box.
[0088] Here, the area threshold is a preset value used to determine the similarity of the areas of the outline graphic and the positioning box, which can be set according to the actual situation.
[0089] Based on the above embodiments, Figure 3 This is the second flowchart illustrating the positioning frame matching process provided by the present invention, as shown below. Figure 3 As shown, in step 220, based on the coordinates of the center points of each contour graphic and the coordinate range of the positioning box, the positional relationship between the center points of each contour graphic and the positioning box is determined. This step further includes:
[0090] Step 310: If the area difference between the contour graphic and the positioning box is greater than the area threshold, and / or the positional relationship indicates that the center point of the contour graphic is outside the coordinate range of the positioning box, it is determined that the contour graphic and the positioning box fail to match.
[0091] Step 320: If the matching between each contour graphic and the positioning box fails, update the binarization threshold, and perform contour detection on the scanned image based on the updated binarization threshold to obtain multiple new contour graphics. Match each new contour graphic with the positioning box until a match is successful or the number of matching rounds reaches the upper limit.
[0092] Specifically, in the above process, after obtaining the area difference between each contour graphic and the positioning box, as well as the positional relationship between the center point of each contour graphic and the positioning box, if there is a failure to match each contour graphic with the positioning box, it may be because the contour detection process is too strict. Strict contour detection conditions can eliminate interference and facilitate the search for positioning boxes, but they are prone to ignoring shallower frame lines in the scanned image and easily filtering out positioning boxes. Therefore, in this case, the contour detection conditions can be relaxed, and contour detection can be performed on the scanned image again. The specific process includes:
[0093] Step 310: If the area difference between the contour graphic and the positioning box is greater than the area threshold, and / or the positional relationship indicates that the center point of the contour graphic is outside the coordinate range of the positioning box, that is, if the area difference between the two is large, and / or the center point is far away, it can be determined that the contour graphic and the positioning box fail to match.
[0094] Step 320, further, if all contour graphics fail to match the positioning box, the contour detection conditions can be relaxed, that is, the binarization threshold can be updated. Specifically, the binarization threshold can be increased, and contour detection can be performed on the scanned image according to the updated binarization threshold to obtain multiple new contour graphics. That is, the scanned image can be binarized according to the updated binarization threshold to obtain a binarized scanned image, and then contour detection can be performed on the binarized scanned image to obtain multiple new contour graphics.
[0095] Then, each new contour graphic and positioning box can be matched until any new contour graphic and positioning box is successfully matched, or the matching rounds reach the maximum number of rounds. The matching process here is basically the same as the matching process of each contour graphic and positioning box described above, and will not be repeated here. The maximum number of rounds is preset and represents the maximum number of matching rounds, which can be set according to actual needs.
[0096] Based on the above embodiments, Figure 4 This is a flowchart illustrating the positioning and detection process provided by the present invention, as shown below. Figure 4 As shown, the template image also includes location detection points;
[0097] In step 130, answer sheet recognition is performed based on the scanned positioning image, followed by:
[0098] Step 410: Based on the coordinates of the positioning detection points, determine the positioning detection coordinate range in the scanned positioning image and the average gray value of the positioning detection coordinate range.
[0099] Step 420: Based on the average gray value and the gray value threshold, determine the positioning accuracy and recognition precision, and based on the positioning accuracy and recognition precision, adjust the transformation matrix and the filling content obtained from the answer sheet recognition, respectively.
[0100] Specifically, in step 130, after recognizing the answer sheet based on the scanned positioning image, the positioning accuracy and recognition precision can also be tested, which includes the following steps:
[0101] In this embodiment of the invention, in order to detect the accuracy of the answer sheet positioning and the precision of the information point recognition, a positioning detection point is also set when defining the answer sheet template. That is, the template image contains a positioning detection point, which can be used for positioning detection and recognition verification.
[0102] Step 410: First, the coordinates of the positioning detection points in the template image need to be determined. The positioning detection points here are essentially rectangular boxes similar to filling options, so their coordinates can be understood as the coordinates of the four vertices of the rectangle. Based on these coordinates, the positioning detection coordinate range in the scanned positioning image is determined, that is, the coordinate range corresponding to the rectangle in the scanned positioning image is determined. Then, the average gray value of the positioning detection coordinate range needs to be determined.
[0103] Step 420: Subsequently, the positioning accuracy and recognition precision can be determined based on the average grayscale value of the positioning detection coordinate range and the grayscale threshold. Specifically, since the positioning detection point is actually a completely black rectangle with a grayscale value of 0, if the average grayscale value of the positioning detection coordinate range is larger and closer to white (grayscale value of 255), it indicates that the positioning accuracy and recognition precision are lower; conversely, if the average grayscale value of the positioning detection coordinate range is smaller and closer to black, it indicates that the positioning accuracy and recognition precision are higher. Therefore, in this embodiment of the invention, the grayscale threshold can be set to 255. The positioning accuracy and recognition precision are evaluated by the difference between the grayscale threshold and the average grayscale value. That is, the larger the difference, the higher the positioning accuracy and recognition precision; conversely, the smaller the difference, the lower the positioning accuracy and recognition precision.
[0104] After that, the positioning and recognition processes can be adjusted based on the positioning accuracy and recognition precision. Specifically, the transformation matrix between the scanned image and the template image, as well as the filling content in the scanned positioning image, can be adjusted based on the positioning accuracy and recognition precision.
[0105] Based on the above embodiments, Figure 5This is a schematic flowchart of the contour detection process provided by the present invention, as shown below. Figure 5 As shown, in step 320, based on the updated binarization threshold, contour detection is performed on the scanned image to obtain multiple new contour patterns, including:
[0106] Step 510: Perform grayscale processing on the scanned image to obtain a scanned grayscale image;
[0107] Step 520: Based on the updated binarization threshold, the scanned grayscale image is binarized, and contour detection is performed on the binarized scanned grayscale image to obtain multiple new contour patterns.
[0108] Specifically, step 320, which involves performing contour detection on the scanned image based on the updated binarization threshold to obtain multiple new contour patterns, includes the following steps:
[0109] Step 510: First, the scanned image can be converted into a grayscale image, that is, the scanned image can be processed into grayscale to obtain a grayscale image of scanned grayscale, i.e., a scanned grayscale image.
[0110] Step 520: The scanned grayscale image can then be binarized according to the updated binarization threshold to obtain the binarized scanned grayscale image; then, contour detection can be performed on the binarized scanned grayscale image to obtain multiple new contour patterns.
[0111] In this embodiment of the invention, by using grayscale processing and binarization, noise introduced during the scanning process can be eliminated, interference from pulse noise in the scanned image can be avoided, and interference near the positioning box can be eliminated, making it easier to perform contour detection and positioning box matching to find the positioning box, thus greatly improving the anti-interference capability of the positioning process.
[0112] Based on the above embodiments, Figure 6 This is the third flowchart illustrating the positioning frame matching process provided by the present invention, as shown below. Figure 6 As shown, in step 320, each new contour graphic and positioning box is matched, and then the process includes:
[0113] Step 610: If the number of matching rounds reaches the maximum number of rounds, update the positioning box;
[0114] Step 620: Match each new contour graphic with the updated positioning box;
[0115] Step 630: If each new contour graphic fails to match the updated positioning box, determine that the scanned image is faulty.
[0116] Specifically, in step 320, after obtaining multiple new contour shapes and matching each new contour shape with the positioning box, if the matching rounds reach the upper limit and none of the new contour shapes match the positioning box, the positioning box can be updated, and another positioning box can be selected for answer sheet positioning. The specific process includes:
[0117] Step 610: After several rounds of matching, none of the new contour graphics can match the positioning box, that is, none of the new contour graphics can match the positioning box. At this time, if the number of matching rounds between the contour graphics and the positioning box has reached the upper limit of the number of rounds, it can be determined that it is difficult to find the positioning box from the scanned image. Therefore, the positioning box can be updated, that is, the positioning box can be replaced.
[0118] Step 620: Match each new contour graphic with the updated positioning box. This matching process is basically the same as the matching process of each contour graphic and positioning box mentioned above, and will not be described again here.
[0119] Step 630, further, if none of the new contour graphics can match the updated positioning box, that is, if none of the new contour graphics can match the updated positioning box, it can be determined that there is an error in the scanned image, that is, there is an obvious error or a large variation (such as stretching, rotation, translation, distortion, etc.) during the scanning process.
[0120] The overall process of the answer sheet recognition method provided by this invention includes the following steps:
[0121] First, determine the template image and scanned image of the answer sheet to be recognized. The template image includes a positioning box.
[0122] Subsequently, contour detection is performed on the scanned image to obtain multiple contour patterns. Each contour pattern is matched with a bounding box, and based on the successfully matched contour patterns and bounding boxes, the transformation matrix between the scanned image and the template image is determined. Specifically, the transformation matrix between the scanned image and the template image can be determined based on the corner coordinates of the successfully matched contour patterns and the corner coordinates of the bounding boxes.
[0123] The process of matching each contour graphic with the positioning box includes the following steps: determining the area difference between each contour graphic and the positioning box based on the area of each contour graphic and the area of the positioning box; determining the positional relationship between the center point of each contour graphic and the positioning box based on the coordinates of the center point of each contour graphic and the coordinate range of the positioning box; and determining that the contour graphic and the positioning box are successfully matched if the area difference between any contour graphic and the positioning box is less than or equal to the area threshold and the positional relationship indicates that the center point of the contour graphic is within the coordinate range of the positioning box.
[0124] Further, based on the coordinates of the center point of each contour graphic and the coordinate range of the positioning box, the positional relationship between the center point of each contour graphic and the positioning box is determined. This then includes: if the area difference between the contour graphic and the positioning box is greater than an area threshold, and / or the positional relationship indicates that the center point of the contour graphic is outside the coordinate range of the positioning box, then the contour graphic is determined to have failed to match the positioning box. In cases where each contour graphic fails to match the positioning box, the binarization threshold is updated, and based on the updated binarization threshold, contour detection is performed on the scanned image to obtain multiple new contour graphics. Each new contour graphic is then matched with the positioning box until a successful match is achieved, or the number of matching rounds reaches the upper limit.
[0125] Specifically, based on the updated binarization threshold, contour detection is performed on the scanned image to obtain multiple new contour patterns, including: performing grayscale processing on the scanned image to obtain a scanned grayscale image; binarizing the scanned grayscale image based on the updated binarization threshold, and performing contour detection on the binarized scanned grayscale image to obtain multiple new contour patterns.
[0126] Furthermore, the process involves matching each new contour graphic with a bounding box, and then includes: updating the bounding box when the matching round reaches the upper limit; matching each new contour graphic with the updated bounding box; and determining that the scanned image has an error when each new contour graphic fails to match the updated bounding box.
[0127] Subsequently, based on the transformation matrix, the scanned image is transformed to obtain the scanned positioning image, and the answer sheet is recognized based on the scanned positioning image.
[0128] The process of recognizing answer sheets based on scanned positioning images also includes: determining the range of positioning detection coordinates in the scanned positioning image and the average gray value of the positioning detection coordinate range based on the coordinates of the positioning detection points in the template image; determining the positioning accuracy and recognition precision based on the average gray value and gray threshold; and adjusting the transformation matrix and the filled content obtained from the recognition of the answer sheet based on the positioning accuracy and recognition precision.
[0129] The method provided in this invention matches multiple contour graphics of a scanned image obtained from contour detection with positioning boxes in a template image. Based on the successfully matched contour graphics and positioning boxes, a transformation matrix between the scanned image and the template image is determined. Coordinate system transformation is performed based on this transformation matrix, and answer sheet recognition is performed based on the transformed scanned positioning image. The coordinate system transformation completes the coordinate space transformation from the scanned image to the template image, realizing answer sheet positioning. This overcomes the shortcomings of traditional positioning methods, such as high requirements for positioning elements and poor anti-interference ability. It reduces the requirements for positioning elements, enhances the anti-interference ability of the positioning process, and improves positioning accuracy and recognition precision.
[0130] The answer sheet recognition device provided by the present invention is described below. The answer sheet recognition device described below can be referred to in correspondence with the answer sheet recognition method described above.
[0131] Figure 7 This is a schematic diagram of the answer sheet recognition device provided by the present invention, as shown below. Figure 7 As shown, the device includes:
[0132] The image determination unit 710 is used to determine the template image and the scanned image of the answer sheet to be identified, wherein the template image includes a positioning box;
[0133] The positioning box matching unit 720 is used to perform contour detection on the scanned image to obtain multiple contour patterns, match each contour pattern with the positioning box, and determine the transformation matrix between the scanned image and the template image based on the successfully matched contour patterns and the positioning boxes.
[0134] The positioning and recognition unit 730 is used to perform coordinate system transformation on the scanned image based on the transformation matrix to obtain a scanned positioning image, and to perform answer sheet recognition based on the scanned positioning image.
[0135] The answer sheet recognition device provided by this invention matches multiple contour graphics of the scanned image obtained by contour detection with the positioning boxes in the template image. Based on the successfully matched contour graphics and positioning boxes, it determines the transformation matrix between the scanned image and the template image, performs coordinate system transformation based on this transformation matrix, and performs answer sheet recognition based on the transformed scanned positioning image. Through coordinate system transformation, it completes the coordinate space transformation from the scanned image to the template image, realizing answer sheet positioning. This overcomes the shortcomings of traditional positioning methods, such as high requirements for positioning elements and poor anti-interference ability. It reduces the requirements for positioning elements, enhances the anti-interference ability of the positioning process, and improves the positioning accuracy and recognition precision.
[0136] Based on the above embodiments, the positioning frame matching unit 720 is used for:
[0137] Based on the corner coordinates of the successfully matched contour graphic and the corner coordinates of the positioning box, the transformation matrix between the scanned image and the template image is determined.
[0138] Based on the above embodiments, the positioning frame matching unit 720 is used for:
[0139] Based on the area of each contour graphic and the area of the positioning frame, determine the area difference between each contour graphic and the positioning frame;
[0140] Based on the coordinates of the center point of each contour graphic and the coordinate range of the positioning box, the positional relationship between the center point of each contour graphic and the positioning box is determined.
[0141] If the area difference between any contour graphic and the positioning frame is less than or equal to the area threshold, and the positional relationship indicates that the center point of the contour graphic is within the coordinate range of the positioning frame, then the contour graphic is determined to be successfully matched with the positioning frame.
[0142] Based on the above embodiments, the positioning frame matching unit 720 is used for:
[0143] If the area difference between any contour graphic and the positioning frame is greater than an area threshold, and / or the positional relationship indicates that the center point of any contour graphic is outside the coordinate range of the positioning frame, then it is determined that any contour graphic fails to match the positioning frame.
[0144] If the contour pattern fails to match the positioning box, the binarization threshold is updated, and based on the updated binarization threshold, contour detection is performed on the scanned image to obtain multiple new contour patterns. Each new contour pattern is matched with the positioning box until a match is successful or the number of matching rounds reaches the upper limit.
[0145] Based on the above embodiments, the template image also includes location detection points;
[0146] The device further includes a positioning detection unit for:
[0147] Based on the coordinates of the positioning detection points, the positioning detection coordinate range in the scanned positioning image and the average gray value of the positioning detection coordinate range are determined.
[0148] Based on the average gray value and the gray value threshold, the positioning accuracy and recognition precision are determined, and based on the positioning accuracy and the recognition precision, the transformation matrix and the filled content obtained from the answer sheet recognition are adjusted respectively.
[0149] Based on the above embodiments, the positioning frame matching unit 720 is used for:
[0150] The scanned image is processed to obtain a grayscale image;
[0151] Based on the updated binarization threshold, the scanned grayscale image is binarized, and contour detection is performed on the binarized scanned grayscale image to obtain multiple new contour patterns.
[0152] Based on the above embodiments, the positioning frame matching unit 720 is used for:
[0153] If the number of matching rounds reaches the upper limit of the number of rounds, update the positioning frame;
[0154] Match each new outline graphic with the updated positioning box;
[0155] If the new contour graphics fail to match the updated positioning boxes, the scanned image is determined to be faulty.
[0156] Figure 8 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 8 As shown, the electronic device may include a processor 810, a communication interface 820, a memory 830, and a communication bus 840, wherein the processor 810, the communication interface 820, and the memory 830 communicate with each other via the communication bus 840. The processor 810 can call logical instructions in the memory 830 to execute an answer sheet recognition method. This method includes: determining a template image and a scanned image of the answer sheet to be recognized, wherein the template image includes a positioning bounding box; performing contour detection on the scanned image to obtain multiple contour graphics; matching each contour graphic with the positioning bounding box; and determining a transformation matrix between the scanned image and the template image based on the successfully matched contour graphics and the positioning bounding box; performing coordinate system transformation on the scanned image based on the transformation matrix to obtain a scanned positioning image; and performing answer sheet recognition based on the scanned positioning image.
[0157] Furthermore, the logical instructions in the aforementioned memory 830 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0158] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, wherein when the program instructions are executed by a computer, the computer is able to execute the answer sheet recognition method provided by the above methods, the method comprising: determining a template image and a scanned image of an answer sheet to be recognized, the template image including a positioning box; performing contour detection on the scanned image to obtain multiple contour graphics, matching each contour graphic with the positioning box, and determining a transformation matrix between the scanned image and the template image based on the successfully matched contour graphics and the positioning box; performing coordinate system transformation on the scanned image based on the transformation matrix to obtain a scanned positioning image, and performing answer sheet recognition based on the scanned positioning image.
[0159] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the answer sheet recognition method provided by the above methods. The method includes: determining a template image and a scanned image of the answer sheet to be recognized, wherein the template image includes a positioning bounding box; performing contour detection on the scanned image to obtain multiple contour graphics; matching each contour graphic with the positioning bounding box; and determining a transformation matrix between the scanned image and the template image based on the successfully matched contour graphics and the positioning bounding box; performing coordinate system transformation on the scanned image based on the transformation matrix to obtain a scanned positioning image; and performing answer sheet recognition based on the scanned positioning image.
[0160] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0161] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0162] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An answer sheet recognition method characterized by comprising: include: Determine the template image and scanned image of the answer sheet to be identified. The template image includes a positioning frame and filling options. The positioning frame is the outer border set around the filling options. Contour detection is performed on the scanned image to obtain multiple contour patterns. Each contour pattern is matched with the positioning box, and a transformation matrix between the scanned image and the template image is determined based on the successfully matched contour patterns and the positioning boxes. The contour detection only detects the outer contour of the scanned image and ignores the inner frame lines of the scanned image. Based on the transformation matrix, the scanned image is transformed to obtain a scanned positioning image, and the answer sheet is recognized based on the scanned positioning image.
2. The method of claim 1, wherein The step of determining the transformation matrix between the scanned image and the template image based on the successfully matched contour graphic and the positioning box includes: Based on the corner coordinates of the successfully matched contour graphic and the corner coordinates of the positioning box, the transformation matrix between the scanned image and the template image is determined.
3. The answer sheet recognition method according to claim 1, characterized in that, The matching of each contour graphic with the positioning box includes: Based on the area of each contour graphic and the area of the positioning frame, determine the area difference between each contour graphic and the positioning frame; Based on the coordinates of the center point of each contour graphic and the coordinate range of the positioning box, the positional relationship between the center point of each contour graphic and the positioning box is determined. If the area difference between any contour graphic and the positioning frame is less than or equal to the area threshold, and the positional relationship indicates that the center point of any contour graphic is within the coordinate range of the positioning frame, then the contour graphic is determined to be successfully matched with the positioning frame.
4. The answer sheet recognition method according to claim 3, characterized in that, The method of determining the positional relationship between the center point of each contour graphic and the positioning frame based on the coordinates of the center point of each contour graphic and the coordinate range of the positioning frame, further includes: If the area difference between any contour graphic and the positioning frame is greater than an area threshold, and / or the positional relationship indicates that the center point of any contour graphic is outside the coordinate range of the positioning frame, then it is determined that any contour graphic fails to match the positioning frame. If the contour pattern fails to match the positioning box, the binarization threshold is updated, and based on the updated binarization threshold, contour detection is performed on the scanned image to obtain multiple new contour patterns. Each new contour pattern is matched with the positioning box until a match is successful or the number of matching rounds reaches the upper limit.
5. The answer sheet recognition method according to any one of claims 1 to 4, characterized in that, The template image also includes location detection points; The step of recognizing the answer sheet based on the scanned positioning image further includes: Based on the coordinates of the positioning detection points, the positioning detection coordinate range in the scanned positioning image and the average gray value of the positioning detection coordinate range are determined. Based on the average gray value and the gray value threshold, the positioning accuracy and recognition precision are determined, and based on the positioning accuracy and the recognition precision, the transformation matrix and the filled content obtained from the answer sheet recognition are adjusted respectively.
6. The answer sheet recognition method according to claim 4, characterized in that, Based on the updated binarization threshold, contour detection is performed on the scanned image to obtain multiple new contour patterns, including: The scanned image is processed to obtain a grayscale image; Based on the updated binarization threshold, the scanned grayscale image is binarized, and contour detection is performed on the binarized scanned grayscale image to obtain multiple new contour patterns.
7. The answer sheet recognition method according to claim 4, characterized in that, The process of matching each new contour graphic with the positioning box then includes: If the number of matching rounds reaches the upper limit of the number of rounds, update the positioning frame; Match each new outline graphic with the updated positioning box; If the new contour graphics fail to match the updated positioning boxes, the scanned image is determined to be faulty.
8. An answer sheet recognition device, characterized in that, include: An image determination unit is used to determine a template image and a scanned image of the answer sheet to be identified. The template image includes a positioning frame and filling options. The positioning frame is an outer border set around the filling options. The bounding box matching unit is used to perform contour detection on the scanned image to obtain multiple contour patterns, match each contour pattern with the bounding box, and determine the transformation matrix between the scanned image and the template image based on the successfully matched contour patterns and the bounding boxes; wherein, the contour detection only detects the outer contour of the scanned image and ignores the inner bounding box of the scanned image. The positioning and recognition unit is used to perform coordinate system transformation on the scanned image based on the transformation matrix to obtain a scanned positioning image, and to perform answer sheet recognition based on the scanned positioning image.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the answer sheet recognition method as described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the answer sheet recognition method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Method for accurately positioning moving object based on deep learning
CN109934848A
Answer sheet correction method and device, electronic equipment and storage medium
CN112348019A