A method and system for detecting printing marks of a thermal printer
By using reflective or through-beam photoelectric sensors in thermal printers for filtering and clustering analysis, combined with fast Fourier transform, the problems of high printing mark detection cost, high design difficulty and low accuracy in the existing technology are solved. Enables simple, accurate mark detection for a variety of paper types.
Patent Information
- Application Number
- CN202210056405.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-18
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2042-01-18
AI Technical Summary
The printing mark detection technology of existing thermal printers is expensive, difficult to design, and has low detection accuracy. In particular, reflective infrared sensors are easily affected by external factors, resulting in high missed recognition and misrecognition rates.
Use reflective or through-beam photoelectric sensors to detect printed marks, drive the paper motor to feed paper for a fixed length, obtain the signal voltage value for filtering processing and cluster analysis, learn the mark threshold, and use fast Fourier transform to evaluate clustering As a result, the mark position is judged, which is suitable for simultaneous detection of gap and black mark marks.
It realizes mark detection with simple structure design and low cost. It has a wide range of applications, avoids the problem of misjudgment of pre-printed color content in traditional methods, improves detection accuracy, is suitable for embedded platforms with weak computing power, and can be used in embedded platforms with weak computing power. Thresholds are updated during printing to resist temperature and light interference.
Smart Images

Figure CN114327311B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the technical field of thermal printers, and in particular to a method and system for detecting a print mark of a thermal printer. Background Art
[0002] Thermal printers are widely used in various industries. Among them, the thermal printing paper used in most scenarios with high requirements on the size and position of printed documents is marked printing paper, such as common pre-printed black mark paper, intermittent label paper, etc. During the printing process of the printer, it is necessary to determine the printing starting point according to the mark position, so as to align the printed content with the preset position, or to ensure the uniform length of each print. In order to identify the black mark or gap mark on the printing paper, a reflective infrared sensor or a through-beam infrared sensor is usually used to detect the reflectivity of the paper surface and the transmittance of the paper respectively. The characteristics of low reflectivity and non-marked areas at the black mark and high transmittance and non-marked areas at the gap are used to identify the mark position, thereby locating the printed content. However, on the one hand, the through-beam photodiode requires a sensor to be placed on each side of the paper at the print head for transmitting and receiving infrared signals respectively, which has high requirements on the structural design of the printer and requires extremely long wires to be set inside to avoid the influence of the opening and closing cover on the sensor; on the other hand, it cannot detect black mark marks, and its scope of application is severely limited. Although the reflective infrared sensor has a simple structure and can detect black marks and gap marks, it is very susceptible to external temperature, light, sensor batch differences, paper materials and other factors during actual use due to the low difference in the degree of reflection at the gap and non-gap. There is a large rate of missed recognition and false recognition. When detecting black mark paper, it is also easy to judge ordinary pre-printed color content as a mark, which seriously affects the user experience. Therefore, the existing technology usually designs a photodiode and a reflective photodiode at the printer movement, which are used to detect black mark marks and gap marks respectively, which is costly and difficult to design. Summary of the invention
[0003] To this end, an embodiment of the present invention provides a method and system for detecting a print mark of a thermal printer to solve the problems of high cost, great design difficulty and low detection accuracy in the existing print mark detection.
[0004] In order to achieve the above purpose, the embodiment of the present invention provides the following technical solutions:
[0005] According to a first aspect of an embodiment of the present invention, a printing mark detection method of a thermal printer is provided, the method comprising:
[0006] The paper feeding motor is driven to feed the paper for a fixed length, and the print mark on the printing paper is detected by using a reflective or through-beam photoelectric sensor, and the signal voltage value collected by the reflective or through-beam photoelectric sensor during the paper feeding process is obtained as a sampling value, and sampling data of multiple sampling points are obtained according to a preset paper feeding interval;
[0007] The sampled data is filtered to remove high-frequency noise, the filtered sampled data is clustered, and the clustering results are evaluated, and the learned marking threshold is obtained after the evaluation is qualified;
[0008] The printing paper to be detected is driven to feed and sampled, the obtained sampling data is filtered, and the sampling value of the current paper feeding position is compared with the learned mark threshold to determine whether the current paper feeding position is the printing mark position.
[0009] Furthermore, the method further comprises:
[0010] The real-time sampling data of the printing paper to be detected is recorded, and re-learning is performed based on the sampling data to obtain an updated marking threshold.
[0011] Furthermore, the paper feeding motor is driven to feed the paper for a fixed length, and the signal voltage value collected by the reflective or through-beam photoelectric sensor during the paper feeding process is obtained as a sampling value, and sampling data of multiple sampling points are obtained according to a preset paper feeding interval, specifically including:
[0012] The fixed paper feeding length must be greater than twice the maximum single label length supported by the thermal printer.
[0013] Further, filtering the sampled data to remove high-frequency noise specifically includes:
[0014] The sliding average filter method is used to filter the sampled data to remove its high-frequency noise, and the maximum and minimum values of the samples are recorded at the same time.
[0015] Furthermore, the filtered sampled data is clustered and analyzed, and the clustering results are evaluated. After the evaluation is qualified, the learned marking threshold is obtained, which specifically includes:
[0016] K-Means clustering method is used for clustering. The initial categories are set to 2 categories, and the initial class centers are set to the maximum and minimum values of the samples respectively.
[0017] The two categories obtained by clustering are defined as the marked area and the unmarked area according to the size of their class centers, and the number of discontinuous marks is the number of current sample marks M obtained by clustering;
[0018] The sample data from the first marked peak to the last marked peak is intercepted, and the length is padded to a fixed-length sample using linear interpolation. The fixed-length sample is converted into the frequency domain using the fast Fourier transform method, and the spectrum leakage degree of the converted data at a frequency of M is calculated. The clustering result is judged whether it is qualified according to the spectrum leakage degree. If it is qualified, the marking threshold is calculated. If it is unqualified, a classification number is added. The initial class center is the bisection point between the maximum and minimum values. The classification-evaluation steps are repeated until the evaluation is qualified to obtain the marking threshold that best suits the current sample. The marking threshold is the average of the maximum and second maximum values of the cluster center.
[0019] Furthermore, the printed mark includes a gap mark and a black mark.
[0020] According to a second aspect of an embodiment of the present invention, a printing mark detection system for a thermal printer is provided, the system comprising:
[0021] The paper learning module is used to drive the paper feeding motor to feed the paper for a fixed length, use a reflective or through-beam photoelectric sensor to detect the print mark on the printing paper, obtain the signal voltage value collected by the reflective or through-beam photoelectric sensor during the paper feeding process as a sampling value, and obtain sampling data of multiple sampling points according to a preset paper feeding interval;
[0022] The sampled data is filtered to remove high-frequency noise, the filtered sampled data is clustered, and the clustering results are evaluated, and the learned marking threshold is obtained after the evaluation is qualified;
[0023] The paper detection module is used to drive the printing paper to be detected to feed and sample, filter the obtained sampling data, compare the sampling value of the current paper feeding position with the learned mark threshold, and determine whether the current paper feeding position is the printing mark position.
[0024] The embodiments of the present invention have the following advantages:
[0025] 1. Use reflective or through-beam photoelectric sensors for mark detection, which has a simple structure design and low cost. It can process black mark and gap mark at the same time and has a wide range of applications.
[0026] 2. Using clustering method to learn the marking threshold effectively avoids the problem of being unable to accurately identify pre-printed color content and black mark content caused by the traditional median judgment threshold based on the maximum and minimum sampling values, and can adapt to paper with large sampling differences and signal characteristics;
[0027] 3. Using the fast Fourier transform method and the fixed spacing of printing paper marks, we can obtain the sample frequency domain information to evaluate the clustering results, which effectively avoids the situation where the K-Means clustering method is sensitive to the number of initial classifications and the centroid of the class, resulting in the inability to obtain the most suitable threshold value in one classification;
[0028] 4. During the printing process, the printing paper sampling information is recorded, and the paper learning function is called multiple times to update the most suitable threshold value. On the one hand, it avoids the problem that the threshold learning is inaccurate due to the large differences in different positions of certain specific papers, and the small number of samples learned by paper cannot represent the complete paper; on the other hand, it avoids the problem that the sampling baseline drift caused by low-frequency noise interference such as temperature and light during use causes the threshold value to no longer be suitable for the current paper;
[0029] 5. Work with complex calculations and long computing time is non-real-time work. In the real-time monitoring process, only the marking threshold is used to judge whether the current state is at the marked position. The conditions are simple and very suitable for use on embedded platforms with weak computing power.
[0030] 6. Compared with the discrete Fourier transform, the use of fast Fourier transform greatly improves the calculation speed without losing accuracy. The accuracy of the clustering results is evaluated by utilizing the characteristic that the discrete Fourier transform will have spectrum leakage in the case of non-integer period truncation, avoiding the problem of difficulty in obtaining integer period truncation samples when using Fourier transform alone to obtain the threshold. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the implementation methods of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for the implementation methods or the description of the prior art. Obviously, the drawings in the following description are only exemplary, and for ordinary technicians in this field, other implementation drawings can be derived from the provided drawings without creative work.
[0032] Figure 1 A schematic flow chart of a method for detecting a print mark of a thermal printer provided in Embodiment 1 of the present invention;
[0033] Figure 2 It is the original sampling result of the reflective photoelectric sensor on a thermal self-adhesive printing paper with a gap mark;
[0034] Figure 3 It is the original sampling result of the reflective photoelectric sensor on a thermal paper with black mark and color pre-printed content;
[0035] Figure 4 Based on Figure 2 The sampling data is used to obtain the marker positioning result using the method of Example 1 of the present invention;
[0036] Figure 5 Based on Figure 3 The sampling data is used to obtain the marker positioning result using the method of Example 1 of the present invention. DETAILED DESCRIPTION
[0037] The following is a description of the implementation of the present invention by specific embodiments. People familiar with the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0038] Example 1
[0039] As shown in the figure, this embodiment proposes a printing mark detection method for a thermal printer, which mainly includes a paper learning step and a paper detection step, which are as follows:
[0040] S100, drive the paper feeding motor to feed the paper for a fixed length, use a reflective or through-beam photoelectric sensor to detect the print mark on the printing paper, obtain the signal voltage value collected by the reflective or through-beam photoelectric sensor during the paper feeding process as a sampling value, and obtain sampling data of multiple sampling points according to a preset paper feeding interval.
[0041] Printing marks include gap marks and black mark marks. Reflective infrared sensors or through-beam infrared sensors are used to detect the reflectivity and transmittance of the paper surface, respectively. The black mark has low reflectivity and is not a mark, and the gap has high transmittance and is not a mark, so the mark position can be identified to locate the printed content.
[0042] In this embodiment, the fixed paper feeding length needs to be greater than twice the maximum single label length supported by the thermal printer.
[0043] Specifically, a paper feeding motor is used to drive the printing paper to feed, and the paper is fed 0.125 mm at a time during this process. An ADC is used to collect the voltage of the signal output of the reflective photodiode to obtain the current sampling value.
[0044] According to the maximum single label length L supported by the printer Max (mm) specifies the fixed paper feed length L (mm) during paper learning, where the maximum single label length supported by the printer is L Max (mm) is usually determined by the printer buffer size; the fixed paper feed length L must be greater than 2 times the maximum single label length L supported by the printer Max ,Right now:
[0045] L>2×L Max
[0046] Drive the printer to feed paper L (mm), and record the sampling value during this process. In order to reduce the amount of calculation, the sampling can be reduced at a frequency of recording once every 0.5mm step.
[0047] S200, filtering the sampled data to remove high-frequency noise, clustering the filtered sampled data, and evaluating the clustering results. After the evaluation is qualified, the learned marking threshold is obtained.
[0048] In this embodiment, the sliding average filtering method is used to filter the sampled data to remove its high-frequency noise, and the maximum and minimum values of the samples are recorded at the same time.
[0049] Specifically, the recorded samples are filtered by multi-order sliding average, and the formula is:
[0050]
[0051] Among them, Y refers to the sampling value sequence before filtering, and X refers to the sampling value sequence after filtering;
[0052] Y(k+i) refers to the k+ith sample value before filtering;
[0053] X(k) refers to the kth sample value after filtering;
[0054] N refers to the filter window width, which depends on the cutoff frequency and sampling frequency of the sliding average filter. The calculation formula is as follows:
[0055] N=0.443×f s / f co
[0056] where f s is the sampling frequency, f co is the cutoff frequency. In this example, a sampling point is recorded every 0.5 mm. Usually, the mark width is greater than 2 mm, so N can be set to 2 or 3 to achieve the best filtering effect.
[0057] In this embodiment, the K-Means clustering method is used for clustering, the initial categories are set to 2 categories, and the initial class centers are set to the maximum value and the minimum value of the samples respectively;
[0058] The two categories obtained by clustering are defined as the marked area and the unmarked area according to the size of their class centers, and the number of discontinuous marks is the number of current sample marks M obtained by clustering;
[0059] The sample data from the first marked peak to the last marked peak is intercepted, and the length is padded to 512 or 1024-bit fixed-length samples using linear interpolation. The fixed-length samples are converted into frequency domain using the fast Fourier transform method, and the spectrum leakage degree of the converted data at frequency M is calculated. The clustering result is judged whether it is qualified according to the spectrum leakage degree. If it is qualified, the marking threshold is calculated. If it is unqualified, a classification number is added. The initial class center is the bisection point between the maximum and minimum values. The classification-evaluation steps are repeated until the evaluation is qualified to obtain the marking threshold that best suits the current sample. The marking threshold is the average of the maximum and second maximum values of the cluster center.
[0060] The specific process is as follows:
[0061] Perform K-Means clustering on the sampled data after filtering, cluster the n objects into the specified m clusters according to the distance between the objects, and each object belongs to and only belongs to one cluster with the smallest distance to the cluster center, where the number of clusters m is initially set to 2, namely the labeled class and the unlabeled class, and initialize m cluster centers {C1, C2}, where C1 is set to the maximum value of the sample sequence after filtering and C2 is set to the minimum value of the sample sequence after filtering in order to speed up clustering speed and accuracy, and then calculate the Euclidean distance from each object to each cluster center. Since the sampling value of this example is one-dimensional data, the Euclidean distance can be simplified to the absolute value of the difference between the sampling value and the cluster center, as shown in the following formula:
[0062] dis(Y i ,C j )=|X j -C j |
[0063] Compare each sample value to each example of the class center in turn, and assign it to the cluster of the cluster center closest to the example, and obtain m clusters {S1, S2};
[0064] Calculate the mean of the samples in the m clusters as the new cluster center {C'1, C'2}, if for all cluster centers, it satisfies:
[0065] C′ i =C i
[0066] Then the clustering ends;
[0067] If clustering is not completed, C i Update to C' i , calculate the Euclidean distance from each object to each cluster center again, and perform a new round of classification and cluster center update operations;
[0068] If clustering is over, mark the threshold X Tis the average of the maximum and second maximum values of the cluster center;
[0069] According to the clustering results, the cluster with the largest cluster center can be regarded as the printing paper mark. The sample data between the peak of the first mark and the peak of the last mark are intercepted in the sampling order, and the number of marks M of this segment of data is calculated. Then, the linear interpolation algorithm is used to unify the sample length to 512. The calculation formula is as follows:
[0070]
[0071] in, Refers to no more than The largest integer of ;
[0072] Where Z(k) refers to the kth sample value after linear interpolation calculation;
[0073] Where X(k) refers to the kth sample value after sliding average filtering;
[0074] The sequence Z obtained by linear interpolation is subjected to fast Fourier transform to obtain the frequency domain sequence F. Since the fast Fourier transform uses the symmetry of the discrete Fourier transform to reduce the amount of calculation, the calculation results of the two are exactly the same. Therefore, for ease of understanding, the formula here is the formula of the discrete Fourier transform, and its calculation formula is as follows:
[0075]
[0076] According to the frequency domain sequence F obtained by Fourier transform, the spectrum leakage degree at F(M) and F(2M) is calculated, and the degree of spectrum leakage is measured by parameter G. The calculation formula is as follows:
[0077]
[0078] If G is less than 1, it is considered that the spectrum leakage is low, the clustering result can better reflect the characteristics of the paper, and the current clustering result is considered qualified; if G is greater than 1, it is considered that there is obvious spectrum leakage, or the number of markers obtained by clustering does not match the actual number of markers, and the current clustering result is considered unqualified;
[0079] If the clustering result is judged to be unqualified, the current number of clusters m needs to be increased to 3, and the initial class center {C1, C2} is increased to {C1, C2, C3}, where C1 and C2 are still the maximum and minimum sample values, and C3 is the bisection point of C1 and C2. If the 3 categories still do not meet the qualified standards, it is necessary to increase to 4 categories again, and the initial class center is increased to {C1, C2, C3, C4}, where C3 and C4 are the trisection points of C1 and C2. If the 4 categories still cannot meet the qualified standards, it can be determined that the printer status is abnormal and the sampling data cannot distinguish between marks and noise.
[0080] S300, driving the printing paper to be detected to feed and sampling, filtering the obtained sampling data, comparing the sampling value of the current paper feeding position with the learned mark threshold, and judging whether the current paper feeding position is the printing mark position.
[0081] Furthermore, the method further includes: recording real-time sampling data of the printing paper to be detected, and re-learning based on the sampling data to obtain an updated marking threshold.
[0082] The marking threshold obtained during the paper learning phase is used to determine whether the current sensor position is at the marking position. The judgment result is received by the printer main program and used for paper positioning. At the same time, the current sampling value is recorded. After recording to a sufficient length, when the printer is idle without a printing task, the recorded sample data is sent to the paper learning function for analysis again, and the most suitable threshold is updated to avoid sampling baseline drift caused by light, temperature, etc.
[0083] During normal operation, the reflective or through-beam photoelectric sensor sampling value Y is read once every 0.125mm step. R , perform sliding average filtering. Since the sampling frequency at this time is 4 times higher than the sampling frequency during paper learning, the sliding average filter parameter N can be 6-8 to obtain the best filtering effect;
[0084] The filtered current position sampling value X R With the current marking threshold X T By comparison, it can be determined whether it is at the threshold of the mark, and the determination result is sent to the printer main process for business process positioning processing.
[0085] During normal printing, the sample value is saved every 0.5mm step. After being saved to a certain length, the threshold is updated again using the aforementioned paper learning function. The saved length still needs to be greater than 2 times the maximum single label length L supported by the printer. Max Here, the frequency of repeated learning can be reduced according to the actual usage environment to reduce the amount of printer calculation.
[0086] Figure 2 The original sampling results of the reflective photoelectric sensor on a thermal self-adhesive printing paper with a gap mark are provided. Figure 3 Provides the original sampling results of the reflective photoelectric sensor on a black mark thermal paper with color pre-printed content, based on Figure 2 and Figure 3 The data is filtered and learned using this method to obtain the labeling result as follows Figure 4 , Figure 5As shown, it can be seen that the method can better adapt to the differences in sampling baseline, amplitude, and waveform caused by different papers on reflective or through-beam photoelectric sensors, and set a suitable marking threshold.
[0087] Example 2
[0088] Corresponding to the above-mentioned embodiment 1, this embodiment proposes a printing mark detection system for a thermal printer, the system comprising:
[0089] The paper learning module is used to drive the paper feeding motor to feed the paper for a fixed length, use a reflective or through-beam photoelectric sensor to detect the print mark on the printing paper, obtain the signal voltage value collected by the reflective or through-beam photoelectric sensor during the paper feeding process as a sampling value, and obtain sampling data of multiple sampling points according to a preset paper feeding interval;
[0090] The sampled data is filtered to remove high-frequency noise, the filtered sampled data is clustered, and the clustering results are evaluated, and the learned marking threshold is obtained after the evaluation is qualified;
[0091] The paper detection module is used to drive the printing paper to be detected to feed and sample, filter the obtained sampling data, compare the sampling value of the current paper feeding position with the learned mark threshold, and determine whether the current paper feeding position is the printing mark position.
[0092] The functions performed by the various components in the print mark detection system of a thermal printer provided by the embodiment of the present invention have been described in detail in the above embodiment 1, so no further details will be given here.
[0093] Although the present invention has been described in detail above by general description and specific embodiments, it is obvious to those skilled in the art that some modifications or improvements can be made to the present invention. Therefore, these modifications or improvements made without departing from the spirit of the present invention all belong to the scope of protection claimed by the present invention.
Claims
1. A method for detecting a printed mark of a thermal printer, characterized in that: The method comprises: The paper feeding motor is driven to feed the paper for a fixed length, and the print mark on the printing paper is detected by using a reflective or through-beam photoelectric sensor, and the signal voltage value collected by the reflective or through-beam photoelectric sensor during the paper feeding process is obtained as a sampling value, and sampling data of multiple sampling points are obtained according to a preset paper feeding interval; The sampled data is filtered to remove high-frequency noise, the filtered sampled data is clustered, and the clustering results are evaluated, and the learned marking threshold is obtained after the evaluation is qualified; Drive the printing paper to be detected to feed and sample, filter the obtained sampled data, compare the sampled value of the current paper feeding position with the learned mark threshold, and determine whether the current paper feeding position is the printing mark position; The filtered sampled data is clustered and analyzed, and the clustering results are evaluated. After the evaluation is qualified, the learned marking threshold is obtained, which specifically includes: K-Means clustering method is used for clustering. The initial categories are set to 2 categories, and the initial class centers are set to the maximum and minimum values of the samples respectively. The two categories obtained by clustering are defined as the marked area and the unmarked area according to the size of their class centers, and the number of discontinuous marks is the number of current sample marks M obtained by clustering; The sample data from the first marked peak to the last marked peak is intercepted, and the length is padded to a fixed-length sample using linear interpolation. The fixed-length sample is converted into the frequency domain using the fast Fourier transform method, and the spectrum leakage degree of the converted data at a frequency of M is calculated. The clustering result is judged whether it is qualified according to the spectrum leakage degree. If it is qualified, the marking threshold is calculated. If it is unqualified, a classification number is added. The initial class center is the bisection point between the maximum and minimum values. The classification-evaluation steps are repeated until the evaluation is qualified to obtain the marking threshold that best suits the current sample. The marking threshold is the average of the maximum and second maximum values of the cluster center.
2. A method for detecting printed marks of a thermal printer according to claim 1, characterized in that: The method further comprises: The real-time sampling data of the printing paper to be detected is recorded, and re-learning is performed based on the sampling data to obtain an updated marking threshold.
3. The method for detecting printed marks of a thermal printer according to claim 1, characterized in that: Drive the paper feeding motor to feed the paper for a fixed length, obtain the signal voltage value collected by the reflective or through-beam photoelectric sensor during the paper feeding process as the sampling value, and obtain the sampling data of multiple sampling points according to the preset paper feeding interval, specifically including: The fixed paper feeding length must be greater than twice the maximum single label length supported by the thermal printer.
4. The method for detecting printed marks of a thermal printer according to claim 1, characterized in that: The sampling data is filtered to remove high-frequency noise, specifically including: The sliding average filter method is used to filter the sampled data to remove its high-frequency noise, and the maximum and minimum values of the samples are recorded at the same time.
5. The method for detecting printed marks of a thermal printer according to claim 1, characterized in that: The printing marks include gap marks and black mark marks.
6. A printing mark detection system for a thermal printer, characterized in that: The system comprises: The paper learning module is used to drive the paper feeding motor to feed the paper for a fixed length, use a reflective or through-beam photoelectric sensor to detect the print mark on the printing paper, obtain the signal voltage value collected by the reflective or through-beam photoelectric sensor during the paper feeding process as a sampling value, and obtain sampling data of multiple sampling points according to a preset paper feeding interval; The sampled data is filtered to remove high-frequency noise, the filtered sampled data is clustered, and the clustering results are evaluated, and the learned marking threshold is obtained after the evaluation is qualified; The paper detection module is used to drive the printing paper to be detected to feed and sample, filter the obtained sampling data, compare the sampling value of the current paper feeding position with the learned mark threshold, and determine whether the current paper feeding position is the printing mark position; The filtered sampled data is clustered and analyzed, and the clustering results are evaluated. After the evaluation is qualified, the learned marking threshold is obtained, which specifically includes: K-Means clustering method is used for clustering. The initial categories are set to 2 categories, and the initial class centers are set to the maximum and minimum values of the samples respectively. The two categories obtained by clustering are defined as the marked area and the unmarked area according to the size of their class centers, and the number of discontinuous marks is the number of current sample marks M obtained by clustering; The sample data from the first marked peak to the last marked peak is intercepted, and the length is padded to a fixed-length sample using linear interpolation. The fixed-length sample is converted into the frequency domain using the fast Fourier transform method, and the spectrum leakage degree of the converted data at a frequency of M is calculated. The clustering result is judged whether it is qualified according to the spectrum leakage degree. If it is qualified, the marking threshold is calculated. If it is unqualified, a classification number is added. The initial class center is the bisection point between the maximum and minimum values. The classification-evaluation steps are repeated until the evaluation is qualified to obtain the marking threshold that best suits the current sample. The marking threshold is the average of the maximum and second maximum values of the cluster center.
