A method for detecting lens dirtiness, a terminal and a computer-readable storage medium

Through the detection method of the lens dirty detection on the smart terminal, image processing technology is used to automatically identify whether the lens is dirty and prompt the user to clean it up, which solves the problem of image quality decline caused by the dirty lens of the smart terminal and improves the user's photography experience.

CN110738629BActive Publication Date: 2024-12-17ZTE CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201810710488.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-07-02
Publication Date
2024-12-17
Estimated Expiration
2039-02-12

AI Technical Summary

Technical Problem

Smart terminal lenses are prone to fingerprints, oil or dust, resulting in unclear pictures and poor contrast, making it difficult for users to know and clean them in time, affecting the photography experience.

Method used

Provide a method for detecting dirty lenses. By obtaining the preview image collected by the camera, calculating its staining degree parameters, automatically identifying whether the lens is dirty, and outputting prompt information for cleaning the lens to avoid image quality degradation.

Benefits of technology

Real-time and automatic identification of lens dirty, reminding users to clean up, thereby improving imaging quality and avoiding unclear images and poor contrast problems caused by lens dirty.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110738629B_ABST
    Figure CN110738629B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention discloses a method for detecting lens dirtiness, a terminal and a computer-readable storage medium, wherein the method comprises: obtaining an image to be detected, wherein the image to be detected is a preview image captured by the camera; obtaining a first contamination degree parameter of the image to be detected and a second contamination degree parameter of an image in a detection result set; if it is determined that the lens of the camera is dirty based on the first contamination degree parameter and the second contamination degree parameter, outputting a prompt message for cleaning the lens.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method for detecting lens dirtiness, a terminal and a computer-readable storage medium. Background Art

[0002] With the development of mobile communication technology, especially the promotion and application of mobile networks and smart terminals, the field of mobile Internet has developed rapidly. At present, the function of smart terminals is no longer simply to meet people's mutual connection, but has become a very important mobile personal entertainment terminal in people's daily life.

[0003] Nowadays, the camera function has become an indispensable function of smart terminals, and people can record wonderful moments anytime and anywhere. At present, the lenses on smart terminals are usually exposed, instead of having lens covers to protect the lenses like professional photographic equipment, so fingerprints, oil stains or dust will inevitably stick to them during daily use. Since the physical focal length of the lens is generally very small, this means that the dirt on the lens protection glass is within the imaging distance range, which will cause problems such as unclear pictures and poor contrast, thus affecting the imaging effect. Users may not be able to know the reasons for the poor imaging effect in time, and instead of cleaning it in time, resulting in a poor user experience in taking photos. Summary of the invention

[0004] In order to solve the existing technical problems, the embodiments of the present invention provide a lens dirt detection method, terminal and computer-readable storage medium, which solves the problem in the prior art that users cannot promptly know whether the lens is dirty, resulting in a poor user photo-taking experience. The method can automatically identify whether the lens is dirty and prompt the user to clean it, thereby avoiding problems such as unclear images and poor contrast caused by dirty lenses, thereby improving imaging quality.

[0005] The technical solution of the embodiment of the present invention is achieved as follows:

[0006] In a first aspect, an embodiment of the present invention provides a method for detecting lens dirtiness, which is applied to a terminal, wherein the terminal at least includes a camera, and the method includes:

[0007] Acquire an image to be detected, wherein the image to be detected is a preview image captured by the camera;

[0008] Acquire a first contamination degree parameter of the image to be detected and a second contamination degree parameter of the image in the detection result set;

[0009] If it is determined that the lens of the camera is dirty according to the first contamination degree parameter and the second contamination degree parameter, a prompt message for cleaning the lens is output.

[0010] In a second aspect, an embodiment of the present invention provides a terminal, the terminal comprising at least a camera, a memory, a communication bus, and a processor, wherein:

[0011] The camera is configured to capture images;

[0012] The memory is configured to store a lens dirt detection program;

[0013] The communication bus is configured to realize connection and communication between the processor and the memory;

[0014] The processor is configured to execute a lens dirt detection program stored in the memory to implement the steps in the lens dirt detection method provided in other embodiments of the present invention.

[0015] In a third aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer storage medium stores computer-executable instructions, and the computer-executable instructions are configured to execute the steps in the lens dirt detection method provided in other embodiments of the present invention.

[0016] An embodiment of the present invention provides a method, terminal and computer-readable storage medium for detecting lens dirtiness, wherein first, an image to be detected is obtained, wherein the image to be detected is a preview image captured by the camera; then, a first contamination degree parameter of the image to be detected and a second contamination degree parameter of an image in a detection result set are obtained; if it is determined that the lens of the camera is dirty based on the first contamination degree parameter and the second contamination degree parameter, a prompt message for cleaning the lens is output; in this way, it is possible to automatically identify in real time whether the lens is dirty, and prompt the user to clean it, thereby avoiding problems such as unclear images and poor contrast caused by dirty lenses, thereby improving imaging quality. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In the accompanying drawings (which are not necessarily drawn to scale), like reference numerals may describe similar components in different views. Like reference numerals with different letter suffixes may represent different examples of similar components. The accompanying drawings generally illustrate various embodiments discussed herein by way of example and not limitation.

[0018] Figure 1 The figure is a schematic diagram of the implementation process of the method for detecting lens dirtiness according to an embodiment of the present invention;

[0019] Figure 2 The figure is a schematic diagram of the implementation process of the method for detecting lens dirtiness according to an embodiment of the present invention;

[0020] Figure 3 The figure is a schematic diagram of the implementation process of the method for detecting lens dirtiness according to an embodiment of the present invention;

[0021] Figure 4 This is a schematic diagram of the implementation process of detecting a single preview image according to an embodiment of the present invention;

[0022] Figure 5 A schematic diagram of an implementation flow of determining contrast_radio in an embodiment of the present invention;

[0023] Figure 6 The figure is a schematic diagram of the structure of a terminal according to an embodiment of the present invention. DETAILED DESCRIPTION

[0024] To make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the specific technical solution of the invention will be further described in detail below in conjunction with the drawings in the embodiments of the present invention. The following embodiments are used to illustrate the present invention, but are not intended to limit the scope of the present invention.

[0025] Embodiment 1

[0026] The embodiment of the present invention provides a method for detecting lens dirtiness. Figure 1 FIG. 1 is a schematic diagram of an implementation flow of a method for detecting lens dirtiness according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:

[0027] Step S101, obtaining an image to be detected.

[0028] Here, the step S101 can be implemented by a terminal, and further, it can be a mobile terminal, such as a mobile phone (cell phone), iPad, notebook, wearable smart watch, or other mobile terminal with wireless communication capability. The mobile terminal includes at least a camera and a display screen. The camera can be on the same surface as the plane where the display screen of the terminal is located, or it can be located on the opposite surface of the plane where the display screen of the terminal is located. The lens of the camera is small and is generally exposed to the outside.

[0029] The image to be detected is a preview image captured by the camera, so the dirtiness of the lens can be detected in real time when the user takes a photo, thereby avoiding the problem of poor image quality caused by lens dirtiness.

[0030] In other embodiments, feature information of the image to be detected may also be obtained, wherein the feature information of the image to be detected may be grayscale information, brightness information, etc. of the image. According to the feature information, it may be determined whether the image to be detected is similar to other images.

[0031] Step S102, obtaining a first contamination degree parameter of the image to be detected and a second contamination degree parameter of the image in the detection result set.

[0032] Here, step S102 may be implemented by a terminal.

[0033] In the implementation process, obtaining the first contamination degree parameter of the image to be detected can be to perform contamination detection on the image to be detected to obtain the first contamination degree parameter and the first detection result to determine whether the image to be detected is a contaminated image. In the implementation process, the pixel matrix corresponding to the preview image can be firstly subjected to singular value decomposition, and the sum of singular values ​​can be calculated to find the number of singular values ​​greater than a certain threshold of the sum of singular values. If the number of singular values ​​is large, it is considered that the preview image contains more information, otherwise it is an image with less information. Then, the histogram of the preview image is analyzed to determine the histogram average value of the darker part of the histogram and the histogram average value of the brighter part, and calculate the ratio of the two, wherein the ratio of the two is the first contamination degree parameter.

[0034] In other embodiments, the terminal determines the first detection result according to the first contamination degree parameter and the number of singular values, and adds the first contamination degree parameter and the first detection result to the detection result set.

[0035] Step S103: If it is determined that the lens of the camera is dirty according to the first contamination degree parameter and the second contamination degree parameter, a prompt message for cleaning the lens is output.

[0036] Here, step 103 may be implemented by a terminal.

[0037] In the process of implementing the step S103, determining whether the lens of the camera is dirty according to the first contamination degree parameter and the second contamination degree parameter can be implemented in at least the following two ways:

[0038] The first method: determine the number of contaminated images in the detection result set according to the second contamination degree parameter of the images in the detection result set; if the first detection result indicates that the image to be detected is a contaminated image and the number of contaminated images in the detection result set is greater than a first threshold, determine that the lens of the camera is dirty.

[0039] The second method: first determine a first weight for the image to be detected, then select P historical images from the detection result set, and obtain the second contamination degree parameters of the P historical images, and then determine the second weights of the P historical images according to the first weight and the storage time of the P historical images, and perform weighted averaging on the contamination degree parameters and weights of the image to be detected and the P historical images to obtain a fifth value. If the fifth value is greater than the preset fourth threshold, it is determined that the lens of the camera is dirty.

[0040] When it is determined that the lens of the camera is dirty, a prompt message for cleaning the lens can be output. Of course, there can be many ways to output the prompt message. For example, a prompt message similar to "The camera lens seems to be dirty, please clean it in time" can be output on the display interface of the terminal. Voice prompt information can also be output, or illustrated prompt information can be output, etc.

[0041] In a method for detecting lens dirtiness provided in an embodiment of the present invention, first, an image to be detected is obtained, wherein the image to be detected is a preview image captured by the camera; then, a first contamination degree parameter of the image to be detected and a second contamination degree parameter of an image in a detection result set are obtained; if it is determined that the lens of the camera is dirty based on the first contamination degree parameter and the second contamination degree parameter, a prompt message for cleaning the lens is output; in this way, it is possible to automatically identify whether the lens is dirty, and prompt the user to clean it, thereby avoiding problems such as unclear images and poor contrast caused by dirty lenses, thereby improving imaging quality.

[0042] In other embodiments, the determining whether the lens of the camera is dirty according to the first contamination degree parameter and the second contamination degree parameter, when implemented in the second manner, can be implemented by the following steps:

[0043] Step 41: Obtain a first weight corresponding to the first contamination degree parameter.

[0044] Here, the first weight may be preset.

[0045] Step 42: Determine P second contamination degree parameters of P historical images and second weights corresponding to the P second contamination degree parameters according to the storage time of the images in the detection result set and the first weight.

[0046] Here, P is an integer greater than 2, for example, P may be 5. In the implementation process of step 42, the images in the detection result set may be sorted according to the storage time of the images in the detection result set, for example, they may be sorted in ascending order according to the interval between the current moment and the storage time, and then the second contamination degree parameters of the first P images are taken, and the second weights corresponding to the P second contamination degree parameters are determined according to the storage time of the P images and the first weights. In the implementation, the second contamination degree parameters of the historical images closer to the current moment have the larger second weights corresponding to them, but the second weights are smaller than the first weights.

[0047] In other embodiments, the first weight and the second weight can be preset. For example, if P is 5, the first weight is preset to 10, and the P second weights are preset to 9, 8, 7, 6, and 5. The detection result set can be realized by using a queue. The P historical images can obtain the second contamination degree parameters of the P historical images from the end of the queue. When P is 5, the second weight corresponding to the second contamination degree parameter of the first historical image at the end of the queue is 9, the second weight corresponding to the second contamination degree parameter of the second historical image at the end of the queue is 8, the second weight corresponding to the second contamination degree parameter of the third historical image at the end of the queue is 7, the second weight corresponding to the second contamination degree parameter of the fourth historical image at the end of the queue is 6, and the second weight corresponding to the second contamination degree parameter of the fifth historical image at the end of the queue is 5.

[0048] Step 43: determining a fifth value according to the first contamination degree parameter, the first weight, P second contamination degree parameters, and the second weights corresponding to the P second contamination degree parameters.

[0049] Step 44: If the fifth value is greater than a preset fourth threshold, it is determined that the lens of the camera is dirty.

[0050] In practical applications, step 43 can be implemented by the following steps:

[0051] Step 431, performing weighted summation on the first contamination degree parameter and the first weight, the P second contamination degree parameters and the second weights corresponding to the P second contamination degree parameters to obtain a sixth value;

[0052] Step 432, summing the first weight and the second weights corresponding to the P second contamination degree parameters to obtain a seventh value;

[0053] Step 433: determine the ratio of the sixth value to the seventh value as the fifth value.

[0054] Embodiment 2

[0055] Based on the above embodiments, the present invention further provides a method for detecting lens dirtiness. Figure 2 FIG. 1 is a schematic diagram of an implementation flow of a method for detecting lens dirtiness according to an embodiment of the present invention. Figure 2 As shown, the method comprises the following steps:

[0056] Step S201, obtaining an operation instruction from a user to start a camera application.

[0057] Here, the step S201 can be implemented by the terminal. In this embodiment, the user can start the camera application in a variety of ways, for example: the camera application can be started by clicking the camera application icon of the terminal, or by pressing the touch operation area on the side of the terminal, that is, the terminal obtains the user's operation instruction to start the camera application, including: obtaining the touch operation received by the preset touch operation area on the side of the terminal, and determining the control instruction corresponding to the touch operation; when the control instruction is to start the camera application, start the camera application. In addition, the camera application can also be started by voice and gestures. The triggering methods for starting the camera application listed above are only exemplary. Other triggering methods for starting the camera application proposed by those skilled in the art using the technical ideas of the present invention and according to their specific needs are all within the protection scope of the present invention, and are not listed one by one here.

[0058] Step S202: start the camera based on the operation instruction to obtain a preview image.

[0059] Here, the camera may be a front camera or a rear camera. For example, each time the camera application is started, the rear camera may be started by default. Alternatively, the camera used when the camera application was last closed may be started.

[0060] After the terminal starts the camera, it enters the shooting preview interface of the terminal to obtain a preview image. It should be noted that the preview image in the embodiment of the present invention is the image to be detected in other embodiments.

[0061] In the terminal, the camera may be a standard camera, a wide-angle camera, a telephoto camera, a black-and-white camera, etc.

[0062] In other embodiments of the present invention, when the terminal includes multiple cameras, such as two front cameras and two rear cameras, the types of the two front cameras may be the same or different. For example, both front cameras are standard cameras, or one front camera is a standard camera and the other front camera is a black and white camera. Similarly, the types of the two rear cameras may be the same or different. For example, both rear cameras are standard cameras, or one rear camera is a wide-angle camera and the other rear camera is a telephoto camera.

[0063] Step S203: down-sample the pixel matrix of the preview image to obtain a first matrix.

[0064] Here, step S203 may be implemented by the terminal.

[0065] Assuming that the size of the pixel matrix is ​​M*N, downsampling is performed s times, that is, the first matrix of size (M / s)*(N / s) is obtained, of course, s should be a common divisor of M and N. Downsampling the pixel matrix s times means converting the image in the s*s window of the pixel matrix into a pixel, and the value of this pixel is the mean of all pixels in the window.

[0066] Step S204: performing singular value decomposition on the first matrix to obtain the first number of singular values ​​that meet a first preset condition.

[0067] Here, the step S204 may be implemented by the terminal. The first preset condition may be satisfied by being greater than a preset percentage of the sum of all singular values.

[0068] Step S205, obtaining a dark channel image of the image to be detected and a histogram of the dark channel image.

[0069] Here, the step S205 may be implemented by the terminal. In practical applications, the step S205 may be implemented by the following steps:

[0070] Step S2051, obtaining the minimum value of the red, green and blue (RGB) components of each pixel in the image to be detected;

[0071] Step S2052, generating the dark channel image according to the minimum value corresponding to each pixel, wherein the dark channel image is a grayscale image of the same size as the image to be detected;

[0072] Step S2053: Based on the dark channel image, a histogram of the dark channel image is obtained.

[0073] Here, the histogram of the dark channel image can be generated by calling a preset histogram generation function. The horizontal coordinate of the histogram is pixel value 0 to pixel value 255, and the vertical coordinate of the histogram is the number corresponding to each pixel value.

[0074] Step S206: determining a ratio of the first value to the second value according to the histogram.

[0075] Here, step S206 may be implemented by the terminal.

[0076] The first value is determined based on each pixel value in the histogram, the number corresponding to each pixel value and a preset dark area percentage; the second value is determined based on each pixel value in the histogram, the number corresponding to each pixel value and a preset bright area percentage.

[0077] Step S207: determining the ratio as a first contamination degree parameter.

[0078] Step S208: determining a first detection result of the preview image according to the first number and the first contamination degree parameter.

[0079] Here, step S208 may be implemented by the terminal.

[0080] If the first number is greater than the second threshold, and the first contamination degree parameter is greater than the third threshold, a first detection result is obtained that the preview image is a contaminated image; if the first number is not greater than the second threshold, or the first contamination degree parameter is not greater than the third threshold, a first detection result is obtained that the preview image is a non-contaminated image.

[0081] Step S209: determining whether the first detection result indicates that the preview image is a contaminated image.

[0082] Here, the step S209 may be implemented by the terminal. If the first detection result indicates that the preview image is a contaminated image, the process proceeds to step S210; if the first detection result indicates that the preview image is a non-contaminated image, the process proceeds to step S213.

[0083] Step S210, determining the number of contaminated images in the detection result set.

[0084] Step S211, determining whether the number of contaminated images in the detection result set is greater than a first threshold.

[0085] Here, the step S211 may be implemented by a terminal. Here, if the preview image is a dirty image, and the number of dirty images in the detection result set is greater than a first threshold, it indicates that the lens of the camera is dirty, and the process proceeds to step S212. If the number of dirty images in the detection result set is not greater than the first threshold, the process proceeds to step S213.

[0086] Step S212, determining that the lens of the camera is dirty, and outputting a prompt message for cleaning the lens.

[0087] Here, step S212 may be implemented by the terminal.

[0088] Step S213, determine that the lens of the camera is not dirty, and end the process.

[0089] Here, step S213 may be implemented by the terminal.

[0090] It should be noted that the explanations of the same steps or concepts in this embodiment as those in other embodiments may refer to the descriptions in other embodiments.

[0091] In the lens dirt detection method provided in an embodiment of the present invention, firstly, an operation instruction of a user to start a camera application is obtained, and based on the operation instruction, the camera application is started and a preview image is obtained; then, the pixel matrix of the image to be detected is downsampled to obtain a first matrix; then, singular value decomposition is performed on the first matrix to obtain a first number of singular values ​​that meets a first preset condition; then, a dark channel image of the image to be detected and a histogram of the dark channel image are obtained, and a ratio of a first value to a second value is determined according to the histogram; then, a first detection result of the image to be detected is determined according to the first number and the ratio; if the first detection result indicates that the image to be detected is a contaminated image and the number of contaminated images in the detection result set is greater than a first threshold, it is determined that the lens of the camera is dirty, and a prompt message for cleaning the lens is output, otherwise it is determined that the lens of the camera is not dirty; in this way, it is possible to automatically identify whether the lens is dirty, thereby notifying the user in time to clean it, avoiding imaging problems such as unclear images and poor contrast caused by dirty lenses, thereby improving imaging quality.

[0092] In other embodiments, after step S208, the method further includes:

[0093] Step 31, obtaining feature information of the preview image.

[0094] Here, the feature information may be a fingerprint string generated according to the preview image, and then the fingerprint strings of different images may be compared. The smaller the difference in the fingerprint strings, the more similar the images are.

[0095] Step 32, determining whether the feature information exists in the detection result set.

[0096] Here, if the characteristic information is a fingerprint string of an image, to determine whether the characteristic information exists in the detection result set, the fingerprint string can be compared with the fingerprint string in the detection result set. If the fingerprint string in the detection result set does not have a fingerprint string that is different from the fingerprint string of the preview image by the number of bits less than a fifth threshold, it means that there is no fingerprint string in the detection result set that is identical to the fingerprint string of the preview image, which means that the characteristic information does not exist in the detection result set, and the process goes to step 33. If the fingerprint string in the detection result set has a fingerprint string that is different from the fingerprint string of the preview image by the number of bits less than the fifth threshold, it means that there is a fingerprint string in the detection result set that is identical to the fingerprint string of the preview image, which means that the characteristic information exists in the detection result set, and the process goes to step 34.

[0097] Step 33: adding the characteristic information, the first detection result and the first contamination degree parameter to the detection result set.

[0098] Step 34: determine whether the second detection result corresponding to the feature information in the detection result set is the same as the first detection result.

[0099] Here, if the second detection result is the same as the first detection result, no operation is performed and the process proceeds to step S209; if the second detection result is different from the first detection result, the process proceeds to step 35.

[0100] Step 35: Update the second detection result to the first detection result.

[0101] In other embodiments, step 31 may be implemented by the following steps:

[0102] Step 311, down-sampling the pixel matrix of the preview image to obtain a second matrix.

[0103] Here, the principle of downsampling in step S312 is the same as that in step S203, but the downsampling multiple in step 311 is larger than that in step S203. In this step, the preview image can be reduced to a size of 8*8, that is, the size of the second matrix is ​​8*8, with a total of 64 pixels. The purpose of this step is to remove the details of the image and only retain basic information such as structure, brightness, etc., thereby eliminating the differences caused by different sizes and proportions.

[0104] Step S312, converting the pixels in the second matrix into 64 levels of grayscale.

[0105] That is to say, there are only 64 colors in total for all pixels, which can simplify the colors.

[0106] Step 313, calculating the grayscale average value of all 64 pixels.

[0107] Step 314, compare the grayscale of each pixel with the grayscale average value, if it is greater than or equal to the average value, it is recorded as 1; if it is less than the average value, it is recorded as 0.

[0108] Step 315, calculate the hash value to obtain feature information of the preview image.

[0109] Here, the comparison results obtained in step 314 are combined to form a 64-bit integer, which is the fingerprint string of the preview image, that is, the feature information. The order of combination is not important, as long as all pictures are in the same order.

[0110] After getting the fingerprint string, you can compare different images to see how many of the 64 bits are different. In theory, this is equivalent to calculating the "Hamming distance". If the number of different data bits does not exceed 5, it means that the two images are very similar; if it is greater than 10, it means that these are two different images.

[0111] In other embodiments, step S204 may be implemented by the following steps:

[0112] Step S2041: performing singular value decomposition on the first matrix to obtain singular values ​​of the first matrix.

[0113] Step S2042: sum the singular values ​​to obtain a third value.

[0114] Here, the third value is the sum of all singular values.

[0115] Step S2043: Determine a fourth value according to the third value and a preset percentage.

[0116] Here, the fourth value is the product of the third value and the percentage. Assuming that the third value is 100 and the percentage is 15%, the fourth value is 15.

[0117] Step S2044: determine the number of the singular values ​​that are greater than the fourth value as the first number.

[0118] In other embodiments, step S206 may be implemented by the following steps:

[0119] Step S2061, obtaining the total number of pixels of the dark channel image according to the histogram.

[0120] Step S2062, determining a second number according to the total number of pixels and the percentage of the dark area, and determining a third number according to the total number of pixels and the percentage of the bright area.

[0121] Here, the second number is the product of the total number of pixels and the percentage of the dark area, and the third number is the product of the total number of pixels and the percentage of the bright area.

[0122] Step S2063, determining a first value according to the second number, each pixel value in the histogram, and the number corresponding to each pixel value.

[0123] Step S2064, determining a second value according to the third number, each pixel value in the histogram, and the number corresponding to each pixel value.

[0124] Step S2065, determining the ratio of the first value to the second value.

[0125] In actual application, step S2063 can be implemented by the following steps:

[0126] Step 11, determining the pixel value N according to the second number and the histogram.

[0127] Here, (d0+d1+…+d N ) is less than or equal to the second number, and (d0+d1+…+d N+1 ) is greater than the second number, N is an integer greater than or equal to 0 and less than 256, d i is the number corresponding to pixel value i, i=0, 1,…,N.

[0128] Assuming that the total number of pixels is 1024 and the percentage of dark area is 15%, the second number is 153.6, the number corresponding to pixel value 0 is 0, the number corresponding to pixel value 1 is 0, the number corresponding to pixel value 2 is 0, the number corresponding to pixel value 3 is 10, the number corresponding to pixel value 4 is 53, the number corresponding to pixel value 5 is 30, the number corresponding to pixel value 6 is 15, the number corresponding to pixel value 7 is 10, the number corresponding to pixel value 8 is 15, the number corresponding to pixel value 9 is 12, the number corresponding to pixel value 10 is 5, and the number corresponding to pixel value 11 is 30. At this time, the pixel value N is determined to be 10 according to the second number and the histogram.

[0129] Step 12: 0*d0+1*d1+…_+N*d N Determined as the first weighted value.

[0130] Here, the first weighted value is 3*10+4*53+5*30+6*15+7*10+8*15+9*12+10*5=883.

[0131] Step 13: If the fourth number is equal to the second number, determine the first weighted value as the first numerical value.

[0132] Here, the fourth number is (d0+d1+…+d N ), continuing with the above example, the fourth number is 150. Since the fourth number is smaller than the second number, the first value needs to be calculated according to steps 14 and 15.

[0133] Step 14: If the fourth number is smaller than the second number, the product of the difference between the second number and the fourth number and the pixel value (N+1) is determined as the second weighted value.

[0134] Here, the fourth number is 150 and the second number is 153.6, so the second weighted value is (153.6-150)*11=39.6.

[0135] Step 15: Determine the sum of the first weighted value and the second weighted value as a first value.

[0136] Here, the first value is 883+39.6=922.6.

[0137] In actual application, step S2064 can be implemented by the following steps:

[0138] Step 21, determining the pixel value M according to the third number and the histogram.

[0139] Here, (d 255 +d 254 +…_+d M ) is less than or equal to the third number, and (d 255 +d 254 +…+d M-1 ) is greater than the third number, M is an integer greater than or equal to 0 and less than 256, d j is the number corresponding to the pixel value j, j=M, M+1,…,255.

[0140] Assuming that the percentage of bright area is 5%, the third number is 51.2, the number corresponding to the pixel value 255 is 0, the number corresponding to the pixel value 254 is 0, the number corresponding to the pixel value 253 is 0, the number corresponding to the pixel value 252 is 5, the number corresponding to the pixel value 251 is 10, the number corresponding to the pixel value 250 is 20, the number corresponding to the pixel value 249 is 5, and the number corresponding to the pixel value 248 is 20. Therefore, according to the third number and the histogram, the pixel value M is determined to be 249.

[0141] Step 22, convert 255*d 255 +254*d 254 +…_+M*d M Determined as the third weighted value.

[0142] Here, the third weighted value is 252*5+251*10+250*20+249*5=10015.

[0143] Step 23: If the fifth number is equal to the third number, determine the third weighted value as the second value.

[0144] Here, the fifth number is (d 255 +d 254 +…_+d M)=40. Since the fifth number is smaller than the third number, the second value needs to be determined according to steps 24 and 25.

[0145] Step 24, if the fifth number is smaller than the third number, the product of the difference between the third number and the fifth number and the pixel value (M-1) is determined as the fourth weighted value;

[0146] Here, the fourth weighted value is (51.2-40)*248=2777.6.

[0147] Step 25: Determine the sum of the third weighted value and the fourth weighted value as a second value.

[0148] Here, the second numerical value is 10015+2777.6=12792.6.

[0149] It should be noted that the steps S203 to S211 may also be implemented by a server. In this case, before the step S203, the method further includes: the terminal sending the preview image to the server; after the step S211, the method further includes: the server sending a first notification message indicating that the lens is dirty to the terminal.

[0150] Embodiment 3

[0151] If a user accidentally touches the phone lens with his finger or the lens is worn out after being used for a long time, considering that the physical focal length of the phone lens is very small, this means that the dirt on the lens protection glass is already within the imaging distance range, which will affect the imaging effect, causing unclear images, poor contrast and other problems, reducing the user's photo-taking experience.

[0152] As for the problems of unclear images and poor contrast, image defogging can be used in related technologies to solve them. Image defogging has always been an important field in image processing technology. The dark channel defogging algorithm can solve the problem of low contrast in foggy images. In addition, there are algorithms such as histogram equalization and CLAHE to improve image contrast. Such algorithms do not solve a problem, that is, how to better identify low-contrast images to avoid over-processing of normal images. The lens dirt detection method provided by the embodiment of the present invention can effectively solve this problem.

[0153] Figure 3 FIG. 1 is a schematic diagram of an implementation flow of a method for detecting lens dirtiness according to an embodiment of the present invention. Figure 3 As shown, the method comprises the following steps:

[0154] Step S301, input a preview picture.

[0155] Step S302: extract the fingerprint string of the preview image and use it as a mark of the scene.

[0156] Here, only when the fingerprint difference between two scenes is greater than a preset threshold Th, they are regarded as two different scenes.

[0157] Step S303: Detect the preview image to obtain a contamination determination result.

[0158] Step S304: input the current image fingerprint and contamination judgment result into a queue Q.

[0159] Here, it is assumed that the queue length is set to M.

[0160] In other embodiments, before step S305, the method further includes: obtaining a value of a contaminated image threshold N. The value of N may be preset by a developer, and may be set according to the length of the queue Q. For example, the value of N may be half of the value of M, assuming that M is 30 and N is 15.

[0161] Step S305 , determining whether the number of contaminated images in the queue Q is greater than N and whether the current preview image is a contaminated image.

[0162] Step S306, when the number of contaminated pictures in the queue Q is greater than N and the current preview picture is a contaminated picture, determine that the detection result is lens contamination, otherwise enter S301.

[0163] In this embodiment, step S303 can be based on Figure 4 The steps shown are implemented as Figure 4 As shown, the implementation process of detecting the preview image includes:

[0164] Step S401, obtaining a preview photo taken by a mobile phone.

[0165] Step S402, down-sampling the preview photo to obtain a down-sampled photo.

[0166] Step S403: performing singular value decomposition on the matrix represented by the downsampled photo, and calculating the sum of all singular values ​​of the matrix.

[0167] Step S404, calculating the number k of singular values ​​greater than a preset threshold Th_N of the sum of singular values.

[0168] In this example, the threshold Th_N is set to 70%, and the number k of singular values ​​that accounts for the total singular value Th_N is calculated.

[0169] Step S405, calculating the average brightness m of the bright area of ​​the photo histogram and the average brightness n of the dark area of ​​the photo histogram, and calculating the value of m / n, contrast_radio.

[0170] Step S406, judging whether the preview photo is blurred according to k and contrast_radio.

[0171] Here, in the implementation process, judging whether the preview photo is blurred according to k and contrast_radio may be performed by judging whether k is greater than a preset threshold value Th_k, and whether contrast_radio is greater than another preset threshold value Th_c.

[0172] Step S407: If k is greater than a preset threshold value Th_k, and contrast_radio is greater than another preset threshold value Th_c, it is considered that the preview photo is blurred.

[0173] In this example, assuming that Th_k is 10 and Th_c is 0.1, if k>10 and contrast_radio>0.1, the preview photo is considered to be blurred.

[0174] It should be noted that, in this embodiment, both Th_k and Th_c can be adjusted according to actual conditions.

[0175] Step S408: If k is not greater than a preset threshold value Th_k, or contrast_radio is not greater than another preset threshold value Th_c, no processing is performed.

[0176] Step S409, uploading the processing result of the preview photo.

[0177] Here, uploading the processing result of the preview photo may be adding the processing result of the preview photo to a queue Q.

[0178] Figure 5 The implementation flow diagram of contrast_radio is determined in the embodiment of the present invention, as shown in FIG. Figure 5 As shown, contrast_radio can be determined by the following steps:

[0179] Step S4051, input image;

[0180] Step S4052, taking the minimum value of the image RGB as the dark channel of the image;

[0181] Step S4053, calculating the dark channel histogram.

[0182] Step S4054, calculating dark_mean and bright_mean of the dark channel histogram.

[0183] Step S4055, calculate contrast_radio=dark_mean / bright_mean.

[0184] In the lens dirty detection method provided by the embodiment of the present invention, firstly, singular value decomposition is performed on the matrix corresponding to the preview image of the user preview interface, and the sum of singular values ​​is calculated, and the number of singular values ​​whose sum of singular values ​​reaches the specified threshold is obtained. If the number of singular values ​​is large at this time, it is considered that the photo contains more information, otherwise it is a picture with less information. Then the histogram of the preview interface photo is analyzed. When the histogram average of the darker part of the photo histogram is equal to the histogram average of the brighter part, and the ratio of the two is calculated. Combining the above two information, if the photo contains more information and the ratio of the dark area to the bright area of ​​the photo histogram is large, it is considered that the photo is blurred, that is, the lens is determined to be dirty. When it is detected that the lens is dirty, the user can be reminded to wipe the lens at a reasonable time to improve the user's photo-taking experience.

[0185] In other embodiments, after a blurred photo is detected, the detected information can be further used to perform contrast stretching processing on the blurred photo, which can improve the imaging quality of the photo and enhance the user experience.

[0186] Embodiment 4

[0187] This embodiment provides a terminal. Figure 6 FIG. 1 is a schematic diagram of the structure of a terminal according to an embodiment of the present invention. Figure 6 As shown, the terminal 600 at least includes a camera 601, a memory 602, a communication bus 603 and a processor 604, wherein:

[0188] The camera 601 is configured to capture images;

[0189] The memory 602 is configured to store a lens dirt detection program;

[0190] The communication bus 603 is configured to realize the connection and communication between the processor and the memory;

[0191] The processor 604 is configured to execute a lens dirt detection program stored in the memory to implement the following steps:

[0192] Acquire an image to be detected, wherein the image to be detected is a preview image captured by the camera;

[0193] Acquire a first contamination degree parameter of the image to be detected and a second contamination degree parameter of the image in the detection result set;

[0194] If it is determined that the lens of the camera is dirty according to the first contamination degree parameter and the second contamination degree parameter, a prompt message for cleaning the lens is output.

[0195] It should be noted that the description of the above terminal embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment, so it is not repeated. For technical details not disclosed in the terminal embodiment of the present invention, please refer to the description of the method embodiment of the present invention for understanding.

[0196] Correspondingly, an embodiment of the present invention provides a computer storage medium, in which computer executable instructions are stored. The computer executable instructions are configured to execute the lens dirt detection method provided in other embodiments of the present invention.

[0197] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.

[0198] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0199] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0200] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1The steps for the functions specified in one or more boxes.

[0201] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention.

Claims

1. A method for detecting lens dirtiness, applied to a terminal, wherein the terminal at least comprises a camera, characterized in that: The method comprises: Acquire an image to be detected, wherein the image to be detected is a preview image captured by the camera; Acquire a first contamination degree parameter of the image to be detected and a second contamination degree parameter of the image in the detection result set; If it is determined that the lens of the camera is dirty according to the first contamination degree parameter and the second contamination degree parameter, outputting prompt information for cleaning the lens; if it is determined that the lens of the camera is dirty according to the first contamination degree parameter and the second contamination degree parameter, comprising: Determining a first detection result of the image to be detected according to the first contamination degree parameter; Determining the number of contaminated images in the detection result set; If the first detection result indicates that the image to be detected is a contaminated image and the number of contaminated images in the detection result set is greater than a first threshold, it is determined that the lens of the camera is dirty.

2. The method according to claim 1, characterized in that If it is determined that the lens of the camera is dirty according to the first contamination degree parameter and the second contamination degree parameter, the method further includes: Obtaining a first weight corresponding to the first contamination degree parameter; Determining P second contamination degree parameters corresponding to P historical images and second weights corresponding to the P second contamination degree parameters according to the storage time of the images in the detection result set and the first weight, wherein P is an integer greater than 2; Determine a fifth value according to the first contamination degree parameter, the first weight, P second contamination degree parameters, and the second weights corresponding to the P second contamination degree parameters; If the fifth value is greater than a preset fourth threshold, it is determined that the lens of the camera is dirty.

3. The method according to claim 2, characterized in that The determining of the fifth value according to the first contamination degree parameter, the first weight, P second contamination degree parameters and the second weights corresponding to the P second contamination degree parameters includes: Performing a weighted summation on the first contamination degree parameter and the first weight, the P second contamination degree parameters and the second weights corresponding to the P second contamination degree parameters to obtain a sixth value; Summing the first weight and the second weights corresponding to the P second contamination degree parameters to obtain a seventh value; A ratio of the sixth value to the seventh value is determined as the fifth value.

4. The method according to claim 1, characterized in that Acquiring a first contamination degree parameter of the image to be detected includes: Acquire a dark channel image of the image to be detected and a histogram of the dark channel image; Determine a ratio of a first value to a second value according to the histogram, wherein the first value is determined according to each pixel value in the histogram, the number corresponding to each pixel value, and a preset percentage of a dark area; and the second value is determined according to each pixel value in the histogram, the number corresponding to each pixel value, and a preset percentage of a bright area; The ratio is determined as the first contamination degree parameter.

5. The method according to claim 1, characterized in that The step of determining a first detection result of the image to be detected according to the first contamination degree parameter includes: Downsampling the pixel matrix of the image to be detected to obtain a first matrix; Performing singular value decomposition on the first matrix to obtain a first number of singular values ​​that meets a first preset condition; A first detection result is determined according to the first contamination degree parameter and the first number, wherein if the first number is greater than a second threshold and the first contamination degree parameter is greater than a third threshold, it is determined that the image to be detected is a contaminated image.

6. The method according to claim 5, characterized in that The step of performing singular value decomposition on the first matrix to obtain a first number of singular values ​​that meets a first preset condition includes: Performing singular value decomposition on the first matrix to obtain singular values ​​of the first matrix; summing the singular values ​​to obtain a third value; Determining a fourth value according to the third value and a preset percentage; The number of the singular values ​​that is greater than the fourth value is determined as a first number.

7. The method according to claim 4, characterized in that The step of acquiring a dark channel image of the image to be detected and a histogram of the dark channel image comprises: Obtain the minimum value of the red, green and blue (RGB) components of each pixel in the image to be detected; Generate the dark channel image according to the minimum value corresponding to each pixel, wherein the dark channel image is a grayscale image with the same size as the image to be detected; Based on the dark channel image, a histogram of the dark channel image is acquired.

8. The method according to claim 7, characterized in that Determining the ratio of the first value to the second value according to the histogram includes: Acquire the total number of pixels of the dark channel image according to the histogram; Determine a second number according to the total number of pixels and the percentage of the dark area, and determine a third number according to the total number of pixels and the percentage of the bright area; Determine a first value according to the second number, each pixel value in the histogram, and the number corresponding to each pixel value; Determine a second value according to the third number, each pixel value in the histogram, and the number corresponding to each pixel value; A ratio of the first value to the second value is determined.

9. The method according to claim 8, characterized in that The determining the first value according to the second number, each pixel value in the histogram, and the number corresponding to each pixel value includes: The pixel value N is determined according to the second number and the histogram, wherein (d0+d1+…_+d N ) is less than or equal to the second number, and (d0+d1+…_+d N+1 ) is greater than the second number, N is an integer greater than or equal to 0 and less than 256, d i is the number corresponding to pixel value i, i = 0, 1, ..., N; 0*d0+1*d1+…_+N*d N Determined as a first weighted value; If the fourth number is equal to the second number, the first weighted value is determined as a first value, wherein the fourth number is (d0+d1+…_+d N ); If the fourth number is smaller than the second number, the product of the difference between the second number and the fourth number and the pixel value (N+1) is determined as the second weighted value; A sum of the first weighted value and the second weighted value is determined as a first value.

10. The method according to claim 8, characterized in that The determining the second value according to the third number, each pixel value in the histogram, and the number corresponding to each pixel value includes: The pixel value M is determined according to the third number and the histogram, wherein (d 255 +d 254 +…+d M ) is less than or equal to the third number, and (d 255 +d 254 +…_+d M-1 ) is greater than the third number, M is an integer greater than or equal to 0 and less than 256, d j is the number of pixels corresponding to the pixel value j, j = M, M + 1, ..., 255; 255*d 255 +254*d 254 +…+M*d M Determined as a third weighted value; If the fifth number is equal to the third number, the third weighted value is determined as the second value, wherein the fifth number is (d 255 +d 254 +…+d M ); If the fifth number is smaller than the third number, the product of the difference between the third number and the fifth number and the pixel value (M-1) is determined as the fourth weighted value; The sum of the third weighted value and the fourth weighted value is determined as a second value.

11. The method according to claim 1, characterized in that The method further comprises: Acquiring feature information of the image to be detected; If the feature information does not exist in the detection result set, adding the feature information and the first detection result to the detection result set; If the feature information is stored in the detection result set, and the second detection result corresponding to the feature information in the detection result set is different from the first detection result, the second detection result is updated to the first detection result.

12. A terminal, characterized in that: The terminal includes at least a camera, a memory, a communication bus and a processor, wherein: The camera is configured to capture images; The memory is configured to store a lens dirt detection program; The communication bus is configured to realize connection and communication between the processor and the memory; The processor is configured to execute a lens dirt detection program stored in the memory to implement the steps in the lens dirt detection method of claims 1 to 11 below.

13. A computer-readable storage medium, characterized in that: The computer storage medium stores computer executable instructions, which are configured to execute the steps in the lens dirt detection method provided in any one of claims 1 to 11 above.