A method and system for measuring the diameter of a test tube

By improving the bee colony algorithm and point cloud data splitting technology, and combining it with dual-sensor deployment, the problem of difficulty in distinguishing the label surface from the test tube surface in serum test tube measurement was solved. This enabled high-precision online detection of test tube diameter, adapting to test tubes of different specifications and surface conditions, and meeting the automation needs of medical testing.

CN122329172APending Publication Date: 2026-07-03CHANGCHUN INST OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610794629.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-03
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

In existing technologies, when line profile sensors measure serum tubes with attached labels, the close distance between the label surface and the tube surface makes it impossible for the least squares method to effectively distinguish between two concentric circles, resulting in insufficient measurement accuracy and making it difficult to meet the needs of medical testing towards automation and high throughput.

Method used

An improved bee colony algorithm is used in conjunction with point cloud data splitting and dual sensor arrangement. The point clouds on the test tube surface and the label surface are separated by K-means clustering and the 3σ criterion. The optimal circle fitting under concentric constraints is used to achieve high-precision measurement of the test tube diameter.

Benefits of technology

It significantly improves the fitting accuracy and convergence reliability of non-complete small circular arcs under conditions of sparse point cloud data and high noise. It can quickly, stably and accurately complete the online detection of test tube diameter, adapt to test tubes of different specifications and surface conditions, and overcome the local optima problem of existing methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122329172A_ABST
    Figure CN122329172A_ABST
Patent Text Reader

Abstract

This invention relates to the field of precision measurement technology, and more particularly to a method and system for measuring the diameter of a test tube. The method includes: acquiring point cloud data of the cross-sectional profile of the test tube and splitting it into a test tube surface point set and a label surface point set; calculating the diameter of the test tube after performing optimal circle fitting using an improved bee colony algorithm. The optimal circle fitting using the improved bee colony algorithm includes: A10, defining the objective function and initializing the food source population and parameters; A20, sequentially executing the hired bee stage and the observation bee stage, updating the food sources and their corresponding stagnation counts; A30, entering the scout bee stage, checking the stagnation count of each food source, initializing food sources with stagnation counts exceeding the abandonment threshold according to a mixing strategy, and updating the food source population; A40, incrementing the current iteration count by 1 and returning to step A20, until the iteration termination condition is met. This invention improves the accuracy of test tube diameter measurement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of precision measurement technology, and in particular relates to a method and system for measuring the diameter of a test tube. Background Technology

[0002] Test tubes, as one of the most basic consumables in laboratory and clinical testing, are widely used in chemical analysis, biological experiments, and medical testing. With the continuous development of medical testing technology, the requirements for the geometric precision of test tubes are increasing.

[0003] Serum tubes are fundamental containers widely used in medical testing, and their diameter accuracy directly affects the accuracy of sample processing, storage, and test results. As medical testing moves towards automation and high throughput, higher demands are placed on the measurement accuracy of tube dimensions. Traditional measurement methods mainly rely on manual caliper measurements or simple mechanical contact measurements, which have limitations such as low measurement efficiency, large human error, and inability to achieve automation.

[0004] Non-contact measurement methods, such as diameter measurement using line profile sensors, mainly include single-sided measurement based on a single scan and double-sided measurement based on a symmetrical arrangement of two sensors. Single-sided measurement based on a single scan involves fitting a circle diameter by acquiring arc data from one side of the workpiece; double-sided measurement based on a symmetrical arrangement of two sensors involves simultaneously acquiring arc data from both sides of the workpiece for circle fitting. In existing technologies, the least squares method is typically used for circle fitting. However, for labeled serum tubes, because the label surface and the tube surface are spatially close and share a common center, existing least squares methods often identify them as a single entity, making it difficult to effectively distinguish the point cloud on the outer wall of the tube from the point cloud on the label surface. This leads to decreased circle fitting accuracy, directly affecting the accuracy of sample processing, storage, and test results, and failing to meet the demands of clinical testing towards automation and high throughput. Summary of the Invention

[0005] In view of this, the present invention aims to provide a method and computer device for measuring the diameter of a test tube, so as to overcome the technical defects of the prior art in which the line contour sensor cannot effectively distinguish two concentric circles and the measurement accuracy is insufficient when measuring serum test tubes with attached labels due to the close distance between the label surface and the test tube surface. The invention achieves rapid, stable and high-precision online detection of the diameter of the test tube surface and the label surface.

[0006] To achieve the above objectives, the technical solution created by this invention is implemented as follows: In a first aspect, the present invention provides a method for measuring the diameter of a test tube, comprising the steps of: S10. Obtain the point cloud data of the cross-sectional profile of the tube to be tested; S20. The point cloud data is split into a test tube surface point set and a label surface point set; S30. Using the improved bee colony algorithm, perform optimal circle fitting under concentric constraints on the point set on the test tube surface and the point set on the label surface to obtain the center coordinates and radius of the tube to be tested, and calculate the diameter of the tube to be tested. Step S30 includes: A10. Define the objective function and initialize the food source population and parameters. The food source in the food source population is a four-dimensional variable, and the first to fourth dimensions correspond to the horizontal coordinate of the center of the circle, the vertical coordinate of the center of the circle, the radius of the tube to be tested, and the radius of the label, respectively. A20. Execute the hired bee phase and the observation bee phase in sequence, and update the food source and its corresponding number of stagnations; A30. Enter the scout bee phase, check the number of times each food source has stopped, initialize food sources whose number of stops exceeds the abandonment threshold according to the mixing strategy, and update the food source population; A40. Determine if the iteration termination condition has been met. If yes, terminate the iteration; otherwise, increment the current iteration count by 1 and return to step A20.

[0007] Furthermore, in at least one step from A10 to A30, the food source is subjected to radius constraint processing: if the radius of the tube to be tested is greater than the label radius, the values ​​of the radius of the tube to be tested and the label radius are exchanged.

[0008] Furthermore, step A10 includes calculating the first... i food source x i fitness value F(x i ) Step A20 includes: A21. Execute the hired bee phase, for the aforementioned... i A food source is generated according to an adaptive step size formula, and the fitness value of the hired food source is calculated. A22. Determine whether the fitness value of the hired food source is greater than that of the first... i food source x i fitness value F (x i ); If yes, proceed to step A23; if no, proceed to step A24. A23, the first i food source Update to the aforementioned food source for employment; A24, the firsti food source The corresponding number of pauses increases by 1.

[0009] Furthermore, the adaptive step size formula is as follows: ; in, This is an adaptive step size factor. This represents the current iteration number. This represents the maximum number of iterations. For the first of the hired food sources Dimensional variables; food source The Dimensional variables; For the randomly selected first k The first food source Dimensional variables; It is a random number between [-1, 1].

[0010] Furthermore, step A20 also includes: A25. For each observation bee, select a food source according to probability, perform a neighborhood search in the vicinity of the selected food source to generate an observation food source, and calculate the fitness value of the observation food source. A26. Determine whether the fitness value of the observed food source is greater than the fitness value of the selected food source. If yes, proceed to step A27; otherwise, proceed to step A28. A27. Update the selected food source to the observed food source; A28. Increase the number of pauses corresponding to the selected food source by 1.

[0011] Furthermore, step A30 also includes: determining the current optimal solution based on the updated food source and according to the objective function; The hybrid strategy is as follows: initialize completely randomly with a 50% probability, and perturb based on the current optimal solution with a 50% probability.

[0012] in, Indicates the first i The first food source Dimensional variables; Indicates the first The lower bound of a dimensional variable; Indicates the first Upper bound of a dimensional variable; Represents a random number between [0, 1]; The current optimal solution is the th Dimensional variables.

[0013] Furthermore, step S10 includes: acquiring point cloud data of the cross-sectional profile of the tube under test using a dual-sensor symmetrical arrangement.

[0014] Furthermore, step S20 includes: S21. Calculate the distance from each measurement point in the point cloud data to the origin. ; S22, at the distance Using the K-means algorithm as a feature, the point cloud data is clustered to obtain test tube surface clusters and label surface clusters; S23. Using the 3σ criterion, outlier measurement points are removed from the clusters on the test tube surface to obtain the test tube surface point set; using the 3σ criterion, outlier measurement points are removed from the clusters on the label surface to obtain the label surface point set.

[0015] Secondly, the present invention provides a test tube diameter measurement system, comprising a first sensor and a second sensor symmetrically arranged on both sides of the test tube, and a computer device connected to the first sensor and the second sensor; the computer device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, which enables the at least one processor to perform the test tube diameter measurement method provided in any embodiment of the present invention.

[0016] Thirdly, the present invention provides a non-transitory computer-readable storage medium storing computer instructions for causing the computer to execute the test tube diameter measurement method provided in any embodiment of the present invention.

[0017] Compared with the prior art, the present invention can achieve the following beneficial effects: (1) The test tube diameter measurement method of the present invention combines automatic clustering of point cloud data with improved bee colony algorithm, which significantly improves the fitting accuracy and convergence reliability of non-complete small arc under the condition of sparse point cloud data and high noise. It effectively avoids the problem of traditional methods easily getting trapped in local optima and can quickly, stably and with high precision complete the online detection of the diameter of the test tube.

[0018] (2) In the point cloud data segmentation described in this invention, based on the distance from the point to the origin, the K-means clustering algorithm is used to automatically segment the point cloud data into test tube surface clusters and label surface clusters, solving the problem that existing technologies have difficulty effectively distinguishing between the outer wall of the test tube and the label surface. On this basis, the 3σ criterion is used to remove outlier measurement points within each cluster, further improving the quality of the test tube surface point set and the label surface point set. The entire segmentation process requires no manual intervention and can adapt to test tubes of different specifications and surface conditions.

[0019] (3) The point cloud data of the cross-sectional profile of the tube to be tested described in this invention is collected by symmetrically arranged dual sensors. By simultaneously acquiring the profile data of both sides of the tube to be tested, the measurement error caused by the eccentric installation of the tube to be tested is effectively compensated, and the problem of insufficient fitting accuracy caused by incomplete data in the existing single sensor measurement method is overcome.

[0020] (4) The hired bee stage described in this invention performs a traversal search for each food source. By randomly selecting neighbors and dimensions, an adaptive step size formula is used to generate hired food sources. The step size factor decreases with the number of iterations. In the early stage, a large step size is beneficial for global exploration, while in the later stage, a small step size is beneficial for local fine development. After the hired food source is subjected to radius constraint processing, its fitness value is calculated, and based on this, it is determined whether to update the food source and its stagnation counter, thereby achieving the initial optimization of the food source population.

[0021] (5) The observation bee stage of the present invention calculates the selection probability based on the fitness value of each food source, so that the high-quality food source has a higher selection probability. The selected food source is searched in the neighborhood to generate observation food sources. After radius constraint processing, the food source and its stagnation counter are updated by greedy selection. Based on the hired bee stage, the local development capability is further enhanced to achieve in-depth optimization of the food source population.

[0022] (6) The reconnaissance bee stage described in this invention identifies candidate solutions trapped in local optima by checking the stagnation counter of each food source. When the number of stagnations exceeds the abandonment threshold, a hybrid strategy is adopted to reinitialize the food source: a new food source is generated by adding a Gaussian perturbation based on the current optimal solution with a 50% probability, and the search direction is guided by existing good information. A new food source is generated completely randomly in the search space with a 50% probability, and the introduction of new food sources maintains population diversity. The new food source is subjected to radius constraint processing and the stagnation counter is reset, which effectively escapes local optima and enhances the global search capability of the algorithm. Attached Figure Description

[0023] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments and descriptions of the invention are used to explain the invention and do not constitute an undue limitation of the invention. In the drawings: Figure 1 A schematic flowchart illustrating the test tube diameter measurement method described in the embodiments of the present invention; Figure 2 This is a schematic diagram of point cloud data of the cross-sectional profile of the tube to be tested according to an embodiment of the present invention; Figure 3 This is a schematic diagram of point cloud data provided in an embodiment of the present invention being split into a test tube surface point set and a label surface point set; Figure 4 This is a schematic diagram of optimal circle fitting under concentric constraints for the test tube surface point set and the label surface point set using an improved bee colony algorithm according to an embodiment of the present invention. Figure 5 A schematic diagram of the bee-hiring stage in the test tube diameter measurement method described in the embodiment of the present invention; Figure 6 A schematic diagram of the reconnaissance bee stage in the test tube diameter measurement method described in the embodiment of the present invention; Figure 7 A schematic diagram of the computer device in the test tube diameter measurement system described in an embodiment of the present invention.

[0024] Explanation of reference numerals in the attached figures: 62. Computer equipment; 64. External devices; 66. Processing unit; 68. Bus; 70. Network adapter; 72. Input / output (I / O) interface; 74. Display; 78. System memory; 80. Random access memory (RAM); 82. Cache memory; 84. Storage system; 90. Program / utility; 92. Program module. Detailed Implementation

[0025] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only for explaining the invention and do not constitute a limitation thereof. Similar elements in different embodiments are referred to by associated similar element reference numerals. In the following embodiments, many details are described to facilitate a better understanding of the invention. However, those skilled in the art will readily recognize that some features may be omitted in different situations, or may be replaced by other elements, materials, or methods. In some cases, some operations related to the invention are not shown or described in the specification. This is to avoid obscuring the core parts of the invention with excessive description. For those skilled in the art, detailed description of these related operations is not necessary; they can fully understand the related operations based on the description in the specification and general technical knowledge in the art.

[0026] It should be noted that, unless otherwise specified, the embodiments and features described in this invention can be combined to form various implementations. Furthermore, the order of the steps or actions in the method description can be changed or adjusted in a manner readily apparent to those skilled in the art. Therefore, the various orders in the specification and drawings are merely for the clear description of a particular embodiment and do not imply a mandatory order, unless otherwise stated that a particular order must be followed.

[0027] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," "clockwise," and "counterclockwise," etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation on this invention. The term "based on" should be understood as "at least partially based on." Furthermore, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, features defined with "first," "second," etc., may explicitly or implicitly include one or more of that feature. In the description of this invention, unless otherwise stated, "a plurality of" means two or more, and the term "including" means "including but not limited to." Various embodiments of the present invention may exist in the form of a range; it should be understood that the description in the form of a range is merely for convenience and brevity and should not be construed as a rigid limitation on the scope of the invention; therefore, it should be considered that the range description has specifically disclosed all possible sub-ranges and single numerical values ​​within that range; for example, it should be considered that the range description from 1 to 6 has specifically disclosed sub-ranges, such as from 1 to 3, from 1 to 4, from 1 to 5, from 2 to 4, from 2 to 6, from 3 to 6, etc., and single numbers within the range, such as 1, 2, 3, 4, 5, and 6, regardless of the range. Furthermore, whenever a numerical range is referred to herein, it means including any referenced number (fraction or integer) within the range referred to.

[0028] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art will understand the specific meaning of the above terms in this invention based on the specific circumstances.

[0029] The present invention will now be described in detail with reference to the accompanying drawings and embodiments.

[0030] Example 1 like Figure 1 As shown, this embodiment provides a method for measuring the diameter of a test tube, including the following steps: S10. Obtain the point cloud data of the cross-sectional profile of the tube to be tested; The point cloud data mentioned above is acquired through non-contact measurement technology. Preferably, this invention employs a dual-sensor symmetrical arrangement to acquire point cloud data of the cross-sectional profile of the tube under test. In specific implementation, two sensors are symmetrically positioned on both sides of the tube under test, and both sensors are simultaneously triggered to acquire profile data from both sides of the tube. The resulting data is fused to form the point cloud data as shown below. Figure 2 The image shows the complete cross-sectional profile point cloud data of the test tube. This method eliminates the need to rotate the test tube, allowing for a complete profile acquisition in a single data entry. It effectively compensates for test tube installation eccentricity errors, providing high-quality data input for subsequent point cloud segmentation and circle fitting.

[0031] S20. The point cloud data is split into a test tube surface point set and a label surface point set; The core idea of ​​splitting point cloud data is to use the natural spatial difference between the surface of the tube under test and the surface of the label to achieve automatic separation of point cloud data. That is, the surface of the tube under test is closer to the center of the cross-sectional outline of the tube under test, while the surface of the label is farther from the center of the cross-sectional outline of the tube under test.

[0032] In practice, the point cloud data can first be divided into the following categories using the K-means algorithm: Figure 3 The test tube surface cluster and label surface cluster are shown. Then, the 3σ criterion is used to remove outlier measurement points within the two clusters, thus obtaining a pure test tube surface point set and label surface point set, which provides high-quality input data for subsequent optimal circle fitting under concentric constraints.

[0033] More specifically, step S20 includes: S21. Calculate the distance from each measurement point in the point cloud data to the origin. ;

[0034] in,( x p ,y p ) represents the first point in the point cloud data. p The coordinates of the measurement points N arc This indicates the total number of measurement points contained in the point cloud data. The origin refers to the reference point of the measurement coordinate system. Currently, in systems that use a symmetrical arrangement of two sensors for point cloud data acquisition, a common technique for unifying the coordinate systems of the two sensors is as follows: a standard circular block (or a standard sphere) is used as a common reference object, placed in the common field of view of the two sensors, and the two sensors are simultaneously triggered to acquire point cloud data at least 2-3 different poses; then, each frame of point cloud is filtered and segmented, and the geometric center coordinates (center of the circle or the center of the sphere) of the block in its respective sensor coordinate system are fitted at each pose, thereby obtaining a series of corresponding point pairs in space; finally, the optimal rotation matrix and translation vector between the two coordinate systems are calculated using algorithms such as singular value decomposition (SVD) or least squares method, ultimately completing the unification of the coordinate systems and the calibration of the origin.

[0035] S22, at the distance d p Using the K-means algorithm as the feature, the point cloud data is clustered to obtain test tube surface cluster and label surface cluster; The goal of the K-means algorithm is to minimize the sum of squared intra-class distances. Q : ; in, d p Indicates the first p The distance from each measurement point to the origin. C q Indicates the first q One cluster, μ q As the cluster center, it is the first q The average distance from all measurement points to the origin in each cluster.

[0036] After clustering, two cluster centers were obtained. and By comparing two cluster centers and The size can determine the clustering of test tube surfaces and label surfaces. Let... ,but and The corresponding point sets are as follows: ; ; in, This indicates clustering on the test tube surface. This indicates label surface clustering.

[0037] S23. Using the 3σ criterion, outlier measurement points are removed from the clusters on the test tube surface to obtain the test tube surface point set; using the 3σ criterion, outlier measurement points are removed from the clusters on the label surface to obtain the label surface point set.

[0038] Clustering on the test tube surface Calculate the distance from each measurement point to the origin. d small,m : ; in,( x small,m ,y small,m ) represents the first cluster in the test tube surface cluster. m The coordinates of the measurement points This represents the total number of measurement points contained in the cluster on the test tube surface.

[0039] Calculate the mean distance and standard deviation : ; ; Remove measurement points that meet the following conditions (i.e., outlier measurement points): ; The retained measurement points constitute a pure test tube surface point set. P small : ; in, N small This represents the number of measurement points in the point set on the test tube surface.

[0040] Similarly, clustering of label surfaces Perform the same process to obtain a clean set of label surface points. P large .

[0041] S30. The improved bee colony algorithm is used to process the test tube surface point set and the label surface point set as follows: Figure 4 The optimal circle fitting under the concentric constraint shown is used to obtain the center coordinates and radius of the tube under test, and the diameter of the tube under test is calculated. The optimal circle fitting under the concentric constraint described above means that for the test tube surface point set and the label surface point set obtained in step S20, both share the same center point but correspond to different radii. The center coordinates are then found through an optimization algorithm. O ( c x , c y ), and the radius of the tube to be tested r 1 and label radius r 2. This minimizes the overall fitting error between the test tube surface point set and the label surface point set to their respective corresponding circles.

[0042] Step S30 includes: A10. Define the objective function and initialize the food source population and parameters; To achieve the optimal circle fitting described above, this embodiment constructs the following objective function: ; in, N small This indicates the number of measurement points in the point set on the test tube surface; d 1m The coordinates of the points on the test tube surface are ( x small,m , y small,m ) m Coordinates from each measurement point to the center of the circle O ( c x , c y Euclidean distance of ) ; N large This indicates the number of measurement points in the point set on the label surface; d 2n The coordinates of the points on the label surface are ( x large,n , y large,n ) n Coordinates from each measurement point to the center of the circle O ( c x , c y Euclidean distance of ) .

[0043] The smaller the objective function value, the better the fit. When the objective function value is zero, all points fall exactly on the corresponding circle.

[0044] The aforementioned food source population contains SN food sources, each of which is a four-dimensional variable. The first to fourth dimensions correspond to the x-coordinate of the circle center, the y-coordinate of the circle center, the radius of the test tube, and the radius of the label, respectively. The food source population contains the SN food sources. i The food source is recorded as x i = [ c x,i ,c y,i ,r 1,i ,r 2,i ] , in c x,i For the first i The x-coordinate of the center of the circle corresponding to each food source c y,i For the first i The vertical coordinate of the center of the circle corresponding to each food source r 1,i For the first i The radius of the test tube corresponding to each food source r 2,i For the first i The label radius corresponding to each food source.

[0045] When initializing the food source population, SN food sources can be randomly generated first, and radius constraint processing can be performed on each food source: if the radius of the test tube is greater than the label radius, the values ​​of the test tube radius and the label radius are swapped, thereby ensuring that all food sources satisfy the rule that the test tube radius is less than the label radius.

[0046] With the first i food source x i = [ c x,i ,c y,i ,r 1,i ,r 2,i For example, if r 1,i Greater than r 2,i Then swap( r 1,i ,r 2,i ); where swap( r 1,i ,r 2,i ) indicates exchange r1,i ,r 2,i The value. If r 1,i and r 2,i If they are equal, then generate a new random number. r 1,i or r 2,i until r 1,i and r 2,i If they are not equal, radius constraints are applied again; preferably, in the random generation... r 1,i or r 2,i At that time, the random generation can be further restricted. r 1,i or r 2,i The numerical range, r 1,i The numerical range is [ r 1,min , r 2,i ), r 2,i The numerical range of is ( r 1,i , r 2,max ],in, r 1,min This is the lower bound of the radius of the tube to be tested. r 2,max The upper bound of the label radius can be set in advance based on the test tube diameter and label thickness specifications. In this case, no radius constraint processing is required.

[0047] The initialization method adopted for the food source population is as follows: ; in, j The dimension representing the food source is D=4, since each food source is a four-dimensional variable with 4 dimensions. Indicates the first i The first food source Dimensional variable; specifically: first-dimensional variable ( j =1) represents the x-coordinate of the center of the circle. c x,i ; Second dimension variable ( j =2) represents the ordinate of the center of the circle. c y,i ; The third dimension variable ( j =3) represents the radius of the tube to be tested. r1,i ; 4th dimension variable ( j =4) represents the label radius r 2,i ; Represents a random number between [0, 1]; Indicates the first The lower bound of the dimension variable, i.e., the first dimension variable. j The minimum value in the range of values ​​for a dimensional variable; Indicates the first The upper bound of the dimension variable, i.e., the first... j The maximum value within the range of possible values ​​for a dimensional variable. , It can be preset according to the origin, test tube diameter specifications, and label thickness specifications.

[0048] After the food source population is initialized, the objective function value and fitness value corresponding to each food source are further calculated. i food source x i The objective function value is Fitness value F(x i ) , F(x i )= 1 / (1 + ).

[0049] In addition, this step also requires parameter initialization. In this embodiment, the parameters that need to be initialized include the number of food sources (SN) and the maximum number of iterations. Abandon threshold, error target ε Number of pauses =0, current iteration count t =0.

[0050] A20. Execute the hired bee phase and the observation bee phase in sequence, and update the food source and its corresponding number of stagnations; During the hired bee phase, each food source is given an opportunity to be improved. This phase ensures the diversity of food source populations by traversing all food sources.

[0051] During the observation phase, only selected food sources are given the opportunity to be improved, and the higher the fitness value of a food source, the more likely it is to be selected. This phase optimizes the food source population by concentrating search resources near high-quality food sources.

[0052] A30. Enter the scout bee phase, check the number of times each food source has stopped, initialize food sources whose number of stops exceeds the abandonment threshold according to the mixing strategy, and update the food source population; Each food source is associated with a stagnation counter, which records the number of consecutive times that food source has not been improved (stagnation count). In each iteration, if a food source is not replaced, its stagnation count is incremented by 1; if it is replaced, the stagnation count is reset to zero. During the scout bee phase, all food sources are traversed, and the stagnation count of each food source is checked. If the stagnation count of a food source exceeds a preset abandonment threshold, it indicates that the food source has not been improved for a long time and may have been trapped in a local optimum, unable to escape through conventional neighborhood search.

[0053] In specific implementation, for the first i food source , and the number of times it stagnates Compared with the preset abandonment threshold Limit Compare; if ≤ Limit This indicates that the first i food source It is still in an active state and has not yet fallen into a local optimum. No action is taken; this state is retained. i food source ;like This indicates that the first i food source The problem has remained unresolved for a long time and has fallen into a local optimum, requiring further improvement. i food source Perform initialization.

[0054] Preferably, a hybrid strategy is used when initializing food sources. Before this, the current optimal solution needs to be determined based on the updated food sources and the objective function. Specifically, after completing the hired bee and observation bee phases, each food source in the current food source population is traversed, and the objective function value of each food source is calculated according to the pre-constructed objective function. The smaller the objective function value, the closer the center coordinates, test tube radius, and label radius of the corresponding food source are to the true values. Among all food sources, the food source with the smallest objective function value is determined as the current optimal solution.

[0055] The hybrid strategy combines two initialization methods: a completely random initialization with a 50% probability; and an initialization of the food source with a 50% probability based on the current optimal solution by adding a small perturbation; where the small perturbation is achieved by setting the perturbation amplitude coefficient to 0.1.

[0056] In other words, the hybrid strategy combines two initialization methods, using random numbers to determine which one to use. In practice, random numbers are generated first. Then based on random numbers Choose the initialization method, when the first i food source x i When initialization requires a hybrid strategy:

[0057] in, Indicates the first i The first food source Dimensional variables; Indicates the first The lower bound of a dimensional variable; Indicates the first Upper bound of a dimensional variable; Represents a random number between [0, 1]; The current optimal solution is the th Dimensional variable; 0.1 is the disturbance amplitude coefficient; ( ub j - lb j ) is the first j The search range width for dimensional variables.

[0058] It can be seen that when random numbers When the value is less than 0.5, completely random initialization is used to introduce entirely new food sources and maintain population diversity. When the random number... When equal to or greater than 0.5, in the current optimal solution... Dimensional variables Add small perturbations nearby to generate new food sources. The perturbation amplitude coefficient of 0.1 controls the perturbation amplitude. (rand(0,1)-0.5) generates a random perturbation direction of [-0.5, 0.5] to avoid excessive deviation from the current optimal solution.

[0059] In this way, while maintaining the diversity of food source populations, existing valuable information is utilized for guidance. Food sources initialized through a hybrid strategy also need to undergo radius constraint processing, then their fitness values ​​are recalculated, and the stagnation counter is reset to zero. In this manner, the scout bee phase maintains population diversity, effectively avoids the algorithm getting trapped in local optima, and enhances global search capabilities.

[0060] After the hired bee phase and the observation bee phase, in the food source population, food sources that have stagnated more than the abandonment threshold are replaced by food sources that have been initialized through a mixing strategy. The resulting new food source population will serve as the basis for determining the iteration termination condition in step A40.

[0061] A40. Determine if the iteration termination condition has been met. If yes, terminate the iteration, output the center coordinates and radius of the test tube in the global optimal solution, and calculate the diameter of the test tube based on the radius as the final measurement result; otherwise, set the current iteration number to zero. Increase by 1 and return to step A20.

[0062] The iteration termination condition is: the current iteration number. Reaching the maximum number of iterations Or the global optimum is less than or equal to the error target. 。 The global optimum is determined based on the new food source population formed during the scout bee phase. Specifically, it iterates through each food source in this new population, calculating the objective function value for each source based on a pre-constructed objective function. The smaller the objective function value, the closer the center coordinates, test tube radius, and tag radius of that food source are to the true values. Among all food sources in this new population, the food source with the smallest objective function value is identified as the global optimum, and the objective function value corresponding to this global optimum is the global optimum value. .

[0063] If the current iteration number Reaching the maximum number of iterations ( (), or the current global optimum is less than or equal to the error target. ε ( ),in If the value is the global optimum, it means that the current iteration state meets the termination condition. At this point, the iteration terminates, and the coordinates of the center of the circle and the radius of the tube under test in the global optimum solution obtained from the last iteration update are output. The diameter of the tube under test is then calculated based on the radius of the tube under test as the final measurement result.

[0064] like t < T max and f best > ε If the objective function has not yet converged to sufficient accuracy and there are still iterations remaining, then the current iteration count should be... Increment by 1, and return to step A20 to continue the next round of population update phase (hired bee phase and observation bee phase). This dual termination condition design ensures that the process can end within a limited time while also ensuring that the output results meet the preset accuracy requirements, thus achieving an effective balance between computational efficiency and measurement accuracy.

[0065] In at least one of steps A10 to A30 above, the food sources are subjected to radius constraints. Preferably, the food sources are subjected to radius constraints in all steps A10 to A30, thereby ensuring that all food sources in the food source population always satisfy the condition that the radius of the test tube is smaller than the label radius during the update, effectively narrowing the search range and improving the convergence speed. At the same time, this design can prevent the objective function value from fluctuating drastically due to the generation of extreme invalid solutions during the iteration process, enhancing the stability of the algorithm, and allowing the final output global optimal solution to be used directly as the measurement result without additional correction.

[0066] Example 2 Based on Example 1, this example provides a method for measuring the diameter of a test tube, including steps S10 to S30. These steps are the same as those in Example 1 and will not be repeated here. Please also refer to... Figure 5 In this embodiment, the bee-hiring stage in step A20 of step S30 specifically includes the following steps: A21. Execute the hired bee phase. For each food source, generate hired food sources according to the adaptive step size formula, and calculate the fitness value of the hired food sources. Specifically, for the first i food source x i First, randomly select a number different from the first one. i food source x i The neighbor, for example, is the first food source x k At the same time, randomly select a dimension. This means that for the first... i food source x i Only modify the first one each time. j One dimension is the variable, while the other three dimensions remain unchanged. This strategy of updating dimension by dimension facilitates fine-grained local searches. In determining the neighbors (the first... k (food sources) and dimensions ( j After that, the food source for hiring is generated according to the adaptive step size formula. Hiring food sources Dimensional variables for: ; in, This is an adaptive step size factor. This represents the current iteration number. This represents the maximum number of iterations. food source x i The Dimensional variables; For the randomly selected first k The first food source Dimensional variables; It is a random number between [-1, 1].

[0067] It is evident that the adaptive step size factor decreases as the number of iterations increases. A larger step size in the early stages is beneficial for global exploration, while a smaller step size in the later stages is beneficial for local development.

[0068] food source for hire After applying radius constraints, calculate the fitness value of the hired food source. .

[0069] A22. Determine the source of the hired food. fitness value Is it greater than the first? i food source x i fitness value F(x i ); If yes, proceed to step A23; if no, proceed to step A24. A23, the first i food source Updated to the aforementioned food source for hire ; That is, if Then use hired food sources Replace the first i food source .

[0070] A24, the first i food source The corresponding number of pauses increases by 1.

[0071] That is, if F(v i ) ≤ F(x i ), Then retain the first i food source Update # i food source Corresponding number of stagnations , making the first i food source The corresponding stagnation count increases by 1; the stagnation count represents the number of times the food source has not been improved. When a food source cannot be improved for a long time (i.e., the stagnation count exceeds the abandonment threshold), it indicates that it may be trapped in a local optimum and needs to be initialized in the subsequent scout bee stage in order to escape the local optimum and maintain the diversity of the population.

[0072] Example 3 Based on Example 1 or 2, this example provides a method for measuring the diameter of a test tube, including steps S10 to S30. These steps are the same as those in Example 1 or 2, and will not be repeated here. Please also refer to... Figure 6 In this embodiment, the observation bee stage in step A20 of step S30 specifically includes the following steps: A25. For each observation bee, select a food source according to probability, perform a neighborhood search in the vicinity of the selected food source to generate an observation food source, and calculate the fitness value of the observation food source. The probability mentioned above refers to the probability that the food source is selected. This probability is calculated based on the fitness value of each food source. The higher the fitness value of a food source, the greater its probability.

[0073] No. i food source The probability of being selected by the observed bee for: ; in, F(x i ) For the first i food source fitness value, F(x m ) For the first m food source x m The fitness value; SN is the total number of food sources in the food source population; m This is the index variable used to iterate through all food sources when summing.

[0074] For each observation bee (total) Only one food source is selected as the development target based on probability. When the g-th food source... x g Once selected, the observation bee performs a neighborhood search in the vicinity of the selected food source to generate the observed food source. w g .

[0075] The aforementioned neighborhood search can randomly select a neighbor that is different from the selected food source. h (h≠g) food source xh One dimension to be optimized j For the selected food source x g Only modify the first one each time. j By keeping one dimension constant (the other three dimensions unchanged), the corresponding observed food source can be obtained. w g .

[0076] In determining neighbors (the first) h (food sources) and dimensions to be optimized ( j After that, the first observation of the food source is generated according to the adaptive step size formula. Dimensional variables w gj : ; in, This is an adaptive step size factor. This represents the current iteration number. This represents the maximum number of iterations. x gj food source x g The Dimensional variables; x hj For the first h The first food source Dimensional variables; It is a random number between [-1, 1].

[0077] For observing food sources w g After applying radius constraints, the observed food source is calculated. w g fitness value F ( w g ).

[0078] A26. Determine the fitness value of the observed food source. F ( w g Is the fitness value greater than that of the selected food source? F ( x g If yes, proceed to step A27; otherwise, proceed to step A28. A27. Selected food sources x g Updated to observe food sources w g ; A28. Selected food sources xg The corresponding number of pauses increases by 1.

[0079] If we observe the fitness value of the food source F ( w g The fitness value is greater than that of the selected food source. F ( x g If so, it indicates that the food source was being observed. w g Superior to the selected food source x g At this point, proceed to step A27, and select the food source. x g Update; observe the fitness value of the food source. F ( w g The fitness value of the selected food source is less than or equal to its fitness value. F ( x g If the selected food source is indicated, then the food source is selected. x g Superior to observing food sources w g No need to select food sources x g To update, proceed to step A28 and select the food source. x g The corresponding number of pauses increases by 1.

[0080] This greedy selection mechanism ensures that only truly superior observed food sources can replace the selected food sources, guaranteeing a continuous improvement in population quality.

[0081] Example 4 This embodiment provides a test tube diameter measurement system, including a first sensor and a second sensor symmetrically arranged on both sides of the test tube, and a computer device connected to the first sensor and the second sensor.

[0082] Please refer to the following at the same time Figure 7 , Figure 7 This is a schematic diagram of the structure of a computer device 62 provided in an embodiment of the present invention. Figure 7 A block diagram of an exemplary computer device 62 suitable for implementing embodiments of the present invention is shown. Figure 7 The computer device 62 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present invention.

[0083] like Figure 7As shown, computer device 62 is represented in the form of a general-purpose computing device. Computer device 62 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. Electronic devices may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0084] The components of computer device 62 may include, but are not limited to: one or more processors or processing units 66, system memory 78, and bus 68 connecting different system components (including system memory 78 and processing unit 66).

[0085] Bus 68 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. Examples of these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.

[0086] Computer device 62 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by computer device 62, including volatile and non-volatile media, removable and non-removable media.

[0087] System memory 78 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 80 and / or cache memory 82. Computer device 62 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 84 may be used to read and write non-removable, non-volatile magnetic media (…). Figure 7 Not shown; usually referred to as a "hard drive"). Although Figure 7Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 68 via one or more data media interfaces. System memory 78 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of any of embodiments 1 to 3 of the present invention.

[0088] A program / utility 90 having a set (at least one) of program modules 92 may be stored, for example, in system memory 78. Such program modules 92 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. The program modules 92 typically perform the functions and / or methods of any of the embodiments 1 to 3 described in this invention.

[0089] Computer device 62 can also communicate with one or more external devices 64 (e.g., keyboard, pointing device, display 74, etc.), and with one or more devices that enable a user to interact with computer device 62, and / or with any device that enables computer device 62 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 72. Furthermore, computer device 62 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 70. As shown, network adapter 70 communicates with other modules of computer device 62 via bus 68. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with computer device 62, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0090] The processing unit 66 executes various functional applications and data processing by running programs stored in the system memory 78, such as implementing the test tube diameter measurement method provided in any of the embodiments 1 to 3 of the present invention.

[0091] This invention also provides a non-transitory computer-readable storage medium storing computer instructions, on which a computer program is stored, wherein when the program is executed by a processor, it implements the test tube diameter measurement method provided in any of embodiments 1 to 3 of this invention.

[0092] The computer storage medium of this invention can be any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. More specific examples (a non-exhaustive list) of computer-readable storage media include: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0093] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.

[0094] The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof. The computer program code for performing the operations of this invention can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages—such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer can be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0095] This invention also provides a computer program product, including a computer program that, when executed by a processor, implements a method for measuring the diameter of a test tube according to any one of embodiments 1 to 3.

[0096] It should be understood that the various forms of processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this invention disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this invention can be achieved, and this is not limited herein.

[0097] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A method of measuring the diameter of a test tube, characterized by, Including the following steps: S10. Obtain the point cloud data of the cross-sectional profile of the tube to be tested; S20. The point cloud data is split into a test tube surface point set and a label surface point set; S30. Using the improved bee colony algorithm, perform optimal circle fitting under concentric constraints on the point set on the test tube surface and the point set on the label surface to obtain the center coordinates and radius of the tube to be tested, and calculate the diameter of the tube to be tested. Step S30 includes: A10. Define the objective function and initialize the food source population and parameters. The food source in the food source population is a four-dimensional variable, and the first to fourth dimensions correspond to the horizontal coordinate of the center of the circle, the vertical coordinate of the center of the circle, the radius of the tube to be tested, and the radius of the label, respectively. A20. Execute the hired bee phase and the observation bee phase in sequence, and update the food source and its corresponding number of stagnations; A30. Enter the scout bee phase, check the number of times each food source has stopped, initialize food sources whose number of stops exceeds the abandonment threshold according to the mixing strategy, and update the food source population; A40. Determine if the iteration termination condition has been met. If yes, terminate the iteration; otherwise, increment the current iteration count by 1 and return to step A20.

2. The method for measuring the diameter of a test tube according to claim 1, characterized in that, In at least one step from A10 to A30, the food source is subjected to radius constraint processing: if the radius of the tube to be tested is greater than the radius of the label, the values ​​of the radius of the tube to be tested and the radius of the label are exchanged.

3. The method for measuring the diameter of a test tube according to claim 1, characterized in that, Step A10 includes calculating the first i food source x i fitness value F(x i ) ; Step A20 includes: A21. Execute the hired bee phase, for the aforementioned... i food source x i Generate hired food sources according to an adaptive step size formula, and calculate the fitness value of the hired food sources; A22. Determine whether the fitness value of the hired food source is greater than that of the first... i food source x i fitness value F(x i ); If yes, proceed to step A23; if no, proceed to step A24. A23, the first i food source Update to the aforementioned food source for employment; A24, the first i food source The corresponding number of pauses increases by 1.

4. The method for measuring the diameter of a test tube according to claim 3, characterized in that, The adaptive step size formula is: ; in, This is an adaptive step size factor. This represents the current iteration number. This represents the maximum number of iterations. For the first of the hired food sources Dimensional variables; For the first i food source The Dimensional variables; For the randomly selected first k The first food source Dimensional variables; It is a random number between [-1, 1].

5. The method for measuring the diameter of a test tube according to claim 1, characterized in that, Step A20 further includes: A25. For each observation bee, select a food source according to probability, perform a neighborhood search in the vicinity of the selected food source to generate an observation food source, and calculate the fitness value of the observation food source. A26. Determine whether the fitness value of the observed food source is greater than the fitness value of the selected food source. If yes, proceed to step A27; otherwise, proceed to step A28. A27. Update the selected food source to the observed food source; A28. Increase the number of pauses corresponding to the selected food source by 1.

6. The method for measuring the diameter of a test tube according to claim 1, characterized in that, Step A30 further includes: determining the current optimal solution based on the updated food source and according to the objective function; The hybrid strategy is as follows: initialize completely randomly with a 50% probability, and perturb based on the current optimal solution with a 50% probability. in, Indicates the first i The first food source Dimensional variables; Indicates the first The lower bound of a dimensional variable; Indicates the first Upper bound of a dimensional variable; Represents a random number between [0, 1]; The current optimal solution is the th Dimensional variables.

7. The method for measuring the diameter of a test tube according to claim 1, characterized in that, Step S10 includes: acquiring point cloud data of the cross-sectional profile of the tube under test using a dual-sensor symmetrical arrangement.

8. The method for measuring the diameter of a test tube according to claim 1, characterized in that, Step S20 includes: S21. Calculate the distance from each measurement point in the point cloud data to the origin. ; S22, at the distance Using the K-means algorithm as a feature, the point cloud data is clustered to obtain test tube surface clusters and label surface clusters; S23. Using the 3σ criterion, outlier measurement points are removed from the clusters on the test tube surface to obtain the test tube surface point set; using the 3σ criterion, outlier measurement points are removed from the clusters on the label surface to obtain the label surface point set.

9. A test tube diameter measuring system, characterized in that, The test tube includes a first sensor and a second sensor symmetrically arranged on both sides of the tube to be tested, and a computer device connected to the first sensor and the second sensor; the computer device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the test tube diameter measurement method according to any one of claims 1 to 8.

10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to execute the test tube diameter measurement method according to any one of claims 1 to 8.