Camera lens smudginess detection method based on self-supervision and motion modeling
Through self-supervision combined with motion modeling, inter-frame motion pattern encoders and self-supervised representation learning are used to capture regional motion pattern abnormalities caused by lens contamination, which solves the problem of poor lens contamination detection in outdoor scenes in the existing technology. problem, achieving accurate detection and high availability in a variety of scenarios.
Patent Information
- Application Number
- CN202410774168.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-10-18
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing lens dirt detection methods are not effective in outdoor scenes, especially in environments with low background contrast. Moreover, traditional methods rely on single-frame images and manually annotated data, have poor generalization capabilities, and cannot effectively detect dirt on action camera lenses. .
Using a method based on self-supervision combined with motion modeling, the video is input frame by frame through a sliding window, and the inter-frame motion pattern encoder and self-supervised representation learning are used to capture regional motion pattern abnormalities caused by lens contamination, and a local motion pattern perturbation strategy is designed. , to achieve end-to-end lens dirt detection.
It achieves accurate lens dirt detection in a variety of scenarios, reduces reliance on manual annotation of data, and improves the universality and usability of detection.
Smart Images

Figure CN118799263A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of lens dirt detection, and in particular is a camera lens dirt detection method based on self-supervision combined with motion modeling. Background Art
[0002] With the development of science and technology and the improvement of people's quality of life, outdoor sports have become a leisure choice for more and more people. Sports cameras have become the choice of many outdoor enthusiasts to record their lives because of their ruggedness and durability as well as functions such as slow motion and time-lapse shooting. However, outdoor sports or extreme sports often pose challenges to the stable shooting of sports cameras because of their harsh and uncontrollable environments. For example, in activities such as surfing, skiing, sailing, desert off-roading, and jungle crossing, the lens of a sports camera often comes into contact with interferences such as water, snowflakes, sand, and mud, which seriously affects the shooting quality of the sports camera. For advanced sports cameras with AI functions such as face recognition and body tracking, the decline in image quality will greatly reduce the function. Therefore, it is very important to monitor the status of the lens of the sports camera.
[0003] The current lens dirt detection scheme often uses traditional image processing methods to make judgments based on single-frame images. The process can be divided into: 1. Image preprocessing, converting RGB three-channel images into grayscale images; 2. Laplacian transform of the preprocessed image to obtain a representation of the image gradient transformation. The value of each pixel in the representation represents the sharpness of the original image at that position; 3. Binarization of the transformed result based on a pre-set threshold; 4. Morphological operations are performed on the binary image to eliminate discontinuities in the area; 5. The final blurred area is determined based on the statistical value of the area of the connected domain.
[0004] The above traditional schemes are mainly based on the results obtained by Laplace transform as the basis for judging whether the image is blurred. However, for some outdoor scenes, such as snow, desert, lake, etc., the contrast inside some background areas is not high, which will cause certain interference to the subsequent judgment. In addition, the above traditional methods rely on the modulation of parameters in the binary judgment and morphological operation effects, and the fixed parameters do not meet the requirements of multi-scene generalization faced by sports cameras. Most importantly, the above methods are only based on single-frame image input, and do not fully utilize the characteristics that the background content in the applicable scenes of sports cameras may change rapidly while the lens is dirty and does not move. There are also some works based on deep learning for dirt detection, but the usability is poor. On the one hand, these methods require manual data annotation, which has high time cost and resource requirements. On the other hand, their output results are easily affected by the scene of the training data set, resulting in poor generalization ability in unknown scenes and lack of universality. Summary of the invention
[0005] The purpose of the present invention is to overcome the defects of the prior art and provide a camera lens dirt detection method based on self-supervision combined with motion modeling.
[0006] To achieve the above object, the present invention adopts the following technical solutions:
[0007] A camera lens dirt detection method based on self-supervision combined with motion modeling includes the following steps:
[0008] S1 inputs the trained video into the model T frames at a time in the form of sliding windows without overlap, and obtains the abnormality scores of each region of the T frames;
[0009] S2 outputs a label according to the sensitivity card threshold. If there is at least one area in the T frame that outputs an abnormal label, the detection result containing the approximate location of the dirt is output according to the area division rules.
[0010] Preferably, in step S1, the model is configured as follows:
[0011] Divide the T-frame video into blocks evenly by region to obtain a series of non-overlapping video blocks of the same size;
[0012] Each video block first passes through the convolution layer to extract the features of the video image frame by frame, and obtains the frame-by-frame latent coding vector of each region;
[0013] After an inter-frame motion pattern encoder, the encoder is mainly responsible for extracting the temporal motion information between frames and outputting the motion pattern hidden coding vector of each region;
[0014] Finally, after passing through the classification layer, the label of whether there is abnormal motion pattern in each area is output.
[0015] Preferably, in step S1, the inter-frame motion pattern encoder includes several attention layers + linear layers, and the input parameter of the inter-frame motion pattern encoder is the frame-by-frame image latent coding vector of the region, which is superimposed with the frame position coding vector to be accompanied by timing information, and the frame position coding adopts absolute position coding; the output parameter of the inter-frame motion pattern encoder is the motion pattern latent coding vector containing timing information.
[0016] Preferably, in step S1, the calculation formula in the attention layer + linear layer is:
[0017] Q=XW q ,K=XW k , V = XW v ;
[0018]
[0019] in, is the input latent coding matrix, which is composed of the frame-by-frame latent coding vectors of the region, t is the number of frames, and d is the dimension of the latent variable; is the timing characteristic of the output; is the learnable parameter matrix of the attention layer; is the linear layer learnable parameter matrix.
[0020] Preferably, in step S1, the video training includes: performing local motion pattern perturbation on the input T-frame video to simulate pixel blocks that do not conform to light and shadow changes and motion patterns in real imaging.
[0021] Preferably, in step S1, the video training specifically includes: randomly selecting a pixel area in the image coordinates, extracting the corresponding pixel data into a video area block, then randomly extracting a pixel block of any frame, performing Gaussian filtering and smoothing on the edge of the pixel block, and extending the processed pixel block by T frames to obtain a processed video area block, and finally filling it into the corresponding area position to obtain an input video with local motion disturbance.
[0022] Preferably, in step S1, during the training phase, for a batch of training samples, a training operation is performed on each video with probability p=0.5, the number of regions for each operation is k, and k is uniformly distributed between 1 and 5.
[0023] Preferably, in step S1, after a training operation is performed on a batch of training samples, the motion pattern implicit coding features of each area block of each video are obtained, and the self-supervised representation learning loss is calculated, the loss is back-propagated, and the model updates the parameters, and this process is repeated until the model converges.
[0024] Preferably, in step S1, the self-supervision represents the learning loss, which can be expressed as:
[0025]
[0026] Among them, N is the number of regional blocks extracted from all video samples in a batch of samples. When the regional block contains motion disturbance, yi=1, otherwise yi=0. The former indicates that the region contains pixel blocks with abnormal motion patterns, and the latter indicates that the region is normal real imaging data.
[0027] In summary, due to the adoption of the above technical solution, the beneficial effects of the present invention are:
[0028] In the present invention, based on the characteristics that a dirty lens is relatively still in a video and has no obvious changes in light and shadow, and utilizing the motion information contained in adjacent time image frames and the abnormal motion patterns of some areas caused by lens dirt, an end-to-end modeling framework combining a motion pattern perturbation strategy with self-supervised representation learning is designed to enhance the model's ability to capture light and shadow changes and motion patterns in real imaging, thereby achieving accurate camera lens dirt detection in general scenarios, with strong usability and universality. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 It is a schematic diagram of the model structure of a camera lens dirt detection method based on self-supervision combined with motion modeling in the present invention;
[0030] Figure 2 It is a schematic diagram of the structure of an inter-frame motion pattern encoder in a camera lens dirt detection method based on self-supervision combined with motion modeling in the present invention;
[0031] Figure 3 It is a schematic diagram of a video local motion pattern disturbance strategy in a camera lens dirt detection method based on self-supervision combined with motion modeling in the present invention;
[0032] Figure 4 It is a schematic diagram of the output process of the reasoning stage in a camera lens dirt detection method based on self-supervision combined with motion modeling in the present invention. DETAILED DESCRIPTION
[0033] The following is a further description of a specific implementation of a camera lens dirt detection method based on self-supervision combined with motion modeling of the present invention in conjunction with an embodiment. The camera lens dirt detection method based on self-supervision combined with motion modeling of the present invention is not limited to the description of the following embodiment.
[0034] Embodiment 1:
[0035] A camera lens dirt detection method based on self-supervision combined with motion modeling, such as Figure 1 As shown, the following steps are included:
[0036] S1 inputs the trained video into the model T frames at a time in the form of sliding windows without overlap, and obtains the abnormality scores of each region of the T frames;
[0037] S2 outputs a label according to the sensitivity card threshold. If there is at least one area in the T frame that outputs an abnormal label, the detection result containing the approximate location of the dirt is output according to the area division rules.
[0038] Furthermore, in step S1, the model configuration is:
[0039] Divide the T-frame video into blocks evenly by region to obtain a series of non-overlapping video blocks of the same size;
[0040] Each video block first passes through the convolution layer to extract the features of the video image frame by frame, and obtains the frame-by-frame latent coding vector of each region;
[0041] After an inter-frame motion pattern encoder, the encoder is mainly responsible for extracting the temporal motion information between frames and outputting the motion pattern hidden coding vector of each region;
[0042] Finally, after passing through the classification layer, the label of whether there is abnormal motion pattern in each area is output.
[0043] Furthermore, in step S1, the inter-frame motion pattern encoder includes several attention layers + linear layers. The input parameter of the inter-frame motion pattern encoder is the frame-by-frame image latent coding vector of the region, which is superimposed with the frame position coding vector to carry timing information. The frame position coding adopts absolute position coding; the output parameter of the inter-frame motion pattern encoder is the motion pattern latent coding vector containing timing information.
[0044] Furthermore, in step S1, the calculation formula in the attention layer + linear layer is:
[0045] Q=XW q ,K=XW k , V = XW v ;
[0046]
[0047] in, is the input latent coding matrix, which is composed of the frame-by-frame latent coding vectors of the region, t is the number of frames, and d is the dimension of the latent variable; is the timing characteristic of the output; is the learnable parameter matrix of the attention layer; is the linear layer learnable parameter matrix.
[0048] Furthermore, in step S1, the video training includes: performing local motion pattern perturbation on the input T-frame video to simulate pixel blocks that do not conform to the light and shadow changes and motion patterns in real imaging.
[0049] Furthermore, in step S1, the video training specifically includes: randomly selecting a pixel area in the image coordinates, extracting the corresponding pixel data into a video area block, then randomly extracting a pixel block of any frame, performing Gaussian filtering and smoothing on the edge of the pixel block, and extending the processed pixel block by T frames to obtain a processed video area block, and finally filling it into the corresponding area position to obtain an input video with local motion disturbance.
[0050] Furthermore, in step S1, during the training phase, for a batch of training samples, a training operation is performed on each video with probability p=0.5, and the number of regions for each operation is k, where k is uniformly distributed between 1 and 5.
[0051] Furthermore, in step S1, after a batch of training samples is trained, the motion pattern implicit coding features of each area block of each video are obtained, and the self-supervised representation learning loss is calculated, the loss is back-propagated, and the model updates the parameters. This process is repeated until the model converges.
[0052] Furthermore, in step S1, the self-supervised representation learning loss can be expressed as:
[0053]
[0054] Among them, N is the number of regional blocks extracted from all video samples in a batch of samples. When the regional block contains motion disturbance, yi=1, otherwise yi=0. The former indicates that the region contains pixel blocks with abnormal motion patterns, and the latter indicates that the region is normal real imaging data.
[0055] Embodiment 2:
[0056] The model used in Example 1 is configured as follows: for video data of consecutive T frames (time windows), the model first divides the video into blocks uniformly by region to obtain a series of non-overlapping video blocks of the same size; each video block first passes through a convolutional layer to extract the features of the video image frame by frame to obtain a frame-by-frame latent coding vector for each region; then passes through an inter-frame motion pattern encoder, which is mainly responsible for extracting the temporal motion information between frames and outputting the motion pattern latent coding vector for each region; finally, passes through a classification layer to output a label for each region as to whether there is an abnormal motion pattern. Specifically, Figure 1 As shown in the figure, the inter-frame motion pattern encoder is mainly composed of multiple "attention layers + linear layers". The input of this module is the frame-by-frame image latent coding vector of the region, which is first processed by the superposition of the frame position coding vector to make it have time sequence information. The frame position coding adopts absolute position coding; the output of this module is the motion pattern latent coding vector containing time sequence information, as shown in the figure. Figure 2 As shown; the main calculation formula of "attention layer + linear layer" is as follows:
[0057] Q=XW q ,K=XW k ,V=XW v ;
[0058]
[0059] in, is the input latent coding matrix, which is composed of the frame-by-frame latent coding vectors of the region, t is the number of frames, and d is the dimension of the latent variable; is the timing characteristic of the output; is the learnable parameter matrix of the attention layer; is the linear layer learnable parameter matrix.
[0060] Embodiment 3:
[0061] For the same batch of samples, we divide them into several T-frame videos. First, we perturb the local motion pattern of the input T-frame video to simulate pixel blocks that do not conform to the light and shadow changes and motion patterns in real imaging. The specific steps are as follows: Figure 3 As shown in the figure, a pixel area in the image coordinates is randomly selected, and the corresponding pixel data is extracted into a video area block. Then, a pixel block of any frame is randomly selected, and the edge of the pixel block is smoothed by Gaussian filtering. The processed pixel block is extended by T frames to obtain the processed video area block, and finally filled into the corresponding area position to obtain the input video with local motion disturbance. In the training stage, for a batch of training samples, the above operation is performed on each video with probability p = 0.5, and the number of regions operated each time is k, and k is uniformly distributed from 1 to 5.
[0062] After the above processing is performed on a batch of training samples, they can be sent to the model to obtain the motion pattern hidden coding features of each area block of each video, and calculate the self-supervised representation learning loss, back propagate the loss, and update the model parameters. Repeat this process until the model converges. The self-supervised representation learning loss can be expressed as:
[0063]
[0064] Among them, N is the number of regional blocks extracted from all video samples in a batch of samples. When the regional block contains motion disturbance, yi=1, otherwise yi=0. The former indicates that the region contains pixel blocks with abnormal motion patterns, and the latter indicates that the region is normal real imaging data.
[0065] Embodiment 4:
[0066] The video is input into the model in the form of a sliding window without overlap, T frames at a time, and the abnormality score of each region of the T frame is obtained. Then, the label is output according to the sensitivity card threshold (such as 0.5). If there is at least one region in the T frame that outputs an abnormal label, the detection result containing the approximate location of the dirt is output according to the rules of regional division, such as "there is dirt in the upper left corner of the lens". Figure 4 shown.
[0067] By adopting the above technical solution:
[0068] In this application, based on the prior knowledge that the lens dirt is relatively stable while the background changes dramatically in the scene shot by the sports camera, an end-to-end motion modeling deep learning algorithm framework is designed to effectively use the motion information of adjacent frames for lens dirt detection. A self-supervised learning strategy based on local motion pattern perturbation is proposed, which can construct positive and negative sample pairs without manually annotated data, greatly reducing the system's dependence on annotated data.
[0069] In this application, based on the characteristics that dirty lenses are relatively static in videos and have no obvious changes in light and shadow, and utilizing the motion information contained in adjacent time image frames and the abnormal motion patterns of some areas caused by lens dirt, a motion pattern perturbation strategy is designed in combination with an end-to-end modeling framework of self-supervised representation learning. This enhances the model's ability to capture light and shadow changes and motion patterns in real imaging, and can achieve accurate camera lens dirt detection in general scenarios, with strong usability and universality.
[0070] Design ideas:
[0071] The pictures taken by sports cameras will have smooth or drastic changes in motion and light and shadow in a short period of time, while the dirt on the lens will not change significantly over time. Based on this prior knowledge, this case proposes a camera lens dirt detection method based on self-supervision combined with motion modeling. It uses the motion information contained in adjacent time image frames and the abnormal motion patterns of some areas caused by lens dirt to design ① an end-to-end motion modeling model to capture inter-frame changes, ② a motion pattern perturbation strategy to construct positive and negative sample pairs without human intervention, and through self-supervision representation learning loss, enhances the model's ability to capture light and shadow changes and motion patterns in real imaging, and achieves accurate camera lens dirt detection.
[0072] The above contents are further detailed descriptions of the present invention in combination with specific preferred embodiments, and it cannot be determined that the specific implementation of the present invention is limited to these descriptions. For ordinary technicians in the technical field to which the present invention belongs, several simple deductions or substitutions can be made without departing from the concept of the present invention, which should be regarded as falling within the protection scope of the present invention.
Claims
1. A camera lens dirt detection method based on self-supervision combined with motion modeling, characterized in that: The following steps are involved: S1 inputs the trained video into the model T frames at a time in the form of sliding windows without overlap, and obtains the abnormality scores of each region of the T frames; S2 outputs a label according to the sensitivity card threshold. If there is at least one area in the T frame that outputs an abnormal label, the detection result containing the approximate location of the dirt is output according to the area division rules.
2. The camera lens dirt detection method based on self-supervision combined with motion modeling as claimed in claim 1, characterized in that: In step S1, the model configuration is: Divide the T-frame video into blocks evenly by region to obtain a series of non-overlapping video blocks of the same size; Each video block first passes through the convolution layer to extract the features of the video image frame by frame, and obtains the frame-by-frame latent coding vector of each region; After an inter-frame motion pattern encoder, the encoder is mainly responsible for extracting the temporal motion information between frames and outputting the motion pattern hidden coding vector of each region; Finally, after passing through the classification layer, the label of whether there is abnormal motion pattern in each area is output.
3. The camera lens dirt detection method based on self-supervision combined with motion modeling as claimed in claim 2, characterized in that: In the step S1, the inter-frame motion pattern encoder includes several attention layers + linear layers. The input parameter of the inter-frame motion pattern encoder is the frame-by-frame image latent coding vector of the region, which is superimposed with the frame position coding vector to attach timing information, and the frame position coding adopts absolute position coding; the output parameter of the inter-frame motion pattern encoder is the motion pattern latent coding vector containing timing information.
4. The camera lens dirt detection method based on self-supervision combined with motion modeling as claimed in claim 1, characterized in that: In step S1, the calculation formula in the attention layer + linear layer is: Q=XWq, K=XWk, V=XW,; in, is the input latent coding matrix, which is composed of the frame-by-frame latent coding vectors of the region, t is the number of frames, and d is the dimension of the latent variable; is the timing characteristic of the output; is the learnable parameter matrix of the attention layer; is the linear layer learnable parameter matrix.
5. The camera lens dirt detection method based on self-supervision combined with motion modeling as claimed in claim 1, characterized in that: In step S1, the video training includes: performing local motion pattern perturbation on the input T-frame video to simulate pixel blocks that do not conform to the light and shadow changes and motion patterns in real imaging.
6. The camera lens dirt detection method based on self-supervision combined with motion modeling as claimed in claim 5, characterized in that: In step S1, the video training specifically includes: randomly selecting a pixel area in the image coordinates, extracting the corresponding pixel data into a video area block, then randomly extracting a pixel block of any frame, performing Gaussian filtering and smoothing on the edge of the pixel block, and extending the processed pixel block by T frames to obtain a processed video area block, and finally filling it into the corresponding area position to obtain an input video with local motion disturbance.
7. The camera lens dirt detection method based on self-supervision combined with motion modeling as claimed in claim 6, characterized in that: In step S1, during the training phase, for a batch of training samples, a training operation is performed on each video with probability p=0.5, and the number of regions for each operation is k, where k is uniformly distributed between 1 and 5.
8. The camera lens dirt detection method based on self-supervision combined with motion modeling as claimed in claim 6, characterized in that: In step S1, after a batch of training samples is trained, the motion pattern hidden coding features of each area block of each video are obtained, and the self-supervised representation learning loss is calculated, the loss is back-propagated, and the model updates the parameters. This process is repeated until the model converges.
9. The camera lens dirt detection method based on self-supervision combined with motion modeling as claimed in claim 8, characterized in that: In step S1, the self-supervision represents the learning loss, which can be expressed as: Among them, N is the number of regional blocks extracted from all video samples in a batch of samples. When the regional block contains motion disturbance, yi=1, otherwise yi=0. The former indicates that the region contains pixel blocks with abnormal motion patterns, and the latter indicates that the region is normal real imaging data.
Citation Information
Patent Citations
Lens dirt detection method, device and equipment
CN111970506A
Camera lens state detection method and device, equipment and storage medium
CN112348784A
Weak supervision behavior positioning method and device based on action fragment sorting
CN114049581A
Face living body detection algorithm based on long-distance time sequence feature VisionTransform
CN116884069A
Cited By
Method and device for predicting pollution failure of 3D camera lens with air curtain
CN121503240A
