Control method of camera, camera, and storage medium
By acquiring and calculating the brightness value and exposure parameters of the current frame image in real time, and dynamically adjusting the exposure parameters, the problem of low efficiency in exposure parameter adjustment in embedded devices is solved, and fast convergence of exposure parameter adjustment is achieved, thus improving the image quality.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN PUDU TECH CO LTD
- Filing Date
- 2022-04-07
- Publication Date
- 2026-07-03
AI Technical Summary
The limited computing power of embedded or mobile devices leads to low efficiency in adjusting exposure parameters, and it is difficult for exposure parameters to converge to the optimal state. Existing algorithms have low adjustment efficiency.
By acquiring the brightness value of the current frame image in real time, dynamically selecting the calculation method to calculate the target brightness value of the next frame image, and calculating the target exposure parameters based on the brightness value and exposure parameters of the current frame image, the process is adjusted multiple times until the same exposure parameters are obtained twice in a row before taking a picture.
It improves the efficiency of exposure parameter adjustment, enabling the rapid acquisition of convergent exposure parameters. Compared with existing technologies, it reduces the frame rate requirement and improves image quality.
Smart Images

Figure CN116939348B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of photography technology, and in particular to a camera control method, a camera, and a storage medium. Background Technology
[0002] In camera-based sensing devices in embedded or mobile devices, the limited computing power of these devices results in a low raw frame rate when acquiring images. This low frame rate leads to very slow adjustment of the exposure parameters of the brightness camera. Increasing the adjustment range of the exposure parameters can easily cause brightness oscillations, making it difficult for the exposure parameters to converge to the optimal state. Existing algorithms are inefficient at adjusting exposure parameters. Summary of the Invention
[0003] Therefore, it is necessary to provide a camera control method, camera, and storage medium that can improve the efficiency of exposure parameter adjustment in response to the above-mentioned technical problems.
[0004] In a first aspect, this application provides a camera. The camera includes a camera lens, a memory, and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0005] The camera acquires the current frame image in real time, and determines the corresponding current brightness value based on the current frame image;
[0006] Determine the brightness range of the current brightness value, and select a calculation method corresponding to the brightness range of the current brightness value to calculate the target brightness value of the next frame image;
[0007] Calculate the target exposure parameters of the next frame image based on the current brightness value and the target brightness value;
[0008] If the target exposure parameters of the next frame image are the same as the exposure parameters of the current frame image, the camera is controlled to take a picture using the target exposure parameters of the next frame image.
[0009] Secondly, this application also provides a method for controlling a camera. The method includes:
[0010] The camera acquires the current frame image in real time, and determines the corresponding current brightness value based on the current frame image;
[0011] Determine the brightness range of the current brightness value, and select a calculation method corresponding to the brightness range of the current brightness value to calculate the target brightness value of the next frame image;
[0012] The target exposure parameters of the next frame image are calculated based on the current brightness value and the target brightness value.
[0013] If the target exposure parameters of the next frame image are the same as the exposure parameters of the current frame image, the camera is controlled to take a picture using the target exposure parameters of the next frame image.
[0014] Thirdly, this application also provides a camera control device. The device includes:
[0015] The first acquisition module is used to acquire the current frame image in real time through the camera, and determine the corresponding current brightness value based on the current frame image;
[0016] The first calculation module is used to determine the brightness range of the current brightness value and select a calculation method corresponding to the brightness range of the current brightness value to calculate the target brightness value of the next frame image.
[0017] The second calculation module is used to calculate the target exposure parameters of the next frame image based on the current brightness value and the target brightness value.
[0018] The camera module is used to control the camera to take a picture using the target exposure parameters of the next frame image if the target exposure parameters of the next frame image are the same as the exposure parameters of the current frame image.
[0019] Fourthly, this application also provides a computer-readable storage medium. This computer-readable storage medium stores a computer program thereon, which, when executed by a processor, is used to implement the steps of the above-described camera control method.
[0020] The aforementioned camera control method, device, camera, and storage medium, during the camera's metering phase, repeatedly selects a corresponding calculation method based on the brightness range corresponding to the current brightness value of the current frame image. Based on the current brightness value and the selected calculation method, the target brightness value of the next frame image is calculated. Then, based on the current brightness value of the current frame image, the target brightness value, and the exposure parameters of the current frame image, the target exposure parameters of the next frame image are calculated. Thus, depending on the brightness range of the current frame image, an appropriate calculation method is dynamically selected to obtain the target brightness value of the next frame image. After multiple calculations, if the target exposure parameters of the next frame image are the same as the exposure parameters of the current frame image (i.e., at least two consecutive identical exposure parameters are obtained), the converged exposure parameters are used for taking pictures. Compared to existing technologies (which require 30 frames to obtain converged exposure parameters), this improves the efficiency of exposure parameter adjustment and enables the rapid acquisition of converged exposure parameters. Attached Figure Description
[0021] Figure 1 This is a flowchart illustrating a camera control method in one embodiment;
[0022] Figure 2 This is a schematic diagram illustrating the process of refining the brightness of the current frame image in one embodiment, whereby the current brightness value is obtained as the current frame image brightness.
[0023] Figure 3 This is a detailed flowchart illustrating the process of calculating the target exposure parameters of the next frame image based on the current brightness value, the target brightness value, and the exposure parameters of the current frame image in one embodiment.
[0024] Figure 4 This is a structural block diagram of the camera control device in one embodiment;
[0025] Figure 5 This is a diagram of the internal structure of a camera in one embodiment. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0027] The camera control method provided in this application can be applied to a camera or a photographic device including a camera lens. The camera or photographic device may include a memory, a processor, and a camera lens. The camera lens is used to acquire external image data, the memory is used to store computer programs, and the processor is used to run the computer programs stored in the memory. The exposure parameters are adjusted using the external image data acquired by the camera lens. The photographic device can be a smartphone, tablet, smart camera, robot, or any other device with camera functionality.
[0028] In one embodiment, such as Figure 1 As shown, a camera control method is provided. Taking the application of this method to a camera as an example, the method includes the following steps:
[0029] Step S100: Acquire the current frame image in real time through the camera, and determine the corresponding current brightness value based on the current frame image.
[0030] As one embodiment, this application is applied to a camera. The camera acquires images through its camera lens. Before acquiring images, the camera enters a metering phase and acquires multiple frames of images. Each time, the target exposure parameters for the next frame are calculated based on the currently acquired frame image, thereby continuously adjusting the exposure parameters to obtain the most suitable exposure parameters. Then, the most suitable exposure parameters are used to take a picture and obtain a high-quality image.
[0031] For ease of explanation, in this embodiment, the image currently acquired by the camera (i.e., the latest acquired frame) is defined as the current frame image, and the image to be acquired after the current frame image (i.e., the frame following the current frame) is defined as the next frame image. For example, when the camera acquires the first frame image, the first frame image is the current frame image, and the second frame image to be acquired is the next frame image; if the camera currently acquires the fifth frame image, then the fifth frame image is the current frame image, and the sixth frame image to be acquired is the next frame image. In other words, when the camera acquires the first frame image, the first frame image is the current frame image, and the second frame image to be acquired is the next frame image. As the metering phase progresses, when the camera acquires the second frame image, the current frame image is the second frame image, and the third frame image to be acquired is the next frame image, and so on. When the camera acquires the third frame image, the current frame image is the third frame image, and the fourth frame image to be acquired is the next frame image.
[0032] During the metering phase, the camera acquires the current frame image and obtains the current brightness value of the current frame image. As one example, the average value of each pixel in the current frame image can be calculated and the obtained average value can be used as the current brightness value of the current frame.
[0033] Step S200: Determine the brightness range of the current brightness value, and select a calculation method corresponding to the brightness range of the current brightness value to calculate the target brightness value of the next frame image.
[0034] In this embodiment, multiple brightness ranges are preset, and each brightness range is configured with a corresponding calculation method for calculating the target brightness value of the next frame image. After obtaining the current brightness value of the current frame, the brightness range in which the current brightness value is located is determined, and the corresponding calculation method is selected to calculate the target brightness value of the next frame image based on the determined brightness range in which the current brightness value of the current frame image is located.
[0035] As one embodiment, the step of determining the brightness range of the current brightness value and selecting a calculation method corresponding to the brightness range of the current brightness value to calculate the target brightness value of the next frame image includes:
[0036] Step S220: If the current brightness value is greater than the first threshold, then the brightness range of the current brightness value of the current frame image is determined to be the first brightness range, and the first calculation method corresponding to the first brightness range is selected to calculate the target brightness value of the next frame image.
[0037] Step S230: If the current brightness value is greater than or equal to the second threshold and less than or equal to the first threshold, determine that the brightness range of the current brightness value of the current frame image is the second brightness range, and select the second calculation method corresponding to the second brightness range to calculate the target brightness value of the next frame image, wherein the second threshold is less than the first threshold;
[0038] Step S240: If the current brightness value is less than the second threshold, then the brightness range of the current brightness value of the current frame image is determined to be the third brightness range, and the third calculation method corresponding to the third brightness range is selected to calculate the target brightness value of the next frame image.
[0039] Specifically, in this embodiment, N thresholds are preset, dividing the brightness range into N+1 brightness ranges. For example, two thresholds are set: a first threshold and a second threshold. The second threshold is less than the first threshold. These two thresholds divide the brightness range into three brightness ranges: a first brightness range, a second brightness range, and a third brightness range. The current brightness value of the current frame image is compared with the first and second thresholds to obtain a comparison result. There are three possible comparison results:
[0040] 1) If the current brightness value is greater than the first threshold, it is determined that the current brightness value of the current frame image is within the first brightness range. In this case, the first calculation method corresponding to the first brightness range is selected to calculate the target brightness value of the next frame image. When the current brightness value is within the first brightness range, the brightness is relatively high, indicating that the light is sufficient or there may be overexposed pixels (e.g., due to reflections, sunlight, etc.). To eliminate the influence of overexposed pixels on the calculation of the target brightness value, in this embodiment, when it is determined that the current brightness value of the current frame image is within the first brightness range, the first calculation method corresponding to the first brightness range is selected to calculate the target brightness value of the next frame image, including:
[0041] Step S221: Determine the number of overexposed pixels in the current frame image;
[0042] Step S222: If the number of overexposed pixels in the current frame image is greater than 0, calculate the target brightness value of the next frame image based on the current brightness value of the current frame image, and the target brightness value of the next frame image is less than the current brightness value of the current frame image.
[0043] Step S223: If the number of overexposed pixels in the current frame image is equal to 0, the current brightness value of the current frame image is used as the target brightness value of the next frame image.
[0044] Specifically, first, the number of overexposed pixels in the current frame image is counted. If the number of overexposed pixels in the current frame image is 0, it means that there are no overexposed pixels in the current frame image, and the image brightness is good. In this case, the current brightness value of the current frame image is used as the target brightness value of the next frame image. If the number of overexposed pixels in the current frame image is greater than 0, it means that there are overexposed pixels in the current frame image. In this case, the image brightness needs to be reduced to reduce the impact of overexposed pixels. For example, when there are overexposed pixels in the current frame image, the ratio of the pixels other than overexposed pixels to the total number of pixels in the current frame image is calculated, and the target brightness value of the next frame image is calculated based on the ratio and the current brightness value. As one embodiment, the target brightness value of the next frame image can be calculated using the following formula:
[0045] Bt=(1-Ng / N)×Bc,
[0046] Where Bt represents the target brightness value of the next frame image, Ng represents the number of overexposed pixels, N represents the total number of pixels in the current frame image, and Bc represents the current brightness value of the current frame image.
[0047] 2) If the current brightness value is greater than or equal to the second threshold and less than or equal to the first threshold, it is determined that the current brightness value of the current frame image is within the second brightness range, and the second calculation method corresponding to the second brightness range is selected to calculate the target brightness value of the next frame image. When the current brightness value is within the second brightness range, the brightness is relatively moderate. Therefore, the target brightness value of the next frame image can be set to be basically the same as the current brightness value of the current frame. For example, the second calculation method is to keep the target brightness value of the next frame image unchanged, that is, the target brightness value of the next frame image is equal to the current brightness value of the current frame.
[0048] 3) If the current brightness value is less than the second threshold, determine that the current brightness value of the current frame image is within the third brightness range, and select the third calculation method corresponding to the third brightness range to calculate the target brightness value of the next frame image. When the current brightness value is within the third brightness range, it indicates that the image brightness is relatively dark. Darker environments will reduce image quality. At this time, a larger margin can be used to obtain the target brightness value of the next frame image. For example, selecting the third calculation method corresponding to the third brightness range to calculate the target brightness value of the next frame image includes:
[0049] The photometric brightness of the next frame image is obtained, and the photometric brightness of the next frame image is incremented. The incremented brightness is used as the target brightness value of the next frame image. In one embodiment, the target brightness value Bt of the next frame image can be calculated according to the formula Bt=Bt*α, where Bt is the target brightness value of the next frame image, the initial value can be the brightness value in the second brightness range, and α is a natural number greater than 1.
[0050] Step S300: Calculate the target exposure parameters of the next frame image based on the current brightness value, the target brightness value, and the exposure parameters of the current frame image.
[0051] The exposure parameters include exposure time and gain. The longer the exposure time, the brighter the captured image. Gain characterizes the sensitivity of the photosensitive device to light. The greater the gain, the higher the sensitivity of the photosensitive device to light. Exposure time and / or gain will affect the image quality.
[0052] In this implementation, the target exposure parameters for the next frame image are calculated using the current brightness value and exposure parameters of the current frame image, and the target brightness value of the next frame image. Specifically, during the metering phase, the camera can acquire multiple frame images. The target exposure parameters for the next frame image are calculated based on each acquired frame image. When the first frame image is acquired, it is considered the current frame image. The second frame image is considered the next frame image. The target brightness value of the second frame image is calculated using the current brightness value and exposure parameters of the first frame image, along with the target brightness value of the second frame image. The camera then uses the exposure parameters of the second frame image for metering. While metering using the exposure parameters of the second frame image, the second frame image is acquired, and this second frame image is considered the current frame image. The third frame image is considered the next frame image. The camera uses the current brightness value and exposure parameters of the second frame image to calculate the target brightness value of the third frame image, and so on.
[0053] As one embodiment, calculating the target exposure parameters of the next frame image based on the current brightness value, the target brightness value, and the exposure parameters of the current frame image may include: determining whether the brightness of the next frame image is increased or decreased relative to the current frame image based on the target brightness value of the next frame image and the current brightness value of the current frame image; if the brightness of the next frame image is increased relative to the current frame image, increasing the exposure time and / or gain accordingly based on the exposure time and gain in the exposure parameters of the current frame image; if the brightness of the next frame image is decreased relative to the current frame image, decreasing the exposure time and / or gain accordingly based on the exposure time and gain in the exposure parameters of the current frame image.
[0054] Step S400: If the target exposure parameters of the next frame image are the same as the exposure parameters of the current frame image, control the camera to take a picture using the target exposure parameters of the next frame image.
[0055] After obtaining the target exposure parameters for the next frame image each time, the exposure parameters obtained in two consecutive frames are compared. When the target exposure parameters for the next frame image are the same as those for the current frame image (which can also be understood as the target exposure parameters for the next frame images obtained in two consecutive frames being the same, where the previous frame image is the current frame image and the next frame image is the next frame image), it indicates that the camera exposure parameters have converged and the most suitable exposure parameters have been obtained. At this time, the camera can directly use the target exposure parameters of the at least two consecutive frames obtained to take a picture based on user operation or automatic shooting.
[0056] The aforementioned camera control method, device, camera, and storage medium, during the camera's metering phase, repeatedly selects a corresponding calculation method based on the brightness range corresponding to the current brightness value of the current frame image. Based on the current brightness value and the selected calculation method, the target brightness value of the next frame image is calculated. Then, based on the current brightness value of the current frame image, the target brightness value, and the exposure parameters of the current frame image, the target exposure parameters of the next frame image are calculated. Thus, since the current brightness value of the current frame image falls within different brightness ranges, an appropriate calculation method is dynamically selected to obtain the target brightness value of the next frame image. After multiple calculations, if the target exposure parameters of the next frame image are the same as the exposure parameters of the current frame image (i.e., at least two consecutive identical exposure parameters are obtained), the converged exposure parameters are used for taking a picture. Compared to existing technologies (which require 30 frames to obtain converged exposure parameters), this improves the efficiency of exposure parameter adjustment and enables the rapid acquisition of converged exposure parameters.
[0057] In an optional embodiment, based on the above embodiments, in order to improve the accuracy of measuring the brightness of the actual scene captured by the camera, the step of determining the corresponding current brightness value based on the current frame image may include:
[0058] Step S110: Based on the current frame image, obtain the brightness histogram of the current frame image;
[0059] As one embodiment, in the process of obtaining the brightness of the current frame image, this embodiment first obtains the brightness histogram of the current frame image. The brightness histogram includes the brightness of each pixel in the current frame image and the number of pixels at each brightness. For example, the brightness histogram can be obtained using existing technology, which will not be elaborated on here.
[0060] Step S120: Count the number of overexposed pixels in the brightness histogram, the number of pixels in the first preset range, and the number of pixels in the second preset range. Also, determine the average brightness of the current frame image, the brightness value of pixels in the first preset range, and the brightness value of pixels in the second preset range based on the brightness histogram. The first preset range includes the peak value of the highest peak in the brightness histogram, and the second preset range includes the peak value of the second highest peak in the brightness histogram.
[0061] After obtaining the brightness histogram of the current frame image, the number of overexposed pixels, the number of pixels within a first preset range, the number of pixels within a second preset range, and the average brightness of the current frame image are statistically analyzed. Overexposed pixels are those with the highest brightness; for example, if the brightness range of a pixel is [0, 255], then an overexposed pixel is one with a brightness value of 255. The number of pixels within the first preset range includes the maximum number of pixels for a given brightness in the histogram (a waveform graph of brightness and pixel count). The maximum number of pixels is defined as the peak value of the highest peak. For example, the first preset range is a range of 5 values to the left and right of the peak pixel. The number of pixels within the second preset range includes the second maximum number of pixels for a given brightness in the histogram. The second maximum number of pixels is defined as the peak value of the second highest peak. For example, the first preset range is a range of 5 values to the left and right of the peak pixel. The average brightness of the current frame image is the average obtained by averaging the products of each brightness value and the number of pixels for each brightness value.
[0062] Furthermore, to improve the accuracy of the statistical results, before processing various information in the statistical brightness histogram (i.e., the number of overexposed pixels, the number of pixels within the first preset range, the number of pixels within the second preset range, and the average brightness of the current frame image), the brightness histogram of the current frame image can be filtered first to eliminate abrupt changes in the histogram and improve the accuracy of the statistical results.
[0063] Step S130: Calculate a first calculated value based on the number of pixels in the first preset range, the number of pixels in the second preset range, the brightness values of the pixels in the first preset range, and the brightness values of the pixels in the second preset range.
[0064] Step S140: Calculate a second calculated value based on the number of overexposed pixels and the total number of pixels in the current frame image;
[0065] Step S150: Calculate a third value based on the total number of pixels in the current frame image, the average brightness of the current frame image, the number of pixels in the first preset range, the number of pixels in the second preset range, and the number of overexposed pixels.
[0066] Step S160: The sum of the first calculated value, the second calculated value, and the third calculated value is taken as the current brightness value of the current frame image.
[0067] After counting the number of overexposed pixels, the number of pixels within the first preset range, the number of pixels within the second preset range, and the average brightness of the current frame image, the current brightness value of the current frame is calculated based on the counted number of overexposed pixels, the number of pixels within the first preset range, the number of pixels within the second preset range, and the average brightness of the current frame image.
[0068] Specifically, the step of calculating the current brightness value based on the number of overexposed pixels, the number of pixels within the first preset range, the number of pixels within the first preset range, and the average brightness of the current frame image may include:
[0069] The sum of the first calculated value, the second calculated value, and the third calculated value is used as the current brightness value of the current frame image. The first calculated value is a value calculated based on the number of pixels within the first preset range, the number of pixels within the second preset range, the brightness value of each pixel within the first preset range, and the brightness value of each pixel within the second preset range. The second calculated value is a value calculated based on the number of overexposed pixels and the total number of pixels in the current frame image. The third calculated value is a value calculated based on the total number of pixels in the current frame image, the average brightness, the number of pixels within the first preset range, the number of pixels within the second preset range, and the number of overexposed pixels.
[0070] Specifically, in this embodiment, a first calculated value is calculated based on the number of pixels within a first preset range, the number of pixels within a second preset range, the brightness value of each pixel within the first preset range, and the brightness value of each pixel within the first preset range in the current frame image. For example, the first calculated value is calculated using the following formula:
[0071]
[0072] Where Nx represents the average number of pixels within a first preset range, Ny represents the average number of pixels within a second preset range, Bx represents the average brightness value of pixels within the first preset range, By represents the average brightness value of pixels within the first preset range, and N represents the total number of pixels in the current frame image. In specific implementations, other calculation formulas can be used to calculate the first calculated value A, for example, using the number and brightness value of each pixel to calculate the total brightness within the first and second preset ranges, and then dividing by the total number of pixels in the current frame image.
[0073] Simultaneously, the camera also calculates a second calculated value based on the number of overexposed pixels and the total number of pixels in the current frame image. For example, the second calculated value is calculated using the following formula:
[0074]
[0075] Here, Ng represents the number of overexposed pixels. In practice, other calculation formulas can be used to calculate the second calculated value B.
[0076] The camera also calculates a third calculated value based on the average brightness of the current frame image, the total number of pixels in the current frame image, the number of pixels within a first preset range, and the number of overexposed pixels. For example, the third calculated value is calculated using the following formula:
[0077]
[0078] Where Bi represents the average brightness of the current frame image. In specific implementations, other calculation formulas can be used to calculate the third calculated value C.
[0079] After obtaining the first, second, and third calculated values, the first, second, and third calculated values are summed, and the sum is used as the current brightness value Bc of the current frame image. It is understood that the calculation processes for the first, second, and third calculated values are not sequential and can be performed simultaneously. Alternatively, the current brightness value of the current frame image can be obtained directly using the following formula:
[0080]
[0081] In this embodiment, during the process of obtaining the current brightness value of the current frame image, the pixels with higher brightness due to overexposure in the current frame image (the number of overexposed pixels, pixels within a first preset range, and pixels within a second preset range) are used as factors in calculating the current brightness value (the pixels with higher brightness due to overexposure are correspondingly reduced). This avoids the problem of local overexposure causing the image to appear too bright, thereby improving the accuracy of measuring the current brightness value of the current frame image. As another embodiment, the average brightness value of all pixels in the current frame image can be calculated first, and then multiplied by a percentage (this percentage is less than 1 and greater than 0) to obtain the current brightness value of the current frame image.
[0082] In an optional embodiment, based on the above embodiments, the step of calculating the target exposure parameters of the next frame image according to the current brightness value, the target brightness value, and the exposure parameters of the current frame image includes:
[0083] Step S310: Determine the exposure parameters of the current frame image based on the current frame image, wherein the exposure parameters of the current frame image include a first exposure time and a first gain;
[0084] Step S320: Determine the relationship between the current brightness value and the target brightness value of the next frame image;
[0085] Step S330: Based on the relationship between the current brightness value and the target brightness value of the next frame image, and the first exposure time, obtain the second exposure time of the next frame image;
[0086] Specifically, when the camera calculates the target exposure parameters for the next frame, it first obtains the exposure parameters of the current frame. For ease of description, the exposure time and gain in the exposure parameters of the current frame are defined as the first exposure time and the first gain, respectively.
[0087] As one embodiment, determining the magnitude relationship between the current brightness value and the target brightness value of the next frame image, and obtaining the second exposure time of the next frame image based on the magnitude relationship and the first exposure time, may include: determining whether the brightness of the next frame image increases or decreases based on the current brightness value of the current frame image and the target brightness value of the next frame image (i.e., determining the magnitude relationship between the current brightness value and the target brightness value of the next frame image, and based on the magnitude relationship), if it increases (i.e., the target brightness value of the next frame image is greater than the current brightness value), then a fixed increase time is added to the first exposure time of the current frame image as the second exposure time of the next frame image; if it decreases (i.e., the target brightness value of the next frame image is less than the current brightness value), then a fixed decrease time is subtracted from the first exposure time of the current frame image as the second exposure time of the next frame image, wherein both the fixed increase time and the fixed decrease time are positive values greater than 0, and can be set according to the specific camera.
[0088] As another embodiment, determining the magnitude relationship between the current brightness value and the target brightness value of the next frame image, and obtaining the second exposure time of the next frame image based on the magnitude relationship and the first exposure time, may further include: calculating the second exposure time of the next frame image based on the difference between the target brightness value and the current brightness value and the first exposure time. Specifically, the difference between the target brightness value of the next frame image and the current brightness value of the current frame image is calculated (the magnitude relationship between the current brightness value and the target brightness value of the next frame image can be determined based on this difference; a positive difference corresponds to the increasing case in the previous embodiment; a negative difference corresponds to the decreasing case in the previous embodiment), and the calculated difference is multiplied by a fixed coefficient. Further, it can be calculated using the following formula:
[0089] β*(Bt-Bc)+D
[0090] Where β is a fixed coefficient, which is less than 1 and greater than 0, Bt represents the target brightness value of the next frame image, Bc represents the current brightness value of the current frame image, and D represents the first exposure time of the current frame image.
[0091] It should be noted that the difference between the target brightness value of the next frame and the current brightness value of the current frame can be positive or negative. Therefore, the second exposure time of the next frame may increase or decrease relative to the first exposure time D of the current frame.
[0092] Step S340: Determine the exposure time intervals to which the first exposure time and the second exposure time belong respectively, and determine whether the exposure time intervals corresponding to the first exposure time and the second exposure time are the same, and obtain the determination result;
[0093] Step S350: Select the corresponding gain calculation method according to the judgment result to obtain the second gain of the next frame image, and use the second exposure time and the second gain as the target exposure parameters of the next frame image.
[0094] As one embodiment, after calculating the second exposure time of the next frame image, the exposure time intervals to which the first and second exposure times belong are determined, and it is judged whether the exposure time intervals corresponding to the first and second exposure times are the same, and the judgment result is obtained. For example, this embodiment sets 5 exposure time intervals, and each exposure time interval corresponds to a gain interval. That is, this embodiment sets 5 sets of parameters, each set of parameters includes a gain interval and an exposure time interval, and the gain interval and exposure time interval correspond one-to-one. The setting of the exposure time interval and gain interval can be set according to the specific situation, and is not limited here. For ease of explanation, in this embodiment, the 5 exposure time intervals are named exposure time interval 1-5, and the gain intervals are named gain interval 1-5, respectively. Exposure time intervals and gain intervals with the same number correspond one-to-one, that is, exposure time interval 1 corresponds to gain interval 1, exposure time interval 2 corresponds to gain interval 2, and so on, as shown in the table below:
[0095] Serial Number Gain Exposure time 1 Gain range 1 Exposure time interval 1 2 Gain range 2 Exposure time interval 2 3 Gain range 3 Exposure time interval 3 4 Gain range 4 Exposure time interval 4 5 Gain range 5 Exposure time interval 5
[0096] For example, if the first exposure time of the current frame belongs to exposure time interval 1, and the exposure time of the next frame also belongs to exposure time interval 1, the result is that both belong to the same exposure time interval. In this case, the first gain is assigned to the second gain, i.e., the first gain of the current frame is used as the second gain of the next frame. If the first exposure time of the current frame belongs to exposure time interval 1, and the exposure time of the next frame belongs to exposure time interval 2, the result is that both belong to different exposure time intervals. In this case, the second gain of the next frame is calculated based on the first gain of the current frame. As an example, the process of calculating the second gain of the next frame based on the first gain of the current frame can include incrementing the first gain to obtain the second gain of the next frame. The increment can be set according to the specific camera parameters.
[0097] The second exposure time and second gain of the next frame image are used as the target exposure parameters of the next frame image. After obtaining the target exposure parameters of multiple next frame images in the above manner, if the target exposure parameters of at least two consecutive next frame images are the same, the camera uses the exposure parameters to take a picture.
[0098] In this embodiment, the exposure time is first calculated. Then, the gain of the next frame image is calculated using different methods depending on whether the exposure time intervals of the current frame and the next frame image are the same. Specifically, when the exposure time intervals of the current frame and the next frame image are the same, the gain of the next frame image is kept the same as the gain of the current frame image. When the exposure time intervals of the current frame and the next frame image are different, the exposure time of the next frame image is kept the same as the exposure time of the current frame image, and the gain of the next frame image is adjusted. Therefore, during the metering stage, the frame images obtained by the camera will not exhibit flickering caused by excessive adjustment amplitude (e.g., adjusting both exposure time and gain simultaneously would result in excessive adjustment amplitude). Simultaneously, when the exposure time intervals of the current frame and the next frame image are different, the camera gain can be quickly adjusted, allowing even low frame rate cameras to quickly adjust exposure parameters. Testing shows that cameras using this method only need about 10 frames for metering in most environments to obtain converged exposure parameters, while many existing algorithms require 30 frames to obtain converged exposure parameters.
[0099] As one embodiment, to further reduce image flicker, based on the above embodiment, determining the exposure time intervals to which the first exposure time and the second exposure time belong respectively includes:
[0100] The corresponding exposure time gradient is determined based on the relationship between the current brightness value and the target brightness value of the next frame image;
[0101] Determine the exposure time intervals to which the first exposure time and the second exposure time belong in the exposure time gradient.
[0102] In this embodiment, the exposure time is divided into two exposure time gradients, defined as the first exposure time gradient and the second exposure time gradient, respectively. The first exposure time gradient and the second exposure time gradient include the same number of exposure time intervals. The upper bound (i.e., the maximum value) of each exposure time interval in the second exposure time gradient is greater than the upper bound of the corresponding exposure time interval in the first exposure time gradient, as exemplified in the table below:
[0103] Serial Number Gain Exposure time (exp_time) 1 Gain range 1 {1.0,5.0} 2 Gain range 2 {3.0,11.0} 3 Gain range 3 {5.0,18.0} 4 Gain range 4 {7.0,20.0} 5 Gain range 5 {12.0,25.0}
[0104] In this table, the values to the left of each exposure time interval corresponding to the serial number in the exposure time column are the upper bounds of each exposure time interval in the first exposure time gradient, and the values to the right are the upper bounds of each exposure time interval in the second exposure time gradient. Specifically, the first exposure time gradient includes 5 exposure time intervals, and the second exposure time gradient also includes 5 exposure time intervals. The 5 exposure time intervals in the first exposure time gradient are exposure time intervals 1-5, and the 5 exposure time intervals in the second exposure time gradient are exposure time intervals 1'-5'. Exposure time interval 1' corresponds to exposure time interval 1, and both exposure time interval 1' and exposure time interval 1 correspond to gain interval 1; exposure time interval 2' corresponds to exposure time interval 2, and both exposure time interval 2' and exposure time interval 2 correspond to gain interval 2, and so on. Exposure time interval 1' is (0, 1], exposure time interval 2' is (1, 3], exposure time interval 1 is (0, 5], and exposure time interval 2 is (5, 11]. At this time, the upper limit of exposure time interval 1 is 5, which is greater than the upper limit of exposure time interval 1' is 1, and the upper limit of exposure time interval 2 is 11, which is greater than the upper limit of exposure time interval 2' is 3. Those skilled in the art know that the unit of exposure time is milliseconds (ms).
[0105] As one embodiment, determining the magnitude relationship between the current brightness value and the target brightness value of the next frame image, and determining the corresponding exposure time gradient based on the magnitude relationship, includes:
[0106] If the current brightness value is greater than the target brightness value, the exposure time gradient is determined to be the first exposure time gradient;
[0107] If the current brightness value is less than the target brightness value, the exposure time gradient is determined to be the second exposure time gradient.
[0108] Specifically, when the current brightness value is greater than the target brightness value (i.e., the brightness of the next frame image is less than the current frame image), the first exposure time gradient is selected to adjust the exposure parameters. When the current brightness value is less than the target brightness value (i.e., the brightness of the next frame image is greater than the current frame image), the second exposure time gradient is selected to adjust the exposure parameters. It can be understood that the parameters in the first and second exposure time gradients can be interchanged.
[0109] In this embodiment, two exposure time gradients are set: one for decreasing brightness and the other for increasing brightness. By using different exposure time gradients for different situations, it is more suitable for camera adjustments, avoids brightness fluctuations in the frame image during the adjustment process, and reduces brightness flicker in the frame image. At the same time, selecting the corresponding exposure time gradient based on the increase or decrease in brightness can improve adjustment efficiency.
[0110] As one embodiment, based on the above embodiment, after obtaining the second gain by incrementing the first gain, the process includes:
[0111] If the second gain and the first gain correspond to the same gain interval, then when calculating the target exposure parameters of the next frame image, the second exposure time remains unchanged, and the second gain of the next frame image is incremented as the first gain of the current frame image to obtain the second gain of the next frame image, until the gain interval corresponding to the second gain corresponds to the exposure time interval to which the second exposure time belongs.
[0112] After obtaining the second gain through auto-incrementing calculation based on the first gain, it is determined whether the gain intervals corresponding to the second gain and the first gain are the same. For example, taking a gain interval of 5, the gain intervals 1-5 are [1,2), [2,3), [3,4), [4,5), [5,X), where X is the maximum gain of the camera. If the current frame image is the first frame image, then the next frame image is the second frame image. The gain of the first frame image is 1, so the gain of the next frame image is obtained by auto-incrementing the gain of the first frame image. If the auto-increment increment is 0.3 (the auto-increment increment can be set according to the specific camera parameters), the second gain of the second frame image is calculated to be 1.3. It is then determined whether the gain interval to which 1.3 belongs is the same as the gain interval to which 1 belongs. If the gain intervals to which they belong are the same, then when setting the target exposure parameters for the next frame image, the second exposure time is kept unchanged, and the second gain of the next frame image is used as the first gain of the current frame image for auto-incrementing. To obtain the second gain of the next frame image, for example, if the gain interval of the second frame image 1.3 is the same as the gain interval of the first frame image 1 (both belong to gain interval 1), then when calculating the exposure parameters of the next frame image (i.e. the third frame image) of the second frame image, the exposure time of the third frame image is equal to the exposure time of the second frame image (at this time, the second frame is the current frame image of the third frame image, and the third frame image is the next frame image of the second frame image), and the gain of the third frame image is obtained by incrementing the gain (1.3) of the second frame image, that is, the gain of the third frame image is equal to 1.6.
[0113] As another example, taking a gain interval of 5 as an example, gain intervals 1-5 are 1, 2, 3, 4, and 5 respectively. When determining whether the second gain of the next frame image and the first gain of the current frame image belong to the same gain interval, the calculated gain of the next frame image is rounded down and then compared with the gain of the current frame image. For example, if the gain of a certain next frame is 1.6, after rounding down it is 1, which belongs to gain interval 1. Then it is determined whether gain interval 1 is the same as the gain interval of the current frame.
[0114] At this point, the exposure parameters of the third frame image are different from those of the second frame image, meaning that there are no two frames with the same exposure parameters. Therefore, when obtaining the exposure parameters of the fourth frame image, the third frame image is used as the current frame image, the fourth frame image is used as the next frame image, the exposure time of the fourth frame image is equal to the exposure time of the third frame image, and the gain of the fourth frame image is equal to the gain increment of the third frame image (i.e., 1.6 + 0.3 = 1.9).
[0115] After the fourth frame image is calculated, the fifth frame image is calculated (because there are no images with the same exposure parameters, and the gain interval and exposure time interval do not correspond). At this time, the fourth frame image is the current frame image, and the fifth frame image is the next frame image. The calculation method is the same, and the exposure parameters of the fifth frame image are obtained as follows: the exposure time is equal to the exposure time of the fourth frame image, and the gain is equal to 2.2 (1.9+0.3). At this time, the gain interval of the fifth frame image is different from the gain interval of the fourth frame image, and the gain interval (gain interval 2) of the fifth frame image is the same as the exposure time interval (exposure time interval 2) of the fifth frame image.
[0116] After incrementing the first gain and obtaining the second gain based on the incremented first gain, the method further includes:
[0117] If the gain range corresponding to the second gain is not the same as that corresponding to the first gain, return to step: obtain the second exposure time of the next frame image based on the first exposure time and the target brightness value.
[0118] As an example, when calculating the 5th frame, the gain interval of the 5th frame image is different from that of the 4th frame image, and the gain and exposure time of the 5th frame image correspond to the gain interval and exposure time interval, respectively. At this point, the process returns to step: obtaining the second exposure time of the next frame image based on the first exposure time and the target brightness value. That is, using the exposure parameters of the 5th frame image as the exposure parameters of the current frame image, the exposure parameters of the next frame image (the 6th frame image) are calculated. First, the exposure time of the 6th frame image is calculated. Then, based on whether the exposure time intervals of the 6th frame image and the 5th frame image are the same, the corresponding calculation method is selected to calculate the gain of the 7th frame image. The calculation process is the same as in the above embodiment and will not be repeated here. This continues until at least two consecutive exposure parameters are identical (referred to as the target exposure parameters), at which point the image is taken using the target exposure parameters.
[0119] As one embodiment, the method for adjusting the exposure parameters of the camera includes:
[0120] In this embodiment, three brightness ranges are pre-defined: a first brightness range, a second brightness range, and a third brightness range. Each brightness range has a corresponding calculation method for calculating the target brightness value of the next frame image, namely, the first brightness calculation method, the second brightness calculation method, and the third brightness calculation method. Five exposure time intervals are also set, and each exposure time interval corresponds to a gain interval; that is, the gain interval and the exposure time interval are in one-to-one correspondence. For ease of explanation, in this embodiment, the five exposure time intervals are named Exposure Time Interval 1-5, and the gain intervals are named Gain Interval 1-5. Exposure time intervals and gain intervals with the same number correspond one-to-one, i.e., Exposure Time Interval 1 corresponds to Gain Interval 1, Exposure Time Interval 2 corresponds to Gain Interval 2, and so on.
[0121] During the metering phase, the first frame image is acquired. Based on this first frame image, its current brightness value is obtained. This acquisition process includes: obtaining the histogram of the first frame image and filtering it to remove abrupt changes. The number of overexposed pixels, the highest peak pixel count, the second highest peak pixel count, and the average brightness of the current frame image are then statistically analyzed from the filtered histogram. Using these statistically analyzed numbers as input parameters, the current brightness value of the first frame image is calculated using the following formula:
[0122]
[0123] Wherein, Nx represents the average number of pixels within the first preset range, Ny represents the average number of pixels within the second preset range, Bx represents the average brightness value of pixels within the first preset range, By represents the average brightness value of pixels within the first preset range, N represents the total number of pixels in the current frame image, Ng represents the number of overexposed pixels, and Bi represents the average brightness of the current frame image (the average brightness of the current frame image is obtained by averaging the brightness values of all pixels).
[0124] After obtaining the current brightness value of the first frame image, determine the brightness range to which the current brightness value of the first frame image belongs:
[0125] If the current brightness value of the first frame image is within a first brightness range, then the first calculation method corresponding to the first brightness range is selected to calculate the target brightness value of the second frame image. The first calculation method includes: determining the number of overexposed pixels in the first frame image; if the number of overexposed pixels in the first frame image is 0, then the current brightness value of the first frame image is used as the target brightness value of the second frame image; if the number of overexposed pixels in the current frame image is greater than 0, it indicates that there are overexposed pixels in the first frame image, and in this case, the image brightness needs to be reduced to mitigate the impact of the overexposed pixels. The target brightness value of the second frame image is calculated using the following formula:
[0126] Bt=(1-Ng / N)×Bc,
[0127] Where Bt represents the target brightness value of the next frame image (which is now the second frame image, and the current frame image is the first frame image), Ng represents the number of overexposed pixels, N represents the total number of pixels in the current frame image, and Bc represents the current brightness value of the current frame image.
[0128] If the current brightness value of the current frame image is within the second brightness range, select the second calculation method corresponding to the second brightness range to calculate the target brightness value of the next frame image, and the current brightness value of the current frame image can be used as the target brightness value of the next frame.
[0129] When the current brightness value of the first frame image is within the third brightness range, the third calculation method corresponding to the third brightness range is selected to calculate the target brightness value of the second frame image. Specifically, the target brightness value of the next two frames image is calculated according to the following formula: Bt = Bt * α, where Bt is the target brightness value of the next frame image, the initial value can be the brightness value within the second brightness range, and α is a natural number greater than 1.
[0130] After calculating the target brightness value of the second frame image, the exposure time of the second frame image is determined based on whether its target brightness value increases or decreases relative to the current brightness value of the first frame image. If it increases, the exposure time of the second frame image is increased by adding to the exposure time of the first frame image. Then, it is determined whether the exposure time interval of the second frame image is the same as that of the first frame image.
[0131] If the two frames belong to the same exposure time interval, the gain of the second frame image is equal to the gain of the first frame image; if the two frames belong to different exposure time intervals, the second exposure time is kept unchanged (i.e., the exposure time of the next frame image is equal to the exposure time of the current frame), and the gain of the first frame is incremented to obtain the gain of the second frame image.
[0132] At this time, the exposure parameters of the first frame image and the second frame image are not the same. Based on the same process described above, the second frame is used as the current frame image to calculate the exposure parameters of the third frame image. After obtaining the exposure parameters of the third frame image, it is determined whether the gain interval corresponding to the gain of the third frame corresponds to the exposure time interval of the third frame image.
[0133] If they correspond, when calculating the exposure parameters of the 4th frame image, first calculate the exposure time of the 4th frame image using the above method, and then calculate the gain of the 4th frame image. If the gain interval corresponding to the gain of the 3rd frame image does not correspond to the exposure time interval of the 3rd frame image, then directly set the exposure time of the 4th frame image to the exposure time of the 3rd frame image, and only calculate the gain of the 4th frame image. When calculating the 5th frame, the exposure time is kept the same as the 4th frame, and only the gain of the 5th frame image is calculated, until the exposure time and gain intervals of a certain frame image correspond to the exposure time intervals and gain intervals mentioned above. For example, when calculating the 7th frame, the exposure time interval of the 7th frame image corresponds to the gain interval of the 7th frame image. Subsequently, when calculating the 8th frame, the exposure time of the 8th frame is calculated based on the exposure time of the 7th frame image, and the above process is repeated, and so on, to calculate the exposure parameters of subsequent images. When at least two frames have the same exposure parameters, the same exposure parameters for at least two frames are used for taking pictures.
[0134] The calculation processes involved in this embodiment are relatively simple. For example, the statistical processes and calculation formulas are simple operations (addition, subtraction, multiplication, and division), requiring fewer computational resources. Each calculation only requires data from the current frame image, and the remaining historical data can be discarded from memory, further reducing memory requirements (only the data from the current frame image and the calculated data from the next frame image can be retained to determine if there are two identical exposure parameters). In ideal conditions (no change in ambient light), only 3 frames are needed to obtain converged exposure parameters. In general conditions (changes in ambient light), a maximum of 10 frames are needed to obtain converged exposure parameters. This means that the time required for metering using the method of this application is shorter for cameras with the same performance (existing technologies require 30 frames to obtain converged exposure parameters; assuming a camera's performance is 60 frames per second, existing technologies require 0.5 seconds to obtain converged exposure parameters, while the method of this application only requires 1 / 6 of a second). This application offers high adjustment efficiency.
[0135] Based on the same inventive concept, this application also provides a camera control device for implementing the above-described method. The solution provided by this device is similar to the solution described in the above-described method; therefore, the specific limitations in the one or more camera control device embodiments provided below can be found in the limitations of the camera control method described above, and will not be repeated here.
[0136] In one embodiment, such as Figure 4 As shown, a camera control device is provided, comprising:
[0137] The first acquisition module 100 is used to acquire the current frame image in real time through the camera, and determine the corresponding current brightness value based on the current frame image;
[0138] The first calculation module 200 is used to determine the brightness range of the current brightness value and select a calculation method corresponding to the brightness range of the current brightness value to calculate the target brightness value of the next frame image.
[0139] The second calculation module 300 is used to calculate the target exposure parameters of the next frame image based on the current brightness value, the target brightness value, and the exposure parameters of the current frame image.
[0140] The camera module 400 is used to control the camera to take a picture using the target exposure parameters of the next frame image if the target exposure parameters of the next frame image are the same as the exposure parameters of the current frame image.
[0141] In an optional embodiment, the first acquisition module 100 includes:
[0142] The first acquisition unit (not shown) is used to obtain the brightness histogram of the current frame image based on the current frame image;
[0143] The statistical unit (not shown in the figure) is used to count the number of overexposed pixels in the brightness histogram, the number of pixels in the first preset range, the number of pixels in the second preset range, and to determine the average brightness of the current frame image, the brightness value of the pixels in the first preset range, and the brightness value of the pixels in the second preset range based on the brightness histogram. The first preset range includes the peak value of the highest peak in the brightness histogram, and the second preset range includes the peak value of the second highest peak in the brightness histogram.
[0144] A first calculation unit (not shown) is configured to calculate a first calculated value based on the number of pixels within the first preset range, the number of pixels within the second preset range, the brightness value of each pixel within the first preset range, and the brightness value of each pixel within the second preset range; calculate a second calculated value based on the number of overexposed pixels and the total number of pixels in the current frame image; calculate a third calculated value based on the total number of pixels in the current frame image, the average brightness of the current frame image, the number of pixels within the first preset range, the number of pixels within the second preset range, and the number of overexposed pixels; and use the sum of the first calculated value, the second calculated value, and the third calculated value as the current brightness value of the current frame image.
[0145] In an optional embodiment, the first calculation unit is further configured to obtain the current brightness value of the current frame image using the following calculation formula:
[0146]
[0147] Wherein, Nx represents the average number of pixels within the first preset range, Ny represents the average number of pixels within the second preset range, Bx represents the average brightness value of pixels within the first preset range, By represents the average brightness value of pixels within the first preset range, N represents the total number of pixels in the current frame image, and Bi represents the average brightness of the current frame image.
[0148] In an optional embodiment, the first acquisition module 100 further includes:
[0149] A filtering unit (not shown) is used to obtain a first luminance histogram of the current frame image based on the current frame image; and to filter the first luminance histogram to obtain a luminance histogram.
[0150] In an optional embodiment, the first computing module 200 includes:
[0151] The second calculation unit (not shown) is used to determine the brightness range of the current brightness value as the first brightness range if the current brightness value is greater than the first threshold, and to select the first calculation method corresponding to the first brightness range to calculate the target brightness value of the next frame image.
[0152] The third calculation unit (not shown) is used to determine the brightness range of the current brightness value as the second brightness range if the current brightness value is greater than or equal to the second threshold and less than or equal to the first threshold, and to select the second calculation method corresponding to the second brightness range to calculate the target brightness value of the next frame image, wherein the second threshold is less than the first threshold.
[0153] The fourth calculation unit (not shown) is used to determine the brightness range of the current brightness value as the third brightness range if the current brightness value is less than the second threshold, and to select the third calculation method corresponding to the third brightness range to calculate the target brightness value of the next frame image.
[0154] In an optional embodiment, the second computing unit is further configured to:
[0155] Determine the number of overexposed pixels in the current frame image;
[0156] If the number of overexposed pixels in the current frame image is greater than 0, the target brightness value of the next frame image is calculated based on the current brightness value of the current frame image, and the target brightness value of the next frame image is less than the current brightness value of the current frame image.
[0157] If the number of overexposed pixels in the current frame image is equal to 0, the current brightness value of the current frame image is used as the target brightness value of the next frame image.
[0158] In an optional embodiment, the second computing unit is further configured to:
[0159] Calculate the number of pixels in the current frame image excluding overexposed pixels, and the total number of pixels in the current frame image;
[0160] Calculate the ratio of the number of pixels in the current frame image excluding overexposed pixels to the total number of pixels in the current frame image;
[0161] The target brightness value of the next frame image is calculated based on the ratio and the current brightness value.
[0162] In an optional embodiment, the second computing unit is further configured to:
[0163] The target brightness value of the next frame image is calculated using the following formula:
[0164] Bt=(1-Ng / N)×Bc,
[0165] Where Bt represents the target brightness value of the next frame image, Ng represents the number of overexposed pixels, N represents the total number of pixels in the current frame image, and Bc represents the current brightness value of the current frame image.
[0166] In an optional embodiment, the third computing unit is further configured to:
[0167] The current brightness value of the current frame image is used as the target brightness value of the next frame image.
[0168] In an optional embodiment, the fourth computing unit is further configured to:
[0169] The photometric brightness of the next frame image is obtained, and the photometric brightness of the next frame image is incremented to obtain the incremented photometric brightness. The incremented photometric brightness is used as the target brightness value of the next frame image.
[0170] In an optional embodiment, the second computing module 300 is further configured to:
[0171] The exposure parameters of the current frame image are determined based on the current frame image, and the exposure parameters of the current frame image include a first exposure time and a first gain;
[0172] Determine the relationship between the current brightness value and the target brightness value of the next frame image;
[0173] Based on the relationship between the current brightness value and the target brightness value of the next frame image, and the first exposure time, the second exposure time of the next frame image is obtained;
[0174] Determine the exposure time intervals to which the first exposure time and the second exposure time belong, and determine whether the exposure time intervals corresponding to the first exposure time and the second exposure time are the same, and obtain the determination result;
[0175] Based on the judgment result, the corresponding gain calculation method is selected to obtain the second gain of the next frame image, and the second exposure time and the second gain are used as the target exposure parameters of the next frame image.
[0176] In an optional embodiment, the second computing module 300 is further configured to:
[0177] Based on the relationship between the current brightness value and the target brightness value of the next frame image, the corresponding exposure time gradient is determined according to the relationship.
[0178] The exposure time intervals to which the first exposure time and the second exposure time belong in the exposure time gradient are determined respectively, wherein the first exposure time gradient and the second exposure time gradient include the same number of exposure time intervals, and the upper bound of each exposure time interval in the second exposure time gradient is greater than the upper bound of the corresponding exposure time interval in the first exposure time gradient.
[0179] In an optional embodiment, the second computing module 300 is further configured to:
[0180] If the current brightness value is greater than the target brightness value, the exposure time gradient is determined to be the first exposure time gradient;
[0181] If the current brightness value is less than the target brightness value, the exposure time gradient is determined to be the second exposure time gradient.
[0182] In an optional embodiment, the second computing module 300 is further configured to:
[0183] The second exposure time of the next frame image is calculated based on the difference between the target brightness value and the current brightness value and the first exposure time.
[0184] In an optional embodiment, the second computing module 300 is further configured to:
[0185] If the exposure time interval of the second exposure time of the next frame image is the same as the exposure time interval of the first exposure time of the current frame image, then the first gain is used as the second gain.
[0186] If the exposure time interval of the second exposure time of the next frame image is different from the exposure time interval of the first exposure time of the current frame image, then the first exposure time is used as the exposure time of the next frame image, and the first gain is incremented according to the first gain, and the second gain is obtained according to the incremented first gain.
[0187] In an optional embodiment, the second computing module 300 is further configured to:
[0188] If the second gain has the same gain interval as the first gain, when calculating the target exposure parameters of the next frame image, the second exposure time remains unchanged, and the second gain of the next frame image is incremented as the first gain of the current frame image to obtain the second gain of the next frame image, until the gain interval corresponding to the second gain corresponds to the exposure time interval to which the second exposure time belongs.
[0189] In an optional embodiment, the second computing module 300 is further configured to:
[0190] If the gain range corresponding to the second gain is not the same as that corresponding to the first gain, return to step: obtain the second exposure time of the next frame image based on the first exposure time and the target brightness value.
[0191] The various modules in the camera's control device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the computer device's memory as software, so that the processor can call and execute the corresponding operations of each module.
[0192] In one embodiment, a camera is provided, which can be a monocular camera, a multi-view camera, or a device including a camera module. Its internal structure diagram can be as follows: Figure 5 As shown, the computer device includes a processor, memory, and a camera. The camera's processor provides computational and control capabilities. The camera's memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. When the computer program is executed by the processor, it is used to implement a camera control method.
[0193] Those skilled in the art will understand that Figure 5The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0194] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, is used to implement the steps of the camera control method described above.
[0195] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, is used to implement the steps of the camera control method described above.
[0196] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The processors involved in the embodiments provided in this application can be general-purpose processors, central processing units, graphics processors, etc., and are not limited thereto.
[0197] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0198] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A camera, comprising a camera lens, a memory, and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it performs the following steps: The camera acquires the current frame image in real time, and determines the corresponding current brightness value based on the current frame image; Determine the brightness range of the current brightness value, and select a calculation method corresponding to the brightness range of the current brightness value to calculate the target brightness value of the next frame image; The exposure parameters of the current frame image are determined based on the current frame image, and the exposure parameters of the current frame image include a first exposure time and a first gain; Determine the relationship between the current brightness value and the target brightness value of the next frame image; Based on the relationship between the current brightness value and the target brightness value of the next frame image, and the first exposure time, the second exposure time of the next frame image is obtained; Determine the exposure time intervals to which the first exposure time and the second exposure time belong, and determine whether the exposure time intervals corresponding to the first exposure time and the second exposure time are the same, and obtain the determination result; Based on the judgment result, the corresponding gain calculation method is selected to obtain the second gain of the next frame image, and the second exposure time and the second gain are used as the target exposure parameters of the next frame image; If the target exposure parameters of the next frame image are the same as the exposure parameters of the current frame image, the camera is controlled to take a picture using the target exposure parameters of the next frame image.
2. The camera according to claim 1, characterized in that, Determining the corresponding current brightness value based on the current frame image includes: Based on the current frame image, obtain the brightness histogram of the current frame image; The number of overexposed pixels in the brightness histogram, the number of pixels within a first preset range, and the number of pixels within a second preset range are counted. The average brightness of the current frame image, the brightness value of pixels within the first preset range, and the brightness value of pixels within the second preset range are determined based on the brightness histogram. The first preset range includes the peak value of the highest peak in the brightness histogram, and the second preset range includes the peak value of the second highest peak in the brightness histogram. A first calculated value is obtained based on the number of pixels in the first preset range, the number of pixels in the second preset range, the brightness value of each pixel in the first preset range, and the brightness value of each pixel in the second preset range. A second calculated value is obtained based on the number of overexposed pixels and the total number of pixels in the current frame image; A third calculated value is obtained based on the total number of pixels in the current frame image, the average brightness of the current frame image, the number of pixels within the first preset range, the number of pixels within the second preset range, and the number of overexposed pixels; The sum of the first calculated value, the second calculated value, and the third calculated value is used as the current brightness value of the current frame image.
3. The camera according to claim 2, characterized in that, The step of obtaining the brightness histogram of the current frame image based on the current frame image includes: Based on the current frame image, obtain the first brightness histogram of the current frame image; The first luminance histogram is filtered to obtain the luminance histogram.
4. The camera according to claim 1, characterized in that, The step of determining the brightness range of the current brightness value and selecting a calculation method corresponding to the brightness range of the current brightness value to calculate the target brightness value of the next frame image includes: If the current brightness value is greater than the first threshold, then the brightness range in which the current brightness value is located is determined to be the first brightness range, and the first calculation method corresponding to the first brightness range is selected to calculate the target brightness value of the next frame image. If the current brightness value is greater than or equal to the second threshold and less than or equal to the first threshold, then the brightness range in which the current brightness value is located is determined to be the second brightness range, and the second calculation method corresponding to the second brightness range is selected to calculate the target brightness value of the next frame image, wherein the second threshold is less than the first threshold; If the current brightness value is less than the second threshold, then the brightness range in which the current brightness value is located is determined to be the third brightness range, and the third calculation method corresponding to the third brightness range is selected to calculate the target brightness value of the next frame image.
5. The camera according to claim 4, characterized in that, The first calculation method includes: Determine the number of overexposed pixels in the current frame image; If the number of overexposed pixels in the current frame image is greater than 0, then the target brightness value of the next frame image is calculated based on the number of pixels other than overexposed pixels in the current frame image, the total number of pixels in the current frame image, and the current brightness value of the current frame image, and the target brightness value of the next frame image is less than the current brightness value of the current frame image. If the number of overexposed pixels in the current frame image is equal to 0, then the current brightness value of the current frame image is used as the target brightness value of the next frame image.
6. The camera according to claim 5, characterized in that, The step of calculating the target brightness value of the next frame image based on the number of pixels in the current frame image excluding overexposed pixels, the total number of pixels in the current frame image, and the current brightness value of the current frame image includes: Calculate the number of pixels in the current frame image excluding overexposed pixels, and the total number of pixels in the current frame image; Calculate the ratio of the number of pixels in the current frame image excluding overexposed pixels to the total number of pixels in the current frame image; The target brightness value of the next frame image is calculated based on the ratio and the current brightness value.
7. The camera according to claim 4, characterized in that, The second calculation method includes: The current brightness value of the current frame image is used as the target brightness value of the next frame image.
8. The camera according to claim 4, characterized in that, The third calculation method includes: The photometric brightness of the next frame image is obtained, and the photometric brightness of the next frame image is incremented to obtain the incremented photometric brightness. The incremented photometric brightness is used as the target brightness value of the next frame image.
9. The camera according to claim 1, characterized in that, Determining the exposure time intervals to which the first exposure time and the second exposure time belong respectively includes: The corresponding exposure time gradient is determined based on the relationship between the current brightness value and the target brightness value of the next frame image; Determine the exposure time intervals to which the first exposure time and the second exposure time belong in the exposure time gradient, respectively; Correspondingly, determining the corresponding exposure time gradient based on the relationship between the current brightness value and the target brightness value of the next frame image includes: If the current brightness value is greater than the target brightness value, the exposure time gradient is determined to be the first exposure time gradient; If the current brightness value is less than the target brightness value, the exposure time gradient is determined to be the second exposure time gradient, wherein the first exposure time gradient and the second exposure time gradient include the same number of exposure time intervals, and the maximum value of each exposure time interval in the second exposure time gradient is greater than the maximum value of the corresponding exposure time interval in the first exposure time gradient.
10. The camera according to claim 9, characterized in that, The step of obtaining the second exposure time of the next frame image based on the first exposure time and the target brightness value includes: The second exposure time of the next frame image is calculated based on the difference between the target brightness value and the current brightness value and the first exposure time.
11. The camera according to claim 9, characterized in that, The step of selecting the corresponding gain calculation method based on the judgment result to obtain the second gain of the next frame image includes: If the exposure time interval of the second exposure time of the next frame image is the same as the exposure time interval of the first exposure time of the current frame image, then the first gain is used as the second gain. If the exposure time interval of the second exposure time of the next frame image is different from the exposure time interval of the first exposure time of the current frame image, then the first exposure time is used as the exposure time of the next frame image, and the first gain is incremented according to the first gain, and the second gain is obtained according to the incremented first gain.
12. The camera according to claim 11, characterized in that, After incrementing the gain based on the first gain and obtaining the second gain based on the incremented first gain, the processor, when executing the computer program, further implements the following steps: If the second gain is the same as the gain interval corresponding to the first gain, then when calculating the target exposure parameters of the next frame image, the second exposure time is kept unchanged, and the second gain of the next frame image is incremented as the first gain of the current frame image to obtain the second gain of the next frame image, until the gain interval corresponding to the second gain corresponds to the exposure time interval to which the second exposure time belongs.
13. The camera according to claim 12, characterized in that, After obtaining the second gain by incrementing the first gain, the method further includes: If the second gain is not the same as the gain range corresponding to the first gain, return to step: obtain the second exposure time of the next frame image based on the first exposure time and the target brightness value.
14. A method for controlling a camera, characterized in that, The method includes: The current frame image is acquired in real time by the camera, and the corresponding current brightness value is determined based on the current frame image; Determine the brightness range of the current brightness value, and select a calculation method corresponding to the brightness range of the current brightness value to calculate the target brightness value of the next frame image; The exposure parameters of the current frame image are determined based on the current frame image, and the exposure parameters of the current frame image include a first exposure time and a first gain; Determine the relationship between the current brightness value and the target brightness value of the next frame image; Based on the relationship between the current brightness value and the target brightness value of the next frame image, and the first exposure time, the second exposure time of the next frame image is obtained; Determine the exposure time intervals to which the first exposure time and the second exposure time belong, and determine whether the exposure time intervals corresponding to the first exposure time and the second exposure time are the same, and obtain the determination result; Based on the judgment result, the corresponding gain calculation method is selected to obtain the second gain of the next frame image, and the second exposure time and the second gain are used as the target exposure parameters of the next frame image; If the target exposure parameters of the next frame image are the same as the exposure parameters of the current frame image, the camera is controlled to take a picture using the target exposure parameters of the next frame image.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it is used to implement the steps of the method of claim 14.
Citation Information
Patent Citations
Exposure adjustment method and device and storage device
CN112153297A