Camera shielding detection method and device, electronic equipment and storage medium
By calculating the ratio of pixel points in the image in camera occlusion detection and combining image processing technology, the problem of high false alarm rate in the prior art is solved, and higher detection accuracy and reliability are achieved.
Patent Information
- Application Number
- CN202410211510.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-26
- Publication Date
- 2025-08-26
AI Technical Summary
In the prior art, when identifying camera occlusion conditions, there are false alarms, resulting in low accuracy of camera occlusion detection.
By acquiring the image currently collected by the camera, inputting the pre-generated detection model, calculating the ratio of the number of pixels corresponding to each pixel value in the image to the total number, and determining whether the camera is in an occlusion state based on the ratio, combining binarization processing, expansion corrosion and connection domain processing to improve detection accuracy.
Improve the accuracy and reliability of camera occlusion detection and reduce the false alarm rate.
Smart Images

Figure CN120547320A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of communication technology, and in particular to a camera occlusion detection method, device, electronic device, and storage medium. Background Art
[0002] In the existing technology, the occlusion of the vehicle-mounted camera can be identified through a deep learning model. However, when identifying the occlusion of the camera, the existing technology may produce false alarms, resulting in low accuracy of camera occlusion detection. Summary of the Invention
[0003] The present disclosure aims to solve one of the technical problems in the related art at least to a certain extent.
[0004] The first embodiment of the present disclosure provides a camera occlusion detection method, comprising:
[0005] Get the first image currently captured by the camera;
[0006] Inputting the first image into a pre-generated detection model to obtain a detection result output by the detection model;
[0007] When the detection result indicates that the camera is currently in an occlusion state, determining a first ratio between the number of pixels corresponding to each pixel value in the image and the total number of pixels contained in the image;
[0008] Determine whether the camera is currently in an obstructed state according to the first ratio.
[0009] A second embodiment of the present disclosure provides a camera occlusion detection device, comprising:
[0010] A first acquisition module is used to acquire a first image currently captured by the camera;
[0011] a second acquisition module, configured to input the first image into a pre-generated detection model and obtain a detection result output by the detection model;
[0012] a first determining module, configured to determine, when the detection result indicates that the camera is currently in an occlusion state, a first ratio between the number of pixels corresponding to each pixel value in the image and the total number of pixels contained in the image;
[0013] The second determining module is configured to determine whether the camera is currently in an obstructed state according to the first ratio.
[0014] The third aspect embodiment of the present disclosure proposes an electronic device, including: a memory, a processor, and a computer program stored in the memory and runnable on the processor. When the processor executes the program, it implements the camera occlusion detection method proposed in the first aspect embodiment of the present disclosure.
[0015] The fourth embodiment of the present disclosure proposes a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the camera occlusion detection method proposed in the first embodiment of the present disclosure is implemented.
[0016] The camera occlusion detection method, device, electronic device, and storage medium provided by the present disclosure have the following beneficial effects:
[0017] In the embodiment of the present disclosure, after obtaining the first image currently captured by the camera, the first image is first input into a pre-generated detection model to obtain the detection result output by the detection model. If the detection result indicates that the camera is currently in an occlusion state, a first ratio between the number of pixels corresponding to each pixel value in the image and the total number of pixels contained in the image is determined, and then, based on the first ratio, whether the camera is currently in an occlusion state is determined. Thus, if the detection result of the image obtained by the detection model indicates that the camera is currently in an occlusion state, whether the camera is currently in an occlusion state is determined based on the ratio of the number of pixels corresponding to each pixel value in the image to the total number of pixels in the image, thereby improving the accuracy and reliability of the camera occlusion detection method.
[0018] Additional aspects and advantages of the present disclosure will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The above and / or additional aspects and advantages of the present disclosure will become apparent and readily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0020] Figure 1 A flowchart of a camera occlusion detection method provided by an embodiment of the present disclosure;
[0021] Figure 2 A schematic diagram of the structure of the detection model provided in the embodiment of the present disclosure;
[0022] Figure 3 A schematic flow chart of a camera occlusion detection method provided in another embodiment of the present disclosure;
[0023] Figure 4 A schematic flow chart of a camera occlusion detection method provided in another embodiment of the present disclosure;
[0024] Figure 5 A schematic flow chart of a camera occlusion detection method provided in another embodiment of the present disclosure;
[0025] Figure 6 A schematic diagram of an image before and after binarization processing provided by an embodiment of the present disclosure;
[0026] Figure 7 A schematic diagram of the results of image expansion and erosion and connected domain processing provided by an embodiment of the present disclosure;
[0027] Figure 8 A schematic flow chart of a camera occlusion detection method provided in another embodiment of the present disclosure;
[0028] Figure 9 A schematic flow chart of a camera occlusion detection method provided in another embodiment of the present disclosure;
[0029] Figure 10 A schematic structural diagram of a camera occlusion detection device provided in another embodiment of the present disclosure;
[0030] Figure 11 A block diagram of an exemplary electronic device suitable for implementing embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0031] The following describes in detail embodiments of the present disclosure, examples of which 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 intended to be used to explain the present disclosure, and should not be construed as limiting the present disclosure.
[0032] The following describes the camera occlusion detection method, device, electronic device, and storage medium according to the embodiments of the present disclosure with reference to the accompanying drawings.
[0033] Figure 1 A flowchart of a camera occlusion detection method provided in an embodiment of the present disclosure.
[0034] The embodiment of the present disclosure takes the camera occlusion detection method configured in a camera occlusion detection device as an example for illustration. The camera occlusion detection device can be applied to any electronic device so that the electronic device can perform a camera occlusion detection function.
[0035] like Figure 1 As shown, the camera occlusion detection method may include the following steps:
[0036] Step 101: Acquire a first image currently captured by a camera.
[0037] It should be noted that the camera can be a monocular camera, a binocular camera, or any other camera that can be installed on a vehicle and sense information around the vehicle, and this disclosure does not limit this.
[0038] The first image is image data collected in real time by the camera and needs to be judged whether there is any occlusion.
[0039] It should be noted that the camera obstruction may be obstruction by foreign objects, mud, opaque liquids and other attachments, and this disclosure does not limit this.
[0040] Step 102: Input the first image into a pre-generated detection model to obtain a detection result output by the detection model.
[0041] The detection model is a model used to detect whether the first image is occluded, and can be any model. For example, the backbone network of the detection model can be any lightweight neural network model such as a mobile classification network MobileNet, a high-precision network model EfficientNet, or SqueezeNet, and this disclosure does not limit this.
[0042] The detection result is a result used to indicate whether the camera is in an obstructed state. For example, the detection result may indicate that the camera is in an obstructed state, or it may indicate that the camera is in an unobstructed state, which is not limited in this disclosure.
[0043] Below is Figure 2 As an example, the structure of the detection model is explained. Figure 2 A schematic diagram of the structure of the detection model provided in an embodiment of the present disclosure.
[0044] like Figure 2 As shown in the figure, first, the backbone network of the detection model can be a lightweight neural network model, such as MobileNet, EfficientNet, SqueezeNet, etc. Then, the secondary feature extraction module, the convolution layer with an output channel of 2, and the activation function softmax function can be connected in sequence after the backbone network model to form a detection model, thereby realizing the detection of whether the camera is currently in an occlusion state.
[0045] Step 103 : When the detection result indicates that the camera is currently in an occlusion state, determine a first ratio between the number of pixels corresponding to each pixel value in the image and the total number of pixels contained in the image.
[0046] In the present disclosure, when the detection result indicates that the camera is currently in an occlusion state, in order to further determine whether the camera is currently in an occlusion state and avoid false positives from the detection model, the ratio of the number of pixels corresponding to each pixel value to the total number of pixels in the first image, i.e., the first ratio, can be calculated. The formula for calculating the first ratio F is: Where p in the formula is any pixel value.
[0047] Step 104: Determine whether the camera is currently in an obstructed state based on the first ratio.
[0048] In the present disclosure, after determining the first ratio corresponding to each pixel value in the image, it can be determined based on the first ratio whether the camera is currently in an obstruction state.
[0049] In the embodiment of the present disclosure, after obtaining the first image currently captured by the camera, the first image is first input into a pre-generated detection model to obtain the detection result output by the detection model. If the detection result indicates that the camera is currently in an occlusion state, a first ratio between the number of pixels corresponding to each pixel value in the image and the total number of pixels contained in the image is determined, and then, based on the first ratio, whether the camera is currently in an occlusion state is determined. Thus, if the detection result of the image obtained by the detection model indicates that the camera is currently in an occlusion state, whether the camera is currently in an occlusion state is determined based on the ratio of the number of pixels corresponding to each pixel value in the image to the total number of pixels in the image, thereby improving the accuracy and reliability of the camera occlusion detection method.
[0050] Figure 3 A flow chart of a camera occlusion detection method provided by an embodiment of the present disclosure is shown as follows: Figure 3 As shown, the camera occlusion detection method may include the following steps:
[0051] Step 301: Acquire a first image currently captured by a camera.
[0052] Step 302: Input the first image into a pre-generated detection model to obtain a detection result output by the detection model.
[0053] Step 303 : When the detection result indicates that the camera is currently in an occlusion state, determine a first ratio between the number of pixels corresponding to each pixel value in the image and the total number of pixels contained in the image.
[0054] The specific implementation of steps 301 to 303 can refer to the detailed description of other embodiments of the present disclosure and will not be repeated here.
[0055] Step 304: When at least one first ratio is greater than a first ratio threshold, determine that the camera is currently in an obstruction state.
[0056] The first ratio threshold is a critical value of the first ratio used to determine whether the camera is currently in an obstruction state, which can be pre-set. For example, the first ratio threshold can be any ratio threshold such as 40%, 37%, 34%, etc., and this disclosure does not limit this.
[0057] In the present disclosure, after determining the first ratios of pixel values in an image, the current state of the camera can be determined based on the relationship between the first ratios and a first ratio threshold. If at least one first ratio is greater than the first ratio threshold, it can be assumed that a large number of pixels in the first image correspond to the pixel values having the at least one first ratio greater than the first ratio threshold. In this case, it can be determined that the camera is currently in an obstructed state.
[0058] In the embodiment of the present disclosure, after obtaining the first image currently captured by the camera, the first image is first input into a pre-generated detection model to obtain the detection result output by the detection model. When the detection result indicates that the camera is currently in an occlusion state, the first ratio between the number of pixels corresponding to each pixel value in the image and the total number of pixels contained in the image is determined. When at least one of the first ratios is greater than a first ratio threshold, it is determined that the camera is currently in an occlusion state. Thus, by determining whether the camera is currently in an occlusion state based on the relationship between the first ratios of the determined pixel values and the first ratio threshold, and when at least one of the first ratios is greater than the first ratio threshold, it is determined that the camera is currently in an occlusion state, thereby improving the accuracy of the camera occlusion detection method.
[0059] Figure 4 A flow chart of a camera occlusion detection method provided by an embodiment of the present disclosure; Figure 4 As shown, the camera occlusion detection method may include the following steps:
[0060] Step 401: Acquire a first image currently captured by a camera.
[0061] Step 402: Input the first image into a pre-generated detection model to obtain a detection result output by the detection model.
[0062] Step 403 : When the detection result indicates that the camera is currently in an occlusion state, determine a first ratio between the number of pixels corresponding to each pixel value in the image and the total number of pixels in the image.
[0063] The specific implementation of steps 401 to 403 can refer to the detailed description of other embodiments of the present disclosure and will not be repeated here.
[0064] Step 404 : When each first ratio is less than or equal to the first ratio threshold, it is determined that the camera is currently in an unobstructed state.
[0065] In the present disclosure, when each first ratio is less than or equal to the first ratio threshold, it can be considered that the number of pixel points corresponding to each pixel value in the first image is small. At this time, it can be determined that the camera is currently in an unobstructed state.
[0066] In the embodiment of the present disclosure, after obtaining the first image currently captured by the camera, the first image is first input into a pre-generated detection model to obtain the detection result output by the detection model. When the detection result indicates that the camera is currently in an occluded state, the first ratio between the number of pixels corresponding to each pixel value in the image and the total number of pixels contained in the image is determined. When each first ratio is less than or equal to a first ratio threshold, it is determined that the camera is currently in an unobstructed state. Thus, by determining whether the camera is currently in an occluded state based on the relationship between the first ratio of each pixel value and the first ratio threshold, when the first ratio corresponding to each pixel value is less than the first ratio threshold, it is determined that the camera is currently in an unobstructed state, thereby improving the accuracy of the camera occlusion detection method.
[0067] Figure 5 A flow chart of a camera occlusion detection method provided by an embodiment of the present disclosure; Figure 5 As shown, the camera occlusion detection method may include the following steps:
[0068] Step 501: Acquire a first image currently captured by a camera.
[0069] Step 502: Input the first image into a pre-generated detection model to obtain a detection result output by the detection model.
[0070] Step 503 : When the detection result indicates that the camera is currently in an occlusion state, determine a first ratio between the number of pixels corresponding to each pixel value in the image and the total number of pixels in the image.
[0071] The specific implementation of steps 501 to 503 can refer to the detailed description of other embodiments of the present disclosure and will not be repeated here.
[0072] Step 504 : When a first ratio is greater than a first ratio threshold, the pixel value of a pixel point corresponding to the first ratio is set to a first pixel value, and the pixel values of other pixels are set to a second pixel value to obtain a second image.
[0073] The first pixel value may be a larger pixel value in the binarization process of the first image, which may be preset. For example, the first pixel value may be 255, 254, etc., which is not limited in the present disclosure.
[0074] The second pixel value may be a smaller pixel value in the process of binarization of the image, which may be preset. For example, the second pixel value may be 0, 3, etc., which is not limited in the present disclosure.
[0075] It should be noted that the second pixel value is smaller than the first pixel value.
[0076] The second image is an image obtained by binarizing the first image.
[0077] In the present disclosure, when a first ratio is greater than a first ratio threshold, in order to avoid the situation where the detection model falsely reports that a camera that is currently in an unobstructed state is in an obstructed state, and to improve the accuracy of camera obstruction detection, the first image can be binarized, and the pixel value of any pixel point in the first image whose first ratio is greater than the first ratio threshold is set to the first pixel value, such as 255, and the pixel values of other pixel points are set to the second pixel value, such as 0, that is, Wherein, p is the pixel value of any pixel point corresponding to which the first ratio is greater than the first ratio threshold. Figure 6 As shown, Figure 6 This is a schematic diagram of an image before and after binarization processing provided by an embodiment of the present disclosure, wherein: Figure 6 a is the first image, Figure 6 b is a second image obtained by binarizing the first image.
[0078] Step 505: dilate, erode, and perform connected domain processing on the second image to obtain a third image.
[0079] It should be noted that when performing dilation and erosion processing on the second image, the size of the convolution kernel used can be determined during the model training phase. For example, the size of the convolution kernel can be 3×3, 5×5, 7×7, etc., and this disclosure does not limit this.
[0080] It should be noted that, when performing connected domain processing on the second image, in order to connect regions of pixel points corresponding to the same pixel value, an 8-connected operation may be selected for processing, and this disclosure does not limit this.
[0081] In the present disclosure, after obtaining the second image, the second image is firstly dilated and eroded to remove the smaller areas and outlier pixels in the second image, and fill some of the hole areas in the second image. Then, the second image after dilation and erosion is processed and connected domain processing is performed to connect the areas of pixels corresponding to the same pixel value in the image, such as Figure 7 As shown, Figure 7 This is a schematic diagram of the results of image expansion, erosion, and connected domain processing provided by an embodiment of the present disclosure, wherein: Figure 7 a is the second image, Figure 7 b is a schematic diagram of the dilation result after the image is dilated. Figure 7 c is a schematic diagram of the corrosion result after the image is corroded. Figure 7 d is a schematic diagram of the connected domain result after the image is processed, that is, the third image.
[0082] Step 506 : Determine a second ratio of an area occupied by a pixel corresponding to the first pixel value in the third image to an area of the third image.
[0083] In the present disclosure, after obtaining the third image, the area occupied by the pixel points corresponding to the first pixel value in the third image is connected. At this time, the second ratio of the area occupied by the pixel points corresponding to the first pixel value to the area of the third image can be calculated.
[0084] Step 507: When the second ratio is greater than the second ratio threshold, it is determined that the camera is currently in an obstructed state.
[0085] The second ratio threshold is a critical value of the second ratio used to determine whether the camera is currently in an obstruction state. It can be pre-set and can be the same as the first ratio threshold, or it can be different from the first ratio threshold. For example, the second ratio threshold can be 30%, 35%, 40%, etc., which is not limited in this disclosure.
[0086] In the present disclosure, when the second ratio is greater than the second ratio threshold, it can be considered that the area occupied by the pixel points corresponding to the first pixel value in the third image is larger. At this time, it can be determined that the camera is currently in an occlusion state.
[0087] It should be noted that when the second ratio is less than or equal to the second ratio threshold, it can be considered that the area occupied by the pixel points corresponding to the first pixel value in the third image is small. At this time, it can be determined that the camera is currently in an unobstructed state.
[0088] In an embodiment of the present disclosure, after obtaining the first image currently captured by the camera, the first image is first input into a pre-generated detection model to obtain a detection result output by the detection model. When the detection result indicates that the camera is currently in an occlusion state, a first ratio between the number of pixel points corresponding to each pixel value in the image and the total number of pixel points contained in the image is determined. When a first ratio is greater than a first ratio threshold, the pixel value of a pixel point corresponding to the first ratio is set to a first pixel value, and the pixel values of other pixel points are set to a second pixel value to obtain a second image. The second image is then dilated, eroded, and connected domain processed to obtain a third image. Thereafter, a second ratio of the area occupied by the pixel points corresponding to the first pixel value in the third image to the area of the third image is determined. When the second ratio is greater than the second ratio threshold, it is determined that the camera is currently in an occlusion state. Therefore, by dilating, corroding and connecting domain processing the second image based on the binarized second image, a third image is obtained, and the ratio between the area occupied by the pixel points corresponding to the first pixel value in the third image and the area of the third image is determined. Based on the relationship between the ratio and the proportional threshold, it is determined whether the camera is currently in an occlusion state, thereby further improving the accuracy of the camera occlusion detection method and reducing the false alarm of the camera occlusion detection.
[0089] Figure 8 A flow chart of a camera occlusion detection method provided by an embodiment of the present disclosure; Figure 8 As shown, the camera occlusion detection method may include the following steps:
[0090] Step 801: Acquire a first image currently captured by a camera.
[0091] Step 802: Input the first image into a pre-generated detection model to obtain a detection result output by the detection model.
[0092] Step 803 : When the detection result indicates that the camera is currently in an occlusion state, determine a first ratio between the number of pixels corresponding to each pixel value in the image and the total number of pixels contained in the image.
[0093] The specific implementation of steps 801 to 803 can refer to the detailed description of other embodiments of the present disclosure and will not be repeated here.
[0094] Step 804, when multiple first ratios are all greater than the first ratio threshold, the pixel values of the pixel points corresponding to each first ratio in the multiple first ratios are set to different pixel values of the first pixel value group, and the pixel values of other pixel points are set to the second pixel value to obtain a fourth image.
[0095] The first pixel value group may be pre-set, for example, the pixel values in the first pixel value group may be 255, 254, 253, etc., which is not limited in the present disclosure.
[0096] The fourth image is an image obtained by processing the first image.
[0097] In the present disclosure, when multiple first ratios are all greater than the first ratio threshold, the pixel values of the pixel points corresponding to each first ratio in the multiple first ratios are set to different pixel values of the first pixel value group, thereby improving the reliability of the occlusion detection method.
[0098] Step 805 : Perform dilation, erosion, and connected domain processing on the fourth image to obtain a fifth image.
[0099] In the present disclosure, after obtaining the fourth image, dilation, erosion and connected domain processing may be performed on the fourth image to obtain the fifth image.
[0100] Step 806 : Determine a third ratio of the area occupied by the pixels corresponding to the different pixel values in the first pixel value group in the fifth image to the area of the fifth image.
[0101] In the present disclosure, after obtaining the fifth image, third ratios of the areas occupied by pixel points corresponding to different pixel values in the first pixel value group to the area of the fifth image may be determined respectively.
[0102] Step 807: When at least one third ratio is greater than the second ratio threshold, determine that the camera is currently in an obstruction state.
[0103] In the present disclosure, when at least one third ratio is greater than the second ratio threshold, it can be considered that the pixel points corresponding to the at least one pixel value in the first pixel group occupy a larger area. At this time, it can be determined that the camera is currently in an occlusion state.
[0104] In an embodiment of the present disclosure, after obtaining the first image currently captured by the camera, the first image is input into a pre-generated detection model to obtain a detection result output by the detection model. When the detection result indicates that the camera is currently in an occlusion state, a first ratio between the number of pixel points corresponding to each pixel value in the image and the total number of pixel points contained in the image is determined. When multiple first ratios are all greater than a first ratio threshold, the pixel value of the pixel point corresponding to each first ratio in the multiple first ratios is set to a different pixel value of the first pixel value group, and the pixel values of other pixel points are set to the second pixel value to obtain a fourth image. The fourth image is then dilated, eroded, and connected domain processed to obtain a fifth image. Thereafter, a third ratio of the area occupied by pixel points corresponding to different pixel values in the first pixel value group in the fifth image to the area of the fifth image is determined. When at least one third ratio is greater than the second ratio threshold, it is determined that the camera is currently in an occlusion state. Therefore, by setting pixel values whose first ratios are all greater than the first ratio threshold as different pixel values in the first pixel value group, and determining other pixel values as second pixel values, the obtained image is dilated, eroded and connected domain processed, the ratio between the area occupied by the pixel points corresponding to each pixel value in the first pixel value group in the processed image and the image area is determined, and based on the relationship between the ratio and the ratio threshold, the current state of the camera is determined, thereby further improving the accuracy and reliability of the camera detection method.
[0105] Figure 9 A flow chart of a camera occlusion detection method provided by an embodiment of the present disclosure; Figure 9 As shown, the camera occlusion detection method may include the following steps:
[0106] Step 901: Acquire a first image currently captured by a camera.
[0107] Step 902: Input the first image into a pre-generated detection model to obtain a detection result output by the detection model.
[0108] Step 903 : When the detection result indicates that the camera is currently in an occlusion state, determine a first ratio between the number of pixels corresponding to each pixel value in the image and the total number of pixels contained in the image.
[0109] Step 904, when multiple first ratios are all greater than the first ratio threshold, the pixel values of the pixel points corresponding to each first ratio in the multiple first ratios are set to different pixel values of the first pixel value group, and the pixel values of other pixel points are set to the second pixel value to obtain a fourth image.
[0110] Step 905 : Perform dilation, erosion, and connected domain processing on the fourth image to obtain a fifth image.
[0111] Step 906 : Determine a third ratio of the area occupied by the pixels corresponding to the different pixel values in the first pixel value group in the fifth image to the area of the fifth image.
[0112] The specific implementation of steps 901 to 906 can refer to the detailed description of other embodiments of the present disclosure and will not be repeated here.
[0113] Step 907 : When each third ratio is smaller than the second ratio threshold, determine the sum of the plurality of third ratios.
[0114] In the present disclosure, when each third ratio is less than the second ratio threshold, in order to further determine whether the camera is currently in an obstruction state and reduce the possibility of false alarms, the sum of multiple third ratios can be determined first.
[0115] Step 908 : If the sum of the multiple third ratios is greater than the third ratio threshold, and each third ratio is greater than the fourth ratio threshold, it is determined that the camera is currently in an obstructed state.
[0116] The third ratio threshold is a critical value of the sum of the third ratios used to determine whether the camera is currently in an obstruction state. The third ratio threshold may be preset and may be the same as or different from the second ratio threshold. For example, the third ratio threshold may be 30%, 35%, 37%, 41%, etc., and this disclosure does not limit this.
[0117] The fourth ratio threshold is a critical value of the third ratio used to determine whether the camera is currently in an obstruction state. It can be pre-set and is not limited in this disclosure. For example, the fourth ratio threshold can be 10%, 13%, 17%, etc., and is not limited in this disclosure.
[0118] In the present disclosure, when the sum of multiple third ratios is greater than the third ratio threshold and each third ratio is greater than the fourth ratio threshold, it can be considered that the total area occupied by the pixel points corresponding to the pixel values belonging to these multiple third ratios in the fifth image is larger. At this time, it can be determined that the camera is currently in an occlusion state.
[0119] In an embodiment of the present disclosure, after obtaining a first image currently captured by a camera, the first image is first input into a pre-generated detection model to obtain a detection result output by the detection model. If the detection result indicates that the camera is currently in an occlusion state, a first ratio between the number of pixels corresponding to each pixel value in the image and the total number of pixels contained in the image is determined. If multiple first ratios are all greater than a first ratio threshold, the pixel value of the pixel corresponding to each of the multiple first ratios is set to a different pixel value in the first pixel value group, and the pixel values of the other pixels are set to the second pixel value to obtain a fourth image. The fourth image is then dilated, eroded, and subjected to connected domain processing to obtain a fifth image. Then, a third ratio between the area occupied by pixels corresponding to different pixel values in the first pixel value group and the area of the fifth image in the fifth image is determined. If each third ratio is less than the second ratio threshold, a sum of multiple third ratios is determined. If the sum of the multiple third ratios is greater than the third ratio threshold and each third ratio is greater than the fourth ratio threshold, it is determined that the camera is currently in an occlusion state. Therefore, by setting pixel values whose first ratios are all greater than the first ratio threshold as different pixel values in the first pixel value group, and determining other pixel values as second pixel values, the obtained image is dilated, eroded and connected domain processed, and the ratio between each pixel value in the first pixel value group and the image area in the processed image is determined, when each ratio is less than the second ratio threshold, based on the relationship between the sum of the multiple ratios and the third ratio threshold, and the relationship between each ratio and the fourth ratio threshold, it is determined whether the camera is currently in an occlusion state, thereby further improving the accuracy of the camera detection method.
[0120] In order to implement the above embodiments, the present disclosure also proposes a camera occlusion detection device.
[0121] Figure 10 This is a structural diagram of a camera occlusion detection device provided in an embodiment of the present disclosure.
[0122] like Figure 10 As shown, the camera occlusion detection device 1000 may include: a first acquisition module 1001 , a second acquisition module 1002 , a first determination module 1003 , and a second determination module 1004 .
[0123] A first acquisition module 1001 is used to acquire a first image currently captured by a camera;
[0124] The second acquisition module 1002 is configured to input the first image into a pre-generated detection model and obtain a detection result output by the detection model;
[0125] A first determining module 1003 is configured to determine a first ratio between the number of pixels corresponding to each pixel value in the image and the total number of pixels in the image when the detection result indicates that the camera is currently in an occlusion state;
[0126] The second determining module 1004 is configured to determine whether the camera is currently in an obstructed state according to the first ratio.
[0127] Optionally, the second determining module 1004 is specifically configured to:
[0128] When at least one first ratio is greater than a first ratio threshold, determining that the camera is currently in an obstructed state; or
[0129] When each first ratio is less than or equal to the first ratio threshold, it is determined that the camera is currently in an unobstructed state.
[0130] Optionally, the second determining module 1004 is specifically configured to:
[0131] When a first ratio is greater than a first ratio threshold, setting a pixel value of a pixel point corresponding to the first ratio to a first pixel value, and setting pixel values of other pixels to a second pixel value, so as to obtain a second image;
[0132] Performing dilation, erosion and connected domain processing on the second image to obtain a third image;
[0133] determining a second ratio of an area occupied by a pixel corresponding to the first pixel value in the third image to an area of the third image;
[0134] When the second ratio is greater than the second ratio threshold, it is determined that the camera is currently in an obstructed state.
[0135] Optionally, the second determining module 1004 is specifically configured to:
[0136] When all of the first ratios are greater than the first ratio threshold, setting the pixel value of a pixel point corresponding to each of the first ratios to a different pixel value of the first pixel value group, and setting the pixel values of the other pixel points to the second pixel value, so as to obtain a fourth image;
[0137] Performing dilation, erosion, and connected domain processing on the fourth image to obtain a fifth image;
[0138] determining, in the fifth image, a third ratio of areas occupied by pixels corresponding to different pixel values in the first pixel value group to an area of the fifth image;
[0139] When at least one third ratio is greater than the second ratio threshold, it is determined that the camera is currently in an obstruction state.
[0140] Optionally, after determining the third ratio of the areas occupied by pixel points corresponding to different pixel values in the first pixel value group in the fifth image to the area of the fifth image, the second determining module 1004 is further configured to:
[0141] determining a sum of the plurality of third ratios when each third ratio is less than the second ratio threshold;
[0142] When the sum of the multiple third ratios is greater than the third ratio threshold, and each third ratio is greater than the fourth ratio threshold, it is determined that the camera is currently in an obstructed state.
[0143] The functions and specific implementation principles of the above modules in the embodiments of the present disclosure can be referred to the above method embodiments and will not be repeated here.
[0144] The camera occlusion detection device of the disclosed embodiment, after acquiring the first image currently captured by the camera, first inputs the first image into a pre-generated detection model, obtains the detection result output by the detection model, and, if the detection result indicates that the camera is currently in an occlusion state, determines a first ratio between the number of pixels corresponding to each pixel value in the image and the total number of pixels contained in the image, and then determines whether the camera is currently in an occlusion state based on the first ratio. Thus, if the detection result of the image acquired by the detection model indicates that the camera is currently in an occlusion state, the camera is determined to be currently in an occlusion state based on the ratio of the number of pixels corresponding to each pixel value in the image to the total number of pixels in the image, thereby improving the accuracy and reliability of the camera occlusion detection method.
[0145] In order to implement the above embodiments, the present disclosure also proposes an electronic device, including: a memory, a processor, and a computer program stored in the memory and runnable on the processor. When the processor executes the program, it implements the camera occlusion detection method proposed in the above embodiments of the present disclosure.
[0146] In order to implement the above embodiments, the present disclosure further proposes a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the camera occlusion detection method proposed in the above embodiments of the present disclosure is implemented.
[0147] Figure 11 A block diagram of an exemplary electronic device suitable for implementing embodiments of the present disclosure is shown. Figure 11 The electronic device 12 shown is only an example and should not limit the functionality and scope of use of the embodiments of the present disclosure.
[0148] like Figure 11As shown, electronic device 12 is implemented as a general-purpose computing device. Components of electronic device 12 may include, but are not limited to, one or more processors or processing units 16, system memory 28, and a bus 18 that connects various system components (including system memory 28 and processing unit 16).
[0149] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. Examples of such architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnection (PCI) bus.
[0150] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0151] The memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be configured to read and write non-removable, non-volatile magnetic media ( Figure 11 Not shown, often called a "hard drive"). Although Figure 11Although not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a Compact Disc Read Only Memory (hereinafter referred to as: CD-ROM), a Digital Video Disc Read Only Memory (hereinafter referred to as: DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the various embodiments of the present disclosure.
[0152] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may include an implementation of a network environment. Program modules 42 generally implement the functions and / or methods of the embodiments described herein.
[0153] The electronic device 12 can also communicate with one or more external devices 14 (e.g., a keyboard, pointing device, display 24, etc.), one or more devices that enable a user to interact with the electronic device 12, and / or any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). This communication can occur via an input / output (I / O) interface 22. Furthermore, the electronic device 12 can communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 via the bus 18. It should be understood that, although not shown, other hardware and / or software modules can be used in conjunction with the electronic device 12, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0154] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing the methods mentioned in the above embodiments.
[0155] The technical solution disclosed herein, after obtaining the first image currently captured by the camera, first inputs the first image into a pre-generated detection model, obtains the detection result output by the detection model, and, if the detection result indicates that the camera is currently in an occlusion state, determines a first ratio between the number of pixels corresponding to each pixel value in the image and the total number of pixels contained in the image, and then determines whether the camera is currently in an occlusion state based on the first ratio. Thus, if the detection result of the image obtained by the detection model indicates that the camera is currently in an occlusion state, the ratio of the number of pixels corresponding to each pixel value in the image to the total number of pixels in the image is used to determine whether the camera is currently in an occlusion state, thereby improving the accuracy and reliability of the camera occlusion detection method.
[0156] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification and features of different embodiments or examples, unless they are mutually inconsistent.
[0157] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features being referred to. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. Throughout the present disclosure, "plurality" means at least two, such as two, three, etc., unless otherwise specifically defined.
[0158] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present disclosure includes additional implementations in which functions may be performed out of the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present disclosure belong.
[0159] The logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing the logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (e.g., a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device). For purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection with one or more wires (electronic devices), a portable computer disk cartridge (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and programmable read-only memory (EPROM or flash memory), fiber optic devices, and a portable compact disc read-only memory (CDROM). Furthermore, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing it in another suitable manner if necessary, and then storing it in a computer memory.
[0160] It should be understood that various parts of the present disclosure can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented using hardware, as in another embodiment, any one of the following technologies known in the art or a combination thereof can be used to implement: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application-specific integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0161] Those skilled in the art will understand that all or part of the steps in the method of the above embodiment can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiment.
[0162] In addition, the functional units in the various embodiments of the present disclosure may be integrated into a single processing module, or each unit may exist physically separately, or two or more units may be integrated into a single module. The aforementioned integrated modules may be implemented in the form of hardware or in the form of software functional modules. If the integrated modules are implemented in the form of software functional modules and sold or used as independent products, they may also be stored in a computer-readable storage medium.
[0163] The storage medium mentioned above may be a read-only memory, a magnetic disk, or an optical disk, etc. Although the embodiments of the present disclosure have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present disclosure. A person of ordinary skill in the art may make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present disclosure.
Claims
1. A camera occlusion detection method, characterized in that: include: Get the first image currently captured by the camera; Inputting the first image into a pre-generated detection model to obtain a detection result output by the detection model; When the detection result indicates that the camera is currently in an occlusion state, determining a first ratio between the number of pixels corresponding to each pixel value in the image and the total number of pixels contained in the image; Determine whether the camera is currently in an obstructed state according to the first ratio.
2. The method according to claim 1, wherein The determining, based on the first ratio, whether the camera is currently in an obstructed state includes: When at least one first ratio is greater than a first ratio threshold, determining that the camera is currently in an obstructed state; or When each of the first ratios is less than or equal to a first ratio threshold, it is determined that the camera is currently in an unobstructed state.
3. The method according to claim 1, wherein The determining, based on the first ratio, whether the camera is currently in an obstructed state includes: When a first ratio is greater than a first ratio threshold, setting a pixel value of a pixel point corresponding to the first ratio to a first pixel value, and setting pixel values of other pixel points to a second pixel value, so as to obtain a second image; Performing dilation, erosion, and connected domain processing on the second image to obtain a third image; determining, in the third image, a second ratio of an area occupied by a pixel corresponding to the first pixel value to an area of the third image; When the second ratio is greater than a second ratio threshold, it is determined that the camera is currently in an obstructed state.
4. The method according to claim 1, wherein The determining, based on the first ratio, whether the camera is currently in an obstructed state includes: When all of the first ratios are greater than the first ratio threshold, setting the pixel value of a pixel point corresponding to each of the first ratios to a different pixel value of the first pixel value group, and setting the pixel values of the other pixel points to the second pixel value, so as to obtain a fourth image; Performing dilation, erosion, and connected domain processing on the fourth image to obtain a fifth image; determining, in the fifth image, a third ratio of areas occupied by pixels corresponding to different pixel values in the first pixel value group to an area of the fifth image; When at least one third ratio is greater than the second ratio threshold, it is determined that the camera is currently in an obstruction state.
5. The method according to claim 4, wherein After determining, in the fifth image, a third ratio of areas occupied by pixels corresponding to different pixel values in the first pixel value group to an area of the fifth image, the method further includes: determining a sum of the plurality of third ratios when each of the third ratios is less than a second ratio threshold; When the sum of the plurality of third ratios is greater than the third ratio threshold, and each of the third ratios is greater than a fourth ratio threshold, it is determined that the camera is currently in an obstructed state.
6. A camera occlusion detection device, characterized in that: The device comprises: A first acquisition module is used to acquire a first image currently captured by the camera; a second acquisition module, configured to input the first image into a pre-generated detection model and obtain a detection result output by the detection model; a first determining module, configured to determine, when the detection result indicates that the camera is currently in an occlusion state, a first ratio between the number of pixels corresponding to each pixel value in the image and the total number of pixels contained in the image; The second determining module is configured to determine whether the camera is currently in an obstructed state according to the first ratio.
7. The device according to claim 6, characterized in that The second determining module is specifically configured to: When at least one first ratio is greater than a first ratio threshold, determining that the camera is currently in an obstructed state; or When each of the first ratios is less than or equal to a first ratio threshold, it is determined that the camera is currently in an unobstructed state.
8. The device according to claim 6, wherein The second determining module is specifically configured to: When a first ratio is greater than a first ratio threshold, setting a pixel value of a pixel point corresponding to the first ratio to a first pixel value, and setting pixel values of other pixel points to a second pixel value, so as to obtain a second image; Performing dilation, erosion, and connected domain processing on the second image to obtain a third image; determining, in the third image, a second ratio of an area occupied by a pixel corresponding to the first pixel value to an area of the third image; When the second ratio is greater than a second ratio threshold, it is determined that the camera is currently in an obstructed state.
9. The device according to claim 6, wherein The second determining module is specifically configured to: When all of the first ratios are greater than the first ratio threshold, setting the pixel value of a pixel point corresponding to each of the first ratios to a different pixel value of the first pixel value group, and setting the pixel values of the other pixel points to the second pixel value, so as to obtain a fourth image; Performing dilation, erosion, and connected domain processing on the fourth image to obtain a fifth image; determining, in the fifth image, a third ratio of areas occupied by pixels corresponding to different pixel values in the first pixel value group to an area of the fifth image; When at least one third ratio is greater than the second ratio threshold, it is determined that the camera is currently in an obstruction state.
10. The device according to claim 9, wherein After determining, in the fifth image, a third ratio of areas occupied by pixels corresponding to different pixel values in the first pixel value group to an area of the fifth image, the second determining module is further configured to: determining a sum of the plurality of third ratios when each of the third ratios is less than a second ratio threshold; When the sum of the plurality of third ratios is greater than the third ratio threshold, and each of the third ratios is greater than a fourth ratio threshold, it is determined that the camera is currently in an obstructed state.
11. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the program, the method for detecting camera occlusion as described in any one of claims 1 to 5 is implemented.
12. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the camera occlusion detection method as described in any one of claims 1 to 5 is implemented.