Multifunctional grain counting machine and grain counting method

Through a multi-functional pill counting method, using multi-spectral light source arrays and pre-trained image quality prediction models, combined with morphological detection and spatio-temporal tracking technology, the problem of uneven illumination and pill overlap is solved, and high-precision drug counting and identification are achieved, adapting to Different materials and environmental changes ensure high-speed and high-reliability pharmaceutical production.

CN118570712BActive Publication Date: 2024-09-24NANJING BISUNMIT INTELLIGENT TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411027837.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2024-09-24
Estimated Expiration
2044-07-30

AI Technical Summary

Technical Problem

Existing pill counting technology has problems such as uneven illumination, shadow effects, overlap and occlusion of tablets, difficulty in identifying drugs made of different materials, and environmental factors in complex and high-speed production environments, making it difficult to achieve high-precision, stable and reliable drug counting.

Method used

Using a multi-functional pill counting method, the vibrating plate image is obtained through a pre-configured camera, the scene feature vector is constructed, the multi-spectral light source array parameters are adjusted, morphological detection, spatio-temporal tracking and debris removal are performed, and the number of pill trajectories is dynamically counted, combined with multi-channel collaborative decision-making. and fuzzy logic control to realize medicine counting and material door control.

Benefits of technology

It effectively solves the problems of uneven illumination and shadows, improves the adaptability of medicines made of different materials, enhances image tracking accuracy under high-speed motion, realizes multi-angle tablet recognition and micro-defect detection, and improves the system's adaptability to environmental changes. High-precision and high-reliability pharmaceutical production is ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118570712B
    Figure CN118570712B
Patent Text Reader

Abstract

The present invention discloses a multifunctional tablet counting machine and a tablet counting method, the method comprising: adjusting spectral configuration parameters and working parameter adjustment; obtaining a third image after the working parameter adjustment, based on the middle area and the end area of ​​the third image; performing morphological detection, spatiotemporal tracking, and debris removal, and dynamically counting the number of effective tablet tracks on each motion path, and calculating the end time and confidence of tablet counting, and sending a tablet counting end signal to a cylinder controlling the opening and closing of a material door. The problem of uneven illumination and shadow is solved, the adaptability of the system to medicines of different materials is improved, the tracking accuracy is improved, and the precise control and accurate tablet counting of a complex production process are realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to image processing technology, in particular to a grain counting method and a grain counting machine based on the image processing technology. Background Art

[0002] At present, significant progress has been made in drug counting technology, mainly including mechanical counting, photoelectric counting and visual counting methods. Mechanical counting technology uses a vibrating disk and a counting device to achieve counting through physical separation. It has the advantages of simple structure and low cost, but the accuracy is limited and it is easily affected by the shape of the drug. Photoelectric counting technology uses photoelectric sensors to detect the passage of drugs. The counting speed is fast, but it is difficult to deal with transparent or reflective drugs and is easily affected by factors such as dust. Visual counting technology is based on image processing and machine vision algorithms. It has the characteristics of high precision and strong reliability. It is a hot research direction at present. Despite these advances, existing technologies still face many challenges when facing complex and high-speed actual production environments.

[0003] The main problems faced by existing counting technologies include: on complex structures such as W-shaped vibrating plates, uneven light distribution can easily produce shadows, affecting image quality and recognition accuracy. During high-speed vibration, tablets may briefly overlap or block each other, especially at the corners of the vibrating plate, resulting in counting errors. Tablets are presented at various angles on the vibrating plate, and existing image recognition algorithms need to be improved. Traditional image acquisition methods may cause severe motion blur under high-speed conditions, affecting recognition accuracy. Drugs of different materials (such as transparent capsules, colored tablets, etc.) have different reflection and absorption characteristics for light, making it difficult to develop a universal recognition algorithm. In a high-speed processing environment, it is still difficult to distinguish between tiny defects on the surface of tablets and normal embossed characters or textures. Factors such as dust, vibration and temperature changes in the production environment may affect image quality and equipment performance, and how to design a stable and reliable system still needs to be explored. Finally, with the continuous innovation of drug design (such as special-shaped tablets, multi-layer tablets, etc.), how to ensure that the detection system can quickly adapt to new drug forms is a long-term challenge.

[0004] In order to solve the above problems, technicians have explored and proposed a purely visual solution, such as the Chinese patent with publication number CN105405145B, which uses image segmentation technology to count grains. However, this solution is still in the experimental stage and there are many difficulties in its application as mentioned above.

[0005] The applicant has conducted some exploration and development and applied for a Chinese patent with the publication number CN117022817B. In this solution, the combination of software and hardware is expected to solve engineering problems. However, in practice, it is found that there are still some problems, including accuracy being greatly affected by the environment, being unable to be deployed on systems of different models, and insufficient generalization ability. In short, the use of image segmentation technology alone, whether it is the existing pure vision solution or the image and optoelectronic fusion solution, has problems. Therefore, research and innovation are needed. Summary of the invention

[0006] The purpose of the invention is to provide a multifunctional grain counting machine and grain counting method, in order to solve the above-mentioned problems existing in the prior art.

[0007] Technical solution, according to one aspect of the present application, provides a multifunctional grain counting method, comprising the following steps:

[0008] Step S1, acquiring a first image of the vibration plate through a preconfigured camera, and constructing a feature vector of the current scene based on the first image; wherein a multi-spectral light source array is arranged around the vibration plate;

[0009] Step S2, calling a pre-trained image quality prediction model, predicting an image quality score based on the feature vector of the current scene and the current spectral configuration parameters; calling a pre-stored optimization algorithm, combining the feature vector of the current scene and the image quality score, calculating the optimal spectral configuration parameters, and comparing them with the current spectral configuration parameters, adjusting the control parameters of the multi-spectral light source array to achieve the optimal spectral configuration parameters;

[0010] Step S3, obtaining the second image under the optimal spectral configuration parameters, detecting the movement direction of the tablet, and dividing the second image into a starting area, a middle area, and a terminal area; for each area, extracting the image information of the tablet and preliminarily performing morphological detection, spatiotemporal tracking, debris removal, and working parameter adjustment;

[0011] Step S4, obtaining the third image after the working parameters are adjusted, based on the middle area and the end area of ​​the third image; performing real-time morphological detection, spatiotemporal tracking, and debris removal, and dynamically counting the number of effective tablet trajectories on each motion path, and calculating the end time and confidence of counting, and sending the counting end signal to the cylinder that controls the opening and closing of the material door.

[0012] In the present application, in order to solve the above problems, the environmental parameters are first checked through steps S1 and S2, and the working parameters of the light source are adjusted so that the device can work in the best lighting environment. Then the working parameters are adjusted through step S3 to match the working rhythm of the camera and the vibration disk so that the internal configuration of the system is optimal. Finally, in step S4, the pills are counted according to the adjusted environmental parameters and working parameters, and statistics are performed through each path. For example, if it is a single channel, it is difficult to achieve a high-precision pill counting effect. The pills are counted through 4-10 channels, and then different channels are controlled by separate switches. By controlling the early switching of some channels and retaining some drugs, the pill counting results can be accurately predicted.

[0013] It should be noted that in steps S3 and S4, the processes of morphological detection, spatiotemporal tracking, and debris removal are basically similar or identical, the difference lies in the parameter configuration. In some cases, the parameter configuration is even the same, so no repetitive description is given.

[0014] According to another aspect of the present application, there is also provided a multifunctional pellet counting machine, comprising a camera, a multi-spectral light source array, a cylinder module and a control module, wherein the control module comprises at least one processor; and

[0015] a memory communicatively connected to at least one of the processors; wherein,

[0016] The memory stores instructions that can be executed by the processor, and the instructions are used to be executed by the processor to implement the multifunctional particle counting method described in any of the above technical solutions.

[0017] In this device, the cylinder assembly module, the cylinder rotation control material gate, and the separation and sealing design of the cylinder and the material will be described below. The cylinder structure is designed so that it does not come into direct contact with the material (drug), thereby reducing the impact on the tablets.

[0018] Beneficial effects: Through the multi-spectral light source array and the pre-trained image quality prediction model, the problems of uneven illumination and shadows are effectively solved, and the system's adaptability to medicines of different materials is improved. The spatiotemporal tracking method based on dynamic pedigree tree and variational autoencoder is adopted to successfully deal with the problems of image blur, tablet overlap and occlusion under high-speed motion, and improve the tracking accuracy. The morphological detection method using adaptive ripple transformation and resonance clustering is used to achieve multi-angle tablet recognition and accurate detection of tiny defects. Through multi-dimensional motion analysis and adaptive parameter adjustment, the system's adaptability to environmental changes is improved, and image acquisition and tablet motion control are optimized. The method of counting end judgment and material gate control based on multi-channel collaborative decision-making and fuzzy logic control realizes accurate control of complex production processes. It can be applied to intelligent drug production systems with high speed, high precision and high reliability. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 It is a flow chart of the present invention.

[0020] Figure 2 It is a flow chart of constructing a feature vector of the current scene based on the first image in step S1 of the present invention.

[0021] Figure 3 It is a flowchart of predicting the image quality score in step S2 of the present invention.

[0022] Figure 4 It is a flow chart of calculating the optimal spectrum configuration parameters in step S2 of the present invention.

[0023] Figure 5 It is a flow chart of preliminary morphological detection in step S3 of the present invention.

[0024] Figure 6 It is a flow chart of preliminary spatiotemporal tracking in step S3 of the present invention.

[0025] Figure 7 It is a flow chart of the working parameter adjustment in step S3 of the present invention.

[0026] Figure 8 It is a flow chart of dynamically counting the number of effective tablet tracks on each motion path in step S4 of the present invention. DETAILED DESCRIPTION

[0027] like Figure 1 As shown, according to one aspect of the present application, a multifunctional particle counting method is provided, comprising the following steps:

[0028] Step S1, acquiring a first image of the vibration plate through a preconfigured camera, and constructing a feature vector of the current scene based on the first image; wherein a multi-spectral light source array is arranged around the vibration plate;

[0029] Step S2, calling a pre-trained image quality prediction model, predicting an image quality score based on the feature vector of the current scene and the current spectral configuration parameters; calling a pre-stored optimization algorithm, combining the feature vector of the current scene and the image quality score, calculating the optimal spectral configuration parameters, and comparing them with the current spectral configuration parameters, adjusting the control parameters of the multi-spectral light source array to achieve the optimal spectral configuration parameters;

[0030] Step S3, obtaining the second image under the optimal spectral configuration parameters, detecting the movement direction of the tablet, and dividing the second image into a starting area, a middle area, and a terminal area; for each area, extracting the image information of the tablet and preliminarily performing morphological detection, spatiotemporal tracking, debris removal, and working parameter adjustment;

[0031] Step S4, obtaining the third image after the working parameters are adjusted, based on the middle area and the end area of ​​the third image; performing real-time morphological detection, spatiotemporal tracking, and debris removal, and dynamically counting the number of effective tablet trajectories on each motion path, and calculating the end time and confidence of counting, and sending the counting end signal to the cylinder that controls the opening and closing of the material door.

[0032] In this embodiment, by using a multi-spectral light source array and a pre-trained image quality prediction model, the method effectively solves the problems of uneven illumination and shadows. The multi-spectral light source array can provide adjustable illumination conditions, and the pre-trained model can automatically optimize the spectrum configuration parameters according to the current scene characteristics. This dynamic illumination adjustment can not only reduce the shadow effect on the W-shaped vibration plate, but also adapt to the optical properties of medicines of different materials, thereby improving the adaptability of the system to diversified medicines. By dividing the image into the starting, middle and end areas for processing, the method cleverly solves the problem of tablet overlap and occlusion. In particular, the morphological detection, spatiotemporal tracking and debris removal performed in the middle and end areas can effectively identify and process short-term overlap or mutual occlusion, thereby improving the accuracy of counting. By dynamically counting the number of effective tablet trajectories on each motion path, the method can accurately track and count tablets under high-speed motion conditions, effectively overcoming the difficulties caused by image blur. By calculating the end time and confidence of counting pills in real time and sending the signal to the cylinder that controls the opening and closing of the material gate, the method achieves efficient real-time processing and response. This closed-loop control mechanism not only improves production efficiency, but also responds to abnormal situations in the production process in a timely manner.

[0033] In short, it demonstrates good adaptability and robustness, can effectively cope with complex production environments and diverse drug forms, and provides a comprehensive solution for high-speed, high-precision drug counting and detection.

[0034] like Figure 2As shown, according to one aspect of the present application, the process of constructing the feature vector of the current scene based on the first image in step S1 is specifically as follows:

[0035] Step S101, converting the first image into a grayscale image, and generating a predetermined number of spiral sampling templates for each pixel in the grayscale image;

[0036] Step S102: for each spiral sampling template, sample pixel values ​​along the spiral path to obtain a pixel sequence, calculate the statistical features of the pixel sequence, and decompose the pixel sequence using wavelet transform to obtain multi-scale frequency features; based on the multi-scale frequency features, construct a frequency vector and use principal component analysis to reduce the dimension to obtain a compressed feature vector and perform spatial pyramid pooling to obtain a global texture feature vector; the statistical features include mean, variance, skewness and kurtosis;

[0037] Step S103, constructing an initialized gradient tensor field, obtaining a grayscale image and performing Gaussian filtering to obtain a smoothed image; for each pixel in the smoothed image, calculating the local gradient covariance matrix and performing eigenvalue decomposition to obtain eigenvalues ​​and eigenvectors, calculating anisotropy based on the eigenvalues, and calculating the gradient flow direction based on the eigenvectors; updating the gradient tensor field based on the anisotropy and the gradient flow direction;

[0038] Step S104, calling the fast forward method FMM to simulate the gradient flow diffusion process on the gradient tensor field, starting from the high gradient point, propagating along the gradient flow direction, recording the diffusion time and cumulative gradient strength of each pixel; constructing an edge feature map based on the diffusion time and cumulative gradient strength and performing threshold segmentation to obtain a binary edge map, performing morphological operations on the binary edge map, reducing the edge to a single pixel width, extracting the edge chain of the binary edge map, calculating the features of each edge chain, including length, curvature and direction distribution, and constructing a global edge feature vector based on the features of the edge chain;

[0039] Step S105: Calculate the global contrast vector and the local contrast vector of the grayscale image, and combine the global texture feature and the global edge feature vector to construct a feature vector of the current scene and standardize it.

[0040] In this embodiment, the scene feature extraction method based on multi-scale and multi-feature fusion improves the system's ability to understand complex scenes and solves the problems of multi-angle recognition and accurate recognition of small defects. Through spiral sampling templates and wavelet transforms, the method can capture the multi-scale texture features of the image. This method can not only adapt to the situation where the tablets are presented at various angles on the W-shaped vibration plate, but also effectively identify the subtle texture differences on the surface of the tablets, providing a basis for distinguishing normal embossed characters from small defects. By constructing a gradient tensor field and using the fast moving method (FMM) for quasi-gradient flow diffusion, the method can accurately extract edge features. This advanced edge detection technology can accurately locate the outline of the tablet under complex backgrounds and maintain high accuracy even in the case of uneven lighting. In particular, when extracting edge chains and calculating their features (such as length, curvature, and directional distribution), the method provides support for the recognition of new drug forms such as special-shaped tablets and multi-layer tablets. By calculating the global contrast vector and the local contrast vector and combining them with texture and edge features, the method constructs a comprehensive scene feature vector. The multi-dimensional feature representation can effectively capture the impact of environmental factors (such as dust, vibration, etc.) on image quality, improving the robustness of the system in a real production environment. By standardizing the feature vectors, this method ensures the comparability of features between different scenes, laying the foundation for subsequent image quality prediction and spectral optimization. In short, this complex and comprehensive feature extraction method not only improves the system's ability to recognize various drug forms, but also enhances the system's adaptability in complex and changing environments, providing a solid data foundation for high-precision drug detection and counting.

[0041] like Figure 3 As shown, according to one aspect of the present application, in step S2, a pre-trained spectral optimization model is called to predict the image quality score based on the feature vector of the current scene and the current spectral configuration parameters, specifically:

[0042] Step S201, reading and constructing an input feature vector based on the feature vector of the current scene and the current spectrum configuration parameters;

[0043] Step S202: call the pre-trained image quality prediction model to obtain the image quality score, and compare it with the preset image quality threshold to determine whether optimization is needed. If so, proceed to the next step.

[0044] In this embodiment, the image quality prediction method based on machine learning significantly improves the adaptability of the system in complex and changing environments, and can solve problems such as uneven lighting, material diversity and environmental factors. By combining the feature vector of the current scene with the current spectral configuration parameters to construct the input feature vector, the method can fully capture the complexity of the scene and the lighting conditions. This comprehensive consideration enables the system to adapt to the reflection and absorption characteristics of light by drugs of different materials (such as transparent capsules, colored tablets, smooth or matte surfaces), and improves the versatility of recognition. The evaluation using a pre-trained image quality prediction model reflects the learning ability and adaptability of the system. This model may be trained based on a large amount of historical data, including various lighting conditions, drug materials and environmental factors, so it can accurately predict the image quality under given conditions. By comparing with the preset threshold and judging whether optimization is needed, the method realizes adaptive adjustment, and can respond to the impact of environmental changes (such as temperature fluctuations, dust accumulation, etc.) in real time during the production process. This dynamic optimization mechanism not only improves the stability of the system, but also maximizes production efficiency while ensuring image quality. It has high computational efficiency, can quickly evaluate the current image quality and make optimization decisions, and meets the needs of real-time processing on high-speed production lines. In short, this intelligent image quality prediction and optimization method enhances the adaptability and robustness of the system. It can automatically cope with various complex scenarios, ensure that high-quality images can be obtained under different drugs and different environmental conditions, and lay the foundation for subsequent accurate identification and counting. It not only improves the versatility of the system, enabling it to adapt to new drug forms, but also improves production efficiency through intelligent adjustment.

[0045] like Figure 4 As shown, according to one aspect of the present application, in step S2, a pre-stored optimization algorithm is called to calculate the optimal spectral configuration parameters in combination with the feature vector and image quality score of the current scene, specifically:

[0046] Step S203, calling a pre-stored dynamic spectrum tree search algorithm as an optimization algorithm, creating a root node of the tree, initializing a priority queue, and adding the root node to the queue; the root node contains an initial spectrum configuration and a corresponding quality score;

[0047] Step S204, read the current node, calculate the spectral gradient, and generate a number of child nodes along the gradient direction, that is, obtain branch nodes; each child node represents a new spectral configuration; for each newly generated spectral configuration, calculate the image quality score corresponding to the spectral configuration;

[0048] Step S205, calculating a potential score for each child node in sequence, adding the child node and its potential score to a priority queue, and outputting the priority queue;

[0049] Step S206: select a number of the best child nodes from the priority queue to form an excellent node set, use the pre-trained nonlinear dynamic system model to simulate the evolution of the spectrum configuration of each excellent node in the excellent node set over time, generate the evolution trajectory of each configuration, obtain a new spectrum configuration, calculate the image quality score for each new spectrum configuration, and add them to the sampling set;

[0050] Step S207: Comprehensively evaluate each spectral configuration in the sample set, select the configuration with the highest score as the new best candidate, and update the global optimal solution if the score of the new best candidate exceeds the current global optimal solution; wherein the comprehensive evaluation includes the image quality score, and the complexity and stability of the spectral configuration;

[0051] Step S208, calculate the entropy of the current search tree to measure the uncertainty of the search space; if the entropy is lower than a certain threshold, perform a pruning operation to remove nodes and their subtrees whose potential scores are lower than the threshold; check the global optimal solution of the most recent iterations and calculate the improvement rate of the image quality score; if the improvement rate is lower than the threshold for N consecutive times, or reaches the preset maximum number of iterations, terminate the search; N is a natural number greater than 1;

[0052] Step S209: When the search is terminated, the found global optimal spectrum configuration and its corresponding image quality score are returned, and the global optimal spectrum configuration is output to the multi-spectral light source array to obtain the best image quality.

[0053] In this embodiment, by creating a dynamic search tree and using a priority queue, the method can efficiently explore a large-scale spectral configuration space. Not only can the local optimal solution be found quickly, but also the local optimal solution can be avoided through global search, thereby achieving the best illumination uniformity on the surface of a complex W-shaped vibrating disk. By introducing a nonlinear dynamic system model to simulate the time evolution of the spectral configuration, a deep understanding of the dynamic changes of illumination is demonstrated. Dynamic simulation can predict the performance of different spectral configurations in time, and effectively respond to the illumination changes that may occur during the production process, such as the fluctuation of ambient light or the impact of equipment aging. By comprehensively evaluating multiple factors including image quality score, configuration complexity and stability, the method not only optimizes the illumination effect, but also considers the feasibility and stability of practical applications. This multi-objective optimization strategy can ensure the long-term stable operation of the system while improving image quality, and adapt to different production environments and drug types. It is particularly noteworthy that the method introduces the concept of search tree entropy to measure the uncertainty of the search space, and performs dynamic pruning accordingly. This adaptive search strategy improves the efficiency of the algorithm, enabling it to adjust the spectral configuration in real time on high-speed production lines. By setting the improvement rate threshold and the maximum number of iterations, this method ensures the convergence and timeliness of the optimization process and meets the needs of real-time processing. In short, the spectral optimization method not only solves the problems of uneven illumination and shadows, but also effectively copes with the challenges brought by material diversity. It can provide the best lighting conditions for different types of drugs (such as transparent capsules, colored tablets, etc.), improving the versatility and adaptability of the system. Through real-time and intelligent spectral adjustment, this method provides a stable and reliable image foundation for high-speed and high-precision drug detection and counting.

[0054] like Figure 5 As shown, according to one aspect of the present application, in step S3, the process of preliminary morphological detection is specifically as follows:

[0055] Step S301, sequentially obtain image data of the starting area, the middle area and the ending area in the second image, adopt adaptive ripple transformation for the image data of each area, obtain transformation data of a predetermined scale and direction, and map the image to the ripple space; the ripple space is in the form of a four-dimensional tensor;

[0056] Step S302: using a resonance clustering algorithm for the ripple space to identify regions with similar ripple features; obtaining a ripple resonance clustering result;

[0057] Step S303, reading the ripple resonance clustering result, constructing a polar coordinate system for each ripple resonance cluster, with the origin being the cluster center; finding the optimal closed curve in the polar coordinate system through dynamic programming; converting the polar coordinate curve back to the Cartesian coordinate system to obtain the tablet contour;

[0058] Step S304: for each extracted contour, construct a shape atlas, calculate the spectrum matrix of the atlas, and extract the first k eigenvalues ​​of the atlas as shape feature vectors; k is a natural number greater than 1;

[0059] Step S305: Based on the shape feature vector, use a support vector machine classifier to determine whether the outline is a valid tablet, and output a morphological detection result.

[0060] In this embodiment, the morphological detection method based on adaptive ripple transformation and resonance clustering shows good performance in tablet recognition and defect detection, and effectively solves key problems such as multi-angle recognition and precise recognition of small defects. Through adaptive ripple transformation, images can be analyzed at multiple scales and directions, which is crucial for capturing the features of tablets presented at various angles on the W-shaped vibration plate. The four-dimensional tensor representation of the ripple space provides a rich information basis for subsequent fine analysis. The resonance clustering algorithm is used for feature recognition, which can effectively separate areas with similar ripple features from complex backgrounds, and maintain high accuracy even when the tablets are partially overlapped or blocked. The advantage of this clustering method is that it can adaptively identify tablets of different shapes and sizes, providing support for the detection of new drug forms such as special-shaped tablets and multi-layer tablets. In the contour extraction link, by using dynamic programming in the polar coordinate system to find the optimal closed curve, high adaptability to complex shapes is demonstrated. This method can not only accurately describe tablets of regular shape, but also effectively handle irregular or damaged tablets, improving the system's ability to detect various defects. In particular, when constructing the shape atlas and extracting the eigenvalues ​​as shape feature vectors, the method provides a mathematical basis for the identification of tiny defects. This high-dimensional shape representation can capture subtle changes in the tablet surface and effectively distinguish normal embossed characters from abnormal cracks or bubbles. By using a support vector machine classifier to determine whether the contour is a valid tablet, the method achieves an efficient and reliable decision-making process. The use of support vector machines not only improves the accuracy of classification, but also enhances the system's adaptability to new drug morphologies, as it can quickly adapt to new drug types through simple retraining. In short, the morphological detection method improves the accuracy and flexibility of drug detection. It can effectively deal with the problem of image blur under high-speed motion, and improves the system's ability to recognize moving tablets through multi-scale and multi-directional analysis. At the same time, the adaptive characteristics of the method enable it to cope with various changing factors in the production environment, such as lighting changes, vibration, etc., ensuring the consistency and reliability of the detection results.

[0061] like Figure 6 As shown, according to one aspect of the present application, in step S3, the process of preliminary spatiotemporal tracking is specifically as follows:

[0062] Step S306, reading the second image, and for each region, identifying the tablets and obtaining the tablet detection results, for each detected tablet, extracting the shape invariant moment, calculating the optical flow field, and estimating the local deformation matrix, combining them into a spatiotemporal feature vector, and obtaining a spatiotemporal feature vector set;

[0063] Step S307, read the spatiotemporal feature vector set of the current moment and the previous moment, calculate the spectral distance matrix, and apply the spectral clustering algorithm to the spectral distance matrix to obtain a set of matching pairs; update the pedigree tree according to the set of matching pairs, add the matching pills as child nodes of the corresponding nodes, create a new root node for the unmatched pills, and construct a complete dynamic pedigree tree;

[0064] Step S308: based on the constructed dynamic pedigree tree and the pill detection result of the current frame, extract the ancestral path of each leaf node in the dynamic pedigree tree, use the variational autoencoder to encode and predict the ancestral path, obtain the predicted trajectory and prediction confidence, input the predicted trajectory, the pill detection result of the current frame and the prediction confidence into the graph cutting algorithm, optimize the global trajectory allocation, and obtain the optimized pill trajectory set;

[0065] Step S309: Based on the optimized trajectory set and pedigree tree, calculate the health index of each trajectory, and prune or strengthen the pedigree tree according to the value of the health index; perform pedigree tree balancing operation to obtain an updated pedigree tree as the input for pill tracking at the next moment.

[0066] In this embodiment, the spatiotemporal tracking method based on the dynamic pedigree tree and the variational autoencoder effectively solves the key problems such as image blur, tablet overlap and occlusion under high-speed motion. By extracting shape invariant moments, calculating optical flow fields and estimating local deformation matrices to construct spatiotemporal feature vectors, the dynamic characteristics of tablets in high-speed motion can be fully captured. This multi-dimensional feature representation can not only cope with motion blur, but also maintain the continuity of tracking when tablets are briefly overlapped or occluded. By calculating the spectral distance matrix and applying the spectral clustering algorithm, the method achieves high precision in cross-frame tablet matching. The use of spectral clustering is particularly suitable for processing nonlinear and high-dimensional data, and can effectively cope with complex tablet motion trajectories on W-shaped vibration disks. The innovation of constructing a dynamic pedigree tree is that it not only records the instantaneous state of the tablets, but also preserves the complete motion history. This structure enables the system to use long-term spatiotemporal information to make more accurate tracking decisions, especially when dealing with long-term occlusion or complex cross-motion. Particularly noteworthy is the use of variational autoencoders, which have demonstrated powerful capabilities in encoding and predicting ancestral paths. This deep learning method can not only effectively compress and reconstruct complex spatiotemporal information, but also generate high-quality predicted trajectories, providing key support for processing high-speed motion and complex scenes. By inputting the predicted trajectory, the current frame pill detection results and the prediction confidence into the graph cutting algorithm, this method achieves the optimization of global trajectory allocation. This global optimization strategy can effectively solve the data association problem in multi-target tracking and improve the tracking accuracy in high-density pill scenes.

[0067] This method demonstrates a deep understanding of long-term tracking stability by calculating a health metric for each trajectory and pruning or strengthening the lineage tree accordingly. This adaptive mechanism not only removes erroneous or unreliable trajectories in a timely manner, but also strengthens reliable trajectories, thereby maintaining high accuracy over long periods of time. The balancing operation of the lineage tree further optimizes the data structure, ensuring the efficiency and stability of the tracking algorithm over long periods of time. This method is particularly suitable for handling long-term drug tracking tasks on continuous production lines, and can effectively cope with the accumulated errors caused by environmental factors (such as vibration and temperature changes).

[0068] In summary, the spatiotemporal tracking method improves the accuracy, stability, and adaptability of drug tracking. It can effectively handle the problem of image blur under high-speed motion, and improves the system's tracking ability for fast-moving tablets through multi-frame information fusion and prediction mechanisms. At the same time, the adaptive characteristics of this method enable it to cope with various abnormal situations in the production process, such as tablets temporarily leaving the field of view or suddenly changing the direction of movement. This method not only improves the accuracy of current drug tracking, but also provides a technical basis for handling more complex tracking scenarios (such as the simultaneous production of multiple drugs). It opens up new possibilities for high-speed and high-precision drug production line monitoring and quality control.

[0069] like Figure 7 As shown, according to one aspect of the present application, in step S3, the process of adjusting the working parameters is specifically as follows:

[0070] Step S310, obtaining an optimized tablet trajectory set and debris removal data; extracting the velocity sequence and acceleration sequence of all tablet trajectories in each region of the second image, and calculating the velocity standard deviation and the acceleration standard deviation, and processing the velocity standard deviation and the acceleration standard deviation using a weighted summation method to obtain a motion stability index set for each region;

[0071] Step S311, reading the stability index set and the current parameter setting set, calculating the adaptive learning rate and updating the parameters, and obtaining an updated parameter set; wherein the current parameter setting set includes the sampling rate of the camera and the vibration frequency of the vibration plate;

[0072] Step S312: input the updated parameter set into the parameter constraint module, and use the limit value truncation method and monotonicity check to perform constraint processing on the updated parameter set to obtain the constrained parameter set;

[0073] Step S313: Calculate the difference between the constrained parameter set and the current parameter setting, input the difference into the smoothing filter, obtain the smoothed parameter adjustment amount and send it to the control module.

[0074] In this embodiment, the method based on multi-dimensional motion analysis and adaptive parameter adjustment demonstrates the system's ability to finely control complex dynamic processes, and effectively solves key problems such as image blur, environmental factors, and real-time processing response under high-speed motion. First, by extracting the velocity sequence and acceleration sequence of all tablet trajectories in each area and calculating the corresponding standard deviation, this method can fully capture the dynamic characteristics of tablet motion. This multi-dimensional motion analysis can not only accurately describe the complex motion of tablets on the W-shaped vibration disk, but also effectively identify abnormal motion patterns, providing a reliable basis for subsequent parameter adjustments. In particular, the weighted summation method is used to process the velocity standard deviation and the acceleration standard deviation to obtain a motion stability index. This method reflects a deep understanding of the importance of different motion characteristics and can more accurately reflect the stability requirements in the actual production process.

[0075] This method shows a high degree of intelligence and flexibility by calculating the adaptive learning rate to update the parameters. The use of adaptive learning rate enables the system to dynamically adjust the amplitude of parameter changes according to the current motion stability, which is crucial for quickly responding to environmental changes while ensuring system stability. This method is particularly suitable for dealing with various interference factors in the production environment, such as temperature fluctuations, changes in vibration intensity, etc., and can adjust the camera sampling rate and vibration frequency of the vibration plate in real time to maintain the best working state.

[0076] By introducing the parameter constraint module, using the limit value truncation method and monotonicity check, the safety and reliability of parameter adjustment are ensured. This multiple constraint mechanism not only prevents excessive oscillation or unstable state that may occur during parameter adjustment, but also ensures the smoothness of parameter changes, thereby avoiding the adverse effects of sudden changes in working conditions on tablet movement. In particular, the introduction of monotonicity check reflects the system's emphasis on the continuity of parameter adjustment, which is extremely important for maintaining the stability of the production process.

[0077] By using a smoothing filter to process the parameter adjustment, the stability of the system response is further improved. The application of smoothing filtering can not only filter out possible high-frequency noise, but also ensure the gradualness of parameter adjustment, which is particularly important for high-speed production systems and can effectively avoid system instability caused by sudden changes in parameters.

[0078] In general, the working parameter adjustment method improves the stability, adaptability and efficiency of the drug production process. It can effectively cope with various challenges under high-speed motion and optimize image acquisition and tablet motion control through real-time and fine parameter adjustment. It not only improves the system's ability to adapt to environmental changes, but also provides a technical basis for handling more complex production scenarios (such as simultaneous production of multiple drugs, dynamic changes in production line speed, etc.).

[0079] like Figure 8 As shown, according to one aspect of the present application, in step S4, the number of effective tablet trajectories on each motion path is dynamically counted, specifically:

[0080] Step S401, obtaining a third image after the working parameters are adjusted, and using an image segmentation algorithm to divide the third image into three regions, including a middle region and a terminal region of each tablet conveying channel, to obtain a region set;

[0081] Step S402, obtaining a region set, extracting tablet information and calculating dynamic pedigree tracking of the tablets, obtaining tablet tracking results, extracting tablet trajectories in the middle area and the end area of ​​each channel; using a trajectory filtering algorithm to remove abnormal trajectories that do not conform to the preset motion pattern, and obtaining a valid trajectory set for each channel;

[0082] Step S403: Apply a sliding window counting algorithm to the valid trajectory set of each channel, slide the window in the time dimension, count the number of tablets entering the termination area in each window, and obtain a dynamic counting sequence for each channel, that is, the number of valid trajectories of the tablets.

[0083] In this embodiment, the dynamic statistical method based on multi-region analysis and sliding window counting demonstrates the system's good ability to perform accurate counting in high-speed and complex scenarios, and effectively solves key problems such as multi-angle recognition, tablet overlap and occlusion, and real-time processing response. By using an image segmentation algorithm to divide the image into different areas, especially dividing each tablet conveying channel into an intermediate area and a terminal area, this method achieves a refined analysis of the movement of tablets on a complex W-shaped vibration disk. This spatial segmentation strategy can not only effectively handle the different motion characteristics that tablets may present in different areas, but also provide a structured data basis for subsequent trajectory analysis and counting.

[0084] By performing dynamic pedigree tracking on pills, this method demonstrates the ability to accurately track high-speed moving objects. Dynamic pedigree tracking can not only deal with the image blur problem that may occur when pills are moving at high speed, but also effectively handle short-term overlap or occlusion. The advantage is that it can use historical information to predict the movement of pills, thereby maintaining the continuity and accuracy of tracking in complex scenarios. In particular, when extracting the pill trajectories in the middle and terminal areas of each channel, this method can fully capture the entire process from the pills entering the field of view to leaving, providing a reliable data basis for subsequent counting.

[0085] This method shows great attention to data quality by using a trajectory filtering algorithm to remove abnormal trajectories that do not conform to the preset motion pattern. This filtering mechanism can not only eliminate erroneous trajectories caused by vibration, light changes or other interference factors, but also effectively identify and remove possible debris or impurities, improving the accuracy of counting. This method is particularly suitable for handling various abnormal situations that may occur in real production environments, such as broken tablets, dust interference, etc.

[0086] By applying a sliding window counting algorithm, this method achieves dynamic and continuous statistics of the number of tablets. The use of sliding windows can not only smooth short-term fluctuations, but also capture the dynamic trend of tablet counts. This method is particularly suitable for handling continuous counting tasks on high-speed production lines, and can reflect production changes in real time, providing timely and accurate data support for production management. In particular, by counting the number of tablets entering the termination area, this method ensures that only tablets that have completely passed the detection area are counted in the final number, further improving the accuracy of the counting.

[0087] In short, the dynamic statistical method improves the accuracy, stability and real-time performance of drug counting. It can effectively handle various challenges under high-speed motion, and achieves accurate statistics of the number of tablets in complex scenarios through multi-region analysis, dynamic tracking and intelligent filtering. It not only improves the accuracy of current drug counting, but also provides a technical basis for handling more complex production scenarios (such as simultaneous production of multiple drugs, dynamic changes in production line speed, etc.).

[0088] According to one aspect of the present application, in step S4, the end time and confidence of counting are calculated, and a counting end signal is sent to the cylinder controlling the opening and closing of the material door, specifically:

[0089] Step S404: using the dynamic counting sequence, applying a change point detection algorithm to each channel, identifying a significant change point of the counting rate as a potential end time of counting, and obtaining a set of candidate end times for each channel;

[0090] Step S405: Based on the candidate end time set and the dynamic counting sequence, the Bayesian inference model is applied to calculate the probability of each channel ending at different times to obtain a probability distribution sequence;

[0091] Step S406: Based on the probability distribution sequence, a multi-channel collaborative decision-making algorithm is adopted, and the mutual influence between channels and the historical grain counting mode are considered to comprehensively evaluate the overall grain counting progress; the global grain counting state and the grain counting confidence of each channel are obtained;

[0092] Step S407, according to the global grain count state and the confidence of each channel, a fuzzy logic controller is applied to generate a material gate control signal for each channel;

[0093] Step S408: Transmit the material door control signal to the cylinder control module, and the cylinder control module executes the corresponding material door closing operation according to the received signal.

[0094] In this embodiment, the counting end judgment and material gate control method based on multi-channel collaborative decision-making and fuzzy logic control demonstrates the system's ability to make accurate decisions and control in a complex and dynamic environment, and effectively solves key issues such as real-time processing response, environmental factors and adaptability to new drug forms.

[0095] By applying a change point detection algorithm to each channel, this method can accurately identify significant change points in the counting rate. It can not only adapt to rate fluctuations that may occur during the production process of different drugs, but also effectively capture sudden changes caused by production batch switching or equipment adjustments. The use of change point detection reflects the system's in-depth understanding of the dynamic characteristics of the drug production process and provides a reliable time benchmark for subsequent decision-making.

[0096] By applying the Bayesian inference model to calculate the probability of each channel ending at different times, the ability to handle uncertainty in a refined manner is demonstrated. The use of Bayesian inference can not only comprehensively consider historical data and current observations, but also dynamically update the end probability, which is crucial for dealing with complex and changing production environments. In particular, when generating probability distribution sequences, it can fully reflect the dynamic characteristics of the counting process and provide a rich information basis for subsequent decision-making.

[0097] By adopting a multi-channel collaborative decision-making algorithm, a comprehensive evaluation of the overall counting progress is achieved. The collaborative decision-making mechanism not only considers the independent situation of each channel, but also captures the mutual influence between channels, which is particularly important for processing multiple drugs at the same time or complex vibration plate systems. Especially when considering historical counting patterns, this method demonstrates a deep understanding of long-term production characteristics and can effectively cope with changes that may be caused by different batches or different types of drugs.

[0098] By using a fuzzy logic controller to generate the gate control signal, this method achieves refined control of complex decision-making processes. The application of fuzzy logic can not only handle the uncertainty and ambiguity in the decision-making process, but also achieve smooth control output, avoiding the sudden changes and oscillations that may be caused by traditional binary logic. This method is particularly suitable for handling various intermediate states and gradual processes that may occur in real production environments, and can achieve more stable and reliable gate control.

[0099] In short, the method of judging the end of counting and controlling the material gate improves the accuracy, stability and adaptability of the pharmaceutical production process. It can effectively cope with various challenges in high-speed and complex production environments, and achieves accurate judgment and smooth control of the counting process through multi-dimensional analysis, probabilistic inference and fuzzy control. It not only improves the efficiency and reliability of current pharmaceutical production, but also provides a technical basis for handling more complex production scenarios (such as multi-variety small batch production, intelligent production lines, etc.). It opens up new possibilities for achieving highly automated, intelligent and flexible pharmaceutical production.

[0100] In this process, multiple independently controlled channels are set up, and then motion tracking is performed. Some channels can be closed in time, and then the tablets are temporarily stored in the channels, realizing precise control of pure visual counting. In the existing technical solutions, if the tablets are counted by weighing, if there is one residual piece, or one more or one less among 100 tablets, it is impossible to accurately identify them in some cases. Therefore, there are still loopholes in the solution combining electric eyes and weighing. In addition, even if a problem is found, the existing device directly removes the tablets from the whole bottle and then processes them again manually, which not only introduces uncontrollable factors such as dust, but also affects production efficiency. This method of the present application solves the problem that the existing pure visual counting cannot accurately control the filling accuracy of tablets.

[0101] According to another aspect of the present application, there is also provided a multifunctional pellet counting machine, comprising a camera, a multi-spectral light source array, a cylinder module and a control module, wherein the control module comprises at least one processor; and

[0102] a memory communicatively connected to at least one of the processors; wherein,

[0103] The memory stores instructions that can be executed by the processor, and the instructions are used to be executed by the processor to implement the multifunctional particle counting method described in any of the above technical solutions.

[0104] In this embodiment, the cylinder module needs to be described as follows:

[0105] The cylinder module consists of the following main components:

[0106] The cylinder body can be made of high-strength aluminum alloy material, and the interior is precisely machined to ensure the stability of the piston movement.

[0107] The piston rod is made of hard chrome-plated stainless steel and is airtightly connected to the cylinder body through a sealing ring.

[0108] The end covers are located at both ends of the cylinder, made of aluminum alloy, and connected to the cylinder body by bolts.

[0109] The air source interface is located on the cylinder end cover and is used to connect the air source pipeline.

[0110] The position sensor is installed on the outer wall of the cylinder and is used to detect the position of the piston rod.

[0111] The buffer device is located at both ends of the cylinder and is used to reduce the impact of the piston movement.

[0112] The cylinder body is hollow cylindrical with a smooth surface that is precisely machined inside. The piston rod is solid cylindrical and connected to the piston. The end cover is disc-shaped with a through hole in the center for the piston rod to pass through. The piston rod passes through the cylinder body in the center, the end covers are located at both ends of the cylinder, the air source interface is located on the end covers, the position sensor is arranged linearly along the outer wall of the cylinder body, and the buffer device is located at both ends of the cylinder. The cylinder body and the end cover are fastened by bolts, and the piston rod passes through the cylinder body and one end cover. The position sensor is fixed to the outer wall of the cylinder through a special slot. The cylinder body provides space for the piston to move, the piston rod performs linear motion, the end cover seals the internal space of the cylinder, the air source interface provides a compressed air inlet, the position sensor monitors the position of the piston rod, and the buffer device reduces the impact of movement.

[0113] The rotary control mechanism consists of the following components:

[0114] The rotating shaft is vertically connected to the piston rod and is made of wear-resistant alloy steel.

[0115] The bearing seat, which supports the rotating shaft, adopts high-precision rolling bearings.

[0116] The connecting rod mechanism converts the linear motion of the cylinder into rotational motion.

[0117] The material door is made of food-grade stainless steel and is fan-shaped or disc-shaped.

[0118] The limit device is used to control the opening and closing angle of the material door.

[0119] The piston rod of the cylinder is connected to the rotating shaft through a connecting rod mechanism. The rotating shaft is fixed to the frame through a bearing seat, and the material door is directly fixed to the rotating shaft. The cylinder provides the power source, the connecting rod mechanism converts the linear motion into rotational motion, the rotating shaft drives the material door to rotate, the bearing seat provides stable support, and the limit device controls the rotation angle. The cylinder is located on the side of the frame, the connecting rod mechanism is located between the cylinder piston rod and the rotating shaft, the rotating shaft is perpendicular to the bottom of the hopper, and the material door is located at the hopper outlet. The connecting rod mechanism adopts a crank slider structure, the rotating shaft is cylindrical, and the material door is fan-shaped or disc-shaped, which is coaxially fixed with the rotating shaft.

[0120] To ensure that the cylinder does not come into direct contact with the material, the following structure is designed:

[0121] The sealing chamber is used to completely seal the cylinder and its moving mechanism. The isolation plate is located between the hopper and the cylinder mechanism and is made of food-grade stainless steel. The flexible sealing ring is installed at the perforation between the rotating shaft and the isolation plate. The dust cover is used to cover the outside of the connecting rod mechanism.

[0122] The sealing chamber is fixedly connected to the frame, the isolation plate separates the hopper from the cylinder mechanism, the flexible sealing ring is installed at the shaft hole of the isolation plate, and the dust cover is fixed to the connecting rod mechanism. The sealing chamber isolates the cylinder from the external environment, the isolation plate prevents materials from entering the cylinder area, the flexible sealing ring allows the rotating shaft to rotate while preventing material leakage, and the dust cover protects the connecting rod mechanism from contamination. The sealing chamber completely surrounds the cylinder and its moving mechanism, the isolation plate is located between the bottom of the hopper and the cylinder mechanism, the flexible sealing ring is located at the contact between the isolation plate and the rotating shaft, and the dust cover covers the entire connecting rod mechanism. The sealing chamber is a box-type structure, the isolation plate is flat, the flexible sealing ring is annular with an adaptive sealing lip, and the dust cover is a detachable shell structure.

[0123] The preferred embodiments of the present invention are described in detail above; however, the present invention is not limited to the specific details in the above embodiments. Within the technical concept of the present invention, various equivalent transformations can be made to the technical solutions of the present invention, and these equivalent transformations all belong to the protection scope of the present invention.

Claims

1. A multifunctional grain counting method, characterized in that: The steps include: Step S1, acquiring a first image of the vibration plate through a preconfigured camera, and constructing a feature vector of the current scene based on the first image; wherein a multi-spectral light source array is arranged around the vibration plate; Step S2: calling a pre-trained image quality prediction model to predict an image quality score based on a feature vector of the current scene and current spectral configuration parameters; Calling the pre-stored optimization algorithm, combining the feature vector and image quality score of the current scene, calculating the optimal spectrum configuration parameters, and comparing them with the current spectrum configuration parameters, adjusting the control parameters of the multi-spectral light source array to achieve the optimal spectrum configuration parameters; Step S3, obtaining a second image under the optimal spectral configuration parameters, detecting the movement direction of the tablet, and dividing the second image into a starting area, a middle area, and a terminal area; For each area, the tablet image information is extracted and preliminary morphological detection, spatiotemporal tracking, debris removal and working parameter adjustment are performed; Step S4, obtaining the third image after the working parameters are adjusted, based on the middle area and the end area of ​​the third image; performing real-time morphological detection, spatiotemporal tracking, and debris removal, and dynamically counting the number of effective tablet trajectories on each motion path, and calculating the end time and confidence of counting, and sending a counting end signal to the cylinder that controls the opening and closing of the material door; In step S4, the end time and confidence of counting are calculated, and a signal of the end of counting is sent to the cylinder controlling the opening and closing of the material door, specifically: Step S404: using the dynamic counting sequence, applying a change point detection algorithm to each channel, identifying a significant change point of the counting rate as a potential end time of counting, and obtaining a set of candidate end times for each channel; Step S405: Based on the candidate end time set and the dynamic counting sequence, the Bayesian inference model is applied to calculate the probability of each channel ending at different times to obtain a probability distribution sequence; Step S406: Based on the probability distribution sequence, a multi-channel collaborative decision-making algorithm is adopted, and the mutual influence between channels and the historical grain counting mode are considered to comprehensively evaluate the overall grain counting progress; the global grain counting state and the grain counting confidence of each channel are obtained; Step S407, according to the global grain count state and the confidence of each channel, a fuzzy logic controller is applied to generate a material gate control signal for each channel; Step S408: Transmit the material door control signal to the cylinder control module, and the cylinder control module executes the corresponding material door closing operation according to the received signal.

2. The multifunctional grain counting method according to claim 1, characterized in that: The process of constructing the feature vector of the current scene based on the first image in step S1 is specifically as follows: Step S101, converting the first image into a grayscale image, and generating a predetermined number of spiral sampling templates for each pixel in the grayscale image; Step S102: for each spiral sampling template, sample pixel values ​​along the spiral path to obtain a pixel sequence, calculate the statistical features of the pixel sequence, and decompose the pixel sequence using wavelet transform to obtain multi-scale frequency features; based on the multi-scale frequency features, construct a frequency vector and use principal component analysis to reduce the dimension to obtain a compressed feature vector and perform spatial pyramid pooling to obtain a global texture feature vector; Statistical characteristics include mean, variance, skewness, and kurtosis; Step S103, constructing an initialized gradient tensor field, obtaining a grayscale image and performing Gaussian filtering to obtain a smoothed image; for each pixel in the smoothed image, calculating the local gradient covariance matrix and performing eigenvalue decomposition to obtain eigenvalues ​​and eigenvectors, calculating anisotropy based on the eigenvalues, and calculating the gradient flow direction based on the eigenvectors; updating the gradient tensor field based on the anisotropy and the gradient flow direction; Step S104, calling the fast forward method FMM to simulate the gradient flow diffusion process on the gradient tensor field, starting from the high gradient point, propagating along the gradient flow direction, recording the diffusion time and cumulative gradient strength of each pixel; constructing an edge feature map based on the diffusion time and cumulative gradient strength and performing threshold segmentation to obtain a binary edge map, performing morphological operations on the binary edge map, reducing the edge to a single pixel width, extracting the edge chain of the binary edge map, calculating the features of each edge chain, including length, curvature and direction distribution, and constructing a global edge feature vector based on the features of the edge chain; Step S105: Calculate the global contrast vector and the local contrast vector of the grayscale image, and combine the global texture feature and the global edge feature vector to construct a feature vector of the current scene and standardize it.

3. The multifunctional grain counting method according to claim 2, characterized in that: In step S2, the pre-trained spectral optimization model is called to predict the image quality score based on the feature vector of the current scene and the current spectral configuration parameters, specifically: Step S201, reading and constructing an input feature vector based on the feature vector of the current scene and the current spectrum configuration parameters; Step S202: call the pre-trained image quality prediction model to obtain the image quality score, and compare it with the preset image quality threshold to determine whether optimization is needed. If so, proceed to the next step.

4. The multifunctional grain counting method according to claim 3, characterized in that: In step S2, the pre-stored optimization algorithm is called to calculate the optimal spectrum configuration parameters by combining the feature vector and image quality score of the current scene, specifically: Step S203, calling a pre-stored dynamic spectrum tree search algorithm as an optimization algorithm, creating a root node of the tree, initializing a priority queue, and adding the root node to the queue; the root node contains an initial spectrum configuration and a corresponding quality score; Step S204, read the current node, calculate the spectral gradient, and generate a number of child nodes along the gradient direction, that is, obtain a branch node; Each child node represents a new spectral configuration; for each newly generated spectral configuration, the image quality score corresponding to the spectral configuration is calculated; Step S205, calculating a potential score for each child node in sequence, adding the child node and its potential score to a priority queue, and outputting the priority queue; Step S206: select a number of the best child nodes from the priority queue to form an excellent node set, use the pre-trained nonlinear dynamic system model to simulate the evolution of the spectrum configuration of each excellent node in the excellent node set over time, generate the evolution trajectory of each configuration, obtain a new spectrum configuration, calculate the image quality score for each new spectrum configuration, and add them to the sampling set; Step S207: Comprehensively evaluate each spectral configuration in the sample set, select the configuration with the highest score as the new best candidate, and update the global optimal solution if the score of the new best candidate exceeds the current global optimal solution; wherein the comprehensive evaluation includes the image quality score, and the complexity and stability of the spectral configuration; Step S208, calculate the entropy of the current search tree to measure the uncertainty of the search space; if the entropy is lower than a certain threshold, perform a pruning operation to remove nodes and their subtrees whose potential scores are lower than the threshold; check the global optimal solution of the most recent iterations and calculate the improvement rate of the image quality score; if the improvement rate is lower than the threshold for N consecutive times, or reaches the preset maximum number of iterations, terminate the search; N is a natural number greater than 1; Step S209: When the search is terminated, the found global optimal spectrum configuration and its corresponding image quality score are returned, and the global optimal spectrum configuration is output to the multi-spectral light source array to obtain the best image quality.

5. The multifunctional grain counting method according to claim 4, characterized in that: In step S3, the process of preliminary morphological detection is specifically as follows: Step S301, sequentially obtain image data of the starting area, the middle area and the ending area in the second image, adopt adaptive ripple transformation for the image data of each area, obtain transformation data of a predetermined scale and direction, and map the image to the ripple space; the ripple space is in the form of a four-dimensional tensor; Step S302: using a resonance clustering algorithm for the ripple space to identify regions with similar ripple features; obtaining a ripple resonance clustering result; Step S303, reading the ripple resonance clustering result, constructing a polar coordinate system for each ripple resonance cluster, with the origin being the cluster center; finding the optimal closed curve in the polar coordinate system through dynamic programming; converting the polar coordinate curve back to the Cartesian coordinate system to obtain the tablet contour; Step S304: for each extracted contour, construct a shape atlas, calculate the spectrum matrix of the atlas, and extract the first k eigenvalues ​​of the atlas as shape feature vectors; k is a natural number greater than 1; Step S305: Based on the shape feature vector, use a support vector machine classifier to determine whether the outline is a valid tablet, and output a morphological detection result.

6. The multifunctional particle counting method according to claim 5, characterized in that: In step S3, the process of preliminary spatiotemporal tracking is specifically as follows: Step S306, reading the second image, and for each region, identifying the tablets and obtaining the tablet detection results, for each detected tablet, extracting the shape invariant moment, calculating the optical flow field, and estimating the local deformation matrix, combining them into a spatiotemporal feature vector, and obtaining a spatiotemporal feature vector set; Step S307, reading the spatiotemporal feature vector sets of the current moment and the previous moment, calculating the spectral distance matrix, and applying the spectral clustering algorithm to the spectral distance matrix to obtain a set of matching pairs; Based on the set of matching pairs, the pedigree tree is updated, the matching pills are added as children of the corresponding nodes, new root nodes are created for the unmatched pills, and a complete dynamic pedigree tree is constructed; Step S308: based on the constructed dynamic pedigree tree and the pill detection result of the current frame, extract the ancestral path of each leaf node in the dynamic pedigree tree, use the variational autoencoder to encode and predict the ancestral path, obtain the predicted trajectory and prediction confidence, input the predicted trajectory, the pill detection result of the current frame and the prediction confidence into the graph cutting algorithm, optimize the global trajectory allocation, and obtain the optimized pill trajectory set; Step S309: Calculate the health index of each trajectory based on the optimized trajectory set and the pedigree tree, and perform pruning or strengthening operations on the pedigree tree according to the value of the health index; Perform a pedigree tree balancing operation to obtain an updated pedigree tree as the input for pill tracking at the next moment.

7. The multifunctional particle counting method according to claim 6, characterized in that: In step S3, the process of adjusting the working parameters is specifically as follows: Step S310, obtaining an optimized tablet trajectory set and debris removal data; extracting the velocity sequence and acceleration sequence of all tablet trajectories in each region of the second image, and calculating the velocity standard deviation and the acceleration standard deviation, and processing the velocity standard deviation and the acceleration standard deviation using a weighted summation method to obtain a motion stability index set for each region; Step S311, reading the stability index set and the current parameter setting set, calculating the adaptive learning rate and updating the parameters, and obtaining an updated parameter set; wherein the current parameter setting set includes the sampling rate of the camera and the vibration frequency of the vibration plate; Step S312: input the updated parameter set into the parameter constraint module, and use the limit value truncation method and monotonicity check to perform constraint processing on the updated parameter set to obtain the constrained parameter set; Step S313: Calculate the difference between the constrained parameter set and the current parameter setting, input the difference into the smoothing filter, obtain the smoothed parameter adjustment amount and send it to the control module.

8. The multifunctional grain counting method according to claim 7, characterized in that: In step S4, the number of effective tablet tracks on each motion path is dynamically counted, specifically: Step S401, obtaining a third image after the working parameters are adjusted, and using an image segmentation algorithm to divide the third image into three regions, including a middle region and a terminal region of each tablet conveying channel, to obtain a region set; Step S402, obtaining a region set, extracting tablet information and calculating dynamic pedigree tracking of the tablets, obtaining tablet tracking results, and extracting tablet trajectories in the middle area and the end area of ​​each channel; Adopt trajectory filtering algorithm to eliminate abnormal trajectories that do not conform to the preset motion mode and obtain the valid trajectory set of each channel; Step S403: Apply a sliding window counting algorithm to the valid trajectory set of each channel, slide the window in the time dimension, count the number of tablets entering the termination area in each window, and obtain a dynamic counting sequence for each channel, that is, the number of valid trajectories of the tablets.

9. A multifunctional counting machine, characterized in that: Including camera, multi-spectral light source array, cylinder module and control module, The control module includes at least one processor; and, a memory communicatively connected to at least one of the processors; wherein, The memory stores instructions executable by the processor, and the instructions are used to be executed by the processor to implement the multifunctional particle counting method described in any one of claims 1 to 8.

Citation Information

Cited By

  • Embedded electronic grain counting machine control method and system

    CN120297312A