Automatic focusing methods, devices, and storage media
By acquiring images at intervals within the objective lens's range of motion and determining the range of motion based on changes in sharpness, the high memory and processor requirements and long processing time of existing technologies are solved, achieving highly efficient autofocus.
Patent Information
- Application Number
- CN202411884535.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2044-12-18
AI Technical Summary
Existing autofocus methods acquire images step by step within the objective lens's range of motion, resulting in high memory and processor requirements, long focus acquisition time, and low efficiency.
By acquiring images at intervals within a preset range of motion, the range of motion of the objective lens is determined based on changes in sharpness, and images are acquired within the narrowed range until the optimal focus position is found.
It reduces the number of images acquired and analyzed, lowers memory and processor requirements, shortens focus acquisition time, and improves focus acquisition efficiency.
Smart Images

Figure CN119767139B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image acquisition, and more specifically, to an autofocus method, apparatus, and storage medium. Background Technology
[0002] With the rapid development of optical technology, its applications are expanding into more and more fields. In optical technology, the autofocus of objective lenses has always been a focus of attention. Current autofocus methods, after setting the objective lens's range of motion, require controlling the lens to acquire images step by step within that range. This method places high demands on memory and processor resources, easily leading to lag issues, and the objective lens's focus-finding process is time-consuming and inefficient. Summary of the Invention
[0003] The present invention addresses the aforementioned problems. It provides an autofocus method, apparatus, and storage medium. This approach involves acquiring and analyzing a small number of images during the objective lens focusing process, has low requirements for memory and processor, and offers short focusing time and high efficiency.
[0004] According to one aspect of the present invention, an autofocus method is provided. The method includes: controlling an objective lens to move linearly within a preset first motion range; during the motion, acquiring images of a target object at intervals of a first step distance to obtain a target group of images; determining a second motion range of the objective lens based on the sharpness change of the latest acquired target group of images, wherein a first position of the objective lens corresponding to the highest sharpness of an image in the target group of images is within the second motion range, the second motion range is within the first motion range, and the motion distance corresponding to the second motion range is less than the motion distance corresponding to the first motion range; controlling the objective lens to move linearly within the second motion range; during the motion, acquiring images of the target object at intervals of a second step distance corresponding to the second motion range to obtain a new target group of images; when the second step distance is greater than a target step distance, using the second motion range as a new first motion range, returning to the step of determining the second motion range of the objective lens based on the sharpness change of the latest acquired target group of images; and when the second step distance is equal to the target step distance, determining the focusing position of the objective lens for the target object based on the sharpness change of the latest acquired target group of images, wherein the focusing position is the second position of the objective lens corresponding to the highest sharpness of an image in the latest acquired target group of images.
[0005] Optionally, the second step distance is obtained by: acquiring the second step distance input by the user; or, determining the second step distance based on the focus speed and focus time, wherein one or both of the focus speed and focus time are input by the user, and when the user inputs one of the focus speed and focus time, the other is a preset value.
[0006] Optionally, each second step distance is smaller than the first step distance; the second step distance corresponding to each determined second movement range is smaller than the second step distance corresponding to the previously determined second movement range.
[0007] Optionally, determining the second motion range of the objective lens based on the sharpness change of the latest acquired target group images includes: determining a first position based on the sharpness change of the latest acquired target group images; determining a third and fourth position of the objective lens based on the first position, wherein the third and fourth positions are located on either side of the first position, and the images acquired at the third, first, and fourth positions are continuously acquired images; and defining the third and fourth positions as the boundaries of the second motion range to determine the second motion range.
[0008] Optionally, based on the changes in sharpness of the latest acquired target group images, a second range of motion of the objective lens is determined, including: determining the similarity between each image in the target group images and a reference image, wherein the reference image is an image acquired by the objective lens when it is in a focusing position for a reference object, and the reference object and the target object are objects of the same type; determining the second range of motion based on the changes in similarity between each image in the target group images and the reference image; wherein the changes in sharpness are represented by changes in similarity.
[0009] Optionally, before controlling the objective lens to move linearly within a preset first range of motion, the method further includes: determining a first step distance in response to a user input operation.
[0010] Optionally, controlling the objective lens to move in a straight line within a preset first range of motion includes: controlling the objective lens to move from a starting position to an ending position, wherein the starting position and the ending position are located on both sides of the coarse focusing position, the coarse focusing position is the focusing position of the objective lens for the reference object, wherein the reference object and the target object are objects of the same type, and the focusing position for the reference object is the second position of the objective lens corresponding to the highest image sharpness in the image acquired for the reference object.
[0011] According to another aspect of the present invention, an autofocus device is also provided, comprising: a first control module, configured to control an objective lens to move linearly within a preset first motion range, wherein during the motion, images of a target object are acquired at step distance intervals to obtain a target group of images; a determination module, configured to determine a second motion range of the objective lens based on the sharpness change of the latest acquired target group of images, wherein a first position of the objective lens corresponding to the highest sharpness of an image in the target group of images is within the second motion range, the second motion range is within the first motion range, and the motion distance corresponding to the second motion range is less than the motion distance corresponding to the first motion range; and a second control module, configured to control... The objective lens moves in a straight line within the second motion range. During the movement, it acquires images of the target object at intervals corresponding to the second step distance of the second motion range to obtain new target group images. When the second step distance is greater than the target step distance, the second motion range is taken as the new first motion range, and the process returns to the step of determining the second motion range of the objective lens based on the sharpness change of the latest acquired target group images. When the second step distance is equal to the target step distance, the focusing position of the objective lens on the target object is determined based on the sharpness change of the latest acquired target group images. The focusing position is the second position of the objective lens corresponding to the highest sharpness of the image in the latest acquired target group images.
[0012] According to another aspect of the present invention, a storage medium is also provided, on which program instructions are stored, which are used to execute the above-described autofocus method when running.
[0013] The above technical solution determines the second motion range of the objective lens by analyzing the sharpness changes of the target group images acquired within the first motion range. It then determines the focusing position of the objective lens on the target object based on the sharpness changes of the target group images acquired within the second motion range, which is smaller than the first motion range. This method allows for multiple focus searches, with the motion range of the objective lens's focusing position on the target object reduced after each search, eliminating the need for step-by-step image acquisition within the set motion range. This results in fewer images being acquired and analyzed during the entire focusing process, while ensuring the accuracy of the determined focusing position meets requirements. Consequently, it places lower demands on memory and processor, reduces the likelihood of lag, and minimizes the objective lens's focus search time, leading to high focus search efficiency.
[0014] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0015] The above and other objects, features, and advantages of the present invention will become more apparent from the more detailed description of the embodiments of the invention in conjunction with the accompanying drawings. The drawings are provided to further illustrate the embodiments of the invention and form part of the specification. They are used together with the embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings, the same reference numerals generally represent the same parts or steps.
[0016] Figure 1 This diagram illustrates the position of the objective lens during the focusing process in a related art according to an embodiment of the present invention;
[0017] Figure 2 A schematic flowchart of an autofocus method according to an embodiment of the present invention is shown;
[0018] Figure 3 A schematic diagram showing the position of the objective lens when acquiring an image within a first range of motion, according to an embodiment of the present invention, is provided.
[0019] Figure 4 A schematic block diagram of an autofocus device according to an embodiment of the present invention is shown;
[0020] Figure 5 A schematic block diagram of an electronic device according to an embodiment of the present invention is shown. Detailed Implementation
[0021] To make the objectives, technical solutions, and advantages of the present invention more apparent, exemplary embodiments according to the present invention will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are merely a part of the embodiments of the present invention, and not all of the embodiments of the present invention. It should be understood that the present invention is not limited to the exemplary embodiments described herein. Based on the embodiments of the present invention described herein, all other embodiments obtained by those skilled in the art without inventive effort should fall within the protection scope of the present invention.
[0022] Please see Figure 1 The diagram shown illustrates the position of the objective lens during the focusing process in related technologies. Figure 1 In the example shown, the motion range set for the objective lens is from the acquisition start point to the acquisition end point, with a step size of [missing information]. Figure 1The distance shown represents the distance between any two adjacent vertical arrows of the three vertical arrows located at the acquisition start point, or the distance between any two adjacent vertical arrows of the three vertical arrows located at the acquisition end point. The distance from the acquisition start point to the acquisition end point is the distance the objective lens travels during the focusing process. The autofocus system may include an image acquisition device and a driving device. The image acquisition device may include an objective lens. The driving device can control the objective lens to move from the acquisition start point to the acquisition end point. During the movement of the objective lens, the image acquisition device can acquire N images of the target object through the objective lens according to the step distance, which can be expressed as N = 1 + (Z2 - Z1) / s, where Z2 represents the measured value of the grating ruler when the objective lens is located at the acquisition end point, Z1 represents the measured value of the grating ruler when the objective lens is located at the acquisition start point, and s represents the step distance. Taking Z2 = 200 μm, Z1 = 100 μm, and s = 0.5 μm as an example, then N = 1 + (200 μm - 100 μm) / 0.5 μm = 201. The different images captured by an image acquisition device correspond to the position of the objective lens. The closer the objective lens is to its focusing position on the target object, the clearer the captured image will be. The image is clearest when the objective lens is at its focusing position on the target object.
[0023] As described above, this method requires controlling the objective lens to acquire images step by step within a set range of motion. This places high demands on memory and processor, and the objective lens focusing process is time-consuming. To at least partially solve the above-mentioned technical problems, embodiments of the present invention provide an autofocus method, apparatus, and storage medium. This solution acquires and analyzes fewer images during the objective lens focusing process, has lower requirements on memory and processor, and is faster and more efficient.
[0024] Please see Figure 2 The diagram shown is a schematic flowchart of an autofocus method according to an embodiment of the present invention. According to one aspect of the present invention, an autofocus method is provided, the method comprising: steps S210, S220, and S230.
[0025] In step S210, the objective lens is controlled to move in a straight line within a preset first motion range. During the motion, images of the target object are acquired at intervals of one step distance to obtain a group of target images.
[0026] For example, the target object can be any object that the objective lens needle focuses on, such as a wafer, a chip, etc. In some embodiments, the preset first range of motion can be preset by the user, with the starting and ending positions of the objective lens set as follows. In other embodiments, the first range of motion can be determined based on the objective lens position when acquiring a reference image; for example, the starting and ending positions of the first range of motion can be located on either side of the coarse focusing position corresponding to the reference image. The distance between the starting and ending positions and the coarse focusing position can be set as needed, such as a preset default distance. The reference image can be an image acquired when the reference object is positioned at the objective lens's focusing position. The reference object can be any one of multiple target objects of the same type, or an object of the same type as the target object, excluding the target object itself. Specifically, when acquiring an image of the reference object, the reference object can be placed within the image acquisition range of the image acquisition device along the optical axis of the objective lens. The distance between the objective lens and the reference object is adjusted. During the adjustment process, the image acquisition device can acquire an image of the reference object and use the image with the highest resolution as the reference image. The position of the objective lens when acquiring the reference image can then be used as the coarse focusing position of the objective lens. In other words, the coarse focusing position of the objective lens is the position where the image acquired for the reference object is sharpest when the lens is in that position. The sharpness of the image acquired for the reference object can be judged by the user, or a sharpness evaluation method can be used to evaluate the sharpness of each image. Sharpness evaluation methods could include calculating the variance of the Laplacian operator of the image, or calculating the sum of squared gradient magnitudes of the image based on the Sobel operator. It is understood that the objective lens is in a coarse focusing position when acquiring the reference image because different target objects have different surface flatness, and the flatness of the platform used to place the target object is not absolutely horizontal. Therefore, the objective lens is in a coarse focusing position when acquiring the reference image. Since the objective lens's focusing position for the target object is near the coarse focusing position, the starting and ending positions of the objective lens movement can be determined based on the coarse focusing position, and the first range of motion can be from the starting position to the ending position. In some embodiments, the first range of motion can also be determined based on the theoretical focal length in the objective lens's factory parameters. Specifically, taking a theoretical focal length of 200μm for the objective lens as an example, the reference object is placed within the image acquisition range of the image acquisition device along the optical axis of the objective lens. The distance between the objective lens and the reference object is adjusted until the distance between the objective lens and the reference object equals 200μm, at which point the movement of the objective lens is stopped. The position of the objective lens at this point can be used as the coarse focusing position of the objective lens. In other words, the coarse focusing position of the objective lens is the position where the distance between it and the reference object equals the theoretical focal length. Based on the coarse focusing position, the starting and ending positions of the objective lens movement can be determined, and the first range of motion can be from the starting position to the ending position.
[0027] For example, an autofocus system may include a drive unit and an optical encoder. The optical encoder determines the real-time position information of the objective lens during the movement of the objective lens driven by the drive unit. This position information can be obtained by reading the corresponding value on the optical encoder. The optical encoder and the objective lens can be coaxially mounted on the drive shaft. A reading head can be provided on the optical encoder. The measurement value read from the reading head represents the position information of the objective lens. The drive unit can acquire this position information and drive the objective lens to move according to it. During the movement of the objective lens, the measurement value read from the reading head will change. The read measurement value represents the current real-time position information of the objective lens. For the optical encoder, any high-precision optical encoder can be selected. For example, the precision of the optical encoder can be 0.1 μm. The step size of the objective lens can be equal to the precision of the optical encoder. The higher the precision of the optical encoder, the more precisely the objective lens can be controlled from the initial position to the final position. That is, throughout the entire movement, the higher the precision of the optical encoder, the smaller the step size of the objective lens, and the more images are acquired. For example, the step of controlling the objective lens to move linearly within a preset first range of motion may include: controlling the objective lens to move linearly from a starting position to an ending position according to the measurement value of the grating ruler; wherein, during the movement, the position of the objective lens at the time of image acquisition is determined using the grating ruler. The objective lens can be driven by a motor, and the motor can be driven or controlled to rotate by a drive device, which can control the rotation of the motor according to the measurement value of the grating ruler. For example, according to the measurement value of the grating ruler, when the measurement value returned by the grating ruler to the drive device indicates that the current position of the objective lens is the starting position, the drive device drives the motor to start rotating, thereby controlling the objective lens to start moving; and when the measurement value returned by the grating ruler to the drive device indicates that the current position of the objective lens is the ending position, the drive device stops driving the motor to rotate, thereby controlling the objective lens to stop moving. In addition, during the movement, the position of the objective lens at the time of image acquisition is determined using the grating ruler. Thus, according to the measurement value of the grating ruler, the image acquisition device can be controlled to acquire images of the target object at a specified position, thereby enabling the image acquisition device to acquire images of the target object at a step distance interval to obtain a target group of images. The target image set may include multiple images, and for any two consecutively acquired images, the distance between the positions of the objective lenses when acquiring those two images is the first step distance. The first step distance can be an integer multiple of the minimum step distance of the objective lens, and the first step distance is greater than the minimum step distance of the objective lens; for example, the first step distance can be the minimum step distance of a 20x objective lens. Taking a minimum step distance of 0.5μm as an example, the first step distance can be an integer multiple of 0.5μm, such as 10μm. The first step distance can be set according to actual needs; for example, when the minimum step distance of the objective lens is small, the first step distance can be larger. In some embodiments, the minimum step distance of the objective lens can be equal to the accuracy of the grating ruler.
[0028] In step S220, based on the changes in sharpness of the latest acquired target group images, the second motion range of the objective lens is determined. The first position of the objective lens corresponding to the highest image sharpness in the target group images is within the second motion range. The second motion range is within the first motion range, and the motion distance corresponding to the second motion range is less than the motion distance corresponding to the first motion range.
[0029] For example, multiple images acquired within the current motion range can be used as the latest acquired target group images. Specifically, the current motion range can be a preset first motion range or a second motion range determined each time. For each image in the target group acquired within the first motion range, the sharpness of the image can be evaluated. Specifically, for each image in the target group, the sharpness of the image can be evaluated by calculating the variance of the Laplacian operator of the image; a larger variance indicates a sharper image. Alternatively, the sharpness of the image can be evaluated by using the sum of squared gradient magnitudes based on the Sobel operator; a larger sum of squared gradient magnitudes indicates a sharper image. Alternatively, the similarity between the reference image and the image can be calculated, and the sharpness of the image can be evaluated based on the similarity; a larger similarity indicates a sharper image. For example, after obtaining the sharpness of each image in the latest acquired target group, the second motion range of the objective lens can be determined based on the changes in the sharpness of the target group images. It is understandable that during the movement of the objective lens within the first range of motion, the distance between it and the focusing position may first decrease and then increase. Correspondingly, when the images of the target group are arranged in order from near to far from the starting position, the sharpness of the target group images may first increase and then decrease.
[0030] For example, based on the changes in sharpness among the target group images, the image with the highest sharpness can be obtained, and the position of the objective lens when acquiring this image with the highest sharpness can be obtained; this position can be denoted as the first position. Along the optical axis of the objective lens, new starting positions and new ending positions can be obtained on either side of the first position, and the distances of the new starting positions and new ending positions from the first position are respectively a first preset distance. The first preset distance corresponding to the new starting position and the first preset distance corresponding to the new ending position can be the same or different. The second movement range can be from the new starting position to the new ending position. Specifically, the first preset distance corresponding to the starting position of the second movement range can be less than or equal to the distance between the starting position and the first position of the first movement range, and the first preset distance corresponding to the ending position of the second movement range can be less than the distance between the ending position and the first position of the first movement range; or, the first preset distance corresponding to the starting position of the second movement range can be less than the distance between the starting position and the first position of the first movement range, and the first preset distance corresponding to the ending position of the second movement range can be less than or equal to the distance between the ending position and the first position of the first movement range. It can be understood that the second range of motion is within the first range of motion, and the distance of motion corresponding to the second range of motion is less than the distance of motion corresponding to the first range of motion. More specifically, the distance of motion corresponding to the first range of motion is equal to the distance between the starting position and the ending position corresponding to the first range of motion, and the distance of motion corresponding to the second range of motion is equal to the distance between the starting position and the ending position corresponding to the second range of motion.
[0031] In step S230, the objective lens is controlled to move in a straight line within the second motion range. During the movement, images of the target object are acquired at intervals corresponding to the second step distance of the second motion range to obtain new target group images. When the second step distance is greater than the target step distance, the second motion range is taken as the new first motion range, and the process returns to the step of determining the second motion range of the objective lens based on the sharpness change of the latest acquired target group images. When the second step distance is equal to the target step distance, the focusing position of the objective lens for the target object is determined based on the sharpness change of the latest acquired target group images. The focusing position is the second position of the objective lens corresponding to the highest sharpness of the image in the latest acquired target group images.
[0032] For example, after determining the second range of motion of the objective lens, the objective lens can be controlled to move in a straight line within the second range of motion. The process of controlling the objective lens to move in a straight line within the second range of motion can refer to the process of controlling the objective lens to move in a straight line within a preset first range of motion in the foregoing embodiment, and will not be repeated here. During the movement, the image acquisition device can acquire images of the target object at second step intervals to obtain new target group images. The second step interval can be less than or equal to the first step interval, and the second step interval can be an integer multiple of the minimum step interval of the objective lens. Specifically, the target step interval can be defined by the user based on actual focusing needs, and it can be equal to the minimum step interval of the objective lens, or it can be equal to an integer multiple of the minimum step interval of the objective lens. For each determined second range of motion, the second step interval is greater than or equal to the target step interval. When the second step interval equals the target step interval, the image with the highest sharpness can be obtained from the latest acquired target group images according to the sharpness change, and the position of the objective lens when acquiring the image with the highest sharpness can be obtained. This position can be recorded as the second position, and the second position can be used as the focusing position of the objective lens for the target object. When the second step distance is greater than the target step distance, the current second motion range can be used as the new first motion range to return to the step of determining the objective lens's second motion range based on the sharpness change of the latest acquired target group images, until the second step distance corresponding to the determined second motion range equals the target step distance. That is, steps S220 and S230 can be executed once or multiple times. Each time a new target group image is acquired based on the current second step distance, a new second motion range is determined based on the latest acquired target group image, and the objective lens is controlled to move within the new second motion range. After any execution of steps S220 and S230, if the current second step distance is found to equal the target step distance, the next execution of steps S220 and S230 will not begin. In other words, the repeated execution of steps S220 and S230 can stop when the current second step distance equals the target step distance. After the last execution of steps S220 and S230, based on the changes in sharpness of the latest acquired target group images, the image with the highest sharpness can be obtained from the latest acquired target group images, and the position of the objective lens when acquiring the image with the highest sharpness can be obtained. This position can be recorded as the second position, and the second position can be used as the focusing position of the objective lens for the target object.
[0033] The above technical solution determines the second motion range of the objective lens by analyzing the sharpness changes of the target group images acquired within the first motion range. It then determines the focusing position of the objective lens on the target object based on the sharpness changes of the target group images acquired within the second motion range, which is smaller than the first motion range. This method allows for multiple focus searches, with the motion range of the objective lens's focusing position on the target object reduced after each search, eliminating the need for step-by-step image acquisition within the set motion range. This results in fewer images being acquired and analyzed during the entire focusing process, while ensuring the accuracy of the determined focusing position meets requirements. Consequently, it places lower demands on memory and processor, reduces the likelihood of lag, and minimizes the objective lens's focus search time, leading to high focus search efficiency.
[0034] Optionally, the second step distance is obtained by: acquiring the second step distance input by the user; or, determining the second step distance based on the focus speed and focus time, wherein one or both of the focus speed and focus time are input by the user, and when the user inputs one of the focus speed and focus time, the other is a preset value.
[0035] For example, the second step distance corresponding to each determined second motion range can be determined by information input by the user. Specifically, the autofocus system may include an interactive device (e.g., a keyboard, touchscreen, etc.), through which the user can directly input the second step distance, and the processor of the autofocus system can obtain the second step distance input by the user. In some embodiments, the user can set the second step distance for each determined second motion range and input the set second step distance through the interactive device. In other embodiments, the user can select only the second step distance corresponding to the last determined second motion range, which can be equal to the target step distance. In this case, the processor of the interactive device can calculate the second step distance corresponding to each determined second motion range based on a preset rule according to the first step distance and the second step distance corresponding to the last determined second motion range. The second step distance calculated according to the preset rule can satisfy the following: for the second step distance corresponding to the first determined second motion range, the second step distance can be less than or equal to the first step distance and is an integer multiple of the minimum step distance of the objective lens; for the second step distance corresponding to a second motion range not determined for the first time, the second step distance can be less than or equal to the second step distance corresponding to the previously determined second motion range and is an integer multiple of the minimum step distance of the objective lens.
[0036] For example, regarding the second step distance corresponding to the initially determined second range of motion, when the starting position and / or ending position of the determined second range of motion do not coincide with the position of the objective lens corresponding to each image in the target group of images acquired within the first range of motion, the second step distance can be equal to the first step distance. In a specific embodiment, the preset starting position of the first range of motion can be the position of the objective lens at 0 μm, the ending position can be the position of the objective lens at 25 μm, and the first step distance is 5 μm. The image acquisition device acquires images of the target object at positions of 0 μm, 5 μm, 10 μm, 15 μm, 20 μm, and 25 μm, respectively, and the resulting target group of images includes six images. In the target group of images, the image acquired when the objective lens is at 15 μm has the highest clarity, and the position of the objective lens at 15 μm can be used as the first position. The starting position of the determined second range of motion can be the position of the objective lens at 8 μm, and the ending position can be the position of the objective lens at 23 μm. In this embodiment, the second step distance can be 5 μm, and this second range of motion can serve as a new first range of motion. During the movement of the objective lens within this new first range of motion, the image acquisition device can acquire images of the target object at positions of 8 μm, 13 μm, 18 μm, and 23 μm, respectively. The resulting new target image set includes four images. Among the target image set, the image acquired when the objective lens is at 13 μm has the highest clarity, and this position can be considered the new first position. Similarly, for a second step distance corresponding to a second range of motion that is not initially determined, this second step distance can be equal to the second step distance corresponding to the previously determined second range of motion.
[0037] For example, a user can input the focus-seeking speed and / or focus-seeking time through an interactive device, and the processor of the autofocus system can obtain the focus-seeking speed and / or focus-seeking time input by the user. Specifically, the user can set the focus-seeking speed for the currently determined second motion range, and the focus-seeking time can be equal to the ratio of the motion distance corresponding to the currently determined second motion range to the focus-seeking speed. In this case, the currently determined second motion range can be used as the last determined second motion range, and the image acquisition device continuously takes pictures at a preset image acquisition speed m, where m is measured in frames per second. Let the motion distance corresponding to the currently determined second motion range be denoted as S, the focus-seeking speed as v, and the second step distance as s, then s = S / [(S / v)*m-1]. The user can also set the focus-seeking time for the currently determined second motion range, and the focus-seeking speed can be equal to the ratio of the motion distance corresponding to the currently determined second motion range to the focus-seeking time. Similarly, the currently determined second motion range can be used as the last determined second motion range, and the image acquisition device continuously takes pictures at a preset image acquisition speed m, where m is measured in frames per second. Let S be the distance corresponding to the currently determined second motion range, t be the focusing time, and s be the second step distance. Then, s = S / (t*m-1). The user can also set the focusing speed and focusing time for the currently determined second motion range, and the product of the set focusing speed and focusing time is equal to the distance corresponding to the currently determined second motion range. Similarly, the currently determined second motion range can be used as the last determined second motion range. The image acquisition device continuously takes pictures at a preset image acquisition speed m, where m is measured in frames per second. Let S be the distance corresponding to the currently determined second motion range, t be the focusing time, s be the second step distance, and v be the focusing speed. Then, s = S / [(S / v)*m-1] or s = S / (t*m-1).
[0038] The above technical solution determines the second step distance based on the user's input information, allowing the user to define the value of the second step distance according to the actual focusing effect. This enables the user to control the time from the start of focusing to determining the focusing position of the objective lens on the target object, providing high flexibility and adaptability to various focusing scenarios.
[0039] Optionally, each second step distance is smaller than the first step distance; the second step distance corresponding to each determined second movement range is smaller than the second step distance corresponding to the previously determined second movement range.
[0040] For example, the second step distance corresponding to each determined second movement range is smaller than the first step distance. For instance, when the first step distance is equal to 10 μm, the second step distance corresponding to each determined second movement range can be equal to 8 μm, 5 μm, 2 μm, etc. The second step distance corresponding to each non-first determined second movement range is smaller than the second step distance corresponding to the previously determined second movement range. For instance, when the second step distance corresponding to the first determined second movement range is equal to 5 μm, the second step distance corresponding to the second determined second movement range can be 2 μm, and the second step distance corresponding to the third determined second movement range can be 0.5 μm.
[0041] In the above technical solution, the second step distance corresponding to the determined second motion range can gradually approach the target step distance of the objective lens, so that the distance between the position of the objective lens corresponding to the highest image sharpness in the target group image and the theoretical position of the objective lens corresponding to the maximum image sharpness can gradually decrease until the distance between the determined focus position and the theoretical position of the objective lens corresponding to the maximum image sharpness does not exceed the target step distance. When the objective lens is located at the finally determined focus position, the sharpness of the acquired image can be extremely close to the theoretical maximum sharpness of the acquired image.
[0042] Optionally, determining the second motion range of the objective lens based on the sharpness change of the latest acquired target group images includes: determining a first position based on the sharpness change of the latest acquired target group images; determining a third and fourth position of the objective lens based on the first position, wherein the third and fourth positions are located on either side of the first position, and the images acquired at the third, first, and fourth positions are continuously acquired images; and defining the third and fourth positions as the boundaries of the second motion range to determine the second motion range.
[0043] For example, for the latest acquired target group images, the image with the highest resolution can be obtained based on its resolution variation. The position of the objective lens when acquiring this image with the highest resolution can be determined as the first position. After determining the first position, a third position and a fourth position can be determined on both sides of the first position. The image acquired when the objective lens is in the third position is continuous with the image acquired when it is in the first position, and the image acquired when the objective lens is in the first position is continuous with the image acquired when it is in the fourth position. In other words, the images acquired at the third, first, and fourth positions are continuously acquired images. The third and fourth positions can be determined as the boundaries of the second motion range; that is, the third position can be used as the starting position corresponding to the second motion range, and the fourth position can be used as the ending position corresponding to the second motion range. For example, during the process of the objective lens moving in a straight line within the first motion range, the image acquisition device acquires images of the target object at positions of 150μm, 160μm, 170μm, 180μm, 190μm, and 200μm, respectively, resulting in a target group image comprising six images. In this embodiment, the image acquired when the objective lens is at 180μm has the highest clarity. Therefore, the first position is the position when the objective lens is at 180μm, the third position is the position when the objective lens is at 170μm, and the fourth position is the position when the objective lens is at 190μm. The boundaries of the second range of motion determined based on this set of target images are the positions when the objective lens is at 170μm and 190μm.
[0044] The above technical solution defines the third and fourth positions on both sides of the first position as the boundaries of the second motion range. The images acquired by the objective lens in the third position and the images acquired by the objective lens in the fourth position are both continuous with the images acquired by the objective lens in the first position. This method can ensure that the motion distance corresponding to the determined second motion range is much smaller than the motion distance corresponding to the first motion range, which is beneficial to save focusing time and can ensure that the theoretical position of the objective lens corresponding to the maximum image clarity is within the second motion range.
[0045] Optionally, based on the changes in sharpness of the latest acquired target group images, a second range of motion of the objective lens is determined, including: determining the similarity between each image in the target group images and a reference image, wherein the reference image is an image acquired by the objective lens when it is in a focusing position for a reference object, and the reference object and the target object are objects of the same type; determining the second range of motion based on the changes in similarity between each image in the target group images and the reference image; wherein the changes in sharpness are represented by changes in similarity.
[0046] For example, the reference image can be an image acquired when the reference object is pre-positioned in the focusing position of the objective lens. The reference object can be any one of multiple target objects of the same type, or it can be an object of the same type as the target object, excluding the target object. For example, when the target objects are multiple wafers of the same model, the reference object can be one of the multiple wafers that are the target objects, or it can be a wafer of the same model as the multiple wafers. The specific process of acquiring the reference image can be referred to the foregoing embodiments, and will not be repeated here. The sharpness of each image in the target group of images can be represented by the similarity between the image and the reference image. The similarity can be quantified by a score; the higher the score, the greater the similarity. Accordingly, the change in sharpness of the target group of images can be represented by the change in the similarity of the target group of images. The second range of motion of the objective lens can be determined based on the change in the similarity of the target group of images, and the first position of the objective lens corresponding to the image in the target group of images with the highest similarity to the reference image is within the second range of motion. The embodiments of the present invention do not impose specific limitations on the method of obtaining similarity. For example, the method of obtaining similarity may be to calculate the mean square error between each image of the target group and the reference image, or to calculate the structural similarity index between each image of the target group and the reference image.
[0047] The above technical solution determines the sharpness of each image by comparing the similarity between each image in the target group and the reference image. It can quickly and accurately quantify the changes in the sharpness of each image, and thus intuitively and accurately determine the second motion range based on the changes in the sharpness of each image.
[0048] Optionally, before controlling the objective lens to move linearly within a preset first range of motion, the method further includes: determining a first step distance in response to a user input operation.
[0049] For example, the first step distance can be input by the user through the interactive device of the autofocus system, and the processor of the autofocus system can determine the first step distance in response to the user's input operation. Specifically, the autofocus system may also include a display device, on which an input box for inputting the first step distance can be provided, and the user can set the first step distance in the input box through the interactive device.
[0050] The above technical solution can determine the first step distance based on the user's input information, allowing the user to define the value of the first step distance according to the actual focusing effect. This helps the user to control the time from the start of focusing to determining the focusing position of the objective lens on the target object, providing high flexibility and adaptability to various focusing scenarios.
[0051] Optionally, after determining the first step distance and before controlling the objective lens to move linearly within the second motion range, the method further includes: determining the second step distance corresponding to the second motion range determined each time based on the first step distance and the target step distance of the objective lens; wherein the second step distance corresponding to the last determined second motion range is equal to the target step distance.
[0052] For example, the processor of the interactive device can determine the second step distance corresponding to the second movement range determined each time based on the first step distance and the target step distance of the objective lens. The second step distance corresponding to the last determined second movement range is equal to the target step distance of the objective lens. Specifically, for the second step distance corresponding to the first determined second movement range, the second step distance can be less than or equal to the first step distance and is an integer multiple of the minimum step distance of the objective lens; for the second step distance corresponding to a second movement range not determined for the first time, the second step distance can be less than or equal to the second step distance corresponding to the previously determined second movement range and is an integer multiple of the minimum step distance of the objective lens.
[0053] For example, the second step distance corresponding to the second movement range determined each time can be determined according to a preset rule based on the first step distance and the target step distance. For example, the first step distance can be 10 μm, the target step distance can be 0.5 μm, and the preset rule can include: the first step distance is a multiple of the second step distance corresponding to the first determined second movement range that is an integer greater than 4; the second step distance corresponding to the second movement range determined each time is a multiple of the second step distance corresponding to the second movement range determined next time that is an integer greater than 2; the second step distance corresponding to the second movement range determined each time is an integer multiple of the minimum step distance of the objective lens; and the second step distance corresponding to the second movement range determined last time is equal to the target step distance. In this case, the second step distance corresponding to the first determined second movement range can be 2 μm, and the second step distance corresponding to the second determined second movement range can be 0.5 μm.
[0054] For example, the first step distance could be 10 μm, the target step distance could be 0.5 μm, and the preset rules could include: the first step distance is a multiple of 2 relative to the second step distance corresponding to the first determined second motion range; for each determined second motion range other than the last determined second motion range, the second step distance corresponding to the determined second motion range is a multiple of 0.5 relative to the second step distance corresponding to the previously determined second motion range, and the maximum number of focus attempts is 4. In this case, the second step distance corresponding to the first determined second motion range could be 5 μm, the second step distance corresponding to the second determined second motion range could be 2.5 μm, and the second step distance corresponding to the third determined second motion range could be 0.5 μm.
[0055] For example, the initial step distance could be 10 μm, and the target step distance could be 0.5 μm. Preset rules could include: the second step distance corresponding to the first determined second motion range is equal to the initial step distance; the multiple of the second step distance corresponding to each determined second motion range relative to the second step distance corresponding to the next determined second motion range is an integer greater than 2; the maximum number of focus attempts is 4; the second step distance corresponding to each determined second motion range is an integer multiple of the objective lens's minimum step distance; and the second step distance corresponding to the last determined second motion range is equal to the target step distance. In this case, the second step distance corresponding to the first determined second motion range could be 10 μm, the second step distance corresponding to the second determined second motion range could be 2 μm, and the second step distance corresponding to the third determined second motion range could be 0.5 μm.
[0056] In the above embodiments, if the preset rule may include the maximum number of focus attempts, the maximum number of focus attempts may be input by the user, or it may be a preset default value, or it may be determined based on the motion distance corresponding to the first preset first motion range. For example, the maximum number of focus attempts may be determined based on the preset numerical range into which the motion distance corresponding to the preset first motion range falls. Different preset numerical ranges may correspond to different maximum number of focus attempts. The larger the average / median / extreme value of the preset numerical range, the larger the corresponding maximum number of focus attempts.
[0057] It is understood that the preset rules described in the above embodiments are merely examples. The preset rules may further include, for example, that the difference between the first step distance and the second step distance corresponding to the first determined second motion range is a first preset difference (e.g., 5 μm); the difference between the second step distance corresponding to each determined second motion range and the second step distance corresponding to the next determined second motion range is a second preset difference (e.g., 3 μm); the second step distance corresponding to each determined second motion range is an integer multiple of the minimum step distance of the objective lens; and the second step distance corresponding to the last determined second motion range is equal to the target step distance. Alternatively, the preset rules may further include: the difference between the first step distance and the second step distance corresponding to the first determined second motion range is equal to the difference between the second step distance corresponding to each determined second motion range and the second step distance corresponding to the next determined second motion range; the second step distance corresponding to each determined second motion range is an integer multiple of the minimum step distance of the objective lens; and the second step distance corresponding to the last determined second motion range is equal to the target step distance. The embodiments of the present invention do not impose specific limitations on the preset rules. The preset rules can be used to determine the second step distance corresponding to the second movement range determined each time based on the first step distance and the target step distance of the objective lens, and the second step distance corresponding to the last determined second movement range is equal to the target step distance.
[0058] The above technical solution can determine each second step distance based on the first step distance and the target step distance, which can realize the automated implementation of the second step distance with less user operation.
[0059] Optionally, controlling the objective lens to move in a straight line within a preset first range of motion includes: controlling the objective lens to move from a starting position to an ending position, wherein the starting position and the ending position are located on both sides of the coarse focusing position, the coarse focusing position is the focusing position of the objective lens for the reference object, wherein the reference object and the target object are objects of the same type, and the focusing position for the reference object is the second position of the objective lens corresponding to the highest image sharpness in the image acquired for the reference object.
[0060] For example, the reference object can be any one of multiple target objects of the same type, or an object of the same type as the target object but other than the target object. The starting position and the ending position can be located on opposite sides of the coarse focusing position along the optical axis of the objective lens. The distances between the starting position and the ending position and the coarse focusing position can be denoted as the second preset distance. The second preset distances corresponding to the starting position and the ending position can be the same or different. The starting position, the coarse focusing position, and the ending position are located on the same straight line, which is parallel to the optical axis of the objective lens, and the focusing position of the objective lens is located between the starting position and the ending position. The second preset distance can be any value, which can be set according to various parameters in the application scenario, such as the thickness difference of different target objects. If the thickness difference of different target objects is large, the second preset distance can be set to be large. For example, the second preset distances between the starting position and the ending position and the coarse focusing position can be equal. In the above embodiment where the reference object is placed within the image acquisition range of the image acquisition device along the optical axis of the objective lens, the second preset distance can be equal to 50 μm. The starting position can be represented as the difference between the coarse focusing position and the second preset distance, i.e., the position of 150 μm. In other words, when the distance between the objective lens and the target object is 150 μm, it is at the starting position. The ending position can be represented as the sum of the coarse focusing position and the second preset distance, i.e., the position of 250 μm. When the distance between the objective lens and the target object is 250 μm, it is at the ending position. It can be understood that the starting and ending positions can also be interchanged; that is, the starting position is 250 μm from the target object, and the ending position is 150 μm from the target object.
[0061] The above technical solution uses the focusing position of the reference object as the coarse focusing position, which can be found without high-cost devices. This can quickly and accurately determine the first motion range and ensure that the theoretical position of the objective lens corresponding to the maximum image sharpness is within the first motion range.
[0062] Please see Figure 3 The diagram shown illustrates the position of the objective lens when acquiring an image within a first range of motion, according to an embodiment of the present invention. Figure 3 In the illustrated embodiment, the preset first range of motion for the objective lens is from the starting position to the ending position, with the starting position being at... Figure 3 The leftmost vertical arrow indicates the starting point of the data collection, and the endpoint is shown in the image. Figure 3 The image shows the location indicated by the rightmost vertical arrow (i.e., the acquisition endpoint). The objective lens can move in a straight line from the starting position to the endpoint. In this embodiment, the measurement value of the acquisition starting point on the grating ruler is 100 μm, and the measurement value of the acquisition endpoint on the grating ruler is 200 μm. The first step distance is... Figure 3 The distance shown is the distance between any two adjacent vertical arrows of the three vertical arrows located at the starting position, or the distance between any two adjacent vertical arrows of the two vertical arrows located at the ending position. In this embodiment, the first step distance is equal to 10 μm. The movement distance corresponding to the first movement range is the distance from the starting position to the ending position. During the process of controlling the objective lens to move in a straight line within the preset first movement range, images of the target object can be acquired at intervals of the first step distance to obtain a group of target images (denoted as the first target group images). The sharpness score of each image in the obtained first target group images is shown in Table 1:
[0063] Table 1. Sharpness scores for each image in the first target group.
[0064] id 1 2 3 4 5 6 7 8 9 10 11 Z 100 110 120 130 140 150 160 170 180 190 200 score 60 65 70 75 80 85 90 95 85 80 75
[0065] The number of images in the first target group acquired within the preset first motion range is denoted as N1. Then, N1 = (200μm - 100μm) / 10μm + 1 = 11. Arranged in ascending order of distance from the acquisition starting point, the first image has an index (id) of 1 in Table 1, the second image has an index of 2, and so on, up to the eleventh image has an index of 11. In Table 1, Z represents the measurement value of the objective lens on the grating ruler when acquiring the corresponding image. This measurement value indicates the position of the objective lens, and its unit of measurement is μm. Score represents the sharpness score of the corresponding image. Table 1 shows that the image with the highest sharpness score is the eighth image (id = 8), with a sharpness score of 95. The objective lens position when acquiring the eighth image was at 170μm, which can be considered the first position. After determining the first position, the third and fourth positions of the objective lens can be determined based on the first position. The third and fourth positions are located on either side of the first position. In this embodiment, the third position is the position when the objective lens is at 160 μm, and the fourth position is the position when the objective lens is at 180 μm. The third and fourth positions are defined as the boundaries of the second motion range to determine the second motion range. After determining the second motion range, the objective lens can be controlled to move linearly within the second motion range. During the movement, images of the target object are acquired at intervals corresponding to the second step distance of the second motion range to obtain a new group of target images (denoted as the second target group images). In this embodiment, the second step distance corresponding to the currently determined second motion range is 2 μm. The sharpness scores of each image in the obtained second target group images are shown in Table 2.
[0066] Table 2. Sharpness scores for each image in the second target group.
[0067] id 1 2 3 4 5 6 7 8 9 10 11 Z 160 162 164 166 168 170 172 174 176 178 180 score 90 94 97 99 98 95 94 92 90 88 85
[0068] The number of images in the second target group acquired within the second motion range is denoted as N2. Then, N2 = (180μm - 160μm) / 2μm + 1 = 11. Arranged in ascending order of distance from the third position, the first image has an ID value (id) of 1 in Table 1, the second image has an ID value of 2 in Table 2, and so on, with the eleventh image having an ID value of 11 in Table 1. In Table 2, Z represents the measurement value of the objective lens on the grating ruler when acquiring the corresponding image. This measurement value indicates the position of the objective lens, and its unit of measurement is μm. Score represents the sharpness score of the corresponding image. In this embodiment, the target step distance is 0.5μm. The second step distance is greater than the target step distance. The currently determined second motion range is taken as the first motion range, and the second motion range of the objective lens is determined again based on the sharpness changes of the second target group images. As shown in Table 2, the image with the highest sharpness score is the fourth image (id=4), with a sharpness score of 99. The objective lens position when acquiring the fourth image is at 166μm, which can be used as the first position. After determining the first position, the third and fourth positions of the objective lens can be determined based on the first position. The third and fourth positions are located on both sides of the first position. In this embodiment, the third position is the position when the objective lens is at 164μm, and the fourth position is the position when the objective lens is at 168μm. The third and fourth positions are determined as the boundaries of the second motion range to define the second motion range. After determining the second motion range, the objective lens can be controlled to move in a straight line within the second motion range. During the movement, images of the target object are acquired at intervals corresponding to the second step distance of the second motion range to obtain a new target group image (denoted as the third target group image). In this embodiment, the second step distance corresponding to the currently determined second motion range is 0.5μm. The sharpness scores of each image in the obtained third target group image are shown in Table 3.
[0069] Table 3. Sharpness scores for each image in the third target group.
[0070] id 1 2 3 4 5 6 7 8 9 Z 164 164.5 165 165.5 166 166.5 167 167.5 168 score 97 98 98.5 99 100 99.5 98.5 98.5 98
[0071] Let N3 be the number of images in the third target group. Then, N3 = (168μm - 164μm) / 0.5μm + 1 = 9. Arranged in ascending order of distance from the third position, the first image has an id value of 1 in Table 3, the second image has an id value of 2, ..., and the ninth image has an id value of 9. In Table 3, Z represents the measurement value of the objective lens on the grating ruler when acquiring the corresponding image. This measurement value can indicate the position of the objective lens, and its unit of measurement is μm. Score represents the sharpness score of the corresponding image. In this embodiment, the target step size is 0.5μm, and the second step size is equal to the target step size. The focusing position of the objective lens for the target object can be determined based on the sharpness changes of the third target group images. As shown in Table 3, the image with the highest sharpness score is the fifth image (id = 5), with a sharpness score of 100. The objective lens position when acquiring the fifth image is at 166μm, so this position can be used as the focusing position of the objective lens for the target object.
[0072] Please see Figure 4 The diagram shown is a schematic block diagram of an autofocus device according to one embodiment of the present invention. According to another aspect of the present invention, an autofocus device 400 is also provided, comprising:
[0073] The first control module 410 is used to control the objective lens to move in a straight line within a preset first motion range. During the motion, the objective lens is used to acquire images of the target object at intervals of one step distance to obtain a group of target images.
[0074] The determination module 420 is used to determine the second motion range of the objective lens based on the changes in the sharpness of the latest acquired target group images. The first position of the objective lens corresponding to the highest image sharpness in the target group images is within the second motion range. The second motion range is within the first motion range, and the motion distance corresponding to the second motion range is less than the motion distance corresponding to the first motion range.
[0075] The second control module 430 is used to control the objective lens to move in a straight line within the second motion range. During the movement, the objective lens acquires images of the target object at intervals corresponding to the second step distance of the second motion range to obtain new target group images. When the second step distance is greater than the target step distance, the second motion range is taken as the new first motion range, and the process returns to the step of determining the second motion range of the objective lens based on the sharpness change of the latest acquired target group images. When the second step distance is equal to the target step distance, the objective lens is determined for the target object based on the sharpness change of the latest acquired target group images. The focusing position is the second position of the objective lens corresponding to the highest sharpness of the image in the latest acquired target group images.
[0076] Please see Figure 5As shown, it is a schematic block diagram of an electronic device according to an embodiment of the present invention. According to another aspect of the present invention, an electronic device 500 is also provided, including: a processor 510 and a memory 520, wherein the memory 520 stores computer program instructions, which are executed by the processor 510 to perform the above-described autofocus method.
[0077] According to another aspect of the present invention, a storage medium is also provided, on which program instructions are stored. When the program instructions are executed by a computer or processor, the computer or processor performs corresponding steps of the autofocus method described above in the embodiments of the present invention, and is used to implement corresponding modules in the autofocus device described above in the embodiments of the present invention, or corresponding modules in the autofocus device described above. The storage medium may, for example, include a memory card of a smartphone, a storage component of a tablet computer, a hard disk of a personal computer, a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a portable compact disc read-only memory (CD-ROM), a USB memory, or any combination of the above storage media. A computer-readable storage medium may be any combination of one or more computer-readable storage media.
[0078] According to another aspect of the present invention, a computer program product is also provided, including computer program instructions that, when executed, perform the autofocus method as described above.
[0079] Those skilled in the art can understand the specific implementation and beneficial effects of the above-described autofocus device by reading the detailed description of the autofocus method above, and for the sake of brevity, they will not be described in detail here.
[0080] Although exemplary embodiments have been described herein with reference to the accompanying drawings, it should be understood that the above exemplary embodiments are merely illustrative and are not intended to limit the scope of the invention. Various changes and modifications can be made therein by those skilled in the art without departing from the scope and spirit of the invention. All such changes and modifications are intended to be included within the scope of the invention as claimed in the appended claims.
[0081] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0082] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed.
[0083] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0084] Similarly, it should be understood that, in order to streamline the invention and aid in understanding one or more of the various aspects of the invention, features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof in the description of exemplary embodiments of the invention. However, this approach should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as reflected in the corresponding claims, its inventive point lies in solving the corresponding technical problem with fewer features than all of those in a single disclosed embodiment. Therefore, the claims following the detailed description are hereby expressly incorporated into that detailed description, wherein each claim itself is a separate embodiment of the invention.
[0085] Those skilled in the art will understand that, apart from the mutual exclusion of features, all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or apparatus so disclosed can be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.
[0086] Furthermore, those skilled in the art will understand that although some embodiments herein include certain features included in other embodiments but not others, combinations of features from different embodiments are intended to be within the scope of the invention and form different embodiments. For example, in the claims, any of the claimed embodiments can be used in any combination.
[0087] The various component embodiments of the present invention can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some modules in an autofocus device according to embodiments of the present invention. The present invention can also be implemented as an apparatus program (e.g., a computer program and computer program product) for performing some or all of the methods described herein. Such programs implementing the present invention can be stored on a computer-readable medium or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
[0088] It should be noted that the above embodiments are illustrative of the invention and not restrictive, and that those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.
[0089] The above are merely specific embodiments or descriptions of the present invention, and the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. The scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. An auto-focusing method characterized by, The method comprises: controlling the objective lens to move linearly within a preset first movement range, and during the movement, acquiring images of a target object at intervals of a first step distance to obtain a target group of images; determining a second movement range of the objective lens according to a variation in sharpness of the latest acquired target group of images, wherein a first position of the objective lens corresponding to the highest sharpness of the images in the target group of images is within the second movement range, the second movement range is within the first movement range, and a movement distance corresponding to the second movement range is smaller than a movement distance corresponding to the first movement range; controlling the objective lens to move linearly within the second movement range, and during the movement, acquiring images of the target object at intervals of a second step distance corresponding to the second movement range to obtain a new target group of images, when the second step distance is greater than a target step distance, taking the second movement range as a new first movement range, and returning to perform the step of determining the second movement range of the objective lens according to the variation in sharpness of the latest acquired target group of images, and when the second step distance is equal to the target step distance, determining a focusing position of the objective lens for the target object according to the variation in sharpness of the latest acquired target group of images, wherein the focusing position is a second position of the objective lens corresponding to the highest sharpness of the images in the latest acquired target group of images.
2. The method of claim 1, wherein, The second step distance is obtained by: obtaining the second step distance input by a user; or determining the second step distance based on a focusing speed and a focusing time, wherein one or both of the focusing speed and the focusing time is input by the user, and when one of the focusing speed and the focusing time is input by the user, the other is a preset value.
3. The method of claim 1, wherein: each of the second step distances is smaller than the first step distance; and the second step distance corresponding to each determined second movement range is smaller than the second step distance corresponding to the last determined second movement range.
4. The method of claim 1, wherein, The step of determining the second movement range of the objective lens according to the variation in sharpness of the latest acquired target group of images comprises: determining the first position according to the variation in sharpness of the latest acquired target group of images; determining a third position and a fourth position of the objective lens according to the first position, wherein the third position and the fourth position are respectively located on two sides of the first position, and images respectively acquired at the third position, the first position, and the fourth position are continuously acquired images; determining the third position and the fourth position as boundaries of the second movement range to determine the second movement range.
5. The method of claim 1, wherein, The step of determining the second movement range of the objective lens according to the variation in sharpness of the latest acquired target group of images comprises: determining a similarity between each image in the target group of images and a reference image, wherein the reference image is an image acquired by the objective lens when the objective lens is located at a focusing position for a reference object, and the reference object and the target object are objects of the same type. determine the second motion range according to a change of the similarity between each image in the target group of images and the reference image; wherein the change of the sharpness is represented by the change of the similarity.
6. The method according to any one of claims 1 to 5, characterized in that, before the controlling the objective lens to move in a straight line within the preset first motion range, the method further comprises: determine the first step distance in response to an input operation of a user.
7. The method according to claim 6 when dependent on claim 2 or 3, characterized in that, after the determining the first step distance, before the controlling the objective lens to move in a straight line within the second motion range, the method further comprises: determine the second step distance corresponding to each determined second motion range according to the first step distance and a target step distance of the objective lens; wherein the second step distance corresponding to the last determined second motion range is equal to the target step distance.
8. The method according to any one of claims 1 to 5, characterized in that, the controlling the objective lens to move in a straight line within the preset first motion range comprises: controlling the objective lens to move from a starting position to an ending position, wherein the starting position and the ending position are respectively located on two sides of a coarse focus position, the coarse focus position is a focus position of the objective lens for a reference object, wherein the reference object and the target object are objects of the same type, and the focus position for the reference object is a position of the objective lens corresponding to a highest sharpness of an image in an image acquired for the reference object.
9. An auto-focusing device characterized by comprising: comprise: a first control module configured to control the objective lens to move in a straight line within a preset first motion range, and during the movement, to acquire images of a target object at intervals of a first step distance to obtain a target group of images; a determination module configured to determine a second motion range of the objective lens according to a change of sharpness of a newly acquired target group of images, wherein a first position of the objective lens corresponding to a highest sharpness of an image in the target group of images is within the second motion range, the second motion range is within the first motion range, and a motion distance corresponding to the second motion range is smaller than a motion distance corresponding to the first motion range; a second control module configured to control the objective lens to move in a straight line within the second motion range, and during the movement, to acquire images of the target object at intervals of a second step distance corresponding to the second motion range to obtain a new target group of images, when the second step distance is greater than a target step distance, to take the second motion range as a new first motion range, and to return to perform the step of determining the second motion range of the objective lens according to the change of sharpness of the newly acquired target group of images, and when the second step distance is equal to the target step distance, to determine a focus position of the objective lens for the target object according to the change of sharpness of the newly acquired target group of images, wherein the focus position is a second position of the objective lens corresponding to a highest sharpness of an image in the newly acquired target group of images.
10. A storage medium on which program instructions are stored, characterized in that, the program instructions, when executed, cause the processor to perform the method of any one of claims 1-8. the program instructions, when executed, cause the processor to perform the method of any one of claims 1-8.
Citation Information
Patent Citations
Focusing method and device, electronic equipment and storage medium
CN114460791A
Automatic focusing method, system and device, electronic equipment and storage medium
CN116243448A