Template matching target detection method for low-computing-power front-end real-time tracking
By adopting a template matching target detection method on a low-computing power front-end chip, adaptively determining the search range and performing sliding window matching, the problem of low-computing power front-end chips being difficult to achieve real-time target detection is solved, and the accuracy and speed of detection are improved.
Patent Information
- Application Number
- CN202310879527.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-18
- Publication Date
- 2025-01-21
AI Technical Summary
In transmission line video surveillance, low-computing front-end chips are difficult to achieve real-time object detection and tracking analysis, resulting in target markings sometimes without or lag in detection boxes.
The template matching target detection method is used to perform template matching operations on each frame of image through the matching thread, adaptively determine the search range, and perform sliding window matching within the search range, and use the maximum similarity and distribution to determine the target frame position.
It improves the accuracy and speed of target detection, enables real-time target detection on low-computing power front-end chips, and meets the application requirements of video surveillance.
Smart Images

Figure CN119339276A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of image processing and computer vision, and in particular to a template matching target detection method for real-time tracking of a low-computing-power front end. Background Art
[0002] Currently, in the field of power transmission line video surveillance, front-end computing power has been widely used for video analysis. However, due to the low computing power and poor performance of the front-end chip, target detection based on deep learning cannot achieve real-time detection, and the high computational complexity of prediction and matching cannot achieve real-time target tracking and analysis. Therefore, it can generally only be processed through frame skipping detection, resulting in the phenomenon that the target mark in the monitoring and analysis video appears sometimes and sometimes not, or the mark frame lags behind.
[0003] In multi-target tracking solutions, it is usually necessary to perform real-time detection on each frame of the image, and then use Kalman filtering to give the predicted target frame information of the current frame target based on the target detection result of the previous frame, and then perform Hungarian matching based on the feature information of the predicted target frame and the feature information of the detection frame to obtain the motion trajectory of the same target. It can be seen that this requires real-time detection of each frame of the image in order to match the targets. It requires both target detection and target prediction, which consumes a lot of computing resources and is difficult to meet application requirements on low-computing front-end chips. Summary of the invention
[0004] The present invention provides a template matching target detection method for real-time tracking of a low-computing-power front end, which can improve both the matching accuracy and the matching speed, and ensure the real-time performance of the front-end video analysis.
[0005] The present invention provides the following technical solutions:
[0006] A template matching target detection method for low computing power front-end real-time tracking, the method comprising:
[0007] S10: Acquire each frame of the video capture, and cache each frame of the image into an image queue in chronological order;
[0008] S20: Performing a template matching operation through a matching thread, wherein the template matching operation includes:
[0009] S21: taking out the first cached frame of image from the image queue as the current frame of image;
[0010] S22: Obtaining a target detection result of a previous frame image of the current frame image, wherein the target detection result of the previous frame image includes a plurality of target frames;
[0011] S23: for each of the target frames, calculate the searchROI of the target frame, and expand the searchROI pixels upward, downward, left and right respectively with the center point of the target frame of the previous frame image as the center on the current frame image to obtain the search range of the target frame;
[0012] searchROI = [(1+2*ratio)box w , (1+2*ratio)box h ]
[0013]
[0014] Among them, box w and box h are the width and height of the target frame respectively, I h is the height of the previous frame image, boxCenter y is the y coordinate of the center point of the target frame;
[0015] S24: For each of the target frames, a sliding window having the same size as the target frame is used to perform sliding window matching within the search range of the target frame according to a set sliding strategy, and a similarity R(x, y) between the target frame and each sliding window is calculated;
[0016] S25: Compare each similarity R(x, y) with a set similarity threshold, and record all similarities R(x, y) greater than the similarity threshold as a similarity set;
[0017] S26: Determine the position of each target frame on the current frame image by using the maximum similarity value and the distribution of the similarity set, obtain the target detection result of the current frame image composed of the target frames of the current frame image, and return to S21.
[0018] Further, the S26 includes:
[0019] S261: If the maximum similarity value and other similarity values in the similarity set are adjacent and non-isolated, and the similarity set presents a Gaussian distribution, then the sliding window corresponding to the maximum similarity value is used as the target window;
[0020] S262: If the maximum similarity value exists in isolation and is not adjacent to other similarity values in the similarity set, the sliding window corresponding to the center point of the similarity set is used as the target window;
[0021] S263: Determine the position of the target frame on the current frame image according to the target window, and obtain the target detection result of the current frame image composed of the target frame of the current frame image.
[0022] Furthermore, after S23 and before S24, the following steps are further included:
[0023] S231: Determine whether the width and height of the target frame are greater than the set width threshold and height threshold, respectively. If so, perform hole downsampling on the target frame so that the width and height of the target frame after hole downsampling are not greater than the width threshold and the height threshold, respectively.
[0024] In S24, when performing sliding window matching, the sliding window is subjected to the same hole downsampling as the target frame, and the similarity R(x, y) between the target frame after the hole downsampling and each sliding window after the hole downsampling is calculated;
[0025] The S263 includes:
[0026] The target window is upsampled corresponding to the hole downsampling, the position of the upsampled target window is determined on the current frame image, the upsampled target window is used as the target frame of the current frame image, and the target detection result of the current frame image is obtained.
[0027] Furthermore, upsampling is performed using the following formula:
[0028] curBoxCenter x =boxCenter x ′*step+(box w -box w ′*step) / 2
[0029] curBoxCenter y =boxCenter y ′*step+(box h -box h ′*step) / 2
[0030] Among them, (curBoxCenterx, curBoxCenter y ) is the center point coordinate of the target window after upsampling, (boxCenter x ′, boxCenter y ′) is the center point position coordinate of the target window before upsampling, and step is the sampling rate of hole downsampling and upsampling.
[0031] Furthermore, the sampling rate step is determined by the following formula:
[0032]
[0033] The value of the similarity threshold is 0.65*max(R[x, y]).
[0034] Furthermore, the similarity R(x, y) is calculated by the following formula:
[0035]
[0036] Wherein, T(x′, y′) is the pixel value at (x′, y′) of the target frame of the previous frame image, I(x+x′, y+y′) is the pixel value at (x′, y′) in the sliding window of the current frame image relative to the coordinates of the center point (x, y) of the sliding window, and Δx and Δy are the x-coordinate change and y-coordinate change of the center point of the sliding window of the current frame image relative to the center point of the target frame of the previous frame image, respectively.
[0037] Furthermore, before returning to S21, the method further includes:
[0038] S27: Calculate the x-coordinate change Δx′ and y-coordinate change Δy′ of the center point of the target frame of the current frame image and the target frame corresponding to the previous frame image, and use Δx′ and Δy′ as the movement direction of the target frame of the current frame image, and record the movement direction of the target frame of the current frame image in the target detection result of the current frame image;
[0039] Before S24, it also includes: determining whether the target detection result of the previous frame image includes the motion direction of the target frame of the previous frame image. If so, when performing sliding window matching in S24, taking the center point of the search range as the initial point, firstly perform sliding window matching within a collection range close to the motion direction [x+Δx, y+Δy]. If there is a target window determined by the method described in S261 within the collection range, then the target window is used as the final target window. Otherwise, perform sliding window matching within the search range outside the collection range.
[0040] Furthermore, the method further comprises:
[0041] S30: performing a target detection operation by a target detection thread executed in parallel with the matching thread, the target detection operation comprising:
[0042] S31: Performing target detection on the first frame image of the video capture by using a deep learning target detection method to obtain a target detection result of the first frame image;
[0043] S32: After the target detection of the first frame image is completed, the target detection method of deep learning is used to perform target detection on the last cached frame image in the image queue to obtain its target detection result, and return to S32.
[0044] Furthermore, before S22, the step further includes:
[0045] S211: Determine whether the current frame image has a target detection result. If so, output the target frame of the target detection result and return to S21; otherwise, execute S22.
[0046] Furthermore, before S24, the step also includes: normalizing the target frame of the previous frame image and the search range of the current frame image.
[0047] The present invention has the following beneficial effects:
[0048] The present invention performs a template matching operation on each frame image of video acquisition through a matching thread to obtain the target detection result of each frame image. When performing the template matching operation, the size of the target frame of the previous frame image and the upper and lower positions in the video monitoring are used as the benchmark to adaptively determine the search range, a small search range is used for small targets near the top of the image, and a large search range is used for large targets near the bottom of the image. When performing sliding window matching, it is only performed within the search range. The present invention uses a search range with an iou greater than an adaptive threshold with the target frame to perform target search matching, directly obtains the corresponding target information, reduces the iou matching calculation process, and improves the target matching speed. The application requirements of real-time target detection can be met on a low-computing power front-end chip. In addition, the present invention uses the maximum similarity value and the distribution of the similarity set to jointly determine the position of each target frame on the current frame image, obtain the target detection result of the current frame image, and improve the accuracy of template matching target detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 It is a flow chart of the template matching target detection method for low computing power front-end real-time tracking of the present invention;
[0050] Figure 2 A flow chart of the template matching operation performed for the matching thread;
[0051] Figure 3 Flowchart of the object detection operations performed by the object detection thread. DETAILED DESCRIPTION
[0052] In order to make the technical problems, technical solutions and advantages to be solved by the present invention more clear, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.
[0053] The embodiment of the present invention provides a template matching target detection method for real-time tracking of a low computing power front end, such as Figure 1 As shown, the method includes:
[0054] S10: Acquire each frame of the video capture, and cache each frame of the image into an image queue in chronological order.
[0055] In the present invention, a video stream is collected in real time by a camera, and each frame of the video stream is cached in real time in an image queue according to a chronological order.
[0056] S20: Perform template matching operation through matching thread, such as Figure 2 As shown, the template matching operation includes the following process.
[0057] S21: taking out the first cached frame of image from the image queue as the current frame of image. After taking out, the frame of image no longer exists in the image queue.
[0058] S22: Obtaining a target detection result of a previous frame image of the current frame image, wherein the target detection result of the previous frame image includes a plurality of target frames.
[0059] The target detection result of the previous frame image can be obtained by performing a template matching operation by a matching thread, or by performing a target detection operation by a target detection thread described later. The target detection result includes multiple detected targets, each of which is displayed in the form of a target frame.
[0060] S23: For each target frame, calculate the searchROI of the target frame, and expand the searchROI pixels upward, downward, left and right respectively with the center point of the target frame of the previous frame image as the center on the current frame image to obtain the search range of the target frame.
[0061] searchROI = [(1+2*ratio)box w , (1+2*ratio)box h ]
[0062]
[0063] Among them, box w and box h are the width and height of the target box, I h is the height of the previous frame image, boxCenter y The y coordinate of the center point of the target box.
[0064] In the present invention, in order to search for a target frame of the current frame that matches a target frame of the previous frame image in the current frame image, an adaptive solution is used to determine the search range.
[0065] It is assumed that the ground moving targets that need to be paid attention to in the transmission line video monitoring appear in the imaging situation that the closer the target is to the monitoring point, the larger it is and the closer it is to the bottom of the image; the farther the target is from the monitoring point, the smaller it is and the farther it is from the bottom of the image. Based on the above assumptions, in order to speed up the matching operation, a larger search range is required for large targets that are closer to the bottom of the image, and a smaller search range is required for small targets that are farther from the bottom of the image.
[0066] Since the time interval between the previous and next two frames is short, the moving distance of the moving target that needs to be paid attention to is limited, so there is generally a certain degree of overlap between the target frames of the previous and next two frames. Based on this, the present invention limits the search range of each target frame to a range where the iou with the target frame of the previous frame is greater than a certain threshold. For small targets near the top of the image, a small searchROI value is used to determine the search range, and for large targets near the bottom of the image, a large searchROI value is used to determine the search range.
[0067] Specifically, the calculation formula of searchROI is as above. After the searchROI is calculated, the center point of the target frame of the previous frame image is taken as the center on the current frame image, and the searchROI pixels are expanded upward, downward, left, and right respectively to obtain the search range of the target frame.
[0068] The present invention uses the size of the target frame of the previous frame image and the upper and lower positions in the video surveillance as a reference to adaptively determine the search range. A small search range is used for small targets near the upper part of the image, and a large search range is used for large targets near the lower part of the image. When sliding window matching is performed subsequently, it is only performed within the search range. The present invention uses a search range with an iou (Intersection over Union) greater than an adaptive threshold with the target frame to perform target search and matching, directly obtain corresponding target information, reduce the iou matching calculation process, and improve the target matching speed.
[0069] S24: For each target frame, a sliding window of the same size as the target frame is used to perform sliding window matching within the search range of the target frame according to the set sliding strategy, and the similarity R(x, y) between the target frame and each sliding window is calculated.
[0070] In one example, the similarity R(x, y) is calculated as follows:
[0071]
[0072] Wherein, T(x′, y′) is the pixel value at (x′, y′) of the target frame of the previous frame image, I(x+x′, y+y′) is the pixel value at (x′, y′) in the sliding window of the current frame image relative to the coordinates of the center point (x, y) of the sliding window, and Δx and Δy are the x-coordinate change and y-coordinate change of the center point of the sliding window of the current frame image relative to the center point of the target frame of the previous frame image, respectively.
[0073] For the above similarity R(x, y), the more the target box matches the sliding window, the closer the value of R(x, y) is to 1, and the less the target box matches the sliding window, the closer the value of R(x, y) is to -1.
[0074] S25: Compare each similarity R(x, y) with a set similarity threshold, and record all similarities R(x, y) greater than the similarity threshold as a similarity set.
[0075] Exemplarily, the value of the similarity threshold may be adaptively acquired based on the statistical values of all similarities R(x, y), for example, the value of the similarity threshold is 0.65*max(R[x, y]).
[0076] S26: Determine the position of each target frame on the current frame image by using the maximum similarity value and the distribution of the similarity set, obtain the target detection result of the current frame image composed of the target frames of the current frame image, and return to S21.
[0077] Specifically, the method of S26 may include:
[0078] S261: If the maximum similarity value and other similarity values in the similarity set are adjacent and non-isolated, and the similarity set presents a Gaussian distribution, then the sliding window corresponding to the maximum similarity value is used as the target window.
[0079] In the present invention, for ground moving targets that need to be paid attention to in power transmission lines, their similarity R(x, y) generally presents a Gaussian distribution, and it is considered to be moving at a uniform speed in the picture. Therefore, if the maximum similarity is non-isolated, adjacent to other similarities, and the similarity set presents a Gaussian distribution, then the sliding window corresponding to the maximum similarity is considered to be the ground moving target of interest, and the sliding window is used as the target window.
[0080] S262: If the maximum similarity value exists in isolation and is not adjacent to other similarity values in the similarity set, the sliding window corresponding to the center point of the similarity set is used as the target window.
[0081] For ground moving targets that need to be paid attention to in power transmission lines, if there are small targets that are far away and similar to the background, the point with the maximum similarity value is the background sliding window and exists in isolation. At this time, the maximum similarity value is not adjacent to other points in the R[x, y] set. It is considered that this point with the maximum similarity value is not the position of the target. Therefore, the center point of the R[x, y] set is used as the position of the current frame target, and the sliding window corresponding to the center point is used as the target window.
[0082] S263: Determine the position of the target frame on the current frame image according to the target window, and obtain the target detection result of the current frame image composed of the target frame of the current frame image.
[0083] After the target window is determined as mentioned above, the position of the target window can be used as the position of the target frame of the previous frame image on the current frame image to obtain the target frame of the current frame image, that is, the target detection result of the current frame image.
[0084] Then, return to S21, take out the first remaining cached frame image (i.e., the next frame image) in the image queue as the current frame image, repeat the above steps, and perform template matching operation on the next frame image according to the target detection result of the current frame image. In this way, the template matching is continuously performed to obtain the target detection result of each frame image of the video capture in real time, and the target frame is displayed in real time in the video screen.
[0085] In the existing technology, the inference speed of deep learning target detection based on low-computing front-end chips is too slow. Multi-target tracking solutions are based on target detection results to update tracking trajectories, and the calculation complexity involved in the tracking prediction process is high, resulting in the inability to achieve real-time tracking and identification of hidden dangers in front-end video surveillance. Frame skipping detection can make up for the video frame backlog caused by slow inference speed, but the detection results will appear sometimes when displayed on the recorded video, and the target detection frame will lag behind.
[0086] To solve the above problems, the present invention performs a template matching operation on each frame image of video acquisition through a matching thread to obtain the target detection result of each frame image. When performing the template matching operation, the size of the target frame of the previous frame image and the upper and lower positions in the video monitoring are used as the benchmark to adaptively determine the search range. A small search range is used for small targets near the top of the image, and a large search range is used for large targets near the bottom of the image. When performing sliding window matching, it is only performed within the search range. The present invention uses a search range with an iou greater than an adaptive threshold with the target frame to perform target search matching, directly obtain the corresponding target information, reduce the iou matching calculation process, so that the target matching speed can be improved, and the application requirements of real-time target detection can be met on low-computing power front-end chips. In addition, the present invention uses the maximum similarity value and the distribution of the similarity set to jointly determine the position of each target frame on the current frame image, obtain the target detection result of the current frame image, and improve the accuracy of template matching target detection.
[0087] When the target frame is small, the calculation speed is faster when the target frame of the previous frame is used to slide and match the target within the search range of the current frame to locate the target; however, when the target frame is large, the calculation will be very slow using the same solution.
[0088] To solve this problem, the present invention further includes after S23 and before S24:
[0089] S231: Determine whether the width and height of the target frame are greater than the set width threshold and height threshold respectively. If so, perform hole downsampling on the target frame so that the width and height of the target frame after hole downsampling are not greater than the width threshold and height threshold respectively.
[0090] In order to speed up the matching calculation of large targets, the present invention adopts a hole downsampling method to downsample the target frame, and controls the size of the target frame within a width threshold and a height threshold, for example, within a pixel range of [60, 60].
[0091] The downsampling method is based on the center point of the target box (T centerx , T centery ) as the initial point, Perform hole downsampling for the sampling interval and downsample the target box to within [60, 60].
[0092] In S24, when performing sliding window matching, the sliding window is subjected to the same hole downsampling as the target frame, and the similarity R(x, y) between the target frame after the hole downsampling and each sliding window after the hole downsampling is calculated.
[0093] Corresponding to the above-mentioned hole downsampling of the target frame, in the process of sliding window matching with the search range, the sliding window in the search range is also subjected to the same hole downsampling, and then matching is performed.
[0094] In the aforementioned S263, the position of the small target in the current frame image can be directly obtained through the target window (as described in the aforementioned S263). However, for a large target, it is necessary to upsample the target window and return to the original current frame image to calculate the position information of the target in the original current frame image. Specifically, it includes:
[0095] The target window is upsampled corresponding to the hole downsampling, the position of the upsampled target window is determined on the current frame image, the upsampled target window is used as the target frame of the current frame image, and the target detection result of the current frame image is obtained.
[0096] The formula for upsampling is as follows:
[0097] curBoxCenter x =boxCenter x ′*step+(box w -box w ′*step) / 2
[0098] curBoxCenter y =boxCenter y ′*step+(box h -box h ′*step) / 2
[0099] Among them, (curBoxCenter x ,curBoxCenter y ) is the center point coordinate of the target window after upsampling, (boxCenter x ′, boxCenter y ′) is the center point position coordinate of the target window before upsampling, and step is the sampling rate of hole downsampling and upsampling.
[0100] The present invention adopts a hollow downsampling method that diffuses outward from the center point of the target when matching large targets, which can accelerate the matching search process, and then upsample the matching results to restore them to the original image position. The present invention adopts target-level downsampling to downsample the target frame and the sliding window, which can ensure that the speed of target matching is constant and does not cause the disadvantage of missing small target information due to downsampling of the entire image. The present invention adopts target-level downsampling processing according to the different sizes of targets, while improving the matching speed of large targets, it ensures the accuracy of feature matching of small targets.
[0101] On the one hand, the present invention adopts a search range with an iou greater than an adaptive threshold with the target frame for target search and matching, and on the other hand, performs hole downsampling when matching large targets. Both improve the matching speed and can ensure a constant processing speed of 10ms / target, ensuring that the application requirements of real-time target detection can be met on low-computing power front-end chips.
[0102] As an improvement of the embodiment of the present invention, before returning to S21, the method of the present invention further includes:
[0103] S27: Calculate the x-coordinate change Δx′ and y-coordinate change Δy′ of the center point of the target frame of the current frame image and the corresponding target frame of the previous frame image, and use Δx′ and Δy′ as the movement direction of the target frame of the current frame image, and record the movement direction of the target frame of the current frame image in the target detection result of the current frame image. When the template matching operation is subsequently performed on the next frame image according to the target detection result of the current frame image, the movement direction of the target frame of the current frame image can narrow the search range of the sliding window matching of the next frame image, thereby accelerating the search and matching process.
[0104] Correspondingly, before S24, it also includes: judging whether the target detection result of the previous frame image includes the motion direction of the target frame of the previous frame image (the method for obtaining the motion direction of the previous frame image is the same as that of the current frame image, except that during the loop execution, the next frame image is used as the current frame image and the current frame image is used as the previous frame image). If so, when performing sliding window matching in S24, the center point (T centerx , T centery ) is the initial point, firstly, sliding window matching is performed in the set range close to the motion direction [x+Δx, y+Δy], and then processed through S25 and S26. If there is a target window determined by the method of S261 in the set range (i.e., the similarity presents a Gaussian distribution and the maximum similarity value point appears), then the target window is used as the final target window, otherwise (i.e., the similarity value in this area presents a random distribution), then sliding window matching is performed in the search range outside the set range, and it also needs to be processed through S25 and S26. This accelerates the search and matching process.
[0105] As another improvement of the embodiment of the present invention, the method further includes:
[0106] S30: Performing target detection operations by executing a target detection thread in parallel with the matching thread, such as Figure 3 As shown, the target detection operation includes the following process.
[0107] S31: Perform target detection on the first frame image of the video capture using a deep learning target detection method to obtain a target detection result of the first frame image, and cache the obtained subsequent frame images into an image queue.
[0108] S32: After the target detection of the first frame image is completed, the target detection method of deep learning is used to perform target detection on the last cached frame image in the image queue to obtain its target detection result, and return to S32.
[0109] The target detection thread and the matching thread are executed in parallel. The deep learning target detection method can adopt the edge CPU target detection algorithm solution, including but not limited to nanodet, picodet and other deep learning target detection algorithms. After completing the target detection of a frame of image each time, the target detection is then performed on the last cached frame of image in the image queue, i.e., frame skipping detection.
[0110] Correspondingly, the matching thread corresponding to the target detection thread also includes before S22:
[0111] S211: Determine whether the current frame image has a target detection result. If so, output the target frame of the target detection result and return to S21; otherwise, execute S22.
[0112] That is, the target detection thread skips frame detection. When the matching thread performs template matching operation on each frame image, it first determines whether the target detection result of the frame image has been obtained by the target detection thread. If so, the template matching operation is no longer performed, and the operation is repeated in S21 for the next frame image. At this time, the target detection result of the target detection thread is used as the input of the template matching of the next frame image. If not, S22 is executed to perform the template matching operation normally. When processing the next frame image, the target detection result of the matching thread is used as the input of the template matching of the next frame image.
[0113] In order to prevent the influence of ambient lighting, target angle, shadow, etc., the matching thread of the present invention further includes normalizing the target frame of the previous frame image and the search range of the current frame image before executing S24.
[0114] The effects of the present invention are intuitively described below with specific experimental examples:
[0115] The method of the present invention can achieve a matching detection speed of 10ms / target on a Qualcomm msm8909 chip (quad-core Cortex-A7, main frequency 1.1GHz, 1GB DDR3). The number of hidden danger targets in actual video surveillance scenes is generally less than 4 on average, that is, the processing speed of each frame image is within 40ms, which can fully meet the requirements of real-time applications. Compared with the inference speed of deep learning target detection (1.8s / frame), the present invention greatly improves the target detection and tracking efficiency of hidden dangers in low-computing front-end video analysis.
[0116] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A template matching target detection method for real-time tracking of low-computing front-end, characterized in that: The method comprises: S10: Acquire each frame of the video capture, and cache each frame of the image into an image queue in chronological order; S20: Performing a template matching operation through a matching thread, wherein the template matching operation includes the following process: S21: taking out the first cached frame of image from the image queue as the current frame of image; S22: Obtaining a target detection result of a previous frame image of the current frame image, wherein the target detection result of the previous frame image includes a plurality of target frames; S23: for each of the target frames, calculate the search distance searchROI of the target frame, and expand searchROI pixels upward, downward, left and right respectively with the center point of the target frame of the previous frame image as the center on the current frame image to obtain the search range of the target frame; searchROI=[(1+2*ratio)box w ,(1+2*ratio)box h ] Among them, box w and box h are the width and height of the target frame respectively, I h is the height of the previous frame image, boxCenter y is the y coordinate of the center point of the target frame; S24: For each of the target frames, a sliding window having the same size as the target frame is used to perform sliding window matching within the search range of the target frame according to a set sliding strategy, and a similarity R(x, y) between the target frame and each sliding window is calculated; S25: Compare each similarity R(x, y) with a set similarity threshold, and record all similarities R(x, y) greater than the similarity threshold as a similarity set; S26: Determine the position of each target frame on the current frame image by using the maximum similarity value and the distribution of the similarity set, obtain the target detection result of the current frame image composed of the target frames of the current frame image, and return to S21.
2. The template matching target detection method for low computing power front-end real-time tracking according to claim 1, characterized in that: The S26 includes: S261: If the maximum similarity value and other similarity values in the similarity set are adjacent and non-isolated, and the similarity set presents a Gaussian distribution, then the sliding window corresponding to the maximum similarity value is used as the target window; S262: If the maximum similarity value exists in isolation and is not adjacent to other similarity values in the similarity set, the sliding window corresponding to the center point of the similarity set is used as the target window; S263: Determine the position of the target frame on the current frame image according to the target window, and obtain the target detection result of the current frame image composed of the target frame of the current frame image.
3. The template matching target detection method for low computing power front-end real-time tracking according to claim 2 is characterized in that: After S23 and before S24, the following further includes: S231: Determine whether the width and height of the target frame are greater than the set width threshold and height threshold, respectively. If so, perform hole downsampling on the target frame so that the width and height of the target frame after hole downsampling are not greater than the width threshold and the height threshold, respectively. In S24, when performing sliding window matching, the sliding window is subjected to the same hole downsampling as the target frame, and the similarity R(x, y) between the target frame after the hole downsampling and each sliding window after the hole downsampling is calculated; The S263 includes: The target window is upsampled corresponding to the hole downsampling, the position of the upsampled target window is determined on the current frame image, the upsampled target window is used as the target frame of the current frame image, and the target detection result of the current frame image is obtained.
4. The template matching target detection method for low computing power front-end real-time tracking according to claim 3 is characterized in that: Upsampling is performed using the following formula: curBoxCenter x =boxCenter x ′*step+(box w -box w ′*step) / 2 curBoxCenter y =boxCenter y ′*step+(box h -box h ′*step) / 2 Among them, (curBoxCenter x ,curBoxCenter y ) is the center point coordinate of the target window after upsampling, (boxCenter x ′,boxCenter y ′) is the center point position coordinate of the target window before upsampling, and step is the sampling rate of hole downsampling and upsampling.
5. The template matching target detection method for low computing power front-end real-time tracking according to claim 4 is characterized in that: The sampling rate step is determined by the following formula: The value of the similarity threshold is 0.65*max(R[x,y]).
6. The template matching target detection method for low computing power front-end real-time tracking according to claim 1, characterized in that: The similarity R(x,y) is calculated by the following formula: Wherein, T(x′, y′) is the pixel value at (x′, y′) of the target frame of the previous frame image, I(x+x′, y+y′) is the pixel value at (x′, y′) in the sliding window of the current frame image relative to the coordinates of the center point (x, y) of the sliding window, and Δx and Δy are the x-coordinate change and y-coordinate change of the center point of the sliding window of the current frame image relative to the center point of the target frame of the previous frame image, respectively.
7. The template matching target detection method for low computing power front-end real-time tracking according to claim 6, characterized in that: Before returning to S21, the method further includes: S27: Calculate the x-coordinate change Δx′ and y-coordinate change Δy′ of the center point of the target frame of the current frame image and the target frame corresponding to the previous frame image, and use Δx′ and Δy′ as the movement direction of the target frame of the current frame image, and record the movement direction of the target frame of the current frame image in the target detection result of the current frame image; Before S24, it also includes: determining whether the target detection result of the previous frame image includes the motion direction of the target frame of the previous frame image. If so, when performing sliding window matching in S24, taking the center point of the search range as the initial point, firstly perform sliding window matching within a collection range close to the motion direction [x+Δx, y+Δy]. If there is a target window determined by the method described in S261 within the collection range, then the target window is used as the final target window. Otherwise, perform sliding window matching within the search range outside the collection range.
8. The template matching target detection method for low computing power front-end real-time tracking according to any one of claims 1 to 7, characterized in that: The method further comprises: S30: performing a target detection operation by a target detection thread executed in parallel with the matching thread, wherein the target detection operation includes: S31: Performing target detection on the first frame image of the video capture using a deep learning target detection method to obtain a target detection result of the first frame image; S32: After the target detection of the first frame image is completed, the target detection method of deep learning is used to perform target detection on the last cached frame image in the image queue to obtain its target detection result, and return to S32.
9. The template matching target detection method for low computing power front-end real-time tracking according to claim 8, characterized in that: The S22 also includes: S211: Determine whether the current frame image has a target detection result. If so, output the target frame of the target detection result and return to S21; otherwise, execute S22.
10. The template matching target detection method for low computing power front-end real-time tracking according to claim 9, characterized in that: Before S24, the method further includes: normalizing the target frame of the previous frame image and the search range of the current frame image.