Answer sheet option positioning method and device, electronic equipment and storage medium

By dividing the answer sheet image into selection boxes in two vertical directions, determining the target gradient using the change in the number of foreground pixels, and combining the maximum gradient and clustering algorithms to correct the position, the problem of inaccurate answer sheet option positioning was solved, thus improving the accuracy of online marking.

CN115909341BActive Publication Date: 2026-06-05IFLYTEK CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
IFLYTEK CO LTD
Filing Date
2022-12-28
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

In existing technologies, the accuracy of online marking is low due to inaccurate positioning of answer sheet options, especially when the filling is not standardized or the printing is light, the positioning error is large.

Method used

By dividing the answer sheet image into selection boxes in two vertical directions, the target gradient is determined by the change in the number of foreground pixels in the first and second directions. The selection is located by combining the maximum gradient and the position is corrected by a clustering algorithm to ensure accurate positioning.

Benefits of technology

It improves the accuracy of locating answer sheet options, enhances the accuracy of online marking, and avoids positioning deviations caused by improper filling or light printing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115909341B_ABST
    Figure CN115909341B_ABST
Patent Text Reader

Abstract

The application provides a positioning method and device for options of an answer sheet, electronic equipment and a storage medium. The method comprises: obtaining an answer sheet image to be recognized, the answer sheet image comprising at least two options arranged in a matrix; dividing at least two frame groups corresponding to each target value in two directions of the answer sheet image, the two directions comprising a first direction and a second direction perpendicular to each other; for each target value, determining a target gradient corresponding to the target value based on first foreground pixel points in a first frame included in the frame group corresponding to the target value and second foreground pixel points in a second frame, the target gradient being used to represent changes in the number of the first foreground pixel points and the number of the second foreground pixel points; and positioning the at least two options based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction. The application improves the accuracy of positioning the options of the answer sheet, and further improves the accuracy of online marking.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a method, apparatus, electronic device, and storage medium for locating answer sheet options. Background Technology

[0002] With the development of the times and the advancement of technology, traditional manual marking methods can no longer meet the marking needs of current examinations. For example, in large-scale examinations such as the National College Entrance Examination (Gaokao) and the College English Test Band 4 and Band 6, traditional manual marking methods suffer from a series of problems, including heavy workload, long processing times, and high error rates. Therefore, current technologies typically employ online marking methods based on answer sheets to improve the efficiency of examination marking.

[0003] Specifically, in online marking based on answer sheets, existing technology requires first scanning the paper answer sheets and then projecting the scanned answer sheet images horizontally and vertically to locate the specific positions of the answer sheet options using the features of the projected answer sheet images. Then, using OMR (Optical Mark Recognition) technology, the answer results located on the answer sheet image are quickly extracted to compare the answer results with the corresponding standard answers, thereby completing the marking and scoring of the paper answer sheets.

[0004] However, the existing methods for locating answer sheet options using horizontal and vertical projection can lead to inaccurate option positioning when the answerer fills in the answer sheet incorrectly, such as when the filled area exceeds the option area or the option is printed lightly. This results in lower accuracy of online marking. Summary of the Invention

[0005] This invention provides a method, apparatus, electronic device, and storage medium for locating answer sheet options, which solves the problem of low accuracy in marking caused by inaccurate positioning of answer sheet options in the prior art, and achieves the goal of improving the accuracy of answer sheet option positioning, thereby improving the accuracy of online marking.

[0006] This invention provides a method for locating answer sheet options, comprising:

[0007] Obtain an image of an answer sheet to be identified, the image of which includes at least two options arranged in a matrix;

[0008] In the two directions of the answer sheet image, at least two selection box groups are divided for each target value. The two directions include a first direction and a second direction that are perpendicular to each other. In the first direction, the target value is used to indicate the target height of the first selection box in the selection box group corresponding to the first direction. In the second direction, the target value is used to indicate the target width of the first selection box in the selection box group corresponding to the second direction.

[0009] For each target value, based on the first foreground pixel in the first selection box and the second foreground pixel in the second selection box included in the selection box group corresponding to the target value, the target gradient corresponding to the target value is determined. The target gradient is used to characterize the change in the number of the first foreground pixel and the number of the second foreground pixel.

[0010] Based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction, the at least two options are located.

[0011] According to a method for locating answer sheet options provided by the present invention, determining the target gradient corresponding to the target value based on the first foreground pixel in the first selection box and the second foreground pixel in the second selection box of the selection box group corresponding to the target value includes:

[0012] Determine the first number of first foreground pixels in all first selection boxes corresponding to the current target value, and the second number of second foreground pixels in all second selection boxes; the target value is iterated within a preset range.

[0013] Get the third number of first foreground pixels in all first selection boxes corresponding to the previous target value, and the fourth number of second foreground pixels in all second selection boxes;

[0014] Based on the current target value, the previous target value, the first quantity, the second quantity, the third quantity, and the fourth quantity, the target gradient corresponding to the target value is determined.

[0015] According to a method for locating answer sheet options provided by the present invention, determining the target gradient corresponding to the target value based on the current target value, the previous target value, the first quantity, the second quantity, the third quantity, and the fourth quantity includes:

[0016] Determine a first difference between the first quantity and the second quantity, and determine a second difference between the third quantity and the fourth quantity;

[0017] Determine a third difference between the first difference and the second difference, and determine a fourth difference between the current target value and the previous target value;

[0018] Based on the third and fourth differences, the target gradient corresponding to the target value is determined.

[0019] According to a method for locating answer sheet options provided by the present invention, the step of locating at least two options based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction includes:

[0020] Among all target gradients corresponding to the first direction, determine the largest first target gradient, and among all target gradients corresponding to the second direction, determine the largest second target gradient;

[0021] Based on the first target gradient and the second target gradient, the at least two options are located.

[0022] According to a method for locating answer sheet options provided by the present invention, the step of locating at least two options based on a first target gradient and a second target gradient includes:

[0023] Determine the first selection box corresponding to the first target gradient, and the first selection box corresponding to the second target gradient;

[0024] The overlapping area of ​​the first selection box corresponding to the first target gradient and the first selection box corresponding to the second target gradient is determined as the location of the corresponding option.

[0025] According to a method for locating answer sheet options provided by the present invention, after determining the overlapping area of ​​the first selection box corresponding to the first target gradient and the first selection box corresponding to the second target gradient as the location of the corresponding option, the method further includes:

[0026] Determine the center position of each option included within each of the overlapping regions;

[0027] For either the first or the second direction, when it is determined that all center positions are not located on the same standard line, the position of the option corresponding to the center position that deviates from the standard line is corrected based on the standard line.

[0028] According to a method for locating answer sheet options provided by the present invention, the step of dividing at least two selection box groups corresponding to each target value includes:

[0029] Based on the identification information in the answer sheet image, obtain the answer sheet template corresponding to the answer sheet image;

[0030] Based on the answer sheet template, determine the layout information of at least two options in the answer sheet image;

[0031] Based on the layout information, the target number of selection box groups corresponding to each of the two directions of the answer sheet image is determined respectively;

[0032] Divide the target value into a number of selection boxes corresponding to the target quantity.

[0033] The present invention also provides a positioning device for answer sheet options, comprising:

[0034] An acquisition module is used to acquire an answer sheet image to be identified, the answer sheet image including at least two options arranged in a matrix;

[0035] The segmentation module is used to divide the answer sheet image into at least two selection box groups corresponding to each target value in two directions. The two directions include a first direction and a second direction that are perpendicular to each other. In the first direction, the target value is used to indicate the target height of the first selection box in the selection box group corresponding to the first direction. In the second direction, the target value is used to indicate the target width of the first selection box in the selection box group corresponding to the second direction.

[0036] The determination module is used to determine the target gradient corresponding to each target value based on the first foreground pixel in the first selection box and the second foreground pixel in the second selection box included in the selection box group corresponding to the target value. The target gradient is used to characterize the change in the number of the first foreground pixel and the number of the second foreground pixel.

[0037] The localization module is used to locate the at least two options based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction.

[0038] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method for locating answer sheet options as described above.

[0039] The present invention also provides an electronic device, including a camera, a memory, a processor, and a computer program stored in the memory and executable on the processor. The camera is used to capture an image of an answer sheet to be recognized. The processor is used to divide the answer sheet image into at least two selection box groups corresponding to each target value in two directions, the two directions including a first direction and a second direction that are perpendicular to each other. In the first direction, the target value is used to indicate the target height of a first selection box in the selection box group corresponding to the first direction, and in the second direction, the target value is used to indicate the target width of a first selection box in the selection box group corresponding to the second direction. For each target value, based on a first foreground pixel in the first selection box and a second foreground pixel in the second selection box included in the selection box group corresponding to the target value, a target gradient corresponding to the target value is determined. The target gradient is used to characterize the change in the number of the first foreground pixels and the number of the second foreground pixels. Based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction, the at least two options are located.

[0040] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for locating answer sheet options as described above.

[0041] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the method for locating answer sheet options as described above.

[0042] The present invention provides a method, apparatus, electronic device, and storage medium for locating answer sheet options. This involves dividing the acquired answer sheet image to be identified into at least two selection box groups corresponding to each target value along a first and second mutually perpendicular direction. Based on each target value, the first foreground pixel in the first selection box and the second foreground pixel in the second selection box of the corresponding selection box group are determined, thereby determining the target gradient corresponding to the target value. The target values ​​in the first and second directions respectively indicate the target height of the first selection box in the selection box group corresponding to the first direction and the target width of the first selection box in the selection box group corresponding to the second direction. By dividing the selection box into groups, the first foreground pixels in the first selection box and the second foreground pixels in the second selection box include not only pixels corresponding to abnormal options such as those with irregular filling or light printing, but also pixels corresponding to normal options. In this way, the distribution of all options can be determined based on the target gradient corresponding to the target value determined by the first and second foreground pixels. In the process of locating the options based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction, since the distribution of all options is considered, the number of pixels corresponding to normal options can be used to locate all options. This avoids the problem of inaccurate positioning of irregularly filled options caused by considering only the feature information of some options in the existing technology, thereby improving the accuracy of answer sheet option positioning and thus improving the accuracy of online marking. Attached Figure Description

[0043] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0044] Figure 1 This is a flowchart illustrating the method for locating answer sheet options provided in an embodiment of the present invention;

[0045] Figure 2 This is a schematic diagram of an answer sheet image to be recognized provided in an embodiment of the present invention;

[0046] Figure 3 This is a schematic diagram of the gradient image of the answer sheet image to be identified provided in an embodiment of the present invention;

[0047] Figure 4 This is a schematic diagram of the binarized image of the answer sheet image to be identified provided in an embodiment of the present invention;

[0048] Figure 5This is a schematic diagram of the horizontal projection of a binarized image provided in an embodiment of the present invention;

[0049] Figure 6 This is a schematic diagram of the longitudinal projection of a binarized image provided in an embodiment of the present invention;

[0050] Figure 7 This is a schematic diagram of a selection box group in the first direction provided in an embodiment of the present invention;

[0051] Figure 8 This is a schematic diagram of a selection box group in the second direction provided in an embodiment of the present invention;

[0052] Figure 9 This is a schematic diagram showing the overlap of the first selection box in the first direction and the second direction provided in the embodiments of the present invention;

[0053] Figure 10 This is a flowchart illustrating a clustering algorithm provided in an embodiment of the present invention;

[0054] Figure 11 This is a schematic diagram of a clustering result provided in an embodiment of the present invention;

[0055] Figure 12 This is a schematic diagram of the structure of the answer sheet option positioning device provided in an embodiment of the present invention;

[0056] Figure 13 This is one of the structural schematic diagrams of the electronic device provided by the present invention;

[0057] Figure 14 This is the second schematic diagram of the electronic device provided by the present invention. Detailed Implementation

[0058] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0059] Online marking systems are modern computer systems that rely on computer network technology and electronic scanning technology to automatically mark objective questions and grade subjective questions online. This type of marking eliminates the hassle of manual marking, which involves hierarchical data aggregation and reporting. It also allows for direct use in teaching reviews and quality analysis, maximizing the sharing of performance data and meeting the needs of leaders, teachers, students, and parents. Therefore, it is widely used in various large-scale examinations. Automatic marking of objective questions generally involves two steps: first, locating the objective questions, i.e., locating the answer sheet options; second, identifying and marking the located answer sheet options.

[0060] Specifically, in locating answer sheet options, existing technologies generally fall into two categories: traditional graphics algorithms and model-trained detection algorithms. The latter, model-trained detection algorithms, require letter recognition to locate answer sheet options. Therefore, this method is not only time-consuming but also consumes significant GPU (Graphics Processing Unit) resources, increasing the cost of grading. Thus, in practice, traditional graphics algorithms are typically the primary approach. Traditional graphics algorithms usually employ horizontal and vertical projection to determine the feature information of the projected portion corresponding to the option, and then locate the answer sheet option based on this feature information. This method requires high accuracy in the answerer's filling, meaning it is only suitable for scenarios where the answerer's filling is relatively standardized. In other abnormal scenarios where the answerer's filling is not standardized, the irregular filling method can destroy the feature information, making the above-mentioned positioning method prone to answer sheet option positioning deviations.

[0061] Based on this, this invention proposes a method for locating answer sheet options. By dividing the selection box into groups, the first foreground pixels in the first selection box and the second foreground pixels in the second selection box include not only pixels corresponding to abnormal options such as those with irregular filling or light printing, but also pixels corresponding to normal options. In this way, the distribution of all options can be determined based on the target gradient corresponding to the target value determined by the first and second foreground pixels. In the process of locating options based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction, since the distribution of all options is considered, the number of pixels corresponding to normal options can be used to determine the location of irregularly filled options, thereby completing the location of all options. This avoids the problem of inaccurate location of irregularly filled options caused by considering only the feature information of some options in the prior art, thus improving the accuracy of answer sheet option location and consequently improving the accuracy of online marking.

[0062] The following is combined Figures 1-11 The method for locating answer sheet options provided in this embodiment of the invention is described. This method can be applied in online marking scenarios, especially in scenarios where answer sheets are marked online, and the answer sheet contains objective question options. The subject executing this method can be an electronic device such as a computer, or any other device capable of image processing.

[0063] Figure 1 This is a flowchart illustrating the method for locating answer sheet options provided in an embodiment of the present invention, as shown below. Figure 1 As shown, the method includes:

[0064] Step 101: Obtain the answer sheet image to be identified, which includes at least two options arranged in a matrix.

[0065] Among them, at least two options are the objects that the respondent needs to fill in. These options can be arranged in a matrix pattern, and their arrangement has a hierarchical structure.

[0066] Specifically, the collected paper answer sheets can be scanned into an image of the answer sheet to be recognized using a scanning device and then sent to an electronic device. Alternatively, the answer sheet image can be obtained by scanning the answer sheet using a camera installed in the electronic device.

[0067] Step 102: Divide the answer sheet image into at least two selection box groups corresponding to each target value in two directions. The two directions include a first direction and a second direction that are perpendicular to each other. In the first direction, the target value is used to indicate the target height of the first selection box in the selection box group corresponding to the first direction. In the second direction, the target value is used to indicate the target width of the first selection box in the selection box group corresponding to the second direction. The direction of the target height is the same as that of the second direction, and the direction of the target width is the same as that of the first direction.

[0068] For example, Figure 2 A schematic diagram of an answer sheet image to be identified provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the gradient image of the answer sheet image to be identified provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of a binarized image of an answer sheet image to be identified, provided in an embodiment of the present invention. Specifically, in the case of... Figure 2 Before dividing the answer sheet image into selection boxes, it needs to be preprocessed, such as by gradient simplification and binarization, to obtain the desired result. Figure 3 The gradient image of the answer sheet shown and as follows Figure 4 The binarized image of the answer sheet shown is then used. Next, the binarized image of the answer sheet is divided into selection boxes corresponding to each target value in two mutually perpendicular directions.

[0069] The process of dividing the selection box into groups on the binarized image of the answer sheet image to be recognized will be explained in detail below, taking the first direction as the horizontal direction of the image and the second direction as the vertical direction of the image as an example.

[0070] For example, Figure 5 This is a schematic diagram of the horizontal projection of a binarized image provided in an embodiment of the present invention; Figure 6 This is a schematic diagram of the longitudinal projection of a binarized image provided in an embodiment of the present invention. Specifically, as shown... Figure 4 The binarized image shown is subjected to horizontal and vertical projections to obtain, as shown below. Figure 5 The horizontal projection image of the binarized image shown and as... Figure 6 The vertical projection of the binarized image shown can be used to improve the efficiency of answer sheet option detection and localization. Based on the horizontal and vertical projections, the detection boundaries corresponding to the answer sheet options can be determined to narrow the detection area and thus crop out a more accurate target detection area.

[0071] Furthermore, taking the first direction as an example, Figure 7 This is a schematic diagram of a selection box group in a first direction provided in an embodiment of the present invention. 71 represents a first selection box, 72 represents the target value in the first direction (i.e., the target height of the first selection box in the selection box group corresponding to the first direction), 73 represents a second selection box, and 74 represents the height of the second selection box. Specifically, an answer sheet template corresponding to the answer sheet image can be determined, thereby determining the number of rows and columns of options in the answer sheet template, and thus obtaining the number of rows and columns of options in the answer sheet image. Taking the first direction as a horizontal direction as an example, the number of first and second selection boxes in the first direction can be determined, both being the number of rows of options. Furthermore, after determining the target detection area, a detection starting position in the first direction, as well as the target height of each first selection box and the height of each second selection box in each selection box group, can be set.

[0072] After determining the detection start position in the first direction, the height of the second selection box is fixed. Then, using this detection start position as the start position of the first selection box, the height values ​​of the first selection box are traversed from a preset range to divide the selection box into multiple groups with different first selection box heights. After traversing all the first selection box height values ​​within the preset range, the height of the second selection box is updated, and the height of the first selection box is again traversed from the preset range to divide the selection box into multiple groups with different first selection box heights. The height of the second selection box also varies within a certain range. Thus, the selection box group corresponding to each target value in the first direction can be determined.

[0073] Figure 8This is a schematic diagram of a selection box group in the second direction provided in an embodiment of the present invention. 81 represents the first selection box, 82 represents the target value in the second direction, i.e., the target width of the first selection box in the selection box group corresponding to the second direction, 83 represents the second selection box, and 84 represents the height of the second selection box. Specifically, the division of the selection box group in the second direction is similar to that in the first direction, and will not be repeated here.

[0074] Step 103: For each target value, based on the first foreground pixel in the first selection box and the second foreground pixel in the second selection box included in the selection box group corresponding to the target value, determine the target gradient corresponding to the target value. The target gradient is used to characterize the change in the number of the first foreground pixel and the number of the second foreground pixel.

[0075] Since the answer sheet image is preprocessed into a binary image, the first foreground pixel and the second foreground pixel mentioned here both refer to pixels with non-zero grayscale values ​​in the binary image.

[0076] Specifically, by traversing the grayscale values ​​of the above-mentioned target detection area, the number of first foreground pixels in the first selection box and the number of second foreground pixels in the second selection box corresponding to each target value can be obtained. Then, the difference between the number of first foreground pixels and the number of second foreground pixels in the first selection box corresponding to each target value can be calculated, and the target gradient corresponding to all target values ​​can be determined.

[0077] Step 104: Based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction, locate at least two options.

[0078] In step 102, the heights of both the first and second selection boxes in the first direction change within a certain range. This causes the first foreground pixel in the first selection box and the second foreground pixel in the second selection box corresponding to each target value in step 103 to also change within a certain range. Therefore, each target value in the first direction corresponds to a change in the number of first and second foreground pixels, meaning each target value corresponds to a unique target gradient. Similarly, each target value in the second direction also corresponds to a unique target gradient.

[0079] Specifically, after obtaining each target gradient in the first direction and the second direction through the above method, the first selection box corresponding to the largest target gradient among all target gradients in the first direction is taken as the target selection box in the first direction; the first selection box corresponding to the largest target gradient among all target gradients in the second direction is taken as the target selection box in the second direction, and then the intersection operation is performed on the target selection boxes corresponding to the first direction and the second direction respectively, so as to obtain the positioning selection box covering each answer sheet option, that is, the positioning of at least two answer sheet options is realized.

[0080] The method for locating answer sheet options provided in this invention divides the acquired answer sheet image to be identified into at least two selection box groups corresponding to each target value in a first direction and a second direction that are perpendicular to each other. Based on each target value, the method determines the first foreground pixel in the first selection box and the second foreground pixel in the second selection box of the corresponding selection box group, thereby determining the target gradient corresponding to the target value. Specifically, in the first direction, the target value indicates the target height of the first selection box in the selection box group corresponding to the first direction; in the second direction, the target value indicates the target width of the first selection box in the selection box group corresponding to the second direction. By dividing the selection box into groups, the first foreground pixels in the first selection box and the second foreground pixels in the second selection box include not only pixels corresponding to abnormal options such as those with irregular filling or light printing, but also pixels corresponding to normal options. In this way, the distribution of all options can be determined based on the target gradient corresponding to the target value determined by the first and second foreground pixels. In the process of locating the options based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction, since the distribution of all options is considered, the number of pixels corresponding to normal options can be used to locate all options. This avoids the problem of inaccurate positioning of irregularly filled options caused by considering only the feature information of some options in the existing technology, thereby improving the accuracy of answer sheet option positioning and thus improving the accuracy of online marking.

[0081] Based on the above embodiments, when determining the target gradient corresponding to the target value based on the first foreground pixels in the first selection box and the second foreground pixels in the second selection box of the selection box group corresponding to the target value, the determination can be carried out in the following way: determine the first number of first foreground pixels in all first selection boxes corresponding to the current target value, and the second number of second foreground pixels in all second selection boxes; traverse the target value within a preset range; obtain the third number of first foreground pixels in all first selection boxes corresponding to the previous target value, and the fourth number of second foreground pixels in all second selection boxes; determine the target gradient corresponding to the target value based on the current target value, the previous target value, the first number, the second number, the third number, and the fourth number.

[0082] For example, when the current target value is the lower limit within a preset range, the first number of first foreground pixels in all first selection boxes corresponding to the current target value and the second number of second foreground pixels in all second selection boxes can be used as the third number of first foreground pixels in all first selection boxes and the fourth number of second foreground pixels in all second selection boxes corresponding to the previous target value. Based on the current target value, the previous target value, the first and second numbers of the current target value, and the third and fourth numbers corresponding to the previous target value, the target gradient corresponding to the current target value can be determined.

[0083] Furthermore, taking the first direction as the horizontal direction of the image as an example, such as Figure 7 As shown, when the target value 72 in the first direction represents the target height of the first selection box in the corresponding selection box group, different target values ​​72 correspond to different first foreground pixels within the first selection box. That is, when the target value 72 changes, the first number of first foreground pixels within the first selection box will also change accordingly. Similarly, as... Figure 8 As shown, when the target value 82 in the second direction changes, the first number of the first foreground pixels within the first selection box also changes accordingly. Correspondingly, the second number of the second foreground pixels in the second selection box in both the first and second directions also changes with the height of the second selection box.

[0084] Therefore, the current target value can be incremented by 1 to obtain the next target value. This allows us to calculate the first number of first foreground pixels in all first selection boxes and the second number of second foreground pixels in all second selection boxes corresponding to the next target value. The current target value is then used as the previous target value, and the first and second numbers of the current target value are used as the third and fourth numbers of the previous target value. This allows us to calculate the target gradient corresponding to the next target value. From this pattern, we can obtain the target gradient corresponding to all target values ​​within a preset range in the first and second directions.

[0085] It should be noted that incrementing the current target value by 1 is merely an example of how to iterate through the target value within a preset range. It can be replaced by any other iteration method, and no specific restrictions are imposed here.

[0086] In this embodiment, by calculating the first number of first foreground pixels in all first selection boxes corresponding to the current target value, the second number of second foreground pixels in all second selection boxes, the third number of first foreground pixels in all first selection boxes corresponding to the previous target value, and the fourth number of second foreground pixels in all second selection boxes, the target gradient corresponding to each target value in the first and second directions can be determined based on the current target value, the previous target value, the first number, the second number, the third number, and the fourth number. Therefore, by determining the target gradient corresponding to each target value within a preset range using the current target value, the previous target value, the first number of first foreground pixels in all first selection boxes, the second number of second foreground pixels in all second selection boxes, the third number of first foreground pixels in all first selection boxes corresponding to the previous target value, and the fourth number of second foreground pixels in all second selection boxes, a more accurate target gradient corresponding to the first selection box located at the answer sheet option's position can be obtained, thus obtaining a more accurate location of the answer sheet option.

[0087] Furthermore, to improve the accuracy of locating answer sheet options, based on the above embodiments, when determining the target gradient corresponding to the target value based on the current target value, the previous target value, the first quantity, the second quantity, the third quantity, and the fourth quantity, the following method can be adopted: determine the first difference between the first quantity and the second quantity, and determine the second difference between the third quantity and the fourth quantity; determine the third difference between the first difference and the second difference, and determine the fourth difference between the current target value and the previous target value; determine the target gradient corresponding to the target value based on the third difference and the fourth difference.

[0088] Specifically, taking the determination of the target gradient corresponding to the current target value as an example, we can first subtract the second quantity from the first quantity obtained in the above embodiment to obtain the first difference corresponding to the current target value. Similarly, we can subtract the fourth quantity from the third quantity obtained in the above embodiment to obtain the second difference corresponding to the previous target value.

[0089] Based on this, the obtained current target value, previous target value, and the first difference corresponding to the current target value and the second difference corresponding to the previous target value are substituted into the following target gradient formula (1) to calculate the target gradient corresponding to the current target value:

[0090]

[0091] in, This represents the first difference corresponding to the i-th target value; This represents the second difference corresponding to the (i-1)th target value.

[0092] As can be seen from the above, the target gradient corresponding to all target values ​​within the preset range can be obtained by using the above formula (1).

[0093] In this embodiment, a third difference is obtained by subtracting the first difference between the first and second quantities from the second difference between the third and fourth quantities. This third difference is then combined with the fourth difference between the current target value and the previous target value to determine the target gradient corresponding to each target value within a preset range. This further determines the target gradient corresponding to the first selection box located at the answer sheet option's position, thus obtaining a more accurate location of the answer sheet option and providing a foundation for improving the accuracy of answer sheet option positioning. Based on this, in one possible implementation, when positioning at least two options based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction, the largest first target gradient can be determined among all target gradients corresponding to the first direction, and the largest second target gradient can be determined among all target gradients corresponding to the second direction; the positioning of at least two options is then performed based on the first and second target gradients.

[0094] Specifically, taking the first direction as an example, in order to improve the efficiency of locating the answer sheet options, the target gradient corresponding to the target value with a first difference greater than 0 in the above embodiment is first eliminated to avoid the possibility of the second selection box becoming the selection box for locating the position of the answer sheet option. That is, the effectiveness of the target gradient corresponding to the first selection box located at the position of the answer sheet option in the first direction is improved, thereby improving the efficiency of locating the answer sheet options.

[0095] Then, among the target gradients after removing the target gradients corresponding to the target values ​​with a difference greater than 0, the largest target gradient is selected as the first target gradient corresponding to the first direction. Similarly, the second target gradient corresponding to the second direction can also be obtained. Further, the target position of the answer sheet option is determined by the target height and target width of the first selection box corresponding to the first and second target gradients determined above. Since the first selection box contains all answer sheet options, it corresponds to the largest target gradient. Therefore, when the largest first target gradient in the first direction and the largest second target gradient in the second direction are determined, the target height and target width of the corresponding first selection box just cover the entire answer sheet option. Thus, the printing standard area and filling standard area detected by the largest target gradient in the first and second directions can be more accurate and complete. Therefore, based on the largest first target gradient in the first direction and the largest second target gradient in the second direction, the position of the answer sheet option can be determined more accurately, thereby more accurately avoiding the filling of non-standard areas.

[0096] In one possible implementation, when locating at least two options based on the first target gradient and the second target gradient, the overlapping area of ​​the first selection box corresponding to the first target gradient and the first selection box corresponding to the second target gradient can be determined as the location of the corresponding option.

[0097] For example, Figure 9 This is a schematic diagram showing the overlap of a first selection box in a first direction and a second direction, provided for an embodiment of the present invention. In this diagram, 91 represents a first selection box in the first direction, 92 represents a first selection box in the second direction, and 93 represents the overlapping area of ​​the first selection boxes in the first direction and the second direction.

[0098] To accurately locate the position of each answer sheet option, the first checkbox representing each row's option and the first checkbox representing each column's option are overlapped within the same answer sheet image. The non-overlapping areas within the overlapped first checkboxes are then removed, leaving only the overlapping areas. For example... Figure 9 As shown, the overlapping area of ​​the first selection box after overlapping consists of a number of rows multiplied by a number of columns of small rectangles, where each small rectangle represents an answer sheet option.

[0099] Based on the previous embodiment, this embodiment determines the target height and target width of each answer sheet option in the first and second directions by taking the overlapping area of ​​the first selection box corresponding to the largest first target gradient that covers the entire answer sheet option in the first direction and the first selection box corresponding to the largest second target gradient that covers the entire answer sheet option in the second direction. This allows for a more accurate determination of the specific location of the corresponding option, thus improving the accuracy of the answer sheet option positioning.

[0100] Furthermore, such as Figure 9 As shown, the location of the corresponding option determined by the overlapping area of ​​the first selection box corresponding to the first target gradient and the second target gradient in the above embodiment cannot make the border of the overlapping area of ​​all the first selection boxes exactly snap to the boundary of their respective options. Therefore, in order to improve the accuracy of the answer sheet option location, after determining the overlapping area of ​​the first selection box corresponding to the first target gradient and the first selection box corresponding to the second target gradient as the location of the corresponding option, the location of the option can also be corrected in the following way: determine the center position of the option included in each overlapping area respectively; for the first direction or the second direction, when it is determined that all center positions are not located on the same standard line, correct the position of the option corresponding to the center position that deviates from the standard line based on the standard line.

[0101] Specifically, before correcting the location of the options, a clustering algorithm is used to perform a row-by-row and column-by-column check on the location of the options to determine whether each option's features meet the requirements of the template features. If they meet the requirements, then correction is performed; otherwise, the location of the determined option is considered to have low credibility and does not require correction. The requirements for the template features include at least whether the width, height, and distance between options are within the allowable error range of the template features.

[0102] To facilitate understanding of the row and column check of the position of the option in the above embodiments, the following is a detailed explanation of the one-pass clustering algorithm used for the check.

[0103] Specifically, Figure 10 This is a flowchart illustrating a clustering algorithm provided in an embodiment of the present invention, as shown below. Figure 10 As shown, the algorithm includes:

[0104] Step 1001: Read a new object from the dataset.

[0105] Within each overlapping area, the center of the options represents an object.

[0106] Specifically, initially, the cluster set is empty, and a new object needs to be read in, which can be read in a row or column manner to read the center position of the options included in each overlapping area of ​​the answer sheet image.

[0107] Step 1002: Construct a new cluster using the new object.

[0108] In this context, a cluster can be understood as the central location of options within a class of overlapping regions.

[0109] Step 1003: Determine whether the dataset has been completely read.

[0110] Specifically, if the center position of each option within the overlapping area of ​​the answer sheet image has been read, it means there are no new detection objects, and the verification ends at this time; otherwise, proceed to step 1004 below.

[0111] Step 1004: Read another new object from the dataset, calculate its distance to each existing cluster, and select the cluster with the smallest distance to it.

[0112] Each existing cluster has a different cluster center, which can be understood as the average center position of each detected object in the cluster.

[0113] Specifically, the distance between the center position of the options included in the newly read overlapping region and the average center position of each existing cluster is calculated, and the cluster with the smallest distance is selected as the distance verification benchmark for the center position of the options included in the overlapping region.

[0114] Step 1005: Determine whether the minimum distance exceeds the threshold.

[0115] The threshold is defined as the maximum allowed distance between the center position of the options included in each overlapping region and the average center position of the cluster with the smallest distance.

[0116] Specifically, if the calculated minimum distance exceeds the threshold, the object is considered to be non-compliant, meaning that the verification of the center position of the option included in the overlapping area has failed, and step 1002 is executed; otherwise, the verification is considered to be successful, and step 1006 is executed as follows.

[0117] Step 1006: Merge the object into the cluster with the smallest distance to it, and update the cluster center of that cluster.

[0118] Specifically, after the center position of the option included in the above-mentioned overlapping area is verified, it is incorporated into the cluster with the smallest distance, and the average center position of the cluster, i.e., the cluster center, is updated.

[0119] The one-pass clustering algorithm is an unsupervised clustering algorithm, characterized by its high efficiency and simplicity, requiring only one pass through the dataset to complete the clustering. Therefore, by using this one-pass clustering algorithm to verify the features of the options, the algorithm can quickly eliminate the positions of options that do not meet the template feature requirements.

[0120] Furthermore, after eliminating the positions of all options that do not meet the template feature requirements, the center position of the options included in each overlapping area is calculated, and the straight line connecting the most center positions in each row or column is used as the standard line to correct the position of the options corresponding to other center positions in that row or column that deviate from the standard line. That is, the position of the option is slightly adjusted so that its overlapping area exactly covers the option.

[0121] In this embodiment, by determining whether the center position of the options included in each overlapping area is located on the same standard line in the first or second direction, the position of the option that is not accurate enough can be detected, that is, the position of the option to be corrected. Then, the position of the option corresponding to the center position that deviates from the standard line can be corrected based on the standard information, thereby further improving the accuracy of the positioning of the answer sheet options.

[0122] In addition, to avoid inaccurate recognition results due to lightly filled options, after obtaining the positions of all answer sheet options, the following clustering method can be used to determine whether the option position has been filled, thereby obtaining more accurate answer results.

[0123] Specifically, based on the positions of all the answer sheet options, the average gray value corresponding to each option is calculated. This average gray value is then clustered using the K-Means algorithm, either row-wise or column-wise. The clustering labels can be categorized into three types: confirmed filled, confirmed unfilled, and suspected filled areas. For example... Figure 11 This is a schematic diagram of a clustering result provided in an embodiment of the present invention, as shown below. Figure 11 As shown, the options within the selected area are for confirmation of filling, while the options outside the selected area are for confirmation of not filling. It should also be noted that "each row" or "each column" refers to... Figure 11 The row and column corresponding to all answer sheet options are shown, not just a row and column corresponding to some answer sheet options.

[0124] Furthermore, the algorithm produces different clustering results based on different filling situations. Therefore, the corresponding filling situation can also be deduced from the different clustering results generated by the algorithm. For example, when the algorithm outputs only one clustering result, its average gray value can be compared with a first gray value threshold. If it is greater than the first gray value threshold, filling is confirmed; otherwise, no filling is confirmed. When the algorithm outputs two clustering results, the option with the larger gray value is considered to be filled, and the option with the smaller gray value is considered to be unfilled. When the algorithm outputs three or more clustering results, the option with the largest gray value is considered to be filled, and the option with the smallest gray value is considered to be unfilled. For options between the largest and smallest gray values, all are confirmed as suspected filled areas, and the filled area of ​​each suspected filled area is compared with a filling area threshold. If it is greater than the filling area threshold, filling is confirmed. Otherwise, proceed to the next round of grayscale threshold comparison, which compares the average grayscale value with the second grayscale threshold. If the average grayscale value is greater than the second grayscale threshold, the filling is confirmed; otherwise, the filling is confirmed as not filled. The second grayscale threshold is greater than the first grayscale threshold.

[0125] In addition, based on any of the above embodiments, when dividing the answer sheet image into at least two selection box groups corresponding to each target value in both directions, one possible implementation is as follows: based on the identification information in the answer sheet image, obtain the answer sheet template corresponding to the answer sheet image; based on the answer sheet template, determine the layout information of at least two options in the answer sheet image; based on the layout information, determine the target number of selection box groups corresponding to each of the two directions of the answer sheet image; and divide the target number of selection box groups corresponding to each target value.

[0126] The identification information includes the subject or type of the answer sheet, such as subjects like mathematics, Chinese, and geography, or types like Mathematics A and Mathematics B.

[0127] Specifically, the answer sheet template corresponding to the identification information contained in the answer sheet image can be obtained from a pre-set answer sheet template library. The answer sheet template library includes the answer sheet template corresponding to the identification information and the layout information of the answer sheet options within the template. This layout information includes at least the number of rows and columns of options for each question type. Based on the obtained answer sheet template and the corresponding layout information of the answer sheet options, the layout information of all options in the answer sheet image can be determined. This layout information includes, for example, the number of question types and the number of questions and options for each question type. Furthermore, the target number of selection boxes corresponding to each horizontal and vertical direction in the answer sheet image can be directly obtained from this layout information; that is, the number of rows and columns of options corresponding to each question type. This allows for a more accurate division of the target number of selection boxes corresponding to each target value.

[0128] In this embodiment, an answer sheet template corresponding to the answer sheet image is determined by the identification information obtained from the answer sheet image. Then, using this template, the layout information of at least two options in the answer sheet image can be determined, thus obtaining more precise distribution information of all options in the answer sheet, including the number of options in different directions. Based on this layout information, the target number of selection boxes corresponding to each direction in the answer sheet image can be determined. Therefore, with a more precise number of options in both directions, the target number of selection boxes corresponding to each target value can be more accurately divided, thus determining the distribution number of the answer sheet option to be located in both directions. This allows for more accurate location of the answer sheet options, improving the accuracy of answer sheet option location.

[0129] The positioning device for answer sheet options provided in the embodiments of the present invention will be described below. The positioning device for answer sheet options described below and the positioning method for answer sheet options described above can be referred to in correspondence with each other.

[0130] Figure 12 This is a schematic diagram of the structure of the answer sheet option positioning device provided in an embodiment of the present invention, as shown below. Figure 12 As shown, the device includes:

[0131] The acquisition module 121 is used to acquire an answer sheet image to be identified, the answer sheet image including at least two options arranged in a matrix;

[0132] The segmentation module 122 is used to divide the answer sheet image into at least two selection box groups corresponding to each target value in two directions. The two directions include a first direction and a second direction that are perpendicular to each other. In the first direction, the target value is used to indicate the target height of the first selection box in the selection box group corresponding to the first direction. In the second direction, the target value is used to indicate the target width of the first selection box in the selection box group corresponding to the second direction.

[0133] The determination module 123 is used to determine the target gradient corresponding to each target value based on the first foreground pixel in the first selection box and the second foreground pixel in the second selection box included in the selection box group corresponding to the target value. The target gradient is used to characterize the change in the number of the first foreground pixel and the number of the second foreground pixel.

[0134] The localization module 124 is used to locate at least two options based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction.

[0135] The answer sheet option positioning device provided in this embodiment of the invention divides the answer sheet image to be identified, acquired by the acquisition module 121, into at least two selection box groups corresponding to each target value in a first direction and a second direction that are perpendicular to each other, by the division module 122. Then, by the determination module 123, based on each target value, the first foreground pixel in the first selection box and the second foreground pixel in the second selection box included in the corresponding selection box group are determined. Furthermore, the determination module 123 can determine the target gradient corresponding to the target value. Specifically, in the first direction, the target value indicates the target height of the first selection box in the corresponding selection box group in the first direction; in the second direction, the target value indicates the target width of the first selection box in the corresponding selection box group in the second direction. By dividing the selection box into groups, the first foreground pixels in the first selection box and the second foreground pixels in the second selection box include not only pixels corresponding to abnormal options such as those with irregular filling or light printing, but also pixels corresponding to normal options. In this way, the distribution of all options can be determined based on the target gradient corresponding to the target value determined by the first and second foreground pixels. In the process of locating the options based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction, since the distribution of all options is considered, the number of pixels corresponding to normal options can be used to locate all options. This avoids the problem of inaccurate positioning of irregularly filled options caused by considering only the feature information of some options in the existing technology, thereby improving the accuracy of answer sheet option positioning and thus improving the accuracy of online marking.

[0136] Optionally, the determining module 123 is specifically used for:

[0137] Determine the first number of first foreground pixels in all first selection boxes corresponding to the current target value, and the second number of second foreground pixels in all second selection boxes; the target value is iterated through within a preset range.

[0138] Get the third number of first foreground pixels in all first selection boxes corresponding to the previous target value, and the fourth number of second foreground pixels in all second selection boxes;

[0139] Based on the current target value, the previous target value, the first quantity, the second quantity, the third quantity, and the fourth quantity, determine the target gradient corresponding to the target value.

[0140] Optionally, the determining module 123 is specifically used for:

[0141] Determine the first difference between the first quantity and the second quantity, and determine the second difference between the third quantity and the fourth quantity;

[0142] Determine the third difference between the first and second differences, and determine the fourth difference between the current target value and the previous target value;

[0143] Based on the third and fourth differences, the target gradient corresponding to the target value is determined.

[0144] Optionally, the positioning module 124 is specifically used for:

[0145] Among all target gradients corresponding to the first direction, determine the largest first target gradient, and among all target gradients corresponding to the second direction, determine the largest second target gradient;

[0146] Based on the first target gradient and the second target gradient, locate at least two options.

[0147] Optionally, the positioning module 124 is specifically used for:

[0148] Determine the first bounding box corresponding to the gradient of the first target, and the first bounding box corresponding to the gradient of the second target;

[0149] The overlapping area of ​​the first selection box corresponding to the first target gradient and the first selection box corresponding to the second target gradient is determined as the location of the corresponding option.

[0150] Optionally, the device further includes:

[0151] The determining module 123 is also used to determine the center position of the options included in each overlapping region;

[0152] The correction module is used to correct the position of the option corresponding to the center position that deviates from the standard line, based on the standard line, when it is determined that all center positions are not located on the same standard line in the first or second direction.

[0153] Optionally, the partitioning module 122 is specifically used for:

[0154] Based on the identification information in the answer sheet image, obtain the answer sheet template corresponding to the answer sheet image;

[0155] Based on the answer sheet template, determine the layout information of at least two options in the answer sheet image;

[0156] Based on the layout information, determine the target number of selection box groups corresponding to each of the two directions of the answer sheet image;

[0157] Divide the target into groups of select boxes corresponding to the number of targets for each target value.

[0158] The apparatus of this embodiment can be used to execute the method of any embodiment of the method embodiment for locating answer sheet options. Its specific implementation process and technical effects are similar to those of the method embodiment for locating answer sheet options. For details, please refer to the detailed description in the method embodiment for locating answer sheet options, which will not be repeated here.

[0159] Figure 13 This example illustrates one of the physical structural diagrams of an electronic device, such as... Figure 13 As shown, the electronic device may include: a processor 131, a communication interface 132, a memory 133, and a communication bus 134, wherein the processor 131, the communication interface 132, and the memory 133 communicate with each other through the communication bus 134. The processor 131 can call logical instructions in the memory 133 to execute a method for locating answer sheet options, including: acquiring an answer sheet image to be identified, the answer sheet image including at least two options arranged in a matrix; dividing the answer sheet image into at least two selection box groups corresponding to each target value in two directions, the two directions including a first direction and a second direction that are perpendicular to each other, in the first direction, the target value is used to indicate the target height of the first selection box in the selection box group corresponding to the first direction, and in the second direction, the target value is used to indicate the target width of the first selection box in the selection box group corresponding to the second direction; for each target value, determining a target gradient corresponding to the target value based on the first foreground pixel in the first selection box and the second foreground pixel in the second selection box included in the selection box group corresponding to the target value, the target gradient being used to characterize the change in the number of the first foreground pixel and the number of the second foreground pixel; and locating at least two options based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction.

[0160] Furthermore, the logical instructions in the aforementioned memory 133 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0161] Figure 14 Example 2: A schematic diagram of the physical structure of an electronic device, such as... Figure 14 As shown, the electronic device may include: a processor 141, a communications interface 142, a memory 143 and a communications bus 144, and also includes a camera 145. The processor 141, the communications interface 142, the memory 143 and the camera 145 communicate with each other through the communications bus 144. The camera 145 is used to acquire an image of an answer sheet to be recognized. The processor 141 can call logical instructions in the memory 143 to execute a method for locating answer sheet options, including: acquiring an image of the answer sheet to be recognized, the image including at least two options arranged in a matrix; dividing the answer sheet image into at least two selection box groups corresponding to each target value in two directions, the two directions including a first direction and a second direction that are perpendicular to each other, in the first direction, the target value is used to indicate the target height of the first selection box in the selection box group corresponding to the first direction, and in the second direction, the target value is used to indicate the target width of the first selection box in the selection box group corresponding to the second direction; for each target value, determining a target gradient corresponding to the target value based on the first foreground pixel in the first selection box and the second foreground pixel in the second selection box group included in the selection box group corresponding to the target value, the target gradient being used to characterize the change in the number of the first foreground pixel and the number of the second foreground pixel; and locating at least two options based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction.

[0162] Furthermore, the logical instructions in the aforementioned memory 143 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0163] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer is able to execute the answer sheet option positioning method provided by the above methods, including: acquiring an answer sheet image to be identified, the answer sheet image including at least two options arranged in a matrix; dividing the answer sheet image into at least two selection box groups corresponding to each target value in two directions, the two directions including a first direction and a second direction that are perpendicular to each other, in the first direction, the target value is used to indicate the target height of the first selection box in the selection box group corresponding to the first direction, and in the second direction, the target value is used to indicate the target width of the first selection box in the selection box group corresponding to the second direction; for each target value, determining the target gradient corresponding to the target value based on the first foreground pixel in the first selection box and the second foreground pixel in the second selection box included in the selection box group corresponding to the target value, the target gradient being used to characterize the change in the number of the first foreground pixel and the number of the second foreground pixel; and locating at least two options based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction.

[0164] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements a method for locating answer sheet options provided by the methods described above, comprising: acquiring an answer sheet image to be identified, the answer sheet image including at least two options arranged in a matrix; dividing the answer sheet image into at least two selection box groups corresponding to each target value in two directions, the two directions including a first direction and a second direction that are perpendicular to each other, wherein in the first direction, the target value is used to indicate the target height of the first selection box in the selection box group corresponding to the first direction, and in the second direction, the target value is used to indicate the target width of the first selection box in the selection box group corresponding to the second direction; for each target value, determining a target gradient corresponding to the target value based on the first foreground pixel in the first selection box and the second foreground pixel in the second selection box included in the selection box group corresponding to the target value, the target gradient being used to characterize the change in the number of the first foreground pixel and the number of the second foreground pixel; and locating at least two options based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction.

[0165] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0166] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0167] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for locating answer sheet options, characterized in that, include: Obtain an image of an answer sheet to be identified, the image of which includes at least two options arranged in a matrix; In the two directions of the answer sheet image, at least two selection box groups are divided for each target value. The two directions include a first direction and a second direction that are perpendicular to each other. In the first direction, the target value is used to indicate the target height of the first selection box in the selection box group corresponding to the first direction. In the second direction, the target value is used to indicate the target width of the first selection box in the selection box group corresponding to the second direction. For each target value, based on the number of first foreground pixels in the first selection box and the number of second foreground pixels in the second selection box included in the selection box group corresponding to the target value, as well as the number of first foreground pixels in all first selection boxes and the number of second foreground pixels in all second selection boxes corresponding to the previous target value, the target gradient corresponding to the target value is determined, and the target gradient is used to characterize the change in the number of first foreground pixels and the number of second foreground pixels; Based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction, the largest target gradient in the first direction and the second direction are determined respectively, and the at least two options are located according to the first selection box corresponding to the largest target gradient in their respective directions.

2. The method for locating answer sheet options according to claim 1, characterized in that, The step of determining the target gradient corresponding to the target value based on the number of first foreground pixels in the first selection box and the number of second foreground pixels in the second selection box included in the selection box group corresponding to the target value, as well as the number of first foreground pixels in all first selection boxes and the number of second foreground pixels in all second selection boxes corresponding to the previous target value, includes: Determine the first number of first foreground pixels in all first selection boxes corresponding to the current target value, and the second number of second foreground pixels in all second selection boxes; the target value is iterated within a preset range. Get the third number of first foreground pixels in all first selection boxes corresponding to the previous target value, and the fourth number of second foreground pixels in all second selection boxes; Based on the current target value, the previous target value, the first quantity, the second quantity, the third quantity, and the fourth quantity, the target gradient corresponding to the target value is determined.

3. The method for locating answer sheet options according to claim 2, characterized in that, The step of determining the target gradient corresponding to the target value based on the current target value, the previous target value, the first quantity, the second quantity, the third quantity, and the fourth quantity includes: Determine a first difference between the first quantity and the second quantity, and determine a second difference between the third quantity and the fourth quantity; Determine a third difference between the first difference and the second difference, and determine a fourth difference between the current target value and the previous target value; Based on the third and fourth differences, the target gradient corresponding to the target value is determined.

4. The method for locating answer sheet options according to any one of claims 1-3, characterized in that, Based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction, the maximum target gradient in the first direction and the second direction are determined respectively, and the at least two options are located according to the first selection box corresponding to the maximum target gradient in their respective directions, including: Among all target gradients corresponding to the first direction, determine the largest first target gradient, and among all target gradients corresponding to the second direction, determine the largest second target gradient; Based on the first selection box corresponding to the first target gradient and the second target gradient in their respective directions, the at least two options are located.

5. The method for locating answer sheet options according to claim 4, characterized in that, The step of locating the at least two options based on the first selection boxes corresponding to the first target gradient and the second target gradient in their respective directions includes: Determine the first selection box corresponding to the first target gradient, and the first selection box corresponding to the second target gradient; The overlapping area of ​​the first selection box corresponding to the first target gradient and the first selection box corresponding to the second target gradient is determined as the location of the corresponding option.

6. The method for locating answer sheet options according to claim 5, characterized in that, After determining the overlapping area of ​​the first selection box corresponding to the first target gradient and the first selection box corresponding to the second target gradient as the location of the corresponding option, the method further includes: Determine the center position of each option included within each of the overlapping regions; For either the first or the second direction, when it is determined that all center positions are not located on the same standard line, the position of the option corresponding to the center position that deviates from the standard line is corrected based on the standard line.

7. The method for locating answer sheet options according to any one of claims 1-3, characterized in that, The process of dividing each target value into at least two selection boxes includes: Based on the identification information in the answer sheet image, obtain the answer sheet template corresponding to the answer sheet image; Based on the answer sheet template, determine the layout information of at least two options in the answer sheet image; Based on the layout information, the target number of selection box groups corresponding to each of the two directions of the answer sheet image is determined respectively; Divide the target value into a number of selection boxes corresponding to the target quantity.

8. A device for positioning answer sheet options, characterized in that, include: An acquisition module is used to acquire an answer sheet image to be identified, the answer sheet image including at least two options arranged in a matrix; The segmentation module is used to divide the answer sheet image into at least two selection box groups corresponding to each target value in two directions. The two directions include a first direction and a second direction that are perpendicular to each other. In the first direction, the target value is used to indicate the target height of the first selection box in the selection box group corresponding to the first direction. In the second direction, the target value is used to indicate the target width of the first selection box in the selection box group corresponding to the second direction. The determination module is used to determine the target gradient corresponding to each target value based on the number of first foreground pixels in the first selection box and the number of second foreground pixels in the second selection box included in the selection box group corresponding to the target value, as well as the number of first foreground pixels in all first selection boxes and the number of second foreground pixels in all second selection boxes corresponding to the previous target value. The target gradient is used to characterize the change in the number of first foreground pixels and the number of second foreground pixels. The positioning module is used to determine the largest target gradient in the first direction and the second direction based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction, and to position the at least two options according to the first selection box corresponding to the largest target gradient in each direction.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method for locating answer sheet options as described in any one of claims 1 to 7.

10. An electronic device comprising a camera, a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The camera is used to capture an image of the answer sheet to be recognized; the processor is used to divide the answer sheet image into at least two selection box groups corresponding to each target value in two directions, the two directions including a first direction and a second direction that are perpendicular to each other. In the first direction, the target value is used to indicate the target height of the first selection box in the selection box group corresponding to the first direction, and in the second direction, the target value is used to indicate the target width of the first selection box in the selection box group corresponding to the second direction. For each target value, based on the number of first foreground pixels in the first selection box and the number of second foreground pixels in the second selection box included in the selection box group corresponding to the target value, as well as the number of first foreground pixels in all first selection boxes and the number of second foreground pixels in all second selection boxes corresponding to the previous target value, the target gradient corresponding to the target value is determined. The target gradient is used to characterize the change in the number of first foreground pixels and the number of second foreground pixels. Based on each target gradient corresponding to the first direction and each target gradient corresponding to the second direction, the largest target gradient in the first direction and the second direction are determined respectively, and the at least two options are located according to the first selection box corresponding to the largest target gradient in their respective directions.

11. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the method for locating answer sheet options as described in any one of claims 1 to 7.