Veterinary injection quality detection method and system
By using gated phase-locked loop and background template modeling technology, the problem of confusion between the inherent characteristics of the bottle and foreign object signals was solved, achieving high precision and efficient separation in the quality detection of veterinary drug injection solutions, reducing the false judgment and false detection rates, and improving the overall reliability of the detection system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- RUICHENG LVMAN BIOLOGICAL PHARM CO LTD
- Filing Date
- 2026-04-28
- Publication Date
- 2026-05-29
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing veterinary drug injection quality testing systems struggle to distinguish between periodic interference signals generated by the inherent characteristics of the vial and non-periodic transient signals generated by visible foreign objects during rotational testing. This leads to high rates of misjudgment and missed detection, impacting the accuracy and efficiency of the testing.
By employing gated phase-locked loop and background template modeling techniques, the transient state of foreign objects is identified through gated signals, the loop filter state is frozen, and signal processing is performed only during the stable interference period to establish a high-purity background template, eliminate periodic interference signals, and achieve accurate separation of foreign object signals.
It significantly reduces the false positive rate and false negative rate, improves the accuracy and reliability of the detection system, and ensures that the rotation cycle can be extracted stably and accurately and foreign objects can be detected even under mechanical vibration and strong foreign object interference.
Smart Images

Figure CN122109087A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of automated testing, and in particular to a method and system for quality testing of veterinary drug injection solutions. Background Technology
[0002] In the automated production process of veterinary drug injections, quality inspection is a crucial step in ensuring drug safety. Optical inspection systems are used to remove substandard products containing visible foreign matter, such as glass shards, fibers, and hair.
[0003] To improve the detection rate of foreign objects inside bottles, especially those settled at the bottom or attached to the bottle walls, the industry commonly uses rotary optical detection systems. This system uses a rotating device to make the bottle rotate at high speed at the detection station, utilizing centrifugal force to move the foreign objects in the liquid, thus allowing them to be captured by optical sensors. However, this rotary detection mechanism introduces a serious technical challenge: the inherent physical characteristics of the bottle itself, such as scratches, glass mold marks, label edges, and uneven glass thickness, can generate periodic optical interference signals during rotation. These interference signals, especially the transient pulse signals generated by sharp scratches, are highly similar in signal morphology and frequency domain to the non-periodic transient signals generated by randomly tumbling visible foreign objects, thus creating a synchronization confusion problem.
[0004] Existing signal processing methods, such as traditional Fourier transform-based frequency domain filters or waveform-based morphological analysis methods, struggle to effectively distinguish between these two morphologically similar but originating signals. This makes detection systems highly susceptible to misjudgment or missed detection, severely impacting the accuracy of veterinary drug injection quality testing and production line efficiency.
[0005] Therefore, how to adaptively and accurately separate the periodic interference signals generated by the inherent characteristics of the bottle from the non-periodic transient signals generated by visible foreign objects, and avoid confusion between the two, so as to significantly reduce the false judgment rate and false detection rate of the detection system, is a technical problem that urgently needs to be solved in this field. Summary of the Invention
[0006] To address the problem of accurately distinguishing between periodic interference signals generated by the inherent characteristics of the bottle and non-periodic transient signals generated by visible foreign objects, thereby achieving accurate quality testing of veterinary drug injection solutions, this invention provides a method and system for quality testing of veterinary drug injection solutions.
[0007] In a first aspect, the present invention provides a method for quality testing of veterinary drug injections, employing the following technical solution: A method for quality testing of veterinary drug injection solutions, comprising the following steps: Optical detection timing signals of a rotating veterinary drug injection bottle are acquired at a preset sampling frequency. The optical detection timing signals include periodic interference signals that are synchronized with the rotation of the bottle and asynchronous sparse transient signals generated by visible foreign objects. Transient detection is performed on the optical detection timing signal to identify the location where the asynchronous sparse transient signal appears, and a gating signal is generated. The gating signal is used to distinguish between the stationary interference period and the foreign object transient period in the optical detection timing signal. Based on the optical detection timing signal and the gating signal, the periodic interference signal is locked during the stable interference period through a gating phase-locked loop to extract the actual rotation period of the bottle. Based on the gating signal and the rotation period, the optical detection timing signal is cyclically averaged only during the stable interference period to establish a bottle background template characterizing the periodic interference signal. The bottle background template is subtracted from the optical detection timing signal to obtain the residual signal, and the presence of visible foreign objects is determined based on the residual signal.
[0008] This invention first identifies transient signals from foreign objects through a gating mechanism, and then shields these foreign object signals from interference when extracting the rotation reference and modeling the interference template, ensuring the stable locking of the phase-locked loop and the purity of the background template. Finally, it achieves precise separation of bottle interference and foreign object signals through cancellation, solving the problem of confusion between the two.
[0009] Preferably, transient detection is performed on the optical detection timing signal to generate a gating signal, including: Calculate the instantaneous energy of the optical detection timing signal; Calculate the dynamic baseline of the instantaneous energy; When the instantaneous energy is greater than the transient threshold set based on the dynamic baseline, it is determined to be the foreign object transient period; otherwise, it is determined to be the stable interference period, and the corresponding gating signal is generated.
[0010] This invention provides a simple, efficient, and adaptive transient detection method by comparing instantaneous energy and dynamic baseline, which can mark the location of foreign object pulses in real time.
[0011] Preferably, the instantaneous energy is calculated using a first moving average filter; the dynamic baseline is calculated using a second moving average filter; and the window size of the second moving average filter is larger than the window size of the first moving average filter.
[0012] Preferably, the method for extracting the rotation period includes: During the stable interference period, the loop filter of the gated phase-locked loop updates its state according to the phase error output by the phase detector in order to adjust the current estimated frequency of the numerically controlled oscillator in the gated phase-locked loop. During the foreign object transient period, the loop filter is frozen to keep the current estimated frequency of the numerically controlled oscillator unchanged, thereby preventing the asynchronous sparse transient signal from causing the gated phase-locked loop to lose lock. When the gated phase-locked loop is stably locked, the reciprocal of the current estimated frequency of the numerically controlled oscillator is obtained as the actual rotation period of the bottle.
[0013] This invention effectively prevents the impact of the huge phase error generated by the foreign object pulse on the phase-locked loop by freezing the state of the loop filter during the foreign object transient period, greatly enhancing the robustness of the phase-locked loop and enabling it to accurately extract the actual rotation period from the uncontaminated, stable interference signal.
[0014] Preferably, the loop filter is a proportional-integral controller; the freezing state during the foreign object transient period specifically includes: freezing the accumulated value of the integrator in the proportional-integral controller and setting the output of the proportional term to zero.
[0015] Preferably, a method for creating the bottle background template includes: Initialize a template array with a length equal to the rotation period; By iterating through the optical detection timing signals, when the gate signal indicates a stable interference period, the values of the corresponding phase positions in the template array are updated using a preset learning rate based on the synchronization phase at the current moment, so as to obtain the bottle background template.
[0016] This invention provides an iterative update method based on learning rate to build a background template. This method has low computational overhead, can update the template in real time, and is suitable for streaming data processing.
[0017] Preferably, another method for creating the bottle background template includes: Initialize an accumulation template array and a counting template array with a length equal to the rotation period; The optical detection timing signal is iterated over. When the gate signal indicates a stable interference period, the current signal value is accumulated to the corresponding phase position of the accumulation template array, and the corresponding phase position of the counting template array is incremented by one. After the traversal is complete, each element of the accumulated template array is divided by the corresponding element of the counting template array to obtain the bottle background template.
[0018] This invention provides an alternative batch processing template modeling method. Because it only accumulates and counts data during periods of stable interference, it avoids contamination of the template by foreign signals. The final template is a precise average of multiple periodic interference signals, resulting in high model accuracy.
[0019] Preferably, the method further includes: Calculate the waveform energy or peak value of the bottle background template; When the waveform energy or peak value is greater than the preset background threshold, it is determined to be a bottle defect or excessive background turbidity of the medicine liquid.
[0020] Preferably, before performing transient detection on the optical detection timing signal, the method further includes: The optical detection timing signal is subjected to high-pass or band-pass filtering to remove DC components, power frequency interference, or out-of-band noise.
[0021] Secondly, the present invention provides a quality testing system for veterinary drug injections, which adopts the following technical solution: A veterinary drug injection quality testing system includes a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the aforementioned veterinary drug injection quality testing method is implemented.
[0022] By adopting the above technical solution, a computer program for the quality testing method of veterinary drug injection is generated and stored in a memory so that it can be loaded and executed by a processor. A terminal device can then be made based on the memory and processor for convenient use.
[0023] The present invention has the following technical effects: This invention first identifies asynchronous foreign signals and generates a gating signal; this gating signal is then used as a shielding switch to ensure that the learning process of the adaptive algorithm is completely unaffected by foreign signals, thereby fundamentally solving the problem of confusion between periodic interference and asynchronous transient signals.
[0024] Furthermore, this invention utilizes a gating signal to freeze the state of the loop filter during the transient period of foreign matter. This mechanism effectively prevents the instantaneous impact of strong foreign matter pulses on the phase-locked loop, preventing loop lockout or divergence. Therefore, this method can stably and accurately extract the actual rotation period of the bottle from the contaminated signal even under harsh conditions of mechanical jitter and strong foreign matter signal interference, providing a high-precision benchmark for subsequent synchronization cancellation.
[0025] Furthermore, this invention employs gated cyclic averaging to ensure that the signal is accumulated and averaged only during periods of stable interference. This guarantees that asynchronous foreign object signals and random noise will not be incorrectly learned into the background template, thereby establishing a high-purity, high-fidelity background template that only characterizes the synchronous interference of the bottle.
[0026] Furthermore, by subtracting the established background template from the original signal, the resulting residual signal contains almost only pure foreign object signals and background noise. A simple threshold determination of this residual signal yields extremely high accuracy, significantly reducing the false positive and false negative rates caused by signal confusion in traditional methods, and greatly improving the overall reliability of the detection system. Attached Figure Description
[0027] Figure 1 This is a flowchart of a method for quality testing of veterinary drug injection provided in an embodiment of the present invention; Figure 2 This is an optical detection timing signal image provided in an embodiment of the present invention; Figure 3 The gate control signal image provided in the embodiment of the present invention; Figure 4 The residual signal image provided in the embodiment of the present invention. Detailed Implementation
[0028] This invention discloses a method for quality testing of veterinary drug injection solutions, referring to... Figure 1 This includes steps S1-S5: S1: Acquire optical detection timing signals of a rotating veterinary drug injection bottle at a preset sampling frequency. The optical detection timing signals include periodic interference signals synchronized with the bottle rotation and asynchronous sparse transient signals generated by visible foreign objects.
[0029] Specifically, firstly, a rotating device drives a veterinary drug injection bottle to be tested to rotate at high speed around a central axis, and an optical sensor is aligned with a specific detection area on the bottle. The optical sensor is then used at a preset high sampling frequency; an exemplary sampling frequency is... It continuously collects simulated signals of light intensity passing through or being reflected.
[0030] Next, the analog light intensity signal is sampled and quantized using an analog-to-digital converter to obtain a digitized optical detection timing signal.
[0031] The optical detection timing signal is subjected to high-pass or band-pass filtering to remove DC components, power frequency interference, or out-of-band noise. For ease of subsequent description, the filtered optical detection timing signal will still be referred to as the optical detection timing signal.
[0032] Figure 2The optical detection timing signal shows that there is a periodic signal in the signal, while there is also a non-periodic signal at 1.2 seconds.
[0033] It should be noted that the acquired optical detection timing signal is a mixed signal, containing periodic interference signals synchronized with rotation, asynchronous sparse transient signals asynchronous with rotation, and random noise signals. Therefore, in order to achieve accurate foreign object detection, the periodic interference signals need to be removed from the optical detection timing signal.
[0034] S2: Perform transient detection on the optical detection timing signal to identify the location where the asynchronous sparse transient signal appears, and generate a gating signal. The gating signal is used to distinguish between the stationary interference period and the foreign object transient period in the optical detection timing signal.
[0035] It should be noted that, in order to remove periodic interference signals, we consider fitting the periodic interference signal. Therefore, we only need to remove the fitted periodic interference signal from the optical detection timing signal to eliminate the interference from the periodic interference signal. To achieve accurate fitting of the periodic interference signal, asynchronous sparse transient signals must first be removed.
[0036] Preferably, as an example, transient detection is performed on the optical detection timing signal to identify the location where the asynchronous sparse transient signal occurs, and a gating signal is generated, including: First, using a window with a size of The first moving average filter calculates the square value of the optical detection time-series signal to obtain the instantaneous energy sequence.
[0037] The instantaneous energy satisfies the following relationship:
[0038] in, For the first Instantaneous energy at any moment Let be the window size of the first moving average filter. For example, the window size of the first moving average filter is 20. The first in the optical detection timing signal Data at any given time Use the summation index within the window.
[0039] The instantaneous energy at all moments is arranged in chronological order to obtain the instantaneous energy sequence.
[0040] Understandably, this formula calculates the average energy of the signal within a short time window. Because this window is small, the calculated instantaneous energy is very sensitive to foreign object pulses, i.e., asynchronous sparse transient signals, and will produce sharp peaks accordingly.
[0041] Then, using a window with a size of The second moving average filter is used to smooth the instantaneous energy sequence to obtain the dynamic baseline sequence.
[0042] The dynamic baseline sequence satisfies the following relationship:
[0043] in, For the first Dynamic baseline at any given time, The window size of the second moving average filter is required to be... Much larger For example, the window size of the second moving average filter is 1650. For the first The instantaneous energy value at a given moment. Use the summation index within the window.
[0044] Understandably, due to Window much larger This dynamic baseline reflects the bottle disturbance, that is, the average energy fluctuation of the synchronous periodic disturbance signal, without responding to short-term foreign object pulses.
[0045] The gating signal is then generated by comparing the instantaneous energy with the dynamic baseline.
[0046] The method for determining the gate signal satisfies the following relationship:
[0047] in, For the first The gating signal at any moment, For the first Instantaneous energy at any moment For the first Dynamic baseline at any given time, This is a preset detection sensitivity coefficient; for example, the detection sensitivity coefficient is set to 4.
[0048] Understandably, this formula utilizes This constitutes an adaptive transient threshold, when the instantaneous energy... A sudden surge, exceeding the dynamic baseline. of When the frequency is multiple times higher than normal, it is determined to be a foreign object transient period; otherwise, it is determined to be a stable interference period. The signal during the foreign object transient period is an asynchronous sparse transient signal. Therefore, this method can identify and remove asynchronous sparse transient signals, thus providing a basis for accurately fitting the periodic interference signal.
[0049] Figure 3 The image shows a gated signal. At the 1.2-second non-periodic signal position, the gated signal is 1, while at the other periodic signal positions, the gated signal is 0. The image demonstrates that the present invention can effectively identify the time interval corresponding to asynchronous non-periodic signals.
[0050] S3: Based on the optical detection timing signal and the gating signal, the periodic interference signal is locked during the stable interference period through a gating phase-locked loop to extract the actual rotation period of the bottle.
[0051] It should be noted that in order to fit the periodic interference signal, the periodic information needs to be accurately extracted.
[0052] It should be further noted that mechanical vibrations or belt slippage on the production line can cause discrepancies between the collected cycle information and the actual rotational speed of the bottle. Therefore, in order to accurately fit the cycle interference signal, it is necessary to adaptively extract the actual cycle information of the bottle from the signal itself.
[0053] Preferably, as an example, based on the optical detection timing signal and the gating signal, the periodic interference signal is locked during the stable interference period through a gated phase-locked loop to extract the actual rotation period of the bottle, including: Preset an initial frequency, for example, the initial frequency is 0. Set the initial frequency to the current estimated frequency.
[0054] In response to the door lock phase loop not being stably locked, the following operations are performed, including: First, the numerically controlled oscillator inside the phase-locked loop generates a frequency that is consistent with the currently estimated frequency. Synchronized orthogonal reference signal.
[0055] Then, the optical detection timing signal and the orthogonal reference signal are processed using a multiplication phase detector to obtain the phase error, which specifically satisfies the following relationship:
[0056] in, For the first Phase error at time, For the first Optical detection timing signal at time of moment, This is the quadrature reference signal generated by the numerically controlled oscillator.
[0057] Then, a second-order proportional-integral controller is used as a loop filter. When the gate signal is 0, the loop filter of the gated phase-locked loop updates its internal state normally according to the phase error output by the multiplication phase detector, and adjusts the current estimated frequency of the numerically controlled oscillator. When the gate signal is 1, the freeze state is executed, that is, the accumulated value of the integrator in the proportional-integral controller is frozen, and the output of the proportional term is set to zero.
[0058] After the gated phase-locked loop stabilizes and locks, the average reciprocal of the current estimated frequency of the numerically controlled oscillator is used as the rotation period.
[0059] Understandably, freezing the circuit during the foreign object transient period blocks the instantaneous impact of strong pulses on the phase-locked loop (PLL). This avoids the loop divergence or loss of lock-in that standard PLLs encounter when facing such strong transients, ensuring that the PLL can still stably lock onto the periodic interference signal under strong foreign object interference, thereby accurately extracting the actual rotation period of the bottle.
[0060] S4: Based on the gating signal and the rotation period, the optical detection timing signal is cyclically averaged only during the stable interference period to establish a bottle background template characterizing the periodic interference signal.
[0061] It should be noted that the periodic information has been obtained above, and the periodic interference signal needs to be fitted based on the periodic information below.
[0062] Optionally, as an example, based on the gating signal and the rotation period, the optical detection timing signal is cyclically averaged only during the stable interference period to establish a bottle background template characterizing the periodic interference signal, including: Set up an accumulation template array of length L, and initialize all elements in the accumulation template array to 0. Denote this accumulation template array as the bottle background template. The rotation period is defined. A counting template array of the same length is also set, and all elements in the counting template array are initialized to 0.
[0063] Iterate through the optical detection timing signal, and for each time point, perform the following operations: Check the gating signal. If the gating signal is equal to 0, update the data in the bottle background template at the current moment, specifically including: Calculate the synchronization phase , This indicates the remainder operation.
[0064] Execute accumulation: , For the bottle background template in phase The value at that location, The current sampling point time Optical detection timing signal.
[0065] Execution count: , This is the value of the counting template array at phase i.
[0066] If the gating signal is not equal to 0, the data in the bottle background template at the current moment will not be updated.
[0067] After traversing all moments of the optical detection timing signal, the final bottle background template is calculated: .
[0068] It is understandable that the periodic information in the periodic synchronization signal is updated to the bottle background model through the above conditional update operation. This method can better fit the periodic interference signal of the bottle.
[0069] Preferably, as an example, based on the gating signal and the rotation period, the optical detection timing signal is cyclically averaged only during the stable interference period to establish a bottle background template characterizing the periodic interference signal, including: Set a template array of length L, and initialize all elements in the template array to 0. Let this template array be denoted as the bottle background template. The rotation period.
[0070] Initialize an update rate Exemplary .
[0071] Iterate through the optical detection timing signal, and for each time point, perform the following operations: Check the gating signal. If the gating signal is equal to 0, update the data at that time in the bottle background template, specifically including: Calculate the synchronization phase at the current time t. , This indicates the remainder operation.
[0072] The bottle background template is updated using an exponential smoothing formula in the current phase. Update the value at:
[0073] in, For the bottle background template in phase The value at that location, The current sampling point time Optical detection timing signal.
[0074] If the gating signal is not equal to 0, the data in the bottle background template at any time will not be updated.
[0075] After traversing all moments of the optical detection timing signal, the final bottle background template is obtained.
[0076] It is understandable that by updating the exponential moving average of the above-described conditional expression, the periodic information in the periodic synchronization signal is updated into the bottle background model, while foreign object signals and noise signals that are not synchronized with the rotation period will approach 0 during the averaging process. This method can effectively fit the periodic interference signal of the bottle.
[0077] S5: Subtract the bottle background template from the optical detection timing signal to obtain the residual signal, and determine whether there are visible foreign objects based on the residual signal.
[0078] It should be noted that the above steps have already fitted the bottle interference signal. The following steps only need to eliminate the influence of the bottle interference information and determine whether there is a foreign object based on the remaining signals.
[0079] Preferably, as an example, subtracting the bottle background template from the optical detection timing signal to obtain a residual signal, and determining whether a visible foreign object exists based on the residual signal, includes: The residual signal is obtained by removing the bottle background template from the optical detection timing signal, specifically satisfying the following relationship:
[0080] in, For the first Residual signal at time, For the first Optical detection timing signal at any given moment. For the background template in the first Synchronization phase corresponding to time The value at that location.
[0081] It is understandable that by subtracting the signal corresponding to the background template from the optical detection timing signal, the influence of the bottle periodic interference signal can be eliminated, so that the residual signal contains only pure foreign object signal and background noise, thereby achieving accurate separation of interference and foreign objects.
[0082] The residual signal is subjected to threshold comparison processing using a peak detection algorithm. If There exists any peak value. satisfy , If the preset foreign body threshold is used, the veterinary drug injection is determined to be "unqualified due to visible foreign bodies".
[0083] Figure 4 The image shows the residual signal. As can be seen from the image, the present invention can eliminate periodic signal interference and accurately extract asynchronous non-periodic information, thus providing a basis for accurate foreign object detection.
[0084] Optionally, as an example, subtracting the bottle background template from the optical detection timing signal to obtain a residual signal, and determining whether a visible foreign object exists based on the residual signal, includes: The waveform energy of the bottle background template was analyzed using the waveform energy calculation formula, and the specific relationship satisfied is as follows:
[0085] in, The waveform energy of the bottle background template. For the rotation period, Background template in phase The value at that location.
[0086] Understandably, the waveform energy represents the total intensity of background interference on the veterinary medicine bottle. Higher energy indicates heavier scratches or mold marks on the bottle, or a more turbid liquid.
[0087] Compare the waveform energy of the bottle background template with a preset background threshold. If... , If the preset background threshold is used, the bottle is determined to be either "unqualified due to bottle defect" or "unqualified due to excessive background turbidity of the medicine".
[0088] This invention also discloses a veterinary drug injection quality testing system, including a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement a veterinary drug injection quality testing method according to the present invention.
[0089] The system also includes other components well known to those skilled in the art, such as communication buses and communication interfaces, the settings and functions of which are known in the art and will not be described in detail here.
[0090] In this invention, the aforementioned memory can be any tangible medium containing or storing a program that can be used or combined with an instruction execution system, apparatus, or device. For example, a computer-readable storage medium can be any suitable magnetic or magneto-optical storage medium, such as resistive random access memory (DRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (DRAM), high-bandwidth memory, hybrid memory cube, etc., or any other medium that can be used to store desired information and can be accessed by an application, module, or both. Any such computer storage medium can be part of a device or accessible to or connected to a device.
Claims
1. A method for quality testing of veterinary drug injection solutions, characterized in that, Including the following steps: Optical detection timing signals of a rotating veterinary drug injection bottle are acquired at a preset sampling frequency. The optical detection timing signals include periodic interference signals that are synchronized with the rotation of the bottle and asynchronous sparse transient signals generated by visible foreign objects. Transient detection is performed on the optical detection timing signal to identify the location where the asynchronous sparse transient signal appears, and a gating signal is generated. The gating signal is used to distinguish between the stationary interference period and the foreign object transient period in the optical detection timing signal. Based on the optical detection timing signal and the gating signal, the periodic interference signal is locked during the stable interference period through a gating phase-locked loop to extract the actual rotation period of the bottle. Based on the gating signal and the rotation period, the optical detection timing signal is cyclically averaged only during the stable interference period to establish a bottle background template characterizing the periodic interference signal. The bottle background template is subtracted from the optical detection timing signal to obtain the residual signal, and the presence of visible foreign objects is determined based on the residual signal.
2. The method for quality testing of veterinary drug injection solution according to claim 1, characterized in that, Transient detection is performed on the optical detection timing signal to generate a gating signal, including: Calculate the instantaneous energy of the optical detection timing signal; Calculate the dynamic baseline of the instantaneous energy; When the instantaneous energy is greater than the transient threshold set based on the dynamic baseline, it is determined to be the foreign object transient period; otherwise, it is determined to be the stable interference period, and the corresponding gating signal is generated.
3. The method for quality testing of veterinary drug injection solution according to claim 2, characterized in that, The instantaneous energy is calculated using a first moving average filter; the dynamic baseline is calculated using a second moving average filter; the window size of the second moving average filter is larger than the window size of the first moving average filter.
4. The method for quality testing of veterinary drug injection solution according to claim 1, characterized in that, The method for extracting the rotation period includes: During the stable interference period, the loop filter of the gated phase-locked loop updates its state according to the phase error output by the phase detector in order to adjust the current estimated frequency of the numerically controlled oscillator in the gated phase-locked loop. During the foreign object transient period, the loop filter is frozen to keep the current estimated frequency of the numerically controlled oscillator unchanged, thereby preventing the asynchronous sparse transient signal from causing the gated phase-locked loop to lose lock. When the gated phase-locked loop is stably locked, the reciprocal of the current estimated frequency of the numerically controlled oscillator is obtained as the actual rotation period of the bottle.
5. The method for quality testing of veterinary drug injection solution according to claim 4, characterized in that, The loop filter is a proportional-integral controller; the freezing state during the foreign object transient period specifically includes: freezing the accumulated value of the integrator in the proportional-integral controller and setting the output of the proportional term to zero.
6. The method for quality testing of veterinary drug injection solution according to claim 1, characterized in that, One method for creating the bottle background template includes: Initialize a template array with a length equal to the rotation period; By iterating through the optical detection timing signals, when the gate signal indicates a stable interference period, the values of the corresponding phase positions in the template array are updated using a preset learning rate based on the synchronization phase at the current moment, so as to obtain the bottle background template.
7. The method for quality testing of veterinary drug injection solution according to claim 1, characterized in that, Another method for creating the bottle background template includes: Initialize an accumulation template array and a counting template array with a length equal to the rotation period; The optical detection timing signal is iterated over. When the gate signal indicates a stable interference period, the current signal value is accumulated to the corresponding phase position of the accumulation template array, and the corresponding phase position of the counting template array is incremented by one. After the traversal is complete, each element of the accumulated template array is divided by the corresponding element of the counting template array to obtain the bottle background template.
8. The method for quality testing of veterinary drug injection solution according to claim 1, characterized in that, The method further includes: Calculate the waveform energy or peak value of the bottle background template; When the waveform energy or peak value is greater than the preset background threshold, it is determined to be a bottle defect or excessive background turbidity of the medicine liquid.
9. The method for quality testing of veterinary drug injection solution according to claim 1, characterized in that, Before performing transient detection on the optical detection timing signal, the method further includes: The optical detection timing signal is subjected to high-pass or band-pass filtering to remove DC components, power frequency interference, or out-of-band noise.
10. A quality testing system for veterinary drug injections, characterized in that, include: A processor and a memory, the memory storing computer program instructions that, when executed by the processor, implement a method for quality testing of veterinary drug injection solutions according to any one of claims 1-9.