Lens focal power measurement method, storage medium and electronic equipment
By combining Hartmann aperture and annular aperture for lens power measurement, and incorporating lens mounting deviation and optical imaging deviation compensation strategies, a weighted fusion algorithm is used to calculate the power value. This solves the problems of low accuracy or high cost of existing focimeters, and achieves high-precision, low-cost power measurement.
Patent Information
- Application Number
- CN202511575016.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-31
- Publication Date
- 2026-02-03
AI Technical Summary
Existing focimeter measurement solutions suffer from either low accuracy or high cost, making it difficult to reduce costs while ensuring accuracy.
A lens power measurement method combining Hartmann aperture and annular aperture is adopted. By acquiring the spot and annular contour in the optical imaging information, the initial center point is calibrated using lens mounting deviation and optical imaging deviation compensation strategies, and the power value is calculated by combining a weighted fusion algorithm.
It achieves high-precision focal length measurement, reduces equipment costs, avoids the impact of poor spot imaging quality, and provides higher measurement accuracy.
Smart Images

Figure CN121453344A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of lens optical parameter measurement, in particular to a lens power measurement method, a storage medium and an electronic device. BACKGROUND
[0002] A lensometer is an instrument for measuring the diopter of a spectacle lens (including myopia glasses, hyperopia glasses, astigmatism glasses, etc.). At present, there are mainly two ways to measure the diopter of a lens by a lensometer: (1) Using photoelectric imaging technology and digital image processing technology, a specific optical pattern (such as a cross line, a circular ring, etc.) is projected onto the measured lens, and the light rays refracted by the lens form a specific image on the image sensor. By analyzing the image obtained by the sensor, the deformation and displacement of the pattern in the image are calculated to obtain the diopter of the lens. The accuracy of the diopter calculation result of this scheme is limited by the imaging quality; (2) Hartmann wavefront sensing technology, which is a technology for measuring the wavefront distortion of light waves, is mainly used for high-end applications such as astronomical telescopes. A microlens array is used in cooperation with a Hartmann diaphragm. The microlens array is composed of a large number of small lenses arranged in an orderly manner. Each microlens corresponds to a sub-aperture and focuses the incident light rays onto a detector to form a light spot. The position data of the light spot obtained by the detector is processed and analyzed by a data processing system. Through a specific algorithm, the wavefront slope is calculated according to the light spot offset, and the shape of the wavefront is reconstructed by using a wavefront reconstruction algorithm to obtain specific information about the wavefront distortion. This scheme is costly and complicated to operate.
[0003] Therefore, there is an urgent need for a lens power measurement scheme that meets both accuracy and cost requirements. SUMMARY
[0004] The technical problem to be solved by the present application is that the existing lens power measurement schemes either have low accuracy or high cost, and therefore a lens power measurement method, a storage medium and an electronic device are provided.
[0005] In a first aspect, the technical scheme of the present application provides a lens power measurement method, which comprises: Obtaining optical imaging information of a lens to be measured, the optical imaging information being image information formed on a light screen after a light beam emitted by a light source passes through a collimating lens, a Hartmann diaphragm, a ring diaphragm and the lens to be measured in sequence; Determining a light spot profile and a ring profile in the optical imaging information; the light spot profile corresponds to a diaphragm hole in the Hartmann diaphragm, and the ring profile corresponds to a diaphragm hole in the ring diaphragm; Determining an initial light spot center point according to the light spot profile and an initial ring center point according to the ring profile; According to the lens mounting deviation compensation strategy and the optical imaging deviation compensation strategy, positions of the initial light spot center point and the initial ring center point are calibrated to obtain a light spot center point and a ring center point; According to the light spot center point, a first focal power value of the lens under test is calculated, and according to the ring center point, a second focal power value of the lens under test is calculated; A light spot center positioning reliability and a ring center positioning reliability are calculated; According to the light spot center positioning reliability, the first focal power value, the ring center positioning reliability and the second focal power value, a weighted fusion algorithm is used to obtain a focal power value of the lens under test.
[0006] Preferably, in the lens focal power measurement method, the determining the light spot profile and the ring profile in the optical imaging information further comprises pre-processing the optical imaging information, and the pre-processing comprises: Gaussian filtering is performed on the optical imaging information to eliminate high-frequency noise in the optical imaging information to obtain smoothed optical imaging information; Self-adaptive threshold segmentation processing is performed on the smoothed optical imaging information to obtain a light spot and background boundary line and a ring and background boundary line, and segmented optical imaging information is obtained; For the light spot in the segmented optical imaging information, holes in the light spot are filled by expanding the light spot edge, and then the original size of the light spot is restored, and then isolated scattered points in the light spot are eliminated to complete the pre-processing of the optical imaging information.
[0007] Preferably, in the lens focal power measurement method, the determining the light spot profile and the ring profile in the optical imaging information is performed by the following method: The light spot area and the circularity of each light spot are obtained, and light spots with a light spot area not within a preset light spot area range and light spots with a circularity less than a circularity threshold value are filtered out; The ring width and the circularity of the ring profile are obtained, and rings with a ring width not within a preset ring width range and rings with a circularity less than a circularity threshold value are filtered out; The light spot profile of the remaining light spot is obtained as the light spot profile, and the ring profile of the remaining ring is obtained as the ring profile.
[0008] Preferably, in the lens focal power measurement method, the determining the initial light spot center point according to the light spot profile and the determining the initial ring center point according to the ring profile comprise: For the light spot profile: A plurality of algorithms are used to obtain the center position coordinates (cx i , cy i ); (cxi , cy i ) is the horizontal and vertical coordinates of the center position obtained by the i-th algorithm; The weight value a of different algorithms is determined according to the circularity of the spot profile i , and n is the total number of algorithm types; The initial spot center point coordinates (cx, cy) of the spot profile are calculated, wherein: cx= , cy= ; For the annular profile: The inner and outer circles of the annular profile are determined; The initial annular center point coordinates (x 00 , y 00 ) of the annular profile are calculated according to the center position coordinates (x 01 , y 01 ) of the inner circle and the center position coordinates (x 02 , y 02 ) of the outer circle, wherein: x 00 =(x 01 +x 02 ) / 2, y 00 =(y 01 +y 02 ) / 2.
[0009] Preferably, in the lens power measurement method, the positions of the initial spot center point and the initial annular center point are calibrated according to a lens installation deviation compensation strategy and an optical imaging deviation compensation strategy to obtain a spot center point and an annular center point, wherein: The lens installation deviation compensation strategy includes: selecting two groups of spots, the theoretical center connecting line of one group of spots being parallel to the horizontal axis, and the theoretical center connecting line of the other group of spots being parallel to the vertical axis; determining the horizontal axis offset, the vertical axis offset and / or the rotation offset according to the positional relationship between the actual center connecting line and the theoretical center connecting line of each group of spots; translating the initial spot center point and the initial annular center point according to the horizontal axis offset and / or the vertical axis offset to compensate for the horizontal axis offset error and / or the vertical axis offset error; and / or, rotating the initial spot center point and the initial annular center point according to the rotation matrix corresponding to the rotation offset to compensate for the rotation angle error; The optical imaging deviation compensation strategy includes: determining the correction parameters through a calibration test for a camera used for optical imaging; and compensating for the optical imaging deviation of the initial spot center point and the initial annular center point by using the correction parameters.
[0010] Preferably, in the lens power measurement method, the step of determining the initial light spot center point according to the light spot profile and determining the initial ring center point according to the ring profile further comprises the step of compensating the light spot gray value and the ring gray value according to a preset light source compensation strategy and an ambient light interference compensation strategy. The preset light source compensation strategy comprises: acquiring the actual power of the light source, querying a preset power gray mapping table according to the actual power, and determining the light spot gray mean value and the ring gray mean value corresponding to the actual power; if the light spot gray mean value or the ring gray mean value is not within a preset gray mean value range, triggering a compensation control mode of the light source. The ambient light interference compensation strategy comprises: acquiring a dark field image collected before the measurement starts, obtaining the light spot background gray and the ring background gray in the dark field image; and performing adaptive gain control on the light spot gray value and the ring gray value in the optical imaging information according to the light spot background gray and the ring background gray to realize ambient light interference compensation.
[0011] Preferably, in the lens power measurement method, the step of calculating the light spot center positioning confidence and the ring center positioning confidence comprises: determining a light spot effective data proportion according to the ratio of the number of remaining light spots to the total number of light spots, and determining a ring effective data proportion according to the ratio of the number of remaining rings to the total number of rings; determining a light spot precision coefficient according to the standard deviation of the offset of each light spot, and determining a ring precision coefficient according to the standard deviation of the offset of each ring; determining the light spot center positioning confidence according to the product of the light spot effective data proportion and the light spot precision coefficient, and determining the ring center positioning confidence according to the product of the ring effective data proportion and the ring precision coefficient.
[0012] Preferably, in the lens power measurement method, the step of obtaining the power value of the lens to be measured by using a weighted fusion algorithm according to the light spot center positioning confidence, the first power value, the ring center positioning confidence and the second power value comprises: Dfinal=(C1×D1+C2×D2) / (C1+C2); wherein D1 represents the first power value, D2 represents the second power value, C1 represents the light spot center positioning confidence, and C2 represents the ring center positioning confidence. If the lens to be measured is a standard spherical mirror, the light spot center positioning confidence and the ring center positioning confidence are fixed values. If the to-be-tested lens is a non-standard lens, the spot center positioning reliability and the annular center positioning reliability are variable values, and the closer to the edge of the to-be-tested lens, the smaller the value.
[0013] In a second aspect, the technical solution of the present application provides a computer program product, comprising computer programs / instructions, characterized in that the computer programs / instructions are executed by a processor to realize the steps of the lens power measurement method of any one of the first aspect.
[0014] In a third aspect, the technical solution of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored on the memory, wherein the processor executes the computer program to realize the steps of the lens power measurement method of any one of the first aspect.
[0015] The above technical solution provided by the present application has the following technical effects compared with the prior art: The lens power measurement method, storage medium and electronic device provided by the present application, in which the optical imaging information of the to-be-tested lens obtained in the method is the imaging information of the incident light of the to-be-tested lens on the screen after passing through the double diaphragm, so it includes not only the spot corresponding to the Hartmann diaphragm but also the annulus corresponding to the annular diaphragm. On this basis, the initial spot center point and the initial annular center point can be obtained first, and before the power value is obtained, the initial spot center point and the initial annular center point are calibrated by using the lens installation deviation compensation strategy and the optical imaging deviation compensation strategy to obtain more accurate spot center point and annular center point. The first power value can be calculated by using the spot center point, and the second power value can be calculated by using the annular center point. The confidence of the two power value calculation results is given, and the power value of the to-be-tested lens is obtained by using the weighted fusion algorithm according to the spot center positioning reliability, the first power value, the annular center positioning reliability and the second power value, so that a power value with high accuracy can be calculated. In the present application, the spot and the annulus are processed respectively, and the compensation strategy is used to calibrate the calculation results, so as to avoid the influence of poor spot imaging quality on the power value calculation results, and the high-cost device is not needed, which has the advantages of high precision and low cost compared with the prior art. BRIEF DESCRIPTION OF DRAWINGS
[0016] Figure 1 The flowchart of the lens power measurement method according to an embodiment of the present application is described. Figure 2 The optical path structure schematic diagram for obtaining the optical imaging information according to an embodiment of the present application is described. Figure 3 The schematic diagram of the optical imaging information of the standard spherical lens according to an embodiment of the present application is described. Figure 4aThis is a schematic diagram illustrating the initial spot center point confirmation according to an embodiment of the present invention; Figure 4b This is a schematic diagram illustrating the initial ring center point confirmation according to an embodiment of the present invention; Figure 5 This is a flowchart of the preprocessing procedure according to an embodiment of the present invention; Figure 6 This is a schematic diagram of the optical imaging information of a non-standard lens according to an embodiment of the present invention; Figure 7 This is a fitting curve for a standard lens based on a light spot, as described in one embodiment of the present invention; Figure 8 This is a fitting curve for a standard lens based on a ring, as described in one embodiment of the present invention; Figure 9 This is a schematic diagram of the hardware connections of an electronic device for performing a lens power measurement method according to an embodiment of the present invention. Detailed Implementation
[0017] The specific embodiments of this application will be further described below with reference to the accompanying drawings.
[0018] It is readily understood that, based on the technical solution of this application, various structural and implementation methods can be interchanged by those skilled in the art without altering the essential spirit of this application. Therefore, the following detailed embodiments and accompanying drawings are merely illustrative examples of the technical solution of this application and should not be considered as the entirety of this application or as limitations or restrictions on the technical solution of the application.
[0019] This embodiment provides a method for measuring lens power, applied in a focimeter, such as... Figure 1 As shown, the method includes the following steps: S100: Acquire optical imaging information of the lens under test.
[0020] like Figure 2 As shown, when the lens 20 under test needs to be measured, the optical imaging information is: the image information formed on the screen 25 after the light beam emitted from the light source 21 passes sequentially through the collimating lens 22, the Hartmann stop 23, the annular stop 24 (the positions of the two stops can be interchanged) and the lens 20 under test. If the crystal 20 under test is a standard spherical mirror, the image information on the screen 25 can be obtained by capturing it with a camera as shown below. Figure 3 As shown. Optical imaging information 30 includes a background, a light spot 301, and a ring 302 (the number of rings is consistent with the number of rings in the ring aperture; in this embodiment, one is used as an example).
[0021] S200: Determine the light spot contour and the annular contour in the optical imaging information; the light spot contour corresponds to the aperture in the Hartmann aperture, and the annular contour corresponds to the aperture in the annular aperture.
[0022] In practice, image processing techniques can be used to identify light spots and ring contours by distinguishing grayscale values and brightness values.
[0023] S300: Determine the initial light spot center point based on the light spot contour, and determine the initial ring center point based on the ring contour.
[0024] In practice, the coordinates of the initial spot center point and the initial ring center point can be directly calculated using methods such as the contour centroid method, the minimum circumcircle, and the least squares circle fitting method.
[0025] S400: The positions of the initial spot center point and the initial ring center point are calibrated according to the lens mounting deviation compensation strategy and the optical imaging deviation compensation strategy, such as... Figure 4a and Figure 4b As shown, the center point 3011 of the light spot and the center point 3021 of the ring are obtained.
[0026] Specifically, the lens under test may be offset during installation, which affects the position of the initial spot center point and the initial ring center point. The offset during lens installation is identified and compensated according to the lens installation deviation compensation strategy. When the intrinsic distortion coefficient of the camera that captures the screen needs to be calibrated, the calibration parameters are obtained through the optical imaging deviation compensation strategy to calibrate the position of the initial spot center point and the initial ring center point.
[0027] S500: Calculate the first power value of the lens under test based on the center point of the light spot, and calculate the second power value of the lens under test based on the center point of the ring.
[0028] In practice, the first focal length value is calculated by offsetting the center point of the light spot from the center position of the standard light spot. The second focal length value is calculated based on the radii of the inner and outer circles of the ring (if the actual fitting result is an ellipse, the radius is transformed into the lengths of the major and minor axes).
[0029] S600: Calculate the reliability of the spot center location and the ring center location.
[0030] In practice, the effectiveness of each light spot can be verified, and the ratio of the number of effective light spots to the total number of light spots can be determined to establish the reliability of the center location of the light spot. Similarly, the effectiveness of each ring can be verified, and the ratio of the number of effective rings to the total number of rings can be determined to establish the reliability of the center location of the ring.
[0031] S700: Based on the location confidence of the light spot center, the first focal length value, the location confidence of the ring center, and the second focal length value, a weighted fusion algorithm is used to obtain the focal length value of the lens under test. The focal length value obtained in this step is a more accurate result obtained under the premise of optimizing image imaging quality and without adding a complex sensor structure.
[0032] The above-described scheme provided in this embodiment obtains the optical imaging information of the lens under test 20, which is the imaging information of the incident light of the lens under test after passing through the double apertures on the screen 25. Therefore, it includes both the light spot corresponding to the Hartmann aperture 23 and the ring corresponding to the annular aperture 24. Based on this, the initial light spot center point and the initial ring center point can be obtained first. Before obtaining the focal length value, the initial light spot center point and the initial ring center point are calibrated using the lens mounting deviation compensation strategy and the optical imaging deviation compensation strategy to obtain a more accurate light spot center point 3011 and annular center point 3021. The first focal length value can be calculated using the light spot center point, and the second focal length value can be calculated using the ring center point. Confidence levels are assigned to the two focal length value calculation results. Based on the light spot center positioning confidence level, the first focal length value, the ring center positioning confidence level, and the second focal length value, a weighted fusion algorithm is used to obtain the focal length value of the lens under test, which can calculate a focal length value with high accuracy. The proposed solution processes both light spot and ring-shaped graphic information separately and uses a compensation strategy to calibrate the calculation results. This avoids the impact of poor light spot imaging quality on the focal length calculation results. Furthermore, it can be implemented without the need for high-cost devices, and compared with existing technologies, it has the advantages of high accuracy and low cost.
[0033] Preferably, in the above scheme, step S200, determining the spot contour and ring contour in the optical imaging information, further includes preprocessing the optical imaging information, such as... Figure 5 As shown, the preprocessing includes: S201: Perform Gaussian filtering on the optical imaging information to eliminate high-frequency noise in the optical imaging information and obtain smoothed optical imaging information.
[0034] In practice, the optical imaging information is converted into a single-channel grayscale image to avoid interference from the color channel in the filtering effect. A Gaussian kernel with σ=1.2 is used, and the kernel size is determined to be 5×5. The Gaussian filtering function is then called to filter the grayscale image, achieving a balance between high-frequency noise reduction and preservation of spot / ring details. The OpenCV function cv2.GaussianBlur() can directly call the Gaussian filtering function.
[0035] S202: Perform adaptive threshold segmentation processing on the smoothed optical imaging information to obtain the boundary line between the light spot and the background and the boundary line between the ring and the background, thus obtaining the segmented optical imaging information.
[0036] The principle of adaptive thresholding segmentation is local dynamic thresholding. The image is divided into multiple local blocks, and a "local threshold" is calculated for each block based on the gray-level statistics of pixels within the block, such as the mean or Gaussian weighted mean. The segmentation threshold for each pixel is determined by the threshold of its local block; in practice, the local threshold needs to be in the range of 120-180. That is, if a pixel's gray-level exceeds the threshold, it is considered to belong to a spot or ring; otherwise, it is considered to belong to the background. After classifying each pixel, the boundary between spots and background, as well as the boundary between rings and background, can be identified.
[0037] S203: For the light spot in the segmented optical imaging information, fill the internal holes of the light spot by expanding the edge of the light spot, then restore the original size of the light spot, and then eliminate the isolated scattered points in the light spot to complete the preprocessing of the optical imaging information.
[0038] This step is used to repair defects in the light spot (internal holes, isolated points) while maintaining the original shape of the light spot. Expanding the edge of the light spot and filling internal holes is a morphological dilation operation in digital image processing. Using the edge pixels of the light spot as seeds, a pre-set structuring element (such as a 3×3 structuring element) is used to expand inwards the light spot and perform a closing operation, gradually filling the blank area surrounded by the edge until the hole is completely covered. Restoring the original size of the light spot is done using a morphological erosion operation. Using structuring elements of the same size and shape as those in the dilation stage, the expanded edge of the light spot is shrunk until the outer contour, area, and other dimensional parameters of the light spot return to the original state after segmentation. Eliminating isolated points in the light spot is done using a morphological opening operation. Small-sized structuring elements (such as a 1×1 structuring element) are used to preferentially replace isolated points, while having minimal impact on the large-sized light spot body.
[0039] Through the above steps, this solution can repair spot defects without destroying the original geometric features.
[0040] Furthermore, the above-mentioned step S200 also includes: S204: Obtain the spot area and circularity of each spot, filter out spots whose spot area is not within the preset spot area range, and filter out spots whose circularity is less than the circularity threshold.
[0041] This step calculates two key geometric features—spot area and circularity—to eliminate spots that do not meet preset standards, ultimately retaining valid spots with regular shapes and acceptable sizes. Specifically, all independent spot connected regions are marked using a connected component labeling method. The number of pixels within each connected region is counted, which represents the pixel area of the spot. Based on pre-set urban / rural parameters corresponding to the camera, the pixel area is converted into the actual physical area. The formula for calculating circularity is: Circularity = 1 indicates a perfectly circular light spot; a smaller circularity indicates a more irregular light spot. In this scheme, the range of the light spot area can be determined based on the standard area of the Hartmann aperture imaged on the screen, with a fluctuation range of 10%. The circularity threshold can be selected as 0.8.
[0042] S205: Obtain the ring width and roundness of the ring profile, and filter out rings whose ring width is not within the preset ring width range and rings whose roundness is less than the roundness threshold.
[0043] The ring width reflects the average distance between the inner and outer contours of the ring (to avoid errors caused by uneven width in some areas), and the calculation method for roundness is the same as in step S204.
[0044] In this scheme, the range of the annular width can be determined based on the standard area of the annular aperture on the screen, with a fluctuation range of 10%, and the circularity threshold can be selected as 0.8.
[0045] S206: Obtain the light spot contour of the remaining light spot as the light spot contour, and obtain the ring contour of the remaining ring as the ring contour.
[0046] The above steps preserve valid spot and ring data, ensuring high accuracy of the spot and ring data used for subsequent analysis.
[0047] Preferably, in the above scheme, step S300, determining the initial light spot center point based on the light spot contour and determining the initial ring center point based on the ring contour, includes: S301: Regarding the outline of the light spot: Its center position coordinates (cx) are obtained using multiple algorithms. i cy i ); (cx i cy i ( ) represents the x and y coordinates of the center position obtained by the i-th algorithm; the weight value α for different algorithms is determined based on the circularity of the light spot outline. i ,and n is the total number of algorithm types; the initial center point coordinates (cx, cy) of the light spot contour are calculated, where: cx = cy= ; In specific implementation, five algorithms can be used: the result obtained by the centroid method is (cx1, cy1), the result obtained by the least circumscribed circle method is (cx2, cy2), the result obtained by the least squares circle fitting method is (cx3, cy3), the result obtained by the RANSAC circle fitting method is (cx4, cy4), and the result obtained by the RANSAC ellipse fitting method is (cx5, cy5); the initial center point coordinates (cx, cy) of the final spot contour are: cx=cx1×α1+cx2×α2+cx3×α3+cx4×α4+cx5×α5; cy=cy1×α1+cy2×α2+cy3×α3+cy4×α4+cy5×α5; The above weighting can be determined based on empirical values. For example, the light spot can be divided into three levels based on its circularity: high circularity, medium circularity, and low circularity. The higher the circularity, the higher the weighting values for least squares circle fitting and RANSAC circle fitting. The lower the circularity, the higher the weighting values for the centroid method.
[0048] S302: Regarding the annular contour: Determine the inner and outer rings of the annular profile; Based on the center position coordinates (x) of the inner ring 01 y 01 ) and the center position coordinates (x) of the outer ring 02 y 02 ) Calculate the initial coordinates (x, y) of the annular center point of the annular profile. 00 y 00 ), where: x 00 =(x 01 +x 02 ) / 2, y 00 =(y 01 +y 02 ) / 2.
[0049] The above steps enabled sub-pixel fitting and localization of the light spot and the ring.
[0050] In the above scheme, step S300 also includes a step of compensating the gray values of the light spot and the ring based on a preset light source compensation strategy and an ambient light interference compensation strategy: S3001: The preset light source compensation strategy includes: obtaining the actual power of the light source, querying a preset power grayscale mapping table based on the actual power, and determining the average grayscale value of the spot and the average grayscale value of the ring corresponding to the actual power; if the average grayscale value of the spot or the average grayscale value of the ring is not within the preset grayscale value range, the compensation control mode of the light source is triggered. In specific implementation, a power grayscale mapping table can be pre-established at a built-in power monitoring point (sampling frequency 10Hz) in the light source. For example, when the average grayscale value of the spot is I0 at the reference power P0=10mW, and the average grayscale value corresponding to the measured power P1 is I1, then the compensated grayscale value Icomp=I0×(P1 / P0); if |P1-P0|>10%, the compensation control mode is triggered, mainly including constant temperature control of the light source, and the data is marked for retesting.
[0051] S3002: The ambient light interference compensation strategy includes: acquiring a dark field image collected before the measurement starts, and obtaining the background grayscale of the light spot and the background grayscale of the ring in the dark field image; and performing adaptive gain control on the grayscale value of the light spot and the background grayscale of the ring in the optical imaging information according to the background grayscale of the light spot and the background grayscale of the ring to achieve ambient light interference compensation. In practice, before the measurement begins, the light source is turned off, and a 1-frame dark field image grayscale Ienv is acquired. After the light source is turned off, the image only contains the background grayscale generated by ambient light. The acquired Ienv at this time can accurately represent the interference intensity of the current ambient light. During the measurement process (when the light source is turned on), the grayscale Imaes of the light spot image is calculated in real time. By using the difference Inet = Imaes - Ienv, the ambient light interference can be directly removed to obtain the effective grayscale Inet that only reflects the target itself. Under different ambient light conditions (e.g., 0 lux → 500 lux), Ienv will change, which may cause the mean value of Inet to deviate from 100-120 (e.g., when the ambient light is too strong, Imaes saturates, and Inet may be too low). By adjusting the image gain (amplifying / reducing the grayscale signal), the mean value of Inet can be pulled back to the target range to ensure grayscale stability. Through adaptive gain adjustment, the mean grayscale value of Inet in the effective area of the light spot is kept stable at 100-120 (8-bit image) under different ambient light conditions (0-500 lux), thus achieving adaptive adjustment.
[0052] Furthermore, in the above scheme, S400 calibrates the positions of the initial spot center point and the initial ring center point according to the lens mounting deviation compensation strategy and the optical imaging deviation compensation strategy, obtaining the following from the spot center point and the ring center point: S401: The lens mounting deviation compensation strategy includes: selecting two sets of light spots, one set of light spots having a theoretical center line parallel to the horizontal axis, and the other set of light spots having a theoretical center line parallel to the vertical axis; determining the horizontal axis offset, vertical axis offset, and / or rotational offset based on the positional relationship between the actual center line and the theoretical center line of each set of light spots; translating the initial light spot center point and the initial annular center point according to the horizontal axis offset and / or the vertical axis offset to compensate for the horizontal axis offset error and / or the vertical axis offset error; and / or, performing rotation angle compensation on the initial light spot center point and the initial annular center point according to the rotation matrix corresponding to the rotational offset. That is, by using two sets of orthogonal light spots (horizontal axis parallel, vertical axis parallel), the planar rigid body deviation of the lens mounting (including at least one of horizontal axis translation, vertical axis translation, and rotational offset) is captured, and then the initial center point coordinates are corrected through translation and / or rotational compensation. Understandably, in this scheme, the design center coordinates of each light spot when the lens is without deviation can be pre-calibrated and stored in the focimeter. For example, if both sets of light spots have a unidirectional X-axis offset Δx = Δxdev, then the compensation amount is -Δxdev; if both sets of light spots have rotational deviations, these are corrected using a rotation matrix: x′ = xcosθ + ysinθ, y′ = -xsinθ + ycosθ, where θ is the rotation angle, calculated from the light spot offset.
[0053] S402: The optical imaging deviation compensation strategy includes: determining correction parameters through calibration experiments for a camera used for optical imaging; and using the correction parameters to compensate for optical imaging deviations at the initial spot center point and the initial ring center point. The camera calibration process includes: Obtain the camera intrinsic parameter matrix : ; Where f x f y For pixel focal length, c x c y The principal point coordinates are given; ideally, the principal point should be the image center. s is the pixel skew coefficient, which is close to 0 in modern industrial cameras.
[0054] The distortion coefficients include radial distortion and tangential distortion. Radial distortion includes uneven refractive index of the lens, which causes light to be deflected at a different degree than at the paraxial position, with coefficients (k1, k2, k3, k4). Tangential distortion includes non-parallelism between the lens and the image sensor, and deformation of the sensor itself, with coefficients (p1, p2).
[0055] In practice, the `cv2.undistort` function in OpenCV can be used for correction. K = np.array([[f x ,0,cx ],[0,f y ,c y The intrinsic parameter matrix is corrected using [0,0,1], and the distortion coefficients are corrected using D=np.array([k1,k2,p1,p2,k3]). After compensation, the standard deviation of the offset between the two sets of light spots is ≤0.005 pixels, indicating that the obtained center point of the light spot and the center point of the ring have high accuracy.
[0056] Preferably, in the above scheme, the calculation of the spot center location confidence and the ring center location confidence in step S600 includes: S601: Determine the percentage of effective light spot data based on the ratio of the number of remaining light spots (as mentioned above, the remaining light spots are the effective light spots) to the total number of light spots (which can be determined based on the number of apertures of the Hartmann aperture); determine the percentage of effective ring data based on the ratio of the number of remaining rings (as mentioned above, the remaining light spots are the effective rings) to the total number of rings (which can be determined based on the number of rings in the apertures of the ring aperture).
[0057] S602: Determine the spot accuracy coefficient based on the standard deviation σ1 of the offset of each spot, and determine the ring accuracy coefficient based on the standard deviation σ2 of the offset of each ring.
[0058] As an optional solution, the spot accuracy coefficient = 1 - 0.1 × σ1, and the ring accuracy coefficient = 1 - 0.2 × σ2.
[0059] S603: Determine the confidence level of the spot center location based on the product of the effective data ratio of the spot and the spot accuracy coefficient, and determine the confidence level of the ring center location based on the product of the effective data ratio of the ring and the ring accuracy coefficient.
[0060] In this scheme, the confidence level of spot center location = (number of effective spots / total number of spots) × (1 - 0.1 × σ1); The reliability of the center of the ring is calculated as follows: (Number of valid rings / Total number of rings) × (1 - 0.2 × σ²).
[0061] The maximum value for the location reliability of the light spot center and the location reliability of the ring center is 1. The higher the value, the more reliable the measurement.
[0062] Preferably, in the above scheme, in step S700, the focal power value of the lens under test is obtained by using a weighted fusion algorithm based on the confidence level of the spot center location, the first focal power value, the confidence level of the ring center location, and the second focal power value. The focal power value of the lens under test is calculated in the following way: S701: Dfinal=(C1×D1+C2×D2) / (C1+C2); where D1 represents the first focal length value, D2 represents the second focal length value, C1 represents the confidence level of the spot center location, and C2 represents the confidence level of the ring center location. S702: If the lens under test is a standard spherical lens, the confidence level of the spot center location and the confidence level of the annular center location are fixed values. If the lens under test is a non-standard lens (such as an aspherical lens, a progressive multifocal lens, or a point diffuser lens), the confidence level of the spot center location and the confidence level of the annular center location are variable values, with the value decreasing closer to the edge of the lens. For example, a confidence level of 0.8 is used within a radius of 4mm, a confidence level of 0.2 is used in the 6-7mm range, and a Gaussian transition is used in the middle region to change the confidence level from 0.8 to 0.2. For point diffuser lenses, a high confidence level at the center, a low confidence level at the edge, and a Gaussian transition confidence level are used to avoid the interference of edge positioning errors on the final focal power, ensuring that Dfinal can truly reflect the actual optical performance of the lens.
[0063] like Figure 6 As shown, during the measurement of non-standard lenses, the imaging quality of the light spot in its optical imaging information is poor, but the imaging quality of the ring is high. Therefore, the focal power value can be calculated by identifying the ring. In the calculation, a higher confidence value is chosen for the ring center location, while a lower confidence value is chosen for the light spot center location, and the confidence value decreases as the position approaches the edge.
[0064] The solubility measurement method obtained through the above scheme can be verified using multiple different types of lenses with known solubility values (including spherical, aspherical, progressive multifocal lenses, and dot diffuse lenses). Once the verification passes a certain number of times, it can be considered applicable to the solubility measurement of various types of lenses.
[0065] Furthermore, the proposed solution exhibits high accuracy in power measurement, thus allowing for the measurement of lenses with different power values to obtain a standard fitting curve, such as... Figure 7 and Figure 8 As shown, Figure 7 It is a fitting curve based on a standard lens with a light spot. Figure 8 The curve above is a fitting curve based on a standard ring lens. In the curve, represents the pixel position, and the vertical axis represents the power value. The red dots are the measurement results, and the green curve is the curve fitted based on the measurement results.
[0066] This application also provides a computer program product, including a computer program / instructions, which, when executed by a processor, implement the steps of the lens power measurement method described in any of the above method embodiments.
[0067] This application also provides an electronic device, such as... Figure 9 As shown, the electronic device includes at least one processor 91 and at least one memory 92. The at least one memory 92 stores program information. After reading the program information, the at least one processor 91 executes the lens power measurement method described in any of the above embodiments. The device may further include an input device 93 and an output device 94. The processor 91, memory 92, input device 93, and output device 94 are communicatively connected. The memory 92, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. The processor 91 executes various functional applications and data processing by running the non-volatile software programs, instructions, and modules stored in the memory 92, thereby implementing the lens power measurement method provided in any of the above embodiments. The memory 92 may include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a function; the data storage area may store data created based on the use of the lens power measurement method, etc. Furthermore, memory 92 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state memory device. In some embodiments, memory 92 may optionally include memory remotely located relative to processor 91, which can be connected via a network to the apparatus performing the lens power measurement method. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof. Input device 93 may receive user clicks and generate signal inputs related to user settings and function control of the lens power measurement method. Output device 94 may include a display device such as a display screen. When the one or more modules are stored in memory 92 and are executed by the one or more processors 91, the lens power measurement method in any of the above method embodiments is performed.
[0068] As needed, the above technical solutions can be combined to achieve the best technical effect.
[0069] The above are merely the principles and preferred embodiments of this application. It should be noted that, for those skilled in the art, several other modifications can be made based on the principles of this application, and these modifications should also be considered within the scope of protection of this application.
Claims
1. A method for measuring lens power, characterized in that, include: Obtain the optical imaging information of the lens under test, wherein the optical imaging information is: the image information formed on the screen after the light beam emitted by the light source passes through the collimating lens, Hartmann stop, annular stop and the lens under test in sequence; The light spot contour and the annular contour in the optical imaging information are determined; the light spot contour corresponds to the aperture in the Hartmann aperture, and the annular contour corresponds to the aperture in the annular aperture; The initial light spot center point is determined based on the light spot contour, and the initial ring center point is determined based on the ring contour. The positions of the initial spot center point and the initial ring center point are calibrated according to the lens mounting deviation compensation strategy and the optical imaging deviation compensation strategy to obtain the spot center point and the ring center point. The first power value of the lens under test is calculated based on the center point of the light spot, and the second power value of the lens under test is calculated based on the center point of the ring. Calculate the reliability of the spot center location and the ring center location; The focal length of the lens under test is obtained by using a weighted fusion algorithm based on the location confidence of the light spot center, the first focal length value, the location confidence of the ring center, and the second focal length value.
2. The lens power measurement method according to claim 1, characterized in that, The process of determining the spot contour and ring contour in the optical imaging information further includes preprocessing the optical imaging information, the preprocessing including: Gaussian filtering is applied to the optical imaging information to eliminate high-frequency noise and obtain smoothed optical imaging information. The smoothed optical imaging information is subjected to adaptive threshold segmentation to obtain the boundary line between the light spot and the background and the boundary line between the ring and the background, thus obtaining the segmented optical imaging information. For the light spot in the segmented optical imaging information, the internal holes of the light spot are filled by expanding the edge of the light spot, then the original size of the light spot is restored, and then the isolated scattered points in the light spot are eliminated to complete the preprocessing of the optical imaging information.
3. The lens power measurement method according to claim 2, characterized in that, In determining the spot contour and the annular contour in the optical imaging information, the spot contour and the annular contour are obtained in the following manner: Obtain the spot area and circularity of each spot, filter out spots whose spot area is outside the preset spot area range, and filter out spots whose circularity is less than the circularity threshold; Obtain the ring width and roundness of the ring contour, and filter out rings whose ring width is not within the preset ring width range and rings whose roundness is less than the roundness threshold; The remaining light spot outline is obtained as the light spot outline, and the remaining ring outline is obtained as the ring outline.
4. The lens power measurement method according to claim 3, characterized in that, The step of determining the initial light spot center point based on the light spot contour and determining the initial ring center point based on the ring contour includes: Regarding the outline of the light spot: Its center position coordinates (cx) are obtained using multiple algorithms. i cy i ); (cx i cy i ( ) represents the x and y coordinates of the center position obtained by the i-th algorithm; The weight value α for different algorithms is determined based on the circularity of the light spot outline. i ,and , where n is the total number of algorithm types; The initial center point coordinates (cx, cy) of the light spot contour are calculated, where: cx = cy= ; Regarding the aforementioned annular contour: Determine the inner and outer rings of the annular profile; According to the center position coordinates (x) of the inner ring 01 y 01 ) and the center position coordinates (x) of the outer ring 02 y 02 ) Calculate the initial coordinates (x, y) of the annular center point of the annular profile. 00 y 00 ), where: x 00 =(x 01 +x 02 ) / 2, y 00 =(y 01 +y 02 ) / 2.
5. The lens power measurement method according to claim 1, characterized in that, The positions of the initial spot center point and the initial ring center point are calibrated according to the lens mounting deviation compensation strategy and the optical imaging deviation compensation strategy, resulting in the following: The lens mounting deviation compensation strategy includes: selecting two sets of light spots, one set of light spots having a theoretical center line parallel to the horizontal axis, and the other set of light spots having a theoretical center line parallel to the vertical axis; determining the horizontal axis offset, vertical axis offset, and / or rotation offset based on the positional relationship between the actual center line and the theoretical center line of each set of light spots; translating the initial light spot center point and the initial annular center point according to the horizontal axis offset and / or the vertical axis offset to compensate for the horizontal axis offset error and / or the vertical axis offset error; and / or, performing rotation angle compensation on the initial light spot center point and the initial annular center point according to the rotation matrix corresponding to the rotation offset. The optical imaging deviation compensation strategy includes: determining correction parameters through calibration experiments for a camera used for taking optical images; and using the correction parameters to compensate for optical imaging deviations of the initial spot center point and the initial ring center point.
6. The lens power measurement method according to claim 5, characterized in that, The step of determining the initial light spot center point based on the light spot contour and the initial ring center point based on the ring contour further includes the step of compensating the light spot gray value and the ring gray value according to a preset light source compensation strategy and an ambient light interference compensation strategy: The preset light source compensation strategy includes: obtaining the actual power of the light source, querying a preset power grayscale mapping table based on the actual power, and determining the average grayscale value of the spot and the average grayscale value of the ring corresponding to the actual power; if the average grayscale value of the spot or the average grayscale value of the ring is not within the preset grayscale value range, then triggering the compensation control mode of the light source. The ambient light interference compensation strategy includes: acquiring a dark field image collected before the measurement begins, and obtaining the background grayscale of the light spot and the background grayscale of the ring in the dark field image; and performing adaptive gain control on the grayscale values of the light spot and the ring in the optical imaging information based on the background grayscale of the light spot and the background grayscale of the ring to achieve ambient light interference compensation.
7. The lens power measurement method according to any one of claims 3-6, characterized in that, The calculation of the spot center location confidence and the ring center location confidence includes: The effective data percentage of light spots is determined by the ratio of the number of remaining light spots to the total number of light spots; the effective data percentage of rings is determined by the ratio of the number of remaining rings to the total number of rings. The spot accuracy coefficient is determined based on the standard deviation of the offset of each spot, and the ring accuracy coefficient is determined based on the standard deviation of the offset of each ring. The reliability of the spot center location is determined by multiplying the effective data ratio of the spot and the spot accuracy coefficient, and the reliability of the ring center location is determined by multiplying the effective data ratio of the ring and the ring accuracy coefficient.
8. The lens power measurement method according to claim 7, characterized in that, The method for obtaining the focal power value of the lens under test using a weighted fusion algorithm based on the location confidence of the light spot center, the first focal power value, the location confidence of the ring center, and the second focal power value is as follows: Dfinal=(C1×D1+C2×D2) / (C1+C2); Where D1 represents the first focal length value, D2 represents the second focal length value, C1 represents the center position reliability of the light spot, and C2 represents the center position reliability of the ring. If the lens under test is a standard spherical mirror, then the confidence level of the spot center location and the confidence level of the ring center location are fixed values; If the lens under test is a non-standard lens, the reliability of the spot center positioning and the reliability of the ring center positioning are variable values, and the variation pattern is that the value is smaller as it gets closer to the edge of the lens under test.
9. A computer program product, characterized in that, The method includes a computer program / instruction, characterized in that, when executed by a processor, the computer program / instruction implements the steps of the lens power measurement method according to any one of claims 1-8.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the lens power measurement method according to any one of claims 1-8.