Method and device for intelligently determining defect positions of answer sheet images based on visual recognition
Through visual recognition technology, the location of the corners, scratches and black edge defects in the answer sheet are determined and color correction is carried out, which solves the problem that defects in the existing technology affect the scanning results, and improves the reliability and accuracy of the answer sheet marking.
Patent Information
- Application Number
- CN202411266825.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-11
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2044-09-11
AI Technical Summary
The prior art is difficult to effectively determine and eliminate the corners, scratches and black edge defects in the answer sheet, which affects the reliability of the scanning results.
Using a visual recognition-based method, by obtaining the shapes of corner areas, straight lines and connecting domains in the answer sheet image, combining preset length and proportion, the positions of corners, scratches and black edge defects are determined, and color correction is performed to eliminate defects.
It improves the reliability of the answer sheet marking results, accurately identify and eliminate defects, and improves the completeness and accuracy of the scan results.
Smart Images

Figure CN118781603B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence, and in particular to a method and device for intelligently determining the position of a defect in an answer sheet image based on visual recognition. Background Art
[0002] In order to reduce the intensity of grading, it is becoming more and more common to use answer sheet scanners for grading. In complex actual situations, answer sheets will have various defects (such as black edges, folded corners, scratches, etc.), which will seriously affect the scanning results of answer sheet scanners, and thus affect the reliability of answer sheet grading results.
[0003] Therefore, how to determine the defects and defect locations in the answer sheet has become an urgent problem to be solved. Summary of the invention
[0004] In view of this, the purpose of the present application is to provide a method and device for intelligently determining the defect positions of answer sheet images based on visual recognition, which can determine the positions of corner defects, scratch defects and black edge defects in the answer sheet image and eliminate them, thereby improving the reliability of the answer sheet grading results.
[0005] In a first aspect, an embodiment of the present application provides a method for intelligently determining the position of a defect in an answer sheet image based on visual recognition, and the method for intelligently determining the position of a defect in an answer sheet image based on visual recognition includes:
[0006] Obtain the corner area image, background color, and target straight line whose length exceeds a preset length in the target answer sheet image;
[0007] According to the shape of the connected domain corresponding to the target connected domain in the corner area image and the proportion of black pixels in the corner area image, the corner defect position in the target answer sheet image is determined; the target connected domain is determined based on the proportion of black pixels in the minimum external bounding box corresponding to each connected domain in the corner area image;
[0008] The position of the target pixel whose color is the background color on the target straight line is determined as the scratch defect position in the target answer sheet image; the adjacent pixel refers to the pixel adjacent to the target pixel in the vertical direction of the target straight line;
[0009] The positions of multiple consecutive windows in which the proportion of black pixels in the target answer sheet image exceeds a preset proportion are determined as the positions of black edge defects in the target answer sheet image; wherein the preset length and the size of the window are determined based on the size of the target answer sheet.
[0010] In a possible implementation, the target straight line includes a target horizontal straight line and a target vertical straight line, and the preset length includes a preset horizontal length and a preset vertical length. The target straight line in the target answer sheet image is determined by the following steps:
[0011] Detect the straight line in the target answer sheet image and obtain the initial straight line;
[0012] Determine an initial straight line whose slope is within a first preset slope range as a horizontal straight line, and determine an initial straight line whose slope is within a second preset slope range as a vertical straight line;
[0013] A horizontal straight line whose length exceeds a preset horizontal length is determined as a target horizontal straight line, and a vertical straight line whose length exceeds a preset vertical length is determined as a target vertical straight line; the preset horizontal length and the preset vertical length are determined based on the size of the target answer sheet.
[0014] In a possible implementation, determining the corner defect position in the target answer sheet image according to the connected domain shape corresponding to the target connected domain in the corner area image and the proportion of black pixels in the corner area image includes:
[0015] A connected domain in which the proportion of black pixels in the minimum external frame in the corner area image is greater than a first preset proportion of black pixels is determined as an initial connected domain; the proportion of black pixels in the minimum external frame corresponding to the connected domain refers to the proportion of black pixels in the connected domain in the minimum external frame of the connected domain;
[0016] The largest area in the initial connected domain is determined as the target connected domain;
[0017] Determine whether the proportion of black pixels in the corner area image corresponding to the target connected domain is greater than a second preset black pixel proportion; the proportion of black pixels in the corner area image refers to the proportion of black pixels in the target connected domain in the corner area image;
[0018] If the proportion of black pixels in the corner area image corresponding to the target connected domain is greater than the second preset proportion of black pixels, determining whether the shape of the connected domain corresponding to the target connected domain is a triangle;
[0019] If the shape of the connected domain corresponding to the target connected domain is a triangle, the position of the target connected domain in the corner area image is determined as the corner defect position in the target answer sheet image.
[0020] In a possible implementation, the window includes a horizontal window and a vertical window; the size of the window is determined by the following steps:
[0021] The width of the target answer sheet image is determined as the width of the horizontal window, and the preset height is determined as the height of the horizontal window;
[0022] The height of the target answer sheet image is determined as the height of the vertical window, and the preset width is determined as the width of the vertical window.
[0023] In a possible implementation, the preset proportion includes a preset horizontal proportion and a preset vertical proportion; determining the positions of a plurality of consecutive windows in which the proportion of black pixels in the target answer sheet image exceeds the preset proportion as the positions of black edge defects in the target answer sheet image includes:
[0024] The positions of the continuous multiple horizontal windows where the proportion of black pixels in the target answer sheet image exceeds the preset horizontal proportion are determined as the positions of the black edge defects in the target answer sheet image; the preset horizontal proportion is determined based on the width of the target answer sheet;
[0025] The positions of multiple consecutive vertical windows where the proportion of black pixels in the target answer sheet image exceeds a preset vertical proportion are determined as the positions of black edge defects in the target answer sheet image; the preset vertical proportion is determined based on the height of the target answer sheet.
[0026] In a possible implementation, the positions of a plurality of continuous horizontal windows where the proportion of black pixels in the target answer sheet image exceeds a preset horizontal proportion are determined as the positions of black edge defects in the target answer sheet image, including:
[0027] Slide the horizontal window downward and upward respectively from the upper end and the lower end of the target answer sheet image;
[0028] If the black pixel ratio of the current sliding horizontal window exceeds the preset horizontal ratio, and the sliding distance is less than the first preset distance, the horizontal window continues to slide; the first preset distance is determined based on the height of the target answer sheet;
[0029] If the black pixel ratio of the current sliding horizontal window is less than or equal to the preset horizontal ratio, the sliding horizontal window is terminated;
[0030] After the sliding is completed, the positions of the continuous multiple horizontal windows sliding in the target answer card image are determined as the black edge defect positions in the target answer card image.
[0031] In a possible implementation, the positions of a plurality of consecutive vertical windows in which the proportion of black pixels in the target answer sheet image exceeds a preset vertical proportion are determined as the positions of black edge defects in the target answer sheet image, including:
[0032] Starting from the left and right ends of the target answer sheet image, slide the vertical window to the right and left respectively;
[0033] If the black pixel ratio of the current sliding vertical window exceeds the preset vertical ratio, and the sliding distance is less than the second preset distance, the vertical window continues to slide; the second preset distance is determined based on the width of the target answer sheet;
[0034] If the black pixel ratio of the current sliding vertical window is less than or equal to the preset vertical ratio, the sliding vertical window is terminated;
[0035] After the sliding is completed, the positions of the continuous multiple vertical windows sliding in the target answer card image are determined as the black edge defect positions in the target answer card image.
[0036] In a possible implementation, the method further includes:
[0037] Correct the color of the pixel at the corner defect position in the target answer sheet image to the background color;
[0038] Correct the color of the pixel at the scratch defect position in the target answer sheet image to the background color;
[0039] Correct the color of the pixel points at the black edge defect position in the target answer sheet image to the background color.
[0040] In a second aspect, the embodiment of the present application further provides a device for intelligently determining the position of a defect in an answer sheet image based on visual recognition, the device comprising:
[0041] An acquisition module is used to acquire a corner area image, a background color, and a target straight line whose length exceeds a preset length in a target answer sheet image;
[0042] A determination module is used to determine the corner defect position in the target answer sheet image according to the shape of the connected domain corresponding to the target connected domain in the corner area image and the proportion of black pixels in the corner area image; the target connected domain is determined based on the proportion of black pixels in the minimum external bounding box corresponding to each connected domain in the corner area image;
[0043] The determination module is further used to determine the position of the target pixel whose color of the adjacent pixel on the target straight line is the background color as the scratch defect position in the target answer sheet image; the adjacent pixel refers to the pixel adjacent to the target pixel in the vertical direction of the target straight line;
[0044] The determination module is also used to determine the positions of multiple consecutive windows in which the proportion of black pixels in the target answer sheet image exceeds a preset proportion as the positions of black edge defects in the target answer sheet image; wherein the preset length and the size of the window are determined based on the size of the target answer sheet.
[0045] In the third aspect, an embodiment of the present application also provides an electronic device, comprising: a processor, a storage medium and a bus, the storage medium storing machine-readable instructions executable by the processor, when the electronic device is running, the processor and the storage medium communicate through the bus, and the processor executes the machine-readable instructions to perform the steps of the method for intelligently determining the position of answer sheet image defects based on visual recognition as any one of the first aspects.
[0046] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the method for intelligently determining the location of defects in an answer sheet image based on visual recognition as described in any one of the first aspects are executed.
[0047] The embodiment of the present application provides a method and device for intelligently determining the defect position of an answer sheet image based on visual recognition, the method comprising: obtaining a corner area image, a background color, and a target straight line whose straight line length exceeds a preset length in a target answer sheet image; determining the corner defect position in the target answer sheet image according to the connected domain shape corresponding to the target connected domain in the corner area image and the proportion of black pixels in the corner area image; the target connected domain is determined based on the proportion of black pixels in the minimum circumscribed frame corresponding to each connected domain in the corner area image; and determining the position of the target pixel point whose adjacent pixel point on the target straight line has the background color as the scratch defect position in the target answer sheet image; the adjacent pixel point refers to the pixel point adjacent to the target pixel point in the vertical direction of the target straight line; and determining the position of a plurality of consecutive windows whose proportion of black pixels in the target answer sheet image exceeds a preset proportion as the black edge defect position in the target answer sheet image; wherein the preset length and the size of the window are determined based on the size of the target answer sheet. The present application can determine the corner defect position, scratch defect position, and black edge defect position in the answer sheet image, thereby improving the reliability of the answer sheet grading results. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0049] Figure 1 A flow chart of a method for intelligently determining the position of a defect in an answer sheet image based on visual recognition provided by an embodiment of the present application is shown;
[0050] Figure 2 A schematic diagram showing images of four corner areas in an answer sheet image provided in an embodiment of the present application is shown;
[0051] Figure 3 A flowchart of another method for intelligently determining the position of a defect in an answer sheet image based on visual recognition provided by an embodiment of the present application is shown;
[0052] Figure 4 A flowchart of answer sheet image defect detection provided by an embodiment of the present application is shown;
[0053] Figure 5 A flow chart of the answer sheet subject detection provided by an embodiment of the present application is shown;
[0054] Figure 6 A schematic diagram of the structure of a device for intelligently determining the position of a defect in an answer sheet image based on visual recognition provided in an embodiment of the present application is shown;
[0055] Figure 7 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0056] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.
[0057] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0058] In order to enable those skilled in the art to use the content of this application, the following implementation is provided in conjunction with the specific application scenario "artificial intelligence field". For those skilled in the art, the general principles defined herein can be applied to other embodiments and application scenarios without departing from the spirit and scope of this application. Although this application is mainly described around the "artificial intelligence field", it should be understood that this is only an exemplary embodiment.
[0059] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.
[0060] The following is a detailed description of a method for intelligently determining the location of answer sheet image defects based on visual recognition provided in an embodiment of the present application.
[0061] Reference Figure 1 As shown, it is a flowchart of a method for intelligently determining the position of an answer sheet image defect based on visual recognition provided by an embodiment of the present application. The exemplary steps of the embodiment of the present application are described below:
[0062] S101, obtaining a corner area image, a background color, and a target straight line whose length exceeds a preset length in a target answer sheet image.
[0063] In the implementation manner of the present application, the target answer sheet image refers to the image of the target answer sheet (referring to the answer sheet whose defect location needs to be determined) scanned by the answer sheet scanner. The corner area image refers to the image at the corner position of the target answer sheet image. The target answer sheet image may contain one or more corner area images; refer to Figure 2 As shown, it is a schematic diagram of the images of the four corner areas in the answer sheet image provided in the embodiment of the present application. The background color refers to the color of the area other than the text area and the symbol area in the target answer sheet (generally white). The target straight line includes a target horizontal straight line and a target vertical straight line; the preset length is determined based on the size of the target answer sheet, including a preset horizontal length and a preset vertical length; specifically, the preset horizontal length = A*the width of the target answer sheet; the preset vertical length = B*the height of the target answer sheet; wherein A and B are preset multiples, generally taking a value of 0.98.
[0064] Furthermore, the target straight line in the target answer sheet image is determined by the following steps:
[0065] Step 1: Detect the straight line in the target answer sheet image and obtain the initial straight line.
[0066] In the implementation manner of the present application, the target answer sheet image is preprocessed; a straight line in the preprocessed target answer sheet image is detected by the Hough transform method, and the straight line is used as the initial straight line. There may be 0, 1 or more initial straight lines in the target answer sheet image.
[0067] Among them, the preprocessing can be to first use a 5×5 structure element Gaussian filter, then use Canny to find the edge to extract the edge in the image after Gaussian filtering, and finally use the 5×5 structure element to dilate the image after edge extraction. Hough transform is a technology widely used in image processing, mainly used to detect shapes in images, especially straight lines and curves. The basic idea of Hough transform is to map the pixels in the image to the parameter space by constructing a mathematical analytical expression for detecting the shape. Through this mapping, the Hough transform converts the detection problem in the image space into the parameter space, and completes the detection task through relatively simple cumulative statistics.
[0068] Step 2: determine the initial straight line whose slope is within the first preset slope range as the horizontal straight line, and determine the initial straight line whose slope is within the second preset slope range as the vertical straight line.
[0069] In the implementation manner of the present application, the first preset slope range is If the slope of the initial straight line is within the first preset slope range, the initial straight line is a horizontal straight line. The second preset slope range is and If the slope of the initial straight line is within the second preset slope range, the initial straight line is a vertical straight line.
[0070] Step 3: Determine a horizontal straight line whose length exceeds a preset horizontal length as a target horizontal straight line, and determine a vertical straight line whose length exceeds a preset vertical length as a target vertical straight line.
[0071] In the embodiment of the present application, if the length of the horizontal straight line exceeds the preset horizontal length, it means that the horizontal straight line is a scratch. If the length of the vertical straight line exceeds the preset vertical length, it means that the vertical straight line is a scratch.
[0072] S102, determining the corner defect position in the target answer sheet image according to the connected domain shape corresponding to the target connected domain in the corner area image and the proportion of black pixels in the corner area image.
[0073] In the implementation mode of the present application, the corner area image is binarized, and the connected domain of black pixels in the binarized corner area image is searched through a connected domain search algorithm; the target connected domain is determined based on the proportion of black pixels in the minimum external frame corresponding to each connected domain in the corner area image. The ratio of the number of black pixels in the connected domain to the total number of pixels in the minimum external frame of the connected domain is determined as the proportion of black pixels in the minimum external frame corresponding to the connected domain; that is, the proportion of black pixels in the minimum external frame corresponding to the connected domain refers to the proportion of black pixels in the connected domain in the minimum external frame of the connected domain. The ratio of the number of black pixels in the target connected domain to the total number of pixels in the corner area image is determined as the proportion of black pixels in the corner area image corresponding to the target connected domain; that is, the proportion of black pixels in the corner area image refers to the proportion of black pixels in the target connected domain in the corner area image.
[0074] Specifically, the following steps are performed to determine the corner defect position in the target answer sheet image according to the connected domain shape corresponding to the target connected domain in the corner area image and the proportion of black pixels in the corner area image.
[0075] Step 1: Determine a connected domain in which the proportion of black pixels in the smallest bounding box in the corner area image is greater than a first preset proportion of black pixels as an initial connected domain.
[0076] In the implementation manner of the present application, the greater the proportion of black pixels in the minimum circumscribed frame, the greater the possibility that the position of the connected domain in the target answer sheet image is the position of the corner defect. The first preset black pixel proportion can be determined according to the actual situation. If the proportion of black pixels in the minimum circumscribed frame corresponding to all connected domains is less than or equal to the first preset black pixel proportion, no further judgment is made, and it is directly deemed that there is no corner defect in the answer sheet image. If the proportion of black pixels in the minimum circumscribed frame corresponding to the target connected domain is greater than the first preset black pixel proportion, it means that the position of the connected domain may be the position of the corner defect, so the connected domain in the corner area image whose proportion of black pixels in the minimum circumscribed frame is greater than the first preset black pixel proportion is determined as the initial connected domain.
[0077] Step 2: Determine the target connected domain with the largest area in the initial connected domain.
[0078] In the implementation manner of the present application, generally, the area of the corner defect position is the largest, so the area of the largest initial connected domain is determined as the target connected domain.
[0079] Step 3: Determine whether the proportion of black pixels in the corner area image corresponding to the target connected domain is greater than a second preset proportion of black pixels.
[0080] In the implementation mode of the present application, in order to improve the accuracy of corner defect detection, it is further determined whether the proportion of black pixels in the corner area image corresponding to the target connected domain is greater than the second preset black pixel proportion; the greater the proportion of black pixels in the corner area image, the greater the possibility that the position of the target connected domain in the target answer sheet image is the position of the corner defect. The second preset black pixel proportion can be determined according to actual conditions. If the proportion of black pixels in the corner area image corresponding to the target connected domain is less than or equal to the second preset black pixel proportion, the determination is no longer continued, and it is directly deemed that there is no corner defect in the target answer sheet image.
[0081] Step 4: If the proportion of black pixels in the corner area image corresponding to the target connected domain is greater than the second preset proportion of black pixels, it is determined whether the shape of the connected domain corresponding to the target connected domain is a triangle.
[0082] In the implementation manner of the present application, in addition to judging the proportion of black pixels in the minimum circumscribed frame corresponding to the target connected domain and the proportion of black pixels in the corner area image, it is also necessary to judge the shape of the target connected domain to further improve the accuracy of corner defect detection.
[0083] Step 5: If the shape of the connected domain corresponding to the target connected domain is a triangle, the position of the target connected domain in the corner area image is determined as the position of the corner defect in the target answer sheet image.
[0084] In the implementation manner of the present application, corner defects are generally triangles. Therefore, if the shape of the connected domain corresponding to the target connected domain is a triangle, the position of the target connected domain in the corner area image is determined as the corner defect position in the target answer sheet image.
[0085] In addition, if the corner defect has other shapes, it can also be added to the judgment. The triangle here refers to one case, and other shapes can also be added according to the actual situation.
[0086] S103, determining the position of the target pixel whose adjacent pixel on the target straight line has the background color as the scratch defect position in the target answer sheet image.
[0087] In the implementation of the present application, adjacent pixel points refer to the pixel points adjacent to the target pixel point in the vertical direction of the target straight line. In actual situations, the pixel points of the target straight line may overlap with the original text, symbols, etc. in the target answer sheet image. Such overlapping pixel points cannot be considered as the scratch defect position, so it is necessary to judge again based on the color of the adjacent pixel points to improve the accuracy of the determination of the scratch defect position.
[0088] For example, there is a pixel a on the target line, and the adjacent pixels in the vertical direction of the target line are b and c; if the colors of pixel b and pixel c are the background colors corresponding to the target answer sheet image, then the position of pixel a is the scratch defect position. If the color of either pixel b or pixel c is not the background color, then the position of pixel a should not be considered as the scratch defect position.
[0089] S104, determining the positions of multiple consecutive windows in which the proportion of black pixels in the target answer sheet image exceeds a preset proportion as the positions of black edge defects in the target answer sheet image.
[0090] In the implementation mode of the present application, the preset proportion includes a preset horizontal proportion and a preset vertical proportion. The size of the window is determined based on the size of the target answer sheet, and the window includes a horizontal window and a vertical window. The width of the target answer sheet image is determined as the width of the horizontal window, and the preset height (generally 5) is determined as the height of the horizontal window; the height of the target answer sheet image is determined as the height of the vertical window, and the preset width (generally 5) is determined as the width of the vertical window.
[0091] Specifically, the positions of multiple consecutive horizontal windows in which the proportion of black pixels in the target answer sheet image exceeds a preset horizontal proportion are determined as the positions of black edge defects in the target answer sheet image; the positions of multiple consecutive vertical windows in which the proportion of black pixels in the target answer sheet image exceeds a preset vertical proportion are determined as the positions of black edge defects in the target answer sheet image.
[0092] Furthermore, after the defect position of the answer sheet image is determined, the defect of the answer sheet image can be eliminated. Specifically, the color of the pixel point at the corner defect position in the target answer sheet image is corrected to the background color; the color of the pixel point at the scratch defect position in the target answer sheet image is corrected to the background color; the color of the pixel point at the black edge defect position in the target answer sheet image is corrected to the background color.
[0093] Reference Figure 3 As shown, it is a flow chart of another method for intelligently determining the position of an answer sheet image defect based on visual recognition provided by an embodiment of the present application. The exemplary steps of the embodiment of the present application are described below:
[0094] S301, determining the positions of multiple continuous horizontal windows where the proportion of black pixels in the target answer sheet image exceeds a preset horizontal proportion as the positions of black edge defects in the target answer sheet image.
[0095] In the implementation mode of the present application, the preset horizontal proportion is determined based on the width of the target answer sheet; the preset horizontal proportion = C*the width of the target answer sheet, where C is a preset multiple, generally 0.8. The target answer sheet image is preprocessed by grayscale or binarization to obtain the final target answer sheet image; then the positions of the continuous multiple horizontal windows where the proportion of black pixels in the target answer sheet image exceeds the preset horizontal proportion are determined as the positions of the black edge defects in the target answer sheet image through the following steps:
[0096] Step 1: Slide the horizontal window downward and upward from the top and bottom of the target answer sheet image respectively.
[0097] In the implementation manner of the present application, for the horizontal window, there are two sliding directions: sliding downward from the upper end of the target answer sheet image and sliding upward from the lower end of the target answer sheet image.
[0098] Step 2: If the black pixel ratio of the current sliding horizontal window exceeds the preset horizontal ratio and the sliding distance is less than the first preset distance, continue to slide the horizontal window; the first preset distance is determined based on the height of the target answer sheet image.
[0099] In the implementation manner of the present application, the first preset distance is generally 1 / 4 of the height of the target answer sheet image. The greater the proportion of black pixels in the currently sliding horizontal window, the greater the possibility that the currently sliding horizontal window has a black border.
[0100] Specifically, for each sliding direction, if the black pixel ratio of the current sliding horizontal window in the sliding direction exceeds the preset horizontal ratio, and the sliding distance is less than the first preset distance, the horizontal window continues to slide.
[0101] Here, if the proportion of black pixels in the current sliding horizontal window in the sliding direction exceeds the preset horizontal proportion, it means that the current sliding horizontal window has a black border.
[0102] Step 3: If the black pixel ratio of the current sliding horizontal window is less than or equal to the preset horizontal ratio, the sliding horizontal window is terminated.
[0103] In an implementation manner of the present application, if the proportion of black pixels in the current sliding horizontal window in the sliding direction does not exceed the preset horizontal proportion, the current sliding horizontal window is not a black border, and the sliding of the horizontal window is ended.
[0104] Step 4: After the sliding is completed, the positions of the continuous multiple horizontal windows sliding in the target answer sheet image are determined as the positions of the black edge defects in the target answer sheet image.
[0105] In the implementation of the present application, the black edge defect area generally includes multiple consecutive windows, not just one, so in the sliding direction, the positions of the multiple consecutive horizontal windows sliding in the target answer sheet image are determined as the black edge defect position in the target answer sheet image. If there are no multiple consecutive horizontal windows, it means that there is no black edge defect in this direction.
[0106] S302, determining the positions of multiple consecutive vertical windows where the proportion of black pixels in the target answer sheet image exceeds a preset vertical proportion as the positions of black edge defects in the target answer sheet image.
[0107] In the implementation mode of the present application, the preset vertical ratio is determined based on the height of the target answer sheet. The preset vertical ratio = D * the height of the target answer sheet, where D is a preset multiple, generally 0.8. The target answer sheet image is preprocessed by grayscale or binarization to obtain the final target answer sheet image; then the positions of the continuous multiple vertical windows where the black pixel ratio in the target answer sheet image exceeds the preset vertical ratio are determined as the black edge defect positions in the target answer sheet image through the following steps:
[0108] Step 1: Starting from the left and right ends of the target answer sheet image, slide the vertical window to the right and left respectively.
[0109] In the implementation manner of the present application, the vertical window includes two sliding directions: sliding from the left end of the target answer sheet image to the right, and sliding from the right end of the target answer sheet image to the left.
[0110] Step 2: If the black pixel ratio of the current sliding vertical window exceeds the preset vertical ratio, and the sliding distance is less than the second preset distance, continue to slide the vertical window; the second preset distance is determined based on the width of the target answer sheet.
[0111] In the implementation manner of the present application, the second preset distance is generally 1 / 4 of the width of the target answer sheet image. The greater the proportion of black pixels in the currently sliding vertical window, the greater the possibility that the currently sliding vertical window has a black border.
[0112] Specifically, for each sliding direction, if the black pixel ratio of the current sliding vertical window in the sliding direction exceeds the preset vertical ratio, and the sliding distance is less than the second preset distance, the vertical window continues to slide.
[0113] Here, if the black pixel ratio of the current sliding vertical window in the sliding direction exceeds the preset vertical ratio, it means that the current sliding vertical window has a black border.
[0114] Step 3: If the black pixel ratio of the current sliding vertical window is less than or equal to the preset vertical ratio, the sliding vertical window is terminated.
[0115] In an embodiment of the present application, if the black pixel ratio of the current sliding vertical window in the sliding direction does not exceed the preset vertical ratio, the current sliding horizontal window is not a black border, and the sliding vertical window is ended.
[0116] Step 4: After the sliding is completed, the positions of the continuous multiple vertical windows sliding in the target answer sheet image are determined as the positions of the black edge defects in the target answer sheet image.
[0117] In the implementation of the present application, the black edge defect area generally includes multiple consecutive windows, not just one, so in the sliding direction, the positions of the multiple consecutive vertical windows sliding in the target answer sheet image are determined as the black edge defect position in the target answer sheet image. If there are no multiple consecutive vertical windows, it means that there is no black edge defect in this direction.
[0118] The method of the present application can accurately determine the location of the black edge defect, thereby improving the accuracy of the answer sheet grading results.
[0119] Furthermore, the method for intelligently determining the position of defect in the answer sheet image based on visual recognition can also detect defects such as integrity and blank pages in the answer sheet image. Figure 4 As shown, it is a flowchart of answer sheet image defect detection provided by an embodiment of the present application; specifically, it includes:
[0120] S401, obtaining the answer sheet images in the scanning group corresponding to the target answer sheet image.
[0121] In the implementation manner of the present application, a single student answer sheet may have multiple answer sheets, and all answer sheets of the same student are taken as answer sheets of a scanning group, and all answer sheets of a certain student are scanned in sequence by an answer sheet scanner to obtain answer sheet images;
[0122] S402: If the number of answer sheet images in the scan group is equal to the number of answer sheets of a single student, then answer sheet integrity detection is performed on the answer sheet images in the scan group according to the number of matches between corresponding positions of every two answer sheet images in the scan group.
[0123] In the implementation manner of the present application, the number of answer sheets for a single student refers to the total number of answer sheets for a student. If the number of answer sheet images in the scan group is equal to the number of single answer sheets, it means that all the answer sheets of a certain student have been scanned. However, due to some human factors, there may be anomalies such as the scan group containing answer sheet images of multiple students or the answer sheet of a student being missing pages. Therefore, when the number of answer sheet images in the scan group is equal to the number of single student answer sheets, the answer sheet integrity check is performed on the answer sheet images in the scan group.
[0124] Among them, the answer sheet integrity detection refers to detecting whether there are repeated missing pages of a single student's answer sheet, missing pages of a single student's answer sheet, and confusion of answer sheets between students in the answer sheet images within the scanning group. Here, repeated missing pages of a single student's answer sheet refers to the repeated scanning of a student's answer sheet resulting in the lack of an image of a certain answer sheet of the student; missing pages of a single student's answer sheet refers to the lack of an image of a certain answer sheet of the student; confusion of answer sheets between students refers to the existence of answer sheet images of multiple students in the scanning group.
[0125] Specifically, according to the number of matches between corresponding positions of every two answer sheet images in the scan group, the answer sheet integrity detection is performed on the answer sheet images in the scan group, including:
[0126] Step 1: For every two answer sheet images in the scan group, count the number of matches between corresponding positions in all positions of the two answer sheet images.
[0127] In the implementation mode of the present application, each pixel point is used as a detection position, and the SIFT algorithm is used to count the number of matches of the corresponding positions in all positions of the two answer sheet images. For example, the answer sheet image includes only two positions, a and b, and it is determined whether position a in the first answer sheet image matches position a in the second answer sheet image, and whether position b in the first answer sheet image matches position b in the second answer sheet image, and the number of successful matches is counted to obtain the number of matches of the corresponding positions in all positions of the two answer sheet images.
[0128] Step 2: If the number of matches of corresponding positions in all positions of the two answer sheet images is greater than a first preset number, then the answer sheet images in the scan group have a single student answer sheet with duplicate missing pages.
[0129] In the implementation manner of the present application, the greater the number of matches, the greater the similarity of the two answer sheet images. If the number of matches of the corresponding positions in all positions of the two answer sheet images is greater than the first preset number, it means that the two answer sheet images are exactly the same, and therefore it means that there are duplicated answer sheets in the answer sheet images in the scan group, resulting in a single student's answer sheet missing page, that is, there is a single student's answer sheet duplicate missing page anomaly in the answer sheet images in the scan group.
[0130] Among them, the ratio of the first preset number to the total number of answer sheet image positions needs to be very large, so as to accurately indicate whether the two answer sheet images are images of the same answer sheet of the same student, and whether there is a single student's answer sheet duplicate missing page anomaly.
[0131] Step 3: If the number of matches of corresponding positions in all positions of the two answer sheet images is less than or equal to a first preset number, the number of matches of corresponding positions in preset key positions of the two answer sheet images is counted.
[0132] In an implementation manner of the present application, if the number of matches of corresponding positions in all positions of two answer sheet images is less than or equal to a first preset number, it means that the two answer sheet images are not images of the same answer sheet of the same student, then the number of matches of corresponding positions in the preset key positions of the two answer sheet images will continue to be counted.
[0133] Among them, the preset key position can be a title, page number, etc.
[0134] Step 4: If the number of matches of corresponding positions in the preset key positions of the two answer sheet images is greater than the second preset number, then there is an abnormality in the answer sheet images in the scanning group that a single student's answer sheet is missing a page or the answer sheets of different students are in disarray.
[0135] In the implementation manner of the present application, the greater the number of matches of corresponding positions in the preset key positions of the two answer sheet images, the higher the similarity of the two answer sheet images. On the premise that the two answer sheet images are not images of the same answer sheet of the same student, if the number of matches of corresponding positions in the preset key positions of the two answer sheet images is greater than the second preset number, it means that the two answer sheet images are images of the same page of answer sheets of different students, so there are anomalies in the answer sheet images of a single student with missing pages and anomalies in the disorder of answer sheets between students in the scanned group.
[0136] In addition, the present application can also determine missing page numbers and duplicate page numbers based on the page numbers of the answer sheet images in the scan group.
[0137] S403, calculating the blank page score of the target answer sheet image according to the window proportion of white pixels in the target answer sheet image exceeding the preset proportion.
[0138] In the implementation manner of the present application, the larger the blank page score is, the greater the possibility that the target answer sheet image is a blank page. The white pixel ratio refers to the ratio of the number of white pixels in the window to the total number of pixels in the window. The window ratio refers to the ratio of the number of windows whose white pixel ratio exceeds the preset ratio to the total number of windows. Among them, the window ratio includes the horizontal window ratio and the vertical window ratio, and the preset ratio includes the preset horizontal ratio and the preset vertical ratio.
[0139] Here, the window includes a horizontal window and a vertical window, and the size of the window is determined based on the size of the target answer sheet image; specifically, the width of the target answer sheet image is determined as the width of the horizontal window, and the preset height (generally 5) is determined as the height of the horizontal window; the height of the target answer sheet image is determined as the height of the vertical window, and the preset width (generally 5) is determined as the width of the vertical window.
[0140] Furthermore, the proportion of windows in which the proportion of white pixels in the target answer sheet image exceeds a preset proportion is determined by the following steps:
[0141] Step 1: determine the proportion of the horizontal window in which the proportion of white pixels in the target answer sheet image exceeds the preset horizontal proportion; the preset horizontal proportion is determined based on the width of the currently scanned answer sheet.
[0142] In the implementation manner of the present application, the proportion of horizontal windows refers to the ratio of the number of horizontal windows in which the proportion of white pixels exceeds the preset horizontal proportion to the total number of horizontal windows.
[0143] Specifically, starting from the upper or lower end of the target answer sheet image, slide the horizontal window downward or upward; count the number of horizontal windows in which the proportion of white pixels in the target answer sheet image exceeds the preset horizontal proportion to obtain the target number of horizontal windows; and determine the ratio of the target number of horizontal windows to the total number of horizontal windows sliding in the target answer sheet image as the horizontal window proportion.
[0144] For example, starting from the top or bottom of the target answer sheet image, slide the horizontal window downward or upward, and slide a total of 10 horizontal windows. Among them, the proportion of white pixels in 8 horizontal windows exceeds the preset horizontal proportion. Therefore, the number of target horizontal windows is 8, the total number of horizontal windows is 10, and the proportion of horizontal windows is 8 / 10.
[0145] Step 2: Determine the ratio of white pixels in the target answer sheet image that exceeds the preset vertical ratio and the ratio of the vertical window; the preset vertical ratio is determined based on the height of the currently scanned answer sheet.
[0146] In the implementation manner of the present application, the proportion of vertical windows refers to the ratio of the number of vertical windows in which the proportion of white pixels exceeds the preset vertical proportion to the total number of vertical windows.
[0147] Specifically, starting from the left or right end of the target answer sheet image, slide the vertical window to the right or left; count the number of vertical windows in which the proportion of white pixels in the target answer sheet image exceeds the preset vertical proportion to obtain the target vertical window number; determine the ratio of the target vertical window number to the total number of vertical windows sliding in the target answer sheet image as the vertical window proportion.
[0148] For example, starting from the left or right end of the target answer sheet image, slide the vertical window to the right or left, and slide a total of 10 vertical windows. Among them, the white pixel ratio of 8 vertical windows exceeds the preset vertical ratio. Therefore, the number of target vertical windows is 8, the total number of vertical windows is 10, and the vertical window ratio is 8 / 10.
[0149] Further, the window proportion in which the proportion of white pixels in the target answer sheet image exceeds the preset proportion is substituted into the following formula to calculate the blank page score of the target answer sheet image;
[0150] ;
[0151] in, is the blank page score of the target answer sheet image, is the horizontal window ratio, is the vertical window ratio, is the proportion of white pixels in the target answer sheet image, is the preset weight of the horizontal window ratio, is the preset weight of the vertical window ratio, is the preset weight of the proportion of white pixels in the target answer sheet image. Generally, a and b are 0.25, and c is 0.5.
[0152] Here, the proportion of white pixels in the target answer sheet image refers to the ratio of the number of white pixels in the target answer sheet image to the total number of white pixels in the target answer sheet image.
[0153] S404: If the blank page score is greater than the preset score, the target answer sheet image is a blank page.
[0154] Furthermore, the method for intelligently determining the position of defect in the answer sheet image based on visual recognition can also detect the subject of the answer sheet image, referring to Figure 5 As shown, it is a flowchart of the answer sheet subject detection provided by the embodiment of the present application; specifically including:
[0155] S501. Obtain the specified scanning subject category corresponding to the target answer sheet image.
[0156] In the implementation manner of the present application, the specified scanning subject category refers to the subject category (such as mathematics, Chinese, etc.) specified by the answer sheet scanner when scanning the target answer sheet image.
[0157] S502: Input the target answer sheet image into the subject recognition model to obtain the subject category corresponding to the target answer sheet image.
[0158] In the implementation mode of the present application, the subject recognition model is trained based on the sample image of the answer sheet and the corresponding subject category annotation. The subject category of the answer sheet image is recognized in real time by the trained subject recognition model, and the recognition result is compared with the specified current scan subject category. If the recognized subject category is inconsistent with the current scan subject category, a prompt message is returned to report the subject abnormality.
[0159] Here, the subject recognition model uses the LabelImg tool to annotate the answer sheet sample images and generate XML format data files. Then, these annotated answer sheet sample images are input into the YOLOv5 model that introduces the Multi-Head Self-Attention mechanism for training, and finally a subject recognition model that can identify different subject categories is obtained.
[0160] Among them, the multi-head self-attention mechanism processes the input features through multiple attention heads in parallel, calculates the attention score in each attention head, and then forms a global feature representation by weighted summation of these scores. Finally, these global features are combined with the original features and input into the subsequent network layers for further processing. This method ensures the accuracy of subject recognition during the scanning process, helps to timely discover and correct subject errors that may occur during the scanning process, and improves the overall reliability of answer sheet scanning. After introducing the multi-head self-attention mechanism, the model can better capture important information in the answer sheet image, reduce misjudgments and missed judgments, and thus improve the overall performance of subject recognition.
[0161] Specifically, first, the input answer sheet image is adjusted to a fixed size and then enters the model. The backbone network (Backbone) extracts multi-scale features through CSPDarknet53, and then these features are processed by the multi-head self-attention mechanism to obtain attention scores. The self-attention mechanism weights and sums these scores to form a global feature map, which enhances the ability to capture details and global information. Then, these global feature maps are multi-scale feature fused through the multi-head self-attention mechanism to further improve the feature representation ability. Then, the fused feature map enters the head network (Head) to generate bounding boxes, predict output confidence and categories. Finally, the overlapping prediction boxes are filtered by the NMS algorithm to output the exact location and subject category marked on the answer sheet. This structure that combines YOLO-v5 and the multi-head self-attention mechanism improves the accuracy and robustness of answer sheet object detection.
[0162] S503: If the subject category corresponding to the target answer sheet image is different from the specified scanned subject category, then there is a subject anomaly in the target answer sheet image.
[0163] Reference Figure 6 FIG. 1 is a schematic diagram of a device for intelligently determining the position of an answer sheet image defect based on visual recognition provided by an embodiment of the present application, the device comprising:
[0164] An acquisition module 601 is used to acquire a corner area image, a background color, and a target straight line whose length exceeds a preset length in a target answer sheet image;
[0165] A determination module 602 is used to determine the corner defect position in the target answer sheet image according to the shape of the connected domain corresponding to the target connected domain in the corner area image and the proportion of black pixels in the corner area image; the target connected domain is determined based on the proportion of black pixels in the minimum bounding box corresponding to each connected domain in the corner area image;
[0166] The determination module 602 is further used to determine the position of the target pixel whose color of the adjacent pixel on the target straight line is the background color as the scratch defect position in the target answer sheet image; the adjacent pixel refers to the pixel adjacent to the target pixel in the vertical direction of the target straight line;
[0167] The determination module 602 is also used to determine the positions of multiple consecutive windows in which the proportion of black pixels in the target answer sheet image exceeds a preset proportion as the positions of black edge defects in the target answer sheet image; wherein the preset length and the size of the window are determined based on the size of the target answer sheet.
[0168] In a possible implementation, the target straight line includes a target horizontal straight line and a target vertical straight line, the preset length includes a preset horizontal length and a preset vertical length, and the determination module 602 is further used to:
[0169] Detect the straight line in the target answer sheet image and obtain the initial straight line;
[0170] Determine an initial straight line whose slope is within a first preset slope range as a horizontal straight line, and determine an initial straight line whose slope is within a second preset slope range as a vertical straight line;
[0171] A horizontal straight line whose length exceeds a preset horizontal length is determined as a target horizontal straight line, and a vertical straight line whose length exceeds a preset vertical length is determined as a target vertical straight line; the preset horizontal length and the preset vertical length are determined based on the size of the target answer sheet.
[0172] In a possible implementation, the determination module 602 is specifically used to determine a connected domain in which the proportion of black pixels in the minimum circumscribed frame in the corner area image is greater than the first preset black pixel proportion as the initial connected domain; the proportion of black pixels in the minimum circumscribed frame corresponding to the connected domain refers to the proportion of black pixels in the connected domain in the minimum circumscribed frame of the connected domain; the domain with the largest area in the initial connected domain is determined as the target connected domain; it is determined whether the proportion of black pixels in the corner area image corresponding to the target connected domain is greater than the second preset black pixel proportion; the proportion of black pixels in the corner area image refers to the proportion of black pixels in the target connected domain in the corner area image; if the proportion of black pixels in the corner area image corresponding to the target connected domain is greater than the second preset black pixel proportion, it is determined whether the shape of the connected domain corresponding to the target connected domain is a triangle; if the shape of the connected domain corresponding to the target connected domain is a triangle, the position of the target connected domain in the corner area image is determined as the corner defect position in the target answer sheet image.
[0173] In a possible implementation, the window includes a horizontal window and a vertical window; the determination module 602 is further configured to:
[0174] The width of the target answer sheet image is determined as the width of the horizontal window, and the preset height is determined as the height of the horizontal window;
[0175] The height of the target answer sheet image is determined as the height of the vertical window, and the preset width is determined as the width of the vertical window.
[0176] In a possible implementation, the preset proportion includes a preset horizontal proportion and a preset vertical proportion; the determination module 602 is specifically used to determine the positions of multiple consecutive horizontal windows in the target answer sheet image where the proportion of black pixels exceeds the preset horizontal proportion as the positions of black edge defects in the target answer sheet image; the preset horizontal proportion is determined based on the width of the target answer sheet; the positions of multiple consecutive vertical windows in the target answer sheet image where the proportion of black pixels exceeds the preset vertical proportion are determined as the positions of black edge defects in the target answer sheet image; the preset vertical proportion is determined based on the height of the target answer sheet.
[0177] In one possible implementation, the determination module 602 is specifically used to slide the horizontal window downward and upward starting from the upper end and the lower end of the target answer sheet image, respectively; if the proportion of black pixels in the current sliding horizontal window exceeds the preset horizontal proportion, and the sliding distance is less than the first preset distance, the horizontal window continues to be slid; the first preset distance is determined based on the height of the target answer sheet; if the proportion of black pixels in the current sliding horizontal window is less than or equal to the preset horizontal proportion, the sliding of the horizontal window is ended; after the sliding is completed, the positions of the continuous multiple horizontal windows sliding in the target answer card image are determined as the positions of the black edge defects in the target answer card image.
[0178] In one possible implementation, the determination module 602 is specifically used to slide the vertical window to the right and to the left respectively starting from the left end and the right end of the target answer sheet image; if the proportion of black pixels in the current sliding vertical window exceeds the preset vertical proportion, and the sliding distance is less than the second preset distance, the vertical window continues to be slid; the second preset distance is determined based on the width of the target answer sheet; if the proportion of black pixels in the current sliding vertical window is less than or equal to the preset vertical proportion, the sliding of the vertical window ends; after the sliding is completed, the positions of multiple consecutive vertical windows sliding in the target answer card image are determined as the positions of black edge defects in the target answer card image.
[0179] In a possible implementation, the device further includes: an elimination module 603;
[0180] The elimination module 603 is used to correct the color of the pixel point at the corner defect position in the target answer sheet image to the background color;
[0181] The elimination module 603 is also used to correct the color of the pixel point at the scratch defect position in the target answer sheet image to the background color;
[0182] The elimination module 603 is also used to correct the color of the pixel points at the black edge defect position in the target answer sheet image to the background color.
[0183] The present application provides an intelligent device for determining the defect position of an answer sheet image based on visual recognition, which can determine the corner defect position, scratch defect position and black edge defect position in the answer sheet image, thereby improving the reliability of the answer sheet grading results.
[0184] like Figure 7 As shown, an electronic device 700 provided in an embodiment of the present application includes: a processor 701, a memory 702 and a bus, the memory 702 stores machine-readable instructions executable by the processor 701, when the electronic device is running, the processor 701 and the memory 702 communicate through the bus, and the processor 701 executes the machine-readable instructions to perform the steps of the above-mentioned method for intelligently determining the defect position of an answer sheet image based on visual recognition.
[0185] Specifically, the above-mentioned memory 702 and processor 701 can be general-purpose memory and processor, which are not specifically limited here. When the processor 701 runs the computer program stored in the memory 702, it can execute the above-mentioned method for intelligently determining the defect position of the answer sheet image based on visual recognition.
[0186] Corresponding to the above-mentioned method for intelligently determining the position of answer sheet image defects based on visual recognition, an embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by the processor, the steps of the above-mentioned method for intelligently determining the position of answer sheet image defects based on visual recognition are executed.
[0187] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the method embodiment, and will not be repeated in this application. In the several embodiments provided in this application, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0188] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0189] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0190] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application, 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. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the information processing method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks.
[0191] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for intelligently determining the defect position of answer sheet images based on visual recognition, It is characterized in that The method comprises: Obtain the corner area image, background color, and target straight line whose length exceeds a preset length in the target answer sheet image; According to the shape of the connected domain corresponding to the target connected domain in the corner area image and the proportion of black pixels in the corner area image, the corner defect position in the target answer sheet image is determined, including: determining the connected domain in which the proportion of black pixels in the minimum external frame in the corner area image is greater than the first preset black pixel proportion as the initial connected domain; the proportion of black pixels in the minimum external frame corresponding to the connected domain refers to the proportion of black pixels in the connected domain in the minimum external frame of the connected domain; determining the largest area in the initial connected domain as the target connected domain; judging whether the proportion of black pixels in the corner area image corresponding to the target connected domain is greater than the second preset black pixel proportion Pixel ratio; the black pixel ratio in the corner area image refers to the ratio of black pixels in the target connected domain in the corner area image; if the black pixel ratio in the corner area image corresponding to the target connected domain is greater than the second preset black pixel ratio, it is determined whether the connected domain shape corresponding to the target connected domain is a triangle; if the connected domain shape corresponding to the target connected domain is a triangle, the position of the target connected domain in the corner area image is determined as the corner defect position in the target answer sheet image; the target connected domain is determined based on the black pixel ratio in the minimum circumscribed frame corresponding to each connected domain in the corner area image; The position of the target pixel whose adjacent pixel on the target straight line has the background color is determined as the scratch defect position in the target answer sheet image; the adjacent pixel refers to the pixel adjacent to the target pixel in the vertical direction of the target straight line; and determining the positions of a plurality of consecutive windows in which the proportion of black pixels in the target answer sheet image exceeds a preset proportion as the positions of black edge defects in the target answer sheet image; wherein the preset length and the size of the window are determined based on the size of the target answer sheet; The window includes a horizontal window and a vertical window; the size of the window is determined by the following steps: the width of the target answer sheet image is determined as the width of the horizontal window, and the preset height is determined as the height of the horizontal window; the height of the target answer sheet image is determined as the height of the vertical window, and the preset width is determined as the width of the vertical window; The preset proportion includes a preset horizontal proportion and a preset vertical proportion; the determination of the positions of a plurality of consecutive windows whose proportion of black pixels in the target answer sheet image exceeds the preset proportion as the positions of black edge defects in the target answer sheet image includes: determining the positions of a plurality of consecutive horizontal windows whose proportion of black pixels in the target answer sheet image exceeds the preset horizontal proportion as the positions of black edge defects in the target answer sheet image; the preset horizontal proportion is determined based on the width of the target answer sheet; determining the positions of a plurality of consecutive vertical windows whose proportion of black pixels in the target answer sheet image exceeds the preset vertical proportion as the positions of black edge defects in the target answer sheet image; the preset vertical proportion is determined based on the height of the target answer sheet; The method of determining the positions of the continuous multiple horizontal windows in which the proportion of black pixels in the target answer sheet image exceeds the preset horizontal proportion as the positions of the black edge defects in the target answer sheet image includes: sliding the horizontal window downward and upward respectively from the upper end and the lower end of the target answer sheet image; if the proportion of black pixels in the current sliding horizontal window exceeds the preset horizontal proportion and the sliding distance is less than a first preset distance, continuing to slide the horizontal window; the first preset distance is determined based on the height of the target answer sheet; if the proportion of black pixels in the current sliding horizontal window is less than or equal to the preset horizontal proportion, ending the sliding of the horizontal window; after the sliding is completed, determining the positions of the continuous multiple horizontal windows sliding in the target answer sheet image as the positions of the black edge defects in the target answer sheet image; The method of determining the positions of the multiple vertical windows in which the proportion of black pixels in the target answer sheet image exceeds the preset vertical proportion as the positions of black edge defects in the target answer sheet image includes: starting from the left end and the right end of the target answer sheet image, sliding the vertical window to the right and to the left respectively; if the proportion of black pixels in the current sliding vertical window exceeds the preset vertical proportion, and the sliding distance is less than the second preset distance, continuing to slide the vertical window; the second preset distance is determined based on the width of the target answer sheet; if the proportion of black pixels in the current sliding vertical window is less than or equal to the preset vertical proportion, ending the sliding of the vertical window; after the sliding is completed, determining the positions of the multiple vertical windows in which the vertical window slides in the target answer sheet image as the positions of black edge defects in the target answer sheet image.
2. According to the method for intelligently determining the position of defect in an answer sheet image based on visual recognition according to claim 1, It is characterized in that The target straight line includes a target horizontal straight line and a target vertical straight line, and the preset length includes a preset horizontal length and a preset vertical length. The target straight line in the target answer sheet image is determined by the following steps: Detecting a straight line in the target answer sheet image to obtain an initial straight line; Determine an initial straight line whose slope is within a first preset slope range as a horizontal straight line, and determine an initial straight line whose slope is within a second preset slope range as a vertical straight line; A horizontal line whose length exceeds the preset horizontal length is determined as a target horizontal line, and a vertical line whose length exceeds the preset vertical length is determined as a target vertical line; the preset horizontal length and the preset vertical length are determined based on the size of the target answer sheet.
3. The method for intelligently determining the position of defect in an answer sheet image based on visual recognition according to claim 1 or 2, It is characterized in that The method further comprises: Correcting the color of the pixel at the corner defect position in the target answer sheet image to the background color; Correcting the color of the pixel at the scratch defect position in the target answer sheet image to the background color; The color of the pixel point at the black edge defect position in the target answer sheet image is corrected to the background color.
4. An intelligent device for determining the position of defect in answer sheet image based on visual recognition, It is characterized in that The device comprises: An acquisition module is used to acquire a corner area image, a background color, and a target straight line whose length exceeds a preset length in a target answer sheet image; The determination module is used to determine the corner defect position in the target answer sheet image according to the connected domain shape corresponding to the target connected domain in the corner area image and the proportion of black pixels in the corner area image, including: determining the connected domain in which the proportion of black pixels in the minimum external frame in the corner area image is greater than the first preset black pixel proportion as the initial connected domain; the proportion of black pixels in the minimum external frame corresponding to the connected domain refers to the proportion of black pixels in the connected domain in the minimum external frame of the connected domain; determining the largest area in the initial connected domain as the target connected domain; judging whether the proportion of black pixels in the corner area image corresponding to the target connected domain is greater than the second preset black pixel proportion Assume a black pixel ratio; the black pixel ratio in the corner area image refers to the ratio of black pixels in the target connected domain in the corner area image; if the black pixel ratio in the corner area image corresponding to the target connected domain is greater than the second preset black pixel ratio, determine whether the connected domain shape corresponding to the target connected domain is a triangle; if the connected domain shape corresponding to the target connected domain is a triangle, determine the position of the target connected domain in the corner area image as the corner defect position in the target answer sheet image; the target connected domain is determined based on the black pixel ratio in the minimum circumscribed frame corresponding to each connected domain in the corner area image; The determination module is further used to determine the position of the target pixel whose adjacent pixel on the target straight line has the background color as the scratch defect position in the target answer sheet image; the adjacent pixel refers to the pixel adjacent to the target pixel in the vertical direction of the target straight line; The determination module is further used to determine the positions of a plurality of consecutive windows in which the proportion of black pixels in the target answer sheet image exceeds a preset proportion as the positions of black edge defects in the target answer sheet image; wherein the preset length and the size of the window are determined based on the size of the target answer sheet; The window includes a horizontal window and a vertical window; the determination module is further used to: determine the width of the target answer sheet image as the width of the horizontal window, and determine the preset height as the height of the horizontal window; determine the height of the target answer sheet image as the height of the vertical window, and determine the preset width as the width of the vertical window; The preset proportion includes a preset horizontal proportion and a preset vertical proportion; the determination module is specifically used to determine the positions of the continuous multiple horizontal windows in which the proportion of black pixels in the target answer sheet image exceeds the preset horizontal proportion as the positions of black edge defects in the target answer sheet image; the preset horizontal proportion is determined based on the width of the target answer sheet; the positions of the continuous multiple vertical windows in which the proportion of black pixels in the target answer sheet image exceeds the preset vertical proportion are determined as the positions of black edge defects in the target answer sheet image; the preset vertical proportion is determined based on the height of the target answer sheet; The determination module is specifically used to slide the horizontal window downward and upward respectively from the upper end and the lower end of the target answer sheet image; if the proportion of black pixels in the current sliding horizontal window exceeds the preset horizontal proportion, and the sliding distance is less than the first preset distance, the horizontal window continues to be slid; the first preset distance is determined based on the height of the target answer sheet; if the proportion of black pixels in the current sliding horizontal window is less than or equal to the preset horizontal proportion, the sliding of the horizontal window ends; after the sliding is completed, the positions of the continuous plurality of horizontal windows sliding in the target answer sheet image are determined as the positions of the black edge defects in the target answer sheet image; The determination module is specifically used to slide the vertical window to the right and left respectively starting from the left end and the right end of the target answer sheet image; if the proportion of black pixels in the current sliding vertical window exceeds the preset vertical proportion, and the sliding distance is less than the second preset distance, continue to slide the vertical window; the second preset distance is determined based on the width of the target answer sheet; if the proportion of black pixels in the current sliding vertical window is less than or equal to the preset vertical proportion, end sliding the vertical window; after the sliding is completed, the positions of the continuous multiple vertical windows sliding in the target answer sheet image are determined as the positions of black edge defects in the target answer sheet image.
5. An electronic device, It is characterized in that include: A processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the method for intelligently determining the position of answer sheet image defects based on visual recognition as described in any one of claims 1 to 3.
6. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for intelligently determining the defect position of an answer sheet image based on visual recognition as described in any one of claims 1 to 3 are executed.
