Focusing method, camera and storage medium
By obtaining the status information of the camera's target components and using pre-calibrated associations and a one-way hill climbing algorithm to optimize image plane selection, the resolution loss and time-consuming problems caused by day and night defocus are solved, achieving fast and clear imaging.
Patent Information
- Application Number
- CN202510591112.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-07
- Publication Date
- 2025-09-19
AI Technical Summary
The existing automatic focusing process can easily lead to resolution loss or take a long time when solving the day and night defocus phenomenon, and cannot effectively and quickly restore a clear image.
By obtaining the status information of the camera's target components and using the pre-calibrated association relationship to determine the target focusing information, the image plane position is adjusted to achieve clear imaging. A one-way hill climbing algorithm is used to optimize the image plane selection and reduce invalid traversal.
It achieves rapid restoration of clear images in defocused conditions day and night, avoids resolution loss, and improves the camera's operating smoothness and imaging efficiency.
Smart Images

Figure CN120676247A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of imaging system control, and in particular to a focusing method, a camera, and a computer-readable storage medium. Background Art
[0002] Day-night defocus refers to the phenomenon in which the wavelength of the primary light source switches during the transition from day to night, causing the image plane to shift, resulting in a blurry image. Current technologies addressing day-night defocus primarily use autofocus lenses to adjust the image plane. However, the autofocus process often results in resolution loss or is time-consuming. Summary of the Invention
[0003] The present application provides a focusing method, a camera, and a computer-readable storage medium.
[0004] The focusing method involved in the embodiments of the present application is applied to a camera, and the method includes:
[0005] Obtaining status information corresponding to a target component in the camera;
[0006] When a change in the state information is detected, determining target focus information corresponding to the current moment from a correspondence between the state information and focus information based on the change; and
[0007] The image plane position of the camera is adjusted based on the target focus information to make the imaging of the camera clear.
[0008] In this way, the present application can directly calculate and determine the image plane that can currently achieve clear imaging based on the camera's own operating state and target focus information. In other words, based on the relationship between the camera's own operating state and the wavelength of the main light source, as well as the correlation between changes in the main light source wavelength and changes in the target focus information, the present application can directly determine the target focus information and further adjust the image plane position to achieve focus, thereby reducing the time required to refocus and restore image clarity in the event of defocus during the day or night.
[0009] In some embodiments, the target focus information determined based on the change from a correspondence between the state information and the focus information includes:
[0010] Based on the change, determining the target focusing direction corresponding to the current moment from the corresponding relationship;
[0011] The adjusting the image plane position of the camera based on the target focus information includes:
[0012] An image plane position of the camera is adjusted based on the target focus direction.
[0013] In some embodiments, adjusting the image plane position of the camera based on the target focusing direction includes:
[0014] Traversing each image plane along the focusing direction, comparing the imaging clarity between adjacent image planes based on a one-way hill climbing algorithm to obtain a comparison result;
[0015] According to the comparison result, determining the position of the image plane with the highest imaging clarity as the target image plane position; and
[0016] The image plane position of the camera is adjusted to the target image plane position.
[0017] In some embodiments, determining the target focus information corresponding to the current moment from a correspondence between the state information and the focus information based on the change includes:
[0018] determining a first camera focal length and a current image plane position of the camera according to first state information before the state information changes, and determining a current object distance of the camera according to the first camera focal length and the current image plane position;
[0019] According to the object distance and the correspondence between the state information and the focusing information, the target focusing information after the state information changes is determined, wherein the correspondence is a pre-calibrated correspondence between the object distance and the image plane position under different main light source wavelength conditions.
[0020] In some embodiments, determining the target focus information corresponding to the current moment from a correspondence between the state information and the focus information based on the change includes:
[0021] Acquire the wavelength of the first main light source before the state information changes;
[0022] When a change in the wavelength of the main light source is detected, determining a second main light source wavelength after the state information is changed;
[0023] determining a current image plane position of the camera according to first state information before the state information changes;
[0024] determining, according to the current image plane position and the first main light source wavelength, an object distance of the camera based on a correspondence between the state information and the focus information, wherein the correspondence is a pre-calibrated correspondence between the object distance and the image plane position under different main light source wavelengths;
[0025] The target focusing information is determined according to the second main light source wavelength and the object distance based on the corresponding relationship.
[0026] In some embodiments, determining the changed wavelength of the main light source includes:
[0027] Acquiring the second main light source wavelength based on the main light source wavelength detection device; and / or,
[0028] Acquire an image frame corresponding to a current moment, and determine color information of the image frame according to the image frame;
[0029] Based on the color information, the second main light source wavelength is determined from a preset correspondence relationship associated with the color information and the main light source wavelength.
[0030] In some embodiments, the main light source includes monochromatic light or mixed light. When the main light source includes mixed light, the first main light source wavelength and / or the second main light source wavelength include the average wavelength of the mixed light, or the first main light source wavelength and / or the second main light source wavelength include the wavelength with the highest intensity in the light source spectrum.
[0031] In some embodiments, the state information includes an open state and a closed state, the target component includes a filter switch or an infrared light source, and the change includes a change of the filter switch from an open state to a closed state, and a change from a closed state to an open state.
[0032] The camera in the embodiment of the present application includes a memory and a processor. The memory stores a computer program. When the computer program is executed by the processor, the above-mentioned focusing method can be implemented.
[0033] The computer-readable storage medium in the embodiments of the present application stores a computer program, and when the computer program is executed by one or more processors, the above-mentioned focusing method is implemented.
[0034] Additional aspects and advantages of the embodiments of the present application will be given in part in the description below, and in part will become obvious from the description below, or will be learned through practice of the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0036] Figure 1 This is one of the flow charts of the focusing method in the embodiment of the present application;
[0037] Figure 2This is the second flow chart of the focusing method in the embodiment of the present application;
[0038] Figure 3 This is the third flow chart of the focusing method in the embodiment of the present application;
[0039] Figure 4 This is the fourth flow chart of the focusing method in the embodiment of the present application. DETAILED DESCRIPTION
[0040] The embodiments of the present application are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals represent the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the embodiments of the present application, and should not be understood as limiting the embodiments of the present application.
[0041] See also Figure 1 The focusing method in the embodiment of the present application is applied to a camera, and the method specifically includes the following steps:
[0042] S101: Obtaining status information corresponding to a target component in a camera;
[0043] S102: When a change in the state information is detected, based on the change, determining the target focus information corresponding to the current moment from the correspondence between the associated state information and the focus information;
[0044] S103: Adjusting the image plane position of the camera based on the target focus information to make the camera image clear.
[0045] In some embodiments, the state information includes an open state and a closed state, the target component includes a filter switch or an infrared light source, and the change includes a change of the filter switch from an open state to a closed state, and a change from a closed state to an open state.
[0046] The camera in the embodiments of the present application can implement the aforementioned focusing method. Specifically, the camera includes a memory and a processor, wherein the memory stores a computer program, and the processor is configured to obtain status information corresponding to a target component in the camera, and upon detecting a change in the status information, determine target focusing information corresponding to the current moment based on a correspondence between the status information and the focusing information, and adjust the position of the camera's image plane based on the target focusing information to ensure a clear image.
[0047] Specifically, the focusing method in the embodiments of the present application is applied to a camera. The aforementioned camera includes devices such as cameras used in surveillance, security, and other fields, and the aforementioned camera supports infrared fill light when operating at night or in other environments with insufficient light. The aforementioned target focusing information includes image plane information that maximizes the camera's imaging clarity under the current light conditions.
[0048] On this basis, the focusing method primarily determines target focusing information based on the state information of the target component on the camera. The target component typically includes an infrared cut (IR-CUT) or an infrared light source. The target component's state information typically includes an on and off state. A change in state information typically refers to a change from on to off, or vice versa. For example, for an IR-CUT, when the IR-CUT is on, the corresponding primary light source is infrared, while when the IR-CUT is off, the corresponding primary light source is visible light. Next, when the camera detects a change in the target component's state information, it calls upon its factory-calibrated correspondence between the aforementioned state information and focusing information. Based on the change in the target component's state information, the camera determines the target focusing information. Based on the target focusing information, the camera's current image plane is directly adjusted to the image plane that maximizes image clarity under the current light source conditions, thereby completing the focusing process. Compared to the phase focusing method currently used in related technologies, the focusing method in this application directly calculates the position of the image plane based on the acquired working status and image plane position parameter information, without the need to set phase pixels and without causing resolution loss. Compared to the contrast focusing method currently used in related technologies, the focusing method in this application does not require a targeted traversal analysis of a large number of candidate image planes. Instead, it can directly obtain the image plane position with the highest imaging clarity based on the acquired status information changes and the pre-calibrated correlation correspondence, which can greatly save the time required for focusing, thereby improving the smoothness of camera operation.
[0049] In this way, the present application can directly calculate and determine the image plane that can currently achieve clear imaging based on the camera's own operating state and target focus information. In other words, based on the relationship between the camera's own operating state and the wavelength of the main light source, as well as the correlation between changes in the main light source wavelength and changes in the target focus information, the present application can directly determine the target focus information and further adjust the image plane position to achieve focus, thereby reducing the time required to refocus and restore image clarity in the event of defocus during the day or night.
[0050] In order to explain the actual execution process of the focusing method in the above embodiment in more detail, please refer to Figure 2 , Figure 2 An example of a specific execution process of the focusing method is shown, that is, the focusing method in the embodiment of the present application can be executed according to the following steps:
[0051] S201: Acquire status information of a filter switch in a camera.
[0052] Specifically, an infrared cut filter switcher (IR-CUT) typically optimizes the device's imaging performance under different primary light sources by switching between different filters. The IR-CUT typically consists of an infrared cut filter (IR cut filter) and a full-spectrum optical glass (Full Spectrum Optical Glass), with switching between the two optical glass components controlled by circuitry.
[0053] The IR-CUT has two main modes. During daytime or when visible light is sufficient, the IR-CUT switches to the infrared cutoff filter, effectively operating in daytime mode. This filter blocks infrared light while allowing visible light to pass through, allowing the camera to capture video images with true color and preventing infrared interference. In this case, the camera's primary light source is visible light. At night or when visible light is insufficient, the IR-CUT automatically moves the infrared cutoff filter, switching to the full-spectrum transmittance filter, effectively operating in nighttime mode. This allows the camera to sense infrared light from the infrared fill light device, significantly improving night vision performance. In this case, infrared light is the primary light source.
[0054] Based on the above example, before determining the target image plane in the day and night defocus conditions, the status information of the IR-CUT in the camera in the current state is first obtained. The above status information includes the current working mode information of the IR-CUT, that is, whether the IR-CUT is currently working in day mode or night mode.
[0055] S202: Obtaining the working status information of the lens in the camera,
[0056] The working status information of the lens is stored before the camera leaves the factory. The working status information of the lens includes the corresponding relationship between the status information of the filter switch and the changing direction of the imaging of the image sensor.
[0057] Specifically, based on the above-mentioned embodiment, in addition to the working status of the IR-CUT, illustratively, before determining the target image plane under day and night defocus conditions, it is also necessary to obtain the working status information of the lens in the camera. Among them, the above-mentioned working status information is an inherent attribute of the lens and is stored in the memory of the device before the camera leaves the factory. The working status information of the lens includes a first correspondence between the working status of the IR-CUT and the changing direction of imaging of the image sensor in the camera. Since the main cause of the day and night defocus phenomenon is the change in the wavelength of the main light source, and when the camera is fixed, the wavelength of the main light source and the image distance (equivalent to the position of the image plane) have a fixed correlation, the above-mentioned correlation is equivalent to the correspondence between the wavelength of the main light source of the camera and the adjustment direction of the image plane.
[0058] S203: Determine the current image distance position of the camera and the target focusing direction of the image plane in the day and night defocus conditions according to the status information of the filter switcher and the working status information of the lens.
[0059] Specifically, based on the above implementation, obtaining the current operating mode of the IR-CUT is equivalent to obtaining the wavelength of the current camera's primary light source. Based on this information about the lens's operating status, the camera's image distance and imaging position can be determined under different IR-CUT operating modes—that is, different primary light source wavelengths. Furthermore, this information about the lens's operating status can be used to determine the target focusing direction of the image plane required to improve image clarity in daytime and nighttime defocus conditions.
[0060] S204: Switch the status information of the filter switch.
[0061] Specifically, based on the above embodiment, once all preparatory work has been completed, the focusing process can be started at any time. The specific execution of the focusing process begins with the IR-CUT's operating state switching. When the IR-CUT's operating state switches from the current operating state included in the acquired first operating state information to another operating state, the camera can determine the image plane based on the target focusing direction obtained through the above steps.
[0062] S205: traversing each image plane of the camera along the target focusing direction of the image plane using a one-way hill climbing algorithm to obtain an imaging clarity comparison result of each image plane;
[0063] Specifically, on the basis of the above-mentioned embodiment, when the working state of IR-CUT has been switched, starting from the current image plane of the camera, the image plane is screened along the above-mentioned target focusing direction using a one-way hill climbing algorithm. At the same time, since there is a correlation between the image distance and the wavelength of the main light source, there is also a corresponding correlation between the image plane and the image distance. Therefore, the above-mentioned image plane screening can only be performed along the target focusing direction within the range specified by the correlation between the image plane and the image distance. This can reduce the time consumption of the coarse search process, which is more time-saving than the hill climbing algorithm used in the contrast focusing method in the current related technology.
[0064] For example, when the IR-CUT switches from daytime mode to nighttime mode, it first traverses each image plane along the determined target focus direction at a preset step size, comparing the image clarity between two adjacent image planes. For example, the comparison result can be a numerical value obtained by subtracting the image clarity of the previous image plane from the next. Next, the position of the target image plane can be calculated by analyzing each comparison result based on a one-way hill climbing algorithm.
[0065] S206: According to the imaging clarity comparison result, the image plane with the highest imaging clarity is determined as the target image plane.
[0066] Specifically, based on the above example, the sign of each image clarity comparison result along the target focus direction is analyzed using a one-way hill climbing algorithm to determine the position of the target image plane. Generally, starting from the image plane closest to the camera and traversing toward the target image plane, the image clarity of each image plane increases, and the image clarity difference between two adjacent image planes is negative. Within a certain range near the target image plane, the image clarity reaches its highest point and then declines. Within this range, the image clarity difference becomes positive. The image plane corresponding to the point where the image clarity difference changes sign can then be determined as the target image plane.
[0067] The camera can then perform focusing according to the determined target image plane, adjusting the position of its own image plane to the position of the target image plane, thereby completing focusing under day and night defocus conditions.
[0068] Please see further Figure 3 , Figure 3 An example of a specific execution process of the focusing method is shown, that is, the focusing method in the embodiment of the present application can be executed according to the following steps:
[0069] First, it should be noted that in certain special scenarios, such as indoors, the change in the main light source is predictable, that is, it must switch between a main light source with a first wavelength and a main light source with a second wavelength, where the first wavelength corresponds to the camera's IR-CUT operating in daytime mode, and the second wavelength corresponds to the camera's IR-CUT operating in nighttime mode. Therefore, before the camera leaves the factory, it is possible to calibrate the position of the image plane with the highest imaging clarity for different object distances and different main light source wavelengths to form a second correspondence. The calibrated second correspondence between the object distance and the image plane is stored in the camera's memory as data for easy reference during focus control.
[0070] S301: determining a first camera focal length and a current image plane position of the camera according to first state information of the camera, and determining a current object distance of the camera according to the first camera focal length and the current image plane position.
[0071] Specifically, in some examples, the current camera operates normally. It is assumed that the current camera operates normally under the condition of a main light source of the first wavelength. At this time, the current image plane position of the camera can be obtained according to the correspondence between the first wavelength and the image plane position, and the position of the image plane is equivalent to the current image distance of the camera. The current image distance of the camera can be uniquely obtained according to the image plane position.
[0072] On this basis, if the camera is currently able to form a clear image, the focal length parameter of the camera under the first wavelength condition (corresponding to the first camera focal length) and the current image plane position of the camera (equivalent to the current image distance) can be obtained according to the current working state of the camera (including the working state corresponding to the first wavelength and IR-CUT). Then, based on the known focal length parameter of the camera itself under the first wavelength condition and the current image distance, based on the corresponding relationship between the image distance v, the object distance u and the focal length f:
[0073]
[0074] When the focal length f is the focal length parameter of the camera itself and the image distance v is the known current image distance, the object distance u can be determined as the current object distance of the camera. Next, the image plane position after focusing is calculated based on the current object distance.
[0075] S302: When the working state of the filter switch is switched, target focus information is determined according to the object distance of the camera and the corresponding relationship between the object distance and the image plane position under different main light source wavelengths.
[0076] Specifically, based on the above embodiment, to achieve focus adjustment in the case of day and night defocus, it is also necessary to obtain the switching status of the camera status information. The above camera status information includes the current operating mode information of the IR-CUT. For example, the first status information of the camera corresponds to the IR-CUT operating in the daytime state, and the second status information of the camera corresponds to the IR-CUT operating in the nighttime state. Based on the above embodiment, when the IR-CUT operates in the daytime state, the corresponding main light source wavelength is the first wavelength, and when the IR-CUT operates in the nighttime state, the corresponding main light source wavelength is the second wavelength.
[0077] Let's assume that before the camera's status information changes, the IR-CUT operates normally in the daytime state. At this time, according to step S301, the current object distance of the camera can be determined. Then, when the camera's status information changes, the IR-CUT switches its operating state to the nighttime state. Since the object distance can be assumed to be unchanged when the camera is operating indoors, the target focus information can be obtained based on the camera's object distance before the camera's status information is switched according to the pre-calibrated second correspondence between the object distance and the image plane position under the second wavelength. The target focus information includes image plane position information. The image plane position information is the position information corresponding to the image plane with the highest imaging clarity under the second wavelength and the camera's object distance before the camera's status information is switched. This image plane is the target image plane that can achieve the highest imaging clarity.
[0078] It should be noted that since the first wavelength and the second wavelength are preset known values, step S302 can be executed either when the IR-CUT operating state is switched, as described above, or it can be pre-executed when the camera is operating normally and the IR-CUT operating state has not switched. When step S302 is pre-executed when the camera is operating normally and the IR-CUT operating state has not switched, step S302 is equivalent to preparing data for focus adjustment in advance.
[0079] Next, once the target focus information has been determined, the camera adjusts the image plane to the target image plane position, completing the focusing process. Specifically, if step S302 is executed while the IR-CUT's operating state is switched, the focusing process can be performed immediately after step S302 completes and obtains the target focus information. If step S302 is pre-executed while the camera is operating normally and the IR-CUT's operating state has not yet switched, the focusing process begins when the IR-CUT's operating state is switched. When the IR-CUT's operating state switches from its current state to another, the wavelength of the primary light source switches accordingly. Based on the target focus information obtained in the above embodiment, the camera directly adjusts the image plane to the position corresponding to the image plane position information included in the target focus information, completing the focusing process. This effectively shifts the time required for refocusing the camera in daytime or nighttime defocus situations to before the camera leaves the factory. In actual use, this can significantly shorten the time it takes for image blur caused by light source changes in special scenarios, such as indoors, where the wavelength of the primary light source is relatively fixed.
[0080] Please see further Figure 4 , Figure 4 An example of a specific execution process of the focusing method is shown, that is, the focusing method in the embodiment of the present application can be executed according to the following steps:
[0081] First, it should be noted that, similar to the above-described embodiment, the correspondence between object distance and the position of the image plane with the highest imaging clarity under a variety of primary light source wavelengths can be pre-calibrated as a third correspondence before the camera leaves the factory. This third correspondence can then be stored as data in the camera's memory as a camera-specific parameter, allowing for easy recall during focusing. In this calibrated correspondence, the greater the variety of primary light source wavelengths, the greater the number of image plane positions that can be obtained under the same object distance. Consequently, given a larger number of image planes that can be screened, the subsequent target image plane position will be more accurate.
[0082] S401: Acquire the wavelength of the first main light source in real time according to the imaging module of the camera.
[0083] Specifically, based on the above implementation, and based on the current operation of the camera, the camera can obtain the current main light source wavelength (ie, the first main light source wavelength) based on the image obtained within the current viewing range.
[0084] Exemplarily, the imaging module of the camera is provided with a main light source wavelength detection device, which generally directly measures the main light source of the environment where the camera is located through a sensor.
[0085] Furthermore, by way of example, the color information of the image within the current framing range can be obtained using the color information in the imaging module, and the first dominant light source wavelength of the current camera can be derived based on the color information and the corresponding relationship between the color information and the dominant light source wavelength. It should be noted that, by way of example, the three actions of obtaining the image information within the current framing range, obtaining the color information of the image using the imaging module, and roughly determining the current first dominant light source wavelength based on the color information are continuous, with the goal of continuously monitoring changes in the dominant light source wavelength.
[0086] S402: Determine whether the wavelength of the current main light source has changed. If so, proceed to step S403; if not, return to step S401.
[0087] Specifically, based on the above-mentioned embodiment, in the process of continuously judging the current first main light source wavelength, there may be a relatively small or relatively large difference between the first main light source wavelengths judged according to two adjacent frames. Considering that there is a certain error range when judging whether the main light source wavelength has changed based on color information, when judging whether the first main light source wavelengths corresponding to two adjacent frames have changed, for example, a wavelength difference threshold or a wavelength difference threshold range can be set. When the difference between the main light source wavelengths corresponding to two adjacent frames is less than or equal to the above-mentioned wavelength difference threshold, or is within the above-mentioned wavelength difference threshold range, it is considered that there is no change between the main light source wavelengths corresponding to the two adjacent frames. On the contrary, when the difference between the main light source wavelengths corresponding to two adjacent frames is greater than the above-mentioned wavelength difference threshold, or is outside the above-mentioned wavelength difference threshold range, it is considered that there is a change between the main light source wavelengths corresponding to the two adjacent frames.
[0088] Furthermore, if the wavelengths of the main light sources corresponding to two adjacent frames do not change, the detection and determination process for the current main light source wavelength continues. However, if the wavelengths of the main light sources corresponding to two adjacent frames do change, it can be determined that the camera has entered a day-night defocus condition and requires focusing. If a change in the main light source wavelength is detected, the changed main light source wavelength becomes the second main light source wavelength.
[0089] It's important to note that the primary light source in an environment can be monochromatic, such as red light, blue light, or infrared light of a specific frequency, or mixed light, such as white light. When the primary light source in an environment is mixed light, the first and second primary light source wavelengths in the above example can be the average wavelength of the mixed light or the wavelength corresponding to the highest intensity portion of the mixed light spectrum.
[0090] S403: Determine the current object distance of the camera according to the wavelength of the first main light source before the state information changes and the current image plane position of the camera.
[0091] Specifically, based on the above embodiment, if a change in the main light source wavelength is detected, the camera's state information will change accordingly, such as when the IR-CUT operating state switches. In this case, the camera can determine the camera's current object distance based on the first main light source wavelength condition before the change and the image plane position before the state information switches, based on the third correspondence between object distance and image plane position for different main light source wavelength conditions pre-calibrated at the factory.
[0092] Specifically, when the imaging module of the camera detects that the wavelength of the main light source in the environment changes from the first main light source wavelength to the second main light source wavelength, the working state of the IR-CUT is switched first. In response to the above switching action, the camera first obtains the current image plane position information, and then the camera determines the object distance information corresponding to the above image plane position information as the current object distance of the camera based on the pre-calibrated third correspondence under the condition of the first main light source wavelength.
[0093] S404: Determine target focusing information according to the current object distance and the correspondence between the object distance and the image plane position, and under the wavelength condition of the second main light source after the state information changes.
[0094] Specifically, based on the above embodiment, further, when the current object distance is known, since the camera's operating environment remains unchanged, the camera's current object distance can be considered unchanged, while the wavelength of the dominant light source in the environment has changed from the first dominant light source wavelength to the second dominant light source wavelength. Based on the aforementioned third correspondence between object distance and image plane position, the camera can obtain target focus information corresponding to the camera's current object distance under the condition of the second dominant light source wavelength. This target focus information includes target image plane position information corresponding to the current object distance under the condition of the second dominant light source wavelength. This position is the image plane position with the highest imaging clarity after the dominant light source wavelength changes in the day-night defocus condition.
[0095] Next, once the target focus information has been determined, the camera adjusts the image plane to the target image plane position to complete the focus. This shifts the time required for the camera to refocus during daytime or nighttime defocus conditions to before shipment. During actual use, the captured image can be used to detect changes in the wavelength of the current main light source. If the main light source wavelength changes, the target image plane position can be quickly determined and adjusted directly to the desired position, significantly reducing the time it takes for image blur to occur due to light source changes.
[0096] The computer-readable storage medium in the embodiments of the present application stores a computer program, and when the computer program is executed by one or more processors, the above-mentioned focusing method is implemented.
[0097] In the description of this specification, the reference terms "certain embodiments", "in an example", "exemplarily", etc. mean that the specific features, structures, materials or characteristics described in conjunction with the embodiments or examples are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are mutually inconsistent.
[0098] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may be performed out of the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present application belong.
[0099] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A focusing method, characterized in that: The focusing method is applied to a camera, and the method comprises: Obtaining status information corresponding to a target component in the camera; When a change in the state information is detected, determining target focus information corresponding to the current moment from a correspondence between the state information and focus information based on the change; and The image plane position of the camera is adjusted based on the target focus information to make the imaging of the camera clear.
2. The method according to claim 1, characterized in that The target focus information determined based on the change from the corresponding relationship between the state information and the focus information includes: Based on the change, determining the target focusing direction corresponding to the current moment from the corresponding relationship; The adjusting the image plane position of the camera based on the target focus information includes: An image plane position of the camera is adjusted based on the target focus direction.
3. The method according to claim 2, characterized in that The adjusting the image plane position of the camera based on the target focusing direction includes: Traversing each image plane along the focusing direction, comparing the imaging clarity between adjacent image planes based on a one-way hill climbing algorithm to obtain a comparison result; According to the comparison result, determining the position of the image plane with the highest imaging clarity as the target image plane position; and The image plane position of the camera is adjusted to the target image plane position.
4. The method according to claim 1, wherein The determining, based on the change, target focus information corresponding to the current moment from a correspondence between the state information and the focus information includes: determining a first camera focal length and a current image plane position of the camera according to first state information before the state information changes, and determining a current object distance of the camera according to the first camera focal length and the current image plane position; According to the object distance and the correspondence between the state information and the focusing information, the target focusing information after the state information changes is determined, wherein the correspondence is a pre-calibrated correspondence between the object distance and the image plane position under different main light source wavelength conditions.
5. The method according to claim 1, wherein The determining, based on the change, target focus information corresponding to the current moment from a correspondence between the state information and the focus information includes: Acquire the wavelength of the first main light source before the state information changes; When a change in the wavelength of the main light source is detected, determining a second main light source wavelength after the state information is changed; determining a current image plane position of the camera according to first state information before the state information changes; determining, according to the current image plane position and the first main light source wavelength, an object distance of the camera based on a correspondence between the state information and the focus information, wherein the correspondence is a pre-calibrated correspondence between the object distance and the image plane position under different main light source wavelengths; The target focusing information is determined according to the second main light source wavelength and the object distance based on the corresponding relationship.
6. The method according to claim 5, characterized in that The determining the wavelength of the second main light source after the state information changes includes: Acquiring the second main light source wavelength based on the main light source wavelength detection device; and / or, Acquire an image frame corresponding to a current moment, and determine color information of the image frame according to the image frame; Based on the color information, the second main light source wavelength is determined from a preset correspondence relationship associated with the color information and the main light source wavelength.
7. The method according to claim 5, characterized in that The main light source includes monochromatic light or mixed light. When the main light source includes mixed light, the first main light source wavelength and / or the second main light source wavelength include the average wavelength of the mixed light, or the first main light source wavelength and / or the second main light source wavelength include the wavelength with the highest intensity in the light source spectrum.
8. The method according to claim 1, characterized in that The state information includes an open state and a closed state, the target component includes a filter switch or an infrared light source, and the change includes a change of the filter switch from an open state to a closed state, and a change from a closed state to an open state.
9. A camera, characterized in that: The camera includes a memory and a processor, the memory stores a computer program, and when the computer program is executed by the processor, the focusing method according to any one of claims 1 to 8 can be implemented.
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 by one or more processors, the focusing method according to any one of claims 1 to 8 is implemented.