Method and electronic device for processing image preview requests and image shooting requests
Embodiments of this application provide a photographing method and an electronic device. In the method, the electronic device displays an image preview interface of a target application, where the target application is an application with a camera function, and a preview image frame displayed in the image preview interface is collected based on an image preview request continuously delivered by the target application; the target application generates an image shooting request in response to a received user operation, where an exposure parameter of the image shooting request is different from an exposure parameter of the image preview request; and if both the unprocessed image preview request and the unprocessed image shooting request exist, the electronic device invokes an image sensor to collect a shot image frame corresponding to the image shooting request.
1 . A photographing method, applied to an electronic device, the method comprising:
displaying an image preview interface of a target application, wherein the target application is an application with a camera function, and a preview image frame displayed in the image preview interface is collected based on an image preview request delivered by the target application, and wherein image preview requests are continuously delivered by the target application and stored in a request queue, and the request queue is a first in first out queue;
generating, by the target application, an image shooting request in response to a received user operation, wherein an exposure parameter of the image shooting request is different from an exposure parameter of the image preview request, wherein image shooting requests delivered by the target application are stored in a target module; and
when the image preview request is stored in the request queue and the image shooting request is stored in the target module at a same time, invoking an image sensor to collect a shot image frame corresponding to the image shooting request.
2 . The method according to claim 1 , wherein the electronic device comprises a camera hardware abstraction layer (HAL) module, an image signal processing (ISP) module, and an image sensor drive module, and the method comprises:
successively obtaining, by the camera HAL module, one image preview request from the request queue, and sending each successively obtained one image preview request to the ISP module;
receiving, by the ISP module, each successively obtained one image preview request; and
if reading an image shooting request from the target module, sending, by the ISP module, the image shooting request read from the target module to the image sensor drive module, so that the image sensor drive module drives the image sensor to collect a shot image frame corresponding to the image shooting request; or
if no image shooting request is read from the target module, sending, by the ISP module, an image preview request read from the request queue to the image sensor drive module, so that the image sensor drive module drives the image sensor to collect a preview image frame corresponding to the image preview request.
3 . The method according to claim 2 , further comprising:
if reading an image shooting request from the target module, discarding, by the ISP module, a corresponding image preview request.
4 . The method according to claim 2 , further comprising:
receiving, by the camera HAL module, an image preview request or an image shooting request that is delivered by the target application, storing the image preview request that is delivered by the target application in the request queue, and storing the image shooting request that is delivered by the target application in the target module.
5 . The method according to claim 2 , further comprising:
successively sending, by the ISP module to the camera HAL module, a preview image frame or a shot image frame that is fed back by the image sensor drive module; and
successively storing, by the camera HAL module, the preview image frames or the shot image frames in a zero shutter lag queue.
6 . The method according to claim 5 , further comprising:
in a multi-frame composition shooting scenario, reading, by the camera HAL module, a corresponding quantity of preview image frames and a corresponding quantity of shot image frames from the zero shutter lag queue, and performing a multi-frame image composition operation by using an image processing algorithm that matches a shooting mode, to obtain a target image, wherein the target image is used to be stored in a gallery application.
7 . The method according to claim 1 , wherein the target application is a camera application.
8 . An electronic device, comprising:
one or more processors;
a memory; and
one or more computer programs, wherein the one or more computer programs are stored in the memory, and when the computer programs are executed by the one or more processors, the electronic device is enabled to:
display an image preview interface of a target application, wherein the target application is an application with a camera function, and a preview image frame displayed in the image preview interface is collected based on an image preview request delivered by the target application, and wherein image preview requests are continuously delivered by the target application and stored in a request queue, and the request queue is a first in first out queue;
generate, by the target application, an image shooting request in response to a received user operation, wherein an exposure parameter of the image shooting request is different from an exposure parameter of the image preview request, wherein image shooting requests delivered by the target application are stored in a target module; and
when the image preview request is stored in the request queue and the image shooting request is stored in the target module at a same time, invoke an image sensor to collect a shot image frame corresponding to the image shooting request.
9 . The electronic device according to claim 8 , wherein the electronic device comprises a camera hardware abstraction layer (HAL) module, an image signal processing (ISP) module, and an image sensor drive module, and when the computer programs are executed by the one or more processors, the electronic device is enabled to:
successively obtain, by the camera HAL module, one image preview request from the request queue, and send each successively obtained one image preview request to the ISP module;
receive, by the ISP module, each successively obtained one image preview request; and
if reading an image shooting request from the target module, send, by the ISP module, the image shooting request read from the target module to the image sensor drive module, so that the image sensor drive module drives the image sensor to collect a shot image frame corresponding to the image shooting request; or
if no image shooting request is read from the target module, send, by the ISP module, an image preview request read from the request queue to the image sensor drive module, so that the image sensor drive module drives the image sensor to collect a preview image frame corresponding to the image preview request.
10 . The electronic device according to claim 9 , wherein when the computer programs are executed by the one or more processors, the electronic device is enabled further to:
if reading an image shooting request from the target module, discard, by the ISP module, a corresponding image preview request.
11 . The electronic device according to claim 9 , wherein when the computer programs are executed by the one or more processors, the electronic device is enabled further to:
receive, by the camera HAL module, an image preview request or an image shooting request that is delivered by the target application, store the image preview request that is delivered by the target application in the request queue, and store the image shooting request that is delivered by the target application in the target module.
12 . The electronic device according to claim 9 , wherein when the computer programs are executed by the one or more processors, the electronic device is enabled further to:
successively send, by the ISP module to the camera HAL module, a preview image frame or a shot image frame that is fed back by the image sensor drive module; and
successively store, by the camera HAL module, the preview image frames or the shot image frames in a zero shutter lag queue.
13 . The electronic device according to claim 12 , wherein when the computer programs are executed by the one or more processors, the electronic device is enabled further to:
in a multi-frame composition shooting scenario, read, by the camera HAL module, a corresponding quantity of preview image frames and a corresponding quantity of shot image frames from the zero shutter lag queue, and perform a multi-frame image composition operation by using an image processing algorithm that matches a shooting mode, to obtain a target image, wherein the target image is used to be stored in a gallery application.
14 . The electronic device according to claim 8 , wherein the target application is a camera application.
15 . A non-transitory computer-readable storage medium, comprising a computer program, wherein when the computer program is run on an electronic device, the electronic device is enabled to:
display an image preview interface of a target application, wherein the target application is an application with a camera function, and a preview image frame displayed in the image preview interface is collected based on an image preview request delivered by the target application, and wherein image preview requests are continuously delivered by the target application and stored in a request queue, and the request queue is a first in first out queue;
generate, by the target application, an image shooting request in response to a received user operation, wherein an exposure parameter of the image shooting request is different from an exposure parameter of the image preview request, wherein image shooting requests delivered by the target application are stored in a target module; and
when the image preview request is stored in the request queue and the image shooting request is stored in the target module at a same time, invoke an image sensor to collect a shot image frame corresponding to the image shooting request.
16 . The non-transitory computer-readable storage medium according to claim 15 , wherein the electronic device comprises a camera hardware abstraction layer (HAL) module, an image signal processing (ISP) module, and an image sensor drive module, and when the computer program is run on the electronic device, the electronic device is enabled to:
successively obtain, by the camera HAL module, one image preview request from the request queue, and send each successively obtained one image preview request to the ISP module;
receive, by the ISP module, each successively obtained one image preview request; and
if reading an image shooting request from the target module, send, by the ISP module, the image shooting request read from the target module to the image sensor drive module, so that the image sensor drive module drives the image sensor to collect a shot image frame corresponding to the image shooting request; or
if no image shooting request is read from the target module, send, by the ISP module, an image preview request read from the request queue to the image sensor drive module, so that the image sensor drive module drives the image sensor to collect a preview image frame corresponding to the image preview request.
17 . The non-transitory computer-readable storage medium according to claim 16 , wherein when the computer program is run on the electronic device, the electronic device is enabled to:
if reading an image shooting request from the target module, discard, by the ISP module, a corresponding image preview request.
18 . The non-transitory computer-readable storage medium according to claim 16 , wherein when the computer program is run on the electronic device, the electronic device is enabled to:
receive, by the camera HAL module, an image preview request or an image shooting request that is delivered by the target application, store the image preview request that is delivered by the target application in the request queue, and store the image shooting request that is delivered by the target application in the target module.
19 . The non-transitory computer-readable storage medium according to claim 16 , wherein when the computer program is run on the electronic device, the electronic device is enabled to:
successively send, by the ISP module to the camera HAL module, a preview image frame or a shot image frame that is fed back by the image sensor drive module; and
successively store, by the camera HAL module, the preview image frames or the shot image frames in a zero shutter lag queue.
20 . The non-transitory computer-readable storage medium according to claim 15 , wherein the target application is a camera application.