CN118678208A - Camera preview method and device, terminal and storage medium - Google Patents
Camera preview method and device, terminal and storage medium Download PDFInfo
- Publication number
- CN118678208A CN118678208A CN202310258617.2A CN202310258617A CN118678208A CN 118678208 A CN118678208 A CN 118678208A CN 202310258617 A CN202310258617 A CN 202310258617A CN 118678208 A CN118678208 A CN 118678208A
- Authority
- CN
- China
- Prior art keywords
- image
- display
- preview
- time interval
- preview image
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 58
- 230000005540 biological transmission Effects 0.000 claims abstract description 54
- 230000004044 response Effects 0.000 claims description 8
- 238000001514 detection method Methods 0.000 claims description 3
- 230000000903 blocking effect Effects 0.000 abstract description 9
- 238000012545 processing Methods 0.000 description 18
- 238000005457 optimization Methods 0.000 description 13
- 238000004891 communication Methods 0.000 description 10
- 238000005516 engineering process Methods 0.000 description 6
- 238000007499 fusion processing Methods 0.000 description 5
- 238000010586 diagram Methods 0.000 description 4
- 230000006870 function Effects 0.000 description 4
- 230000003287 optical effect Effects 0.000 description 4
- 230000008569 process Effects 0.000 description 4
- 230000005236 sound signal Effects 0.000 description 4
- 230000009286 beneficial effect Effects 0.000 description 3
- 230000001133 acceleration Effects 0.000 description 2
- 230000006978 adaptation Effects 0.000 description 2
- 238000004364 calculation method Methods 0.000 description 2
- 230000008859 change Effects 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 230000004927 fusion Effects 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 238000007726 management method Methods 0.000 description 2
- 230000009471 action Effects 0.000 description 1
- 230000003044 adaptive effect Effects 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000007613 environmental effect Effects 0.000 description 1
- 238000009499 grossing Methods 0.000 description 1
- 238000003384 imaging method Methods 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000007500 overflow downdraw method Methods 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 230000009467 reduction Effects 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Landscapes
- Studio Devices (AREA)
Abstract
The disclosure relates to a camera preview method and device, a terminal and a storage medium, which are applied to electronic equipment comprising a display screen, wherein the method comprises the following steps: responsive to detecting a start instruction for a camera application in the electronic device, capturing an image; generating a preview image based on the acquired image, and adding the preview image into a cache queue; determining a transmission time interval of the preview image; and transmitting each preview image in the buffer queue to the display screen for display based on the transmission time interval. According to the method, the electronic equipment can send the preview images to the display screen at fixed time intervals, interface blocking conditions during the image previewing of the electronic equipment are reduced, display smoothness of the preview interface of the electronic equipment is improved, and the method has the advantages of being small in occupied resources, low in power consumption, high in universality and the like.
Description
Technical Field
The disclosure relates to the technical field of electronic equipment, and in particular relates to a camera preview method and device, a terminal and a storage medium.
Background
Cameras are the most common application in intelligent terminal equipment at present, and with the rapid development of image capturing technology, the quality requirements of users on images captured by the cameras are higher and higher. In order to improve the shooting effect of a camera and facilitate a user to intuitively see a preview image with high image quality before shooting, a plurality of image optimization algorithms are generally added in the camera preview function.
However, when the image quality of the preview image of the camera is improved through an image optimization algorithm, the preview image displayed on the preview interface of the camera is easy to cause unsmooth and a clamping sense, and the method is particularly obvious when the camera shoots a moving object.
Disclosure of Invention
The disclosure provides a camera preview method and device, a terminal and a storage medium.
According to a first aspect of embodiments of the present disclosure, there is provided a camera preview method applied to an electronic device including a display screen, including:
responsive to detecting a start instruction for a camera application in the electronic device, capturing an image;
Generating a preview image based on the acquired image, and adding the preview image into a cache queue;
determining a transmission time interval of the preview image;
And transmitting each preview image in the buffer queue to the display screen for display based on the transmission time interval.
In some embodiments, the determining the transmission time interval of the preview image includes:
Acquiring an acquisition frame rate of the electronic equipment for acquiring the image;
Determining the acquisition duration of each image frame based on the acquisition frame rate;
and determining the sending time interval of the preview image according to the acquisition time length of each image frame.
In some embodiments, the method further comprises:
Acquiring the exposure time of the electronic equipment;
The determining the sending time interval of the preview image according to the acquisition time length of each image frame includes:
And determining the longer time length of the acquisition time length and the exposure time length of the image frame as the sending time interval of the preview image.
In some embodiments, the method further comprises:
Acquiring a display frame rate of the display screen;
Determining the display duration of each image frame according to the display frame rate;
And sending each preview image in the buffer queue to the display screen for display based on the sending time interval, including:
And transmitting each preview image in the buffer queue to the display screen for display based on the display time length and the transmission time interval of each image frame.
In some embodiments, the sending each preview image in the buffer queue to the display screen for display based on the display duration and the sending time interval of each image frame includes:
Responding to the sending time interval being greater than or equal to the display duration of each image frame, and sending the preview images in the buffer queue to the display screen for display at the sending time interval;
And in response to the sending time interval being smaller than the display duration of each image frame, sending the preview images in the buffer queue to the display screen for display in the display duration of each image frame.
In some embodiments, the sending, based on the sending time interval, each preview image in the buffer queue to the display screen for display includes:
and based on the sending time interval, sending each preview image to the display screen for display according to the time sequence of adding each preview image into the buffer queue.
In some embodiments, the generating the preview image based on the acquired image and adding the preview image to a buffer queue includes:
And generating the preview image after fusing at least two images acquired by the electronic equipment, and adding the preview image into the cache queue.
According to a second aspect of embodiments of the present disclosure, there is provided a camera preview apparatus applied to an electronic device including a display screen, including:
The acquisition module is used for responding to the detection of a starting instruction of camera application in the electronic equipment and acquiring an image;
the caching module is used for generating a preview image based on the acquired image and adding the preview image into a caching queue;
a first determining module, configured to determine a transmission time interval of the preview image;
And the display module is used for transmitting each preview image in the buffer queue to the display screen for display based on the transmission time interval.
In some embodiments, the first determining module is further configured to obtain an acquisition frame rate at which the electronic device acquires the image; determining the acquisition duration of each image frame based on the acquisition frame rate; and determining the sending time interval of the preview image according to the acquisition time length of each image frame.
In some embodiments, the apparatus further comprises:
The first acquisition module is used for acquiring the exposure time of the electronic equipment;
the first determining module is further configured to determine a longer duration of the acquisition duration and the exposure duration of the image frame as the transmission time interval of the preview image.
In some embodiments, the apparatus further comprises:
The second acquisition module is used for acquiring the display frame rate of the display screen;
The second determining module is used for determining the display duration of each image frame according to the display frame rate;
And the display module is also used for transmitting each preview image in the buffer queue to the display screen for display based on the display time length and the transmission time interval of each image frame.
In some embodiments, the display module is further configured to send the preview images in the buffer queue to the display screen for display at the sending time interval in response to the sending time interval being greater than or equal to the display duration of each of the image frames; and in response to the sending time interval being smaller than the display duration of each image frame, sending the preview images in the buffer queue to the display screen for display in the display duration of each image frame.
In some embodiments, the display module is further configured to send each of the preview images to the display screen for display in a time sequence in which each of the preview images joins the buffer queue based on the sending time interval.
In some embodiments, the buffer module is further configured to generate the preview image after performing fusion processing on at least two images acquired by the electronic device, and add the preview image to the buffer queue.
According to a third aspect of embodiments of the present disclosure, there is provided an electronic device, comprising:
A processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to perform the camera preview method as described in the first aspect above.
According to a fourth aspect of embodiments of the present disclosure, there is provided a storage medium comprising:
the instructions in the storage medium, when executed by a processor of the electronic device, enable the electronic device to perform the camera preview method as described in the first aspect above.
The technical scheme provided by the embodiment of the disclosure can comprise the following beneficial effects:
In the embodiment of the disclosure, the electronic device adds the preview images processed by the image optimization algorithm into the buffer queue, namely, the preview images with different generating speeds are buffered firstly, and then each preview image in the buffer queue is sent to the display screen for display based on the sending time interval, namely, the preview images are sent to the display screen at the same time interval, so that the preview images are sent to the display screen at the fixed time interval, the frame rate of the preview images sent to the display screen is fixed, the display screen is convenient to display the preview images at the stable frame rate, and the conditions of blocking and unsmooth preview interface of the display screen are reduced. In addition, the preview images in the buffer queue are input and output, so that the preview images are added into the buffer queue and are sent to the display screen at the sending time interval, the electronic equipment resource occupation is less, the power consumption is lower, and the method has the characteristics of strong universality and simplicity and easiness in implementation.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure.
Fig. 1 is a flowchart of a camera preview method according to an embodiment of the present disclosure.
Fig. 2 is a flowchart two of a camera preview method according to an embodiment of the present disclosure.
Fig. 3 is a flowchart illustrating a camera preview method according to an embodiment of the present disclosure.
Fig. 4 is a diagram of a camera preview device, according to an example embodiment.
Fig. 5 is a block diagram illustrating an electronic device apparatus 800 according to an example embodiment.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present disclosure as detailed in the accompanying claims.
Fig. 1 is a flowchart of a camera preview method according to an embodiment of the present disclosure, and as shown in fig. 1, the camera preview method applied to an electronic device including a display screen includes the following steps:
s11, responding to detection of a starting instruction of camera application in the electronic equipment, and acquiring an image;
s12, generating a preview image based on the acquired image, and adding the preview image into a cache queue;
s13, determining a transmission time interval of the preview image;
and S14, based on the sending time interval, sending each preview image in the buffer queue to the display screen for display.
In an embodiment of the present disclosure, an electronic device including a display screen includes: a mobile device and a stationary device; the mobile device includes: a cell phone, a tablet computer, a wearable device or an intelligent robot, etc. The stationary device includes, but is not limited to, a personal computer (Personal Computer, PC).
In step S11, the electronic device detects a start instruction of the camera application by the user, and the electronic device may generate a captured image through image data captured by the image sensor. The starting instruction of the camera application in the electronic equipment can be triggered by clicking the camera application of the electronic equipment by a user; the triggering of the camera application of the electronic device by the user by voice operation may also be performed. For example, a user clicks a camera Application (APP) on a mobile phone to start a shooting function of the mobile phone; for example, the user sends out "open camera shoot" to the intelligent robot, and starts the shooting function of the intelligent robot.
In step S12, a preview image is generated based on the collected image, which may be that the single image collected by the image sensor is subjected to optimization processing such as beautifying and noise reduction; or fusion processing is carried out on a plurality of images shot by a plurality of cameras of the electronic equipment; the image format conversion processing can be performed on the shot image so as to meet various requirements of users on shooting of the electronic equipment.
In the embodiment of the disclosure, after obtaining the preview image that has undergone the optimization process, the electronic device may add the preview image to a buffer queue of the memory, and may use a first-in first-out (First Input First Output, FIFO), least recently Used (LEAST RECENTLY Used, LRU), or other buffer algorithm to buffer. When the preview image is added into the buffer queue, a buffer identification of the preview image may be added, and the buffer identification may be buffer time information, image size information, and the like.
In step S13, the electronic device determines a transmission time interval of the preview image, which may be determined according to an acquisition frame rate at which the image sensor acquires the image; or determining the sending time interval of the preview image according to the acquisition frame rate and the exposure time of the image sensor; but may also be a time interval set by a user or developer. The transmission time interval of the preview image refers to the transmission time interval of two adjacent frames of preview images.
In the embodiment of the present disclosure, in step S14, when the electronic device sends each preview image in the buffer queue to the display screen for display, the preview images in the buffer queue may be sent to the display screen for display at a sending time interval; and each preview image in the buffer queue can be sent to the display screen for display based on the display time length and the sending time interval of each frame of image of the display screen.
It should be noted that, in the embodiment of the present disclosure, after detecting that the preview image exists in the buffer queue, the electronic device may start to send each preview image in the buffer queue to the display screen for display based on the sending time interval after the preset duration, so as to reserve a certain buffer time for the buffer queue, so that the preview image in the buffer queue can be obtained and sent by the electronic device all the time. The method for reserving a certain buffer time in the buffer queue can be that a preset buffer time is determined according to data such as acquisition time length, exposure time length, display time length and the like of the electronic equipment, and the electronic equipment waits for the preset time before sending the preview image from the buffer queue for the first time; or backing up the first two frames of preview images in the buffer queue, and respectively transmitting the first two frames of images twice, so as to strive for two frames of display time for the subsequent preview images. Therefore, a certain buffer time is reserved for the buffer queue, so that slight blocking caused by no preview data in the buffer queue due to the fact that the generation speed of the preview image is slightly slow can be reduced, and the preview image in the buffer queue can be smoothly sent to the display screen.
It should be noted that, after the electronic device captures an image through the image sensor, the image processing algorithm may be used to optimize the captured image, so that the image quality of the displayed preview image is better. However, the image processing algorithms used may be different for different images acquired, such as a daytime acquired image and a night acquired image, or a still scene acquired image and a moving scene acquired image, resulting in different durations for generating the preview image. In one case, the electronic device may display the preview image at a predetermined display frame rate, and at this time, a possibility that the preview image is not yet generated may occur, which may cause a situation that the display of the preview image is not smooth, is stuck, and the like. In another case, the display frame rate of the display screen can be continuously switched to display the preview image with unstable frame rate in real time, but on one hand, the display frame rate supported by the display screen may not be adapted to the generation frame rate of the preview image, and the display of the preview image is not smooth, is blocked, and other situations occur; on the other hand, the calculation amount of the display screen is increased.
In view of the above, in the related art, it is generally considered that the image optimization algorithm has a large calculation amount and occupies too much hardware resources of the electronic device, so that the preview screen is blocked, and therefore, the image optimization algorithm is properly cut, so as to reduce the consumption of resources of the electronic device, thereby improving the fluency of image preview. For example, the image optimization algorithm with higher consumption of a central processing unit (Central Processing Unit, CPU) of the mobile phone can be cut, so that the consumption of the CPU of the mobile phone in the image optimization process is reduced, and the fluency of image preview is improved. However, the proposal of the related art clipping optimization algorithm can improve the fluency and simultaneously consume the image quality of the preview image.
In the embodiment of the disclosure, the electronic device adds the preview images processed by the image optimization algorithm into the buffer queue, namely, the preview images with different generating speeds are buffered firstly, and then each preview image in the buffer queue is sent to the display screen for display based on the sending time interval, namely, the preview images are sent to the display screen at the same time interval, so that the preview images are sent to the display screen at the fixed time interval, the frame rate of the preview images sent to the display screen is fixed, the display screen is convenient to display the preview images at the stable frame rate, and the conditions of blocking and unsmooth preview interface of the display screen are reduced. In addition, the preview images in the buffer queue are input and output, so that the preview images are added into the buffer queue and are sent to the display screen at the sending time interval, the electronic equipment resource occupation is less, the power consumption is lower, and the method has the characteristics of strong universality and simplicity and easiness in implementation.
Fig. 2 is a flowchart two of a camera preview method according to an embodiment of the present disclosure, as shown in fig. 2, the determining a transmission time interval of the preview image includes:
s21, acquiring an acquisition frame rate of the electronic equipment for acquiring the image;
s22, determining the acquisition duration of each image frame based on the acquisition frame rate;
S23, determining the sending time interval of the preview image according to the acquisition time length of each image frame.
In step S21, the acquired frame rate of the electronic device indicates the number of images captured by the image sensor per unit time, which may be the frame rate of photographing by the camera; or the frame rate at which the camera records the video. In the embodiment of the disclosure, the acquisition frame rate may be preset when the electronic device leaves the factory, or may be set by a user after the device leaves the factory.
In step S22, the electronic device determines the acquisition duration of each image Frame based on the acquisition Frame rate, for example, the acquisition Frame rate of the smart phone is 30 frames Per Second (fps), which means that the smart phone can acquire 30 frames of images Per Second, that is, the acquisition duration of each image Frame is 1/30 seconds.
In step S23, according to the acquisition duration of each image frame, determining a transmission time interval of the preview image, which may be directly using the acquisition duration as the transmission time interval of the preview image; the acquisition time length can be added or multiplied by a numerical value to be used as the transmission time interval of the preview image, and the transmission time interval of the preview image can be determined together based on the acquisition time length and the exposure time length of the camera. For example, the acquisition duration is 1/30 second, the acquisition duration is multiplied by a minute value of 30/25, and 1/25 second is taken as the time interval of the preview image.
In the embodiment of the disclosure, the acquisition frame rate of the camera acquisition image is acquired, the acquisition time length is calculated based on the acquisition frame rate, and the sending time interval of the preview image is determined according to the acquisition time length, so that the buffer queue is beneficial to sending the preview image at a frequency close to the frequency of generating the acquisition image by the image sensor of the electronic equipment, the display screen can be beneficial to displaying at a shooting frame rate close to the electronic equipment, and the instantaneity of displaying the preview image can be further improved on the basis of smoothing the preview image; in addition, the storage time of each preview image in the cache queue can be reduced, so that the memory consumption of the electronic equipment is reduced.
In some embodiments, the method further comprises:
Acquiring the exposure time of the electronic equipment;
The determining the sending time interval of the preview image according to the acquisition time length of each image frame includes:
And determining the longer time length of the acquisition time length and the exposure time length of the image frame as the sending time interval of the preview image.
In the embodiment of the disclosure, the exposure time of the electronic device characterizes the time when the electronic device collects a single frame of image, the time when light irradiates the image sensor, the exposure time can be preset, can be automatically calculated by the electronic device according to the environmental condition, and can be controlled by a user during shooting. In the embodiment of the disclosure, the electronic device may acquire a preset exposure time for the camera to acquire an image; the current exposure time of the camera can also be obtained in real time through the camera App.
Because the electronic device may not be able to complete image acquisition with the set acquisition time length when photographing, in some special cases, for example, when photographing a night scene by the electronic device, a long exposure may be required for photographing a frame of image, and the exposure time length may be longer than the set acquisition time length, at this time, the electronic device may not be able to acquire the image according to the set acquisition time length. For example, when the electronic device performs long exposure, when the preset acquisition duration corresponding to the acquisition frame rate is smaller than the exposure duration, although the time of the preset acquisition duration is already up, the exposure processing of the frame image is not yet finished (i.e. the image acquisition is not finished), and the image acquisition may not be completed until the exposure is finished. Therefore, the preview image is still transmitted with the preset acquisition time length during long exposure, and the transmission speed of the preview image is larger than the generation speed, so that the problem of blocking caused by insufficient generation speed of the preview image in the buffer queue can occur.
In contrast, in the embodiment of the present disclosure, the electronic device compares the acquired acquisition duration and the exposure duration of each acquired image frame, and uses the larger duration as the transmission time interval of the preview image, so that the occurrence of the jamming condition can be reduced. The comparison method may be a difference method or a ratio method. For example, when the collection duration minus the exposure duration to obtain a positive number, it may be determined that the collection duration is longer, and the collection duration is used as a transmission time interval of the preview image; when the acquisition time length is divided by the exposure time length to obtain a decimal, the exposure time length can be determined to be longer, and the exposure time length is taken as the transmission time interval of the preview image.
In the embodiment of the disclosure, the exposure time of the electronic device is obtained, the collection time of the image frames and the longer time of the exposure time are determined as the sending time interval of the preview images, so that the sending time interval of the preview images is consistent with the generating time interval, the blocking of the preview images caused by the overlong exposure time of the electronic device is reduced, the electronic device can stably output the preview images in various shooting environments, and the stability of the preview function of the electronic device is improved.
In some embodiments, the method further comprises:
Acquiring a display frame rate of the display screen;
Determining the display duration of each image frame according to the display frame rate;
And sending each preview image in the buffer queue to the display screen for display based on the sending time interval, including:
And transmitting each preview image in the buffer queue to the display screen for display based on the display time length and the transmission time interval of each image frame.
In the embodiment of the disclosure, the display frame rate of the display screen of the electronic device characterizes the number of preview image frames that can be presented per second, and according to the display frame rate, the display duration of each image frame can be determined. For example, when the display frame rate of the display screen of the electronic device is 60fps, the display duration of each image frame is 1/60 second. In the embodiment of the disclosure, the display frame rate of the display screen may be set by a user or developer; it may also be that the electronic device is automatically adapted according to various display scenarios, for example, the mobile phone displays a frame rate of 120fps in the game mode and 60fps in the viewing mode. In general, the display frame rate of the electronic device determines the upper limit of the frame rate at which the electronic device displays the preview image. For example, when the display frame rate of the electronic device is 60fps, the display screen of the electronic device can display the preview image only at a frame rate of 60fps, that is, the display screen displays 60 frames of preview image per second, even if the transmitted preview image frame rate is 90 fps.
In the embodiment of the disclosure, the electronic device may obtain a display frame rate of the display screen, calculate a display duration of each frame of preview image according to the display frame rate of the display screen, compare the display duration of each frame of preview image with a transmission time interval, and transmit each preview image in the buffer queue to the display screen for display based on a comparison result. The comparison mode of the display time length of each frame of preview image and the sending time interval can adopt a difference method, a ratio method and the like.
It should be noted that, the electronic device refreshes the display preview image at the display frame rate, that is, displays each frame of preview image at the display duration. If the preview image sending time interval is smaller than the display time length, the preview image sending speed is too high for the display screen, and the display is possibly congested; if the preview image sending time interval is longer than the display duration, the sending speed of the preview image for the display screen is too slow, which may cause that the display screen cannot acquire the preview image for display in real time. Thus, too fast or too slow a preview image transmission speed for the display screen may cause the preview image display to jam.
In the embodiment of the disclosure, the electronic device acquires and determines the display duration of each image frame displayed by the display screen, and sends each preview image in the buffer queue to the display screen for display based on the display duration and the sending time interval, so that the preview image sending time interval in the buffer queue is favorably matched with the display duration of the display screen, namely the preview image is sent at the display frame rate speed of the adaptive display screen, and the display stability of the preview image is improved.
In some embodiments, the sending each preview image in the buffer queue to the display screen for display based on the display duration and the sending time interval of each image frame includes:
Responding to the sending time interval being greater than or equal to the display duration of each image frame, and sending the preview images in the buffer queue to the display screen for display at the sending time interval;
And in response to the sending time interval being smaller than the display duration of each image frame, sending the preview images in the buffer queue to the display screen for display in the display duration of each image frame.
In the embodiment of the disclosure, based on the transmission time interval and the display time length of each image frame, each preview image in the buffer queue is transmitted to the display screen for display, or when the transmission time interval is greater than or equal to the display time length of each image frame, the preview image in the buffer queue is transmitted to the display screen for display at the transmission time interval; or when the sending time interval is smaller than the display time length of each image frame, sending the preview images in the buffer queue to the display screen for display in the display time length of each image frame.
It can be understood that, based on the display duration and the transmission time interval of each image frame, when the display duration is greater than or equal to the transmission time interval, the transmission speed of the preview image is greater than or equal to the display speed of the display screen, so that the preview image is transmitted in the display duration, and the blocking caused by relatively slow display speed of the display screen can be reduced; when the display duration is smaller than the transmission time interval, the transmission speed of the preview image is smaller than the display speed of the display screen, and the preview image is transmitted at the transmission time interval, so that the blocking caused by slow transmission speed of the preview image can be reduced.
It should be noted that, in the embodiment of the present disclosure, in the case where the display duration and the transmission interval are inconsistent, the transmission policy may be changed so that the preview image can be displayed smoothly. For example, when the transmission time interval of the preview image is 1/30 second and the display duration of each image frame is 1/60 second, the electronic device transmits the preview image to the display screen at the time interval of 1/30 second, the display screen displays the preview image (60 fps) at the speed of 1/60 second for each frame, the preview image of each frame can be repeatedly displayed once in a double display manner, and the preview display screen can be smoothly displayed. For another example, when the transmission time interval of the preview image is 1/60 second and the display time period of each image frame is 1/30 second, the electronic device can refresh the preview image only at 1/30 second at most, and then the preview image can be transmitted to the display screen at intervals of the display time period, so that the display screen can display the preview image (30 fps) at a speed of 1/30 second for each frame, and the preview display screen can be smoothly displayed.
In some embodiments, the sending, based on the sending time interval, each preview image in the buffer queue to the display screen for display includes:
and based on the sending time interval, sending each preview image to the display screen for display according to the time sequence of adding each preview image into the buffer queue.
In the embodiment of the disclosure, after the electronic device stores the generated preview images in the buffer queue, the generated preview images are not immediately transmitted to the display screen, but the preview images are dequeued according to the time sequence of adding the preview images into the buffer queue based on the transmission time interval of the preview images, so that the preview images which are first enqueued are firstly transmitted to the display screen. For example, the electronic device may detect the buffer time information of each preview image in the buffer queue, and first send each preview image with the buffer time information in front to the display screen.
In the embodiment of the disclosure, based on the sending time interval, according to the time sequence of adding each preview image into the buffer queue, each preview image is sent to the display screen for display, so that each preview image which is first in queue is first out queue, and the display according to shooting time sequence of the preview image is facilitated. In addition, the situations that useful data are not dequeued and dequeued data are not needed and the like caused by unordered dequeuing are reduced, so that the cache resources of the electronic equipment are saved, and the efficiency of previewing images by the electronic equipment is improved.
In some embodiments, the generating the preview image based on the acquired image and adding the preview image to a buffer queue includes:
And generating the preview image after fusing at least two images acquired by the electronic equipment, and adding the preview image into the cache queue.
In the embodiment of the disclosure, the electronic device may collect multiple images based on one camera, or collect multiple images based on multiple cameras, and fuse information of the multiple images, so as to obtain a preview image with richer information. The method of fusion processing can be pixel-level image fusion; feature level image fusion is also possible. For example, the electronic device can acquire the same object through a plurality of cameras to obtain a plurality of acquired images, and the dominant feature information in each acquired image is extracted in a targeted manner by using a feature level image fusion method, so that the dominant features of the plurality of acquired images are fused, and a preview image with higher image quality is obtained.
In the embodiment of the disclosure, at least two images acquired by the electronic equipment are fused to generate the preview image, and the preview image is added into the buffer queue, so that the image quality of the preview image can be improved through image fusion processing, and the effect of the preview image of the electronic equipment is further improved.
The following description will take a mobile phone as an example. Fig. 3 is a flowchart illustrating an exemplary process of a camera preview method according to an embodiment of the present disclosure, where, as shown in fig. 3, the camera preview method includes the following steps:
S31, the camera service receives the preview image sent by the hardware abstraction layer and adds the preview image into the cache queue.
In this embodiment, the camera application program is software on the mobile phone for controlling the camera to shoot, that is, the camera application in the embodiment of the disclosure; the camera service is a process of receiving and processing a request sent by a camera application program in the electronic device, namely a system service on the electronic device in the embodiment of the disclosure; in this embodiment, the hardware abstraction layer is an interface framework layer for controlling the hardware to perform related operations in the electronic device, that is, an interface between the electronic device and the image sensor in the real-time example of the disclosure.
In this embodiment, the user clicks on the camera application program to start shooting, that is, in response to detecting a start instruction of the camera application in the electronic device in the embodiment of the present disclosure; the hardware abstraction layer controls the image sensor to collect images, namely the electronic equipment in the embodiment of the disclosure collects images; the hardware abstraction layer performs image optimization processing on the acquired image to obtain a preview image, namely, the preview image is generated based on the acquired image in the embodiment of the disclosure; the camera service receives the preview image sent by the hardware abstraction layer, and adds the preview image into the buffer queue, i.e. adds the preview image into the buffer queue in the embodiment of the disclosure.
S32, the camera application program obtains the current acquisition time length and exposure time length of each image frame of the electronic equipment, and determines a value with a longer time length as a sending time interval of the preview image.
In this embodiment, the acquisition duration is the time for the mobile phone to acquire each image frame, that is, the acquisition duration of each image frame in the embodiment of the present disclosure; the exposure time is the exposure time of each image frame shot by the mobile phone, namely the exposure time of each image frame in the embodiment of the disclosure; the camera application program obtains the current collection time length and exposure time length of each image frame of the electronic equipment, namely, the collection time length of the electronic equipment and the exposure time length of the electronic equipment are obtained and determined in the embodiment of the disclosure; and determining a value with a longer duration as a transmission time interval of the preview image, namely determining a longer duration of the acquisition duration and the exposure duration of the image frame as the transmission time interval of the preview image in the embodiment of the disclosure.
S33, the camera application program continuously transmits a display signal to the camera service at transmission time intervals.
In this embodiment, the start-to-send signal is a send instruction sent by the camera application to the camera service, and the camera application continuously sends the start-to-send signal to the camera service at a sending time interval, i.e., based on the sending time interval in the embodiment of the present disclosure.
S34, the camera service detects whether a signal for starting to send is received or not; if yes, go to step S35; if not, go to step S34.
In this embodiment, if the camera service receives the start display signal sent by the camera application, the camera service executes step S35; if the camera service does not receive the start display signal sent by the camera application, the camera service continues to step S34. In this embodiment, the camera service detects whether a start send signal is received, i.e., in the presently disclosed embodiment, determines whether to send a preview image.
S35, the camera service confirms that a signal for starting to send is received, and the preview image which is enqueued earliest is sent to the display screen.
In this embodiment, the preview image that is the earliest enqueued is the preview image that is added to the buffer queue and has the earliest time, and the camera service confirms that the signal to start sending is received, and sends the preview image that is the earliest enqueued to the display screen.
In the embodiment of the disclosure, the electronic device adds the preview images processed by the image optimization algorithm into the buffer queue, namely, the preview images with different generating speeds are buffered firstly, and then each preview image in the buffer queue is sent to the display screen for display based on the sending time interval, namely, the preview images are sent to the display screen at the same time interval, so that the preview images are sent to the display screen at fixed time intervals, the frame rate of the preview images sent to the display screen is fixed, the display screen is convenient to display the preview images at a stable frame rate, and the conditions of blocking and unsmooth preview interface of the display screen are reduced. In addition, preview images based on the cache queue are input and output, so that the preview images are added into the cache queue and are sent to the display screen at the sending time interval, the electronic equipment resource occupation is less, the power consumption is lower, and the method has the characteristics of strong universality and simplicity and easiness in implementation.
Fig. 4 is a diagram of a camera preview device, according to an example embodiment. Referring to fig. 4, in an alternative embodiment, the apparatus includes:
An acquisition module 401, responsive to detecting a start instruction for a camera application in the electronic device, for acquiring an image;
A buffer module 402, configured to generate a preview image based on the acquired image, and add the preview image to a buffer queue;
a first determining module 403, configured to determine a transmission time interval of the preview image;
and the display module 404 is configured to send each preview image in the buffer queue to the display screen for display based on the sending time interval.
In some embodiments, the first determining module 403 is further configured to obtain an acquisition frame rate at which the electronic device acquires the image; determining the acquisition duration of each image frame based on the acquisition frame rate; and determining the sending time interval of the preview image according to the acquisition time length of each image frame.
In some embodiments, the apparatus further comprises:
A first obtaining module 405, configured to obtain an exposure duration of the electronic device;
the first determining module 403 is further configured to determine a longer duration of the acquisition duration and the exposure duration of the image frame as the transmission time interval of the preview image.
In some embodiments, the apparatus further comprises:
a second obtaining module 405, configured to obtain a display frame rate of the display screen;
a second determining module 406, configured to determine a display duration of each image frame according to the display frame rate;
the display module 404 is further configured to send each preview image in the buffer queue to the display screen for display based on the display duration and the sending time interval of each image frame.
In some embodiments, the display module 404 is further configured to send the preview images in the buffer queue to the display screen for display at the sending time interval in response to the sending time interval being greater than or equal to the display duration of each of the image frames; and in response to the sending time interval being smaller than the display duration of each image frame, sending the preview images in the buffer queue to the display screen for display in the display duration of each image frame.
In some embodiments, the display module 404 is further configured to send each of the preview images to the display screen for display in a time sequence of adding each of the preview images to the buffer queue based on the sending time interval.
In some embodiments, the buffer module 402 is further configured to generate the preview image after performing fusion processing on at least two images acquired by the electronic device, and add the preview image to the buffer queue.
The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.
Fig. 5 is a block diagram illustrating an electronic device apparatus 800 according to an example embodiment. For example, the device 800 may be a mobile phone, mobile computer, or the like.
Referring to fig. 5, apparatus 800 may include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input/output (I/O) interface 812, a sensor component 814, and a communication component 816.
The processing component 802 generally controls overall operation of the apparatus 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to perform all or part of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interactions between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operations at the device 800. Examples of such data include instructions for any application or method operating on the device 800, contact data, phonebook data, messages, pictures, videos, and the like. The memory 804 may be implemented by any type or combination of volatile or nonvolatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
The power supply component 806 provides power to the various components of the device 800. The power components 806 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the device 800.
The multimedia component 808 includes a screen between the device 800 and the user that provides an output interface. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may sense not only the boundary of a touch or slide action, but also the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and/or a rear camera. The front camera and/or the rear camera may receive external multimedia data when the device 800 is in an operational mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the device 800 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may be further stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 further includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be a keyboard, click wheel, buttons, etc. These buttons may include, but are not limited to: homepage button, volume button, start button, and lock button.
The sensor assembly 814 includes one or more sensors for providing status assessment of various aspects of the apparatus 800. For example, the sensor assembly 814 may detect an on/off state of the device 800, a relative positioning of the components, such as a display and keypad of the apparatus 800, the sensor assembly 814 may also detect a change in position of the apparatus 800 or one component of the apparatus 800, the presence or absence of user contact with the apparatus 800, an orientation or acceleration/deceleration of the apparatus 800, and a change in temperature of the apparatus 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscopic sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate communication between the apparatus 800 and other devices, either in a wired or wireless manner. The device 800 may access a wireless network based on a communication standard, such as Wi-Fi,4G, or 5G, or a combination thereof. In one exemplary embodiment, the communication component 816 receives broadcast signals or broadcast related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), digital Signal Processors (DSPs), digital Signal Processing Devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic elements for executing the methods described above.
In an exemplary embodiment, a non-transitory computer readable storage medium is also provided, such as memory 804 including instructions executable by processor 820 of apparatus 800 to perform the above-described method. For example, the non-transitory computer readable storage medium may be ROM, random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
A non-transitory computer readable storage medium, which when executed by a processor of a terminal, enables the terminal to perform a camera preview method, the method comprising:
responsive to detecting a start instruction for a camera application in the electronic device, capturing an image;
Generating a preview image based on the acquired image, and adding the preview image into a cache queue;
determining a transmission time interval of the preview image;
And transmitting each preview image in the buffer queue to the display screen for display based on the transmission time interval.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any adaptations, uses, or adaptations of the disclosure following the general principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It is to be understood that the present disclosure is not limited to the precise arrangements and instrumentalities shown in the drawings, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims (10)
1. A camera preview method for use with an electronic device including a display screen, the method comprising:
responsive to detecting a start instruction for a camera application in the electronic device, capturing an image;
Generating a preview image based on the acquired image, and adding the preview image into a cache queue;
determining a transmission time interval of the preview image;
And transmitting each preview image in the buffer queue to the display screen for display based on the transmission time interval.
2. The method of claim 1, wherein the determining the transmission time interval of the preview image comprises:
Acquiring an acquisition frame rate of the electronic equipment for acquiring the image;
Determining the acquisition duration of each image frame based on the acquisition frame rate;
and determining the sending time interval of the preview image according to the acquisition time length of each image frame.
3. The method according to claim 2, wherein the method further comprises:
Acquiring the exposure time of the electronic equipment;
The determining the sending time interval of the preview image according to the acquisition time length of each image frame includes:
And determining the longer time length of the acquisition time length and the exposure time length of the image frame as the sending time interval of the preview image.
4. The method according to claim 1, wherein the method further comprises:
Acquiring a display frame rate of the display screen;
Determining the display duration of each image frame according to the display frame rate;
And sending each preview image in the buffer queue to the display screen for display based on the sending time interval, including:
And transmitting each preview image in the buffer queue to the display screen for display based on the display time length and the transmission time interval of each image frame.
5. The method of claim 4, wherein the sending each preview image in the buffer queue to the display screen for display based on the display duration and the sending time interval of each image frame comprises:
Responding to the sending time interval being greater than or equal to the display duration of each image frame, and sending the preview images in the buffer queue to the display screen for display at the sending time interval;
And in response to the sending time interval being smaller than the display duration of each image frame, sending the preview images in the buffer queue to the display screen for display in the display duration of each image frame.
6. The method of claim 1, wherein the sending each of the preview images in the buffer queue to the display screen for display based on the sending time interval comprises:
and based on the sending time interval, sending each preview image to the display screen for display according to the time sequence of adding each preview image into the buffer queue.
7. The method of claim 1, wherein the generating preview images based on the captured images and adding the preview images to a cache queue comprises:
And generating the preview image after fusing at least two images acquired by the electronic equipment, and adding the preview image into the cache queue.
8. A camera preview apparatus for use with an electronic device including a display screen, the apparatus comprising:
The acquisition module is used for responding to the detection of a starting instruction of camera application in the electronic equipment and acquiring an image;
the caching module is used for generating a preview image based on the acquired image and adding the preview image into a caching queue;
a first determining module, configured to determine a transmission time interval of the preview image;
And the display module is used for transmitting each preview image in the buffer queue to the display screen for display based on the transmission time interval.
9. An electronic device, comprising:
A processor;
a memory for storing processor-executable instructions;
Wherein the processor is configured to perform the camera preview method of any of claims 1 to 7.
10. A non-transitory computer readable storage medium, characterized in that instructions in the storage medium, when executed by a processor of a terminal, enable the terminal to perform the camera preview method of any of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310258617.2A CN118678208A (en) | 2023-03-16 | 2023-03-16 | Camera preview method and device, terminal and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310258617.2A CN118678208A (en) | 2023-03-16 | 2023-03-16 | Camera preview method and device, terminal and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN118678208A true CN118678208A (en) | 2024-09-20 |
Family
ID=92719792
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310258617.2A Pending CN118678208A (en) | 2023-03-16 | 2023-03-16 | Camera preview method and device, terminal and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN118678208A (en) |
-
2023
- 2023-03-16 CN CN202310258617.2A patent/CN118678208A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10674088B2 (en) | Method and device for acquiring image, terminal and computer-readable storage medium | |
CN111314617B (en) | Video data processing method and device, electronic equipment and storage medium | |
CN107040591B (en) | Method and device for controlling client | |
WO2018000711A1 (en) | Method and apparatus for outputting image | |
CN111586282A (en) | Shooting method, shooting device, terminal and readable storage medium | |
CN112866576B (en) | Image preview method, storage medium and display device | |
CN105847627B (en) | A kind of method and apparatus of display image data | |
CN113703937B (en) | Animation switching method and device and storage medium | |
CN112217990A (en) | Task scheduling method, task scheduling device, and storage medium | |
CN112153396A (en) | Page display method, device and system and storage medium | |
CN111724803A (en) | Audio processing method and device, electronic equipment and storage medium | |
CN111586280B (en) | Shooting method, shooting device, terminal and readable storage medium | |
CN111610899A (en) | Interface display method, interface display device and storage medium | |
CN114079724B (en) | Taking-off snapshot method, device and storage medium | |
CN107026941B (en) | Method and device for processing reply of unread message | |
CN114339320B (en) | Virtual resource processing method, device, equipment and storage medium | |
CN118678208A (en) | Camera preview method and device, terminal and storage medium | |
CN114943791A (en) | Animation playing method, device, equipment and storage medium | |
CN113079312A (en) | Method and device for adjusting focal length of camera, electronic equipment and storage medium | |
CN112995504B (en) | Image display method and device and storage medium | |
CN110392294A (en) | Human body detecting method, device, electronic equipment and storage medium | |
CN106454094A (en) | Shooting method and device, and mobile terminal | |
CN115733913B (en) | Continuous photographing method and device and storage medium | |
CN118695085A (en) | Display method and device of preview image, electronic equipment and storage medium | |
CN112087572B (en) | Method and device for controlling zoom of lens, electronic equipment and readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination |