WO2022088620A1 - 相机镜头的状态检测方法、装置、设备及存储介质 - Google Patents

相机镜头的状态检测方法、装置、设备及存储介质 Download PDF

Info

Publication number
WO2022088620A1
WO2022088620A1 PCT/CN2021/088211 CN2021088211W WO2022088620A1 WO 2022088620 A1 WO2022088620 A1 WO 2022088620A1 CN 2021088211 W CN2021088211 W CN 2021088211W WO 2022088620 A1 WO2022088620 A1 WO 2022088620A1
Authority
WO
WIPO (PCT)
Prior art keywords
area
abnormal
image
preset
target image
Prior art date
Application number
PCT/CN2021/088211
Other languages
English (en)
French (fr)
Inventor
姚兴华
曾星宇
Original Assignee
北京市商汤科技开发有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 北京市商汤科技开发有限公司 filed Critical 北京市商汤科技开发有限公司
Priority to KR1020217037804A priority Critical patent/KR20220058843A/ko
Priority to JP2021565780A priority patent/JP2023503749A/ja
Publication of WO2022088620A1 publication Critical patent/WO2022088620A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N17/00Diagnosis, testing or measuring for television systems or their details
    • H04N17/002Diagnosis, testing or measuring for television systems or their details for television cameras
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01MTESTING STATIC OR DYNAMIC BALANCE OF MACHINES OR STRUCTURES; TESTING OF STRUCTURES OR APPARATUS, NOT OTHERWISE PROVIDED FOR
    • G01M11/00Testing of optical apparatus; Testing structures by optical methods not otherwise provided for
    • G01M11/02Testing optical properties
    • G01M11/0242Testing optical properties by measuring geometrical properties or aberrations
    • GPHYSICS
    • G03PHOTOGRAPHY; CINEMATOGRAPHY; ANALOGOUS TECHNIQUES USING WAVES OTHER THAN OPTICAL WAVES; ELECTROGRAPHY; HOLOGRAPHY
    • G03BAPPARATUS OR ARRANGEMENTS FOR TAKING PHOTOGRAPHS OR FOR PROJECTING OR VIEWING THEM; APPARATUS OR ARRANGEMENTS EMPLOYING ANALOGOUS TECHNIQUES USING WAVES OTHER THAN OPTICAL WAVES; ACCESSORIES THEREFOR
    • G03B43/00Testing correct operation of photographic apparatus or parts thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/50Constructional details
    • H04N23/55Optical parts specially adapted for electronic image sensors; Mounting thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20036Morphological image processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20048Transform domain processing

Definitions

  • the present disclosure relates to the field of detection technology, and in particular, to a state detection method, device, device and storage medium of a camera lens.
  • the camera has an image acquisition function, and the captured image data can be widely used in various computer vision applications such as smart cities, smart transportation, smart factories, smart campuses, smart communities, autonomous driving, and robot perception.
  • a camera collects the external environment through its lens to obtain image data. Therefore, the lens of the camera serves as the source of data in the entire application and plays an extremely important role.
  • the lens of the camera In real applications, the lens of the camera is exposed to the outdoor environment, and it usually suffers from wind and rain, dust pollution, abnormal occlusion and other abnormal conditions that affect its normal operation. Therefore, it is very important to monitor the status of the lens of the camera and find out the abnormality of the lens of the camera in time.
  • Embodiments of the present disclosure provide at least a method, apparatus, device, and storage medium for detecting a state of a camera lens.
  • a first aspect of the embodiments of the present disclosure provides a method for detecting the state of a camera lens.
  • the method includes: performing abnormality detection on a target image captured by a camera to obtain a final abnormal area in the target image; analyzing the final abnormal area to determine Whether the lens of the camera is in an abnormal state.
  • the abnormal state detection of the camera lens is directly realized by using the abnormal area of the image, without relying on other sensors, thus reducing the difficulty of detecting the camera lens and reducing the detection cost.
  • the above-mentioned abnormal detection of the target image captured by the camera to obtain the final abnormal area in the target image includes: performing blur detection on the target image captured by the camera to obtain several candidate abnormal areas in the target image; Select at least one candidate abnormal area in the area as the final abnormal area.
  • the abnormal area existing in the target image can be determined according to the fuzzy condition of the target image, and the abnormal area identification of the target image is realized, so that the camera can be judged according to the final abnormal area obtained later.
  • Anomalies of the lens various types of abnormal conditions of the lens, such as water mist, smudges, occlusion, etc., often cause blurring of some areas in the target image. Therefore, the blur detection of the image can be used to detect all the above abnormal conditions. out to improve detection breadth.
  • performing blur detection on the target image captured by the camera to obtain several candidate abnormal regions in the target image including: performing preset transformation on the target image captured by the camera to obtain a transformed image, wherein the pixels in the transformed image are The pixel value can reflect the blur information of the transformed image; based on the pixel value of the transformed image, the candidate abnormal area is determined.
  • performing preset transformation on the target image captured by the camera to obtain the transformed image includes: preprocessing the target image to obtain the preprocessed image; performing Laplacian transformation on the preprocessed image to obtain the transformed image .
  • the above-mentioned determination of the candidate abnormal region based on the pixel value of the transformed image includes: performing binarization processing based on the transformed image to obtain a binarized image; finding out the pixel points whose pixel value satisfies a preset pixel condition from the binarized image, to form candidate abnormal regions.
  • the value obtained after Laplacian transformation can reflect the blur information of the changed image, making the edge of the blurred area more obvious.
  • the blurred area in the transformed image can be preliminarily obtained by the size of the obtained pixel value.
  • the amount of data can be greatly reduced, which can improve the operation speed and speed up the detection of candidate abnormal areas; Candidate abnormal regions are highlighted.
  • the above-mentioned preprocessing of the target image to obtain the preprocessed image includes: performing grayscale processing on the target image to obtain the preprocessed image.
  • the above-mentioned binarization processing based on the transformed image to obtain a binarized image includes: filtering the transformed image to obtain a filtered image; the filtering processing includes morphological closing operation; and binarizing the filtered image to obtain a binarized image deal with.
  • the above-mentioned finding out the pixel points whose pixel value meets the preset pixel condition from the binarized image to form the candidate abnormal area includes: inverting the pixel value of the binarized image to obtain an inverse binarized image; Pixels whose pixel values satisfy preset pixel conditions are found in the valued image to form candidate abnormal regions.
  • the amount of data that needs to be calculated can be reduced, and the calculation speed can be improved.
  • filtering processing such as morphological closing operation
  • the interference information inside the unblurred area can be eliminated, the accuracy of subsequent detection of the blurred area can be improved, and the accuracy of judging whether the camera lens is in an abnormal state can be improved.
  • the subsequent processing of the blurred area can be facilitated, the operation speed is improved, and the detection difficulty is reduced.
  • selecting at least one candidate abnormal area from the above several candidate abnormal areas as the final abnormal area includes: obtaining a first area of each candidate abnormal area; selecting a candidate whose first area satisfies a preset area condition from the several candidate abnormal areas The abnormal area is regarded as the pending abnormal area; at least one pending abnormal area is determined as the final abnormal area.
  • the fuzzy area can be more accurately identified.
  • the above-mentioned preset area condition is that the first area is greater than the first preset area threshold.
  • the above-mentioned determination of at least one undetermined abnormal area as the final abnormal area includes: determining at least one statistical value of the undetermined abnormal area in the target image; wherein, the at least one statistical value of the undetermined abnormal area includes the saturation of the undetermined abnormal area obtained by statistics. At least one first statistical value, and/or, at least one second statistical value obtained by counting the pixel values of the abnormal area to be determined; if it is determined that at least one statistical value of the abnormal area to be determined satisfies the preset statistical conditions, the abnormal area to be determined is determined is the final abnormal area.
  • the accuracy of the blur detection can be improved, thereby improving the accuracy of the state detection of the camera lens.
  • the first statistical value and the second statistical value respectively include at least one of a mean value and a variance
  • the above-mentioned preset statistical conditions include: each statistical value of the undetermined abnormal area is greater than a preset threshold value corresponding to the statistical value.
  • the above-mentioned determining at least one statistical value of the undetermined abnormal area in the target image includes: generating at least one mask corresponding to the undetermined abnormal area based on the pixel position information of the undetermined abnormal area, wherein the at least one mask includes an area mask and/or Boundary mask; in the case where at least one mask includes a region mask, obtain a saturation image corresponding to the target image, and use the region mask corresponding to the undetermined abnormal region to obtain a saturation image corresponding to the undetermined abnormal region the first area to be counted; perform statistics on the saturation of the first area to be counted to obtain at least one first statistic value of the unusual area to be determined; and/or, in the case that at least one mask includes a boundary mask, use and The boundary mask
  • the mask is used to extract the area related to the abnormal area to be determined in the target image, so as to realize the accurate statistics of the statistical value of the abnormal area to be determined, and improve the accuracy of subsequent blur detection.
  • the above analysis of the final abnormal area to determine whether the lens of the camera is in an abnormal state includes: obtaining the second area of the final abnormal area; judging whether the second area of the final abnormal area satisfies the preset area condition; if so, determining The target image is in an abnormal state; when it is detected that there are at least a second preset number of frames in an abnormal state in the target image of the continuous first preset number of frames, it is determined that the camera lens is in an abnormal state; wherein the first preset number and the first preset number of frames are in an abnormal state; 2.
  • the preset number is a positive integer.
  • the abnormal state of the target image is determined by using the area of the final abnormal area in the target image, and whether the camera lens is in an abnormal state is determined based on the state of the target image of a preset number of frames, thereby realizing the abnormality detection of the camera lens, and, When the preset number is greater than 1, the state of the target images of consecutive multiple frames is used to comprehensively determine whether the camera lens is in an abnormal state, so the detection accuracy of the state of the camera lens can be improved.
  • judging whether the second area of the final abnormal area satisfies the preset area condition includes: judging whether the second area of the final abnormal area satisfies the first preset area condition or the second preset area condition. If the above-mentioned conditions are satisfied, then determining that the target image is in an abnormal state includes: if the first preset area condition is satisfied, determining that the target image is in the first abnormal state; if the second preset area condition is satisfied, determining that the target image is in the second abnormal state abnormal state.
  • the above-mentioned determining that the camera lens is in an abnormal state when it is detected that there are at least a second preset number of frames in an abnormal state in the target image of the continuous first preset number of frames includes: detecting that the continuous first preset number of frames of the target image is in an abnormal state. In the case where the images are all in the first abnormal state, it is determined that the camera lens is in the first abnormal state. When it is detected that the target images of the first preset number of consecutive frames are not uniformly in the first abnormal state, and there are at least the second preset number of frames in the first abnormal state. In the case of an abnormal state or a second abnormal state, it is determined that the camera lens is in the second abnormal state.
  • a second aspect of the embodiments of the present disclosure provides a device for detecting a state of a camera lens, the device including: a region detecting part and a state analyzing part.
  • the area detection part is configured to perform abnormality detection on the target image captured by the camera to obtain the final abnormal area in the target image.
  • the state analysis part is configured to analyze the final abnormal area to determine whether the lens of the camera is in an abnormal state.
  • a third aspect of the embodiments of the present disclosure provides an electronic device, including a mutually coupled memory and a processor, where the processor is configured to execute a computer program stored in the memory to implement the method for detecting the state of a camera lens in the first aspect.
  • a fourth aspect of the embodiments of the present disclosure provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, implements the method for detecting the state of a camera lens in the first aspect.
  • a fifth aspect of the embodiments of the present disclosure provides a computer program, including computer-readable codes.
  • a processor in the electronic device executes a process for implementing the camera lens in the first aspect. Status detection method.
  • the above solution by performing abnormal detection on the target image captured by the camera, directly uses the abnormal area of the image to detect the abnormal state of the camera lens without relying on other sensors, thus reducing the difficulty of detecting the camera lens and reducing the detection cost. .
  • FIG. 1A is a schematic diagram 1 of an application scenario of an electronic device provided by an embodiment of the present disclosure
  • FIG. 1B is a second schematic diagram of an application scenario of an electronic device method provided by an embodiment of the present disclosure
  • FIG. 2 is a schematic flowchart of a first embodiment of a method for detecting a state of a camera lens provided by an embodiment of the present disclosure
  • FIG. 3 is a first schematic flowchart of a second embodiment of a method for detecting a state of a camera lens provided by an embodiment of the present disclosure
  • FIG. 4 is a second schematic flowchart of a second embodiment of a method for detecting a state of a camera lens provided by an embodiment of the present disclosure
  • FIG. 5 is a third schematic flowchart of the second embodiment of the state detection method for a camera lens provided by an embodiment of the present disclosure
  • FIG. 6 is a fourth schematic flowchart of the second embodiment of the state detection method of the camera lens provided by the embodiment of the present disclosure.
  • FIG. 7 is a fifth schematic flowchart of the second embodiment of the camera lens state detection method provided by the embodiment of the present disclosure.
  • FIG. 8 is a schematic diagram of an application scenario of a method for detecting a state of a camera lens provided by an embodiment of the present disclosure
  • FIG. 9 is a schematic diagram of a processing flow of an abnormal area detection module provided by an embodiment of the present disclosure.
  • FIG. 10 is a schematic diagram of a grayscale image in each scene provided by an embodiment of the present disclosure.
  • FIG. 11 is a schematic diagram of a transformed image in each scene provided by an embodiment of the present disclosure.
  • FIG. 12 is a schematic diagram of filtered images in various scenarios provided by an embodiment of the present disclosure.
  • FIG. 13 is a schematic diagram of an inverse binarized image in each scene provided by an embodiment of the present disclosure.
  • FIG. 14 is a schematic diagram of candidate abnormal regions in various scenarios provided by an embodiment of the present disclosure.
  • FIG. 15 is a schematic frame diagram of an embodiment of a state detection device for a camera lens provided by an embodiment of the present disclosure
  • 16 is a schematic diagram of a framework of an embodiment of an electronic device provided by an embodiment of the present disclosure.
  • FIG. 17 is a schematic framework diagram of an embodiment of a computer-readable storage medium provided by an embodiment of the present disclosure.
  • the camera described in the embodiments of the present disclosure can be any device that can realize image acquisition, such as a video camera, a camera, a mobile phone and other terminal devices, and the lens of the camera is the optical component of the device for forming an image. It can be understood that as long as it is a device capable of capturing images or videos, the method for detecting the state of a camera lens described in the embodiments of the present disclosure can be applied. In some possible implementations, the method for detecting the state of a camera lens described in the embodiments of the present disclosure may be implemented by a processor calling a computer program stored in a memory.
  • the execution subject of the method for detecting the state of the camera lens provided by the embodiment of the present disclosure may be an electronic device.
  • the electronic device may include a processor 11 and a camera 12 .
  • the electronic device 11 can collect the target image through the camera 12
  • the processor 12 can detect the target image.
  • the target image is analyzed to determine whether the lens of the camera 12 is in an abnormal state.
  • the electronic device may be implemented as a cell phone.
  • the electronic device 10 can receive the real-time captured target image transmitted by other devices 13 through the network 14 .
  • the electronic device 10 can analyze and process the received target image, so as to determine whether the camera lens of the other device 13 is in an abnormal state.
  • the electronic device can be implemented as a computer, and the computer can receive the target image collected by the camera through the network.
  • FIG. 2 is a schematic flowchart of a first embodiment of a method for detecting a state of a camera lens according to an embodiment of the present disclosure. Specifically, the following steps can be included:
  • Step S11 Perform abnormality detection on the target image captured by the camera to obtain the final abnormal area in the target image.
  • an image captured by a camera is defined as a target image.
  • the target image may be a certain frame image in the video captured by the camera lens, or may be a single image captured directly.
  • the target image may be a color image or a grayscale image.
  • abnormality detection can be performed directly on the target image to obtain the final abnormal area in the target image.
  • Anomaly detection is to detect the abnormal area in the target image.
  • the abnormal area of the target image can be understood as the area without normal imaging, such as the fuzzy area in the target image, or the whole target image is black, etc. .
  • the situations that cause the target image to have an abnormal area are, for example, that the lens is contaminated with water mist, stains, the lens is blocked, the lens is out of focus, and so on.
  • the obtained area with abnormality in the target image is defined as the final abnormal area.
  • the final abnormal area may be a part of the target image, and the number may be one or more, and the final abnormal area may also be that the entire target image is an abnormal area.
  • Step S12 Analyze the final abnormal area to determine whether the lens of the camera is in an abnormal state.
  • the obtained final abnormal area can be analyzed to more accurately determine whether the lens is in an abnormal state.
  • the position, size, shape, pixel information, etc. of the final abnormal area can be analyzed. It can be understood that all the information about the final abnormal area can be used as basic data for analysis.
  • a plurality of basic data for analysis can be combined, and whether the lens of the camera is in an abnormal state can be more accurately determined through the analysis of the plurality of data.
  • the analysis can be performed in a corresponding manner according to the type of the basic data of the final abnormal area to be analyzed.
  • the saturation analysis method can be used to calculate the saturation of the final abnormal area, and then the saturation of the final abnormal area can be used to determine whether the camera lens is in an abnormal state, or the pixel point statistics method can be used to calculate the final abnormal area.
  • the included pixels are used to determine the size of the final area.
  • the abnormal state detection of the camera lens is directly realized by using the abnormal area of the image, without relying on other sensors, thus reducing the difficulty of detecting the camera lens, and Reduced inspection costs.
  • FIG. 3 is a first schematic flowchart of a second embodiment of a state detection method for a camera lens according to an embodiment of the present disclosure. This embodiment is further described on the basis of the above-mentioned first embodiment. Specifically, the following steps may be included:
  • Step S21 Perform blur detection on the target image captured by the camera to obtain several candidate abnormal regions in the target image.
  • blur detection may be performed on the target image first to preliminarily determine the abnormality of the target image.
  • fuzzy areas in the target image can be obtained, which are defined as candidate abnormal areas.
  • the candidate abnormal region is a part of the target image, the number of candidate abnormal regions may be one or more, and the specific number is determined according to the blur detection result.
  • FIG. 4 is a schematic flowchart of a second embodiment of a method for detecting a state of a camera lens according to an embodiment of the present disclosure.
  • blur detection is performed on a target image captured by a camera to obtain several candidate abnormal regions in the target image, which can be specifically implemented by the following steps:
  • Step S211 Perform preset transformation on the target image captured by the camera to obtain a transformed image, wherein the pixel value of each pixel in the transformed image can reflect the blur information of the transformed image.
  • a preset transformation is performed on the target image, and the transformed image is defined as a transformed image.
  • the pixel value of each pixel in the obtained transformed image can reflect the blur information of the transformed image. Since the preset transformation is performed on each pixel point, the pixel value corresponding to each pixel point can be obtained accordingly.
  • the pixel value of the pixel can reflect the blur information of the changing image, which can be reflected by the change trend of the pixel value of the pixel. For example, the boundary between the blurred area and the non-blurred area can be made more obvious by the change trend of the pixel value. , that is, to make the candidate anomaly regions more obvious.
  • the size of the pixel value of the pixel point can also reflect whether the area where the pixel point is located is blurred. That is, the fuzzy area and the non-blurred area can be preliminarily determined by judging the size of the pixel value of the pixel point.
  • the preset transformation may be to process the information contained in each pixel in the target image, and the value obtained after processing is the pixel value.
  • the target image is a color image
  • it can be processed according to the values of the red (R), green (G), and blue (B) three color channels of each pixel of the target image, and the final value is the pixel value.
  • the preset transformation is performed by using, for example, a Brenner gradient function, a Tenengrad gradient function, a Laplacian (Laplace) gradient function, or an SMD (grayscale variance) function. It can be understood that any method that can be used to detect the blurring of an image can be applied to the embodiments of the present disclosure.
  • a preset transformation is performed on a target image captured by a camera to obtain a transformed image, which specifically includes the following steps:
  • Step S2111 Preprocess the target image to obtain a preprocessed image.
  • the target image When performing preset transformation on the target image, the target image may be preprocessed first, and the obtained image is the preprocessed image.
  • the preprocessing may be to process the information contained in each pixel in the image, for example, to process the RGB three-channel information of the target image.
  • the preprocessing may be to perform grayscale processing on the target image, and the obtained grayscale image is the preprocessed image.
  • the target image can be grayscaled according to the following formula:
  • R, G, and B respectively represent the values of the three color channels of red (R), green (G), and blue (B) of a pixel, and the obtained value Gray is the value of the pixel. grayscale value. It can be understood that the specific calculation formula of the grayscale processing can be adjusted accordingly according to the specific situation.
  • the information contained in each pixel can be converted from RGB three-channel to single-channel information of gray value, which can simplify the amount of data in subsequent processing of the information contained in the pixel. Improve operation speed.
  • Step S2112 Laplace transform is performed on the preprocessed image to obtain a transformed image.
  • the preprocessed image obtained after preprocessing can be processed by using the Laplacian gradient function transformation, and the obtained image is the transformed image.
  • the Laplacian transform By using the Laplacian transform, the real blur area in the preprocessed image can be detected to obtain the blurry area in the preprocessed image.
  • the specific process of Laplacian is to first use the Sobel operator to calculate the second-order x and y differences, and then sum them up.
  • the formula is as follows:
  • x and y are the coordinates of each pixel in the pixel coordinates, respectively, src represents the input image, and dst represents the output image.
  • the obtained value is the pixel value of each pixel point, and the pixel value can reflect the blur information of the changed image, for example, to make the edge of the blurred area more obvious, and at the same time, the obtained pixel value can be obtained by Judging the size of the image, the blurred area in the transformed image is initially obtained.
  • Step S212 Determine candidate abnormal regions based on pixel values of the transformed image.
  • the candidate abnormal region can be determined based on the pixel value of the transformed image. Based on the pixel value of the transformed image, it means that the candidate abnormal area can be determined according to the change trend of the pixel value of the transformed image, the overall distribution of the pixel value, or the size of the pixel value and other information related to the pixel value. That is, the candidate abnormal region may be determined according to the pixel values of a part of the transformed image, or may be determined according to the pixel points of the entire transformed image. For example, a region enclosed by a range in which the change trend of the pixel value of the pixel point exceeds a certain level can be determined as a candidate abnormal region.
  • the candidate abnormal region can be determined from the transformed image by binarizing the transformed image. Specifically, it can be illustrated with reference to FIG. 5 , which is a third schematic flowchart of the second embodiment of the state detection method of the camera lens according to the embodiment of the present disclosure.
  • “determining candidate abnormal regions based on pixel values of the transformed image” can be specifically implemented through the following steps:
  • Step S2121 Perform binarization processing based on the transformed image to obtain a binarized image.
  • the transformed image can be binarized.
  • the transformed image can be thresholded first. Threshold segmentation is to classify the pixel value of the pixel, for example, a feature threshold is set, the pixels whose pixel value is less than or equal to the feature threshold are classified into one category, and the pixels whose pixel value is greater than the feature threshold are classified into one category.
  • the threshold is, for example, any number from 50 to 80, such as 50.
  • the pixel value of each pixel in the transformed image is divided into two categories.
  • a binarization operation can be performed to make the difference between the pixel values of the two types of pixel points more obvious.
  • the pixel degree of a pixel whose pixel value is greater than the feature threshold may be set as the first preset pixel value
  • the pixel value of the pixel whose pixel value is less than or equal to the feature threshold may be set as the second preset pixel value
  • the pixel value may be 0, and the second preset pixel value may be 255; or the first preset pixel value may be 255, and the second preset pixel value may be 0.
  • the above-mentioned first preset pixel value and second preset pixel value may also be set to other pixel values, which are not limited herein.
  • the amount of data contained in the image can be greatly reduced, thereby improving the operation speed and speeding up the detection of candidate abnormal regions.
  • the boundary of the blurred area in the binarized image can be made more obvious, and the candidate abnormal area can be highlighted.
  • performing threshold segmentation and image binarization based on the transformed image to obtain a binarized image may specifically include the following steps 1 and 2:
  • Step 1 Filter the transformed image to obtain a filtered image.
  • the filtering process may include, but is not limited to, a morphological closing operation. Morphological closing operation is to perform dilation operation first, and then perform erosion operation.
  • the dilation operation can be used to fill in the holes of the unblurred areas and to remove the small grain noise (interference information in the unblurred areas) contained in the unblurred areas.
  • the formula is as follows:
  • A can be a non-blurred area
  • B can be a structural element.
  • the unblurred area A is expanded by the structural element B.
  • the erosion operation can cause the boundary of the unblurred area to shrink, which can be used to eliminate some small holes or small cracks.
  • the formula is as follows:
  • the obtained image is defined as a filtered image.
  • the interference information in the unblurred area has been eliminated by the morphological closing operation in the filtered image, which can improve the accuracy of subsequent detection of the blurred area and the accuracy of judging whether the camera lens is in an abnormal state.
  • Step 2 Binarize the filtered image to obtain a binarized image.
  • the above binarization process can be used, and the image obtained after processing is a binary value. image.
  • Step S2122 Find out the pixel points whose pixel value meets the preset pixel condition from the binarized image to form a candidate abnormal area.
  • the pixel values of the pixels in the binarized image at this time are only two.
  • the pixel points whose pixel values satisfy the preset pixel condition can be found, and the area composed of these pixel points is the candidate abnormal area.
  • the pixel value of the pixel point in the unblurred area is set to a smaller value, the point with the larger pixel value in the binarized image can be selected to form the blurred area.
  • the pixel value of the pixel point in the unblurred area can be set to 255, and the pixel point with the pixel value of 255 can be found by using the cv::findContours function in the OpenCV open source computer vision library.
  • the pixel value of the blurred area when performing an image binarization operation on the transformed image, the pixel value of the blurred area may be set to 0. Since the pixel value of the blurred area is 0, it is inconvenient for subsequent processing of the blurred area. The speed of operation reduces the difficulty of calculation.
  • the following steps can be performed to realize "find out the pixel points whose pixel value meets the preset pixel condition from the binarized image to form a candidate abnormal area", which specifically includes the following steps 1 and 2:
  • Step 1 Invert the pixel values of the binarized image to obtain an inverse binarized image.
  • the inversion operation can be performed, that is, the pixel values of the unblurred area and the blurred area can be exchanged .
  • the pixel value of the blurred area is 0 and the pixel value of the unblurred area is 255
  • the pixel value of the blurred area is 255
  • the pixel value of the unblurred area is 0.
  • the pixel value of the blurred area can be made not to be 0, which can facilitate subsequent processing of the blurred area, improve the operation speed, and reduce the difficulty of detection.
  • thresh is the pixel threshold of the preset value
  • max Val is the maximum pixel value
  • the obtained image is defined as an inverse binarized image.
  • Step 2 Find out the pixel points whose pixel value satisfies the preset pixel condition from the inverse binarization image to form a candidate abnormal area.
  • the inverse binarization image it is also possible to find out the pixel points whose pixel value satisfies the preset pixel condition, and the pixel point whose pixel value satisfies the preset pixel condition. Since the pixel value of the blurred area is greater than 0, the preset pixel condition may be that the pixel value of the pixel point is greater than 0.
  • the way to find pixels can be to use the cv::findContours function in the OpenCV open source computer vision library to find them.
  • Step S22 Select at least one candidate abnormal area from several candidate abnormal areas as the final abnormal area.
  • At least one of the candidate abnormal regions can be selected as the final abnormal region. For example, after performing certain processing on the candidate abnormal regions, at least one of them can be selected as the final abnormal region.
  • FIG. 6 is a fourth schematic flowchart of the second embodiment of the state detection method of the camera lens according to the embodiment of the present disclosure.
  • the candidate abnormal area may be further analyzed to determine the final abnormal area. For example, "select at least one candidate abnormal area from several candidate abnormal areas as the final abnormal area" may specifically include the following steps:
  • Step S221 Obtain the first area of each candidate abnormal region.
  • the area of the candidate abnormal region is defined as the first area.
  • the area of the candidate abnormal area can be determined by counting the number of pixels contained in the candidate abnormal area. For example, if the number of pixels contained in a candidate abnormal area is 100, the first area size of the candidate abnormal area is 100 pixel size.
  • Step S222 From several candidate abnormal areas, select a candidate abnormal area whose first area satisfies a preset area condition as a pending abnormal area.
  • the candidate abnormal area can be screened by judging whether the area of the candidate abnormal area satisfies the preset area condition, and the candidate abnormal area that satisfies the preset area condition is defined as the pending abnormal area.
  • the preset area condition may be that the first area is greater than the first preset area threshold.
  • the first preset area threshold is, for example, any value of 2500-3000 pixels in size, such as 2500 pixels in size. Since the area of the fuzzy area is generally large, by setting the first area threshold, the candidate abnormal area with a small area can be excluded, and the accuracy of identifying the fuzzy area is improved.
  • Step S223 Determine at least one pending abnormal area as the final abnormal area.
  • At least one abnormal area to be determined can be selected as the final abnormal area.
  • at least one of them can be selected as the final abnormal area.
  • FIG. 7 is a fifth schematic flowchart of the second embodiment of the state detection method of the camera lens according to the embodiment of the present disclosure.
  • "determining at least one pending abnormal area as the final abnormal area” may specifically include the following steps:
  • Step S2231 Determine at least one statistical value of the abnormal region to be determined in the target image.
  • processing may be performed on the pending abnormal area to further determine whether the pending abnormal area is the final abnormal area.
  • statistics may be performed on the pending abnormal area to obtain statistical values related to the pending abnormal area.
  • further analysis can be carried out by using the saturation information of the target image to determine the abnormal area.
  • at least one first statistical value may be obtained by performing statistics on the saturation of the abnormal region to be determined.
  • the pixel values of the to-be-determined abnormal region can also be counted, so as to obtain at least one second statistical value. It can be understood that when implementing the state detection method for a camera lens described in this disclosure, the first statistical value and the second statistical value can be obtained as the statistical value of the pending abnormal area, and one of them can also be selected as the statistical value of the pending abnormal area. value.
  • max(R, G, B) is the maximum value obtained after processing the RGB value of each pixel in the target image
  • min(R, G, B) is the pixel value of each pixel in the target image.
  • the minimum value obtained after processing the RGB values, S represents the saturation of the target image.
  • the method for processing the RGB values of the pixels in the target image is, for example, the above-mentioned formula (1).
  • the above-mentioned first statistical value and second statistical value respectively include at least one of a mean value and a variance. That is, the at least one first statistical value includes the mean value and/or the variance of the saturation of the abnormal area to be determined, and the at least one second statistical value includes the mean value and/or the variance of the pixel values of the abnormal area to be determined.
  • step S2231 may specifically include the following steps 1 to 3.
  • Step 1 Based on the pixel position information of the abnormal region to be determined, generate at least one mask corresponding to the abnormal region to be determined, wherein the at least one mask includes an area mask and/or a boundary mask.
  • the position of the pixel points can be determined by analyzing the position information, such as coordinates, of the pixel points in the undetermined abnormal area.
  • the mask corresponding to the undetermined abnormal area is consistent with the shape and size of the entire undetermined abnormal area, or only the shape and size of a part of the undetermined abnormal area.
  • Masks can be used to block out pending anomaly regions.
  • the mask may be an image, a figure, etc., used to block the abnormal area to be determined.
  • a mask corresponding to a complete undetermined abnormal region is a region mask; generating a mask corresponding to the boundary of a pending abnormal region is a boundary mask.
  • the number and shape of the generated masks are not limited. For example, an area mask and a boundary mask corresponding to each pending anomaly area may be generated for all pending anomaly areas.
  • Step 2 In the case where at least one mask includes an area mask, obtain a saturation image corresponding to the target image, and use the area mask corresponding to the undetermined abnormal area to obtain a saturation image corresponding to the undetermined abnormal area.
  • the first area to be counted; the saturation of the first area to be counted is counted to obtain at least one first statistical value of the to-be-determined abnormal area.
  • step 1 if the generated mask includes a region mask, a saturation image corresponding to the target image can be obtained at this time. Specifically, saturation calculation can be performed on each pixel of the target image, so as to obtain a saturation image corresponding to the target image.
  • the saturation calculation is, for example, converting an RGB image to a hue-saturation-lightness (HSV) image and extracting the value of the saturation S channel.
  • HSV hue-saturation-lightness
  • the corresponding position of the undetermined abnormal area on the saturation image that is, the first area to be counted, can be obtained through the position information, such as coordinates, of the pixels of the undetermined abnormal area in the target image.
  • the coordinates of a certain pixel in the undetermined abnormal area on the target image are (1,1)
  • the coordinates of the pixel corresponding to the pixel are also (1,1). Therefore, the first to-be-statistical area corresponding to the to-be-determined abnormal area can be obtained in the saturation image.
  • the saturation of the first region to be counted may also be counted, and a value obtained from the count is defined as the first statistic value.
  • the statistics on the saturation of the first to-be-statistical area may be performed on the entire to-be-determined abnormal area, or may be performed on a certain part of the to-be-determined abnormal area.
  • the statistical method is not limited, for example, the average saturation, variance, standard deviation, etc., of the undetermined abnormal area can be counted.
  • step 3 can be performed at this time.
  • Step 3 Using the boundary mask corresponding to the abnormal area to be determined, obtain a second area to be counted corresponding to the abnormal area to be determined in the target image; Count the pixel values of the second area to be counted to obtain at least one area of the abnormal area to be determined. Second statistic.
  • the boundary mask corresponding to the undetermined abnormal area is generated, the area covered by the boundary mask is the second to-be-statistical area corresponding to the undetermined abnormal area.
  • the pixel values of the second area to be counted may be counted, for example, the pixel values are grayscale values, and the statistical value obtained by the statistics is the second statistical value.
  • both steps 2 and 3 may be performed, or only one of the steps may be performed.
  • Step S2232 If it is determined that at least one statistical value of the pending abnormal area satisfies the preset statistical condition, the pending abnormal area is determined as the final abnormal area.
  • the statistical value can be analyzed to further determine whether the pending abnormal area is a fuzzy area, and obtain the final abnormal area. Specifically, if it is determined that at least one statistical value of the pending abnormal area satisfies the preset statistical condition, the pending abnormal area is determined as the final abnormal area.
  • the preset statistical condition may be that the size of the statistical value is within a certain range. For example, when the statistical value is an arithmetic mean value, the preset condition may be that the arithmetic mean value is between 40-216.
  • the pending abnormal area can be determined as the final abnormal area, or several statistical values meet the preset statistical conditions, or all statistical values can be determined as the final abnormal area. The values all meet the preset statistical conditions.
  • the preset statistical condition may be that each statistical value of the abnormal region to be determined is greater than a preset threshold corresponding to the statistical value.
  • the statistical value includes the arithmetic mean and variance of the whole and boundary of the undetermined abnormal area, it means that there will be 4 statistical values in an undetermined abnormal area, which are the arithmetic mean and variance of the entire undetermined abnormal area, to be determined Arithmetic mean and variance of anomaly region boundaries. Only when the four statistical values are all greater than the preset threshold corresponding to the statistical value, the pending abnormal area is determined as the final abnormal area.
  • the preset threshold value of the arithmetic mean may be 40, and the preset threshold value of the variance may be 100.
  • the blur situation of the abnormal area to be determined can be further judged, thereby improving the accuracy of blur detection and further improving the accuracy of the state detection of the camera lens.
  • the detection steps can be simplified and the detection speed can be accelerated.
  • the final blurred area of the image is obtained. At this time, it can be determined whether the camera lens is in an abnormal state by analyzing the final abnormal area.
  • Step S23 obtaining the second area of the final abnormal area
  • the fuzzy area can be analyzed by obtaining the area of the final abnormal area.
  • the area of the final abnormal region is defined as the second area.
  • the area of the final abnormal area can also be represented by the number of pixels it contains. For example, if a final abnormal area contains 3000 pixels, the area of the final abnormal area is 3000 pixels in size.
  • Step S24 Determine whether the second area of the final abnormal area satisfies the preset area condition. If satisfied, go to step S25, if not, go to step S27.
  • the final abnormal area can be classified by judging whether the second area satisfies the preset area condition.
  • the preset area condition is, for example, the size of the area, or the position of the final abnormal area in the target image, and so on.
  • the preset area condition may include a first preset area condition or a second preset area condition.
  • "judging whether the second area of the final abnormal area satisfies the preset area condition" specifically includes: judging whether the second area of the final abnormal area satisfies the first preset area condition or the second preset area condition.
  • the first preset area condition is that the second area is greater than the second preset area threshold; the second preset area condition is that the second area is greater than the second preset area threshold and smaller than the third preset area threshold, Wherein, the second preset area threshold is greater than the third preset area threshold.
  • the second preset area threshold may be a size of 5000 pixels, and the third preset area threshold may be a size of 3000 pixels.
  • Step S27 If not satisfied, determine that the target image is in a normal state.
  • the target image is in a normal state.
  • Step S25 If satisfied, determine that the target image is in an abnormal state.
  • the target image can be considered to be in an abnormal state. It can be understood that when the second area of the final abnormal area does not meet the preset area condition, it can be considered that the target image of the frame is in a normal state.
  • the final abnormal area can be further classified according to these two conditions. Specifically, when the second area of the final abnormal area satisfies the first preset area condition, it can be determined that the target image is in the first abnormal state; when the second area of the final abnormal area satisfies the second preset area condition, the target image is determined in the second abnormal state.
  • the abnormal state of the target image is more serious.
  • the first abnormal state is, for example, an error state
  • the second abnormal state is, for example, a warning state.
  • the abnormal state of the target image can be further divided, so that a more accurate judgment of the abnormal state of the target image can be realized.
  • the abnormal state of the frame of target image can be determined. It can be understood that when the lens of the camera is in an abnormal state, generally speaking, several consecutive frames of target images captured by the camera are in an abnormal state. Therefore, the state of the camera lens can be further judged by analyzing the number of target images in an abnormal state. Based on this, after step S25, the following steps can be continued:
  • Step S26 in the case of detecting that there are at least a second preset number of frames in an abnormal state in the target image of the continuous first preset number of frames, determine that the camera lens is in an abnormal state; wherein the first preset number and the second preset number of frames are in an abnormal state; Quantity is a positive integer.
  • the first preset number and the second preset number are positive integers.
  • the first preset number is, for example, 30, and the second preset number is, for example, 15.
  • part of the target image may be periodically extracted from the target avatar shot by the camera lens within a period of time to determine whether the extracted target image is in an abnormal state. In this way, it can be determined whether the camera lens is in an abnormal state within a certain period of time, thereby improving the detection accuracy of the camera lens.
  • the target image is in the first abnormal state or the second abnormal state, The following situations may occur:
  • the first situation if it is detected that the target images of the first preset number of consecutive frames are all in the first abnormal state, it can be determined that the camera lens is in the first abnormal state. At this time, it can be considered that the abnormal state of the camera lens is relatively serious, and the first abnormal state is, for example, an error state.
  • the second situation if it is detected that the target images of the first consecutive preset number of frames are in a normal state, then the camera lens can be considered to be in a normal state at this time.
  • the third situation if it is detected that the target images of the first preset number of consecutive frames are not all in the first abnormal state, and there is a situation that at least the target image of the second preset number of frames is in the first abnormal state or the second abnormal state , to determine that the camera lens is in the second abnormal state. At this time, it is possible that the target images of the consecutive first preset number of frames are all in the second abnormal state, or at least the second preset number of frame images of the target images of the consecutive first preset number of frames (the second preset number of frames) The number is not equal to the first preset number) is in the first abnormal state or the second abnormal state.
  • the camera lens may be in an abnormal state, so it is determined that the camera lens is in the second abnormal state.
  • the second abnormal state is, for example, a warning state.
  • the second preset number can be specifically set according to the actual situation, for example, it can be any positive integer such as 1, 5, and 15.
  • the abnormal state of the target image is determined by using the area of the final abnormal area in the target image, and whether the camera lens is in an abnormal state is determined based on the state of the target image in a preset number of frames, thereby realizing the abnormality detection of the camera lens.
  • the number is set to be greater than 1, that is, whether the camera lens is in an abnormal state is comprehensively determined by using the state of the target images of multiple consecutive frames, so the detection accuracy of the state of the camera lens can be improved.
  • the blur detection of the image can be used to detect all the above abnormal conditions. out to improve detection breadth.
  • the writing order of each step does not mean a strict execution order but constitutes any limitation on the implementation process, and the specific execution order of each step should be based on its function and possible Internal logic is determined.
  • the state detection method of the camera lens can be completed by the abnormal area detection module 81 , the abnormal area filtering module 82 , the state analysis processing module 83 and the control processing module 84 .
  • the abnormal area detection module 81 can detect the abnormal area of the target image.
  • the types of abnormal areas include: the lens is stained with water mist; the lens is stained, and the lens is blocked.
  • the abnormal area filtering module 82 can filter the results of the abnormal area detection module. Filtering is achieved through a series of human-designed rules and characteristics.
  • the filtering rules here include statistics such as region size, region color, region boundary features, etc.
  • the state analysis and processing module 83 can detect whether the state of the camera lens is an abnormal state through the threshold value set manually.
  • the processing results of the state analysis and processing module can be divided into three states: normal, abnormal, and error. Among them, the normal state, that is, the camera lens does not have any abnormality. Abnormal state, that is, the state of the camera lens is slightly abnormal, but not serious. Error status, that is, the camera lens status is abnormally serious and needs to be shut down immediately.
  • the output result of this module can be handed over to the control module 84 for processing, so that the control module can make different responses to different states.
  • the abnormal area detection module 81 may perform the following steps:
  • Step 811 Acquire a target image.
  • the target image is an image captured by a camera.
  • Step 812 Perform grayscale processing on the target image to obtain a grayscale image.
  • the target image is a color RGB image.
  • the target image can be subjected to grayscale processing according to the above formula (1) to obtain the grayscale value of each pixel, thereby obtaining a grayscale image.
  • Figure 10 shows grayscale images in different scenarios.
  • 1001 in Figure 10 is the grayscale image in normal conditions
  • 1002 in Figure 10 is the grayscale image of the camera lens contaminated with water mist
  • 1003 in Figure 10 is the grayscale image of the camera lens contaminated with contamination
  • 1004 in Figure 10 Grayscale image with occlusions for the camera lens.
  • Step 813 Perform Laplacian transformation on the grayscale image to obtain a transformed image.
  • Laplacian is, for example, firstly use the sobel operator to calculate the second-order x and y differences, and then sum them up.
  • the formula please refer to the above formula (2).
  • the transformed image shown in FIG. 11 can be obtained.
  • 1101 in Fig. 11 is the transformed image collected under normal conditions
  • 1102 in Fig. 11 is the transformed image of the camera lens contaminated with water mist
  • 1103 in Fig. 11 is the transformed image of the camera lens contaminated with stains
  • 1104 in Fig. 11 A rollover image with occlusions for the camera lens.
  • Step 814 Perform filtering processing on the transformed image to obtain a filtered image.
  • the filtering process may include, but is not limited to, morphological closing operations. Morphological closing operation is to perform dilation operation first, and then perform erosion operation. The specific processes of the expansion operation and the erosion operation are the same as those of the above-mentioned embodiment, and are not repeated here.
  • the filtered image shown in FIG. 12 can be obtained.
  • 1201 in Fig. 12 is the filtered image collected under normal conditions
  • 1202 in Fig. 12 is the filtered image of the camera lens contaminated with water mist
  • 1203 in Fig. 12 is the filtered image of the camera lens contaminated with contamination
  • 1204 in Fig. 12 A filtered image with occlusions for the camera lens.
  • Step 815 Perform binarization processing on the filtered image to obtain a binarized image.
  • Step 816 Invert the pixel values of the binarized image to obtain an inverse binarized image.
  • the formula for performing the binarization processing and the inversion operation on the filtered image may refer to the formula (5) in the above embodiment, which will not be repeated here.
  • the inverse binarized image shown in FIG. 13 can be obtained.
  • 1301 in Figure 13 is the inverse binarization image under normal conditions
  • 1302 in Figure 13 is the inverse binarization image of the camera lens contaminated with water mist
  • 1303 in Figure 13 is the inverse binary image of the camera lens contaminated with stains 1304 in Fig. 13 is an inverse binarized image where the camera lens is occluded.
  • Step 817 Find out the pixel points whose pixel value meets the preset pixel condition from the inverse binarized image, so as to form several candidate abnormal regions.
  • contour region search is performed on the inverse binary image to obtain independent individual abnormal regions.
  • the specific implementation can use the cv::findContours function in the OpenCV open source computer vision library.
  • the area framed by the solid line frame is the candidate abnormal area in different scenarios.
  • the abnormal area filtering module 82 may perform the following steps:
  • Step 821 Obtain the first area of each candidate abnormal region.
  • Step 822 from several candidate abnormal areas, select at least one candidate abnormal area whose first area satisfies the preset area condition as the pending abnormal area.
  • the preset area condition is that the first area is greater than the first preset area threshold. That is to say, the abnormal candidate contours can be filtered by area, and the area that is too small can be deleted to obtain the undetermined abnormal area.
  • Step 823 based on the pixel position information of the abnormal region to be determined, generate at least one mask corresponding to the abnormal region to be determined, wherein the at least one mask includes a region mask and/or a boundary mask.
  • Step 824 In the case where at least one mask includes an area mask, obtain a saturation image corresponding to the target image, and use the area mask corresponding to the undetermined abnormal area to obtain a saturation image corresponding to the undetermined abnormal area.
  • the first area to be counted; the saturation of the first area to be counted is counted to obtain at least one first statistical value of the to-be-determined abnormal area.
  • the saturation information of the target image can be calculated according to formula (6) to obtain a saturation image.
  • the first statistical value may be one of the mean value and the variance of the saturation of the undetermined abnormal area.
  • Step 825 Obtain a second area to be counted corresponding to the abnormal area to be determined in the target image by using the boundary mask corresponding to the abnormal area to be determined; perform statistics on the pixel values of the second area to be counted to obtain at least one abnormal area to be determined. Second statistic.
  • the second statistical value includes at least one of a mean and a variance.
  • Step 826 If it is determined that at least one statistical value of the pending abnormal area satisfies the preset statistical condition, determine the pending abnormal area as the final abnormal area.
  • the state analysis processing module 83 may perform the following steps:
  • Step 831 Obtain the second area of the final abnormal area.
  • the cv::contourArea function in the OpenCV open source computer vision library can be used to calculate the second area of the most total abnormal area.
  • Step 832 Determine whether the second area of the final abnormal area satisfies the first preset area condition or the second preset area condition.
  • the first preset area condition is that the second area is greater than the second preset area threshold.
  • the second preset area condition is that the second area is greater than the second preset area threshold and smaller than the third preset area threshold, wherein the second preset area threshold is greater than the third preset area threshold.
  • Step 833 If the first preset area condition is satisfied, it is determined that the target image is in the first abnormal state; if the second preset area condition is satisfied, it is determined that the target image is in the second abnormal state.
  • Step 834 when it is detected that the target images of the first preset number of consecutive frames are in the first abnormal state, determine that the camera lens is in the first abnormal state.
  • the abnormal area existing in the target image can be determined according to the fuzzy condition of the target image, and the abnormal area identification of the target image is realized, so that the follow-up can be based on the obtained final abnormal area.
  • various types of abnormal conditions of the lens such as water mist, smudges, occlusion, etc., often cause blurring of some areas in the target image. Therefore, the blur detection of the image can be used to detect all the above abnormal conditions. out to improve detection breadth.
  • FIG. 15 is a schematic frame diagram of an embodiment of a state detection apparatus for a camera lens according to an embodiment of the present disclosure.
  • the detection device 70 includes an area detection part 71 and a state analysis part 72 .
  • the area detection section 71 is configured to perform abnormality detection on the target image captured by the camera to obtain the final abnormal area in the target image.
  • the state analysis section 72 is configured to analyze the final abnormal area to determine whether the lens of the camera is in an abnormal state.
  • the area detection part 71 is also configured to perform blur detection on the target image captured by the camera to obtain several candidate abnormal areas in the target image; select at least one candidate abnormal area from several candidate abnormal areas as the final abnormal area .
  • the region detection part 71 is also configured to perform preset transformation on the target image captured by the camera to obtain a transformed image, wherein the pixel value of each pixel in the transformed image can reflect the blur information of the transformed image; Pixel values to identify candidate abnormal regions.
  • the region detection part 71 is further configured to preprocess the target image to obtain a preprocessed image, and to perform Laplace transform on the preprocessed image to obtain a transformed image.
  • the region detection part 71 is further configured to perform binarization processing based on the transformed image to obtain a binarized image; to find out the pixel points whose pixel value meets the preset pixel condition from the binarized image to form a candidate abnormal region.
  • the region detection part 71 is further configured to perform grayscale processing on the target image to obtain a preprocessed image.
  • the region detection part 71 is further configured to perform filtering processing on the transformed image to obtain a filtered image.
  • the filtering process may be, but not limited to, a morphological closing operation.
  • the region detection section 71 is further configured to perform inversion of pixel values of the binarized image to obtain an inverse binarized image. Execute to find out the pixel points whose pixel value satisfies the preset pixel condition from the de-binarized image, so as to form a candidate abnormal area.
  • the area detection part 71 is further configured to obtain the first area of each candidate abnormal area; select a candidate abnormal area whose first area satisfies the preset area condition from several candidate abnormal areas, as the pending abnormal area; At least one pending abnormal area is determined as the final abnormal area.
  • the above-mentioned preset area condition is that the first area is greater than the first preset area threshold.
  • the region detection part 71 is further configured to perform determining at least one statistical value of the abnormal region to be determined in the target image; wherein, the at least one statistical value of the abnormal region to be determined includes at least one first statistical value obtained from the saturation statistics of the abnormal region to be determined A statistical value, and/or, at least one second statistical value obtained by counting the pixel values of the abnormal area to be determined; if it is determined that at least one statistical value of the abnormal area to be determined satisfies the preset statistical conditions, the abnormal area to be determined is determined as the final abnormality area.
  • the above-mentioned at least one statistical value includes at least one of mean and variance.
  • the above-mentioned preset statistical conditions include: each statistical value of the undetermined abnormal area is greater than a preset threshold corresponding to the statistical value.
  • the area detection part 71 is further configured to generate at least one mask corresponding to the undetermined abnormal area based on the pixel position information of the undetermined abnormal area, wherein the at least one mask includes an area mask and/or a boundary mask;
  • a mask includes a region mask
  • a saturation image corresponding to the target image is obtained, and at least one first pending abnormal region corresponding to the pending abnormal region is obtained in the saturation image by using the region mask corresponding to the pending abnormal region.
  • Statistical area wherein at least one area to be counted includes an overall area and/or a boundary area; obtain a saturation image corresponding to the target image, and determine the saturation of the area corresponding to the overall area in the saturation image of the first area to be counted and/or, in the case where at least one mask includes a boundary mask, use the boundary mask corresponding to the abnormal area to be determined to obtain in the target image a
  • the second to-be-statistical area corresponding to the undetermined abnormal area; the pixel values of the second to-be-statistical area are counted to obtain at least one second statistical value of the undetermined abnormal area.
  • the state analysis part 72 is further configured to execute obtaining the second area of the final abnormal area; execute determining whether the second area of the final abnormal area satisfies the preset area condition; if so, execute determining that the target image is in an abnormal state; execute in When it is detected that there are at least a second preset number of frames in an abnormal state in the target image of the continuous first preset number of frames, it is determined that the camera lens is in an abnormal state; wherein the first preset number and the second preset number are positive integers .
  • the state analysis part 72 is further configured to judge whether the second area of the final abnormal area satisfies the first preset area condition or the second preset area condition. If so, the state analysis part 72 is further configured to determine that the target image is in the first abnormal state if the first preset area condition is met; and to execute the determination that the target image is in the second abnormal state if the second preset area condition is met.
  • the state analysis part 72 is further configured to determine that the camera lens is in the first abnormal state when it is detected that the target images of the consecutive first preset number of frames are in the first abnormal state;
  • the frame target images are not uniformly in the first abnormal state, and when at least a second preset number of frames are in the first abnormal state or the second abnormal state, it is determined that the camera lens is in the second abnormal state.
  • FIG. 16 is a schematic frame diagram of an embodiment of an electronic device according to an embodiment of the present disclosure.
  • the electronic device 80 includes a memory 81 and a processor 82 coupled to each other, and the processor 82 is configured to execute the computer program stored in the memory 81 to implement the steps of any of the above embodiments of the camera lens state detection method.
  • the electronic device 80 may include, but is not limited to, a microcomputer and a server.
  • the electronic device 80 may also include mobile devices such as a notebook computer and a tablet computer, which are not limited herein.
  • the processor 82 is configured to control itself and the memory 81 to implement the steps of any of the above embodiments of the camera lens state detection method.
  • the processor 82 may also be referred to as a CPU (Central Processing Unit, central processing unit).
  • the processor 82 may be an integrated circuit chip with signal processing capability.
  • the processor 82 can also be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field-Programmable Gate Array, FPGA) or other Programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
  • a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
  • the processor 82 may be jointly implemented by an integrated circuit chip.
  • FIG. 17 is a schematic diagram of a framework of an embodiment of a computer-readable storage medium according to an embodiment of the present disclosure.
  • the computer-readable storage medium 90 stores a computer program 901 that can be executed by the processor, and the computer program 901 is used to implement the steps of any of the foregoing embodiments of the camera lens state detection method.
  • An embodiment of the present disclosure further provides a computer program, including computer-readable code, when the computer-readable code is executed in an electronic device, a processor in the electronic device executes a state detection method configured to implement the above-mentioned camera lens Example steps.
  • the functions or included parts of the apparatus, device, or medium provided in the embodiments of the present disclosure may be used to execute the methods described in the above method embodiments, and the specific implementation may refer to the descriptions in the above method embodiments. For the sake of brevity, details are not repeated here.
  • the disclosed method and apparatus may be implemented in other manners.
  • the device implementations described above are only illustrative, for example, the division of parts or units is only a logical function division, and other divisions may be used in actual implementation, for example, units or components may be combined or integrated to another system, or some features can be ignored, or not implemented.
  • the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, which may be in electrical, mechanical or other forms.
  • each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units can be implemented in the form of hardware, and can also be implemented in the form of software functional units.
  • the integrated unit if implemented as a software functional unit and sold or used as a stand-alone product, may be stored in a computer-readable storage medium.
  • a computer-readable storage medium includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (processor) to execute all or part of the steps of the methods in the various implementation manners of the embodiments of the present disclosure.
  • the aforementioned storage medium includes: U disk, mobile hard disk, Read-Only Memory (ROM, Read-Only Memory), Random Access Memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes .

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Quality & Reliability (AREA)
  • Theoretical Computer Science (AREA)
  • Analytical Chemistry (AREA)
  • Health & Medical Sciences (AREA)
  • Chemical & Material Sciences (AREA)
  • Biomedical Technology (AREA)
  • General Health & Medical Sciences (AREA)
  • Geometry (AREA)
  • Studio Devices (AREA)
  • Image Analysis (AREA)

Abstract

一种相机镜头的状态检测方法、装置、设备及存储介质,该方法包括:对相机拍摄得到的目标图像进行异常检测,以获得目标图像中的最终异常区域(S11);对最终异常区域进行分析,确定相机的镜头是否处于异常状态(S12)。上述方法,能够降低对相机镜头的检测难度,并且降低检测成本。

Description

相机镜头的状态检测方法、装置、设备及存储介质
相关申请的交叉引用
本公开要求在2020年10月28日提交中国专利局、申请号为202011172425.2、申请名称为“相机镜头的状态检测方法、装置、设备及存储介质”的中国专利申请的优先权,该中国专利申请的全部内容在此以全文引入的方式引入本公开。
技术领域
本公开涉及检测技术领域,特别是涉及一种相机镜头的状态检测方法、装置、设备及存储介质。
背景技术
相机具备图像采集功能,拍摄的图像数据可以广泛应用于智慧城市、智慧交通、智慧工厂、智慧校园、智慧社区、自动驾驶、机器人感知等各类计算机视觉应用中。一般相机通过其镜头对外部环境进行采集得到图像数据。故相机的镜头在整个应用中作为数据的源头,充当及其重要的角色。
在现实应用中,相机的镜头暴露在室外环境,其通常会遭受风吹雨打,粉尘污染,异常遮挡等影响其正常工作的异常情况。因此,如何监控相机的镜头的状态,以及时发现相机的镜头存在异常情况,就显得至关重要。
发明内容
本公开实施例至少提供一种相机镜头的状态检测方法、装置、设备及存储介质。
本公开实施例第一方面提供了一种相机镜头的状态检测方法,该方法包括:对相机拍摄得到的目标图像进行异常检测,获得目标图像中的最终异常区域;对最终异常区域进行分析,确定相机的镜头是否处于异常状态。
因此,通过对相机拍摄得到的目标图像进行异常检测,直接利用图像异常区域来实现对相机镜头的异常状态检测,无需依赖其它传感器,因此降低了对相机镜头的检测难度,并且降低了检测成本。
其中,上述对相机拍摄得到的目标图像进行异常检测,获得目标图像中的最终异常区域,包括:对相机拍摄得到的目标图像进行模糊检测,得到目标图像中的若干候选异常区域;从若干候选异常区域中选择至少一个候选异常区域,作为最终异常区域。
因此,通过对目标图像进行模糊检测,使得可以根据目标图像的模糊情况来确定目标图像中存在的异常区域,实现了对目标图像的异常区域识别,使得后续可以根据得到的最终异常区域来判断相机镜头的异常情况。而且,镜头的多类异常情况如沾染水雾、沾染污迹、被遮挡等,往往会引起目标图像中一些区域的模糊,因此可通过图像的模糊检测,可使得上述各类异常情况均被检测出来,提高检测广度。
其中,上述对相机拍摄得到的目标图像进行模糊检测,得到目标图像中的若干候选异常区域,包括:对相机拍摄得到的目标图像进行预设变换,得到变换图像,其中,变换图像中各像素的像素值能够反映变化图像的模糊信息;基于变换图像的像素值,确定候选异常区域。
因此,通过直接对目标图像进行预设变换,能够实现对目标图像的模糊度检测,进而获得候选异常区域。
其中,上述对相机拍摄得到的目标图像进行预设变换,得到变换图像,包括:对目标图像进行预处理,得到预处理图像;对预处理图像进行拉普拉斯(Laplacian)变换,得到变换图像。上述的 基于变换图像的像素值,确定候选异常区域,包括:基于变换图像进行二值化处理,得到二值化图像;从二值化图像中查找出像素值满足预设像素条件的像素点,以组成候选异常区域。
因此,经过Laplacian变换以后所得到的值,可以反映变化图像的模糊信息,使得模糊区域的边缘更加明显,同时可以通过得到的像素值的大小,初步得到变换图像中的模糊区域。另外,通过进行图像二值化,可以使得数据量大为减少,以此可以提高运算速度,加快对候选异常区域的检测;同时,还能使得二值化图像中的模糊区域的边界更加明显,突出了候选异常区域。
其中,上述对目标图像进行预处理,得到预处理图像,包括:对目标图像进行灰度化处理,得到预处理图像。上述基于变换图像进行二值化处理,得到二值化图像,包括:对变换图像进行滤波处理,得到滤波图像;滤波处理包括形态学闭运算;对滤波图像进行二值化,得到二值化图像处理。上述从二值化图像中查找出像素值满足预设像素条件的像素点,以组成候选异常区域,包括:将二值化图像的像素值进行取反,得到反二值化图像;从反二值化图像中查找出像素值满足预设像素条件的像素点,以组成候选异常区域。
因此,通过对目标图像进行灰度化处理,可以减少需要运算的数据量,提高运算速度。通过形态学闭运算等滤波处理消除了不模糊区域内部的干扰信息,可以提高针后续对模糊区域检测的准确度,提高对相机镜头是否处于异常状态的判断的准确性。另外,通过取反操作,可以方便后续对模糊区域的处理,提高运算速度,降低检测难度。
其中,上述若干候选异常区域中选择至少一个候选异常区域,作为最终异常区域,包括:获取各候选异常区域的第一面积;从若干候选异常区域中,选择第一面积满足预设面积条件的候选异常区域,作为待定异常区域;将至少一个待定异常区域确定为最终异常区域。
因此,通过对候选异常区域进行进一步的分析,来确定最终异常区域,能够更加准确地识别模糊区域。
其中,上述预设面积条件为第一面积大于第一预设面积阈值。上述将至少一个待定异常区域确定为最终异常区域,包括:确定目标图像中的待定异常区域的至少一个统计值;其中,待定异常区域的至少一个统计值包括对待定异常区域的饱和度统计得到的至少一个第一统计值,和/或,对待定异常区域的像素值统计得到的至少一个第二统计值;若确定待定异常区域的至少一个统计值满足预设统计条件,则将待定异常区域确定为最终异常区域。
因此,通过确定待定异常区域的统计值来进一步判断待定异常区域的模糊情况,以此可以提高模糊检测的准确度,进而提高对相机镜头的状态检测的准确度。
其中,上述第一统计值和第二统计值分别包括均值和方差中的至少一个,上述的预设统计条件包括:待定异常区域的每个统计值均大于对应于统计值的预设阈值。上述确定目标图像中的待定异常区域的至少一个统计值包括:基于待定异常区域的像素位置信息,生成与待定异常区域对应的至少一个掩模,其中,至少一个掩模包括区域掩模和/或边界掩模;在至少一个掩模包括区域掩模的情况下,获取与目标图像对应的饱和度图像,并利用与待定异常区域对应的区域掩模,在饱和度图像中获得与待定异常区域对应的第一待统计区域;对第一待统计区域的饱和度进行统计,得到待定异常区域的至少一个第一统计值;和/或,在至少一个掩模包括边界掩模的情况下,利用与待定异常区域对应的边界掩模,在目标图像中获得与待定异常区域对应的第二待统计区域;对第二待统计区域的像素值度进行统计,得到待定异常区域的至少一个第二统计值。
因此,利用掩模在目标图像中提取与待定异常区域有关的区域,进而可以实现对待定异常区域的统计值的精准统计,提高了后续模糊检测的准确度。
其中,上述对最终异常区域进行分析,确定相机的镜头是否处于异常状态,包括:获取最终异常区域的第二面积;判断最终异常区域的第二面积是否满足预设区域条件;若满足,则确定目标图 像处于异常状态;在检测到连续第一预设数量帧目标图像中存在至少第二预设数量帧处于异常状态的情况下,确定相机镜头处于异常状态;其中,第一预设数量和第二预设数量为正整数。
因此,通过利用目标图像中最终异常区域的面积来确定目标图像的异常状态,并基于预设数量帧目标图像的状态来确定相机镜头是否处于异常状态,由此实现相机镜头的异常检测,而且,当预设数量为大于1时,即利用连续多帧目标图像的状态来综合判断相机镜头是否处于异常状态,故可以提高对相机镜头的状态的检测准确度。
其中,上述判断最终异常区域的第二面积是否满足预设区域条件,包括:判断最终异常区域的第二面积是否满足第一预设区域条件或第二预设区域条件。上述的若满足,则确定目标图像处于异常状态,包括:若满足第一预设区域条件,则确定目标图像处于第一异常状态;若满足第二预设区域条件,则确定目标图像处于第二异常状态。上述的在检测到连续第一预设数量帧目标图像中存在至少第二预设数量帧处于异常状态的情况下,确定相机镜头处于异常状态,包括:在检测到连续第一预设数量帧目标图像均处于第一异常状态的情况下,确定相机镜头处于第一异常状态在检测到连续第一预设数量帧目标图像不均处于第一异常状态,且存在至少第二预设数量帧处于第一异常状态或第二异常状态的情况下,确定相机镜头处于第二异常状态。
因此,通过对相机镜头的异常状态进行进一步的划分,以此可以实现对相机镜头的异常状态更加精准的判断。
其中,上述的第一预设区域条件为第二面积大于第二预设面积阈值;第二预设区域条件为第二面积大于第二预设面积阈值且小于第三预设面积阈值,其中,第二预设面积阈值大于第三预设面积阈值。
本公开实施例第二方面提供了一种相机镜头的状态检测装置,该装置包括:区域检测部分和状态分析部分。
区域检测部分,被配置为对相机拍摄得到的目标图像进行异常检测,获得目标图像中的最终异常区域。状态分析部分,被配置为对最终异常区域进行分析,确定相机的镜头是否处于异常状态。
本公开实施例第三方面提供了一种电子设备,包括相互耦接的存储器和处理器,处理器用于执行存储器中存储的计算机程序,以实现上述第一方面中的相机镜头的状态检测方法。
本公开实施例第四方面提供了一种计算机可读存储介质,其存储有计算机程序,计算机程序被处理器执行时实现上述第一方面中的相机镜头的状态检测方法。
本公开实施例第五方面提供了一种计算机程序,包括计算机可读代码,当计算机可读代码在电子设备中运行时,电子设备中的处理器执行用于实现第一方面中的相机镜头的状态检测方法。
上述方案,通过对相机拍摄得到的目标图像进行异常检测,直接利用图像异常区域来实现对相机镜头的异常状态检测,无需依赖其它传感器,因此降低了对相机镜头的检测难度,并且降低了检测成本。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,而非限制本公开。
附图说明
此处的附图被并入说明书中并构成本说明书的一部分,这些附图示出了符合本公开的实施例,并与说明书一起用于说明本公开的技术方案。
图1A是本公开实施例提供的电子设备应用场景示意图一;
图1B是本公开实施例提供的电子设备方法应用场景示意图二;
图2是本公开实施例提供的相机镜头的状态检测方法第一实施例的流程示意图;
图3是本公开实施例提供的相机镜头的状态检测方法第二实施例的第一流程示意图;
图4是本公开实施例提供的相机镜头的状态检测方法第二实施例的第二流程示意图;
图5是本公开实施例提供的相机镜头的状态检测方法第二实施例的第三流程示意图;
图6是本公开实施例提供的相机镜头的状态检测方法第二实施例的第四流程示意图;
图7是本公开实施例提供的相机镜头的状态检测方法第二实施例的第五流程示意图;
图8是本公开实施例提供的相机镜头的状态检测方法应用场景示意图;
图9是本公开实施例提供的异常区域检测模块处理流程示意图;
图10是本公开实施例提供的各个场景中的灰度图像示意图;
图11是本公开实施例提供的各个场景中的变换图像示意图;
图12是本公开实施例提供的各个场景中的滤波图像示意图;
图13是本公开实施例提供的各个场景中的反二值化图像示意图;
图14是本公开实施例提供的各个场景中的候选异常区域示意图;
图15是本公开实施例提供的相机镜头的状态检测装置一实施例的框架示意图;
图16是本公开实施例提供的电子设备一实施例的框架示意图;
图17为本公开实施例提供的计算机可读存储介质一实施例的框架示意图。
具体实施方式
下面结合说明书附图,对本公开实施例的方案进行详细说明。
以下描述中,为了说明而不是为了限定,提出了诸如特定***结构、接口、技术之类的具体细节,以便透彻理解本公开。
本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系。此外,本文中的“多”表示两个或者多于两个。另外,本文中术语“至少一种”表示多种中的任意一种或多种中的至少两种的任意组合,例如,包括A、B、C中的至少一种,可以表示包括从A、B和C构成的集合中选择的任意一个或多个元素。
本公开实施例所描述相机,可以是任意可实现图像采集的设备,例如摄像机、照相机、手机等终端设备,相机的镜头即为该设备用于形成图像的光学部件。可以理解的,只要是能够拍摄图像或视频的设备,都能应用本公开实施例描述的相机镜头的状态检测方法。在一些可能的实现方式中,本公开实施例描述的相机镜头的状态检测方法可以通过处理器调用存储器中存储的计算机程序的方式来实现。
本公开实施例提供的相机镜头的状态检测方法的执行主体可以为电子设备。
在一种可能的实现方式中,参考图1A所示电子设备应用场景示意图一,电子设备可以包括处理器11和相机12,这样,电子设备11可以通过相机12采集目标图像,通过处理器12对目标图像进行分析处理,以确定相机12的镜头是否处于异常状态。例如,电子设备可以实施为手机。
在另一种可能的实现方式中,参考图1B所示的一种电子设备应用场景示意图二,电子设备10可以通过接收其他设备13通过网络14传送的实时采集到的目标图像,这样,电子设备10可以对接收到的目标图像进行分析处理,从而判断其他设备13的相机镜头是否处于异常状态。例如,电子设备可以实施为计算机,计算机可以通过网络接收摄像装置采集的目标图像。
请参阅图2,图2是本公开实施例相机镜头的状态检测方法第一实施例的流程示意图。具体而言,可以包括如下步骤:
步骤S11:对相机拍摄得到的目标图像进行异常检测,以获得目标图像中的最终异常区域。
本公开实施例中,将利用相机拍摄的图像定义为目标图像。目标图像可以是由相机镜头拍摄的视频中的某一帧图像,也可以是直接拍摄得到的单张图像。在一些公开实施例中,目标图像可以是彩色图像,也可以是灰度图像。
在得到目标图像后,可以直接对目标图像进行异常检测,以得到目标图像中的最终的异常区域。异常检测即是对目标图像中的存在的异常区域进行检测,目标图像的异常区域可以理解为没有正常成像的区域,例如是目标图像存在的模糊区域,或是目标图像的整体都是黑色等等。其中,造成目标图像存在异常区域的情况例如是,镜头沾染了水雾、污渍、镜头存在遮挡,镜头失焦等等。
在对目标图像进行异常检测后,得到的在目标图像中存在异常的区域定义为最终异常区域。最终异常区域可以是目标图像中的一部分,数量可以为一个或多个,最终异常区域也可以是整个目标图像都是异常区域。
步骤S12:对最终异常区域进行分析,确定相机的镜头是否处于异常状态。
在进行异常检测后,可以对得到的最终异常区域进行分析,以更加准确的判断镜头是否处于异常状态。例如,可以对最终异常区域所处的位置、大小、形状、像素信息等等来进行分析,可以理解的,关于最终异常区域的所有信息都可以作为用于分析的基础数据。在一些公开实施例中,可以是结合多个用于分析的基础数据,通过多个数据的分析,来更加准确的确定相机的镜头是否处于异常状态。
在分析时,可以根据需要分析的最终异常区域的基础数据的类型,采用对应的方式进行分析。例如可以采用饱和度分析方式,来对最终异常区域进行饱和度的计算,进而通过最终异常区域的饱和度情况来确定相机的镜头是否处于异常状态,或是采用像素点统计方式,计算最终异常区域所包含的像素点,以此来确定最终区域的面积大小。
在本公开实施例中,通过对相机拍摄得到的目标图像进行异常检测,直接利用图像异常区域来实现对相机镜头的异常状态检测,无需依赖其它传感器,因此降低了对相机镜头的检测难度,并且降低了检测成本。
请参阅图3,图3是本公开实施例相机镜头的状态检测方法第二实施例的第一流程示意图。本实施例在上述第一实施例的基础上,进一步的描述,具体而言,可以包括如下步骤:
步骤S21:对相机拍摄得到的目标图像进行模糊检测,得到目标图像中的若干候选异常区域。
一般而言,当相机的镜头处于异常状态的情况,相机拍摄得到的目标图像都会出现模糊区域,即目标图像中存在不清楚的区域。因此,在本实施例中,可以首先对目标图像进行模糊检测,以初步判断目标图像的异常情况。经过模糊检测以后,可以得到目标图像中的模糊区域,定义为候选异常区域。候选异常区域是目标图像的中一部分时,候选异常区域的数量可以是1个,也可以是多个,具体数量根据模糊检测结果确定。
其中,可通过对目标图像进行相关变换以根据变换结果来确定模糊情况。具体可结合参阅图4进行举例说明。图4是本公开实施例相机镜头的状态检测方法第二实施例的第二流程示意图。在一个公开实施例中,对相机拍摄得到的目标图像进行模糊检测,得到目标图像中的若干候选异常区域,具体可以通过以下步骤实现:
步骤S211:对相机拍摄得到的目标图像进行预设变换,得到变换图像,其中,变换图像中各像素的像素值能够反映变化图像的模糊信息。
对目标图像进行预设变换,变换后得到的图像定义为变换图像。在经过预设变换后,得到的变换图像中各像素的像素值能够反映变化图像的模糊信息。由于是对每一个像素点进行了预设变换,也就能相应得到每个像素点对应的像素值。像素的像素值能够反映变化图像的模糊信息,可以是通过像素的像素值的变化趋势来反映变化图像的模糊信息,例如可以通过像素值的变化趋势来使得模糊区域与不模糊区域的边界更加明显,即使得候选异常区域的更加明显。另外,像素点的像素值大小也可以反映该像素点所在的区域是否模糊。也即,可以通过判断像素点像素值的大小来初步判断模糊区域和不模糊区域。
预设变换可以是对目标图像中每一个像素点的所包含的信息进行处理,处理后到的值为像素值。例如目标图像是彩色图像时,可以根据目标图像的每一个像素点的红(R)、绿(G)、蓝(B)三个颜色通道的值进行处理,最后得到的值即为像素值。预设变换例如是利用Brenner(布伦纳)梯度函数、Tenengrad梯度函数、Laplacian(拉普拉斯)梯度函数或SMD(灰度方差)函数来进行预设变换。可以理解的,只要是可以用于对图像的模糊情况进行检测的方法,都可以应用于本公开实施例中。
在一个公开实施例中,对相机拍摄得到的目标图像进行预设变换,得到变换图像,具体包括以下步骤:
步骤S2111:对目标图像进行预处理,得到预处理图像。
在对目标图像进行预设变换时,可以首先对目标图像进行预处理,得到的图像为预处理图像。预处理可以是针对图像中的每个像素点所包含的信息进行处理,例如是对目标图像的中RGB三通道信息进行处理。
在一个公开实施例中,预处理可以是对目标图像进行灰度化处理,得到灰度图像即为预处理图像。例如,可以根据以下的公式对目标图像进行灰度化处理:
Gray=R×0.299+G×0.587+B×0.114        (1)
上述公式(1)中,R、G、B分别代表某一像素点的红(R)、绿(G)、蓝(B)三个颜色通道的值,得到的值Gray即为该像素点的灰度值。可以理解,灰度化处理的具体计算公式可以根据具体情况相应地调整。
通过灰度化处理,可以将每一个像素点所包含的信息从RGB三通道,转换为灰度值的单通道信息,以此可以简化后续对像素点所包含的信息进行处理时的数据量,提高运算速度。
步骤S2112:对预处理图像进行拉普拉斯变换,得到变换图像。
可以利用Laplacian梯度函数变换,对经过预处理后得到的预处理图像进行处理,得到的图像即为变换图像。通过利用Laplacian变换,可以对预处理图像中真实存在的模糊区域进行检测,以求得在预处理图像中的模糊区域。Laplacian的具体过程例如是先用索贝尔算子(sobel)算子计算二阶x和y差分,再求和,公式如下:
Figure PCTCN2021088211-appb-000001
上述公式(2)中,x和y分别是像素坐标中的每个像素点的坐标,src代表输入图像,dst代表输出图像。
以此,经过Laplacian变换以后,得到的值,即为每一个像素点的像素值,该像素值可以反映变化图像的模糊信息,例如是使得模糊区域的边缘更加明显,同时可以通过得到的像素值的大小的判断,初步得到变换图像中的模糊区域。
请继续参阅图4。
步骤S212:基于变换图像的像素值,确定候选异常区域。
因为变换图像的像素值可以反映变化图像的模糊信息,因此可以基于变换图像的像素值,确定候选异常区域。基于变换图像的像素值,表示可以根据变换图像的像素值的变化趋势、像素值的整体分布情况、或是像素值的大小等等一切与像素值有关的信息来确定候选异常区域。即可以根据变换图像中的一部分的像素值来确定候选异常区域,也可以是根据整个变换图像的像素点来确定。例如,可以通过确定像素点的像素值变化趋势超出一定程度的范围所围成的区域为候选异常区域。
因此,通过直接对目标图像进行预设变换,能够实现对目标图像的模糊度检测,进而获得候选异常区域。
其中,可通过对变换图像进行二值化处理以从变换图像中确定出候选异常区域。具体可结合参 阅图5进行举例说明,图5是本公开实施例相机镜头的状态检测方法第二实施例的第三流程示意图。在一个公开实施例中,“基于变换图像的像素值,确定候选异常区域”具体可以通过以下步骤实现:
步骤S2121:基于变换图像进行二值化处理,得到二值化图像。
为了进一步使各个像素点的像素值之间的差异更加明显,促进变换图像中的模糊区域和不模糊区域的边界更加明显,以准确的确定候选异常区域,可以对变换图像进行二值化处理。例如,可先对变换图像进行阈值分割。阈值分割即是对像素点的像素值进行分类,例如设定一个特征阈值,像素点值小于等于特征阈值的像素点归为一类,像素点值大于特征阈值的像素点归为一类,特征阈值例如是50-80中任意一个数字,如50。
在阈值分割之后,变换图像中的每一个像素点的像素点值被分为两类。此时,可以进行二值化操作,使得这两类像素点的像素值的差异更加明显。例如,可以将像素点值大于特征阈值的像素点的像素度设为第一预设像素值,小于或等于特征阈值的像素点的像素值设为第二预设像素值;该第一预设像素值可以为0,第二预设像素值可以为255;或者第一预设像素值为255,第二预设像素值可以为0。当然,上述第一预设像素值和第二预设像素值也可设为其他像素值,在此不做限定。
通过上述图像二值化,可以使得图像包含的数据量大为减少,以此可以提高运算速度,加快对候选异常区域的检测。同时,还能使得二值化图像中的模糊区域的边界更加明显,突出了候选异常区域。
在一个公开实施例中,“基于变换图像进行阈值分割和图像二值化,得到二值化图像”具体可以包括以下步骤1和步骤2:
步骤1:对变换图像进行滤波处理,得到滤波图像。
经过预设变换后得到的变换图像,在不模糊区域的内部,可能会存在着一小部分的像素点的像素值与其他像素点的像素值存在较大的差异。造成这些差异的原因可能是目标图像在不模糊区域的色彩信息变化或是灰度变化较大,而模糊区域的色彩信息变化或是灰度变化很小,甚至趋近于0,这就使得经过预设变换后的部分像素点的像素值与其它像素点相比,差异较大。体现在变换图像中,即为在不模糊区域的内部,可能会存在孔洞(点状的较大差异像素点的集合)或是小裂缝(条状的较大差异像素点集合),由于其这些孔洞或是小裂缝并不属于模糊区域,为了避免这些孔洞和小裂缝对后续的模糊检测产生影响,可以通过利用滤波处理,来消除这些孔洞或是小裂缝,将不模糊区域连接在一起,并且保持不模糊区域总的位置和形状不变。
具体的,该滤波处理可以但不限包括形态学闭运算。形态学闭运算是先进行膨胀运算,再进行腐蚀运算。
膨胀运算可以用来填补不模糊区域的空洞以及消除包含在不模糊区域中的小颗粒噪声(不模糊区域中的干扰信息)。公式如下:
Figure PCTCN2021088211-appb-000002
其中,A可以是不模糊区域,B可以是结构元素。通过结构元素B来对不模糊区域A进行膨胀处理。
腐蚀运算可以造成不模糊区域的边界收缩,可以用来消除一些小孔洞或是小裂缝。公式如下:
Figure PCTCN2021088211-appb-000003
变换图像经过形态学闭运算后,得到的图像定义为滤波图像。此时,滤波图像中已经通过形态学闭运算消除了不模糊区域内部的干扰信息,可以提高后续针对模糊区域检测的准确度,提高对相机镜头是否处于异常状态的判断的准确性。
步骤2:对滤波图像进行二值化处理,得到二值化图像。
在利用滤波处理消除不模糊区域的孔洞或小裂缝后,为了使得不模糊区域和模糊区域的边界更 加明显,同时简化运算量,可以采用如上二值化处理,处理后得到的图像即为二值化图像。
继续参阅图5。
步骤S2122:从二值化图像中查找出像素值满足预设像素条件的像素点,以组成候选异常区域。
在得到二值化图像以后,此时的二值化图像中的像素点的像素值只有两个。此时,可以查找出像素值满足预设像素条件的像素点,这些像素点组成的区域即为候选异常区域。例如,当把不模糊区域的像素点的像素值设为较小的值后,则可以选择二值化图像中像素值较大的点来组成模糊区域。在一个具体实施场景中,可以把不模糊区域的像素点的像素值设为255,通过利用OpenCV开源计算机视觉库中的cv::findContours函数,来查找像素值为255的像素点。
在一个公开实施例中,在对变换图像进行图像二值化操作时,可能会把模糊区域的像素值设为0,由于模糊区域的像素值为0不方便后续对模糊区域的处理,为了提高运算的速度,减少计算的难度。此时可以执行以下步骤,以实现“从二值化图像中查找出像素值满足预设像素条件的像素点,以组成候选异常区域”,具体包括以下步骤1和步骤2:
步骤1:将二值化图像的像素值进行取反,得到反二值化图像。
在进行图像二值化操作后,如果把模糊区域的像素值设为0,不模糊区域设为大于0的值,则可以进行取反操作,即把不模糊区域和模糊区域的像素值互换。例如,当模糊区域的像素值为0,不模糊区域的像素值为255时,进行取反操作以后,模糊区域的像素值为255,不模糊区域的像素值为0。以此,可以使得模糊区域的像素值不为0,可以方便后续对模糊区域的处理,提高运算速度,降低检测难度。
在一个公开实施例中,进行阈值分割,图像二值化和取反操作的公式如下:
Figure PCTCN2021088211-appb-000004
其中,thresh为预设值的像素阈值,max Val为最大像素值。
在将二值化图像的像素值进行取反操作后,得到的图像定义为反二值化图像。
步骤2:从反二值化图像中查找出像素值满足预设像素条件的像素点,组成候选异常区域。
在反二值化图像中,也可以查找出像素值满足预设像素条件的像素点,像素值满足预设像素条件的像素点。由于模糊区域的像素值是大于0的,则预设像素条件可以是像素点的像素值大于0。查找像素点的方法可以是利用OpenCV开源计算机视觉库中的cv::findContours函数来查找。
请继续参阅图3。
步骤S22:从若干候选异常区域中选择至少一个候选异常区域,作为最终异常区域。
在得到候选异常区域以后,可以在候选异常区域中选择至少一个,以作为最终异常区域。例如可以对候选异常区域进行一定处理之后,再从中选择至少一个作为最终异常区域。
请参阅图6,图6是本公开实施例相机镜头的状态检测方法第二实施例的第四流程示意图。在一个公开实施例中,为了更加准确地识别模糊区域,可以对候选异常区域进行进一步的分析,来确定最终异常区域。例如,“从若干候选异常区域中选择至少一个候选异常区域,作为最终异常区域”具体可以包括以下步骤:
步骤S221:获取各候选异常区域的第一面积。
候选异常区域的面积定义为第一面积。候选异常区域的面积可以是通过统计候选异常区域的所包含的像素点的数量确定,例如,某一候选异常区域包含的像素点的数量为100个,则该候选异常区域的第一面积大小为100个像素点的大小。
步骤S222:从若干候选异常区域中,选择第一面积满足预设面积条件的候选异常区域,作为待定异常区域。
在获得候选异常区域的面积后,可以通过判断候选异常区域的面积是否满足预设面积条件来对候选异常区域进行筛选,满足预设面积条件的候选异常区域,定义为待定异常区域。
在一个具体实施场景中,预设面积条件可以是第一面积大于第一预设面积阈值。第一预设面积阈值例如是2500-3000个像素点大小的任一数值,如2500个像素点大小。由于模糊区域的面积一般较大,通过设定第一面积阈值,可以把面积较小的候选异常区域排除在外,提高了对模糊区域识别的准确度。
步骤S223:将至少一个待定异常区域确定为最终异常区域。
在对候选异常区域进行筛选以后,就可以从得到的待定异常区域中,选择出至少一个,作为最终异常区域。具体选择时,可以对待定异常区域进行一定处理之后,再从中选择至少一个来作为最终异常区域。
请参阅图7,图7是本公开实施例相机镜头的状态检测方法第二实施例的第五流程示意图。在一个公开实施例中,在对待定异常区域进行进一步的分析时,“将至少一个待定异常区域确定为最终异常区域”具体可以包括以下步骤:
步骤S2231:确定目标图像中的待定异常区域的至少一个统计值。
在得到目标图像中的待定异常区域后,可以针对待定异常区域进行处理,以进一步判断待定异常区域是否为最终异常区域。
在本公开实施例中,可以对待定异常区域进行统计,以此来获得与待定异常区域相关的统计值。例如,可以通过利用目标图像的饱和度信息,来对待定异常区域进行进一步的分析。具体而言,可以是对待定异常区域的饱和度进行统计,以此来获得到至少一个第一统计值。或者,还可以对待定异常区域的像素值进行统计,以此来获得至少一个第二统计值。可以理解的,在实施本公开描述的相机镜头的状态检测方法时,可以获取第一统计值和第二统计值作为该待定异常区域的统计值,也可以选择其中一个作为该待定异常区域的统计值。
在一个公开实施例中,饱和度的计算公式如下:
Figure PCTCN2021088211-appb-000005
其中,max(R,G,B)是对目标图像中的每一个像素点的RGB值进行处理后得到的最大值,min(R,G,B)像素值对目标图像中的每一个像素点的RGB值进行处理后得到的最小值,S表示目标图像的饱和度。对目标图像中像素点的RGB值处理方法例如是上述提及的公式(1)。
在一个公开实施例中,上述的第一统计值和第二统计值分别包括均值和方差中的至少一个。即,该至少一个第一统计值包括待定异常区域的饱和度的均值和/或方差,该至少一个第二统计值包括待定异常区域的像素值的均值和/或方差。
在一个公开实施例中,步骤S2231具体可以包括以下步骤1至步骤3。
步骤1:基于待定异常区域的像素位置信息,生成与待定异常区域对应的至少一个掩模,其中,至少一个掩模包括区域掩模和/或边界掩模。
在获得了组成待定异常区域的像素点以后,就可以通过分析这些待定异常区域的像素点的位置信息,如坐标,来确定这些像素点的位置。另外,也就可以根据待定异常区域的像素位置信息,生成与待定异常区域对应的一个掩模。与待定异常区域对应的掩模即为与整个待定异常区域的形状、大小一致,或是只与待定异常区域的部分区域的形状、大小一致。掩模可以用于遮挡待定异常区域。在一个具体实施场景中,掩模可以是一种图像,图形等等,用于遮挡待定异常区域。
在生成掩模时,一个完整的待定异常区域对应的掩模,为区域掩模;生成与一个待定异常区域的边界对应的掩模,为边界掩模。可以理解的,生成的掩模的数量和形状不受限制。例如,可以对 全部待定异常区域,生成与每一待定异常区域对应的区域掩模和边界掩模。
步骤2:在至少一个掩模包括区域掩模的情况下,获取与目标图像对应的饱和度图像,并利用与待定异常区域对应的区域掩模,在饱和度图像中获得与待定异常区域对应的第一待统计区域;对第一待统计区域的饱和度进行统计,得到待定异常区域的至少一个第一统计值。
在步骤1中,若生成的掩模中包括区域掩模,此时可以获取与目标图像对应的饱和度图像。具体而言,可以对目标图像的每一个像素点进行饱和度计算,以此来获取与目标图像对应的饱和度图像。饱和度计算例如是将RGB图像转换为色调-饱和度-明度(HSV)图像,并提取饱和度S通道的值。
在获得饱和度图像以后,可以通过目标图像中待定异常区域的像素点的位置信息,如坐标,来得到待定异常区域在饱和度图像上对应的位置,即第一待统计区域。例如,目标图像上的待定异常区域中某一像素点的坐标为(1,1),则在饱和度图像中,与该像素点对应的像素点的坐标也是(1,1)。因此,可以在饱和度图像中得到与待定异常区域对应的第一待统计区域。
在一个公开实施例中,也可以是直接利用待定异常区域的像素点的位置信息,直接在饱和度图像中直接提取中对应的像素点,来组成第一待统计区域,再进行饱和度的统计。
同时,还可以对第一待统计区域的饱和度进行统计,将统计得到的值定义为第一统计值。对第一待统计区域的饱和度进行统计,既可以是整个待定异常区域进行统计,也可以是对待定异常区域的某一部分进行统计。统计的方法不是限制,例如是可以统计待定异常区域的饱和度平均值,方差、标准差等等。在对待定异常区域的不同部分进行统计,以及对待定异常区域进行多种类型的统计时,可以得到数个不同的统计值。
另外,在步骤1中,若生成的掩模中包括边界掩模,此时可以执行步骤3。
步骤3:利用与待定异常区域对应的边界掩模,在目标图像中获得与待定异常区域对应的第二待统计区域;对第二待统计区域的像素值进行统计,得到待定异常区域的至少一个第二统计值。
在生成与待定异常区域对应的边界掩模后,边界掩模所覆盖的区域,为与待定异常区域对应的第二待统计区域。此时,可以对第二待统计区域的像素值进行统计,像素值例如是灰度值,统计得到的统计值为第二统计值。
可以理解的,若同时存在区域掩模和掩模,既可以执行步骤2和步骤3,也可以只执行其中一个步骤。
以上,通过利用掩模来提取与待定异常区域有关的区域,可以实现对待定异常区域的第一统计值和第二统计值的精准统计,提高了计算的准确度。
请继续参阅图7。
步骤S2232:若确定待定异常区域的至少一个统计值满足预设统计条件,则将待定异常区域确定为最终异常区域。
在得到第一统计值和第二统计值后,就可以对统计值进行分析,以进一步的判断待定异常区域是否为模糊区域,得到最终异常区域。具体的,若确定待定异常区域的至少一个统计值满足预设统计条件,则将待定异常区域确定为最终异常区域。预设统计条件可以是统计值的大小处于某一特定的范围。例如,当统计值是算术平均值时,则预设条件可以是算数平均值处于40-216之间。
当统计值有多个时,可以认为只要有一个统计值满足预设统计条件,则可以将待定异常区域确定为最终异常区域,也可以是数个统计值满足预设统计条件,或是全部统计值均满足预设统计条件。
在一个公开实施例中,预设统计条件可以是待定异常区域的每个统计值均大于对应于统计值的预设阈值。例如,当统计值包括待定异常区域的整体和边界的算术平均值和方差时,则意味着一个待定异常区域,会有4个统计值,分别是待定异常区域整体的算术平均值和方差,待定异常区域边 界的算术平均值和方差。只有这4个统计值均大于对应于统计值的预设阈值时,才将待定异常区域确定为最终异常区域。
在一个公开实施例中,算术平均值的预设阈值可以是40,方差的预设阈值可以是100。
通过利用统计值来对待定异常区域进行进一步的分析,可以进一步判断待定异常区域的模糊情况,以此可以提高模糊检测的准确度,进而提高对相机镜头的状态检测的准确度。
在一个公开实施例中,如果已经得到最终异常区域,可以直接认为该帧目标图像是处于异常状态,而不必进行后续的操作。以此,可以简化检测的步骤,加快检测的速度。
在获得最终异常区域后,即等于获得了图像的最终的模糊区域。此时,可以通过对最终异常区域进行分析,来确定相机镜头是否处于异常状态。
请继续参阅图3。步骤S23:获取最终异常区域的第二面积;
可以通过获取最终异常区域的面积来对模糊区域进行分析。最终异常区域的面积定义为第二面积。最终异常区域的面积同样也可以用其所包含的像素点的多少来表示。例如,某一最终异常区域包含3000个像素点,则该最终异常区域的面积为3000个像素点的大小。
步骤S24:判断最终异常区域的第二面积是否满足预设区域条件。若满足,则执行步骤S25,若不满足,则执行步骤S27。
在获得了最终异常区域的第二面积以后,可以通过判断第二面积是否满足预设区域条件,来对最终异常区域进行分类。预设区域条件例如是面积的大小,或是最终异常区域在目标图像中的位置等等。
在一个公开实施例中,预设区域条件可以包括第一预设区域条件或第二预设区域条件。在此情况下,“判断最终异常区域的第二面积是否满足预设区域条件”具体是包括:判断最终异常区域的第二面积是否满足第一预设区域条件或第二预设区域条件。
在一个实施场景中,第一预设区域条件为第二面积大于第二预设面积阈值;第二预设区域条件为第二面积大于第二预设面积阈值且小于第三预设面积阈值,其中,第二预设面积阈值大于第三预设面积阈值。第二预设面积阈值可以是5000个像素点的大小,第三预设面积阈值可以是3000个像素点的大小。
步骤S27:若不满足,则确定目标图像处于正常状态。
在一个公开实施例中,如果最终异常区域的第二面积不满足预设区域条件,则可以认为目标图像处于正常状态。
步骤S25:若满足,则确定目标图像处于异常状态。
在对最终异常区域的第二面积是否满足预设区域条件进行判断之后,可以根据得到的结果,来确定目标图像是否处于异常状态。
具体的,当最终异常区域的第二面积满足预设区域条件时,可以认为,最终异常区域对相机镜头获取的目标图像影响较大,则可以认为该张目标图像处于异常状态。可以理解的,当最终异常区域的第二面积不满足预设区域条件时,则可以认为该帧目标图像处于正常的状态。
当预设区域条件包括第一预设区域条件或第二预设区域条件时,则可以针对这两个条件,对最终异常区域进行进一步的分类。具体的,当最终异常区域的第二面积满足第一预设区域条件时,可以确定目标图像处于第一异常状态;当最终异常区域的第二面积满足第二预设区域条件,则确定目标图像处于第二异常状态。
在一个具体实施场景中,因为第一预设区域面积大于第二预设区域面积,因此可以认为满足第一预设区域面积时,目标图像的异常状态更加严重。第一异常状态例如是错误状态,第二异常状态例如是警告状态。
通过对最终异常区域的进一步分类,可以对目标图像的异常状态进行进一步的划分,以此可以实现对目标图像的异常状态更加精准的判断。
以上,通过对一帧目标图像进行模糊检测,可以判断该帧目标图像的异常状态。可以理解的,当相机的镜头的处于异常状态时,一般来说,其拍摄的连续数帧目标图像,都会是处于异常状态的。因此,可以通过对处于异常状态的目标图像的数量进行分析,来进一步判断相机镜头的状态。基于此,可以在步骤S25之后,继续执行以下步骤:
步骤S26:在检测到连续第一预设数量帧目标图像中存在至少第二预设数量帧处于异常状态的情况下,确定相机镜头处于异常状态;其中,第一预设数量和第二预设数量为正整数。
如果检测到连续第一预设数量帧的目标图像中,存在着至少第二预设数量帧处于异常状态的情况,则意味着相机镜头很有可能处于异常状态,使得在连续输帧的目标图像中,出现了较多的异常目标图像。可以理解的,因为目标图像的单位是帧数,所以第一预设数量和第二预设数量为正整数。第一预设数量例如是30,第二预设数量例如是15。
在一个公开实施例中,也可以是对相机镜头在一段时间内拍摄的目标头像中,周期性地抽取部分目标图像,来判断抽取的目标图像是否处于异常状态。以此可以判断相机镜头在一定的时间内,是否处于异常状态,进而可以提高对相机镜头的检测准确度。
在一个公开实施例中,对应于上述的预设区域条件包括第一预设区域条件或第二预设区域条件,进而可以判断出目标图像处于第一异常状态或是第二异常状态的情况,可能会出现以下几种情形:
第一种情形:如果检测到连续第一预设数量帧的目标图像均处于第一异常状态的情况下,则可以确定相机镜头处于第一异常状态。此时可以认为相机镜头的异常状态比较严重,第一异常状态例如是错误状态。
第二种情形:如果检测到连续第一预设数量帧的目标图像均处于正常状态,则此时可以认为相机镜头处于正常状态。
第三种情形:如果检测到连续第一预设数量帧的目标图像不是全部处于第一异常状态,且存在至少第二预设数量帧的目标图像处于第一异常状态或第二异常状态的情况,确定相机镜头处于第二异常状态。此时,可能的情况有,连续第一预设数量帧的目标图像均处于第二异常状态,或者连续第一预设数量帧的目标图像的至少第二预设数量帧图像(第二预设数量不等于第一预设数量)处于第一异常状态或第二异常状态。对于这种情形,可以认为相机镜头可能会处于异常状态,因此认定相机镜头处于第二异常状态。第二异常状态例如是警告状态。第二预设数量具体可根据实际情况设置,例如可以是1、5、15等任意正整数。
通过利用目标图像中最终异常区域的面积来确定目标图像的异常状态,并基于预设数量帧目标图像的状态来确定相机镜头是否处于异常状态,由此实现相机镜头的异常检测,而且,当预设数量为大于1时,即利用连续多帧目标图像的状态来综合判断相机镜头是否处于异常状态,故可以提高对相机镜头的状态的检测准确度。
上述的方案,通过对目标图像进行模糊检测,使得可以根据目标图像的模糊情况来确定目标图像中存在的异常区域,实现了对目标图像的异常区域识别,使得后续可以根据得到的最终异常区域来判断相机镜头的异常情况。而且,镜头的多类异常情况如沾染水雾、沾染污迹、被遮挡等,往往会引起目标图像中一些区域的模糊,因此可通过图像的模糊检测,可使得上述各类异常情况均被检测出来,提高检测广度。
本领域技术人员可以理解,在具体实施方式的上述方法中,各步骤的撰写顺序并不意味着严格的执行顺序而对实施过程构成任何限定,各步骤的具体执行顺序应当以其功能和可能的内在逻辑确定。
下面结合具体应用场景,对本公开实施例提供的相机镜头的状态检测方法进行详细阐述。
在实施例提供的应用场景中,参考图8所示,相机镜头的状态检测方法可以通过异常区域检测模块81、异常区域过滤模块82、状态分析处理模块83和控制处理模块84完成。
其中,异常区域检测模块81,可以对目标图像的异常区域进行检测。异常区域的类型包括:镜头沾染水雾;镜头沾染污渍,镜头存在遮挡等类型。另外,异常区域过滤模块82,可以对异常区域检测模块的结果进行过滤。过滤通过一系列人工设计的规则和特征实现。此处的过滤规则包括区域大小,区域颜色,区域边界特征等统计信息。
状态分析处理模块83,可以通过人工设置的阈值,检测相机镜头的状态否为异常状态。状态分析处理模块的处理结果可以分为正常、异常、错误三种状态。其中正常状态,即相机镜头不存在任何异常。异常状态,即相机镜头的状态存在轻微异常,但是不严重。错误状态,即相机镜头状态异常严重,需要立即进行停机操作。该模块的输出结果可以交给控制模块84处理,便于控制模块针对不同的状态做出不同的响应。
在本公开实施例中,参考图9所示,异常区域检测模块81可以执行以下步骤:
步骤811、获取目标图像。该目标图像为相机拍摄得到的图像。
步骤812、对目标图像进行灰度化处理,得到灰度图像。
这里,目标图像为彩色RGB图像。可以根据上述公式(1)对目标图像进行灰度化处理,得到每个像素点的灰度值,从而得到灰度图像。
示例性的,图10不同场景下的灰度图像。其中,图10中的1001为正常情况的灰度图像,图10中的1002为相机镜头沾染水雾的灰度,图10中的1003为相机镜头沾染污渍的灰度图像,图10中的1004为相机镜头存在遮挡的灰度图像。
步骤813、对灰度图像进行Laplacian变换,得到变换图像。
其中,Laplacian的具体过程例如是先用sobel算子计算二阶x和y差分,再求和,公式参见上述公式(2)。
示例性的,对图10所示的灰度图像进行Laplacian变换后,可以得到图11所示的变换图像。其中,图11中的1101为正常情况下采集的变换图像,图11中的1102为相机镜头沾染水雾的变换图像,图11中的1103为相机镜头沾染污渍的变换图像,图11中的1104为相机镜头存在遮挡的变换图像。
步骤814、对变换图像进行滤波处理,得到滤波图像。
其中,滤波处理可以但不限包括形态学闭运算。形态学闭运算是先进行膨胀运算,再进行腐蚀运算。具体的膨胀运算和腐蚀运算的过程与上述实施例相同,此处不再赘述。
示例性的,对图11所示的变换图像进行形态学闭运算处理后,可以得到图12所示的滤波图像。其中,图12中的1201为正常情况下采集的滤波图像,图12中的1202为相机镜头沾染水雾的滤波图像,图12中的1203为相机镜头沾染污渍的滤波图像,图12中的1204为相机镜头存在遮挡的滤波图像。
步骤815、对滤波图像进行二值化处理,得到二值化图像。
步骤816、将二值化图像的像素值进行取反处理,得到反二值化图像。
需要说明的是,对滤波图像进行二值化处理和取反操作的公式可以参考上述实施例中的公式(5),此处不再赘述。
示例性的,对图12所示的滤波图像进行二值化处理以及取反处理后,可以得到图13所示的反二值化图像。其中,图13中的1301为正常情况下的反二值化图像,图13中的1302为相机镜头沾染水雾的反二值化图像,图13中的1303为相机镜头沾染污渍的反二值化图像,图13中的1304为 相机镜头存在遮挡的反二值化图像。
步骤817、从反二值化图像中查找出像素值满足预设像素条件的像素点,以组成若干个候选异常区域。
这里,对反二值图像进行轮廓区域查找,获取独立的个体异常区域。具体实现可以利用OpenCV开源计算机视觉库中的cv::findContours函数。
示例性的,如图14中用实线框框出的区域即为不同场景下的候选异常区域。
在本公开实施例中,异常区域过滤模块82,可以执行以下步骤:
步骤821、获取各候选异常区域的第一面积。
步骤822、从若干候选异常区域中,选择第一面积满足预设面积条件的至少一个候选异常区域,作为待定异常区域。
其中,预设面积条件为第一面积大于第一预设面积阈值。也就是说,可以对异常候选轮廓进行面积过滤,删除面积过小的区域,得到待定异常区域。
步骤823、基于待定异常区域的像素位置信息,生成与待定异常区域对应的至少一个掩模,其中,至少一个掩模包括区域掩模和/或边界掩模。
步骤824、在至少一个掩模包括区域掩模的情况下,获取与目标图像对应的饱和度图像,并利用与待定异常区域对应的区域掩模,在饱和度图像中获得与待定异常区域对应的第一待统计区域;对第一待统计区域的饱和度进行统计,得到待定异常区域的至少一个第一统计值。
具体地,可以根据公式(6)计算目标图像的饱和度信息,得到饱和度图像。
其中,第一统计值可以是待定异常区域的饱和度的均值和方差中的一个。
步骤825、利用与待定异常区域对应的边界掩模,在目标图像中获得与待定异常区域对应的第二待统计区域;对第二待统计区域的像素值进行统计,得到待定异常区域的至少一个第二统计值。
第二统计值包括均值和方差中的至少一个。
步骤826、若确定待定异常区域的至少一个统计值满足预设统计条件,则将待定异常区域确定为最终异常区域。
在本公开实施例中,状态分析处理模块83,可以执行以下步骤:
步骤831、获取最终异常区域的第二面积。
这里,可以利用OpenCV开源计算机视觉库中的cv::contourArea函数,计算最总异常区域的第二面积。
步骤832、判断最终异常区域的第二面积是否满足第一预设区域条件或第二预设区域条件。
其中,第一预设区域条件为第二面积大于第二预设面积阈值。第二预设区域条件为第二面积大于第二预设面积阈值且小于第三预设面积阈值,其中,第二预设面积阈值大于第三预设面积阈值。
步骤833、若满足第一预设区域条件,则确定目标图像处于第一异常状态;若满足第二预设区域条件,则确定目标图像处于第二异常状态。
步骤834、在检测到连续第一预设数量帧目标图像均处于第一异常状态的情况下,确定所述相机镜头处于所述第一异常状态。
在检测到连续第一预设数量帧目标图像不均处于第一异常状态,且存在至少第二预设数量帧处于第一异常状态或所述第二异常状态的情况下,确定相机镜头处于第二异常状态。
由此可见,通过对目标图像进行模糊检测,使得可以根据目标图像的模糊情况来确定目标图像中存在的异常区域,实现了对目标图像的异常区域识别,使得后续可以根据得到的最终异常区域来判断相机镜头的异常情况。而且,镜头的多类异常情况如沾染水雾、沾染污迹、被遮挡等,往往会引起目标图像中一些区域的模糊,因此可通过图像的模糊检测,可使得上述各类异常情况均被检测 出来,提高检测广度。
请参阅图15,图15是本公开实施例相机镜头的状态检测装置一实施例的框架示意图。该检测装置70包括区域检测部分71和状态分析部分72。区域检测部分71被配置为对相机拍摄得到的目标图像进行异常检测,以获得目标图像中的最终异常区域。状态分析部分72被配置为对最终异常区域进行分析,确定相机的镜头是否处于异常状态。
其中,区域检测部分71,还被配置为对相机拍摄得到的目标图像进行模糊检测,得到目标图像中的若干候选异常区域;执行从若干候选异常区域中选择至少一个候选异常区域,作为最终异常区域。
其中,区域检测部分71,还被配置为对相机拍摄得到的目标图像进行预设变换,得到变换图像,其中,变换图像中各像素的像素值能够反映变化图像的模糊信息;执行基于变换图像的像素值,确定候选异常区域。
其中,区域检测部分71,还被配置为用对目标图像进行预处理,得到预处理图像;执行对预处理图像进行拉普拉斯变换,得到变换图像。区域检测部分71,还被配置为基于变换图像进行二值化处理,得到二值化图像;执行从二值化图像中查找出像素值满足预设像素条件的像素点,以组成候选异常区域。
其中,区域检测部分71,还被配置为对目标图像进行灰度化处理,得到预处理图像。区域检测部分71,还配置为对变换图像进行滤波处理,得到滤波图像。其中,滤波处理可以但不限为形态学闭运算。执行对滤波图像进行二值化处理,得到二值化图像。区域检测部分71,还被配置为执行将二值化图像的像素值进行取反,得到反二值化图像。执行从反二值化图像中查找出像素值满足预设像素条件的像素点,以组成候选异常区域。
其中,区域检测部分71,还被配置为获取各候选异常区域的第一面积;执行从若干候选异常区域中,选择第一面积满足预设面积条件的候选异常区域,作为待定异常区域;执行将至少一个待定异常区域确定为最终异常区域。
其中,上述的预设面积条件为第一面积大于第一预设面积阈值。
其中,区域检测部分71,还被配置为执行确定目标图像中的待定异常区域的至少一个统计值;其中,待定异常区域的至少一个统计值包括对待定异常区域的饱和度统计得到的至少一个第一统计值,和/或,对待定异常区域的像素值统计得到的至少一个第二统计值;若确定待定异常区域的至少一个统计值满足预设统计条件,则将待定异常区域确定为最终异常区域。
其中,上述的至少一个统计值包括均值和方差中的至少一个。上述的预设统计条件包括:待定异常区域的每个统计值均大于对应于统计值的预设阈值。
其中,区域检测部分71,还配置为基于待定异常区域的像素位置信息,生成与待定异常区域对应的至少一个掩模,其中,至少一个掩模包括区域掩模和/或边界掩模;在至少一个掩模包括区域掩模的情况下,获取与目标图像对应的饱和度图像,并利用与待定异常区域对应的区域掩模,在饱和度图像中获得与待定异常区域对应的至少一个第一待统计区域,其中,至少一个待统计区域包括整体区域和/或边界区域;获取与目标图像对应的饱和度图像,并对确定在第一待统计区域饱和度图像中与整体区域对应的区域的饱和度进行统计,得到待定异常区域的至少一个第一统计值;和/或,在至少一个掩模包括边界掩模的情况下,利用与待定异常区域对应的边界掩模,在目标图像中获得与待定异常区域对应的第二待统计区域;对第二待统计区域的像素值度进行统计,得到待定异常区域的至少一个第二统计值。
其中,状态分析部分72,还被配置为执行获取最终异常区域的第二面积;执行判断最终异常区域的第二面积是否满足预设区域条件;若满足,执行确定目标图像处于异常状态;执行在检测到连 续第一预设数量帧目标图像中存在至少第二预设数量帧处于异常状态的情况下,确定相机镜头处于异常状态;其中,第一预设数量和第二预设数量为正整数。
其中,状态分析部分72,还被配置为判断最终异常区域的第二面积是否满足第一预设区域条件或第二预设区域条件。若满足,状态分析部分72,还被配置为若满足第一预设区域条件,执行确定目标图像处于第一异常状态;若满足第二预设区域条件,执行确定目标图像处于第二异常状态。状态分析部分72,还被配置为在检测到连续第一预设数量帧目标图像均处于第一异常状态的情况下,确定相机镜头处于第一异常状态;执行在检测到连续第一预设数量帧目标图像不均处于第一异常状态,且存在至少第二预设数量帧处于第一异常状态或第二异常状态的情况下,确定相机镜头处于第二异常状态。
其中,上述的第一预设区域条件为第二面积大于第二预设面积阈值;第二预设区域条件为第二面积大于第二预设面积阈值且小于第三预设面积阈值,其中,第二预设面积阈值大于第三预设面积阈值。
请参阅图16,图16是本公开实施例电子设备一实施例的框架示意图。电子设备80包括相互耦接的存储器81和处理器82,处理器82用于执行存储器81中存储的计算机程序,以实现上述任一相机镜头的状态检测方法实施例的步骤。在一个具体的实施场景中,电子设备80可以包括但不限于:微型计算机、服务器,此外,电子设备80还可以包括笔记本电脑、平板电脑等移动设备,在此不做限定。
具体而言,处理器82用于控制其自身以及存储器81以实现上述任一相机镜头的状态检测方法实施例的步骤。处理器82还可以称为CPU(Central Processing Unit,中央处理单元)。处理器82可能是一种集成电路芯片,具有信号的处理能力。处理器82还可以是通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。另外,处理器82可以由集成电路芯片共同实现。
请参阅图17,图17为本公开实施例计算机可读存储介质一实施例的框架示意图。计算机可读存储介质90存储有能够被处理器运行的计算机程序901,计算机程序901用于实现上述任一相机镜头的状态检测方法实施例的步骤。
本公开实施例还提出一种计算机程序,包括计算机可读代码,当所述计算机可读代码在电子设备中运行时,所述电子设备中的处理器执行配置为实现上述机镜头的状态检测方法实施例的步骤。
在一些实施例中,本公开实施例提供的装置、设备或介质具有的功能或包含的部分可以用于执行上文方法实施例描述的方法,其具体实现可以参照上文方法实施例的描述,为了简洁,这里不再赘述。
上文对各个实施例的描述倾向于强调各个实施例之间的不同之处,其相同或相似之处可以互相参考,为了简洁,本文不再赘述。
在本公开所提供的几个实施例中,应该理解到,所揭露的方法和装置,可以通过其它的方式实现。例如,以上所描述的装置实施方式仅仅是示意性的,例如,部分或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如单元或组件可以结合或者可以集成到另一个***,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性、机械或其它的形式。
另外,在本公开各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形 式实现,也可以采用软件功能单元的形式实现。
集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本公开实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(processor)执行本公开实施例各个实施方式方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。

Claims (25)

  1. 一种相机镜头的状态检测方法,包括:
    对相机拍摄得到的目标图像进行异常检测,获得所述目标图像中的最终异常区域;
    对所述最终异常区域进行分析,确定所述相机的镜头是否处于异常状态。
  2. 根据权利要求1所述的方法,其中,所述对相机拍摄得到的目标图像进行异常检测,以获得所述目标图像中的最终异常区域,包括:
    对所述相机拍摄得到的所述目标图像进行模糊检测,得到所述目标图像中的若干候选异常区域;
    从所述若干候选异常区域中选择至少一个所述候选异常区域,作为所述最终异常区域。
  3. 根据权利要求2所述的方法,其中,所述对相机拍摄得到的目标图像进行模糊检测,得到所述目标图像中的若干候选异常区域,包括:
    对所述相机拍摄得到的所述目标图像进行预设变换,得到变换图像,其中,所述变换图像中各像素的像素值能够反映所述变化图像的模糊信息;
    基于所述变换图像的像素值,确定所述候选异常区域。
  4. 根据权利要求3所述的方法,其中,所述对相机拍摄得到的所述目标图像进行预设变换,得到变换图像,包括:
    对所述目标图像进行预处理,得到预处理图像;
    对所述预处理图像进行拉普拉斯变换,得到所述变换图像;
    所述基于所述变换图像的像素值,确定所述候选异常区域,包括:
    基于所述变换图像进行二值化处理,得到二值化图像;
    从所述二值化图像中查找出所述像素值满足预设像素条件的像素点,组成所述候选异常区域。
  5. 根据权利要求4所述的方法,其中,所述对所述目标图像进行预处理,得到预处理图像,包括:
    对所述目标图像进行灰度化处理,得到预处理图像;
    所述基于所述变换图像进行二值化处理,得到二值化图像,包括:
    对所述变换图像进行滤波处理,得到滤波图像;所述滤波处理包括形态学闭运算;
    对所述滤波图像进行二值化处理,得到所述二值化图像;
    所述从所述二值化图像中查找出所述像素值满足预设像素条件的像素点,组成所述候选异常区域,包括:
    将所述二值化图像的像素值进行取反,得到反二值化图像;
    从所述反二值化图像中查找出所述像素值满足所述预设像素条件的像素点,组成所述候选异常区域。
  6. 根据权利要求2至5任一项所述的方法,其中,所述从所述若干候选异常区域中选择至少一个所述候选异常区域,作为所述最终异常区域,包括:
    获取各所述候选异常区域的第一面积;
    从所述若干候选异常区域中,选择所述第一面积满足预设面积条件的至少一个候选异常区域,作为待定异常区域;
    将至少一个所述待定异常区域确定为所述最终异常区域。
  7. 根据权利要求6所述的方法,其中,所述预设面积条件为所述第一面积大于第一预设面积阈值;和/或,
    所述将至少一个所述待定异常区域确定为所述最终异常区域,包括:
    确定所述目标图像中的所述待定异常区域的至少一个统计值;其中,所述待定异常区域的至少一个统计值包括对所述待定异常区域的饱和度统计得到的至少一个第一统计值,和/或,对所述待定异常区域的像素值统计得到的至少一个第二统计值;
    若确定所述待定异常区域的至少一个统计值满足预设统计条件,则将所述待定异常区域确定为所述最终异常区域。
  8. 根据权利要求7所述的方法,其中,所述第一统计值和第二统计值分别包括均值和方差中的至少一个,所述预设统计条件包括:所述待定异常区域的每个所述统计值均大于对应于所述统计值的预设阈值;
    所述确定所述目标图像中的所述待定异常区域的至少一个统计值,包括:
    基于所述待定异常区域的像素位置信息,生成与所述待定异常区域对应的至少一个掩模,其中,所述至少一个掩模包括区域掩模和/或边界掩模;
    在所述至少一个掩模包括区域掩模的情况下,获取与所述目标图像对应的饱和度图像,并利用与所述待定异常区域对应的区域掩模,在所述饱和度图像中获得与所述待定异常区域对应的第一待统计区域;对所述第一待统计区域的饱和度进行统计,得到所述待定异常区域的所述至少一个第一统计值;和/或,
    在所述至少一个掩模包括边界掩模的情况下,利用与所述待定异常区域对应的边界掩模,在所述目标图像中获得与所述待定异常区域对应的第二待统计区域;对所述第二待统计区域的像素值进行统计,得到所述待定异常区域的所述至少一个第二统计值。
  9. 根据权利要求1至8任一项所述的方法,其中,所述对所述最终异常区域进行分析,确定所述相机的镜头是否处于异常状态,包括:
    获取所述最终异常区域的第二面积;
    判断所述最终异常区域的第二面积是否满足预设区域条件;
    若满足,则确定所述目标图像处于异常状态;
    在检测到连续第一预设数量帧所述目标图像中存在至少第二预设数量帧处于异常状态的情况下,确定所述相机镜头处于异常状态;其中,所述第一预设数量和第二预设数量为正整数。
  10. 根据权利要求9所述的方法,其中,所述判断所述最终异常区域的第二面积是否满足预设区域条件,包括:
    判断所述最终异常区域的第二面积是否满足第一预设区域条件或第二预设区域条件;
    所述若满足,则确定所述目标图像处于异常状态,包括:
    若满足所述第一预设区域条件,则确定所述目标图像处于第一异常状态;
    若满足所述第二预设区域条件,则确定所述目标图像处于第二异常状态;
    所述在检测到连续第一预设数量帧所述目标图像中存在至少第二预设数量帧处于异常状态的情况下,确定所述相机镜头处于异常状态,包括:
    在检测到所述连续第一预设数量帧所述目标图像均处于所述第一异常状态的情况下,确定所述相机镜头处于所述第一异常状态;
    在检测到所述连续第一预设数量帧所述目标图像不均处于所述第一异常状态,且存在至少所述第二预设数量帧处于所述第一异常状态或所述第二异常状态的情况下,确定所述相机镜头处于第二异常状态。
  11. 根据权利要求10所述的方法,其中,所述第一预设区域条件为所述第二面积大于第二预设面积阈值;所述第二预设区域条件为所述第二面积大于第二预设面积阈值且小于第三预设面积阈值, 其中,所述第二预设面积阈值大于所述第三预设面积阈值。
  12. 一种相机镜头的状态检测装置,包括:
    区域检测部分,被配置为对相机拍摄得到的目标图像进行异常检测,获得所述目标图像中的最终异常区域;
    状态分析部分,被配置为对所述最终异常区域进行分析,确定所述相机的镜头是否处于异常状态。
  13. 根据权利要求12所述的装置,其中,所述区域检测部分,还被配置为对所述相机拍摄得到的所述目标图像进行模糊检测,得到所述目标图像中的若干候选异常区域;执行从所述若干候选异常区域中选择至少一个所述候选异常区域,作为所述最终异常区域。
  14. 根据权利要求13所述的装置,其中,所述区域检测部分,还被配置为对相机拍摄得到的所述目标图像进行预设变换,得到变换图像,其中,变换图像中各像素的像素值能够反映变化图像的模糊信息;执行基于所述变换图像的像素值,确定候选异常区域。
  15. 根据权利要求14所述的装置,其中,所述区域检测部分,还被配置为对目标图像进行预处理,得到预处理图像;执行对所述预处理图像进行拉普拉斯变换,得到所述变换图像;
    所述区域检测部分,还被配置为基于所述变换图像进行二值化处理,得到二值化图像;执行从所述二值化图像中查找出像素值满足预设像素条件的像素点,组成所述候选异常区域。
  16. 根据权利要求15所述的装置,其中,所述区域检测部分,还被配置为对所述目标图像进行灰度化处理,得到所述预处理图像;
    所述区域检测部分,还被配置为对所述变换图像进行滤波处理,得到滤波图像;所述滤波处理包括形态学闭运算;执行对所述滤波图像进行二值化处理,得到所述二值化图像;
    所述区域检测部分,还被配置为将所述二值化图像的像素值进行取反,得到反二值化图像;执行从所述反二值化图像中查找出像素值满足预设像素条件的像素点,组成所述候选异常区域。
  17. 根据权利要求13至16任一项所述的装置,所述区域检测部分,还被配置为获取各所述候选异常区域的第一面积;从所述若干候选异常区域中,选择所述第一面积满足预设面积条件的至少一个候选异常区域,作为待定异常区域;将至少一个所述待定异常区域确定为所述最终异常区域。
  18. 根据权利要求17所述的装置,其中,预设面积条件为所述第一面积大于第一预设面积阈值;
    所述区域检测部分,还被配置为确定所述目标图像中的所述待定异常区域的至少一个统计值;其中,所述待定异常区域的至少一个统计值包括对所述待定异常区域的饱和度统计得到的至少一个第一统计值,和/或,对所述待定异常区域的像素值统计得到的至少一个第二统计值;若确定所述待定异常区域的至少一个统计值满足预设统计条件,则将所述待定异常区域确定为所述最终异常区域。
  19. 根据权利要求18所述的装置,其中,所述第一统计值和第二统计值分别包括均值和方差中的至少一个,所述预设统计条件包括:所述待定异常区域的每个所述统计值均大于对应于所述统计值的预设阈值;
    所述区域检测部分,还被配置为基于所述待定异常区域的像素位置信息,生成与所述待定异常区域对应的至少一个掩模,其中,所述至少一个掩模包括区域掩模和/或边界掩模;在所述至少一个掩模包括区域掩模的情况下,获取与所述目标图像对应的饱和度图像,并利用与所述待定异常区域对应的区域掩模,在所述饱和度图像中获得与所述待定异常区域对应的第一待统计区域;对所述第一待统计区域的饱和度进行统计,得到所述待定异常区域的所述至少一个第一统计值;和/或,在所述至少一个掩模包括边界掩模的情况下,利用与所述待定异常区域对应的边界掩模,在所述目标图像中获得与所述待定异常区域对应的第二待统计区域;对所述第二待统计区域的像素值进行统计,得到所述待定异常区域的所述至少一个第二统计值。
  20. 根据权利要求12至18所述的装置,其中,所述状态分析部分,还被配置为获取所述最终异常区域的第二面积;执行判断所述最终异常区域的第二面积是否满足预设区域条件;若满足,执行确定所述目标图像处于异常状态;执行在检测到连续第一预设数量帧所述目标图像中存在至少第二预设数量帧处于异常状态的情况下,确定所述相机镜头处于异常状态;其中,所述第一预设数量和第二预设数量为正整数。
  21. 根据权利要求20所述的装置,其中,所述状态分析部分,还被配置为判断所述最终异常区域的第二面积是否满足第一预设区域条件或第二预设区域条件;若满足所述第一预设区域条件,则执行确定所述目标图像处于第一异常状态;若满足所述第二预设区域条件,则执行确定所述目标图像处于第二异常状态;
    所述状态分析部分,还被配置为在检测到所述连续第一预设数量帧所述目标图像均处于所述第一异常状态的情况下,确定所述相机镜头处于所述第一异常状态;在检测到所述连续第一预设数量帧所述目标图像不均处于所述第一异常状态,且存在至少所述第二预设数量帧处于所述第一异常状态或所述第二异常状态的情况下,确定所述相机镜头处于第二异常状态。
  22. 根据权利要求21所述的装置,其中,所述第一预设区域条件为所述第二面积大于第二预设面积阈值;所述第二预设区域条件为所述第二面积大于第二预设面积阈值且小于第三预设面积阈值,其中,所述第二预设面积阈值大于所述第三预设面积阈值。
  23. 一种电子设备,包括:相互耦接的存储器和处理器,所述处理器用于执行所述存储器中存储的计算机程序,以实现权利要求1至11任一项所述的相机镜头的状态检测方法。
  24. 一种计算机可读存储介质,其存储有计算机程序,所述计算机程序被处理器执行时实现权利要求1至11任一项所述的相机镜头的状态检测方法。
  25. 一种计算机程序,包括计算机可读代码,当所述计算机可读代码在电子设备中运行时,所述电子设备中的处理器执行用于实现权利要求1至11任一项所述的相机镜头的状态检测方法。
PCT/CN2021/088211 2020-10-28 2021-04-19 相机镜头的状态检测方法、装置、设备及存储介质 WO2022088620A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
KR1020217037804A KR20220058843A (ko) 2020-10-28 2021-04-19 카메라 렌즈의 상태 검출 방법, 장치, 기기 및 저장 매체
JP2021565780A JP2023503749A (ja) 2020-10-28 2021-04-19 カメラレンズの状態検出方法、装置、機器及び記憶媒体

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011172425.2A CN112348784A (zh) 2020-10-28 2020-10-28 相机镜头的状态检测方法、装置、设备及存储介质
CN202011172425.2 2020-10-28

Publications (1)

Publication Number Publication Date
WO2022088620A1 true WO2022088620A1 (zh) 2022-05-05

Family

ID=74358940

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/088211 WO2022088620A1 (zh) 2020-10-28 2021-04-19 相机镜头的状态检测方法、装置、设备及存储介质

Country Status (4)

Country Link
JP (1) JP2023503749A (zh)
KR (1) KR20220058843A (zh)
CN (1) CN112348784A (zh)
WO (1) WO2022088620A1 (zh)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114943938A (zh) * 2022-07-26 2022-08-26 珠海视熙科技有限公司 客流统计方法、装置、***及介质
CN114998317A (zh) * 2022-07-18 2022-09-02 福思(杭州)智能科技有限公司 镜头遮挡检测方法、装置、摄像装置和存储介质
CN115081957A (zh) * 2022-08-18 2022-09-20 山东超华环保智能装备有限公司 一种危废暂存及监测的危废管理平台
CN115379208A (zh) * 2022-10-19 2022-11-22 荣耀终端有限公司 一种摄像头的测评方法及设备
CN116883446A (zh) * 2023-09-08 2023-10-13 鲁冉光电(微山)有限公司 一种车载摄像头镜片碾磨程度实时监测***

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112348784A (zh) * 2020-10-28 2021-02-09 北京市商汤科技开发有限公司 相机镜头的状态检测方法、装置、设备及存储介质
CN113596420B (zh) * 2021-07-28 2022-12-09 歌尔科技有限公司 投影仪镜片的检测方法、装置、投影仪及可读存储介质
CN113658169B (zh) * 2021-08-26 2024-07-05 歌尔科技有限公司 图像斑点检测方法、设备、介质及计算机程序产品
CN113727097B (zh) * 2021-08-31 2023-07-07 重庆紫光华山智安科技有限公司 拍摄设备状态确认方法、***、设备及介质
CN113884123A (zh) * 2021-09-23 2022-01-04 广州小鹏汽车科技有限公司 一种传感器校验方法及装置、车辆、存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107404647A (zh) * 2016-05-20 2017-11-28 中兴通讯股份有限公司 镜头状态检测方法及装置
JP2018132861A (ja) * 2017-02-14 2018-08-23 クラリオン株式会社 車載用撮像装置
CN108986097A (zh) * 2018-08-23 2018-12-11 上海小萌科技有限公司 一种镜头起雾状态检测方法、计算机装置及可读存储介质
CN110632077A (zh) * 2018-06-01 2019-12-31 发那科株式会社 视觉传感器的镜头或镜头盖的异常检测***
CN110992327A (zh) * 2019-11-27 2020-04-10 北京达佳互联信息技术有限公司 镜头脏污状态的检测方法、装置、终端及存储介质
CN112348784A (zh) * 2020-10-28 2021-02-09 北京市商汤科技开发有限公司 相机镜头的状态检测方法、装置、设备及存储介质

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110544211B (zh) * 2019-07-26 2024-02-09 纵目科技(上海)股份有限公司 一种镜头付着物的检测方法、***、终端和存储介质

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107404647A (zh) * 2016-05-20 2017-11-28 中兴通讯股份有限公司 镜头状态检测方法及装置
JP2018132861A (ja) * 2017-02-14 2018-08-23 クラリオン株式会社 車載用撮像装置
CN110632077A (zh) * 2018-06-01 2019-12-31 发那科株式会社 视觉传感器的镜头或镜头盖的异常检测***
CN108986097A (zh) * 2018-08-23 2018-12-11 上海小萌科技有限公司 一种镜头起雾状态检测方法、计算机装置及可读存储介质
CN110992327A (zh) * 2019-11-27 2020-04-10 北京达佳互联信息技术有限公司 镜头脏污状态的检测方法、装置、终端及存储介质
CN112348784A (zh) * 2020-10-28 2021-02-09 北京市商汤科技开发有限公司 相机镜头的状态检测方法、装置、设备及存储介质

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114998317A (zh) * 2022-07-18 2022-09-02 福思(杭州)智能科技有限公司 镜头遮挡检测方法、装置、摄像装置和存储介质
CN114998317B (zh) * 2022-07-18 2022-11-04 福思(杭州)智能科技有限公司 镜头遮挡检测方法、装置、摄像装置和存储介质
CN114943938A (zh) * 2022-07-26 2022-08-26 珠海视熙科技有限公司 客流统计方法、装置、***及介质
CN115081957A (zh) * 2022-08-18 2022-09-20 山东超华环保智能装备有限公司 一种危废暂存及监测的危废管理平台
CN115081957B (zh) * 2022-08-18 2022-11-15 山东超华环保智能装备有限公司 一种危废暂存及监测的危废管理平台
CN115379208A (zh) * 2022-10-19 2022-11-22 荣耀终端有限公司 一种摄像头的测评方法及设备
CN116883446A (zh) * 2023-09-08 2023-10-13 鲁冉光电(微山)有限公司 一种车载摄像头镜片碾磨程度实时监测***
CN116883446B (zh) * 2023-09-08 2023-11-21 鲁冉光电(微山)有限公司 一种车载摄像头镜片碾磨程度实时监测***

Also Published As

Publication number Publication date
KR20220058843A (ko) 2022-05-10
CN112348784A (zh) 2021-02-09
JP2023503749A (ja) 2023-02-01

Similar Documents

Publication Publication Date Title
WO2022088620A1 (zh) 相机镜头的状态检测方法、装置、设备及存储介质
WO2020029518A1 (zh) 一种监控视频处理方法、装置及计算机可读介质
CN115205223B (zh) 透明物体的视觉检测方法、装置、计算机设备及介质
CN113449606B (zh) 一种目标对象识别方法、装置、计算机设备及存储介质
KR100868884B1 (ko) 유리 기판 유리 불량 정보 시스템 및 분류 방법
CN112291551A (zh) 一种基于图像处理的视频质量检测方法、存储设备及移动终端
EP4000040A1 (en) Method, computer program product and computer readable medium for generating a mask for a camera stream
WO2017048491A1 (en) Image analysis system and method
US11068740B2 (en) Particle boundary identification
CN115731493A (zh) 基于视频图像识别的降水微物理特征参量提取与分析方法
CN113283439B (zh) 基于图像识别的智能计数方法、装置及***
CN110569840A (zh) 目标检测方法及相关装置
JP2018142828A (ja) 付着物検出装置および付着物検出方法
Tama et al. Nailfold capillaroscopy image processing for morphological parameters measurement
WO2024016632A1 (zh) 亮点定位方法、亮点定位装置、电子设备及存储介质
CN116958058A (zh) 镜头脏污检测方法、装置及图像检测设备
CN112329572B (zh) 一种基于边框和闪光点的快速静态活体检测方法及装置
CN111027560B (zh) 文本检测方法以及相关装置
CN111563869A (zh) 用于摄像模组质检的污点测试方法
JP2019067377A (ja) 画像処理装置及び方法及び監視システム
CN114998283A (zh) 一种镜头遮挡物检测方法及装置
CN109859200B (zh) 一种基于背景分析的低空慢速无人机快速检测方法
CN115082326A (zh) 视频去模糊的处理方法、边缘计算设备及中心处理器
JP6043178B2 (ja) フラットパネルディスプレイの自動ムラ検出装置および自動ムラ検出方法
CN115546135A (zh) 一种视频图像质量检测方法、装置、设备及存储介质

Legal Events

Date Code Title Description
ENP Entry into the national phase

Ref document number: 2021565780

Country of ref document: JP

Kind code of ref document: A

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21884363

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21884363

Country of ref document: EP

Kind code of ref document: A1