Moving target detection method, device and storage medium
The simplified optical flow method is used to detect moving targets in dynamic backgrounds, and gradient calculation and merging step sizes are used to improve detection accuracy. This solves the problems of high complexity and limitations of infrared image detection in the existing technology, and realizes detection in dynamic scenes. Efficient moving target detection.
Patent Information
- Application Number
- CN202210043527.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-14
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2042-01-14
AI Technical Summary
Existing moving target detection algorithms are highly complex in dynamic backgrounds and have great limitations in detecting infrared images, making it difficult to accurately detect moving targets in dynamic scenes, especially when the temperature of static objects is higher than the target.
Using a simplified optical flow method, the original optical flow matrix is obtained by obtaining the gradient calculation of the current image and the previous image, and merging them using the merging step size to obtain a stable optical flow field representation, thereby determining the position of the moving target. This method is based on the Horn–Schunck optical flow calculation algorithm, which simplifies the iterative calculation process and is suitable for infrared and visible light images under dynamic backgrounds.
It reduces the usage of computing resources, improves the accuracy of moving target detection, overcomes the limitations of traditional methods in tracking the highest temperature point in infrared images, is suitable for mobile devices with limited resources, and can effectively detect moving targets in complex scenes. .
Smart Images

Figure CN114399539B
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing and computing, and in particular to a moving target detection method, device and storage medium. Background Art
[0002] Moving target tracking is a common and necessary image processing technology. Traditional dynamic target tracking methods are mainly aimed at detecting moving targets under static backgrounds, such as background difference method, frame difference method and optical flow method. Background difference method refers to storing the background image in advance and then performing a difference operation with the observed image to detect the moving area. Although the background difference method can obtain relatively complete moving target information, the background image must be continuously updated with changes in external conditions such as illumination, and the acquisition and update of the background model is relatively troublesome. The frame difference method refers to a method of directly comparing the grayscale values of the corresponding pixels of two adjacent frames of images, and then extracting the moving area in the sequence image through a threshold. The frame difference method has a fast update speed, a simple and easy-to-implement algorithm, strong adaptability, and does not require the acquisition of a background image, but there needs to be a certain degree of grayscale difference between the background and the moving target, otherwise a hole may be generated inside the target, and the moving target cannot be completely extracted.
[0003] Traditional motion target detection methods for static backgrounds have great limitations for dynamic target tracking in dynamic backgrounds. Moreover, on some handheld mobile devices, dynamic target tracking in dynamic backgrounds has higher requirements, considering both the tracking effect and the limited performance of the machine. This is a great challenge to achieve using traditional methods.
[0004] At present, one implementation method of dynamic target detection based on dynamic background is to use motion estimation method and feature point matching algorithm to realize it, that is, by finding the unique matching point of each feature point of the reference image in the image, the displacement vector is obtained by the change of the point position between two frames, and then all motion information is brought into the motion model to obtain the global motion parameters of the background. Finally, the global motion parameters are used to stabilize the front and back frame images, and then the frame difference method is used to find the dynamic target. Another existing implementation method of dynamic target detection based on dynamic background is a dynamic target detection method based on deep learning, which mainly uses SVM (Support Vector Machines) or neural network to mark the dynamic targets in the image and then train them, so as to achieve the effect of tracking dynamic targets. However, the calculation of global motion parameters using matching point algorithm has high complexity and will occupy a large part of computing resources. For deep learning methods, since not all devices support deep learning acceleration, the application range is limited. In addition, based on the characteristics of infrared imaging, the existing recognition method for dynamic targets on infrared devices is to assume that the dynamic target has a higher temperature than the surrounding environment by default, and use the highest temperature point to track the target. Although the method of using the highest temperature point to track targets in infrared scenes is simple to implement, some objects in some scenes (such as rocks exposed to sunlight) often have higher temperatures than the target. Therefore, for dynamic targets on infrared devices, the method of only detecting the highest temperature point also has great limitations. Summary of the invention
[0005] In order to solve the existing technical problems, the present application provides a moving target detection method, device and storage medium that can reduce the computing power resources occupied.
[0006] A moving target detection method, comprising:
[0007] Acquire a current image and a previous image associated with the current image;
[0008] Performing gradient calculation based on pixels in the first detection window corresponding to the current image and the previous image, and determining an original optical flow matrix of the current image based on the gradient calculation result;
[0009] Merging the original optical flow matrices according to a set merging step size to obtain a merged optical flow matrix;
[0010] An optical flow field change region is determined according to the combined optical flow matrix, and a position of a moving target in the current image is determined according to the optical flow field change region.
[0011] A moving target detection device, comprising a memory and a processor;
[0012] The processor executes the steps of the detection method when running the computer program instructions stored in the memory.
[0013] A computer-readable storage medium storing computer program instructions;
[0014] When the computer program instructions are executed by a processor, the steps of the detection method are implemented.
[0015] As can be seen from the above, in the moving target detection method provided by the present application, gradient calculation is performed based on the pixels in the first detection window corresponding to the current image and the previous image, and the original optical flow matrix of the current image is determined based on the gradient calculation result. The method for calculating the optical flow is relatively simple and occupies less computing power resources. In addition, the original optical flow matrix is merged using a set merging step size to obtain a stable representation of the optical flow field, so that the moving target positioning performed based on the change area of the optical flow field determined by the merged optical flow matrix has a higher accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings are only used to illustrate the embodiments and are not to be considered as limiting the present invention. In addition, the same reference symbols are used to represent the same components throughout the accompanying drawings. In the accompanying drawings:
[0017] Figure 1 This is a schematic diagram of the principle of moving target detection based on optical flow field;
[0018] Figure 2 A schematic diagram of a method for detecting a moving target according to some embodiments of the present application;
[0019] Figure 3 A schematic diagram of a first detection window at a corresponding sliding step according to some embodiments of the present application;
[0020] Figure 4 A schematic flow chart of a method for detecting a moving target according to other embodiments of the present application;
[0021] Figure 5 A schematic diagram of a moving target detection device provided according to some embodiments of the present application;
[0022] Figure 6 A schematic diagram of the structure of a moving target detection device provided according to some embodiments of the present application. DETAILED DESCRIPTION
[0023] The technical solution of the present application is further elaborated in detail below in conjunction with the accompanying drawings and specific embodiments of the specification.
[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit the implementation of this application. The term "and / or" used herein includes any and all combinations of one or more related listed items.
[0025] In the description of the present application, it should be understood that the terms "center", "upper", "lower", "front", "back", "left", "right", "vertical", "row", "top", "bottom", "inside", "outside", etc., indicating positions or positional relationships, are based on the positions or positional relationships shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific position, be constructed and operated in a specific position, and therefore cannot be understood as a limitation on the present application. In the description of the present application, unless otherwise specified, "multiple" means two or more.
[0026] In the description of this application, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a direct connection, or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0027] In order to solve the problems of high complexity of existing moving target detection algorithms and their limitations when applied to infrared image detection, the present application provides a new moving target detection method. The new moving target detection method provided in some embodiments of the present application can solve the problem of infrared moving target detection in dynamic scenes. It can detect the position of the moving target in the dynamic scene when there are static objects with similar or higher temperatures, and mark it so that the user can observe the moving target more easily. In addition to being applicable to the detection of moving targets in infrared images, the new moving target detection method provided in some embodiments of the present application can also be applied to the detection of moving targets with obvious motion characteristics in visible light images.
[0028] The moving target detection method provided by some embodiments of the present application is mainly implemented based on the optical flow method. The optical flow method is a method that uses the changes in pixels in the time domain in the image sequence and the correlation between adjacent frames to find the corresponding relationship between the previous image and the current image, thereby calculating the motion information of the object between the previous and next images. Generally speaking, the optical flow is caused by the movement of the foreground target itself in the scene, the movement of the camera, or the joint movement of the two. The optical flow on the image can be regarded as the motion trajectory of the object or scene. It has a size and direction at a certain instant and is a two-dimensional vector. The optical flow is defined based on the pixel points, and the set of all optical flows is called the optical flow field. The optical flow field is a two-dimensional vector field, which reflects the change trend of the grayscale of each point on the image. It can be regarded as the instantaneous velocity field generated by the movement of the grayscale pixel points on the image plane. The information it contains is the instantaneous motion velocity vector information of each pixel.
[0029] The Horn–Schunck optical flow calculation algorithm (hereinafter referred to as the HS optical flow calculation algorithm) is an optical flow calculation method based on two assumptions about the optical properties of object motion. The two assumptions are:
[0030] 1. The grayscale of a moving object remains unchanged within a very short interval;
[0031] 2. The velocity vector field within a given neighborhood changes slowly.
[0032] Based on the above assumptions, if Figure 1 As shown in the figure, in a scene without dynamic targets, if the scene moves as a whole, the size and direction of the optical flow on its image should be consistent. If there is a target in the scene, as long as the target and the scene are relatively displaced, its optical flow vector will be inconsistent with the optical flow vector of the overall scene. In this way, the position of the moving target can be found by finding the inconsistent optical flow vector area (the changing area of the optical flow field).
[0033] The following is an introduction to the derivation process of the HS optical flow calculation algorithm:
[0034] Based on the first assumption above, we can get the following equation (1):
[0035] I(x,y,t)=I(x+δx,y+δy,t+δt) (1)
[0036] In equation (1), I(x, y, t) represents the grayscale function of the moving object, and δx and δy are the displacements of the pixel in the x and y axes within the time δt, respectively. Taylor expansion of the right side of equation (1) at x and y gives the following equation (2):
[0037]
[0038] In equation (2), ε is a second-order and higher-order term including δx, δy, and δt. Subtract I(x, y, t) from both sides of equation (2) and divide by δt to obtain the following equation (3):
[0039]
[0040] In equation (3), O(δt) is a small quantity containing δt. In the limit, when δt->0, that is, δt approaches 0 from both sides of 0, equation (3) can be transformed into the following equation (4):
[0041]
[0042] Furthermore, as well as Then equation (4) becomes the following equation (5):
[0043] I x u+I y v+I t =0 (5)
[0044] Equation (5) is the optical flow constraint equation, which reflects the corresponding relationship between grayscale and speed. When there are two variables u and v in equation (5), the speed cannot be solved. Therefore, it is necessary to introduce the second assumption mentioned above, that is, the global smoothness constraint condition of the optical flow, and introduce the second assumption into the smoothness term, as shown in equation (6):
[0045]
[0046] For all pixels, the sum of equations (5) and (6) must be minimized. Therefore, the following equation (7) can be established:
[0047] ζ 2 =∫∫α 2 ζ 2 +(I x u+I y v+I t ) 2 dxdy (7)
[0048] In equation (7), α represents the smoothing weight coefficient, which represents the weight of the speed smoothing term. Since the sum of equations (5) and (6) needs to be minimized, the following equation (8) needs to be minimized:
[0049]
[0050] Using variational calculation for equation (8), according to the Euler equation, we can obtain the following equations (9) and (10):
[0051]
[0052]
[0053] And further transform equations (9) and (10) to obtain the following equations (11) and (12):
[0054]
[0055]
[0056] The Laplace operator in equations (11) and (12) is approximated by the difference between the velocity of a point and the average velocity of its surroundings, and the following equations (13) and (14) are obtained:
[0057]
[0058]
[0059] Simplifying equations (13) and (14), we can obtain the following equations (15) and (16):
[0060]
[0061]
[0062] The corresponding u and v are calculated according to the above equations (15) and (16) using an iterative algorithm to obtain the optical flow field of the image.
[0063] During the research process, the inventors of the present application believed that the detection of moving targets based on the existing HS optical flow calculation algorithm requires iterative calculation during the detection process, which will occupy a large part of the computing resources and is not suitable for mobile devices with limited computing and storage resources, such as FPGA (Field Programmable Gate Array).
[0064] Based on the above problems, a method flow chart of a moving target detection method provided in some embodiments of the present application is as follows: Figure 2 As shown, the moving target detection method provided in this embodiment includes S2, S4, S6 and S8. The moving target detection method provided in this embodiment is as follows Figure 5 The moving target detection device shown in Figure 6 The moving target detection device is implemented as shown.
[0065] S2: Acquire a current image and a previous image associated with the current image.
[0066] Specifically, S2 can be composed of Figure 5The image acquisition module 11 in the moving target detection device shown in FIG. Figure 6 The memory 21 in the moving target detection device shown in the figure stores the image acquisition program, which is then Figure 6 The processor 22 in the shown moving target detection device is implemented when executing the image acquisition program stored in the memory 21.
[0067] In some embodiments, the current image and the previous image of the current image can be obtained from the video image sequence as two images to be detected. In other embodiments, the previous image and the current image can also be images captured successively by an image capture device (such as a camera). The previous image can be a previous image adjacent to the current image, or a previous image separated from the current image by a moving time interval.
[0068] Since the optical flow method calculates the optical flow field based on the motion information in two different images before and after the time axis, it is necessary to obtain the current image and the previous image. Therefore, in some embodiments, before obtaining the current frame image and the previous frame image from the video image sequence according to the moving target detection method provided by the present application, it is necessary to first define a cache frame for storing the previous frame image. Specifically, the previous frame image is the previous frame image adjacent to the current frame image. At the beginning of the execution of the moving target detection method, the cache frame is blank, but since the data of the cache frame is needed in the process of calculating the optical flow, when it is detected that the current frame image is the first frame in the video image sequence, the cache frame needs to be initialized. The method of initializing the cache frame is to copy the current frame image of the first frame as the initial value of the cache frame. Then in the subsequent cycle process, the content in the cache frame needs to be updated, and the updating method is to use the current frame image as the cache frame, then at the beginning of the next frame, the previous current frame image is used as the previous frame image of the next frame image, and the next frame image is used as the current current frame image.
[0069] S4: performing gradient calculation based on the pixels in the first detection window corresponding to the current image and the previous image, and determining the original optical flow matrix of the current image based on the gradient calculation result.
[0070] S4 can be Figure 5 The original optical flow calculation module 12 in the moving target detection device shown in FIG. Figure 6 The memory 21 in the moving target detection device shown in FIG. 1 stores the original optical flow calculation program, which is then Figure 6 The processor 22 in the moving target detection device shown is implemented when executing the original optical flow calculation program stored in the memory 21.
[0071] Specifically, in S4, the first detection window is used to obtain the sub-images at the corresponding positions of the current image and the previous image (the area framed by the first detection window), and then the gradient between the sub-images at the corresponding positions of the current image and the previous image is calculated, and the optical flow matrix of the current image and the original image is determined according to the calculation result of the gradient, that is, according to the gradient value between each pair of sub-images (the current image and the sub-image corresponding to the previous image), an optical flow vector in the original optical flow matrix can be calculated.
[0072] Specifically, S4 further includes:
[0073] S41: using a first detection window of a set size to slide through the current image and the previous image in sequence.
[0074] S42: performing gradient calculation based on pixels contained in the first detection window in the current image and the previous image corresponding to each sliding step of the first detection window.
[0075] S43: Determine the optical flow vector corresponding to each sliding step of the first detection window according to the gradient calculation result, and then determine the original optical flow matrix of the current image.
[0076] In some embodiments, the length and width of the first detection window are equal, and when the first detection window is used to traverse the current image fr2 and the previous image fr1, the first detection window may be used to synchronously and sequentially traverse the current image fr2 and the previous image fr1. The sequential sliding traversal means that the traversal paths of the first detection window in the current image fr2 and the previous image fr1 are the same, such as starting from the first pixel point of the current image fr2 and the previous image fr1 and traversing from left to right and from top to bottom, or starting from the last pixel point of the current image fr2 and the previous image fr1 and traversing from right to left and from bottom to top.
[0077] In other embodiments, the time when the first detection window traverses the current image fr2 and the time when the first detection window traverses the previous image fr1 are not synchronized, and can be a sequential relationship. Therefore, before performing gradient calculation according to the pixels in the corresponding first detection window, it is necessary to determine the corresponding position of the first detection window in the previous image according to the position of the first detection window in the current image fr2. That is, the first group of pixels and the second group of pixels are the corresponding pixels in the first detection window at the same sliding position in the current image fr2 and the previous image fr1.
[0078] Performing gradient calculation based on the first group of pixels and the second group of pixels means calculating the pixel gradient between the first detection window in the current image fr2 and the first detection window in the previous image fr1 based on the first group of pixels and the second group of pixels. At each sliding step of the first detection window, the first detection window in the previous image fr1 is equivalent to the first sub-image fr11 of the previous image fr1, and the first detection window in the current image fr2 is equivalent to the second sub-image fr21 in the current image fr2, and the position of the second sub-image fr21 in the current image fr2 is the same as the position of the first sub-image fr11 in the previous image fr1. Performing gradient calculation based on the first group of pixels and the second group of pixels is to calculate the image gradient between the second sub-image fr21 and the first sub-image fr11. After obtaining the image gradient corresponding to the first detection window at each sliding step, the corresponding optical flow vector can be calculated based on the gradient method. When calculating the optical flow vector based on the image gradient, as with the HS optical flow calculation method, the following two constraints need to be set:
[0079] 1. The grayscale of a moving object remains unchanged within a very short interval;
[0080] 2. The velocity vector field within a given neighborhood changes slowly.
[0081] The corresponding optical flow vector is calculated based on the calculation result of the image gradient and the above two constraints. Determining the original optical flow matrix of the current image according to the optical flow vector corresponding to each sliding step of the first detection window means that each element in the original optical flow matrix is the optical flow vector, and the position of the corresponding optical flow vector in the original optical flow matrix is determined according to the position of the corresponding first detection window in the current image. The first detection window can select a matrix with the same number of rows and columns. In order to reduce the computational power in the process of moving target detection, the first detection window can be set to a minimum detection unit matrix of 2×2.
[0082] In addition, it should be noted that the optical flow vector calculated above includes a first component u in the x-axis direction and a second component v in the y-axis direction, and the optical flow vector includes u and v. In some embodiments, each original optical flow vector in the original optical flow matrix can be (u, v), that is, the original optical flow matrix is a matrix containing a first component and a second component. In other embodiments, the original optical flow matrix includes a first component original matrix and a second component original matrix. Among them, each element in the first component original matrix is the corresponding first component, and each element in the second component original matrix is the corresponding second component. Therefore, in some embodiments, before determining the original optical flow matrix, the motion detection method also needs to define the first component original matrix U and the second component original matrix V respectively, and then fill the calculated first components and second components into the defined first component original matrix U and second component original matrix V respectively to determine the original optical flow matrix.
[0083] In some embodiments provided in the present application, a first detection window of a preset size is used to slide through the current image fr2 and the previous image fr1 respectively. At each sliding step of the first detection window, the current image fr2 and the first detection window at the corresponding position in the previous image fr1 can respectively capture the second sub-image fr21 of the current image fr2 and the first sub-image fr11 of the previous image fr1, and then the image gradient is calculated based on the second sub-image fr21 and the first sub-image fr11, and the optical flow vector corresponding to each sliding step is calculated based on the image gradient. Since it is relatively simple to calculate the image gradient of each sub-image, the calculation process of the optical flow vector based on the image gradient between each sub-image occupies less computing resources and can be implemented on a mobile device with less computing and storage resources (such as FPGA).
[0084] S6: According to the original optical flow matrix and the set merging step size, the original optical flow matrix is merged to obtain a merged optical flow matrix.
[0085] Specifically, S6 can be Figure 5 The combined optical flow calculation module 13 in the moving target detection device shown in FIG. Figure 6 The memory 21 in the moving target detection device shown in FIG. 1 stores the combined optical flow calculation program, and then Figure 6 The processor 22 in the moving target detection device shown is implemented when executing the merged optical flow calculation program stored in the memory 21.
[0086] In order to avoid the problem that the original optical flow matrix is easily affected by image changes due to its high sensitivity, which causes large errors in the calculation of the subsequent optical flow field change area, it is necessary to merge the original optical flow field matrix to obtain a stable optical flow matrix representation. Before merging, a merging step size needs to be defined first. The step size here includes the first step size step1 corresponding to the row direction (x-axis direction) merging, and the second step size step2 corresponding to the column direction (y-axis direction) merging. Then the original optical flow matrix is merged according to the preset step size, and the number of rows of the obtained merged optical flow matrix is the number of rows of the original optical flow matrix divided by step1, and the number of columns of the merged optical flow matrix is the number of columns of the original optical flow matrix divided by step2. It should be noted that, corresponding to the original optical flow matrix, if each element in the original optical flow matrix is a corresponding (u, v), then each element in the merged optical flow matrix is also a corresponding (u, v). If the original optical flow matrix is composed of the above-mentioned first component original matrix U and the second component original matrix V, then the merged optical flow matrix also includes the first component merged matrix Us and the second component merged matrix Vs. Among them, the number of rows of Us is the number of rows of U divided by step1, the number of columns of Us is the number of columns of U divided by step2, the number of rows of Vs is the number of rows of V divided by step1, and the number of columns of Vs is the number of columns of V divided by step2. Each element in the merged optical flow matrix can be the average value of each original in the original optical flow matrix within each merge step.
[0087] Merging the original optical flow fields can obtain more stable optical flow vectors, improve the accuracy of detection, and reduce the computational complexity of the detection algorithm.
[0088] S8: Determine an optical flow field change region according to the combined optical flow matrix, and determine a position of a moving target in the current image according to the optical flow field change region.
[0089] S8 can be Figure 5 The moving target position determination module 14 in the moving target detection device shown in FIG. Figure 6 The memory 21 in the moving target detection device shown in the figure stores the moving target determination program, which is then Figure 6 The processor 22 in the shown moving target detection device is implemented when executing the original moving target determination program stored in the memory 21.
[0090] Depend on Figure 1The principle diagram of moving target detection based on the optical flow method is shown. After the representation of the optical flow field corresponding to the current image (merged optical flow matrix) is determined, the position of the moving target can be determined based on the change area of the optical flow field. The moving target detection method that determines the position of the moving target based on the change of the optical flow field can be adapted to the detection of moving targets in infrared images, overcoming the limitation of the existing method of only detecting the highest temperature point in the infrared image to locate the moving target.
[0091] As can be seen from the above, in the moving target detection method provided by the present application, gradient calculation is performed based on the pixels in the first detection window corresponding to the current image and the previous image, and the original optical flow matrix of the current image is determined based on the gradient calculation result. The method for calculating the optical flow is relatively simple and occupies less computing power resources. In addition, the original optical flow matrix is merged using a set merging step size to obtain a stable representation of the optical flow field, so that the moving target positioning performed based on the change area of the optical flow field determined by the merged optical flow matrix has a higher accuracy.
[0092] In some embodiments, in order to speed up the traversal speed of the current image fr2 and the previous image fr1 in S4 and reduce the amount of computational data for moving target detection, the current image fr2 and the previous image fr1 are not source images captured by the image capture device, but thumbnail images corresponding to the original image. Then S2 specifically includes: acquiring the source images captured successively by the image capture device, and then thumbnail processing each source image to obtain the thumbnailed current image fr2 and the previous image fr1 associated with the current image. For example, the corresponding source images are thumbnailed to 1 / 2 to obtain the corresponding current image fr1 and the previous image fr2. In some embodiments, the source image corresponding to the previous image is the previous image adjacent to the source image corresponding to the current image.
[0093] In some embodiments, S42 further includes:
[0094] S421: Acquire a first group of pixels contained in the first detection window in the current image and a second group of pixels contained in the first detection window in the previous image corresponding to each sliding step during the synchronous sliding of the first detection window in the current image and the previous image.
[0095] In this embodiment, the first detection window is used to traverse the current image fr2 and the previous image fr1 at the same time, that is, the first detection window slides synchronously in the current image fr2 and the previous image fr1, that is, the first detection window in the current image fr2 and the first detection window in the previous image fr1 slide at the same time, and the sliding frequency is the same, and for each sliding step, the positions of the first detection window in the current image fr2 and the first detection window in the previous image fr1 in their respective images correspond to the same.
[0096] Acquiring the first group of pixels and the second group of pixels corresponding to each sliding step refers to taking out the pixels in the first detection window in the current image fr2 and the first detection window in the previous image fr1 corresponding to each sliding step, and numbering the taken out pixels according to the pixel coordinates of the pixels in the images to which they belong. The first group of pixels corresponds to the pixels in the second sub-image fr21, and the second group of pixels corresponds to the pixels in the first sub-image fr11.
[0097] In order to more clearly describe S421 and subsequent related steps, the present application takes the first detection window as a 2×2 matrix as an example to illustrate each step, but in other embodiments, the size of the first detection window is not limited to 2×2.
[0098] like Figure 3 As shown, the left window is the first detection window in the previous image fr1 of a certain sliding step, that is, the first sub-image fr11, and the right window is the first detection window in the current image fr2 of the corresponding sliding step on the left, that is, the second sub-image fr21. Among them, the pixels in the first sub-image fr11 are the interlaced positions of the i-th row, i+1-th row and the j-th column, j+1-th column in the previous image fr1, and each pixel in the first group of pixels and the second group of pixels is numbered and identified according to the corresponding position of each pixel in the first group of pixels and the second group of pixels in the image. For example, the first group of pixels includes pixel t1 in the i-th row and j-th column, pixel t3 in the i-th row and j+1-th column, pixel t5 in the i+1-th row and j+1-th column, and pixel t7 in the i+1-th row and j+1-th column in the previous image fr1; the second group of pixels includes pixel t2 in the i-th row and j-th column, pixel t4 in the i-th row and j+1-th column, pixel t6 in the i+1-th row and j+1-th column, and pixel t8 in the i+1-th row and j+1-th column in the current image fr2.
[0099] S422: performing inter-image gradient calculation, inter-row gradient calculation, and inter-column gradient calculation according to the first group of pixels and the second group of pixels, respectively, to determine corresponding time direction gradient, row direction gradient, and column direction gradient, respectively.
[0100] After obtaining the first group of pixels corresponding to the second sub-image fr21 and the second group of pixels corresponding to the first sub-image fr11, inter-image gradient calculation, inter-row gradient calculation and inter-column gradient calculation can be performed according to the corresponding pixels to obtain image gradients corresponding to each sub-image, respectively, and the image gradient includes a time direction gradient g corresponding to the inter-image gradient between the second sub-image fr21 and the first sub-image fr11 i , a row direction gradient g corresponding to the inter-row gradient between the rows of the second sub-image fr21 and the first sub-image fr11 h and a column direction gradient g corresponding to the column-to-column gradient between the columns of the second sub-image fr21 and the first sub-image fr11 w .
[0101] In some embodiments, the specific steps of S422 are further described based on the specific example of the first detection window provided above, which further includes S4221, S4222 and S4223. However, it should be noted that the order of S4221, S4222 and S4223 is not specifically limited in this application, and unless otherwise specified, the order of other steps in this application is not specifically limited.
[0102] S4221: Calculate the average pixel difference between corresponding pixels in the first group of pixels and the second group of pixels to obtain the time direction gradient.
[0103] From the above example description, it can be obtained that the position of pixel t1 in the first group of pixels in the current image fr2 is the same as the position of pixel t2 in the second group of pixels in the previous image fr1, then pixel t1 in the first group of pixels and pixel t2 in the second group of pixels are corresponding pixels. Similarly, pixel t3 in the first group of pixels and pixel t4 in the second group of pixels are corresponding pixels, pixel t5 in the first group of pixels and pixel t6 in the second group of pixels are corresponding pixels, and pixel t7 in the first group of pixels and pixel t8 in the second group of pixels are corresponding pixels. The temporal gradient g i The calculation is performed according to the following equation (17):
[0104] g i =[(t2-t1)+(t4-t3)+(t6-t5)+(t8-t7)] / 4 (17)
[0105] S4222: Calculate the average pixel difference between each pixel in the latter row and each pixel corresponding to the previous row in the first group of pixels and the second group of pixels to obtain the row direction gradient.
[0106] From the above example description, it can be obtained that the pixels t5 and t7 in the first group of pixels and the pixels t6 and t8 in the second group of pixels are all pixels in the i+1th row of the image to which they belong, and the pixels t1 and t3 in the first group of pixels and the pixels t2 and t4 in the second group of pixels are all pixels in the ith row of the image to which they belong. In addition, if pixels t1 and t5 belong to the same column, then the pixel in the previous row corresponding to t5 is t1. Similarly, the pixel in the previous row corresponding to t7 is t3, the pixel in the previous row corresponding to t6 is t2, and the pixel in the previous row corresponding to t8 is t4. The row direction gradient g h The calculation is performed according to the following equation (18):
[0107] g h =[(t5-t1)+(t7-t3)+(t6-t2)+(t8-t4)] / 4 (18)
[0108] S4223: Calculate the average pixel difference between each pixel in the latter column and each pixel corresponding to the previous column in the first group of pixels and the second group of pixels to obtain the column direction gradient.
[0109] From the above example description, it can be obtained that the pixels t3 and t7 in the first group of pixels and the pixels t4 and t8 in the second group of pixels are all pixels in the j+1th column of the image to which they belong, and the pixels t1 and t5 in the first group of pixels and the pixels t2 and t6 in the second group of pixels are all pixels in the jth column of the image to which they belong. In addition, if pixels t1 and t3 belong to the same row, then the pixel in the previous column corresponding to t3 is t1. Similarly, the pixel in the previous column corresponding to t7 is t5, the pixel in the previous column corresponding to t4 is t2, and the pixel in the previous column corresponding to t8 is T6. The row direction gradient g w The calculation is performed according to the following equation (19):
[0110] g w =[(t3-t1)+(t7-t5)+(t4-t2)+(t8-t6)] / 4 (19)
[0111] From the above description of the HS optical flow calculation method, it can be seen that the HS optical flow algorithm needs to perform complex iterative calculations according to equations (15) and (16) to obtain the optical flow vector. Such a calculation method occupies a large amount of computing resources. In this regard, the inventors of the present application proposed a simplified HS optical flow algorithm based on this, that is, when calculating the optical flow vector based on the time direction gradient, the row direction gradient and the column direction gradient, remove (I x *u+I y *v+I t ) in Ix*u+Iy*v, only keep I tAs a parameter, and removing the iteration process, that is, ignoring the first and second terms of equations (15) and (16), thus transforming equations (15) and (16) into the following equations (20) and (21) respectively:
[0112]
[0113]
[0114] I in equations (20) and (21) t This is equivalent to the time directional gradient g described above. i , I x Equivalent to the row direction gradient g described above h , I y Equivalent to the column-wise gradient g described above w .
[0115] Therefore, in some embodiments, the simplified HS optical flow calculation method provided by the present application is used based on the temporal direction gradient g i , the row direction gradient g h And the column direction gradient g w The step of calculating the optical flow vector corresponding to each sliding step and then determining the original optical flow matrix, that is, S43 further includes S431, S432 and S433.
[0116] S431: Calculate according to the time direction gradient, the row direction gradient and the column direction gradient to obtain a first intermediate parameter, wherein the size of the first intermediate parameter is proportional to the time direction gradient and inversely proportional to a second intermediate parameter, wherein the second intermediate parameter is the sum of a preset scaling factor, the square of the row direction gradient and the square of the column direction gradient.
[0117] Specifically, the first intermediate parameter δ can be obtained by the following equation (22):
[0118] δ=g i / (α+g h 2 +g w 2 ) (twenty two)
[0119] Among them, α in the equation is the scaling factor, which is used to fix the subsequently obtained optical flow vector in a suitable interval. This interval is determined according to the actual situation and the empirical value. g in equation (22) h 2 +g w 2 is the second intermediate component.
[0120] S432: Calculate according to the first intermediate parameter and the row direction gradient to obtain a first component of the optical flow vector in the row direction, wherein the magnitude of the first component is proportional to the product of the first intermediate parameter and the row direction gradient.
[0121] In some embodiments, according to the above equation (20), the first component u(i, j) corresponding to each sliding step is obtained, and its calculation equation is shown in the following equation (23):
[0122]
[0123] Obviously, the above equation (23) corresponds to equation (20) obtained by the simplified HS calculation method.
[0124] S433: Perform calculation based on the first intermediate parameter and the column direction gradient to obtain a second component of the optical flow vector in the column direction, wherein the magnitude of the second component is proportional to the product of the first intermediate parameter and the column direction gradient.
[0125] In some embodiments, according to the above equation (21), the second component v(i, j) corresponding to each sliding step is obtained, and its calculation equation is shown in the following equation (24):
[0126]
[0127] Obviously, the above equation (24) corresponds to equation (21) obtained by the simplified HS calculation method.
[0128] Since the optical flow vectors obtained in some embodiments of the present application are based on the simplified HS optical flow algorithm, they are highly sensitive and easily affected by image changes. If they are directly used to subsequently determine the optical flow field change area, large errors will be generated, making the position of the final detected moving target inaccurate. Therefore, it is necessary to merge the original optical flow matrix calculated in S4 to obtain the stable optical flow field representation corresponding to the current image, that is, the merged optical flow matrix obtained in S6.
[0129] In some embodiments, S6 further includes: traversing the original optical flow matrix using a second detection window of a set size, determining a merged optical flow vector corresponding to each sliding step of the second detection window based on the average value of each optical flow vector in the second detection window corresponding to each sliding step of the second detection window, and determining a merged optical flow matrix based on the merged optical flow vector.
[0130] Specifically, before merging the original optical flow matrix, it is necessary to define the merging step size, that is, define a second detection window of a predetermined size. The number of rows of the second detection window is step1, the number of columns is step2, and the second preset window is a step1×step2 matrix. In some embodiments, step1 and step2 can be set to be equal, and in other embodiments, step1 and step2 can also be unequal.
[0131] The average value of each optical flow vector in the second detection window corresponding to each sliding step of the second detection window means that, for each sliding step of the second detection window, each optical flow vector in the corresponding second detection window is added and then the average value is taken to obtain a merged optical flow vector, and the calculated average value is stored in the corresponding position in the new matrix to obtain the merged optical flow matrix.
[0132] If the original optical flow matrix is composed of the above-mentioned first component original matrix U and second component original matrix V, it is necessary to use the second detection window to traverse the first component original matrix U and the second component original matrix V respectively, and then determine the first component merged matrix Us and the second component merged matrix Vs respectively according to the average value of each optical flow vector in the second detection window in the first component original matrix U corresponding to each sliding step of the second detection window and the average value of each optical flow vector in the second detection window in the second component original matrix U. Among them, the number of rows of Us is the number of rows of U divided by step1, the number of columns of Us is the number of columns of U divided by step2, the number of rows of Vs is the number of rows of V divided by step1, and the number of columns of Vs is the number of columns of V divided by step2. Each element in the merged optical flow matrix can be the average value of each original in the original optical flow matrix within each merging step.
[0133] like Figure 1 As shown in the schematic diagram of determining the position of a moving target based on the optical flow field change area, if the entire scene moves, the optical flow vectors of the static objects in the scene will be different, but theoretically their approximate directions and sizes will not differ much; and the dynamic targets will cause great disturbances to the surrounding optical flow vectors due to their own movement and deformation on the image. Therefore, in some embodiments, a simple variance method can be used to determine the position where the optical flow field changes most dramatically, that is, the determination of the optical flow field change area (S81) based on the merged optical flow matrix in S8 further includes: traversing the merged optical flow matrix using a third detection window of a set size, and determining the optical flow field change area based on the variance between the intermediate merged optical flow vector in the third detection window corresponding to each sliding step of the third detection window and each adjacent merged optical flow vector according to the size of the variance.
[0134] Furthermore, determining the optical flow field change area according to the size of the variance in S81 (S811) includes: judging whether the variance is greater than or equal to a preset threshold, and if so, marking the position points corresponding to the intermediate merged optical flow vector in a blank matrix having the same size as the merged optical flow matrix to obtain a marking matrix, and then determining the optical flow field change area according to the area where the marked points in the marking matrix are located.
[0135] Taking the merged optical flow matrix including the first component merged matrix Us and the second component merged matrix Vs, and the third detection frame being a 3×3 matrix as an example, the process of determining the optical flow field change area based on the variance method in S61 is further explained as follows:
[0136] Use the 3×3 third detection window to traverse Us and Vs respectively. Taking the traversal of Us as an example, each time the third detection window is slid, calculate whether the variance of the middle point (i, j) in the third detection window and the 8 vector components around it is greater than a preset threshold threshold. If so, it is considered that the current middle point is likely to be a candidate point for a dynamic target. Then mark the current middle point in a blank matrix tmp of the same size as Us to form a first component marking matrix corresponding to the first component merging matrix. For the traversal of Vs, the corresponding middle point as a candidate point is also marked in a blank matrix tmp of the same size as Vs to form a second component marking matrix corresponding to the second component merging matrix. The area determined by each marking point in the marking matrix is the change area of the optical flow field.
[0137] In some embodiments, the step of determining the position of the moving target in the current image according to the optical flow field change area (S82) in S8 specifically includes S821 and S822.
[0138] S821: Connect the optical flow field change area using an image dilation algorithm.
[0139] After traversing all the points in the merge matrix, the area where the corresponding marked points in the marking matrix are located is very likely to be the area where the dynamic target is located. By filling the blanks in these areas with an image expansion algorithm, the discontinuous areas can basically be connected to obtain a connected optical flow field change area.
[0140] S822: Using a spatial connected domain search algorithm to find the boundary of the connected optical flow field change area, and delineate a corresponding boundary box, and determine the position of the moving target in the current image according to the position of the boundary box.
[0141] The position of the bounding box of the optical flow field change area is the final output representing the position of the moving target. According to the moving target detection algorithm provided by this application, the bounding box representing the moving target position is not necessarily a rectangular box. If the shape of the moving object is more complex, the bounding box drawn by the final marking area is an irregular shape with jagged edges.
[0142] The order of the above-described steps in the motion target detection method provided by the present application is not limited. In order to allow the public to more clearly understand the motion target detection method provided by the present application, a specific embodiment of the motion target detection method provided by the present application is provided below.
[0143] like Figure 4 As shown, the moving target detection method described in this embodiment includes the following steps:
[0144] S01: Image scaling. Obtain the current source image and the previous source image of the current source image successively captured by the image capture device, and perform thumbnail processing on the two source images respectively to shrink the source images to 1 / 2, so as to obtain the current image fr2 and the previous image fr1 of the current image. That is, the size of the current image fr2 is 1 / 2 of the current source image, and the size of the previous image fr1 is 1 / 2 of the previous source image. Before performing S01, it is also necessary to define a cache frame for storing the previous source image. The image capture device here can be an infrared camera or a visible light camera.
[0145] S02: Calculate the original optical flow field. The current image obtained after thumbnail and the previous image are traversed using the 2×2 first detection window at the same time. Each time the second detection window is slid, four adjacent pixels in the image need to be taken out for subsequent gradient calculation. The pixel-by-pixel method Figure 3 As shown, the pixels in the first detection window at the corresponding position in the current image and the previous image are respectively taken out to form 8 pixels, and these 8 pixels are numbered respectively, as shown in FIG. Figure 3 t1, t2, t3, t4, t5, t6, t7 and t8 in the above. Figure 3 A detailed introduction has been made, so I will not repeat it here. Then, the corresponding time direction gradient (inter-image gradient), row direction gradient and column direction gradient are calculated according to the following formula group based on each pixel taken out.
[0146]
[0147] Then, the calculated gradient result is substituted into the following formula group to obtain the corresponding original optical flow vector, and the original optical flow vector is stored in a predefined original optical flow matrix. The original optical flow matrix includes a first component original optical flow matrix U for storing the first component u of the original optical flow vector and a second component original optical flow matrix V for storing the second component v of the original optical flow vector.
[0148]
[0149] S03: Merge the original optical flow field. So this step merges the vectors of the original optical flow field (adds and takes the average) to obtain a stable vector representation. Before merging the original optical flow field, the step1×step2 matrix is defined as the second detection window, that is, the side length of the merged detection window is defined. This step will require traversing the U and V matrices separately. The values under each second detection window of size step1*step2 will be added and averaged, and stored in the pre-defined new Us and Vs matrices, respectively, where the length of Us is the length of U divided by step1, and the width of Us is the width of U divided by Step2. Similarly, the length of Vs is the length of V divided by step1, and the width of Vs is the width of V divided by step2, and step1=step2.
[0150] S04: traverse the optical flow field and determine the degree of optical flow disturbance. This step is to use a simple variance method to determine the position where the optical flow field changes most dramatically. That is, use the 3×3 third detection window to traverse Us and Vs respectively. Each time the third detection window is slid one step, the variance of the middle point (i, j) in the third detection window and the surrounding 8 corresponding components is calculated to determine the degree of optical flow disturbance based on the variance. The larger the variance, the greater the optical flow disturbance.
[0151] S05: Mark the area with large disturbance in the optical flow field. If the variance of the middle point (i, j) and the 8 vector components around it is greater than a threshold, it means that the optical flow disturbance of this point is large. Then the current point is considered to be a candidate point of a dynamic target and needs to be marked in a blank matrix tmp of the same size as Us.
[0152] S06: Draw a bounding box. After traversing all the points in the merged optical flow matrix, the area where the marked points in the marking matrix are located is very likely to be the area where the dynamic target is located. Then, an image expansion algorithm is used to fill the blanks in these areas, and the discontinuous areas can be basically connected to obtain a connected optical flow field change area. Then, a spatial connected domain search algorithm is performed on these areas to find their boundaries and draw the corresponding bounding box. The location of the bounding box is the detection location of the moving target.
[0153] As can be seen from the description of the above parts, the relative motion of the scene and the moving target is cleverly utilized in the moving target detection method provided in each embodiment of the present application. The traditional and simplified HS optical flow method is used for moving target detection, which can effectively reduce the computing resources required by the detection algorithm. Further, by merging the original optical flow field, a more stable optical flow vector can be obtained, which improves the accuracy of the detection and also reduces the amount of calculation of the detection algorithm. In addition, according to the irregularity of the optical flow vector around the moving target, the variance is used to measure the irregularity of the detection area, and the location of the dynamic target is found, so that the moving target detection method provided by the present application is suitable for outdoor scenes with complex environmental information and irregular shapes of moving target objects. Moreover, the moving target detection method provided by the present application uses the reduced image for calculation during the calculation process, which can minimize the amount of calculation while ensuring the accuracy of the detection. Thus, the moving target detection method provided by the present application can be implemented using an FPGA with relatively less computing resources, which can provide real-time dynamic target marking while reducing costs.
[0154] In some embodiments, the present application also provides a moving target detection device, specifically, Figure 5 As shown, it includes an image acquisition module 11, an original optical flow calculation module 12, a merged optical flow calculation module 13 and a moving target position determination module 14. Among them, the image acquisition module 11 is mainly used to acquire the current image and the previous image associated with the current image. The original optical flow calculation module 12 is mainly used to use a first detection window of a set size to traverse the current image and the previous image in order, and to perform gradient calculation according to the first group of pixels contained in the first detection window in the current image and the second group of pixels contained in the first detection window in the previous image corresponding to each sliding step during the sliding process of the first detection window, and to determine the optical flow vector corresponding to each sliding step of the first detection window according to the result of the gradient calculation, and to determine the original optical flow matrix of the current image according to the optical flow vectors corresponding to each sliding step of the first detection window. The merged optical flow calculation module 13 is used to merge the original optical flow matrix according to the original optical flow matrix and the set merging step size to obtain a merged optical flow matrix. The motion module position determination module 14 is mainly used to determine the optical flow field change area according to the combined optical flow matrix, and to determine the position of the moving target in the current image according to the optical flow field change area.
[0155] like Figure 6As shown, in some embodiments, the present application also provides a moving target detection device, which includes a memory 21 and a processor 22. Wherein, the processor 22 executes the steps of the detection method provided in any embodiment of the present application when running the computer program instructions stored in the memory 21. Since the computational complexity of the motion detection method provided in the present application is relatively small, the processor 22 shown can be implemented using an FPGA processor.
[0156] In addition, the present application also provides a computer-readable storage medium, which stores computer program instructions; when the computer program instructions are executed by a processor, the steps of the detection method described in the items provided in any embodiment of the present application are implemented.
[0157] The processor may be a CPU (Central Processing Unit), or an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present invention. The one or more processors included in the moving target detection device may be processors of the same type, such as one or more CPUs; or may be processors of different types, such as one or more CPUs and one or more ASICs or FPGAs.
[0158] The above-mentioned memory may include high-speed RAM (Random Access Memory), and may also include NVM (Non-Volatile Memory), such as at least one disk storage.
[0159] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for detecting a moving target, characterized in that: include: Acquire a current image and a previous image associated with the current image; Using a first detection window to slide through the current image and the previous image in sequence, respectively, performing gradient calculation according to pixels contained in the first detection window in the current image and the previous image corresponding to each sliding step, and determining an original optical flow matrix of the current image according to the gradient calculation result; traversing the original optical flow matrix using a second detection window of a set size, determining a merged optical flow vector corresponding to each sliding step of the second detection window according to an average value of each optical flow vector in the second detection window corresponding to each sliding step of the second detection window, and determining a merged optical flow matrix according to the merged optical flow vector; Determining an optical flow field change region according to the combined optical flow matrix, and determining a position of a moving target in the current image according to the optical flow field change region; The gradient calculation result corresponding to each sliding step includes a time-direction gradient between a pixel in the first detection window in the current image and a corresponding pixel in the first detection window in the previous image, and a row-direction gradient and a column-direction gradient of a pixel in the first detection window in the current image. Determining the original optical flow matrix of the current image according to the gradient calculation result includes: Calculation is performed based on the time direction gradient, the row direction gradient and the column direction gradient corresponding to each sliding step to obtain the first component of the streamer vector in the row direction and the second component in the column direction corresponding to each sliding step to determine the original streamer matrix; wherein the size of the first component is proportional to the product of the first intermediate parameter and the row direction gradient, the size of the second component is proportional to the product of the first intermediate parameter and the column direction gradient, the size of the first intermediate parameter is proportional to the time direction gradient and inversely proportional to the second intermediate parameter, and the second intermediate parameter is the sum of a preset scaling factor, the square of the row direction gradient and the square of the column direction gradient.
2. The detection method according to claim 1, characterized in that: The performing gradient calculation on pixels contained in the first detection window in the current image and the previous image corresponding to each sliding step of the first detection window comprises: Acquire a first group of pixels contained in the first detection window in the current image and a second group of pixels contained in the first detection window in the previous image corresponding to each sliding step during the synchronous sliding of the first detection window in the current image and the previous image; Inter-image gradient calculation, inter-row gradient calculation and inter-column gradient calculation are performed respectively according to the first group of pixels and the second group of pixels to respectively determine the corresponding time direction gradient, the row direction gradient and the column direction gradient.
3. The detection method according to claim 2, characterized in that: The first detection window is a 2×2 matrix, and the inter-image gradient calculation, the inter-row gradient calculation, and the inter-column gradient calculation are performed according to the first group of pixels and the second group of pixels, respectively, to determine the corresponding time direction gradient, the row direction gradient, and the column direction gradient, respectively, including: Calculating an average pixel difference between corresponding pixels in the first group of pixels and the second group of pixels to obtain the temporal directional gradient; Calculating an average pixel difference between each pixel in a subsequent row and each pixel corresponding to a previous row in the first group of pixels and the second group of pixels to obtain the row direction gradient; The average pixel difference between each pixel in the latter column and each pixel corresponding to the former column in the first group of pixels and the second group of pixels is calculated to obtain the column direction gradient.
4. The detection method according to claim 1, characterized in that: The calculating according to the time direction gradient, the row direction gradient and the column direction gradient corresponding to each sliding step to obtain the first component in the row direction and the second component in the column direction of the streamer vector corresponding to each sliding step includes: Calculating according to the time direction gradient, the row direction gradient, and the column direction gradient to obtain the first intermediate parameter, wherein the magnitude of the first intermediate parameter is proportional to the time direction gradient and inversely proportional to a second intermediate parameter, wherein the second intermediate parameter is the sum of a preset scaling factor, the square of the row direction gradient, and the square of the column direction gradient; Calculating according to the first intermediate parameter and the row direction gradient to obtain a first component of the optical flow vector in the row direction, wherein the magnitude of the first component is proportional to the product of the first intermediate parameter and the row direction gradient; A calculation is performed based on the first intermediate parameter and the column-direction gradient to obtain a second component of the optical flow vector in the column direction, wherein the magnitude of the second component is proportional to the product of the first intermediate parameter and the column-direction gradient.
5. The detection method according to claim 1, characterized in that: The determining the optical flow field change area according to the combined optical flow matrix includes: The merged optical flow matrix is traversed using a third detection window of a set size, the variance between the intermediate merged optical flow vector in the third detection window corresponding to each sliding step of the third detection window and each adjacent merged optical flow vector is calculated, and the optical flow field change area is determined according to the size of the variance.
6. The detection method according to claim 5, characterized in that: The determining of the optical flow field change area according to the size of the variance includes: Determine whether the variance is greater than or equal to a preset threshold, and if so, mark the position points corresponding to the intermediate merged optical flow vector in a blank matrix having the same size as the merged optical flow matrix to obtain a marking matrix; The optical flow field change region is determined according to the region where the marking points in the marking matrix are located.
7. The detection method according to claim 6, characterized in that: The determining the position of the moving target in the current image according to the optical flow field change area includes: Using an image expansion algorithm to connect the optical flow field change area; The spatial connected domain search algorithm is used to find the boundary of the connected optical flow field change area, and a corresponding boundary box is drawn, and the position of the moving target in the current image is determined according to the position of the boundary box.
8. A moving target detection device, characterized in that: including memory and processor; When the processor runs the computer program instructions stored in the memory, the processor performs the steps of the detection method described in any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that: The computer readable storage medium stores computer program instructions; When the computer program instructions are executed by a processor, the steps of the detection method described in any one of claims 1 to 7 are implemented.
