A focusing method and related device
By dynamically adjusting the number of preview stream image frames and controlling the camera movement direction, it solves the defocus problem caused by delayed focus during sports shooting, achieves timely and accurate focus, and ensures clear imaging of the subject.
Patent Information
- Application Number
- CN202311038919.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-16
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2043-08-16
AI Technical Summary
When the subject is in motion, the focus is not followed in time, causing the photo or video to be out of focus, resulting in unclear images of the subject.
By collecting multiple preview stream image frames, we can obtain the movement speed and direction of the subject relative to the electronic device, dynamically adjust the number of preview stream image frames used to determine the focus information, and control the camera focus according to the movement direction to improve the timeliness of focus. and accuracy.
It effectively avoids the problem of unclear imaging of the shooting object, improves the user experience, and ensures the clarity and continuity of the picture taken during exercise.
Smart Images

Figure 00000000_0000
Abstract
Description
Technical Field
[0001] The present application relates to the field of electronic technology, and in particular to a focusing method and related devices. Background Art
[0002] With the development of terminal technology, terminal devices with camera functions, such as smart phones, tablet computers, and drones, need to focus first when capturing images, so as to ensure that the first object being photographed is clearly imaged in the image.
[0003] For a first object in motion, when a terminal device with a camera function focuses on the first object, the focusing may not be timely, resulting in defocusing of the photo or video, causing the object to be unclear in the image. Summary of the invention
[0004] A focusing method and a related device provided in an embodiment of the present application can improve the timeliness and accuracy of focusing during the process of focusing on a first object in motion.
[0005] In a first aspect, the present application provides a focusing method, applied to an electronic device, the method comprising: acquiring multiple preview stream image frames including a first object; obtaining a movement speed of the first object relative to the electronic device; based on the movement speed, determining a first number of preview stream image frames from the multiple preview stream image frames; determining first focusing information according to the first number of preview stream image frames; and focusing on the first object according to the first focusing information.
[0006] In the above method, the electronic device can obtain the movement speed of the first object being photographed relative to the electronic device, so as to configure the number of preview stream image frames used to determine the focus information according to the movement speed. It can be seen that the focus information is a value related to the movement speed of the first object relative to the electronic device, and the accuracy of the focus information is improved. Therefore, focusing on the first object according to the above focus information can be closer to the actual scene, improve the accuracy and timeliness of the focus, avoid shooting out of focus and unclear imaging, and enhance the user experience.
[0007] In a possible implementation manner, after acquiring a plurality of preview stream image frames including the first object and before focusing on the first object according to the first focus information, the method further includes:
[0008] Acquire a movement direction of the first object relative to the electronic device.
[0009] In the above method, the electronic device can not only obtain the movement speed of the first object relative to the electronic device, but also obtain the movement direction of the first object relative to the electronic device, and determine the movement of the first object from multiple angles.
[0010] In a possible implementation manner, focusing on the first object according to the first focus information includes: focusing on the first object according to the first focus information and a movement direction of the first object relative to the electronic device.
[0011] In the above method, when focusing on the first object, the movement direction of the first object relative to the electronic device is taken into consideration, which can improve the timeliness of follow-focusing and the accuracy of focusing.
[0012] In a possible implementation, when the movement speed of the first object relative to the electronic device is greater than a first threshold, the first number is less than a preset number, and the preset number is the number of preview stream image frames used to determine object information determined from the multiple preview stream image frames when the first object is in a stationary state.
[0013] In the above method, when the first object is stationary, the number of preview stream image frames used to determine the focus information is a preset number, and when the movement speed of the first object relative to the electronic device is greater than a first threshold, it indicates that the movement speed of the first object is relatively fast. The latest frame of the multiple preview stream image frames collected has a large data fluctuation compared to the previous frame or the previous frames. In order to improve the timeliness of the focus tracking, the number of frames can be reduced.
[0014] In one possible implementation, when the movement speed of the first object relative to the electronic device is less than or equal to a first threshold, the first number is greater than or equal to a preset number, and the preset number is the number of preview stream image frames determined from the multiple preview stream image frames for determining focus information when the first object is in a stationary state.
[0015] In the above method, when the first object is stationary, the number of image frames used to determine the focus information is a preset number, and when the movement speed of the first object relative to the electronic device is less than or equal to the first threshold, it means that the movement speed of the first object is relatively slow. The latest frame of the multiple preview stream image frames collected has relatively stable data compared to the previous frame or the previous frames. In order to improve the accuracy of focus, the number of frames can be increased.
[0016] In a possible implementation manner, the electronic device includes a camera, and focusing on the first object according to the first focus information and a movement direction of the first object relative to the electronic device includes:
[0017] When the movement direction of the camera controlled according to the first focus information is consistent with the movement direction of the first object relative to the electronic device, the camera is controlled to move to a first position corresponding to the first focus information to focus on the first object.
[0018] In the above method, the electronic device can obtain the movement direction of the first object, and move the camera when the movement direction is consistent with the direction of moving the camera according to the focus information, thereby avoiding the focus pulling phenomenon caused by the position output by the algorithm being opposite to the movement direction, and improving the timeliness and accuracy of the focus tracking.
[0019] In a possible implementation, the electronic device includes a camera, and controlling the camera to focus on the first object according to the first focus information and a movement direction of the first object relative to the electronic device includes:
[0020] When the movement direction of the camera controlled according to the first focus information is inconsistent with the movement direction of the first object relative to the electronic device, the position of the camera focusing on the first object is controlled to remain unchanged.
[0021] In the above method, the electronic device can obtain the movement direction of the first object, and when the movement direction is inconsistent with the direction in which the camera is moved according to the focus information, the camera is not moved, thereby avoiding the focus pulling phenomenon caused by the position output by the algorithm being opposite to the movement direction, and improving the timeliness and accuracy of the focus tracking.
[0022] In a possible implementation manner, the electronic device further includes a time-of-flight TOF sensor, and acquiring a movement speed of the first object relative to the electronic device includes:
[0023] Detecting a first distance between the first object and the electronic device by the TOF sensor;
[0024] Determine a change value between M adjacent image frames in the plurality of preview stream image frames, wherein M is a positive integer greater than 2;
[0025] The movement speed of the first object relative to the electronic device is determined according to the change value and a threshold corresponding to the first distance.
[0026] In the above method, because the first object is constantly moving relative to the electronic device, the distance between the first object and the electronic device may gradually approach or gradually increase. Different first distances correspond to different thresholds, so the motion speed is driven according to the change value between the adjacent M image frames and the threshold corresponding to the first distance, which can improve the accuracy of the judgment, thereby improving the accuracy of the focus information and the accuracy of the focus.
[0027] In a possible implementation manner, determining the movement speed of the first object relative to the electronic device according to the change value and a threshold corresponding to the first distance includes:
[0028] If the change value is greater than a threshold value corresponding to the first distance, it is determined that the movement speed of the first object relative to the electronic device is greater than a first threshold value, indicating that the movement speed is fast;
[0029] If the change value is less than or equal to the threshold corresponding to the first distance, it is determined that the movement speed of the first object relative to the electronic device is less than or equal to the first threshold, indicating that the movement speed is slow.
[0030] In the above method, the threshold is a value used to determine the speed of movement of the first object relative to the electronic device. If the change value is greater than the first threshold, it means that the movement speed is fast; if the change value is less than or equal to the first threshold, it means that the movement speed is slow. Among them, "equal to" can also be placed in another branch of the judgment. For example, if the change value is greater than or equal to the threshold corresponding to the first distance, then the movement speed of the first object relative to the electronic device is greater than or equal to the first threshold.
[0031] In a possible implementation manner, obtaining a movement direction of the first object relative to the electronic device includes:
[0032] Obtain depth data corresponding to the multiple preview stream image frames respectively; if the depth data gradually decreases according to the acquisition time of the preview stream image frames corresponding to the depth data, the first object moves in a direction approaching the electronic device; if the depth data gradually increases according to the acquisition time of the preview stream image frames corresponding to the depth data, the first object moves in a direction away from the electronic device.
[0033] The present application senses the movement direction of the first object relative to the electronic device through the collected preview stream image frames, and then focuses the first focus in combination with the movement direction to improve the accuracy of focusing.
[0034] In a possible implementation manner, determining the first focus information according to the first number of preview stream image frames includes: determining the first focus information according to an average value of focus data corresponding to the first number of preview stream image frames.
[0035] It can be seen that the first number is a number related to the movement speed of the first object, so the first focus information determined by the average of the focus data of the first number of image frames is more consistent with the actual shooting scene and can improve the timeliness of focus tracking.
[0036] In a second aspect, an embodiment of the present application provides an electronic device, the electronic device comprising: a camera; one or more processors; a memory; wherein the camera is used to capture multiple preview stream image frames including a first object; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the focusing method described in the first aspect or any possible implementation of the first aspect.
[0037] In a third aspect, the present application provides a chip or a chip system, the chip or chip system comprising at least one processor and a communication interface, the communication interface and the at least one processor are interconnected through a line, and the at least one processor is used to run a computer program or instruction to execute the method of driving a sound-generating device to generate sound as described in the first aspect or any possible implementation of the first aspect. The communication interface in the chip may be an input / output interface, a pin, or a circuit, etc.
[0038] In a possible implementation, the chip or chip system described above in the embodiment of the present application further includes at least one memory, in which instructions are stored. The memory may be a storage unit inside the chip, such as a register, a cache, etc., or a storage unit of the chip (e.g., a read-only memory, a random access memory, etc.).
[0039] In a fourth aspect, an embodiment of the present application provides a computer storage medium, which stores a computer program. When the computer program is executed by a processor, the computer executes the focusing method described in the first aspect or any possible implementation of the first aspect.
[0040] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on a communication device, the communication device executes the focusing method described in the first aspect or any possible implementation of the first aspect.
[0041] It should be understood that the description of technical features, technical solutions, beneficial effects or similar language in this application does not imply that all features and advantages can be realized in any single embodiment. On the contrary, it is understood that the description of features or beneficial effects means that specific technical features, technical solutions or beneficial effects are included in at least one embodiment. Therefore, the description of technical features, technical solutions or beneficial effects in this specification does not necessarily refer to the same embodiment. Furthermore, the technical features, technical solutions and beneficial effects described in the present embodiment can also be combined in any appropriate manner. Those skilled in the art will understand that the embodiment can be realized without one or more specific technical features, technical solutions or beneficial effects of a specific embodiment. In other embodiments, additional technical features and beneficial effects can also be identified in a specific embodiment that does not embody all embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The following is an introduction to the drawings used in the embodiments of the present application.
[0043] Figure 1A is a schematic diagram of a scene in which a first object is photographed getting closer and closer to an electronic device, provided by an embodiment of the present application;
[0044] Figure 1B is a schematic diagram of a scene in which the first object photographed is getting farther and farther away from the electronic device;
[0045] FIG. 2A to FIG. 2C The UI for taking a photo and focusing on the first object is exemplarily shown;
[0046] Figure 3A-3C The UI for focusing a photograph of a first object gradually approaching the electronic device is exemplarily shown;
[0047] Figure 4A-4C The UI for focusing a photograph of a first object that gradually moves away from the electronic device is exemplarily shown;
[0048] Figure 5A-Figure 5C The UI for focusing a video of a first object gradually approaching the electronic device is exemplarily shown;
[0049] Figure 5D-5F An example UI for focusing a video of a first object that is gradually moving away from the electronic device is shown;
[0050] Figure 6 The hardware structure of the electronic device of the embodiment of the present application is exemplarily shown;
[0051] Figure 7 The composition structure of the camera is shown by way of example;
[0052] Figure 8The software architecture of the electronic device of the embodiment of the present application is exemplarily shown;
[0053] Fig. 9A is a schematic diagram of a collaborative relationship in situation 1 provided in an embodiment of the present application;
[0054] Fig. 9B is a schematic diagram of a collaborative relationship in situation 2 provided in an embodiment of the present application;
[0055] Fig. 9C is a schematic diagram of a collaborative relationship in situation three provided in an embodiment of the present application;
[0056] Fig.9D is a schematic diagram of a collaborative relationship in situation 4 provided in an embodiment of the present application;
[0057] Fig.10 It is a flowchart of a focusing method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0058] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations to the present application. As used in the specification and appended claims of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to also include plural expressions, unless there is a clear indication to the contrary in the context. It should also be understood that the term "and / or" used in the present application refers to and includes any or all possible combinations of one or more listed items.
[0059] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.
[0060] The term "user interface (UI)" in the following embodiments of the present application refers to a medium interface for interaction and information exchange between an application or operating system and a user, which realizes the conversion between the internal form of information and the form acceptable to the user. The user interface is a source code written in a specific computer language such as Java and extensible markup language (XML). The interface source code is parsed and rendered on an electronic device, and finally presented as content that can be recognized by the user. The commonly used form of user interface is a graphical user interface (GUI), which refers to a user interface related to computer operation displayed in a graphical manner. It can be a visual interface element such as text, icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, widgets, etc. displayed on the display screen of an electronic device.
[0061] The embodiments of the present application are described below in conjunction with the accompanying drawings.
[0062] During the shooting process, in order to ensure that the shooting picture is as smooth as possible when following the focus, the electronic device usually selects a fixed number of image frames from multiple preview stream image frames when focusing on the first object and determining the focus information of the first object, and uses the average of the focus data of the fixed number of image frames as the focus information finally used.
[0063] However, if the first object is constantly moving and the movement speed varies, for example, the first object moves away from or approaches the electronic device at a varying speed, if the electronic device still selects image frames from the captured preview stream image frames according to a fixed frame number to determine the focus information, it may cause the camera to have difficulty focusing on the first object, resulting in problems such as untimely focus tracking and unclear images.
[0064] For example, see Figure 1A and Figure 1B , Figure 1A This is a schematic diagram of a scene in which a first object gradually approaches an electronic device provided in an embodiment of the present application. Figure 1B This is a schematic diagram of a scene in which a first object gradually moves away from an electronic device, provided in an embodiment of the present application.
[0065] like Figure 1A As shown, when the user shoots the first object 200 through the electronic device 100, when the first object 200 is in motion, during the process of moving from position 1 to position 2, the first object 200 can gradually approach the electronic device 100 at speed 1 or speed 2. It can be understood that during the distance from position 1 to position 2, the electronic device 100 collects multiple preview stream image frames including the first object through the camera.
[0066] like Figure 1B As shown, when the user shoots the first object 200 through the electronic device 100, when the first object 200 is in motion, during the process of moving from position 1 to position 3, the first object 200 can gradually move away from the electronic device 100 at speed 1 or speed 2. It can be understood that during the distance from position 1 to position 3, the electronic device 100 collects multiple preview stream image frames including the first object through the camera.
[0067] Among them, speed 1 is greater than speed 2, speed 1 is greater than a preset threshold, and speed 2 is less than a preset threshold. It can be understood that speed 1 indicates that the first object 200 moves faster relative to the electronic device 100, and speed 2 indicates that the first object 200 moves slower relative to the electronic device 100. It can be understood that the first object can gradually approach or gradually move away from the electronic device at a varying speed during the movement.
[0068] In the related art, the electronic device 100 will not obtain the movement direction and / or movement speed of the first object 200 during the shooting process, that is, the electronic device 100 will not perceive at what movement speed the first object 200 is approaching or moving away from the electronic device 100. According to the existing method, the electronic device 100 still determines the focus information from the above-mentioned multiple preview stream image frames collected according to a fixed frame number, and focuses on the first object 200 according to the focus information. For example, if N image frames are collected, M image frames are selected from the N image frames according to a fixed frame number. Among them, M and N are positive integers greater than or equal to 1, and M is less than or equal to N. When focusing, the electronic device 100 uses the mean of the phase detection (PD) data of the M image frames as the focus information, thereby controlling the camera to focus on the first object 200 according to the mean of the PD data of the M image frames, and displaying the focused image on the preview interface.
[0069] It should be noted that phase detection (PD) is an important technology in the camera autofocus system. It uses the phase detection pixel array located on the camera's sensor to divide each pixel into two parts, and measures the object distance and focal length by comparing the phase difference of light in the two parts of different pixel points, thereby achieving the focusing function.
[0070] exist Figure 1A and Figure 1B In the example, the first object 200 moves at different speeds relative to the electronic device 100 (for example, at different speeds 1 or 2). At different speeds, the multiple preview stream image frame data collected by the electronic device 100 are also different.
[0071] For example, if the first object 200 moves faster relative to the electronic device 100, the data difference between the multiple preview stream image frame data is large. At this time, if the preview stream image frames are filtered according to a fixed frame number, the image frames corresponding to the focus data with a larger value will average out the image frames corresponding to the focus data with a smaller value, or the image frames corresponding to the focus data with a smaller value will average out the image frames corresponding to the focus data with a larger value. Since the first object 200 moves faster, the PD data mean determined according to the fixed frame number cannot accurately represent the focus position of the first object 200, so there will be a problem of untimely focus tracking, so that the image of the first object 200 in the image displayed on the preview interface of the electronic device 100 will become blurred.
[0072] exist Figure 1A and Figure 1B In the embodiment, the first object 200 gradually approaches the electronic device 100 or gradually moves away from the electronic device 100. If the movement direction of the first object is not taken into consideration, the movement direction of the camera controlled by the electronic device 100 may be different from the movement direction of the first object, thereby causing the image of the first object 200 in the image frame displayed on the preview interface of the electronic device 100 to be out of focus, that is, the image of the first object has a main body radially blurred phenomenon.
[0073] In view of this, an embodiment of the present application provides a focusing method, in which the electronic device determines a first number of preview stream image frames according to the movement speed of the first object to be focused when shooting, and uses the average of the focus data of the first number of preview stream image frames as the focus information used when focusing. In a possible implementation, when the electronic device focuses according to the above focus information, it moves the position of the camera according to the movement direction of the first object, so as to focus on the first object.
[0074] The electronic device is an electronic device that has a camera and provides shooting and display services, such as a smart phone, a tablet computer, a large-screen device, etc. The focusing method provided in the embodiment of the present application can be embodied in the electronic device as a function of focusing on a moving subject.
[0075] First, focusing on a first object to be photographed by a focusing method provided in an embodiment of the present application is described in conjunction with a UI interface provided on an electronic device.
[0076] FIG. 2A to FIG. 2C The UI for focusing on the first object is exemplarily shown.
[0077] Figure 2A The system desktop 111 involved in the embodiment of the present application is exemplarily shown.
[0078] like Figure 2AAs shown, a page with application icons is displayed in the desktop 111, and the page includes multiple application icons (for example, a settings application icon, an application market application icon, a gallery application icon, a browser application icon, etc.). A page indicator is also displayed below the multiple application icons to indicate the positional relationship between the currently displayed page and other pages. A tray area is displayed below the page indicator. Among them, the tray area includes multiple tray icons, for example, a camera application icon, an address book application icon, a phone application icon, and a message application icon. The tray area remains displayed when the page is switched. In some embodiments, the above-mentioned page may also include multiple application icons and a page indicator. The page indicator may not be part of the page and exist independently. The above-mentioned tray icon is also optional, and the embodiments of the present application are not limited to this.
[0079] The electronic device may receive a user operation of opening a camera application, such as clicking a desktop icon of the camera application. In response to the operation, the electronic device may display a Figure 2B The user interface shown.
[0080] Figure 2B The user interface of the shooting and display service provided in the embodiment of the present application is exemplarily shown, also called a preview interface.
[0081] like Figure 2B As shown, the preview interface may include a mode bar 121, a shooting control 122, a preview interface 123, a review control 124 and a quick function area 126. Among them:
[0082] The mode bar 121 may include multiple camera mode options, such as "night scene", "portrait", "photo", "video recording", etc. Different camera modes can provide users with camera services with different effects. Users can select any of the multiple camera modes to take photos according to different needs. For example, "photo" can be the default camera mode for taking photos. "Video recording" is used to record videos. The "night scene" mode is suitable for photo scenes with dim light, such as at night. The "portrait" mode is suitable for photo scenes where the subject of the photo is a person. The electronic device 100 can also provide more shooting modes, such as "large aperture", "movie", "professional", etc., which are not listed one by one here.
[0083] The electronic device 100 may receive a user operation for switching modes, such as swiping left / right in the mode bar 121, and change the currently used photo mode according to the operation. For example, when receiving a leftward swipe of the mode bar 121 (left swipe operation) and causing the float to stop at the "portrait" option, the electronic device may switch to the "portrait" mode. By default, the electronic device first uses the "photo" mode.
[0084] When the "photographing" mode is used, the shooting control 122 is used to trigger photographing; when the "recording" mode is used, the shooting control 122 can be switched to a recording control, and the recording control is used to trigger recording. The electronic device can receive whether there is a user operation acting on the shooting control 122, such as a click operation. After receiving the user operation acting on the shooting control 122, the electronic device can generate a shooting instruction. The electronic device can obtain the image reported by the camera corresponding to the timestamp according to the shooting instruction, and then save it as a photo.
[0085] The preview interface 123 displays the image frames captured by the camera. In the "photographing" mode, the preview interface 123 is a photo-taking preview interface, and in the "recording" mode, the preview interface 123 is a recording preview interface. Here, the preview interface 123 can display in real time the images processed by the image processing algorithms corresponding to different modes, so that the user can perceive the photographing effects corresponding to different photographing modes in real time.
[0086] The review control 124 can be used to browse thumbnails of photos / videos that have been taken. When receiving a user operation acting on the review control 124, the electronic device can also display the wonderful photos corresponding to the thumbnail.
[0087] The quick function area 126 may include an HDR function option 126A, an AI function option 126B, a flash function option 126C, a color mode function option 126D, a setting function option 126E, etc. The HDR function option 126A can be used to trigger the electronic device to use the HDR algorithm to fuse the image when it is turned on. The AI function option 126B can be used to trigger the electronic device to recognize the photo scene in the preview screen when it is turned on. The current AI function option 126B is in the off state. The flash control 126C can be used to trigger the electronic device to turn on or off the flash. The color mode function option 126D can be used to trigger the electronic device to use a color filter to process the image collected by the camera. The setting function option 126E can be used to set the photo parameters of the electronic device (for example, image size, image storage format, etc.).
[0088] exist Figure 2B In the preview interface 123 shown, in a possible implementation, the electronic device 100 may automatically detect whether the image frame displayed in real time on the preview interface 123 includes a first object, and the first object may be one of the pre-set objects on which focusing is required.
[0089] For example, if there is only one object that needs to be focused on, such as only a person, the electronic device 100 detects whether the image frame displayed on the preview interface includes a person through image recognition. If a person is included, the person in the current image frame is used as the first object. If multiple people are included in the current image frame, one person can be selected from the multiple people as the first object, for example, the person closest to the center point in the current image frame can be used as the first object.
[0090] In another possible implementation, the user can select the first object to be focused on according to the image frame content presented by the preview interface 123. Therefore, when the electronic device receives a trigger operation from the user on the preview interface 123, the first object to be focused on can be determined according to the trigger operation. Optionally, the trigger operation may include a touch operation, a voice operation, and a sight interaction operation, but is not limited thereto.
[0091] Therefore, when the electronic device automatically detects that the image displayed in real time on the preview interface 123 includes the first object 127, or receives a trigger operation applied to the preview interface 123 for focusing on the first object 127, the electronic device focuses on the first object 127 displayed in the preview interface 123 and displays the image as shown in FIG. Figure 2C The preview interface is shown.
[0092] exist Figure 2C In the preview interface shown, when the electronic device focuses on the first object 127 displayed in the preview interface 123, a focus frame 128 may be displayed, and the focused first object 127 is within the focus frame 128. The image within the focus frame 128 is clearer than the image not within the focus frame 128.
[0093] It is understandable that when taking portrait photos, the person is the first and most important object in the picture. If you want to ensure that the person's expression is clear, the focus frame should be in the face area of the person. If you want to take a close-up of the person's face, the focus frame can be aimed at the person's eye area to ensure that the eyes are clearer. If you are taking a full-body portrait at a slightly farther distance, with a little environment, the focus frame can be roughly aimed at the face area. If you are taking a portrait of a person in the environment at a farther distance, and the person's proportion in the picture is very small, then the focus frame can be not in the person area, and can be in an area with moderate overall brightness in the picture to ensure overall balanced exposure.
[0094] Taking the "Photograph" mode as an example, it is introduced to display image frames of a clear target subject in motion in the preview interface.
[0095] Figure 3A-3CThe UI for focusing on the first object gradually approaching the electronic device is exemplified. The first object 127 moves from position 1 to position 2 and approaches the electronic device 100. The electronic device 100 focuses on the first object 127 gradually approaching from a distance, so that a clear image frame without a focus phenomenon is displayed on the preview interface 123.
[0096] Figure 4A-4C The UI for focusing on the first object that is gradually moving away from the electronic device is exemplified. The first object 127 moves away from the electronic device 100 during the process of moving from position 2 to position 1. The electronic device 100 focuses on the first object 127 that is gradually moving away from the near distance, so that a clear image frame without a focus phenomenon is displayed on the preview interface 123.
[0097] For the convenience of subsequent explanation, Figure 3A-3C The image frames displayed on the preview interface 123 are numbered in chronological order as the i-1th frame, the ith frame, and the i+1th frame. Figure 4A-4C The image frames displayed on the preview interface 123 are numbered as the k-1th frame, the kth frame, and the k+1th frame in chronological order.
[0098] During the shooting process, the electronic device 100 can detect the first object 127 that needs to be focused in the current image frame through the subject detection function, and can obtain the movement speed and / or movement direction of the first object 127 relative to the electronic device 100 based on the perception function. How the electronic device 100 obtains the movement speed and / or movement direction of the first object 127 relative to the electronic device 100 based on the perception function will be described in detail later, and will not be repeated here.
[0099] Then, the electronic device 100 determines a first number of preview stream image frames from multiple preview stream image frames including the first object captured by the camera based on the movement speed of the first object 127 relative to the electronic device 100, determines first focus information according to the first number of preview stream image frames, and focuses on the first object 127 according to the first focus information. Thereby, the i-1th frame, the i-th frame, the i+1th frame or the k-1th frame, the k-th frame, and the k+1th frame are displayed in the preview interface 123 in chronological order.
[0100] In one possible implementation, if the movement speed of the first object 127 acquired by the electronic device 100 relative to the electronic device 100 is greater than the first threshold, it indicates that the movement speed is fast. In order to follow the focus in time, the electronic device 100 needs to reduce the number of preview stream image frames used to determine the first focus information, that is, the first number is less than the preset number.
[0101] from Figure 3A-3CIt can be seen that if the first object 127 moves from position 1 to position 2 at a faster speed, then the time required for the first object 127 to approach the electronic device 200 from a distance is relatively short. Figure 4A-4C It can be seen that if the first object 127 moves from position 2 to position 1 at a relatively fast speed, then the time required for the first object 127 to move from a near distance to the electronic device 200 is relatively short. Therefore, among the multiple preview stream image frames collected by the electronic device 100 according to the collection interval, there are image frames with large focus data differences, and the focus data of the image frames may suddenly increase or decrease.
[0102] by Figure 3A-3C For example, assuming that the process of moving from position 1 to position 2 includes 4 acquisition intervals, the focus data of the preview stream image frame acquired in the first acquisition interval may be 50, and the focus data of the preview stream image frame acquired in the second acquisition interval may be 49. Since the movement speed of the first object 127 moving toward the direction where the electronic device 100 is located between the second acquisition interval and the fourth acquisition interval is greater than the first threshold, it will move closer to the direction where the electronic device 100 is located from a distance at a relatively fast movement speed. Then, the focus data acquired in the third acquisition interval may be 20, and the focus data acquired in the fourth acquisition interval may be 15.
[0103] It can be seen that for the first object 127, which moves faster than the electronic device 100, the focus data collected in the third acquisition interval and the fourth acquisition interval are significantly different from the focus data collected in the first acquisition interval and the second acquisition interval. The focus data collected in the third acquisition interval and the fourth acquisition interval are the latest collected data, which can more accurately represent the focus position of the first object 127 at this time. In other words, the focus data collected in the first acquisition interval and the second acquisition interval cannot accurately represent the focus position of the first object 127 at this time. If the focus information is determined according to a preset number (for example, 4) of focus data, the focus data collected in the first acquisition interval and the second acquisition interval will affect the focus data collected in the third acquisition interval and the fourth acquisition interval, and the focus information cannot accurately represent the focus position of the first object 127 at this time, so that the problem of untimely focus tracking will occur. Therefore, the electronic device 100 reduces the number of frames based on the preset number, and the determined first number of preview stream image frames are the latest captured image frames, which can more accurately represent the focus position of the first object 127 at this time, thereby improving the timeliness of focus tracking.
[0104] In another possible implementation, if the acquired movement speed of the first object 127 relative to the electronic device 100 is less than or equal to the first threshold, it indicates that the movement speed is slow. In order to improve the accuracy of focusing, the electronic device 100 needs to increase the number of preview stream image frames used to determine the first focus information, that is, the first number is greater than or equal to the preset number.
[0105] from Figure 3A-3C It can be seen that if the movement speed of the first object 127 from position 1 to position 2 is relatively slow, then it takes a relatively long time for the first object 127 to approach the electronic device 100 from a distance.
[0106] from Figure 4A-4C It can be seen that if the movement speed of the first object 127 from position 2 to position 1 is relatively slow, then the time required for the first object 127 to move from a close distance to a distance from the electronic device 100 is relatively long.
[0107] Therefore, in the multiple preview stream image frames collected by the electronic device 100 according to the collection interval, the image frame data is relatively stable, and the image frame data will not suddenly increase or decrease. Therefore, in order to improve the accuracy of focusing and obtain more accurate focusing information, the electronic device 100 can increase the number of frames based on the preset number, and the determined first number of preview stream image frames can reflect the focus position of the first object 127 in the current motion state.
[0108] The preset number is the number of image frames used to determine the focus information from multiple preview stream image frames when the first object 127 is in a stationary state. That is, if the first object 127 is in a stationary state, the electronic device 100 determines the first focus information based on the focus data of the preset number of preview stream image frames. If the first object 127 is in a moving state, the electronic device 100 increases or decreases the number of frames based on the preset number according to the moving speed of the first object 127, and determines the first focus information according to the increased or decreased number of frames.
[0109] Finally, the electronic device 100 focuses on the first object 127 according to the first focus information, and displays an image frame including the first object in the preview interface 123 .
[0110] In a possible implementation, the electronic device can focus on the first object 127 according to the first focus information and the movement direction of the first object 127 relative to the electronic device 100, so as to display an image frame of the first object 127 with a clear subject in the preview interface 123. Figure 3C The i-1th frame, the i-th frame, and the i+1th frame shown, Figure 4C The k-1th frame, the kth frame, and the k+1th frame are shown.
[0111] For example, if Figure 3B As shown, the i-th frame displayed on the preview interface 123 is taken as an example. If the electronic device 100 controls the camera to move in the direction of the first object 127 according to the first focus information, Figure 3B It can be seen that the first object 127 is moving in a direction close to the electronic device 100. Therefore, the movement direction of the camera toward the first object is consistent with the movement direction of the first object 127 relative to the electronic device 100. The electronic device 100 can control the camera to move in the direction of the first object 127 to the first position corresponding to the first focus information, focus on the first object 127, and thus display the i-th frame in the preview interface 123.
[0112] If the electronic device 100 controls the camera to move in the opposite direction of the first object 127 according to the first focus information, Figure 3B It can be seen that the first object 127 moves in the direction where the electronic device 100 is located, that is, the movement direction of the camera in the opposite direction to the first object is inconsistent with the movement direction of the first object 127 relative to the electronic device 100. In order to avoid the pull focus phenomenon, the electronic device 100 controls the position of the camera focusing on the first object 127 to remain unchanged, and focuses on the first object 127 at the last focus position, so that the i-th frame is displayed in the preview interface 123.
[0113] The last focus position is when the electronic device 100 focuses on the first object 127, as shown in FIG. Figure 3A The position of the i-1th frame in the preview interface 123 is shown.
[0114] For example, Figure 4B As shown, the kth frame displayed on the preview interface 123 is taken as an example. If the electronic device 100 controls the camera to move in the opposite direction of the first object 127 according to the first focus information, Figure 4B It can be seen that the first object 127 is moving away from the electronic device 100. Therefore, the movement direction of the camera is consistent with the movement direction of the first object 127 relative to the electronic device 100. The electronic device 100 controls the camera to move in the opposite direction of the first object 127 to the first position corresponding to the first focus information, focuses on the first object 127, and displays the kth frame in the preview interface 123.
[0115] If the electronic device 100 controls the camera to move in the direction of the first object 127 according to the first focus information, Figure 4BIt can be seen that the first object 127 is moving away from the electronic device 100, that is, the moving direction of the camera is inconsistent with the moving direction of the first object 127 relative to the electronic device 100. In order to avoid the pull focus phenomenon, the electronic device 100 controls the position of the camera focusing on the first object 127 to remain unchanged, and focuses on the first object 127 at the last focus position, so that the kth frame is displayed in the preview interface 123.
[0116] The last focus position is when the electronic device 100 focuses on the first object 127, as shown in FIG. Figure 4A The position of the k-1th frame in the preview interface 123 is shown.
[0117] It is understandable that if the moving direction of the camera is inconsistent with the moving direction of the first object relative to the electronic device, it will cause the focus pulling phenomenon. Therefore, in the embodiment of the present application, when the moving direction of the camera is consistent with the moving direction of the first object relative to the electronic device, the camera is moved to focus on the first object; when the moving direction of the camera is consistent with the moving direction of the first object relative to the electronic device, the camera is not moved and the first object is focused at the original position. Thereby, the occurrence of the focus pulling phenomenon can be avoided.
[0118] Not limited to the above-mentioned photo-taking scene, the user can also display a clear image frame of the target subject in the preview interface in a video recording scene.
[0119] The electronic device 100 may receive a signal acting on Figure 3A-3C or Figure 4A-4C The left swipe operation of the mode bar 121 shown. In response to the above operation, the electronic device 100 can switch the "photographing" mode to the "video recording" mode. After entering the "video recording" mode, the electronic device 100 can switch the preview interface corresponding to the original "photographing" mode to the preview interface corresponding to the "video recording" mode. Specifically, the electronic device 100 can switch the original photo taking control of the "photographing" mode to the start video recording control of the "video recording" mode. The electronic device 100 receives a user operation acting on the start video recording control. In response to the above operation, the electronic device 100 can start recording a video.
[0120] Figure 5A-Figure 5C The UI for focusing the video of the first object gradually approaching the electronic device is shown as an example. A set of video recording interfaces displayed by the electronic device 100 during the process of recording the first object 127 moving from position 1 to position 2. The preview interface 123 can sequentially display the motion states of the first object 127 that is clear and does not have a focus phenomenon captured by the camera at different moments during the process of gradually approaching the electronic device 100 from a distance. The timestamp control 313 can be updated as the recording time increases.
[0121] Figure 5D-5FThe UI for focusing the video of the first object that is gradually moving away from the electronic device is exemplified. A set of video recording interfaces displayed by the electronic device 100 during the process of recording the first object 127 moving from position 2 to position 1. The preview interface 123 can sequentially display the motion states of the first object 127 that is clear and has no focus phenomenon captured by the camera at different moments during the process of gradually moving away from the electronic device 100 from a close distance. The timestamp control 313 can be updated as the recording time increases.
[0122] Therefore, when recording a video, the electronic device 100 focuses on the first object 127, and the solution of displaying a clear picture in the preview interface 123 can refer to the relevant description under the above-mentioned photo-taking scene, which will not be repeated here.
[0123] Next, the form and software and hardware architecture of the electronic device provided in the embodiments of the present application are introduced.
[0124] Electronic equipment can be equipped Or portable terminal devices with other operating systems, such as mobile phones, tablet computers, desktop computers, laptop computers, handheld computers, notebook computers, ultra-mobile personal computers (UMPC), netbooks, as well as cellular phones, personal digital assistants (PDA), augmented reality (AR) devices, virtual reality (VR) devices, artificial intelligence (AI) devices, wearable devices, vehicle-mounted devices, smart home devices and / or smart city devices, etc.
[0125] Figure 6 The hardware structure of the electronic device of the embodiment of the present application is exemplified. Figure 6As shown, the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 129, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, 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.
[0126] It is to be understood that the structure illustrated in the embodiment of the present invention 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 may be implemented in hardware, software, or a combination of software and hardware.
[0127] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0128] The controller can generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions. The processor 110 can also be provided with a memory for storing instructions and data.
[0129] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0130] 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.
[0131] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD). The display panel can also be made of 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 may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0132] In the embodiment of the present application, the electronic device 100 can display the display function provided by the GPU, the display screen 194, and the application processor, etc. Figure 2A-2C , Figure 3A-3C , Figure 4A-4C , Figure 5A-5F The user interface shown.
[0133] The electronic device can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0134] The ISP is used to process the data fed back by the camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. The ISP can also perform algorithm optimization on the noise and brightness of the image. The ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP can be set in the camera 193.
[0135] The camera 193 is used to capture still images or videos. In some embodiments, the electronic device may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0136] Figure 7 The composition structure of the camera is exemplarily shown. The camera 193 may include components such as a lens, a photosensitive element, and a camera motor.
[0137] The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in standard RGB, YUV and other formats.
[0138] Among them, Figure 7 As shown, the lens may include multiple groups of lenses (or lens groups) and apertures and other components. The lenses are used to converge the light reflected by the first object to be photographed onto the focal plane of the photosensitive element for imaging. The aperture is used to control the amount of light that passes through the lens and enters the photosensitive surface of the photosensitive element. The camera motor can push one or more groups of lenses to move or push the photosensitive element to move to change the position of the lenses or the photosensitive element, thereby changing the focusing distance and the focal position of the lens.
[0139] When the distance between the first object and the electronic device is different, the corresponding imaging position is different, and the position of the lens and the photosensitive element needs to be adjusted. The "moving direction of the camera" mentioned in the embodiments of the present application can be understood as the moving direction of one or more sets of lenses pushed forward or backward by the camera motor, or the moving direction of the photosensitive element pushed forward or backward by the camera motor.
[0140] In a possible implementation, when the direction in which the camera 193 is controlled to move according to the first focus information is consistent with the movement direction of the first object, the electronic device 100 can drive the camera motor to drive one or more groups of lenses or photosensitive elements to move to the first position corresponding to the first focus information, thereby focusing on the first object.
[0141] In another possible implementation, when the direction in which the camera 193 is controlled to move according to the focus information is inconsistent with the movement direction of the first object, the electronic device 100 can control the camera motor to remain stationary, thereby not driving one or more groups of lenses or photosensitive elements to move, thereby controlling the lens to focus on the first object at the focus position where it last focused on the first object.
[0142] In the embodiment of the present application, the focus of the lens may also be referred to as the focusing position, focusing point or focusing point of the camera 193 .
[0143] In the embodiment of the present application, the camera 193 may include one or more of the following cameras: a telephoto camera, a wide-angle camera, an ultra-wide-angle camera, a zoom camera, or a depth camera. Among them, the telephoto camera has a small shooting range and is suitable for shooting distant objects; the wide-angle camera has a larger shooting range; the ultra-wide-angle camera has a larger shooting range than the wide-angle camera and is suitable for shooting panoramic and other large-screen scenes. The depth camera can be used to measure the object distance of the object to be photographed, that is, to measure the depth information of the object to be photographed, for example, it may include a three-dimensional (3D) depth camera, a time of flight (TOF) depth camera, or a binocular depth camera.
[0144] The camera 193 may include a main camera and a secondary camera. The main camera may be used to capture images, for example, it may include a telephoto camera, a wide-angle camera, an ultra-wide-angle camera, or a zoom camera, etc. The secondary camera may be used for ranging or other auxiliary functions, for example, it may include a depth camera.
[0145] The camera 193 may include a front camera and / or a rear camera. The front camera may include one or more main cameras, and the rear camera may also include one or more main cameras. When capturing an image, the target main camera used by the electronic device to capture the image may be a default main camera or a main camera selected by the user.
[0146] Video codecs are used to compress or decompress digital videos. The electronic device 100 may support one or more video codecs. Thus, the electronic device 100 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0147] In an embodiment of the present application, the electronic device 100 can acquire images through shooting functions provided by ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0148] The external memory interface 120 can be used to connect to an external non-volatile memory to expand the storage capacity of the electronic device 100. The external non-volatile memory communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, image files such as photos obtained in the "photographing" mode or the "recording" mode are stored in the external non-volatile memory.
[0149] The electronic device 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone interface 170D, and the application processor, etc. For example, after the camera application is turned on, the camera application can call the audio module 170 to obtain the ambient audio signal, and combine it with the image stream generated by the camera and other devices to form a video.
[0150] The gyro sensor 180B can be used to detect the magnitude of the angular velocity of the electronic device 100 in various directions (generally three axes). The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions. The gyro sensor 180B and the acceleration sensor 180E can be used to determine the motion posture of the electronic device 100. In the embodiment of the present application, the data reported by the acceleration sensor 180E and the gyro sensor 180B can be used to determine the motion state of the device, and then assist in determining whether the image at the corresponding moment will be jittery, ghosting, etc.
[0151] The touch sensor 180K is also called a "touch control device". The touch sensor 180K can be set on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, also called a "touch control 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. 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.
[0152] Figure 8 The software architecture of the electronic device according to the embodiment of the present application is exemplified.
[0153] like Figure 8As shown, the system of the electronic device 100 may adopt a layered architecture, which divides the system into several layers, each layer having a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the system is divided into five layers, from top to bottom, namely, the application layer, the application framework layer (framework), the hardware abstract layer (HAL), the driver layer, and the hardware layer. Among them:
[0154] The application layer (application) may include a series of application packages. For example, the application package may include camera applications, gallery and other applications. The camera application may include but is not limited to: UI module, camera module, gallery module, etc. Among them, the UI module may be the cameraUI module mentioned in other embodiments of this document, which may be mainly responsible for the human-computer interaction of the camera application, such as controlling the preview interface and the display of the preview screen therein, receiving and responding to user operations occurring in the preview interface. The camera module provides camera functions, focus functions, etc. The gallery module can be used to store clear photos taken by the user in the file system or a specific database of the electronic device for retrieval by applications such as the gallery.
[0155] The application framework layer provides application programming interfaces (APIs) and programming frameworks for applications in the application layer. It mainly involves the camera framework, which can include camera management and camera device access interfaces, and plays a role in connecting the upper and lower parts. It can interact with camera applications through the application API and interact with HAL through the HAL interface definition language (HIDL). It can also include a window manager. The camera application and the gallery application can display the photos taken to the user with the support of the window manager.
[0156] The hardware abstraction layer (HAL) is an interface layer located between the application framework layer and the driver layer, and provides a virtual hardware platform for the operating system. Exemplarily, the hardware abstraction layer may include a camera hardware abstraction layer and a focus module. Among them, the camera hardware abstraction layer may provide virtual hardware for camera device 1 (first camera), camera device 2 (second camera) and more camera devices.
[0157] The focus module stores a variety of image processing algorithms. For example, in an embodiment of the present application, the focus module may include a subject detection algorithm, a motion direction algorithm, a motion speed algorithm, a focus algorithm, etc. Among them:
[0158] The subject detection algorithm can be used to detect the first object in the image that needs to be focused, such as a person, a cat, a dog, etc., and also to obtain parts of these objects, such as a person's face, a cat's face, and a dog's face. After detecting a specific shooting object, the algorithm module can mark the size and position of the object in the image. After identifying the preset first object, the subject detection algorithm can output a focus frame. The focus frame marks the size and position of the first object in the image.
[0159] The motion direction algorithm may be used to detect the motion direction of the photographed first object relative to the electronic device 100 , whether it is gradually approaching the electronic device 100 from a distance, or gradually moving away from the electronic device 100 from a nearby location.
[0160] Specifically, the camera captures multiple preview stream image frames including the first object, and the motion direction algorithm can calculate the depth data of the L image frames closest to the current capture time among the multiple preview stream image frames, and compare the depth data corresponding to the L image frames in order according to the capture time of the above L image frames. Wherein, L is a positive integer greater than or equal to 1, and if the L depth data are sorted according to the capture time of the corresponding preview stream image frames, the L depth data gradually decreases, indicating that the depth data shows a downward trend, indicating that the distance between the first object being photographed and the electronic device is decreasing, that is, the motion direction of the first object relative to the electronic device is gradually approaching the electronic device.
[0161] If the L depth data are sorted according to the acquisition time of the corresponding preview stream image frames, the L depth data gradually increase, indicating that the depth data shows an upward trend, indicating that the distance between the first object being photographed and the electronic device is increasing, that is, the movement direction of the first object relative to the electronic device is gradually moving away from the electronic device.
[0162] The motion speed algorithm can be used to detect the motion speed of the first object relative to the electronic device 100. For example, relative to the electronic device 100, if the motion speed is greater than the first threshold, it means that the motion speed of the first object is fast; if the motion speed is less than or equal to the first threshold, it means that the motion speed of the first object is slow.
[0163] Specifically, the motion speed algorithm can calculate the change value between M adjacent preview stream image frames in multiple preview stream image frames. For example, when M is equal to 2, the change value may include the change value between the depth data of the current image frame (the Mth frame) and the depth data of the previous image frame (the M-1th frame); when M is equal to 3, the change value may include the change value between the depth data of the Mth frame and the depth data of the M-1th frame, and the change value between the depth data of the M-1th frame and the depth data of the M-2th frame. When M is equal to 4, the change value may include the change value between the depth data of the Mth frame and the depth data of the M-1th frame, the change value between the depth data of the M-1th frame and the depth data of the M-2th frame, and the change value between the depth data of the M-2th frame and the M-3th frame.
[0164] The motion speed algorithm can determine the motion speed of the first object relative to the electronic device according to the above change value and a threshold value corresponding to the distance between the first object and the electronic device.
[0165] For example, if the above change value is greater than the threshold corresponding to the first distance, it is determined that the movement speed of the first object relative to the electronic device is greater than the first threshold, indicating that the movement speed of the first object relative to the electronic device is fast.
[0166] If the change value is less than or equal to the threshold corresponding to the first distance, it is determined that the movement speed of the first object relative to the electronic device is less than or equal to the first threshold, indicating that the movement speed of the first object relative to the electronic device is slow.
[0167] The focus algorithm can be used to determine a focus result based on the movement speed of the first object relative to the electronic device. The focus result includes first focus information, which is determined based on a first number of preview stream image frames, and the first number is determined from multiple preview stream image frames based on the above movement speed. Or,
[0168] The focus algorithm can be used to determine a focus result based on the movement speed and movement direction of the first object relative to the electronic device. In one implementation, when the movement direction of the camera is controlled to be consistent with the movement direction according to the first focus information determined based on the movement speed, the focus result includes the first focus information.
[0169] In another implementation, when the movement direction of the camera controlled according to the first focus information determined based on the movement speed is inconsistent with the movement direction, no focus result is generated.
[0170] The driver layer is a layer between hardware and software, which includes drivers for various hardware. The driver layer may include camera drivers, digital signal processor drivers, and image processor drivers. Among them, the camera driver is used to drive the image sensor of one or more cameras in the camera to collect images and drive the image signal processor to pre-process the image. The digital signal processor driver is used to drive the digital signal processor to process images. The image processor driver is used to drive the graphics processor to process images.
[0171] The hardware layer may include a camera, an image signal processor, a digital signal processor, and an image processor. The camera may include one or more image sensors of the camera (e.g., image sensor 1, image sensor 2, etc.). Optionally, the camera may also include a camera motor, a lens, a TOF sensor, and the like.
[0172] In the embodiment of the present application, the workflow of the software system of the electronic device 100 is exemplified in combination with the process of displaying image frames in a preview scenario.
[0173] The system desktop can receive the user's operation of opening the camera application, such as the user clicking the desktop icon of "Camera". In response to the user operation of opening the camera application, the system can start the CameraUI module and display the preview interface. The CameraUI module can be responsible for the human-computer interaction of the camera application, such as controlling the display of the preview interface and its interface elements, and monitoring and responding to user operations occurring in the preview interface.
[0174] After the camera application is started, the camera device in the camera hardware abstraction layer, such as camera device 1, is called to send an instruction to start the camera application. The camera hardware abstraction layer sends the instruction to the camera device driver of the driver layer, and the camera device driver can start the sensor corresponding to the camera device, and then collect the image light signal through the sensor, and transmit the image light signal to the image signal processor for preprocessing to obtain a plurality of preview stream image frames including the first object. At this time, the preview stream image frames can be called the original image stream. Then, the original image stream is transmitted back to the hardware abstraction layer through the camera device driver.
[0175] The camera hardware abstraction layer can send the original image stream to the focus algorithm module. Based on the support of the digital signal processor and the image processor, the focus algorithm module can call one or more of the perception algorithms such as the subject detection algorithm, the motion direction algorithm, the motion speed algorithm and the focus algorithm to perform focus processing on the original image stream and determine the focus processing result. The focus algorithm module sends the focus processing result to the camera hardware abstraction layer, and the camera hardware abstraction layer calls the camera device driver according to the focus processing result, and the camera device driver drives the camera to focus on the first object. Then, the camera device driver transmits the image frame including the first object after focusing back to the HAL, and the HAL returns the image frame including the first object to the camera framework layer. After receiving the image frame from the HAL, the camera framework can pass the image frame to the CameraUI in the camera application to trigger the CameraUI to display the preview image frame in the preview interface. A user interface that provides shooting and display services can be displayed, also known as a preview interface, in which the image frames in the image stream captured by the camera are displayed.
[0176] The following describes the cooperative relationship between the components in the electronic device in the scenario of focusing on the first object. The following example uses the TOF sensor to detect the distance between the first object and the electronic device as an example. In a specific implementation, other sensors may also be used for detection.
[0177] In case 1, the moving speed of the first object is greater than the first threshold, and the moving direction of the first object is consistent with the moving direction of the camera.
[0178] See also Fig. 9A , Fig. 9A It is a schematic diagram of the collaborative relationship regarding situation one provided in an embodiment of the present application.
[0179] Step S1. The motion speed algorithm determines the motion speed of the first object relative to the electronic device.
[0180] The TOF sensor sends a first distance between the first object and the electronic device to the motion speed algorithm, and the motion speed algorithm can determine the motion speed of the first object relative to the electronic device according to the first distance.
[0181] The motion speed algorithm sends the motion speed of the first object relative to the electronic device to the focus algorithm.
[0182] Step S2: The motion direction algorithm determines the motion direction of the first object.
[0183] The movement direction includes movement toward the electronic device and movement away from the electronic device.
[0184] After determining the direction of motion, the motion speed algorithm sends the direction of motion of the first object relative to the electronic device to the focus algorithm.
[0185] Step S3: The directions are consistent, and a focusing algorithm determines a focusing result, where the focusing result includes first focusing information.
[0186] When the movement speed of the first object relative to the electronic device is greater than a first threshold, the focus algorithm determines a first number of image frames less than a preset number from the plurality of preview stream image frames.
[0187] The focus algorithm determines first focus information based on a first number of image frames that is less than a preset number.
[0188] When the focusing algorithm determines, based on the first focusing information, that the moving direction of the camera is consistent with the moving direction of the first object, the focusing result includes the first focusing information.
[0189] The focus module sends first focus information to the camera application abstraction layer based on a focus result determined by the focus algorithm.
[0190] Step S4: The camera application abstraction layer calls the camera device driver according to the first focus information.
[0191] The camera application abstraction layer receives first focus information from the focus module, and calls the camera device driver according to the first focus information.
[0192] Step S5: The camera device driver drives the camera according to the first focus information.
[0193] Therefore, when the movement directions are consistent, the camera device driver can drive the camera to focus on the first object according to the first focus information.
[0194] Step S6: The camera focuses on the first object according to the first focusing information.
[0195] In case 2, the moving speed of the first object is greater than the first threshold, and the moving direction of the first object is inconsistent with the moving direction of the camera.
[0196] See also Fig. 9B , Fig. 9B It is a schematic diagram of the collaborative relationship regarding situation 2 provided in an embodiment of the present application.
[0197] Step S1. The motion speed algorithm determines the motion speed of the first object relative to the electronic device.
[0198] The TOF sensor sends a first distance between the first object and the electronic device to the motion speed algorithm, and the motion speed algorithm can determine the motion speed of the first object relative to the electronic device according to the first distance.
[0199] The motion speed algorithm sends the motion speed of the first object relative to the electronic device to the focus module.
[0200] Step S2: The motion direction algorithm determines the motion direction of the first object.
[0201] The movement direction includes movement toward the electronic device and movement away from the electronic device.
[0202] After determining the direction of motion, the motion direction algorithm sends the direction of motion of the first object relative to the electronic device to the focus algorithm.
[0203] Step S3: The directions are inconsistent, and the focusing algorithm does not generate a focusing result.
[0204] When the movement speed of the first object relative to the electronic device is greater than a first threshold, the focus algorithm determines a first number of image frames less than a preset number from the plurality of preview stream image frames.
[0205] The focus algorithm determines first focus information based on a first number of image frames that is less than a preset number.
[0206] When the focusing algorithm determines, according to the first focusing information, that the moving direction of the camera is inconsistent with the moving direction of the first object, no focusing result is generated.
[0207] Because no focus result is generated, the focus module does not send the focus result to the camera application abstraction layer.
[0208] Step S4: The camera focuses on the first object at the last focus position.
[0209] If the camera application abstraction layer does not receive the focus result, the camera application abstraction layer will not call the camera device driver.
[0210] If the camera device driver does not receive the latest focus information, the camera device driver will not drive the camera. Therefore, the camera keeps the focus position unchanged and focuses on the first object at the last focus position.
[0211] Case three: the moving speed of the first object is less than or equal to the first threshold, and the moving direction of the first object is consistent with the moving direction of the camera.
[0212] See also Fig. 9C , Fig. 9C This is a schematic diagram of the collaborative relationship regarding situation three provided in an embodiment of the present application.
[0213] Step S1. The motion speed algorithm determines the motion speed of the first object relative to the electronic device.
[0214] The TOF sensor sends a first distance between the first object and the electronic device to the motion speed algorithm, and the motion speed algorithm can determine the motion speed of the first object relative to the electronic device according to the first distance.
[0215] The motion speed algorithm sends the motion speed of the first object relative to the electronic device to the focus algorithm.
[0216] Step S2: The motion direction algorithm determines the motion direction of the first object.
[0217] The movement direction includes movement towards the electronic device and movement away from the electronic device. After determining the movement direction, the movement speed algorithm sends the movement direction of the first object relative to the electronic device to the focus algorithm.
[0218] Step S3: The directions are consistent, and a focusing algorithm determines a focusing result, where the focusing result includes first focusing information.
[0219] If the movement speed of the first object relative to the electronic device is less than or equal to a first threshold, the focus algorithm determines a first number of image frames greater than or equal to a preset number from the plurality of preview stream image frames.
[0220] The focus algorithm may determine first focus information based on a first number of image frames that is greater than or equal to a preset number.
[0221] The focusing algorithm determines, based on the first focusing information, that the moving direction of the camera is consistent with the moving direction of the first object, and the focusing result includes the first focusing information.
[0222] The focus module sends first focus information to the camera application abstraction layer based on a focus result determined by the focus algorithm.
[0223] Step S4: The camera application abstraction layer calls the camera device driver according to the first focus information.
[0224] The camera application abstraction layer receives first focus information from the focus module, and calls the camera device driver according to the first focus information.
[0225] Step S5: The camera device driver drives the camera according to the first focus information.
[0226] Therefore, when the movement directions are consistent, the camera device driver can drive the camera to focus on the first object according to the first focus information.
[0227] Step S6: The camera focuses on the first object according to the first focusing information.
[0228] Case 4: the moving speed of the first object is less than or equal to the first threshold, and the moving direction of the first object is inconsistent with the moving direction of the camera.
[0229] See also Fig.9D , Fig.9D This is a schematic diagram of the collaborative relationship regarding situation four provided in an embodiment of the present application.
[0230] Step S1. The motion speed algorithm determines the motion speed of the first object relative to the electronic device.
[0231] The TOF sensor sends a first distance between the first object and the electronic device to the motion speed algorithm, and the motion speed algorithm can determine the motion speed of the first object relative to the electronic device according to the first distance.
[0232] The motion speed algorithm sends the motion speed of the first object relative to the electronic device to the focus algorithm.
[0233] Step S2: The motion direction algorithm determines the motion direction of the first object.
[0234] The movement direction includes movement toward the electronic device and movement away from the electronic device.
[0235] After determining the direction of motion, the motion direction algorithm sends the direction of motion of the first object relative to the electronic device to the focus algorithm.
[0236] Step S3: The directions are inconsistent, and the focusing algorithm does not generate a focusing result.
[0237] When the movement speed of the first object relative to the electronic device is less than a first threshold, the focus algorithm determines a first number of image frames greater than or equal to a preset number from the plurality of preview stream image frames.
[0238] The focus algorithm determines first focus information based on a first number of image frames that is greater than or equal to a preset number.
[0239] The focusing algorithm determines, based on the first focusing information, that the moving direction of the camera is inconsistent with the moving direction of the first object, and does not generate a focusing result.
[0240] The focus module does not send the focus result to the camera application abstraction layer.
[0241] Step S4: The camera focuses on the first object at the last focus position.
[0242] If the camera application abstraction layer does not receive the focus result, the camera application abstraction layer will not call the camera device driver.
[0243] If the camera device driver does not receive the latest focus information, the camera device driver will not drive the camera. Therefore, the camera keeps the focus position unchanged and focuses on the first object at the last focus position.
[0244] It should be noted that Figure 9A-9D The execution order of step S1 and step S2 is not limited to step S1 before step S2. Step S1 and step S2 can be executed at the same time, and step S2 can also be executed before step S1. This application does not impose any restrictions on this.
[0245] Based on the above embodiments, the focusing method provided by the embodiments of the present application is described below. The method can be applied to the electronic device 100 shown in the above content, and the method may include but is not limited to the following steps:
[0246] See also Fig.10 , Fig.10 It is a flowchart of a focusing method provided in an embodiment of the present application.
[0247] Step S1001: collecting a plurality of preview stream image frames including a first object.
[0248] The electronic device receives a user operation performed by a user on a camera application. In response to the operation, the electronic device may start the camera and collect a plurality of preview stream image frames including the first object through the camera.
[0249] Step S1002: Acquire a movement speed of the first object relative to the electronic device.
[0250] The electronic device can determine the focus area, that is, the size of the focus frame, based on the autofocus function or the trigger operation input by the user. Autofocus can be divided into center focus, face focus and tracking focus. Among them, the size of the focus frame under center focus is the screen ratio output by the sensor. The size of the focus frame under face focus and tracking focus is determined by the corresponding algorithms, and this application does not impose any restrictions on this.
[0251] The electronic device can calculate the depth data that matches the focus frame according to the size of the focus frame. The depth data refers to the distance between each pixel of the first object in the captured scene and the electronic device. The above depth data can be obtained by various methods of calculating the depth data of the image, such as obtaining the depth data of each point in the first object through laser radar ranging; obtaining the depth data of each point in the image through zoom ranging or multi-baseline stereo imaging; and obtaining the depth data by dual camera ranging.
[0252] The electronic device obtains the depth corresponding to the focus frame in the current image frame by weighted averaging the depth data of each pixel point. The depth corresponding to the focus frame can be expressed as the distance between the first object in the focus frame and the camera.
[0253] The electronic device may determine the movement speed of the first object relative to the electronic device according to the change value between the depth data respectively corresponding to M adjacent image frames in the multiple image frames.
[0254] The movement speed is used to indicate the movement speed of the first object 127 relative to the electronic device 100 in the process of the first object 127 gradually approaching the electronic device 100 in the direction where the electronic device is located. Alternatively, it is used to indicate the movement speed of the first object 127 relative to the electronic device 100 in the process of the first object 127 gradually moving away from the electronic device 100 in the opposite direction where the electronic device is located. Further, if the movement speed of the first object 127 is greater than the first threshold, it means that the movement speed of the first object 127 is relatively fast, and if the movement speed of the first object 127 is less than or equal to the first threshold, it means that the movement speed of the first object 127 is relatively slow.
[0255] The electronic device 100 can detect a first distance between the first object and the electronic device through a time of flight (TOF) sensor, and determine a movement speed of the first object relative to the electronic device based on a change value between M adjacent image frames in a plurality of preview stream image frames and a threshold value corresponding to the first distance.
[0256] Among them, the electronic device 100 is internally provided with three distance segments of near, medium and far, and each distance segment corresponds to a threshold value for judging the motion speed. Among them, the three distance segments of near, medium and far are obtained by dividing the effective distance detected by the TOF sensor. For example, the near distance may include a distance less than 70cm, the long distance may include a distance greater than 1.8m, and the medium distance may include a distance greater than or equal to 70cm and less than or equal to 1.8m.
[0257] Case 1: the first distance is in the long distance segment. If the change value between the depth data corresponding to the two frames (the Mth frame and the M-1th frame) is greater than the threshold value (for example, 15 cm) corresponding to the long distance segment, and further, the change value between the depth data of multiple consecutive (for example, greater than or equal to three) frames shows an increasing trend, it indicates that the movement speed of the first object relative to the electronic device is greater than the first threshold value, and the movement speed of the first object is relatively fast; if the above change value is less than or equal to the threshold value (for example, 15 cm) corresponding to the long distance segment, and further, the change value between the depth data of multiple consecutive (for example, greater than or equal to three) frames does not show an increasing trend, it indicates that the movement speed of the first object relative to the electronic device is less than or equal to the first threshold value, and the movement speed of the first object is relatively slow.
[0258] Case 2: The first distance is in the middle distance segment. If the change value between the depth data corresponding to the two frames (the Mth frame and the M-1th frame) is greater than the threshold value corresponding to the middle distance segment (for example, 10 cm), and further, the change value between the depth data of multiple consecutive (for example, greater than or equal to three) frames shows an increasing trend, it indicates that the movement speed of the first object relative to the electronic device 100 is greater than the first threshold value, and the movement speed of the first object is relatively fast. If the above change value is less than or equal to the threshold value corresponding to the middle distance segment (for example, 10 cm), and further, the change value between the depth data of multiple consecutive (for example, greater than or equal to three) frames does not show an increasing trend, it indicates that the movement speed of the first object relative to the electronic device is less than or equal to the first threshold value, and the movement speed of the first object is relatively slow.
[0259] Case three, the first distance is in the short distance segment. If the change value between the depth data corresponding to the two frames (the Mth frame and the M-1th frame) is greater than the threshold value corresponding to the short distance segment (for example, 5 cm), and further, the change value between the depth data of multiple consecutive (for example, greater than or equal to three) frames shows an increasing trend, it indicates that the movement speed of the first object relative to the electronic device is greater than the first threshold value, and the movement speed of the first object is relatively fast. If the above change value is less than or equal to the threshold value corresponding to the short distance segment (for example, 5 cm), and further, the change value between the depth data of multiple consecutive (for example, greater than or equal to three) frames does not show an increasing trend, it indicates that the movement speed of the first object relative to the electronic device is less than or equal to the first threshold value, and the movement speed of the first object is relatively slow.
[0260] Step S1003: determining a first number of preview stream image frames from a plurality of preview stream image frames based on a movement speed of the first object relative to the electronic device.
[0261] The electronic device dynamically adjusts the target frame number based on the movement speed of the first object, thereby determining a first number of image frames from a plurality of preview stream image frames captured by the camera.
[0262] In a possible implementation, when the movement speed of the first object relative to the electronic device is greater than the first threshold, it means that the movement speed of the first object relative to the electronic device is fast and the number of filtering frames needs to be reduced, then the first number is less than the preset number.
[0263] In another possible implementation, when the movement speed of the first object relative to the electronic device is less than or equal to the first threshold, it indicates that the movement speed of the first object relative to the electronic device is slow and the number of filtering frames needs to be increased, then the first number is greater than or equal to the preset number,
[0264] The preset number is the number of image frames used to determine the focus information determined from the first image when the first object is in a stationary state relative to the electronic device.
[0265] In the prior art, whether the first object to be focused is in motion or in a static state, a preset number of image frames are used to determine the focus information. To overcome this problem, in an embodiment of the present application, the electronic device can obtain the motion speed of the first object and adjust the target frame number based on the motion speed, so that it can be better applied to actual scenes, improve the timeliness of focus tracking, and avoid unclear images caused by the motion of the first object.
[0266] Step S1004: determining first focus information according to a first number of preview stream image frames.
[0267] The electronic device may filter the plurality of preview stream image frames according to the first number, and use the average of the focus data (for example, PD data) of the first number of preview stream image frames as the first focus information.
[0268] Step S1005: focusing on the first object according to the first focusing information.
[0269] The electronic device can move the camera to a position corresponding to the first focus information according to the first focus information, focus on the first object, and thus display an image frame of the first object with a clear subject on the preview interface.
[0270] Specifically, the camera includes a camera motor and a lens. The camera motor is pushed to drive the lens to the position where the first focus information is located, focusing on the first object, thereby collecting image light information of the first object and displaying a clear image frame of the subject in the preview interface.
[0271] In a possible implementation, after the electronic device captures multiple preview stream image frames including a first object, before focusing on the first object according to the first focus information, the electronic device can also obtain the movement direction of the first object relative to the electronic device based on the change value of the depth data between adjacent image frames in the multiple image frames.
[0272] Movement direction, the electronic device can obtain the depth data of the L preview stream image frames closest to the current acquisition time among multiple preview stream image frames, and compare the depth data corresponding to the L preview stream image frames according to the acquisition time corresponding to the above L preview stream image frames. Wherein, L is a positive integer greater than or equal to 1. If the above depth data shows a downward trend, it means that the movement direction of the first object relative to the electronic device is gradually approaching the electronic device. If the above depth data shows an upward trend, it means that the movement direction of the first object relative to the electronic device is gradually moving away from the electronic device.
[0273] For example, if the depth data gradually decreases according to the acquisition time of the preview stream image frame corresponding to the depth data, that is, the depth data of the Lth frame image is less than the depth data of the L-1th frame, it means that the distance of each pixel of the first object in the Lth frame image relative to the electronic device is less than the distance of each pixel of the first object in the L-1th frame relative to the electronic device. Therefore, the distance between the first object being photographed and the electronic device is decreasing, and the movement direction of the first object relative to the electronic device is gradually moving towards the electronic device.
[0274] If the depth data gradually increases according to the acquisition time of the preview stream image frame corresponding to the depth data, that is, the depth data of the Lth frame image is greater than or equal to the depth data of the L-1th frame, it means that the distance of each pixel of the first object in the Lth frame image relative to the electronic device is greater than or equal to the distance of each pixel of the first object in the L-1th frame relative to the electronic device. Therefore, the distance between the first object being photographed and the electronic device is increasing, and the movement direction of the first object relative to the electronic device is gradually moving away from the electronic device.
[0275] In a possible implementation, the electronic device may focus on the first object according to the first focus information and a moving direction of the first object relative to the electronic device.
[0276] Implementation method 1: when the direction in which the camera is controlled to move according to the first focus information is consistent with the movement direction of the first object relative to the electronic device, the electronic device controls the camera to move to the first position corresponding to the first focus information to focus on the first object.
[0277] Implementation method 2: when the direction in which the camera is controlled to move according to the first focus information is inconsistent with the movement direction of the first object relative to the electronic device, the electronic device controls the camera to focus on the position of the first object unchanged.
[0278] Here, “controlling the position of the camera to focus on the first object remains unchanged” can be understood as maintaining the position at which the camera was controlled to focus on the first object last time.
[0279] Therefore, when the electronic device obtains the movement direction and movement speed of the first object, the frame number of the image frame can be adjusted according to the movement speed, thereby determining the focus information for focusing on the first object. Then, when focusing on the first object, the direction in which the camera motor corresponding to the focus information moves can be compared with the movement direction of the first object. If the directions are consistent, the camera motor is moved according to the focus information to focus on the first object. If the directions are inconsistent, the position of the camera motor is kept unchanged.
[0280] The present application also provides a computer program product, which includes: a computer program (also referred to as code, or instruction), which enables a computer to execute the method executed by the electronic device in any of the above embodiments when the computer program is executed.
[0281] The present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program (also referred to as code or instruction). When the computer program is executed, the computer executes the method executed by the electronic device in any of the above embodiments.
[0282] The various implementation modes of the present application can be combined arbitrarily to achieve different technical effects.
[0283] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in this application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integration. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk), etc.
[0284] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be implemented by a computer program to instruct the relevant hardware to complete the process, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above-mentioned method embodiments. The aforementioned storage medium can be a non-volatile memory, and specifically can include: ROM or random access memory RAM, a magnetic disk or an optical disk and other media that can store program codes. In short, the above is only an embodiment of the technical solution of the present invention, and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made according to the disclosure of the present invention should be included in the scope of protection of the present invention.
Claims
1. A focusing method, characterized in that: Applied to electronic equipment, the method comprises: Acquiring a plurality of preview stream image frames including a first object; Acquire a movement speed of the first object relative to the electronic device; Based on the motion speed, determining a first number of preview stream image frames from the plurality of preview stream image frames; determining first focus information according to the first number of preview stream image frames; The first object is focused according to the first focusing information.
2. The method according to claim 1, characterized in that After acquiring a plurality of preview stream image frames including the first object and before focusing on the first object according to the first focusing information, the method further includes: Acquire a movement direction of the first object relative to the electronic device.
3. The method according to claim 2, characterized in that The focusing on the first object according to the first focusing information includes: The first object is focused according to the first focusing information and a moving direction of the first object relative to the electronic device.
4. The method according to any one of claims 1 to 3, characterized in that: When the movement speed of the first object relative to the electronic device is greater than a first threshold, the first number is less than a preset number, and the preset number is the number of preview stream image frames determined from the multiple preview stream image frames for determining focus information when the first object is in a stationary state.
5. The method according to any one of claims 1 to 3, characterized in that: When the movement speed of the first object relative to the electronic device is less than or equal to a first threshold, the first number is greater than or equal to a preset number, and the preset number is the number of preview stream image frames determined from the multiple preview stream image frames for determining focus information when the first object is in a stationary state.
6. The method according to claim 3, characterized in that The electronic device includes a camera, and focusing on the first object according to the first focusing information and a movement direction of the first object relative to the electronic device includes: When the movement direction of the camera controlled according to the first focus information is consistent with the movement direction of the first object relative to the electronic device, the camera is controlled to move to a first position corresponding to the first focus information to focus on the first object.
7. The method according to claim 3, characterized in that The electronic device includes a camera, and focusing on the first object according to the first focusing information and a movement direction of the first object relative to the electronic device includes: When the movement direction of the camera controlled according to the first focus information is inconsistent with the movement direction of the first object relative to the electronic device, the position of the camera focusing on the first object is controlled to remain unchanged.
8. The method according to any one of claims 1 to 3, characterized in that: The electronic device further includes a time-of-flight (TOF) sensor, and obtaining the movement speed of the first object relative to the electronic device includes: Acquire a first distance between the first object and the electronic device by using the TOF sensor; Obtaining a change value between M adjacent image frames in the plurality of preview stream image frames, wherein M is a positive integer greater than 2; The movement speed of the first object relative to the electronic device is determined according to the change value and a threshold corresponding to the first distance.
9. The method according to claim 8, characterized in that The determining the movement speed of the first object relative to the electronic device according to the change value and a threshold value corresponding to the first distance includes: If the change value is greater than a threshold value corresponding to the first distance, determining that a movement speed of the first object relative to the electronic device is greater than a first threshold value; If the change value is less than or equal to a threshold value corresponding to the first distance, it is determined that the movement speed of the first object relative to the electronic device is less than or equal to the first threshold value.
10. The method according to any one of claims 2, 3, 6 or 7, characterized in that: The obtaining the movement direction of the first object relative to the electronic device includes: Acquire depth data corresponding to each of the plurality of preview stream image frames; If the depth data gradually decreases according to the acquisition time of the preview stream image frame corresponding to the depth data, the first object moves toward the electronic device; if the depth data gradually increases according to the acquisition time of the preview stream image frame corresponding to the depth data, the first object moves away from the electronic device.
11. The method according to claim 1, characterized in that: The determining the first focus information according to the first number of preview stream image frames includes: The first focus information is determined according to an average value of the focus data of the first number of preview stream image frames.
12. An electronic device, characterized in that: The method comprises one or more processors and one or more memories; wherein the one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program codes, wherein the computer program codes include computer instructions, and when the one or more processors execute the computer instructions, the method as described in any one of claims 1 to 11 is executed.
13. A chip system, the chip system is applied to electronic equipment, the chip system comprises one or more processors, characterized in that: The processor is configured to call computer instructions so as to execute the method according to any one of claims 1 to 11.
14. A computer-readable storage medium comprising instructions, characterized in that: When the instruction is executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 11.
