Spectroscopic confocal sensor calibration method, system, device, and readable storage medium

By acquiring calibration data sets and determining the optimal piecewise fitting curve in the spectral confocal sensor calibration method, the problems of not being able to include identical data points and ensuring small fitting errors in existing technologies are solved, thus achieving higher measurement accuracy.

CN115824048BActive Publication Date: 2026-05-29SHENZHEN TENSUN IND EQUIP

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHENZHEN TENSUN IND EQUIP
Filing Date
2022-12-07
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

In existing methods for calibrating spectral confocal sensors, piecewise curve fitting cannot include identical data points, and it cannot guarantee that the fitting error for each data point is small, resulting in insufficient measurement accuracy.

Method used

By acquiring the calibration data set, the optimal piecewise fitting curve corresponding to each calibration data point is determined. Multiple candidate fitting intervals are selected, and the fitting curve with the smallest fitting error is calculated as the optimal piecewise fitting curve, ensuring that the fitting error is minimized at each calibration data point.

Benefits of technology

The calibration accuracy of the spectral confocal sensor has been improved, ensuring that the fitting error of each data point is small and thus improving the accuracy of the measurement.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115824048B_ABST
    Figure CN115824048B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of sensors, and provides a spectral confocal sensor calibration method, a spectral confocal sensor calibration system, terminal equipment and readable storage media. The method comprises the following steps: acquiring a calibration data set, wherein the calibration data set comprises N calibration data, each calibration data comprises position data of a measured object and a peak wavelength collected by a spectral confocal sensor, and N represents an integer; determining an optimal segmented fitting curve corresponding to the kth calibration data, wherein the optimal segmented fitting curve has the minimum fitting error at the kth calibration data, and k=1, 2, 3...N; and determining an optimal segmented fitting curve corresponding to each calibration data in the calibration data set according to the kth optimal segmented fitting curve. The application can effectively solve the problems that different segments cannot contain the same sample data and cannot guarantee that the fitting errors of all sample data in the segments are small in the prior segmented fitting method, and is beneficial to improving the fitting precision.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of sensor technology, and in particular provides a method, system, device, and readable storage medium for calibrating a spectral confocal sensor. Background Technology

[0002] Spectral confocal sensors are non-contact displacement sensors with advantages such as high measurement accuracy, fast response speed, and good stability. They can be used to measure the dimensions of precision parts, the thickness of transparent objects, the depth of grooves, etc. Currently, they are playing an important role in aerospace, electronics, medicine and other fields, and have broad development prospects.

[0003] Based on a confocal sensor, this system utilizes the positional chromatic aberration of the objective lens to focus monochromatic light of different wavelengths at different axial positions, achieving a one-to-one correspondence between wavelength and position. When a measured object is present, the measuring light is reflected back after illuminating the object's surface. Only the monochromatic light focused on the object's surface satisfies the confocal condition, and most of its energy can be detected by the spectrometer through the confocal aperture. The remaining monochromatic light, defocused on the object's surface, has most of its energy blocked by the aperture and cannot be detected by the spectrometer. Therefore, in the spectral signal, the peak wavelength corresponds to the wavelength of the monochromatic light focused on the object's surface. By pre-calibrating the correspondence between the object's position and the peak wavelength, the object's position can be obtained by detecting the peak wavelength during actual measurement, thus enabling displacement or thickness measurement.

[0004] It is evident that accurate calibration of the position and peak wavelength relationship is fundamental for achieving precise measurements with spectral confocal sensors. Currently, the most accurate methods for calibrating this relationship are piecewise curve fitting. Piecewise curve fitting divides the data points into segments based on the criterion of minimizing fitting error, and then performs curve fitting within each segment, achieving a relatively good fitting effect.

[0005] However, this technique also has some shortcomings: First, after determining a segment, the data points of the previous segment cannot be included when determining the next segment, which may cause the segment with smaller fitting error to be missed; Second, when performing curve fitting for each segment, the overall fitting error of all data points within the segment is considered to be small, without considering whether the fitting error of each data point is small. If the fitting error of a certain data point is large, the positional error will also be large when the peak wavelength near the wavelength of that data point is substituted into the calculation during measurement. Summary of the Invention

[0006] The purpose of this application is to provide a method, system, device and storage medium for calibrating a spectral confocal sensor, which aims to solve the existing problems that different segments cannot contain the same data points and that it is impossible to guarantee that the fitting error of each data point within a segment is small.

[0007] To achieve the above objectives, the technical solution adopted in this application is as follows:

[0008] In a first aspect, this application provides a spectral confocal sensor calibration method, which is applied to a service node. The spectral confocal sensor calibration method includes: acquiring a calibration data set, the calibration data set including N calibration data, each calibration data including the position data of the measured object and the peak wavelength collected by the spectral confocal sensor, where N represents an integer; determining the optimal piecewise fitting curve corresponding to the k-th calibration data, the optimal piecewise fitting curve having the smallest fitting error at the k-th calibration data, where k = 1, 2, 3…N; and determining the optimal piecewise fitting curve corresponding to each calibration data in the calibration data set based on the k-th optimal piecewise fitting curve.

[0009] In one embodiment, acquiring the calibration data set includes: acquiring a second preset number of sample data collected by a spectral confocal sensor; sorting the sample data in ascending order of peak wavelength to generate a sample data sequence; and selecting N sample data from the sample data sequence as a calibration data set according to the order of the sample data sequence.

[0010] In one embodiment, determining the optimal piecewise fitting curve corresponding to the kth calibration data includes: determining a plurality of candidate fitting intervals corresponding to the kth calibration data, each candidate fitting interval containing a first number of sample data; fitting the first number of sample data to obtain a candidate fitting curve corresponding to the candidate fitting interval; and determining the optimal piecewise fitting curve corresponding to the kth calibration data from the candidate fitting curves.

[0011] In one embodiment, determining the plurality of candidate fitting intervals corresponding to the kth calibration data includes: selecting a plurality of first endpoint data and corresponding second endpoint data in the sample data sequence, wherein the order of the first endpoint data in the sample data sequence is less than that of the kth calibration data, and the order of the second endpoint data in the sample data sequence is greater than that of the kth calibration data; determining the candidate fitting interval based on each first endpoint data and corresponding second endpoint data, wherein the starting point of the candidate fitting interval is the first endpoint data, and the ending point of the candidate fitting interval is the second endpoint data.

[0012] In one embodiment, determining the optimal piecewise fitting curve corresponding to the k-th calibration data from the candidate fitting curves includes: calculating the fitting error of all candidate fitting curves at the k-th calibration data; and selecting the candidate fitting curve with the smallest fitting error as the optimal piecewise fitting curve corresponding to the k-th calibration data.

[0013] In one embodiment, fitting the first number of sample data to obtain the candidate fitting curve corresponding to the candidate fitting interval includes: performing polynomial fitting on the first number of sample data to obtain the candidate fitting curve corresponding to the candidate fitting interval.

[0014] In one embodiment, the order of the polynomial fitting calculation is 3, 4, or 5.

[0015] Secondly, this application provides a spectral confocal sensor calibration system, comprising: a calibration point acquisition module for acquiring a calibration data set, the calibration data set including N calibration data, each calibration data including the position data of the object under test and the peak wavelength collected by the spectral confocal sensor, where N represents an integer; a fitting determination module for determining the optimal piecewise fitting curve corresponding to the k-th calibration data, the optimal piecewise fitting curve having the smallest fitting error at the k-th calibration data, where k = 1, 2, 3…N; and an optimal fitting selection module for determining the optimal piecewise fitting curve corresponding to each calibration data in the calibration data set based on the k-th optimal piecewise fitting curve.

[0016] Thirdly, this application also provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor; when the processor executes the computer program, it implements the spectral confocal sensor calibration method of the first aspect described above.

[0017] Fourthly, this application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the spectral confocal sensor calibration method of the first aspect described above.

[0018] The beneficial effects of this application are:

[0019] This application provides a spectral confocal sensor calibration method, system, device, and storage medium. It fits multiple candidate fitting intervals containing calibration data, selects the fitting curve with the smallest fitting error at the calibration data location as the optimal piecewise fitting curve for that calibration data, and determines the corresponding optimal piecewise fitting curve for all calibration data using the same process. This effectively solves the problems of existing piecewise fitting methods where different segments cannot contain the same sample data and cannot guarantee that the fitting error of all sample data within a segment is small, thus improving fitting accuracy.

[0020] Specifically, firstly, a calibration data set comprising N calibration data points is acquired. Each calibration data point includes the position data of the measured object and the corresponding peak wavelength collected by the sensor, where N represents an integer. Then, the optimal piecewise fitting curve corresponding to the k-th calibration data point is determined, where k = 1, 2, 3…N. Multiple candidate fitting intervals are selected for the k-th calibration data point, resulting in multiple candidate fitting curves. The fitting error of all candidate fitting curves at the k-th calibration data point is calculated, and the candidate fitting curve with the smallest fitting error is selected as the optimal piecewise fitting curve corresponding to the k-th calibration data point. This ensures that the optimal piecewise fitting curve has a good fitting effect at the corresponding calibration data point. Finally, based on the k-th optimal piecewise fitting curve, the optimal piecewise fitting curve corresponding to each calibration data point in the calibration data set is determined. Candidate fitting intervals corresponding to different calibration data points can contain the same sample data, overcoming the limitation of existing piecewise fitting methods that different segments cannot contain the same sample data, which is beneficial for finding segments with smaller fitting errors.

[0021] It is understandable that systems, terminal devices, and computer-readable storage media that can implement the above methods have the same beneficial effects. Attached Figure Description

[0022] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0023] Figure 1 This is a flowchart illustrating an embodiment of the spectral confocal sensor calibration method of this application;

[0024] Figure 2 This is a flowchart illustrating an embodiment of the spectral confocal sensor calibration method of this application;

[0025] Figure 3 This is a schematic diagram of the sensor acquisition device in an embodiment of the spectral confocal sensor calibration method of this application;

[0026] Figure 4 This is a schematic diagram of calibration data points for an embodiment of the spectral confocal sensor calibration method of this application;

[0027] Figure 5 This is a flowchart illustrating an embodiment of the spectral confocal sensor calibration method of this application;

[0028] Figure 6 This is a flowchart illustrating an embodiment of the spectral confocal sensor calibration method of this application;

[0029] Figure 7 This is a flowchart illustrating an embodiment of the spectral confocal sensor calibration method of this application;

[0030] Figure 8 This is a schematic diagram of the fitting error σ1 in an embodiment of the spectral confocal sensor calibration method of this application;

[0031] Figure 9 This is a schematic diagram of the fitting error σ2 in an embodiment of the spectral confocal sensor calibration method of this application;

[0032] Figure 10 The fitting error σ in the embodiment of the spectral confocal sensor calibration method of this application is... k Schematic diagram;

[0033] Figure 11 This is a schematic diagram of the optimal piecewise fitting curve for the application of the spectral confocal sensor calibration method embodiment of this application;

[0034] Figure 12 This is a structural block diagram of an embodiment of the spectral confocal sensor calibration system of this application;

[0035] Figure 13 This is a structural block diagram of the terminal device of this application. Detailed Implementation

[0036] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.

[0037] In the description of this application, it should be understood that the terms "length", "width", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing this application 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 of this application.

[0038] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this application, "multiple" means two or more, unless otherwise explicitly specified.

[0039] The spectral confocal sensor calibration method provided in this application can be applied to terminal devices such as microcontrollers and personal computers. This application does not impose any restrictions on the specific type of terminal device.

[0040] The spectral confocal sensor calibration method provided in this application is applied to a sensor acquisition device, which includes a spectral confocal sensor, a measured object, and a precision displacement platform. The spectral confocal sensor is a non-contact displacement sensor with advantages such as high measurement accuracy, fast response speed, and good stability. It can be used to measure the dimensions of precision parts, the thickness of transparent objects, and the depth of grooves, and currently plays an important role in aerospace, electronics, and medical fields, with broad development prospects.

[0041] A spectral confocal sensor, based on the confocal sensor, utilizes the positional chromatic aberration of the objective lens to focus monochromatic light of different wavelengths at different axial positions, achieving a one-to-one correspondence between wavelength and position. When a test object is present, the measuring light is reflected back after illuminating the object's surface. Only the monochromatic light focused on the object's surface satisfies the confocal condition, and most of its energy can be detected by the spectrometer through the confocal aperture. The remaining monochromatic light, defocused on the object's surface, has most of its energy blocked by the confocal aperture and cannot be detected by the spectrometer. Therefore, in the spectral signal, the peak wavelength corresponds to the wavelength of the monochromatic light focused on the object's surface.

[0042] By pre-calibrating the correspondence between the position of the object being measured and the peak wavelength, the position of the object being measured can be obtained by detecting the peak wavelength during actual measurement, thereby realizing displacement measurement or thickness measurement.

[0043] Accurate calibration of the position and peak wavelength relationship is fundamental for achieving precise measurements with spectral confocal sensors. Currently, the most accurate method for calibrating this relationship is piecewise curve fitting. Piecewise curve fitting divides the data points into segments based on the criterion of minimizing fitting error, and then performs curve fitting within each segment, achieving a relatively good fitting effect.

[0044] However, this technique also has some shortcomings: First, after determining a segment, the data points of the previous segment cannot be included when determining the next segment, which may cause the segment with smaller fitting error to be missed; Second, when performing curve fitting for each segment, the overall fitting error of all data points within the segment is considered to be small, without considering whether the fitting error of each data point is small. If the fitting error of a certain data point is large, the positional error will also be large when the peak wavelength near the wavelength of that data point is substituted into the calculation during measurement.

[0045] To address the aforementioned problems, this application provides a method, system, device, and storage medium for calibrating a spectral confocal sensor. The following embodiments illustrate the technical solution described in this application.

[0046] Example 1

[0047] Please see Figure 1 The spectral confocal sensor calibration method provided in this application includes:

[0048] Step S1: Obtain the calibration data set.

[0049] The calibration data set includes N calibration data points, each of which includes the position data of the object under test and the peak wavelength collected by the spectral confocal sensor, where N represents an integer.

[0050] Sensor sample data is a two-dimensional data set containing calibration data, including the position data of the measured object and the corresponding peak wavelength acquired by the sensor. The position data is the distance between the spectral confocal sensor and the measured object, and the peak wavelength is the peak wavelength of the monochromatic light focused on the surface of the measured object. For example, (λ1,d1), (λ2,d2)...(λ k ,d k )……(λ N ,d N Let λ be used to represent this. k Let d be the k-th peak wavelength acquired by the sensor. k This represents the k-th position data of the object being measured.

[0051] In one embodiment, such as Figure 2 As shown, the acquisition of the calibration data set includes:

[0052] Step S11: Obtain a second preset number of sample data collected by the spectral confocal sensor.

[0053] Step S12: Sort the second preset number of sample data according to the peak wavelength from small to large to generate a sample data sequence.

[0054] It should be noted that the above steps are for cases where the order of sensor sample data is irregular. Therefore, it is necessary to sort the sensor sample data from smallest to largest according to the peak wavelength to generate a sample data sequence, which facilitates the subsequent selection of calibration data groups and the fitting calculation of the calibration data in them.

[0055] In applications, it can be... Figure 3 The sensor acquisition device, consisting of the spectral confocal sensor 31, the object under test 32, and the precision displacement platform 33, is used to acquire sensor sample data. During acquisition, the precision displacement platform 33 moves according to a preset step size, so that the spectral confocal sensor 31 can acquire a sequence of sample data sorted from smallest to largest, eliminating the need for sorting in step S12.

[0056] Step S13: Select N sample data as calibration data groups from the second preset number of sample data sequences according to the arrangement order of the second preset number of sample data sequences.

[0057] The value of N is determined based on the required measurement range. For example, if the measurement range is 1 mm, then the positional range of the interval bounded by the start and end calibration data must be greater than or equal to 1 mm. In applications, such as... Figure 4 As shown, the number of sample data sequences is the second preset number, and the third to third-to-last sample data in the sample data sequence is the calibration data group (shown as white dots in the figure).

[0058] Step S2: Determine the optimal piecewise fitting curve corresponding to the kth calibration data.

[0059] The optimal piecewise fitting curve has the smallest fitting error at the kth calibration data point, where k = 1, 2, 3...N.

[0060] In one embodiment, such as Figure 5 As shown, determining the optimal piecewise fitting curve corresponding to the kth calibration data includes:

[0061] Step S21: Determine multiple candidate fitting intervals corresponding to the kth calibration data.

[0062] Each of the candidate fitting intervals contains a first number of sample data.

[0063] In one embodiment, such as Figure 6As shown, determining the multiple candidate fitting intervals corresponding to the kth calibration data includes:

[0064] Step S211: Select multiple first endpoint data and corresponding second endpoint data from the sample data sequence.

[0065] Wherein, the first endpoint data is in a lower order than the kth calibration data in the sample data sequence, and the second endpoint data is in a higher order than the kth calibration data in the sample data sequence.

[0066] In applications, (λ) can be used. k ,d k ) represents the k-th calibration data, where λ k Let d be the k-th peak wavelength acquired by the sensor. k Let be the k-th position data of the object being measured. Then we can use (λ) j ,d j ) represents the first endpoint data, where λ j =λ1, λ2, λ3...λ k-1 d j =d1, d2, d3...d k-1 It can be used with (λ) m ,d m ) represents the second endpoint data, where λ m =λ k+1 , λ k+2 , λ k+3 ……λ N d m =d k+1 d k+2 d k+3 ...d N .

[0067] For example, with (λ) k-2 ,d k-2 ) is the first endpoint data, with (λ) k+2 ,d k+2 Using λ as the second endpoint data, a candidate fitting interval is constructed and polynomial fitting is performed. The fitting error at the k-th calibration data point is calculated, and then (λ) is used as the second endpoint data. k-3 ,d k-3 ) is the new first endpoint data, with (λ) k+3 ,d k+3The first endpoint data is used as the second endpoint data. Then, a new fitting interval is formed and polynomial fitting is performed. The fitting error at the kth calibration data is calculated. This process continues until the first endpoint data is the first sample data in the sample data sequence, or the second endpoint data is the last sample data in the sample data sequence. After completing this round of polynomial fitting and error calculation, no new first endpoint data or second endpoint data is selected.

[0068] Step S212: Determine the candidate fitting interval based on each first endpoint data and the corresponding second endpoint data.

[0069] The starting point of the candidate fitting interval is the first endpoint data, and the ending point of the candidate fitting interval is the second endpoint data.

[0070] In applications, the fitting interval needs to contain sufficient sensor sample data according to the requirements of the fitting calculation. For example, when performing a fourth-order polynomial fitting, the fitting interval needs to contain at least five sensor sample data. To meet this requirement, the first and second endpoint data can be randomly paired to generate the fitting interval. For example, when performing a fourth-order polynomial fitting on the k-th calibration data, the first endpoint data (λ) can be selected. k-2 ,d k-2 ) and second endpoint data (λ) k+2 ,d k+2 Generate the first fitting interval and select the first endpoint data (λ). k-3 ,d k-3 ) and second endpoint data (λ) k+3 ,d k+3 This generates a second fitting interval, and so on. Alternatively, the first endpoint data (λ) can be selected. k-3 ,d k-3 ) and second endpoint data (λ) k+2 ,d k+2 Generate the first fitting interval and select the first endpoint data (λ). k-4 ,d k-4 ) and second endpoint data (λ) k+3 ,d k+3 The second fitting interval is generated, and so on. The specific pairing of the first and second endpoint data points for generating the fitting interval is determined by the user according to their needs.

[0071] Step S22: Fit the first number of sample data to obtain the candidate fitting curve corresponding to the candidate fitting interval.

[0072] In one embodiment, fitting the first number of sample data to obtain the candidate fitting curve corresponding to the candidate fitting interval includes:

[0073] Perform polynomial fitting on the first number of sample data to obtain the candidate fitting curve corresponding to the candidate fitting interval.

[0074] For example, when the polynomial order is 4, the fitted curve is:

[0075] D = 0 + 1λ + 2λ 2 +3λ 3 +4λ 4 (1)

[0076] Where c0, c1, c2, c3, and c4 are the polynomial coefficients of the fitted curve, λ is the peak wavelength acquired by the spectral confocal sensor, and D is the position data of the object under test calculated based on the fitted curve.

[0077] Substitute the peak wavelengths collected by the spectral confocal sensor from the first number of sample data, such as 5 sample data, into formula (1) to calculate the five position data of the object under test. Then, calculate the sum of squared errors between these five position data and the position data of the measured object in the sample data. Then, take the partial derivatives of the sum of squared errors with respect to c0, c1, c2, c3, and c4 respectively, and set each partial derivative result to zero. Finally, obtain the values ​​of the coefficients of the five fitting curve polynomials c0, c1, c2, c3, and c4.

[0078] In applications, the polynomial fitting calculation uses a fitting order of 3, 4, or 5. The fitting error of polynomial fitting generally decreases as the fitting order increases. However, when the fitting order is too high, numerical instability may occur, and the fitting error may actually increase. Therefore, the order of the polynomial fitting should not be too high or too low. Considering factors such as computational cost, the order of polynomial fitting is generally 3, 4, or 5, depending on the actual data distribution.

[0079] Step S23: Determine the optimal piecewise fitting curve corresponding to the kth calibration data from the candidate fitting curves.

[0080] In one embodiment, such as Figure 7 As shown, determining the optimal piecewise fitting curve corresponding to the k-th calibration data from the candidate fitting curves includes:

[0081] Step S231: Calculate the fitting error of all candidate fitting curves at the kth calibration data point.

[0082] Specifically, the k-th calibration data is directly substituted into all candidate fitting curves to obtain the corresponding fitting error. The following example... Figures 8 to 10To illustrate, consider the example where the k-th calibration data has two candidate fitting curves, L1 and L2. Substituting the peak wavelength of the k-th calibration data into the fitting curves L1 and L2 respectively yields the predicted position data of the object being measured. The difference between the two predicted position data and the actual position data of the object is then used as the fitting error. The fitting error σ1 of curve L1 at the k-th calibration data and the fitting error σ2 of curve L2 at the k-th calibration data are then calculated, and so on, until σ... k .

[0083] Step S232: The candidate fitting curve with the smallest fitting error is taken as the optimal piecewise fitting curve corresponding to the kth calibration data.

[0084] For example, the fitting errors σ1, σ2, ..., σ are calculated from the kth calibration data. k If the fitting error σ2 is minimized, then the corresponding fitting curve L2 is the optimal piecewise fitting curve corresponding to the kth calibration data.

[0085] Step S3: Determine the optimal piecewise fitting curve corresponding to each calibration data in the calibration data group based on the k-th optimal piecewise fitting curve.

[0086] like Figure 11 As shown, during measurement, the calibration data that is closest to the measured peak wavelength is selected, and the position of the object to be measured corresponding to the measured peak wavelength is calculated using the optimal piecewise fitting curve corresponding to the calibration data.

[0087] It is understandable that the optimal piecewise fitting curve corresponding to the calibration data not only has a smaller fitting error at the calibration data, but also has a smaller fitting error for measured data with peak wavelengths close to the calibration data during actual measurement.

[0088] This application embodiment fits multiple candidate fitting intervals containing calibration data, selects the fitting curve with the smallest fitting error at the calibration data as the optimal piecewise fitting curve corresponding to the calibration data, and determines the corresponding optimal piecewise fitting curve for all calibration data in the same process. This effectively solves the problems of existing piecewise fitting methods where different segments cannot contain the same sample data and cannot guarantee that the fitting error of all sample data within a segment is small, which is beneficial to improving fitting accuracy.

[0089] Specifically, firstly, a calibration data set comprising N calibration data points is acquired. Each calibration data point includes the position data of the measured object and the corresponding peak wavelength collected by the sensor, where N represents an integer. Then, the optimal piecewise fitting curve corresponding to the k-th calibration data point is determined, where k = 1, 2, 3…N. Multiple candidate fitting intervals are selected for the k-th calibration data point, resulting in multiple candidate fitting curves. The fitting error of all candidate fitting curves at the k-th calibration data point is calculated, and the candidate fitting curve with the smallest fitting error is selected as the optimal piecewise fitting curve corresponding to the k-th calibration data point. This ensures that the optimal piecewise fitting curve has a good fitting effect at the corresponding calibration data point. Finally, based on the k-th optimal piecewise fitting curve, the optimal piecewise fitting curve corresponding to each calibration data point in the calibration data set is determined. Candidate fitting intervals corresponding to different calibration data points can contain the same sample data, overcoming the limitation of existing piecewise fitting methods that different segments cannot contain the same sample data, which is beneficial for finding segments with smaller fitting errors.

[0090] Example 2

[0091] Corresponding to the spectral confocal sensor calibration method described in the above embodiments, Figure 12 A structural block diagram of a spectral confocal sensor calibration system 120 provided in an embodiment of this application is shown. This system can be a virtual appliance in a terminal device, run by the processor of the terminal device, or it can be integrated into the terminal device itself. For ease of explanation, only the parts relevant to the embodiments of this application are shown.

[0092] The spectral confocal sensor calibration system 120 of this application includes:

[0093] The calibration point acquisition module 121 is used to acquire a calibration data set, which includes N calibration data, each of which includes the position data of the object under test and the peak wavelength collected by the spectral confocal sensor, where N represents an integer;

[0094] The fitting determination module 122 is used to determine the optimal piecewise fitting curve corresponding to the kth calibration data, wherein the optimal piecewise fitting curve has the smallest fitting error at the kth calibration data, and k = 1, 2, 3...N;

[0095] The optimal fitting selection module 123 is used to determine the optimal piecewise fitting curve corresponding to each calibration data in the calibration data group based on the kth optimal piecewise fitting curve.

[0096] This application embodiment fits multiple candidate fitting intervals containing calibration data, selects the fitting curve with the smallest fitting error at the calibration data as the optimal piecewise fitting curve corresponding to the calibration data, and determines the corresponding optimal piecewise fitting curve for all calibration data in the same process. This effectively solves the problems of existing piecewise fitting methods where different segments cannot contain the same sample data and cannot guarantee that the fitting error of all sample data within a segment is small, which is beneficial to improving fitting accuracy.

[0097] Specifically, firstly, the calibration point acquisition module acquires a calibration data set comprising N calibration data points. Each calibration data point includes the position data of the measured object and the corresponding peak wavelength collected by the sensor, where N represents an integer. Then, the fitting determination module determines the optimal piecewise fitting curve corresponding to the k-th calibration data point, where k = 1, 2, 3…N. Multiple candidate fitting intervals are selected for the k-th calibration data point, resulting in multiple candidate fitting curves. The fitting error of all candidate fitting curves at the k-th calibration data point is calculated, and the candidate fitting curve with the smallest fitting error is selected as the optimal piecewise fitting curve corresponding to the k-th calibration data point, thus ensuring that the optimal piecewise fitting curve has a good fitting effect at the corresponding calibration data point. Finally, the optimal fitting selection module determines the optimal piecewise fitting curve corresponding to each calibration data point in the calibration data set based on the k-th optimal piecewise fitting curve. Candidate fitting intervals corresponding to different calibration data points can contain the same sample data, overcoming the limitation of existing piecewise fitting methods that different segments cannot contain the same sample data, which is beneficial for finding segments with smaller fitting errors.

[0098] Example 3

[0099] like Figure 13 As shown, this application also provides a terminal device 130, including a memory 131, a processor 132, and a computer program 133 stored in the memory and executable on the processor. For example, when the processor 132 executes the computer program 133, it implements the steps in the above-described embodiments of the spectral confocal sensor calibration methods, such as the method steps in Embodiment 1. When the processor 132 executes the computer program 133, it implements the functions of each module in the above-described device embodiments, such as the functions of each module and unit in Embodiment 2.

[0100] For example, the computer program 133 can be divided into one or more modules, which are stored in the memory 131 and executed by the processor 132 to complete Embodiment 1 and / or Embodiment 2 of this application. The one or more modules can be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program 133 in the terminal device 130. For example, the computer program 133 can be divided into a calibration point acquisition module, a fitting determination module, and an optimal fit selection module, etc. The specific functions of each module have been described in Embodiment 2 above and will not be repeated here.

[0101] The terminal device may include, but is not limited to, a memory 131 and a processor 132. Those skilled in the art will understand that... Figure 13 This is merely an example of terminal device 130 and does not constitute a limitation on terminal device 130. It may include more or fewer components than shown, or combine certain components, or different components. For example, the terminal device may also include input / output devices, network access devices, buses, etc.

[0102] The memory 131 can be an internal storage unit of the terminal device 130, such as a hard disk or memory of the terminal device 130. The memory 131 can also be an external storage device of the terminal device 130, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc., equipped on the terminal device 130. Furthermore, the memory 131 can include both internal and external storage units of the terminal device 130. The memory 131 is used to store the computer program and other programs and data required by the terminal device. The memory 131 can also be used to temporarily store data that has been output or will be output.

[0103] The processor 132 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.

[0104] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0105] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0106] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0107] In the embodiments provided by this invention, it should be understood that the disclosed apparatus / terminal devices and methods can be implemented in other ways. For example, the apparatus / terminal device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0108] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0109] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0110] If the integrated module is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by hardware related to computer program instructions. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.

[0111] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.

Claims

1. A method for calibrating a spectral confocal sensor, characterized in that, include: Acquire a calibration data set, which includes N calibration data points. Each calibration data point includes the position data of the object under test and the peak wavelength collected by the spectral confocal sensor, where N represents an integer. Determine the optimal piecewise fitting curve corresponding to the kth calibration data point, wherein the optimal piecewise fitting curve has the smallest fitting error at the kth calibration data point, and k = 1, 2, 3...N; The optimal piecewise fitting curve corresponding to each calibration data in the calibration data group is determined based on the k-th optimal piecewise fitting curve. Determining the optimal piecewise fitting curve corresponding to the kth calibration data includes: Determine multiple candidate fitting intervals corresponding to the kth calibration data, where each candidate fitting interval contains a first number of sample data; Fit the first number of sample data to obtain the candidate fitting curve corresponding to the candidate fitting interval; Substitute the k-th calibration data into all the candidate fitting curves to obtain the corresponding fitting error, and determine the optimal piecewise fitting curve corresponding to the smallest fitting error of the k-th calibration data from the candidate fitting curves.

2. The method according to claim 1, characterized in that, The acquired calibration data set includes: Acquire a second preset number of sample data collected by the spectral confocal sensor; The sample data are sorted from smallest to largest according to the peak wavelength to generate a sample data sequence; According to the arrangement order of the sample data sequence, N sample data are selected from the sample data sequence as a calibration data group.

3. The method according to claim 1, characterized in that, Determining the multiple candidate fitting intervals corresponding to the kth calibration data includes: Multiple first endpoint data and corresponding second endpoint data are selected from the sample data sequence. The order of the first endpoint data in the sample data sequence is less than that of the k-th calibration data, and the order of the second endpoint data in the sample data sequence is greater than that of the k-th calibration data. The candidate fitting interval is determined based on each first endpoint data and the corresponding second endpoint data, wherein the starting point of the candidate fitting interval is the first endpoint data and the ending point of the candidate fitting interval is the second endpoint data.

4. The method according to claim 1, wherein determining the optimal piecewise fitting curve corresponding to the k-th calibration data from the candidate fitting curves comprises: Calculate the fitting error of all candidate fitting curves at the kth calibration data point; The candidate fitting curve with the smallest fitting error is taken as the optimal piecewise fitting curve corresponding to the k-th calibration data.

5. The method according to claim 1, characterized in that, The step of fitting the first number of sample data to obtain the candidate fitting curve corresponding to the candidate fitting interval includes: Perform polynomial fitting on the first number of sample data to obtain the candidate fitting curve corresponding to the candidate fitting interval.

6. The method according to claim 5, characterized in that, The order of the polynomial fitting calculation is 3, 4, or 5.

7. A spectral confocal sensor calibration system, characterized in that, The system includes: The calibration point acquisition module is used to acquire a calibration data set, which includes N calibration data, each of which includes the position data of the object under test and the peak wavelength collected by the spectral confocal sensor, where N represents an integer; The fitting determination module is used to determine the optimal piecewise fitting curve corresponding to the kth calibration data, wherein the optimal piecewise fitting curve has the smallest fitting error at the kth calibration data, and k=1, 2, 3…N; The optimal fit selection module is used to determine the optimal piecewise fit curve corresponding to each calibration data in the calibration data group based on the k-th optimal piecewise fit curve. The fitting determination module is used for: Determine multiple candidate fitting intervals corresponding to the kth calibration data, where each candidate fitting interval contains a first number of sample data; Fit the first number of sample data to obtain the candidate fitting curve corresponding to the candidate fitting interval; Substitute the k-th calibration data into all the candidate fitting curves to obtain the corresponding fitting error, and determine the optimal piecewise fitting curve corresponding to the smallest fitting error of the k-th calibration data from the candidate fitting curves.

8. A terminal device, characterized in that, The terminal device includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor; When the processor executes the computer program, it implements the spectral confocal sensor calibration method as described in any one of claims 1 to 6.

9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the spectral confocal sensor calibration method as described in any one of claims 1 to 6.