A magnetic card feature point extraction method and storage medium based on AMR sensor
By calculating the peak threshold and trough threshold, detecting the card swiping operation in real time, and updating the bit cycle in real time, the problem of difficulty in extracting feature points when analyzing magnetic weaker magnetic card information is solved, and more stable and accurate feature points are achieved.
Patent Information
- Application Number
- CN202411641189.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2044-11-18
AI Technical Summary
When a Pos machine based on AMR sensor analyzes bank card information with weak magnetic properties and damaged magnetic signals, it is difficult to accurately extract the characteristic points of the magnetic stripe card, affecting the decoding accuracy.
By calculating the historical data of the AMR sensor, the peak threshold and trough threshold are obtained, the data points are detected in real time, the card swiping operation is judged, and the bit period is updated in real time during the feature point extraction stage to ensure the accurate collection of feature points.
It improves the stable acquisition of the feature points of the magnetic card, reduces the impact of the instability of the magnetic signal period on the feature point acquisition, and enhances the accuracy of subsequent decoding.
Smart Images

Figure CN119152610B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of magnetic card decoding, and in particular to a magnetic card feature point extraction method based on an AMR sensor and a storage medium. Background Art
[0002] The current solutions for decoding the magnetic stripe of bank cards on POS machines can be divided into pure hardware decoding solutions and software-hardware combined decoding solutions. The pure hardware solution means that the entire decoding process (including the collection and decoding of magnetic information on the magnetic stripe card) is completed by hardware. The software-hardware combined solution means that the magnetic information is converted into an electrical signal that can be processed by software through a magnetoelectric sensor, and then decoded by the MCU on the POS machine using software processing methods. The pure hardware solution has a fast decoding speed, but the cost is high and it is not easy to modify. In comparison, the software-hardware combined solution has lower cost, greater flexibility, and is easy to transplant and adapt.
[0003] At present, anisotropic magnetoresistive elements (AMR) are widely used as magnetoelectric sensing elements on POS machines due to their low cost and relatively simple process. However, due to the characteristics of AMR itself, POS machines based on AMR sensors have certain difficulties in parsing bank card information with various problems such as weak magnetism and damaged magnetic signals. When extracting the feature points of magnetic stripe cards, the decoding may be affected due to the weak magnetic signal, unstable magnetic card cycle, and burrs on the magnetic signal. Summary of the invention
[0004] To achieve the above-mentioned purpose and other related purposes, the present invention discloses a method for extracting characteristic points of a magnetic card based on an AMR sensor, comprising:
[0005] S1: Calculate the peak threshold and the trough threshold based on the historical data of the AMR sensor;
[0006] S2: Detect data points in real time, and determine whether there is a card swiping operation based on the data points, peak threshold and trough threshold. If a card swiping operation is detected, initialize the variables and enter the feature point extraction stage, otherwise loop the card swiping detection;
[0007] S3: When it is detected that there is a card swiping operation, enter the feature point extraction stage, continue to detect data points, obtain the bit period P according to the maximum and minimum values in the data points, predict the interval of the next extreme point according to the bit period, and detect the extreme point within the interval. Update the bit period P according to the extreme point, and execute this step repeatedly, taking all the data points detected in the feature extraction stage as feature points; when it is detected that the card swiping operation is ended or the number of feature points reaches the first preset number, end the feature point extraction and perform the feature point decoding operation.
[0008] Further, the calculation of the peak threshold and the valley threshold includes:
[0009] Obtain the mean value of the second preset number of historical data collected by the AMR sensor as the normal value NorVal. The peak threshold Pv and the valley threshold Vv satisfy: Pv = NorVal + Thr, Vv = NorVal - Thr, where Thr is the set parameter threshold.
[0010] Further, the determination of whether there is a card - swiping operation currently based on the data points, the peak threshold, and the valley threshold includes:
[0011] Sequentially and cyclically detect each data collected by the sensor. If it is detected that a continuous number of data points greater than the third preset number are greater than the peak threshold, or a continuous number of data points greater than the third preset number are less than the valley threshold, then mark the subscript starting from the first data point among the above - mentioned continuous data points that meet the conditions.
[0012] Obtain the extreme points from the data points that meet the above - mentioned conditions. If four maximum points and four minimum points are alternately detected among the data points within the fourth preset number, and the four extreme points meet the preset conditions, then it is determined that there is a card - swiping operation currently.
[0013] Further, the preset conditions include:
[0014] Set the subscripts of the four extreme points to be N1, N2, N3, and N4 respectively, and the distances between every two adjacent extreme points are P1, P2, P3 respectively, where P1 = N2 - N1, P2 = N3 - N2, P3 = N4 - N3;
[0015] If P1 > P2×1.5 or P1 < P2×0.5 or P2 > P3×1.5 or P2 < P3×0.5, then the preset conditions are not met.
[0016] Further, the initialization of variables includes:
[0017] Initialize the bit period P, P=(P1 + P2 + P3) / 3;
[0018] Initialize the appearance interval [a, b] of the next extreme point predicted according to the bit period: The prediction interval ranges from the sampled data with subscript a to the sampled data with subscript b, where a = N4 + P - P / 4, b = N4 + P + P / 4;
[0019] Initialize the number of data points continuously between the peak threshold and the valley threshold to 0.
[0020] Furthermore, when it is detected that there is a card swiping operation, the data points are continuously detected, the bit period is obtained according to the maximum and minimum values in the data points, the occurrence interval of the next extreme point is predicted according to the bit period, and the extreme point is detected within the interval, and the bit period P is updated according to the extreme point, and this step is executed repeatedly, and all the detected extreme points are taken as feature points including:
[0021] S31: Counting the number of data points that are continuously between the peak threshold and the trough threshold, and if the number is greater than a fourth preset number, determining that the card swiping operation is finished;
[0022] S32: Count the number of data points between the peak threshold and the trough threshold continuously, and if the number is less than a fourth preset number, determine whether the number of data points between the peak threshold and the trough threshold is greater than a preset multiple of the current bit period P;
[0023] If the number of data points between the peak threshold and the trough threshold is greater than the preset multiple of the current bit period P, it is determined that the waveform is abnormal. At this time, if the number of extracted feature points is less than the fifth preset number, step S2 is re-executed. If the number of extracted feature points is greater than the fifth preset number, feature point extraction is terminated.
[0024] S33: If the number of data points between the peak threshold and the trough threshold is less than the preset multiple of the current bit period P, it is determined whether a new feature point is collected in the current interval [a, b];
[0025] If so, determine whether the polarity of the new feature point is the same as that of the previous feature point;
[0026] If they are not the same, save the new feature points and re-execute S31;
[0027] If they are the same, the new feature points are not saved and S31 is executed again;
[0028] S33: If no new feature point is collected in the current interval [a, b], and the subscript of the new feature point is b+1, determine whether the polarity of the new feature point is the same as that of the previous feature point;
[0029] If they are not the same, save the new feature points;
[0030] If they are the same, the new feature points are not saved and S31 is executed again;
[0031] S34: if the number of feature points reaches a first preset number, the feature point extraction is terminated and decoding is performed;
[0032] If the number of feature points does not reach the first preset number, the period P and the interval [a, b] are updated, and S31 is executed again.
[0033] Further, the updating of the period P and the interval [a, b] includes:
[0034] Obtain the period Pn between the new feature point and the previous feature point saved in S33;
[0035] Assign the original P2 to P1, the original P3 to P2, and Pn to P3;
[0036] P satisfies P=(P1+P2+P3) / 3;
[0037] The interval [a, b] satisfies: a=Na+P–P / 4, b=Na+P+P / 4, where Na is the subscript of the new feature point saved in S33.
[0038] On the other hand, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the program implements the above method when executed by a processor.
[0039] By adopting the above technical solution, when it is necessary to decode the magnetic stripe card, it is first necessary to perform the feature point extraction operation. First, the peak threshold and trough data are calculated through historical data, and the card is swiped or not is detected according to the peak data and trough data. When the card is swiped, the feature points are extracted, and the bit period is continuously updated in real time during the extraction process, reducing the impact of the unstable magnetic signal period on the feature point collection, and can collect feature points more stably and reduce the collection of interference data points, which is beneficial to the accuracy of subsequent decoding. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, among which:
[0041] Figure 1 The figure is a flow chart of a method for extracting feature points of a magnetic card based on an AMR sensor. DETAILED DESCRIPTION
[0042] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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 those skilled in the art without creative work are within the scope of protection of the present invention.
[0043] Reference Figure 1 The embodiment of the present invention provides a method for extracting characteristic points of a magnetic card based on an AMR sensor, comprising the following steps:
[0044] S1: Calculate the peak threshold and the trough threshold based on the historical data of the AMR sensor.
[0045] Specifically, the average value of the second preset number of historical data collected by the AMR sensor is obtained as the normal value NorVal, and the peak threshold Pv and the trough threshold Vv satisfy: Pv=NorVal+Thr, Vv=NorVal-Thr, where Thr is the set parameter threshold.
[0046] In the present invention, the second preset number is preferably 1000 groups.
[0047] As mentioned above, Thr is set by those skilled in the art according to actual needs. When the value is greater than Pv or less than Vv, a card swiping operation may have occurred.
[0048] S2: Detect data points in real time, and determine whether there is a card swiping operation based on the data points, peak threshold and trough threshold. If a card swiping operation is detected, initialize the variables and enter the feature point extraction stage. Otherwise, loop the card swiping detection.
[0049] Specifically, judging whether there is a card swiping operation currently according to the data point, the peak threshold and the trough threshold includes:
[0050] Detect each data collected by the sensor in a loop in sequence. If it is detected that a continuous number of data points greater than a third preset number is greater than a peak threshold, or a continuous number of data points greater than a third preset number is less than a trough threshold, then mark the subscript starting from the first data point among the continuous data points that meet the above conditions;
[0051] The extreme value points are obtained from the data points that meet the conditions. If four maximum value points and minimum value points are detected alternately in the data points within the fourth preset number, and the four extreme value points meet the preset conditions, it is determined that a card swiping operation is currently occurring.
[0052] As mentioned above, the specific values of the third preset number and the fourth preset number are set by those skilled in the art and will not be described in detail here.
[0053] As mentioned above, if there are continuously more than the third preset number of data points that are greater than the peak threshold or less than the trough threshold, it indicates that a card swiping operation has occurred at this time, and the data is marked at this time for subsequent processing.
[0054] The pre-conditions include:
[0055] Set the subscripts of the four extreme points to N1, N2, N3, and N4, and the distances between each two adjacent extreme points to P1, P2, and P3, where P1 = N2-N1, P2 = N3-N2, and P3 = N4-N3;
[0056] If P1 > P2 × 1.5 or P1 < P2 × 0.5 or P2 > P3 × 1.5 or P2 < P3 × 0.5, the preset condition is not satisfied.
[0057] The initialization variables include:
[0058] Initialize the bit period P, P = (P1 + P2 + P3) / 3;
[0059] Initialize the occurrence interval [a, b] of the next extreme point predicted according to the bit period: The prediction interval ranges from the sampled data with subscript a to the sampled data with subscript b, where a = N4 + P – P / 4, b = N4 + P + P / 4;
[0060] Initialize the number of data points continuously between the peak threshold and the trough threshold to 0.
[0061] S3: When it is detected that there is a current card swiping operation, enter the feature point extraction stage, continuously detect data points, obtain the bit period P according to the maximum and minimum values in the data points, predict the occurrence interval of the next extreme point according to the bit period, and detect the extreme point within the interval, update the bit period P according to the extreme point, and loop to execute this step. Take all the detected data points within the feature extraction stage as feature points; When it is detected that the card swiping operation ends or the number of feature points reaches the first preset number, end the feature point extraction and perform the feature point decoding operation.
[0062] Specifically, it includes:
[0063] S31: Count the number of data points continuously between the peak threshold and the trough threshold. If the number is greater than the fourth preset number, it is determined that the card swiping operation ends;
[0064] S32: Count the number of data points continuously between the peak threshold and the trough threshold. If the number is less than the fourth preset number, determine whether the number of data points between the peak threshold and the trough threshold is greater than the preset multiple of the current bit period P;
[0065] If the number of data points between the peak threshold and the trough threshold is greater than the preset multiple of the current bit period P, it is determined that the waveform is abnormal. At this time, if the number of extracted feature points is less than the fifth preset number, re - execute step S2. If the number of extracted feature points is greater than the fifth preset number, end the feature point extraction;
[0066] S33: If the number of data points between the peak threshold and the trough threshold is less than the preset multiple of the current bit period P, determine whether a new feature point is collected within the current interval [a, b];
[0067] If so, determine whether the polarity of the new feature point is the same as that of the previous feature point;
[0068] If they are not the same, save the new feature points and re-execute S31;
[0069] If they are the same, the new feature points are not saved and S31 is executed again;
[0070] S33: If no new feature point is collected in the current interval [a, b], and the subscript of the new feature point is b+1, determine whether the polarity of the new feature point is the same as that of the previous feature point;
[0071] If they are not the same, save the new feature points;
[0072] If they are the same, the new feature points are not saved and S31 is executed again;
[0073] S34: if the number of feature points reaches a first preset number, the feature point extraction is terminated and decoding is performed;
[0074] If the number of feature points does not reach the first preset number, the period P and the interval [a, b] are updated, and S31 is executed again.
[0075] As mentioned above, the preset multiple is preferably four times, the fifth preset number is preferably 30, and the first preset number is set by those skilled in the art.
[0076] When the number of data points between the peak threshold and the trough threshold is greater than four times the current bit period P, it is considered that the magnetic card waveform is abnormal. At this time, if the extracted feature points are less than 30, the data collected at this time is judged to be the leading data, and the abnormal waveform is part of the leading data. If the number of feature points extracted at this time is greater than 30, the feature point extraction is terminated directly.
[0077] The update of the period P and the interval [a,b] includes:
[0078] Obtain the period Pn between the new feature point and the previous feature point saved in S33;
[0079] Assign the original P2 to P1, the original P3 to P2, and Pn to P3;
[0080] P satisfies P=(P1+P2+P3) / 3;
[0081] The interval [a, b] satisfies: a=Na+P–P / 4, b=Na+P+P / 4, where Na is the subscript of the new feature point saved in S33.
[0082] The present embodiment provides a method for extracting feature points of a magnetic card based on an AMR sensor. When it is necessary to decode a magnetic stripe card, it is first necessary to perform a feature point extraction operation. First, the peak threshold and the trough data are calculated through historical data, and whether the card is swiped or not is detected according to the peak data and the trough data. After the card is swiped, the feature points are extracted, and the bit period is continuously updated in real time during the extraction process, so as to reduce the influence of the unstable magnetic signal period on the feature point acquisition, so that the feature points can be acquired more stably and the acquisition of interference data points can be reduced, which is beneficial to the accuracy of subsequent decoding.
[0083] An embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, wherein the program implements the above method when executed by a processor.
[0084] Those skilled in the art will appreciate that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as those generally understood by those skilled in the art in the art to which the present invention belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined.
[0085] For the method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0086] It can be known from the description of the above implementation modes that those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be essentially or partly contributed to the prior art in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server or a network device, etc.) to execute the methods described in the various implementation modes of the present application or certain parts of the implementation modes.
[0087] 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 replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for extracting characteristic points of a magnetic card based on an AMR sensor, characterized in that: Including: S1: Calculate the peak threshold and valley threshold based on the historical data of the AMR sensor; S2: Detect data points in real time, and determine whether there is a card - swiping operation currently according to the data points, peak threshold and valley threshold. If a card - swiping operation is detected, initialize variables and enter the feature point extraction stage; otherwise, loop for card - swiping detection; The determination of whether there is a card - swiping operation currently according to the data points, peak threshold and valley threshold includes: Loop through each data collected by the sensor in sequence. If it is detected that a continuous number of data points greater than a third preset number are greater than the peak threshold, or a continuous number of data points greater than a third preset number are less than the valley threshold, then mark the subscript starting from the first data point among the above - mentioned continuous data points that meet the conditions; Obtain the extreme points from the above - mentioned data points that meet the conditions. If four maximum points and four minimum points are alternately detected among the data points within a fourth preset number, and the four extreme points meet the preset conditions, then it is determined that there is a card - swiping operation currently; The preset conditions include: Set the subscripts of the four extreme points as N1, N2, N3, N4 respectively, and the distances between every two adjacent extreme points are P1, P2, P3 respectively, where P1 = N2 - N1, P2 = N3 - N2, P3 = N4 - N3; If P1 > P2×1.5 or P1 < P2×0.5 or P2 > P3×1.5 or P2 < P3×0.5, then the preset conditions are not met; The initialization of variables includes: Initialize the bit period P, P=(P1 + P2 + P3) / 3; Initialize the appearance interval [a, b] of the next extreme point predicted according to the bit period: The prediction interval ranges from the sampled data with subscript a to the sampled data with subscript b, where a = N4+P–P / 4, b = N4+P+P / 4; Initialize the number of data points continuously between the peak threshold and the valley threshold to 0; S3: When it is detected that there is a card - swiping operation currently, enter the feature point extraction stage, continuously detect data points, obtain the bit period P according to the maximum and minimum values in the data points, predict the appearance interval of the next extreme point according to the bit period, and detect the extreme point within the interval, update the bit period P according to the extreme point, loop to execute this step, and take all the detected data points within the feature extraction stage as feature points; when it is detected that the card - swiping operation ends or the number of feature points reaches a first preset number, end the feature point extraction and perform feature point decoding operation; Among them, S3 includes: S31: Count the number of data points continuously between the peak threshold and the valley threshold. If the number is greater than a fourth preset number, then it is judged that the card - swiping operation ends; S32: Count the number of data points continuously between the peak threshold and the valley threshold. If the number is less than a fourth preset number, then judge whether the number of data points between the peak threshold and the valley threshold is greater than a preset multiple of the current bit period P; S33: If the number of data points between the peak threshold and the trough threshold is greater than the preset multiple of the current bit period P, it is determined that the waveform is abnormal. At this time, if the number of feature points extracted is less than the fifth preset number, step S2 is re-executed. If the number of feature points extracted is greater than the fifth preset number, feature point extraction is terminated. If the number of data points between the peak threshold and the trough threshold is less than the preset multiple of the current bit period P, it is determined whether new feature points are collected in the current interval [a, b]; If so, determine whether the polarity of the new feature point is the same as that of the previous feature point; If they are not the same, save the new feature points and re-execute S31; If they are the same, the new feature points are not saved and S31 is executed again; If no new feature point is collected in the current interval [a, b], and the new feature point is subscripted as b+1, then determine whether the polarity of the new feature point is the same as that of the previous feature point; If they are not the same, save the new feature points; If they are the same, the new feature points are not saved and S31 is executed again; S34: if the number of feature points reaches a first preset number, the feature point extraction is terminated and decoding is performed; If the number of feature points does not reach the first preset number, the period P and the interval [a, b] are updated, and S31 is executed again.
2. The method according to claim 1, characterized in that The calculation to obtain the peak threshold and the trough threshold comprises: The average value of the second preset number of historical data collected by the AMR sensor is obtained as the normal value NorVal, and the peak threshold Pv and the trough threshold Vv satisfy: Pv=NorVal+Thr, Vv=NorVal-Thr, wherein Thr is the set parameter threshold.
3. The method according to claim 1, characterized in that The updating of the period P and the interval [a, b] comprises: Obtain the period Pn between the new feature point and the previous feature point saved in S33; Assign the original P2 to P1, the original P3 to P2, and Pn to P3; P satisfies P=(P1+P2+P3) / 3; The interval [a, b] satisfies: a=Na+P–P / 4, b=Na+P+P / 4, where Na is the subscript of the new feature point saved in S33.
4. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method described in any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Anti-theft card swiping method and system
CN110910586A
Blood pressure measurement apparatus
EP0203004A2