An Optimization Method and Device for ViBe Algorithm Parameters
By expanding the neighborhood of the ViBe algorithm to the 5×5 neighborhood and performing adaptive calculations of dynamic background complexity parameters and pixel adaptive thresholds, the ViBe algorithm parameters are optimized, and the problem of poor adaptability of ghosting and dynamic backgrounds is solved, and detection accuracy is improved.
Patent Information
- Application Number
- CN202210408289.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-19
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2042-04-19
AI Technical Summary
The existing ViBe algorithms are prone to ghosting when initializing the background model, and have poor adaptability to dynamic backgrounds, resulting in poor detection results.
The neighborhood selected by the ViBe algorithm is expanded to a 5×5 neighborhood, the background model sample set is constructed, and the ViBe algorithm parameters are optimized through adaptive calculations of dynamic background complexity parameters and pixel adaptive thresholds.
Eliminate ghosting, avoid sample duplication, improve adaptability to dynamic backgrounds, and thus improve detection accuracy.
Smart Images

Figure CN114841933B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data optimization, and particularly relates to a method and device for optimizing ViBe algorithm parameters. Background Art
[0002] The ViBe algorithm is a relatively advanced foreground extraction algorithm. Different from other background model algorithms, the ViBe algorithm only needs one frame of image to initialize the background model.
[0003] The existing ViBe algorithm has good detection effect and high speed, but there are also some problems: First, when establishing the background model, the ViBe algorithm selects the 3×3 neighborhood centered on the pixel points in the first frame image, a total of 8 pixel points, to fill the background model with a sample set number of 20. Although this method has small memory occupation and high speed, it also has disadvantages: one is that it is easy to generate "ghost images", which have a great impact on the detection of moving targets and must be eliminated quickly. The other is that there is a duplication phenomenon in the samples. The 8 pixel points in the neighborhood are used to fill the sample set with 20 samples, resulting in a large amount of calculation with duplicate pixels and samples, and there are many duplicate samples in the sample set space. Secondly, the existing ViBe algorithm has poor adaptability to dynamic backgrounds and is easily affected by dynamic backgrounds, resulting in a large number of false detections, which has an adverse impact on the detection work. Summary of the Invention
[0004] In view of the problems in the prior art, embodiments of the present invention provide a method and device for optimizing ViBe algorithm parameters, which can at least partially solve the problems existing in the prior art.
[0005] On the one hand, the present invention proposes a method for optimizing ViBe algorithm parameters, including:
[0006] Expanding the neighborhood selected by the ViBe algorithm to obtain an expanded neighborhood;
[0007] Constructing a background model sample set according to the expanded neighborhood, and calculating a dynamic background complexity parameter according to the background model sample set, the current frame image information, and a preset factor related to the application scenario;
[0008] According to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter, adaptively calculate the pixel adaptive threshold, and use the adaptively calculated pixel adaptive threshold as the optimized ViBe algorithm parameter.
[0009] Among them, the step of expanding the neighborhood selected by the ViBe algorithm to obtain an expanded neighborhood includes:
[0010] Expanding the neighborhood selected by the ViBe algorithm to a 5×5 neighborhood.
[0011] Among them, the current frame image information includes current frame image pixel information and current frame image size information; correspondingly, calculating the dynamic background complexity parameter according to the background model sample set, the current frame image information, and the application scenario-related preset factor includes:
[0012] Calculating the dynamic background complexity parameter according to the background model sample set, the current frame image pixel information, the current frame image size information, and the application scenario-related preset factor.
[0013] Among them, adaptively calculating the pixel adaptive threshold according to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter includes:
[0014] If it is determined that the pixel adaptive threshold is greater than the dynamic background complexity parameter, the following first calculation formula is used to adaptively calculate the pixel adaptive threshold:
[0015]
[0016] Among them, R(x) is the pixel adaptive threshold, is the dynamic background complexity parameter.
[0017] Among them, adaptively calculating the pixel adaptive threshold according to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter includes:
[0018] If it is determined that the pixel adaptive threshold is less than or equal to the dynamic background complexity parameter, the following second calculation formula is used to adaptively calculate the pixel adaptive threshold:
[0019]
[0020] Among them, R(x) is the pixel adaptive threshold, is the dynamic background complexity parameter.
[0021] Among them, the optimization processing method for the ViBe algorithm parameters further includes:
[0022] If it is determined then adaptively adjust R(x) so that
[0023] Among them, the image detection method based on the above optimization processing method for the ViBe algorithm parameters includes:
[0024] Obtain the image to be detected;
[0025] Performing image detection on the image to be detected based on a preset image detection model to obtain an image detection result; the preset image detection model is a ViBe algorithm including optimized ViBe algorithm parameters.
[0026] On the one hand, the present invention proposes an optimization processing device for ViBe algorithm parameters, including:
[0027] An expansion unit for expanding the neighborhood selected by the ViBe algorithm to obtain an expanded neighborhood;
[0028] A calculation unit for constructing a background model sample set according to the expanded neighborhood, and calculating a dynamic background complexity parameter according to the background model sample set, the current frame image information, and a preset factor related to the application scenario;
[0029] An optimization unit for adaptively calculating the pixel adaptive threshold according to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter, and using the adaptively calculated pixel adaptive threshold as the optimized ViBe algorithm parameter.
[0030] On the other hand, an embodiment of the present invention provides an electronic device, including: a processor, a memory, and a bus, where
[0031] The processor and the memory communicate with each other through the bus;
[0032] The memory stores program instructions executable by the processor, and the processor can execute the following method by calling the program instructions:
[0033] Expanding the neighborhood selected by the ViBe algorithm to obtain an expanded neighborhood;
[0034] Constructing a background model sample set according to the expanded neighborhood, and calculating a dynamic background complexity parameter according to the background model sample set, the current frame image information, and a preset factor related to the application scenario;
[0035] According to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter, adaptively calculating the pixel adaptive threshold, and using the adaptively calculated pixel adaptive threshold as the optimized ViBe algorithm parameter.
[0036] An embodiment of the present invention provides a non-transitory computer-readable storage medium, including:
[0037] The non-transitory computer-readable storage medium stores computer instructions, and the computer instructions cause the computer to execute the following method:
[0038] Expand the neighborhood selected by the ViBe algorithm to obtain an expanded neighborhood;
[0039] Construct a background model sample set based on the expanded neighborhood, and calculate a dynamic background complexity parameter according to the background model sample set, the current frame image information, and a preset factor related to the application scenario;
[0040] Perform adaptive calculation on the pixel adaptive threshold according to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter, and use the pixel adaptive threshold obtained by the adaptive calculation as the optimized ViBe algorithm parameter.
[0041] The method and device for optimizing ViBe algorithm parameters provided by the embodiments of the present invention expand the neighborhood selected by the ViBe algorithm to obtain an expanded neighborhood; construct a background model sample set based on the expanded neighborhood, and calculate a dynamic background complexity parameter according to the background model sample set, the current frame image information, and a preset factor related to the application scenario; perform adaptive calculation on the pixel adaptive threshold according to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter, and use the pixel adaptive threshold obtained by the adaptive calculation as the optimized ViBe algorithm parameter, which can eliminate ghosting, avoid sample duplication, and improve the adaptability to dynamic backgrounds, thereby improving detection accuracy. Description of the Drawings
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts. In the drawings:
[0043] Figure 1 It is a schematic diagram for explaining the 3×3 neighborhood of the ViBe algorithm provided by the prior art.
[0044] Figure 2 It is a flowchart of the method for optimizing ViBe algorithm parameters provided by an embodiment of the present invention.
[0045] Figure 3 It is a flowchart of the method for optimizing ViBe algorithm parameters provided by another embodiment of the present invention.
[0046] Figure 4 It is a schematic diagram for explaining the foreground detection of the ViBe algorithm provided by another embodiment of the present invention.
[0047] Figure 5It is a schematic diagram for explaining the 5×5 neighborhood of the ViBe algorithm provided by an embodiment of the present invention.
[0048] Figure 6 It is a schematic structural diagram of an optimization processing device for the parameters of the ViBe algorithm provided by an embodiment of the present invention.
[0049] Figure 7 It is a schematic diagram of the entity structure of an electronic device provided by an embodiment of the present invention. Detailed implementation manners
[0050] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer and more understandable, the following further describes the embodiments of the present invention in detail with reference to the accompanying drawings. Herein, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but do not limit the present invention. It should be noted that, without conflict, the embodiments in this application and the features in the embodiments can be combined arbitrarily with each other.
[0051] Figure 2 It is a schematic flowchart of an optimization processing method for the parameters of the ViBe algorithm provided by an embodiment of the present invention. As Figure 2 shown, the optimization processing method for the parameters of the ViBe algorithm provided by the embodiment of the present invention includes:
[0052] Step S1: Expand the neighborhood selected by the ViBe algorithm to obtain an expanded neighborhood.
[0053] Step S2: Construct a background model sample set according to the expanded neighborhood, and calculate a dynamic background complexity parameter according to the background model sample set, the current frame image information, and a preset factor related to the application scenario.
[0054] Step S3: Perform adaptive calculation on the pixel adaptive threshold according to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter, and use the pixel adaptive threshold obtained by the adaptive calculation as the optimized ViBe algorithm parameter.
[0055] In the above step S1, the device expands the neighborhood selected by the ViBe algorithm to obtain an expanded neighborhood. The device may be a computer device that executes this method, for example, it may include a server.
[0056] The full name of ViBe is Visual Background Extractor. This algorithm is a foreground detection algorithm at the pixel level. Its principle is: establish a sample set of pixel points by extracting the pixel values around the pixel point (x, y), and then compare the pixel value at the pixel point (x, y) in the next frame of image with the pixel values in the sample set, and determine the foreground pixel point or the background pixel point according to the comparison result.
[0057] As Figure 3 shown, the foreground object extraction process in the ViBe algorithm for the input video mainly consists of five steps: video input, background model initialization, foreground detection, background model update, and obtaining the foreground object.
[0058] Video input means inputting the video into the ViBe algorithm.
[0059] Background model initialization:
[0060] The ViBe algorithm uses the spatio-temporal distribution feature that the pixel value of each pixel is similar to that of each pixel in its 8-neighborhood to establish the background model. Select the pixel values of 8 neighborhood pixels in the 3×3 pixel matrix centered on this pixel, and randomly select and fill the sample set space multiple times from them.
[0061] For a certain pixel point x in an image with image size M×N, its pixel value is set to p(x), and the corresponding sample set is denoted as S(x), then the expression is as shown in Equation (3-1):
[0062] S(x) = {V1, V2,......V n} (3-1)
[0063] Among them, V i represents the pixel value in the background model, n represents the sample set size, generally taking n = 20, and the total sample set size is M×N×n.
[0064] After establishing the sample set, form the sampling space N B (x) of x and each pixel in its 8-neighborhood, randomly select pixel points in the sampling space for background model initialization, and the background model initialization formula is as shown in Equation (3-2):
[0065] M(x) = {V i (x)|x ∈ N B (x)} (3-2)
[0066] V i (x) in the formula corresponds to V i .
[0067] Foreground detection:
[0068] After the background model is completed, foreground detection needs to be carried out. As Figure 4 shown, the circular area with V(x) as the center and R as the radius is called S R(p(x)), where V1, V2,......V6 are the pixel values of the background sample points in the sample set of point V(x). Assume that at a certain time t, the pixel value of V(x) is p(x), the sample set is S(x) = {V1, V2,......V6}, and calculate the Euclidean distance dist({V t between the pixel value V t |V t ∈M}, V), such as if dist({V t |V t ∈M}, V) is less than the classification threshold Rx, then increment the U value (the U value is a general term in the art) of the background sample point by 1. When the value of U is greater than or equal to the background sample point number threshold U min , then determine that this pixel point is a background point. The formula is organized as in Equations (3-3) and (3-4):
[0069]
[0070]
[0071] As can be seen from the above, for the ViBe algorithm in foreground detection, there are mainly three threshold parameters, namely the sample set size n, the classification threshold Rx, and the background sample point number threshold U min , and the general values are: n = 20, Rx = 20, U min = 2.
[0072] Background model update:
[0073] After the foreground pixels and background pixels are classified, the background model needs to be updated. Generally, the update mechanism is divided into a conservative update mechanism and a foreground point counting update mechanism. The explanations are as follows:
[0074] 1. Conservative update: As long as a point is determined to be a foreground target, it will not be updated into the background model. The advantage of this strategy is that it can better detect moving targets, but the disadvantage is that it is prone to "deadlock" and generate "ghosts". For example: If a stationary target is regarded as a foreground target, it will be considered a moving pixel throughout the update process and cause a deadlock. When a moving target enters the video scene and becomes stationary, the conservative mechanism will always determine this point as a moving target, thus generating "ghosts".
[0075] Ghost: It means that the ViBe algorithm will detect the pixel points that originally belong to the background as foreground pixel points, that is, a static pixel point in the background is determined to be a moving pixel point, thus generating a "ghost" area. When performing target detection, two foreground targets will be detected, one is the actual moving target, and the other is actually the background pixel point, which affects the detection effect. In addition, if a stationary target has started moving, but the model has not had time to update, the moving target is detected as a stationary target, resulting in a false foreground when detecting the moving target, and this will also generate "ghosts".
[0076] 2. Foreground point counting: It is to count the number of times a pixel is determined to be a foreground pixel, and retain the foreground pixel points that are continuously determined Y times, and update them as background pixel points.
[0077] Obtaining the foreground target: It refers to obtaining the image detection result, that is, the image detection result for the foreground target.
[0078] The embodiments of the present invention are improved from two aspects: the initialization establishment of the background model and the classification threshold Rx, quickly eliminating "ghosts" and improving the adaptability to dynamic backgrounds at the same time.
[0079] First, when initializing the background model, expand the neighborhood selected by the ViBe algorithm to obtain the expanded neighborhood. Expand the neighborhood selected by the ViBe algorithm to a 5×5 neighborhood, that is, select 24 pixel points in the 5×5 neighborhood to establish a sample set space. By calculating the distance weight contribution rate of the neighborhood pixel points to the central pixel point, it is found that the 5×5 neighborhood pixel points are better than the 3×3 neighborhood pixel points. The derivation theory is as follows:
[0080] As Figure 5 shown, it is a 5×5 neighborhood. As Figure 1 shown, 8 pixel values are randomly selected as sample values. The size of one pixel unit is 1, so the distances from the 8 pixel points to the central pixel point are all 1. As Figure 5 shown, 24 pixel points use the distance weight method to calculate the distance from each pixel point to the central pixel point, and the distance sizes are shown as Figure 5 shown in.
[0081] According to the distance weight, calculate the probability that each pixel point in the neighborhood is selected as a sample in the sample set. The closer the distance to the current pixel point, the greater the weight and the greater the probability of being selected into the sample set. As shown in Equation (3-5):
[0082]
[0083] Among them, k represents the kth pixel point, and S k represents the weight of the kth pixel point, and 1m kIt represents the reciprocal of the distance from the k-th pixel to the central pixel. According to the above formula, calculate the contribution rate ratio of the 3×3 pixel matrix and the 5×5 pixel matrix:
[0084]
[0085] It can be seen from this that the contribution rate ratio of the 3×3 pixel matrix and the 5×5 pixel matrix is 61.31%, so relatively speaking, the contribution rate of the 5×5 pixel matrix is higher.
[0086] In the above step S2, the device constructs a background model sample set according to the expanded neighborhood, and calculates a dynamic background complexity parameter according to the background model sample set, the current frame image information, and the preset factor related to the application scenario.
[0087] In the foreground detection process, the classification threshold Rx is an important basis for determining whether a pixel belongs to the foreground or the background. In the existing algorithm, the value of Rx is fixed and needs to be set manually. If Rx is set too small, false detections will occur due to background changes; if it is set too large, foreground targets cannot be detected. In order to more flexibly adapt to the changes of the dynamic background, a method of determining the pixel adaptive threshold based on the dynamic background complexity parameter is used.
[0088] Introduce the dynamic background complexity parameter Set D(x) as the pixel information of the current frame image of the video, that is, the pixel value of pixel point x (obtained based on the expanded neighborhood, different from p(x) obtained based on the neighborhood before expansion, but the acquisition method is the same), D ij (x) is the background model sample set, that is, the sample set of pixel point x (obtained based on the expanded neighborhood, different from S(x) obtained based on the neighborhood before expansion, but the acquisition method is the same), that is, the sample set established during the initialization of the background model.
[0089] θ is the suppression coefficient, that is, the preset factor related to the application scenario, which can be selected as a value between 0 and 1, and is related to the application scenario. Once the application scenario is determined, this value is determined. If the application scenario is security, it can be selected as the value corresponding to the security application scenario.
[0090] M and N represent the size information of the current frame image, that is, the size of the image is M×N. The current frame image information can include the current frame image pixel information and the current frame image size information.
[0091] Dynamic background complexity parameter It can be adjusted to an appropriate value according to the change degree of the dynamic background. Construct a background model sample set according to the expanded neighborhood, and calculate the dynamic background complexity parameter according to the background model sample set, the current frame image information, and the preset factor related to the application scenario, including:
[0092] Calculate a dynamic background complexity parameter according to the background model sample set, the current frame image pixel information, the current frame image size information, and the application scenario related preset factors. The expression is as follows:
[0093]
[0094] Among them, the parameters can be referred to the above description and will not be elaborated here.
[0095] In the above step S3, the device adaptively calculates the pixel adaptive threshold according to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter, and uses the pixel adaptive threshold obtained by the adaptive calculation as the optimized ViBe algorithm parameter.
[0096] Among them, The value of changes automatically according to the complexity of the environment. If the background in the environment changes greatly, then the value is larger. On the contrary, the value is smaller. Generally, the adjustment rule for the classification threshold Rx can refer to the following rule:
[0097]
[0098] In the formula, R(x) is the improved pixel adaptive threshold (to distinguish from the existing classification threshold R), which changes according to If it is required that R(x) does not converge at a fixed speed, but is adjusted variably according to the size of the difference, so the threshold adjustment amount λ is set as a variable value, and let λ be:
[0099]
[0100] It can be obtained from formula (3-8) that the value of λ is between 0 and 1. Therefore, let the coefficient Substitute it into formula (3-9) to get:
[0101]
[0102] Substitute (3-10) into formula (3-8) to get:
[0103]
[0104] That is, the adaptive calculation of the pixel adaptive threshold according to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter includes:
[0105] If it is determined that the pixel adaptive threshold is greater than the dynamic background complexity parameter, the following first calculation formula is used to perform adaptive calculation on the pixel adaptive threshold:
[0106]
[0107] If it is determined that the pixel adaptive threshold is less than or equal to the dynamic background complexity parameter, the following second calculation formula is used to perform adaptive calculation on the pixel adaptive threshold:
[0108]
[0109] Where, R(x) is the pixel adaptive threshold, is the dynamic background complexity parameter.
[0110] Simplifying Equation (3-11) gives:
[0111]
[0112] As can be seen from Equation (3-12), to prevent abnormal calculation of the pixel adaptive threshold, when R(x) is greater than or equal to 2 times adjust it to be less than 2 times Preferably 1.5 times
[0113] That is, if it is determined that then perform adaptive adjustment on R(x) so that
[0114] The improved ViBe algorithm is summarized as follows:
[0115] (1) Background initialization: For the input initialization image, select the first frame image to establish a background model. Use the pixel values of the 5×5 neighborhood centered on the pixel as sample values, and calculate the Euclidean distance value d for the 25 pixel points in the 5×5 neighborhood centered on the pixel. Since the larger d is, the closer the distance to the current pixel point, the greater the weight, and the greater the probability of being selected into the sample set. Therefore, then sort d from large to small, and select the first 20 pixel points as sample values, overcoming the disadvantage of high repetition rate of existing sample values. At the same time, compared with the 3×3 model, the diversity of samples is increased. Then, combine the conservative background update and the foreground point counting update mechanism to eliminate ghosting.
[0116] (2) Foreground detection: Set the initial value of R(x) to 20, and subsequently calculate a new R(x) according to the adaptive change formula of Equation (3-12) to replace the initial value. Set U minIf it is 2, when the Euclidean distance between the current pixel value and the sample point is less than R(x), and the number of background points less than R(x) is greater than or equal to 2, it is determined as a background pixel; otherwise, it is determined as a foreground pixel.
[0117] (3) Background update: An update mechanism combining conservative update and foreground point counting is adopted. On the one hand, the conservative update mechanism can ensure that the background model can only be updated by background pixel points. On the other hand, by combining the update mechanism of foreground point counting, moving objects staying in the background for a long time can be updated as the background, preventing the deadlock phenomenon caused by conservative update.
[0118] The method for optimizing the parameters of the ViBe algorithm provided by the embodiment of the present invention expands the neighborhood selected by the ViBe algorithm to obtain an expanded neighborhood; constructs a background model sample set according to the expanded neighborhood, calculates a dynamic background complexity parameter according to the background model sample set, the current frame image information, and a preset factor related to the application scenario; adaptively calculates the pixel adaptive threshold according to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter, and uses the adaptively calculated pixel adaptive threshold as the optimized ViBe algorithm parameter, which can eliminate ghosting, avoid sample duplication, improve the adaptability to dynamic backgrounds, and thus improve the detection accuracy.
[0119] Further, the expanding the neighborhood selected by the ViBe algorithm to obtain an expanded neighborhood includes:
[0120] Expand the neighborhood selected by the ViBe algorithm to a 5×5 neighborhood. For details, refer to the above description and will not be elaborated here.
[0121] The method for optimizing the parameters of the ViBe algorithm provided by the embodiment of the present invention expands the neighborhood selected by the ViBe algorithm to a 5×5 neighborhood, which can avoid sample duplication. At the same time, since the neighborhood expansion is not too large, the operation response speed can also be taken into account.
[0122] Further, the current frame image information includes current frame image pixel information and current frame image size information; correspondingly, the calculating the dynamic background complexity parameter according to the background model sample set, the current frame image information, and a preset factor related to the application scenario includes:
[0123] Calculate the dynamic background complexity parameter according to the background model sample set, the current frame image pixel information, the current frame image size information, and the preset factor related to the application scenario. For details, refer to the above description and will not be elaborated here.
[0124] The optimization method for ViBe algorithm parameters provided by the embodiments of the present invention can further accurately and quantitatively calculate the dynamic background complexity parameter, further eliminate ghosting, avoid sample duplication, improve the adaptability to dynamic backgrounds, and thus improve the detection accuracy.
[0125] Further, the adaptive calculation of the pixel adaptive threshold according to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter includes:
[0126] If it is determined that the pixel adaptive threshold is greater than the dynamic background complexity parameter, the following first calculation formula is used for the adaptive calculation of the pixel adaptive threshold:
[0127]
[0128] where R(x) is the pixel adaptive threshold, is the dynamic background complexity parameter. Refer to the above description and will not be elaborated here.
[0129] The optimization method for ViBe algorithm parameters provided by the embodiments of the present invention uses the first calculation formula to perform adaptive calculation on the pixel adaptive threshold, further improves the adaptability to dynamic backgrounds, and thus improves the detection accuracy.
[0130] Further, the adaptive calculation of the pixel adaptive threshold according to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter includes:
[0131] If it is determined that the pixel adaptive threshold is less than or equal to the dynamic background complexity parameter, the following second calculation formula is used for the adaptive calculation of the pixel adaptive threshold:
[0132]
[0133] where R(x) is the pixel adaptive threshold, is the dynamic background complexity parameter. Refer to the above description and will not be elaborated here.
[0134] The optimization method for ViBe algorithm parameters provided by the embodiments of the present invention uses the second calculation formula to perform adaptive calculation on the pixel adaptive threshold, further improves the adaptability to dynamic backgrounds, and thus improves the detection accuracy.
[0135] Further, the optimization method for ViBe algorithm parameters further includes:
[0136] If it is determined that then perform adaptive adjustment on R(x) to make Reference may be made to the above description and will not be elaborated herein.
[0137] The method for optimizing ViBe algorithm parameters provided by the embodiments of the present invention can effectively prevent abnormal calculation of pixel adaptive thresholds.
[0138] Furthermore, an image detection method based on the above method for optimizing ViBe algorithm parameters includes:
[0139] Obtain the image to be detected;
[0140] Perform image detection on the image to be detected based on a preset image detection model to obtain an image detection result; the preset image detection model is a ViBe algorithm including optimized ViBe algorithm parameters. The video to be detected can be input into the preset image detection model, and the preset image detection model performs image detection on each frame of the image to be detected in the video to be detected and outputs an image detection result, that is, the image detection result for the foreground target.
[0141] Traditional security systems in bank branches require manual duty, resulting in high labor costs and being prone to missed detections and false detections. The monitoring system itself cannot perform automatic detection and alarm in a timely manner.
[0142] Moving target detection is commonly used in medical, traffic video surveillance, and intelligent security monitoring systems. Moving target detection: is a detection method for separating the foreground and the background, that is, extracting the changing area from the background image in a sequence of images. The background refers to the part that remains fixed except for the foreground, such as buildings, trees, etc. The foreground refers to the objects that are moving when the background is in a stationary state, such as people, vehicles, animals, etc. in the video.
[0143] When performing moving target detection on the video in an intelligent security monitoring system using the existing ViBe algorithm, there will be "ghost images" in the video frame images, which seriously affect the monitoring effect and quality. The embodiments of the present invention improve the existing ViBe algorithm and apply it to the above application scenarios, and can obtain better moving target detection effects to improve the monitoring quality of the monitoring system.
[0144] The method for optimizing ViBe algorithm parameters provided by the embodiments of the present invention can eliminate ghost images, avoid sample duplication, and improve the adaptability to dynamic backgrounds by using a preset image detection model to perform image detection on the image to be detected, thereby improving the detection accuracy.
[0145] It should be noted that the method for optimizing ViBe algorithm parameters provided by the embodiments of the present invention can be used in the financial field and can also be used in any technical field other than the financial field. The embodiments of the present invention do not limit the application field of the method for optimizing ViBe algorithm parameters.
[0146] Figure 6 This is a schematic structural diagram of an optimization processing device for ViBe algorithm parameters provided by an embodiment of the present invention. As Figure 6 shown, the optimization processing device for ViBe algorithm parameters provided by the embodiment of the present invention includes an expansion unit 601, a calculation unit 602, and an optimization unit 603, where:
[0147] The expansion unit 601 is used to expand the neighborhood selected by the ViBe algorithm to obtain an expanded neighborhood; the calculation unit 602 is used to construct a background model sample set according to the expanded neighborhood, and calculate a dynamic background complexity parameter according to the background model sample set, the current frame image information, and a preset factor related to the application scenario; the optimization unit 603 is used to perform adaptive calculation on the pixel adaptive threshold according to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter, and use the pixel adaptive threshold obtained by the adaptive calculation as the optimized ViBe algorithm parameter.
[0148] Specifically, the expansion unit 601 in the device is used to expand the neighborhood selected by the ViBe algorithm to obtain an expanded neighborhood; the calculation unit 602 is used to construct a background model sample set according to the expanded neighborhood, and calculate a dynamic background complexity parameter according to the background model sample set, the current frame image information, and a preset factor related to the application scenario; the optimization unit 603 is used to perform adaptive calculation on the pixel adaptive threshold according to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter, and use the pixel adaptive threshold obtained by the adaptive calculation as the optimized ViBe algorithm parameter.
[0149] The optimization processing device for ViBe algorithm parameters provided by the embodiment of the present invention expands the neighborhood selected by the ViBe algorithm to obtain an expanded neighborhood; constructs a background model sample set according to the expanded neighborhood, and calculates a dynamic background complexity parameter according to the background model sample set, the current frame image information, and a preset factor related to the application scenario; performs adaptive calculation on the pixel adaptive threshold according to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter, and uses the pixel adaptive threshold obtained by the adaptive calculation as the optimized ViBe algorithm parameter, which can eliminate ghosting, avoid sample duplication, and improve the adaptability to dynamic backgrounds, thereby improving the detection accuracy.
[0150] Further, the expansion unit 601 is specifically used for:
[0151] Expand the neighborhood selected by the ViBe algorithm to a 5×5 neighborhood.
[0152] The optimization processing device for ViBe algorithm parameters provided by the embodiments of the present invention expands the neighborhood selected by the ViBe algorithm to a 5×5 neighborhood, which can avoid sample duplication. At the same time, since the neighborhood expansion is not too large, the operation response speed can also be taken into account.
[0153] Further, the current frame image information includes current frame image pixel information and current frame image size information; correspondingly, the calculation unit 602 is specifically configured to:
[0154] Calculate a dynamic background complexity parameter according to the background model sample set, the current frame image pixel information, the current frame image size information, and the preset factor related to the application scenario.
[0155] The optimization processing device for ViBe algorithm parameters provided by the embodiments of the present invention further accurately and quantitatively calculates the dynamic background complexity parameter, can further eliminate ghosting, avoid sample duplication, and improve the adaptability to the dynamic background, thereby improving the detection accuracy.
[0156] Further, the optimization unit 603 is specifically configured to:
[0157] If it is determined that the pixel adaptive threshold is greater than the dynamic background complexity parameter, the following first calculation formula is used to perform adaptive calculation on the pixel adaptive threshold:
[0158]
[0159] where R(x) is the pixel adaptive threshold, is the dynamic background complexity parameter.
[0160] The optimization processing device for ViBe algorithm parameters provided by the embodiments of the present invention performs adaptive calculation on the pixel adaptive threshold by using the first calculation formula, further improves the adaptability to the dynamic background, and thereby improves the detection accuracy.
[0161] Further, the optimization unit 603 is specifically configured to:
[0162] If it is determined that the pixel adaptive threshold is less than or equal to the dynamic background complexity parameter, the following second calculation formula is used to perform adaptive calculation on the pixel adaptive threshold:
[0163]
[0164] where R(x) is the pixel adaptive threshold, is the dynamic background complexity parameter.
[0165] The optimization processing device for ViBe algorithm parameters provided by an embodiment of the present invention adaptively calculates the pixel adaptive threshold using a second calculation formula, further improving the adaptability to a dynamic background and thus enhancing the detection accuracy.
[0166] Furthermore, the optimization processing device for ViBe algorithm parameters is further configured to:
[0167] If it is determined that then adaptively adjust R(x) so that
[0168] The optimization processing device for ViBe algorithm parameters provided by an embodiment of the present invention can effectively prevent abnormalities in the calculation of the pixel adaptive threshold.
[0169] Furthermore, an image detection device based on the above optimization processing device for ViBe algorithm parameters is specifically configured to:
[0170] Obtain an image to be detected;
[0171] Perform image detection on the image to be detected based on a preset image detection model to obtain an image detection result; the preset image detection model is a ViBe algorithm including optimized ViBe algorithm parameters.
[0172] The optimization processing device for ViBe algorithm parameters provided by an embodiment of the present invention can eliminate ghost images, avoid sample duplication, and improve the adaptability to a dynamic background by using the preset image detection model to perform image detection on the image to be detected, thereby enhancing the detection accuracy.
[0173] The embodiments of the optimization processing device for ViBe algorithm parameters provided by an embodiment of the present invention can specifically be used to execute the processing procedures of the above method embodiments, and their functions will not be elaborated here. Reference can be made to the detailed descriptions of the above method embodiments.
[0174] Figure 7 The following is a schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention. As Figure 7 shown, the electronic device includes: a processor 701, a memory 702, and a bus 703;
[0175] Among them, the processor 701 and the memory 702 communicate with each other through the bus 703;
[0176] The processor 701 is configured to call program instructions in the memory 702 to execute the methods provided by the above method embodiments, for example, including:
[0177] Expand the neighborhood selected by the ViBe algorithm to obtain an expanded neighborhood;
[0178] Construct a background model sample set according to the expanded neighborhood, and calculate a dynamic background complexity parameter according to the background model sample set, the current frame image information, and a preset factor related to the application scenario;
[0179] According to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter, perform adaptive calculation on the pixel adaptive threshold, and use the adaptively calculated pixel adaptive threshold as the optimized ViBe algorithm parameter.
[0180] This embodiment discloses a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the methods provided in the above method embodiments, for example, including:
[0181] Expand the neighborhood selected by the ViBe algorithm to obtain an expanded neighborhood;
[0182] Construct a background model sample set according to the expanded neighborhood, and calculate a dynamic background complexity parameter according to the background model sample set, the current frame image information, and a preset factor related to the application scenario;
[0183] According to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter, perform adaptive calculation on the pixel adaptive threshold, and use the adaptively calculated pixel adaptive threshold as the optimized ViBe algorithm parameter.
[0184] This embodiment provides a computer-readable storage medium, which stores a computer program that enables the computer to execute the methods provided in the above method embodiments, for example, including:
[0185] Expand the neighborhood selected by the ViBe algorithm to obtain an expanded neighborhood;
[0186] Construct a background model sample set according to the expanded neighborhood, and calculate a dynamic background complexity parameter according to the background model sample set, the current frame image information, and a preset factor related to the application scenario;
[0187] According to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter, perform adaptive calculation on the pixel adaptive threshold, and use the adaptively calculated pixel adaptive threshold as the optimized ViBe algorithm parameter.
[0188] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0189] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be realized by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate means for realizing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0190] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including instruction means that realize the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0191] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for realizing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0192] In the description of this specification, the description with reference to terms such as "one embodiment", "a specific embodiment", "some embodiments", "for example", "example", "specific example", or "some examples", etc. means that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0193] The specific embodiments described above have further elaborated on the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above are only specific embodiments of the present invention and are not used to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. An optimization method for ViBe algorithm parameters, characterized in that Including: Expand the neighborhood selected by the ViBe algorithm to obtain an expanded neighborhood; Construct a background model sample set according to the expanded neighborhood, and calculate a dynamic background complexity parameter according to the background model sample set, the current frame image information, and a preset factor related to the application scenario; According to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter, adaptively calculate the pixel adaptive threshold, and use the adaptively calculated pixel adaptive threshold as the optimized ViBe algorithm parameter, where the pixel adaptive threshold is used as the classification threshold in the ViBe algorithm parameters; Wherein, the dynamic background complexity parameter is calculated by the following formula: ; Among them, is the dynamic background complexity parameter, is the pixel information of the current frame image of the video, that is, the pixel point pixel value, is the background model sample set, that is, the sample set of the pixel point sample set, is the suppression coefficient, that is, an application scenario-related preset factor, which can be selected as a value between 0 and 1. M and N represent the current frame image size information, that is, the size of the image is , and the current frame image information includes the current frame image pixel information and the current frame image size information; The adaptively calculating the pixel adaptive threshold according to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter includes: if it is determined that the pixel adaptive threshold is greater than the dynamic background complexity parameter, then use the following first calculation formula to adaptively calculate the pixel adaptive threshold: ; If it is determined that the pixel adaptive threshold is less than or equal to the dynamic background complexity parameter, then use the following second calculation formula to adaptively calculate the pixel adaptive threshold: ; Among them, is the pixel adaptive threshold, is the dynamic background complexity parameter.
2. The optimization method for ViBe algorithm parameters according to claim 1, characterized in that The expanding the neighborhood selected by the ViBe algorithm to obtain an expanded neighborhood includes: Expand the neighborhood selected by the ViBe algorithm to a 5×5 neighborhood.
3. The optimization method for ViBe algorithm parameters according to claim 1, characterized in that, The method for optimizing the ViBe algorithm parameters further includes: If it is determined that , then perform adaptive adjustment on so that .
4. An image detection method based on an optimization processing method for ViBe algorithm parameters as described in claim 1, characterized in that, Including: Obtain an image to be detected; Perform image detection on the image to be detected based on a preset image detection model to obtain an image detection result; The preset image detection model is the ViBe algorithm including the optimized ViBe algorithm parameters.
5. An optimization processing device for ViBe algorithm parameters, characterized in that, Including: An expansion unit, configured to expand the neighborhood selected by the ViBe algorithm to obtain an expanded neighborhood; A calculation unit, configured to construct a background model sample set according to the expanded neighborhood, and calculate a dynamic background complexity parameter according to the background model sample set, the current frame image information, and a preset factor related to the application scenario; An optimization unit, configured to adaptively calculate the pixel adaptive threshold according to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter, and use the adaptively calculated pixel adaptive threshold as the optimized ViBe algorithm parameter, where the pixel adaptive threshold is used as the classification threshold in the ViBe algorithm parameters; Wherein, the dynamic background complexity parameter is calculated by the following formula: ; Among them, is the dynamic background complexity parameter, is the pixel information of the current frame image of the video, that is, the pixel point pixel value, is the background model sample set, that is, the sample set of the pixel point ; is the suppression coefficient, that is, an application scenario-related preset factor, which can be selected as a value between 0 and 1. M and N represent the current frame image size information, that is, the size of the image is , and the current frame image information includes the current frame image pixel information and the current frame image size information; The adaptively calculating the pixel adaptive threshold according to the comparison result between the pixel adaptive threshold of the ViBe algorithm and the dynamic background complexity parameter includes: if it is determined that the pixel adaptive threshold is greater than the dynamic background complexity parameter, then use the following first calculation formula to adaptively calculate the pixel adaptive threshold: ; If it is determined that the pixel adaptive threshold is less than or equal to the dynamic background complexity parameter, then use the following second calculation formula to adaptively calculate the pixel adaptive threshold: ; Among them, is the pixel adaptive threshold, is the dynamic background complexity parameter.
6. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, the steps of the method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Marine ship target detection method based on improved background difference method
CN111259866A
Dynamic target detection method
CN112561946A