Answer sheet template generation method, answer sheet recognition method, device and electronic device

By checking the answer sheet images for marquee checking and adjusting the distribution parameters, the answer sheet templates are automatically generated, which solves the problem of time-consuming and labor-intensive setting of templates by manually setting them, and achieves efficient and accurate template generation.

CN114254605BActive Publication Date: 2025-04-18IFLYTEK CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111328865.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-10
Publication Date
2025-04-18
Estimated Expiration
2041-11-10

AI Technical Summary

Technical Problem

In the prior art, manually setting answer sheet templates is time-consuming and labor-intensive, and it is prone to setting errors.

Method used

By performing marquee detection on the answer sheet image to be modeled, the distribution parameters of the marquee array are determined, and multiple sets of second distribution parameters are obtained by adjusting these parameters. Based on the array scores of these parameters, the third distribution parameters are determined, and the answer sheet template is finally generated.

Benefits of technology

The automatic generation of answer sheet templates is realized, ensuring that the marquee selection position is as consistent as possible, reducing labor costs and time consumption, and improving the accuracy of generating templates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114254605B_ABST
    Figure CN114254605B_ABST
Patent Text Reader

Abstract

The present invention provides a method for generating an answer sheet template, an answer sheet recognition method, a device and an electronic device, wherein the template generation method comprises: performing box detection on an answer sheet image to be modeled to obtain the box position of each box; determining the first distribution parameter of the box array to which each box belongs based on the box position of each box; adjusting the first distribution parameter to obtain multiple groups of second distribution parameters, and determining the array score of each group of second distribution parameters, wherein the array score is determined based on the degree of overlap between the virtual box area and the real box area of ​​the box array under the corresponding second distribution parameter; determining the third distribution parameter based on the array score of each group of second distribution parameters, and generating the answer sheet template based on the third distribution parameter. The method, device and electronic device provided by the present invention realize the automatic and precise positioning of the box on the basis of realizing the automatic generation of the answer sheet template, thereby reducing the manpower cost and time consumption of the generation of the answer sheet template.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to an answer sheet template generation method, an answer sheet recognition method, a device and an electronic device. Background Art

[0002] The intelligent marking system can accurately read the objective question information filled in by students on the answer sheet through scanning technology and image processing technology, thereby realizing the rapid marking of the objective question part of the answer sheet.

[0003] In order to realize intelligent marking, it is necessary to prepare the answer sheet template in advance, so as to provide the necessary position parameters and style parameters of the objective questions for the intelligent marking system to identify and locate. Usually, the answer sheet template includes information such as the number of multiple-choice questions, the number of options, the position of the options, the size of the options, the horizontal and vertical arrangement, and the question number.

[0004] Since answer sheets produced by different manufacturers have different styles, and some exams have a huge number of objective questions, answer sheet templates need to be manually set before each marking, which is time-consuming and labor-intensive, and may result in setting errors, especially when the operator is unskilled. Summary of the invention

[0005] The present invention provides an answer sheet template generation method, an answer sheet recognition method, a device and an electronic device, which are used to solve the problem that it is time-consuming and labor-intensive to manually set an answer sheet template in the prior art.

[0006] The present invention provides a method for generating an answer sheet template, comprising:

[0007] Performing box detection on the answer sheet image to be modeled to obtain the box positions of each box in the answer sheet image;

[0008] Determining, based on the selection frame positions of the selection frames, first distribution parameters of the selection frame arrays to which the selection frames belong;

[0009] Adjusting the first distribution parameter to obtain multiple groups of second distribution parameters, and determining an array score for each group of second distribution parameters, wherein the array score is determined based on a degree of overlap between a virtual marquee area corresponding to the second distribution parameter and a real marquee area of ​​the marquee array;

[0010] Based on the array scores of the groups of second distribution parameters, a third distribution parameter is determined, and based on the third distribution parameter, an answer sheet template is generated.

[0011] According to a method for generating an answer sheet template provided by the present invention, the step of determining the array score of each group of second distribution parameters includes:

[0012] Determine the array score of each set of second distribution parameters based on the overlap degree between the virtual selection frame area and the real selection frame area under each set of second distribution parameters, and the overlap degree between the virtual spacing area and the real selection frame area under each set of second distribution parameters;

[0013] The virtual spacing area is an area outside the virtual selection frame area in the selection frame array.

[0014] According to a method for generating an answer sheet template provided by the present invention, the array score of each group of second distribution parameters is determined based on the overlap degree between the virtual selection box area and the real selection box area under each group of second distribution parameters, and the overlap degree between the virtual spacing area and the real selection box area under each group of second distribution parameters, including:

[0015] Determining the row score in the array score of each group of second distribution parameters based on the difference between the intra-row overlap degree and the inter-row overlap degree under each group of second distribution parameters, wherein the intra-row overlap degree is the overlap degree between the row area of ​​the virtual selection frame area and the row area of ​​the real selection frame area, and the inter-row overlap degree is the overlap degree between the row area of ​​the virtual spacing area and the row area of ​​the real selection frame area;

[0016] Based on the difference between the intra-column overlap degree and the inter-column overlap degree under each group of second distribution parameters, the column score in the array score of each group of second distribution parameters is determined, the intra-column overlap degree is the overlap degree between the column area of ​​the virtual selection frame area and the column area of ​​the real selection frame area, and the inter-column overlap degree is the overlap degree between the column area of ​​the virtual spacing area and the column area of ​​the real selection frame area.

[0017] According to a method for generating an answer sheet template provided by the present invention, the step of determining the first distribution parameter of the selection box array to which each selection box belongs based on the selection box position of each selection box includes:

[0018] Performing question block detection on the answer sheet image to obtain the question block position of each question block in the answer sheet image;

[0019] Based on the position of each question block and the position of each selection box, determining the question block to which each selection box belongs;

[0020] Based on the selection box position of each selection box under each question block, a first distribution parameter of the selection box array corresponding to each question block is determined.

[0021] According to a method for generating an answer sheet template provided by the present invention, the first distribution parameter of the selection box array corresponding to each question block is determined based on the selection box position of each selection box under each question block, including:

[0022] Based on the selection box positions of each selection box under any question block, image rendering and binarization are performed on the question block image of any question block in the answer sheet image to obtain a binarized image of any question block;

[0023] Performing horizontal projection and vertical projection on the binary image to obtain a horizontal projection histogram and a vertical projection histogram of the binary image;

[0024] Based on the horizontal projection histogram and the vertical projection histogram, a first distribution parameter of the selection box array corresponding to any one of the question blocks is determined.

[0025] According to a method for generating an answer sheet template provided by the present invention, the question block detection is performed on the answer sheet image to obtain the question block position of each question block in the answer sheet image, and then the method further includes:

[0026] Based on the question block position of each question block and the question number position of each question number in the answer sheet image, determining the question block to which each question number belongs;

[0027] Based on the position of each question number under each question block, the arrangement of the questions in each question block is determined.

[0028] According to a method for generating an answer sheet template provided by the present invention, generating an answer sheet template based on the third distribution parameter includes:

[0029] Based on the third distribution parameter, determine a selection box inspection area of ​​the answer sheet image, perform text recognition on the selection box inspection area, and obtain a text recognition result;

[0030] Based on the text recognition result, determining template verification information of the answer sheet image;

[0031] Determining a fourth distribution parameter based on the template verification information and the third distribution parameter;

[0032] Based on the fourth distribution parameter, the answer sheet template is generated.

[0033] According to a method for generating an answer sheet template provided by the present invention, determining the fourth distribution parameter based on the template verification information and the third distribution parameter includes:

[0034] If the number of options in the template verification information is different from the number of options indicated by the third distribution parameter, determining a reference selection box area and an error selection box area based on the template verification information and the third distribution parameter;

[0035] Determining the number of verification options based on the pixel ratio of the reference selection box area and the pixel ratio of the error selection box area;

[0036] The fourth distribution parameter is determined based on the number of verification options and the third distribution parameter.

[0037] The present invention also provides an answer sheet recognition method, comprising:

[0038] Obtaining a response image to be recognized;

[0039] The answer recognition is performed on the answer image based on the answer sheet template, and the answer sheet template is determined based on the answer sheet template generation method as described above.

[0040] The present invention also provides a device for generating an answer sheet template, comprising:

[0041] A selection box detection unit, used to perform selection box detection on the answer sheet image to be modeled, and obtain the selection box position of each selection box in the answer sheet image;

[0042] A parameter determination unit, configured to determine, based on the selection frame position of each selection frame, a first distribution parameter of a selection frame array to which each selection frame belongs;

[0043] a parameter adjustment unit, configured to adjust the first distribution parameter to obtain multiple groups of second distribution parameters, and determine an array score for each group of second distribution parameters, wherein the array score is determined based on a degree of overlap between a virtual marquee area corresponding to the second distribution parameter and a real marquee area of ​​the marquee array;

[0044] The template generating unit is used to determine the third distribution parameter based on the array scores of the groups of second distribution parameters, and to generate an answer sheet template based on the third distribution parameter.

[0045] The present invention also provides an answer sheet recognition device, comprising:

[0046] An image determination unit, used for acquiring a response image to be identified;

[0047] The answer recognition unit is used to recognize the answer of the answer image based on the answer sheet template, and the answer sheet template is determined based on the answer sheet template generation method as described above.

[0048] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the processor implements the steps of any one of the above-mentioned methods for generating answer sheet templates or the above-mentioned method for identifying answer sheet.

[0049] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the computer program implements the steps of any of the above-mentioned answer sheet template generation methods or the above-mentioned answer sheet recognition methods.

[0050] The answer sheet template generation method, answer sheet recognition method, device and electronic device provided by the present invention obtain multiple groups of second distribution parameters by adjusting the first distribution parameters obtained by selection box detection, and select third distribution parameters from the multiple groups of second distribution parameters to generate an answer sheet template through an array score that can reflect the difference between the actual situation. On the basis of realizing the automatic generation of answer sheet templates, it is ensured that the position of each selection box in the answer sheet template can fit the actual situation in the answer sheet image as much as possible, and the automatic and precise positioning of the selection box is realized, which reduces the labor cost and time consumption of generating answer sheet templates. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly described below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0052] Figure 1 It is a flow chart of the method for generating an answer sheet template provided by the present invention;

[0053] Figure 2 is a schematic diagram of a selection frame array provided by the present invention;

[0054] Figure 3 is a schematic diagram of a flow chart of a method for calculating array scores provided by the present invention;

[0055] Figure 4 It is a flowchart of step 120 in the method for generating an answer sheet template provided by the present invention;

[0056] Figure 5 It is a flowchart of step 123 in the method for generating an answer sheet template provided by the present invention;

[0057] Figure 6 is a binary image of the question block provided by the present invention;

[0058] Figure 7 It is a flow chart of the method for determining the question arrangement mode provided by the present invention;

[0059] Figure 8 It is a flowchart of step 140 in the method for generating an answer sheet template provided by the present invention;

[0060] Fig. 9 It is a flowchart of step 143 in the method for generating an answer sheet template provided by the present invention;

[0061] Fig.10 It is a flow chart of the answer sheet recognition method provided by the present invention;

[0062] Fig.11 It is a structural schematic diagram of the answer sheet template generating device provided by the present invention;

[0063] Fig.12 It is a structural schematic diagram of the answer sheet recognition device provided by the present invention;

[0064] Fig.13 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0065] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0066] Most of the existing methods for generating answer sheet templates are manual or semi-automatic, which can be implemented in the following steps: First, obtain the image used to make the answer sheet template, and perform preprocessing operations on the image, including image enhancement and horizontal correction. Secondly, the operator specifies the area where the objective questions are located, including information such as the size of the selection box, the number of options, and the number of questions. Subsequently, the computer uses the parameters entered by the operator to render the corresponding objective question position in the specified area. Then, the operator fine-tunes some parameters according to the rendering effect and actual situation, so that the rendered selection box is completely aligned with the actual selection box on the picture. After the above operations are completed, the operator confirms the relevant information, saves it, and then draws the next question block.

[0067] The above method requires the operator to constantly adjust the relevant parameters, and only one question block can be drawn at a time. Assuming that a question block contains 5 small questions, it takes more than 2 minutes to draw a question block. If an exam has 50 multiple-choice questions, it will take at least 20 minutes to complete the answer sheet template drawing. In this process, there may also be operator errors, such as unreasonable selection box size settings, incorrect horizontal and vertical parameter settings, incorrect number of options settings, and so on. The main reason for these problems is that the operator needs to manually set too many parameters. As shown in the following table, more than 10 relevant parameters need to be set for a question block:

[0068] Number of options …… Preferences upper left corner horizontal coordinate …… Arrangement Horizontal / Vertical Preferences upper left corner vertical coordinate …… Is it continuous? whether Option Width …… Question quantity …… Option Height …… …… …… Horizontal option spacing …… …… …… Vertical option spacing ……

[0069] Any unreasonable parameter setting may cause corresponding problems. The manual setting is complicated and uncontrollable, which leads to frequent problems in the final answer sheet template, affecting the final marking and grading.

[0070] In view of the above problems, an embodiment of the present invention provides a method for generating an answer sheet template to realize automatic generation of an answer sheet template. Figure 1 It is a flow chart of the method for generating the answer sheet template provided by the present invention, such as Figure 1 As shown, the method includes:

[0071] Step 110, performing selection box detection on the answer sheet image to be modeled, and obtaining the selection box position of each selection box in the answer sheet image.

[0072] Specifically, the answer sheet image to be modeled is the image corresponding to the answer sheet for which the answer sheet template needs to be generated. The answer sheet image can be obtained by taking a picture with a camera, scanning, or downloading from the network, and the embodiment of the present invention does not specifically limit this.

[0073] The answer sheet corresponding to the answer sheet image contains a selection box for selecting and answering objective questions. Here, the selection box is a frame containing options. For example, if an objective question provides four options A, B, C, and D, then four selection boxes A, B, C, and D are set for the objective question on the answer sheet. The answerer can fully fill in one of the selection boxes to indicate the selection of the option corresponding to the selection box. After obtaining the answer sheet image to be modeled, the selection box detection can be performed on the answer sheet image to locate the selection box position of each selection box in the answer sheet image.

[0074] Here, the selection box detection of the answer sheet image can be realized by an image detection model, and the image detection model can be trained with the sample answer sheet image as a training sample and the positions of each selection box pre-annotated in the sample answer sheet image as a label. In addition, while detecting the selection box position in the answer sheet image, the image detection model can also detect the position of information such as the question block and question number in the answer sheet image.

[0075] The positions of each selection box in the answer sheet image obtained by selection box detection are recorded as selection box positions. For any selection box, the selection box position may include the coordinates of the upper left corner and the lower right corner of the selection box in the answer sheet image, and may also include the coordinates of the center of the selection box in the answer sheet image and the length and width of the selection box, and may also include the coordinates of a vertex of the selection box in the answer sheet image and the length and width of the selection box, which is not specifically limited in the embodiment of the present invention.

[0076] Step 120: Determine a first distribution parameter of a selection frame array to which each selection frame belongs based on the selection frame position of each selection frame.

[0077] Specifically, in a test, there are usually multiple objective questions, and each objective question has multiple options. Therefore, there will be multiple checkboxes in the answer sheet. The checkboxes belonging to the same question are arranged in a row or a column at equal intervals, and the checkboxes belonging to multiple questions are arranged in a checkbox array at equal intervals. For example, in order to facilitate the respondent to locate the question number and options on the answer sheet, the question block is usually constructed in the form of a group of 5 objective questions. At this time, the checkboxes contained in the 5 objective questions in the answer sheet image can be regarded as a checkbox array, such as Figure 2 As shown, the selection boxes framed by dotted lines constitute a selection box array.

[0078] According to the position of each selection box, the relative position between the selection boxes can be obtained, so as to determine which selection boxes belong to the same selection box array, divide the selection boxes into units of the selection box array, and thereby determine the first distribution parameters of each selection box array. The first distribution parameters here include both the position of the selection box array in the answer sheet image, such as the position of the selection box in the upper left corner and / or lower right corner of the selection box array in the answer sheet image, and the arrangement information of each selection box inside the selection box array, such as the row and column spacing of the selection boxes, the number of selection boxes in each row and column, the total number of selection boxes, etc.

[0079] Step 130, adjust the first distribution parameter to obtain multiple groups of second distribution parameters, and determine an array score for each group of second distribution parameters, wherein the array score is determined based on the degree of overlap between the virtual marquee area under the corresponding second distribution parameter and the real marquee area of ​​the marquee array.

[0080] Considering that the first distribution parameter obtained in step 120 may deviate from the actual selection box position in the answer sheet image, the first distribution parameter is adjusted in the embodiment of the present invention, thereby obtaining multiple sets of adjusted first distribution parameters, i.e., second distribution parameters. Here, considering that the distribution parameters of the selection box array specifically include multiple parameters, such as the average height and average width of the selection box, the coordinates of the upper left corner of the first selection box in the upper left corner, and the mean of the row and column spacing, when obtaining the second distribution parameter based on the first distribution parameter, each parameter in the first distribution parameter can be adjusted separately, or a combination of multiple parameters in the first distribution parameter can be adjusted, and the embodiment of the present invention does not specifically limit this.

[0081] After obtaining multiple sets of second distribution parameters, the array scores of each set of second distribution parameters can be calculated respectively. The array scores here are used to reflect the degree of overlap between the virtual selection box area in the selection box array corresponding to the second distribution parameters and the real selection box area in the real selection box array in the answer sheet image. The virtual selection box area here is the area occupied by each selection box in the selection box array set according to the second distribution parameters, and the real selection box area is the area occupied by the real selection box in the selection box array of the answer sheet image. The real selection box area can be obtained by performing image rendering, binarization processing and other operations on the answer sheet image. The higher the degree of overlap, the closer the current distribution parameter setting is to the actual situation, and the higher the array score is. The lower the degree of overlap, the greater the difference between the current distribution parameter setting and the actual situation, and the lower the array score is.

[0082] Step 140, determining a third distribution parameter based on the array scores of each group of second distribution parameters, and generating an answer sheet template based on the third distribution parameter.

[0083] Specifically, based on the array scores of each group of second distribution parameters, a group of second distribution parameters with the highest array scores, that is, a group of second distribution parameters that are closest to the actual situation of the selection box area of ​​the answer sheet image, can be screened out from the groups of second distribution parameters as the final distribution parameters, that is, the third distribution parameters, and the answer sheet template is constructed accordingly.

[0084] The method provided by the embodiment of the present invention obtains multiple groups of second distribution parameters by adjusting the first distribution parameters obtained by the selection box detection, and selects the third distribution parameter from the multiple groups of second distribution parameters through the array score that can reflect the difference with the actual situation to generate an answer sheet template. On the basis of realizing the automatic generation of the answer sheet template, it is ensured that the position of each selection box in the answer sheet template can be as close as possible to the actual situation in the answer sheet image, and the automatic and precise positioning of the selection box is realized, which reduces the labor cost and time consumption of generating the answer sheet template.

[0085] Based on the above embodiment, in step 130, adjusting the first distribution parameter to obtain multiple groups of second distribution parameters includes:

[0086] According to the adjustment range and adjustment step of each variable in the preset distribution parameters, each variable in the first distribution parameter is adjusted respectively, and each variable can obtain multiple adjusted values. By arranging and combining the multiple adjusted values ​​of each variable, multiple groups of second distribution parameters can be obtained.

[0087] For example, the variables in the distribution parameters include the average height h and average width w of the selection box, the coordinates (x, y) of the upper left corner of the first selection box in the upper left corner, and the mean values ​​of row and column spacing rowOffset and colOffset. The adjustment range of each parameter is set from -3 to +3, and the adjustment step is set to 1. After completing the adjustment of one variable and obtaining all the values ​​of the variable after adjustment, the next variable is adjusted to achieve the traversal of all the second distribution parameters. For example, the adjustment in the vertical direction can be reflected in the following program:

[0088]

[0089] Among them, a+(b+c)*(line_count-1)+b represents the height of the selection box array corresponding to the current second distribution parameter in the vertical direction. This height should not exceed the image height. Therefore, if this height is greater than the image height, the loop needs to be jumped out.

[0090] Based on any of the above embodiments, in step 130, determining the array score of each group of second distribution parameters includes:

[0091] Determine the array score of each set of second distribution parameters based on the overlap degree between the virtual selection frame area and the real selection frame area under each set of second distribution parameters, and the overlap degree between the virtual spacing area and the real selection frame area under each set of second distribution parameters;

[0092] The virtual spacing area is an area outside the virtual selection frame area in the selection frame array.

[0093] Specifically, in the selection box array, there are intervals between each selection box. Therefore, when examining whether the selection box array depicted by the second distribution parameters is close to the actual situation, we can not only refer to the degree of overlap between the virtual selection box area and the real selection box area under the second distribution parameters, but also refer to the degree of overlap between the virtual interval area and the real selection box area under the second distribution parameters.

[0094] Here, the virtual spacing area is the area occupied by the intervals between the selection boxes in the selection box array set according to the second distribution parameters. It can be understood that, in the area occupied by the mineral processing array set according to the second distribution parameters, the virtual spacing area is the area outside the virtual selection box area.

[0095] In an ideal state, when the arrangement of the marquee array set by the second distribution parameter is completely consistent with the arrangement of the real marquee array, the virtual spacing area should completely overlap with the spacing area in the real marquee array, and the overlap degree between the virtual spacing area and the real marquee area is 0. However, in reality, there is often a difference between the arrangement of the marquee array set by the second distribution parameter and the real marquee array, and the virtual spacing area may cover part of the real marquee area. Therefore, the overlap degree between the virtual spacing area and the real marquee area can also be used as a basis for judging whether the setting of the second distribution parameter is close to the actual situation, and the higher the overlap degree between the virtual spacing area and the real marquee area, the greater the difference between the current distribution parameter setting and the actual situation, and the lower the array score; the lower the overlap degree, the closer the current distribution parameter setting is to the actual situation, and the higher the array score.

[0096] In an embodiment of the present invention, the degree of overlap between the virtual selection box area and the real selection box area, as well as the degree of overlap between the virtual spacing area and the real selection box area, are combined to measure whether the second distribution parameter is close to the actual situation, thereby improving the reliability of the selection of the third distribution parameter and ensuring that the answer sheet template finally generated can fit the actual situation of the answer sheet image as closely as possible.

[0097] Based on any of the above embodiments, Figure 3 is a schematic diagram of the process of calculating the array score provided by the present invention, such as Figure 3 As shown, in step 130, determining the array score of each group of second distribution parameters includes:

[0098] Step 131, determining a row score in the array score of each group of second distribution parameters based on the difference between the intra-row overlap degree and the inter-row overlap degree under each group of second distribution parameters, wherein the intra-row overlap degree is the overlap degree between the row area of ​​the virtual selection frame area and the row area of ​​the real selection frame area, and the inter-row overlap degree is the overlap degree between the row area of ​​the virtual spacing area and the row area of ​​the real selection frame area;

[0099] Step 132, based on the difference between the intra-column overlap degree and the inter-column overlap degree under each group of second distribution parameters, determine the column score in the array score of each group of second distribution parameters, the intra-column overlap degree is the overlap degree between the column area of ​​the virtual selection frame area and the column area of ​​the real selection frame area, and the inter-column overlap degree is the overlap degree between the column area of ​​the virtual spacing area and the column area of ​​the real selection frame area.

[0100] Specifically, when analyzing the degree of overlap between the virtual marquee area and the real marquee area in the marquee array under each group of second distribution parameters, as well as the degree of overlap between the virtual spacing area and the real marquee area, the analysis can be performed separately from the horizontal direction and the vertical direction, that is, from the perspective of the rows and columns of the marquee array.

[0101] For any set of second distribution parameters, from the perspective of the rows of the selection box array, for the virtual selection box area under this set of second distribution parameters, the average height of the selection boxes, the vertical coordinates of each row of selection boxes, the row spacing between each row of selection boxes and other parameters in this set of second distribution parameters can be applied to locate the row area of ​​the virtual selection box area and the row area of ​​the virtual spacing area.

[0102] As for the row area of ​​the real selection box area, the projection histogram of the real selection box area in the horizontal direction can be obtained by horizontally projecting the partial image of the answer sheet image that contains the selection box array. The ordinate in the projection histogram is the position in the vertical direction, and the abscissa is the number of pixels of the selection box area contained in the position in the horizontal direction. In this way, the positioning of the row area in the real selection box area can be achieved.

[0103] After completing the positioning of the row area of ​​the virtual selection box area, the row area of ​​the virtual spacing area, and the row area of ​​the real selection box area, the degree of overlap between the row area of ​​the virtual selection box area and the row area of ​​the real selection box area, that is, the intra-row overlap degree, and the degree of overlap between the row area of ​​the virtual spacing area and the row area of ​​the real selection box area, that is, the inter-row overlap degree, can be calculated.

[0104] Considering that the greater the intra-row overlap, the closer the setting of the second distribution parameter in the horizontal direction is to the actual situation, and the smaller the inter-row overlap, the closer the setting of the second distribution parameter in the horizontal direction is to the actual situation, the intra-row overlap and the inter-row overlap can be subtracted, and the row score can be determined based on the difference between the two to measure whether the setting of the second distribution parameter in the horizontal direction is close to the actual situation. It can be understood that the greater the difference between the intra-row overlap and the inter-row overlap, the higher the row score, and the more realistic the setting of the second distribution parameter in the horizontal direction is.

[0105] Similarly, from the perspective of the columns of the selection box array, for the virtual selection box area under the set of second distribution parameters, the parameters such as the average width of the selection box, the horizontal coordinate of each column of selection boxes, the column spacing between each column of selection boxes in the set of second distribution parameters can be applied to locate the column area of ​​the virtual selection box area and the column area of ​​the virtual spacing area.

[0106] As for the column area of ​​the real selection box area, the projection histogram of the real selection box area in the vertical direction can be obtained by vertically projecting the partial image of the answer sheet image that contains the selection box array. The horizontal axis in the projection histogram is the position in the horizontal direction, and the vertical axis is the number of pixels of the selection box area contained in the position in the vertical direction. In this way, the positioning of the column area in the real selection box area can be achieved.

[0107] After completing the positioning of the column area of ​​the virtual marquee area, the column area of ​​the virtual spacing area, and the column area of ​​the real marquee area, the degree of overlap between the column area of ​​the virtual marquee area and the column area of ​​the real marquee area, that is, the intra-column overlap degree, and the degree of overlap between the column area of ​​the virtual spacing area and the column area of ​​the real marquee area, that is, the inter-column overlap degree, can be calculated.

[0108] Considering that the greater the degree of overlap within a column, the closer the setting of the second distribution parameter in the vertical direction is to the actual situation, and the smaller the degree of overlap between columns, the closer the setting of the second distribution parameter in the vertical direction is to the actual situation, the degree of overlap within a column and the degree of overlap between columns can be subtracted, and the column score can be determined based on the difference between the two to measure whether the setting of the second distribution parameter in the vertical direction is close to the actual situation. It can be understood that the greater the difference between the degree of overlap within a column and the degree of overlap between columns, the higher the column score, and the more realistic the setting of the second distribution parameter in the vertical direction is.

[0109] Thus, a set of row scores of the second distribution parameters in the horizontal direction and column scores in the vertical direction can be obtained. For the second distribution parameters with the highest row scores in each set of second distribution parameters, various parameters in the horizontal direction, such as the average height of the selection box, the vertical coordinate of each row of selection boxes, the row spacing between each row of selection boxes, etc., can be used as parameters in the third distribution parameters for representing the selection box array layout in the horizontal direction; for the second distribution parameters with the highest column scores in each set of second distribution parameters, various parameters in the vertical direction, such as the average width of the selection box, the horizontal coordinate of each column of selection boxes, the column spacing between each column of selection boxes, etc., can be used as parameters in the third distribution parameters for representing the selection box array layout in the vertical direction, thereby obtaining a complete set of third distribution parameters.

[0110] Based on any of the above embodiments, Figure 4 is a flow chart of step 120 in the method for generating an answer sheet template provided by the present invention, such as Figure 4 As shown, step 120 includes:

[0111] Step 121, performing question block detection on the answer sheet image to obtain the question block position of each question block in the answer sheet image.

[0112] Specifically, a question block is an area composed of multiple questions in an answer sheet. In order to facilitate the test taker to locate the question number and options on the answer sheet, a question block is usually constructed in the form of multiple objective questions as a group. In this case, the selection boxes contained in the multiple objective questions in the answer sheet image can be regarded as a selection box array, and the selection box array is contained in the question block. In addition to the selection box array, the question block can also contain the question number corresponding to the selection box array.

[0113] After obtaining the answer sheet image, not only can the option detection be performed on the answer sheet image, but also the question block detection can be performed on the answer sheet image. Here, the question block detection on the answer sheet image can be realized by an image detection model. The image detection model here and the image detection model used for box detection can be the same model or two independent models. The image detection model can be trained using the sample answer sheet image as a training sample and the positions of each question block pre-marked in the sample answer sheet image as labels.

[0114] The position of each question block in the answer sheet image obtained by question block detection is recorded here as the question block position. For any question block, the question block position may include the coordinates of the upper left corner and the lower right corner of the question block in the answer sheet image, and may also include the coordinates of the center of the question block in the answer sheet image and the length and width of the question block. It may also include the coordinates of a vertex of the question block in the answer sheet image and the length and width of the question block. The embodiments of the present invention do not make specific limitations on this.

[0115] Step 122, based on the question block position of each question block and the selection box position of each selection box, determine the question block to which each selection box belongs.

[0116] Specifically, in order to facilitate the determination of the selection box array to which each selection box belongs, the question block to which each selection box belongs can be determined first. For any selection box, based on the selection box position of the selection box and the question block positions of each question block, it can be determined whether the selection box overlaps with each question block. If there is a question block that overlaps with the selection box, the question block is used as the question block to which the selection box belongs; or the overlapping area between the selection box and each question block can be calculated, and the question block with the largest overlapping area can be used as the question block to which the selection box belongs; and in the case where it is not possible to determine the selection box based on whether the selection box overlaps with the question block or the overlapping area between the selection box and the question block, the distance between the selection box and the edge of each question block can be calculated, and the question block with the closest distance can be determined as the question block to which the selection box belongs.

[0117] Step 123: determining the first distribution parameter of the selection box array corresponding to each question block based on the selection box position of each selection box under each question block.

[0118] Specifically, there is a selection box array under a question block, and the selection box array under the question block is composed of all the selection boxes under the question block. For any question block, the first distribution parameter of the selection box array under the question block can be determined based on the selection box positions of all the selection boxes in the question block. For example, the average length and width of all the selection boxes under the question block can be counted as the selection box length and width in the first distribution parameter, the interval distance between adjacent selection boxes under the question block can be counted as the selection box interval in the first distribution parameter, and the upper left corner coordinates of the selection box in the upper left corner can be used as the selection box array vertex coordinates in the first distribution parameter.

[0119] The method provided in the embodiment of the present invention divides the selection box into question blocks to determine the first distribution parameter, which helps to improve the generation efficiency and generation accuracy of the answer sheet template.

[0120] Based on any of the above embodiments, Figure 5 is a flow chart of step 123 in the method for generating an answer sheet template provided by the present invention, such as Figure 5 As shown, step 123 includes:

[0121] Step 1231, based on the selection box positions of each selection box under any question block, performing image rendering and binarization on the question block image of any question block in the answer sheet image to obtain a binarized image of any question block;

[0122] Specifically, for any question block, the question block image of the question block can be located in the answer sheet image through the question block position of the question block. The question block image contains all the boxes under the question block. According to the box positions of the boxes detected, the question block image can be rendered, so that the area of ​​each box in the question block image is colored, so that the area where each box is located can be distinguished from the non-box area. On this basis, the question block image after image rendering is binarized to obtain a binary image of the question block. At this time, the binary image can be Figure 6 In the case shown, the binary image is divided into black and white according to the area where the selection box is located and the area without the selection box.

[0123] Furthermore, in the case where the question block image contains a question number, in order to avoid the question number from affecting image rendering and binarization, the position corresponding to the question number may be whitened in advance.

[0124] Step 1232, performing horizontal projection and vertical projection on the binary image to obtain a horizontal projection histogram and a vertical projection histogram of the binary image;

[0125] Step 1233: Determine the first distribution parameter of the selection box array corresponding to any question block based on the horizontal projection histogram and the vertical projection histogram.

[0126] Specifically, after obtaining the binary image, the binary image can be horizontally projected and vertically projected respectively. The horizontal projection histogram of the binary image can be obtained by the horizontal projection, in which the ordinate is the position in the vertical direction, and the abscissa is the number of pixel points of the selection area contained in the horizontal direction at the position; the vertical projection histogram of the binary image can be obtained by the vertical projection, in which the abscissa is the position in the horizontal direction, and the ordinate is the number of pixel points of the selection area contained in the vertical direction at the position.

[0127] For the horizontal projection histogram, the parameters of the first distribution parameter in the horizontal direction can be determined. For example, by detecting the number of peaks in the horizontal projection histogram, the number of rows of the selection box array in the question block can be determined. By detecting the width occupied by each peak from the start to the end in the horizontal projection histogram, the average height of each row of selection boxes in the question block can be determined. By detecting the width occupied by the end of each peak to the start of the next peak in the horizontal projection histogram, the average interval between every two rows of selection boxes in the question block can be determined.

[0128] For the vertical projection histogram, the parameters of the first distribution parameter in the vertical direction can be determined. For example, by detecting the number of peaks in the vertical projection histogram, the number of columns of the selection box array in the question block can be determined. By detecting the width occupied by each peak from the start to the end in the vertical projection histogram, the average width of each column of selection boxes in the question block can be determined. By detecting the width occupied by the end of each peak to the start of the next peak in the vertical projection histogram, the average interval between every two columns of selection boxes in the question block can be determined.

[0129] In this process, the detection of the start or end position of the peak in the horizontal projection histogram or the vertical projection histogram can be achieved by comparing the number of pixel points in the selection box area of each row and column with a pre-set threshold. For example, when detecting the peak in the horizontal projection histogram, a hysteresis comparator can be set, including thresholds th1 and th2, where th1 > th2. If the number of pixel points in the selection box area of a row, that is, the projection length Li of a row > th1, it indicates the start of the peak, and the ordinate of this row is recorded as y1. If the projection length of each subsequent row > th2, it indicates that each row is still in the peak until a row with a projection length < th2 appears, at which point the peak of this row ends, and the ordinate of this row is recorded as y2. The width of the selection box row corresponding to this peak, that is, the row height h = y2 - y1. According to this method, the number of peaks that appear in the binary image, that is, the total number of rows of the selection box array, can be determined.

[0130] Based on any of the above embodiments, Figure 7 is a schematic flowchart of the method for determining the arrangement method of questions provided by the present invention. As Figure 7 shown, after step 121, it further includes:

[0131] Step 124, based on the question block positions of the respective question blocks and the question number positions of the respective question numbers in the answer sheet image, determine the question blocks to which the respective question numbers belong.

[0132] Specifically, after obtaining the answer sheet image, not only can the answer sheet image be subjected to option detection and question block detection, but also the question number detection can be performed on the answer sheet image. Here, the question number detection on the answer sheet image can be realized by an image detection model. The image detection model here can be the same model as the image detection model used for selection box detection or question block detection, or can be two independent models. The image detection model can be trained using the sample answer sheet image as a training sample and the positions of the pre-marked question numbers in the sample answer sheet image as labels.

[0133] The position of each question number in the answer sheet image obtained by question number detection is recorded as the question number position here. For any question number, the question number position may include the coordinates of the upper left corner and the lower right corner of the question number in the answer sheet image, and may also include the coordinates of the center of the question number in the answer sheet image and the length and width of the area where the question number is located. It may also include the coordinates of a vertex of the question number in the answer sheet image and the length and width of the question number. The embodiments of the present invention do not make specific limitations on this.

[0134] In order to analyze the arrangement of the boxes of multiple questions in a question block, such as horizontal or vertical arrangement, the question block to which each question number belongs can be determined first. For any question number, based on the question number position of the question number and the question block position of each question block, it can be determined whether the question number overlaps with each question block. If there is a question block that overlaps with the question number, the question block will be regarded as the question block to which the question number belongs; or the overlapping area between the question number and each question block can be calculated, and the question block with the largest overlapping area can be regarded as the question block to which the question number belongs; it is also possible to calculate the distance between the question number and the edge of each question block when it is not possible to determine the question number based on whether the question number overlaps with the question block or the overlapping area between the question number and the question block, and determine the question block with the closest distance as the question block to which the question number belongs.

[0135] Step 125, based on the position of each question number under each question block, determine the arrangement of the questions in each question block.

[0136] Specifically, after obtaining the relationship between each question number and question block, the arrangement of each question number in each question block can be analyzed according to the position of each question number in each question block, so as to determine the arrangement of questions in each question block.

[0137] For any question block, the question number positions of all question numbers under the question block can be obtained, and the arrangement of all question numbers can be analyzed based on this. Specifically, the center position of the area where each question number is located can be determined based on the question number positions of all question numbers, and the distribution discreteness of each center position in the horizontal and vertical directions can be calculated:

[0138] If the distribution dispersion of each center position in the horizontal direction is much smaller than the distribution dispersion of each center position in the vertical direction, it can be explained that the ordinate of the center position of each question number is closer than the abscissa, the question numbers in the question block are arranged horizontally, and the question arrangement of the question block is vertical; if the distribution dispersion of each center position in the horizontal direction is much larger than the distribution dispersion of each center position in the vertical direction, it can be explained that the abscissa of the center position of each question number is closer than the total coordinate, the question numbers in the question block are arranged vertically, and the question arrangement of the question block is horizontal. Here, the distribution dispersion can be variance, standard deviation, etc., and the embodiment of the present invention does not specifically limit this.

[0139] For example, suppose that the coordinates of the question numbers in a question block are (10, 10), (10, 20), (10, 30), (10, 40), (10, 50), and their vertical degree of dispersion, that is, the mean square error of the horizontal coordinate, is D=0, and their horizontal degree of dispersion, that is, the mean square error of the vertical coordinate, is D=200. At this time, the question numbers are arranged vertically, and the questions in the question block are arranged horizontally; suppose that the coordinates of the question numbers in a question block are (10, 10), (20, 10), (30, 10), (40, 10), (50, 10), and their vertical degree of dispersion, that is, the mean square error of the horizontal coordinate, is D=200, and their horizontal degree of dispersion, that is, the mean square error of the vertical coordinate, is D=0. At this time, the question numbers are arranged horizontally, and the questions in the question block are arranged vertically.

[0140] Based on any of the above embodiments, Figure 8 is a flow chart of step 140 in the method for generating an answer sheet template provided by the present invention, such as Figure 8 As shown, step 140 includes:

[0141] Step 141, based on the third distribution parameter, determine the selection box inspection area of ​​the answer sheet image, perform text recognition on the selection box inspection area, and obtain a text recognition result.

[0142] Specifically, in order to further improve the reliability of answer sheet template generation, the third distribution parameter can be verified, and specifically, the selection box area planned under the third distribution parameter in the answer sheet image can be located, that is, the area to be tested below, which is recorded as the selection box test area. Considering that under normal circumstances, the selection box in the answer sheet image is marked with option letters to prompt the respondent which option in the question the selection box represents, text recognition can be performed on the selection box test area to obtain the text recognition result contained in the selection box test area.

[0143] Furthermore, for performing text recognition on the selection box inspection area, each selection box area planned under the third distribution parameter may be separately intercepted to perform text recognition, thereby obtaining a text recognition result corresponding one-to-one to each selection box area planned under the third distribution parameter, or each row of selection box areas planned under the third distribution parameter may be separately intercepted to perform text row recognition, thereby obtaining a text recognition result corresponding one-to-one to each row of selection box areas planned under the third distribution parameter.

[0144] Step 142: Determine template verification information of the answer sheet image based on the text recognition result.

[0145] Here, the template verification information is used to characterize the information for verifying whether the third distribution parameter fits the answer sheet image. For the text recognition results corresponding to a row of selection box areas planned under the third distribution parameter, it is possible to determine whether the question arrangement of the corresponding question block is horizontal or vertical based on whether the letters in the row of text recognition results are the same. For example, if the letters are the same, the question arrangement is vertical; if the letters are different, the question arrangement is horizontal.

[0146] The text recognition results can also be sorted according to the alphabet, and the maximum number of options in the question block can be determined by determining the last letter in the text recognition results. In addition, the number of questions in the question block can be determined based on the number of times the same letter appears in the text recognition results, such as the number of times option A appears.

[0147] One or more of the above question arrangement, number of options, and number of questions may be included in the template verification information.

[0148] Step 143: Determine fourth distribution parameters based on the template verification information and the third distribution parameters.

[0149] Step 144: Generate the answer sheet template based on the fourth distribution parameter.

[0150] Specifically, after obtaining the template verification information, it can be determined whether the template verification information and the information reflected by the third distribution parameter itself are consistent, so as to determine whether the third distribution parameter may not match the actual situation of the answer sheet image.

[0151] If the template verification information is consistent with the information reflected by the third distribution parameter itself, it can be determined that the third distribution parameter does not have the problem of not fitting the actual situation of the answer sheet image, and the third distribution parameter can be directly used as the fourth distribution parameter to generate the answer sheet template. If the template verification information is inconsistent with the information reflected by the third distribution parameter itself, an alarm message can be generated to prompt the user to confirm, and the third distribution parameter can be adjusted based on the information confirmed by the user to obtain the fourth distribution parameter that can be used to generate the answer sheet template. It can also be combined with the template verification information and the information reflected by the third distribution parameter itself for further inspection and confirmation, and the third distribution parameter can be adjusted based on the information confirmed by the inspection and confirmation to obtain the fourth distribution parameter that can be used to generate the answer sheet template.

[0152] For example, if the arrangement of questions in the template verification information is different from the arrangement of questions determined in the previous step, an alarm message can be returned to prompt the user to confirm; for another example, if the number of questions or the number of options in the template verification information is different from the number of questions or the number of options reflected by the third distribution parameter, an alarm message can be returned to prompt the user to confirm

[0153] On this basis, the answer sheet template is generated based on the adjusted and verified fourth distribution parameters, which can further improve the reliability of the answer sheet template.

[0154] Based on any of the above embodiments, Fig. 9 is a flow chart of step 143 in the method for generating an answer sheet template provided by the present invention, such as Fig. 9 As shown, step 143 includes:

[0155] Step 1431, if the number of options in the template verification information is different from the number of options indicated by the third distribution parameter, determining a reference selection box area and an error selection box area based on the template verification information and the third distribution parameter;

[0156] Step 1432, determining the number of verification options based on the pixel ratio of the reference selection box area and the pixel ratio of the error selection box area;

[0157] Step 1433: Determine the fourth distribution parameter based on the number of verification options and the third distribution parameter.

[0158] Specifically, in the case where the number of options in the template verification information is different from the number of options indicated by the third distribution parameter, the smaller number of options between the two can be considered as the number of options that have been confirmed to exist, and the difference between the two can be considered as the number of options that may exist, based on which the reference selection box area and the error selection box area can be located.

[0159] The reference marquee area is the marquee area corresponding to the options that have been determined to exist, and the error marquee area is the marquee area corresponding to the options that may exist. For example, if the number of options in the template verification information and the number of options indicated by the third distribution parameter are 3 and 4 respectively, the marquee areas corresponding to the first 3 options can be determined as the reference marquee area, and the marquee area corresponding to the 4th option can be determined as the error marquee area.

[0160] On this basis, the pixel ratio of the reference marquee area and the pixel ratio of the error marquee area can be counted respectively. Considering that the marquee in the answer sheet image is usually reflected as a black border on a white background, and the black border contains black letters, the pixel ratio can be the ratio of black pixels in the corresponding marquee area to all pixels in the marquee area. In the case that it has been determined that there must be a marquee in the reference marquee area, the pixel ratio of the reference marquee area can reflect the general situation of the pixel ratio of the real marquee area. If the pixel ratio of the error marquee area is close to that of the reference marquee area, it can be determined that there must be a marquee in the error marquee area. If the pixel ratio of the error marquee area is much smaller than that of the reference marquee area, it can be determined that there is no marquee in the error marquee area. Based on this, the real number of options, that is, the number of verification options, can be determined. For example, when the selection box areas corresponding to the first three options are determined as the reference selection box areas, and the selection box area corresponding to the fourth option is determined as the error selection box area, if the pixel ratio of the fourth option is much smaller than the pixel ratio of the first three options, for example, less than 1 / 3 of the pixel ratio of the first three options, then it is determined that the fourth option does not exist, and the number of verification options is 3. For another example, if the pixel ratio of the fourth option is close to the pixel ratio of the first three options, then it is determined that the fourth option exists, and the number of verification options is 4.

[0161] After obtaining the number of verification options, it is necessary to determine whether the number of verification options is consistent with the number of options indicated by the third distribution parameter. If they are consistent, the third distribution parameter can be used as the fourth distribution parameter. If they are inconsistent, the third distribution parameter needs to be adjusted to obtain the fourth distribution parameter. For example, if the number of verification options exceeds the number of options indicated by the third distribution parameter, it is necessary to expand the options outwards based on the third distribution parameter. For another example, if the number of verification options is less than the number of options indicated by the third distribution parameter, it is necessary to delete the options inwards based on the third distribution parameter.

[0162] Based on any of the above embodiments, a method for generating an answer sheet template includes the following steps:

[0163] First, obtain the answer sheet image, which can be obtained by scanning. For the answer sheet image, preprocessing can be performed before image detection. The preprocessing operation here can be to first calculate the size of the long side of the answer sheet image, maintain the aspect ratio by pixel, scale the long side of the answer sheet image to a preset number of pixels, and record the scaling ratio r_resize. The preset number here can be 1024 or other values. After the scaling is completed, the answer sheet image is normalized, dst = (src-128.0) / 128.0, where src and dst are the pixel values ​​before and after normalization, respectively, so that an image with a value range of -1 to 1 can be obtained.

[0164] Secondly, image detection is performed on the preprocessed answer sheet image. Specifically, the answer sheet image can be input into a pre-trained image detection model. The output of the image detection model can include the selection box position, question number position, and question block position. The obtained selection box position, question number position, and question block position can be scaled to the original size according to the same ratio r_resize, thereby obtaining the selection box position of each selection box, the question number position of each question number, and the question block position of each question block in the answer sheet image.

[0165] The detected selection boxes and question numbers are classified separately so that each selection box and question number can correspond to the corresponding question block. Specifically, the overlapping area between each selection box / question number and all question blocks can be calculated, and the question block with the largest overlapping area can be used as the question block to which the selection box / question number belongs. If the selection box / question number cannot be determined based on the overlapping area between the selection box / question number and the question block, the distance between the selection box / question number and the edge of each question block can be calculated, and the question block with the closest distance can be determined as the question block to which the selection box / question number belongs. Thus, a set is formed, that is, an answer sheet image contains multiple question blocks, and each question block contains the corresponding question number and selection box. When calculating the parameters next, each question block is calculated separately.

[0166] For any question block, the question number positions of all question numbers under the question block can be obtained, the center position of the area where each question number is located can be determined, and the distribution discreteness of each center position in the horizontal and vertical directions can be calculated. If the distribution discreteness of each center position in the horizontal direction is much smaller than the distribution discreteness of each center position in the vertical direction, the question numbers in the question block are arranged horizontally, and the questions in the question block are arranged vertically; if the distribution discreteness of each center position in the horizontal direction is much larger than the distribution discreteness of each center position in the vertical direction, the question numbers in the question block are arranged vertically, and the questions in the question block are arranged horizontally.

[0167] For any question block, all the selection boxes in the question block can be rendered and binarized, and the resulting binarized image can be horizontally projected, and the horizontal projection histogram can be applied to determine the parameters of the first distribution parameter in the horizontal direction; the binarized image can be vertically projected, and the vertical projection histogram can be applied to determine the parameters of the first distribution parameter in the vertical direction.

[0168] After obtaining the first distribution parameter of any question block, the situation of the real selection box area of ​​the question block in the horizontal direction can be determined according to the horizontal projection histogram of the binary image of the question block, and multiple groups of second distribution parameters can be obtained by fine-tuning the parameters of the first distribution parameters in the horizontal direction. According to the situation of the virtual selection box area in the horizontal direction under the settings of the multiple groups of second distribution parameters, the overlap degree between the row area of ​​the virtual selection box area and the row area of ​​the real selection box area under each group of second distribution parameters, and the overlap degree between the row area of ​​the virtual spacing area and the row area of ​​the real selection box area are calculated, and the row score of each group of second distribution parameters is determined based on the difference between the two. The third distribution parameter is determined based on the second distribution parameter with the highest row score. The method comprises the steps of: determining a parameter of a real selection box area of ​​the question block in the vertical direction according to a vertical projection histogram of the binary image of the question block, and obtaining a plurality of groups of second distribution parameters by fine-tuning the parameters of the first distribution parameters in the vertical direction, and calculating a degree of overlap between the column area of ​​the virtual selection box area and the column area of ​​the real selection box area under each group of second distribution parameters, as well as a degree of overlap between the column area of ​​the virtual spacing area and the column area of ​​the real selection box area according to the conditions of the virtual selection box area in the vertical direction under the settings of the plurality of second distribution parameters, and determining a column score of each group of second distribution parameters based on the difference between the two, and determining a parameter of the third distribution parameter in the vertical direction based on the second distribution parameter with the highest column score.

[0169] In order to further improve the reliability of answer sheet template generation, the third distribution parameter can be verified, and the selection box area of ​​each row planned under the third distribution parameter can be intercepted to perform text line recognition, so as to obtain a text recognition result that corresponds to the selection box area of ​​each row planned under the third distribution parameter. For the text recognition result, if the entire row is the same letter, the question number is horizontal, and if the entire row contains multiple different letters, the question number is vertical. Sort the recognition results of all rows by alphabet, record the largest letter, and thus determine the maximum number of options. It is divided into the following cases:

[0170] A. If the previous step fails to determine the question arrangement, the question arrangement determined in this step will be used. If the previous step has determined the question arrangement and it is inconsistent with the question arrangement determined in this step, an error will be returned.

[0171] B. If the number of questions determined in the previous step is inconsistent with the number of questions determined in this step, the number of questions determined in the previous step will be used, and an alarm message will be returned to prompt the user for further confirmation.

[0172] C. If the number of options determined in the previous step is inconsistent with the number of options determined in this step, the number of options determined in the previous step is used, and an alarm message is returned to prompt the user to further confirm. Consider the exception of the judgment question (options are T / F), the maximum letter is T / F, and the number of options determined in the previous step is 2, which is considered consistent.

[0173] In addition, further checks can be performed for situations where the number of options determined in the previous step is inconsistent with the number of options determined in this step. Specifically, the information that the intervals between adjacent question blocks are mostly large blank spaces can be used for further judgment. There are two situations. In the first situation, the number of options detected in the previous step is greater than the number of options determined in this step. For example, 4 columns are detected in the previous step, but only the largest letter C is detected in the text recognition result of this step, and the letter D cannot be recognized. It is necessary to count the proportion of black pixels in the 4th column and the first 3 columns based on the column information. If the proportion of black pixels in the fourth column does not exceed 1 / 3 of the average proportion of black pixels in the first three columns, it means that it is quite different from the previous columns. Select the 3 items detected in this step as the final result, and delete the selection box information in the last column. Otherwise, the number of option columns is determined to be 4. In the second case, the number of options detected in the previous step is less than the number of options determined in this step. For example, 4 columns are detected in the previous step, but the largest letter detected in the text recognition result of this step is E. Use the same method, keep the same column spacing, expand one column to the right, calculate and compare the average black pixel ratio to determine whether it is 5 columns or 4 columns.

[0174] The method provided in the embodiment of the present invention obtains multiple groups of second distribution parameters by adjusting the first distribution parameters obtained by the selection box detection, and selects the third distribution parameter from the multiple groups of second distribution parameters through the array score that can reflect the gap with the actual situation to generate the answer sheet template. On the basis of realizing the automatic generation of the answer sheet template, it ensures that the position of each selection box in the answer sheet template can fit the actual situation in the answer sheet image as much as possible, realizes the automatic and precise positioning of the selection box, and reduces the manpower cost and time consumption of the generation of the answer sheet template. In addition, the embodiment of the present invention adds a detection and verification scheme, and returns a corresponding alarm message for the situation that the system cannot determine, thereby ensuring the reliability of the answer sheet template generated in the end.

[0175] Based on any of the above embodiments, Fig.10 : is a flow chart of the answer sheet recognition method provided by the present invention, such as Fig.10 As shown, the method includes:

[0176] Step 1010, obtaining a response image to be recognized;

[0177] Step 1020: performing answer recognition on the answer image based on an answer sheet template, wherein the answer sheet template is determined based on an answer sheet template generation method.

[0178] Specifically, in the actual application stage, an answer image that needs to be recognized by the answer sheet can be obtained. The answer image here is the image of the answer sheet after the respondent completes the answer. The answer image can be obtained by taking a picture with a camera or by scanning. The embodiment of the present invention does not specifically limit this.

[0179] The answer sheet template can be automatically generated according to the above-mentioned embodiments, which includes the positioning of the selection box of each question in the answer sheet. By applying the answer sheet template, the selection box of each question in the answer image can be positioned, so as to determine the specific selected options for each question in the answer image, thereby realizing answer recognition. On this basis, the answer image can be automatically marked and scored based on the recognized answers and the pre-set standard answers.

[0180] The method provided by the embodiment of the present invention uses the automatically generated answer sheet template to perform answer sheet recognition, thereby effectively ensuring the reliability of answer sheet recognition.

[0181] Based on any of the above embodiments, Fig.11 Schematic diagram of the structure of the answer sheet template generating device provided by the present invention. Fig.11 As shown, the answer sheet template generating device comprises:

[0182] A selection box detection unit 1110 is used to perform selection box detection on the answer sheet image to be modeled, and obtain the selection box position of each selection box in the answer sheet image;

[0183] A parameter determination unit 1120, configured to determine, based on the position of each selection box, a first distribution parameter of a selection box array to which each selection box belongs;

[0184] a parameter adjustment unit 1130, configured to adjust the first distribution parameter to obtain multiple groups of second distribution parameters, and determine an array score for each group of second distribution parameters, wherein the array score is determined based on a degree of overlap between a virtual marquee area corresponding to the second distribution parameter and a real marquee area of ​​the marquee array;

[0185] The template generating unit 1140 is used to determine the third distribution parameter based on the array scores of the groups of second distribution parameters, and generate an answer sheet template based on the third distribution parameter.

[0186] The device provided by the embodiment of the present invention obtains multiple groups of second distribution parameters by adjusting the first distribution parameters obtained by the selection box detection, and selects the third distribution parameter from the multiple groups of second distribution parameters to generate an answer sheet template through the array score that can reflect the difference between the actual situation. On the basis of realizing the automatic generation of the answer sheet template, it is ensured that the position of each selection box in the answer sheet template can fit the actual situation in the answer sheet image as much as possible, and the automatic and precise positioning of the selection box is realized, which reduces the labor cost and time consumption of generating the answer sheet template.

[0187] Based on any of the above embodiments, the parameter adjustment unit 1130 includes a score calculation unit, which is used to:

[0188] Determine the array score of each set of second distribution parameters based on the overlap degree between the virtual selection frame area and the real selection frame area under each set of second distribution parameters, and the overlap degree between the virtual spacing area and the real selection frame area under each set of second distribution parameters;

[0189] The virtual spacing area is an area outside the virtual selection frame area in the selection frame array.

[0190] Based on any of the above embodiments, the score calculation unit is specifically used for:

[0191] Determining the row score in the array score of each group of second distribution parameters based on the difference between the intra-row overlap degree and the inter-row overlap degree under each group of second distribution parameters, wherein the intra-row overlap degree is the overlap degree between the row area of ​​the virtual selection frame area and the row area of ​​the real selection frame area, and the inter-row overlap degree is the overlap degree between the row area of ​​the virtual spacing area and the row area of ​​the real selection frame area;

[0192] Based on the difference between the intra-column overlap degree and the inter-column overlap degree under each group of second distribution parameters, the column score in the array score of each group of second distribution parameters is determined, the intra-column overlap degree is the overlap degree between the column area of ​​the virtual selection frame area and the column area of ​​the real selection frame area, and the inter-column overlap degree is the overlap degree between the column area of ​​the virtual spacing area and the column area of ​​the real selection frame area.

[0193] Based on any of the foregoing embodiments, the parameter determination unit 1120 is configured to:

[0194] Performing question block detection on the answer sheet image to obtain the question block position of each question block in the answer sheet image;

[0195] Based on the position of each question block and the position of each selection box, determining the question block to which each selection box belongs;

[0196] Based on the selection box position of each selection box under each question block, a first distribution parameter of the selection box array corresponding to each question block is determined.

[0197] Based on any of the foregoing embodiments, the parameter determination unit 1120 is configured to:

[0198] Based on the selection box positions of each selection box under any question block, image rendering and binarization are performed on the question block image of any question block in the answer sheet image to obtain a binarized image of any question block;

[0199] Performing horizontal projection and vertical projection on the binary image to obtain a horizontal projection histogram and a vertical projection histogram of the binary image;

[0200] Based on the horizontal projection histogram and the vertical projection histogram, a first distribution parameter of the selection box array corresponding to any one of the question blocks is determined.

[0201] Based on any of the foregoing embodiments, the parameter determination unit 1120 is configured to:

[0202] Based on the question block position of each question block and the question number position of each question number in the answer sheet image, determining the question block to which each question number belongs;

[0203] Based on the position of each question number under each question block, the arrangement of the questions in each question block is determined.

[0204] Based on any of the above embodiments, the template generating unit 1140 is used to:

[0205] Based on the third distribution parameter, determine a selection box inspection area of ​​the answer sheet image, perform text recognition on the selection box inspection area, and obtain a text recognition result;

[0206] Based on the text recognition result, determining template verification information of the answer sheet image;

[0207] Determining a fourth distribution parameter based on the template verification information and the third distribution parameter;

[0208] Based on the fourth distribution parameter, the answer sheet template is generated.

[0209] Based on any of the above embodiments, the template generating unit 1140 is used to:

[0210] If the number of options in the template verification information is different from the number of options indicated by the third distribution parameter, determining a reference selection box area and an error selection box area based on the template verification information and the third distribution parameter;

[0211] Determining the number of verification options based on the pixel ratio of the reference selection box area and the pixel ratio of the error selection box area;

[0212] The fourth distribution parameter is determined based on the number of verification options and the third distribution parameter.

[0213] Based on any of the above embodiments, Fig.12 Schematic diagram of the structure of the answer sheet recognition device provided by the present invention. Fig.12 As shown, the answer sheet recognition device includes:

[0214] An image determination unit 1210, configured to obtain a response image to be identified;

[0215] The answer recognition unit 1220 is used to perform answer recognition on the answer image based on an answer sheet template, and the answer sheet template is determined based on an answer sheet template generation method.

[0216] The device provided by the embodiment of the present invention uses the automatically generated answer sheet template to perform answer sheet recognition, thereby effectively ensuring the reliability of answer sheet recognition.

[0217] Fig.13 An example of a physical structure diagram of an electronic device is shown in FIG. Fig.13 As shown, the electronic device may include: a processor 1310, a communication interface 1320, a memory 1330 and a communication bus 1340, wherein the processor 1310, the communication interface 1320 and the memory 1330 communicate with each other through the communication bus 1340. The processor 1310 may call the logic instructions in the memory 1330 to execute the answer sheet template generation method, which includes:

[0218] Performing box detection on the answer sheet image to be modeled to obtain the box positions of each box in the answer sheet image;

[0219] Determining, based on the selection frame positions of the selection frames, first distribution parameters of the selection frame arrays to which the selection frames belong;

[0220] Adjusting the first distribution parameter to obtain multiple groups of second distribution parameters, and determining an array score for each group of second distribution parameters, wherein the array score is determined based on a degree of overlap between a virtual marquee area corresponding to the second distribution parameter and a real marquee area of ​​the marquee array;

[0221] Based on the array scores of the groups of second distribution parameters, a third distribution parameter is determined, and based on the third distribution parameter, an answer sheet template is generated.

[0222] The processor 1310 may also call the logic instructions in the memory 1330 to execute the answer sheet recognition method, which includes:

[0223] Obtaining a response image to be recognized;

[0224] Based on the answer sheet template, answer recognition is performed on the answer image, and the answer sheet template is determined based on the answer sheet template generation method.

[0225] In addition, the logic instructions in the above-mentioned memory 1330 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a 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, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0226] On the other hand, the present invention further 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, when the program instructions are executed by a computer, the computer can execute the answer sheet template generation method provided by the above methods, the method comprising:

[0227] Performing box detection on the answer sheet image to be modeled to obtain the box positions of each box in the answer sheet image;

[0228] Determining, based on the selection frame positions of the selection frames, first distribution parameters of the selection frame arrays to which the selection frames belong;

[0229] Adjusting the first distribution parameter to obtain multiple groups of second distribution parameters, and determining an array score for each group of second distribution parameters, wherein the array score is determined based on a degree of overlap between a virtual marquee area corresponding to the second distribution parameter and a real marquee area of ​​the marquee array;

[0230] Based on the array scores of the groups of second distribution parameters, a third distribution parameter is determined, and based on the third distribution parameter, an answer sheet template is generated.

[0231] When the program instructions are executed by a computer, the computer can also execute the answer sheet recognition method provided by the above methods, which method includes:

[0232] Obtaining a response image to be recognized;

[0233] Based on the answer sheet template, answer recognition is performed on the answer image, and the answer sheet template is determined based on the answer sheet template generation method.

[0234] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to perform the above-mentioned answer sheet template generation method, the method comprising:

[0235] Performing box detection on the answer sheet image to be modeled to obtain the box positions of each box in the answer sheet image;

[0236] Determining, based on the selection frame positions of the selection frames, first distribution parameters of the selection frame arrays to which the selection frames belong;

[0237] Adjusting the first distribution parameter to obtain multiple groups of second distribution parameters, and determining an array score for each group of second distribution parameters, wherein the array score is determined based on a degree of overlap between a virtual marquee area corresponding to the second distribution parameter and a real marquee area of ​​the marquee array;

[0238] Based on the array scores of the groups of second distribution parameters, a third distribution parameter is determined, and based on the third distribution parameter, an answer sheet template is generated.

[0239] The computer program can also be implemented by the processor to perform the above-mentioned answer sheet recognition method, which includes:

[0240] Obtaining a response image to be recognized;

[0241] Based on the answer sheet template, answer recognition is performed on the answer image, and the answer sheet template is determined based on the answer sheet template generation method.

[0242] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0243] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0244] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for generating an answer sheet template, characterized in that: include: Performing box detection on the answer sheet image to be modeled to obtain the box positions of each box in the answer sheet image; Determining, based on the selection frame positions of the selection frames, first distribution parameters of the selection frame arrays to which the selection frames belong; Adjusting the first distribution parameter to obtain multiple groups of second distribution parameters, and determining an array score for each group of second distribution parameters, wherein the array score is determined based on a degree of overlap between a virtual marquee area corresponding to the second distribution parameter and a real marquee area of ​​the marquee array; Determining a third distribution parameter based on the array scores of each group of second distribution parameters, and generating an answer sheet template based on the third distribution parameter; The step of generating an answer sheet template based on the third distribution parameter comprises: Based on the third distribution parameter, determine a selection box inspection area of ​​the answer sheet image, perform text recognition on the selection box inspection area, and obtain a text recognition result; Based on the text recognition result, determine the template verification information of the answer sheet image, the template verification information including at least one of the question arrangement, the number of options, and the number of questions; Determining whether the template verification information is consistent with information embodied by the third distribution parameter to determine whether to adjust the third distribution parameter to obtain a fourth distribution parameter; Based on the fourth distribution parameter, the answer sheet template is generated.

2. The method for generating an answer sheet template according to claim 1, characterized in that: Determining the array score of each group of second distribution parameters comprises: Determine the array score of each set of second distribution parameters based on the overlap degree between the virtual selection frame area and the real selection frame area under each set of second distribution parameters, and the overlap degree between the virtual spacing area and the real selection frame area under each set of second distribution parameters; The virtual spacing area is an area outside the virtual selection frame area in the selection frame array.

3. The method for generating an answer sheet template according to claim 2, characterized in that: The determining of the array score of each group of second distribution parameters based on the overlap degree between the virtual selection frame area and the real selection frame area under each group of second distribution parameters, and the overlap degree between the virtual spacing area and the real selection frame area under each group of second distribution parameters, comprises: Determining the row score in the array score of each group of second distribution parameters based on the difference between the intra-row overlap degree and the inter-row overlap degree under each group of second distribution parameters, wherein the intra-row overlap degree is the overlap degree between the row area of ​​the virtual selection frame area and the row area of ​​the real selection frame area, and the inter-row overlap degree is the overlap degree between the row area of ​​the virtual spacing area and the row area of ​​the real selection frame area; Based on the difference between the intra-column overlap degree and the inter-column overlap degree under each group of second distribution parameters, the column score in the array score of each group of second distribution parameters is determined, the intra-column overlap degree is the overlap degree between the column area of ​​the virtual selection frame area and the column area of ​​the real selection frame area, and the inter-column overlap degree is the overlap degree between the column area of ​​the virtual spacing area and the column area of ​​the real selection frame area.

4. The method for generating an answer sheet template according to any one of claims 1 to 3, characterized in that: The determining, based on the selection frame positions of the selection frames, first distribution parameters of the selection frame array to which the selection frames belong includes: Performing question block detection on the answer sheet image to obtain the question block position of each question block in the answer sheet image; Based on the position of each question block and the position of each selection box, determining the question block to which each selection box belongs; Based on the selection box position of each selection box under each question block, a first distribution parameter of the selection box array corresponding to each question block is determined.

5. The method for generating an answer sheet template according to claim 4, characterized in that: The determining of the first distribution parameter of the selection box array corresponding to each question block based on the selection box position of each selection box under each question block includes: Based on the selection box positions of each selection box under any question block, image rendering and binarization are performed on the question block image of any question block in the answer sheet image to obtain a binarized image of any question block; Performing horizontal projection and vertical projection on the binary image to obtain a horizontal projection histogram and a vertical projection histogram of the binary image; Based on the horizontal projection histogram and the vertical projection histogram, a first distribution parameter of the selection box array corresponding to any one of the question blocks is determined.

6. The method for generating an answer sheet template according to claim 4, characterized in that: The step of performing question block detection on the answer sheet image to obtain the question block position of each question block in the answer sheet image further includes: Based on the question block position of each question block and the question number position of each question number in the answer sheet image, determining the question block to which each question number belongs; Based on the position of each question number under each question block, the arrangement of the questions in each question block is determined.

7. The method for generating an answer sheet template according to claim 1, characterized in that: The determining whether the information represented by the template verification information is consistent with the information represented by the third distribution parameter to determine whether to adjust the third distribution parameter to obtain the fourth distribution parameter includes: If the number of options in the template verification information is different from the number of options indicated by the third distribution parameter, determining a reference selection box area and an error selection box area based on the template verification information and the third distribution parameter; Determining the number of verification options based on the pixel ratio of the reference selection box area and the pixel ratio of the error selection box area; The fourth distribution parameter is determined based on the number of verification options and the third distribution parameter.

8. A method for answer sheet recognition, characterized in that: Obtaining a response image to be recognized; The answer recognition is performed on the answer image based on an answer sheet template, wherein the answer sheet template is determined based on the answer sheet template generation method according to any one of claims 1 to 7.

9. A device for generating an answer sheet template, characterized in that: include: A selection box detection unit, used to perform selection box detection on the answer sheet image to be modeled, and obtain the selection box position of each selection box in the answer sheet image; A parameter determination unit, configured to determine, based on the selection frame position of each selection frame, a first distribution parameter of a selection frame array to which each selection frame belongs; a parameter adjustment unit, configured to adjust the first distribution parameter to obtain multiple groups of second distribution parameters, and determine an array score for each group of second distribution parameters, wherein the array score is determined based on a degree of overlap between a virtual marquee area corresponding to the second distribution parameter and a real marquee area of ​​the marquee array; A template generating unit, configured to determine a third distribution parameter based on the array scores of the groups of second distribution parameters, and to generate an answer sheet template based on the third distribution parameter; The template generation unit is specifically used for: Based on the third distribution parameter, determine a selection box inspection area of ​​the answer sheet image, perform text recognition on the selection box inspection area, and obtain a text recognition result; Based on the text recognition result, determine the template verification information of the answer sheet image, the template verification information including at least one of the question arrangement, the number of options, and the number of questions; Determining whether the template verification information is consistent with information embodied by the third distribution parameter to determine whether to adjust the third distribution parameter to obtain a fourth distribution parameter; Based on the fourth distribution parameter, the answer sheet template is generated.

10. An answer sheet recognition device, characterized in that: include: An image determination unit, used for acquiring a response image to be identified; An answer recognition unit is used to recognize the answer to the answer image based on an answer sheet template, wherein the answer sheet template is determined based on the answer sheet template generation method according to any one of claims 1 to 7.

11. 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 program, it implements the steps of the answer sheet template generation method according to any one of claims 1 to 7, or the answer sheet recognition method according to claim 8.

12. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the answer sheet template generation method according to any one of claims 1 to 7 or the answer sheet recognition method according to claim 8 are implemented.

Citation Information

Patent Citations

  • Answer sheet template generation method, answer sheet template identification method, answer sheet template generation device, answer sheet template identification device and storage medium

    CN111046644A