Die-cut label photoelectric threshold automatic calibration method, system, medium and electronic device
By analyzing the changing trend of photoelectric values in die-cutting label printers, the photoelectric threshold is automatically calibrated, solving the problem of poor adaptability caused by manual adjustment, and improving the accuracy of label edge recognition and the storage efficiency of die-cutting label printers.
Patent Information
- Application Number
- CN202610178625.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-09
- Publication Date
- 2026-05-15
- Estimated Expiration
- 2046-02-09
AI Technical Summary
In existing die-cut label printers, the determination of the photoelectric threshold relies on manual adjustment, resulting in poor adaptability and affecting the accuracy of label edge recognition.
By acquiring the photoelectric value during the continuous movement of the stepper motor in the die-cut label printer, the photoelectric value change trend is analyzed using first-order and second-order derivative data, the photoelectric threshold is automatically calibrated, and the threshold is optimized by combining the background paper color weight and historical records.
It improves the compatibility between photoelectric threshold and label, ensures the accuracy of label edge recognition, and reduces the storage pressure on die-cut label printers.
Smart Images

Figure CN121677561B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of die-cut label technology, specifically to an automatic calibration method, system, medium, and electronic device for photoelectric threshold of die-cut labels. Background Technology
[0002] Die-cut labels are self-adhesive labels with customized irregular shapes, processed using a die-cutting process. Unlike traditional square / rectangular standard labels, they can be directly peeled off and pasted from the backing paper, and are widely used in product identification, traceability management, and classification marking. The photoelectric threshold of a die-cut label is essentially the critical photoelectric value at which the photoelectric sensor in the die-cut label printer determines whether the label edge has been detected. Identifying the label edge is a core prerequisite for accurate label printing and die-cutting; it essentially sets a uniform "reference starting point" for the processing of each label, avoiding content offset and cutting misalignment. Therefore, determining the photoelectric threshold of a die-cut label is of great importance. A die-cut label printer is a specialized device that integrates label printing and die-cutting functions, completing both label content printing and irregular shape cutting in one step, eliminating the need for subsequent manual cutting or separate die-cutting processes. It is widely used in scenarios requiring customized irregular-shaped labels.
[0003] Currently, the common method for determining the photoelectric threshold of die-cut labels is to manually adjust the threshold according to the different labels to be printed, setting a photoelectric threshold in the photoelectric sensor of the die-cut label printer that matches the label. However, this manual adjustment method is highly dependent on the experience of the personnel, resulting in poor compatibility between the determined photoelectric threshold and the label. Summary of the Invention
[0004] To improve the compatibility between photoelectric threshold and label, this application provides an automatic calibration method, system, medium, and electronic device for photoelectric threshold of die-cut labels.
[0005] The first aspect of this application provides an automatic calibration method for photoelectric threshold of die-cut labels, specifically including:
[0006] Obtain N actual photoelectric values, wherein the actual photoelectric values are the photoelectric values collected at each step during the continuous N-step movement of the stepper motor in the die-cutting label printer, where N represents the even number of steps the stepper motor continuously moves, and the actual photoelectric values are the photoelectric values collected by the photoelectric sensor in the die-cutting label printer for the label to be printed.
[0007] According to the collection order from front to back, the actual photoelectric values are sorted and added to a preset first array. Based on the first array, the first derivative data is determined. The first derivative data is the data reflecting the rate of change of each actual photoelectric value.
[0008] The first array is updated to obtain the target array, and the target array is determined as the first array. The step of determining the first derivative data based on the first array is repeated until N first derivative data are obtained. The target array contains N photoelectric values.
[0009] Based on the first derivative data, the second derivative data corresponding to the photoelectric value collected by the photoelectric sensor is determined. The second derivative data is data that reflects the changing trend of the rate of change of the photoelectric value.
[0010] Based on the first-order derivative data and the second-order derivative data, the target photoelectric threshold corresponding to the label to be printed is determined.
[0011] By adopting the above technical solution, after obtaining N actual photoelectric values, these N values are stored in a first array. Then, based on the changing trends of each actual photoelectric value in the first array, the first derivative data reflecting the rate of change of each actual photoelectric value is determined. As the stepper motor continues to move, the photoelectric values in the first array are updated, ensuring that only N photoelectric values are always stored in the first array. This avoids storing every collected photoelectric value, thus reducing the storage pressure on the MCU in the die-cutting label printer. Furthermore, based on the updated photoelectric values in the first array, the first derivative data is determined again, and this operation is repeated multiple times. The first array is updated multiple times, and new first derivative data is determined based on the updated first array multiple times, until N first derivative data are obtained. Next, based on multiple first-order derivative data, the corresponding second-order derivative data is determined, thereby determining the trend of the rate of change of photoelectric value collected by the photoelectric sensor during the stepper motor's movement. Furthermore, by combining the first-order and second-order derivative data, it is analyzed whether the photoelectric value is in a state of fastest change and the trend of change is about to reverse, so as to more accurately determine whether the label edge has reached the photoelectric position. Then, by combining the photoelectric value collected when the label edge reaches the photoelectric position, the target photoelectric threshold that is more suitable for the label to be printed is accurately determined, thereby improving the compatibility between the target photoelectric threshold and the label to be printed.
[0012] In one implementation, determining the first derivative data based on the first array specifically includes:
[0013] Summing the first N / 2 actual photoelectric values in the first array yields the first summation result;
[0014] Summing the last N / 2 actual photoelectric values in the first array yields a second summation result.
[0015] Subtracting the first sum from the second sum gives the first derivative data.
[0016] In one implementation, updating the first array to obtain the target array specifically includes:
[0017] After the stepper motor moves one more step, the photoelectric sensor acquires the corresponding target photoelectric value.
[0018] The target photoelectric value is added to the first array, and the first actual photoelectric value in the first array is removed to obtain the target array.
[0019] In one embodiment, determining the second derivative data corresponding to the photoelectric value collected by the photoelectric sensor based on each of the first derivative data specifically includes:
[0020] Each of the first derivative data is added to a preset second array, and the earlier the first derivative data is determined, the earlier its position is in the second array;
[0021] In order from front to back, subtract the previous first-order derivative data from each first-order derivative data in the second array to obtain the second-order derivative data corresponding to the photoelectric value collected by the photoelectric sensor.
[0022] In one implementation, determining the target photoelectric threshold corresponding to the label to be printed based on the first-order derivative data and the second-order derivative data specifically includes:
[0023] Select the largest first derivative data from each of the first derivative data. When the largest first derivative data is positive, sort the second derivative data to obtain a sorted set. The earlier the second derivative data is determined, the earlier its position is in the sorted set.
[0024] Select target second derivative data from the sorted set, wherein the preceding second derivative data of the target second derivative data is negative, and the target second derivative data is non-negative;
[0025] Determine whether the number of stepper motor steps corresponding to the maximum first derivative data is consistent with the number of stepper motor steps corresponding to the target second derivative data;
[0026] If they match, the target photoelectric threshold corresponding to the label to be printed is determined based on the number of steps of the stepper motor.
[0027] In one implementation, at least one accent color is determined based on multiple different historical colors of the backing paper when deviation occurs at the label edge.
[0028] Based on the background paper color being the key color and label edge recognition deviation occurring, at least one key threshold range corresponding to the key color is determined using multiple historical photoelectric thresholds.
[0029] Determine the color weight of the key color, and determine the range weight of each key threshold range;
[0030] Obtain the actual color of the base paper in the label to be printed, and verify the target photoelectric threshold based on the actual color, the color weight, and the range weight.
[0031] In one implementation, verifying the target photoelectric threshold based on the actual color, the color weight, and the range weight specifically includes:
[0032] When the actual color is the key color, determine whether the target photoelectric threshold exists in the key threshold range corresponding to the actual color;
[0033] If it exists, the key threshold range where the target photoelectric threshold exists is determined as the reference threshold range, and the weight product of the color weight of the actual color and the range weight of the corresponding reference threshold range is calculated.
[0034] If the weighted product is not greater than a preset product threshold, the target photoelectric threshold verification is determined to be passed; if the weighted product is greater than the preset product threshold, the target photoelectric threshold verification is determined to be failed.
[0035] A second aspect of this application provides an automatic photoelectric threshold calibration system for die-cut labels, specifically comprising:
[0036] The information acquisition module is used to acquire N actual photoelectric values. The actual photoelectric values are the photoelectric values collected at each step during the continuous N-step movement of the stepper motor in the die-cutting label printer. N represents the even number of steps the stepper motor moves continuously. The actual photoelectric values are the photoelectric values collected by the photoelectric sensor in the die-cutting label printer for the label to be printed.
[0037] The first processing module is used to sort the actual photoelectric values according to the acquisition order from front to back and add them to a preset first array. Based on the first array, the first derivative data is determined, and the first derivative data is data reflecting the rate of change of each actual photoelectric value.
[0038] The second processing module is used to update the first array to obtain a target array, and to determine the target array as the first array. The step of determining the first derivative data based on the first array is repeated until N first derivative data are obtained. The target array contains N photoelectric values.
[0039] The third processing module is used to determine the second derivative data corresponding to the photoelectric value collected by the photoelectric sensor based on the first derivative data. The second derivative data is data that reflects the changing trend of the rate of change of the photoelectric value.
[0040] The threshold determination module is used to determine the target photoelectric threshold corresponding to the label to be printed based on the first-order derivative data and the second-order derivative data.
[0041] By adopting the above technical solution, after the information acquisition module obtains N actual photoelectric values, the first processing module determines the first derivative data based on the first array. Then, the second processing module updates the first array to obtain the target array and determines the target array as the first array. The step of determining the first derivative data based on the first array is repeated. Next, the third processing module determines the second derivative data corresponding to the photoelectric values collected by the photoelectric sensor based on each first derivative data. Finally, the threshold determination module is used to determine the target photoelectric threshold corresponding to the label to be printed based on the first derivative data and the second derivative data.
[0042] A third aspect of this application provides a computer-readable storage medium storing a computer program that, when loaded and executed by a processor, performs the steps of the method described in any one of the first aspects.
[0043] A fourth aspect of this application provides an electronic device, specifically comprising:
[0044] A processor, a memory, and a computer program stored in the memory and capable of running on the processor, the processor being configured to load and execute the computer program stored in the memory to cause the electronic device to perform the method as described in any one of the first aspects.
[0045] In summary, this application includes at least one of the following beneficial technical effects: Based on the changing trend of each actual photoelectric value in the first array, first-order derivative data reflecting the rate of change of each actual photoelectric value is determined. Then, as the stepper motor continues to move, the photoelectric values in the first array are updated, ensuring that only N photoelectric values are always stored in the first array, avoiding the need to store every collected photoelectric value and increasing the storage pressure on the MCU in the die-cutting label printer. Furthermore, based on the updated photoelectric values in the first array, the first-order derivative data is determined again, and this operation is repeated multiple times, updating the first array and determining new first-order derivative data multiple times based on the updated first array, until N first-order derivative data are obtained. Next, based on multiple first-order derivative data, the corresponding second-order derivative data is determined, thereby determining the trend of the rate of change of photoelectric value collected by the photoelectric sensor during the stepper motor's movement. Furthermore, by combining the first-order and second-order derivative data, it is analyzed whether the photoelectric value is in a state of fastest change and the trend of change is about to reverse, so as to more accurately determine whether the label edge has reached the photoelectric position. Then, by combining the photoelectric value collected when the label edge reaches the photoelectric position, the target photoelectric threshold that is more suitable for the label to be printed is accurately determined, thereby improving the compatibility between the target photoelectric threshold and the label to be printed. Attached Figure Description
[0046] Figure 1 This is a flowchart illustrating an automatic calibration method for photoelectric threshold of die-cut labels provided in an embodiment of this application;
[0047] Figure 2 This is a schematic diagram illustrating the relationship between a key color and a key threshold range, provided in an embodiment of this application.
[0048] Figure 3 This is a schematic diagram of the structure of an automatic photoelectric threshold calibration system for die-cut labels provided in an embodiment of this application;
[0049] Figure 4 This is a schematic diagram of another automatic photoelectric threshold calibration system for die-cut labels provided in an embodiment of this application.
[0050] Explanation of reference numerals in the attached figures: 11. Information acquisition module; 12. First processing module; 13. Second processing module; 14. Third processing module; 15. Threshold determination module; 16. Threshold verification module. Detailed Implementation
[0051] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.
[0052] In the description of the embodiments of this application, words such as "exemplarily," "for example," or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplarily," "for example," or "for instance" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of words such as "exemplarily," "for example," or "for instance" is intended to present the relevant concepts in a specific manner.
[0053] In the description of the embodiments of this application, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, B existing alone, or A and B existing simultaneously. Furthermore, unless otherwise stated, the term "multiple" means two or more. For example, multiple systems refer to two or more systems, and multiple screen terminals refer to two or more screen terminals. In addition, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the indicated technical features. Thus, a feature defined with "first" or "second" may explicitly or implicitly include one or more of that feature. The terms "comprising," "including," "having," and their variations all mean "including but not limited to," unless otherwise specifically emphasized.
[0054] See Figure 1 This application discloses a flowchart illustrating an automatic photoelectric threshold calibration method for die-cut labels. This method can be implemented using a computer program or run on an automatic photoelectric threshold calibration system for die-cut labels based on the von Neumann architecture. The computer program can be integrated into an application or run as a standalone utility application, specifically including:
[0055] S101: Obtain N actual photoelectric values. The actual photoelectric values are the photoelectric values collected at each step during the continuous N-step movement of the stepper motor in the die-cut label printer.
[0056] Specifically, the actual photoelectric value is the photoelectric value collected by the photoelectric sensor in the die-cutting label printer for the label to be printed. A die-cutting label printer is a specialized device that integrates label content printing and irregular contour die-cutting functions. It can complete label information printing and customized shape cutting in one go, eliminating the need for subsequent manual cutting or separate die-cutting processes. The finished labels can be directly peeled off and used. Its core workflow is as follows: The label paper (composed of a face paper, adhesive layer, and backing paper) is placed in the paper. Then, the photoelectric sensor identifies the positioning marks (black mark gaps) on the label paper, and a stepper motor (which drives the paper feed roller to transport the label paper) achieves precise label positioning. Finally, thermal or thermal transfer technology is used to print text, barcodes, QR codes, and other information onto the face paper. In this embodiment, the die-cutting label printer can be used as an express delivery waybill printer, a commodity barcode label printer, or a logistics label printer, etc. A stepper motor is an open-loop control motor that converts electrical pulse signals into angular or linear displacement. Simply put, unlike a regular motor that rotates continuously, it rotates by a fixed angle (called the step angle) with each input electrical pulse. It features precise positioning and fast start / stop response, and is widely used in scenarios requiring precise displacement control (such as paper feeding positioning in die-cut label printers). The face paper refers to the surface functional paper of the self-adhesive label; it is the "information carrier" of the label and the part that is ultimately pasted onto the target object. The backing paper refers to the bottom supporting paper of the self-adhesive label, also called release paper / backing paper, and is the temporary carrier of the label. The label to be printed can be understood as the label paper that needs to be positioned and printed.
[0057] Furthermore, a photoelectric sensor is a non-contact detection element installed on the paper feed path of the printer. Its core function is to identify positioning marks (black marks, gaps, indentations) on the label paper, determine whether the label edge has reached the preset position, and provide accurate signals for the stepper motor to start / stop and for triggering printing / die-cutting actions. The photoelectric value is the quantized output signal value of the photoelectric sensor, representing the light intensity detected by the receiver. In the embodiments of this application, the photoelectric sensor can be an analog photoelectric sensor; in other embodiments, the photoelectric sensor can also be a digital photoelectric sensor.
[0058] The traditional method for label edge positioning involves a photoelectric sensor collecting a photoelectric value for each step the stepper motor takes. The collected photoelectric value is then compared with a preset photoelectric threshold. If the photoelectric value exceeds the threshold, the label edge is identified. This method requires manual adjustment of the photoelectric threshold to adapt to different labels and improve label edge recognition. This method is affected by subjective factors and experience, which can lead to misidentification of label edges.
[0059] Furthermore, during the label edge positioning process using the stepper motor and photoelectric sensor, a preset encoder monitors the stepper motor's movement in real time. Each time the stepper motor takes one step, the photoelectric sensor collects a photoelectric value from the label to be printed, obtaining the actual photoelectric value. This process continues until the stepper motor takes N consecutive steps, at which point the photoelectric sensor collects N actual photoelectric values. It should be noted that N represents the even number of consecutive steps taken by the stepper motor. For example, N can be 8, meaning that if the stepper motor takes 8 consecutive steps, the photoelectric sensor collects 8 corresponding actual photoelectric values, each corresponding to one step taken by the stepper motor. The 8th photoelectric value collected corresponds to the 8th step taken by the stepper motor. In other embodiments, N can also be 4 or 6.
[0060] S102: Sort the actual photoelectric values according to the acquisition order from front to back and add them to the preset first array. Based on the first array, determine the first derivative data, which is the data reflecting the rate of change of each actual photoelectric value.
[0061] Specifically, after acquiring N actual photoelectric values, they are sorted according to the acquisition order from front to back. The earlier the acquisition order, the higher the corresponding photoelectric value is in the sorted order. The sorted N actual photoelectric values are then added to a preset first array for storage. Then, based on this first array, the first derivative data, i.e., the rate of change of each actual photoelectric value, is determined. One feasible method for determining this is as follows:
[0062] The first N / 2 actual photoelectric values in the first array are summed to obtain the first summation result. Then, the last N / 2 actual photoelectric values in the first array are summed to obtain the second summation result. Finally, the first summation result is subtracted from the second summation result to obtain a single first derivative data, which reflects the rate of change of the photoelectric value collected in real time by the photoelectric sensor. It should be noted that since there may be acquisition errors during the real-time acquisition of photoelectric values by the photoelectric sensor, this application subtracts the summation result of the first N / 2 actual photoelectric values from the summation result of the last N / 2 actual photoelectric values to determine the rate of change of the photoelectric value. This can offset some acquisition errors, especially showing a significant suppression effect on systematic or random errors caused by random noise, ambient light fluctuations, etc. The core principle is to use the symmetry and randomness of the error to cancel it out, so that the determined first derivative data can more accurately reflect the rate of change of the photoelectric value.
[0063] S103: Update the first array to obtain the target array, and determine the target array as the first array. Repeat the step of determining the first derivative data based on the first array until N first derivative data are obtained. The target array contains N photoelectric values.
[0064] Specifically, after the first-order derivative data is determined, as the stepper motor continues to move downwards, the first array is updated (keeping the number of elements in the first array unchanged) to obtain the target array. One feasible implementation is as follows: after detecting that the stepper motor has moved down one more step, the target photoelectric value of the label to be printed is collected again in real time by the photoelectric sensor, and then this target photoelectric value is added to the first array. The target photoelectric value is ranked last in the first array, while the actual photoelectric value ranked first in the first array is removed, resulting in the target array. Further, this target array is redefined as the first array, and the step of determining the first-order derivative data based on the first array in step S102 is repeated. That is, the sum of the last N / 2 elements in the redefined first array is subtracted from the sum of the first N / 2 elements to obtain another first-order derivative data, and so on, until N first-order derivative data are obtained. The target array also contains N photoelectric values. It should be noted that as the stepper motor moves downwards and continuously collects photoelectric values, the first array is also constantly updated while maintaining the same number of N elements, thereby reducing the amount of photoelectric value storage and reducing the storage pressure on the MCU.
[0065] S104: Based on the first derivative data, determine the second derivative data corresponding to the photoelectric value collected by the photoelectric sensor. The second derivative data is the data that reflects the changing trend of the rate of change of the photoelectric value.
[0066] Specifically, after determining N first-order derivative data points, all first-order derivative data points are added to the second array for storage. Simultaneously, the order in which each first-order derivative data point is determined within the second array is also determined; the earlier the first-order derivative data is determined, the earlier its position in the second array. Further, following a forward-to-backward order, each first-order derivative data point in the second array is subtracted from the previous one to obtain the second-order derivative data corresponding to the photoelectric value collected by the photoelectric sensor, thus reflecting the trend of the rate of change of the photoelectric value.
[0067] S105: Determine the target photoelectric threshold corresponding to the label to be printed based on the first-order derivative data and the second-order derivative data.
[0068] Specifically, the largest first-order derivative data is selected from all first-order derivative data. This largest first-order derivative data represents the largest rate of change in photoelectric value. If the largest first-order derivative data is positive, it indicates the largest increase in photoelectric value. Then, the second-order derivative data are sorted to obtain a sorted set. The earlier the second-order derivative data is determined, the earlier its position in the sorted set. Next, the target second-order derivative data is selected from the sorted set. If the preceding second-order derivative data of the target second-order derivative data is negative, and the target second-order derivative data is non-negative, it indicates that the rate of change in photoelectric value corresponding to this target second-order derivative data remains constant or is "decelerating." Further, it is determined whether the stepper motor step number corresponding to the largest first-order derivative data is consistent with the stepper motor step number corresponding to the target second-order derivative data. If they are consistent, it means that at this stepper motor step number, the label edge has likely reached the photoelectric position. Therefore, when the current stepper motor step number is this step number, the photoelectric value that is the first in the sorted array is directly determined as the target photoelectric threshold. It should be noted that, since there is an interval of N / 2 steps when calculating the first derivative data based on the first array, and there is also an interval of N / 2 steps when calculating the second derivative data, it means that the current step number of the stepper motor is the actual number of steps N steps behind the edge of the tag reaching the photoelectric position. Therefore, the photoelectric value that is sorted first in the first array is determined as the target photoelectric threshold, rather than the photoelectric value that is sorted last in the first array.
[0069] If they are inconsistent, the stepper motor is controlled to continue moving downwards, and photoelectric values are collected in real time to update the first array. Based on the updated first array, the first-order derivative data and the second-order derivative data are determined, and the maximum first-order derivative data and the target second-order derivative data are re-determined until the number of steps of the stepper motor corresponding to the maximum first-order derivative data is consistent with the number of steps of the stepper motor corresponding to the target second-order derivative data.
[0070] In other embodiments, based on the cached historical records of label edge recognition, different historical colors of the backing paper are obtained from the historical records. These historical records include, but are not limited to, the historical colors of different backing papers when recognition deviations occurred, and information such as the historical photoelectric thresholds used. The frequency of occurrence of a single historical color among all historical colors is counted. If the frequency exceeds a preset frequency threshold, it indicates that the historical color appears frequently in historical label recognition, and this historical color is identified as a key color—that is, a historical color that is likely to induce label edge recognition deviations. At least one key color is present.
[0071] Furthermore, based on the aforementioned historical records, when the background paper color is a single key color and label edge recognition deviation occurs, multiple historical photoelectric thresholds are used. A preset clustering algorithm is used to perform cluster analysis on all historical photoelectric thresholds, dividing them into multiple photoelectric threshold ranges covering all historical photoelectric thresholds. The clustering algorithm can be K-Means or hierarchical clustering; the clustering analysis process is existing technology and will not be elaborated here. Next, the number of historical photoelectric thresholds contained within each photoelectric threshold range is counted. If the number exceeds a preset threshold, then that photoelectric threshold range is determined as the key threshold range corresponding to that key color, i.e., the photoelectric threshold range where label edge recognition deviation is likely to occur. At least one key threshold range exists.
[0072] Furthermore, the color weight corresponding to each key color is determined. The color weight is the ratio of the frequency of occurrence of a single key color to the sum of the frequencies of occurrence of all key colors, representing the likelihood that the key color will induce label edge recognition deviation. Then, the range weight of each key threshold range corresponding to the key color is determined. The range weight is the ratio of the number of key threshold ranges corresponding to a single key threshold range to the sum of the number of key threshold ranges corresponding to all key threshold ranges, representing the likelihood that when the background paper color in the label is the key color, the photoelectric threshold used is within the corresponding key threshold range, causing label edge recognition deviation. For example, there are key colors e, f, and g. The frequency of occurrence of key color e is 25 times, the frequency of occurrence of key color f is 35 times, and the frequency of occurrence of key color g is 40 times. Then, the color weight of key color e is: 25 times / (25 times + 35 times + 40 times) = 0.25. Furthermore, the key color 'e' corresponds to key threshold ranges e1, e2, and e3; the key color 'f' corresponds to key threshold ranges f1 and f2, etc.; and the key color 'g' corresponds to key threshold ranges g1 and g2, etc. The number of key threshold ranges e1 is 40, e2 is 30, and e3 is 30. Therefore, the range weight of key threshold range e1 is: 40 / (40 + 30 + 30) = 0.4. See details in [link to documentation]. Figure 2 .
[0073] Further, the actual color of the backing paper in the label to be printed is obtained. Specifically, this can be achieved using a preset OpenCV tool to identify the actual color of the backing paper in the label to be printed. Then, when the actual color is a key color, it is determined whether a target photoelectric threshold exists within the key threshold range corresponding to the actual color. If it does, this key threshold range is determined as the reference threshold range. The weighted product of the color weight of the actual color and the range weight of the corresponding reference threshold range is calculated. The weighted product represents the probability of recognition deviation when the label edge recognition is performed using the target photoelectric threshold. The weighted product is compared with a preset product threshold. If the weighted product is not greater than the product threshold, it indicates that the probability of recognition deviation is relatively small when using the target photoelectric threshold for label edge recognition, thus verifying that the target photoelectric threshold is reasonable. At the same time, the first product of the color weight of the actual color and the range weight of each corresponding first threshold range is calculated and summed to obtain a first comprehensive result. The first threshold range is a key threshold range where the minimum value of the range is greater than the target photoelectric threshold. The first comprehensive result represents the overall probability of recognition deviation when the photoelectric threshold used is greater than the target photoelectric threshold. Furthermore, the second product of the color weight of the actual color and the range weight of each corresponding second threshold range is calculated and summed to obtain the second comprehensive result. The second threshold range is the key threshold range where the maximum value of the range is less than the target photoelectric threshold. The second comprehensive result characterizes the overall probability of identification deviation when the adopted photoelectric threshold is less than the target photoelectric threshold. If both the first and second comprehensive results are greater than the preset result threshold, it indicates that the probability of identification deviation is relatively high when the adopted photoelectric threshold is greater than the target photoelectric threshold, and the probability of identification deviation is also relatively high when the adopted photoelectric threshold is less than the target photoelectric threshold. This further verifies the rationality of the target photoelectric threshold.
[0074] Conversely, if the weighted product is greater than the product threshold, it indicates a higher probability of recognition deviation when using the target photoelectric threshold for tag edge recognition. Furthermore, if neither the first nor the second comprehensive result exceeds the result threshold, it further verifies that the target photoelectric threshold is likely biased and needs adjustment and optimization. Therefore, the target threshold range can be determined by selecting the key threshold range with the smallest range weight from the various key threshold ranges corresponding to the actual color. Based on this target threshold range, the target photoelectric threshold can be adjusted. One feasible implementation method is as follows:
[0075] The third comprehensive result is obtained by multiplying the color weight of the actual color with the range weights of the corresponding third threshold ranges and summing the results. The third threshold range is a key threshold range where all values within the range are greater than those within the target threshold range. The third comprehensive result represents the overall probability of identification deviation when the used photoelectric threshold is greater than the target threshold range. The fourth comprehensive result is obtained by multiplying the color weight of the actual color with the range weights of the corresponding fourth threshold ranges and summing the results. The fourth threshold range is a key threshold range where all values within the range are less than those within the target threshold range. The fourth comprehensive result represents the overall probability of identification deviation when the used photoelectric threshold is less than the target threshold range. If both the third and fourth comprehensive results are greater than the result threshold, then the target threshold range is considered reasonable. Conversely, if the fourth comprehensive result is less than the third comprehensive result, then the target photoelectric threshold is adjusted to the minimum value of the target threshold range.
[0076] The implementation principle of the automatic photoelectric threshold calibration method for die-cut labels in this application embodiment is as follows: Based on the changing trend of each actual photoelectric value in the first array, the first derivative data reflecting the rate of change of each actual photoelectric value is determined. Then, as the stepper motor continues to move, the photoelectric values in the first array are updated, ensuring that only N photoelectric values are always stored in the first array, avoiding the storage of each collected photoelectric value and increasing the storage pressure on the MCU in the die-cut label printer. Furthermore, based on the updated photoelectric values in the first array, the first derivative data is determined again, and this operation is repeated multiple times, updating the first array and determining new first derivative data based on the updated first array multiple times, until N first derivative data are obtained. Next, based on multiple first-order derivative data, the corresponding second-order derivative data is determined, thereby determining the trend of the rate of change of photoelectric value collected by the photoelectric sensor during the stepper motor's movement. Furthermore, by combining the first-order and second-order derivative data, it is analyzed whether the photoelectric value is in a state of fastest change and the trend of change is about to reverse, so as to more accurately determine whether the label edge has reached the photoelectric position. Then, by combining the photoelectric value collected when the label edge reaches the photoelectric position, the target photoelectric threshold that is more suitable for the label to be printed is accurately determined, thereby improving the compatibility between the target photoelectric threshold and the label to be printed.
[0077] The following are system embodiments of this application, which can be used to execute the method embodiments of this application. For details not disclosed in the system embodiments of this application, please refer to the method embodiments of this application.
[0078] Please see Figure 3This is a schematic diagram of the automatic photoelectric threshold calibration system for die-cut labels provided in this application embodiment. This automatic photoelectric threshold calibration system for die-cut labels can be implemented as all or part of a system through software, hardware, or a combination of both. The system includes an information acquisition module 11, a first processing module 12, a second processing module 13, a third processing module 14, and a threshold determination module 15.
[0079] The information acquisition module 11 is used to acquire N actual photoelectric values. The actual photoelectric values are the photoelectric values collected at each step during the continuous N-step movement of the stepper motor in the die-cutting label printer. N represents the even number of steps the stepper motor moves continuously. The actual photoelectric values are the photoelectric values collected by the photoelectric sensor in the die-cutting label printer for the label to be printed.
[0080] The first processing module 12 is used to sort the actual photoelectric values according to the acquisition order from front to back and add them to a preset first array. Based on the first array, the first derivative data is determined. The first derivative data is the data that reflects the rate of change of each actual photoelectric value.
[0081] The second processing module 13 is used to update the first array to obtain the target array, and to determine the target array as the first array. The step of determining the first derivative data based on the first array is repeated until N first derivative data are obtained. The target array contains N photoelectric values.
[0082] The third processing module 14 is used to determine the second derivative data corresponding to the photoelectric value collected by the photoelectric sensor based on the first derivative data. The second derivative data is the data that reflects the changing trend of the rate of change of the photoelectric value.
[0083] The threshold determination module 15 is used to determine the target photoelectric threshold corresponding to the label to be printed based on the first-order derivative data and the second-order derivative data.
[0084] Optionally, the first processing module 12 is specifically used for:
[0085] Summing the first N / 2 actual photoelectric values in the first array yields the first summation result;
[0086] Summing the last N / 2 actual photoelectric values in the first array yields the second summation result;
[0087] Subtracting the first sum from the second sum gives the first derivative data.
[0088] Optionally, the second processing module 13 is specifically used for:
[0089] After the stepper motor moves one more step, the corresponding target photoelectric value is obtained by the photoelectric sensor;
[0090] Add the target photoelectric value to the first array, and remove the first-ranked actual photoelectric value from the first array to obtain the target array.
[0091] Optionally, the third processing module 14 is specifically used for:
[0092] Each first derivative data is added to a preset second array. The earlier the first derivative data is determined, the earlier its position in the second array.
[0093] By subtracting the previous first-order derivative data from each first-order derivative data in the second array in the order from front to back, we obtain the second-order derivative data corresponding to the photoelectric value collected by the photoelectric sensor.
[0094] Optionally, the threshold determination module 15 is specifically used for:
[0095] Select the largest first derivative from all the first derivative data. When the largest first derivative data is positive, sort all the second derivative data to obtain a sorted set. The earlier the second derivative data is determined, the earlier its position is in the sorted set.
[0096] Select the target second derivative data from the sorted set. The first second derivative data of the target second derivative data is negative, and the target second derivative data is non-negative.
[0097] Determine whether the number of stepper motor steps corresponding to the maximum first derivative data is consistent with the number of stepper motor steps corresponding to the target second derivative data;
[0098] If they match, the target photoelectric threshold corresponding to the label to be printed is determined based on the number of steps of the stepper motor.
[0099] Optional, such as Figure 4 As shown, the system also includes a threshold verification module 16, which is specifically used for:
[0100] Based on the identification of multiple different historical colors of the backing paper when deviation occurs at the label edge, at least one key color is determined;
[0101] Based on the background paper color being the key color and label edge recognition deviation occurring, multiple historical photoelectric thresholds are used to determine at least one key threshold range corresponding to the key color.
[0102] Determine the color weight of the key colors and the range weight of each key threshold range;
[0103] Obtain the actual color of the backing paper in the label to be printed, and verify the target photoelectric threshold based on the actual color, color weight, and range weight.
[0104] Optional, threshold verification module 16, specifically used for:
[0105] When the actual color is the key color, determine whether there is a target photoelectric threshold within the key threshold range corresponding to the actual color;
[0106] If it exists, the key threshold range where the target photoelectric threshold exists is determined as the reference threshold range, and the weight product of the color weight of the actual color and the range weight of the corresponding reference threshold range is calculated.
[0107] If the weighted product is not greater than the preset product threshold, the target photoelectric threshold verification is determined to be passed; if the weighted product is greater than the preset product threshold, the target photoelectric threshold verification is determined to be failed.
[0108] It should be noted that the above-described automatic photoelectric threshold calibration system for die-cut labels, when executing the automatic photoelectric threshold calibration method for die-cut labels, is only illustrated by the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. Furthermore, the above-described automatic photoelectric threshold calibration system for die-cut labels and the embodiment of the automatic photoelectric threshold calibration method for die-cut labels belong to the same concept, and their implementation process is detailed in the method embodiment, which will not be repeated here.
[0109] This application also discloses a computer-readable storage medium, which stores a computer program, wherein when the computer program is executed by a processor, it implements an automatic calibration method for photoelectric threshold of die-cut labels as described in the above embodiments.
[0110] The computer program can be stored in a computer-readable medium. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or certain middleware. The computer-readable medium includes any entity or device capable of carrying computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the computer-readable medium includes, but is not limited to, the above-mentioned components.
[0111] The above-described method for automatic calibration of photoelectric threshold of die-cut labels is stored in the computer-readable storage medium and loaded and executed on the processor to facilitate the storage and application of the method.
[0112] This application also discloses an electronic device in which a computer program is stored in a computer-readable storage medium. When the computer program is loaded and executed by a processor, it implements the above-mentioned method for automatic calibration of photoelectric threshold of die-cut labels.
[0113] The electronic device can be a desktop computer, a laptop computer, or a cloud server, and includes, but is not limited to, a processor and a memory. For example, the electronic device may also include input / output devices, network access devices, and buses.
[0114] The processor can be a central processing unit (CPU). Of course, depending on the actual use, it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), off-the-shelf programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc., and this application does not limit it.
[0115] The memory can be an internal storage unit of an electronic device, such as a hard disk or RAM, or an external storage device, such as a plug-in hard disk, smart memory card (SMC), secure digital card (SD), or flash memory card (FC) equipped on the electronic device. Furthermore, the memory can be a combination of an internal storage unit and an external storage device. The memory is used to store computer programs and other programs and data required by the electronic device. The memory can also be used to temporarily store data that has been output or will be output. This application does not limit this.
[0116] In this electronic device, the photoelectric threshold automatic calibration method for die-cut labels described above is stored in the memory of the electronic device and loaded and executed on the processor of the electronic device for convenient use.
[0117] The foregoing description is merely an exemplary embodiment of this disclosure and should not be construed as limiting the scope of this disclosure. Any equivalent changes and modifications made in accordance with the teachings of this disclosure shall still fall within the scope of this disclosure. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not described in this disclosure. The specification and embodiments are considered exemplary only, and the scope and spirit of this disclosure are defined by the claims.
Claims
1. An automatic calibration method for photoelectric threshold of die-cut labels, characterized in that, The method includes: Obtain N actual photoelectric values, wherein the actual photoelectric values are the photoelectric values collected at each step during the continuous N-step movement of the stepper motor in the die-cutting label printer, where N represents the even number of steps the stepper motor continuously moves, and the actual photoelectric values are the photoelectric values collected by the photoelectric sensor in the die-cutting label printer for the label to be printed. According to the collection order from front to back, the actual photoelectric values are sorted and added to a preset first array. Based on the first array, the first derivative data is determined. The first derivative data is the data reflecting the rate of change of each actual photoelectric value. The first array is updated to obtain the target array, and the target array is determined as the first array. The step of determining the first derivative data based on the first array is repeated until N first derivative data are obtained. The target array contains N photoelectric values. Based on the first derivative data, the second derivative data corresponding to the photoelectric value collected by the photoelectric sensor is determined. The second derivative data is data that reflects the changing trend of the rate of change of the photoelectric value. Based on the first-order derivative data and the second-order derivative data, determine the target photoelectric threshold corresponding to the label to be printed; based on the multiple different historical colors of the backing paper when the label edge recognition deviates, determine at least one key color; Based on the background paper color being the key color and label edge recognition deviation occurring, at least one key threshold range corresponding to the key color is determined using multiple historical photoelectric thresholds. Determine the color weight of the key color, and determine the range weight of each key threshold range; Obtain the actual color of the base paper in the label to be printed, and verify the target photoelectric threshold based on the actual color, the color weight, and the range weight.
2. The automatic photoelectric threshold calibration method for die-cut labels according to claim 1, characterized in that, The step of determining the first derivative data based on the first array specifically includes: Sum the first N / 2 actual photoelectric values in the first array to obtain the first summation result; Summing the last N / 2 actual photoelectric values in the first array yields a second summation result. Subtracting the first sum from the second sum gives the first derivative data.
3. The automatic photoelectric threshold calibration method for die-cut labels according to claim 2, characterized in that, The step of updating the first array to obtain the target array specifically includes: After the stepper motor moves one more step, the photoelectric sensor acquires the corresponding target photoelectric value. The target photoelectric value is added to the first array, and the first actual photoelectric value in the first array is removed to obtain the target array.
4. The automatic photoelectric threshold calibration method for die-cut labels according to claim 1, characterized in that, The step of determining the second derivative data corresponding to the photoelectric value collected by the photoelectric sensor based on each of the first derivative data specifically includes: Each of the first derivative data is added to a preset second array, and the earlier the first derivative data is determined, the earlier its position is in the second array; In order from front to back, subtract the previous first-order derivative data from each first-order derivative data in the second array to obtain the second-order derivative data corresponding to the photoelectric value collected by the photoelectric sensor.
5. The automatic photoelectric threshold calibration method for die-cut labels according to claim 4, characterized in that, The step of determining the target photoelectric threshold corresponding to the label to be printed based on the first-order derivative data and the second-order derivative data specifically includes: Select the largest first derivative data from each of the first derivative data. When the largest first derivative data is positive, sort the second derivative data to obtain a sorted set. The earlier the second derivative data is determined, the earlier its position is in the sorted set. Select target second derivative data from the sorted set, wherein the preceding second derivative data of the target second derivative data is negative, and the target second derivative data is non-negative; Determine whether the number of stepper motor steps corresponding to the maximum first derivative data is consistent with the number of stepper motor steps corresponding to the target second derivative data; If they match, the target photoelectric threshold corresponding to the label to be printed is determined based on the number of steps of the stepper motor.
6. The automatic photoelectric threshold calibration method for die-cut labels according to claim 1, characterized in that, The step of verifying the target photoelectric threshold based on the actual color, the color weight, and the range weight specifically includes: When the actual color is the key color, determine whether the target photoelectric threshold exists in the key threshold range corresponding to the actual color; If it exists, the key threshold range where the target photoelectric threshold exists is determined as the reference threshold range, and the weight product of the color weight of the actual color and the range weight of the corresponding reference threshold range is calculated. If the weighted product is not greater than a preset product threshold, the target photoelectric threshold verification is determined to be passed; if the weighted product is greater than the preset product threshold, the target photoelectric threshold verification is determined to be failed.
7. An automatic photoelectric threshold calibration system for die-cut labels, used to implement the automatic photoelectric threshold calibration method for die-cut labels according to any one of claims 1 to 6, characterized in that, include: The information acquisition module (11) is used to acquire N actual photoelectric values. The actual photoelectric values are the photoelectric values collected at each step during the continuous N-step process of the stepper motor in the die-cut label printer. N represents the even number of steps that the stepper motor continuously moves. The actual photoelectric values are the photoelectric values collected by the photoelectric sensor in the die-cut label printer for the label to be printed. The first processing module (12) is used to sort the actual photoelectric values according to the acquisition order from front to back and add them to a preset first array. Based on the first array, the first derivative data is determined, and the first derivative data is data reflecting the rate of change of each actual photoelectric value. The second processing module (13) is used to update the first array to obtain a target array, and to determine the target array as the first array. The step of determining the first derivative data based on the first array is repeated until N first derivative data are obtained. The target array contains N photoelectric values. The third processing module (14) is used to determine the second derivative data corresponding to the photoelectric value collected by the photoelectric sensor based on the first derivative data. The second derivative data is data that reflects the changing trend of the photoelectric value change rate. The threshold determination module (15) is used to determine the target photoelectric threshold corresponding to the label to be printed based on the first-order derivative data and the second-order derivative data.
8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is loaded and executed by the processor, it implements the method of any one of claims 1-6.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, characterized in that, When the processor loads and executes the computer program, it implements the method of any one of claims 1-6.