Infrared lens automatic focusing method and device based on definition
By controlling the movement and clarity detection of the focus motor in an infrared lens, automatic focus is achieved, solving the problem of low efficiency of traditional manual focus, and improving image clarity and recognition effect.
Patent Information
- Application Number
- CN202411873546.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-03-18
AI Technical Summary
The traditional infrared lens manual focusing method cannot quickly and accurately position to the clearest position of the picture, resulting in low operation efficiency and poor image recognition effect.
By controlling the movement of the focus motor in different directions, positioning and marking the clear points according to the change trend of image clarity, combined with distance compensation, automatic focusing of the infrared lens is achieved.
It realizes rapid and accurate positioning of clear points on the image screen, improving focus efficiency and image recognition effect.
Smart Images

Figure CN119653209A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the technical field of automatic focusing, and in particular to a method and device for automatic focusing of an infrared lens based on clarity. Background Art
[0002] With the popularization of monitoring, the use scenarios have become more diverse and complex, and the operability of the equipment has also increased. Fast focus and clarity are very important in operability. Only by being able to focus quickly and accurately can the subsequent observation and identification effects be guaranteed.
[0003] Conventional manual focus operations are slow and difficult to obtain the clearest picture, and are not ideal in terms of time and effect.
[0004] Therefore, there is an urgent need to provide an infrared lens automatic focusing method and device based on clarity. Summary of the invention
[0005] In order to solve the problem that the traditional manual focusing method of an infrared lens cannot quickly and accurately locate the clearest position of the image, an embodiment of the present invention provides an infrared lens automatic focusing method and device based on clarity.
[0006] In a first aspect, an embodiment of the present invention provides an infrared lens automatic focusing method based on clarity, the method comprising:
[0007] Get the far focus and near focus limit values of the infrared lens and set the image clarity value and focus motor parameters;
[0008] Based on the focusing motor parameters, the focusing motor is controlled to move in a first direction, and the image clarity value of each position point during the movement is obtained. If the clarity value of 3-5 frames of images decreases continuously, the focusing motor is stopped from moving in the first direction.
[0009] Based on the focus motor parameter, the focus motor is controlled to move in the second direction, and the image clarity value of each position point during the movement is obtained. If the clarity value of 3-5 frames of images decreases continuously, the position point corresponding to the first frame of the image in which the clarity value of the continuous 3-5 frames of images decreases is marked, and the focus motor is stopped from moving in the second direction; wherein the first direction is opposite to the second direction;
[0010] Based on the focusing motor parameters, the focusing motor is controlled to move toward the marked position point, and then moves in a second direction at the marked position point by a preset compensation distance to complete automatic focusing of the infrared lens.
[0011] In a second aspect, an embodiment of the present invention further provides an infrared lens automatic focusing device based on clarity, the device comprising:
[0012] An acquisition unit, used to acquire the limit values of the far focus and near focus of the infrared lens and set the image clarity value and focus motor parameters;
[0013] A first control unit is used to control the focus motor to move in a first direction based on the focus motor parameters, and obtain the image clarity value of each position point during the movement, and if the clarity value of 3-5 frames of images decreases continuously, the focus motor is stopped from moving in the first direction;
[0014] a second control unit, configured to control the focus motor to move in a second direction based on the focus motor parameters, and obtain the image clarity value of each position point during the movement, and if the clarity value of 3-5 frames of images decreases continuously, mark the position point corresponding to the first frame of the image in which the clarity value of the continuous 3-5 frames of images decreases, and stop the focus motor from moving in the second direction; wherein the first direction is opposite to the second direction;
[0015] The third control unit is used to control the focus motor to move to the marked position point based on the focus motor parameters, and then move a preset compensation distance in a second direction at the marked position point to complete automatic focusing of the infrared lens.
[0016] In a third aspect, an embodiment of the present invention further provides a computing device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method described in any embodiment of this specification is implemented.
[0017] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, enables the computer to execute the method described in any embodiment of this specification.
[0018] On the other hand, an embodiment of the present application further provides a computer program product, which includes a computer program. A processor of a computer device reads the computer program from a computer-readable storage medium, and the processor executes the computer program, so that the computer device executes any of the methods described in the above embodiments.
[0019] The embodiment of the present invention provides an automatic focusing method for an infrared lens based on clarity, which controls a focusing motor to move in different directions, locates and marks the clear points of an image according to the clarity change trend of the image during the movement, and performs distance compensation based on the position of the marked point. In this way, the clear point position of the image can be quickly and accurately located and focused, thereby improving the focusing efficiency and the image recognition effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0021] Figure 1 is a flow chart of a definition-based automatic focusing method for an infrared lens provided by an embodiment of the present invention;
[0022] Figure 2 is a hardware architecture diagram of a computing device provided by an embodiment of the present invention;
[0023] Figure 3 The present invention is a structural diagram of an infrared lens automatic focusing device based on clarity provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0025] The specific implementation of the above concept is described below.
[0026] Please refer to Figure 1 The embodiment of the present invention provides an infrared lens automatic focusing method based on clarity, the method comprising:
[0027] Step 100, obtaining the limit values of the far focus and near focus of the infrared lens and setting the image clarity value and focus motor parameters;
[0028] Step 102, controlling the focus motor to move in a first direction based on the focus motor parameters, and obtaining the image clarity value at each position point during the movement, and if the clarity values of 3-5 frames of images decrease continuously, stopping the focus motor from moving in the first direction;
[0029] Step 104, based on the focus motor parameters, control the focus motor to move in the second direction, and obtain the image clarity value of each position point during the movement. If the clarity value of 3-5 frames of images decreases continuously, mark the position point corresponding to the first frame of the continuous 3-5 frames of images in which the clarity value decreases, and stop the focus motor from moving in the second direction; wherein the first direction is opposite to the second direction;
[0030] Step 106 , controlling the focus motor to move toward the marked position point based on the focus motor parameters, and then moving the marked position point in a second direction by a preset compensation distance to complete automatic focusing of the infrared lens.
[0031] In the embodiment of the present invention, the focus motor is controlled to move in different directions, and the clear point of the image is located and marked according to the clarity change trend of the image during the movement, and distance compensation is performed based on the position of the marked point. In this way, the clear point position of the image can be quickly and accurately positioned and focused, thereby improving the focusing efficiency and image recognition effect.
[0032] For step 100:
[0033] In some implementations, the focus motor parameters include a search speed and a positioning speed of the focus motor.
[0034] In some embodiments, before controlling the focus motor to move in a first direction based on the focus motor parameters, it also includes: determining whether the focus motor is within the limit range of far focus and near focus; if the focus motor is outside the limit range, controlling the focus motor to move in the direction of the limit range based on the focus motor parameters until it reaches the limit range.
[0035] In an embodiment of the present invention, after triggering automatic focusing, it is first determined whether the focus motor is within the processing limit range. If it is within the limit range, the focus motor is directly controlled to start the image automatic search process. If it is outside the limit range, the focus motor must first be moved into the limit range, and the focus motor is stopped after reaching the limit range, and then the image automatic search process is started. This can prevent the focus direction from deviating and facilitate quick focusing.
[0036] Regarding step 102 and step 104:
[0037] In some embodiments, the first direction is a far focus direction or a near focus direction, and the second direction is a near focus direction or a far focus direction.
[0038] In an embodiment of the present invention, the focus motor can be first controlled to move in one direction (for example, the far focus direction), and the image clarity value of each position point during the movement process is obtained. The clarity value change trend of the two frames of images before and after is judged based on the image clarity value of each position point. When the clarity values of 3-5 consecutive frames of images are all decreasing, it means that the focus motor has been moving in the blurred direction and the focus motor is in the far focus direction of the clear point. Therefore, it is necessary to stop the focus motor from moving in the far focus direction and control the focus motor to run in the near focus direction. In order to ensure the stable movement of the focus motor, the focus motor needs to be stopped and stabilized for a period of time. Afterwards, the focus motor is controlled to run in the near focus direction, which is now the direction of the image clarity point, and will pass the clearest position during the movement. In this process, the image clarity value of each position during the movement is also obtained, and the clarity value change trend of the two frames of images before and after the movement is judged based on the image clarity value of each position. When the clarity values of 3-5 consecutive frames of images are all decreasing, it means that the focus motor has passed the clearest point, and the clearest point is near the position P1 where the clarity value of the first frame decreases. At this time, the focus motor is stopped from moving in the second direction, and the focus motor is stabilized for a period of time.
[0039] Regarding step 106:
[0040] In some embodiments, the preset compensation distance is the distance difference between the position point corresponding to the highest point of the image clarity value and the marked position point.
[0041] In the embodiment of the present invention, considering that there will be a certain delay in the control of the focus motor during the image acquisition and processing, the position point P1 where the clarity value of the first frame decreases is not the clearest position point. Based on this position, the focus motor is manually controlled to move to the position P2 corresponding to the maximum value of the image clarity. P2-P1 is the initial preset compensation distance D. The preset compensation distance D is moved again at the marked position point to ensure that the focus motor is at the clearest position point. It should be noted that in the embodiment of the present invention, the preset compensation distance D only needs to be calculated once at the first automatic focusing, and the automatic focusing can be realized by writing this value in the subsequent triggering of the automatic focusing.
[0042] like Figure 2 , Figure 3 As shown, the embodiment of the present invention provides an infrared lens automatic focusing device based on clarity. The device embodiment can be implemented by software, or by hardware or a combination of software and hardware. From the hardware level, Figure 2 As shown in FIG. 1 , a hardware architecture diagram of a computing device where a definition-based infrared lens automatic focusing device is provided in an embodiment of the present invention is provided. Figure 3In addition to the processor, memory, network interface, and non-volatile memory shown in the figure, the computing device in which the device is located in the embodiment may also generally include other hardware, such as a forwarding chip responsible for processing messages, etc. Taking software implementation as an example, Figure 3 As shown, as a device in a logical sense, the CPU of the computing device in which it is located reads the corresponding computer program in the non-volatile memory into the internal memory and runs it.
[0043] This embodiment provides an infrared lens automatic focusing device based on clarity, the device comprising:
[0044] An acquisition unit 301 is used to acquire the limit values of the far focus and near focus of the infrared lens and set the image clarity value and the focus motor parameters;
[0045] A first control unit 302 is used to control the focus motor to move in a first direction based on the focus motor parameters, and obtain the image clarity value of each position point during the movement, and if the clarity value of 3-5 frames of images decreases continuously, the focus motor is stopped from moving in the first direction;
[0046] The second control unit 303 is used to control the focus motor to move in the second direction based on the focus motor parameters, and obtain the image clarity value of each position point during the movement process. If the clarity value of 3-5 frames of images decreases continuously, the position point corresponding to the first frame of the continuous 3-5 frames of images in which the clarity value decreases is marked, and the focus motor is stopped from moving in the second direction; wherein the first direction is opposite to the second direction;
[0047] The third control unit 304 is used to control the focus motor to move to the marked position point based on the focus motor parameters, and then move the marked position point in a second direction by a preset compensation distance to complete automatic focusing of the infrared lens.
[0048] In an embodiment of the present invention, the acquisition unit 301 can be used to execute step 100 in the above method embodiment, the first control unit 302 can be used to execute step 102 in the above method embodiment, the second control unit 303 can be used to execute step 104 in the above method embodiment, and the third control unit 304 can be used to execute step 106 in the above method embodiment.
[0049] In one embodiment of the present invention, in the acquisition unit 301, the focus motor parameters include the search speed and positioning speed of the focus motor.
[0050] In one embodiment of the present invention, before the first control unit 302 controls the focus motor to move in a first direction based on the focus motor parameters, it also includes: determining whether the focus motor is within the limit range of far focus and near focus; if the focus motor is outside the limit range, controlling the focus motor to move in the direction of the limit range based on the focus motor parameters until it reaches the limit range.
[0051] In one embodiment of the present invention, in the first control unit 302, the first direction is a far focus direction or a near focus direction, and the second direction is a near focus direction or a far focus direction.
[0052] In one embodiment of the present invention, in the third control unit 304, the preset compensation distance is the distance difference between the position point corresponding to the highest point of the image clarity value and the marked position point.
[0053] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on an infrared lens automatic focusing device based on definition. In other embodiments of the present invention, an infrared lens automatic focusing device based on definition may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0054] The information interaction, execution process and other contents between the modules in the above-mentioned device are based on the same concept as the embodiment of the method of the present invention. For the specific contents, please refer to the description in the embodiment of the method of the present invention, and no further description is given here.
[0055] An embodiment of the present invention further provides a computing device, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, a clarity-based infrared lens automatic focusing method in any embodiment of the present invention is implemented.
[0056] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the processor executes a clarity-based automatic focusing method for an infrared lens in any embodiment of the present invention.
[0057] Specifically, a system or device equipped with a storage medium can be provided, on which software program code that implements the functions of any of the above-mentioned embodiments is stored, and a computer (or CPU or MPU) of the system or device can be enabled to read and execute the program code stored in the storage medium.
[0058] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.
[0059] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer by a communication network.
[0060] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.
[0061] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or to a memory provided in an expansion module connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or expansion module is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.
[0062] An embodiment of the present application also provides a computer-readable storage medium, on which is stored at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is loaded and executed by a processor to implement a clarity-based infrared lens automatic focusing method provided in the above-mentioned method embodiments.
[0063] It should be noted that, in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0064] A person of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiments; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk, etc., various media that can store program codes.
[0065] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A definition-based automatic focusing method for infrared lenses, characterized in that: include: Get the far focus and near focus limit values of the infrared lens and set the image clarity value and focus motor parameters; Based on the focusing motor parameters, the focusing motor is controlled to move in a first direction, and the image clarity value of each position point during the movement is obtained. If the clarity value of 3-5 frames of images decreases continuously, the focusing motor is stopped from moving in the first direction. Based on the focus motor parameter, the focus motor is controlled to move in the second direction, and the image clarity value of each position point during the movement is obtained. If the clarity value of 3-5 frames of images decreases continuously, the position point corresponding to the first frame of the image in which the clarity value of the continuous 3-5 frames of images decreases is marked, and the focus motor is stopped from moving in the second direction; wherein the first direction is opposite to the second direction; Based on the focusing motor parameters, the focusing motor is controlled to move toward the marked position point, and then moves in a second direction at the marked position point by a preset compensation distance to complete automatic focusing of the infrared lens.
2. The method according to claim 1, characterized in that The focus motor parameters include the search speed and positioning speed of the focus motor.
3. The method according to claim 1, characterized in that The first direction is a far focus direction or a near focus direction, and the second direction is a near focus direction or a far focus direction.
4. The method according to claim 1, characterized in that: The preset compensation distance is the distance difference between the position point corresponding to the highest point of the image clarity value and the marked position point.
5. The method according to claim 1, characterized in that Before controlling the focus motor to move in a first direction based on the focus motor parameters, it also includes: determining whether the focus motor is within the limit range of far focus and near focus; if the focus motor is outside the limit range, controlling the focus motor to move in the direction of the limit range based on the focus motor parameters until it reaches the limit range.
6. An infrared lens automatic focusing device based on clarity, characterized in that: include: An acquisition unit, used to acquire the limit values of the far focus and near focus of the infrared lens and set the image clarity value and focus motor parameters; A first control unit is used to control the focus motor to move in a first direction based on the focus motor parameters, and obtain the image clarity value of each position point during the movement, and if the clarity value of 3-5 frames of images decreases continuously, the focus motor is stopped from moving in the first direction; a second control unit, configured to control the focus motor to move in a second direction based on the focus motor parameters, and obtain the image clarity value of each position point during the movement, and if the clarity value of 3-5 frames of images decreases continuously, mark the position point corresponding to the first frame of the image in which the clarity value of the continuous 3-5 frames of images decreases, and stop the focus motor from moving in the second direction; wherein the first direction is opposite to the second direction; The third control unit is used to control the focus motor to move to the marked position point based on the focus motor parameters, and then move a preset compensation distance in a second direction at the marked position point to complete automatic focusing of the infrared lens.
7. A computing device, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute the method according to any one of claims 1 to 5.
9. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 5 when executed by a processor.