Autofocus voice coil motor vcm linearity test method, apparatus, product, and medium
By employing image acquisition and processing techniques, combined with a three-dimensional accumulator and a suppression radius mechanism, the instability problem of laser displacement sensor measurement methods in complex environments was solved, enabling high-precision evaluation of the linearity of autofocus voice coil motors (VCMs).
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUNAN JINKANG OPTOELECTRONICS CO LTD
- Filing Date
- 2026-02-09
- Publication Date
- 2026-05-29
AI Technical Summary
Existing laser displacement sensor measurement methods are easily affected by external factors such as vibration, temperature changes and electromagnetic interference when testing the linearity of autofocus voice coil motors (VCMs), resulting in poor stability and repeatability of test results and making it difficult to guarantee the reliability of the test results.
Image acquisition technology is used to acquire the test image containing Mark points, perform Gaussian blur processing and gradient calculation, identify the edge features of Mark points, combine a three-dimensional accumulator array and a suppression radius mechanism to calculate the pixel distance between Mark points, and finally calculate the motor linearity index through the error distribution function.
It effectively avoids the influence of external interference on test results, improves the accuracy and precision of motor linearity evaluation, provides a reliable basis for linearity evaluation, and enables accurate motor performance evaluation in complex environments.
Smart Images

Figure CN122107930A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of precision measurement, specifically to a method, equipment, product, and medium for testing the linearity of an autofocus voice coil motor (VCM). Background Technology
[0002] As modern manufacturing moves towards higher precision and automation, precision motion control equipment is being used more and more widely in industrial production. As the core actuator of various automated equipment, the motion accuracy of motors directly affects the performance of the entire system. Especially in high-precision applications such as semiconductor manufacturing, precision machining, and optical inspection, the linearity performance of motors has become a key indicator for measuring equipment quality.
[0003] Currently, the linearity testing of autofocus voice coil motors (VCMs) primarily employs a laser displacement sensor method. This method measures displacement by illuminating the target object with a laser beam and analyzing changes in reflected light, offering high measurement accuracy. During testing, the laser displacement sensor is fixed to the motor's motion platform. By controlling the motor to move to different positions, the laser displacement sensor measures the actual displacement of the motor in real time and compares it with the theoretical stroke value, thereby evaluating the motor's linearity performance.
[0004] However, existing laser displacement sensor measurement methods have significant shortcomings in practical applications. These methods are highly demanding in terms of testing environment and are easily affected by external factors such as vibration, temperature changes, and electromagnetic interference, resulting in poor stability and repeatability of the test results. Especially in complex environments such as industrial sites, where numerous external interference factors exist, laser displacement sensor measurement methods often struggle to guarantee the reliability of test results, affecting the accuracy of motor linearity assessment. Summary of the Invention
[0005] This application provides a method, device, product, and medium for testing the linearity of an autofocus voice coil motor (VCM), which can improve the accuracy of motor linearity evaluation.
[0006] The first aspect of this application provides a method for testing the linearity of an autofocus voice coil motor (VCM), specifically including: The motor under test is controlled to move sequentially to multiple test positions according to a preset displacement increment, and each test position corresponds to a theoretical stroke value; At each of the test locations, a test image containing two Mark points is acquired. The test image is then converted to obtain a grayscale image. The test image contains a fixed first Mark point and a second Mark point that moves with the test motor. The grayscale image data is subjected to Gaussian blurring to obtain a preprocessed image; Gradient calculation is performed on the preprocessed image to form a gradient image, and the set of edge point coordinates of the gradient image is determined. Scan the set of edge point coordinates within a preset radius of each Mark point to obtain the first center coordinates, and determine the second center coordinates based on the first center coordinates; Calculate the pixel distance between the coordinates of the first center of the circle and the coordinates of the second center of the circle; Multiply the pixel distance by a preset conversion coefficient to obtain the current physical distance between the two Mark points at each test location; Calculate the displacement deviation between each current physical distance and the corresponding theoretical travel value, and calculate the motor linearity index of each motor under test based on each displacement deviation.
[0007] By adopting the above technical solution, the testing system can complete the measurement without direct contact with the motor under test by using Mark points as test markers and acquiring the image of the test subject through image acquisition, effectively avoiding the influence of vibration and electromagnetic interference on the test results. Converting the image of the test subject to grayscale and performing Gaussian blurring effectively eliminates image noise and improves image quality; gradient calculation and filtering of edge point coordinate sets accurately identify the edge features of the Mark points; scanning within a preset radius to obtain the center coordinates further improves the accuracy of Mark point positioning. Combining the pre-calibrated conversion coefficient between pixels and actual physical length, pixel distance can be accurately converted to the current physical distance, ensuring the accuracy of the measurement results. Then, by calculating the displacement deviation between the current physical distance and the theoretical stroke value, the final motor linearity index can truly reflect the motor's motion accuracy, providing a reliable basis for motor performance evaluation and improving the accuracy of motor linearity assessment.
[0008] Optionally, the step of performing gradient calculation on the preprocessed image data to form a gradient image, and filtering the gradient image to obtain a set of edge point coordinates, includes: The gradient components of each pixel in the preprocessed image are calculated in the horizontal and vertical directions respectively. The gradient components in the two directions are vector synthesized to obtain the gradient magnitude of each pixel and form a gradient image. The gradient image is traversed, and pixels with gradient magnitudes greater than a preset gradient threshold are identified as edge points. An edge point coordinate set is generated based on the coordinate positions of each edge point.
[0009] By employing the aforementioned technical solution, simultaneously calculating and synthesizing the gradient components in both horizontal and vertical directions, the variation characteristics of the Mark point's edge in all directions can be comprehensively captured, avoiding the loss of edge information that might occur with single-direction gradient calculation. Setting a reasonable gradient threshold to filter the gradient image effectively removes weak edge responses caused by image noise or changes in ambient lighting, retaining only the strong gradient responses corresponding to the true edges of the Mark point, thereby improving the accuracy and robustness of edge detection. The final set of edge point coordinates more accurately reflects the geometric contour of the Mark point, providing a reliable data foundation for subsequent center coordinate calculations and further enhancing the overall accuracy of the VCM linearity test for autofocus voice coil motors.
[0010] Optionally, the step of scanning within a preset radius based on the set of edge point coordinates to obtain the coordinates of the first center of the circle includes: Establish a three-dimensional accumulator array, wherein the three dimensions of the three-dimensional accumulator array correspond to the x-coordinate of the center of the circle, the y-coordinate of the center of the circle, and the radius of the circle, respectively; The preset radius range of each Mark point is divided into multiple radius values according to the preset step size. Based on the coordinates of each edge point in the set of edge point coordinates and each radius value, multiple circle center positions are calculated through the geometric equation of the circle. The abscissa, ordinate, and radius value of the circle center corresponding to each circle center position are incremented by one in the corresponding count value in the three-dimensional accumulator array. In the three-dimensional accumulator array, the x-coordinate of the center of the circle with the largest count value and the y-coordinate of the center of the circle with the largest count value are used as the coordinates of the first center.
[0011] By employing the above technical solution, a three-dimensional accumulator array is used to simultaneously record the center coordinates and radius information, comprehensively preserving the geometric features of the Mark point and avoiding information loss that might occur from considering the center position alone. By meticulously dividing the radius range with a preset step size and combining it with the geometric equation of the circle to calculate the center position, accurate searching of the Mark point parameters can be achieved with a reasonable computational load. Utilizing a voting mechanism in the accumulator array, the contributions of all edge points to the center position are accumulated and statistically analyzed. The parameter combination with the highest number of votes is ultimately selected as the center coordinates. This not only effectively resists the influence of missing or noisy local edge points but also fully utilizes the overall distribution characteristics of the edge points, ensuring the optimal center positioning result and providing a more accurate reference point for subsequent distance calculations.
[0012] Optionally, determining the coordinates of the second center based on the coordinates of the first center includes: The suppression radius is set according to the coordinates of the first center of the circle; Calculate the Euclidean distance between each circle center position and the coordinates of the first circle center; In the three-dimensional accumulator array, the horizontal and vertical coordinate counts corresponding to the center positions where the Euclidean distance is less than the suppression radius are set to zero; The x-coordinate of the center of the circle with the largest remaining count value and the y-coordinate of the center of the circle with the largest remaining count value are used as the coordinates of the second center.
[0013] By adopting the above technical solution, the introduction of a suppression radius mechanism effectively avoids repeated detection of the center point in the vicinity of the first center point coordinates, ensuring that the detection result of the second center point is independent of the first Mark point. Using Euclidean distance for spatial distance measurement accurately reflects the actual interval between the center point positions, providing a reliable basis for spatial filtering. By clearing the accumulator array count within the suppression radius range, candidate positions far from the first center point can be retained while completely eliminating interference from local optima. Finally, the coordinates with the highest number of votes from the remaining candidate positions are selected as the coordinates of the second center point. This ensures both the spatial independence of the two Mark point detection results and maintains the reliability of the detection based on the voting mechanism, providing accurate reference point pairs for subsequent displacement calculations.
[0014] Optionally, the step of calculating the motor linearity index based on each displacement deviation includes: Establish the error distribution function between the displacement deviation and the test position; The fluctuation amplitude of the displacement deviation and the offset trend of the displacement deviation are calculated based on the error distribution function. The motor linearity index is calculated based on the fluctuation amplitude and the offset trend.
[0015] By adopting the above technical solution, an error distribution function between displacement deviation and test position is established, which can systematically describe the deviation change law during motor motion and provide a complete mathematical model for linearity evaluation. Calculating the fluctuation amplitude and offset trend of displacement deviation separately allows for the quantification of the nonlinear characteristics of motor motion from both fluctuating and systematic dimensions. The fluctuation amplitude reflects the magnitude of random errors during motion, while the offset trend characterizes the cumulative effect of systematic errors. Using the fluctuation amplitude and offset trend as comprehensive evaluation indicators considers both the stability of motor motion and the overall characteristics of the motion trajectory, thus providing a more comprehensive and objective reflection of the motor's linear motion quality.
[0016] Optionally, calculating the motor linearity index based on the fluctuation amplitude and the systematic offset trend includes: Obtain the total number of test locations, and calculate the motor linearity index based on the total number, the fluctuation amplitude, the offset trend, and the preset motor linearity formula; The formula for motor linearity is: ; Where L represents the motor linearity index, with a larger value indicating better linearity, and n represents the total number of test positions. The maximum value among all theoretical travel values. σ is the minimum value among all theoretical travel values, σ is the fluctuation amplitude, σ is calculated by the standard deviation of the displacement deviation, and k is the offset trend, which is represented by the absolute value of the slope of the linear fit of the error distribution function.
[0017] By adopting the above technical solution, a scientific and reasonable formula for evaluating motor linearity is proposed. This formula comprehensively considers key factors such as the number of test points, test range, random error, and systematic error, ensuring that the evaluation results not only reflect the essential characteristics of motor performance but also have good comparability. By using the standard deviation of displacement deviation as an indicator of fluctuation amplitude, the degree of random fluctuation in motor motion can be accurately quantified; by using the slope of the linear fitting of the error distribution function as an indicator of offset trend, the cumulative effect of systematic error can be effectively characterized. The design of the index values follows the intuitive principle that "the larger the value, the better the linearity," making it easy for engineers to understand and use. This evaluation method based on a mathematical model not only provides a unified evaluation standard but also effectively distinguishes motor products of different quality grades, providing a reliable quantitative basis for product quality control and process improvement.
[0018] Optionally, after calculating the motor linearity index based on each of the displacement deviations, the method further includes: Determine whether the motor linearity index meets the preset linearity threshold requirement; When the motor linearity index does not meet the preset linearity threshold requirement, abnormal test positions in each test position where the displacement deviation exceeds the preset deviation range are identified. Calculate the displacement correction value for each of the abnormal test locations, and generate a motor correction parameter table containing the abnormal test locations and the corresponding displacement correction values.
[0019] By adopting the above technical solution and judging based on a preset linearity threshold, motor products that do not meet quality requirements can be identified in a timely manner. For non-conforming products, the system automatically identifies the specific abnormal test location, achieving precise problem localization. By calculating displacement correction values and generating a correction parameter table, precise compensation basis is provided for subsequent motor control, effectively improving the motor's motion accuracy. This adaptive correction method based on measured data avoids the blindness of traditional experience-based correction and provides traceable correction records, significantly improving the linearity of motor motion. Simultaneously, the establishment of the correction parameter table provides data support for quality improvement of batch products, helping to optimize production processes and control strategies, and achieving continuous improvement in motor performance.
[0020] In a second aspect, this application provides an autofocus voice coil motor (VCM) linearity testing device, which includes: one or more processors and a memory; the memory is coupled to the one or more processors, and the memory is used to store computer program code, which includes computer instructions, and the one or more processors call the computer instructions to cause the autofocus voice coil motor (VCM) linearity testing device to perform the method described in the first aspect and any possible implementation thereof.
[0021] Thirdly, this application provides a computer program product containing instructions that, when the computer program product is run on an autofocus voice coil motor (VCM) linearity testing device, cause the autofocus voice coil motor (VCM) linearity testing device to perform the method described in the first aspect and any possible implementation thereof.
[0022] Fourthly, this application provides a computer-readable storage medium including instructions that, when executed on an autofocus voice coil motor (VCM) linearity testing device, cause the autofocus voice coil motor (VCM) linearity testing device to perform the method described in the first aspect and any possible implementation thereof. Attached Figure Description
[0023] Figure 1 This is a system architecture diagram of an autofocus voice coil motor (VCM) linearity testing system provided in an embodiment of this application; Figure 2 This is a flowchart illustrating a method for testing the linearity of an autofocus voice coil motor (VCM) according to an embodiment of this application. Figure 3 This is a schematic diagram of the structure of a VCM motor provided in an embodiment of this application; Figure 4 This is an exemplary hardware structure diagram of an autofocus voice coil motor (VCM) linearity testing device provided in an embodiment of this application. Detailed Implementation
[0024] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.
[0025] In the description of the embodiments of this application, the words "for example" or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design that is described as "for example" or "for instance" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design options. Rather, the use of the words "for example" or "for instance" is intended to present the relevant concepts in a specific manner.
[0026] In the description of the embodiments of this application, the term "multiple" means two or more. For example, multiple systems means two or more systems, and multiple screen terminals means two or more screen terminals. 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 indicated technical features. Thus, a feature defined with "first" or "second" may explicitly or implicitly include one or more of that feature. The terms "comprising," "including," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.
[0027] Figure 1 An architecture for a linearity testing system for an autofocus voice coil motor (VCM) is shown. For example... Figure 1 As shown, the system architecture may include a motor testing device 011, a network 012, and electronic devices 013. Network 012 provides a data transmission link between the motor testing device 011 and the electronic devices 013. Network 012 may include various connection types, such as wired or wireless communication links or fiber optic cables.
[0028] The motor testing device 011 can send motion status data to the electronic device 013 via the network 012. The motor testing device 011 is mainly responsible for moving to each test position according to the preset displacement increment and assisting in the acquisition of Mark point images.
[0029] The motor testing device 011 is hardware, which can be a motor device with precision motion control and position feedback functions, including but not limited to basic actuators such as stepper motors, servo motors, and linear motors.
[0030] Electronic device 013 is responsible for receiving motion control commands and performing comprehensive analysis and processing, including core functions such as motor motion control, image acquisition and processing, Mark point recognition and positioning, displacement deviation calculation, linearity index evaluation, and correction parameter generation. Electronic device 013 can adaptively evaluate motor performance based on test results and preset thresholds, calculate the optimal linearity index, and, combined with preset evaluation rules, ultimately achieve dynamic monitoring of motor motion accuracy. These analysis and processing results can be used to improve the accuracy and stability of motor motion control.
[0031] It should be noted that electronic devices can be either hardware or software. When an electronic device is hardware, it can be implemented as a distributed cluster of multiple electronic devices or as a single electronic device. When an electronic device is software, it can be implemented as multiple software programs or software modules (e.g., multiple software programs or software modules used to provide distributed processing) or as a single software program or software module. No specific limitations are set here.
[0032] It should be understood that Figure 1 The number of motor testing devices 011, networks 012, and electronic devices 013 shown is merely illustrative. Depending on implementation needs, there can be any number of motor testing devices 011, networks 012, and electronic devices 013. In particular, if test control does not need to be transmitted remotely, the above system architecture may exclude network 012 and include only motor testing devices 011 or electronic devices 013.
[0033] This application provides a method for testing the linearity of an autofocus voice coil motor (VCM), referencing... Figure 2 , Figure 2 This is a flowchart illustrating a method for testing the linearity of an autofocus voice coil motor (VCM) according to an embodiment of this application, including steps S101 to S108, as follows: S101: Control the motor under test to move sequentially to multiple test positions according to preset displacement increments, with each test position corresponding to a theoretical stroke value.
[0034] In this embodiment, the preset displacement increment refers to the pre-set step distance of each motor movement, used to represent the fixed increment value of the motor's displacement during each test. For example, if the displacement increment is set to 1mm, the motor will move sequentially to positions of 1mm, 2mm, 3mm, etc., for testing.
[0035] Specifically, the electronic device first acquires the motion parameter configuration of the motor under test (DUT). The DUT represents a precision motion device for which linearity evaluation is required, typically including stepper motors, servo motors, or linear motors. Based on preset displacement increments, the electronic device calculates and generates a series of test positions according to the principle of equal spacing. Each test position refers to a specific spatial coordinate point that the motor needs to sequentially reach and stop at during the test. The electronic device then sends motion control commands to drive the DUT to move gradually from its initial position according to preset displacement increments. When the motor reaches each test position, the electronic device pauses the motor movement and waits for the position to stabilize. Each test position has a corresponding theoretical travel value, which is the theoretical position the motor should reach, calculated based on the preset displacement increment and position number.
[0036] refer to Figure 3 This is a structural schematic diagram of a VCM motor provided in an embodiment of this application; like Figure 3 As shown, an external fixed base with a first mark point M1 is fixedly installed, and its position does not change with the movement of the motor. A target plate with a second mark point M2 is fixedly installed on the moving part of the motor under test. The field of view of an image acquisition device (such as an industrial camera) covers the first mark point M1 and the second mark point M2. When the motor moves, the second mark point M2 moves accordingly, causing a change in the distance between the two mark points. This method calculates the actual displacement of the motor by accurately measuring this distance change.
[0037] S102: At each test position, acquire a test image containing at least two Mark points, convert the test image to obtain a grayscale image, the test image contains a fixed first Mark point and a second Mark point that moves with the test motor.
[0038] In the embodiments of this application, a Mark point refers to a pre-set marker feature point on the object under test or in the test environment, used to represent the positional reference and measurement target during image processing. For example, a Mark point can be a circular mark, a cross mark, or a geometric pattern of a specific shape printed on a test plate.
[0039] Specifically, after the motor under test reaches and stabilizes at each test position, the electronic device captures images of the test area using an image acquisition device to obtain the image under test. This image is a raw color or multi-channel digital image containing the current positional information of the motor under test. During image acquisition, the electronic device ensures that each image under test contains at least two Mark points: a fixed first Mark point and a second Mark point that moves with the motor under test. After acquiring the image under test, the electronic device performs image conversion. Image conversion is a digital processing procedure that converts the raw multi-channel color image into a single-channel image, typically achieved through specific channel extraction. Through this image conversion operation, the electronic device ultimately obtains a grayscale image.
[0040] S103: Perform Gaussian blur processing on the grayscale image data to obtain a preprocessed image.
[0041] In this embodiment, Gaussian blurring refers to a digital image processing technique that uses a Gaussian function as the convolution kernel to smooth and filter an image. It represents a filtering algorithm that reduces image noise while preserving edge information through weighted averaging. Gaussian blurring can effectively eliminate random noise points in an image while avoiding excessive destruction of the edge contour features of the Mark points.
[0042] Specifically, the electronic device acquires grayscale image data, where each pixel has a corresponding row and column coordinate position. Gaussian kernel parameters are set, determining the size of the Gaussian kernel matrix to be 5 rows and 5 columns with 25 elements. The standard deviation parameter, controlling the blur intensity, is set to 1.0. The Gaussian kernel matrix is constructed, and the weight value at each position is calculated. Using the center of the kernel matrix as a reference point, the spatial distance from each other position to the center is calculated. Elements closer to the center are assigned larger weight values, and elements farther from the center are assigned smaller weight values, forming a weight distribution pattern where the value is largest at the center and gradually decreases towards the edges. The standard deviation parameter determines the rate of weight decay; a larger standard deviation results in a stronger blur effect. The entire kernel matrix is then normalized so that the sum of all weights equals one. Convolution operations are performed: for each pixel position in the image, all pixel values within a 5x5 column range around the pixel position are multiplied by the weight value at the corresponding position in the Gaussian kernel. All products are then summed to obtain the new value for that pixel, resulting in the preprocessed image.
[0043] S104: Perform gradient calculation on the preprocessed image to form a gradient image, and determine the set of edge point coordinates of the gradient image.
[0044] In this embodiment, gradient calculation refers to an image processing technique that calculates the rate of change of brightness of each pixel in an image using numerical differentiation methods. This is used to represent edge detection algorithms that detect regions with abrupt changes in grayscale values in an image. Gradient calculation can effectively identify image regions with obvious brightness jumps, such as Mark point boundaries and object contours.
[0045] Specifically, the electronic device calculates the gradient components of each pixel in the preprocessed image in both the horizontal and vertical directions, typically using convolution kernels such as the Sobel, Prewitt, or Scharr operators. The device then synthesizes these gradient components into vectors and calculates the result using the Euclidean distance formula, obtaining the gradient magnitude of each pixel. The combined gradient magnitudes of all pixels form a gradient image, which highlights the edges and contours in the original image. Subsequently, the device iterates through the pixels in the gradient image, identifying pixels with gradient magnitudes greater than a preset gradient threshold as edge points. Finally, the device generates a set of edge point coordinates based on the coordinate positions of each edge point.
[0046] Based on the above embodiments, as an optional embodiment, S104: the step of performing gradient calculation on the preprocessed image to form a gradient image and determining the set of edge point coordinates of the gradient image may specifically include the following steps: S201: Calculate the gradient components of each pixel in the preprocessed image in the horizontal and vertical directions respectively, and synthesize the gradient components in the two directions into vectors to obtain the gradient magnitude of each pixel, forming a gradient image.
[0047] In the embodiments of this application, the gradient component refers to the brightness difference between a pixel and its neighboring pixels in a specific direction, used to represent the intensity and direction of grayscale change of the pixel in that direction. For example, the gradient component in the horizontal direction reflects the brightness difference between the left and right adjacent areas of a pixel, and the gradient component in the vertical direction reflects the brightness difference between the upper and lower adjacent areas of a pixel.
[0048] Specifically, the electronic device processes each pixel in the preprocessed image using gradient operators, calculating the gradient components in the horizontal and vertical directions of each pixel through convolution operations. The electronic device typically uses classic gradient detection operators such as the Sobel, Prewitt, or Scharr operators. These operators convolve with the image using specific kernel templates to obtain gradient response values in both the horizontal and vertical directions. The electronic device then synthesizes the calculated gradient components into vectors using the vector magnitude calculation formula: the gradient magnitude is equal to the square root of the sum of the squares of the horizontal and vertical gradient components. Through this vector synthesis method, the electronic device obtains the gradient magnitude of each pixel. Finally, the electronic device arranges the gradient magnitudes of all pixels according to their spatial positions in the original image to form a gradient image.
[0049] S202: Traverse each pixel in the gradient image, identify pixels with gradient magnitude greater than a preset gradient threshold as edge points, and generate an edge point coordinate set based on the coordinate position of each edge point.
[0050] Specifically, the electronic device traverses each pixel in the gradient image from left to right and top to bottom, reading the gradient magnitude of each pixel one by one. The electronic device compares the gradient magnitude of the current pixel with a preset gradient threshold. When the gradient magnitude is greater than the preset threshold, the electronic device identifies the pixel as an edge point and records its coordinate position information in the image, including row and column coordinates. The electronic device continues to traverse the remaining pixels, repeating the gradient magnitude comparison and edge point identification operations until the entire gradient image is scanned. During the traversal, the electronic device collects and organizes the coordinate position information of all edge points that meet the conditions, generating an edge point coordinate set.
[0051] S105: Scan the set of edge point coordinates within the preset radius of each Mark point to obtain the coordinates of the first circle center, and determine the coordinates of the second circle center based on the coordinates of the first circle center.
[0052] In this embodiment, the first and second center coordinates refer to the geometric center coordinates of two main circular Mark points detected in the image, used to represent the precise spatial position of the Mark points in the image coordinate system. The first center coordinate represents the center position of the Mark point with the most complete circular feature and the clearest edges in the image; this Mark point has the most standard circular outline and the most obvious edge contrast. The second center coordinate represents the center position of the Mark point with the second most complete circular feature and the second clearest edges in the image; this Mark point also has a relatively standard circular outline, but its clarity or completeness is lower than the first Mark point.
[0053] Specifically, the electronic device establishes a three-dimensional accumulator array. The three dimensions of this array correspond to the x-coordinate, y-coordinate, and radius of the circle, respectively, used to count the votes for different combinations of center positions and radii. The electronic device divides the preset radius range of each Mark point into multiple discrete radius values according to a preset step size, forming a radius candidate set. For each edge point in the edge point coordinate set, the electronic device iterates through all radius candidate values, calculates the possible center position of the edge point under the current radius using the geometric equation of the circle, and increments the count of the calculated x-coordinate, y-coordinate, and corresponding radius value in the three-dimensional accumulator array by one. After voting for all edge points, the electronic device finds the position with the largest count in the three-dimensional accumulator array and uses the x-coordinate and y-coordinate of that position as the first center coordinate. Subsequently, the electronic device sets a suppression radius based on the first center coordinate, calculates the Euclidean distance between each center position in the three-dimensional accumulator array and the first center coordinate, and sets the count of center positions with distances less than the suppression radius to zero to eliminate interference near the first center. Finally, the electronic device finds the maximum value among the remaining count values and uses the corresponding x and y coordinates as the coordinates of the second center.
[0054] Based on the above embodiments, as an optional embodiment, S105: the step of scanning the set of edge point coordinates within a preset radius of each Mark point to obtain the first center coordinates, and determining the second center coordinates based on the first center coordinates, may specifically include the following steps: S301: Create a three-dimensional accumulator array. The three dimensions of the three-dimensional accumulator array correspond to the x-coordinate of the center of the circle, the y-coordinate of the center of the circle, and the radius of the circle, respectively.
[0055] In this embodiment, the three-dimensional accumulator array refers to a three-dimensional data structure used to store the circle detection results. This data structure records the strength of evidence for the existence of a circle at each possible location and size in the image, helping to determine the location and size of the actual circular Mark point in the image. The specific meanings of the three dimensions are as follows: the first dimension represents the possible horizontal coordinate position of the circle's center, ranging from the left edge to the right edge of the image across all pixel columns; the second dimension represents the possible vertical coordinate position of the circle's center, ranging from the top edge to the bottom edge of the image across all pixel rows; and the third dimension represents the possible radius of the circle, ranging from the minimum to the maximum radius preset by the Mark point.
[0056] Specifically, the electronic device determines the range of values for the x-coordinate and y-coordinate of the circle's center based on the width and height of the gradient image, and simultaneously determines the range of values for the circle's radius based on the preset radius range of the Mark points. Memory space is allocated to create a three-dimensional array structure. The size of the first dimension equals the number of x-coordinate positions corresponding to the image width, the size of the second dimension equals the number of y-coordinate positions corresponding to the image height, and the size of the third dimension equals the number of radius values divided by the step size within the radius range. The electronic device initializes all elements in the three-dimensional accumulator array to zero, ensuring that the initial count value for each parameter combination is empty.
[0057] S302: Divide the preset radius range of each Mark point into multiple radius values according to the preset step size. Based on the coordinates of each edge point in the edge point coordinate set and each radius value, calculate multiple circle center positions through the geometric equation of the circle. Then, increment the corresponding count value in the three-dimensional accumulator array by one for the calculated abscissa, ordinate, and radius value of the circle corresponding to each circle center position.
[0058] Specifically, the electronic device divides the preset radius range of each Mark point into equal intervals according to a preset step size, generating a series of discrete radius candidate values, forming a radius value set. The electronic device traverses each edge point in the edge point coordinate set, obtaining the x-coordinate and y-coordinate of that edge point. For the current edge point, the electronic device sequentially selects each radius value in the radius value set, and uses the geometric equation of a circle to calculate all possible center positions of the edge point under the current radius. Since an edge point and a radius value can determine countless center positions (forming a circle with the edge point as the center and the given radius as the radius), the electronic device samples multiple center candidate positions on the circumference according to a certain angular step size. The electronic device uses the x-coordinate, y-coordinate, and corresponding radius value of each calculated center candidate position as an index to locate the corresponding array element in the three-dimensional accumulator array, and increments the count value of that element, realizing the voting accumulation of the circle parameter combination.
[0059] For example, if an edge point is detected with coordinates (100, 50), a preset radius range of 15-25 pixels, and a step size of 5 pixels, then the set of radius values after segmentation will be {15, 20, 25}. The angle step size is set to 90 degrees, meaning that four directions (0 degrees, 90 degrees, 180 degrees, 270 degrees) are sampled on each circumference.
[0060] For a radius of 20, the edge point may belong to an infinite number of circles with a radius of 20. The centers of these circles form a circumference with a radius of 20 centered at coordinates (100, 50). According to the geometric equation of a circle, the formula for calculating the center coordinates is: x-coordinate of center = x-coordinate of edge point + radius × cos(angle), y-coordinate of center = y-coordinate of edge point + radius × sin(angle). The specific calculation process is as follows: When the angle is 0 degrees, the center coordinates are (100 + 20×cos(0°), 50+ 20×sin(0°)) = (120, 50); when the angle is 90 degrees, the center coordinates are (100 + 20×cos(90°), 50 + 20×sin(90°)) = (100, 70); when the angle is 180 degrees, the center coordinates are (100 + 20×cos(180°), 50+ 20×sin(180°)) = (80, 50); when the angle is 270 degrees, the center coordinates are (100 + 20×cos(270°), 50 + 20×sin(270°)) = (100, 30).
[0061] For each calculated center position, the electronic device counts the positions in the three-dimensional accumulator array. For a center (120, 50) and a radius of 20, the count for the 120th position in the first dimension is incremented by one, the count for the 50th position in the second dimension is incremented by one, and the count for the position corresponding to radius 20 in the third dimension is incremented by one. For a center (100, 70) and a radius of 20, the count for the 100th position in the first dimension is incremented by one, the count for the 70th position in the second dimension is incremented by one, and the count for the position corresponding to radius 20 in the third dimension is incremented by one. For a center (80, 50) and a radius of 20, the count for the 80th position in the first dimension is incremented by one, the count for the 50th position in the second dimension is incremented by one, and the count for the position corresponding to radius 20 in the third dimension is incremented by one. For a center (100, 30) and a radius of 20, the count for the 100th position in the first dimension is incremented by one, the count for the 30th position in the second dimension is incremented by one, and the count for the position corresponding to radius 20 in the third dimension is incremented by one. Similarly, the electronic device will repeat the above calculation and counting process for radius values 15 and 25, accumulating evidence in the corresponding dimension for each possible center position.
[0062] S303: In the three-dimensional accumulator array, the x-coordinate of the center of the circle with the largest count value and the y-coordinate of the center of the circle with the largest count value are used as the coordinates of the first center.
[0063] Specifically, the electronic device iterates through all elements in the three-dimensional accumulator array, compares the count values of each element, and records the currently encountered maximum count value and its corresponding array index position. The electronic device uses the first dimension index corresponding to the maximum count value as the x-coordinate of the circle's center, the second dimension index as the y-coordinate, and the third dimension index as the corresponding circle radius. The electronic device extracts the x-coordinate and y-coordinate information of the position with the maximum count value, combines these two coordinate values to form a two-dimensional coordinate point, and outputs it as the coordinates of the first circle's center.
[0064] For example, suppose that after processing multiple edge points, the partial counts of the three one-dimensional accumulator arrays are as follows: in the x-coordinate array, x_count
[80] = 5, x_count
[100] = 8, x_count
[120] = 3; in the y-coordinate array, y_count
[30] = 4, y_count
[50] = 6, y_count
[70] = 9; in the radius array, r_count
[15] = 2, r_count
[20] = 7, r_count
[25] = 4. The electronic device searches for the element with the largest count value in each of the three one-dimensional arrays. In the x-coordinate array, x_count
[100] = 8 is the largest count value, corresponding to an x-coordinate of 100. In the y-coordinate array, y_count
[70] = 9 is the largest count value, corresponding to a y-coordinate of 70. The electronic device combines the x-coordinate of the largest count value, 100, with the y-coordinate of 70 to form the first center coordinate (100, 70). This indicates that among all candidate positions, the horizontal coordinate 100 received the most votes from edge points, and the vertical coordinate 70 also received the most votes from edge points. Therefore, the coordinates (100, 70) are determined to be the most likely center position, which is the first center coordinate.
[0065] S401: Set the suppression radius based on the coordinates of the first center.
[0066] In this embodiment of the application, the suppression radius refers to the radius distance of a preset circular suppression region, which is used to represent the spatial range in the non-maximum suppression algorithm that other candidate circles need to be blocked with the detected circle center as the center.
[0067] Specifically, the electronic device obtains the x and y coordinates of the first circle's center as the geometric center of the suppression region. The electronic device then calls a preset suppression radius and, with the first circle's center as the center and the preset suppression radius as the radius, determines a circular suppression region in the space of the three-dimensional accumulator array.
[0068] S402: Calculate the Euclidean distance between the position of each circle center and the coordinates of the first circle center.
[0069] Specifically, the electronic device iterates through all elements in the 3D accumulator array with counts greater than zero, extracting the x-coordinate and y-coordinate of the circle center for each position to form a candidate circle center position list. The electronic device obtains the x-coordinate x1 and y-coordinate y1 of the first circle center coordinate as a reference point. The electronic device then calculates the Euclidean distance between each candidate circle center position (xi, yi) and the first circle center coordinate (x1, y1).
[0070] S403: In the three-dimensional accumulator array, set the x-coordinate count and y-coordinate count of the center position where the Euclidean distance is less than the suppression radius to zero.
[0071] Specifically, the electronic device determines the distance relationship between each candidate circle center and the coordinates of the first circle center based on the Euclidean distance results. It compares the Euclidean distance values of each candidate circle center with a preset suppression radius, filtering out candidate circle center positions whose distance values are less than the suppression radius. The electronic device then locates the specific index positions of these candidate circle centers to be suppressed in the three-dimensional accumulator array, including their corresponding x-coordinate index, y-coordinate index, and radius index. Finally, the electronic device resets all voting count values stored in the accumulator array for these positions to zero.
[0072] S404: Use the x-coordinate of the center of the circle with the largest remaining count value and the y-coordinate of the center of the circle with the largest remaining count value as the coordinates of the second center.
[0073] Specifically, the electronic device rescans all non-zero elements in the 3D accumulator array. It counts the remaining non-zero counts and finds the current maximum vote count by traversing the accumulator array. The electronic device locates the specific index of this maximum count in the 3D accumulator array and extracts the corresponding x-coordinate and y-coordinate indices. It converts these indices to actual pixel coordinates in the image coordinate system, obtaining the precise location of the center of the circle with the largest remaining count in the original image. Finally, the electronic device combines the x-coordinate and y-coordinate of this location to form the complete coordinates of the second center.
[0074] S106: Calculate the pixel distance between the coordinates of the first center and the coordinates of the second center.
[0075] Specifically, the electronic device acquires the x-coordinate (x1) and y-coordinate (y1) of the first center coordinate, and the x-coordinate (x2) and y-coordinate (y2) of the second center coordinate. The electronic device calculates the difference between the two center coordinates in the x-coordinate direction (x2-x1) and in the y-coordinate direction (y2-y1). The electronic device squares these two coordinate differences, obtaining (x2-x1)² and (y2-y1)² respectively. The electronic device adds the two squared values, takes the square root, and calculates the final pixel distance value using the Euclidean distance formula.
[0076] S107: Multiply the pixel distance by a preset conversion factor to obtain the current physical distance between the two Mark points at each test location.
[0077] In this embodiment of the application, the current physical distance refers to the actual distance measurement value between the two Mark points in the real physical space, which is used to represent the accurate distance data obtained after transforming from the image pixel coordinate system to the actual physical coordinate system.
[0078] Specifically, image processing yields distance data in pixel coordinates, while practical applications require distance measurements from the real physical world. Therefore, this embodiment converts image analysis results into meaningful physical dimension data through conversion coefficients, which can then be used for subsequent quality assessment, dimensional inspection, or precision control applications. The specific value of the conversion coefficient depends on the camera's shooting parameters and system configuration. For example, in high-precision circuit board inspection, the conversion coefficient may be 0.01 mm / pixel or 0.02 mm / pixel; in the inspection of larger objects, the conversion coefficient may be 0.1 mm / pixel or 0.2 mm / pixel; and in macroscopic inspection of industrial production lines, the conversion coefficient may even reach 1 mm / pixel or greater.
[0079] The electronic device calls a pre-set conversion coefficient, multiplies the pixel distance value by the conversion coefficient, completes the unit conversion from the pixel coordinate system to the physical coordinate system, and obtains the current physical distance between the two Mark points at each test location.
[0080] For example, suppose in a vision inspection system, calibration shows that one pixel corresponds to a distance of 0.05 mm in actual physical space. Then the conversion factor is 0.05 mm / pixel. If an electronic device measures a pixel distance of 120 pixels between two Mark points in an image, the pixel distance is multiplied by the conversion factor for unit conversion: Current actual physical distance = 120 pixels × 0.05 mm / pixel = 6 mm. This means that the two Mark points are 6 mm apart in real physical space.
[0081] S108: Calculate the displacement deviation between each current physical distance and the corresponding theoretical stroke value, and calculate the motor linearity index of each motor under test based on each displacement deviation.
[0082] In this embodiment, the motor linearity index refers to a comprehensive performance parameter used to quantitatively evaluate the displacement accuracy and linear characteristics of the motor under test. It is used to represent the degree of deviation and linearity quality between the actual motion trajectory and the theoretical expected trajectory of the motor under different displacement amounts.
[0083] Specifically, the electronic device acquires the current physical distance and preset theoretical travel value data corresponding to each test position. The difference between the current physical distance and the theoretical travel value is calculated to obtain the displacement deviation. Based on each displacement deviation, an error distribution function is established between the displacement deviation as the dependent variable and the test position as the independent variable. Then, based on the error distribution function, the fluctuation amplitude and offset trend of the displacement deviation are calculated. Finally, the calculated fluctuation amplitude and offset trend are substituted into the motor linearity index formula to calculate the motor linearity index.
[0084] Based on the above embodiments, as an optional embodiment, S108: the step of calculating the motor linearity index of each motor under test based on each displacement deviation may specifically include the following steps. S501: Establish the error distribution function between displacement deviation and test position.
[0085] In the embodiments of this application, the error distribution function refers to a mathematical function model used to describe the distribution law and variation characteristics of displacement deviation at different test positions, and is used to represent the quantitative mapping relationship and statistical distribution characteristics between displacement deviation and test position.
[0086] Specifically, the electronic equipment collects displacement deviation data corresponding to each test position, forming a set of position-deviation data points. A quadratic polynomial function is chosen as the mathematical function model, with the function form f(x,y) = ax² + by² + cxy + dx + ey + f, where (x,y) represents the test position coordinates, and a, b, c, d, e, and f are the function parameters to be determined. The least squares method is used to fit the parameters of the quadratic polynomial function. The coordinates of each test position and the corresponding displacement deviation value are substituted into the function model, and the values of the function coefficients a, b, c, d, e, and f are determined by solving for the parameter combination that minimizes the sum of squared errors. The final error distribution function f(x,y) = ax² + by² + cxy + dx + ey + f is then established.
[0087] S502: Calculate the fluctuation range of displacement deviation and the offset trend of displacement deviation based on the error distribution function.
[0088] In the embodiments of this application, fluctuation amplitude refers to the maximum range of displacement deviation across all test positions, used to represent the extreme differences and magnitude of change in deviation data; offset trend refers to the systematic offset direction and degree exhibited by displacement deviation as the test position changes, used to indicate whether the deviation exhibits overall increase, decrease or other regular change characteristics.
[0089] Specifically, the electronic device, based on an established error distribution function, iterates through displacement deviation data at all test locations. The maximum and minimum values of the displacement deviation are determined through function evaluation or direct data analysis, and the fluctuation amplitude is calculated as the difference between these two values. Mathematical analysis of the error distribution function is performed, calculating the first derivative to obtain the instantaneous slope of the deviation change. Slope analysis identifies the increasing or decreasing trend of the deviation. The second derivative of the function is further calculated to analyze the acceleration characteristics of the deviation change, identifying the stability and rate of change of the deviation trend. Linear regression analysis is used to fit the relationship between displacement deviation and test location, obtaining the slope of the regression line as the offset trend.
[0090] S503: Calculate the motor linearity index based on the fluctuation amplitude and offset trend.
[0091] Specifically, the electronic device acquires the total number of test positions, and counts the total number of test points involved in this linearity test. The maximum and minimum values among the theoretical stroke values are obtained to determine the test range of the theoretical displacement. The fluctuation amplitude and offset trend calculated in the preceding steps, along with the preset motor linearity formula, are then used for calculation. The motor linearity formula is: Where L is the motor linearity index, a larger value indicates better linearity, and n is the total number of test positions. The maximum value among all theoretical travel values. The minimum value among all theoretical stroke values is given by σ, where σ is the fluctuation amplitude calculated from the standard deviation of the displacement deviation, and k is the offset trend, represented by the absolute value of the slope of the linear fit of the error distribution function. The design of the motor linearity formula structure has good mathematical rationality: numerator part... middle, This demonstrates the positive impact of the number of test points on linearity evaluation, and the use of the square root form avoids excessive numerical amplification when there are too many test points. The denominator represents the test coverage area of the theoretical displacement; a larger coverage area indicates a more comprehensive test. Taking into account the effects of random errors and systematic errors, It reflects the degree of fluctuation in displacement deviation. Reflecting the systematic deviation trend, the square root of the sum of the squares ensures dimensional consistency and numerical stability. The advantage of this structural design is that it balances the influence weight of each parameter through square root calculation, avoiding any one factor from dominating; at the same time, it takes into account both test coverage and error control level, so that the linearity index can objectively reflect the actual performance of the motor.
[0092] For example, assuming there are 64 test locations in a certain test, the theoretical displacement range is... =8mm, calculated fluctuation amplitude =0.04mm², offset trend = 0.09mm², then the motor linearity index L = 177.8.
[0093] Based on the above embodiments, as an optional embodiment, S108: after the step of calculating the motor linearity index based on each displacement deviation, a step of correcting motor linearity anomalies is further included, which may specifically include the following steps: S701: Determine whether the motor linearity index meets the preset linearity threshold requirements.
[0094] Specifically, the electronic device acquires a preset linearity threshold. The motor linearity index is then compared numerically with the linearity threshold. The following judgment logic is executed: when the motor linearity index is greater than the linearity threshold, it is determined that the motor linearity index meets the preset linearity threshold requirement, indicating that the motor has good linearity performance; when the motor linearity index is less than the linearity threshold, it is determined that the motor linearity index does not meet the preset linearity threshold requirement, indicating that the motor has a linearity abnormality problem.
[0095] S702: When the motor linearity index does not meet the preset linearity threshold requirement, identify abnormal test positions where the displacement deviation exceeds the preset deviation range in each test position.
[0096] In this embodiment, the abnormal test location refers to a specific test point where the deviation between the actual displacement and the theoretical displacement exceeds a preset allowable range during the linearity test of the autofocus voice coil motor (VCM). This location is used to pinpoint key issues affecting the overall linearity performance of the motor.
[0097] Specifically, when the electronic device determines that the motor linearity index does not meet the preset linearity threshold requirement, it obtains a preset deviation range. It then iterates through all test positions and obtains the displacement deviation corresponding to each test position. Finally, it executes anomaly detection logic: when the displacement deviation is greater than the maximum value of the preset deviation range or less than the minimum value of the preset deviation range, the test position is marked as an abnormal test position.
[0098] S703: Calculate the displacement correction value for each abnormal test location and generate a motor correction parameter table containing the abnormal test location and the corresponding displacement correction value.
[0099] In this embodiment of the application, the motor calibration parameter table refers to a structured data set containing abnormal test location information and its corresponding displacement correction value, which serves as a reference for guiding the motor control system to perform accuracy compensation and linearity optimization.
[0100] Specifically, the electronic equipment calculates the displacement correction value for each abnormal location. For each abnormal test location, the interpolation between the theoretical displacement and the actual displacement is calculated to obtain the displacement correction value. The rationality of the correction value is verified to ensure that the absolute value of the correction value does not exceed the preset maximum correction range, avoiding system instability caused by over-correction. A data structure for the motor correction parameter table is constructed, including the following key fields: test location index, location coordinate information, theoretical travel value, actual displacement value, displacement deviation, displacement correction value, correction priority, etc. Abnormal locations are sorted according to location order or deviation degree to facilitate subsequent correction processing and parameter application. A standard format motor correction parameter table is generated, supporting multiple data formats such as table files, configuration files, or database records. Metadata information is added to the motor correction parameter table, including test time, motor model, test conditions, correction algorithm version, etc., to ensure the traceability and applicability of the correction parameters.
[0101] The following describes an exemplary autofocus voice coil motor (VCM) linearity testing device provided in an embodiment of this application. Figure 4 This is an exemplary hardware structure diagram of the autofocus voice coil motor (VCM) linearity testing device provided in this application embodiment.
[0102] In some embodiments, the autofocus voice coil motor (VCM) linearity testing device is a computer device or includes a computer device in the autofocus VCM linearity testing device. The computer device includes a processor, memory, and a network interface connected via a system bus. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database of the computer device stores data. The network interface of the computer device is used to communicate with other external terminals or servers via a network connection. In some embodiments, the network interface can be a wired network interface; in some embodiments, the network interface can also be a wireless network interface. When the computer program is executed by the processor, it implements the methods in the embodiments of this application.
[0103] Those skilled in the art will understand that Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0104] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application 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 scope of the technical solutions of the embodiments of this application.
[0105] As used in the above embodiments, depending on the context, the term "when..." can be interpreted as meaning "if...", "after...", "in response to determining...", or "in response to detecting...". Similarly, depending on the context, the phrase "when determining..." or "if (the stated condition or event) is interpreted as meaning "if determining...", "in response to determining...", "when (the stated condition or event) is detected", or "in response to detecting (the stated condition or event)".
[0106] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.
[0107] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A method for testing the linearity of an autofocus voice coil motor (VCM), characterized in that, The method includes: The motor under test is controlled to move sequentially to multiple test positions according to a preset displacement increment, and each test position corresponds to a theoretical stroke value; At each of the test locations, a test image containing two Mark points is acquired, and the test image is converted to obtain a grayscale image. The test image contains a fixed first Mark point and a second Mark point that moves with the test motor. The grayscale image data is subjected to Gaussian blurring to obtain a preprocessed image; Gradient calculation is performed on the preprocessed image to form a gradient image, and the set of edge point coordinates of the gradient image is determined. Scan the set of edge point coordinates within a preset radius of each Mark point to obtain the first center coordinates, and determine the second center coordinates based on the first center coordinates; Calculate the pixel distance between the coordinates of the first center of the circle and the coordinates of the second center of the circle; Multiply the pixel distance by a preset conversion coefficient to obtain the current physical distance between the two Mark points at each test location; Calculate the displacement deviation between each current physical distance and the corresponding theoretical travel value, and calculate the motor linearity index of each motor under test based on each displacement deviation.
2. The method for testing the linearity of the autofocus voice coil motor (VCM) according to claim 1, characterized in that, The step of performing gradient calculation on the preprocessed image data to form a gradient image and determining the set of edge point coordinates of the gradient image includes: The gradient components of each pixel in the preprocessed image are calculated in the horizontal and vertical directions respectively. The gradient components in the two directions are vector synthesized to obtain the gradient magnitude of each pixel and form a gradient image. The gradient image is traversed, and pixels with gradient magnitudes greater than a preset gradient threshold are identified as edge points. An edge point coordinate set is generated based on the coordinate positions of each edge point.
3. The method for testing the linearity of the autofocus voice coil motor (VCM) according to claim 1, characterized in that, The step of scanning the set of edge point coordinates within a preset radius of each Mark point to obtain the coordinates of the first center of the circle includes: Establish a three-dimensional accumulator array, wherein the three dimensions of the three-dimensional accumulator array correspond to the x-coordinate of the center of the circle, the y-coordinate of the center of the circle, and the radius of the circle, respectively; The preset radius range of each Mark point is divided into multiple radius values according to the preset step size. Based on the coordinates of each edge point in the set of edge point coordinates and each radius value, multiple circle center positions are calculated through the geometric equation of the circle. The abscissa, ordinate, and radius value of the circle center corresponding to each circle center position are incremented by one in the corresponding count value in the three-dimensional accumulator array. In the three-dimensional accumulator array, the x-coordinate of the center of the circle with the largest count value and the y-coordinate of the center of the circle with the largest count value are used as the coordinates of the first center.
4. The method for testing the linearity of the autofocus voice coil motor (VCM) according to claim 3, characterized in that, Determining the coordinates of the second center based on the coordinates of the first center includes: The suppression radius is set according to the coordinates of the first center of the circle; Calculate the Euclidean distance between each circle center position and the coordinates of the first circle center; In the three-dimensional accumulator array, the horizontal and vertical coordinate counts corresponding to the center positions where the Euclidean distance is less than the suppression radius are set to zero; The x-coordinate of the center of the circle with the largest remaining count value and the y-coordinate of the center of the circle with the largest remaining count value are used as the coordinates of the second center.
5. The method for testing the linearity of the autofocus voice coil motor (VCM) according to claim 1, characterized in that, The calculation of the motor linearity index of each motor under test based on the displacement deviation includes: Establish the error distribution function between the displacement deviation and the test position; The fluctuation amplitude of the displacement deviation and the offset trend of the displacement deviation are calculated based on the error distribution function. The motor linearity index is calculated based on the fluctuation amplitude and the offset trend.
6. The method for testing the linearity of the autofocus voice coil motor (VCM) according to claim 5, characterized in that, The step of calculating the motor linearity index based on the fluctuation amplitude and the systematic offset trend includes: Obtain the total number of test locations, and calculate the motor linearity index based on the total number, the fluctuation amplitude, the offset trend, and the preset motor linearity formula; The formula for motor linearity is: ; Where L represents the motor linearity index, with a larger value indicating better linearity, and n represents the total number of test positions. The maximum value among all theoretical travel values. σ is the minimum value among all theoretical travel values, σ is the fluctuation amplitude, σ is calculated by the standard deviation of the displacement deviation, and k is the offset trend, which is represented by the absolute value of the slope of the linear fit of the error distribution function.
7. The method for testing the linearity of an autofocus voice coil motor (VCM) according to claim 1, characterized in that, After calculating the motor linearity index based on each displacement deviation, the method further includes: Determine whether the motor linearity index meets the preset linearity threshold requirement; When the motor linearity index does not meet the preset linearity threshold requirement, identify abnormal test positions in each test position where the displacement deviation exceeds the preset deviation range; Calculate the displacement correction value for each of the abnormal test locations, and generate a motor correction parameter table containing the abnormal test locations and the corresponding displacement correction values.
8. A device for testing the linearity of an automatic focusing voice coil motor (VCM), characterized in that, The autofocus voice coil motor (VCM) linearity testing device includes: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to cause the autofocus voice coil motor (VCM) linearity testing device to perform the method as described in any one of claims 1-7.
9. A computer program product containing instructions, characterized in that, When the computer program product is run on the autofocus voice coil motor (VCM) linearity testing equipment, the autofocus voice coil motor (VCM) linearity testing equipment performs the method as described in any one of claims 1-7.
10. A computer-readable storage medium comprising instructions, characterized in that, When the instruction is executed on the autofocus voice coil motor (VCM) linearity testing device, the autofocus voice coil motor (VCM) linearity testing device performs the method as described in any one of claims 1-7.