Image processing method and related device

By processing preview frames at the application framework layer and caching preview frames used to generate dynamic photos, the problem of poor picture quality of dynamic photos is solved, user experience is improved, and electronic device performance is optimized.

CN118540576AActive Publication Date: 2024-08-23HONOR DEVICE CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411001176.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-25
Publication Date
2024-08-23
Estimated Expiration
2044-07-25

AI Technical Summary

Technical Problem

In the existing technology, the picture quality of dynamic photos is poor, which affects the user experience.

Method used

In the preview process of the application frame layer, the preview frame is processed through the image optimization algorithm and cached as a preview frame for generating dynamic photos. The camera application can generate dynamic photos based on the processed preview frames.

Benefits of technology

It improves the quality of dynamic photos, improves user experience, avoids the need for hardware abstraction layers to increase computing power, and reduces the performance consumption of electronic devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118540576A
    Figure CN118540576A
Patent Text Reader

Abstract

The embodiment of the invention provides an image processing method and a related device, and relates to the technical field of terminals. The method comprises the following steps: in a preview process of an application program framework layer, after a preview frame used for image preview is processed by an image optimization algorithm, the preview frame can be additionally cached as a preview frame used for generating a dynamic photo; a camera application may generate a dynamic photo based on a preview frame cached in an application framework for generating the dynamic photo. Therefore, the camera application can generate the dynamic photo based on the preview frame processed by the image optimization algorithm, so that the quality of the generated dynamic photo is improved, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminal technology, and in particular to an image processing method and related devices. Background Art

[0002] Some applications in electronic devices can provide dynamic photo functions, such as camera applications. The dynamic photo function can capture the images within a period of time before and after the image is taken, so that the generated image is not only static, but can show some dynamic effects. In this way, some wonderful moments that are difficult to capture with a single static photo can be captured.

[0003] However, the image quality of dynamic photos generated by some applications is poor, which affects the user experience. Summary of the invention

[0004] In the image processing method and related device provided by the embodiment of the present application, in the preview process of the application framework layer, after the preview frame used for image preview is processed by the image optimization algorithm, the preview frame can be cached as a preview frame for generating dynamic photos, and the camera application can generate dynamic photos based on the preview frame for generating dynamic photos cached in the application framework. In this way, the camera application can generate dynamic photos based on the preview frame processed by the image optimization algorithm, thereby improving the quality of the generated dynamic photos and enhancing the user experience.

[0005] In a first aspect, an embodiment of the present application provides an image processing method, which is applied to an electronic device, and the method includes: In response to a first operation that triggers opening of a target application, image processing is performed on the captured image in the first data stream to obtain first image data, and the first image data is used for image preview; in response to a second operation that triggers taking a photo, image processing is performed on the target image in the second data stream to obtain second image data; wherein the target image is an image at a time corresponding to the second operation in the first data stream, and the second image data includes an image obtained by triggering the second operation; and a dynamic photo is generated based on the first image data and the second image data. In this way, in the first data stream, using the preview frame processed by the image optimization algorithm to generate a dynamic photo can improve the quality of the generated dynamic photo and enhance the user experience.

[0006] In one possible implementation, the first data stream and the second data stream are both set at the application framework layer, and the method further includes: saving the first image data to a preset cache based on the first data stream; generating a dynamic photo based on the first image data and the second image data, including: obtaining the first image data from the preset cache based on the target application, and generating the dynamic photo based on the first image data and the second image data. In this way, the first data stream and the second data stream are both set at the application framework layer, and in the first data stream, after the preview frame used for image preview is processed by the image optimization algorithm, the preview frame can be cached as a preview frame for generating a dynamic photo, and the target application can generate a dynamic photo based on the cached preview frame for generating a dynamic photo. In this way, the target application can generate a dynamic photo based on the preview frame processed by the image optimization algorithm, thereby improving the quality of the generated dynamic photo.

[0007] In a possible implementation, before obtaining the first image data in the preset cache, it also includes: establishing an Android interface definition language AIDL communication connection based on the target application and the application framework layer; obtaining the first image data from the preset cache based on the target application, and generating a dynamic photo based on the first image data and the second image data, including: obtaining the first image data from the preset cache based on the target application, and synthesizing a video file based on the first image data and the collected audio data; generating a dynamic photo based on the video file and the second image data. In this way, by synthesizing a video file based on the first image data and the collected audio data, the audio data and the image data can be time-aligned by the timestamp, so that the audio data stream and the video data stream are kept synchronized during playback or processing. The dynamic photo generated based on the video file and the second image data can capture the picture within a period of time before and after the image is taken, so that the generated image is not only static, but can show some dynamic effects, so that some wonderful moments that are difficult to capture with a single static photo can be captured.

[0008] In a possible implementation, before performing image processing on the captured image in the first data stream, the method further includes: based on the target application and the camera service of the application framework layer, passing a first request to the hardware abstraction layer, the first request is used to instruct the hardware abstraction layer to initialize the preview stream; based on the hardware abstraction layer, the preview stream is initialized, and the image captured by the camera is returned to the camera service through the preview stream; based on the camera service, the captured image is passed to the first data stream. In this way, the first request can carry the photographing parameters set by the target application, and based on the first request, the hardware abstraction layer can instruct the camera driver to set the corresponding photographing parameters, thereby obtaining an image that meets the user's requirements.

[0009] In a possible implementation, before the second operation, it also includes: in response to a third operation that triggers turning on the dynamic photo function, based on the target application and the camera service, a second request is transmitted to the hardware abstraction layer, the second request is used to instruct the hardware abstraction layer to reconfigure the preview stream, and the second request includes a first identifier, the first identifier is used to indicate whether the dynamic photo function is turned on; based on the first identifier, it is determined that the hardware abstraction layer does not reconfigure the preview stream. In this way, the value of the scene mode is used to identify whether the dynamic photo function is turned on, which facilitates the determination of the state of the dynamic photo. The hardware abstraction layer can determine which mode or function has changed based on the value of the scene mode, which simplifies the implementation process of the code in the electronic device, improves the readability and flexibility of the code, and can concisely indicate the on and off states of the dynamic photo.

[0010] In a possible implementation, based on the first identifier, determining that the hardware abstraction layer does not reconfigure the preview stream includes: when the first identifier indicates that the dynamic photo function is turned on, and the last time the first identifier recorded by the hardware abstraction layer indicates that the dynamic photo function is turned off, determining that the hardware abstraction layer does not reconfigure the preview stream. In this way, when the dynamic photo function is turned on, the hardware abstraction layer does not reconfigure the preview stream, which can reduce the situation of no preview frames, reduce the interface jamming, and thus improve the user experience.

[0011] In one possible implementation, based on the first identifier, determining that the hardware abstraction layer does not reconfigure the preview stream includes: when the first identifier indicates that the dynamic photo function is turned on, the last first identifier recorded by the hardware abstraction layer indicates that the dynamic photo function is turned off, and when the dynamic photo function is turned on or off, the electronic device supports the hardware abstraction layer not to reconfigure the preview stream, determining that the hardware abstraction layer does not reconfigure the preview stream. In this way, the electronic device may include one or more methods for implementing dynamic photos, and there may be some differences between different implementation methods. For example, the image processing method of the embodiment of the present application is used to implement the dynamic photo function. When the dynamic photo function is turned on, the hardware abstraction layer may not reconfigure the preview stream, thereby reducing the jamming of the interface. Therefore, by judging that the electronic device supports the hardware abstraction layer not to reconfigure the preview stream, the preview stream can be flexibly configured according to different implementation processes, thereby improving the flexibility of code execution.

[0012] In a possible implementation, before determining that the hardware abstraction layer does not reconfigure the preview stream, the method further includes: returning a second identifier to the camera service based on the hardware abstraction layer, the second identifier being used to indicate that the camera service does not trigger the process of reconfiguring the preview stream. In this way, the second identifier is used to indicate that the camera service does not trigger the process of reconfiguring the preview stream, which simplifies the implementation process of the code in the electronic device, improves the readability and flexibility of the code, and thus the corresponding execution process can be concisely represented by the field identifier.

[0013] In a possible implementation, the method further includes: in response to a fourth operation that triggers the closing of the dynamic photo function, based on the target application and the camera service, transmitting a third request to the hardware abstraction layer, the third request is used to instruct the hardware abstraction layer to reconfigure the preview stream, and the third request includes a first identifier; when the first identifier indicates that the dynamic photo function is closed, and the last time the first identifier recorded by the hardware abstraction layer indicates that the dynamic photo function is opened, determining that the hardware abstraction layer does not reconfigure the preview stream. In this way, when the dynamic photo function is closed, the hardware abstraction layer does not reconfigure the preview stream, which can reduce the situation of no preview frames, reduce the freeze of the interface, and thus improve the user experience.

[0014] In a possible implementation, when the first identifier indicates that the dynamic photo function is turned off, and the last first identifier recorded by the hardware abstraction layer indicates that the dynamic photo function is turned on, it is determined that the hardware abstraction layer does not reconfigure the preview stream, and it also includes: when the first identifier indicates that the dynamic photo function is turned off, the last first identifier recorded by the hardware abstraction layer indicates that the dynamic photo function is turned on, and when the dynamic photo function is turned on or off, the electronic device supports the hardware abstraction layer not to reconfigure the preview stream, it is determined that the hardware abstraction layer does not reconfigure the preview stream. In this way, the electronic device may include one or more ways to implement dynamic photos, and there will be some differences between different implementation methods. For example, the image processing method of the embodiment of the present application is used to implement the dynamic photo function. When the dynamic photo function is turned off, the hardware abstraction layer may not reconfigure the preview stream, thereby reducing the interface jams. Therefore, by judging that the electronic device supports the hardware abstraction layer not to reconfigure the preview stream, the preview stream can be flexibly configured according to different implementation processes, thereby improving the flexibility of code execution.

[0015] In a second aspect, an embodiment of the present application provides an image processing device, which may be an electronic device, or a chip or chip system in an electronic device. The device may include a processing unit. The processing unit is used to implement any method related to processing performed by the electronic device in the first aspect or any possible implementation of the first aspect. When the device is an electronic device, the processing unit may be a processor. The device may also include a storage unit, which may be a memory. The storage unit is used to store instructions, and the processing unit executes the instructions stored in the storage unit so that the electronic device implements a method described in the first aspect or any possible implementation of the first aspect. When the device is a chip or chip system in an electronic device, the processing unit may be a processor. The processing unit executes the instructions stored in the storage unit so that the electronic device implements a method described in the first aspect or any possible implementation of the first aspect. The storage unit may be a storage unit in the chip (for example, a register, a cache, etc.), or a storage unit in the electronic device located outside the chip (for example, a read-only memory, a random access memory, etc.).

[0016] Exemplarily, the processing unit is used to perform image processing on the captured image in the first data stream to obtain first image data; it is also used to perform image processing on the target image in the second data stream to obtain second image data; it is also used to generate a dynamic photo based on the first image data and the second image data.

[0017] In one possible implementation, the processing unit is also used to save the first image data to a preset cache based on the first data stream; specifically, it is also used to obtain the first image data from the preset cache based on the target application, and generate a dynamic photo based on the first image data and the second image data.

[0018] In one possible implementation, the processing unit is also used to establish an Android interface definition language AIDL communication connection based on the target application and the application framework layer; specifically, it is also used to obtain first image data from a preset cache based on the target application, and synthesize a video file based on the first image data and the collected audio data; and generate a dynamic photo based on the video file and the second image data.

[0019] In one possible implementation, the processing unit is further used to transmit a first request to the hardware abstraction layer based on the camera service of the target application and the application framework layer, wherein the first request is used to instruct the hardware abstraction layer to initialize the preview stream; it is also used to initialize the preview stream based on the hardware abstraction layer, and return the image captured by the camera to the camera service through the preview stream; it is also used to pass the captured image to the first data stream based on the camera service.

[0020] In a possible implementation, the processing unit is further configured to transmit a second request to the hardware abstraction layer based on the target application and the camera service; and is further configured to determine, based on the first identifier, that the hardware abstraction layer does not reconfigure the preview stream.

[0021] In a possible implementation, the processing unit is further used to determine that the hardware abstraction layer does not reconfigure the preview stream when the first identifier indicates that the dynamic photo function is turned on and the hardware abstraction layer records that the last time the first identifier indicated that the dynamic photo function was turned off.

[0022] In one possible implementation, the processing unit is further used to determine that the hardware abstraction layer does not reconfigure the preview stream when the first identifier indicates that the dynamic photo function is turned on, the last first identifier recorded by the hardware abstraction layer indicates that the dynamic photo function is turned off, and when the dynamic photo function is turned on or off, the electronic device supports the hardware abstraction layer not reconfiguring the preview stream.

[0023] In a possible implementation, the processing unit is further configured to return a second identifier to the camera service based on the hardware abstraction layer.

[0024] In one possible implementation, the processing unit is further used to pass a third request to the hardware abstraction layer based on the target application and the camera service, and is further used to determine that the hardware abstraction layer does not reconfigure the preview stream when the first identifier indicates that the dynamic photo function is turned off and the last time the first identifier recorded by the hardware abstraction layer indicated that the dynamic photo function is turned on.

[0025] In one possible implementation, the processing unit is further used to determine that the hardware abstraction layer does not reconfigure the preview stream when the first identifier indicates that the dynamic photo function is turned off, the hardware abstraction layer records the last time that the first identifier indicates that the dynamic photo function is turned on, and when the dynamic photo function is turned on or off, the electronic device supports the hardware abstraction layer not reconfiguring the preview stream.

[0026] In a third aspect, an embodiment of the present application provides an electronic device, comprising one or more processors and a memory, wherein 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 are used to call computer instructions to execute the method described in the first aspect or any possible implementation of the first aspect.

[0027] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program or instructions are stored. When the computer program or instructions are run on a computer, the computer executes the method described in the first aspect or any possible implementation of the first aspect.

[0028] In a fifth aspect, an embodiment of the present application provides a computer program product including a computer program. When the computer program runs on a computer, the computer executes the method described in the first aspect or any possible implementation manner of the first aspect.

[0029] In a sixth 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 by a line, and the at least one processor is used to run a computer program or instruction to execute the method described in the first aspect or any possible implementation of the first aspect. The communication interface in the chip can be an input / output interface, a pin or a circuit, etc.

[0030] In a possible implementation, the chip or chip system described above in 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 (such as a read-only memory, a random access memory, etc.).

[0031] It should be understood that the second to sixth aspects of the present application correspond to the technical solutions of the first aspect of the present application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation methods are similar and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 A schematic diagram of a camera preview interface provided in an embodiment of the present application; Figure 2 More schematic diagrams of interfaces of a camera provided in an embodiment of the present application; Figure 3 A schematic diagram of implementing a dynamic photo function provided in an embodiment of the present application; Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application; Figure 5 A schematic diagram of the software structure of an electronic device provided in an embodiment of the present application; Figure 6 A schematic diagram of module interaction of a dynamic photo function provided in an embodiment of the present application; Figure 7 A schematic diagram of an execution flow of a dynamic photo function provided in an embodiment of the present application; Figure 8 A timing diagram of module calls when a dynamic photo function is turned on provided in an embodiment of the present application; Fig. 9 A timing diagram of module calls when a dynamic photo function is turned off provided in an embodiment of the present application; Fig.10 A timing diagram of module calls when another dynamic photo function is turned on provided in an embodiment of the present application; Fig.11 Another timing diagram of module calls when the dynamic photo function is turned off provided in an embodiment of the present application; Fig.12 A schematic diagram of an image processing method provided in an embodiment of the present application; Fig.13 A schematic diagram of the structure of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION

[0033] In order to clearly describe the technical solutions of the embodiments of the present application, some terms and technologies involved in the embodiments of the present application are briefly introduced below: In the embodiments of the present application, words such as "first" and "second" are used to distinguish the same or similar items with substantially the same functions and effects. For example, the first chip and the second chip are only used to distinguish different chips, and their order is not limited. Those skilled in the art can understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit them to be different.

[0034] It should be noted that in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0035] In the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: the existence of A alone, the existence of A and B at the same time, and the existence of B alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, a--c, bc, or abc, where a, b, and c can be single or multiple.

[0036] Some applications in electronic devices can provide functions such as preview, photo taking, and video recording. Taking the camera application as an example, a user can take photos or videos through the camera application.

[0037] For example, Figure 1 The photo preview interface 100 of the camera application is shown, and the user can preview the image and take photos or videos on the interface 100. In some scenarios, the photo preview interface 100 may also be called a preview interface or a shooting interface. The photo preview interface 100 may include a toolbar 101, a preview window 102, a camera mode option 103, an album shortcut control 104, a shooting control 105, and a camera flip control 106.

[0038] The toolbar 101 may be used to display one or more functional controls, which may include a flash control, a dynamic photo control 107 , a short video control, and a setting control, etc. It is understandable that the toolbar 101 may also include more or fewer functional controls.

[0039] The preview window 102 can be used to obtain the image for shooting preview and display the preview image in real time. In some scenes, the preview window 102 can also be called a viewfinder.

[0040] The camera mode option 103 may be used to display one or more shooting mode options. The one or more shooting mode options may include: a night scene mode option, a portrait mode option, a photo mode option, a video mode option, and more options 108. It is understandable that the camera mode option 103 may also include more or fewer shooting mode options.

[0041] The album quick control 104 can display thumbnails of the captured images or videos. In addition, in response to the user triggering the operation of the album quick control 104, the electronic device can start the album application and display the captured images and videos. It is understood that the user operation mentioned in the embodiment of the present application may include but is not limited to touch (for example, click, etc.), voice control, gesture and other operations, and the embodiment of the present application is not limited thereto.

[0042] The shooting control 105 can be used to control the electronic device to shoot. The camera flip control 106 can be used to switch the camera, thereby controlling the electronic device to use the front camera or the rear camera to shoot an image.

[0043] It is understandable that the photo preview interface 100 is only a schematic interface, and the actual interface may include more or less content and controls; the icon of the dynamic photo control 107 can also be set to other styles, which is not limited in the embodiment of the present application.

[0044] When the user is previewing or taking pictures, he can choose to turn on the dynamic photo function. The dynamic photo function can capture the picture within a period of time before and after the image is taken, so that the generated image is not only static, but can show some dynamic effects. In this way, some wonderful moments that are difficult to capture with a single static photo can be captured. For example, the dynamic photo function can save the captured image and the video of 1.5 seconds before and after the shooting moment, a total of 3 seconds of video, into a file to generate a dynamic photo. Among them, 1.5 seconds is only an exemplary value, and the specific length of the video before and after the shooting moment is not limited in the embodiments of the present application. The images described in the embodiments of the present application can also be understood as pictures or photos.

[0045] Exemplarily, the user may trigger the operation of the dynamic photo control 107 in the photo preview interface 100 , and in response to the triggering operation, the camera application may turn on the dynamic photo function.

[0046] Alternatively, the user may trigger the operation of more options 108 in the photo preview interface 100, and in response to the trigger operation, such as Figure 2 As shown, the camera application can display more interfaces 200, and the more interfaces 200 can include a dynamic photo control 201. The user can trigger the operation of the dynamic photo control 201, and in response to the triggering operation, the camera application can turn on the dynamic photo function.

[0047] It is understandable that the above are two ways to open the dynamic photo function, and the camera application may also include other ways to open the dynamic photo function. Exemplarily, in the photo preview interface 100, the dynamic photo control 107 may be located at other positions of the interface 100, for example, it may be located in the camera mode option 103, or at any possible position in the interface 100, which is not limited in the embodiment of the present application.

[0048] In some implementations, such as Figure 3 As shown, electronic devices can use Figure 3 The architecture shown is used to implement the dynamic photo function.

[0049] When the dynamic photo function is turned on, the hardware abstraction layer of the electronic device can start the dynamic photo path during the configuration of the preview stream. The preview stream can be used to process and cache preview frames for image preview, and the dynamic photo path can be used to process and cache preview frames for generating dynamic photos.

[0050] It is understandable that the preview frames cached in the preview stream and the preview frames cached in the dynamic photo path can be image frames in different caches, and the resolution of the preview frames cached in the preview stream and the resolution of the preview frames cached in the dynamic photo path can be the same or different. After the camera application obtains the preview frames cached in the preview stream, it can display them in the preview window, for example, Figure 1 The preview window 102 is displayed. After the camera application obtains the preview frame cached by the dynamic photo channel, it can be used to generate a dynamic photo.

[0051] For example, after acquiring the image frame captured by the camera, the hardware abstraction layer can pass the captured image frame to the dynamic photo path as a preview frame corresponding to the dynamic photo; the hardware abstraction layer can also pass the image at the time of shooting to the photo algorithm path. In some implementations, the photo algorithm path can also be called a photo algorithm link.

[0052] In the dynamic photo pipeline, the image front end (IFE) module can pre-process the preview frame, such as color correction, downsampling, and statistical 3A (auto exposure, auto focus, and auto white balance) data, and pass the pre-processed preview frame to the image processing engine (IPE). The image processing engine can perform image processing such as cropping, noise reduction, and detail enhancement on the preview frame.

[0053] After the image processing engine performs image processing, on the one hand, the image processing engine can cache the preview frame of the dynamic photo and return the preview frame to the camera application, or the camera application obtains the preview frame from the cache. On the other hand, the image processing engine can also pass the preview frame of the dynamic photo to the scene semantic detection module to perform scene semantic detection and return the detection result to the camera application. The camera application can add attributes such as tags to the dynamic photo based on the detection result to facilitate user viewing.

[0054] The camera algorithm path can perform image processing such as cropping, noise reduction, and detail enhancement on the image to generate an image of the shooting moment that can be used for display and storage, and return the image to the camera application. In some scenarios, the image of the shooting moment generated by the camera algorithm path can be called a large image.

[0055] Furthermore, the camera application can generate a dynamic photo based on the preview frame and the large image of the dynamic photo.

[0056] However, in some scenarios, it is necessary to perform image optimization algorithm processing on the preview frame and large image of dynamic photos. For example, image optimization algorithm processing includes image beauty algorithm, filter algorithm and other processing, and electronic devices usually perform these image optimization algorithm processing in the application framework layer. Figure 3 The corresponding architecture is to cache the preview frames of dynamic photos in the hardware abstraction layer and pass the preview frames to the application layer. In this way, the preview frames obtained by the application layer are not processed by the image optimization algorithm, making the quality of the generated dynamic photos relatively poor compared to the quality of the preview images. If the image optimization algorithm is added to the preview frames in the dynamic photo path of the hardware abstraction layer alone, the computing power of the electronic device will be increased and the performance of the electronic device will be reduced.

[0057] In view of this, the image processing method provided by the embodiment of the present application, in the preview process of the application framework layer, after the preview frame used for image preview is processed by the image optimization algorithm, the preview frame can be cached as a preview frame for generating dynamic photos, and the camera application can generate dynamic photos based on the preview frame for generating dynamic photos cached in the application framework. In this way, the camera application can generate dynamic photos based on the preview frame processed by the image optimization algorithm, thereby improving the quality of dynamic photos and enhancing user experience.

[0058] The electronic device of the embodiment of the present application may also be a terminal device in any form. For example, the electronic device may include: a mobile phone, a tablet computer, a PDA, a laptop computer, a mobile internet device (MID), a wearable device, a virtual reality (VR) device, an augmented reality (AR) device, a wireless terminal in industrial control, a wireless terminal in self driving, a wireless terminal in remote medical surgery, a wireless terminal in a smart grid, a wireless terminal in transportation safety, a wireless terminal in a smart city, a wireless terminal in a smart home, a cellular phone, a cordless phone, a session initiation protocol (SIP) phone, a wireless local loop (WLL) station, a personal digital assistant (PDA), a handheld device with wireless communication function, a computing device or other processing device connected to a wireless modem, a vehicle-mounted device, a wearable device, an electronic device in a 5G network or a public land mobile communication network (public land mobile communication network) to be evolved in the future. The electronic devices in the mobile network (PLMN) are not limited to this in the embodiments of the present application.

[0059] As an example but not limitation, in the embodiments of the present application, the electronic device may also be a wearable device. Wearable devices may also be referred to as wearable smart devices, which are a general term for wearable devices that are intelligently designed and developed using wearable technology for daily wear, such as glasses, gloves, watches, clothing, and shoes. A wearable device is a portable device that is worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not only hardware devices, but also powerful functions achieved through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include full-featured, large-sized, and fully or partially independent of smartphones, such as smart watches or smart glasses, as well as devices that only focus on a certain type of application function and need to be used in conjunction with other devices such as smartphones, such as various types of smart bracelets and smart jewelry for vital sign monitoring.

[0060] In addition, in the embodiments of the present application, the electronic device may also be an electronic device in an Internet of Things (IoT) system. IoT is an important part of the future development of information technology. Its main technical feature is to connect objects to the network through communication technology, thereby realizing an intelligent network that interconnects people and machines and things.

[0061] The electronic device in the embodiments of the present application may also be referred to as: user equipment (UE), mobile station (MS), mobile terminal (MT), access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication equipment, user agent or user device, etc.

[0062] In an embodiment of the present application, the electronic device or each network device includes a hardware layer, an operating system layer running on the hardware layer, and an application layer running on the operating system layer. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and a memory (also called main memory). The operating system can be any one or more computer operating systems that implement business processing through processes, such as a Linux operating system, a Unix operating system, an Android operating system, an iOS operating system, or a Windows operating system. The application layer includes applications such as browsers, address books, word processing software, and instant messaging software.

[0063] For example, Figure 4 A schematic structural diagram of an electronic device is shown.

[0064] The electronic device may include a processor 410, an external memory interface 420, an internal memory 421, a universal serial bus (USB) interface 430, a charging management module 440, a power management module 441, a battery 442, an antenna 1, an antenna 2, a mobile communication module 450, a wireless communication module 460, an audio module 470, a speaker 470A, a receiver 470B, a microphone 470C, an earphone interface 470D, a sensor module 480, a button 490, a motor 491, an indicator 492, a camera 493, a display screen 494, and a subscriber identification module (SIM) card interface 495, etc. The sensor module 480 may include a pressure sensor 480A, a gyroscope sensor 480B, an air pressure sensor 480C, a magnetic sensor 480D, an acceleration sensor 480E, a distance sensor 480F, a proximity light sensor 480G, a fingerprint sensor 480H, a temperature sensor 480J, a touch sensor 480K, an ambient light sensor 480L, a bone conduction sensor 480M, etc.

[0065] It is to be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or arrange the components differently. The illustrated components may include hardware, software, or a combination of software and hardware.

[0066] The processor 410 may include one or more processing units, for example, the processor 410 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). Different processing units may be independent devices or integrated into one or more processors. The controller may generate an operation control signal according to the instruction opcode and the timing signal to complete the control of fetching and executing instructions.

[0067] A memory may also be provided in the processor 410 for storing instructions and data. In some embodiments, the memory in the processor 410 is a cache memory. The memory may store instructions or data that the processor 410 has just used or circulated. If the processor 410 needs to use the instruction or data again, it may be directly called from the above-mentioned memory. Repeated access is avoided, and the waiting time of the processor 410 is reduced, thereby improving the efficiency of the system. For example, in an embodiment of the present application, the processor 410 may be used to process a camera application's photo request, and may also be used to process an image using an optimization algorithm, generate dynamic photos, and the like.

[0068] It is understandable that the interface connection relationship between the modules illustrated in the embodiments of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device. In other embodiments of the present application, the electronic device may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0069] The internal memory 421 can be used to store computer executable program codes, and the executable program codes include instructions. The internal memory 421 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, at least one application required for a function, etc. The data storage area may store data created during the use of the electronic device, etc. In addition, the internal memory 421 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 410 executes various functional applications and data processing of the electronic device by running instructions stored in the internal memory 421, and / or instructions stored in a memory provided in the processor. For example, in an embodiment of the present application, the internal memory 421 may be used to store preview frames of dynamic photos and captured images, and may also be used to store relevant codes for implementing dynamic photo functions, etc.

[0070] The electronic device implements the display function through a GPU, a display screen 494, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 494 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 410 may include one or more GPUs that execute program instructions to generate or change display information. The electronic device can implement the shooting function through an ISP, a camera 493, a video codec, a GPU, a display screen 494, and an application processor.

[0071] In some embodiments, the electronic device may include 1 or N cameras 493 , where N is a positive integer greater than 1. The camera 493 may be used to capture still images or videos.

[0072] The display screen 494 is used to display images, videos, etc. The display screen 494 includes a display panel. In some embodiments, the electronic device may include 1 or N display screens 494, where N is a positive integer greater than 1.

[0073] Figure 5 Schematic diagram of the software structure of the electronic device of the embodiment of the present application. The layered architecture divides the software into several layers, each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into five layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime (Android runtime) and the system library, the hardware abstraction layer (hardware adaptation layer, HAL), and the kernel layer.

[0074] The application layer can also be called the application layer, which can include a series of application packages. Figure 5 As shown, the application package may include applications such as camera application, gallery application, phone application, etc. Applications may include system applications and third-party applications.

[0075] In an embodiment of the present application, the camera application may include a camera capture session module (CameraCaptureSession), a camera device module (CameraDevice), and a dynamic photo mode implementation module, etc.

[0076] The camera capture session module can be used to manage and control camera capture sessions, such as creating sessions, setting single capture requests or repeated capture requests, managing the allocation and release of camera resources, etc. Single capture requests can be used for photo taking scenarios, and repeated capture requests can be used for previewing scenarios or video recording scenarios.

[0077] The camera device module of the application layer can provide the application with an interface for starting and stopping camera preview, taking pictures, recording videos, and other functions, so that the parameters passed by the application can be sent to the camera service (CameraService) of the application framework layer. The camera device module can also return the state changes of the camera hardware device, such as opening, closing, and disconnecting, to the application through the callback interface. For example, in the embodiment of the present application, different capture sessions can be managed and controlled through the camera capture session module and the camera device module, including configuring capture requests and processing capture results.

[0078] The dynamic photo mode implementation module can be used to generate dynamic photo files. The dynamic photo mode implementation module can include advanced audio coding (AAC) queue, advanced video coding (AVC) queue, mixing module (muxer), session service host module (ServiceHostGlobalSession), dynamic photo service host module (ServiceHostLivePhoto), etc.

[0079] The AAC queue can be used to cache audio data collected by the electronic device and the corresponding timestamps. The AVC queue can be used to cache image frames and the corresponding timestamps.

[0080] The mixing module can be used to manage and synchronize the audio data stream and the video data stream, so that the audio data stream and the video data stream can be kept synchronized during playback or processing.

[0081] The session service host module can be used to receive the image transmitted by the write module (write) in the post-processing camera algorithm module (ServiceHost), and generate a dynamic photo file based on the image. In the embodiment of the present application, the image transmitted by the write module can also be called a large image, which can be understood as the image generated in the ServiceHost module after the user triggers the photo operation.

[0082] The live photo service host module can be responsible for managing the service logic of live photos, such as storage, processing, and transmission. The live photo service host module can establish an inter-process communication connection with the live photo management proxy module (LivePhotoManagerProxy) of the ServiceHost module based on the Android interface definition language (AIDL) interface, so as to exchange data between the camera application and the hardware algorithm (HwAlgo) side.

[0083] The application framework layer can also be called the Framework layer. The Framework layer can provide application programming interface (API) and programming framework for the application layer applications. The Framework layer can include some predefined functions.

[0084] like Figure 5As shown, the Framework layer may include an activity manager, a window manager, a resource manager, a notification manager, a content provider, a view system, etc. For details, please refer to the description of the relevant technology, which will not be repeated here.

[0085] In the embodiment of the present application, the Framework layer may also include a camera service (CameraService) and a post-processing camera algorithm module (ServiceHost).

[0086] The camera service can be responsible for communicating with the camera hardware on the device. For example, the camera service can interact with the camera through the hardware abstraction layer to implement functions such as opening the camera, closing the camera, and capturing images. The camera service can also provide related interfaces for obtaining camera functions. By calling the camera service interface, the application can control various camera functions, such as starting preview, capturing photos, recording videos, adjusting focus, setting exposure, etc.

[0087] The camera service may include the camera device client module (CameraDeviceClient), the camera device module (Camera3Device), and the camera output stream module (Camera3OutputStream).

[0088] The camera device client module may be used to provide an interface for the camera application to interact with the camera hardware. For example, the camera application may access the functions of the camera through the interface of the camera device client module to capture images.

[0089] The camera device module of the application framework layer can be used to manage and control the specific implementation of the camera hardware. Exemplarily, the camera device module can provide an interface for the camera application to call, thereby realizing the communication between the upper layer application and the hardware abstraction layer. The camera device module can also process image capture requests, such as configuring capture parameters, starting the capture process, and processing the capture results.

[0090] The camera output stream module can be used to manage and process the output of the image frames collected by the camera. For example, the camera output stream can configure and control the parameters of the image frames, such as resolution, format, and frame rate. The camera output stream can also pass the image frames collected by the camera to the data source module (FilterCameraSource) in the ServiceHost module.

[0091] The ServiceHost module may include a preview session (normalSession), a photo session (ppsession), a dynamic photo management proxy module (LivePhotoManagerProxy), and a dynamic photo management module (LivePhotoManager), etc.

[0092] The preview session can be used to handle preview-related processes. For example, the preview session can process each frame of the preview scene in real time and call back the result to the application for display. The preview session can include the data source module (FilterCameraSource), preview algorithm module, forklpp module and preview module (preview).

[0093] Among them, the data source module in the preview session can be used to receive the image frames transmitted by the camera output stream module, and the data source module can also transmit the image frames to the photo data source module (FilterPPSource) of the photo session. The preview algorithm module is used to perform image optimization algorithm processing on the image frames, such as beautification, filter, etc. The diversion module can copy the image frames and pass them to the dynamic photo management module. The preview module can pass the image obtained after the image optimization algorithm is processed to the camera application, so as to display the preview image in the preview window of the camera application.

[0094] The photo session can be used to process the photo-related processes. The photo session can include the photo data source module (Filter PPSource), the image optimization algorithm processing module, the encoding module (Jpeg Encoder) and the writing module (write).

[0095] The photo data source module can be used to receive the image frames transmitted by the data source module of the preview session, and can also transmit the image frames to the image optimization algorithm processing module. The image optimization algorithm processing module can be used to perform image optimization algorithm processing on the image frames, such as beautification, filter, etc.

[0096] The encoding module can be used to convert the format of the image frame, for example, the encoding module can convert the YUV format image to the Jpeg format image. The writing module can be used to write the image to the file path, and can also pass the generated image to the session service host module of the camera application through the callback function for use in generating dynamic photos.

[0097] It is understandable that in some scenarios, the image frames processed in the preview session may also be referred to as preview frames, and the images generated by the preview session may include preview images for display in the camera interface. The image frames processed in the photo session may also be referred to as photo frames, and the images generated by the photo session may include images generated by the photo session, and the images generated by the photo session may also be referred to as large images.

[0098] The dynamic photo management proxy module can be used to interact with the dynamic photo service host module of the camera application, and can also be used to interact with the dynamic photo management module to obtain cached image frames.

[0099] The dynamic photo management module may include a dynamic photo session module (LivePhotoSession), and the dynamic photo session module may include a cycle queue (CycleQueue). The dynamic photo management module is responsible for the creation and destruction of the dynamic photo session module. The dynamic photo management module can also cache the preview frame delivered by the diversion module in the cycle queue through the dynamic photo session module.

[0100] Android runtime includes core libraries and virtual machines. Android runtime is responsible for the control and management of the Android system.

[0101] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.

[0102] The application layer and the framework layer run in a virtual machine. The virtual machine executes the java files of the application layer and the framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection. For example, in the embodiment of the present application, the virtual machine can be used to configure the photo stream or preview stream, and also to create and destroy the path of dynamic photos and other functions.

[0103] The system library can also be called the Native layer, which can include multiple functional modules, such as the media library, function library, and graphics processing library.

[0104] The hardware abstraction layer is an abstract structure between the kernel layer and the Android runtime. The hardware abstraction layer can be a package of the hardware driver, providing a unified interface for the call of the upper layer application. For example, in the embodiment of the present application, the hardware abstraction layer can obtain the image frame captured by the camera, and can also pass the captured image frame to the camera device module of the camera service.

[0105] The kernel layer is the layer between hardware and software. The kernel layer may include camera driver, display driver, audio driver, battery driver, Bluetooth driver, CPU driver, USB driver, etc.

[0106] It should be noted that the embodiments of the present application are only illustrated using the Android system as an example. In other operating systems (such as Windows system, IOS system, etc.), as long as the functions implemented by each functional module are similar to those in the embodiments of the present application, the solutions of the present application can also be implemented.

[0107] The following is a detailed description of the method of the embodiment of the present application through specific embodiments. The following embodiments can be combined with each other or implemented independently, and the same or similar concepts or processes may not be repeated in some embodiments.

[0108] For example, taking a scene of taking a photo with the dynamic photo function turned on, Figure 6 A schematic diagram of module interaction for implementing a dynamic photo function in an embodiment of the present application is shown.

[0109] When the dynamic photo function is turned on, the user can trigger the photo-taking operation, such as Figure 1 In the embodiment, the user may trigger the operation of the shooting control 105. In response to the triggering operation, the camera application may call a pre-processing function (preCapture) to perform a pre-processing process.

[0110] In the preprocessing process, the camera application can create a photo session process, initialize the image name, create a file path for storing images, and determine the photo parameters. The camera application can also create a task process for dynamic photos. Among them, the photo parameters may include exposure value (EV), zoom, parameters corresponding to the dynamic photo function, etc. The preprocessing process can also send a photo request to the camera capture session module. The photo request can carry some or all of the photo parameters, so that the photo parameters can be passed to the camera capture session module.

[0111] The camera capture session module can pass the photo request to the camera device module. The camera device module can send a request list submitRequestList to the camera device client module of the camera service. The request list can include the parameters for turning on or off dynamic photos, and can also include photo parameters such as exposure time, white balance, and focal length.

[0112] The camera device client module can pass a capture request (process_capture_request) to the hardware abstraction layer based on the camera device module. After obtaining the image frame captured by the camera, the hardware abstraction layer can return the result (process_capture_result) to the camera device module of the camera service. The returned result can include the captured image frame, and the camera device module can return the result to the camera output stream module.

[0113] It is understandable that during the camera shooting process, the preview image still needs to be displayed in the preview window of the camera application, and the preview process has not stopped, that is, the photo stream for taking pictures and the preview stream for previewing are executed in parallel. Among them, the preview stream is established when the preview is started, and the life cycle is the entire preview process. The photo stream is created once for each photo, and when the photo is finished, the photo stream will be destroyed. Therefore, the camera output stream module can obtain both the preview frame for image preview and the image at the time of shooting, and pass the preview frame and the image at the time of shooting to the ServiceHost module.

[0114] On the one hand, the ServiceHost module can process the preview frame through the preview stream and return it to the camera application for displaying the preview interface. On the other hand, the ServiceHost module can process the image at the shooting moment through the photo stream and return it to the camera application for saving and display.

[0115] Corresponding to the first aspect, the data source module of the preview session can receive the preview frame transmitted by the camera output stream module, and pass the preview frame to the preview algorithm module. The preview algorithm module can perform image optimization algorithm processing on the preview frame, such as beautifying and filtering the preview frame, and pass the processed preview frame to the diversion module. The diversion module can pass the preview frame to the preview module, and the preview module can pass the image obtained after the image optimization algorithm processing to the camera application, so as to display the preview image in the preview window of the camera application.

[0116] It is understandable that when the dynamic photo function is turned on, the shunt module can also pass the preview frame to the circular queue in the dynamic photo management module for caching, so as to be used for the generation of dynamic photos. Optionally, the shunt module can also pass the preview frame to other storage controls in the dynamic photo management module for caching, which is not limited in the embodiment of the present application.

[0117] Corresponding to the second aspect, the data source module of the preview session can also receive the image of the shooting moment transmitted by the camera output stream module, and transmit the image to the photo data source module of the photo session. The photo data source module can transmit the image to the image optimization algorithm processing module, and the image optimization algorithm processing module can perform image optimization algorithm processing, such as beautifying and filtering the image, and transmit the processed image to the encoding module.

[0118] Optionally, the image optimization algorithm processing module and the preview algorithm module in the preview session may execute the same image processing process, so that the display effect of the image seen by the user in the preview window and the image generated by taking a photo can be kept consistent.

[0119] The encoding module can convert the image format, for example, convert the YUV format image to the Jpeg format image, and pass the converted image to the writing module. The writing module can write the image to the file path, so that the user can view the captured image through the gallery, album, or the camera's album shortcut control. The writing module can also pass the generated image to the session service host module of the camera application through the callback function for use in generating dynamic photos.

[0120] When the dynamic photo function is turned on, the dynamic photo service host-side module of the camera application can establish an AIDL interface communication connection with the dynamic photo management proxy module of the ServiceHost module, and request to obtain the image frames used to generate dynamic photos. The dynamic photo management proxy module can initialize the relevant parameters of the image cache surface, which can be used to cache image frames before and after the photo is taken, so as to generate dynamic photos. The dynamic photo management proxy module can pass the request to obtain image frames to the dynamic photo management module, and the dynamic photo management module can obtain image frames from the circular queue based on the dynamic photo session module and return them to the dynamic photo management proxy module. The dynamic photo management proxy module can cache the image frames in the image cache surface, and the dynamic photo management proxy module can also return the image frames in the image cache surface to the dynamic photo service host-side module of the camera application.

[0121] In a possible implementation, since dynamic photos require 1.5 seconds of video before and after the shooting time, the image cache surface can cache image frames 1.5 seconds or longer before the current moment, which can also be understood as image frames 1.5 seconds or longer before the shooting time to generate 1.5 seconds of video before the shooting time. As time goes by, the image cache surface can cache image frames 1.5 seconds or longer after the shooting time to generate 1.5 seconds of video after the shooting time.

[0122] After the dynamic photo service host module obtains the image frame, it can be passed to the AVC queue. In this way, the mixing module can generate a video file based on the audio data cached by the AAC queue and the image data cached by the AVC queue, as well as information such as timestamps, and the video file may include a video file in mp4 format. It is understandable that the mixing module can time-align the audio data and the image data through the timestamp so that the image and audio are matched in the generated video file.

[0123] Furthermore, the dynamic photo mode implementation module can obtain the video file generated by the mixing module and the captured image obtained in the session service host module, and synthesize the captured image and the video file to generate a dynamic photo file.

[0124] Figure 7 A schematic diagram of the execution flow of realizing the dynamic photo function in an embodiment of the present application is shown.

[0125] The execution process involves the application process side, the service host side, and the hardware algorithm side. The application process side may include the process of the camera application and the process corresponding to the dynamic photo service host module (ServiceHostLivePhoto.java); the service host side may include the process corresponding to the dynamic photo management proxy module (LivephotoManagerProxy.cpp); the hardware algorithm side may include the process corresponding to the dynamic photo management module (LivephotoManager.cpp).

[0126] For ease of description, the following uses the names of each module as an example to introduce the interaction process between modules, omitting the description of the process, but in the actual execution process, each module can be executed in a process. It is understandable that the process mentioned in the embodiments of the present application can also be a thread in some implementations without limitation.

[0127] The specific execution process may include the following processes: (1) the process of opening dynamic photos, (2) the process of applying to request each frame, (3) the process of applying to obtain semantic detection tags, and (4) the process of closing dynamic photos.

[0128] (1) The process of opening dynamic photos.

[0129] In response to a photo-taking operation triggered by the user, the camera application can call the dynamic photo service host-side module to set the dynamic photo callback function setProcLivePhotoCallback(surface, framenumber, mProcLivePhotoCallback), and the parameters passed by the callback function include: image cache surface, frame number framenumber, and dynamic photo callback object mProcLivePhotoCallback. The dynamic photo service host-side module can call the dynamic photo management agent module to set the image cache function setSurfaceForCycle(surface, bufferNum), and the parameters passed by the function include: image cache surface and frame number bufferNum.

[0130] The image buffer surface can be used to store image frames, and the frame number framenumber can be used to set the size of the surface. It can be understood that both framenumber and bufferNum can represent the number of frames, and framenumber and bufferNum can be understood as parameters used in different functions. That is, through calls between modules, the value of the parameter framenumber in the function setProcLivePhotoCallback(surface, framenumber, mProcLivePhotoCallback) can be passed to the parameter bufferNum in the function setSurfaceForCycle(surface, bufferNum).

[0131] The dynamic photo management proxy module can initialize the relevant parameters of the image cache surface, and can also call the dynamic photo management module's initialization dynamic photo parameter function initLivePhotoParameter(cameraId). The input parameter cameraId passed by this function can represent the camera ID. Different cameraId values ​​can represent different cameras. For example, the camera can include a front camera and a rear camera.

[0132] The dynamic photo management module can further initialize the dynamic photo session module (LivephotoSession.cpp) and the circular queue.

[0133] After the dynamic photo initialization is completed, the dynamic photo management module can call the dynamic photo initialization function onLivePhotoInit(livePhotoImageBufferInfo) to return the dynamic photo initialization result to the dynamic photo management proxy module. The parameter livePhotoImageBufferInfo passed by this function can include information such as the format usage of the image cache surface. The dynamic photo management proxy module can set the usage format of the image cache surface, and can also call the function postLivePhotoInitResult() to set the dynamic photo initialization result, and return the dynamic photo initialization result to the dynamic photo service host module.

[0134] The dynamic photo service host-side module can call the dynamic photo initialization completion callback function onLivePhotoInitComplete(res==0) ​​of the dynamic photo callback object mProcLivePhotoCallback, and then return the initialization result of the dynamic photo to the camera application. Among them, res==0 can indicate that the returned result is true, that is, the dynamic photo initialization is successful. It can be understood that in some abnormal circumstances, the result of the dynamic photo initialization completion function returned by the dynamic photo service host-side module can be false, that is, onLivePhotoInitComplete(false).

[0135] In addition, the camera application can also call the setLivePhotoTagCallback() callback function of the dynamic photo service host module, which can be used to execute the relevant process of determining the category of the dynamic photo. The categories of dynamic photos can include people, animals, scenery, etc. In this callback function, a tag callback object mLivePhotoTagCallback can be created.

[0136] It is understandable that there is no distinction in the order of execution between setting the dynamic photo tag callback function and returning the dynamic photo initialization result. The camera application may also call the dynamic photo tag callback function before returning the dynamic photo initialization result. This is not limited to the embodiments of the present application.

[0137] (2) The process of applying each frame request.

[0138] The camera application may call the getNextFrameBuffer() function of the dynamic photo service host module to obtain the next frame buffer. The dynamic photo service host module may further call the getNextFrameBuffer() function of the dynamic photo management agent module to obtain the next frame buffer.

[0139] The dynamic photo management proxy module can obtain the cache buffer for storing dynamic photos from the image cache surface. For example, the dynamic photo management proxy module can execute anw->dequeueBuffer to obtain the cache buffer from the image cache surface. The dynamic photo management proxy module can also call the dynamic photo request function processLivePhotoRequest() of the dynamic photo management module and pass the buffer to the dynamic photo management module to instruct the dynamic photo management module to put the obtained image frame into the cache buffer.

[0140] The dynamic photo management module can obtain image frames from the circular queue and store them in the cache buffer. The dynamic photo management module can also call the dynamic photo acquisition completion function onLivePhotoCompleted(livePhotoResult) to pass the acquired image frames to the dynamic photo management proxy module, where the parameter livePhotoResult can include the cache buffer.

[0141] The dynamic photo management proxy module can return the image frame to the image cache surface through the cache buffer. For example, the dynamic photo management proxy module can execute anw->queueBuffer to put the image frame into the image cache surface. The dynamic photo management proxy module can also call the postLivePhotoProcData() function to set the dynamic photo data. The parameters passed in this function may include the timestamp of the image frame, the frame number of the image frame, and other information, and pass these parameter information to the dynamic photo service host module. Among them, the frame number of the image frame can be used to mark the position of the cover in the video, so that it can be used for later video editing.

[0142] The live photo service host module can encapsulate information such as the timestamp and number of image frames into a Bundle container, and call the live photo callback function onLivePhotoPictureCallback(bundle) of the live photo callback object mProcLivePhotoCallback, and return the data in the Bundle container to the camera application through the parameter bundle. The Bundle container can be understood as a container containing key-value pairs for storing data information.

[0143] (3) Apply the process of obtaining semantic detection labels.

[0144] The camera application can call the getLivePhotoTag(Bundle tagBundle) function of the dynamic photo service host module. The dynamic photo service host module can parse the parameter tagBundle to obtain the name id, start time starttime, end time endtime, timestamp capturetime and other information of the dynamic photo, and call the getLivePhotoTag() function to pass these parameters to the dynamic photo management agent module. The dynamic photo management agent module can call the processLivePhotoGetTag() function to pass these parameters to the dynamic photo management module.

[0145] After obtaining the tag of the dynamic photo, the dynamic photo management module can call the dynamic photo tag result function onLivePhotoAlgoTagResult() to return the result to the dynamic photo management agent module. The dynamic photo management agent module can call the dynamic photo tag setting function postLivePhotoTagData(), the parameters passed in this function may include the tag state, the name id of the dynamic photo, the tag Tag of the dynamic photo, and other information, and pass these parameter information to the dynamic photo service host module.

[0146] It is understandable that when performing tag detection, there may be a situation where the detection fails and the tag detection is invalid. The tag state can indicate whether the detected tag is valid. For example, state 1 can indicate that the detected tag is valid, and state 0 can indicate that the detected tag is invalid. The specific value of the specific tag state is not limited in the embodiment of the application.

[0147] The dynamic photo service host module can encapsulate the dynamic photo state, dynamic photo name id, dynamic photo tag and other information into a Bundle container, and call the dynamic photo tag callback function onTagResult (bundle) of the tag callback object mLivePhotoTagCallback, and return the data in the Bundle container to the camera application through the parameter bundle.

[0148] (4) Turn off the process of dynamic photos.

[0149] The camera application can call the dynamic photo service host-side module's dynamic photo closing function flushLivePhoto(), the dynamic photo service host-side module can further call the dynamic photo management agent module's dynamic photo closing function flushLivePhoto(), the dynamic photo management agent module can call the dynamic photo management module's dynamic photo session closing function flushLivePhotoSession().

[0150] After the dynamic photo management module completes the process of closing the dynamic photo session, the dynamic photo closing function onLivePhotoFlush(res) can be called to return the execution result to the dynamic photo management proxy module.

[0151] In some scenarios, when the user triggers the operation of turning on or off the dynamic photo function, the interface may become stuck.

[0152] This is because after the camera application enters the preview interface, it will instruct the electronic device to create a preview stream in the hardware abstraction layer. Similarly, after the user triggers the photo operation, the camera application will instruct the electronic device to create a photo stream in the hardware abstraction layer. When the user triggers to turn on or off the dynamic photo function, the camera application determines that the turning on or off of the dynamic photo function causes the parameters of the image collected by the camera to change, so the camera application will instruct the electronic device to reconfigure the preview stream or photo stream in the hardware abstraction layer. Reconfiguring the preview stream may take hundreds of milliseconds, during which time no frames will be previewed, causing the interface to freeze.

[0153] Figure 8 It shows the calling sequence diagram of related modules when the dynamic photo function is turned on.

[0154] When the user turns on the dynamic photo function, the camera application can update the status of the dynamic photo switch and send a repeat request function setRepeatingRequest() to the camera service.

[0155] There is a loop thread (threadLoop) in the camera device module (Camera3Device) of the camera service to process the request. In the loop thread, when an application sends a new repeated request, the loop thread will execute the updateSessionParams() function to update the session parameters (session) carried in the request. In some scenarios, the session parameters (session) can also be called the session key (sessionkey).

[0156] In a possible implementation, in the loop thread, the session key (sessionkey) in the request will be compared with the previous session key (sessionkey). If the key-value pair in (sessionkey) changes, it means that the scene mode has changed and the stream needs to be reconfigured. The loop thread will call the hardware abstraction layer's reconfiguration request function isReconfigurationRequired(), and the hardware abstraction layer can determine whether the stream needs to be reconfigured.

[0157] It is understandable that in different modes or different functions of the camera application, the electronic device can set different scene mode values, and use the scene mode value to identify whether the dynamic photo function is turned on, so as to facilitate the judgment of the status of the dynamic photo. In this way, the hardware abstraction layer can determine which mode or function has changed based on the value of the scene mode, simplifying the implementation process of the code in the electronic device, improving the readability and flexibility of the code, so that the on and off status of the dynamic photo can be concisely represented. Among them, the scene mode can be represented by the sceneMode field or the cameraSceneMode field, and can also be defined as other fields, which is not limited in the embodiments of the present application.

[0158] Exemplarily, taking the value of the scene mode corresponding to the dynamic photo function as 73, when the dynamic photo function is turned on, the value of the scene mode is 73; when the dynamic photo function is turned off, the value of the scene mode is 0. In this way, when the value of the scene mode changes from 0 to 73, the hardware abstraction layer can determine that the dynamic photo function is turned on; when the value of the scene mode changes from 73 to 0, the hardware abstraction layer can determine that the dynamic photo function is turned off. The value of the scene mode corresponding to the specific dynamic photo function can be pre-set by the electronic device, and the embodiments of the present application are not limited thereto. For the sake of ease of description, the subsequent description is based on the example of the scene mode value of 73 corresponding to the dynamic photo function.

[0159] When the hardware abstraction layer determines that the dynamic photo function is turned on, it will return a result that the stream needs to be reconfigured to the camera service. For example, the result that the stream needs to be reconfigured can be true, and the result that the stream does not need to be reconfigured can be false. The electronic device can use other fields or values ​​to indicate whether the stream needs to be reconfigured, which is not limited in the embodiments of the present application.

[0160] After the camera service obtains the result, it can call the reconfigureCamera() function to reconfigure the camera parameters. In the reconfiguration function, it can execute the ConfigureStream() function to instruct the hardware abstraction layer to reconfigure the stream and send a capture request (process_capture_request). The hardware abstraction layer can send the relevant parameters after reconfiguring the stream to the camera driver, and then the camera driver can control the camera to capture images based on the new parameters.

[0161] The camera application can also call the post-processing camera algorithm module (ServiceHost) to set the dynamic photo callback function setProcLivePhotoCallback(surface, framenumber, mProcLivePhotoCallback), and pass the image cache, etc. The post-processing camera algorithm module can initialize the dynamic photo session, etc. For the specific process, please refer to Figure 7 The relevant description of the process of opening dynamic photos in (1) of the corresponding embodiment is not repeated here.

[0162] Fig. 9 The following figure shows the calling sequence diagram of related modules when the dynamic photo function is turned off. The calling sequence of specific modules can be referred to Figure 8 The relevant description of the corresponding embodiment will not be repeated here.

[0163] and Figure 8 The difference between the scene in which the dynamic photo function is turned on is that the hardware abstraction layer detects that the value of the scene mode changes from 73 to 0, determines that the dynamic photo function is turned off, and returns a result that the stream needs to be reconfigured to the camera service. For example, the result that the stream needs to be reconfigured can be true.

[0164] After the camera application obtains the result, it can call the flushLivePhoto() function to close the dynamic photo function in the post-processing camera algorithm module (ServiceHost). The post-processing camera algorithm module can clear the callback and destroy the dynamic photo session. For the specific process, please refer to Figure 7 The relevant description of the process of closing dynamic photos in (4) of the corresponding embodiment is not repeated here.

[0165] It is understandable that in Figure 8 and Fig. 9 In the corresponding process, when the dynamic photo function is turned on or off, the hardware abstraction layer determines that the scene mode has changed and returns true to the camera service, which then triggers the process of reconfiguring the flow. The reconfiguration process takes several hundred milliseconds to complete, causing the interface to freeze.

[0166] In the embodiment of the present application, since the caching process of dynamic photos is executed in the preview process of the application framework layer, the opening or closing of the dynamic photo function does not require reconfiguring the preview stream or the photo stream in the hardware abstraction layer. Therefore, when executing the method of the embodiment of the present application, when the hardware abstraction layer determines whether the dynamic photo is turned on or off, it can return a result to the camera service that does not require reconfiguration of the stream, so that the stream does not need to be reconfigured, reducing the interface jams.

[0167] Fig.10 The timing diagram of calling relevant modules when the dynamic photo function is turned on in the method of the embodiment of the present application is shown. The timing diagram of calling specific modules can be referred to Figure 8 The relevant description of the corresponding embodiment will not be repeated here.

[0168] and Figure 8 The difference between opening the scene with the dynamic photo function in is that the hardware abstraction layer can determine the value of the current scene and scene mode to determine whether the stream needs to be reconfigured.

[0169] Exemplarily, if the current scene is a preset field, and the value of the scene mode changes from 0 to 73, the hardware abstraction layer can return a result that does not require reconfiguration of the stream to the camera service, such as false. If the current scene is not a preset field, or the value of the scene mode does not change from 0 to 73 or from 73 to 0, the hardware abstraction layer can return a result that requires reconfiguration of the stream to the camera service, such as true.

[0170] Among them, the preset field is used to identify that the current electronic device adopts the method of the embodiment of the present application, that is, the image frames of dynamic photos cached by the ServiceHost module and the generated large image. For the convenience of description, the architecture corresponding to the image processing method of the embodiment of the present application can also be called a post-processing camera algorithm architecture or a ServiceHost architecture. The definition of the specific preset field is not limited by the embodiment of the present application.

[0171] Fig.11 The timing diagram of calling the relevant modules when the dynamic photo function is turned off in the method of the embodiment of the present application is shown. The timing diagram of calling the specific modules can be referred to Fig. 9 The relevant description of the corresponding embodiment will not be repeated here.

[0172] and Fig. 9 The difference between opening the scene with the dynamic photo function in is that the hardware abstraction layer can determine the value of the current scene and scene mode to determine whether the stream needs to be reconfigured.

[0173] Exemplarily, if the current scene is a preset field, and the value of the scene mode changes from 73 to 0, the hardware abstraction layer can return a result that does not require stream reconfiguration to the camera service, such as false. If the current scene is not a preset field, or the value of the scene mode does not change from 73 to 0 or from 0 to 73, the hardware abstraction layer can return a result that requires stream reconfiguration to the camera service, such as true.

[0174] Fig.12 The image processing method of the embodiment of the present application is shown, which is applied to an electronic device. The method includes: S1201. In response to a first operation of triggering opening a target application, perform image processing on a captured image in a first data stream to obtain first image data, where the first image data is used for image preview.

[0175] In the embodiment of the present application, the target application can be understood as an application that can generate dynamic photos. For example, the target application can include a camera application.

[0176] The first operation can be understood as an operation of opening a target application or an operation of displaying an image preview. The first operation may include but is not limited to operations such as clicking an icon of a target application, opening a target application by voice control, and opening a target application by gesture, and the present application embodiment does not limit this.

[0177] The first data stream can be understood as Figure 6 In the corresponding embodiment, the preview session (normalSession) in the post-processing camera algorithm module can be used to process preview-related processes, such as performing image processing on the captured image. For specific preview sessions, please refer to Figure 5 and Figure 6 The relevant descriptions in the corresponding embodiments are not repeated here.

[0178] The first image data can be understood as Figure 6 In the corresponding embodiment, the image data output by the preview algorithm module in the post-processing camera algorithm module can be used to display on the preview interface of the target application.

[0179] S1202. In response to a second operation that triggers a photo, perform image processing on a target image in a second data stream to obtain second image data; wherein the target image is an image at a time corresponding to the second operation in the first data stream, and the second image data includes an image obtained by triggering the second operation.

[0180] In the embodiment of the present application, the second operation can be understood as a photo-taking operation, and the second operation may include but is not limited to operations such as clicking a photo button, voice control photo-taking, and gesture control photo-taking, which are not limited in the embodiment of the present application. Figure 1 The shooting controls 105 in.

[0181] The second data stream can be understood as Figure 6 In the corresponding embodiment, the photo session (ppsession) in the post-processing camera algorithm module can be used to process the process related to photo taking, such as performing image processing on the image obtained by taking a photo. Figure 5 and Figure 6 The relevant descriptions in the corresponding embodiments are not repeated here.

[0182] The second image data may include one or more images, and the electronic device may generate a captured image with better quality based on the one or more images, thereby showing a better image effect to the user.

[0183] The target image can be understood as Figure 6 In the corresponding embodiment, the image is transmitted from the data source module of the preview session to the photo data source module of the photo session.

[0184] The second image data can be understood as Figure 6 In the corresponding embodiment, the image data output by the writing module in the post-processing camera algorithm module can be used as the image at the time of shooting, and can also be used to generate dynamic photos.

[0185] S1203: Generate a dynamic photo based on the first image data and the second image data.

[0186] In the embodiment of the present application, the implementation of generating a dynamic photo based on the first image data and the second image data can refer to Figure 6 The relevant descriptions in the corresponding embodiments are not repeated here.

[0187] It can be understood that, in the first data stream, using the preview frames processed by the image optimization algorithm to generate dynamic photos can improve the quality of the generated dynamic photos and enhance the user experience.

[0188] Optional, in Fig.12 On the basis of the corresponding embodiments, the first data stream and the second data stream are both set at the application framework layer, and the method may also include: saving the first image data to a preset cache based on the first data stream; generating a dynamic photo based on the first image data and the second image data, which may include: obtaining the first image data from the preset cache based on the target application, and generating a dynamic photo based on the first image data and the second image data.

[0189] In the embodiment of the present application, the preset cache can be understood as Figure 6 The specific process of storing data in the preset cache and obtaining data can refer to the CycleQueue in the corresponding embodiment. Figure 6 The relevant descriptions in the corresponding embodiments are not repeated here.

[0190] It is understandable that the first data stream and the second data stream are both set at the application framework layer, and in the first data stream, after the preview frame used for image preview is processed by the image optimization algorithm, the preview frame can be cached as a preview frame for generating dynamic photos, and the target application can generate dynamic photos based on the cached preview frame for generating dynamic photos. In this way, the target application can generate dynamic photos based on the preview frame processed by the image optimization algorithm, thereby improving the quality of the generated dynamic photos.

[0191] Optional, in Fig.12 On the basis of the corresponding embodiment, before obtaining the first image data in the preset cache, it may also include: establishing an Android interface definition language AIDL communication connection based on the target application and the application framework layer; obtaining the first image data from the preset cache based on the target application, and generating a dynamic photo based on the first image data and the second image data, which may include: based on the target application, obtaining the first image data from the preset cache, and synthesizing a video file based on the first image data and the collected audio data; generating a dynamic photo based on the video file and the second image data.

[0192] In the embodiment of the present application, the implementation of synthesizing a video file based on the first image data and the collected audio data, and generating a dynamic photo based on the video file and the second image data can refer to Figure 6 The relevant descriptions in the corresponding embodiments are not repeated here.

[0193] It is understandable that, by synthesizing a video file based on the first image data and the collected audio data, the audio data and the image data can be time-aligned by the timestamp, so that the audio data stream and the video data stream are kept synchronized during playback or processing. The dynamic photo generated based on the video file and the second image data can capture the picture within a period of time before and after the image is taken, so that the generated image is not only static, but can show some dynamic effects, so that some wonderful moments that are difficult to capture with a single static photo can be captured.

[0194] Optional, in Fig.12 On the basis of the corresponding embodiments, before performing image processing on the captured image in the first data stream, it may also include: based on the camera service of the target application and the application framework layer, passing a first request to the hardware abstraction layer, the first request is used to instruct the hardware abstraction layer to initialize the preview stream; initializing the preview stream based on the hardware abstraction layer, and returning the image captured by the camera to the camera service through the preview stream; and passing the captured image to the first data stream based on the camera service.

[0195] In the embodiment of the present application, the first request can be understood as Figure 6The corresponding capture request (process_capture_request) in the embodiment. For the specific interaction between the hardware abstraction layer and the application framework layer, please refer to Figure 6 The relevant descriptions in the corresponding embodiments are not repeated here.

[0196] It is understandable that the first request may carry the photographing parameters set by the target application. Based on the first request, the hardware abstraction layer may instruct the camera driver to set the corresponding photographing parameters, so as to obtain an image that meets the user's requirements.

[0197] Optional, in Fig.12 On the basis of the corresponding embodiment, before the second operation, it may also include: in response to a third operation that triggers the opening of the dynamic photo function, based on the target application and the camera service, passing a second request to the hardware abstraction layer, the second request is used to instruct the hardware abstraction layer to reconfigure the preview stream, the second request includes a first identifier, and the first identifier is used to indicate whether the dynamic photo function is turned on; based on the first identifier, determining that the hardware abstraction layer does not reconfigure the preview stream.

[0198] In the embodiment of the present application, the third operation can be understood as the operation of opening the dynamic photo function. The third operation may include but is not limited to operations such as clicking the dynamic photo button, opening the dynamic photo by voice control, and opening the dynamic photo by gesture control. The embodiment of the present application does not limit this. For example, clicking the dynamic photo button includes clicking Figure 1 Dynamic photo controls in 107.

[0199] The second request can be understood as Figure 6 The first identifier can be understood as: Figure 8 The identifier corresponding to the scene mode in the corresponding embodiment is, for example, the sceneMode field or the cameraSceneMode field. The specific value of the first identifier can be referred to Figure 8 The relevant description of the scene mode in the corresponding embodiment will not be repeated here.

[0200] The value of the scene mode is used to identify whether the dynamic photo function is turned on, which facilitates the determination of the status of the dynamic photo. The hardware abstraction layer can determine which mode or function has changed based on the value of the scene mode, thereby simplifying the code implementation process in electronic devices and improving code readability and flexibility, thereby being able to concisely represent the on and off status of the dynamic photo.

[0201] Optional, in Fig.12On the basis of the corresponding embodiment, determining based on the first identifier that the hardware abstraction layer does not reconfigure the preview stream may include: when the first identifier indicates that the dynamic photo function is turned on, and the last time the first identifier recorded by the hardware abstraction layer indicated that the dynamic photo function is turned off, determining that the hardware abstraction layer does not reconfigure the preview stream.

[0202] In the present application embodiment, Figure 8 Taking the description in the corresponding embodiment as an example, the first identifier indicating that the dynamic photo function is turned on can be understood as the value of the scene mode being 73, and the first identifier indicating that the dynamic photo function is turned off can be understood as the value of the scene mode being 0. The first identifier indicates that the dynamic photo function is turned on, and the last time the first identifier recorded by the hardware abstraction layer indicated that the dynamic photo function was turned off, it means that the value of the scene mode changes from 0 to 73, and the dynamic photo function is turned on, then it can be determined that the hardware abstraction layer does not need to reconfigure the preview stream.

[0203] It is understandable that when the dynamic photo function is turned on, the hardware abstraction layer does not reconfigure the preview stream, which can reduce the situation of no preview frames and reduce interface jams, thereby improving the user experience.

[0204] Optional, in Fig.12 On the basis of the corresponding embodiments, determining based on the first identifier that the hardware abstraction layer does not reconfigure the preview stream may include: when the first identifier indicates that the dynamic photo function is turned on, the last first identifier recorded by the hardware abstraction layer indicates that the dynamic photo function is turned off, and when the dynamic photo function is turned on or off, the electronic device supports that the hardware abstraction layer does not reconfigure the preview stream, determining that the hardware abstraction layer does not reconfigure the preview stream.

[0205] In an embodiment of the present application, when the dynamic photo function is turned on, the electronic device supports the situation where the hardware abstraction layer does not reconfigure the preview stream. This can be understood as the electronic device using the image processing method of an embodiment of the present application to implement the dynamic photo function. It can also be understood as the dynamic photo cached in the post-processing camera algorithm module (ServiceHost) of the application framework layer corresponding to the image frame.

[0206] It is understandable that the electronic device may include one or more ways to implement dynamic photos, and there may be some differences between different implementation methods. For example, the image processing method of the embodiment of the present application is used to implement the dynamic photo function. When the dynamic photo function is turned on, the hardware abstraction layer may not reconfigure the preview stream, thereby reducing the interface jam. Therefore, by determining whether the electronic device supports the hardware abstraction layer not to reconfigure the preview stream, the preview stream can be flexibly configured according to different implementation processes, thereby improving the flexibility of code execution.

[0207] Optional, in Fig.12On the basis of the corresponding embodiment, before determining that the hardware abstraction layer does not reconfigure the preview stream, the method may further include: returning a second identifier to the camera service based on the hardware abstraction layer, where the second identifier is used to indicate that the camera service does not trigger a process of reconfiguring the preview stream.

[0208] In the embodiment of the present application, the second identifier can be understood as Fig.10 The preset field in the corresponding embodiment is used to indicate the result returned by the hardware abstraction layer to the camera service that the stream does not need to be reconfigured. For example, the second flag may include false. Based on the second flag, the camera service will not call the stream reconfiguration function.

[0209] The second identifier is used to instruct the camera service not to trigger the process of reconfiguring the preview stream, which simplifies the code implementation process in the electronic device and improves the code readability and flexibility, so that the corresponding execution process can be concisely represented by the field identifier.

[0210] Optional, in Fig.12 On the basis of the corresponding embodiments, the method may further include: in response to a fourth operation that triggers turning off the dynamic photo function, based on the target application and the camera service, passing a third request to the hardware abstraction layer, the third request being used to instruct the hardware abstraction layer to reconfigure the preview stream, the third request including a first identifier; when the first identifier indicates that the dynamic photo function is turned off, and the last time the first identifier recorded by the hardware abstraction layer indicated that the dynamic photo function was turned on, determining that the hardware abstraction layer does not reconfigure the preview stream.

[0211] In the embodiment of the present application, the fourth operation can be understood as the operation of closing the dynamic photo function. The fourth operation may include but is not limited to operations such as clicking the dynamic photo button, voice control to close the dynamic photo, gesture control to close the dynamic photo, etc., which are not limited in the embodiment of the present application. For example, clicking the dynamic photo button includes clicking Figure 1 Dynamic photo controls in 107.

[0212] The third request can be understood as Figure 6 Corresponding to the capture request (process_capture_request) in the embodiment. Figure 8 Taking the description in the corresponding embodiment as an example, the first identifier indicates that the dynamic photo function is turned off, and the last first identifier recorded by the hardware abstraction layer indicates that the dynamic photo function is turned on, indicating that the value of the scene mode changes from 73 to 0, and the dynamic photo function is turned off, it can be determined that the hardware abstraction layer does not need to reconfigure the preview stream.

[0213] It is understandable that when the dynamic photo function is turned off, the hardware abstraction layer does not reconfigure the preview stream, which can reduce the situation of no preview frames and reduce interface jams, thereby improving the user experience.

[0214] Optional, in Fig.12 On the basis of the corresponding embodiment, when the first identifier indicates that the dynamic photo function is turned off and the last first identifier recorded by the hardware abstraction layer indicates that the dynamic photo function is turned on, determining that the hardware abstraction layer does not reconfigure the preview stream may also include: when the first identifier indicates that the dynamic photo function is turned off, the last first identifier recorded by the hardware abstraction layer indicates that the dynamic photo function is turned on, and when the dynamic photo function is turned on or off, the electronic device supports that the hardware abstraction layer does not reconfigure the preview stream, determining that the hardware abstraction layer does not reconfigure the preview stream.

[0215] In the embodiment of the present application, when the dynamic photo function is turned off, the electronic device supports the situation where the hardware abstraction layer does not reconfigure the preview stream. This can be understood as the electronic device using the image processing method of the embodiment of the present application to implement the dynamic photo function, and can also be understood as the dynamic photo cached in the post-processing camera algorithm module (ServiceHost) of the application framework layer corresponding to the image frame.

[0216] It is understandable that the electronic device may include one or more ways to implement dynamic photos, and there may be some differences between different implementation methods. For example, the image processing method of the embodiment of the present application is used to implement the dynamic photo function. When the dynamic photo function is turned off, the hardware abstraction layer may not reconfigure the preview stream, thereby reducing the interface jam. Therefore, by determining whether the electronic device supports the hardware abstraction layer not to reconfigure the preview stream, the preview stream can be flexibly configured according to different implementation processes, thereby improving the flexibility of code execution.

[0217] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0218] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of the method. In order to achieve the above functions, it includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily appreciate that, in combination with the method steps of each example described in the embodiment disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.

[0219] The embodiment of the present application can divide the functional modules of the device implementing the method according to the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The integrated module can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0220] like Fig.13 FIG. 13 is a schematic diagram of a chip structure provided by an embodiment of the present application. The chip 1300 includes one or more (including two) processors 1301 , a communication line 1302 , a communication interface 1303 and a memory 1304 .

[0221] In some implementations, the memory 1304 stores the following elements: executable modules or data structures, or a subset thereof, or an extended set thereof.

[0222] The method described in the above embodiment of the present application can be applied to the processor 1301, or implemented by the processor 1301. The processor 1301 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor 1301 or an instruction in the form of software. The above processor 1301 can be a general processor (for example, a microprocessor or a conventional processor), a digital signal processor (digital signal processing, DSP), an application specific integrated circuit (application specific integrated circuit, ASIC), a field-programmable gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gates, transistor logic devices or discrete hardware components. The processor 1301 can implement or execute the methods, steps and logic block diagrams related to each processing disclosed in the embodiment of the present application.

[0223] The steps of the method disclosed in the embodiment of the present application can be directly embodied as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. Among them, the software module can be located in a mature storage medium in the field such as a random access memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable read only memory (EEPROM). The storage medium is located in the memory 1304, and the processor 1301 reads the information in the memory 1304 and completes the steps of the above method in combination with its hardware.

[0224] The processor 1301 , the memory 1304 , and the communication interface 1303 may communicate with each other via the communication line 1302 .

[0225] In the above embodiments, the instructions stored in the memory for execution by the processor may be implemented in the form of a computer program product, wherein the computer program product may be pre-written in the memory, or may be downloaded and installed in the memory in the form of software.

[0226] The embodiment of the present application also provides a computer program product including one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions may 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 may 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 (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or data center that includes one or more available media integrated. For example, the available medium may include a magnetic medium (e.g., a floppy disk, a hard disk or a tape), an optical medium (e.g., a digital versatile disc (DVD)), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.

[0227] The present application also provides a computer-readable storage medium. The methods described in the above embodiments can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. Computer-readable media may include computer storage media and communication media, and may also include any medium that can transfer a computer program from one place to another. The storage medium may be any target medium that can be accessed by a computer.

[0228] As a possible design, the computer readable medium may include a compact disc read-only memory (CD-ROM), RAM, ROM, EEPROM or other optical disc storage; the computer readable medium may include a magnetic disk storage or other magnetic disk storage device. Moreover, any connection line may also be appropriately referred to as a computer readable medium. For example, if the software is transmitted from a website, server or other remote source using a coaxial cable, fiber optic cable, twisted pair, DSL or wireless technologies such as infrared, radio and microwave, the coaxial cable, fiber optic cable, twisted pair, DSL or wireless technologies such as infrared, radio and microwave are included in the definition of medium. Disk and disc as used herein include compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), floppy disk and Blu-ray disc, where disks usually reproduce data magnetically, while discs reproduce data optically using lasers.

[0229] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

Claims

1. An image processing method, applied to an electronic device, characterized in that: The method comprises: In response to a first operation of triggering opening a target application, performing image processing on the captured image in a first data stream to obtain first image data, wherein the first image data is used for image preview; In response to a second operation that triggers photographing, performing image processing on a target image in a second data stream to obtain second image data; wherein the target image is an image in the first data stream at a time corresponding to the second operation, and the second image data includes an image obtained by triggering the second operation; A dynamic photo is generated based on the first image data and the second image data.

2. The method according to claim 1, characterized in that The first data stream and the second data stream are both set at the application framework layer, and the method further includes: Saving the first image data into a preset cache based on the first data stream; The generating a dynamic photo based on the first image data and the second image data includes: The first image data is obtained from the preset cache based on the target application, and the dynamic photo is generated based on the first image data and the second image data.

3. The method according to claim 2, characterized in that Before acquiring the first image data in the preset cache, the method further includes: Establishing an Android interface definition language AIDL communication connection based on the target application and the application framework layer; The acquiring the first image data from the preset cache based on the target application, and generating the dynamic photo based on the first image data and the second image data, includes: Based on the target application, acquiring the first image data from the preset cache, and synthesizing a video file according to the first image data and the collected audio data; The dynamic photo is generated based on the video file and the second image data.

4. The method according to any one of claims 1 to 3, characterized in that: Before performing image processing on the collected image in the first data stream, the method further includes: Based on the target application and the camera service of the application framework layer, delivering a first request to the hardware abstraction layer, wherein the first request is used to instruct the hardware abstraction layer to initialize a preview stream; Initialize the preview stream based on the hardware abstraction layer, and return the image captured by the camera to the camera service through the preview stream; The acquired image is delivered to the first data stream based on the camera service.

5. The method according to claim 4, characterized in that Before the second operation, the method further includes: In response to a third operation that triggers turning on the dynamic photo function, based on the target application and the camera service, delivering a second request to the hardware abstraction layer, the second request being used to instruct the hardware abstraction layer to reconfigure the preview stream, the second request including a first identifier, the first identifier being used to indicate whether the dynamic photo function is turned on; Based on the first identifier, it is determined that the hardware abstraction layer does not reconfigure the preview stream.

6. The method according to claim 5, characterized in that The determining, based on the first identifier, that the hardware abstraction layer does not reconfigure the preview stream includes: When the first identifier indicates that the dynamic photo function is turned on, and the last time the first identifier was recorded by the hardware abstraction layer, it is determined that the hardware abstraction layer does not reconfigure the preview stream.

7. The method according to claim 6, characterized in that The determining, based on the first identifier, that the hardware abstraction layer does not reconfigure the preview stream includes: When the first identifier indicates that the dynamic photo function is turned on, the hardware abstraction layer records the last time that the first identifier indicated that the dynamic photo function was turned off, and when the dynamic photo function is turned on or off, the electronic device supports the hardware abstraction layer not reconfiguring the preview stream, it is determined that the hardware abstraction layer does not reconfigure the preview stream.

8. The method according to claim 7, characterized in that Before determining that the hardware abstraction layer does not reconfigure the preview stream, the method further includes: Based on the hardware abstraction layer, a second identifier is returned to the camera service, where the second identifier is used to instruct the camera service not to trigger a process of reconfiguring the preview stream.

9. The method according to claim 8, characterized in that The method further comprises: In response to a fourth operation that triggers closing the dynamic photo function, based on the target application and the camera service, delivering a third request to the hardware abstraction layer, the third request being used to instruct the hardware abstraction layer to reconfigure the preview stream, the third request including the first identifier; When the first identifier indicates that the dynamic photo function is turned off, and the last time the first identifier was recorded by the hardware abstraction layer, it is determined that the hardware abstraction layer does not reconfigure the preview stream.

10. The method according to claim 9, characterized in that The determining that the hardware abstraction layer does not reconfigure the preview stream when the first identifier indicates that the dynamic photo function is turned off and the last time the first identifier recorded by the hardware abstraction layer indicates that the dynamic photo function is turned on, further includes: When the first identifier indicates that the dynamic photo function is turned off, the hardware abstraction layer records the last time that the first identifier indicated that the dynamic photo function is turned on, and when the dynamic photo function is turned on or off, the electronic device supports the hardware abstraction layer not reconfiguring the preview stream, it is determined that the hardware abstraction layer does not reconfigure the preview stream.

11. An electronic device, characterized in that: The electronic device comprises: one or more processors and a memory; The memory is coupled to the one or more processors, and the memory is used to store computer program codes, wherein the computer program codes include computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the method according to any one of claims 1 to 10.

12. A chip system, characterized in that: The chip system is applied to an electronic device, and the chip system includes one or more processors, and the one or more processors are used to call computer instructions so that the electronic device executes the method as described in any one of claims 1-10.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 10.

14. A computer program product, characterized in that The computer program product comprises a computer program code, and when the computer program code is run on an electronic device, the electronic device is enabled to perform the method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Image data processing method, device, electronic equipment and storage medium

    CN113890998A

  • Photographing method and electronic equipment

    CN116055857A

  • Method for generating preview image, terminal, storage medium and chip

    CN117692759A