Thin card counting method, device, electronic equipment and storage medium

Through the method of slicing image processing and merging the slot position sequence, the problem of low accuracy of thin card counting in the prior art is solved, and high accuracy counting of thin cards is achieved.

CN113920073BInactive Publication Date: 2025-04-08SHENZHEN EMPEROR TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111143328.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-28
Publication Date
2025-04-08
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

When counting thin cards, existing optical imaging card counting machines are limited by the camera imaging quality, image clarity and contrast are reduced, which affect the recognition accuracy. Especially when the card is stuck, broken, dirty, etc., counting is difficult.

Method used

By obtaining a set of slice images of the card image to be counted, images with different preset pixel height ranges are intercepted, image areas containing cards are divided, slot positions are detected, slot positions are generated corresponding to slice images, slot positions of multiple slice images are merged, and count results are output.

Benefits of technology

It improves the accuracy of thin card counting, reduces the impact of card sticking, breaking, dirty and other problems on the identification of card joints, and is suitable for counting thinner cards.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113920073B_ABST
    Figure CN113920073B_ABST
Patent Text Reader

Abstract

The present application discloses a thin card counting method, device, electronic device and storage medium, wherein the method comprises: obtaining a group of slice images of a card image to be counted, wherein the card image to be counted is a side view image of a plurality of arranged cards, each of the slice images is an image intercepted within a different preset pixel height range in the card image to be counted, the width of the slice image is the same as the width of the card image to be counted, and the height of the slice image is less than the height of the card image to be counted; segmenting an image area containing a card from the slice image to obtain a card area; detecting a card seam position in the card area, and generating a card seam position sequence corresponding to the slice image according to the card seam position; merging the card seam position sequences corresponding to the group of slice images to obtain a target card seam position sequence; and outputting a counting result based on the target card seam position sequence.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing, and in particular to a thin card counting method, device, electronic equipment and storage medium. Background Art

[0002] With the continuous development of the smart card industry, the application of cards is becoming more and more extensive, and the number of cards issued is also increasing. Card counting products are needed from production to issuance, distribution, and recycling. The counting method and accuracy of cards in the production, circulation, and recycling process are very important.

[0003] At present, optical imaging card counters are widely used. They can take pictures of the products to be counted with high-resolution industrial cameras, and then analyze the card counting results through software. However, due to the limitations of camera imaging quality, the image clarity and contrast gradually decrease from the imaging center to the edges on both sides, affecting recognition. In addition, there are problems such as card adhesion, card breakage, and card dirtiness. The counting accuracy is not high enough, especially the thinner the card, the more difficult it is to count. Summary of the invention

[0004] The present application provides a thin card counting method, device, electronic equipment and storage medium.

[0005] In a first aspect, a thin card counting method is provided, comprising:

[0006] Acquire a group of slice images of the card image to be counted, wherein the card image to be counted is a side view image of a plurality of arranged cards, each of the slice images is an image intercepted within a different preset pixel height range in the card image to be counted, the width of the slice image is the same as the width of the card image to be counted, and the height of the slice image is less than the height of the card image to be counted;

[0007] Segmenting an image region containing a card from the slice image to obtain a card region;

[0008] Detecting the card seam position in the card area, and generating a card seam position sequence corresponding to the slice image according to the card seam position;

[0009] Merging the card seam position sequences corresponding to the set of slice images to obtain a target card seam position sequence;

[0010] The counting result is output based on the target card slot position sequence.

[0011] In an optional embodiment, the method further includes:

[0012] Acquire multiple groups of slice images, and obtain a target card seam position sequence corresponding to each group of slice images;

[0013] Then the outputting of the counting result based on the target card slot position sequence includes:

[0014] Determine the number of card seam positions based on the target card seam position sequence corresponding to each group of slice images;

[0015] The mode of the number of seam positions corresponding to the multiple groups of slice images is determined as a target count value, and the target count value is output as the counting result.

[0016] Optionally, segmenting the image region containing the card from the slice image to obtain the card region includes:

[0017] Calculating the mean of the pixel matrix of the slice image in the row direction to obtain a mean matrix;

[0018] The coordinates of the first pixel point and the last pixel point in the mean matrix that are greater than a preset boundary threshold are obtained as the starting point and the end point of the card area respectively, to determine the card area.

[0019] In an optional implementation, the detecting the position of the card seam in the card area includes:

[0020] Calculating the mean of the pixel matrix of the card area in the row direction to obtain a mean image;

[0021] Using a preset convolution operator to perform a convolution operation on the mean image to obtain a convolution value;

[0022] Obtaining pixel points whose convolution values ​​are greater than a preset threshold as candidate card seam points, and obtaining a pixel point with the largest convolution value among the candidate card seam points;

[0023] The coordinates of the pixel point with the maximum convolution value are determined as the card seam position.

[0024] In an optional implementation, after detecting the position of the card seam in the card area, the method further includes:

[0025] Based on the slot positions, obtaining a slot spacing between every two consecutive slot positions;

[0026] Comparing the card gap distance with a preset card width range, and determining the category of the card gap distance between every two consecutive card gap positions;

[0027] Acquire a slot subsequence from the slot position sequence, wherein the slot subsequence includes three consecutive slot positions;

[0028] Obtaining categories of the three consecutive slot positions' slot spacings, and determining whether the categories of the three consecutive slot spacings satisfy a preset mode category;

[0029] If yes, compare the total width of the slot subsequence with the preset width value to determine whether the slot subsequence includes a pseudo slot position;

[0030] If included, the pseudo-stitch position is eliminated.

[0031] In an optional implementation, after generating the card seam position sequence corresponding to the slice image according to the card seam position, the method further includes:

[0032] Generate a plurality of information units arranged in sequence according to the slot position sequence, each of the information units recording the slot positions of each two consecutive slots, the slot spacing between each two consecutive slot positions, and the type;

[0033] Generate a card seam sequence, wherein the card seam sequence includes the plurality of information units arranged in the sequence;

[0034] The method further comprises:

[0035] Merging the card seam sequences corresponding to the group of slice images to obtain a target card seam sequence;

[0036] The number of the information units in the target card slot sequence is determined as the counting result, and the counting result is output.

[0037] Optionally, the method further includes:

[0038] Acquire the information unit with abnormal card gap spacing from the card gap sequence, and determine the continuous information units with abnormal card gap spacing as an abnormal subsequence;

[0039] The abnormal subsequence is processed based on a preset card number prediction model, the number of cards in the abnormal subsequence is determined, and the information unit of the abnormal subsequence is updated.

[0040] Optionally, the preset card number prediction model includes a first prediction rule, a second prediction rule and a third prediction rule; the processing of the abnormal subsequence based on the preset card number prediction model to determine the number of cards in the abnormal subsequence includes:

[0041] Predicting the first number of cards and the second number of cards in the abnormal subsequence based on the first prediction rule, predicting the third number of cards and the fourth number of cards in the abnormal subsequence based on the second prediction rule, and predicting the fifth number of cards and the sixth number of cards in the abnormal subsequence based on the third prediction rule;

[0042] Calculate a first reference value according to the first number of cards, the third number of cards, the fifth number of cards and a first preset weight parameter, and calculate a second reference value according to the second number of cards, the fourth number of cards, the sixth number of cards and a second preset weight parameter;

[0043] The first reference value and the second reference value are compared, and according to the size relationship between the first reference value and the second reference value, a value is determined from the first reference value and the second reference value as the number of cards in the abnormal subsequence.

[0044] In a second aspect, a thin card counting device is provided, comprising:

[0045] An acquisition module, used for acquiring a group of slice images of the card image to be counted, wherein the card image to be counted is a side view image of a plurality of arranged cards, each of the slice images is an image intercepted within a different preset pixel height range in the card image to be counted, the width of the slice image is the same as the width of the card image to be counted, and the height of the slice image is less than the height of the card image to be counted;

[0046] An image segmentation module, used to segment an image region containing a card from the slice image to obtain a card region;

[0047] A card seam detection module, used to detect the card seam position in the card area, and generate a card seam position sequence corresponding to the slice image according to the card seam position;

[0048] A merging module, used for merging the card seam position sequences corresponding to the group of slice images to obtain a target card seam position sequence;

[0049] An output module is used to output counting results based on the target card slot position sequence.

[0050] According to a third aspect, an electronic device is provided, comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the first aspect and any possible implementation thereof.

[0051] In a fourth aspect, a computer storage medium is provided, wherein the computer storage medium stores one or more instructions, wherein the one or more instructions are suitable for being loaded by a processor and executing the steps of the above-mentioned first aspect and any possible implementation thereof.

[0052] The thin card counting method in the present application obtains a group of slice images of the card image to be counted, wherein the card image to be counted is a side view image of multiple arranged cards, each of the slice images is an image captured in a different preset pixel height range in the card image to be counted, the width of the slice image is the same as the width of the card image to be counted, and the height of the slice image is less than the height of the card image to be counted; an image area containing the card is segmented from the slice image to obtain a card area; a card seam position in the card area is detected, and a card seam position sequence corresponding to the slice image is generated according to the card seam position; the card seam position sequences corresponding to the group of slice images are merged to obtain a target card seam position sequence; a counting result is output based on the target card seam position sequence, and the card seam position is respectively identified by obtaining multiple slices of the card image to be counted, and the card seam information of multiple slices is merged. When the card seam is identified for card counting, the influence of problems such as card adhesion, card breakage, and card dirt on the identification of the card seam is reduced, thereby improving the accuracy of card counting. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the background technology, the drawings required for use in the embodiments of the present application or the background technology will be described below.

[0054] Figure 1 A schematic diagram of a thin card counting method provided in an embodiment of the present application;

[0055] Figure 2 A schematic diagram of a card image to be counted provided in an embodiment of the present application;

[0056] Figure 3 A schematic diagram of the structure of a thin card counting device provided in an embodiment of the present application;

[0057] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0058] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0059] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, device, product or equipment that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or equipment.

[0060] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0061] The embodiments of the present application are described below in conjunction with the drawings in the embodiments of the present application.

[0062] See also Figure 1 , Figure 1 : is a flow chart of a thin card counting method provided in an embodiment of the present application. The method may include:

[0063] 101. Obtain a group of slice images of the card images to be counted, wherein the card images to be counted are side-view images of a plurality of arranged cards, each of the slice images is an image captured within a different preset pixel height range of the card images to be counted, a width of the slice images is the same as a width of the card images to be counted, and a height of the slice images is less than a height of the card images to be counted.

[0064] The card image to be counted in the embodiment of the present application includes multiple cards, and the multiple cards are neatly and closely arranged, and the counting is performed by collecting the side (including the card seam) perspective image. For example, see Figure 2 The schematic diagram of a card image to be counted is shown in FIG. The specific method is to arrange the thin cards to be counted flatly, and use a clamp to compact the cards, and use a single high-definition industrial camera to capture and obtain the image as shown in FIG. Figure 2 The card image to be counted is shown in which the card is a thin subway card that is worn and dirty after use. The card is evenly illuminated and has an edge area that is not a card area. When counting, the middle card area is processed.

[0065] Among them, there is no limit on the number of cards in the above-collected card image to be counted. Relatively speaking, the more cards are counted at one time, the greater the difficulty of the hardware and algorithm. In one embodiment, the number of cards can be determined according to the image processing capability. For example, through the method in the embodiment of the present application, the number of cards in the card image to be counted can be within 500, and 500 cards can be counted at one time, which has comprehensive advantages in the current card counters on the market.

[0066] The execution subject in the embodiment of the present application is a thin card counting device, which can collect images of cards to be counted through a camera for recognition and processing, thereby realizing card recognition and counting.

[0067] Furthermore, a slice image is extracted from the card image to be counted. A pixel height range for cutting the image (corresponding to the height of the slice image) can be preset, and multiple slice images are intercepted from the card image to be counted according to different preset pixel height ranges. The width of the slice image is the same as the width of the card image to be counted, and the height is less than the height of the card image to be counted.

[0068] Under stable imaging conditions, the width of a thin card in the image remains basically unchanged, but due to the perspective distortion of the lens, there is a "bigger near and smaller far" effect, resulting in differences in the width of the card in the middle and on both sides of the image.

[0069] In one embodiment, since the closer the lens is to the edge, the more obvious the distortion is, the image in the center range is selected as the slice image. For example, assuming Figure 2 The image size of the card image to be counted is 3648*5472. The specific operation can be: preset the pixel height range to be: 1400~1450, and cut the image segment in this range as slice 1, with a size of 50*5472; cut the image segment of the same size 200 pixels above slice 1 as slice 2; cut the image segment of the same size 200 pixels below slice 1 as slice 3.

[0070] Optionally, several slice images are arranged in different orders, which can also be regarded as different slice image groups. For example, by the different arrangement orders of the three slices 1, 2 and 3 obtained above, three groups of slices are obtained: {slice 1, slice 2, slice 3}, {slice 2, slice 1, slice 3}, {slice 3, slice 1, slice 2}. On this basis, the preset pixel height range can be adjusted to obtain more groups of slice images, such as offsetting the above preset pixel height range by -50, -100, -150, +50, +100, +150 in sequence to obtain 6 different preset pixel height ranges, each preset pixel height range can generate 3 groups of slices, and according to the above method, a total of 21 groups of slices can be obtained.

[0071] The number, size and acquisition method of the slices can be selected and adjusted as needed, and the embodiments of the present application do not limit this.

[0072] 102. Segment an image region including a card from the slice image to obtain a card region.

[0073] In order to perform card recognition technology, the slice image is firstly segmented by boundary positioning to extract the card area.

[0074] In an optional implementation, the above step 102 includes:

[0075] Calculate the mean of the pixel matrix of the slice image in the row direction to obtain a mean matrix;

[0076] The coordinates of the first pixel point and the last pixel point in the mean matrix that are greater than a preset boundary threshold are obtained as the starting point and the end point of the card area, respectively, to determine the card area.

[0077] Specifically, the pixel matrix of the slice image is represented as A∈[M,N], and the mean value of the row direction of the matrix is ​​calculated:

[0078]

[0079] Obtain the mean matrix MA∈[1,N], and according to a preset boundary threshold (such as 60), use the coordinates of the first pixel and the last pixel in the mean matrix that are greater than the preset boundary threshold as the starting point and the end point of the card area, respectively, to locate the card area.

[0080] Optionally, the above-mentioned set of slice images includes a first slice image and a second slice image;

[0081] When the starting point coordinates of the card area of ​​the second slice image and the first slice image are inconsistent, the second slice image is perspective transformed to obtain an image having the starting point coordinates consistent with the first slice image.

[0082] Perspective transformation refers to the transformation that uses the perspective center, image point, and target point to rotate the image receiving surface (perspective surface) around the trace (perspective axis) by a certain angle according to the perspective rotation law, destroying the original projection light beam, while still keeping the projected geometric figures on the image receiving surface unchanged. Specifically, when the card is tilted, the starting points of each slice image in a group may not be consistent, which will cause the card seams at corresponding positions of the multi-slice images to be misaligned, so it is necessary to perform perspective transformation on the slice images to obtain images with consistent starting points. For example, the above slices 2 and 3 are perspective transformed to obtain images with consistent starting points with slice 1.

[0083] After completing the perspective transformation, the card area CropM∈[M,L] is segmented from the original image according to the starting and ending point information, where L is the total width of the card area.

[0084] Optionally, the slice images can be enhanced separately to increase the contrast and improve the distinction between the card seam and the card. The number of enhanced groups G of the card area can be calculated based on the preset group pixel height. For example, 300 pixels are a group, and the number of groups is calculated as: G = floor (L / 300); then the card area CropM is divided into G image segments, and the maximum and minimum values ​​are normalized in turn to improve the image contrast.

[0085] Optionally, after the image is normalized, filtering can be performed. For example, a filter that preserves edges, namely bilateral filtering, can be used for denoising. The bilateral filtering parameter is σ s =3,σ r =10.

[0086] 103. Detect the card seam position in the card area, and generate a card seam position sequence corresponding to the slice image according to the card seam position.

[0087] Based on the card area obtained after the above processing is completed, card seam detection can be performed according to a preset card seam detection algorithm to determine the card seam position.

[0088] In an optional implementation, the detecting the position of the card seam in the card area includes:

[0089] Calculate the mean of the pixel matrix of the card area in the row direction to obtain a mean image;

[0090] Use a preset convolution operator to perform a convolution operation on the mean image to obtain a convolution value;

[0091] Obtaining the pixel points whose convolution values ​​are greater than a preset threshold as candidate card seam points, and obtaining the pixel point with the largest convolution value among the candidate card seam points;

[0092] The coordinates of the pixel point with the maximum convolution value are determined as the above-mentioned card seam position.

[0093] Specifically, firstly, the mean value of the pixel matrix CropM in the card area in the row direction can be calculated to obtain the mean image, that is, the one-dimensional image AvgM;

[0094] According to the characteristics of the "high-low-high" pattern of the card seam and the surrounding pixel values, a preset convolution operator is designed, such as the convolution operator:

[0095] kernel = [1 -2 1]

[0096] The AvgM image is convolved using a preset convolution operator to obtain a convolution value DiffM. Since the mode is "high-low-high", the result of the convolution at the seam must be a positive value. The pixel points in the convolution value DiffM that meet the preset threshold are defined as the above-mentioned candidate seam points. The above-mentioned preset threshold can be set as needed, for example, a value of 30.

[0097] After the above convolution, points that satisfy a difference threshold may also appear around the seam, so a non-maximum suppression operation is performed on the convolution result. The point with the highest credibility is selected from a series of consecutive candidate seam points that satisfy the above seam conditions. The specific operation can be:

[0098] In the preset neighborhood (such as 3*3 neighborhood) of the pixel points that meet the above card seam conditions, find the maximum value of the convolution value. The formula is as follows:

[0099] d * =max(d i |i∈Ω 3*3 ),

[0100] The maximum value point is the card seam point. Points that are not maximum values ​​but meet the card seam conditions are eliminated, and only the maximum value point is retained.

[0101] In an optional implementation, after detecting the position of the card seam in the card area, the method further includes:

[0102] Based on the above-mentioned slot positions, a slot spacing between every two consecutive slot positions is obtained;

[0103] Compare the card gap distance with a preset card width range to determine the category of the card gap distance between each two consecutive card gap positions;

[0104] Obtaining a slot subsequence from the slot position sequence, wherein the slot subsequence includes three consecutive slot positions;

[0105] Obtaining the categories of the three consecutive slot spacings at the slot positions, and determining whether the categories of the three consecutive slot spacings meet the preset mode category;

[0106] If yes, compare the total width of the slot subsequence with the preset width value to determine whether the slot subsequence includes a pseudo slot position;

[0107] If included, the above-mentioned pseudo-stitch positions are eliminated.

[0108] Specifically, card width analysis may also be performed in the embodiments of the present application.

[0109] Since cards may be stuck, broken, dirty, or have reduced contrast at the edge of the image, there may be missed detection or false detection at the card gaps. The distance between two consecutive card gaps indicates the width of a card. Based on the normal width range of a card (assuming a width of 9 to 12 pixels), it is possible to determine whether the spacing between the card gaps is normal, and classify the spacing of all card gaps, for example, into three categories: normal card spacing, short card spacing, and long card spacing.

[0110] In an optional implementation, after generating the slot position sequence corresponding to the slice image according to the slot position, the method further includes:

[0111] Generate a plurality of information units arranged in sequence according to the slot position sequence, each of the information units recording every two consecutive slot positions, the slot spacing between every two consecutive slot positions, and the category;

[0112] Generate a card slot sequence, wherein the card slot sequence includes the plurality of information units arranged in the above order.

[0113] Optionally, in the embodiment of the present application, a card slot sequence CardList is used to represent the card spacing information. CardList is composed of multiple information units, and each information unit records the position, card slot spacing and category of two adjacent card slots.

[0114] In the embodiment of the present application, pseudo card gaps can be further removed to improve the credibility of the card gap detection results. When a card has cracks or is dirty, a "pseudo card gap" is generated. This type of card gap is reflected by a very short card spacing. Therefore, according to the category of the card gap spacing of three consecutive card gap positions, it can be judged whether it meets the preset mode category and card width conditions to determine whether there are abnormal conditions such as "pseudo card gaps".

[0115] For example, in the card gap sequence, a card gap subsequence of the "normal card gap-short card gap-normal card gap" pattern is detected. If the sequence is generated by two cards with gaps, the width of the sequence should be equal to the width of the two cards; because it is assumed that the normal width of the card is in the range of 9 to 12 pixels, the width of the two cards is approximately 18 to 24 pixels. If the width of the card gap subsequence is in the interval [18,24], it means that the card gap subsequence is actually composed of two cards, and the pseudo card gap is removed from the card gap sequence CardList.

[0116] When the card is stuck, dirty, or the contrast of the image edge is reduced, the card seam is missed. This type of card seam is reflected by a longer card spacing. The lost card seam information in the slice image can be supplemented by the card seam information in other slice images, that is, for a group of three slice images, the card seam position information of the corresponding positions of slices 2 and 3 is inserted into the card seam position sequence of slice 1 (only one of the duplicates is retained).

[0117] In the multi-slice seam information fusion step, the seam information of other slice images is used. These seams may also be "pseudo seams", so the pseudo seam removal operation can be performed again, which will not be repeated here.

[0118] 104. Merge the seam position sequences corresponding to the above group of slice images to obtain a target seam position sequence.

[0119] 105. Output a counting result based on the target card slot position sequence.

[0120] In an optional implementation, the above method further includes:

[0121] Acquire multiple groups of slice images, and obtain a target card seam position sequence corresponding to each group of the slice images;

[0122] Then step 105 includes:

[0123] Determine the number of card seam positions based on the target card seam position sequence corresponding to each group of slice images;

[0124] The mode of the number of seam positions corresponding to the plurality of groups of slice images is determined as a target count value, and the target count value is output as the counting result.

[0125] For a group of slice images, the above steps 102 to 105 can be performed to obtain the corresponding counting results. In the embodiment of the present application, multiple groups of slice images (such as the 21 groups of slice images mentioned above) can be selected, and the same processing steps are respectively performed, that is, multiple groups of slice images are sequentially input into the card counting algorithm module to obtain corresponding multiple technical results. The thin card counting scheme in the embodiment of the present application uses the results of the voting mechanism of multiple groups of slice images, that is, the mode of multiple groups of counting results is used as the final result to improve the reliability of the thin card counting results. Optionally, other methods can also be used to determine a final result, such as the median, etc., which is not limited in the embodiment of the present application.

[0126] Optionally, the method further includes:

[0127] Merge the card seam sequences corresponding to the above set of slice images to obtain a target card seam sequence;

[0128] The number of the information units in the target card slot sequence is determined as the counting result, and the counting result is output.

[0129] Similarly, when the cardlist sequence CardList is used for judgment, the cardlist sequence of each group of slice images can also be merged (only one repeated information unit is retained) to reduce the problem of losing the cardlist information.

[0130] Optionally, the above method further includes:

[0131] Acquire the information unit with abnormal card gap spacing from the card gap sequence, and determine the continuous information units with abnormal card gap spacing as an abnormal subsequence;

[0132] The abnormal subsequence is processed based on a preset card number prediction model to determine the number of cards in the abnormal subsequence, and the information unit of the abnormal subsequence is updated.

[0133] In the embodiment of the present application, a comprehensive analysis of abnormal card spacing can be further performed.

[0134] After the above steps of removing anomalies, the number of information units classified as "short card spacing" and "long card spacing" has decreased, but it has not been completely resolved. In the card gap sequence CardList, find the information units with abnormal card spacing. If multiple consecutive information units are abnormal, they are treated as an abnormal subsequence for processing.

[0135] In the embodiment of the present application, the above-mentioned preset card number prediction model is set to process and analyze the abnormal subsequence, determine the number of cards corresponding to the abnormal subsequence, and update the information unit therein. In the embodiment of the present application, the card number prediction model or algorithm can be set as needed to perform abnormal card spacing analysis, which is not limited here.

[0136] In an optional implementation, the preset card number prediction model includes a first prediction rule, a second prediction rule and a third prediction rule; the processing of the abnormal subsequence based on the preset card number prediction model to determine the number of cards in the abnormal subsequence includes:

[0137] Predicting the first number of cards and the second number of cards in the abnormal subsequence based on the first prediction rule, predicting the third number of cards and the fourth number of cards in the abnormal subsequence based on the second prediction rule, and predicting the fifth number of cards and the sixth number of cards in the abnormal subsequence based on the third prediction rule;

[0138] Calculate a first reference value based on the first number of cards, the third number of cards, the fifth number of cards and a first preset weight parameter, and calculate a second reference value based on the second number of cards, the fourth number of cards, the sixth number of cards and a second preset weight parameter;

[0139] The first reference value is compared with the second reference value, and according to the size relationship between the first reference value and the second reference value, a value is determined from the first reference value and the second reference value as the number of cards in the abnormal subsequence.

[0140] In the embodiment of the present application, different prediction rules can be set to predict the number of cards in the abnormal subsequence. Each prediction rule can obtain two prediction results (the above reference values), and then weighted calculations are performed separately to determine the final prediction results. Appropriate weight parameters can be selected as needed, and the embodiment of the present application does not limit this.

[0141] In a specific implementation, the card number estimation probability function can be established from the following three perspectives, where N and Nplus are two reference values: one:

[0143] Assume that the abnormal subsequence consists of n information units, and the first information unit is c i , where the coordinate of the left side seam of the unit is x i,1 , the last information unit is c i+n-1 , where the coordinate of the right side seam of the unit is x i+n-1,2 , abnormal subsequence length len = x i+n-1,2 -x i,1 ;

[0144] According to the thin card width W, it is estimated that the number of cards contained in the abnormal subsequence may be N = floor (len / W) or N plus = floor (len / W) + 1. The following formula is used to express the probability of the estimated number of cards being N and N plus respectively:

[0145]

[0146] two:

[0148] Expand the left and right sides of the abnormal subsequence by one information unit each to obtain the second subsequence c i-1 ,c i ,...,c i+n-1 ,c i+n , the second subsequence length len2 = x i+n,2 -x i-1,1, since the second subsequence has 2 more information units than the first subsequence, the number of sheets contained in this subsequence may be N2=N+2 or Nplus2=Nplus+2. The following formula is used to express the probability of estimating the number of sheets to be N2 and Nplus2 respectively:

[0149]

[0150] three:

[0152] Put three slices in the sequence range [x i,1 ,x i+n-1,2 ] The coordinates of the detected seam points are arranged in sequence to obtain s1,...,s m ; N and Nplus are the numbers of sheets, respectively, in the range [x i,1 ,x i+n-1,2 ] to obtain the estimated coordinates of the card slots p1,...,p under the condition of equal card slot spacing N-1 and q1,...,q N_plus-1 , respectively calculate their differences with s1,...,s m Distance:

[0153] For each estimated gap p k or k , in s1,...,s m Find the closest card seam point Add up the distances and find the average distance:

[0154]

[0155]

[0156]

[0157]

[0158] }

[0159] Combining the above three dimensions to evaluate the probability of the number of cards in the abnormal sequence, a judgment function is established:

[0160] ratioN=ratio_N+1.5×ratio_N2+1.5×ratio_N3,

[0161] ratioNplus=ratio_Nplus+1.5×ratio_Nplus2+1.5×ratio_Nplus3,

[0162] If ratioN≥ratioNplus, the abnormal subsequence is estimated to be N cards, and p1,...,p N-1 The card slot information replaces the information unit of the abnormal subsequence and updates the card slot sequence CardList; if ratioN<ratioNplus, the abnormal subsequence is estimated to be Nplus cards, that is, N+1 cards, and q1,...,q N_plus-1 The card gap information replaces the information unit of the abnormal subsequence and updates the card gap sequence CardList.

[0163] After the above steps, the final card slot sequence CardList is obtained. The number of information units in CardList is the final result of card counting, so the number of information units in CardList can be output.

[0164] In the embodiment of the present application, a group of slice images of the card image to be counted is obtained, the card image to be counted is a side view image of multiple arranged cards, each of the slice images is an image captured in a different preset pixel height range in the card image to be counted, the width of the slice image is the same as the width of the card image to be counted, and the height of the slice image is less than the height of the card image to be counted; an image area containing the card is segmented from the slice image to obtain a card area; a card seam position in the card area is detected, and a card seam position sequence corresponding to the slice image is generated according to the card seam position; the card seam position sequences corresponding to the group of slice images are merged to obtain a target card seam position sequence; a counting result is output based on the target card seam position sequence, and the card seam positions are respectively identified by obtaining multiple slices of the card image to be counted, and the card seam information of multiple slices is merged. When the card seam is identified for card counting, the influence of problems such as card adhesion, card breakage, and card dirt on the identification of the card seam is reduced, thereby improving the accuracy of card counting.

[0165] The current card counting is based on the edge of the card. After completing the image preprocessing operation, the Sobel operator can be used to detect the edge of the card according to the characteristics of the image texture. After accurately extracting the card edge information in the image, the edge counting method is studied, and a counting method based on segmentation and a counting method based on projection transformation are proposed. The segmentation-based method mainly binarizes the image and uses mathematical morphology to remove interference information in the image to achieve the purpose of accurate counting. The counting method based on projection transformation directly transforms the detected edge image and finds the best projection vector of the image, converting the edge counting problem into solving the number of pulses in the projection vector. Combined with the periodic nature of the pulse, the counting purpose is achieved by finding the maximum value.

[0166] In order to avoid the problem of decreased image edge clarity and different card widths in the middle and on both sides of the image caused by a single camera, a multi-camera method is generally used, which increases the cost and also has a certain complexity in processing images collected by multiple image collectors. Moreover, this method only provides solutions for cards with relatively clean surfaces and a small number (for example, no more than 120 cards), and the accuracy is not high enough.

[0167] Equivalent to the current solution, the embodiment of the present application can effectively compensate for the estimation deviation caused by the decrease in image edge clarity caused by the single camera and the difference in card width between the middle and both sides of the image, so that the performance of accurate counting can still be maintained under the single camera working mode, effectively reducing costs. In the single camera mode, the present invention can achieve 100% accurate counting of thin cards within 500 pieces. The cards used can be subway thin cards that have been worn and dirty, and the card thickness is only 0.45mm. Among the card types applicable to many card counters, it is a very thin card with high card counting accuracy.

[0168] Based on the description of the above thin card counting method embodiment, the present application embodiment also discloses a thin card counting device. Figure 3 , the thin card counting device 300 comprises:

[0169] The acquisition module 310 is used to acquire a group of slice images of the card image to be counted, wherein the card image to be counted is a side view image of a plurality of arranged cards, each of the slice images is an image intercepted within a different preset pixel height range in the card image to be counted, the width of the slice image is the same as the width of the card image to be counted, and the height of the slice image is less than the height of the card image to be counted;

[0170] An image segmentation module 320 is used to segment an image region containing a card from the slice image to obtain a card region;

[0171] A card seam detection module 330 is used to detect the card seam position in the card area, and generate a card seam position sequence corresponding to the slice image according to the card seam position;

[0172] A merging module 340 is used to merge the seam position sequences corresponding to the group of slice images to obtain a target seam position sequence;

[0173] The output module 350 is used to output the counting result based on the target card slot position sequence.

[0174] Optionally, the acquisition module 310 is further used to acquire multiple groups of slice images; the target seam position sequence corresponding to each group of slice images can be obtained through the seam detection module 330 and the output module 350;

[0175] The output module 350 is specifically used for:

[0176] Determine the number of card seam positions based on the target card seam position sequence corresponding to each group of slice images;

[0177] The mode of the number of seam positions corresponding to the plurality of groups of slice images is determined as a target count value, and the target count value is output as the counting result.

[0178] Optionally, the image segmentation module 320 is specifically used for:

[0179] Calculate the mean of the pixel matrix of the slice image in the row direction to obtain a mean matrix;

[0180] The coordinates of the first pixel point and the last pixel point in the mean matrix that are greater than a preset boundary threshold are obtained as the starting point and the end point of the card area, respectively, to determine the card area.

[0181] Optionally, the card gap detection module 330 is specifically used for:

[0182] Calculate the mean of the pixel matrix of the card area in the row direction to obtain a mean image;

[0183] Use a preset convolution operator to perform a convolution operation on the mean image to obtain a convolution value;

[0184] Obtaining the pixel points whose convolution values ​​are greater than a preset threshold as candidate card seam points, and obtaining the pixel point with the largest convolution value among the candidate card seam points;

[0185] The coordinates of the pixel point with the maximum convolution value are determined as the above-mentioned card seam position.

[0186] Optionally, the card gap detection module 330 is further used for:

[0187] After detecting the card slot positions in the card area, obtaining the card slot spacing between every two consecutive card slot positions based on the card slot positions;

[0188] Compare the card gap distance with a preset card width range to determine the category of the card gap distance between each two consecutive card gap positions;

[0189] Obtaining a slot subsequence from the slot position sequence, wherein the slot subsequence includes three consecutive slot positions;

[0190] Obtaining the categories of the three consecutive slot spacings at the slot positions, and determining whether the categories of the three consecutive slot spacings meet the preset mode category;

[0191] If yes, compare the total width of the slot subsequence with the preset width value to determine whether the slot subsequence includes a pseudo slot position;

[0192] If included, the above-mentioned pseudo-stitch positions are eliminated.

[0193] Optionally, the seam detection module 330 is further configured to, after generating a seam position sequence corresponding to the slice image according to the seam positions, generate a plurality of information units arranged in sequence according to the seam position sequence, each of the information units recording the seam positions of every two consecutive seam positions, the seam spacing between every two consecutive seam positions, and the category;

[0194] Generate a card seam sequence, the card seam sequence includes the plurality of information units arranged in the above order;

[0195] The merging module 340 is also used for:

[0196] Merge the card seam sequences corresponding to the above set of slice images to obtain a target card seam sequence;

[0197] The number of the information units in the target card slot sequence is determined as the counting result, and the counting result is output.

[0198] Optionally, the above-mentioned card gap detection module 330 is also used for:

[0199] Acquire the information unit with abnormal card gap spacing from the card gap sequence, and determine the continuous information units with abnormal card gap spacing as an abnormal subsequence;

[0200] The abnormal subsequence is processed based on a preset card number prediction model to determine the number of cards in the abnormal subsequence, and the information unit of the abnormal subsequence is updated.

[0201] According to an embodiment of the present application, each step involved in the method shown in the above embodiment can be performed by Figure 3 The operations performed by the various modules in the thin card counting device 300 are not described in detail here.

[0202] The thin card counting device 300 in the embodiment of the present application can obtain a group of slice images of the card image to be counted, wherein the card image to be counted is a side view image of multiple arranged cards, each of the slice images is an image captured in a different preset pixel height range in the card image to be counted, the width of the slice image is the same as the width of the card image to be counted, and the height of the slice image is less than the height of the card image to be counted; segment an image area containing the card from the slice image to obtain a card area; detect the card seam position in the card area, and generate a card seam position sequence corresponding to the slice image according to the card seam position; merge the card seam position sequences corresponding to the group of slice images to obtain a target card seam position sequence; output a counting result based on the target card seam position sequence, and respectively identify the card seam position by obtaining multiple slices of the card image to be counted, and fuse the card seam information of multiple slices. When identifying the card seam for card counting, the influence of problems such as card adhesion, card breakage, and card dirt on the identification of the card seam is reduced, thereby improving the accuracy of card counting.

[0203] Based on the description of the above method embodiment and device embodiment, the present application embodiment also provides an electronic device. Figure 4 The electronic device 400 at least includes a processor 401, an input device 402, an output device 403, and a computer storage medium 404. The processor 401, the input device 402, the output device 403, and the computer storage medium 404 in the electronic device may be connected via a bus or other means.

[0204] The computer storage medium 404 can be stored in the memory of the electronic device. The computer storage medium 404 is used to store a computer program. The computer program includes program instructions. The processor 401 is used to execute the program instructions stored in the computer storage medium 404. The processor 401 (or CPU (Central Processing Unit)) is the computing core and control core of the electronic device, which is suitable for implementing one or more instructions, and is specifically suitable for loading and executing one or more instructions to implement the corresponding method flow or corresponding function; in one embodiment, the processor 401 of the embodiment of the present application can be used to perform a series of processing, including any steps in the method involved in the aforementioned embodiment, etc.

[0205] The embodiment of the present application also provides a computer storage medium (Memory), which is a memory device in an electronic device for storing programs and data. It is understandable that the computer storage medium here can include both built-in storage media in electronic devices and, of course, extended storage media supported by electronic devices. The computer storage medium provides a storage space that stores the operating system of the electronic device. In addition, one or more instructions suitable for being loaded and executed by the processor 401 are also stored in the storage space, and these instructions can be one or more computer programs (including program codes). It should be noted that the computer storage medium here can be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk storage; optionally, it can also be at least one computer storage medium located away from the aforementioned processor.

[0206] In one embodiment, one or more instructions stored in a computer storage medium may be loaded and executed by the processor 401 to implement the corresponding steps in the above-mentioned embodiments; in a specific implementation, one or more instructions in a computer storage medium may be loaded and executed by the processor 401 to execute any steps of the method in the above-mentioned embodiments, which will not be repeated here.

[0207] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0208] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the division of the module is only a logical function division, and 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. The mutual coupling, direct coupling, or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.

[0209] 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 modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0210] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media integrations. The available medium may be a read-only memory (ROM), or a random access memory (RAM), or a magnetic medium, such as a floppy disk, a hard disk, a tape, a magnetic disk, or an optical medium, such as a digital versatile disc (DVD), or a semiconductor medium, such as a solid state disk (SSD), etc.

Claims

1. A thin card counting method, characterized in that: The method comprises: Acquire a group of slice images of the card image to be counted, wherein the card image to be counted is a side view image of a plurality of arranged cards, each of the slice images is an image intercepted within a different preset pixel height range in the card image to be counted, the width of the slice image is the same as the width of the card image to be counted, and the height of the slice image is less than the height of the card image to be counted; Segmenting an image region containing a card from the slice image to obtain a card region; Detecting the card seam position in the card area, and generating a card seam position sequence corresponding to the slice image according to the card seam position; The detecting of the card seam position in the card area includes: calculating the mean of the pixel matrix of the card area in the row direction to obtain a mean image; using a preset convolution operator to perform a convolution operation on the mean image to obtain a convolution value; obtaining a pixel point whose convolution value is greater than a preset threshold as a candidate card seam point, and obtaining a pixel point with the largest convolution value among the candidate card seam points; and determining the coordinates of the pixel point with the largest convolution value as the card seam position; Merging the card seam position sequences corresponding to the set of slice images to obtain a target card seam position sequence; The counting result is output based on the target card slot position sequence.

2. The method according to claim 1, characterized in that: The method further comprises: Acquire multiple groups of slice images, and obtain a target card seam position sequence corresponding to each group of slice images; Then the outputting of the counting result based on the target card slot position sequence includes: Determine the number of card seam positions based on the target card seam position sequence corresponding to each group of slice images; The mode of the number of seam positions corresponding to the multiple groups of slice images is determined as a target count value, and the target count value is output as the counting result.

3. The method according to claim 1, characterized in that: The step of segmenting the image region containing the card from the slice image to obtain the card region comprises: Calculating the mean of the pixel matrix of the slice image in the row direction to obtain a mean matrix; The coordinates of the first pixel point and the last pixel point in the mean matrix that are greater than a preset boundary threshold are obtained as the starting point and the end point of the card area respectively, to determine the card area.

4. The method according to any one of claims 1 to 3, characterized in that: After detecting the position of the card slot in the card area, the method further includes: Based on the slot positions, obtaining a slot spacing between every two consecutive slot positions; Comparing the card gap distance with a preset card width range, and determining the category of the card gap distance between every two consecutive card gap positions; Acquire a slot subsequence from the slot position sequence, wherein the slot subsequence includes three consecutive slot positions; Obtaining categories of the three consecutive slot positions' slot spacings, and determining whether the categories of the three consecutive slot spacings satisfy a preset mode category; If yes, compare the total width of the slot subsequence with the preset width value to determine whether the slot subsequence includes a pseudo slot position; If included, the pseudo-stitch position is eliminated.

5. The method according to claim 4, characterized in that: After generating a slot position sequence corresponding to the slice image according to the slot position, the method further includes: Generate a plurality of information units arranged in sequence according to the slot position sequence, each of the information units recording the slot positions of each two consecutive slots, the slot spacing between each two consecutive slot positions, and the type; Generate a card seam sequence, wherein the card seam sequence includes the plurality of information units arranged in the sequence; The method further comprises: Merging the card seam sequences corresponding to the group of slice images to obtain a target card seam sequence; The number of the information units in the target card slot sequence is determined as the counting result, and the counting result is output.

6. The method according to claim 5, characterized in that: The method further comprises: Acquire the information unit with abnormal card gap spacing from the card gap sequence, and determine the continuous information units with abnormal card gap spacing as an abnormal subsequence; The abnormal subsequence is processed based on a preset card number prediction model, the number of cards in the abnormal subsequence is determined, and the information unit of the abnormal subsequence is updated.

7. The method according to claim 6, characterized in that: The preset card number prediction model includes a first prediction rule, a second prediction rule and a third prediction rule; the abnormal subsequence is processed based on the preset card number prediction model to determine the number of cards in the abnormal subsequence, including: Predicting the first number of cards and the second number of cards in the abnormal subsequence based on the first prediction rule, predicting the third number of cards and the fourth number of cards in the abnormal subsequence based on the second prediction rule, and predicting the fifth number of cards and the sixth number of cards in the abnormal subsequence based on the third prediction rule; Calculate a first reference value according to the first number of cards, the third number of cards, the fifth number of cards and a first preset weight parameter, and calculate a second reference value according to the second number of cards, the fourth number of cards, the sixth number of cards and a second preset weight parameter; The first reference value and the second reference value are compared, and according to the size relationship between the first reference value and the second reference value, a value is determined from the first reference value and the second reference value as the number of cards in the abnormal subsequence.

8. A thin card counting device, characterized in that: include: An acquisition module is used to acquire a group of slice images of the card image to be counted, wherein the card image to be counted is a side view image of a plurality of arranged cards, each of the slice images is an image intercepted within a different preset pixel height range in the card image to be counted, the width of the slice image is the same as the width of the card image to be counted, and the height of the slice image is less than the height of the card image to be counted; An image segmentation module, used to segment an image region containing a card from the slice image to obtain a card region; A card seam detection module, used to detect the card seam position in the card area, and generate a card seam position sequence corresponding to the slice image according to the card seam position; The card seam detection module is specifically used to calculate the mean of the pixel matrix of the card area in the row direction to obtain a mean image; use a preset convolution operator to perform a convolution operation on the mean image to obtain a convolution value; obtain pixel points whose convolution values ​​are greater than a preset threshold as candidate card seam points, and obtain the pixel point with the largest convolution value among the candidate card seam points; and determine the coordinates of the pixel point with the largest convolution value as the card seam position; A merging module, used for merging the card seam position sequences corresponding to the group of slice images to obtain a target card seam position sequence; An output module is used to output counting results based on the target card slot position sequence.

9. An electronic device, characterized in that: The invention comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the thin card counting steps according to any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the processor is caused to perform the thin card counting steps according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Image detection method and device, electronic equipment and storage medium

    CN111723634A

  • Crack detection method and system

    CN113160202A