Intelligent pipe gallery moving target detection method and detection device based on optical flow algorithm
By removing the optical flow scattered points and updating the tracking information in the optical flow algorithm, combining the optical flow direction and motion direction histogram, the problems of light changes and target adhesion in the integrated pipeline corridor are solved, and the accuracy and recognition rate of motion target detection are improved .
Patent Information
- Application Number
- CN202110778004.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-09
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2041-07-09
AI Technical Summary
In the integrated pipeline corridor, due to uneven light distribution and complex light sources, directly using optical flow algorithms for motion target detection will cause false detection and target adhesion problems, making it difficult to effectively segment and identify the moving targets.
By acquiring image frames and calculating optical flow images, the optical flow scatter points and the communication domain with an area smaller than the preset threshold are removed, the tracking target information is updated, and the optical flow direction histogram and motion direction histogram are combined to remove low confidence tracking points to improve Target segmentation and tracking accuracy.
It effectively improves the robustness of the optical flow algorithm, reduces the target adhesion rate, improves the accuracy and recognition rate of motion target detection, and is suitable for various smart pipeline scenarios.
Smart Images

Figure CN113592904B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image and video processing, and in particular relates to a method and a device for detecting moving targets in a smart pipe gallery based on an optical flow algorithm. Background Art
[0002] The integrated pipe gallery, also known as the "common trench", is an underground urban pipeline integrated corridor. It is an urban municipal public facility that integrates various pipelines such as electricity, communications, gas, heating, water supply and drainage. It implements unified planning, unified design, unified construction and management. It is an important infrastructure and "lifeline" to ensure the operation of the city. The smart pipe gallery uses comprehensive system integration technologies such as the Internet of Things, modern sensing technology, cloud computing, computer communication technology, virtual reality, and artificial intelligence to conduct real-time monitoring, operation management, and safety warning of pipelines, environments, equipment, and operations in the integrated pipe gallery. And moving target detection is one of the basic functions of the smart pipe gallery.
[0003] Motion target detection is one of the important research contents in the field of video processing. Depending on whether the camera is moving, motion target detection can be divided into static background motion target detection and dynamic background motion target detection. At present, the main methods for static background motion target detection include background difference method, frame difference method, optical flow method, etc. The background difference method uses the input frame image to make a difference with the background image to obtain the foreground target information. The algorithm has low complexity but is sensitive to lighting. The frame difference method uses the input frame image to make a difference with the previous frame image to obtain the motion target information. This method runs fast and is not very sensitive to light, but it is difficult to extract complete target information. The optical flow method uses the changes in pixels in the time domain in the image sequence and the correlation between adjacent frames to calculate the correspondence between two frames of images to obtain the motion target information. This method can avoid incomplete segmentation of targets and has been increasingly widely used.
[0004] However, due to the uneven distribution of light in the integrated pipeline corridor and the relatively complex light sources (such as construction workers' headlights, etc.), directly using the optical flow algorithm for moving target detection will result in a large number of false detections due to lighting changes, and when the moving target is close, the target adhesion problem will occur. Summary of the invention
[0005] In view of this, the present invention provides a method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm, comprising the following steps:
[0006] S1, obtaining the Kth frame image and the Kith frame image, and calculating the optical flow image of the Kth frame image according to the obtained images; wherein the value range of i is 1 to 4, and the optical flow image includes the optical flow value and the optical flow direction;
[0007] S2, obtaining an optical flow value mask image according to the optical flow image, and removing optical flow scatter points and connected domains whose areas are smaller than a preset area threshold in the optical flow value mask image to obtain a motion region mask image;
[0008] S3, updating the tracking point information of the tracked target in the motion region mask image according to the optical flow information in the optical flow image;
[0009] S4, calculating a new connected domain of the tracked target according to the updated tracking point information of the tracked target, and obtaining a new mask image region of the target;
[0010] S5, adding or deleting tracking point information in the new mask image area of the target;
[0011] S6, completing the tracking information update of all tracked targets, taking the union of the mask images of all targets to obtain the mask image of the tracked area, taking the inversion of the mask image of the tracked area and taking the intersection with the mask image of the moving target area to obtain the mask image of the untracked area;
[0012] S7, adding a new target to be tracked in the mask image of the untracked area and tracking it;
[0013] S8, output the tracked target information and the new target information.
[0014] Preferably, in the above step S2, the specific process of obtaining the optical flow value mask image according to the optical flow image, and removing the optical flow scatter points and the connected domains whose area is less than the preset area threshold in the optical flow value mask image to obtain the motion area mask image is:
[0015] S21, binarizing the optical flow image to obtain a mask image of the moving target;
[0016] S22, based on the optical flow direction histogram, removing the optical flow scatter points in the mask image of the moving target;
[0017] S23, calculating the connected domains with a pixel value of 255, and counting the area size of each connected domain, deleting the connected domains with an area smaller than a preset area threshold, and obtaining a motion region mask image.
[0018] Preferably, in the above step S21, the specific process of binarizing the optical flow image to obtain the mask image of the moving target is:
[0019] S211, preset optical flow value threshold T v ;
[0020] S212, determine whether the optical flow value V(x, y) of the optical flow image at the coordinate (x, y) is less than the optical flow value threshold T v ; If V(x,y) is less than T v, then the value M of the optical flow value mask image at the coordinate (x, y) o (x, y) is set to 0; otherwise, the value M of the optical flow value mask image at the coordinate (x, y) is o (x,y) is set to 255.
[0021] Preferably, in the above step S22, the specific process of removing the optical flow scatter points in the mask image of the moving target based on the optical flow direction histogram is:
[0022] S221, preset an optical flow direction histogram threshold T;
[0023] S222, judging whether the number of optical flow points in each optical flow direction in the optical flow value mask image is less than the optical flow direction histogram threshold T according to the optical flow direction histogram; if the number of optical flow points in a certain optical flow direction is less than the optical flow direction histogram threshold T, remove the optical flow point information of the optical flow direction.
[0024] Preferably, in the above step S3, the specific process of updating the tracking point information of the tracked target in the moving area mask image according to the optical flow information in the optical flow image is:
[0025] S31, based on all tracking point information of the target and the optical flow information of the current frame image, calculate and obtain a target motion direction histogram and a target optical flow direction histogram;
[0026] S32, according to the target motion direction histogram and the target optical flow direction histogram, the optical flow direction of each tracking point is counted to obtain the main direction of the optical flow, and the overall motion direction of each tracking point is counted to obtain the main motion direction of the target;
[0027] S33, setting the tracking points whose optical flow directions are inconsistent with the main direction of the optical flow or whose motion directions are inconsistent with the main motion direction of the target as low-confidence tracking points. If a tracking point is a low-confidence tracking point for N consecutive frames, remove the tracking point.
[0028] Preferably, in the above step S4, the specific process of calculating the new connected domain of the tracked target according to the updated tracking point information of the tracked target to obtain the new mask image area of the target is:
[0029] S41, generating a target tracking area mask image M based on the effective tracking point information after removing the low confidence tracking point targets from the mask image of the effective target t ;
[0030] S42, based on the target optical flow direction, calculate the target tracking area mask image M t The main direction of the optical flow between the center and the target is O f Consistent region mask image M a , and let the region mask image Ma and the motion region mask image M o1 Take the intersection to get the target possible area mask image M p ;
[0031]
[0032] M p =M a ∩M o1
[0033] Where t represents the direction threshold preset by the user, and F(x,y) represents the direction of the optical flow at the coordinate (x,y);
[0034] S43, using the target tracking area mask image M t A point on the image is a seed point, and a mask image M is formed in the target possible area. p Find the connected domain and get the new mask image area M of the target n .
[0035] Preferably, in the above step S5, the specific process of adding or deleting tracking point information in the target new mask image area is:
[0036] S51, traverse all tracking points of the target, assuming that the coordinates of the tracking point are (x t ,y t ), if M n (x t ,y t ) is 0, then the point is marked as a hidden tracking point; if the tracking point is a hidden tracking point for N consecutive frames, then the tracking point is deleted;
[0037] S52: the target tracking area mask image M t Negate and then compare with the target new mask image area M n And, we get the target untracked area mask image M nt ;
[0038]
[0039] S53, mask image M in the target untracked area nt In the connected domain of , evenly select tracking points and add them to the target tracking point set.
[0040] Preferably, in the above step S7, the specific process of adding a new target to be tracked in the untracked area mask image and tracking it is:
[0041] S71, mask image M of the untracked area newPerform morphological processing and calculate the connected domain, remove the targets whose connected area is smaller than the preset area threshold, and obtain a new untracked area mask image M new1 ;
[0042] S72, calculating a new untracked area mask image M new1 Connected domains of , and assign a new target ID to each connected domain;
[0043] S73, traverse each new target, evenly select tracking points on the target mask image and track them.
[0044] Preferably, the specific process of outputting the tracked target information and the new target information is:
[0045] Traverse all tracking targets, count target information based on tracking information, and output target coordinates and ID information to obtain the moving target detection result of the frame image.
[0046] Based on the above-mentioned purpose, the present invention also provides a smart tunnel motion target detection device based on optical flow algorithm, including a memory and a processor, and the processor is configured to execute the above-mentioned smart tunnel motion target detection method based on optical flow algorithm based on instructions stored in the memory.
[0047] Compared with the prior art, the intelligent tunnel moving target detection method based on the optical flow algorithm of the present invention effectively utilizes the direction and size information of the optical flow to remove optical flow scatter points and delete the connected domains whose area is less than the preset area threshold, and uses the optical flow to track the target; combined with the target tracking information, it can effectively segment different targets, effectively improve the target detection rate, and improve the recognition rate of adhesion targets.
[0048] The present invention can improve the robustness of the optical flow algorithm to illumination and shadow by setting a reasonable binarization threshold and removing optical flow scatter points; by removing optical flow scatter points and target tracking information, the target adhesion rate can be reduced and the moving target detection rate can be improved. The intelligent pipe gallery moving target detection method based on the optical flow algorithm provided by the present invention can be used in various moving target detection projects in intelligent pipe gallery scenes. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to make the purpose, technical solution and beneficial effects of the present invention clearer, the present invention provides the following drawings for illustration:
[0050] Figure 1 This is a flow chart of a method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to Embodiment 1 of the present invention;
[0051] Figure 2 This is a flow chart of a method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to Embodiment 2 of the present invention;
[0052] Figure 3 Two frames of images are input to the method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to an embodiment of the present invention, wherein: Figure 3 (a) is the Ki-th frame image, Figure 3 (b) is the Kth frame image;
[0053] Figure 4 This is an image of the method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to an embodiment of the present invention. Figure 4 (a) is the optical flow image, Figure 4 (b) is the optical flow value mask image;
[0054] Figure 5 This is an image of the method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to an embodiment of the present invention. Figure 5 (a) is the optical flow direction histogram, Figure 5 (b) is the optical flow mask image after removing the optical flow scatter points;
[0055] Figure 6 This is an image of the method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to an embodiment of the present invention. Figure 6 (a) is the effective target mask image, Figure 6 (b) is the target motion direction histogram and the target optical flow direction histogram;
[0056] Figure 7 This is an image of the method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to an embodiment of the present invention. Figure 7 (a) is the target tracking point image, Figure 7 (b) is the target tracking point mask image;
[0057] Figure 8 This is an image of the method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to an embodiment of the present invention. Figure 8 (a) is the target mask image, Figure 8 (b) is the effective tracking point mask image;
[0058] Fig. 9 This is an image of the method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to an embodiment of the present invention. Fig. 9 (a) is the target tracking information display diagram. Fig. 9 (b) is the target accurate mask image;
[0059] Fig.10 This is an image of the method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to an embodiment of the present invention. Fig.10 (a) is the target’s valid tracking point, low confidence tracking point and invalid tracking point image. Fig.10 (b) is the image of the area where the target is not tracked;
[0060] Fig.11 This is an image of the method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to an embodiment of the present invention. Fig.11 (a) is the image after morphological processing of the target untracked area. Fig.11 (b) is the new tracking point map of the target, where each bright spot is a tracking point;
[0061] Fig.12 This is an image of the method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to an embodiment of the present invention. Fig.12 (a) is the target mask after removing the tracked target. Fig.12 (b) is the connected domain image of the new target;
[0062] Fig.13 This is a schematic diagram of the motion target detection results of the smart tunnel motion target detection method based on the optical flow algorithm in an embodiment of the present invention. Each rectangular box in the figure is a target, and the number in the upper left corner of the box is the ID of the target. DETAILED DESCRIPTION
[0063] In order to make the purpose, technical solutions and advantages of the embodiments of the present application more clearly understood, the spirit of the contents disclosed in the present application will be clearly explained with the accompanying drawings and detailed descriptions below. After understanding the embodiments of the contents of the present application, any technician in the relevant technical field can change and modify them according to the techniques taught by the contents of the present application without departing from the spirit and scope of the contents of the present application.
[0064] The exemplary embodiments and descriptions of the present application are used to explain the present application, but are not intended to limit the present application. In addition, elements / components with the same or similar reference numerals used in the drawings and embodiments are used to represent the same or similar parts.
[0065] The terms “first”, “second”, etc. used in this document do not particularly refer to an order or sequence, nor are they used to limit this application. They are only used to distinguish elements or operations described with the same technical terms.
[0066] The directional terms used in this document, such as up, down, left, right, front or back, etc., are only used to refer to the directions of the drawings. Therefore, the directional terms used are used to illustrate and not to limit the present invention.
[0067] The words “include,” “including,” “have,” “contain,” etc. used in this document are open-ended terms, meaning including but not limited to.
[0068] As used herein, "and / or" includes any or all combinations of the items described.
[0069] As used herein, “plurality” includes “two” and “more than two”; as used herein, “plurality groups” includes “two groups” and “more than two groups”.
[0070] The terms "substantially" and "approximately" used herein are used to modify any quantity or error that may vary slightly, but these slight changes or errors do not change their essence. Generally speaking, the range of slight changes or errors modified by such terms may be 20% in some embodiments, 10% in some embodiments, 5% in some embodiments, or other values. Those skilled in the art should understand that the aforementioned values can be adjusted according to actual needs and are not limited thereto.
[0071] Certain terms used to describe the present application are discussed below or elsewhere in this specification to provide additional guidance to those skilled in the art regarding the description of the present application.
[0072] Figure 1 This is a flow chart of a method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to Embodiment 1 of the present invention. The method comprises the following steps:
[0073] S1. Acquire the Kth frame image and the Kith frame image, and calculate the optical flow image of the Kth frame image based on the acquired images.
[0074] The value range of i is 1 to 4 and the value of K is greater than the value of i. The optical flow image includes the optical flow value and the optical flow direction.
[0075] S2. Obtain an optical flow value mask image according to the optical flow image, and remove the optical flow scatter points and the connected domains whose area is less than the preset area threshold in the optical flow value mask image to obtain a motion region mask image M. o1 , the specific process is:
[0076] S21, binarize the optical flow image to obtain an optical flow value mask image, that is, a mask image M of the moving target o .
[0077] Specifically, the optical flow image of the Kth frame image is binarized to obtain an optical flow value mask image.
[0078] Among them, the specific process of binarization of the optical flow image is:
[0079] S211, preset optical flow value threshold T v ;
[0080] S212: Determine whether the optical flow value V(x, y) of the optical flow image at the coordinate (x, y) is less than the optical flow value threshold T v ; If V(x,y) is less than T v, then the value M of the optical flow value mask image at the coordinate (x, y) o (x, y) is set to 0; otherwise, the value M of the optical flow value mask image at the coordinate (x, y) is o (x, y) is set to 255, which is the value M of the optical flow value mask image at the coordinate (x, y) o (x,y) is:
[0081]
[0082] S22, based on the optical flow direction histogram, remove the mask image M of the moving target o The optical flow scatter points in the image are set to 0, and the specific process is:
[0083] S221, preset an optical flow direction histogram threshold T;
[0084] S222. Determine whether the number of optical flow points in each optical flow direction in the optical flow value mask image is less than the optical flow direction histogram threshold T according to the optical flow direction histogram; if the number of optical flow points in a certain optical flow direction is less than the optical flow direction histogram threshold T, remove the optical flow point information in the optical flow direction, thereby effectively removing the optical flow scatter points and effectively separating the adhered targets.
[0085] Specifically, the optical flow scatter points are processed using the following optical flow scatter point removal formula.
[0086]
[0087] Where M(x,y) represents the value of the optical flow mask image at the coordinate (x,y) after removing the optical flow scatter points; I = F(x,y), F(x,y) represents the direction of the optical flow at the coordinate (x,y); H(I) represents the value of the optical flow direction histogram at direction I.
[0088] S23, calculate the connected domains with a pixel value of 255, and count the area size of each connected domain, delete the connected domains with an area smaller than a preset area threshold, and obtain a mask image of a valid target, that is, a motion area mask image M o1 .
[0089] The connected domains whose area is smaller than a preset area threshold in the optical flow mask image after removing the optical flow scatter points are deleted to obtain a mask image of a valid target.
[0090] The mask image of a valid target is a mask image containing multiple targets. Each connected region is a candidate target.
[0091] It should be noted that the deletion of the connected domain whose area is smaller than the preset area threshold is achieved by setting all pixels of the connected domain to 0.
[0092] S3, according to the optical flow information in the optical flow image obtained in step S1, updating the tracking point information of the tracked target in the motion area mask image, the specific process is as follows:
[0093] S31. Based on all tracking point information of the target and the optical flow information of the current frame image, a target motion direction histogram and a target optical flow direction histogram are calculated.
[0094] S32, according to the target motion direction histogram and the target optical flow direction histogram, the optical flow direction of each tracking point is counted to obtain the main direction of the optical flow. f , the overall motion direction of each tracking point is counted to obtain the main motion direction of the target O m .
[0095] S33, the optical flow direction and the main direction of the optical flow O f Inconsistent tracking point or movement direction with the target main movement direction O m Inconsistent tracking points are set as low-confidence tracking points. If a tracking point is a low-confidence tracking point for N consecutive frames, the tracking point is removed.
[0096] S4. According to the updated tracking point information of the tracked target, a new connected domain of the tracked target is calculated to obtain a new mask image region of the target. The specific process is as follows:
[0097] S41, based on the effective tracking point information after removing the low-confidence tracking point targets from the effective target mask image, generate a target tracking area mask image M t .
[0098] S42, based on the target optical flow direction, calculate the target tracking area mask image M t The main direction of the optical flow between the center and the target is O f Consistent region mask image M a , and let the region mask image M a and the motion region mask image M o1 Take the intersection to get the target possible area mask image M p .
[0099]
[0100] M p =M a ∩M o1 ,
[0101] Where t represents the direction threshold preset by the user.
[0102] S43, using the target tracking area mask image M t A point on the image is a seed point, and a mask image M is formed in the target possible area. pFind the connected domain and get the new mask image area M of the target n .
[0103] S5. In the target new mask image area M n Add and delete tracking point information. The specific process is as follows:
[0104] S51, traverse all tracking points of the target, assuming that the coordinates of the tracking point are (x t ,y t ), if M n (x t ,y t ) is 0, the point is marked as a hidden tracking point; if the tracking point is a hidden tracking point for N consecutive frames, the tracking point is deleted.
[0105] S52: mask image M of target tracking area t Negate and then compare with the target new mask image area M n And, we get the target untracked area mask image M nt .
[0106]
[0107] S53: mask image M in the target untracked area nt In the connected domain of , evenly select tracking points and add them to the target tracking point set.
[0108] S6, repeat steps S3 to S5 to complete the tracking information update of all tracked targets, and take the union of the mask images of all targets to obtain the mask image M of the tracked area at , M at Negate and move the target area mask image M o1 Take the intersection and get the untracked area mask image M new .
[0109] S7, adding a new target to be tracked in the untracked area mask image and tracking it, the specific process is as follows:
[0110] S71: mask image M of the untracked area new Perform morphological processing and calculate the connected domain. Use the method in step S23 to remove targets with too small connected domain area to obtain a new untracked region mask image M. new1 .
[0111] S72, calculate a new untracked area mask image M new1 and assigns a new target ID to each connected domain.
[0112] S73, traverse each new target, evenly select tracking points on the target mask image and track it.
[0113] S8. Output the tracked target information and the new target information.
[0114] Traverse all tracking targets, count target information based on tracking information, and output target coordinates and ID information to obtain the moving target detection result of the frame image.
[0115] The following uses Figure 2 The flowchart of the method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to Embodiment 2 of the present invention is shown, and Figure 3 to Figure 13 The image specifically illustrates the process of the smart tunnel moving target detection method based on optical flow algorithm provided in this application.
[0116] An image is acquired and optical flow information is calculated, wherein the optical flow information includes an optical flow value and an optical flow direction.
[0117] Remove optical flow scatter points according to the optical flow direction.
[0118] Remove objects whose connected domain area is smaller than the preset area threshold.
[0119] Determine whether the current frame image is the first frame image. If so, obtain each connected area and mark it as a new target for tracking, and output the tracked target; otherwise, update the tracking point information of the tracked target according to the optical flow information.
[0120] Perform consistency verification on tracking points.
[0121] Eliminate inconsistent tracking points and generate a valid tracking mask map.
[0122] According to the direction of optical flow, the target connected domain is calculated and the untracked area is added to the tracking point.
[0123] Calculate the tracking information of the tracked target based on the tracking information.
[0124] Subtract all valid tracking mask maps from the optical flow value mask map to generate the untracked area.
[0125] Finally enter all tracking targets.
[0126] Get Figure 3 The K-1th frame image shown in (a) and Figure 3 The K-th frame image shown in (b) is calculated using the pyramid LK optical flow algorithm as follows Figure 3 (a) is the optical flow image of the Kth frame.
[0127] For example Figure 4 The optical flow image of the Kth frame shown in (a) is binarized to obtain Figure 4 (b) The optical flow value mask image shown.
[0128] according to Figure 5 The optical flow direction histogram shown in (a) is removed. Figure 4 The optical flow scatter points in the optical flow value mask image shown in (b) are obtained as follows Figure 5 (b) shows the optical flow mask image after removing the optical flow scatter points.
[0129] Delete as Figure 5 (b) shows the connected domains in the optical flow mask image after removing the optical flow scatter points, where the connected domain area is smaller than the preset area threshold. Figure 6 (a) shows the effective object mask image.
[0130] According to all the tracking point information of the target and the optical flow information of the current frame image, we can get Figure 6 (b) shows the target motion direction histogram and target optical flow direction histogram.
[0131] According to Figure 6 (b) shows the target motion direction histogram and the target optical flow direction histogram. The coordinates of the unhidden tracking points are plotted as follows: Figure 7 (a) shows the target tracking point image.
[0132] For example Figure 7 The target tracking point image shown in (a) is expanded to obtain Figure 7 (b) The target tracking point mask image shown.
[0133] The optical flow direction based on the target is as follows Figure 6 Based on the effective target mask image shown in (a), the optical flow points in a specific direction are removed to obtain Figure 8 (a) shows the target mask image.
[0134] like Figure 7 (b) The target tracking point mask image and Figure 8 The target mask image shown in (a) is ANDed to obtain Figure 8 (b) The valid tracking point mask image shown.
[0135] like Figure 7 The target bounding rectangle in the target tracking point mask image shown in (b) is loaded into Figure 8 On the target mask image shown in (a), the gray area in the white area is the central area of the target circumscribed rectangle, and the following is obtained: Fig. 9 (a) shows the target tracking information display diagram.
[0136] Use as Fig. 9 The target tracking information shown in (a) shows that the gray area in the white area is used as the seed area, and the seed filling method is used to obtain the following Fig. 9(b) The target accurate mask image shown.
[0137] like Fig. 9 The target accurate mask image shown in (b) is different from Figure 7 The target tracking point mask image shown in (b) is obtained by operation as follows Fig.10 (a) The valid tracking points, low confidence tracking points and invalid tracking points of the target shown in the figure, where the left side of the white area (i.e. Figure 7 (b) There is Figure 8 The area without (a) is the area where the low-confidence tracking points are located, and the outer area of the white area (i.e., the area without N consecutive frames) is the area where the invalid tracking points are located.
[0138] like Fig. 9 (b) shows the target accurate mask image and Figure 8 The effective tracking point mask image shown in (b) is XORed to obtain Fig.10 (b) shows the area where the target is not tracked.
[0139] For example Fig.10 The area where the target is not tracked in the image shown in (b) is morphologically processed to obtain the following Fig.11 (a) is the image of the untracked target area after morphological processing.
[0140] like Fig.11 The target is tracked by adding tracking points to the image of the target untracked area shown in (a) after morphological processing. Fig.11 (b) shows the new tracking point map of the target.
[0141] like Fig. 9 (b) shows the target accurate mask image and Figure 6 The effective target mask image shown in (a) is XORed to obtain Fig.12 (a) shows the target mask after removing the tracked target.
[0142] Fig.12 (b) shows the connected domain of the new object.
[0143] like Fig.13 As shown in the figure, each box represents a moving target, and the number in the upper left corner of the target box is the target ID.
[0144] The method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm provided in the embodiment of the present application can improve the robustness of the optical flow algorithm to illumination and shadows by setting a reasonable binarization threshold and removing optical flow scatter points; by removing optical flow scatter points and target tracking information, the target adhesion rate can be reduced and the detection rate of moving targets can be improved. The method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm provided in the present application can be used in moving target detection projects in various smart pipe gallery scenarios.
[0145] In an exemplary embodiment, the embodiment of the present application also provides a smart tunnel motion target detection device based on an optical flow algorithm, which includes a memory and a processor coupled to the memory, and the processor is configured to execute the smart tunnel motion target detection method based on the optical flow algorithm in any embodiment of the present application based on instructions stored in the memory.
[0146] The memory may be a system memory or a fixed non-volatile storage medium, etc. The system memory may store an operating system, an application program, a boot loader, a database, and other programs, etc.
[0147] In an exemplary embodiment, the embodiment of the present application also provides a computer storage medium, which is a computer-readable storage medium, for example, a memory including a computer program. The above computer program can be executed by a processor to complete the smart tunnel moving target detection method based on the optical flow algorithm in any embodiment of the present application.
[0148] The above description is only an illustrative specific implementation manner of the present application. Without departing from the concept and principle of the present application, any equivalent changes and modifications made by any technician in the field should fall within the scope of protection of the present application.
Claims
1. A method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm, characterized in that: The method comprises the following steps: S1, obtaining the Kth frame image and the Kith frame image, and calculating the optical flow image of the Kth frame image according to the obtained image; wherein the value range of i is 1 to 4 and the value of K is greater than the value of i, and the optical flow image includes the optical flow value and the optical flow direction; S2, obtaining an optical flow value mask image according to the optical flow image, and removing optical flow scatter points and connected domains whose areas are smaller than a preset area threshold in the optical flow value mask image to obtain a motion region mask image; S3, updating the tracking point information of the tracked target in the motion region mask image according to the optical flow information in the optical flow image; S4, calculating a new connected domain of the tracked target according to the updated tracking point information of the tracked target, and obtaining a new mask image region of the target; S5, adding or deleting tracking point information in the new mask image area of the target; S6, completing the tracking information update of all tracked targets, taking the union of the mask images of all targets to obtain the mask image of the tracked area, taking the inversion of the mask image of the tracked area and taking the intersection with the mask image of the moving target area to obtain the mask image of the untracked area; S7, adding a new target to be tracked in the mask image of the untracked area and tracking it; S8, output the tracked target information and the new target information.
2. According to the method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to claim 1, it is characterized in that: In the above step S2, the specific process of obtaining the optical flow value mask image according to the optical flow image, and removing the optical flow scatter points and the connected domains whose area is less than the preset area threshold in the optical flow value mask image to obtain the motion area mask image is: S21, binarizing the optical flow image to obtain a mask image of the moving target; S22, based on the optical flow direction histogram, removing the optical flow scatter points in the mask image of the moving target; S23, calculating the connected domains with a pixel value of 255, and counting the area size of each connected domain, deleting the connected domains with an area smaller than a preset area threshold, and obtaining a motion region mask image.
3. According to the method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to claim 2, it is characterized in that: In the above step S21, the specific process of binarizing the optical flow image to obtain the mask image of the moving target is: S211, preset optical flow value threshold T v ; S212, determine whether the optical flow value V(x, y) of the optical flow image at the coordinate (x, y) is less than the optical flow value threshold T v ; If V(x,y) is less than T v , then the value M of the optical flow value mask image at the coordinate (x, y) o (x, y) is set to 0; otherwise, the value M of the optical flow value mask image at the coordinate (x, y) is o (x,y) is set to 255.
4. According to the method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to claim 2, it is characterized in that: In the above step S22, the specific process of removing the optical flow scatter points in the mask image of the moving target based on the optical flow direction histogram is: S221, preset an optical flow direction histogram threshold T; S222, judging whether the number of optical flow points in each optical flow direction in the optical flow value mask image is less than the optical flow direction histogram threshold T according to the optical flow direction histogram; if the number of optical flow points in a certain optical flow direction is less than the optical flow direction histogram threshold T, remove the optical flow point information of the optical flow direction.
5. According to the method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to claim 1, it is characterized in that: In the above step S3, the specific process of updating the tracking point information of the tracked target in the moving area mask image according to the optical flow information in the optical flow image is as follows: S31, based on all tracking point information of the target and the optical flow information of the current frame image, calculate and obtain a target motion direction histogram and a target optical flow direction histogram; S32, according to the target motion direction histogram and the target optical flow direction histogram, the optical flow direction of each tracking point is counted to obtain the main direction of the optical flow, and the overall motion direction of each tracking point is counted to obtain the main motion direction of the target; S33, setting the tracking points whose optical flow directions are inconsistent with the main direction of the optical flow or whose motion directions are inconsistent with the main motion direction of the target as low-confidence tracking points. If a tracking point is a low-confidence tracking point for N consecutive frames, remove the tracking point.
6. The method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to claim 1 is characterized in that: In the above step S4, the specific process of calculating the new connected domain of the tracked target based on the updated tracking point information of the tracked target and obtaining the new mask image area of the target is: S41, generating a target tracking area mask image M based on the effective tracking point information after removing the low confidence tracking point targets from the mask image of the effective target t ; S42, based on the target optical flow direction, calculate the target tracking area mask image M t The main direction of the optical flow between the center and the target is O f Consistent region mask image M a , and let the region mask image M a and the motion region mask image M o1 Take the intersection to get the target possible area mask image M p ; M p =M a ∩M o1 Where t represents the direction threshold preset by the user, and F(x,y) represents the direction of the optical flow at the coordinate (x,y); S43, using the target tracking area mask image M t A point on the image is a seed point, and a mask image M is formed in the target possible area. p Find the connected domain and get the new mask image area M of the target n .
7. The method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to claim 6 is characterized in that: In the above step S5, the specific process of adding and deleting tracking point information in the target new mask image area is: S51, traverse all tracking points of the target, assuming that the coordinates of the tracking point are (x t ,y t ), if M n (x t ,y t ) is 0, the point is marked as a hidden tracking point; If the tracking point is hidden for N consecutive frames, delete the tracking point; S52: the target tracking area mask image M t Negate and then compare with the target new mask image area M n And, we get the target untracked area mask image M nt ; S53, mask image M in the target untracked area nt In the connected domain of , evenly select tracking points and add them to the target tracking point set.
8. The method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to claim 1 is characterized in that: In the above step S7, the specific process of adding a new target to be tracked in the untracked area mask image and tracking it is as follows: S71, mask image M of the untracked area new Perform morphological processing and calculate the connected domain, remove the targets whose connected area is smaller than the preset area threshold, and obtain a new untracked area mask image M new1 ; S72, calculating a new untracked area mask image M new1 Connected domains of , and assign a new target ID to each connected domain; S73, traverse each new target, evenly select tracking points on the target mask image and track them.
9. The method for detecting moving targets in a smart pipe gallery based on an optical flow algorithm according to claim 8 is characterized in that: The specific process of outputting the tracked target information and the new target information is as follows: Traverse all tracking targets, count target information based on tracking information, and output target coordinates and ID information to obtain the moving target detection result of the frame image.
10. A smart pipe gallery moving target detection device based on optical flow algorithm, characterized in that: It includes a memory and a processor, and the processor is configured to execute the intelligent pipeline corridor moving target detection method based on the optical flow algorithm as described in any one of claims 1 to 9 based on the instructions stored in the memory.
Citation Information
Patent Citations
Moving object tracking method and system applied to human-computer interaction
CN103985137A
Object tracking method and device, storage medium and electronic device
CN110866480A
