Detection method and electronic device
By acquiring multiple frames of images at different positions of the camera module, calculating and marking the pixel values in the depth and amplitude images, the problem of low dirt detection accuracy and high cost in the existing technology is solved, and high accuracy and low cost are achieved. Contamination detection.
Patent Information
- Application Number
- CN202410769350.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2044-06-14
AI Technical Summary
In the existing technology, the method of detecting dirt on the surface of a camera module is expensive and has low accuracy, and cannot effectively improve the detection accuracy.
By acquiring multiple frames of images at different positions of the camera module, calculate the pixel values in the depth and amplitude images, mark the depth and standard deviation, and determine whether the depth and standard deviation of the pixels meet the preset values to determine whether there is dirt on the surface, and Issue a warning or discard depth information.
It improves the accuracy of dirt detection on the surface of the camera module, reduces detection costs, eliminates the need to add additional hardware equipment, and enables simultaneous dirt detection during the work process.
Smart Images

Figure CN118334037B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of dirt detection, and in particular to a detection method and an electronic device. Background Art
[0002] When the surface of the camera module is dirty, the quality of the image will be reduced, which will cause the electronic device equipped with the camera module to have functional problems such as obstacle avoidance failure, mapping errors, and recognition errors. At present, external equipment is generally used to obtain the surface image of the camera module, and the brightness comparison or depth value comparison is used to determine whether the surface of the camera module is dirty. However, the method of using external equipment for detection is costly and has low detection accuracy. Summary of the invention
[0003] In view of the above, it is necessary to provide a detection method and an electronic device to reduce the detection cost while improving the detection accuracy.
[0004] The present application provides a detection method for detecting whether there is dirt on the surface of a camera module in an electronic device. The detection method includes:
[0005] Acquire n frames of images of the imaging target at n different positions of the electronic device relative to the imaging target by using the camera module;
[0006] Based on the n frames of images, obtain n depth maps and n amplitude maps corresponding to the n depth maps, each of the depth maps and each of the amplitude maps including i pixels;
[0007] Traversing i pixels of each of the depth maps to obtain a depth traversal atlas, and traversing i pixels of each of the amplitude maps to obtain an amplitude traversal atlas;
[0008] Based on the depth traversal atlas, a set of depth values of i pixels in n depth maps is obtained to form i depth value sets, wherein the i depth value sets are {D 11 , D 12 , ...D 1n}, {D 21 , D 22 , ...D 2n}, ... {D i1 , D i2 , ...D in};
[0009] Based on the amplitude traversal atlas, a set of amplitudes of i pixels in n amplitude maps is obtained to form i amplitude sets, and the i amplitude sets are {F 11 、F 12 ,……F 1n}、{F 21 、F22 ,……F 2n}, ... {F i1 、F i2 ,……F in};
[0010] Based on the i depth value sets, obtaining the sum of all elements in each of the depth value sets to form i depth sums corresponding to the i pixels one by one;
[0011] Based on the i amplitude value sets, obtaining the average value and the standard deviation of all elements in each amplitude value set to respectively form i average values and i standard deviations corresponding to the i pixels one by one;
[0012] Compare i depth sums with a preset value X respectively, if the depth sum is greater than X, mark the pixel corresponding to the depth sum, compare i standard deviations with a preset value Y respectively, if the standard deviation is less than Y, mark the pixel corresponding to the standard deviation, arrange i average values from large to small or from small to large to form an average value sequence set, mark the pixels corresponding to the average values in the first Z% and the last Z% of the average value sequence set;
[0013] Get the total number B of marked pixels among i pixels;
[0014] Determine whether the total number B is greater than a preset value m. If so, determine that there is dirt on the surface of the camera module, and issue a warning message or discard the depth information of the marked pixel. If not, return to the step of obtaining n depth maps and n amplitude maps corresponding to the n depth maps based on the n frames of images.
[0015] Among them, n, i, B, and m are all positive integers.
[0016] In the above detection method, n images are acquired by the camera module at n different positions respectively, and each depth map corresponds to i pixels in each amplitude map one by one. The depth value of each pixel is proportional to the distance between the camera module and the imaging target, that is, the closer the distance between the camera module and the imaging target, the smaller the depth value corresponding to the pixel, and the amplitude of each pixel is inversely proportional to the distance between the camera module and the imaging target, that is, the closer the distance between the camera module and the imaging target, the larger the amplitude corresponding to the pixel, and the i depth sum is obtained based on the set of depth values of i pixels in n depth maps, and the i average values and i standard deviations are obtained based on the set of amplitude values of i pixels in n amplitude maps. Therefore, the above detection method uses pixels as detection units and marks pixels from two different latitudes of depth value and amplitude, which is conducive to improving the detection accuracy of dirt on the camera module. In addition, the above detection method can be completed synchronously during the operation of the electronic device without adding additional hardware equipment, thereby reducing the detection cost of dirt on the camera module.
[0017] In some embodiments, acquiring n frames of images of the imaging target at n different positions of the electronic device relative to the imaging target by the camera module includes:
[0018] Initializing parameters of the electronic device;
[0019] The electronic device drives the camera module to move relative to the imaging target, so that the camera module acquires n frames of images of the imaging target at n different positions relative to the imaging target.
[0020] Therefore, initializing the parameters of the electronic device can form a unified comparison benchmark, reducing the difficulty of comparing parameters in the subsequent image processing process. In addition, by driving the camera module to move relative to the imaging target through the electronic device, it is beneficial to realize the synchronous completion of dirt detection by the camera module during the working process.
[0021] In some embodiments, the movement of the camera module relative to the imaging target is at least one of linear movement and rotation.
[0022] Therefore, the above-mentioned movement method is helpful to improve the application range of the camera module.
[0023] In some embodiments, traversing i pixels of each of the depth maps to obtain a depth traversal atlas comprises:
[0024] Processing the n depth maps using flying spot filtering;
[0025] Traverse i pixels in each depth map processed by flying point filtering to obtain the depth traversal atlas.
[0026] Therefore, the flying point filter can be used to reduce the noise of the depth map, which is beneficial to improve the accuracy of the depth traversal atlas.
[0027] In some embodiments, before comparing the i depths and the preset value X respectively, the method further includes:
[0028] Determine whether the number of frames n reaches the set upper limit M. If yes, execute the subsequent steps. If no, return to the step of obtaining n depth maps and n amplitude maps corresponding to the n depth maps based on the n frames of images.
[0029] Therefore, through the above steps, the upper limit value can be adjusted in time based on different needs, which is conducive to improving the application scope of the detection method.
[0030] In some embodiments, the reference benchmarks set by the preset values X, Y, and Z include at least one of the sensitivity of dirt detection and the range of dirt detection.
[0031] Therefore, the preset values X, Y, and Z formed based on the sensitivity of dirt detection or the range of dirt detection are beneficial to improving the accuracy of dirt detection.
[0032] In some embodiments, if B is greater than m, between determining whether the total B is greater than the preset value m and determining whether the surface of the detector is dirty and issuing a warning message, the following steps are further included:
[0033] Determine whether the exposure value E1 of the camera module when acquiring n frames of images reaches the set upper limit value e. If yes, reduce the exposure value of the camera module to E2, and return to the step of obtaining n depth maps and n amplitude maps corresponding to the n depth maps based on the n frames of images. If no, determine that there is dirt on the surface of the camera module and issue a warning message.
[0034] Therefore, the above setting can improve the accuracy of dirt detection.
[0035] In some embodiments, the detection method satisfies the relationship:
[0036] E2≥e / 2.
[0037] Therefore, by reasonably configuring the exposure value E2, the dirt detection accuracy can be improved while satisfying the dirt detection accuracy.
[0038] The present application also provides an electronic device, including:
[0039] A camera module, used to: obtain n frames of images of an imaging target at n different positions of the electronic device relative to the imaging target; obtain n depth maps and n amplitude maps corresponding to the n depth maps based on the n frames of images, each of the depth maps and each of the amplitude maps including i pixels;
[0040] The acquisition module is used to: traverse i pixels of each of the depth maps to obtain a depth traversal atlas, traverse i pixels in each of the amplitude maps to obtain an amplitude traversal atlas; based on the depth traversal atlas, obtain a set of depth values of i pixels in n of the depth maps to form i depth value sets, wherein the i depth value sets are {D 11 , D 12 , ...D 1n}, {D 21 , D 22 , ...D 2n}, ... {D i1 , D i2 , ...D in}; Based on the amplitude traversal atlas, the set of amplitudes of i pixels in n amplitude maps is obtained to form i amplitude sets, and the i amplitude sets are {F 11 、F 12,……F 1n}、{F 21 、F 22 ,……F 2n}, ... {F i1 、F i2 ,……F in}; Based on the i depth value sets, obtain the sum of all elements in each of the depth value sets to form i depth sums corresponding to the i pixels one by one; based on the i amplitude value sets, obtain the average value and standard deviation of all elements in each of the amplitude value sets to form i average values and i standard deviations corresponding to the i pixels one by one;
[0041] A comparison module, used to: compare i depth sums with a preset value X respectively, if the depth sum is greater than X, mark the pixels corresponding to the depth sum, compare i standard deviations with a preset value Y respectively, if the standard deviation is less than Y, mark the pixels corresponding to the standard deviation, arrange i average values from large to small or from small to large to form an average value sequence set, and mark the pixels corresponding to the average values in the first Z% and the last Z% in the average value sequence set;
[0042] A processing module is used to: obtain the total number B of marked pixels in i pixels; determine whether the total number B is greater than a preset value m, if yes, determine that there is dirt on the surface of the camera module, and issue a warning message or discard the depth information of the marked pixels; if no, return to the camera module to enable the camera module to execute the acquisition of n depth maps and n amplitude maps corresponding to the n depth maps based on the n frames of images; wherein,
[0043] n, i, B, and m are all positive integers.
[0044] In the above electronic device, n images are acquired by the camera module at n different positions respectively, and each depth map corresponds to i pixels in each amplitude map one by one, wherein the depth value of each pixel is proportional to the distance of the camera module relative to the camera target, that is, the closer the distance between the camera module and the imaging target, the smaller the depth value corresponding to the pixel, and the amplitude of each pixel is inversely proportional to the distance of the camera module relative to the imaging target, that is, the closer the distance between the camera module and the imaging target, the larger the amplitude corresponding to the pixel. In the acquisition module, the i depth sums acquired are acquired based on the set of depth values of i pixels in n depth maps, and the i average values and i standard deviations acquired are acquired based on the set of amplitude values of i pixels in n amplitude maps. Therefore, the above electronic device can use pixels as detection units and mark pixels from two different latitudes of depth value and amplitude, which is conducive to improving the detection accuracy of dirt on the camera module. In addition, the above electronic device can be completed synchronously during the operation of the camera module without adding additional hardware equipment, thereby reducing the detection cost of dirt on the camera module.
[0045] In some embodiments, the electronic device further comprises:
[0046] The moving unit is used to drive the camera module, the acquisition module, the comparison module and the processing module to move relative to the imaging target.
[0047] Therefore, the mobile unit is beneficial for enabling the electronic device to automate the dirt detection on the camera module. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 Schematic diagram of the detection method of the embodiment of the present application.
[0049] Figure 2 for Figure 1 A schematic flow chart of step S110 in the detection method is shown.
[0050] Figure 3 for Figure 1 A schematic flow chart of step S130 in the detection method is shown.
[0051] Figure 4 It is a structural block diagram of an electronic device according to an embodiment of the present application.
[0052] Main component symbols
[0053] Electronic device: 100; camera module: 110; acquisition module: 120; comparison module: 130; processing module: 140; mobile unit: 150. DETAILED DESCRIPTION
[0054] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be understood as limiting the present application.
[0055] In the description of this application, it should be noted that, unless otherwise clearly specified and limited, the term "connection" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection, an electrical connection, or mutual communication; it can be a direct connection, or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0056] The following is a detailed description of various embodiments of the present invention in conjunction with the accompanying drawings.
[0057] See also Figure 1, an embodiment of the present application provides a detection method for detecting whether there is dirt on the surface of a camera module in an electronic device. Specifically, the camera module may be a depth sensor, or other imaging device capable of obtaining a depth map and an amplitude map, and the surface of the camera module specifically refers to a light-transmitting member located on the imaging path of the camera module. The dirt may be dust, water droplets, prints, etc. The detection method includes:
[0058] S110, acquiring n frames of images of the imaging target at n different positions of the electronic device relative to the imaging target by using a camera module.
[0059] Specifically, n is a positive integer, the imaging target is a fixed object, and n different positions correspond to n frames of images one by one, that is, one frame of the imaging target image is obtained at each position. It can be understood that N frames of images of the imaging target can also be obtained at n different positions, where N is a positive integer and greater than n, and each position corresponds to one or more frames of images. In this case, it is necessary to screen N frames of images to form n frames of images.
[0060] See also Figure 2 In some embodiments, step S100 of acquiring n frames of images of the imaging target at n different positions of the electronic device relative to the imaging target by using a camera module includes:
[0061] S111, initializing parameters of the electronic device.
[0062] Specifically, the parameters of the electronic device include depth value, amplitude, depth sum, average value and standard deviation. The object corresponding to the parameters is the image acquired by the electronic device. The initialization method can be to eliminate the above parameters or set the above parameters to a certain value, for example: 0.
[0063] Therefore, initializing the parameters of the electronic device can form a unified comparison benchmark, reducing the difficulty of comparing parameters in subsequent image processing processes.
[0064] S112, driving the camera module to move relative to the imaging target by an electronic device, so that the camera module acquires n frames of images of the imaging target at n different positions relative to the imaging target.
[0065] Specifically, the electronic device drives the camera module to move in a manner that a power mechanism in the electronic device drives the camera module to move.
[0066] Therefore, driving the camera module to move relative to the imaging target by an electronic device is conducive to realizing the synchronous completion of dirt detection by the camera module during the working process.
[0067] In some embodiments, the movement of the camera module relative to the imaging target is at least one of linear movement and rotation.
[0068] Specifically, the movement mode of the camera module depends on the way in which the camera module captures images of objects at different angles in the electronic device.
[0069] Therefore, the above-mentioned movement method is helpful to improve the application range of the camera module.
[0070] S120, obtaining n depth maps and n amplitude maps corresponding to the n depth maps based on n frames of images, each depth map and each amplitude map including i pixels.
[0071] Specifically, the i pixels may be arranged in an x*y array or in other arrangements, as long as the i pixels in each depth map and the i pixels in each amplitude map are arranged in a consistent and one-to-one manner.
[0072] S130, traversing i pixels in each depth map to obtain a depth traversal atlas, and traversing i pixels in each amplitude map to obtain an amplitude traversal atlas.
[0073] Specifically, during traversal, the i pixels in each depth map and each amplitude map are defined in the same way. For example, the i pixels in each depth map and each amplitude map are arranged in an x*y array. If B3 represents the pixel in the second row and third column in the first depth, then B3 represents the pixel in the second row and third column in n depth maps and n amplitude maps.
[0074] See also Figure 3 In some embodiments, step S130 of traversing i pixels of each depth map to obtain a depth traversal atlas includes:
[0075] S131, using flying point filtering to process n depth maps.
[0076] Specifically, the flying point filter can be used to perform noise reduction processing on the depth map to remove the flying point noise in the depth map, which is beneficial to improving the accuracy of the depth traversal atlas.
[0077] S132, traversing i pixels in each depth map processed by flying point filtering to obtain a depth traversal atlas.
[0078] S140, based on the depth traversal atlas, obtain a set of depth values of i pixels in n depth maps to form i depth value sets, the i depth value sets are {D 11 , D 12 , ...D 1n}, {D 21 , D 22 , ...D 2n}, ... {D i1 , D i2 , ...D in}.
[0079] Here, an example is given to illustrate the meaning of each element in the above depth value set, for example: D 11 Indicates the depth value of the first pixel defined in the depth map in the first depth map, D in Represents the depth value of the i-th pixel defined in the depth map in the n-th depth map.
[0080] It should be noted that the depth value of each pixel is proportional to the distance between the camera module and the imaging target. Specifically, the closer the distance between the camera module and the imaging target, the smaller the depth value corresponding to the pixel, and the farther the distance between the camera module and the imaging target, the larger the depth value corresponding to the pixel.
[0081] S150, based on the amplitude traversal atlas, obtain the set of amplitudes of i pixels in n amplitude maps to form i amplitude sets, the i amplitude sets are {F 11 、F 12 ,……F 1n}、{F 21 、F 22 ,……F 2n}, ... {F i1 、F i2 ,……F in}.
[0082] Here, we will give an example to illustrate the meaning of each element in the above amplitude set, for example: F 11 Indicates the amplitude of the first pixel defined in the amplitude map in the first amplitude map, F in Represents the amplitude of the i-th pixel defined in the amplitude map in the n-th amplitude map.
[0083] It should be noted that the amplitude of each pixel is inversely proportional to the distance between the camera module and the imaging target. Specifically, the closer the distance between the camera module and the imaging target, the larger the amplitude corresponding to the pixel, and the farther the distance between the camera module and the imaging target, the smaller the amplitude corresponding to the pixel.
[0084] S160 , based on the i depth value sets, obtain the sum of all elements in each depth value set to form i depth sums corresponding to the i pixels one by one.
[0085] Specifically, each depth sum is equal to the sum of all elements in the corresponding depth set, for example: for the depth value set {D 11 , D 12 , ...D 1n}, its depth and Sum1 = D 11 +D 12 +……+D 1n , correspondingly, the depth value set {D i1 , D i2 , ...Din}Depth and Sum i =D i1 +D i2 +……+D in .
[0086] S170, based on the i amplitude value sets, obtain the average value and standard deviation of all elements in each amplitude value set to respectively form i average values and i standard deviations corresponding to the i pixels one by one.
[0087] Specifically, each average value is equal to the average value of all elements in the corresponding amplitude set. For example, for the amplitude set {F 11 、F 12 ,……F 1n}, its average value Av1=(F 11 +F 12 +……+F 1n ) / n, correspondingly, the amplitude set {F i1 、F i2 ,……F in The average value Av i =(F i1 +F i2 +……+F in ) / n.
[0088] S180, respectively compare i depth sums with a preset value X, if the depth sum is greater than X, mark the pixel corresponding to the depth sum, respectively compare i standard deviations with a preset value Y, if the standard deviation is less than Y, mark the pixel corresponding to the standard deviation, arrange i average values from large to small or from small to large to form an average value sequence set, mark the pixels corresponding to the average values in the first Z% and the last Z% in the average value sequence set.
[0089] It should be noted that the camera module obtains n frames of images at n different positions. When the surface of the camera module is not dirty, the depth values of the same pixel in different depth maps must be different. Therefore, the depth sum of the obtained pixels must be large. On the contrary, if there is dirt on the surface of the camera module, during the movement of the camera module, the pixels corresponding to the area where the dirt is located can only detect the dirt on the surface. Therefore, the depth values of the same pixel in different depth maps are small, and the depth sum of the obtained pixels is small. Therefore, the depth sum of the pixel is compared with the lower limit of the set depth sum to determine whether there is dirt on the surface of the camera module.
[0090] It should be noted that the camera module obtains n frames of images at n different positions. When the surface of the camera module is not dirty, the amplitude of the same pixel in different amplitude maps must be different, so the standard deviation of the obtained pixel must be large. On the contrary, if there is dirt on the surface of the camera module, during the movement of the camera module, the pixels corresponding to the area where the dirt is located can only detect the dirt on the surface. Therefore, the difference between the amplitudes of the same pixel in different amplitude maps is small, and the standard deviation of the obtained pixel is small. Therefore, the standard deviation of the pixel is compared with the set upper limit of the standard deviation to determine whether the surface of the camera module is dirty.
[0091] Furthermore, when there is dirt on the surface of the camera module, the amplitude corresponding to the area where the dirt is located is generally large (when the dirt is a bright spot) or small (when the dirt is a dark spot), so the average value of the pixel corresponding to the dirt is at the beginning or end of the average values of all pixels after sorting. Therefore, the i average values are sorted by size, and the pixel range that needs to be marked is divided by the upper limit Z% of the ratio of the beginning and the end.
[0092] In some embodiments, the reference benchmarks set by the preset values X, Y, and Z include at least one of the sensitivity of dirt detection and the range of dirt detection.
[0093] Therefore, the preset values X, Y, and Z formed based on the sensitivity of dirt detection or the range of dirt detection are beneficial to improving the accuracy of dirt detection.
[0094] S190, obtaining the total number B of marked pixels among i pixels.
[0095] Specifically, the total number B is a positive integer, and its statistical cardinality is the number of pixels, that is, each marked pixel is only recorded as 1, no matter how many times the pixel is marked. For example, pixel A is marked when judging the depth sum, standard deviation, and average value, then the number of times pixel A is marked is 3, but in the total number B, pixel A is only recorded as 1.
[0096] S200, determining whether the total number B is greater than a preset value m.
[0097] Specifically, the preset value m is a positive integer, which can reflect the number of pixels affected by the defined dirt in the same image.
[0098] S220, if yes, determine that there is dirt on the surface of the camera module, and issue a warning message or discard the depth information of the marked pixel; if no, return to step S120.
[0099] Specifically, the warning information may be a buzzer sound or a voice prompt light.
[0100] In some embodiments, if B is greater than m, the process between determining whether the total B is greater than a preset value m in step S200 and determining whether there is dirt on the surface of the detector and issuing a warning message in step S220 also includes:
[0101] S210, determining whether the exposure value E1 of the camera module when acquiring n frames of images reaches a set upper limit value e.
[0102] Specifically, the exposure value can affect the brightness and corresponding amplitude of the image, and can further limit the conditions for determining dirt, thereby improving the accuracy of detecting dirt.
[0103] S230, if yes, lower the exposure value of the camera module to E2 and return to step S120, if no, execute step S220.
[0104] Therefore, the above setting can improve the accuracy of dirt detection.
[0105] In some embodiments, the detection method satisfies the relationship:
[0106] E2≥e / 2.
[0107] Therefore, by reasonably configuring the exposure value E2, the dirt detection accuracy can be improved while satisfying the dirt detection accuracy.
[0108] See also Figure 1 In some embodiments, before step S180 compares the i depths and the preset value X respectively, the step further includes:
[0109] S178, determine whether the frame number n reaches the set upper limit value M, if yes, execute the subsequent steps, if no, return to step S120.
[0110] Specifically, the upper limit value M can be defined based on detection requirements.
[0111] Therefore, through the above steps, the upper limit value can be adjusted in time based on different needs, which is conducive to improving the application scope of the detection method.
[0112] In the above detection method, n images are acquired by the camera module at n different positions respectively, each depth map corresponds to i pixels in each amplitude map, i depth sums are acquired based on the set of depth values of i pixels in n depth maps, and i average values and i standard deviations are acquired based on the set of amplitudes of i pixels in n amplitude maps. Therefore, the above detection method uses pixels as detection units and marks pixels from two different latitudes of depth value and amplitude, which is conducive to improving the detection accuracy of dirt on the camera module. In addition, the above detection method can be completed synchronously during the operation of the camera module without adding additional hardware equipment, thereby reducing the detection cost of dirt on the camera module.
[0113] See also Figure 4 The embodiment of the present application further provides an electronic device 100, including a camera module 110, a collection module 120, a comparison module 130 and a processing module 140. The electronic device 100 may be an intelligent robot, a drone, a monitoring device, and the like.
[0114] Specifically, the camera module 110 is used to: obtain n frames of images of the imaging target at n different positions relative to the imaging target through the camera module; obtain n depth maps and n amplitude maps corresponding to the n depth maps based on the n frames of images, each depth map and each amplitude map includes i pixels.
[0115] Correspondingly, the camera module 110 can implement step S110 and step S120 in the above detection method.
[0116] The acquisition module 120 is used to: traverse i pixels in each depth map to obtain a depth traversal atlas, traverse i pixels in each amplitude map to obtain an amplitude traversal atlas; based on the depth traversal atlas, obtain a set of depth values of i pixels in n depth maps to form i depth value sets, and the i depth value sets are {D 11 , D 12 , ...D 1n}, {D 21 , D 22 , ...D 2n}, ... {D i1 , D i2 , ...D in}; Based on the amplitude traversal atlas, the set of amplitudes of i pixels in n amplitude maps is obtained to form i amplitude sets, and the i amplitude sets are {F 11 、F 12 ,……F 1n}、{F 21 、F 22 ,……F 2n}, ... {F i1 、F i2 ,……F in}; Based on the i depth value sets, the sum of all elements in each depth value set is obtained to form i depth sums corresponding to the i pixels one by one; based on the i amplitude value sets, the mean value and standard deviation of all elements in each amplitude value set are obtained to form i mean values and i standard deviations corresponding to the i pixels one by one, respectively.
[0117] Correspondingly, the acquisition module 120 can implement steps S130 to S170 in the above detection method.
[0118] It should be noted that the depth value of each pixel is proportional to the distance between the camera module 110 and the imaging target. Specifically, the closer the distance between the camera module 110 and the imaging target, the smaller the depth value corresponding to the pixel, and the farther the distance between the camera module 110 and the imaging target, the larger the depth value corresponding to the pixel. The amplitude of each pixel is inversely proportional to the distance between the camera module 110 and the imaging target. Specifically, the closer the distance between the camera module 110 and the imaging target, the larger the amplitude corresponding to the pixel, and the farther the distance between the camera module 110 and the imaging target, the smaller the amplitude corresponding to the pixel.
[0119] The comparison module 130 is used to: compare i depth sums with a preset value X respectively, if the depth sum is greater than X, mark the pixels corresponding to the depth sum, compare i standard deviations with a preset value Y respectively, if the standard deviation is less than Y, mark the pixels corresponding to the standard deviation, arrange i average values from large to small or from small to large to form an average value sequence set, and mark the pixels corresponding to the average values located in the first Z% and the last Z% of the average value sequence set.
[0120] Correspondingly, the comparison module 130 can implement step S180 in the above detection method.
[0121] The processing module 140 is used to: obtain the total number B of marked pixels among i pixels; determine whether the total number B is greater than a preset value m. If so, it is determined that there is dirt on the surface of the camera module 110, and a warning message is issued or the depth information of the marked pixels is discarded. If not, it returns to the camera module 110 so that the camera module 110 executes step S120.
[0122] Correspondingly, the processing module 140 can implement step S190 and step S200 in the above detection method.
[0123] In some embodiments, the electronic device 100 further includes a moving unit 150. The moving unit 150 is used to drive the camera module 110, the acquisition module 120, the comparison module 130 and the processing module 140 to move.
[0124] Specifically, the camera module 110 , the acquisition module 120 , the comparison module 130 , and the processing module 140 are all installed on the mobile unit 150 .
[0125] Therefore, the moving unit 150 helps the electronic device 100 to realize automatic dirt detection on the camera module 110 .
[0126] In the above-mentioned electronic device 100, the n images are acquired by the camera module 110 at n different positions respectively, and each depth map corresponds to i pixels in each amplitude map. In the acquisition module 120, the i depths and obtained are obtained based on the set of depth values of the i pixels in the n depth maps, and the i average values and i standard deviations obtained are obtained based on the set of amplitudes of the i pixels in the n amplitude maps. Therefore, the above-mentioned electronic device 100 can use pixels as detection units and mark pixels from two different latitudes of depth value and amplitude, which is conducive to improving the detection accuracy of dirt on the camera module 110. In addition, the above-mentioned electronic device 100 can be completed synchronously during the operation of the camera module 110 without adding additional hardware equipment, thereby reducing the detection cost of dirt on the camera module 110.
[0127] It is obvious to those skilled in the art that the present application is not limited to the details of the exemplary embodiments described above, and that the present application can be implemented in other specific forms without departing from the spirit or essential features of the present application. Therefore, no matter from which point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present application is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present application.
[0128] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present application and are not intended to limit it. Although the present application has been described in detail with reference to the preferred embodiments, a person of ordinary skill in the art should understand that the technical solution of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present application.
Claims
1. A detection method for detecting whether there is dirt on the surface of a camera module in an electronic device, characterized in that: The detection method comprises: Acquire n frames of images of the imaging target at n different positions of the electronic device relative to the imaging target by using the camera module; Based on the n frames of images, obtain n depth maps and n amplitude maps corresponding to the n depth maps, each of the depth maps and each of the amplitude maps including i pixels; Traversing i pixels of each of the depth maps to obtain a depth traversal atlas, and traversing i pixels of each of the amplitude maps to obtain an amplitude traversal atlas; Based on the depth traversal atlas, a set of depth values of i pixels in n depth maps is obtained to form i depth value sets, wherein the i depth value sets are {D 11 , D 12 , ...D 1n }, {D 21 , D 22 , ...D 2n }, ... {D i1 , D i2 , ...D in }; Based on the amplitude traversal atlas, a set of amplitudes of i pixels in n amplitude maps is obtained to form i amplitude sets, and the i amplitude sets are {F 11 、F 12 ,……F 1n }、{F 21 、F 22 ,……F 2n }, ... {F i1 、F i2 ,……F in }; Based on the i depth value sets, obtaining the sum of all elements in each of the depth value sets to form i depth sums corresponding to the i pixels one by one; Based on the i amplitude value sets, obtaining the average value and the standard deviation of all elements in each amplitude value set to respectively form i average values and i standard deviations corresponding to the i pixels one by one; Compare i depth sums with a preset value X respectively, if the depth sum is greater than X, mark the pixel corresponding to the depth sum, compare i standard deviations with a preset value Y respectively, if the standard deviation is less than Y, mark the pixel corresponding to the standard deviation, arrange i average values from large to small or from small to large to form an average value sequence set, mark the pixels corresponding to the average values in the first Z% and the last Z% of the average value sequence set; Get the total number B of marked pixels among i pixels; Determine whether the total number B is greater than a preset value m. If yes, determine that there is dirt on the surface of the camera module, and issue a warning message or discard the depth information of the marked pixel. If no, return to the step of obtaining n depth maps and n amplitude maps corresponding to the n depth maps based on the n frames of images; wherein, n, i, B, and m are all positive integers.
2. The detection method according to claim 1, characterized in that The step of acquiring n frames of images of the imaging target at n different positions of the electronic device relative to the imaging target by using the camera module comprises: Initializing parameters of the electronic device; The electronic device drives the camera module to move relative to the imaging target, so that the camera module acquires n frames of images of the imaging target at n different positions relative to the imaging target.
3. The detection method according to claim 2, characterized in that The camera module moves relative to the imaging target in at least one of linear movement and rotation.
4. The detection method according to claim 1, characterized in that The traversing i pixels of each of the depth maps to obtain a depth traversal atlas comprises: Processing the n depth maps using flying spot filtering; Traverse i pixels in each depth map processed by flying point filtering to obtain the depth traversal atlas.
5. The detection method according to claim 1, characterized in that Before comparing the i depths and the preset value X respectively, the following further comprises: Determine whether the number of frames n reaches the set upper limit M. If yes, execute the subsequent steps. If no, return to the step of obtaining n depth maps and n amplitude maps corresponding to the n depth maps based on the n frames of images.
6. The detection method according to claim 1, characterized in that The reference standards set by the preset values X, Y, and Z include at least one of the sensitivity of dirt detection and the range of dirt detection.
7. The detection method according to claim 1, characterized in that If B is greater than m, between determining whether the total number B is greater than the preset value m and determining whether the surface of the detector is dirty and issuing a warning message, the following is also included: It is determined whether the exposure value E1 of the camera module when acquiring n frames of images reaches the set upper limit value e. If so, the exposure value of the camera module is reduced to E2, and the process returns to the step of obtaining n depth maps and n amplitude maps corresponding to the n depth maps based on the n frames of images. If not, it is determined that there is dirt on the surface of the camera module and a warning message is issued.
8. The detection method according to claim 7, characterized in that The detection method satisfies the relationship: E2=e / 2.
9. An electronic device, characterized in that: include: The camera module is used to obtain n frames of images of the imaging target at n different positions of the electronic device relative to the imaging target; Based on the n frames of images, obtain n depth maps and n amplitude maps corresponding to the n depth maps, each of the depth maps and each of the amplitude maps including i pixels; The acquisition module is used to: traverse i pixels of each of the depth maps to obtain a depth traversal atlas, traverse i pixels in each of the amplitude maps to obtain an amplitude traversal atlas; based on the depth traversal atlas, obtain a set of depth values of i pixels in n of the depth maps to form i depth value sets, wherein the i depth value sets are {D 11 , D 12 , ...D 1n }, {D 21 , D 22 , ...D 2n }, ... {D i1 , D i2 , ...D in }; Based on the amplitude traversal atlas, the set of amplitudes of i pixels in n amplitude maps is obtained to form i amplitude sets, and the i amplitude sets are {F 11 、F 12 ,……F 1n }、{F 21 、F 22 ,……F 2n }, ... {F i1 、F i2 ,……F in }; Based on the i depth value sets, obtain the sum of all elements in each of the depth value sets to form i depth sums corresponding to the i pixels one by one; Based on the i amplitude value sets, obtaining the average value and the standard deviation of all elements in each amplitude value set to respectively form i average values and i standard deviations corresponding to the i pixels one by one; A comparison module, used to: compare i depth sums with a preset value X respectively, if the depth sum is greater than X, mark the pixels corresponding to the depth sum, compare i standard deviations with a preset value Y respectively, if the standard deviation is less than Y, mark the pixels corresponding to the standard deviation, arrange i average values from large to small or from small to large to form an average value sequence set, and mark the pixels corresponding to the average values in the first Z% and the last Z% in the average value sequence set; A processing module is used to: obtain the total number B of marked pixels in i pixels; determine whether the total number B is greater than a preset value m, if yes, determine that there is dirt on the surface of the camera module, and issue a warning message or discard the depth information of the marked pixels; if no, return to the camera module to enable the camera module to execute the acquisition of n depth maps and n amplitude maps corresponding to the n depth maps based on the n frames of images; wherein, n, i, B, and m are all positive integers.
10. The electronic device according to claim 9, wherein: The electronic device further comprises: The moving unit is used to drive the camera module, the acquisition module, the comparison module and the processing module to move relative to the imaging target.
