Object Detection Methods
By combining background difference method, adaptive difference threshold and rectangle extraction strategy in the object detection method, the target area is dynamically divided, and the image is trained by simulated meteorological factors, the problem of low generalization ability of the object detection model in outdoor environment is solved, and stronger generalization ability and real-time monitoring performance are achieved.
Patent Information
- Application Number
- CN202510013197.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-06
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2045-01-06
AI Technical Summary
In outdoor environments, the camera's object detection model generalization ability is low, it is greatly affected by meteorological factors and the camera installation location, and small object detection is difficult, model inference speed is slow, and deployment problems are serious.
A target detection method is proposed, by reading the current frame image and sequence frame image of the camera, generating environmental background image and new images, and dynamic area division and object detection are used to use background difference method and edge detection algorithm to improve the generalization ability of the model. At the same time, the original image is trained by simulating light and darkness, fog and rain patterns, and a data set that takes into account meteorological factors are constructed to train the object detection model.
The generalization ability of the model is improved, adapted to different meteorological conditions and camera installation locations, enhanced the detection ability of small targets, and improved the real-time monitoring performance of the model.
Smart Images

Figure CN119399455B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of target detection, and in particular to a target detection method. Background Art
[0002] When the camera detects targets indoors, the image is not affected by environmental factors such as sunlight and rain. However, when the camera detects targets outdoors, meteorological factors have a greater impact on the performance of the target detection model and are difficult to ignore. However, the datasets used in most models for training do not take this issue into account, resulting in low model generalization. If the model is directly trained using images under environmental factors such as sunlight, rain, and fog, there will be some limitations and challenges, such as: (1) Difficulty and cost of data acquisition: It is very difficult and expensive to obtain a large amount of diverse image data in a natural environment. (2) Data diversity and coverage: Data in a natural environment may not cover all possible weather conditions and lighting conditions. (3) Data controllability and consistency: In a natural environment, image acquisition is affected by many uncontrollable factors, such as time, location, equipment, etc. (4) Model generalization ability: Directly using limited natural environment images to train the model may lead to model overfitting, that is, the model performs well on the training data, but performs poorly under new environmental conditions that have not been seen.
[0003] In addition, in industrial cameras, the camera is usually installed at a high position, resulting in the target area in the image accounting for even less than 0.01 of the overall image area. If the target in the image is to be identified, it falls into the category of small target detection, which will bring great challenges to the model. In addition, in terms of the process of the camera, the image size is generally much higher than the fixed size used by the recognition model. If an adaptive scaling strategy is used to transform the image to a specified size, most of the pixels in the target area will be lost, further increasing the difficulty of recognition; if the model training size is increased to deal with this problem, the model reasoning speed will be greatly reduced, and the deployment of the model will increase. It cannot be applied to real-time monitoring systems.
[0004] In the related art, an image processing method is proposed in the patent application document with publication number CN113570613A. The scheme obtains the air transmittance corresponding to the target object according to the depth information of the target object in the original image, a random noise generation algorithm and preset air scattering parameters, and then generates a fog map according to the air transmittance, the air illumination parameters in the original image and the original image, thereby increasing the amount of training data used to train the model; the scheme improves the generalization ability of the model by automatically generating the fog map. The simulated generation of the fog map mainly depends on the calculation of the air transmittance, and simulates the fog effect by adjusting the illumination parameters. It has a good effect in simulating uniform fog distribution, but lacks the simulation of the non-uniform distribution and randomness of the fog. The generated fog map does not conform to the complex meteorological conditions in the real world.
[0005] A novel background difference method for moving target detection based on wavelet blocking is proposed in the patent application document with publication number CN107368784A. The scheme realizes the detection of moving targets by converting color images into grayscale images, performing block processing on the grayscale images, using Gaussian mixture background modeling, directly performing background difference on the model to obtain a foreground detection image, wavelet threshold denoising and adaptive background maintenance. It mainly solves the influence of environmental factors such as dynamic background, illumination change, noise and shadow on the detection of moving targets, and improves the accuracy and reliability of detection. It focuses on solving the general problem of moving target detection in complex environments and is not suitable for small target detection in outdoor environments.
[0006] The patent application document with publication number CN108596912A proposes an image multi-threshold segmentation method based on an improved artificial raindrop optimization method. The improved artificial raindrop optimization method is used to perform multi-threshold segmentation of images. Its core is to find the optimal threshold combination to maximize the image segmentation effect, rather than directly simulating the visual impact of rain on the image. Summary of the invention
[0007] The present invention aims to propose a target detection method which can take into account meteorological factors and camera installation positions and has strong generalization.
[0008] The present invention solves the above technical problems by the following technical means:
[0009] A target detection method is proposed, the method comprising:
[0010] Read the current frame image and the sequence frame images before the current frame of the camera, process the sequence frame images to generate an environmental background image, and process the current frame image to generate a new image;
[0011] The background difference method is used to calculate the difference between the new image and the environmental background image, the difference result is binarized according to the adaptive difference threshold to obtain a binary image, and the edge detection algorithm is used to obtain the contour edge in the binary image;
[0012] Calculate the minimum rectangular bounding box of the contour edge as the dynamic area bounding box, and use the rectangle extraction strategy to obtain the image containing the dynamic area;
[0013] An image containing a dynamic area is input into a target detection model to obtain a target detection result, wherein the target detection model is pre-trained using a data set that takes meteorological factors into consideration.
[0014] Furthermore, the processing of the sequence frame images to generate the environment background image and the processing of the current frame image to generate the new image include:
[0015] The sequence frame images are converted into grayscale images and Gaussian filtering is performed, and the mean value of the sequence frame images after filtering is taken as the environment background image;
[0016] The current frame image is converted into a grayscale image and the grayscale mean is calculated as a grayscale image. The grayscale image is subjected to Gaussian filtering to obtain a new image.
[0017] Furthermore, the adaptive differential threshold is expressed by the formula:
[0018]
[0019]
[0020] In the formula, T ada is the adaptive difference threshold, Mean ( G ( x )) is the mean value of the grayscale image of the current frame, T cons is the initial fixed difference threshold, V G The threshold adjustment variable for different grayscale values, T max , T min They are high and low limit thresholds respectively.
[0021] Furthermore, the calculation of the minimum rectangular bounding box of the contour edge as the dynamic area bounding box, and the use of a rectangular extraction strategy to obtain an image containing the dynamic area, includes:
[0022] When the number of the dynamic region bounding boxes is single, the area of the dynamic region is expanded with the dynamic region as the center;
[0023] When there are multiple dynamic region bounding boxes, the area of each dynamic region is expanded with each dynamic region as the center, and the intersecting dynamic regions after expansion are merged into one dynamic region.
[0024] Furthermore, the method further comprises:
[0025] If the image boundary is touched during dynamic region expansion, expansion is performed in the reverse direction.
[0026] Furthermore, the method further comprises:
[0027] When the target detection result is that the target is detected, the target detection frame is restored to the original image and the environment background image is updated according to the target detection result, while keeping the threshold adjustment variable unchanged;
[0028] When the target detection result is that the target is not detected, determining whether the previous frame image of the current frame image detects the target;
[0029] If so, increase the threshold adjustment variable;
[0030] If not, then the threshold adjustment variable is lowered.
[0031] Furthermore, the training process of the target detection model includes:
[0032] The original image set is subjected to light and shade simulation, fog simulation and rain streak simulation respectively to construct the target data set;
[0033] The target data set is used to train the YOLOv5 model to obtain the trained target detection model.
[0034] Furthermore, the original image is simulated for light and shade, including:
[0035] Calculate the brightness mean of the original image set in HSV mode, and divide the original image into a low brightness state image, a balanced state image, and a high brightness state image;
[0036] For the balanced state image, the brightness component is adjusted proportionally to simulate images of different brightness, and then converted back to RGB mode after simulation;
[0037] The target data set is constructed based on simulated images of different brightness, low brightness state images, and high brightness state images.
[0038] Furthermore, fog simulation is performed on the original image, including:
[0039] Synthesize fog according to the RGB channels of the original image, create a fog mask, and mix the fog mask with the original image to create a foggy image;
[0040] The optical model is used to simulate the cluster fog phenomenon, the random center position is used to simulate the center point of the cluster fog, and the appearance of the fog is controlled by adjusting the cluster fog parameters to generate a cluster fog image. The formula of the optical model is expressed as follows:
[0041]
[0042] In the formula, H ( x ) is a foggy image, F ( x ) is a clear image without fog, t ( x ) is the transmittance, A is the global background light, where t ( x ) can be expressed as:
[0043]
[0044] In the formula, r is the scattering coefficient of the atmosphere, d ( x ) is the distance between the object and the imaging system.
[0045] Furthermore, rain streaks are simulated on the original image, including:
[0046] The original images in the original image set are converted into grayscale images and normalized, and the original images are divided into low brightness state images, balanced state images and high brightness state images according to the grayscale mean;
[0047] For the balanced state image, Gaussian noise is used to generate raindrop noise containing the basic shape of raindrops, and the raindrop noise is transformed to generate raindrops of different shapes;
[0048] The motion of raindrops of different shapes is simulated to simulate the motion trajectory of raindrops and obtain raindrop images with motion trajectories;
[0049] The raindrop image with motion trajectory is superimposed on the original equilibrium state image to generate a rain streak image;
[0050] The target data set is formed based on the rain streak image, the low brightness state image and the high brightness state image.
[0051] The advantages of the present invention are:
[0052] (1) The present invention considers the camera installation position and divides the image captured by the camera into dynamic areas for adjusting the size of the target area in the camera to avoid the problem of being unable to identify the target due to the target area accounting for too low a proportion. The image containing the dynamic area is then input into the target detection model for target recognition, wherein the target detection model is trained using a data set that takes meteorological factors into consideration, thereby improving the generalization ability of the model.
[0053] (2) The present invention simulates light and shade, fog and rain streaks on the original image by taking into account meteorological factors, thereby obtaining a natural environment image that is close to the real one and used for training the model, thereby improving the generalization ability of the model.
[0054] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 is a flow chart of a target detection method proposed in one embodiment of the present invention;
[0056] Figure 2 is a schematic diagram of a single dynamic region division in one embodiment of the present invention;
[0057] Figure 3 It is a schematic diagram of multiple dynamic area division in one embodiment of the present invention. DETAILED DESCRIPTION
[0058] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in combination with the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0059] like Figure 1 As shown, an embodiment of the present invention provides a target detection method, which includes the following steps:
[0060] S10, reading the current frame image and the sequence frame images before the current frame of the camera, processing the sequence frame images to generate an environment background image, and processing the current frame image to generate a new image;
[0061] It should be noted that this embodiment reads the first three frames of the current frame output by the camera as sequence frame images, and processes the current frame image and the sequence frame images respectively to generate a new image and an environment background image.
[0062] S20, using a background difference method to calculate the difference between the new image and the environmental background image, binarizing the difference result according to an adaptive difference threshold to obtain a binary image, and using an edge detection algorithm to obtain a contour edge in the binary image;
[0063] S30, calculating the minimum rectangular bounding box of the contour edge as the dynamic area bounding box, and using a rectangular extraction strategy to obtain an image containing the dynamic area;
[0064] S40, inputting the image containing the dynamic area into a target detection model to obtain a target detection result, wherein the target detection model is pre-trained using a data set that takes meteorological factors into consideration.
[0065] This embodiment takes into account the camera installation position and divides the image taken by the camera into dynamic areas for adjusting the size of the target area in the camera to avoid the problem of being unable to recognize the target due to the target area accounting for too low a proportion. The image containing the dynamic area is then input into the target detection model for target recognition, wherein the target detection model is trained using a data set that takes meteorological factors into consideration, thereby improving the generalization ability of the model.
[0066] As a further preferred technical solution, in step S10, the sequence frame images are processed to generate an environment background image, and the current frame image is processed to generate a new image, which specifically includes:
[0067] The sequence frame images are converted into grayscale images and Gaussian filtering is performed, and the mean value of the sequence frame images after filtering is taken as the environment background image;
[0068] The current frame image is converted into a grayscale image and the grayscale mean is calculated as a grayscale image. The grayscale image is subjected to Gaussian filtering to obtain a new image.
[0069] It should be noted that this embodiment reads the first three frames of images of the camera as sequential frame images, records the width and height of the images, converts the images into grayscale images and performs Gaussian filtering to remove environmental noise, and takes the mean of the images as the environmental background image for storage; reads the current frame image of the camera, converts the current frame image into a grayscale image and calculates the grayscale mean, performs Gaussian filtering on the grayscale image, removes environmental noise and picture offset caused by camera shaking, and obtains a new image.
[0070] As a further preferred technical solution, in step S20, the adaptive differential threshold used is expressed by the formula:
[0071]
[0072]
[0073] In the formula, Tada is the adaptive difference threshold, Mean ( G ( x )) is the mean value of the grayscale image of the current frame, T cons is the initial fixed difference threshold, V G The threshold adjustment variable for different grayscale values, T max , T min They are high and low limit thresholds respectively.
[0074] It should be noted that the initial fixed differential threshold T cons The default value is 30. The default values for the high limit threshold and the low limit threshold are 30 and 10 respectively.
[0075] It should be noted that the fixed threshold may not be able to accurately segment the foreground and background in some cases, especially when the lighting changes greatly or the image quality varies. This embodiment improves the robustness of the algorithm to these changes by setting an adaptive threshold, so that stable detection results can be obtained in a wider range of application scenarios. In the calculation formula of the adaptive differential threshold, the mean value of the grayscale image (Mean(G(x))) and the threshold adjustment variable (V G ), which can be adjusted according to the specific content of the image. This flexibility allows the algorithm to maintain good performance under different image and environmental conditions and helps reduce false detections caused by lighting changes, shadows or noise. By dynamically adjusting the threshold, it can more accurately distinguish between true moving targets and changes caused by environmental factors.
[0076] As a further preferred technical solution, in step S30, the minimum rectangular bounding box of the contour edge is calculated as the dynamic area bounding box, and a rectangular extraction strategy is adopted to obtain an image containing the dynamic area, including the following steps:
[0077] When the number of the dynamic region bounding boxes is single, the area of the dynamic region is expanded with the dynamic region as the center;
[0078] When there are multiple dynamic region bounding boxes, the area of each dynamic region is expanded with each dynamic region as the center, and the intersecting dynamic regions after expansion are merged into one dynamic region.
[0079] It should be noted that for the detected dynamic area bounding box, different rectangle extraction strategies are used according to the number of bounding boxes to obtain the image containing the dynamic area. Specifically, when there is a single bounding box, such as Figure 2As shown in the figure, with this area as the center, its width and height are expanded to 3 times respectively, and the area of the bounding box area is increased to 9 times the original area. If the area touches the image boundary during expansion, it will expand in the opposite direction. When there are multiple bounding boxes, such as Figure 3 As shown in the figure, the same region expansion strategy is adopted as that of the single bounding box. If the regions intersect, they are merged and the rectangular region is maintained.
[0080] It should be noted that this embodiment can ensure that all or most of the target object is included by expanding the dynamic area bounding box, even if the target object slightly exceeds the initially detected bounding box during movement. This can reduce detection errors caused by truncation of part of the target, and in actual scenes, the target object may show size changes in the image due to distance changes or other reasons. Expanding the bounding box can provide a certain buffer area to adapt to changes in target size.
[0081] Especially for the problem of small target detection, expanding the bounding box can increase the pixel ratio of the target area, making it easier for the target detection model to identify and locate small targets. The expanded bounding box can not only provide more contextual information for subsequent processing steps (such as feature extraction, target tracking, etc.), which helps to improve the accuracy and efficiency of these steps, but also by reasonably expanding the bounding box, it can reduce the image area that needs to be processed while ensuring detection performance, thereby saving computing resources and improving processing speed.
[0082] As a further preferred technical solution, the method further includes:
[0083] When the target detection result is that the target is detected, the target detection frame is restored to the original image and the environment background image is updated according to the target detection result, while keeping the threshold adjustment variable unchanged;
[0084] When the target detection result is that the target is not detected, determining whether the previous frame image of the current frame image detects the target;
[0085] If so, increase the threshold adjustment variable;
[0086] If not, then the threshold adjustment variable is lowered.
[0087] It should be noted that, when the target is detected in the current frame image, the target detection frame is restored to the original image and the background image is updated according to the detection result, and the threshold adjustment variable is kept constant. V G No change; if no target is detected in the dynamic area located according to the current differential threshold, and no target was detected in the previous frame, increase the threshold adjustment variable V G, the default increase value is 0.1; if the target is detected in the previous frame, and the dynamic area located according to the current differential threshold does not detect the target, then reduce the threshold adjustment variable V G , the default reduction value is 1.
[0088] It should be noted that in different monitoring scenarios, due to differences in lighting, weather and target characteristics, a fixed threshold may not achieve the best detection effect. By adaptively adjusting the threshold, the system can better adapt to various scenarios, improve the accuracy and robustness of detection, and by increasing or decreasing the threshold adjustment variable, the threshold used to distinguish foreground and background in the background difference method can be dynamically adjusted. This enables the system to respond more sensitively to different environmental changes, such as changes in lighting or changes in target movement speed.
[0089] For example, when the target detection result does not detect the target, the threshold adjustment variable is adjusted by judging whether the target is detected in the previous frame image. This can optimize the model's response to dynamic changes and improve the overall performance of the model. This adaptive adjustment mechanism reduces the need for manual intervention, allowing the system to automatically adjust according to actual conditions, reducing labor costs and improving the practicality of the system.
[0090] As a further preferred technical solution, the training process of the target detection model includes:
[0091] The original image set is subjected to light and shade simulation, fog simulation and rain streak simulation respectively to construct the target data set;
[0092] The target data set is used to train the YOLOv5 model to obtain the trained target detection model.
[0093] The data set used in this embodiment when training the model takes meteorological factors into consideration, thereby improving the generalization ability of the model.
[0094] As a further preferred technical solution, light brightness and darkness simulation is performed on the original image, including:
[0095] Calculate the brightness mean of the original image set in HSV mode, and divide the original image into a low brightness state image, a balanced state image, and a high brightness state image;
[0096] It should be noted that for an RGB format image, it is first converted to HSV mode, and then the brightness mean of the image is calculated.
[0097] For the balanced state image, the brightness component is adjusted proportionally to simulate images of different brightness, and then converted back to RGB mode after simulation;
[0098] The target data set is constructed based on simulated images of different brightness, low brightness state images, and high brightness state images.
[0099] This embodiment first converts the image from the RGB color space to the HSV color space, and uses the three dimensions of hue (H), saturation (S), and brightness (V) in the HSV color space to intuitively represent color and brightness, making the processing of light brightness more direct and effective. Then, by calculating the brightness mean of the original image set and dividing the original image into a low-brightness state image, a balanced state image, and a high-brightness state image, it is possible to simulate images under different lighting conditions more carefully, and enhance the adaptability of the model to different lighting environments. Finally, for the balanced state image, the image simulation of different brightness is achieved by proportionally adjusting the brightness component, which can not only simulate images of different brightness, but also maintain the authenticity and consistency of the color in the image. Then, the simulated images of different brightness are trained together with the low-brightness state image and the high-brightness state image, which is very critical for model training and can improve the training effect of the model.
[0100] It should be noted that this embodiment can generate diversified training data by simulating images under different lighting conditions. Such data can help the model learn the characteristics of the target under different lighting conditions, thereby improving the generalization ability of the model in practical applications. Since the lighting conditions in the real world are changeable, including sunlight, shadows, indoor lights, etc., this embodiment simulates the light and dark to make the training data closer to the real environment, which helps to improve the performance of the model under various lighting conditions. In some cases, it is very difficult to obtain image data under sufficiently diverse lighting conditions. Through light and dark simulation, the training data set can be expanded without the need to collect additional real image data to solve the problem of insufficient data. Compared with the actual collection of images under different lighting conditions, the simulation method can quickly generate a large amount of data and improve the efficiency of data processing. The simulation method allows researchers to adjust the lighting conditions, including intensity, direction, and color, as needed, to generate images with specific lighting characteristics. This flexibility and controllability is difficult to achieve with actual data collection. By using the simulation method to generate training data, the manpower and material costs of going out to collect images can be reduced, and the dependence on specific environmental conditions is also reduced.
[0101] As a further preferred technical solution, fog simulation is performed on the original image, including:
[0102] Synthesize fog according to the RGB channels of the original image, create a fog mask, and mix the fog mask with the original image to create a foggy image;
[0103] The optical model is used to simulate the cluster fog phenomenon, the random center position is used to simulate the center point of the cluster fog, and the appearance of the fog is controlled by adjusting the cluster fog parameters to generate a cluster fog image. The formula of the optical model is expressed as follows:
[0104]
[0105] In the formula, H ( x ) is a foggy image, F ( x ) is a clear image without fog, t ( x ) is the transmittance, A is the global background light, where t ( x ) can be expressed as:
[0106]
[0107] In the formula, r is the scattering coefficient of the atmosphere, d ( x ) is the distance between the object and the imaging system.
[0108] It should be noted that the fog simulation in this embodiment includes using an optical model to simulate the fog phenomenon and simulating the center point of the fog cluster through a random center position. This method is closer to the physical model. By simulating non-uniformly distributed fog and randomness, the generated fog map is more in line with the complex meteorological conditions (optical characteristics and distribution) in the real world, thereby improving the generalization ability of the model under various meteorological conditions.
[0109] As a further preferred technical solution, rain streak simulation is performed on the original image, including:
[0110] (1) The original images in the original image set are converted into grayscale images and normalized, and the original images are divided into low-brightness state images, balanced state images, and high-brightness state images according to the grayscale mean;
[0111] Specifically, the original image is first converted into a grayscale image, and the formula is expressed as:
[0112]
[0113] In the formula, Respectively represent the coordinates The coefficients 0.299, 0.587, and 0.114 are weighted according to the sensitivity of the human eye to different colors.
[0114] Then the grayscale image is normalized to convert the pixel value range of the grayscale image from [0,255] to [0,1]:
[0115]
[0116] In the formula, and are the minimum and maximum grayscale values of the image, respectively.
[0117] (2) For the balanced state image, Gaussian noise is used to generate raindrop noise containing the basic shape of raindrops, and the raindrop noise is transformed to generate raindrops of different shapes;
[0118] Specifically, Gaussian noise is first used to generate the basic shape of raindrops. The Gaussian noise formula is:
[0119]
[0120] In the formula, It is at coordinates The Gaussian noise value generated at has a mean of 0 and a variance of The normal distribution of .
[0121] By transforming the raindrop noise, different raindrop shapes are generated:
[0122]
[0123] In the formula, and is the minimum and maximum value of the noise image, by Normalize to the range of [0,1] to get the normalized raindrop noise Prepare for subsequent processing.
[0124] (3) Simulating the motion of raindrops of different shapes to simulate the motion trajectory of raindrops and obtain raindrop images with motion trajectories;
[0125] Specifically, this embodiment applies motion blur to raindrop noise to simulate the effect of falling raindrops, which is expressed as:
[0126]
[0127] This formula represents the normalized raindrop noise Apply Gaussian blur, where It is a parameter of blur degree, which is used to control the blur radius.
[0128] By rotating and stretching the Gaussian blurred raindrops to simulate raindrops in different directions, the formula is expressed as:
[0129]
[0130] In the formula, is the rotation matrix used to transform the blurred image Rotation Angle to simulate the direction of falling raindrops.
[0131] (4) The raindrop image with motion trajectory is superimposed on the original equilibrium state image to generate a rain streak image.
[0132] It should be noted that, in this embodiment, the processed raindrop image is superimposed on the original image to generate a rain streak image, which is expressed as:
[0133]
[0134] In the formula, the raindrop image With the original image Combined, where represents the pixel-level dot product, is the transparency, which is the weight used to control the visibility of raindrops.
[0135] (5) The target data set is formed based on the rain streak image, the low brightness state image and the high brightness state image.
[0136] As a further preferred technical solution, this embodiment further enhances the authenticity of the rain effect by adjusting the brightness and contrast of the rain streak image, which is expressed as:
[0137]
[0138] In the formula, yes The mean of and Used to adjust contrast and brightness respectively.
[0139] It should be noted that this embodiment converts the original image into a grayscale image, then uses Gaussian noise to generate the basic shape of raindrops, and then simulates the motion trajectory of raindrops through motion blur and rotation. Finally, these motion trajectories are superimposed on the original image to generate an image with rain streak effects. The density, speed and direction of raindrops are changed in a time series to simulate the change from light rain to heavy rain. The above parameters can be dynamically adjusted to generate a continuous rain effect, thereby realizing a dynamic change simulation of the rain effect.
[0140] By simulating the impact of rain on images, image data that is closer to the actual rainy environment is generated, so that the target detection model can better adapt to and identify targets under rainy conditions, thereby improving the robustness and accuracy of the model in practical applications, and improving the model's generalization ability to meteorological factors, especially the impact of rain. By simulating the impact of rain on images, the performance and accuracy of the model under actual complex weather conditions are enhanced.
[0141] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0142] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0143] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A target detection method, characterized in that: The method comprises: Read the current frame image and the sequence frame images before the current frame of the camera, process the sequence frame images to generate an environmental background image, and process the current frame image to generate a new image; The background difference method is used to calculate the difference between the new image and the environmental background image, the difference result is binarized according to the adaptive difference threshold to obtain a binary image, and the edge detection algorithm is used to obtain the contour edge in the binary image; The minimum rectangular bounding box of the contour edge is calculated as the dynamic area bounding box, and a rectangular extraction strategy is used to obtain an image containing the dynamic area, including expanding the area of the dynamic area with the dynamic area as the center when the number of dynamic area bounding boxes is single; when the number of dynamic area bounding boxes is multiple, the area of each dynamic area is expanded with each dynamic area as the center, and if there are intersecting dynamic areas after expansion, they are merged into one dynamic area; An image containing a dynamic area is input into a target detection model to obtain a target detection result, wherein the target detection model is pre-trained using a data set that takes meteorological factors into consideration.
2. The target detection method according to claim 1, characterized in that: The step of processing the sequence frame images to generate the environment background image and processing the current frame image to generate the new image includes: The sequence frame images are converted into grayscale images and Gaussian filtering is performed, and the mean value of the sequence frame images after filtering is taken as the environment background image; The current frame image is converted into a grayscale image and the grayscale mean is calculated as a grayscale image. The grayscale image is subjected to Gaussian filtering to obtain a new image.
3. The target detection method according to claim 1, characterized in that: The adaptive differential threshold is expressed by the formula: In the formula, T ada is the adaptive difference threshold, Mean ( G ( x )) is the mean value of the grayscale image of the current frame, T cons is the initial fixed difference threshold, V G The threshold adjustment variable for different grayscale values, T max , T min They are high and low limit thresholds respectively.
4. The target detection method according to claim 1, characterized in that: The method further comprises: If the image boundary is touched during dynamic region expansion, expansion is performed in the reverse direction.
5. The target detection method according to claim 1, characterized in that: The method further comprises: When the target detection result is that the target is detected, the target detection frame is restored to the original image and the environment background image is updated according to the target detection result, while keeping the threshold adjustment variable unchanged; When the target detection result is that the target is not detected, determining whether the previous frame image of the current frame image detects the target; If so, increase the threshold adjustment variable; If not, then the threshold adjustment variable is lowered.
6. The target detection method according to claim 1, characterized in that: The training process of the target detection model includes: The original image set is subjected to light and shade simulation, fog simulation and rain streak simulation respectively to construct the target data set; The target data set is used to train the YOLOv5 model to obtain the trained target detection model.
7. The target detection method according to claim 6, characterized in that: Perform light and shade simulation on the original image, including: Calculate the brightness mean of the original image set in HSV mode, and divide the original image into a low brightness state image, a balanced state image, and a high brightness state image; For the balanced state image, the brightness component is adjusted proportionally to simulate images of different brightness, and then converted back to RGB mode after simulation; The target data set is constructed based on simulated images of different brightness, low brightness state images, and high brightness state images.
8. The target detection method according to claim 6, characterized in that: Perform fog simulation on the original image, including: Synthesize fog according to the RGB channels of the original image, create a fog mask, and mix the fog mask with the original image to create a foggy image; The optical model is used to simulate the cluster fog phenomenon, the random center position is used to simulate the center point of the cluster fog, and the appearance of the fog is controlled by adjusting the cluster fog parameters to generate a cluster fog image. The formula of the optical model is expressed as follows: In the formula, H ( x ) is a foggy image, F ( x ) is a clear image without fog, t ( x ) is the transmittance, A is the global background light, where t ( x ) can be calculated as: In the formula, r is the scattering coefficient of the atmosphere, d ( x ) is the distance between the object and the imaging system.
9. The target detection method according to claim 6, characterized in that: Simulate rain streaks on the original image, including: The original images in the original image set are converted into grayscale images and normalized, and the original images are divided into low brightness state images, balanced state images and high brightness state images according to the grayscale mean; For the balanced state image, Gaussian noise is used to generate raindrop noise containing the basic shape of raindrops, and the raindrop noise is transformed to generate raindrops of different shapes; The motion of raindrops of different shapes is simulated to simulate the motion trajectory of raindrops and obtain raindrop images with motion trajectories; The raindrop image with motion trajectory is superimposed on the original equilibrium state image to generate a rain streak image; The target data set is formed based on the rain streak image, the low brightness state image and the high brightness state image.
Citation Information
Patent Citations
Novel background difference method moving object detection method based on wavelet blocking
CN107368784A
Image multi-threshold segmentation method based on improved artificial raindrop optimization method
CN108596912A
Image processing method and device
CN113570613A
Vision-based ship target automatic identification method and system, and electronic equipment
CN117333796A
Marine small target aerial image recognition model training method in foggy day scene
CN117893879A