Focusing method and electronic equipment
By obtaining the size of the face detection frame during shooting, determining whether the focus position and size match, and adjusting the focus position as needed, the problem of instability in the prior art is solved and the image clarity is improved.
Patent Information
- Application Number
- CN202311322106.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-11
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2043-10-11
AI Technical Summary
In the prior art, the automatic focus function can easily lead to unstable focus and affect image clarity when shooting moving characters or the environment is low.
By obtaining the size of the face detection frame, determine whether the focus position and size match. If it does not match, adjust the focus position to ensure focus stability.
It effectively reduces the frequency of changes in the focus position, improves the focus stability, and thus improves the clarity of the captured image.
Smart Images

Figure CN119854631A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and in particular to a focusing method and electronic equipment. Background Art
[0002] Auto Focus is a method that uses the principle of light reflection from an object to receive the reflected light by the sensor on the camera, and then drives the electric focus device (such as a focus motor) to focus through calculation processing. Currently, electronic devices with shooting functions usually have an auto focus function.
[0003] However, when shooting moving people or in a shooting environment with a low signal-to-noise ratio, the focusing result of the autofocus function is prone to instability, resulting in low clarity of the captured image, thereby affecting the user experience. Summary of the invention
[0004] The present application provides a focusing method and an electronic device, which solve the problem of unstable focusing in the prior art.
[0005] In order to achieve the above objectives, this application adopts the following technical solutions:
[0006] In a first aspect, a focusing method is provided, which is applied to an electronic device, wherein the electronic device includes a camera device, and the method includes:
[0007] Acquire a first focus position and a first size of a first detection frame, wherein the first focus position is a calculated relative distance between a sensor and a lens module after the camera device performs automatic focusing at a first moment, and the first detection frame is a detection frame obtained by performing face detection on a preview image in a viewfinder corresponding to the first moment;
[0008] If the first focus position and the first size do not match, the focus position of the camera device is adjusted to a second focus position so that the camera device focuses according to the second focus position at the first moment, wherein the second focus position is the focus position adopted by the camera device for focusing at the second moment, and the second moment is the previous focus moment of the first moment.
[0009] In the embodiment of the present application, after obtaining the first focus position and the first size of the first detection frame, it can be determined whether the first focus position and the first size match. If the first focus position and the first size match, the camera device is controlled to focus according to the first focus position at the first moment. If the first focus position and the first size do not match, the step of adjusting the focus position of the camera device to the second focus position is performed.
[0010] It can be understood that the focusing method adopted at the second moment may be the same as the focusing method adopted at the first moment.
[0011] For the first focusing moment, in one implementation, the camera device can be made to focus according to the first focusing position at the first focusing moment, wherein the first focusing position is the calculated relative distance between the sensor and the lens module after the camera device performs automatic focusing at the first focusing moment. In this implementation, it is equivalent to focusing using the result of the automatic focusing at the first focusing moment, and the result of the automatic focusing is not adjusted.
[0012] For the first focusing moment, in another implementation, the result of the autofocus at the first focusing moment can also be adjusted, so that the camera device focuses according to the adjusted focus position at the first focusing moment. Specifically: if the first focus position matches the third size of the third detection frame, the camera device is focused according to the first focus position at the first focusing moment; if the first focus position and the third size do not match, the focus position of the camera device is adjusted to a focus position that matches the third size, and the camera device is focused according to the focus position that matches the third size at the first focusing moment. Among them, the third detection frame is a detection frame obtained by performing face detection on the preview image in the viewfinder corresponding to the first focusing moment. Compared with the above implementation, this implementation also adjusts the focus position at the first focusing moment, thereby ensuring that the preview image obtained from the first focusing moment is clear.
[0013] In some related technologies, the camera device usually focuses according to the first focus position. In other words, the camera device focuses using the focus position calculated by the automatic focus function of the electronic device. In the present application, after obtaining the first focus position, it is also necessary to adaptively adjust the focus position of the camera device according to the matching relationship between the first focus position and the first size, and focus according to the adjusted focus position (second focus position) at the first moment. In other words, the focusing method of the embodiment of the present application is equivalent to optimizing the focus position calculated by the automatic focus function of the electronic device.
[0014] In application scenarios such as shooting motion portraits or shooting environments with low signal-to-noise ratios, the focusing methods in related technologies may, by comparison, result in frequent changes in the focus position and unstable focus. Since the face detection frame satisfies the principle of large near and small far away, the size of the focus position and the face detection frame do not match, which is equivalent to the focus position and the shooting distance (the distance between the photographed object and the shooting device) not matching. In the focusing method in the embodiment of the present application, when the focus position and the size of the face detection frame do not match, the focus position is abandoned and the previous focus position is used. In this way, the frequency of changes in the focus position can be effectively reduced, and the focus stability is ensured, which is beneficial to improving the clarity of the captured image.
[0015] In an implementation of the first aspect, the method further includes:
[0016] Acquire a second size of a second detection frame, wherein the second detection frame is a detection frame obtained by performing face detection on the preview image in the viewfinder corresponding to the second moment;
[0017] If the first size and the second size are inconsistent, it is determined whether the first focus position and the first size match.
[0018] If the first size is consistent with the second size, the camera device is controlled to focus according to the second focus position at the first moment.
[0019] Taking the detection frame as a rectangular frame as an example, the first size includes a first width value and a first height value, and the second size includes a second width value and a second height value.
[0020] The detection frame is an elliptical frame, the first size includes a first major axis diameter and a first minor axis diameter, and the second size includes a second major axis diameter and a second minor axis diameter.
[0021] Since the detection frame complies with the principle of large near and small far, in the embodiment of the present application, by judging whether the size of the detection frame is consistent, it is determined whether the shooting distance between the photographed user and the lens has changed; if the first size is inconsistent with the second size, it means that the shooting distance between the photographed user and the lens has changed at the first moment and the second moment, and the focus position is adjusted; if the first size is consistent with the second size, it means that the shooting distance between the photographed user and the lens has not changed at the first moment and the second moment, and there is no need to adjust the first focus position, and the focus position (second focus position) adjusted at the previous moment (second moment) can be used for focusing. In this way, the calculation time of the algorithm can be effectively reduced, thereby improving the focusing efficiency.
[0022] In an implementation manner of the first aspect, the detection box is a rectangular box, the first size includes a first width value and a first height value, the second size includes a second width value and a second height value, and the method further includes:
[0023] If the first width value is consistent with the second width value, and / or the first height value is consistent with the second height value, then it is determined that the first size is consistent with the second size;
[0024] If the first width value is inconsistent with the second width value, and the first height value is inconsistent with the second height value, it is determined that the first size is inconsistent with the second size.
[0025] In the embodiment of the present application, if the sizes of both sides of the detection frame change, the first size and the second size are considered inconsistent; as long as the size of one side of the detection frame does not change, the first size and the second size are considered consistent. By judging the consistency of the first size and the second size in the above implementation, it is possible to more accurately judge whether the distance between the photographed user and the lens has changed, which is beneficial to the stability of subsequent focus.
[0026] It should be noted that if the detection frame is in other shapes, the implementation method for determining whether the first size and the second size are consistent is the same as the implementation method for the detection frame being a rectangular frame, that is, when each of the first size and the second size changes, the first size and the second size are determined to be inconsistent; if either of the first size and the second size does not change, the first size and the second size are determined to be consistent. This will not be repeated here.
[0027] In an implementation of the first aspect, determining whether the first focus position and the first size match includes:
[0028] determining a preset threshold according to the first size and the second size;
[0029] If the first focus position exceeds the preset threshold, determining that the first focus position and the first size do not match;
[0030] If the first focus position does not exceed the preset threshold, it is determined that the first focus position matches the first size.
[0031] In an implementation of the first aspect, the detection box is a rectangular box, the first size includes a first width value and a first height value, and the second size includes a second width value and a second height value; and determining the preset threshold according to the first size and the second size includes:
[0032] Calculating a first change between the first width value and the second width value, and a second change between the first height value and the second height value;
[0033] Acquire relationship data between a size value of a target edge and a focus position, wherein the target edge is an edge corresponding to a target change amount in the first detection frame, and the target change amount is a minimum value between the first change amount and the second change amount;
[0034] The preset threshold is determined according to the relationship data.
[0035] For example, if the first change amount is smaller than the second change amount, the target change amount is the first change amount and the target side is the wide side; if the first change amount is larger than the second change amount, the target change amount is the second change amount and the target side is the high side.
[0036] For example, when the target side is a wide side, the target focus position corresponding to the first width value is searched from the relationship data between the wide side and the focus position. When the target side is a high side, the target focus position corresponding to the first height value is searched from the relationship data between the high side and the focus position.
[0037] Through the above implementation method, the preset threshold of the focus position is determined by the relationship data corresponding to the edge with the smallest change in the detection frame, which can accurately reflect the change in the distance between the photographed user and the lens, improve the reliability of the judgment result, and thus improve the accuracy of the subsequent focus position.
[0038] In some implementations, the relationship data between the size values of each edge of the detection frame and the focus position can be pre-calibrated, and the relationship data can be stored in the electronic device (such as in the storage medium of the electronic device). When needed, the corresponding relationship data can be called.
[0039] In other implementations, the relationship data can be continuously updated as the user uses it. For example, in some application scenarios, if the clarity of the preview image cannot be guaranteed after focusing using the focusing method of the embodiment of the present application, the user may focus manually. In this case, the electronic device can record the focus position of the user's manual focus, associate the focus position with the current size of the face detection frame, and adjust the existing relationship data according to the association relationship, thereby updating the relationship data. With the continuous updating of the relationship data, the focusing stability of the focusing method of the embodiment of the present application will become higher and higher.
[0040] It should be noted that the focusing method provided in the embodiment of the present application can be processed for each image frame, or can be processed once every preset number of image frames.
[0041] In a second aspect, a chip system is provided, the chip system comprising a processor, the processor being coupled to a memory, the processor executing a computer program stored in the memory to implement a method as described in any one of the first aspects.
[0042] According to a third aspect, an electronic device is provided, the electronic device comprising a processor, the processor being configured to run a computer program stored in a memory so that the electronic device implements the method as described in any one of the first aspects.
[0043] According to a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by one or more processors, the method according to any one of the first aspects is implemented.
[0044] According to a fifth aspect, a computer program product is provided. When the computer program product is run on an electronic device, the electronic device can implement any method described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0046] Figure 2 is a software structure block diagram of the electronic device 100 according to an embodiment of the present application;
[0047] Figure 3 is a schematic diagram of the imaging principle provided by an embodiment of the present application;
[0048] Figure 4 is a schematic diagram of a motion portrait shooting scene provided by an embodiment of the present application;
[0049] Figure 5 is a flowchart of a focusing method provided in an embodiment of the present application;
[0050] Figure 6 is a flowchart of a focusing method provided by another embodiment of the present application;
[0051] Figure 7 is a schematic diagram of a first detection frame and a second detection frame provided in an embodiment of the present application;
[0052] Figure 8 is a schematic diagram of a calibration image provided in an embodiment of the present application;
[0053] Fig. 9 is a schematic diagram of the linear relationship between the high side of the detection frame and the focus position;
[0054] Fig.10 is a graph showing changes in the preset threshold value with the size of the detection frame provided in an embodiment of the present application;
[0055] Fig.11 It is a comparison diagram of the focus positions provided in the embodiments of the present application. DETAILED DESCRIPTION
[0056] In the following description, specific details such as specific system structures and technologies are provided for illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details.
[0057] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0058] It should also be understood that in the embodiments of the present application, "one or more" refers to one, two or more than two; "and / or" describes the association relationship of associated objects, indicating that three relationships may exist; for example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B may be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0059] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", "fourth", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0060] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0061] The focusing method provided in the embodiment of the present application can be applied to an electronic device with a shooting function. The electronic device includes a camera device, and the electronic device realizes the shooting function through the camera device. The electronic device in the embodiment of the present application may also be referred to as a terminal device, a terminal, a user equipment (UE) or a user terminal, etc. For example, the electronic device may be a mobile phone, a tablet computer, a handheld computer, a wearable device (such as a smart watch, a smart bracelet, etc.), a laptop computer, a PDA, a personal computer, a smart home device (such as a TV, etc.), a smart screen, a game console, a mobile Internet device (MID), a smart sales terminal (POS), an augmented reality (AR) device, and a virtual reality (VR) device, a camera, a video camera, etc. The embodiment of the present application does not specifically limit the specific form of the electronic device. For ease of explanation, the following embodiments are introduced by taking a mobile phone as an example.
[0062] For example, see Figure 1 , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0063] like Figure 1 As shown, the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 140A, a battery 140B, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0064] The processor 110 may include one or more processing units, wherein different processing units may be independent devices or may be integrated into one or more processors.
[0065] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0066] In some embodiments, the processor 110 is used to run a computer program stored in the memory to implement the focusing method provided in the embodiments of the present application.
[0067] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0068] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1. In some embodiments, the electronic device 100 displays a user interface through the display screen 194, such as a shooting interface of a camera application.
[0069] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0070] The camera 193 is used to capture still images or videos. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0071] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. For example, the processor 110 executes the camera function of the electronic device 100 and the autofocus function during the camera process by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function, etc. The data storage area may store data created during the use of the electronic device 100 (such as interface information corresponding to the user interface, etc.). In addition, the internal memory 121 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, a universal flash storage (UFS), etc.
[0072] The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be set on the display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. A capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure based on the change in capacitance. When a touch operation acts on the display screen 194, the electronic device 100 detects the intensity of the touch operation based on the pressure sensor 180A. The electronic device 100 can also calculate the position of the touch based on the detection signal of the pressure sensor 180A.
[0073] The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. For example, when the touch operation acts on the icon of the camera application, an instruction to open the camera application is executed. For another example, when the touch operation acts on a certain position in the viewfinder in the shooting interface of the camera application, an instruction to autofocus is executed. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.
[0074] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0075] Understandably, Figure 1 It is only an example of the structure of the electronic device 100, and some modules related to the focusing method described in the embodiment of the present application are shown. The structure shown in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 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 can be implemented in hardware, software, or a combination of software and hardware.
[0076] In addition, an operating system runs on the above components, such as the iOS operating system, the Android open source operating system, and the Windows operating system, etc. Application programs can be installed and run on the operating system.
[0077] The operating system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 100.
[0078] Figure 2 It is a software structure block diagram of the electronic device 100 according to an embodiment of the present application.
[0079] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the system library and the Android runtime (Android runtime), and the kernel layer.
[0080] The application layer can include a series of application packages. Figure 2 As shown, the application package may include applications such as camera, gallery, calendar, call, map, e-book, shopping, Bluetooth, music, video, short message, etc. For example, the camera application may include an autofocus function. When a user uses the camera application to take a portrait photo, the electronic device uses the autofocus function to focus on the face as the focus subject.
[0081] The application framework layer provides application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions. Figure 2 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.
[0082] In the embodiment of the present application, the application framework layer may include a camera access interface, wherein the camera access interface is used to provide an application programming interface and a programming framework for the camera application.
[0083] Android runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system. Among them, the core library contains two parts: one is the function that needs to be called by the Java language, and the other is the core library of Android. The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform object life cycle management, stack management, thread management, security and exception management, and garbage collection and other functions.
[0084] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0085] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver. Among them, the camera driver is used to drive the camera to collect images.
[0086] The following describes the focusing method involved in the embodiment of the present application in combination with the above-mentioned hardware structure and software structure.
[0087] To facilitate understanding, the concepts involved in the embodiments of the present application are first introduced.
[0088] Focusing, also known as focusing adjustment or focusing, refers to adjusting the relative distance (image distance) between the sensor and the lens by moving the camera's sensor (such as a CMOS image sensor) or the position of the lens module (such as some floating lenses) to achieve the purpose of making the image clear.
[0089] For example, see Figure 3 , is a schematic diagram of the imaging principle provided by the embodiment of the present application. Figure 3As shown, AB represents the photographed object, A'B' represents the image of AB, CD represents the lens, u represents the object distance (the distance between the photographed object AB and the optical center O of the lens), v represents the image distance (the distance between the optical center O of the lens and the image A'B'), and f represents the focal length (the distance between the focus F and the optical center O of the lens).
[0090] like Figure 3 As shown, triangle ABO and triangle A'B'O are similar triangles, therefore, AB:A'B'=u:v, that is, A'B'=v×AB / u. And because the relationship between image distance, object distance and focal length is 1 / u+1 / v=1 / f, the following relationship exists: A'B'=v×AB / f-AB.
[0091] It can be seen from the above relationship that when the focal length f is fixed and AB remains unchanged, as the lens module moves (moves along the straight line where BB' is located), the image A'B' is linearly related to the image distance v. That is, the larger the image distance v, the larger the image A'B'; the smaller the image distance v, the smaller the image A'B'. Usually the lens is installed at the position of the focus motor, and the position of the lens / focus motor is also linearly related to the image distance v and the object distance u, that is, the closer the lens position / focus motor position is to the object being photographed, the larger the image distance v and the smaller the object distance; the farther the lens position / focus motor position is from the object being photographed, the smaller the image distance v and the larger the object distance.
[0092] The image distance is adjusted by moving the lens module so that the image perceived by the sensor is clear. When the image is clear, the focus is completed. In the embodiment of the present application, the relative distance (image distance) between the sensor and the lens when the focus is completed is called the focus position or the quasi-focus position.
[0093] It should be noted that the above example is a method of focusing by moving the lens module. The principle of focusing by moving the sensor is similar and will not be repeated here. The difference between the two is that the method of focusing by moving the lens module changes both the image distance and the object distance, while the method of focusing by moving the sensor only changes the image distance.
[0094] At present, electronic devices with shooting functions have autofocus functions. Autofocus is a method that uses the principle of light reflection from an object to receive the reflected light by the sensor on the camera, and drives the electric focus device (such as a focus motor) to focus through calculation and processing. Taking a mobile phone as an example, when a user shoots an object through the camera application on the mobile phone, the camera application can automatically focus on the object through the focus algorithm to ensure that the image taken is clear.
[0095] Autofocus includes phase focus and contrast focus. Phase focus refers to using phase detection pixels on the camera sensor to measure the phase difference when light passes through the lens, thereby calculating the distance and position of the object and automatically adjusting the position of the lens. Contrast focus refers to measuring the clarity of the object by detecting the contrast difference between areas in the scene, thereby automatically adjusting the position of the lens. Compared with the two methods, phase focus is usually faster and suitable for shooting moving objects. Contrast focus is more accurate and suitable for shooting static objects or close-up shots.
[0096] In some application scenarios, the focus may be unstable when shooting moving objects. For example, when shooting a moving person, the detected face area does not match the actual face area because the person is in motion, resulting in unstable focus and pulled focus. Pulling focus refers to changing the position of the lens module while pressing the shutter, resulting in a radial exposure effect.
[0097] For example, see Figure 4 , is a schematic diagram of a motion portrait shooting scene provided by an embodiment of the present application. Figure 4 In the camera application user interface 40 shown in (a), the position of the face detection frame 401 in the viewfinder of the user interface 40 matches the actual face area. Since face detection has a certain lag, as the subject moves, the face detection frame may not be able to "keep up" with the movement of the subject. Figure 4 In the user interface 41 of the camera application shown in (b), the position of the face detection frame 402 in the viewfinder of the user interface 41 does not match the actual face area.
[0098] In such Figure 4 In the application scenario shown, since the face detection frame does not match the actual face area, the focus subject may change. For example, part of the background is used as the focus subject. In this case, it is impossible to focus accurately, resulting in a pulled focus situation, thereby affecting the clarity of the portrait shot.
[0099] In other application scenarios, the signal-to-noise ratio of the shooting environment is relatively low, such as shooting portraits against light or at night. In such application scenarios, the phase focus method may detect more erroneous data. For example, some background pixels are used as pixels in the face area, resulting in inaccurate calculated distance and position of the face, which in turn leads to unstable focus and affects the clarity of the portrait shot.
[0100] Based on this, the embodiment of the present application provides a focusing method. Through the method in the embodiment of the present application, it is possible to filter out erroneous and inaccurate focus position data according to the size change of the face detection frame, achieve stable focus, thereby effectively improving the clarity of the captured image and enhancing the user experience.
[0101] See also Figure 5 , is a flowchart of the focusing method provided in the embodiment of the present application. As an example and not a limitation, Figure 5 As shown, the focusing method may include the following steps:
[0102] S501: Acquire a first focus position and a first size of a first detection frame.
[0103] Among them, the first focus position is the calculated relative distance between the sensor and the lens module after the camera device automatically focuses at the first moment, and the first detection frame is the detection frame obtained by performing face detection on the preview image in the viewfinder frame corresponding to the first moment.
[0104] In the embodiment of the present application, the first focus position may be a focus position calculated by an autofocus function (autofocus algorithm) of the electronic device. For example, when the electronic device is a camera, the focus position may be calculated by the autofocus function of the camera. For another example, when the electronic device is a mobile phone, the focus position may be calculated by the autofocus function of the camera application in the mobile phone.
[0105] In the embodiment of the present application, a face detection algorithm can be used to perform face detection processing on the preview image to obtain a detection frame. In the embodiment of the present application, the face detection algorithm used and the method of obtaining the detection frame are not specifically limited.
[0106] The size of the detection frame is used to indicate the size of the detection frame. In some implementations, the detection frame may be a rectangular frame, and accordingly, the size of the detection frame includes the size value of the wide side and the size value of the high side. In other implementations, the detection frame may also be an elliptical frame, and accordingly, the size of the detection frame includes the size values of the major axis diameter and the minor axis diameter (or the major axis radius and the minor axis radius). Of course, the detection frame may also be other shapes, and accordingly, the size of the detection frame includes the size value used to indicate the size of the detection frame. In the embodiment of the present application, the shape of the detection frame is not specifically limited.
[0107] S502: If the first focus position and the first size do not match, adjust the focus position of the camera device to a second focus position, so that the camera device focuses according to the second focus position at the first moment.
[0108] In the embodiment of the present application, after S501, it can be determined whether the first focus position and the first size match. If the first focus position and the first size match, the camera device is controlled to focus according to the first focus position at the first moment. If the first focus position and the first size do not match, S502 is executed.
[0109] In one implementation, if the first focus position and the first size do not match, a focus position that matches the first size can be calculated, and the focus position of the camera device can be adjusted to the calculated focus position that matches the first size, so that the camera device focuses at the first moment according to the focus position that matches the first size. However, compared with the implementation in S502, as long as the first focus position and the first size do not match, this implementation needs to recalculate a new focus position, and the calculation frequency is high, which is easy to affect the focus efficiency; in addition, in the case of inaccurate face detection frame detection and continuous changes in the size of the detection frame, the focus result obtained by this implementation also changes continuously, which still affects the focus stability.
[0110] Among them, the second focus position is the focus position adopted by the camera device for focusing at the second moment, and the second moment is the previous focus moment of the first moment. It can be understood that the focusing method adopted for the second moment can be the same as the focusing method adopted at the first moment mentioned above. Specifically, the third focus position and the second size of the second detection frame are obtained; if the third focus position and the second size do not match, the focus position of the camera device is adjusted to the fourth focus position, that is, the second focus position is the fourth focus position; if the third focus position and the second size match, the second focus position is the third focus position. Among them, the third focus position is the calculated relative distance between the sensor and the lens module after the camera device performs automatic focusing at the second moment, the second detection frame is the detection frame obtained by performing face detection on the preview image in the viewfinder corresponding to the second moment, the fourth focus position is the focus position adopted by the camera device for focusing at the third moment, and the third moment is the previous focus moment of the second moment. And so on.
[0111] For the first focusing moment, in one implementation, the camera device can be made to focus according to the first focusing position at the first focusing moment, wherein the first focusing position is the calculated relative distance between the sensor and the lens module after the camera device performs automatic focusing at the first focusing moment. In this implementation, it is equivalent to focusing using the result of the automatic focusing at the first focusing moment, and the result of the automatic focusing is not adjusted.
[0112] For the first focusing moment, in another implementation, the result of the autofocus at the first focusing moment can also be adjusted, so that the camera device focuses according to the adjusted focus position at the first focusing moment. Specifically: if the first focus position matches the third size of the third detection frame, the camera device is focused according to the first focus position at the first focusing moment; if the first focus position and the third size do not match, the focus position of the camera device is adjusted to a focus position that matches the third size, and the camera device is focused according to the focus position that matches the third size at the first focusing moment. Among them, the third detection frame is a detection frame obtained by performing face detection on the preview image in the viewfinder corresponding to the first focusing moment. Compared with the above implementation, this implementation also adjusts the focus position at the first focusing moment, thereby ensuring that the preview image obtained from the first focusing moment is clear.
[0113] In some related technologies, the camera device usually focuses according to the first focus position. In other words, the camera device focuses using the focus position calculated by the automatic focus function of the electronic device. In the present application, after obtaining the first focus position, it is also necessary to adaptively adjust the focus position of the camera device according to the matching relationship between the first focus position and the first size, and focus according to the adjusted focus position (second focus position) at the first moment. In other words, the focusing method of the embodiment of the present application is equivalent to optimizing the focus position calculated by the automatic focus function of the electronic device.
[0114] In application scenarios such as shooting motion portraits or shooting environments with low signal-to-noise ratios, the focusing methods in related technologies may, by comparison, result in frequent changes in the focus position and unstable focus. Since the face detection frame satisfies the principle of large near and small far away, the size of the focus position and the face detection frame do not match, which is equivalent to the focus position and the shooting distance (the distance between the photographed object and the shooting device) not matching. In the focusing method in the embodiment of the present application, when the focus position and the size of the face detection frame do not match, the focus position is abandoned and the previous focus position is used. In this way, the frequency of changes in the focus position can be effectively reduced, and the focus stability is ensured, which is beneficial to improving the clarity of the captured image.
[0115] In some embodiments, see Figure 6 , is a flowchart of a focusing method provided by another embodiment of the present application. As an example and not a limitation, Figure 6 As shown, the method may include the following steps:
[0116] S601: Acquire a first focus position and a first size of a first detection frame.
[0117] Step S601 is the same as step S501. For details, please refer to the description in the embodiment of S501, which will not be repeated here.
[0118] S602: Obtain a second size of a second detection frame.
[0119] The second detection frame is a detection frame obtained by performing face detection on the preview image in the viewfinder corresponding to the second moment, and the second moment is a focus moment before the first moment.
[0120] The method for obtaining the second detection frame is the same as the method for obtaining the first detection frame. For details, please refer to the description of the method for obtaining the first detection frame in the S501 embodiment, which will not be repeated here.
[0121] S603, determining whether the first size is consistent with the second size.
[0122] Taking the detection frame as a rectangular frame as an example, the first size includes a first width value and a first height value, and the second size includes a second width value and a second height value.
[0123] In some implementations, step S603 may include:
[0124] If the first width value is consistent with the second width value, and the first height value is consistent with the second height value, then it is determined that the first size is consistent with the second size; otherwise, it is determined that the first size is inconsistent with the second size.
[0125] In this implementation, if the sizes of the two sides of the detection frame do not change, the first size and the second size are considered to be consistent; as long as any one side of the detection frame changes, the first size and the second size are considered to be inconsistent.
[0126] See also Figure 7 , is a schematic diagram of a first detection frame and a second detection frame provided in an embodiment of the present application.
[0127] In one case, the distance between the user being photographed and the camera does not change, but the user's facial posture changes. Figure 7 As shown in (a) in the figure, the face in the first detection frame 71 is the front face, and the face in the second detection frame 72 is the side face. In this case, the width value of the detection frame changes. Specifically, the height values of the first detection frame 71 and the second detection frame 72 are the same, both are a1; the width values of the first detection frame 71 and the second detection frame 72 are different, the first width value of the first detection frame 71 is b1, and the second width value of the second detection frame 72 is b2. Figure 7As shown in (b), the face in the first detection frame 71 is in the front view, and the face in the second detection frame 73 is in the tilted state. In this case, the length value of the detection frame changes. Specifically, the height values of the first detection frame 71 and the second detection frame 73 are different, the first height value of the first detection frame 71 is a1, and the second height value of the second detection frame 73 is a2; the width values of the first detection frame 71 and the second detection frame 73 are the same, both b1.
[0128] In another case, the distance between the user being photographed and the camera changes. Figure 7 As shown in (c) in the figure, the face in the first detection frame 71 is a front face, and the face in the second detection frame 74 is also a front face, but because the face corresponding to the second detection frame 74 is far away from the lens position, the height and width values of the first detection frame 71 and the second detection frame 74 have changed. Specifically, the first height value of the first detection frame 71 is a1, and the second height value of the second detection frame 74 is a2; the first width value of the first detection frame 71 is b1, and the second width value of the second detection frame 74 is b2.
[0129] Depend on Figure 7 As can be seen from the example, when both the height and width values of the detection frame change, it means that the distance between the photographed user and the lens has changed; if either the height or width value of the detection frame does not change, it means that the distance between the photographed user and the lens has not changed, and it may be just a change in facial posture.
[0130] It can be seen from this that if the above implementation method is adopted, the situation where the distance between the photographed user and the lens has not changed may be mistakenly judged as a change in the distance between the photographed user and the lens, thereby affecting the stability of subsequent focus.
[0131] To solve the above problem, in some other implementations, step S603 may include:
[0132] If the first width value is consistent with the second width value, and / or the first height value is consistent with the second height value, then it is determined that the first size is consistent with the second size;
[0133] If the first width value is inconsistent with the second width value, and the first height value is inconsistent with the second height value, it is determined that the first size is inconsistent with the second size.
[0134] The first width value and the second width value are consistent, which may mean that the first width value and the second width value are the same, or that the difference between the first width value and the second width value is less than a first preset value. Similarly, the first height value and the second height value are consistent, which may mean that the first height value and the second height value are the same, or that the difference between the first height value and the second height value is less than a second preset value.
[0135] In the above implementation, if the sizes of both sides of the detection frame change, the first size and the second size are considered inconsistent; as long as the size of one side of the detection frame does not change, the first size and the second size are considered consistent. By judging the consistency of the first size and the second size in the above implementation, it is possible to more accurately judge whether the distance between the photographed user and the lens has changed, which is beneficial to the stability of subsequent focus.
[0136] Similarly, if the detection frame is an elliptical frame, correspondingly, the first size may include a first major axis diameter and a first minor axis diameter, and the second size may include a second major axis diameter and a second minor axis diameter. The implementation of S603 may include:
[0137] If the first major axis diameter is consistent with the second major axis diameter, and / or the first minor axis diameter is consistent with the second minor axis diameter, then it is determined that the first size is consistent with the second size;
[0138] If the first major axis diameter is inconsistent with the second major axis diameter, and the first minor axis diameter is inconsistent with the second minor axis diameter, it is determined that the first size is inconsistent with the second size.
[0139] The first major axis diameter is consistent with the second major axis diameter, which may mean that the first major axis diameter is the same as the second major axis diameter, or that the difference between the first major axis diameter and the second major axis diameter is less than a first preset value. Similarly, the first minor axis diameter is consistent with the second minor axis diameter, which may mean that the first minor axis diameter is the same as the second minor axis diameter, or that the difference between the first minor axis diameter and the second minor axis diameter is less than a second preset value.
[0140] It should be noted that if the detection frame is in other shapes, the implementation method of step S603 is the same as the implementation method of the above detection frame being a rectangular frame or an elliptical frame, that is, when each of the first size and the second size changes, the first size and the second size are determined to be inconsistent; if either of the first size and the second size does not change, the first size and the second size are determined to be consistent. No further details are given here.
[0141] S604: If the first size and the second size are inconsistent, determine whether the first focus position and the first size match.
[0142] In some implementations, step S604 may include:
[0143] A preset threshold is determined according to the second size; if the first focus position exceeds the preset threshold, it is determined that the first focus position and the first size do not match; if the first focus position does not exceed the preset threshold, it is determined that the first focus position and the first size match.
[0144] Taking the detection frame as a rectangular frame as an example, the method of determining the preset threshold according to the second size includes: obtaining relationship data between the size value of the high side or the wide side and the focus position; and determining the preset threshold according to the relationship data.
[0145] The data on the relationship between the size value of the high side and the focus position include the focus positions corresponding to the different size values of the high side, and the data on the relationship between the size value of the wide side and the focus position include the focus positions corresponding to the different size values of the wide side.
[0146] like Figure 7 As shown, in some cases, the width of the detection frame does not change, but the height changes. In this case, if the preset threshold is determined using the relationship data corresponding to the height, it is equivalent to determining that the size of the detection frame has changed. In other cases, the width of the detection frame changes, but the height does not change. In this case, if the preset threshold is determined using the relationship data corresponding to the width, it is equivalent to determining that the size of the detection frame has changed. Both of the above situations cannot accurately reflect the change in the distance between the photographed user and the lens, making the reliability of the judgment result poor, thereby affecting the accuracy of the focus position.
[0147] To solve the above problem, in some other implementations, step S604 may include:
[0148] Determining a preset threshold according to the first size and the second size;
[0149] If the first focus position exceeds a preset threshold, determining that the first focus position and the first size do not match;
[0150] If the first focus position does not exceed the preset threshold, it is determined that the first focus position matches the first size.
[0151] Taking the detection frame as a rectangular frame as an example, the method of determining the preset threshold according to the first size and the second size includes: calculating the first change between the first width value and the second width value, and the second change between the first height value and the second height value; obtaining the relationship data between the size value of the target edge and the focus position, and determining the preset threshold according to the relationship data.
[0152] The target edge is the edge corresponding to the target variation in the first detection frame, and the target variation is the minimum value of the first variation and the second variation. For example, if the first variation is less than the second variation, the target variation is the first variation, and the target edge is the wide edge; if the first variation is greater than the second variation, the target variation is the second variation, and the target edge is the high edge.
[0153] Through the above implementation method, the preset threshold of the focus position is determined by the relationship data corresponding to the edge with the smallest change in the detection frame, which can accurately reflect the change in the distance between the photographed user and the lens, improve the reliability of the judgment result, and thus improve the accuracy of the subsequent focus position.
[0154] In some implementations, the relationship data between the size values of each edge of the detection frame and the focus position can be pre-calibrated, and the relationship data can be stored in the electronic device (such as in the storage medium of the electronic device). When S604 is executed, the corresponding relationship data is called.
[0155] For example, see Figure 8 , is a schematic diagram of a calibration image provided in an embodiment of the present application. Figure 8 As shown, during the calibration process, the subject is kept at different shooting distances from the lens. At each shooting distance, the electronic device focuses to make the preview image in the viewfinder clear, and obtains the size and focus position of the detection frame after focusing. After the calibration is completed, the relationship data is generated according to the size and focus position of the detection frame corresponding to each shooting distance. As shown in the following table:
[0156] Object distance (cm) High side of the detection box (pixels) Width of the detection box (pixels) Focus position 30 1410 946 556 50 849 589 635 75 589 419 672 100 453 328 693 125 362 260 707 150 300 221 715 200 220 164 726
[0157] The value of the quasi-angular position is calculated by the algorithm of the autofocus function. The value is converted from digital to analog to obtain a corresponding current value, and the focus motor is driven according to the current value to adjust the focus position of the camera device.
[0158] Based on the data in the table above, we can fit the linear relationship between the high side of the detection frame and the focus position, as well as the linear relationship between the wide side of the detection frame and the focus position. Fig. 9 As shown, it is a linear relationship between the high side of the detection frame and the focus position. According to the linear relationship, the focus position corresponding to any size value of the high side of the detection frame can be calculated.
[0159] In other implementations, the relationship data can be continuously updated as the user uses it. For example, in some application scenarios, if the clarity of the preview image cannot be guaranteed after focusing using the focusing method of the embodiment of the present application, the user may focus manually. In this case, the electronic device can record the focus position of the user's manual focus, associate the focus position with the current size of the face detection frame, and adjust the existing relationship data according to the association relationship, thereby updating the relationship data. With the continuous updating of the relationship data, the focusing stability of the focusing method of the embodiment of the present application will become higher and higher.
[0160] After acquiring the relationship data, the method of determining the preset threshold according to the relationship data between the size value of the target edge and the focus position includes: searching the target focus position corresponding to the size value of the target edge in the first size from the relationship data, and determining the preset threshold according to the target focus position.
[0161] For example, when the target side is a wide side, the target focus position corresponding to the first width value is searched from the relationship data between the wide side and the focus position. When the target side is a high side, the target focus position corresponding to the first height value is searched from the relationship data between the high side and the focus position.
[0162] The preset threshold value may be determined according to the target focus position, for example, by taking the target focus position as the preset threshold value; or by adding / subtracting a certain value from the target focus position as the preset threshold value.
[0163] See also Fig.10 , is a graph showing the change of the preset threshold value with the size of the detection frame provided in the embodiment of the present application. Fig.10 As shown in FIG. 1 , curve 101 represents a curve showing a change in the size of the detection frame, and curve 102 represents a curve showing a change in the preset threshold. As the size of the detection frame changes, the preset threshold also changes accordingly. Fig. 9 It can be seen that the size of the detection frame is inversely linearly related to the preset threshold, so Fig.10 It can be seen that as the size of the detection frame increases, the preset threshold decreases, which is equivalent to the lens module getting closer to the sensor as the distance between the user being photographed and the lens decreases; conversely, as the size of the detection frame decreases, the preset threshold increases, which is equivalent to the lens module getting farther away from the sensor as the distance between the user being photographed and the lens increases. This is consistent with Figure 3 The imaging principle is shown.
[0164] S605: If the first focus position and the first size do not match, adjust the focus position of the camera device to a second focus position, so that the camera device focuses according to the second focus position at the first moment.
[0165] S606: If the first focus position matches the first size, control the camera device to focus according to the first focus position at a first moment.
[0166] Step S605 is the same as the above step S502, and for details, please refer to the description in the embodiment of S502.
[0167] S607: If the first size and the second size are consistent, control the camera device to focus according to the second focus position at the first moment.
[0168] Since the detection frame complies with the principle of large near and small far, in the embodiment of the present application, by judging whether the size of the detection frame is consistent, it is determined whether the shooting distance between the photographed user and the lens has changed; if the first size is inconsistent with the second size, it means that the shooting distance between the photographed user and the lens has changed at the first moment and the second moment, and the focus position is adjusted; if the first size is consistent with the second size, it means that the shooting distance between the photographed user and the lens has not changed at the first moment and the second moment, and there is no need to adjust the first focus position, and the focus position (second focus position) adjusted at the previous moment (second moment) can be used for focusing. In this way, the calculation time of the algorithm can be effectively reduced, thereby improving the focusing efficiency.
[0169] For example, see Fig.11 , is a comparison diagram of the focus position provided by the embodiment of the present application. Fig.11 As shown, if the solution in the related art is adopted (such as Fig.11 The focus position changes frequently and with a large amplitude, resulting in unstable focus. Fig.11 As shown in the curve 112 in FIG, the focus position that does not match the size of the current detection frame is abandoned, and the focus position that matches the size of the detection frame is used for focusing, which effectively reduces the change frequency and change amplitude of the focus position, thereby effectively improving the focus stability.
[0170] It should be noted that the focusing method provided in the embodiment of the present application can be processed for each image frame, or it can be processed once every preset number of image frames. The two methods are only different in processing frequency, and the focusing methods are essentially the same. Therefore, both methods are within the protection scope of the embodiment of the present application.
[0171] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0172] The embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0173] The embodiments of the present application also provide a computer program product. When the computer program product is executed on an electronic device, the electronic device can implement the steps in the above-mentioned various method embodiments.
[0174] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device capable of carrying the computer program code to the first device, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0175] The embodiment of the present application also provides a chip system, the chip system includes a processor, the processor is coupled to a memory, and the processor executes a computer program stored in the memory to implement the steps of any method embodiment of the present application. The chip system can be a single chip or a chip module composed of multiple chips.
[0176] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0177] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application. Finally, it should be noted that the above is only a specific implementation method of the present application, but the scope of protection of the present application is not limited thereto, and any changes or substitutions within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of the present application shall be based on the scope of protection of the claims.
Claims
1. A focusing method, characterized in that: Applied to an electronic device, the electronic device includes a camera device, and the method includes: Acquire a first focus position and a first size of a first detection frame, wherein the first focus position is a calculated relative distance between a sensor and a lens module after the camera device performs automatic focusing at a first moment, and the first detection frame is a detection frame obtained by performing face detection on a preview image in a viewfinder corresponding to the first moment; If the first focus position and the first size do not match, the focus position of the camera device is adjusted to a second focus position so that the camera device focuses according to the second focus position at the first moment, wherein the second focus position is the focus position adopted by the camera device for focusing at the second moment, and the second moment is the previous focus moment of the first moment.
2. The method according to claim 1, characterized in that The method further comprises: Acquire a second size of a second detection frame, wherein the second detection frame is a detection frame obtained by performing face detection on the preview image in the viewfinder corresponding to the second moment; If the first size and the second size are inconsistent, it is determined whether the first focus position and the first size match.
3. The method according to claim 2, characterized in that After obtaining the second size of the second detection frame, the method further includes: If the first size is consistent with the second size, the camera device is controlled to focus according to the second focus position at the first moment.
4. The method according to claim 2 or 3, characterized in that: The first size includes a first width value and a first height value, the second size includes a second width value and a second height value, and the method further includes: If the first width value is consistent with the second width value, and / or the first height value is consistent with the second height value, then it is determined that the first size is consistent with the second size; If the first width value is inconsistent with the second width value, and the first height value is inconsistent with the second height value, it is determined that the first size is inconsistent with the second size.
5. The method according to any one of claims 2 to 4, characterized in that: The determining whether the first focus position and the first size match each other includes: determining a preset threshold according to the first size and the second size; If the first focus position exceeds the preset threshold, determining that the first focus position and the first size do not match; If the first focus position does not exceed the preset threshold, it is determined that the first focus position matches the first size.
6. The method according to claim 5, characterized in that The first size includes a first width value and a first height value, and the second size includes a second width value and a second height value; The determining a preset threshold according to the first size and the second size includes: Calculating a first change between the first width value and the second width value, and a second change between the first height value and the second height value; Acquire relationship data between a size value of a target edge and a focus position, wherein the target edge is an edge corresponding to a target change amount in the first detection frame, and the target change amount is a minimum value between the first change amount and the second change amount; The preset threshold is determined according to the relationship data.
7. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: If the first focus position matches the first size, the camera device is controlled to focus according to the first focus position at the first moment.
8. A chip system, characterized in that: The chip system includes a processor coupled to a memory, and the processor executes a computer program stored in the memory to implement the method according to any one of claims 1 to 7.
9. An electronic device, characterized in that: The electronic device comprises a processor, and the processor is used to run a computer program stored in a memory, so that the electronic device implements the 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 by one or more processors, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Camera focusing method and system, and electronic device
CN106170064A
Focusing control method and device, electronic equipment and computer readable storage medium
CN110650288A
Focusing method and device based on face recognition, terminal equipment and storage medium
CN114339021A
Shooting method, mobile terminal and storage medium
CN116456189A
Focus adjustment device
JP2013088536A