CN111882540B - Stain detection method, device and equipment for camera protection cover - Google Patents
Stain detection method, device and equipment for camera protection cover Download PDFInfo
- Publication number
- CN111882540B CN111882540B CN202010740286.2A CN202010740286A CN111882540B CN 111882540 B CN111882540 B CN 111882540B CN 202010740286 A CN202010740286 A CN 202010740286A CN 111882540 B CN111882540 B CN 111882540B
- Authority
- CN
- China
- Prior art keywords
- stain
- pixel point
- gray
- pixel
- pixels
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/0002—Inspection of images, e.g. flaw detection
- G06T7/0004—Industrial image inspection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/60—Analysis of geometric attributes
- G06T7/62—Analysis of geometric attributes of area, perimeter, diameter or volume
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N23/00—Cameras or camera modules comprising electronic image sensors; Control thereof
- H04N23/60—Control of cameras or camera modules
- H04N23/67—Focus control based on electronic image sensor signals
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/30—Subject of image; Context of image processing
- G06T2207/30108—Industrial image inspection
- G06T2207/30164—Workpiece; Machine component
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Computer Vision & Pattern Recognition (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Geometry (AREA)
- Quality & Reliability (AREA)
- Studio Devices (AREA)
Abstract
The application discloses a stain detection method of a camera protective cover, which comprises the steps of adjusting the focal length and aperture of a camera so that the distance from the focal point of the camera to the protective cover is not greater than a preset distance, and the aperture is not less than the preset aperture; acquiring a gray image of the protective cover by using a camera; and identifying the smudge pixel points in the gray level image, and obtaining smudge distribution data on the protective cover. The camera is modulated into the protective cover image with the focus near the protective cover and shot by adopting the large aperture, so that the problem of interference caused by clear imaging of a background object in the shot protective cover image due to transparent color of the protective cover is avoided to a great extent, the accuracy of identifying the stain in the protective cover image is ensured, and the accuracy of the stain detection result of the protective cover is improved. The application also provides a device and equipment for detecting the stain of the camera protective cover, which have the beneficial effects.
Description
Technical Field
The present invention relates to the field of image technologies, and in particular, to a method, an apparatus, and a device for detecting stains on a camera protection cover.
Background
The video monitoring technology is a monitoring technology which is widely applied at present, can be used for traffic violation monitoring, can be used for important financial safety monitoring, and can even be used for safety operation monitoring of construction sites and the like. In video detection equipment to which the video monitoring technology is applied, a camera is one of key equipment, and accuracy of a monitoring result is related between definition of images shot by the camera.
However, the video detection device has various application environments, and if the working environment is severe, the problems of moisture and heavy pollution exist, the service life of the camera can be affected to a certain extent. Therefore, the transparent waterproof shell can be arranged on the camera with a severe working environment, and the camera is protected. However, with the extension of the working time of the camera, the protection shell is inevitably stained with stains, and if the protection shell is not cleaned for a long time, the stains are more and more large, so that the normal working of the camera is affected.
Disclosure of Invention
The invention aims to provide a method, a device and equipment for detecting stains on a camera protective cover, which solve the technical problem that the normal work of a camera is affected by the stains on the protective cover of the camera.
In order to solve the technical problems, the invention provides a stain detection method of a camera protection cover, comprising the following steps:
Adjusting the focal length and the aperture of the camera so that the distance from the focal point of the camera to the protective cover is not greater than a preset distance, and the aperture is not smaller than the preset aperture;
acquiring a gray level image of the protective cover by using the camera;
and identifying the smudge pixel points in the gray level image to obtain smudge distribution data on the protective cover.
Optionally, identifying the stain pixels in the gray scale image, and obtaining the stain distribution data on the protective cover includes:
Identifying a smudge pixel point according to the gray value of the pixel point in the gray image;
judging whether the proportion of the stain pixel points to the total pixel points of the gray level image is larger than a preset proportion, if so, determining that the stains on the protective cover exceed the standard.
Optionally, determining whether the proportion of the stain pixel points to the total pixel points of the gray image is greater than a preset proportion includes:
determining the total number of all the stain pixels in the gray level image according to the identified stain pixels;
and judging whether the ratio of the total number of all the stain pixel points to the total number of the pixel points of the gray image is larger than a first preset ratio.
Optionally, determining whether the proportion of the stain pixel points to the total pixel points of the gray image is greater than a preset proportion includes:
determining the number of pixel points contained in each stain imaging area according to the coordinate values of each stain pixel point;
judging whether the ratio of the number of pixel points of the stain imaging area with the largest area to the total number of pixel points of the gray level image is larger than a second preset ratio.
Optionally, determining the number of pixels included in each stain imaging area according to the coordinate values of the respective stain pixels includes:
obtaining the maximum abscissa, the minimum abscissa, the maximum ordinate and the minimum ordinate of each pixel point in the same stain imaging area formed by a plurality of stain pixel points;
and (3) estimating a formula according to the number of pixels of the stain imaging area: s=k (X1-X2) (Y1-Y2), and estimating the number of pixels in each of the stain imaging areas, where S is the number of pixels, and X1, X2, Y1, and Y2 are the maximum abscissa, the minimum abscissa, the maximum ordinate, and the minimum ordinate of the stain imaging area, respectively, and K is an estimated scaling factor.
Optionally, determining whether the proportion of the stain pixel points to the total pixel points of the gray image is greater than a preset proportion includes:
Judging whether the ratio of the total number of all the stain pixels to the total number of the pixels of the gray image is larger than a first preset proportion, and/or the ratio of the number of the pixels of the stain imaging area with the largest area to the total number of the pixels of the gray image is larger than a second preset proportion; wherein the first preset proportion is greater than the second preset proportion.
Optionally, identifying the smudge pixel point in the gray scale image includes:
Obtaining the absolute value of the gray difference between adjacent pixel points according to the gray value of each pixel point in the gray image;
Marking the pixel point with the largest gray value in two adjacent pixel points with the gray difference absolute value larger than a preset difference threshold as a stain edge pixel point in the stain pixel points;
identifying expected stain pixel points with gray values larger than a preset gray value in all pixel points of the gray image;
Marking expected stain pixels communicated with the stain edge pixels as stain inner pixels in the stain pixels; the expected stain pixel point communicated with the stain edge pixel point is the expected stain pixel point directly adjacent to the stain edge pixel point or the expected stain pixel point adjacent to the stain edge pixel point through the same expected stain pixel point area; the expected stain pixel point area is a pixel area formed by one or more sequentially adjacent expected stain pixel points.
Optionally, identifying the smudge pixel point in the gray scale image includes:
Taking any pixel point in the gray level image as a current pixel point, judging whether the gray level value of the current pixel point is larger than a preset gray level value, and if so, marking the current pixel point as an expected stain pixel point;
obtaining the gray difference absolute values of the current pixel point and each adjacent pixel point;
judging whether the gray difference absolute value larger than a preset difference threshold exists in the gray difference absolute values, if so, selecting the pixel point with the largest gray value in the adjacent pixel points corresponding to the gray difference absolute value larger than the preset difference threshold and the current pixel point as a stain edge pixel point;
Sequentially taking each adjacent pixel point of the current pixel point as a new current pixel point, and repeatedly executing the operation step of judging whether the gray value of the current pixel point is larger than a preset gray value or not until all pixel points in the gray image are identified to be the expected stain pixel point and the stain edge pixel point;
and identifying and marking the pixel points inside the stains in each expected stain pixel point one by taking any expected stain pixel point adjacent to the stain edge pixel point in the gray level image as a starting point pixel point.
The application also provides a stain detection device of the camera protective cover, which comprises:
The adjusting module is used for adjusting the focal length and the aperture of the camera so that the distance between the focal point of the camera and the protective cover is not greater than a preset distance, and the aperture is not less than the preset aperture;
The acquisition module is used for acquiring a gray image of the protective cover by using the camera;
the identification module is used for identifying the stain pixel points in the gray level image;
The judging module is used for judging whether the proportion of the stain pixel points to the total pixel points of the gray level image is larger than a preset proportion, and if so, an alarm prompt is sent out.
The application also provides a stain detection device of the camera protective cover, which comprises:
a memory for storing a computer program;
A processor for implementing the steps of the method for detecting stains of a camera boot according to any one of the above when executing the computer program.
According to the stain detection method for the camera protective cover, provided by the invention, the camera can be used for shooting an image of the protective cover by utilizing the camera self-shooting function, and stains on the image corresponding to the protective cover are identified in an image identification mode, so that the data of the stain distribution condition on the protective cover are determined, and an effective theoretical basis is provided for determining whether the protective cover needs to be cleaned or not by a worker; meanwhile, when the camera is used for shooting an image of the protective cover, in order to solve the problem that the protective cover is transparent and the background object is interfered, the camera is modulated to be in the vicinity of the protective cover, and the aperture of the camera is adjusted to be a large aperture, so that a blurred picture is formed by the background object in the shot protective cover image, interference caused by the transparent protective cover is avoided to a great extent, the accuracy of identifying the stain in the protective cover image is ensured, and the accuracy of the stain detection result of the protective cover is improved.
The application also provides a device and equipment for detecting the stain of the camera protective cover, which have the beneficial effects.
Drawings
For a clearer description of embodiments of the invention or of the prior art, the drawings that are used in the description of the embodiments or of the prior art will be briefly described, it being apparent that the drawings in the description below are only some embodiments of the invention, and that other drawings can be obtained from them without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart of a method for detecting stains in a camera protection cover according to an embodiment of the present application;
fig. 2 is a schematic flow chart of identifying a smudge pixel point in a gray scale image according to an embodiment of the present application;
FIG. 3 is a schematic view of a gray scale image of a protective cover according to an embodiment of the present application;
FIG. 4 is a flowchart illustrating a process for identifying a smudge pixel in a gray scale image according to another embodiment of the present application;
FIG. 5 is a schematic view of a gray scale image of a protective cover according to another embodiment of the present application;
Fig. 6 is a block diagram of a stain detection device of a camera protection cover according to an embodiment of the present invention;
Fig. 7 is a block diagram of a stain detection device of a camera protection cover according to an embodiment of the present invention.
Detailed Description
The safety cover of camera can protect the camera not disturbed and cause the damage by rainwater, moisture, pollutant etc. in the external environment to a certain extent. The protection cover itself is inevitably stained with stains, and needs to be cleaned frequently. However, if the cleaning cycle is set to clean regularly, the cleaning cycle needs to be set to be shorter, which increases the workload of cleaning the protective cover to a certain extent.
Therefore, the technical scheme for detecting the stains on the protective cover of the camera is provided, and when the condition that the protective cover needs to be cleaned is detected, an alarm can be timely sent out, so that the cleanliness of the protective cover can be ensured, useless cleaning of the protective cover is avoided frequently, and the workload of cleaning the protective cover is reduced on the basis of ensuring that the camera can work normally.
In order to better understand the aspects of the present invention, the present invention will be described in further detail with reference to the accompanying drawings and detailed description. It will be apparent that the described embodiments are only some, but not all, embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
As shown in fig. 1, fig. 1 is a flow chart of a stain detection method for a camera protection cover according to an embodiment of the present application, where the stain detection method may include:
s11: the focal length and the aperture of the camera are adjusted, so that the distance from the focal point of the camera to the protective cover is not greater than a preset distance, and the aperture is not less than the preset aperture.
In the monitoring process, the focal length of the camera is generally set to be relatively large so as to clearly shoot an object picture to be monitored in a distance; the size of the aperture is also selected according to the photographed environment picture.
In this embodiment, the image of the protective cover is captured by using the imaging function of the camera, and the stain condition on the protective cover is determined based on the image recognition technology. However, when the camera performs monitoring operation, the monitoring image needs to be shot through the protective cover, so the protective cover is transparent and colorless in normal times. If the camera directly shoots the image of the protective cover, it is obvious that even if the image formed by the dirt on the protective cover can be shot, the image interference formed by the background object outside the protective cover is difficult to distinguish the dirt from the background object in the image, so that the dirt cannot be accurately identified from the image.
Therefore, when the camera is used for shooting the image of the protective cover, the camera is controlled to focus, and the focus of the camera is adjusted to a position near the protective cover; meanwhile, the aperture of the camera is adjusted to be not smaller than the preset aperture, so that the large aperture shooting of the camera is guaranteed to a certain extent, and the largest aperture of the camera can be directly adopted for shooting.
When the camera shoots an image of the protective cover, background objects outside the protective cover can be subjected to blurring imaging to a certain extent, so that a scene outside the protective cover in the shot image is a blurred shadow image, the problem that the background object imaging interferes with the recognition of the dirt in the image of the protective cover is avoided, and the accuracy of the recognition of the dirt of the protective cover is ensured.
S12: and acquiring a gray level image of the protective cover by using the camera.
S13: and identifying the smudge pixel points in the gray level image, and obtaining smudge distribution data on the protective cover.
It will be appreciated that the stains on the protective cover are typically black or darker in color, and therefore the gray scale values of the pixels in the gray scale image of the protective cover are relatively large. Therefore, when the stain pixel is actually recognized, whether or not it is the stain pixel can be determined according to the gray value size of the pixel.
After the smudge pixel points are determined, the distribution positions of the smudge on the protective cover can be determined, and then whether the smudge condition on the protective cover is serious or not is determined. For example, after the stain pixels are identified, it may be determined whether the proportion of the stain pixels to the total pixels of the gray scale image is greater than a preset proportion, and if so, it is determined that the stain on the protective cover exceeds the standard.
The proportion of the smudge pixel points to the total pixel points of the gray level image is consistent with the proportion of the smudge shielding camera shooting monitoring image, and the condition of the smudge on the protective cover can be judged according to the proportion.
After determining whether the stain on the protective cover is serious or not, a worker can determine whether the protective cover needs to be cleaned according to the stain distribution condition data, if the stain on the protective cover is determined to be too much, namely the stain exceeds the standard, a cleaning alarm prompt can be automatically sent out to determine that the stain on the protective cover is cleaned in time, and the cleaning degree of the protective cover is ensured.
When the stain detection is actually performed on the protective cover of the camera, the image of the protective cover is directly shot by utilizing the shooting function of the camera. It is apparent that the focal length and aperture size of the camera in the working state are not the same as those of the camera in the state of detecting the stain of the protective cover. In order to ensure that the camera can work normally, the camera cannot keep a state of shooting the protective cover image for a long time.
Therefore, in the practical application process, the camera can be set to periodically switch from the working state to the state of detecting the pollution of the protective cover, and after the image shooting of the protective cover is completed, the camera is switched to the working state, so that the periodic detection of the pollution of the protective cover is realized, and the normal monitoring work of the camera can be ensured.
In summary, when the stain condition of the protection cover is detected, the shooting function of the camera is fully utilized to shoot the image of the protection cover, and the shot image is taken as the basis for determining the stain condition of the protection cover, so that the function of the camera is expanded to a certain extent; meanwhile, the focus of the camera when shooting the image of the protective cover is adjusted to be near the protective cover and a large aperture is arranged, so that imaging of objects outside the protective cover is fuzzified, the problem that dirt cannot be accurately identified due to interference of imaging of background objects caused by transparency of the protective cover in the image of the protective cover is avoided, the accuracy of dirt identification in the image of the protective cover is guaranteed, the accuracy of detection results of dirt condition of the protective cover is further guaranteed, and when the dirt condition is serious, the camera alarms in time, and on the basis of guaranteeing dirt cleaning timeliness, the problem of frequently cleaning dirt of the protective cover is avoided, and the workload of cleaning the protective cover is reduced.
Based on the above embodiment, after the identification and judgment as to whether each pixel point in the gray image of the protective cover is a stain pixel point, the process of judging whether the proportion of the stain pixel point to the total pixel points of the gray image is greater than the preset proportion based on the identification and judgment result may include:
determining the total number of all the stain pixels in the gray level image according to the identified stain pixels;
And judging whether the ratio of the total number of all the stain pixels to the total number of the pixels of the gray image is larger than a first preset ratio.
Considering that in the practical application process, if the covered area of the stain pixels on the gray level image is too large, the definition of the image shot by the video monitoring of the camera is inevitably reduced, so that the proportion of the total number of all the stain pixels to the total number of the total pixels of the whole gray level image can be used as the basis for judging whether the protective cover needs to be cleaned.
The size of the preset proportion can be determined according to the requirement on definition in the video monitoring working process of the camera, and the definition requirement is high, so that the preset proportion can be correspondingly set smaller.
Further, considering that in practical application, some fine stain spots may exist on the protective cover, because the area of the stain imaging area is smaller, the sharpness of the monitored image shot by the camera may not be seriously affected, and if only one or two stain spots with relatively large areas appear on the protective cover, the proportion of the stain imaging area formed by the stain spots with large areas in the gray level image to the whole gray level image area is not too large, but the monitoring work of the camera is already affected, so that the situation of cleaning the stains should be considered.
For this reason, in another embodiment of the present application, determining whether the proportion of the stain pixels to the total pixels of the gray image is greater than the preset proportion may specifically include:
determining the number of pixel points contained in each stain imaging area according to the coordinate values of each stain pixel point;
Judging whether the ratio of the number of pixels of the stain imaging area with the largest area to the total number of pixels of the gray level image is larger than a second preset ratio.
Further, in determining the largest stain imaging area, statistical acquisition may be performed in an estimated manner, and the process may include:
Obtaining a maximum abscissa, a minimum abscissa, a maximum ordinate and a minimum ordinate of each pixel point in the same stain imaging area formed by a plurality of stain pixel points;
And (3) estimating a formula according to the number of pixels of the stain imaging area: s=k (X1-X2) (Y1-Y2), the number of pixels in each of the stain imaging areas is estimated, where S is the number of pixels, X1, X2, Y1, Y2 are the maximum abscissa, the minimum abscissa, the maximum ordinate, and the minimum ordinate of each of the stain imaging areas, and K is the estimated scaling factor.
It will be appreciated that one smear imaging area is an imaging area of one smear spot in a gray scale image, and the same smear imaging area is an area covered by sequentially adjacent smear pixel points.
In addition, the estimated proportionality coefficient can be 0.85 or other values, and can be comprehensively set through multiple measurements in practical application, so that the application is not limited.
In summary, in the process of judging the proportion of the dirty pixels to the pixels of the whole gray image, the alarm prompt for cleaning the protection cover may be performed on the condition that the proportion of the total number of the dirty pixels to the total number of the pixels of the gray image exceeds a first preset proportion, or the alarm prompt for cleaning the protection cover may be performed on the condition that the proportion of the number of the pixels of the maximum dirty imaging region to the total number of the pixels of the whole gray image exceeds a second preset proportion. Other determination conditions may be used as long as they can reflect the size of the area in the gray scale image covered by the stain pixels.
Of course, in order to improve the performance of the monitoring work of the camera, after each stain pixel point is identified, two conditions that whether the ratio of the total number of all the stain pixel points to the total number of the gray scale image is larger than a first preset proportion and the ratio of the number of the pixel points in the stain imaging area with the largest area to the total number of the pixel points in the gray scale image is larger than a second preset proportion can be judged. As long as the stain pixel points in the gray level image meet any one of the two conditions, an alarm can be sent out, so that the more comprehensive detection of the stains of the protective cover is realized. In addition, the first preset ratio in the present embodiment should be greater than the second preset ratio.
Based on the above embodiment, in another specific embodiment of the present application, as shown in fig. 2, the process for identifying the stain pixels in the gray-scale image of the protective cover acquired by the camera may include:
S21: and obtaining the absolute value of the gray difference between adjacent pixel points according to the gray value of each pixel point in the gray image.
S22: and marking the pixel point with the largest gray value in the two adjacent pixel points with the gray difference absolute value larger than the preset difference threshold as a stain edge pixel point in the stain pixel points.
After the image of the protective cover is acquired, the image can be adjusted to be an image with a preset pixel size for facilitating subsequent identification and judgment, for example, the image can be adjusted to be an image with a size of 640 x 480; and converting the adjusted image into a gray image, and searching the pixel points with the gray value jump according to the gray values of the pixel points in the gray image.
Because the camera adopts a small focal length and a large aperture when shooting the image of the protective cover, the imaging edge of the background object in the image can be blurred, after the image of the protective cover is converted into a gray image, the gray change of the imaging edge of the background object on the gray image is gradually changed, and the jump of the gray value is relatively small.
The edges of the dirt on the protective cover imaged in the gray level image become sharp, namely the gray level of the dirt imaged edges on the gray level image changes sharply, so that the gray level value of the pixel points of the dirt imaged edges also has larger jump. Therefore, in the embodiment, the stain edge can be identified according to the gray value jump of the pixel point, so that interference caused by imaging of a background object in a gray image is avoided. According to the experimental determination, the edge gray level variation value of the normal stain is greater than 150, and accordingly the preset difference threshold should be set above 150, and the specific value can be adjusted according to the actual situation, which is not particularly limited in this embodiment.
S23: and identifying expected stain pixel points with gray values larger than a preset gray value in all pixel points of the gray image.
It should be noted that, there is no necessary sequence for identifying the expected stain pixels and the stain edge pixels, the expected stain pixels may be identified first, or the stain edge pixels may be identified first, which is not particularly limited in the present application.
Of course, if the gray value of a certain pixel point is larger than the preset gray value and the absolute value of the gray difference value of the adjacent pixel point is larger than the preset difference value threshold, the pixel point is a stain edge pixel point; that is, when the pixel points simultaneously meet the condition that the gray level value is greater than the preset gray level value and the absolute value of the gray level difference value between the pixel points and the adjacent pixel points is greater than the preset difference value threshold value, the pixel points are the pixel points at the edge of the stain.
S24: and marking the expected stain pixel points communicated with the stain edge pixel points as stain inner pixel points in the stain pixel points.
The expected stain pixel point communicated with the stain edge pixel point is an expected stain pixel point directly adjacent to the stain edge pixel point or an expected stain pixel point adjacent to the stain edge pixel point through the same expected stain pixel point area; the expected stain pixel point area is a pixel area formed by one or more sequentially adjacent expected stain pixel points.
In this embodiment, the stain pixels are classified into two types, one is a pixel located at an edge position of the stain imaging area, that is, a stain edge pixel, and the other is a pixel located at an inner middle position of the stain imaging area, that is, a stain inner pixel. After all the stain edge pixels and the stain inner pixels in the gray level image are identified, the identification of all the stain pixels is equivalent.
It will be appreciated that the smear imaging area is formed by the smear inner pixel point and the smear edge pixel point being connected in a sheet, then the smear inner pixel point is necessarily adjacent to the smear edge pixel point or indirectly adjacent to each other through each of the sequentially adjacent smear inner pixel points, that is, the smear inner pixel point and the smear edge pixel point are communicated.
As shown in fig. 3, fig. 3 is a partial schematic diagram of a gray image of a protective cover provided by an embodiment of the present application, where in fig. 3, a pixel point a, a pixel point B, a pixel point C, and a pixel point D all belong to an expected stain internal pixel point whose gray value is greater than a preset gray value, and a pixel point E is a stain edge pixel point; the pixel point D is adjacent to the pixel point E, so the pixel point D is a pixel point in the interior of the stain, and the pixel point A is communicated with the pixel point E through the pixel point B, the pixel point C, the pixel point D and the pixel point E which are sequentially adjacent to each other, so the pixel point A belongs to the pixel point in the interior of the stain.
However, in the region where the background object is imaged in the gray image, there may be some pixels, because the corresponding object is darker, the gray value of the pixel is larger, but there is no connected dirty pixel around the pixel, so the pixel does not belong to the dirty pixel, for example, the pixel F and the pixel G in fig. 2, although the gray values of the pixel F and the pixel G are all larger than the preset gray value, they are not connected to the pixel E and other dirty edge pixels, so it can be determined that the pixel F and the pixel G are not the pixels inside the dirty. And because the gray values of the adjacent pixels of the pixel point F and the pixel point G are gradually changed, the gray difference value between the pixel point F and the adjacent pixels of the pixel point G and the surrounding gray difference value cannot reach the preset difference value threshold value, the possibility that the pixel point F and the pixel point G are the pixels of the stain edge can be eliminated, and therefore interference of background object imaging on stain pixel point identification can be eliminated.
According to the embodiment, the characteristic that the gray value change of the imaging edge of the background object is fuzzy and the gray value change of the imaging edge of the stain is sharp in the gray image of the protective cover is utilized, the stained pixel point in the gray image and the pixel point imaged by the background object with a deeper color are distinguished, interference of the background object on detection of the stain of the protective cover is further eliminated, and accuracy of detection results of the stain of the protective cover is improved.
There may be various recognition sequences for performing the stain pixel point recognition for each pixel point in the gray-scale image of the protective cover. In an alternative embodiment of the present application, as shown in fig. 4, fig. 4 is a schematic flow chart of identifying a stain pixel point in a gray scale image according to another embodiment of the present application, where the identifying process may include:
s31: and selecting any pixel point in the gray level image as the current pixel point.
S32: and judging whether the gray value of the current pixel point is larger than a preset gray value, if so, entering S33, and if not, entering S34.
S33: the current pixel is marked as the expected stain pixel.
S34: and calculating the absolute value of the gray difference between the current pixel point and each adjacent pixel point one by one.
S35: and judging whether the gray difference absolute value greater than a preset difference threshold exists in the gray difference absolute values, if so, entering S36, and if not, entering S37.
S36: and selecting the pixel point with the largest gray value in the adjacent pixel points and the current pixel point corresponding to which the absolute value of the gray difference value is larger than the preset difference value threshold as a stain edge pixel point.
S37: and judging whether all pixel points in the gray level image are identified by expected stain pixel points and stain edge pixel points, if so, entering S39, and if not, entering S38.
S38: and sequentially taking each adjacent pixel point of the current pixel point as a new current pixel point, and entering S32.
S39: and identifying and marking the inside pixel points of the stains in each expected stain pixel point one by taking any expected stain pixel point adjacent to the stain edge pixel point in the gray level image as a starting point pixel point.
Of course, in practical applications, it is not necessary to perform recognition judgment of the pixel points inside the stain on the expected stain pixel points after all the expected stain pixel points and the stain edge pixel points are recognized. For example, after a certain stain edge pixel point is identified, if an expected stain pixel point is identified in the adjacent pixel points, the expected stain pixel point can be marked as a stain inner pixel point in the stain pixel points.
As shown in fig. 5, the initially selected current pixel point is set as a pixel point a0, and after determining whether the pixel point a0 is a stain edge pixel point, the pixel point a1 and the pixel point a2 are sequentially used until the pixel point a8 is the current pixel point to perform identification judgment on whether the stain edge pixel point is the stain edge pixel point. After the pixel points from the pixel point a1 to the pixel point a8 are judged, the pixel points adjacent to the pixel point a1 to the pixel point a8 are further used as the current pixel points to carry out the judgment of whether each pixel point is the dirty pixel point or not, and the judgment of whether each pixel point is the dirty pixel point is realized by the push.
It is to be understood that, for example, when the pixel point a2 is the current pixel point, although the pixel point a0 and the pixel point a1 are both adjacent to the pixel point a2, when the pixel point a0 and the pixel point a1 are the current pixel point, the gray-level difference absolute value operation has been performed with the pixel point a2, and therefore, when the pixel point a2 is the current pixel point, the gray-level difference absolute value operation with the pixel point a0 and the pixel point a1 is not required again. Similarly, when the judgment of the stained pixel point is sequentially performed by taking each pixel point as the current pixel point, the absolute value operation of the gray level difference value is not required to be performed on the adjacent pixel points subjected to the judgment of the stained pixel point.
In addition, for the first pixel point selected for judging the stain pixel point, the first pixel point can be selected at will in the gray level image, the center point in the gray level image can be selected, and the peak pixel point in the gray level image can also be selected, so that the application is not particularly limited.
Further, the identification determination as to whether or not each pixel is a stain pixel is not necessarily the identification determination sequence described above. For example, whether the pixel points are the stain pixel points or not can be judged sequentially from row to row/from column in the gray level image of the protective cover, and the technical scheme of the application can be realized. Other ways of scanning to determine whether each pixel is a smudge pixel can be adopted in the application, and the method is not particularly limited.
The stain detection device of the camera protection cover provided by the embodiment of the invention is introduced below, and the stain detection device of the camera protection cover described below and the stain detection method of the camera protection cover described above can be correspondingly referred to each other.
Fig. 6 is a block diagram of a stain detection device for a camera protection cover according to an embodiment of the present invention, and the stain detection device for a camera protection cover referring to fig. 6 may include:
the adjusting module 100 is configured to adjust a focal length and an aperture of the camera so that a distance from a focal point of the camera to the protective cover is not greater than a preset distance, and the aperture is not less than a preset aperture size;
the acquisition module 200 is used for acquiring a gray image of the protective cover by using the camera;
and the identification module 300 is used for identifying the stain pixel points in the gray level image and obtaining the stain distribution data on the protective cover.
The stain detection device of the camera protection cover of the present embodiment is used to implement the foregoing stain detection method of the camera protection cover, so that the specific embodiments of the stain detection device of the camera protection cover can be seen from the foregoing example portions of the stain detection method of the camera protection cover, for example, the adjusting module 100, the collecting module 200, and the identifying module 300, which are respectively used to implement steps S11 to S13 in the stain detection method of the camera protection cover, so that the specific embodiments thereof may refer to the description of the examples of the respective portions and will not be repeated herein.
The application also provides an embodiment of a stain detection device for a camera protection cover, as shown in fig. 7, fig. 7 is a structural block diagram of the stain detection device for a camera protection cover provided by the embodiment of the application, where the device may include:
a memory 1 for storing a computer program;
a processor 2 for implementing the steps of the method for detecting stains of a camera boot according to any of the embodiments above when executing the computer program.
The processor in this embodiment can execute the computer program stored in the memory, and can realize accurately detecting the stain on the camera protection cover, provide theoretical basis for timely cleaning the protection cover for the staff, expand the function of the camera on the basis that does not influence the normal monitoring work of the camera, and avoid frequent cleaning of the protection cover on the basis of guaranteeing good working performance of the camera.
In addition, the memory 1 may be a Random Access Memory (RAM), a memory, a Read Only Memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements is inherent to. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element. In addition, the parts of the above technical solutions provided in the embodiments of the present application, which are consistent with the implementation principles of the corresponding technical solutions in the prior art, are not described in detail, so that redundant descriptions are avoided.
Claims (9)
1. The method for detecting the stain of the camera protection cover is characterized by comprising the following steps of:
Adjusting the focal length and the aperture of the camera so that the distance from the focal point of the camera to the protective cover is not greater than a preset distance, and the aperture is not smaller than the preset aperture;
acquiring a gray level image of the protective cover by using the camera;
identifying the smudge pixel points in the gray level image, and obtaining smudge distribution data on the protective cover;
Identifying smudge pixels in the grayscale image includes:
Obtaining the absolute value of the gray difference between adjacent pixel points according to the gray value of each pixel point in the gray image;
Marking the pixel point with the largest gray value in two adjacent pixel points with the gray difference absolute value larger than a preset difference threshold as a stain edge pixel point in the stain pixel points;
identifying expected stain pixel points with gray values larger than a preset gray value in all pixel points of the gray image;
Marking expected stain pixels communicated with the stain edge pixels as stain inner pixels in the stain pixels; the expected stain pixel point communicated with the stain edge pixel point is the expected stain pixel point directly adjacent to the stain edge pixel point or the expected stain pixel point adjacent to the stain edge pixel point through the same expected stain pixel point area; the expected stain pixel point area is a pixel area formed by one or more sequentially adjacent expected stain pixel points.
2. The method for detecting stains in a camera boot according to claim 1, wherein identifying the stain pixels in the grayscale image to obtain the stain distribution data on the boot comprises:
Identifying a smudge pixel point according to the gray value of the pixel point in the gray image;
judging whether the proportion of the stain pixel points to the total pixel points of the gray level image is larger than a preset proportion, if so, determining that the stains on the protective cover exceed the standard.
3. The method for detecting stains in a camera boot according to claim 2, wherein determining whether a proportion of the stain pixels to a total pixel of the grayscale image is greater than a preset proportion comprises:
determining the total number of all the stain pixels in the gray level image according to the identified stain pixels;
and judging whether the ratio of the total number of all the stain pixel points to the total number of the pixel points of the gray image is larger than a first preset ratio.
4. The method for detecting stains in a camera boot according to claim 2, wherein determining whether a proportion of the stain pixels to a total pixel of the grayscale image is greater than a preset proportion comprises:
determining the number of pixel points contained in each stain imaging area according to the coordinate values of each stain pixel point;
judging whether the ratio of the number of pixel points of the stain imaging area with the largest area to the total number of pixel points of the gray level image is larger than a second preset ratio.
5. The method for detecting stains in a camera boot according to claim 4, wherein determining the number of pixels included in each stain imaging area based on the coordinate values of the respective stain pixels comprises:
obtaining the maximum abscissa, the minimum abscissa, the maximum ordinate and the minimum ordinate of each pixel point in the same stain imaging area formed by a plurality of stain pixel points;
and (3) estimating a formula according to the number of pixels of the stain imaging area: s=k (X1-X2) (Y1-Y2), and estimating the number of pixels in each of the stain imaging areas, where S is the number of pixels, and X1, X2, Y1, and Y2 are the maximum abscissa, the minimum abscissa, the maximum ordinate, and the minimum ordinate of the stain imaging area, respectively, and K is an estimated scaling factor.
6. The method for detecting stains in a camera boot according to claim 2, wherein determining whether a proportion of the stain pixels to a total pixel of the grayscale image is greater than a preset proportion comprises:
Judging whether the ratio of the total number of all the stain pixels to the total number of the pixels of the gray image is larger than a first preset proportion, and/or the ratio of the number of the pixels of the stain imaging area with the largest area to the total number of the pixels of the gray image is larger than a second preset proportion; wherein the first preset proportion is greater than the second preset proportion.
7. The stain detection method of a camera protective cover according to any one of claims 1 to 6, wherein identifying stain pixels in the grayscale image includes:
Taking any pixel point in the gray level image as a current pixel point, judging whether the gray level value of the current pixel point is larger than a preset gray level value, and if so, marking the current pixel point as an expected stain pixel point;
obtaining the gray difference absolute values of the current pixel point and each adjacent pixel point;
judging whether the gray difference absolute value larger than a preset difference threshold exists in the gray difference absolute values, if so, selecting the pixel point with the largest gray value in the adjacent pixel points corresponding to the gray difference absolute value larger than the preset difference threshold and the current pixel point as a stain edge pixel point;
Sequentially taking each adjacent pixel point of the current pixel point as a new current pixel point, and repeatedly executing the operation step of judging whether the gray value of the current pixel point is larger than a preset gray value or not until all pixel points in the gray image are identified to be the expected stain pixel point and the stain edge pixel point;
and identifying and marking the pixel points inside the stains in each expected stain pixel point one by taking any expected stain pixel point adjacent to the stain edge pixel point in the gray level image as a starting point pixel point.
8. The utility model provides a stain detection device of camera safety cover which characterized in that includes:
The adjusting module is used for adjusting the focal length and the aperture of the camera so that the distance between the focal point of the camera and the protective cover is not greater than a preset distance, and the aperture is not less than the preset aperture;
The acquisition module is used for acquiring a gray image of the protective cover by using the camera;
The identification module is used for identifying the stain pixel points in the gray level image and obtaining the stain distribution data on the protective cover;
The identification module is specifically configured to obtain an absolute value of a gray difference between adjacent pixel points according to a gray value of each pixel point in the gray image; marking the pixel point with the largest gray value in two adjacent pixel points with the gray difference absolute value larger than a preset difference threshold as a stain edge pixel point in the stain pixel points; identifying expected stain pixel points with gray values larger than a preset gray value in all pixel points of the gray image; marking expected stain pixels communicated with the stain edge pixels as stain inner pixels in the stain pixels; the expected stain pixel point communicated with the stain edge pixel point is the expected stain pixel point directly adjacent to the stain edge pixel point or the expected stain pixel point adjacent to the stain edge pixel point through the same expected stain pixel point area; the expected stain pixel point area is a pixel area formed by one or more sequentially adjacent expected stain pixel points.
9. A stain detection device for a camera boot, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the method for detecting stains in a camera boot according to any one of claims 1 to 7 when executing the computer program.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010740286.2A CN111882540B (en) | 2020-07-28 | 2020-07-28 | Stain detection method, device and equipment for camera protection cover |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010740286.2A CN111882540B (en) | 2020-07-28 | 2020-07-28 | Stain detection method, device and equipment for camera protection cover |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111882540A CN111882540A (en) | 2020-11-03 |
CN111882540B true CN111882540B (en) | 2024-06-21 |
Family
ID=73201409
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010740286.2A Active CN111882540B (en) | 2020-07-28 | 2020-07-28 | Stain detection method, device and equipment for camera protection cover |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111882540B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114326422A (en) * | 2021-12-14 | 2022-04-12 | 深圳市时誉高精科技有限公司 | ZigBee remote controller for smart home |
CN114260259B (en) * | 2021-12-22 | 2023-06-02 | 深圳泰德激光技术股份有限公司 | Method and device for cleaning battery by laser and computer readable storage medium |
CN115661208B (en) * | 2022-12-26 | 2023-04-07 | 合肥疆程技术有限公司 | Camera posture and stain detection method and device and automobile |
CN115846306A (en) * | 2022-12-29 | 2023-03-28 | 河北中瓷电子科技股份有限公司 | Automatic cleaning system, method and device for green ceramic chips and terminal equipment |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107333048A (en) * | 2017-08-28 | 2017-11-07 | 湖州靖源信息技术有限公司 | A kind of automatically cleaning monitoring camera |
Family Cites Families (14)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1360833A1 (en) * | 2000-08-31 | 2003-11-12 | Rytec Corporation | Sensor and imaging system |
JP2007318355A (en) * | 2006-05-24 | 2007-12-06 | Matsushita Electric Ind Co Ltd | Imaging device and lens stain detecting method |
CN105872464B (en) * | 2016-04-11 | 2017-09-26 | 三峡大学 | Factory smoke discharge automatic monitoring system based on vision signal |
KR101778561B1 (en) * | 2016-04-20 | 2017-09-14 | 주식회사 아이엠에스일렉트로닉스 | Pollution detect and inform apparatus of camera, and control method thereof |
JP6933608B2 (en) * | 2018-06-01 | 2021-09-08 | ファナック株式会社 | Abnormality detection system for the lens or lens cover of the visual sensor |
CN110738629B (en) * | 2018-07-02 | 2024-12-17 | 中兴通讯股份有限公司 | Method for detecting lens dirt, terminal and computer readable storage medium |
WO2020019352A1 (en) * | 2018-07-27 | 2020-01-30 | 深圳市大疆创新科技有限公司 | Method, device and system for inspecting camera module, and machine readable storage medium |
CN110889801B (en) * | 2018-08-16 | 2023-10-20 | 九阳股份有限公司 | Camera decontamination optimization method of smoke kitchen system and smoke kitchen system |
CN109472772B (en) * | 2018-09-29 | 2020-12-01 | 歌尔光学科技有限公司 | Image stain detection method, device and equipment |
CN109587392B (en) * | 2018-10-18 | 2020-12-22 | 蒋涛 | Method and device for adjusting monitoring equipment, storage medium and electronic device |
CN111380873A (en) * | 2018-12-29 | 2020-07-07 | 尚科宁家(中国)科技有限公司 | Dirt detection method, device, equipment and medium for lens of sweeping robot |
CN110532876B (en) * | 2019-07-26 | 2024-09-03 | 纵目科技(上海)股份有限公司 | Night mode lens attachment detection method, system, terminal and storage medium |
CN110766679B (en) * | 2019-10-25 | 2022-09-06 | 普联技术有限公司 | Lens contamination detection method and device and terminal equipment |
CN111405177B (en) * | 2020-03-09 | 2021-09-24 | Oppo广东移动通信有限公司 | Image processing method, terminal and computer-readable storage medium |
-
2020
- 2020-07-28 CN CN202010740286.2A patent/CN111882540B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107333048A (en) * | 2017-08-28 | 2017-11-07 | 湖州靖源信息技术有限公司 | A kind of automatically cleaning monitoring camera |
Also Published As
Publication number | Publication date |
---|---|
CN111882540A (en) | 2020-11-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111882540B (en) | Stain detection method, device and equipment for camera protection cover | |
WO2022170706A1 (en) | Defect detection method and apparatus for mold monitoring, and device and medium | |
CN110766679B (en) | Lens contamination detection method and device and terminal equipment | |
JP4644283B2 (en) | Dirt detection method | |
US7280141B1 (en) | Fixed pattern noise subtraction in a digital image sensor | |
CN109523527B (en) | Method and device for detecting dirty area in image and electronic equipment | |
CN110197180B (en) | Character defect detection method, device and equipment | |
JP2009064175A (en) | Object detection apparatus and object detection method | |
CN109359593B (en) | Rain and snow environment picture fuzzy monitoring and early warning method based on image local grid | |
CN110572636B (en) | Camera contamination detection method and device, storage medium and electronic equipment | |
CN110532875B (en) | Night mode lens attachment detection system, terminal and storage medium | |
CN110689555B (en) | KCF tracking target loss detection method and system based on foreground detection | |
CN117351011B (en) | Screen defect detection method, apparatus, and readable storage medium | |
CN113379680A (en) | Defect detection method, defect detection device, electronic equipment and computer readable storage medium | |
KR20090043416A (en) | Surveillance camera device for detecting and suppressing camera movement influence and control method thereof | |
WO2019146097A1 (en) | Sensing device and sensing system for defective photographic data | |
JP2021052238A (en) | Deposit detection device and deposit detection method | |
CN109949308A (en) | A Fast Extraction Method of Space Relative Navigation Targets Against Starlight Interference | |
CN104463827A (en) | Image acquisition module automatic detection method and corresponding electronic device | |
JP4533836B2 (en) | Fluctuating region detection apparatus and method | |
CN111435080B (en) | Water level measuring method, device and system | |
JP2021051381A (en) | Attached matter detection device and attached matter detection method | |
CN111524102B (en) | Screen dirt detection method and device of liquid crystal display | |
CN118781110B (en) | Precise detection method for lens dirt, terminal equipment and computer readable storage medium | |
CN112637588A (en) | Method and device for detecting contamination of camera and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |