Tobacco leaf thickness measuring method, device and equipment and storage medium
By using the mean offset algorithm based on the Gaussian kernel function to determine the target line slope in the tobacco leaf thickness online detection system, and using the minimizing distance sum of square rules to determine the fitted line, the problem of poor robustness of the linear fitting algorithm in the prior art is solved, and higher measurement accuracy and calculation efficiency are achieved.
Patent Information
- Application Number
- CN202411848601.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-03-11
AI Technical Summary
In the prior art, in the tobacco leaf thickness online detection system based on modulation line laser, the linear fitting algorithm has poor robustness and is easily affected by noise points, resulting in low measurement accuracy.
The linear fitting method is adopted based on the sample data set of the to-select straight line slope sample and the preset straight line slope determination algorithm. The target straight line slope is determined through the mean offset algorithm of the Gaussian kernel function, and the fitted straight line is determined using the minimizing distance sum of square rules to improve measurement accuracy.
It improves the accuracy and calculation efficiency of tobacco leaf thickness measurement, enhances the anti-interference ability to noise points, and significantly improves the robustness of the linear fitting algorithm.
Smart Images

Figure CN119594871A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of tobacco leaf physical index measurement, and in particular to a tobacco leaf thickness measurement method, device, equipment and storage medium. Background Art
[0002] At present, in the online detection system of reconstituted tobacco leaf thickness based on modulated line laser, the distance between the modulated laser stripes is measured online in real time, and then the thickness of the tobacco leaf is calculated through the angle relationship between the laser and the surface of the object. However, the least squares method is used to determine the position of the straight line by minimizing the sum of the squares of the distances from the data points to the straight line. This method is applicable to linear regression problems, that is, it is applicable when there is a linear relationship between the independent variable and the dependent variable, but the robustness (anti-gross error) is poor, and the data errors at both ends of the straight line have a great influence on the fitting slope. If the Hough transform method is used for online fitting, the calculation complexity is high, the robustness is poor, and it is easily affected by noise points.
[0003] From the above, it can be seen that how to improve the accuracy of the straight line fitting algorithm is an urgent problem to be solved. Summary of the invention
[0004] In view of this, the purpose of the present invention is to provide a tobacco leaf thickness measurement method, device, equipment and storage medium, which can accurately measure the thickness of the tobacco leaf to be measured based on the straight line slope sample data set to be selected and the straight line slope determination algorithm to be preset, thereby improving the calculation efficiency and measurement accuracy. The specific scheme is as follows:
[0005] In a first aspect, the present application provides a method for measuring tobacco leaf thickness, comprising:
[0006] Determine the corresponding original data points based on the center points of each laser stripe on the laser stripe formed when the line laser is projected onto the target tobacco leaf to be tested, and determine the sample data set of the slope of the straight line to be selected based on the corresponding coordinate values of any two data points in the original data points on the preset coordinate axis;
[0007] Determine the initial value of the slope sample centroid corresponding to all the slope candidate data in the candidate straight line slope sample data set, and determine the target straight line slope corresponding to the laser stripe based on the initial value and a preset straight line slope determination algorithm; the preset straight line slope determination algorithm is a mean shift algorithm determined based on a Gaussian kernel function;
[0008] The target straight line slope and a preset rule for minimizing the sum of squared distances are used to determine a fitting straight line corresponding to the laser stripes, so as to determine the thickness of the target tobacco leaf to be measured based on the fitting straight line.
[0009] Optionally, the determining of the sample data set of slopes of the straight line to be selected based on the coordinate values corresponding to any two data points in the original data points on a preset coordinate axis includes:
[0010] Selecting target data points from the original data points using a preset data selection method; the target data points are any two data points among the original data points that can form a straight line;
[0011] The slope candidate data is determined based on a preset slope formula and the corresponding coordinate value of the target data point on the preset coordinate axis, and a corresponding candidate straight line slope sample data set is constructed based on the slope candidate data.
[0012] Optionally, the determining of the initial value of the slope sample centroid corresponding to all the slope candidate data in the candidate straight line slope sample data set includes:
[0013] The preset mean algorithm is used to determine the initial value of the slope sample centroid corresponding to all the slope candidate data in the candidate straight line slope sample data set.
[0014] Optionally, the determining the target straight line slope corresponding to the laser stripe based on the initial value and a preset straight line slope determination algorithm includes:
[0015] Determine a preset straight line slope determination algorithm based on the mean shift algorithm and the Gaussian kernel function algorithm, and after determining the initial value as the current straight line slope, substitute the current straight line slope and all the slope candidate data in the candidate straight line slope sample data set into the preset straight line slope determination algorithm to obtain the calculated straight line slope;
[0016] Determine whether the difference between the calculated straight line slope and the current straight line slope is less than a preset threshold;
[0017] If the difference is less than a preset threshold, the calculated straight line slope is determined as the target straight line slope corresponding to the laser stripe.
[0018] Optionally, after determining whether the difference between the calculated straight line slope and the current straight line slope is less than a preset threshold, the method further includes:
[0019] If the difference is not less than a preset threshold, the kernel function width in the preset straight line slope determination algorithm is updated based on the calculated straight line slope to obtain a new preset straight line slope determination algorithm, and the calculated straight line slope is determined as the new current straight line slope, and then jump to the step of substituting the current straight line slope and all slope candidate data in the candidate straight line slope sample data set into the preset straight line slope determination algorithm to obtain the calculated straight line slope.
[0020] Optionally, the updating of the kernel function width in the preset straight line slope determination algorithm based on the calculated straight line slope to obtain a new preset straight line slope determination algorithm, and determining the calculated straight line slope as a new current straight line slope includes:
[0021] Determine the calculated straight line slope as a new current straight line slope, and determine a target sample density based on the distance between all slope candidate data in the candidate straight line slope sample data set and the current straight line slope;
[0022] The target slope candidate data is determined based on the target sample density to obtain a new candidate straight line slope sample data set, and the kernel function width in the preset straight line slope determination algorithm is updated based on the number of the target slope candidate data to obtain a new preset straight line slope determination algorithm.
[0023] Optionally, the determining the fitting straight line corresponding to the laser stripe by using the target straight line slope and a preset rule of minimizing the sum of squared distances includes:
[0024] The target straight line intercept corresponding to the laser stripe is determined by using the target straight line slope and a preset rule of minimizing the sum of squares of distances, and the fitting straight line corresponding to the laser stripe is determined based on the target straight line intercept and the target straight line slope.
[0025] In a second aspect, the present application provides a tobacco leaf thickness measuring device, comprising:
[0026] The original data point determination module is used to determine the corresponding original data points based on the center points of the laser stripes formed when the line laser is projected onto the target tobacco leaf to be tested, and determine the sample data set of the slope of the straight line to be selected based on the corresponding coordinate values of any two data points in the original data points on the preset coordinate axis;
[0027] A target slope determination module, used to determine the initial value of the slope sample centroid corresponding to all the slope candidate data in the candidate straight line slope sample data set, and determine the target straight line slope corresponding to the laser stripe based on the initial value and a preset straight line slope determination algorithm; the preset straight line slope determination algorithm is a vector form of a Gaussian kernel function;
[0028] The fitting straight line determination module is used to determine the fitting straight line corresponding to the laser stripe by using the target straight line slope and a preset rule of minimizing the sum of squared distances, so as to determine the thickness of the target tobacco leaf to be tested based on the fitting straight line.
[0029] In a third aspect, the present application provides an electronic device, including:
[0030] Memory, used to store computer programs;
[0031] The processor is used to execute the computer program to implement the aforementioned tobacco leaf thickness measurement method.
[0032] In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program, wherein the computer program implements the aforementioned tobacco leaf thickness measurement method when executed by a processor.
[0033] The present application first determines the corresponding original data points based on the center points of each laser stripe on the laser stripe formed when the line laser is projected onto the target tobacco leaf to be tested, and determines the sample data set of the slope of the straight line to be selected based on the coordinate values corresponding to any two data points in the original data points on the preset coordinate axis; determines the initial value of the slope sample centroid corresponding to all the slope candidate data in the sample data set of the slope of the straight line to be selected, and determines the target straight line slope corresponding to the laser stripe based on the initial value and a preset straight line slope determination algorithm; the preset straight line slope determination algorithm is a vector form of a Gaussian kernel function; uses the target straight line slope and a preset rule to minimize the sum of squares of distances to determine the target straight line intercept corresponding to the laser stripe, and determines the fitting straight line corresponding to the laser stripe based on the target straight line intercept and the target straight line slope, so as to determine the thickness of the target tobacco leaf to be tested based on the fitting straight line. As can be seen from the above, the present application determines the center points of each laser stripe on the laser stripes formed when the acquired line laser is projected onto the target tobacco leaf to be tested as the original data point, and determines the corresponding slope selected data based on any two data points in the original data point, so as to determine the initial value of the corresponding slope sample centroid based on all the slope selected data in the selected straight line slope sample data set, and then determine the target straight line slope using the preset straight line slope determination algorithm and the initial value, and finally determine the thickness of the target tobacco leaf to be tested based on the fitting straight line corresponding to the laser stripes obtained based on the target straight line slope and the preset rule of minimizing the sum of squared distances. In this way, the straight line fitting method constructed based on the selected straight line slope sample data set and the preset straight line slope determination algorithm can accurately measure the thickness of the tobacco leaf to be tested, thereby improving the efficiency of calculation and the accuracy of measurement. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0035] Figure 1 This is a flow chart of a tobacco leaf thickness measurement method disclosed in this application;
[0036] Figure 2A schematic diagram of the iterative process of a straight line fitting method provided in this application;
[0037] Figure 3 A schematic diagram of the iterative process of a straight line fitting method provided in this application;
[0038] Figure 4 A schematic diagram of the iterative process of a straight line fitting method provided in this application;
[0039] Figure 5 A schematic diagram of the iterative process of a straight line fitting method provided in this application;
[0040] Figure 6 This is a schematic diagram of the structure of a tobacco leaf thickness measuring device disclosed in this application;
[0041] Figure 7 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION
[0042] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0043] In the online detection system of reconstituted tobacco leaf thickness based on modulated line laser, the distance between the modulated laser stripes is measured online in real time, and then the thickness of the tobacco leaf is calculated through the angular relationship between the laser and the surface of the object. However, the least squares method is used to determine the position of the straight line by minimizing the sum of the squares of the distances from the data points to the straight line. This method is suitable for use when there is a linear relationship between the independent variable and the dependent variable, but its robustness is poor; if the Hough transform method is used for online fitting, the calculation complexity is high, the robustness is poor, and it is easily affected by noise points. To this end, the present application provides a tobacco leaf thickness measurement method, which can accurately measure the thickness of the tobacco leaf to be measured based on the straight line fitting method constructed by the selected straight line slope sample data set and the preset straight line slope determination algorithm, thereby improving the efficiency of calculation and the accuracy of measurement.
[0044] See also Figure 1 As shown, an embodiment of the present invention discloses a physical indicator measurement method, including:
[0045] Step S11, determining the corresponding original data points based on the center points of the laser stripes formed when the line laser is projected onto the target tobacco leaf to be tested, and determining the sample data set of the slope of the straight line to be selected based on the corresponding coordinate values of any two data points among the original data points on the preset coordinate axis.
[0046] In this embodiment, the center points of each laser stripe on the laser stripe formed when the line laser emitted by the industrial line laser and the laser line marking projector is projected onto the target tobacco leaf to be tested are first obtained, and the center points of each laser stripe are read in to obtain the coordinates of all the original data points, and then the corresponding sample data set of the slope of the straight line to be selected is constructed based on the corresponding coordinate values of any two data points in the original data on the preset coordinate axis. Specifically, the sample data set of the slope of the straight line to be selected based on the corresponding coordinate values of any two data points in the original data points on the preset coordinate axis includes: selecting the target data point from the original data points using a preset data selection method; the target data point is any two data points in the original data points that can form a straight line; determining the slope data to be selected based on the preset slope formula and the corresponding coordinate values of the target data point on the preset coordinate axis, and constructing the corresponding sample data set of the slope of the straight line to be selected based on the slope data to be selected.
[0047] It can be understood that after obtaining the coordinates of all the original data points, the permutation and combination ratio is used to obtain any two data points that may constitute a straight line, and then the slope formula is used to calculate the slopes of all possible straight lines. In a specific implementation, the coordinates of the two points are set to and , then the slope is Note that when x1=x2, the slope can be set to a large number, such as 10. 8 , which is equivalent to a vertical line. After traversing all the original data points, the corresponding slope candidate data is obtained. , the slope candidate data is stored in a data set P, and this set is called the candidate straight line slope sample data set.
[0048] Step S12, determining the initial value of the slope sample centroid corresponding to all the slope candidate data in the candidate straight line slope sample data set, and determining the target straight line slope corresponding to the laser stripe based on the initial value and a preset straight line slope determination algorithm; the preset straight line slope determination algorithm is a mean shift algorithm determined based on a Gaussian kernel function.
[0049] In this embodiment, the original data points in the selected straight line slope sample data set have obvious features and many commonalities, and there are no data points of different types. Therefore, the initial value of the slope sample centroid is determined by a preset mean algorithm. Specifically, the initial value of the slope sample centroid corresponding to all the slope selected data in the selected straight line slope sample data set includes: using a preset mean algorithm to determine the initial value of the slope sample centroid corresponding to all the slope selected data in the selected straight line slope sample data set. The preset mean algorithm is as follows:
[0050] ;
[0051] It can be understood that the initial value of the centroid of the slope sample is determined according to the preset mean algorithm, and it is believed that the contribution (weight) of all samples is the same, but in fact it is not. For some noise points, their weights should be set close to 0, so the mean-shift (i.e. mean shift) clustering algorithm with the introduction of kernel function is used. The introduction of kernel function can make the contribution of the drift amount to the mean shift vector different as the distance between the sample and the drifted point is different. The Gaussian kernel function maps each sample point to an infinite-dimensional feature space, so that the originally linearly inseparable data can be linearly separable. By using the Gaussian kernel function, linearly inseparable data can be mapped to a high-dimensional space, making it linearly separable in the high-dimensional space. In the created sample data of the slope of the selected straight line, most of the data points will appear in the neighborhood of the true slope, with fewer features, and because of the efficiency of constructing the sample data, it will not generate a lot of data. Therefore, the Gaussian kernel function is chosen here. The formula of the Gaussian kernel function is as follows:
[0052] ;
[0053] in, is the width parameter of the kernel function, Represents the distance between the data point X1 and the data point X2 corresponding to the slope sample. In a specific implementation, if the distance between the data point X1 and the data point X2 is less than a preset threshold, it indicates that the data points are very close and similar, and the result is 1, otherwise it is 0.
[0054] In this embodiment, a mean-shift vector form of a Gaussian kernel function may be introduced, and the mean-shift vector form is as follows:
[0055] ;
[0056] in, is a unit Gaussian kernel function with bandwidth b, k iis all the slope candidate data in the sample data set of the slope of the selected straight line, and k is the initial value of the centroid of the slope sample. The initial value is taken as the first best slope, that is, the current straight line slope, and the calculated straight line slope is determined based on the current straight line slope and all the slope candidate data. Specifically, the target straight line slope corresponding to the laser stripe is determined based on the initial value and the preset straight line slope determination algorithm, including: determining the preset straight line slope determination algorithm based on the mean shift algorithm and the Gaussian kernel function algorithm, and after the initial value is determined as the current straight line slope, the current straight line slope and all the slope candidate data in the sample data set of the slope of the selected straight line are substituted into the preset straight line slope determination algorithm to obtain the calculated straight line slope; judging whether the difference between the calculated straight line slope and the current straight line slope is less than a preset threshold; if the difference is less than the preset threshold, the calculated straight line slope is determined as the target straight line slope corresponding to the laser stripe.
[0057] It should be noted that when the difference between the calculated straight line slope and the current straight line slope determined by the preset straight line slope determination algorithm is less than a preset threshold or reaches a preset number of iterations, the iteration is terminated, and the calculated straight line slope obtained at this time is determined as the target straight line slope corresponding to the laser stripe; if the difference between the calculated straight line slope and the current straight line slope is not less than the preset threshold, a new preset straight line slope determination algorithm is determined based on the calculated straight line slope. Specifically, after determining whether the difference between the calculated straight line slope and the current straight line slope is less than the preset threshold, it also includes: if the difference is not less than the preset threshold, the kernel function width in the preset straight line slope determination algorithm is updated based on the calculated straight line slope to obtain a new preset straight line slope determination algorithm, and the calculated straight line slope is determined as the new current straight line slope, and then jumps to the step of substituting the current straight line slope and all the slope candidate data in the candidate straight line slope sample data set into the preset straight line slope determination algorithm to obtain the calculated straight line slope. It should be noted that the preset number of iterations can be adjusted according to actual needs and is not specifically limited here.
[0058] Further, the current straight line slope is substituted into the preset straight line slope determination algorithm for iteration, and each iteration can obtain a calculated straight line slope, and the calculated straight line slope is centered, and different sample densities are selected according to the different distances from the calculated straight line slope, and then the kernel function width is automatically determined according to the corresponding slope candidate data to obtain a new preset straight line slope determination algorithm. Specifically, the kernel function width in the preset straight line slope determination algorithm is updated based on the calculated straight line slope to obtain a new preset straight line slope determination algorithm, and the calculated straight line slope is determined as the new current straight line slope, including: determining the calculated straight line slope as the new current straight line slope, and determining the target sample density based on the distance between all the slope candidate data in the candidate straight line slope sample data set and the current straight line slope; determining the target slope candidate data based on the target sample density to obtain a new candidate straight line slope sample data set, and updating the kernel function width in the preset straight line slope determination algorithm based on the number of the target slope candidate data to obtain a new preset straight line slope determination algorithm.
[0059] It can be understood that the target sample density is determined based on the distance between all the slope candidate data in the candidate straight line slope sample data set and the current straight line slope, and the sample data in the candidate straight line slope sample data set that are out of the cluster are deleted to obtain a new candidate straight line slope sample data set, and the new kernel function width is determined based on the number of the target slope candidate data in the candidate straight line slope sample data set to obtain the new preset straight line slope determination algorithm.
[0060] Step S13, using the target straight line slope and a preset rule of minimizing the sum of squared distances to determine a fitting straight line corresponding to the laser stripes, so as to determine the thickness of the target tobacco leaf to be measured based on the fitting straight line.
[0061] In this embodiment, the target straight line intercept corresponding to the laser stripe is determined by minimizing the sum of squares of the distances from the original data point to the straight line using the data coordinates corresponding to the target straight line slope, and then completing the fitting straight line operation corresponding to the laser stripe based on the target straight line intercept and the target straight line slope. Specifically, determining the fitting straight line corresponding to the laser stripe using the target straight line slope and a preset rule of minimizing the sum of squares of distances includes: determining the target straight line intercept corresponding to the laser stripe using the target straight line slope and a preset rule of minimizing the sum of squares of distances, and determining the fitting straight line corresponding to the laser stripe based on the target straight line intercept and the target straight line slope.
[0062] It can be understood that the corresponding straight line family is determined based on the target straight line slope, and the target straight line intercept corresponding to the laser stripe in the straight line family is determined using the preset rule of minimizing the sum of squared distances, and then the fitting straight line corresponding to the laser stripe is determined based on the target straight line intercept and the target straight line slope; wherein the straight line family includes multiple straight lines with the same target straight line slope but different intercepts. After the corresponding straight line family is determined based on the target straight line slope, the intercept of the target straight line corresponding to the laser stripe in the straight line family, i.e., the target straight line intercept, is determined by minimizing the sum of squared distances from data points to the straight line, and then the fitting straight line corresponding to the laser stripe is determined based on the target straight line intercept and the target straight line slope, and then the thickness of the target tobacco leaf to be measured is determined using the distance between the two fitting straight lines.
[0063] In a specific embodiment, the iterative process of the straight line fitting method is as follows Figures 2 to 5 As shown, the slope of the standard straight line is 1 and the intercept is 100. Figure 2 In the iteration process shown, the target straight line slope is 0.972, and the target straight line intercept is 103.92; Figure 3 In the iteration process shown, the target straight line slope is 0.989, and the target straight line intercept is 98.88; Figure 4 In the iteration process shown, the target straight line slope is 0.998, and the target straight line intercept is 99.96; Figure 5 In the iteration process shown, the target straight line slope is 1.000, and the target straight line intercept is 99.99. It can be seen that as the iteration process proceeds, the slope and intercept of the straight line gradually approach the true value, and after the iteration is completed, the target straight line slope is very close to the true value.
[0064] It can be understood that the fitting straight line corresponding to the laser stripe can be calculated to obtain the straight line spacing between two adjacent fitting straight lines, and the straight line spacing is the stripe spacing between different laser stripes. By combining the angle relationship between the line laser and the surface of the target tobacco leaf to be measured and the stripe distance, the thickness of the target tobacco leaf to be measured can be determined by laser triangulation technology; the laser triangulation technology uses a laser beam to illuminate the surface of the target tobacco leaf to be measured, and the thickness of the target tobacco leaf to be measured is also determined by measuring the position change of the reflected light. As can be seen from the above, the present application determines the center point of each laser stripe on the laser stripe formed when the acquired line laser is projected onto the target tobacco leaf to be measured as the original data point, and determines the corresponding slope candidate data based on any two data points in the original data points, so as to determine the initial value of the corresponding slope sample centroid based on all the slope candidate data in the candidate straight line slope sample data set, and then determine the target straight line slope using a preset straight line slope determination algorithm and the initial value, and finally determine the thickness of the target tobacco leaf to be measured based on the target straight line slope and the fitting straight line corresponding to the laser stripe obtained by the least squares method. In this way, the straight line fitting method constructed based on the sample data set of the selected straight line slope and the preset straight line slope determination algorithm can accurately measure the thickness of the tobacco leaf to be measured, thereby improving the calculation efficiency and measurement accuracy.
[0065] Accordingly, see Figure 6 As shown, the present application also provides a tobacco leaf thickness measuring device, comprising:
[0066] The original data point determination module 11 is used to determine the corresponding original data points based on the center points of the laser stripes formed when the line laser is projected onto the target tobacco leaf to be tested, and determine the sample data set of the slope of the straight line to be selected based on the corresponding coordinate values of any two data points in the original data points on the preset coordinate axis;
[0067] The target slope determination module 12 is used to determine the initial value of the slope sample centroid corresponding to all the slope candidate data in the candidate straight line slope sample data set, and determine the target straight line slope corresponding to the laser stripe based on the initial value and a preset straight line slope determination algorithm; the preset straight line slope determination algorithm is a vector form of a Gaussian kernel function;
[0068] The fitting straight line determination module 13 is used to determine the fitting straight line corresponding to the laser stripe by using the target straight line slope and a preset rule of minimizing the sum of squared distances, so as to determine the thickness of the target tobacco leaf to be measured based on the fitting straight line.
[0069] As can be seen from the above, the present application determines the center points of each laser stripe on the laser stripes formed when the acquired line laser is projected onto the target tobacco leaf to be tested as the original data point, and determines the corresponding slope selected data based on any two data points in the original data point, so as to determine the initial value of the corresponding slope sample centroid based on all the slope selected data in the selected straight line slope sample data set, and then determine the target straight line slope using the preset straight line slope determination algorithm and the initial value, and finally determine the thickness of the target tobacco leaf to be tested based on the target straight line slope and the fitting straight line corresponding to the laser stripes obtained by the least squares method. In this way, the straight line fitting method constructed based on the selected straight line slope sample data set and the preset straight line slope determination algorithm can accurately measure the thickness of the tobacco leaf to be tested, thereby improving the efficiency of calculation and the accuracy of measurement.
[0070] In some specific implementations, the original data point determination module 11 may specifically include:
[0071] A target data point determination unit, used to select a target data point from the original data points using a preset data selection method; the target data point is any two data points that can form a straight line among the original data points;
[0072] The module for determining the data to be selected determines the slope data to be selected based on a preset slope formula and the corresponding coordinate values of the target data point on the preset coordinate axis, and constructs a corresponding sample data set of slope of the straight line to be selected based on the slope data to be selected.
[0073] In some specific implementations, the target slope determination module 12 may specifically include:
[0074] The initial value determination unit is used to determine the initial value of the slope sample centroid corresponding to all the slope candidate data in the candidate straight line slope sample data set by using a preset mean algorithm.
[0075] In some specific implementations, the target slope determination module 12 may specifically include:
[0076] A calculated slope determination unit is used to determine a preset straight line slope determination algorithm based on the mean shift algorithm and the Gaussian kernel function algorithm, and after determining the initial value as the current straight line slope, substitute the current straight line slope and all the slope candidate data in the candidate straight line slope sample data set into the preset straight line slope determination algorithm to obtain the calculated straight line slope;
[0077] A conditional judgment unit, used to judge whether the difference between the calculated straight line slope and the current straight line slope is less than a preset threshold;
[0078] The target slope determination unit is used to determine the calculated straight line slope as the target straight line slope corresponding to the laser stripe if the difference is less than a preset threshold.
[0079] In some specific embodiments, the tobacco leaf thickness measuring device may further include:
[0080] A kernel function width updating unit is used to update the kernel function width in the preset straight line slope determination algorithm based on the calculated straight line slope to obtain a new preset straight line slope determination algorithm if the difference is not less than a preset threshold value, and determine the calculated straight line slope as the new current straight line slope, and then jump to the step of substituting the current straight line slope and all slope candidate data in the candidate straight line slope sample data set into the preset straight line slope determination algorithm to obtain the calculated straight line slope.
[0081] In some specific implementations, the target slope determination module 12 may specifically include:
[0082] a target density determination unit, configured to determine the calculated straight line slope as a new current straight line slope, and determine a target sample density based on the distance between all the slope candidate data in the candidate straight line slope sample data set and the current straight line slope;
[0083] A new algorithm determination unit is used to determine the target slope candidate data based on the target sample density to obtain a new candidate straight line slope sample data set, and to update the kernel function width in the preset straight line slope determination algorithm based on the number of the target slope candidate data to obtain a new preset straight line slope determination algorithm.
[0084] In some specific implementations, the fitting straight line determination module 13 may specifically include:
[0085] The fitting straight line completion unit is used to determine the target straight line intercept corresponding to the laser stripe by using the target straight line slope and a preset rule of minimizing the sum of squared distances, and to determine the fitting straight line corresponding to the laser stripe based on the target straight line intercept and the target straight line slope.
[0086] Furthermore, the present application also discloses an electronic device. Figure 7This is a structural diagram of an electronic device 20 according to an exemplary embodiment, and the content in the figure cannot be regarded as any limitation on the scope of use of this application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the tobacco leaf thickness measurement method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0087] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0088] In addition, the memory 22 as a carrier for resource storage may be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon may include an operating system 221, a computer program 222, etc., and the storage method may be temporary storage or permanent storage.
[0089] The operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, and can be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program that can be used to complete the tobacco leaf thickness measurement method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include computer programs that can be used to complete other specific tasks.
[0090] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the tobacco leaf thickness measurement method disclosed above. The specific steps of the method can refer to the corresponding contents disclosed in the above embodiments, and will not be repeated here.
[0091] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0092] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0093] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0094] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0095] The technical solution provided by the present application is introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technicians in this field, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for measuring tobacco leaf thickness, characterized in that: include: Determine the corresponding original data points based on the center points of each laser stripe on the laser stripe formed when the line laser is projected onto the target tobacco leaf to be tested, and determine the sample data set of the slope of the straight line to be selected based on the corresponding coordinate values of any two data points in the original data points on the preset coordinate axis; Determine the initial value of the slope sample centroid corresponding to all the slope candidate data in the candidate straight line slope sample data set, and determine the target straight line slope corresponding to the laser stripe based on the initial value and a preset straight line slope determination algorithm; the preset straight line slope determination algorithm is a mean shift algorithm determined based on a Gaussian kernel function; The target straight line slope and a preset rule for minimizing the sum of squared distances are used to determine a fitting straight line corresponding to the laser stripes, so as to determine the thickness of the target tobacco leaf to be measured based on the fitting straight line.
2. The tobacco leaf thickness measurement method according to claim 1, characterized in that: The step of determining a sample data set of slopes of a straight line to be selected based on the coordinate values corresponding to any two data points in the original data points on a preset coordinate axis comprises: Selecting target data points from the original data points using a preset data selection method; the target data points are any two data points among the original data points that can form a straight line; The slope candidate data is determined based on a preset slope formula and the corresponding coordinate value of the target data point on the preset coordinate axis, and a corresponding candidate straight line slope sample data set is constructed based on the slope candidate data.
3. The tobacco leaf thickness measurement method according to claim 1, characterized in that: The step of determining the initial value of the slope sample centroid corresponding to all the slope candidate data in the slope sample data set for the straight line to be selected comprises: The preset mean algorithm is used to determine the initial value of the slope sample centroid corresponding to all the slope candidate data in the candidate straight line slope sample data set.
4. The tobacco leaf thickness measurement method according to claim 1, characterized in that: The determining the target straight line slope corresponding to the laser stripe based on the initial value and a preset straight line slope determination algorithm includes: Determine a preset straight line slope determination algorithm based on the mean shift algorithm and the Gaussian kernel function algorithm, and after determining the initial value as the current straight line slope, substitute the current straight line slope and all the slope candidate data in the candidate straight line slope sample data set into the preset straight line slope determination algorithm to obtain the calculated straight line slope; Determine whether the difference between the calculated straight line slope and the current straight line slope is less than a preset threshold; If the difference is less than a preset threshold, the calculated straight line slope is determined as the target straight line slope corresponding to the laser stripe.
5. The tobacco leaf thickness measurement method according to claim 4, characterized in that: After determining whether the difference between the calculated straight line slope and the current straight line slope is less than a preset threshold, the method further includes: If the difference is not less than a preset threshold, the kernel function width in the preset straight line slope determination algorithm is updated based on the calculated straight line slope to obtain a new preset straight line slope determination algorithm, and the calculated straight line slope is determined as the new current straight line slope, and then jump to the step of substituting the current straight line slope and all slope candidate data in the candidate straight line slope sample data set into the preset straight line slope determination algorithm to obtain the calculated straight line slope.
6. The tobacco leaf thickness measurement method according to claim 5, characterized in that: The updating of the kernel function width in the preset straight line slope determination algorithm based on the calculated straight line slope to obtain a new preset straight line slope determination algorithm, and determining the calculated straight line slope as a new current straight line slope, comprises: Determine the calculated straight line slope as a new current straight line slope, and determine a target sample density based on the distance between all slope candidate data in the candidate straight line slope sample data set and the current straight line slope; The target slope candidate data is determined based on the target sample density to obtain a new candidate straight line slope sample data set, and the kernel function width in the preset straight line slope determination algorithm is updated based on the number of the target slope candidate data to obtain a new preset straight line slope determination algorithm.
7. The tobacco leaf thickness measurement method according to any one of claims 1 to 6, characterized in that: The method of determining the fitting straight line corresponding to the laser stripe by using the target straight line slope and a preset rule of minimizing the sum of squares of distances comprises: The target straight line intercept corresponding to the laser stripe is determined by using the target straight line slope and a preset rule for minimizing the sum of squares of distances, and a fitting straight line corresponding to the laser stripe is determined based on the target straight line intercept and the target straight line slope.
8. A tobacco leaf thickness measuring device, characterized in that: include: The original data point determination module is used to determine the corresponding original data points based on the center points of the laser stripes formed when the line laser is projected onto the target tobacco leaf to be tested, and determine the sample data set of the slope of the straight line to be selected based on the corresponding coordinate values of any two data points in the original data points on the preset coordinate axis; A target slope determination module, used to determine the initial value of the slope sample centroid corresponding to all the slope candidate data in the candidate straight line slope sample data set, and determine the target straight line slope corresponding to the laser stripe based on the initial value and a preset straight line slope determination algorithm; the preset straight line slope determination algorithm is a vector form of a Gaussian kernel function; The fitting straight line determination module is used to determine the fitting straight line corresponding to the laser stripe by using the target straight line slope and a preset rule of minimizing the sum of squared distances, so as to determine the thickness of the target tobacco leaf to be tested based on the fitting straight line.
9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, used to execute the computer program to implement the steps of the tobacco leaf thickness measurement method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Used to store a computer program, wherein when the computer program is executed by a processor, the steps of the tobacco leaf thickness measurement method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Cigar tobacco tissue thickness measuring method and cutting device
CN121112965A