Image preview method, device, electronic device and computer-readable storage medium

By receiving the preview request of the third-party application in the camera capability opening unit and generating the preview image in the first cache queue, the problem that the third-party application cannot obtain the camera capability opening unit data is solved, and the flexible use of image processing functions and Improve data processing capabilities.

CN113992854BActive Publication Date: 2024-09-06GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111274940.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-29
Publication Date
2024-09-06
Estimated Expiration
2041-10-29

AI Technical Summary

Technical Problem

Third-party applications cannot directly obtain data from the second cache queue inside the camera capability opening unit because the interface is not open to them, resulting in the inability to use all image processing functions of the camera capability opening unit.

Method used

By receiving a preview request generated by a third-party application, obtaining metadata and generating a preview image in the first cache queue, the third-party application can obtain the image from the cache queue, thereby bypassing the second cache queue inside the camera capability opening unit Unopened interface restrictions.

Benefits of technology

It enables third-party applications to flexibly use the image processing functions in the camera capability open unit, overcomes the problem of interface limitations, and improves data transmission speed and processing capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113992854B
    Figure CN113992854B
Patent Text Reader

Abstract

An image preview method, device, electronic device, and computer-readable storage medium, wherein the image preview method is applied to a camera capability exposure unit, and the method comprises: receiving a first preview request generated by a third-party application and carrying a first cache queue; obtaining metadata from a second cache queue in response to the first preview request; processing the metadata to generate a preview image, and storing the preview image in the first cache queue to instruct the third-party application to obtain the preview image from the first cache queue. In an embodiment of the present application, the camera capability exposure unit can store the processed and generated preview image in the first cache queue by receiving a first cache queue of external input, and the third-party application can obtain the preview image from the first cache queue, thereby providing a preview method that allows third-party applications to flexibly use the image processing function in the camera capability exposure unit.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to image preview, and in particular to an image preview method, device, electronic device and computer-readable storage medium. Background Art

[0002] With the development of image processing technology, the camera capability exposure unit can help applications call the camera algorithm from the bottom layer of the terminal, thereby improving the image processing capabilities of the application. However, some callback interfaces of the camera capability exposure unit are not open to third-party applications, resulting in third-party applications being unable to use all the image processing functions of the camera capability exposure unit. Summary of the invention

[0003] The embodiments of the present application provide an image preview method, device, electronic device, and computer-readable storage medium, which can enable third-party applications to flexibly use the image processing function in the camera capability exposure unit without increasing the number of callback interfaces required to be configured in the camera capability exposure unit.

[0004] An image preview method, applied to a camera capability exposure unit, comprises:

[0005] receiving a first preview request generated by a third-party application and carrying a first cache queue;

[0006] In response to the first preview request, acquiring metadata from a second cache queue;

[0007] The metadata is processed to generate a preview image, and the preview image is stored in the first cache queue to instruct the third-party application to obtain the preview image from the first cache queue.

[0008] An image preview method, applied to a third-party application, comprising:

[0009] In response to the preview triggering operation, creating a first cache queue and generating a first preview request;

[0010] Sending a first preview request carrying the first cache queue to instruct the camera capability exposure unit to generate a preview image;

[0011] The preview image is obtained from the first cache queue.

[0012] An image preview device, comprising:

[0013] A request receiving module, used for receiving a first preview request carrying a first cache queue generated by a third-party application;

[0014] a metadata acquisition module, configured to acquire metadata from a second cache queue in response to the first preview request;

[0015] A preview generation module is used to process the metadata to generate a preview image, and store the preview image in the first cache queue to instruct the third-party application to obtain the preview image from the first cache queue.

[0016] An image preview device, comprising:

[0017] A request generating module, configured to create a first cache queue and generate a first preview request in response to a preview triggering operation;

[0018] A request sending module, used for sending a first preview request carrying the first cache queue to instruct the camera capability opening unit to generate a preview image;

[0019] The preview acquisition module is used to acquire, from the first cache queue, a preview image generated by the camera capability exposure unit in response to the first preview request.

[0020] An electronic device includes a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the steps of the above-mentioned image preview method.

[0021] A computer-readable storage medium stores a computer program, which implements the steps of the above-mentioned image preview method when executed by a processor.

[0022] The above-mentioned image preview method, device, electronic device, and computer-readable storage medium, the image preview method, is applied to the camera capability exposure unit, and the method includes: receiving a first preview request carrying a first cache queue generated by a third-party application; in response to the first preview request, obtaining metadata from the second cache queue; processing the metadata to generate a preview image, and storing the preview image in the first cache queue to instruct the third-party application to obtain the preview image from the first cache queue. In an embodiment of the present application, the camera capability exposure unit can store the processed and generated preview image in the first cache queue by receiving the first cache queue of external input, and the third-party application can obtain the preview image from the first cache queue, thereby overcoming the problem that the second cache queue inside the camera capability exposure unit does not open an interface to the third-party application, resulting in the third-party application being unable to directly obtain data from the second cache queue. That is, a preview method is provided in which a third-party application can flexibly use the image processing function in the camera capability exposure unit. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0024] Figure 1 A flowchart of an image preview method according to an embodiment;

[0025] Figure 2 is a sub-flow chart of step 104 of an embodiment;

[0026] Figure 3 A flowchart of an image preview method of a system application program according to an embodiment;

[0027] Figure 4 A flowchart of an image preview method according to another embodiment;

[0028] Figure 5 A flowchart of an image preview method according to another embodiment;

[0029] Figure 6 is a structural block diagram of an image preview device according to an embodiment;

[0030] Figure 7 is a structural block diagram of an image preview device according to another embodiment;

[0031] Figure 8 FIG. 1 is a schematic diagram of the internal structure of an electronic device in an embodiment. DETAILED DESCRIPTION

[0032] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0033] It is understood that the terms "first", "second", etc. used in this application may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish a first element from another element. For example, without departing from the scope of this application, a first preview request may be referred to as a second preview request, and similarly, a second preview request may be referred to as a first preview request. Both the first preview request and the second preview request are preview requests, but they are not the same preview request.

[0034] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present application, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. In the description of the present application, the meaning of "several" is at least one, such as one, two, etc., unless otherwise clearly and specifically defined.

[0035] The embodiment of the present application provides an image preview method, and the image preview method of the embodiment of the present application is described by taking running on an electronic device as an example. Among them, the electronic device includes a camera capability opening unit and an application. The camera capability opening unit is configured with a variety of image processing algorithms, and the camera capability opening unit can process the received image data through at least one image processing algorithm. Exemplarily, the multiple image processing algorithms include but are not limited to at least one of beauty processing, filter processing, rotation processing, watermark processing, blur processing, HDR processing and multi-frame processing. An application refers to a computer program for completing one or more specific tasks, which runs in user mode, can interact with the user, and has a visual user interface. In the related art, an application can access the camera function of an electronic device through the Camera2 API, and receive the camera opening status by implementing and registering CameraDevice.StateCallback, receive the session creation status by implementing and registering CameraCaptureSession.StateCallback, and receive the preview / photo request status and data by implementing and registering CameraCaptureSession.CaptureCallback. If the data is received through ImageReader, the support of ImageReader.OnImageAvailableListener is also required. Therefore, the interface callback method in the related technology is relatively complicated, especially when it needs to be adapted to different platform architectures, the adaptation complexity is even higher.

[0036] Therefore, by accessing the camera capability exposure unit and configuring the API interface, a simpler function call can be provided to the application, and the total number of interfaces can be reduced. The application in the embodiment of the present application includes a third-party application, which refers to an application that is not built-in to the electronic device and is downloaded and installed during the user's use. Generally, the system application has the authority to call all interfaces of the camera capability exposure unit, while the third-party application can only call some interfaces of the camera capability exposure unit. Specifically, both the third-party application and the system application have the calling authority of the encapsulated CameraStateCallback, CameraRecordingCallback, CameraPreviewCallback and CameraPictureCallback interfaces. Among them, the third-party application can call back all states of the CameraStateCallback interface such as +onCameraOpen(), +CameraClosed(), +onCameraDisconnect(), +onCameraErrer(), +onSessionConfigured(), +onSessionConfigureFail() and +onSessionClosed(). The third-party application can call back all states of the CameraRecordingCallback interface such as +onRecordingResult(). Third-party applications can call back the +onPreviewMetaReceived() status of the CameraPreviewCallback interface, and system applications can call back the +onPreviewReceived(), +onVideoReceived(), +onPreviewFrameReceived(), and +onPreviewCaptureProgressed() status of the CameraPreviewCallback interface. Third-party applications can call back the +onCaptureShutter(), +onCaptureMetaReceived(), +onCaptureFailed(), and +onImageReceived() status of the CameraPictureCallback interface, and system applications can call back the +onBurstShotStart(), +onBurstShotEnd(), +onPictureCaptureProgressed(), and +onPictureCaptureSequenceComplete() status of the CameraPictureCallback interface.

[0037] Figure 1 This is a flow chart of an image preview method of an embodiment. The image preview method of this embodiment is described by taking a camera capability exposure unit running in an electronic device as an example. It can be understood that in some possible embodiments, the image preview method can also be applied to a server, or can be applied to a system including an electronic device and a server, and implemented through the interaction between the electronic device and the server, which is not limited in this embodiment. Figure 1 The image preview method of this embodiment includes steps 102 to 106.

[0038] Step 102: Receive a first preview request carrying a first cache queue generated by a third-party application.

[0039] Among them, the first preview request refers to a request generated by a third-party application in response to a preview trigger operation input by a user. Exemplarily, the preview trigger operation can be an operation in which the user double-clicks the volume button of the electronic device, or an operation in which the user clicks the preview icon on the interactive interface, which is not limited in this embodiment. Taking the third-party application "WeChat" as an example, the preview trigger operation of "WeChat" triggering the preview function can be calling the camera interface of the electronic device after clicking the shooting control in the chat dialog box.

[0040] The buffer queue can be understood as a container that can cache images and related data. After the image producer generates the image and related data, the image and related data can be queued in the buffer queue, and the image consumer can obtain the above image and related data from the buffer queue and perform subsequent image processing and other operations. It should be noted that for different buffer queues, the image producer can be different. For example, the image producer can be an imaging device such as a camera, or an intermediate component with image processing capabilities, which can be determined specifically according to the data transmission and interaction process. Among them, the image and related data can include image data and imaging parameter data. The image data can be RAW image data or YUV image data. The imaging parameter data can include automatic exposure control AE, automatic focus control AF, automatic white balance control AWB, aperture size, shutter speed, and sensitivity aperture value.

[0041] Optionally, in response to the preview trigger operation, a third-party application may create the first cache queue, or the third-party application may call other controls to create the first cache queue, and the other controls then transmit the created first cache queue back to the third-party application. Therefore, this embodiment does not limit the creation method of the first cache queue, and only requires the third-party application to have the read permission of the first cache queue. That is, the third-party application can obtain the cached images and related data from the first cache queue.

[0042] Step 104: Responding to the first preview request, obtaining metadata from the second cache queue.

[0043] Among them, metadata refers to images and related data directly generated by the imaging device and not processed by the image processing algorithm. The second cache queue refers to the cache queue inside the camera capability exposure unit. In the embodiment of the present application, the camera capability exposure unit has data read and write permissions for the first cache queue and the second cache queue, but the second cache queue does not open the data reading interface to the third-party application, that is, the third-party application does not have data read permissions for the second cache queue.

[0044] Optionally, the second cache queue may be fixed inside the camera capability exposure unit. When the first preview request is received, the second cache queue is used to cache metadata corresponding to the first preview request, and when the first preview request is not received, it is used to cache data corresponding to other requests. The second cache queue may also be a cache queue created by the camera capability exposure unit in response to the first preview request, and after completing the preview operation corresponding to the first preview request, the second cache queue may be closed to open up memory space to other cache queues.

[0045] Step 106: Process the metadata to generate a preview image, and store the preview image in the first cache queue to instruct the third-party application to obtain the preview image from the first cache queue.

[0046] Specifically, the camera capability exposure unit generates a preview image by performing at least one of the aforementioned beauty processing, filter processing, rotation processing, watermark processing, blur processing, HDR processing and multi-frame processing on the metadata. The type of the preview image may be, for example, a YUV image or a JPEG image. Optionally, the method of instructing a third-party application to obtain a preview image may be that after storing the preview image in the first cache queue, the camera capability exposure unit sends an image update message to the third-party application to inform the third-party application that a new preview image has been generated. The method of instructing a third-party application to obtain a preview image may also be that the third-party application sets a listener in the first cache queue in advance, and when the listener detects that a new preview image has been input, it calls back the third-party application to perform the preview image reading operation.

[0047] In this embodiment, the camera capability exposure unit can store the generated preview image in the first cache queue by receiving the first cache queue of external input. The third-party application can obtain the preview image from the first cache queue, thereby overcoming the problem that the second cache queue inside the camera capability exposure unit does not open the interface to the third-party application, resulting in the third-party application being unable to directly obtain data from the second cache queue. That is, a preview method is provided that allows the third-party application to flexibly use the image processing function in the camera capability exposure unit.

[0048] Figure 2 is a sub-flow chart of step 104 of an embodiment, refer to Figure 2 In this embodiment, step 104 corresponds to the first preview request, and obtains metadata from the second cache queue, including steps 202 to 206.

[0049] Step 202: Create a second cache queue in response to the first preview request.

[0050] Specifically, the camera capability exposure unit creates a second cache queue built into the camera capability exposure unit in response to the first preview request, wherein the length of the second cache queue may be the same as the length of the first cache queue to implement corresponding data reading and data writing operations.

[0051] Step 204: Send a second preview request to the hardware abstraction layer to instruct the hardware abstraction layer to store metadata in the second cache queue in response to the second preview request.

[0052] Among them, the hardware abstraction layer (HAL) refers to a hardware interface layer abstracted from a specific hardware platform, which is responsible for implementing the functions and controls of the specific hardware platform, and at the same time provides a unified API interface for other software modules. In this embodiment, the hardware platform includes imaging devices such as image sensors, and other software modules refer to the camera capability exposure unit. Specifically, the camera capability exposure unit generates a corresponding second preview request based on the first preview request, and the second preview request can carry a second cache queue to inform the hardware abstraction layer of the location of data caching after obtaining the metadata. That is, the difference between the first preview request and the second preview request may only be that the sending and receiving objects of the request are different, and the corresponding cache queues are different. Specifically, after the camera capability exposure unit sends the second preview request to the hardware abstraction layer, the hardware abstraction layer will return the metadata of each frame in turn, and cache the metadata of each frame to different positions in the second cache queue.

[0053] Step 206: Read the metadata from the second cache queue.

[0054] Specifically, the camera capability exposure unit may read different positions in the second cache queue in sequence to respectively obtain metadata of each frame.

[0055] In this embodiment, the camera capability exposure unit creates a second cache queue in response to the first preview request, that is, the camera capability exposure unit only creates the second cache queue when image preview is required, and closes the second cache queue when image preview is not required. Based on the above implementation, it can be avoided that the second cache queue occupies memory space when idle, which is equivalent to increasing the effective memory space of the camera capability exposure unit, thereby improving the data transmission speed and data processing capability of the camera capability exposure unit.

[0056] In one of the embodiments, before sending the second preview request to the hardware abstraction layer, the image preview method also includes registering a third-party callback interface corresponding to the first cache queue, and the third-party callback interface is used by the third-party application to obtain the preview image from the first cache queue. Specifically, different third-party applications correspond to different third-party callback interfaces, that is, each third-party callback interface can only open read permissions to the corresponding third-party application. For example, "Meitu Xiu Xiu" cannot obtain data in the first cache queue from the third-party callback interface corresponding to "WeChat". Based on the above implementation methods, it can be avoided that the data reading permissions of third-party applications are too large, affecting the security of electronic devices. At the same time, it can also avoid conflicts when multiple different third-party applications obtain data through the same third-party callback interface, causing data reading errors.

[0057] In one embodiment, the camera capability exposure unit includes a business subunit and an algorithm processing subunit (Algo process service, APS). The business subunit is connected to a third-party application, that is, the third-party application can be connected to the hardware abstraction layer through the business subunit, so that the business subunit can forward and process different business requests. Specifically, the third-party application can send a first preview request to the business subunit. The business subunit receives the first preview request, and in response to the first preview request, creates a second cache queue, sends a second preview request to the hardware abstraction layer, and obtains metadata from the second cache queue. The hardware abstraction layer then controls the operation of the imaging device according to the second preview request, thereby obtaining the required metadata, and stores the obtained metadata in the second cache queue. The algorithm processing subunit is configured with at least one of the aforementioned beauty processing, filter processing, rotation processing, watermark processing, blur processing, HDR processing and multi-frame processing. The algorithm processing subunit is used to process the metadata through at least one preset image processing algorithm to generate a preview image, and store the preview image in the first cache queue. Optionally, the business subunit may also send metadata to a third-party application to support functions such as peak graph and gesture photography of the third-party application.

[0058] Based on the above structure of the business subunit and the algorithm processing subunit, before storing the preview image in the first cache queue, the image preview method also includes the business subunit calling the Java native interface to transfer the first cache queue to the algorithm processing subunit through the Java native interface. Among them, the Java Native Interface (JNI) is a programming framework for allowing a Java program running on a Java virtual machine to call or be called by a program written in other languages ​​(C, C++ or assembly language, etc.) that is specific to the native hardware and operating system. Specifically, by setting up a Java native interface, business subunit programs and algorithm processing subunit programs written in different languages ​​can be compatible to solve the adaptation problem between different languages. Therefore, through the Java native interface, the algorithm processing subunit can be flexibly called, and the preview images generated by the algorithm processing subunit can be smoothly stored in the first cache queue.

[0059] In one of the embodiments, the application program capable of generating a preview request further includes a system application program. Figure 3 is a flowchart of an image preview method of a system application according to an embodiment, referring to Figure 3 In this embodiment, the image preview method also includes steps 302 to 306.

[0060] Step 302: Receive a third preview request generated by a system application.

[0061] Specifically, the system application has a higher data reading permission, and the system callback interface corresponding to the system application may be pre-configured by the electronic device when it leaves the factory. Therefore, when the system application performs a preview, it does not need to generate and transmit the first cache queue, and can also directly obtain the preview image through the preset system callback interface.

[0062] Step 304, in response to the third preview request, obtain metadata from the second cache queue. It can be understood that the difference between this step and step 104 is only that the corresponding preview request is different. Therefore, the way to obtain metadata in this step can refer to the definition of step 104, which will not be repeated here.

[0063] Step 306: Process the metadata to generate a preview image, and store the preview image in the second cache queue to instruct the system application to obtain the preview image from the second cache queue through a preset system callback interface. Exemplarily, the preview image can be generated through a GLSurfaceView control.

[0064] Optionally, the method of instructing the system application to obtain the preview image may be that after storing the preview image in the first cache queue, the camera capability exposure unit sends an image update message to the system application to inform the system application that a new preview image has been generated. The method of instructing the system application to obtain the preview image may also be that the system application pre-sets a listener in the first cache queue, and when the listener detects that a new preview image has been input, it calls back the system application to perform the operation of reading the preview image.

[0065] In this embodiment, a simpler image preview method is set for system applications with higher data reading permissions. By setting the preview methods of third-party applications and system applications differently, it is possible to ensure that third-party applications can safely use multiple image processing algorithms in the camera capability exposure unit, and to increase the image preview speed of system applications, thereby providing a better image preview method.

[0066] Furthermore, the image format returned by the camera capability exposure unit to the system application can be in YUV format. After receiving the YUV data, the system application can convert the YUV data into texture data so that the GPU can directly render the texture data, thereby improving the power consumption and performance of the image preview.

[0067] In one of the embodiments, the image preview method further includes encapsulating the processing information of the preview image, returning the encapsulation result CameraPreviewResult to the corresponding third-party application or the system application, and obtaining the data key-value pair in the same way as obtaining the metadata. The processing information includes at least one of the image processing information when the preview image is generated for the first time and the decision information when the preview image is generated for the next time. In addition, the above processing information during the shooting and recording process can also be called back through CameraPictureResult and CameraRecordingResult respectively.

[0068] Among them, the image processing information when the preview image is generated for the first time may include the image processing algorithm adopted by the algorithm processing subunit for processing, such as at least one of a beauty processing algorithm, a filter processing algorithm, a rotation processing algorithm, a watermark processing algorithm, a blur processing algorithm, an HDR processing algorithm, and a multi-frame processing algorithm. The image processing information when the preview image is generated for the first time may also include the format of the output preview image, such as a RAW image, a heif image, or a YUV image. The format of the above preview image can be encapsulated as a byte array in CameraPictureImage and identified by an ImageFormat. By returning the above image processing information, it can be convenient for third-party applications or system applications to perform subsequent other image processing.

[0069] The decision information for the next generation of the preview image may include a recommendation for the image processing algorithm to be used next time. For example, if the jitter of the gyroscope is detected to be large during the generation of the preview image, the algorithm recommendation may be multi-frame processing to eliminate the jitter according to the multi-frame processing. If the scene type detected by the AR scene detection result is a person, the algorithm recommendation may be beauty processing to beautify the person. If the scene type detected by the AR scene detection result is a landscape, the algorithm recommendation may be HDR processing to form a landscape image with a high dynamic range. The decision information for the next generation of the preview image may also include the number of frames taken. For example, if the jitter of the gyroscope is detected to be large during the generation of the preview image, the number of frames taken may be more frames to better achieve post-photography processing. If the jitter of the gyroscope is detected to be small, the number of frames taken may be fewer frames to reduce the amount of data transmission. If the ambient brightness is large during the generation of the preview image, the number of frames taken may be more frames to perform HDR synthesis on multiple frames of pictures with different brightness.

[0070] In this embodiment, by returning the processing information of the preview image, the processing efficiency and accuracy of the image can be effectively improved. Moreover, by encapsulating the processing information of the preview image, the efficiency of the processing information transmission can be improved, and the security of data transmission can be improved.

[0071] Figure 4 FIG. 1 is a flowchart of an image preview method according to another embodiment. The image preview method according to this embodiment is described by taking a third-party application running in an electronic device as an example. Figure 4 The image preview method of this embodiment includes steps 402 to 406.

[0072] Step 402: In response to a preview triggering operation, a first cache queue is created and a first preview request is generated.

[0073] Exemplarily, the preview trigger operation may be an operation in which the user double-clicks the volume button of the electronic device, or an operation in which the user clicks the preview icon on the interactive interface, which is not limited in this embodiment. Taking the third-party application "WeChat" as an example, the preview trigger operation of "WeChat" triggering the preview function may be calling the camera interface of the electronic device after clicking the shooting control in the chat dialog box. Optionally, in response to the above-mentioned preview trigger operation, it may be that the third-party application creates a first buffer queue (Buffer Queue), or it may be that the third-party application calls other controls to create the first buffer queue, and the other controls then transmit the created first buffer queue back to the third-party application. Therefore, this embodiment does not limit the creation method of the first buffer queue, and it only requires that the third-party application has the read permission of the above-mentioned first buffer queue.

[0074] Step 404: Send a first preview request carrying the first cache queue to instruct the camera capability exposure unit to generate a preview image. It should be noted that this embodiment does not limit the way in which the camera capability exposure unit generates a preview image, and any implementation method that can generate a preview image falls within the protection scope of this embodiment.

[0075] Step 406: Acquire the preview image from the first cache queue.

[0076] Specifically, the third-party application can respond to the image update message sent by the camera capability exposure unit and read a new preview image from the first cache queue. The third-party application can also monitor the data changes in the first cache queue through a listener pre-set at the first cache queue, thereby obtaining the preview image by callback.

[0077] In this embodiment, the third-party application can directly obtain the preview image from the first cache queue by transmitting the first cache queue to the camera capability exposure module, thereby overcoming the problem that the second cache queue inside the camera capability exposure unit does not open an interface to the third-party application, resulting in the third-party application being unable to directly obtain data from the second cache queue. That is, a preview method is provided that allows the third-party application to flexibly use the image processing function in the camera capability exposure unit.

[0078] Figure 5 This is a flowchart of an image preview method according to another embodiment. The image preview method according to this embodiment is applied to the aforementioned electronic device as an example to present the signal interaction process between the camera capability development unit, the third-party application program, and the hardware abstraction layer. Figure 5 The camera capability development unit of this embodiment includes an algorithm processing unit and a business subunit, and the business subunit specifically includes a producer, a consumer, and a business layer. The image preview method of this embodiment includes steps 502 to 526. The specific definition of each step can refer to the above embodiment, and will not be repeated here.

[0079] Step 502: In response to the preview triggering operation, the third-party application creates a first cache queue and generates a first preview request. Specifically, the third-party application generates the first preview request through the setReaptingRequest and setReaptingRequest(callback) instructions.

[0080] Step 504: The third-party application sends a first preview request carrying a first cache queue. Specifically, the third-party application sends the first preview request through a startPreview instruction, and passes the first cache queue as a method parameter to the camera capability development unit when calling the CameraDevice#startPreview instruction.

[0081] Step 506: The producer constructs parameters. Specifically, the producer constructs parameters through the createRequestTag instruction, and sends the first preview request from the third-party application to the business layer through the createRequestTag, buildStageParameter and startPreview(tag, parameter) instructions.

[0082] Step 508: The business layer receives the first preview request with the first cache queue generated by the third-party application. The business layer includes three parts: Basemode, camera2StateMachineImpl, and Camera2Impl. Basemode is used to receive createRequestTag and buildStageParameter instructions from the producer, and camera2StateMachineImpl is used to receive startPreview(tag, parameter) instructions from the producer.

[0083] Step 510: The consumer registers a third-party callback interface corresponding to the first cache queue. Specifically, the consumer responds to the linkToObserver instruction and calls the reader.setOnImageAvailableListener instruction to set a listener to monitor the data changes in the first cache queue, so that the third-party application can obtain the newly added data in the first cache queue from the third-party callback interface in a timely manner. In addition, the consumer also notifies the algorithm processing subunit to set the preview Surface.

[0084] Step 512: The business layer creates a second cache queue in response to the first preview request.

[0085] Step 514: The business layer calls the Java native interface to transmit the first cache queue to the algorithm processing subunit through the Java native interface.

[0086] Step 516: The business layer sends a second preview request. Specifically, the business layer sends the second preview request through the setRepeatingBurst instruction. Furthermore, the business layer sends the second preview request to the CameraServer in the Framework through the setRepeatingBurst instruction, and the CameraServer further sends the second preview request to the hardware description layer.

[0087] Step 518: The hardware description layer obtains metadata in response to the second preview request and stores the metadata in the second cache queue. Specifically, the hardware description layer sends the metadata to the CameraServer in the Framework, and the CameraServer stores the metadata in the second cache queue.

[0088] Step 520: The consumer obtains metadata from the second cache queue. Specifically, the consumer sends the metadata to the algorithm processing subunit through the addPreviewimage(Image,meta) instruction.

[0089] Step 522: the algorithm processing subunit processes the metadata to generate a preview image, and stores the preview image in the first cache queue. Specifically, the algorithm processing subunit stores the preview image in the first cache queue through the onPreviewReceived(AqsReqult, APsTotalResult) instruction.

[0090] Step 524: The consumer encapsulates the element and returns the encapsulation result to the corresponding third-party application. Specifically, the consumer returns the encapsulation result to the corresponding third-party application via onPreviewFrameReceived.

[0091] Step 526: The third-party application obtains the preview image from the first cache queue through the registered third-party callback interface. Specifically, the third-party application calls back the preview image from the first cache queue through the onPreviewReceived instruction.

[0092] In this embodiment, through the above steps, a preview method is implemented in which a third-party application can flexibly use the image processing function in the camera capability exposure unit.

[0093] It is understandable that the implementation method of the image preview method of the system application is different from Figure 5 The implementation methods provided are similar, except that the image preview method of the system application does not need to generate the first cache queue, and accordingly does not need to execute steps 510 and 514. In addition, after the algorithm processing subunit generates the preview image in step 522, it directly transmits the preview image back to the second cache queue, and the system application directly obtains the preview image from the second cache queue. Therefore, the interaction order of other steps in the image preview method of the system application can be referred to Figure 5 The embodiments will not be described in detail here.

[0094] It should be understood that although Figures 1 to 5 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figures 1 to 5 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0095] Figure 6is a structural block diagram of an image preview device according to an embodiment, Figure 6 The image preview device includes a request receiving module 502, a metadata obtaining module 504 and a preview generating module 506.

[0096] The request receiving module 502 is used to receive a first preview request generated by a third-party application and carrying a first cache queue. The metadata obtaining module 504 is used to obtain metadata from the second cache queue in response to the first preview request. The preview generating module 506 is used to process the metadata to generate a preview image, and store the preview image in the first cache queue to instruct the third-party application to obtain the preview image from the first cache queue.

[0097] In one embodiment, the metadata acquisition module 504 is used to create a second cache queue in response to the first preview request; send the second preview request to the hardware abstraction layer to instruct the hardware abstraction layer to store the metadata in the second cache queue in response to the second preview request; and read the metadata from the second cache queue.

[0098] In one embodiment, the image preview device further comprises an interface registration module, which is used to register a third-party callback interface corresponding to the first cache queue, and the third-party callback interface is used by the third-party application to obtain the preview image from the first cache queue.

[0099] In one embodiment, the request receiving module 502 is further used to obtain metadata from the second cache queue in response to the third preview request. The metadata obtaining module 504 is further used to obtain metadata from the second cache queue in response to the third preview request. The preview generating module 506 is further used to process the metadata to generate a preview image, and store the preview image in the second cache queue to instruct the system application to obtain the preview image from the second cache queue through a preset system callback interface.

[0100] In one embodiment, the image preview device further includes an information encapsulation module. The information encapsulation module is used to encapsulate the processing information of the preview image and return the encapsulation result to the corresponding third-party application or the system application, wherein the processing information includes at least one of the image processing information when the preview image is generated for the first time and the decision information when the preview image is generated for the next time.

[0101] Figure 7 is a structural block diagram of an image preview device according to another embodiment. Figure 7In this embodiment, the image preview device includes a request generation module 602, a request sending module 604 and a preview acquisition module 606. The request generation module 602 is used to create a first cache queue and generate a first preview request in response to a preview trigger operation. The request sending module 604 is used to send a first preview request carrying the first cache queue to instruct the camera capability exposure unit to generate a preview image. The preview acquisition module 606 is used to obtain the preview image generated by the camera capability exposure unit in response to the first preview request from the first cache queue.

[0102] The division of each module in the above-mentioned image preview device is only for illustration. In other embodiments, the image preview device can be divided into different modules as needed to complete all or part of the functions of the above-mentioned image preview device. For the specific definition of the image preview device, please refer to the definition of the image preview method above, which will not be repeated here. Each module in the above-mentioned image preview device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0103] The embodiment of the present application also provides an electronic device, Figure 8 FIG. 1 is a schematic diagram of the internal structure of an electronic device in one embodiment. Figure 8 As shown, the electronic device includes a processor and a memory connected via a system bus. The processor is used to provide computing and control capabilities to support the operation of the entire electronic device. The memory may include a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The computer program can be executed by the processor to implement an image preview method provided in each of the following embodiments. The internal memory provides a cached operating environment for the operating system computer program in the non-volatile storage medium. The electronic device can be any terminal device such as a mobile phone, a tablet computer, a PDA (Personal Digital Assistant), a POS (Point of Sales), a vehicle-mounted computer, a wearable device, etc.

[0104] The implementation of each module in the image preview device provided in the embodiment of the present application can be in the form of a computer program. The computer program can be run on a terminal or a server. The program module constituted by the computer program can be stored in the memory of the electronic device. When the computer program is executed by the processor, the steps of the method described in the embodiment of the present application are implemented.

[0105] The embodiment of the present application also provides a computer-readable storage medium, one or more non-volatile computer-readable storage media containing computer-executable instructions, when the computer-executable instructions are executed by one or more processors, the processors execute the steps of the image preview method.

[0106] The embodiment of the present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the image preview method.

[0107] Any reference to memory, storage, database or other medium used in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM), which is used as an external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0108] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. An image preview method, applied to a camera capability exposure unit, wherein the camera capability exposure unit includes a service subunit and an algorithm processing subunit; the method includes: The service subunit receives a first preview request generated by a third-party application and carrying a first cache queue; The business subunit obtains metadata from the second cache queue in response to the first preview request, and calls a Java native interface to transmit the first cache queue to the algorithm processing subunit through the Java native interface; The algorithm processing subunit processes the metadata to generate a preview image, and stores the preview image in the first cache queue to instruct the third-party application to obtain the preview image from the first cache queue.

2. The image preview method according to claim 1, characterized in that: The business sub-unit obtains metadata from the second cache queue in response to the first preview request, including: The service subunit creates a second cache queue in response to the first preview request; The service sub-unit sends a second preview request to the hardware abstraction layer to instruct the hardware abstraction layer to store metadata in the second cache queue in response to the second preview request; The service sub-unit reads the metadata from the second cache queue.

3. The image preview method according to claim 2, characterized in that: Before sending the second preview request to the hardware abstraction layer, the method further includes: A third-party callback interface corresponding to the first cache queue is registered, where the third-party callback interface is used by the third-party application to obtain the preview image from the first cache queue.

4. The image preview method according to any one of claims 1 to 3, characterized in that: Also includes: receiving a third preview request generated by a system application; In response to the third preview request, acquiring metadata from the second cache queue; The metadata is processed to generate a preview image, and the preview image is stored in the second cache queue to instruct the system application to obtain the preview image from the second cache queue through a preset system callback interface.

5. The image preview method according to claim 4, characterized in that: The image format of the preview image returned by the camera capability exposure unit to the system application is in YUV format.

6. The image preview method according to claim 4, characterized in that: Also includes: The processing information of the preview image is encapsulated, and the encapsulation result is returned to the corresponding third-party application or the system application, wherein the processing information includes at least one of the image processing information when the preview image is generated for the first time and the decision information when the preview image is generated for the next time.

7. The image preview method according to claim 6, characterized in that: The image processing information when the preview image is generated for the first time includes at least one of an image processing algorithm adopted by the algorithm processing subunit during processing and a format of the output preview image.

8. An image preview method, characterized in that: Applied to a third-party application, the method includes: In response to the preview triggering operation, creating a first cache queue and generating a first preview request; sending a first preview request carrying the first cache queue to instruct the camera capability exposure unit to generate a preview image; in response to the first preview request, the service subunit of the camera capability exposure unit obtains metadata from the second cache queue, calls a Java native interface, and transmits the first cache queue to the algorithm processing subunit of the camera capability exposure unit through the Java native interface; the algorithm processing subunit processes the metadata to generate a preview image, and stores the preview image in the first cache queue; The preview image is obtained from the first cache queue.

9. The image preview method according to claim 8, characterized in that: The step of creating a first cache queue includes: A third-party application creates a first cache queue; or The third-party application calls other controls to create a first cache queue, and the other controls then transmit the created first cache queue back to the third-party application.

10. An electronic device comprising a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the steps of the image preview method according to any one of claims 1 to 9.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the image preview method according to any one of claims 1 to 9 are implemented.

12. A computer program product, characterized in that When the computer program product is run on a computer, the computer is enabled to execute the steps of implementing any one of the methods of claims 1 to 9.