Light source brightness adjustment method, electronic device and readable storage medium
By taking multiple shots under the camera of an electronic device and determining the light source illuminance similarity, and automatically adjusting the light source brightness, the problem of inaccurate adjustment of the light source brightness in the prior art is solved, and efficient and accurate image quality adjustment is achieved.
Patent Information
- Application Number
- CN202311290372.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-28
- Publication Date
- 2025-04-04
AI Technical Summary
In the prior art, the adjustment of the brightness of the light source of the electronic device is subjective, and the image quality cannot be accurately measured, resulting in inaccurate adjustment.
The camera of an electronic device takes multiple shots of the target object under different light source illuminance, determines the light source illuminance similarity between the image obtained each time and the reference image, determines the target light source brightness based on the light source brightness adjustment range, and automatically adjusts the light source brightness of the camera.
Automatic adjustment of the brightness of the light source of the electronic device is realized, which improves the convenience and accuracy of adjustment, and ensures that the captured image quality is close to the reference image.
Smart Images

Figure CN119767152A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminal technology, and in particular to a method for adjusting the brightness of a light source, an electronic device, and a readable storage medium. Background Art
[0002] With the development of intelligent electronic devices, machine vision technology is being introduced into more and more fields. Through machine vision technology, product identification, detection, positioning analysis, etc. can be performed. For example, it can be applied in the field of manufacturing. Electronic devices analyze product images to improve production efficiency and product accuracy. Since image quality is the key to electronic devices identifying and analyzing images, the better the image quality, the more accurate the electronic device's image detection and analysis operations, and the brightness of the light source of the electronic device will affect the image quality during the image acquisition process, in order to obtain higher quality images, it is usually necessary to adjust the brightness of the light source of the electronic device.
[0003] Currently, the brightness adjustment of the light source of the electronic device is usually performed manually, that is, the user can manually modify the brightness of the light source of the electronic device until the user feels that the image quality is relatively satisfactory.
[0004] However, the user's adjustment of the light source brightness of the electronic device is subjective and cannot accurately measure the image quality, resulting in inaccurate adjustment of the light source brightness. Summary of the invention
[0005] The present application provides a method for adjusting the brightness of a light source, an electronic device, and a readable storage medium, which can be used to solve the problem of inaccurate adjustment of the brightness of a light source in the related art. The technical solution is as follows:
[0006] In a first aspect, a method for adjusting the brightness of a light source is provided, which is applied to an electronic device, and the method comprises:
[0007] A target object is photographed multiple times by a camera of an electronic device, and the brightness of the light source of the camera is different during each photographing; after a first image is obtained each time the first image is photographed, the similarity of the first light source illumination between the obtained first image and a reference image is determined, the reference image is an image of the target object captured by other devices, and the image quality of the reference image is higher than the image quality of the first image obtained each time when the camera performs multiple photographing; when the similarity of the first light source illumination changes from an upward trend to a downward trend, based on the light source brightness adjustment interval, the target light source brightness is determined, and the target light source brightness maximizes the image quality similarity between the image captured by the camera and the reference image, wherein the light source brightness adjustment interval includes a light source brightness interval indicating that the corresponding light source illumination similarity changes from an upward trend to a downward trend; the light source brightness of the camera is adjusted to the target light source brightness.
[0008] In this way, the electronic device can determine the similarity of the light source illumination between the captured image and the reference image, and through the light source illumination similarity, the light source brightness of the camera can be automatically adjusted to the most appropriate light source brightness, that is, the light source brightness of the camera can be adjusted to the light source brightness that can obtain high-quality images, thereby realizing automatic adjustment of the electronic device without the need for the user to make repeated adjustments, thereby improving the convenience of adjustment. In addition, since the light source brightness of the electronic device camera can be adjusted through the light source illumination similarity, the adjustment of the light source brightness has a data basis, thereby improving the accuracy of the light source brightness adjustment.
[0009] As an example of the present application, the operation of performing multiple shots of a target object through a camera of an electronic device includes: responding to a shooting instruction, shooting the target object based on the minimum light source brightness of the camera; after completing one shot, increasing a first light source brightness threshold based on the light source brightness of the previous shot; responding to the shooting instruction again, continuing to shoot the target object based on the increased light source brightness, and returning to the operation of increasing the first light source brightness threshold based on the light source brightness of the previous shot after completing one shot.
[0010] In other words, the electronic device can start from the lowest light source brightness of the camera, take the first light source brightness threshold as an interval, and shoot the target object in order from small to large light source brightness.
[0011] In this way, the brightness of the camera's light source is adjusted in an incremental manner during the shooting process, so that the electronic device can quickly obtain multiple first images with different light source illuminations, and the first illumination similarities corresponding to the acquired first images can be quickly sorted according to the shooting order, thereby improving the efficiency of determining the changing trend of the first light source illumination similarity.
[0012] As an example of the present application, in a case where the similarity of the illumination of the first light source changes from an upward trend to a downward trend, the operation of determining the brightness of the target light source based on the light source brightness adjustment interval includes: in a case where the similarity of the illumination of the first light source changes from an upward trend to a downward trend, continuing to shoot the target object multiple times through the camera, and the light source brightness of the camera is selected from the light source brightness adjustment interval and is different from each other in each shooting; after a second image is obtained in each shooting, determining the similarity of the illumination of the second light source between the obtained second image and the reference image; in a case where the similarity of the illumination of the second light source changes from an upward trend to a downward trend, determining the brightness of the target light source according to the light source brightness of each second image in the multiple second images currently obtained and the similarity of the illumination of the second light source.
[0013] In this way, by continuing to shoot multiple times in the light source brightness adjustment area and according to the similarity of the second light source illumination between the second image and the reference image, the brightness of the target light source can be determined more accurately.
[0014] As an example of the present application, when the similarity of the illumination of the first light source changes from an upward trend to a downward trend, the operation of continuing to shoot the target object multiple times through the camera includes: responding to a shooting instruction, shooting the target object based on the maximum light source brightness in the light source brightness adjustment interval; after completing one shooting, reducing the second light source brightness threshold based on the light source brightness of the last shooting, the second light source brightness threshold is less than the first light source brightness threshold, and the first light source brightness threshold is the light source brightness interval between two adjacent first images captured by the camera; responding to the shooting instruction again, continuing to shoot the target object based on the reduced light source brightness, and returning to the operation of reducing the second light source brightness threshold based on the light source brightness of the last shooting after completing one shooting.
[0015] In this way, by setting a smaller light source brightness threshold and taking multiple shots at intervals with the smaller light source brightness threshold, the brightness range of the target light source can be determined more accurately later, thereby improving the accuracy of determining the brightness of the target light source.
[0016] As an example of the present application, when the second light source illumination similarity changes from an upward trend to a downward trend, based on the light source brightness of each second image in the multiple second images currently obtained and the similarity of the second light source illumination, the operation of determining the target light source brightness includes: when the second light source illumination similarity changes from an upward trend to a downward trend, based on the light source brightness of each second image in the multiple second images and the similarity of the second light source illumination, fitting a light source illumination relationship function, the light source illumination relationship function being used to indicate the correspondence between the light source brightness and the light source similarity, and the light source illumination relationship function being a unimodal function; and determining the peak value of the light source illumination relationship function as the target light source brightness.
[0017] In this way, since the fitted light source illumination relationship function is a unimodal function, and a unimodal function has only one peak, the peak value of the light source illumination relationship function is determined as the target light source brightness, thereby improving the accuracy of determining the target light source brightness.
[0018] As an example of the present application, when the second light source illumination similarity changes from an upward trend to a downward trend, the operation of determining the target light source brightness based on the light source brightness of each second image in the multiple second images currently obtained and the second light source illumination similarity includes: when the second light source illumination similarity changes from an upward trend to a downward trend, determining the maximum light source illumination similarity from the second light source illumination similarities corresponding to the multiple second images; and determining the light source brightness corresponding to the maximum light source illumination similarity as the target light source brightness.
[0019] In this way, the light source brightness corresponding to the maximum light source illumination similarity is directly determined as the target light source brightness, which not only improves the accuracy of determining the target light source brightness, but also reduces the determination steps and improves the determination efficiency.
[0020] As an example of the present application, after a first image is obtained by each shooting, the operation of determining the similarity of the first light source illumination between the obtained first image and the reference image includes: determining the hash similarity and the histogram similarity between the obtained first image and the reference image; and determining the first light source illumination similarity based on the hash similarity and the histogram similarity.
[0021] In this way, since hash similarity and histogram similarity can reflect the similarity of images in terms of light source illumination, the accuracy and reliability of the electronic device in determining the similarity of the first light source illumination is improved through hash similarity and histogram similarity.
[0022] As an example of the present application, the operation of determining the illumination similarity of the first light source based on hash similarity and histogram similarity includes: multiplying the first weight by the hash similarity to obtain the first similarity; multiplying the second weight by the histogram similarity to obtain the second similarity; and determining the sum of the first similarity and the second similarity as the illumination similarity of the first light source.
[0023] In this way, the first light source illumination similarity is determined by setting the weight, thereby more accurately expressing the relationship between the hash similarity and the histogram similarity.
[0024] As an example of the present application, in a case where the illumination similarity of the first light source changes from an upward trend to a downward trend, the operation of determining the brightness of the target light source based on the light source brightness adjustment interval includes: in a case where the illumination similarity of the first light source changes from an upward trend to a downward trend, determining the light source brightness corresponding to any first light source illumination similarity in a downward trend as the upper limit value of the light source brightness adjustment interval; determining the light source brightness corresponding to any first light source illumination similarity in an upward trend as the lower limit value of the light source brightness adjustment interval; and determining the target light source brightness based on the light source brightness adjustment interval.
[0025] In this way, by determining the light source brightness adjustment interval, the range for determining the target light source brightness can be narrowed, thereby improving the accuracy of determining the target light source brightness.
[0026] In a second aspect, an electronic device is provided, wherein the structure of the electronic device includes a processor and a memory, wherein the memory is used to store a program that supports the electronic device to execute the method for adjusting the brightness of the light source provided in the first aspect, and to store data involved in implementing the method for adjusting the brightness of the light source described in the first aspect. The processor is configured to execute the program stored in the memory. The electronic device may also include a communication bus, wherein the communication bus is used to establish a connection between the processor and the memory.
[0027] In a third aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer executes the method for adjusting the brightness of a light source described in the first aspect.
[0028] In a fourth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the method for adjusting the brightness of a light source described in the first aspect.
[0029] The technical effects obtained by the above-mentioned second aspect, third aspect and fourth aspect are similar to the technical effects obtained by the corresponding technical means in the above-mentioned first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 It is a schematic diagram of the imaging effect of products made of different materials provided in an embodiment of the present application;
[0031] Figure 2 It is a schematic diagram of an application scenario provided by an embodiment of the present application;
[0032] Figure 3 is a schematic diagram of another application scenario provided by an embodiment of the present application;
[0033] Figure 4 This is a schematic flow chart of a method for adjusting the brightness of a light source provided in an embodiment of the present application;
[0034] Figure 5 This is a schematic diagram of the correspondence between a device and an image provided in an embodiment of the present application;
[0035] Figure 6 It is a correspondence relationship between the brightness of a light source and the similarity of the illumination of the light source provided in an embodiment of the present application;
[0036] Figure 7 This is a schematic diagram of a peak search method provided in an embodiment of the present application;
[0037] Figure 8 This is a flow chart of another method for adjusting the brightness of a light source provided in an embodiment of the present application;
[0038] Fig. 9 is a schematic diagram of another peak search method provided in an embodiment of the present application;
[0039] Fig.10 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application;
[0040] Fig.11 It is a block diagram of a software system of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0041] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.
[0042] It should be understood that the "multiple" mentioned in this application refers to two or more. In the description of this application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate the clear description of the technical solution of this application, the words "first" and "second" are used to distinguish between the same items or similar items with basically the same functions and effects. Those skilled in the art can understand that the words "first" and "second" do not limit the quantity and execution order, and the words "first" and "second" do not limit them to be different.
[0043] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0044] In the field of production, machine vision systems (or machine vision technology) can usually be introduced. Electronic devices can use machine vision systems to identify and analyze product images to improve product production efficiency and quality. All information in a machine vision system comes from image acquisition. Therefore, the quality of the image is extremely critical to the entire machine vision system. A high-quality image can improve the accuracy and reliability of the entire system. At the same time, different lighting schemes and parameters need to be matched for different material structures, materials, and colors to achieve the best imaging effect. For example, see Figure 1 , Figure 1 For the imaging effect of products with the same structure but different materials, Figure 1 Figure (a) shows the imaging effect of a black product. Figure 1 Figure (b) shows the imaging effect of the golden product.
[0045] Currently, in order to obtain high-quality images, users usually adjust the light source parameters of a reference device. When the image taken by the reference device is a high-quality image, the light source parameters of the reference device can be copied to other electronic devices of the same type. The light source parameters are usually light source brightness.
[0046] However, due to the differences in illumination of light sources of different electronic devices, even if the same light source parameters as the reference device are used, inconsistent imaging effects may occur. In this case, the user needs to constantly adjust the light source brightness of the electronic device, which results in a cumbersome adjustment method. In addition, the user's adjustment of the light source brightness of the electronic device is subjective and cannot accurately measure the image quality, resulting in inaccurate adjustment of the light source brightness. For example, see Figure 2 , Figure 2 After taking a photo of a product with a reference device and obtaining a high-quality image, the user can copy the light source parameters of the reference device to the electronic device. Due to the difference in light source illumination between the electronic device and the reference device, the image quality obtained after the electronic device takes a photo of the product with the same light source brightness is significantly poor. In this case, the user needs to constantly adjust the light source brightness of the electronic device, which makes the operation cumbersome and the light source brightness adjustment inaccurate.
[0047] In order to improve the accuracy of adjusting the brightness of the light source, an embodiment of the present application provides a method for adjusting the brightness of the light source, in which the electronic device can shoot a target object multiple times under different light source illuminations through a camera, and after each shooting to obtain a first image, the first light source illumination similarity between the first image and the reference image can be determined. In the case where the first light source illumination similarity changes from an upward trend to a downward trend, the electronic device can determine a target light source brightness within the light source brightness interval indicating that the first light source illumination similarity changes from an upward trend to a downward trend, and adjust the light source brightness of the camera to the target light source brightness, and the image quality similarity between the image captured by the camera of the electronic device under the target light source brightness and the reference image is the largest. In the present application, the light source brightness of the electronic device can be automatically adjusted through the light source illumination similarity, and the automatic adjustment of the electronic device is realized, without the need for the user to manually adjust it multiple times, thereby improving the convenience of adjustment. In addition, since the light source brightness of the electronic device can be adjusted through the light source illumination similarity, the adjustment has a data basis, thereby improving the accuracy of the light source brightness adjustment.
[0048] For ease of understanding, before introducing the method provided in the embodiments of the present application in detail, the application scenarios involved in the embodiments of the present application are introduced below.
[0049] Please refer to Figure 3 , Figure 3 It is a schematic diagram of an application scenario according to an exemplary embodiment. In a possible scenario, when a reference device takes a high-quality image of a product, that is, takes a reference image, the electronic device can obtain the reference image, and take multiple photos of the product under different light source brightnesses through a camera, and after each photo, determine the light source illumination similarity between the obtained image and the reference image, and automatically adjust the light source brightness of the electronic device to the target light source brightness according to the change trend of the determined light source illumination similarity. The image quality similarity between the image captured by the camera of the electronic device under the target light source brightness and the reference image is the greatest.
[0050] Based on the execution subject and application scenario provided in the above embodiment, the following is an introduction to the method for adjusting the brightness of the light source provided in the embodiment of the present application. Figure 4 , Figure 4 The present invention is a flow chart of a method for adjusting the brightness of a light source according to an exemplary embodiment. As an example but not a limitation, the method is applied to an electronic device equipped with a camera as an example for explanation. The method may include some or all of the following contents:
[0051] Step 401: Acquire a reference image.
[0052] It should be noted that the electronic device may actively acquire the reference image, or may passively acquire the reference image.
[0053] Exemplarily, the reference image is a high-quality image acquired by other devices, and after acquiring the reference image, the other devices can actively send the reference image to the electronic device, and the electronic device, when receiving the reference image, performs the operation of the following step 402. Alternatively, the electronic device sends an acquisition message to the other device in response to the acquisition instruction; the other device sends the reference image to the electronic device when receiving the acquisition message; the electronic device, when receiving the reference image, performs the operation of the following step 402.
[0054] Step 402: photograph the target object to obtain a first image.
[0055] As an example, the electronic device may actively shoot the target object when receiving the reference image. It may also display first prompt information when receiving the reference image, and the first prompt information is used to prompt the user to use the electronic device to shoot the target object. The user may perform a trigger operation according to the first prompt information, and the electronic device responds to the user's trigger operation to shoot the target object and obtain the first image.
[0056] For ease of understanding, the corresponding relationship between the device and the image is now described. The corresponding relationship between the device and the image can be as follows: Figure 5 As shown, the reference image is obtained by photographing the target object by other devices, and the first image is obtained by photographing the target object by the execution subject of this application, i.e., the electronic device. The target object can also be called a benchmark material.
[0057] As an example, when the electronic device photographs the target object for the first time, the electronic device may photograph the target object based on the minimum light source brightness of the camera to obtain the first image. Alternatively, when the electronic device photographs the target object for the first time, the electronic device may photograph the target object based on the maximum light source brightness of the camera to obtain the first image. Alternatively, when the electronic device photographs the target object for the first time, the electronic device may also photograph the target object based on the brightness of any light source of the camera to obtain the first image.
[0058] In some embodiments, the environment in which the target object is photographed by other devices is the same or similar to the environment in which the electronic device photographs the target object multiple times through the camera, and the position and angle at which the electronic device photographs the target object are the same or similar to the position and angle at which the other devices photograph the target object. In this way, the efficiency and accuracy of adjusting the brightness of the light source of the camera of the electronic device are accelerated.
[0059] Step 403: Determine the histogram similarity between the reference image and the first image.
[0060] In some embodiments, the operation of the electronic device determining the histogram similarity between the first image and the reference image includes: determining a reference two-dimensional histogram of the reference image and a first two-dimensional histogram of the first image; determining a Bhattacharyya distance between the reference two-dimensional histogram and the first two-dimensional histogram, and determining the Bhattacharyya distance as the histogram similarity (CompareHist).
[0061] As an example, the electronic device may determine the Bhattacharyya distance between the reference two-dimensional histogram and the first two-dimensional histogram by using the following first formula (1).
[0062]
[0063] It should be noted that, in the above first formula (1), H1 and H2 represent the histogram data of the reference two-dimensional histogram and the histogram data of the first two-dimensional histogram, respectively. and represents the mean, I represents the number of colors, and d(H1, H2) is the Bhattacharyya distance, i.e. the histogram similarity. In addition, the range of histogram similarity is 0-1, where 0 means that the two histograms are very related and 1 means that they are least similar.
[0064] Step 404: Determine the hash similarity between the reference image and the first image.
[0065] In some embodiments, the operation of the electronic device determining the hash similarity between the first image and the reference image includes: respectively determining a reference hash value of the reference image and a first hash value of the first image; determining a Hamming distance between the reference hash value and the first hash value; and determining the hash similarity based on the Hamming distance.
[0066] As an example, the operation of an electronic device determining a reference hash value of a reference image includes: scaling the reference image to an image of size N*N, and gray-scaling the scaled reference image, such as converting it into a 256-level grayscale image; determining a reference two-dimensional discrete cosine transform value for each pixel in the gray-scaled reference image; comparing the reference two-dimensional discrete cosine transform value of each pixel in the gray-scaled reference image with the average two-dimensional discrete cosine transform value of the gray-scaled reference image, marking pixels in the gray-scaled reference image whose reference two-dimensional discrete cosine transform values are greater than or equal to the average two-dimensional discrete cosine transform value of the gray-scaled reference image as 1, and marking pixels whose reference two-dimensional discrete cosine transform values are less than the average two-dimensional discrete cosine transform value of the gray-scaled reference image as 0; after completing the marking of all pixels, the reference binary array is determined as the reference hash value.
[0067] Similarly, the operation of the electronic device determining the first hash value of the first image includes: scaling the first image to an image of size N*N, and graying the scaled first image, such as converting it into a 256-level grayscale image; determining a first two-dimensional discrete cosine transform value of each pixel in the grayed first image; comparing the first two-dimensional discrete cosine transform value of each pixel in the grayed first image with the average two-dimensional discrete cosine transform value of the grayed first image, marking the pixel points in the grayed first image whose first two-dimensional discrete cosine transform value is greater than or equal to the average two-dimensional discrete cosine transform value of the grayed first image as 1, and marking the pixel points whose first two-dimensional discrete cosine transform value is less than the average two-dimensional discrete cosine transform value of the grayed first image as 0; after completing the marking of all pixel points, the first binary array is determined as the first hash value.
[0068] As an example, the electronic device can determine the reference two-dimensional discrete cosine transform value of each pixel point in the grayscale reference image and the first two-dimensional discrete cosine transform value of each pixel point in the grayscale first image respectively through the second formula (2) (also called the two-dimensional discrete cosine transform formula), and the second formula (2) is expressed as follows.
[0069]
[0070] It should be noted that in the above second formula (2), f(x, y) is the grayscale value of the x row and y column in the grayscale image pixel, the image pixel array is N*N, and F(u, v) is the two-dimensional discrete cosine transform value of the image pixel.
[0071] In some embodiments, the operation of the electronic device determining the Hamming distance between the reference hash value and the first hash value includes: counting the number of different hash values at the same position between the reference hash value and the first hash value. Thus, according to the Hamming distance, the operation of determining the hash similarity includes: determining a first ratio of the number of different hash values to the reference binary array or the first binary array, and determining the first ratio as the hash similarity (i.e., ComparePHASH).
[0072] It should be noted that the embodiment of the present application does not impose any specific restrictions on the execution order of the operation of step 403 and the operation of step 404, that is, the electronic device may first execute the operation of step 403 and then execute the operation of step 404, or the electronic device may first execute the operation of step 404 and then execute the operation of step 403, or the electronic device may execute the operation of step 403 and the operation of step 404 at the same time.
[0073] Step 405: Determine the first light source illumination similarity according to the histogram similarity and the hash similarity.
[0074] In some embodiments, the operation of the electronic device determining the illumination similarity of the first light source based on the histogram similarity and the hash similarity includes: multiplying the first weight by the hash similarity to obtain the first similarity; multiplying the second weight by the histogram similarity to obtain the second similarity; and determining the sum of the first similarity and the second similarity as the illumination similarity of the first light source.
[0075] It should be noted that the first weight and the second weight can be set in advance according to needs, and the sum of the first weight and the second weight is 1. For example, the first weight can be 0.5 and the second weight can be 0.5, or the first weight can be 0.6 and the second weight can be 0.4, or the first weight can be 0.4 and the second weight can be 0.6, etc. The embodiments of the present application do not impose specific restrictions on this.
[0076] Step 406: Determine whether there is a first light source illumination similarity indicating that the first image is closest in quality to the reference image. If yes, perform the operation of the following step 407; if no, perform the operation of the following step 409.
[0077] Since the corresponding relationship diagram between the light source brightness and the light source illumination similarity is a single peak diagram. For example, see Figure 6 , when the light source brightness is 60 candelas / square meter, the corresponding light source illumination similarity is the largest, and when the light source brightness increases from 0 candelas / square meter to 60 candelas / square meter, the corresponding light source illumination similarity shows an upward trend; when the light source brightness increases from 60 candelas / square meter, the corresponding light source illumination similarity shows a downward trend. It can be seen that the electronic device can obtain the first image that is closest to the reference image quality when the light source brightness is 60 candelas / square meter. Therefore, after determining the first light source illumination similarity, the electronic device can determine whether there is a first light source illumination similarity indicating that the first image is closest to the reference image quality according to the change trend of the obtained first light source illumination similarity.
[0078] As an example, when the obtained transformation trend of the first light source illumination similarity changes from an upward trend to a downward trend, the electronic device may determine that there is a first light source illumination similarity indicating that the quality of the first image is closest to that of the reference image. When the obtained transformation trend of the first light source illumination similarity is an upward trend or a downward trend, it is determined that the first light source illumination similarity indicating that the quality of the first image is closest to that of the reference image has not yet appeared.
[0079] Step 407: Determine the target light source brightness based on the light source brightness adjustment interval.
[0080] It should be noted that the target light source brightness maximizes the image quality similarity between the image captured by the camera and the reference image, wherein the light source brightness adjustment interval includes a light source brightness interval indicating that the corresponding light source illumination similarity changes from an upward trend to a downward trend.
[0081] In some embodiments, when there is a first light source illumination similarity indicating that the quality of the first image is closest to that of the reference image, the electronic device may determine the light source brightness corresponding to any first light source illumination similarity that is in a downward trend as the upper limit value of the light source brightness adjustment range; and determine the light source brightness corresponding to any first light source illumination similarity that is in an upward trend as the lower limit value of the light source brightness adjustment range.
[0082] For example, if the similarity variation trend of the first light source illumination is as above Figure 6 As shown, the electronic device can determine 40 as the lower limit value of the light source brightness adjustment interval, and determine 80 as the lower limit value of the light source brightness adjustment interval. Alternatively, the electronic device can determine 40 as the lower limit value of the light source brightness adjustment interval, and determine 65 as the lower limit value of the light source brightness adjustment interval, etc.
[0083] Since the light source brightness adjustment interval includes a light source brightness interval indicating that the corresponding light source illumination similarity changes from an upward trend to a downward trend, the light source brightness corresponding to the first light source illumination similarity indicating that the first image is closest to the reference image quality must be within the light source brightness adjustment interval. Therefore, the electronic device can determine any light source brightness close to the upper limit value within the light source brightness adjustment interval as the target light source brightness. Alternatively, the electronic device can determine the middle value within the light source brightness interval as the target light source brightness. The embodiments of the present application do not impose specific restrictions on this.
[0084] Step 408: photograph the target object through a camera based on the brightness of the target light source.
[0085] Since the brightness of the target light source maximizes the image quality similarity between the image captured by the camera and the reference image, the electronic device can obtain a high-quality first image by photographing the target object through the camera based on the brightness of the target light source.
[0086] Step 409: Change the brightness of the light source of the camera and return to step 402.
[0087] In some embodiments, the electronic device may change the brightness of the light source of the camera in an increasing manner, or may change the brightness of the light source of the camera in a decreasing manner. For example, if the electronic device starts to shoot the target object with the lowest brightness of the light source of the camera, then the electronic device may change the brightness of the light source of the camera in an increasing manner each time with the first light source brightness threshold as an interval. Alternatively, if the electronic device starts to shoot the target object with the maximum brightness of the light source of the camera, then the electronic device may change the brightness of the light source of the camera in a decreasing manner each time with the first light source brightness threshold as an interval.
[0088] In some embodiments, the electronic device may also randomly change the brightness of the light source of the camera, or the electronic device may also change the brightness of the light source of the camera according to the variation trend of the illumination similarity of the first light source. For example, when the brightness of the light source of the camera is changed in an increasing manner, if the variation trend of the illumination similarity of the first light source is a decreasing trend, the electronic device may change to change the brightness of the light source of the camera in a decreasing manner.
[0089] In some embodiments, when the electronic device randomly changes the brightness of the light source of the camera to take multiple shots of the target object, the electronic device can first sort the first light source illumination similarities corresponding to the first image in the order of small to large or large to small according to the light source illumination of the obtained first image in each process of determining the change trend of the first light source illumination similarity; after sorting, determine the change trend of the first light source illumination similarity. In this way, the accuracy of determining the change trend of the first light source illumination similarity is improved.
[0090] In the embodiment of the present application, the electronic device can determine the light source illumination similarity between the captured image and the reference image, and through the light source illumination similarity, the light source brightness of the camera can be automatically adjusted to the most appropriate light source brightness, that is, the light source brightness of the camera can be adjusted to the light source brightness that can obtain high-quality images, thereby realizing automatic adjustment of the electronic device without the user having to adjust repeatedly, thereby improving the convenience of adjustment. In addition, since the light source brightness of the electronic device camera can be adjusted through the light source illumination similarity, the adjustment of the light source brightness has a data basis, thereby improving the accuracy of the light source brightness adjustment.
[0091] In the above embodiment, it can be determined that the target light source brightness is within the light source brightness interval indicating that the change trend of the first light source illumination similarity changes from an upward trend to a downward trend. This determination method can be called peak search, and the above embodiment is a rough search example. On this basis, see Figure 7 In addition to manual adjustment of light source brightness and rough search, electronic devices can also perform fine search. Figure 8 , Figure 8The present invention is a flow chart of a method for adjusting the brightness of a light source according to an exemplary embodiment. As an example but not a limitation, the method is described here by applying it to an electronic device equipped with a camera, and the method is described by including the above-mentioned rough search and continuing the fine search based on the rough search. The method may include some or all of the following contents:
[0092] Step 801: Take multiple photos of a target object using a camera of an electronic device.
[0093] It should be noted that when the electronic device uses a camera to shoot a target object multiple times, the brightness of the light source of the camera is different each time the shooting is performed. Exemplarily, in the process of shooting a target object in multiple places by the camera of an electronic device, the brightness of the light source of the camera may be increased in an incremental manner, or decreased in a decreasing manner each time the shooting is performed. Of course, it may also change randomly, and the embodiments of the present application do not impose specific restrictions on this. In addition, when adjusting the brightness of the light source, the brightness of the light source of the camera may be automatically adjusted by the electronic device each time the camera shoots, or it may be manually adjusted by the user, and the embodiments of the present application do not impose specific restrictions on this either.
[0094] In a possible implementation, the operation of an electronic device taking multiple shots of a target object through a camera of the electronic device includes: the electronic device can start from the lowest light source brightness of the camera, and take the first light source brightness threshold as an interval, and take shots of the target object in order of light source brightness from small to large. In other words, the electronic device can take shots of the target object based on the lowest light source brightness of the camera in response to a shooting instruction; after completing one shot, increase the first light source brightness threshold based on the light source brightness of the last shot; respond to the shooting instruction again, continue to take shots of the target object based on the increased light source brightness, and return to the operation of increasing the first light source brightness threshold based on the light source brightness of the last shot after completing one shot.
[0095] It should be noted that the brightness threshold of the first light source can be preset according to requirements, for example, the brightness threshold of the first light source can be 10 candelas / square meter or 20 candelas / square meter.
[0096] As an example, the shooting instruction may be triggered by the user or automatically by the electronic device. For example, in the case of the first shooting, the user may trigger the shooting instruction through a trigger operation, and the electronic device responds to the shooting instruction and shoots the target object with the lowest light source brightness of the camera. After that, after adjusting the light source brightness, the electronic device may automatically trigger the shooting instruction. Alternatively, after the electronic device adjusts the light source brightness, the user triggers the shooting instruction again.
[0097] It is worth noting that during the shooting process, the brightness of the camera's light source is adjusted in an incremental manner, so that the electronic device can quickly obtain multiple first images with different light source illuminations, and the first illumination similarities corresponding to the acquired first images can be quickly sorted according to the shooting order, thereby improving the efficiency of determining the changing trend of the first light source illumination similarity.
[0098] In another possible implementation, the operation of the electronic device taking multiple shots of the target object through the camera of the electronic device includes: the electronic device can start from the maximum light source brightness of the camera, take the first light source brightness threshold as an interval, and take shots of the target object in order from large to small light source brightness. In other words, the electronic device can take shots of the target object based on the maximum light source brightness of the camera in response to the shooting instruction; after completing one shot, reduce the first light source brightness threshold based on the light source brightness of the last shot; respond to the shooting instruction again, continue to take shots of the target object based on the reduced light source brightness, and return to the operation of reducing the first light source brightness threshold based on the light source brightness of the last shot after completing one shot.
[0099] Step 802: after obtaining a first image each time by shooting, determining the similarity of the first light source illumination between the obtained first image and the reference image.
[0100] It should be noted that the reference image is an image of the target object captured by other devices, and the image quality of the reference image is higher than the image quality of the first image obtained each time when the camera takes multiple shots. In other words, the reference image is a high-quality image captured by other devices (such as the reference device), and the other devices are debugged devices that can capture high-quality images.
[0101] As an example, the electronic device may acquire a reference image before photographing the target object, and the electronic device may acquire the reference image actively or passively.
[0102] Exemplarily, after acquiring the reference image, the other device may actively send the reference image to the electronic device, and the electronic device, upon receiving the reference image, performs the operation of step 801. Alternatively, the electronic device sends an acquisition message to the other device in response to the acquisition instruction; the other device sends the reference image to the electronic device upon receiving the acquisition message; and the electronic device, upon receiving the reference image, performs the operation of step 801.
[0103] In some embodiments, the environment in which the target object is photographed by other devices is the same or similar to the environment in which the electronic device photographs the target object multiple times through the camera, and the position and angle at which the electronic device photographs the target object are the same or similar to the position and angle at which the other devices photograph the target object. In this way, the efficiency and accuracy of adjusting the brightness of the light source of the camera of the electronic device are accelerated.
[0104] In some embodiments, after the electronic device obtains a first image each time it takes pictures, the operation of determining the similarity of the first light source illumination between the obtained first image and the reference image includes: determining the hash similarity and the histogram similarity between the obtained first image and the reference image; and determining the first light source illumination similarity based on the hash similarity and the histogram similarity.
[0105] Since hash similarity and histogram similarity can reflect the similarity of different images in light source illumination, the embodiment of the present application can determine the first light source illumination similarity based on hash similarity and histogram similarity. Of course, the electronic device can also determine the first light source illumination similarity based on hash similarity or histogram similarity alone, or determine the first light source illumination similarity based on other similarities, and the embodiment of the present application does not impose specific restrictions on this.
[0106] It is worth noting that, since hash similarity and histogram similarity can reflect the similarity of images in terms of light source illumination, the accuracy and reliability of the electronic device in determining the similarity of the first light source illumination is improved through hash similarity and histogram similarity.
[0107] It should be noted that the operation of the electronic device determining the hash similarity between the first image and the reference image can refer to the operation of the above step 404, and the operation of the electronic device determining the histogram similarity between the first image and the reference image can refer to the operation of the above step 403, and the embodiments of the present application will not elaborate on this one by one.
[0108] In some embodiments, the operation of the electronic device determining the similarity of the illumination of the first light source based on the hash similarity and the histogram similarity includes: multiplying the first weight by the hash similarity to obtain the first similarity; multiplying the second weight by the histogram similarity to obtain the second similarity; and determining the sum of the first similarity and the second similarity as the similarity of the illumination of the first light source.
[0109] It should be noted that the first weight and the second weight can be set in advance according to needs, and the sum of the first weight and the second weight is 1. For example, the first weight can be 0.5 and the second weight can be 0.5, or the first weight can be 0.6 and the second weight can be 0.4, or the first weight can be 0.4 and the second weight can be 0.6, etc. The embodiments of the present application do not impose specific restrictions on this.
[0110] It is worth noting that the first light source illumination similarity is determined by setting a weight, thereby more accurately expressing the relationship between the hash similarity and the histogram similarity.
[0111] Step 803: when the first light source illumination similarity changes from an upward trend to a downward trend, the target light source brightness is determined based on the light source brightness adjustment interval.
[0112] It should be noted that the target light source brightness maximizes the image quality similarity between the image captured by the camera and the reference image, wherein the light source brightness adjustment interval includes a light source brightness interval indicating that the corresponding light source illumination similarity changes from an upward trend to a downward trend.
[0113] Since when the first light source illumination similarity changes from an upward trend to a downward trend, it indicates that the light source illumination similarity with the closest quality between the first image and the reference image has appeared, and the light source illumination similarity is within the interval corresponding to the change from the upward trend to the downward trend, the electronic device can determine the target light source brightness based on the light source brightness adjustment interval when the first light source illumination similarity changes from an upward trend to a downward trend.
[0114] In some embodiments, when the first light source illumination similarity changes from an upward trend to a downward trend, the light source brightness corresponding to any first light source illumination similarity in a downward trend can be determined as the upper limit value of the light source brightness adjustment interval; the light source brightness corresponding to any first light source illumination similarity in an upward trend can be determined as the lower limit value of the light source brightness adjustment interval; based on the light source brightness adjustment interval, the target light source brightness is determined.
[0115] It is worth noting that by determining the light source brightness adjustment interval, the range for determining the target light source brightness can be narrowed, thereby improving the accuracy of determining the target light source brightness.
[0116] It should be noted that the operation of the electronic device determining the brightness of the target light source based on the light source brightness adjustment interval can refer to the operation of the above step 407. Of course, the operation of the electronic device determining the brightness of the target light source based on the light source brightness adjustment interval can include not only the above operation, but also other operations, such as the following detailed search operation of photographing the target object multiple times to obtain multiple second images.
[0117] See also Figure 7 The operations of step 801 and step 802 correspond to the above Figure 4 In the illustrated embodiment, this operation is called a coarse search, that is, within the light source brightness range supported by the camera, the first light source brightness threshold is used as an interval to roughly search the target light source brightness range. Next, the electronic device can further perform a detailed search.
[0118] In some embodiments, when the similarity of the first light source illumination changes from an upward trend to a downward trend, the electronic device determines the brightness of the target light source based on the light source brightness adjustment interval, including: continuing to shoot the target object multiple times through the camera, the light source brightness of the camera is selected from the light source brightness adjustment interval and is different for each shooting; after a second image is obtained each time, determining the similarity of the second light source illumination between the obtained second image and the reference image; when the similarity of the second light source illumination changes from an upward trend to a downward trend, determining the brightness of the target light source according to the light source brightness of each second image in the multiple second images currently obtained and the similarity of the second light source illumination.
[0119] It should be noted that, when the second light source illumination similarity changes from an upward trend to a downward trend, the operation of determining the target light source brightness according to the light source brightness of each second image in the currently obtained multiple second images and the second light source illumination similarity belongs to Figure 7 The detailed search operation is shown.
[0120] It is worth noting that by continuing to shoot multiple times in the light source brightness adjustment area and according to the similarity of the second light source illumination between the second image and the reference image, the target light source brightness can be determined more accurately.
[0121] It should be noted that the operation of the electronic device determining the similarity of the second light source illumination between the second image and the reference image can refer to the operation of the electronic device determining the similarity of the first light source illumination between the first image and the reference image in the above step 802, and the embodiments of the present application will not elaborate on this one by one.
[0122] In some embodiments, when the similarity of the illumination of the first light source changes from an upward trend to a downward trend, the operation of the electronic device continuing to take multiple shots of the target object through the camera includes: starting from the maximum light source brightness in the light source brightness adjustment interval, taking the second light source brightness threshold as an interval, and taking multiple shots of the target object in order of light source brightness from large to small. That is, in response to the shooting instruction, the electronic device shoots the target object based on the maximum light source brightness in the light source brightness adjustment interval; after completing one shot, the second light source brightness threshold is reduced on the basis of the light source brightness of the last shot, the second light source brightness threshold is less than the first light source brightness threshold, and the first light source brightness threshold is the light source brightness interval between two adjacent first images captured by the camera; in response to the shooting instruction again, the target object is continued to be shot based on the reduced light source brightness, and the operation returns to the operation of reducing the second light source brightness threshold on the basis of the light source brightness of the last shot after completing one shot.
[0123] It should be noted that the second light source brightness threshold can also be pre-set according to demand, and the second light source brightness threshold is set to be smaller than the first light source brightness threshold. For example, when the first light source brightness threshold is 10 candela / square meter or 20 candela / square meter, the second light source brightness threshold can be 5 candela / square meter or 4 candela / square meter.
[0124] It is worth noting that by setting a smaller light source brightness threshold and taking multiple shots at intervals with the smaller light source brightness threshold, the brightness range of the target light source can be determined more accurately later, thereby improving the accuracy of determining the brightness of the target light source.
[0125] In some embodiments, when the coarse search is performed in a manner of increasing the brightness of the light source, the fine search may be performed in a manner of decreasing the brightness of the light source. Fig. 9 When the electronic device performs a coarse search in a manner of increasing the light source brightness with a larger step size (first light source brightness threshold), and determines during the coarse search that the first light source illumination similarity changes from an upward trend to a downward trend, the electronic device can determine that the light source illumination similarity has passed the slope peak position, and record the current light source brightness as X1 (the maximum light source brightness in the light source brightness adjustment interval); thereafter, starting from the X1 position, a fine search is performed in the opposite direction with a smaller step size (second light source brightness threshold).
[0126] In some embodiments, during the rough search process, the electronic device may also perform the search in a decreasing light source brightness manner, and the corresponding fine operation may be performed in an increasing light source brightness manner. Exemplarily, the electronic device starts from the maximum light source brightness of the camera, performs a rough search in a decreasing light source brightness manner, and with a larger step size (first light source brightness threshold), and when it is determined during the rough search process that the first light source illumination similarity changes from an upward trend to a downward trend, the electronic device shoots the target object based on the minimum light source brightness in the light source brightness adjustment interval; after completing one shot, the second light source brightness threshold is increased based on the light source brightness of the last shot; in response to the shooting instruction again, the target object is continued to be shot based on the increased light source brightness, and the operation returns to the operation of increasing the second light source brightness threshold based on the light source brightness of the last shot after completing one shot.
[0127] In some embodiments, when the similarity of the second light source illumination changes from an upward trend to a downward trend, the electronic device determines the target light source brightness based on the light source brightness of each second image in the multiple second images currently obtained and the similarity of the second light source illumination, including: when the similarity of the second light source illumination changes from an upward trend to a downward trend, according to the light source brightness of each second image in the multiple second images and the similarity of the second light source illumination, fitting a light source illumination relationship function, the light source illumination relationship function being used to indicate the correspondence between the light source brightness and the light source similarity, and the light source illumination relationship function being a unimodal function; and determining the peak value of the light source illumination relationship function as the target light source brightness.
[0128] From the above, it can be seen that the correspondence diagram between the light source brightness and the light source similarity is a single-peak image. In this way, the correspondence diagram between the light source brightness of multiple second images and the light source similarity is also a single-peak image. The electronic device can fit the light source illumination relationship function according to the light source brightness of each second image in the multiple second images and the similarity of the second light source illumination, and determine the peak value of the light source illumination relationship function as the target light source brightness.
[0129] It is worth noting that, since the fitted light source illumination relationship function is a unimodal function, and a unimodal function has only one peak, the peak value of the light source illumination relationship function is determined as the target light source brightness, thereby improving the accuracy of determining the target light source brightness.
[0130] In some embodiments, when the second light source illumination similarity changes from an upward trend to a downward trend, the electronic device can not only determine the target light source brightness according to the light source brightness of each second image in the plurality of second images and the second light source illumination similarity in the above manner, but can also determine it in other ways. Exemplarily, when the second light source illumination similarity changes from an upward trend to a downward trend, the electronic device can determine the maximum light source illumination similarity from the second light source illumination similarities corresponding to the plurality of second images; and determine the light source brightness corresponding to the maximum light source illumination similarity as the target light source brightness.
[0131] Since the plurality of second images are determined by the electronic device with a smaller light source illumination threshold, the light source brightness corresponding to the maximum light source illumination similarity is also a relatively accurate light source brightness, and an image with a quality close to the reference image can also be obtained through the light source brightness. Therefore, the light source brightness corresponding to the maximum light source illumination similarity can be determined as the target light source brightness.
[0132] It is worth noting that directly determining the light source brightness corresponding to the maximum light source illumination similarity as the target light source brightness not only improves the accuracy of determining the target light source brightness, but also reduces the determination steps and improves the determination efficiency.
[0133] Step 804: Adjust the brightness of the camera light source to the target light source brightness.
[0134] Since the target light source brightness makes the image quality similarity between the image captured by the camera and the reference image the largest, after adjusting the light source brightness of the camera to the target light source brightness, the camera can capture high-quality images.
[0135] In the embodiment of the present application, the electronic device can determine the light source illumination similarity between the captured image and the reference image, and through the light source illumination similarity, the light source brightness of the camera can be automatically adjusted to the most appropriate light source brightness, that is, the light source brightness of the camera can be adjusted to the light source brightness that can obtain high-quality images, thereby realizing automatic adjustment of the electronic device without the user having to adjust repeatedly, thereby improving the convenience of adjustment. In addition, since the light source brightness of the electronic device camera can be adjusted through the light source illumination similarity, the adjustment of the light source brightness has a data basis, thereby improving the accuracy of the light source brightness adjustment.
[0136] After explaining in detail the method for adjusting the brightness of a light source provided in the embodiment of the present application, the electronic device involved in the embodiment of the present application is explained.
[0137] As an example, the method can be applied to an electronic device equipped with a camera. As an example but not a limitation, the electronic device can be, but is not limited to, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, a vehicle-mounted device, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), a mobile phone, a smart watch, etc., and the embodiments of the present application are not limited to this.
[0138] Fig.10 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.10The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. Among them, the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0139] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0140] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0141] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0142] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0143] In some embodiments, the processor 110 may include one or more interfaces, such as an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0144] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple sets of I2C interfaces. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc. through different I2C interfaces. For example, the processor 110 may be coupled to the touch sensor 180K through the I2C interface, so that the processor 110 communicates with the touch sensor 180K through the I2C interface, thereby realizing the touch function of the electronic device 100.
[0145] The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to implement the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate via the DSI interface to implement the display function of the electronic device 100.
[0146] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 with the camera 193, the display 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.
[0147] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0148] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0149] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0150] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0151] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light emitting diode or an active-matrix organic light emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is an integer greater than 1.
[0152] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0153] ISP is used to process the data fed back by camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 193.
[0154] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is an integer greater than 1.
[0155] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.
[0156] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.
[0157] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created by the electronic device 100 during use (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0158] The electronic device 100 can implement audio functions, such as music playback, recording, etc., through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone interface 170D and the application processor.
[0159] The gyro sensor 180B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyro sensor 180B. The gyro sensor 180B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyro sensor 180B detects the angle of the electronic device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse movement to achieve anti-shake. The gyro sensor 180B can also be used for navigation and somatosensory game scenes.
[0160] The distance sensor 180F is used to measure the distance. The electronic device 100 can measure the distance by infrared or laser. In some embodiments, in a shooting scene, the electronic device 100 can use the distance sensor 180F to measure the distance to achieve fast focusing.
[0161] The ambient light sensor 180L is used to sense the ambient light brightness. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in a pocket to prevent accidental touches.
[0162] Next, the software system of the electronic device 100 will be described.
[0163] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software system of the electronic device 100.
[0164] Fig.11 1 is a block diagram of a software system of an electronic device 100 provided in an embodiment of the present application. Fig.11 The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime (Android runtime) and the system layer, and the kernel layer.
[0165] The application layer can include a series of application packages. Fig.11 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, etc.
[0166] The application framework layer provides an application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions. Figure 2As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, etc. The window manager is used to manage window programs. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc. The content provider is used to store and obtain data and make these data accessible to applications. These data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc. The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build the display interface of the application, and the display interface can be composed of one or more views, for example, including a view for displaying a text message notification icon, including a view for displaying text, and including a view for displaying pictures. The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including connecting, hanging up, etc.). The resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, etc. The notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of an icon or scroll bar text, such as a notification of an application running in the background. The notification manager can also be a notification that appears on the screen in the form of a dialog window, such as a text message in the status bar, a reminder sound, an electronic device vibrating, an indicator light flashing, etc.
[0167] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system. The core library consists of two parts: one is the function that the Java language needs to call, and the other is the Android core library. The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0168] The system library can include multiple functional modules, such as: surface manager, media library, 3D graphics processing library (such as: OpenGL ES), 2D graphics engine (such as: SGL), etc. The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications. The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc. The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing, etc. The 2D graphics engine is a drawing engine for 2D drawing.
[0169] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
[0170] The following is an illustrative description of the workflow of the software and hardware of the electronic device 100 in conjunction with capturing a photo scene.
[0171] When the touch sensor 180K receives a touch operation, the corresponding hardware interrupt is sent to the kernel layer. The kernel layer processes the touch operation into a raw input event (including touch coordinates, timestamp of the touch operation, and other information). The raw input event is stored in the kernel layer. The application framework layer obtains the raw input event from the kernel layer and identifies the control corresponding to the raw input event. For example, if the touch operation is a single-click operation and the control corresponding to the single-click operation is the control of the camera application icon, the camera application calls the interface of the application framework layer, starts the camera application, and then calls the kernel layer to start the camera driver to capture static images or videos through the camera 193.
[0172] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (such as: coaxial cable, optical fiber, data subscriber line (Digital Subscriber Line, DSL)) or wireless (such as: infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access, or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a digital versatile disc (DVD)), or a semiconductor medium (such as a solid state disk (SSD)).
[0173] The above are optional embodiments provided for the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the technical scope disclosed in the present application shall be included in the protection scope of the present application.
Claims
1. A method for adjusting the brightness of a light source, characterized in that: Applied in an electronic device, the method comprises: The target object is photographed multiple times by the camera of the electronic device, and the brightness of the light source of the camera is different during each photographing; After obtaining a first image each time by shooting, determining the similarity of the first light source illumination between the obtained first image and a reference image, wherein the reference image is an image of the target object captured by other devices, and the image quality of the reference image is higher than the image quality of the first image obtained each time by the camera when performing the multiple shootings; In the case where the similarity of the illumination of the first light source changes from an upward trend to a downward trend, determining the brightness of the target light source based on the light source brightness adjustment interval, the target light source brightness maximizes the image quality similarity between the image captured by the camera and the reference image, wherein the light source brightness adjustment interval includes a light source brightness interval indicating that the corresponding light source illumination similarity changes from an upward trend to a downward trend; The brightness of the light source of the camera is adjusted to the brightness of the target light source.
2. The method according to claim 1, characterized in that The method of photographing the target object multiple times by using the camera of the electronic device includes: In response to a shooting instruction, shooting the target object based on the minimum light source brightness of the camera; After completing one shot, the brightness threshold of the first light source is increased based on the brightness of the light source in the previous shot; In response to the shooting instruction again, the target object is continuously shot based on the increased light source brightness, and the process returns to the operation of increasing the first light source brightness threshold based on the light source brightness of the previous shooting after completing one shooting.
3. The method according to claim 1 or 2, characterized in that The step of determining the target light source brightness based on the light source brightness adjustment interval when the first light source illumination similarity changes from an upward trend to a downward trend includes: When the similarity of the illumination of the first light source changes from an upward trend to a downward trend, the target object is continuously photographed multiple times by the camera, and the brightness of the light source of the camera is selected from the light source brightness adjustment interval and is different from each other during each photographing; After obtaining a second image each time by shooting, determining the similarity of the second light source illumination between the obtained second image and the reference image; When the second light source illumination similarity changes from an upward trend to a downward trend, the target light source brightness is determined according to the light source brightness of each second image in the currently obtained plurality of second images and the second light source illumination similarity.
4. The method according to claim 3, characterized in that When the similarity of the illumination of the first light source changes from an upward trend to a downward trend, continuing to shoot the target object multiple times by the camera includes: In response to a shooting instruction, shooting the target object based on the maximum light source brightness in the light source brightness adjustment interval; After completing one shot, reducing the second light source brightness threshold based on the light source brightness of the last shot, the second light source brightness threshold being less than the first light source brightness threshold, the first light source brightness threshold being the light source brightness interval between two adjacent first images captured by the camera; In response to the shooting instruction again, the target object is continued to be shot based on the reduced light source brightness, and the process returns to the operation of reducing the second light source brightness threshold based on the light source brightness of the previous shooting after completing one shooting.
5. The method according to claim 3 or 4, characterized in that In the case where the second light source illumination similarity changes from an upward trend to a downward trend, determining the target light source brightness according to the light source brightness of each second image in the plurality of second images currently obtained and the second light source illumination similarity, comprises: When the second light source illumination similarity changes from an upward trend to a downward trend, a light source illumination relationship function is fitted according to the light source brightness of each second image in the plurality of second images and the second light source illumination similarity, wherein the light source illumination relationship function is used to indicate the corresponding relationship between the light source brightness and the light source similarity, and the light source illumination relationship function is a unimodal function; The peak value of the light source illumination relationship function is determined as the target light source brightness.
6. The method according to claim 3 or 4, characterized in that In the case where the second light source illumination similarity changes from an upward trend to a downward trend, determining that the target light source is bright according to the light source brightness of each second image in the plurality of second images currently obtained and the second light source illumination similarity, comprises: When the second light source illumination similarity changes from an upward trend to a downward trend, determining a maximum light source illumination similarity from the second light source illumination similarities corresponding to the plurality of second images; The light source brightness corresponding to the maximum light source illumination similarity is determined as the target light source brightness.
7. The method according to any one of claims 1 to 6, characterized in that After obtaining a first image each time by shooting, determining the similarity of the first light source illumination between the obtained first image and the reference image includes: Determining a hash similarity and a histogram similarity between the obtained first image and the reference image; The first light source illumination similarity is determined according to the hash similarity and the histogram similarity.
8. The method according to claim 7, characterized in that The determining the first light source illumination similarity according to the hash similarity and the histogram similarity includes: Multiplying the first weight by the hash similarity to obtain a first similarity; Multiplying the second weight by the histogram similarity to obtain a second similarity; The sum of the first similarity and the second similarity is determined as the first light source illumination similarity.
9. The method according to any one of claims 1 to 8, characterized in that The step of determining the target light source brightness based on the light source brightness adjustment interval when the first light source illumination similarity changes from an upward trend to a downward trend includes: When the first light source illumination similarity changes from an upward trend to a downward trend, the light source brightness corresponding to any first light source illumination similarity in a downward trend is determined as the upper limit value of the light source brightness adjustment interval; Determine the light source brightness corresponding to any first light source illumination similarity in an upward trend as the lower limit value of the light source brightness adjustment interval; The target light source brightness is determined based on the light source brightness adjustment interval.
10. An electronic device, characterized in that: The structure of the electronic device includes a processor and a memory; The memory is used to store a program that supports the electronic device to execute the method according to any one of claims 1 to 9.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method according to any one of claims 1 to 9.