Card edge searching method and device, electronic equipment and storage medium
By using preset areas and angle ranges to filter and allocate lines in the card edge search method, the requirements for card placement posture are relaxed, the problem of difficult operation in the existing technology is solved, and the efficiency of card edge search is improved.
Patent Information
- Application Number
- CN202310862784.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-13
- Publication Date
- 2025-01-14
AI Technical Summary
The existing card edge search method requires strict requirements on the card placement posture, which increases the difficulty of user operation.
Use a scanning window with four preset areas: up, down, left and right to obtain the card certificate scan image, detect and filter edge lines, assign lines to the list to be found based on the preset area and angle range, and find cards according to the preset rules. The edge lines of the certificate will relax the requirements for the position of the card certificate.
It reduces the difficulty of user operation, improves the efficiency of card edge search, and can quickly obtain scanned images that meet placement requirements.
Smart Images

Figure CN119313693A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a card edge search method, device, electronic device and storage medium. Background Art
[0002] Given a picture containing a card (such as a bank card, ID card, or driver's license), the edge detection algorithm can detect the edges of the objects in the picture. Since there may be multiple objects in a picture, it is possible to detect many edges belonging to different objects at the same time, and it is difficult to fully detect the edge of a single object. In most cases, only part of it can be detected.
[0003] In the related art, the card edge search method based on the edge detection algorithm is generally as follows: when collecting pictures, it is stipulated that the card must be placed almost horizontally; after the picture is collected, edge detection is performed on the collected picture, and the detected edge line segments are divided into two groups: a horizontal group (line segments are almost horizontal) and a vertical group (line segments are almost vertical); the line segments in the horizontal group and the line segments in the vertical group are paired within the group respectively, such as the intra-group pairing of the horizontal group is: check whether the two line segments are almost parallel, and the length difference is within a certain range, and pair them if they meet the requirements; after the intra-group pairing is completed, the paired line segment pairs in the horizontal group and the paired line segment pairs in the vertical group are paired in a rectangle to check whether the four line segments meet the conditions for forming a rectangle, and the line segments that meet the rectangular pairing conditions are the edges of the card.
[0004] The above-mentioned card edge search method has strict requirements on the placement of the card during image acquisition, which greatly increases the difficulty of operation for users. Summary of the invention
[0005] The present invention provides a card edge search method, device, electronic device and storage medium, which are used to solve the defect that the placement posture of the card is strictly required in the prior art, thereby greatly increasing the difficulty of user operation. The method can capture the scanned image of the card through a scanning window with a preset area, and then classify the horizontal lines and vertical lines detected from the scanned image based on the preset area before searching the edge of the card, thereby relaxing the requirements for the placement posture of the card and reducing the difficulty of user operation.
[0006] The present invention provides a card edge search method, comprising:
[0007] Based on the scanning window with four preset areas of top, bottom, left and right, multiple frames of scanned images of cards are obtained;
[0008] Detecting the edge of the target in any frame of the scanned image to obtain a detection result;
[0009] Filtering the lines whose lengths are greater than or equal to a first preset threshold in the detection results to obtain a filtering result;
[0010] Based on each of the preset areas, the lines in the screening result are allocated to the to-be-searched lists corresponding to each of the preset areas;
[0011] Based on the preset search rule, the edge lines corresponding to the edges of the card are searched from the to-be-searched list corresponding to each preset area.
[0012] According to a card edge search method provided by the present invention, based on each of the preset areas, the lines in the screening results are assigned to the to-be-searched lists corresponding to each of the preset areas, including:
[0013] Based on the upper preset area, the lines in the screening results that belong to the upper preset area and whose angle difference with the horizontal line is within a first preset angle range are allocated to a to-be-searched list corresponding to the upper preset area;
[0014] Based on the lower preset area, the lines in the screening results that belong to the lower preset area and whose angle difference with the horizontal line is within a first preset angle range are allocated to a to-be-searched list corresponding to the lower preset area;
[0015] Based on the left preset area, the lines in the screening results that belong to the left preset area and whose angle difference with the vertical line is within a first preset angle range are allocated to a to-be-searched list corresponding to the left preset area;
[0016] Based on the right preset area, the lines in the screening results that belong to the right preset area and whose angle difference with the vertical line is within a first preset angle range are allocated to a to-be-searched list corresponding to the right preset area.
[0017] According to a card edge search method provided by the present invention, based on a preset search rule, searching for edge lines corresponding to each edge of the card from a to-be-searched list corresponding to each preset area includes:
[0018] Sort the lines in the four to-be-searched lists respectively in order from long to short;
[0019] Based on the preset search rule, the lines to be confirmed are selected from the four lists to be searched in order of sorting, and each selected line to be confirmed is confirmed until the edge lines corresponding to each edge of the card are found in the four lists to be searched.
[0020] According to a card edge search method provided by the present invention, based on the preset search rule, lines to be confirmed are selected from the four to-be-searched lists in sequence according to the sorting order, and each selected to-be-confirmed line is confirmed until edge lines corresponding to each edge of the card are found in the four to-be-searched lists, including:
[0021] Selecting a first line to be confirmed from the to-be-searched list corresponding to the first area in sorted order;
[0022] When the angle difference between the second line to be confirmed selected from the to-be-searched list corresponding to the second area in sorted order and the first line to be confirmed is within a second preset angle range, determining that the first line to be confirmed is the first edge line of the card;
[0023] When the angle differences between the third line to be confirmed selected from the to-be-searched list corresponding to the third area in the sorted order and the first line to be confirmed and the second line to be confirmed are all within a third preset angle range, and the third line to be confirmed is located between the straight lines corresponding to the first line to be confirmed and the second line to be confirmed and is located on one side of the first end of the first line to be confirmed and the first end of the second line to be confirmed, the second line to be confirmed is determined to be the second edge line of the card;
[0024] When the angle differences between the fourth line to be confirmed selected from the to-be-searched list corresponding to the fourth area in the sorted order and the first line to be confirmed and the second line to be confirmed are both within the third preset angle range, and the angle difference between the fourth line to be confirmed and the third line to be determined is within the fourth preset angle range, and the fourth line to be confirmed is located between the straight lines corresponding to the first line to be confirmed and the second line to be confirmed respectively and is located on one side of the second end of the first line to be confirmed and the second end of the second line to be confirmed, the third line to be confirmed is determined to be the third edge line of the card, and the fourth line to be confirmed is determined to be the fourth edge line of the card;
[0025] The first area and the second area are two relative preset areas among the four preset areas, and the third area and the fourth area are the other two relative preset areas among the four preset areas.
[0026] According to a card edge search method provided by the present invention, the method further includes:
[0027] When the edge line corresponding to at least one edge of the card is not found, re-detecting a frame of the scanned image until the edge lines corresponding to all the edges of the card are found;
[0028] Alternatively, after edge lines corresponding to the edges of the card are found, if the card image of the card collected based on the edge lines is incomplete, a frame of scanned image is re-detected until the card image collected based on the edge lines is complete.
[0029] According to a card edge search method provided by the present invention, the method further includes:
[0030] When the number of lines in the obtained screening result is 0, a frame of scanned image is re-detected until the number of lines in the obtained screening result is not 0.
[0031] According to a card edge search method provided by the present invention, the method further includes:
[0032] After the lines in the screening results are distributed to the lists to be searched, if any of the lists to be searched is empty, a frame of scanned image is re-detected until all four lists to be searched are not empty.
[0033] The present invention also provides a card edge search device, comprising:
[0034] A scanning module, used to obtain scanned images of multiple frames of cards based on a scanning window having four preset areas of top, bottom, left and right;
[0035] A detection module, used to detect the edge of the card in any frame of the scanned image and obtain a detection result;
[0036] A screening module, used for screening the lines whose length is greater than or equal to a first preset threshold in the detection results to obtain screening results;
[0037] An allocating module, for allocating the lines in the screening results to the to-be-searched lists corresponding to the preset areas respectively based on the preset areas;
[0038] The search module is used to search for edge lines corresponding to each edge of the card from the to-be-searched list corresponding to each preset area based on a preset search rule.
[0039] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the above-mentioned card edge search methods is implemented.
[0040] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the card edge search method described above is implemented.
[0041] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the card edge search method described above is implemented.
[0042] The card edge search method, device, electronic device and storage medium provided by the present invention collect the scanned image of the card through a scanning window with a preset area, and then classify the horizontal lines and vertical lines detected from the scanned image based on the preset area, and then search for the card edge based on the classification result. By presetting the area, when collecting the scanned image, it is only necessary to place the card according to the preset area, thereby relaxing the requirements for the card placement posture and reducing the user's operation difficulty. Furthermore, after relaxing the requirements for the card placement posture, a scanned image that meets the placement requirements can be quickly obtained, which improves the efficiency of card edge search. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0044] Figure 1 It is a flow chart of the card edge search method provided by the present invention;
[0045] Figure 2 This is one of the ways to segment the preset area of the scanning window provided by the present invention;
[0046] Figure 3 This is the second way of dividing the preset area of the scanning window provided by the present invention;
[0047] Figure 4 is a schematic diagram of detection results based on the edge detection algorithm provided by the present invention;
[0048] Figure 5 It is a structural schematic diagram of the card edge search device provided by the present invention;
[0049] Figure 6 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0051] Combine the following Figure 1-Figure 4 A card edge search method of the present invention is described, such as Figure 1 As shown in , the method includes:
[0052] S101: acquiring scanned images of multiple frames of cards based on a scanning window having four preset areas of top, bottom, left and right.
[0053] Specifically, a dividing line may be pre-set to distinguish four preset areas, namely, top, bottom, left, and right, in the scanning window. Figure 2 As shown in , the preset area can be divided by cross lines, such as the area above line 1 is the upper preset area, the area below line 1 is the lower preset area, the area to the left of line 2 is the left preset area, and the area to the right of line 2 is the right prediction area. Figure 3 As shown, the preset areas can also be divided in a tic-tac-toe manner, such as the upper preset area above line 3, the lower preset area below line 4, the left side of line 5 as the left preset area, and the right side of line 6 as the right preset area. When acquiring scanned images of multiple frames of cards based on a scanning window with four preset areas of upper, lower, left, and right, it is only necessary to make the upper edge of the card located in the upper preset area, the lower edge of the card located in the lower preset area, the left side of the card located in the left preset area, and the right side of the card located in the right preset area, without requiring the card to be placed nearly horizontally.
[0054] S102: Detect the edge of the target in any frame of the scanned image to obtain a detection result.
[0055] Specifically, one frame of scanned images can be selected from multiple frames of scanned images of the card, and the edge of the target in the frame of scanned image can be detected by an edge detection algorithm. Figure 4 As shown in , the targets in the scanned image may include targets such as pillars, walls, and ceilings, so the obtained detection results also include lines detected from the edges of the above targets.
[0056] S103: Filter the lines in the detection results whose lengths are greater than or equal to a first preset threshold to obtain a filtering result.
[0057] Specifically, after edge detection by edge detection algorithm, the edge lines of each target obtained may not be complete, and only part of them may be detected, that is, the obtained lines may be short lines. When the detected lines are too short, the error rate of the search result will be high when searching for the edge of the card based on the short lines; at the same time, the short lines in the detection results may be interference lines.
[0058] Therefore, a first preset threshold can be pre-set according to the size of the card, so as to screen the lines in the detection result based on the length based on the first preset threshold, and retain the lines in the detection result whose length is greater than or equal to the first preset threshold as the screening result, and screen out the lines in the detection result whose length is less than the first preset threshold.
[0059] This method only does not retain lines that are too short, and there is no strict requirement for the upper limit of the length of the lines in the screening results. In this case, if the card edge in the scanned image is incomplete or incomplete, the card image can be collected by searching for the edge lines and then extending the connection to achieve the search for the edge of the incomplete card.
[0060] S104: Based on each of the preset areas, the lines in the screening result are allocated to the to-be-searched lists corresponding to each of the preset areas.
[0061] Based on the contents of the above steps, after the detection results are screened, the lines in the screened results are allocated based on each preset area. Specifically, the lines in the upper preset area are allocated to the to-be-searched list corresponding to the upper preset area, the lines in the lower preset area are allocated to the to-be-searched list corresponding to the lower preset area, the lines in the left preset area are allocated to the to-be-searched list corresponding to the left preset area, and the lines in the right preset area are allocated to the to-be-searched list corresponding to the right preset area.
[0062] S105: Based on a preset search rule, searching for edge lines corresponding to each edge of the card from a to-be-searched list corresponding to each preset area.
[0063] Specifically, after the lines in the screening results are assigned to each list to be searched, the edge lines corresponding to each edge of the card are searched from each list to be searched based on the preset search rule. The preset search rule is pre-set, and the preset search rule may include a preset search order and a search rule set for the preset search order.
[0064] The card edge search method provided by the present invention collects the scanned image of the card through a scanning window with a preset area, and then classifies the horizontal lines and vertical lines detected from the scanned image based on the preset area, and searches for the card edge based on the classification result. By presetting the area, when collecting the scanned image, it is only necessary to place the card according to the preset area, thereby relaxing the requirements for the card placement posture and reducing the user's operation difficulty. Furthermore, after relaxing the requirements for the card placement posture, a scanned image that meets the placement requirements can be quickly obtained, thereby improving the efficiency of card edge search.
[0065] In one embodiment, based on each of the preset areas, allocating the lines in the screening results to the to-be-searched lists corresponding to each of the preset areas respectively includes:
[0066] Based on the upper preset area, the lines in the screening results that belong to the upper preset area and whose angle difference with the horizontal line is within a first preset angle range are allocated to a to-be-searched list corresponding to the upper preset area;
[0067] Based on the lower preset area, the lines in the screening results that belong to the lower preset area and whose angle difference with the horizontal line is within a first preset angle range are allocated to a to-be-searched list corresponding to the lower preset area;
[0068] Based on the left preset area, the lines in the screening results that belong to the left preset area and whose angle difference with the vertical line is within a first preset angle range are allocated to a to-be-searched list corresponding to the left preset area;
[0069] Based on the right preset area, the lines in the screening results that belong to the right preset area and whose angle difference with the vertical line is within a first preset angle range are allocated to a to-be-searched list corresponding to the right preset area.
[0070] Specifically, since the upper preset area and the lower preset area are respectively set for the upper edge and the lower edge of the card, the angles of the lines in the to-be-searched list assigned to the upper preset area and the lines in the to-be-searched list assigned to the lower preset area should be aligned with the horizontal line (e.g. Figure 2 Since the left preset area and the right preset area are set for the left edge and right edge of the card respectively, the angles of the lines in the to-be-searched list assigned to the left preset area and the lines in the to-be-searched list assigned to the right preset area should be close to the vertical line (such as Figure 2 The angle of Line 2 in the figure is relatively close.
[0071] Based on this, the lines in the screening results that belong to the upper preset area and whose angle difference with the horizontal line is within the first preset angle range are allocated to the to-be-searched list corresponding to the upper preset area; the lines in the screening results that belong to the lower preset area and whose angle difference with the horizontal line is within the first preset angle range are allocated to the to-be-searched list corresponding to the lower preset area; the lines in the screening results that belong to the left preset area and whose angle difference with the vertical line is within the first preset angle range are allocated to the to-be-searched list corresponding to the left preset area; the lines in the screening results that belong to the right preset area and whose angle difference with the vertical line is within the first preset angle range are allocated to the to-be-searched list corresponding to the right preset area. Lines in the screening results that do not meet the above conditions are abandoned and will not be allocated or used subsequently.
[0072] In one embodiment, searching for edge lines corresponding to each edge of the card from a to-be-searched list corresponding to each preset area based on a preset search rule includes:
[0073] Sort the lines in the four to-be-searched lists respectively in order from long to short;
[0074] Based on the preset search rule, the lines to be confirmed are selected from the four lists to be searched in order of sorting, and each selected line to be confirmed is confirmed until the edge lines corresponding to each edge of the card are found in the four lists to be searched.
[0075] Specifically, when searching for edge lines corresponding to edges of the card in each to-be-searched list, firstly, the lines in each to-be-searched list are sorted in order from long to short.
[0076] Based on the preset search rules, the lines to be confirmed are selected from each list to be searched in the sorted order. The selected lines to be confirmed are confirmed. If they meet the preset search rules, the lines to be confirmed are edge lines of the card. If they do not meet the preset search rules, the lines to be confirmed are reselected from the list to be searched in the sorted order for confirmation until the edge lines corresponding to the edges of the card are found in the four lists to be searched.
[0077] In one embodiment, based on the preset search rule, the lines to be confirmed are selected from the four to-be-searched lists in order of sorting, and each selected line to be confirmed is confirmed until the edge lines corresponding to each edge of the card are found in the four to-be-searched lists, including:
[0078] Selecting a first line to be confirmed from the to-be-searched list corresponding to the first area in sorted order;
[0079] When the angle difference between the second line to be confirmed selected from the to-be-searched list corresponding to the second area in sorted order and the first line to be confirmed is within a second preset angle range, determining that the first line to be confirmed is the first edge line of the card;
[0080] When the angle differences between the third line to be confirmed selected from the to-be-searched list corresponding to the third area in the sorted order and the first line to be confirmed and the second line to be confirmed are all within a third preset angle range, and the third line to be confirmed is located between the straight lines corresponding to the first line to be confirmed and the second line to be confirmed and is located on one side of the first end of the first line to be confirmed and the first end of the second line to be confirmed, the second line to be confirmed is determined to be the second edge line of the card;
[0081] When the angle differences between the fourth line to be confirmed selected from the to-be-searched list corresponding to the fourth area in the sorted order and the first line to be confirmed and the second line to be confirmed are both within the third preset angle range, and the angle difference between the fourth line to be confirmed and the third line to be determined is within the fourth preset angle range, and the fourth line to be confirmed is located between the straight lines corresponding to the first line to be confirmed and the second line to be confirmed respectively and is located on one side of the second end of the first line to be confirmed and the second end of the second line to be confirmed, the third line to be confirmed is determined to be the third edge line of the card, and the fourth line to be confirmed is determined to be the fourth edge line of the card;
[0082] The first area and the second area are two relative preset areas among the four preset areas, and the third area and the fourth area are the other two relative preset areas among the four preset areas.
[0083] For example, the longest line is selected from the to-be-searched list corresponding to the first area in sorted order as the first to-be-confirmed line; the longest line is selected from the to-be-searched list corresponding to the second area in sorted order as the second to-be-confirmed line. Determine whether the angle difference between the second to-be-confirmed line and the first to-be-confirmed line satisfies condition A:
[0084] Condition A: The angle difference between the second line to be confirmed and the first line to be confirmed is within a second preset angle range (-α, α).
[0085] a) If the second line to be confirmed meets condition A, the third line to be confirmed is selected from the to-be-searched list corresponding to the third area in the sorting order and subsequently confirmed;
[0086] b) If the second line to be confirmed does not meet condition A, reselect the second line to be confirmed;
[0087] c) If there is no second line to be confirmed that meets condition A in the list to be searched corresponding to the second area, then the first line to be confirmed is reselected in the sorting order in the list to be searched corresponding to the first area.
[0088] After the third line to be confirmed is selected from the to-be-searched list corresponding to the third region in the sorted order, it is determined whether the positional relationship between the third line to be confirmed and the first line to be confirmed and the second line to be confirmed satisfies conditions B and C:
[0089] Condition B: the angle differences between the third line to be confirmed and the first line to be confirmed and the second line to be confirmed are all within a third preset angle range (90-β, 90+β);
[0090] Condition C: the third line to be confirmed is located between the straight lines corresponding to the first line to be confirmed and the second line to be confirmed, and is on one side of the first end of the first line to be confirmed and the first end of the second line to be confirmed (wherein the first end of the first line to be confirmed and the first end of the second line to be confirmed are ends facing the same direction, for example, when the first line to be confirmed is in the upper preset area, the second line to be confirmed is in the lower preset area, and the third line to be confirmed is in the left preset area, then the third line to be confirmed should be below the first line to be confirmed, above the second line to be confirmed, and on the left side of the first line to be confirmed and the second line to be confirmed).
[0091] a) If the third line to be confirmed satisfies both conditions B and C, the fourth line to be confirmed is selected from the to-be-searched list corresponding to the fourth area in the sorted order and subsequently confirmed;
[0092] b) If the third line to be confirmed does not meet conditions B and / or C, then reselect the third line to be confirmed;
[0093] c) If there is no third line to be confirmed that meets conditions B and C in the list to be searched corresponding to the third area, then reselect the second line to be confirmed in the list to be searched corresponding to the second area according to the sorting order.
[0094] After the fourth line to be confirmed is selected from the to-be-searched list corresponding to the fourth region in the sorted order, it is determined whether the positional relationship between the fourth line to be confirmed and the first line to be confirmed, the second line to be confirmed, and the third line to be confirmed satisfies conditions D and E:
[0095] Condition D: the angle difference between the fourth line to be confirmed and the first line to be confirmed and the second line to be confirmed is within the third preset angle range (90-β, 90+β), and the angle difference between the fourth line to be confirmed and the third line to be confirmed is within the fourth preset angle range (-γ, γ);
[0096] Condition E: the fourth line to be confirmed is located between the straight lines corresponding to the first line to be confirmed and the second line to be confirmed, and is on one side of the second end of the first line to be confirmed and the second end of the second line to be confirmed (wherein the second end of the first line to be confirmed and the second end of the second line to be confirmed are ends facing the same direction, for example, when the first line to be confirmed is in the upper preset area, the second line to be confirmed is in the lower preset area, and the fourth line to be confirmed is in the right preset area, then the fourth line to be confirmed should be below the first line to be confirmed, above the second line to be confirmed, and to the right of the first line to be confirmed and the second line to be confirmed).
[0097] a) If the fourth line to be confirmed satisfies both conditions D and E, the edge lines corresponding to the edges of the card are found;
[0098] b) If the fourth line to be confirmed does not meet the conditions D and / or E, reselect the fourth line to be confirmed;
[0099] c) If there is no third line to be confirmed that meets conditions D and E in the list to be searched corresponding to the fourth area, then the third line to be confirmed is reselected in the list to be searched corresponding to the third area according to the sorting order.
[0100] In this embodiment, the first area and the second area are two relative preset areas in the four preset areas, and the third area and the fourth area are the other two relative preset areas in the four preset areas. Of course, the order of searching is not limited to this, and can also be the order of left, top, right, bottom, or the order of right, top, left, bottom, etc. If the search order is different, the corresponding conditions will change accordingly, and examples will not be given here one by one.
[0101] In the prior art, when searching for card edges, the detected edge segments are divided into two groups: a horizontal group (line segments are almost horizontal) and a vertical group (line segments are almost vertical); the line segments in the horizontal group and the line segments in the vertical group are paired within the group respectively; after the intra-group pairing is completed, the paired line segment pairs in the horizontal group and the paired line segment pairs in the vertical group are paired in a rectangular manner to check whether the four line segments meet the conditions for forming a rectangle. The line segments that meet the rectangular pairing conditions are the edges of the card. This method takes a long time for horizontal pairing and vertical pairing, but in the end, when searching for rectangles, the pairing search will be stopped as soon as a line segment pair that meets the rectangular pairing conditions is found, which makes many paired horizontal line segment pairs and vertical line segment pairs unused, resulting in a waste of computing resources.
[0102] In the above embodiment, the edge lines of the card are searched step by step in a cascade search method according to a preset search order until the four edge lines corresponding to the card are found. This method does not require horizontal and vertical matching in advance, and only needs to confirm which line to judge, which saves computing resources.
[0103] In one embodiment, the method further comprises:
[0104] When the edge line corresponding to at least one edge of the card is not found, re-detecting a frame of the scanned image until the edge lines corresponding to all the edges of the card are found;
[0105] Alternatively, after edge lines corresponding to the edges of the card are found, if the card image of the card collected based on the edge lines is incomplete, a frame of scanned image is re-detected until the card image collected based on the edge lines is complete.
[0106] In one embodiment, the method further comprises:
[0107] When the number of lines in the obtained screening result is 0, a frame of scanned image is re-detected until the number of lines in the obtained screening result is not 0.
[0108] Specifically, after screening, when the number of lines in the screening result is 0, it means that there are no lines that meet the standard, so it is necessary to re-detect a frame of scanned image until the number of lines in the obtained screening result is not 0.
[0109] In one embodiment, the method further comprises:
[0110] After the lines in the screening results are distributed to the lists to be searched, if any of the lists to be searched is empty, a frame of scanned image is re-detected until all four lists to be searched are not empty.
[0111] Specifically, after allocating the lines in the screening results to each to-be-searched list, there may be a preset area that does not have any lines in the to-be-searched list. Since the edge lines corresponding to each edge of the card are subsequently searched from the to-be-searched list, when the to-be-searched list is empty, the edge lines corresponding to all the edges of the card cannot be found, so a frame of scanned image needs to be re-detected until all four to-be-searched lists are not empty.
[0112] The following is a description of the card edge search device 500 provided by the present invention. The card edge search device 500 described below and the card edge search method described above can be referred to in correspondence with each other. Figure 5As shown, the card edge search device 500 includes: a scanning module 501 , a detection module 502 , a screening module 503 , an allocation module 504 and a search module 505 .
[0113] The scanning module 501 is used to obtain scanned images of multiple frames of cards based on a scanning window having four preset areas: upper, lower, left, and right;
[0114] The detection module 502 is used to detect the edge of the card in any frame of the scanned image to obtain a detection result;
[0115] The screening module 503 is used to screen the lines whose length is greater than or equal to the first preset threshold in the detection result to obtain the screening result;
[0116] The allocation module 504 is used to allocate the lines in the screening result to the to-be-searched lists corresponding to the preset areas respectively based on the preset areas;
[0117] The search module 505 is used to search for edge lines corresponding to each edge of the card from the to-be-searched list corresponding to each preset area based on a preset search rule.
[0118] In one embodiment, the allocation module 504 is specifically configured to:
[0119] Based on the upper preset area, the lines in the screening results that belong to the upper preset area and whose angle difference with the horizontal line is within a first preset angle range are allocated to a to-be-searched list corresponding to the upper preset area;
[0120] Based on the lower preset area, the lines in the screening results that belong to the lower preset area and whose angle difference with the horizontal line is within a first preset angle range are allocated to a to-be-searched list corresponding to the lower preset area;
[0121] Based on the left preset area, the lines in the screening results that belong to the left preset area and whose angle difference with the vertical line is within a first preset angle range are allocated to a to-be-searched list corresponding to the left preset area;
[0122] Based on the right preset area, the lines in the screening results that belong to the right preset area and whose angle difference with the vertical line is within a first preset angle range are allocated to a to-be-searched list corresponding to the right preset area.
[0123] In one embodiment, the search module 505 is specifically used to:
[0124] Sort the lines in the four to-be-searched lists respectively in order from long to short;
[0125] Based on the preset search rule, the lines to be confirmed are selected from the four lists to be searched in order of sorting, and each selected line to be confirmed is confirmed until the edge lines corresponding to each edge of the card are found in the four lists to be searched.
[0126] In one embodiment, the search module 505 is specifically used to:
[0127] Selecting a first line to be confirmed from the to-be-searched list corresponding to the first area in sorted order;
[0128] When the angle difference between the second line to be confirmed selected from the to-be-searched list corresponding to the second area in sorted order and the first line to be confirmed is within a second preset angle range, determining that the first line to be confirmed is the first edge line of the card;
[0129] When the angle differences between the third line to be confirmed selected from the to-be-searched list corresponding to the third area in the sorted order and the first line to be confirmed and the second line to be confirmed are all within a third preset angle range, and the third line to be confirmed is located between the straight lines corresponding to the first line to be confirmed and the second line to be confirmed and is located on one side of the first end of the first line to be confirmed and the first end of the second line to be confirmed, the second line to be confirmed is determined to be the second edge line of the card;
[0130] When the angle differences between the fourth line to be confirmed selected from the to-be-searched list corresponding to the fourth area in the sorted order and the first line to be confirmed and the second line to be confirmed are both within the third preset angle range, and the angle difference between the fourth line to be confirmed and the third line to be determined is within the fourth preset angle range, and the fourth line to be confirmed is located between the straight lines corresponding to the first line to be confirmed and the second line to be confirmed respectively and is located on one side of the second end of the first line to be confirmed and the second end of the second line to be confirmed, the third line to be confirmed is determined to be the third edge line of the card, and the fourth line to be confirmed is determined to be the fourth edge line of the card;
[0131] The first area and the second area are two relative preset areas among the four preset areas, and the third area and the fourth area are the other two relative preset areas among the four preset areas.
[0132] In one embodiment, the card edge finding device 500 is further used for:
[0133] When the edge line corresponding to at least one edge of the card is not found, re-detecting a frame of the scanned image until the edge lines corresponding to all the edges of the card are found;
[0134] Alternatively, after edge lines corresponding to the edges of the card are found, if the card image of the card collected based on the edge lines is incomplete, a frame of scanned image is re-detected until the card image collected based on the edge lines is complete.
[0135] In one embodiment, the card edge finding device 500 is further used for:
[0136] When the number of lines in the obtained screening result is 0, a frame of scanned image is re-detected until the number of lines in the obtained screening result is not 0.
[0137] In one embodiment, the card edge finding device 500 is further used for:
[0138] After the lines in the screening results are distributed to the lists to be searched, if any of the lists to be searched is empty, a frame of scanned image is re-detected until all four lists to be searched are not empty.
[0139] The card edge search device 500 provided by the present invention collects the scanned image of the card through a scanning window with a preset area, and then classifies the horizontal lines and vertical lines detected from the scanned image based on the preset area, and then searches for the card edge based on the classification result. By using the preset area, when collecting the scanned image, it is only necessary to place the card according to the preset area, thereby relaxing the requirements for the card placement posture and reducing the user's operation difficulty. Furthermore, after relaxing the requirements for the card placement posture, a scanned image that meets the placement requirements can be quickly obtained, thereby improving the efficiency of card edge search.
[0140] Figure 6 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6 As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communication interface 620 and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call the logic instructions in the memory 630 to execute the card edge search method, which includes:
[0141] Based on the scanning window with four preset areas of top, bottom, left and right, multiple frames of scanned images of cards are obtained;
[0142] Detecting the edge of the card in any frame of the scanned image to obtain a detection result;
[0143] Filtering the lines whose lengths are greater than or equal to a first preset threshold in the detection results to obtain a filtering result;
[0144] Based on each of the preset areas, the lines in the screening result are allocated to the to-be-searched lists corresponding to each of the preset areas;
[0145] Based on the preset search rule, the edge lines corresponding to the edges of the card are searched from the to-be-searched list corresponding to each preset area.
[0146] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0147] On the other hand, the present invention further provides a computer program product, the computer program product includes a computer program, the computer program can be stored on a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the card edge search method provided by the above methods, the method includes:
[0148] Based on the scanning window with four preset areas of top, bottom, left and right, multiple frames of scanned images of cards are obtained;
[0149] Detecting the edge of the card in any frame of the scanned image to obtain a detection result;
[0150] Filtering the lines whose lengths are greater than or equal to a first preset threshold in the detection results to obtain a filtering result;
[0151] Based on each of the preset areas, the lines in the screening result are allocated to the to-be-searched lists corresponding to each of the preset areas;
[0152] Based on the preset search rule, the edge lines corresponding to the edges of the card are searched from the to-be-searched list corresponding to each preset area.
[0153] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the card edge search method provided by the above methods is implemented, and the method includes:
[0154] Based on the scanning window with four preset areas of top, bottom, left and right, multiple frames of scanned images of cards are obtained;
[0155] Detecting the edge of the card in any frame of the scanned image to obtain a detection result;
[0156] Filtering the lines whose lengths are greater than or equal to a first preset threshold in the detection results to obtain a filtering result;
[0157] Based on each of the preset areas, the lines in the screening result are allocated to the to-be-searched lists corresponding to each of the preset areas;
[0158] Based on the preset search rule, the edge lines corresponding to the edges of the card are searched from the to-be-searched list corresponding to each preset area.
[0159] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0160] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0161] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A card edge search method, characterized in that: include: Based on the scanning window with four preset areas of top, bottom, left and right, multiple frames of scanned images of cards are obtained; Detecting the edge of the card in any frame of the scanned image to obtain a detection result; Filtering the lines whose lengths are greater than or equal to a first preset threshold in the detection results to obtain a filtering result; Based on each of the preset areas, the lines in the screening result are allocated to the to-be-searched lists corresponding to each of the preset areas; Based on the preset search rule, the edge lines corresponding to the edges of the card are searched from the to-be-searched list corresponding to each preset area.
2. The card edge search method according to claim 1, characterized in that: Based on each of the preset areas, allocating the lines in the screening results to the to-be-searched lists corresponding to each of the preset areas respectively includes: Based on the upper preset area, the lines in the screening results that belong to the upper preset area and whose angle difference with the horizontal line is within a first preset angle range are allocated to a to-be-searched list corresponding to the upper preset area; Based on the lower preset area, the lines in the screening results that belong to the lower preset area and whose angle difference with the horizontal line is within a first preset angle range are allocated to a to-be-searched list corresponding to the lower preset area; Based on the left preset area, the lines in the screening results that belong to the left preset area and whose angle difference with the vertical line is within a first preset angle range are allocated to a to-be-searched list corresponding to the left preset area; Based on the right preset area, the lines in the screening results that belong to the right preset area and whose angle difference with the vertical line is within a first preset angle range are allocated to a to-be-searched list corresponding to the right preset area.
3. The card edge search method according to claim 1, characterized in that: The step of searching for edge lines corresponding to each edge of the card from a to-be-searched list corresponding to each preset area based on a preset search rule includes: Sort the lines in the four to-be-searched lists respectively in order from long to short; Based on the preset search rule, the lines to be confirmed are selected from the four lists to be searched in order of sorting, and each selected line to be confirmed is confirmed until the edge lines corresponding to each edge of the card are found in the four lists to be searched.
4. The card edge search method according to claim 3, characterized in that: The method of selecting lines to be confirmed from the four to-be-searched lists in order of sorting based on the preset search rule, and confirming each of the selected lines to be confirmed until edge lines corresponding to each edge of the card are found in the four to-be-searched lists, includes: Selecting a first line to be confirmed from the to-be-searched list corresponding to the first area in sorted order; When the angle difference between the second line to be confirmed selected from the to-be-searched list corresponding to the second area in sorted order and the first line to be confirmed is within a second preset angle range, determining that the first line to be confirmed is the first edge line of the card; When the angle differences between the third line to be confirmed selected from the to-be-searched list corresponding to the third area in the sorted order and the first line to be confirmed and the second line to be confirmed are all within a third preset angle range, and the third line to be confirmed is located between the straight lines corresponding to the first line to be confirmed and the second line to be confirmed and is located on one side of the first end of the first line to be confirmed and the first end of the second line to be confirmed, the second line to be confirmed is determined to be the second edge line of the card; When the angle differences between the fourth line to be confirmed selected from the to-be-searched list corresponding to the fourth area in the sorted order and the first line to be confirmed and the second line to be confirmed are both within the third preset angle range, and the angle difference between the fourth line to be confirmed and the third line to be determined is within the fourth preset angle range, and the fourth line to be confirmed is located between the straight lines corresponding to the first line to be confirmed and the second line to be confirmed respectively and is located on one side of the second end of the first line to be confirmed and the second end of the second line to be confirmed, the third line to be confirmed is determined to be the third edge line of the card, and the fourth line to be confirmed is determined to be the fourth edge line of the card; The first area and the second area are two relative preset areas among the four preset areas, and the third area and the fourth area are the other two relative preset areas among the four preset areas.
5. The card edge search method according to any one of claims 1 to 4, characterized in that: The method further comprises: When the edge line corresponding to at least one edge of the card is not found, re-detecting a frame of the scanned image until the edge lines corresponding to all the edges of the card are found; Alternatively, after edge lines corresponding to the edges of the card are found, if the card image of the card collected based on the edge lines is incomplete, a frame of scanned image is re-detected until the card image collected based on the edge lines is complete.
6. The card edge search method according to any one of claims 1 to 4, characterized in that: The method further comprises: When the number of lines in the obtained screening result is 0, a frame of scanned image is re-detected until the number of lines in the obtained screening result is not 0.
7. The card edge search method according to any one of claims 1 to 4, characterized in that: The method further comprises: After the lines in the screening results are distributed to the lists to be searched, if any of the lists to be searched is empty, a frame of scanned image is re-detected until all four lists to be searched are not empty.
8. A card edge finding device, characterized in that: include: A scanning module, used to obtain scanned images of multiple frames of cards based on a scanning window having four preset areas of top, bottom, left and right; A detection module, used to detect the edge of the card in any frame of the scanned image and obtain a detection result; A screening module, used for screening the lines whose length is greater than or equal to a first preset threshold in the detection results to obtain screening results; An allocating module, for allocating the lines in the screening results to the to-be-searched lists corresponding to the preset areas respectively based on the preset areas; The search module is used to search for edge lines corresponding to each edge of the card from the to-be-searched list corresponding to each preset area based on a preset search rule.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the card edge search method according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the card edge search method according to any one of claims 1 to 7 is implemented.