Automatic focusing method, system and device and storage medium

Through the automatic focusing method, the step size and range are determined according to the movement range and exposure time of the focusing motor, and the automatic focusing of the focusing motor is realized, which solves the problem of unclear images in the existing technology and improves the accuracy of product detection.

CN118784979APending Publication Date: 2024-10-15JIANGSU MUTENGGUANG PRECISION OPTICAL INSTR CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411160623.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-22
Publication Date
2024-10-15

AI Technical Summary

Technical Problem

Due to fixed focus parameters and neglect of exposure time in industrial product quality inspection, the existing focus motor results in unclear collected images, affecting the inspection results.

Method used

By obtaining the movement range and exposure time of the focus motor, determine the coarse search step length and fine search range, control the focus motor to perform automatic focusing, and determine the target focus using coarse search and fine search methods to ensure image clarity.

Benefits of technology

The automatic focusing of the focusing motor is realized, ensuring image clarity and improving the accuracy of product detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118784979A_ABST
    Figure CN118784979A_ABST
Patent Text Reader

Abstract

The invention provides an automatic focusing method, system and device, and a storage medium. The method comprises the following steps: dividing a motion range of a focusing motor according to a coarse search step length to obtain a plurality of coarse search nodes; controlling the focusing motor to start to move from one rough search node, stopping exposure time at each rough search node and shooting a frame of product image at each rough search node until a product image corresponding to each rough search node is obtained, determining the highest definition in the plurality of first definitions according to the first definition of each frame of product image, determining a target product image from the plurality of frames of product images according to the highest definition, and obtaining a coarse search peak node corresponding to the target product image; and determining a precise search range according to the rough search peak node, carrying out precise search on the precise search range according to a preset precise search step length to obtain a target precise search focus, and controlling a focusing motor to move to the target precise search focus. According to the invention, automatic focusing of the focusing motor can be realized, movement is stopped during exposure, and the precision of product quality detection is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of electromechanical control technology, and in particular to an automatic focusing method, system, device and storage medium. Background Art

[0002] In the production process of some industrial products, such as PCB boards and mobile phone panels, since the number of products is often large, it is usually necessary to collect images of the products to perform quality inspection. The commonly used method at present is mostly to use a focus motor. The focus motor usually consists of a motor and a camera. The motor can control the camera to move up and down above the product to collect images of each product separately. However, the existing focus motors mostly use fixed focus parameters for image acquisition, and do not take into account the exposure time of the camera, which can easily lead to unclear images and affect the results of quality inspection. Summary of the invention

[0003] In view of this, an object of the present invention is to overcome the deficiencies in the prior art and to provide an automatic focusing method, system, device and storage medium to achieve automatic focusing of a focus motor.

[0004] The present invention provides the following technical solutions:

[0005] In a first aspect, the present application provides an autofocus method, comprising:

[0006] Acquire the movement range and exposure time of the focus motor, and determine the coarse search step length of the focus motor according to the movement range; each coarse search step length includes two coarse search nodes, and the interval between every two adjacent coarse search nodes is the coarse search step length;

[0007] Control the focus motor to start moving from one of the coarse search nodes, move one coarse search step each time, stop the exposure time at each coarse search node and shoot a frame of product image, until the product image corresponding to each coarse search node is obtained;

[0008] Acquire a first definition of each frame of the product image, determine a highest definition among a plurality of the first definitions, determine a target product image from a plurality of frames of the product image according to the highest definition, and acquire a coarse search peak node corresponding to the target product image;

[0009] A fine search range is determined according to the rough search peak node, a fine search is performed on the fine search range according to a preset fine search step length to obtain a target fine search focus, and the focus motor is controlled to move to the target fine search focus.

[0010] In one implementation manner, after determining the coarse search step length of the focus motor according to the motion range, the method further comprises:

[0011] Acquire the frame rate of the focus motor, and determine the shooting time of each frame image of the focus motor according to the frame rate;

[0012] Obtaining a time difference between the shooting time and the exposure time, and using the time difference as the movement time of the focus motor;

[0013] The movement speed of the focus motor is calculated according to the coarse search step length and the movement time.

[0014] In one implementation, controlling the focus motor to move to the target fine search focus includes:

[0015] Acquire the current position of the focus motor, and determine the target distance between the current position and the target fine search focus;

[0016] The target movement speed of the focus motor is calculated according to the target distance and the movement time, and the focus motor is controlled to move from the current position to the target fine search focus according to the target movement speed.

[0017] In one implementation manner, controlling the focus motor to start moving from one of the coarse search nodes includes:

[0018] Obtaining the node positions of all the rough search nodes, and determining the start node and the end node according to the node positions;

[0019] The focus motor is controlled to move from the starting node at the moving speed.

[0020] In one implementation, the step of obtaining the product image corresponding to each of the rough search nodes includes:

[0021] Acquire a current product image acquired by the focus motor at a current coarse search node;

[0022] Determine whether the current rough search node is the end node;

[0023] If it is the end node, it is determined to obtain the product image corresponding to each of the rough search nodes.

[0024] In one implementation, determining a fine search range according to the rough search peak node includes:

[0025] According to the rough search step length, the motion range is divided to obtain a plurality of rough search intervals;

[0026] Acquire a target coarse search interval adjacent to the coarse search peak node from the plurality of coarse search intervals;

[0027] The fine search range is obtained according to the target rough search interval and the rough search peak node.

[0028] In one implementation, performing a fine search on the fine search range according to a preset fine search step length to obtain a target fine search focus includes:

[0029] According to the refined search step length, the refined search range is divided to obtain a plurality of refined search nodes;

[0030] Acquire a refined search product image corresponding to each refined search node, and acquire a second definition corresponding to each frame of the refined search product;

[0031] Acquire the second clarity of each frame of the product image, determine the highest second clarity among multiple second clarity, determine the target fine search image from multiple frames of the fine search product images according to the highest second clarity, and use the fine search node corresponding to the target fine search product image as the target fine search focus.

[0032] In a second aspect, the present application provides an autofocus system, comprising:

[0033] An acquisition module is used to acquire the movement range and exposure time of the focus motor, and determine the coarse search step length of the focus motor according to the movement range; each of the coarse search step lengths includes two coarse search nodes, and the interval between every two adjacent coarse search nodes is the coarse search step length;

[0034] A motion module, used for controlling the focus motor to start moving from a coarse search node, moving one coarse search step each time, stopping the exposure time at each coarse search node and shooting a frame of product image, until the product image corresponding to each coarse search node is obtained;

[0035] A determination module, configured to obtain a first definition of each frame of the product image, determine a highest definition among a plurality of the first definitions, determine a target product image from a plurality of frames of the product image according to the highest definition, and obtain a coarse search peak node corresponding to the target product image;

[0036] A focusing module is used to determine a fine search range according to the rough search peak node, perform a fine search on the fine search range according to a preset fine search step length, obtain a target fine search focus, and control the focusing motor to move to the target fine search focus.

[0037] In a third aspect, the present application provides an electronic device, comprising a memory and at least one processor, wherein the memory stores a computer program, and the processor is used to execute the computer program to implement the autofocus method as described in the first aspect.

[0038] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed, the autofocus method as described in the first aspect is implemented.

[0039] The embodiments of the present invention have the following beneficial effects:

[0040] The automatic focusing method provided by the present invention determines the coarse search step length according to the movement range of the focus motor, and then controls the focus motor to stop the exposure time after each movement of a coarse search step length, so as to capture a frame of image, determine the coarse search peak node from multiple frames of focus images, determine the fine search range according to the coarse search peak node, and then use the fine search method to search for the target fine search node from the fine search range, and control the focus motor to move to the target fine search focus. The automatic focusing of the focus motor is realized, and the stopping exposure time can ensure the clarity of the image, thereby improving the accuracy of product detection.

[0041] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and understandable, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0043] Figure 1 A schematic diagram of an automatic focusing method flow chart is shown;

[0044] Figure 2 A focus search principle diagram is shown;

[0045] Figure 3 A schematic diagram of a motion speed calculation method is shown;

[0046] Figure 4 A schematic diagram of a focus motor movement method flow is shown;

[0047] Figure 5 A schematic diagram of a method for determining a precise search range is shown;

[0048] Figure 6 A schematic diagram of the framework structure of an auto-focus system is shown.

[0049] Description of main component symbols:

[0050] 600, auto focus system; 601, acquisition module; 602, motion module; 603, determination module; 604, focus module. DETAILED DESCRIPTION

[0051] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.

[0052] The terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0053] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of the template are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.

[0054] Example 1

[0055] See also Figure 1 , Figure 1 A schematic flow chart of an automatic focusing method provided in this embodiment, which can be used to implement automatic focusing of a focus motor, includes:

[0056] S101, acquiring a movement range and an exposure time of a focus motor, and determining a coarse search step length of the focus motor according to the movement range; each coarse search step length includes two coarse search nodes, and an interval between every two adjacent coarse search nodes is the coarse search step length.

[0057] The focus motor generally includes a motor and a lens. It is a device used to drive the lens to move and take pictures of the product through the lens. The motor controls the up and down movement of the lens. The up and down movement range of the lens is used as the movement range of the focus motor. The product is placed under the lens. When the lens moves to different focus positions, the clarity of the pictures taken will also be different. Many factors such as external light, products and production lines will affect the shooting of pictures.

[0058] The existing focus motor usually controls the movement of the lens while shooting after setting fixed focus parameters, and does not take into account the time required for focusing, which can easily lead to unclear product images. In addition, when the external environment or the manufacturing process of the product itself changes, the lens cannot readjust the focus parameters according to the actual situation, which may also lead to unclear product images.

[0059] Therefore, in order to ensure the clarity of the focus motor when the camera is shooting, it is necessary to ensure that the focus motor is in a stationary state during the exposure time.

[0060] like Figure 2 As shown, the motion range is divided according to the coarse search step length to obtain a plurality of coarse search intervals, each of which includes two coarse search nodes.

[0061] S102, controlling the focus motor to start moving from a coarse search node, moving one coarse search step each time, stopping the exposure time at each coarse search node and capturing a frame of product image, until the product image corresponding to each coarse search node is obtained.

[0062] See also Figure 3 , step S102 includes:

[0063] S1021. Acquire a frame rate of the focus motor, and determine a shooting time of each frame image of the focus motor according to the frame rate.

[0064] The frame rate of the focus motor is the number of images that the focus motor camera can capture per second. For example, if the frame rate is 30, 30 images can be captured per second, each image is called a frame, and the focus motor captures each frame for 1 / 30 seconds.

[0065] S1022: Obtain a time difference between the shooting time and the exposure time, and use the time difference as the movement time of the focus motor.

[0066] Since it takes a certain amount of time for the focus motor to be exposed, and the image captured is better when the lens and the product remain relatively still, before capturing the image, the focus motor can be controlled to reach the shooting position, and then the lens can be controlled to remain still. After the shooting is completed, the lens can be controlled to move to capture the next product or the next frame of the image.

[0067] The time difference between the shooting time and the exposure time is used as the movement time of the focus motor. The focus motor moves to the specified shooting position within the movement time, and then remains still for the exposure time. Then it continues to move for a coarse search step length to reach the next coarse search node, and then remains still for the exposure time. This is repeated multiple times until shooting is completed at each coarse search node.

[0068] S1023. Calculate the movement speed of the focus motor according to the coarse search step length and the movement time.

[0069] In order to ensure that the focus motor can complete a coarse search step within the movement time, it is necessary to calculate the movement speed of the focus motor, that is, the average speed, based on the coarse search step and the movement time. Among them, movement speed = coarse search step / movement time.

[0070] In order to prevent the focus motor from suddenly changing from a moving state to a stationary state, causing the lens to vibrate or shift, the movement time can also be divided into acceleration time and deceleration time. First, the focus motor is controlled to accelerate, accelerate to a certain preset speed, and then slowly decelerate, and when it reaches the next coarse search node, it is just stationary.

[0071] See also Figure 4 , step S102 further includes:

[0072] S1024: Obtain node positions of all the rough search nodes, and determine a start node and an end node according to the node positions.

[0073] Since the focus motor moves up and down, the positions of the nodes can be sorted from top to bottom, with the first node as the starting node and the last node as the ending node.

[0074] S1025: Control the focus motor to move at the movement speed, starting from the starting node.

[0075] Then control the focus motor to start from the starting node, shoot a frame of image at the starting node, move to the second node according to the movement speed, stop the exposure time, shoot a frame of image corresponding to the second node, and then move to the third node according to the movement time, and so on, until it moves to the end node and shoots a frame of image at the end node, which means that the focus motor has acquired all the images.

[0076] In order to determine whether the focus motor has captured the product image corresponding to each coarse search node, each time the focus motor moves to a coarse search node, it can be determined whether the current node is the end node. If it is not the end node, the focus motor can be controlled to continue moving to the next coarse search node. If so, it means that the product images corresponding to all coarse search nodes have been captured.

[0077] S103, obtaining a first definition of each frame of the product image, determining a highest definition among a plurality of the first definitions, determining a target product image from a plurality of frames of the product images according to the highest definition, and obtaining a coarse search peak node corresponding to the target product image.

[0078] The clarity of each frame of the product image can be scored using a preset evaluation model or other evaluation methods, and then the target product image corresponding to the highest score is determined, and the coarse search node corresponding to the target product image is used as the coarse search peak node.

[0079] In order to reduce the amount of calculation, each time the focus motor moves to a coarse search focus, the image clarity of the current coarse search node and the previous coarse search node are compared, and then the one with higher clarity is retained and compared with the image clarity of the next coarse search node.

[0080] For example: after obtaining the starting image corresponding to the starting node and the second image corresponding to the second node, compare the clarity of the starting image with the second image. If the starting image has higher clarity, continue to compare the starting image with the third image corresponding to the third coarse search node, and so on, until all the images corresponding to the coarse search nodes are compared, and the result is the coarse search peak node.

[0081] The higher the image clarity, the better the focusing effect of the coarse search node where the focus motor is located when shooting the image, and the coarse search step is usually longer. Therefore, after determining the coarse search peak node in the coarse search node, the nearest shooting node can be determined through fine search.

[0082] S104, determining a fine search range according to the rough search peak node, performing a fine search on the fine search range according to a preset fine search step length to obtain a target fine search focus, and controlling the focus motor to move to the target fine search focus.

[0083] The shooting effect of the lens, that is, the clarity, is usually the closer or farther the lens is from the product, the worse the clarity is. At a certain intermediate position, the clarity reaches the highest value. Therefore, the clarity will be as follows: Figure 2 The parabola shown.

[0084] See also Figure 5 , step S104 includes:

[0085] S1041. Divide the motion range according to the coarse search step length to obtain a plurality of coarse search intervals.

[0086] like Figure 2 As shown, each interval corresponding to the coarse search step can be regarded as a coarse search interval.

[0087] S1042: Acquire a target coarse search interval adjacent to the coarse search peak node from the multiple coarse search intervals.

[0088] In order to improve the auto-focus effect, after determining the coarse search peak node, the fine search interval can be determined according to the coarse search peak node, and usually the coarse search interval adjacent to the coarse search peak node is selected.

[0089] S1043: Obtain the fine search range according to the target rough search interval and the rough search peak node.

[0090] For example, you can select a coarse search interval on the left side of the coarse search focus, a coarse search interval on the right side, and add the coarse search focus itself to form a target focus range. You can also adjust the fine search range according to actual conditions.

[0091] After obtaining the fine search range, the fine search range is divided according to the preset fine search step length to obtain a plurality of the fine search nodes. Then, according to the same principle as the rough search focus acquisition method, the fine search product image corresponding to each fine search node is acquired, and the second definition corresponding to each fine search product is acquired. The fine search node corresponding to the second product image with the highest second definition is taken as the target fine search focus, and the focus motor is controlled to move to the target fine search focus.

[0092] Since the target fine search focus and the current position of the focus motor may not be adjacent, it is necessary to obtain the target distance between the current position and the target fine search focus; based on the target distance and the movement time, the target movement speed of the focus motor is calculated, and the focus motor is controlled to move from the current position to the target fine search focus according to the target movement speed, so as to complete autofocus before the next shooting of the focus motor to avoid affecting the normal product image shooting of the focus motor.

[0093] This embodiment determines the coarse search step length according to the movement range of the focus motor, and then controls the focus motor to stop the exposure time after each coarse search step length, so as to capture a frame of image, determine the coarse search peak node from multiple frames of focus images, determine the fine search range according to the coarse search peak node, and then use the fine search method to search for the target fine search node within the fine search range, and control the focus motor to move to the target fine search focus. The automatic focus of the focus motor is realized, and stopping the exposure time can ensure the clarity of the image, thereby improving the accuracy of product detection.

[0094] Example 2

[0095] See also Figure 6 The present application also provides an autofocus system 600, comprising:

[0096] An acquisition module 601 is used to acquire a movement range and an exposure time of a focus motor, and determine a coarse search step length of the focus motor according to the movement range; each coarse search step length includes two coarse search nodes, and the interval between every two adjacent coarse search nodes is the coarse search step length;

[0097] A motion module 602 is used to control the focus motor to start moving from a coarse search node, move one coarse search step each time, stop the exposure time at each coarse search node and shoot a frame of product image, until the product image corresponding to each coarse search node is obtained;

[0098] The determination module 603 is used to obtain the first definition of each frame of the product image, determine the highest definition among multiple first definitions, determine the target product image from multiple frames of the product image according to the highest definition, and obtain the coarse search peak node corresponding to the target product image;

[0099] The focusing module 604 is used to determine a fine search range according to the rough search peak node, perform a fine search on the fine search range according to a preset fine search step length, obtain a target fine search focus, and control the focusing motor to move to the target fine search focus.

[0100] It can be understood that the implementation method of the auto-focus method in the above-mentioned embodiment 1 is also applicable to this embodiment, so it will not be described again here.

[0101] Example 3

[0102] The embodiment of the present application also provides a computer device, for example, the computer device can be, but is not limited to, a desktop computer, a notebook, etc., and its existence form is not limited, mainly depending on whether it needs to support the interface display function of the browser web page, etc. Exemplarily, the computer device includes a memory and at least one processor, the memory stores a computer program, and the processor is used to execute the computer program to implement the auto-focus method of the above-mentioned embodiment 1.

[0103] Among them, the processor can be an integrated circuit chip with signal processing capabilities. The processor can be a general-purpose processor, including a central processing unit (CPU), a graphics processing unit (GPU) and a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. At least one of the general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc., which can implement or execute the disclosed methods, steps and logic block diagrams in the embodiments of the present application.

[0104] The memory may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc. The memory is used to store a computer program, and the processor may execute the computer program accordingly after receiving an execution instruction.

[0105] Furthermore, the memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function; the data storage area may store data (such as iteration data, version data, etc.) created according to the use of the computer device, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0106] Example 4

[0107] The embodiment of the present application further provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to execute the autofocus method in the above-mentioned embodiment 1.

[0108] It can be understood that the implementation method of the auto-focus method in the above-mentioned embodiment 1 is also applicable to this embodiment, so it will not be described again here.

[0109] The computer-readable storage medium may be either a non-volatile storage medium or a volatile storage medium. For example, the computer-readable storage medium may include, but is not limited to, a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and other media that can store program codes.

[0110] In several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can also be implemented in other ways. The apparatus embodiments described above are merely schematic, for example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the apparatus, method and computer program product according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and a module, a program segment or a part of a code contains one or more executable instructions for implementing a specified logical function. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in a different order from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow diagram, and the combination of boxes in the structure diagram and / or the flow diagram, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0111] In addition, the functional modules or units in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0112] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0113] The above are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be covered by the protection scope of the present application.

[0114] In all examples shown and described herein, any specific values ​​should be interpreted as merely exemplary and not as limiting, and thus other examples of the exemplary embodiments may have different values.

[0115] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0116] The above embodiments only express several implementation methods of the present disclosure, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present disclosure. It should be pointed out that, for those of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present disclosure, and these all belong to the protection scope of the present disclosure.

Claims

1. An automatic focusing method, characterized in that: include: Acquire the movement range and exposure time of the focus motor, and determine the coarse search step length of the focus motor according to the movement range; each coarse search step length includes two coarse search nodes, and the interval between every two adjacent coarse search nodes is the coarse search step length; Control the focus motor to start moving from one of the coarse search nodes, move one coarse search step each time, stop the exposure time at each coarse search node and shoot a frame of product image, until the product image corresponding to each coarse search node is obtained; Acquire a first definition of each frame of the product image, determine a highest definition among a plurality of the first definitions, determine a target product image from a plurality of frames of the product image according to the highest definition, and acquire a coarse search peak node corresponding to the target product image; A fine search range is determined according to the rough search peak node, a fine search is performed on the fine search range according to a preset fine search step length to obtain a target fine search focus, and the focus motor is controlled to move to the target fine search focus.

2. The automatic focusing method according to claim 1, characterized in that: After determining the coarse search step length of the focus motor according to the motion range, the method further comprises: Acquire the frame rate of the focus motor, and determine the shooting time of each frame image of the focus motor according to the frame rate; Obtaining a time difference between the shooting time and the exposure time, and using the time difference as the movement time of the focus motor; The movement speed of the focus motor is calculated according to the coarse search step length and the movement time.

3. The automatic focusing method according to claim 2, characterized in that: The controlling the focus motor to move to the target fine search focus comprises: Acquire the current position of the focus motor, and determine the target distance between the current position and the target fine search focus; The target movement speed of the focus motor is calculated according to the target distance and the movement time, and the focus motor is controlled to move from the current position to the target fine search focus according to the target movement speed.

4. The automatic focusing method according to claim 2, characterized in that: The controlling the focus motor to start moving from a coarse search node comprises: Obtaining the node positions of all the rough search nodes, and determining the start node and the end node according to the node positions; The focus motor is controlled to move from the starting node at the moving speed.

5. The automatic focusing method according to claim 4, characterized in that: The step of obtaining the product image corresponding to each of the rough search nodes includes: Acquire a current product image acquired by the focus motor at a current coarse search node; Determine whether the current rough search node is the end node; If it is the end node, it is determined to obtain the product image corresponding to each of the rough search nodes.

6. The automatic focusing method according to claim 1, characterized in that: The determining of the fine search range according to the rough search peak node comprises: According to the rough search step length, the motion range is divided to obtain a plurality of rough search intervals; Acquire a target coarse search interval adjacent to the coarse search peak node from the plurality of coarse search intervals; The fine search range is obtained according to the target rough search interval and the rough search peak node.

7. The automatic focusing method according to claim 6, characterized in that: The step of performing a fine search on the fine search range according to a preset fine search step length to obtain a target fine search focus includes: According to the refined search step length, the refined search range is divided to obtain a plurality of refined search nodes; Acquire a refined search product image corresponding to each refined search node, and acquire a second definition corresponding to each frame of the refined search product; Acquire the second clarity of each frame of the product image, determine the highest second clarity among multiple second clarity, determine the target fine search image from multiple frames of the fine search product images according to the highest second clarity, and use the fine search node corresponding to the target fine search product image as the target fine search focus.

8. An automatic focusing system, characterized in that: include: An acquisition module is used to acquire the movement range and exposure time of the focus motor, and determine the coarse search step length of the focus motor according to the movement range; each of the coarse search step lengths includes two coarse search nodes, and the interval between every two adjacent coarse search nodes is the coarse search step length; A motion module, used for controlling the focus motor to start moving from a coarse search node, moving one coarse search step each time, stopping the exposure time at each coarse search node and shooting a frame of product image, until the product image corresponding to each coarse search node is obtained; A determination module, configured to obtain a first definition of each frame of the product image, determine a highest definition among a plurality of the first definitions, determine a target product image from a plurality of frames of the product image according to the highest definition, and obtain a coarse search peak node corresponding to the target product image; A focusing module is used to determine a fine search range according to the rough search peak node, perform a fine search on the fine search range according to a preset fine search step length, obtain a target fine search focus, and control the focusing motor to move to the target fine search focus.

9. An electronic device, characterized in that: The invention comprises a memory and at least one processor, wherein the memory stores a computer program, and the processor is used to execute the computer program to implement the auto-focusing method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed, the auto-focusing method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Focusing method and system of infrared camera

    CN121357418A

  • A method and system for focusing an infrared camera

    CN121357418B