A template matching target tracking system based on Otsu's method and SAD-MCD fusion

The template matching method fused by Otsu method and SAD-MCD solves the problem of insufficient adaptability of regional template matching under background interference, illumination changes and occlusion, and achieves higher robustness and real-time target tracking.

CN113592908BActive Publication Date: 2024-09-06HUAZHONG UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110843554.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-26
Publication Date
2024-09-06
Estimated Expiration
2041-07-26

AI Technical Summary

Technical Problem

The region-based template matching scheme has insufficient adaptability in the face of background interference, illumination changes and target occlusion, and has a large amount of calculation and high matching repeatability, which affects the accuracy and real-time performance of target tracking.

Method used

A template matching method based on the Otsu method and SAD-MCD fusion is used to generate a weight matrix through binarization and dilation filtering of grayscale images, combine SAD and MCD distances for similarity matching, and update the template image when necessary to improve Robustness and adaptability.

Benefits of technology

It effectively distinguishes foreground and background points, improves the robustness to background interference, adapts to illumination changes and target occlusion, reduces the amount of calculation, and maintains the stability and real-time performance of long-term tracking.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113592908B
    Figure CN113592908B
Patent Text Reader

Abstract

The present invention discloses a template matching target tracking and system based on Otsu method and SAD-MCD fusion, belonging to the field of digital image processing. The present invention performs a binarization process on the template image of the target based on the threshold of Otsu method before performing template matching, distinguishes the foreground point part belonging to the target in the template image from the background point, can filter out the influence of background point change in similarity matching calculation, and effectively improves the tracking robustness for background interference; the present invention adopts SAD and MCD distance fusion in similarity matching calculation, and the MCD distance can filter out the pixel points with large difference from the template due to occlusion and other reasons, while SAD has higher matching accuracy, and the use of the fusion distance of the two can introduce the anti-occlusion characteristic in the matching without losing too much accuracy; the template update strategy proposed by the present invention not only completes the information update of the image with the highest similarity, but also retains part of the information of the previous template, and improves the adaptability to environmental changes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of digital image processing, and more specifically, relates to a template matching target tracking and system based on Otsu method and SAD-MCD fusion. Background Art

[0002] As the middle layer of the intelligent video surveillance system, vision-based motion target tracking is of great significance to the system's understanding of the target's behavior and subsequent decision-making, and has very wide applications in both military and civilian fields.

[0003] At present, the methods of moving target tracking mainly include contour-based, model-based, region-based and feature point-based methods. Among them, the region-based template matching scheme selects a suitable target initial template and image similarity measurement function, and calculates the similarity value between the template image and the corresponding images of all search windows in the subsequent image frame sequence to achieve the target position prediction in the image frame. In general, the scheme is simple to implement and has a high degree of versatility. It can still achieve good tracking effects in environments with low signal-to-noise ratio and unclear target features, and has been applied in the field of image processing. However, the template matching scheme based on rectangular templates lacks the distinction between foreground and background points between templates, and will be disturbed by background changes when facing complex morphological targets; the traditional strategy of using fixed initial templates for long-term tracking cannot adapt to the accuracy caused by factors such as illumination changes and target occlusion in actual scenes, and the algorithm robustness is insufficient. In addition, the target tracking scheme based on template matching has high matching repeatability and large calculation amount, and the real-time application of the scheme is relatively limited. Summary of the invention

[0004] In view of the above defects or improvement needs of the prior art, the present invention provides a template matching target tracking and system based on Otsu's method and SAD-MCD fusion, which aims to solve the problem of insufficient adaptability of region-based template matching schemes to background interference, illumination changes and target occlusion.

[0005] To achieve the above object, according to one aspect of the present invention, a template matching target tracking method based on Otsu's method and SAD-MCD fusion is provided, comprising:

[0006] S1. Using the grayscale image of the target area in the first frame of the video as a template image;

[0007] S2. According to the grayscale histogram of the template image, solve the Otsu image segmentation threshold corresponding to the template image;

[0008] S3. Binarize the template image according to the image segmentation threshold of the Otsu method, and then perform dilation filtering to obtain a weight matrix corresponding to the template image; the weight matrix is ​​composed of the binarized weights of each pixel of the template image;

[0009] S4. In the next frame of the video, the neighborhood of the target location in the previous frame is used as the search area; in the search area, the image corresponding to each search window is matched with the foreground point in the template image by using the weight matrix, and the search window coordinates with the highest similarity are used as the predicted coordinates of the target in the current frame; wherein the search window size is the same as the template image size, and the similarity size is calculated by the fusion of the absolute error and distance SAD between the image corresponding to the search window and the template image and the maximum adjacent point distance MCD;

[0010] S5. Output the predicted coordinates of the target in the current frame and determine whether the video input is completed; if so, complete the target tracking process; if not, determine whether the similarity corresponding to the predicted coordinates of the current frame is within the set threshold range; if so, use the image at the current predicted coordinates to perform weighted update on the template image, and return to step S4; if not, directly return to step S4.

[0011] Furthermore, step S2 is specifically as follows:

[0012] According to the formula g = ω a ·ω b ·(μ a -μ b ) 2 Calculate the inter-class variance of all gray levels of the template image one by one; where ω a , μ a They represent the proportion of the number of pixels belonging to the foreground in the entire template image and the average grayscale, ω b , μ b They respectively represent the proportion of the number of pixels belonging to the background in the entire template image and the average grayscale;

[0013] The grayscale corresponding to the maximum inter-class variance is selected as the desired Otsu image segmentation threshold.

[0014] Furthermore, step S3 is specifically as follows: sampling and calculating the average grayscale of pixels in the central area of ​​the template image and comparing it with the grayscale of the overall template image; if the average grayscale of the central area is greater than the grayscale of the overall template image, the pixels greater than the Otsu image segmentation threshold are identified as foreground, their weights are reset to 1, and the remaining pixels are set to 0; otherwise, the pixels less than the segmentation threshold are identified as foreground, their weights are set to 1, and the remaining pixels are set to 0.

[0015] Furthermore, the similarity calculation formula in step S4 is:

[0016] I=C1·I1+C2(1-I2)

[0017] I represents the similarity, C1 and C2 are weight coefficients, I1 and I2 are the normalized MCD distance and SAD distance of the matching area, respectively.

[0018] Furthermore, in step S5, the template image is weighted updated using the image at the current prediction coordinates, specifically,

[0019]

[0020]

[0021] T n and T n+1 are the template images of the current frame and the next frame respectively, α is the update weight of the template, x0 and y0 are the row and column coordinates of the search box with the highest similarity, Indicates the image corresponding to the search box with the highest similarity in the neighborhood.

[0022] According to another aspect of the present invention, a template matching target tracking system based on Otsu's method and SAD-MCD fusion is provided, comprising:

[0023] The first module is used to use the grayscale image of the target area in the first frame of the video as a template image;

[0024] The second module is used to solve the Otsu image segmentation threshold corresponding to the template image according to the grayscale histogram of the template image;

[0025] The third module is used to binarize the template image according to the Otsu image segmentation threshold, and then perform dilation filtering to obtain a weight matrix corresponding to the template image; the weight matrix is ​​composed of the weights of each pixel point of the template image;

[0026] The fourth module is used to use the neighborhood of the target location in the previous frame as the search area in the next frame of the video; in the search area, the image corresponding to each search window is matched with the foreground point in the template image by using the weight matrix, and the search window coordinates with the highest similarity are used as the predicted coordinates of the target in the current frame; wherein the search window size is the same as the template image size, and the similarity size is calculated by the fusion of the absolute error and distance SAD between the image corresponding to the search window and the template image and the maximum adjacent point distance MCD;

[0027] The fifth module is used to output the predicted coordinates of the target in the current frame and determine whether the video input is completed; if so, the target tracking process is completed; if not, it is determined whether the similarity corresponding to the predicted coordinates of the current frame is within the set threshold range; if so, the template image is weighted updated using the image at the current predicted coordinates and then enter the fourth module; if not, it directly enters the fourth module.

[0028] Furthermore, the system is implemented based on FPGA.

[0029] In general, compared with the prior art, the above technical solution conceived by the present invention can achieve the following beneficial effects.

[0030] (1) Before performing template matching, the present invention performs a binarization process on the template image of the target based on the Otsu threshold, thereby distinguishing the foreground points belonging to the target from the background points in the template image, thereby filtering out the influence of the background point changes in the similarity matching calculation, thereby effectively improving the tracking robustness of the present invention scheme against background interference.

[0031] (2) The present invention adopts the fusion of SAD and MCD distance in the similarity matching calculation. The MCD distance can filter out the pixels that are greatly different from the template due to occlusion and other reasons, while SAD has higher matching accuracy. The use of the fusion distance of the two can introduce the occlusion-resistant feature in the matching without losing too much accuracy.

[0032] (3) The present invention can better adapt to changes in the target and environment through timely template image updates, thereby maintaining a stable long-term tracking effect. At the same time, the update strategy proposed by the present invention not only completes the information update of the image with the highest similarity, but also retains part of the information of the previous template, thereby ensuring the reliability of the template information during the tracking process, and can significantly improve the algorithm's adaptability to environmental changes.

[0033] (4) When performing image similarity matching, the present invention only selects the search box image within the neighborhood of the target position of the previous frame for matching calculation. Compared with the global search and matching within the frame image range, the neighborhood matching strategy can reduce the probability of false matching due to the existence of similar grayscale distribution images in the background area, and at the same time can greatly reduce the overall similarity matching times, effectively reducing the amount of calculation. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 A flow chart of a target tracking method provided by an embodiment of the present invention;

[0035] Figure 2 Circuit diagram of template grayscale histogram statistics;

[0036] Figure 3This is a schematic diagram of the inter-class variance flow calculation;

[0037] Figure 4 Circuit diagrams for template caching and processing;

[0038] Figure 5 Circuit diagram generated by sliding window for image frame search area;

[0039] Figure 6 This is the circuit diagram of the matching logic basic operation unit. DETAILED DESCRIPTION

[0040] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0041] refer to Figure 1 , the target tracking method proposed by the present invention comprises the following steps:

[0042] S1. Using the grayscale image of the target area in the first frame of the video as a template image;

[0043] S2. According to the grayscale histogram of the template image, solve the Otsu image segmentation threshold corresponding to the template image;

[0044] For the template image T, the segmentation threshold between the foreground and the background is set to t, and the proportion of the number of pixels belonging to the foreground part in the entire template image under this threshold is ω a , and its corresponding average grayscale is recorded as μ a ; The percentage of background pixels and the average grayscale are recorded as ω b and μ b ; Let the average grayscale of the entire template image be μ, and the inter-class variance corresponding to the segmentation threshold be g.

[0045] Then we have:

[0046] μ=ω a ·μ a +ω b ·μ b (1) According to statistical theory, the formula for the inter-class variance, that is, the variance between foreground and background points, is:

[0047] g=ω a ·(μ a -μ) 2 +ω b ·(μb -v) 2 (2) Substituting formula (1) into formula (2), we get:

[0048] g=ω a ·ω b ·(μ a -μ b ) 2 (3)

[0049] According to formula (3), the inter-class variance of all gray levels is calculated one by one, and the gray level corresponding to the maximum value is the required Otsu method image threshold.

[0050] S3. Binarize the template image according to the image segmentation threshold of the Otsu method, and then perform dilation filtering to obtain a weight matrix corresponding to the template image; the weight matrix is ​​composed of the weights of each pixel of the template image;

[0051] First, the direction of image binarization is determined, and the average grayscale of the pixels in the central area of ​​the template image is sampled and calculated and compared with the grayscale of the overall template image. If the average grayscale of the central area is greater than the grayscale of the overall template image, the pixels greater than the image segmentation threshold of the Otsu method are identified as foregrounds, and their weights are reset to 1, and the remaining pixels are set to 0; otherwise, the pixels less than the segmentation threshold are identified as foregrounds, and their weights are set to 1, and the remaining pixels are set to 0. At the same time, considering the possible occasional tracking drift of the matching algorithm, the present invention further performs expansion calculation processing on the processed binary image, and appropriately expands the pixel range of the foreground point area to enhance the error compatibility of the weight matrix for similarity matching in subsequent steps.

[0052] The expansion filter structure element used in the embodiment of the present invention

[0053] Traditional template matching uses rectangular images to locate and characterize the tracking target. Compared with model-based target tracking solutions, rectangular area-based target tracking solutions often lack the distinction between foreground and background points when facing irregular image targets. In the process of image matching, the target pixels and background pixels in the macroblock participate in the calculation of similarity indiscriminately, which may cause the tracking algorithm to drift or even fail when the background changes. The present invention generates a weight matrix of the template image through an image segmentation strategy based on the Otsu threshold method, thereby filtering out background pixels that may cause interference during the similarity matching process, thereby effectively improving the algorithm's compatibility with background interference.

[0054] S4. In the next frame of the video, the neighborhood of the target location in the previous frame is used as the search area. In the search area, the image corresponding to each search window is matched with the foreground point in the template image using a weight matrix, and the search window coordinates with the highest similarity are used as the predicted coordinates of the target in the current frame. The search window size is the same as the template image size. The similarity is calculated by fusing the absolute error and distance SAD (Sum of Absolute Difference) and the maximum close distance MCD (Maximum Close Distance).

[0055] When performing image similarity matching, the present invention only selects the search box image within the neighborhood of the target position of the previous frame for matching calculation. Compared with the global search and matching within the frame image range, the neighborhood matching strategy can reduce the probability of false matching due to the existence of similar grayscale distribution images in the background area, and at the same time can greatly reduce the overall similarity matching times, effectively reducing the amount of calculation.

[0056] The SAD and MCD distance fusion distance is used in the matching calculation. Its essence is the weighted sum of the normalized MCD distance and the SAD distance of the matching area after filtering out occlusion. The MCD distance only counts the pixels between the two images that are less than the set threshold, and can filter out pixels that are significantly different from the template image. Therefore, when applied to template matching, it can filter out the matching errors caused by target occlusion, thereby introducing anti-occlusion characteristics in similarity matching; at the same time, considering that the MCD distance only focuses on the number of pixels and not the similarity of pixels between the two images, the SAD distance counts the sum of the grayscale differences between similar pixels. Therefore, the fusion of the two distances can introduce anti-occlusion characteristics in matching without losing too much accuracy. The definitions of SAD and MCD distances are shown in (4)(5).

[0057]

[0058]

[0059]

[0060] Where SAD(x,y) and MCD(x,y) are the SAD distance and MCD distance of the search window image F at the (x,y) coordinates in the neighborhood of the template image T, i and j are the row and column coordinate counts of the pixels in the template image, and m and n are the row and column lengths of the template image. MCD represents the set MCD threshold, R(T(i,j),F(ij)) represents the binary value of the template image at each pixel, and the accumulation of its value on the entire template image is the solved MCD distance;

[0061] Then the area in the entire template area belonging to the foreground point is defined as G, and the MCD distance between pixels is less than the threshold T MCD The matching area is defined as X. Then the SAD-MCD fusion distance I between the template image and the search box image in the present invention is defined as the weighted sum of the normalized MCD distance I1 and the SAD normalized distance I2 in the matching area. Its formula is defined as follows:

[0062] I=C1·I1+C2(1-I2) (6)

[0063]

[0064]

[0065] Where |X| is the number of pixels in region X, |G| is the number of pixels in the foreground area of ​​the template, and SAD(X(x,y)) is the SAD distance between the template image and the search box image corresponding to the pixels in the matching region X, that is, only the MCD distance in the foreground area is less than the threshold T. MCD The pixels of the image are matched. C1 and C2 are the weight coefficients of the two indicators. I1 reflects the proportion of similar pixels in the covered sub-image. The larger the value, the higher the similarity between images. I2 is the normalized SAD distance of the pixels in the matching area. The smaller the value, the higher the similarity between images. The choice of weight coefficients C1 and C2 reflects the compromise between the algorithm's anti-occlusion ability and matching accuracy. The larger C1, the stronger the algorithm's anti-occlusion ability, and the larger C2, the higher the matching accuracy of the algorithm.

[0066] S5. Output the predicted coordinates of the target in the current frame and determine whether the video input is completed; if so, complete the target tracking process; if not, determine whether the similarity corresponding to the predicted coordinates of the current frame is within the set threshold range; if so, use the image at the current predicted coordinates to perform weighted update on the template image, and return to step S4; if not, directly return to step S4.

[0067] After completing the target tracking calculation, the template update judgment is made based on the similarity between the predicted position image and the template. In the embodiment of the present invention, when the similarity is below 0.4, it is considered that the frame tracking has failed, and the template is not updated, and the tracking of the next frame continues; when the similarity is above 0.8, it is considered that the similarity between the template and the matching sub-image is high enough, and the template is not updated to reduce the tracking drift problem; when the similarity is between the two, the target template is weighted updated and the next frame is processed until the end of the video; timely template updates can make the solution better adapt to changes in the target and environment, thereby maintaining a stable long-term tracking effect. The formula is as follows:

[0068] T MCD=min{T(i,j) / 4,T0} (9)

[0069]

[0070]

[0071] Where T0 is a fixed threshold, which is generally between 10 and 30; T(i,j) / 4 is the relative threshold of the pixel in the image at the position with the highest similarity. The actual threshold for calculating the MCD distance is determined by the smaller value between the two points. α is the update weight of the template, x0 and y0 are the row and column coordinates of the search box with the highest similarity, |G| is the number of pixels in the foreground area of ​​the template, and α is the I1 distance defined in formula (7). n and T n+1 are the matching templates for the current frame and the next frame respectively, Indicates the image corresponding to the search box with the highest similarity in the neighborhood. Compared with the absolute threshold, the relative threshold can respond to weaker illumination changes when the grayscale of the pixel is low. Therefore, the introduction of the relative threshold can ensure the effectiveness of the MCD value in a dark environment and increase the update frequency under low brightness. At the same time, this strategy not only completes the information update of the image with the highest similarity, but also retains part of the information of the previous template image, ensuring the reliability of the template information during the tracking process, and can significantly improve the adaptability of the algorithm to environmental changes.

[0072] Figure 2 The circuit diagram of the grayscale histogram statistics part in the image Otsu method threshold calculation in the embodiment. First, it is necessary to complete the statistics of the grayscale histogram of the template image. In this embodiment, the BRAM of the FPGA is used to complete this operation through the strategy of adjacent number judgment. Among them, data and data_en are the grayscale values ​​of the template image and their corresponding enables, respectively, and the cache and comparison of adjacent pixels are completed through registers; when the grayscale values ​​of adjacent pixels are the same, the BRAM is not written, and the counter cnt is incremented according to the number of repetitions of adjacent pixels; until the grayscale values ​​reg2 and reg1 of the adjacent pixels are different, the write enable signal wren of the BRAM is pulled high, and doutb+cnt+1 is assigned to dina, and the update of the BRAM data is completed in the next clock cycle, thereby realizing the statistics of the grayscale histogram of the template image.

[0073] In order to reduce unnecessary hardware calculations, in the embodiment, formula (3) is rewritten as follows:

[0074]

[0075] Figure 3The figure is a hardware implementation diagram of the inter-class variance calculation part in the Otsu threshold calculation. From formula (12), we can see that the simplified inter-class variance g' is mainly composed of four parts of data, and they can all be calculated through the grayscale histogram of the image. and are the total number of pixels on both sides of the grayscale threshold t; and are the grayscale accumulation sums at both ends of the threshold.

[0076] The calculation of inter-class variance is mainly completed through a four-stage pipeline consisting of three multipliers and two dividers. In this way, the circuit can complete the inter-class variance calculation of a single grayscale value in each clock cycle. Then, after numerical comparison, the Otsu threshold of the image can be obtained.

[0077] Figure 4 The circuit diagram for window caching and weighted processing of template image data. The circuit completes the window caching of the template image through a 32*32 shift register array, then binarizes it through the Otsu threshold and performs morphological filtering. The data after the expansion calculation is cached in the weighted window in the same way as the template image.

[0078] Figure 5 A circuit diagram generated by a sliding sub-image window for matching the search region with a template image.

[0079] The left side of the image is the Shift-RAM row cache. For a video sequence with a resolution of 720P, we configure the number of Shift-RAM taps to 32, the tap length to 128, and the data bit width to 8. The right side is the sliding window cache, and its construction logic is consistent with the template window cache mentioned above. The image frame data is used as the serial input of the first tap, and the output of each tap is piped into the sliding window on the right. Through the above hardware logic, the sliding window cache can update a column of image data per cycle to complete the pixel-by-pixel movement of the template coverage window.

[0080] Figure 6The circuit logic of the basic operation unit in SAD-MCD fusion matching is shown. The entire matching logic requires a total of 32×32 such basic operation units, where each operation unit corresponds to a pixel in the template image and the sliding window image. In each clock cycle, the operation unit array completes the weighted difference of the three window data at the corresponding pixel position in full parallel. In the figure, weight_window is the weight coefficient window, temp_window and Frame_window are the template window and the sliding sub-image window respectively, and t is the adaptive MCD threshold in formula (9). It can be seen that the basic operation module can complete the weighted difference and binarization of the single pixel position window data in each cycle. Then, the output of the basic operation module is pipelined summed, that is, normalized to obtain the similarity distance, and then after numerical comparison and address latching, the predicted position of the moving target in the frame can be obtained.

[0081] It will be easily understood by those skilled in the art that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A template matching target tracking method based on Otsu's method and SAD-MCD fusion, characterized in that: include: S1. Using the grayscale image of the target area in the first frame of the video as a template image; S2. According to the grayscale histogram of the template image, solve the Otsu image segmentation threshold corresponding to the template image; S3. Binarize the template image according to the Otsu image segmentation threshold, and then perform dilation filtering to obtain a weight matrix corresponding to the template image to filter out background pixels that may interfere during the similarity matching process; the weight matrix is ​​composed of the binarized weights of each pixel of the template image; Step S3 specifically comprises sampling and calculating the average grayscale of the pixels in the central area of ​​the template image and comparing it with the grayscale of the overall template image; if the average grayscale of the central area is greater than the grayscale of the overall template image, the pixels greater than the image segmentation threshold of the Otsu method are identified as foreground, and their weights are reset to 1, and the remaining pixels are set to 0; otherwise, the pixels less than the segmentation threshold are identified as foreground, and their weights are set to 1, and the remaining pixels are set to 0; S4. In the next frame of the video, the neighborhood of the target position in the previous frame is used as the search area; In the search area, the weight matrix is ​​used to match the image corresponding to each search window with the foreground point in the template image, and the coordinates of the search window with the highest similarity are used as the predicted coordinates of the target in the current frame; the size of the search window is the same as the size of the template image, and the similarity is calculated by the fusion of the absolute error and distance SAD between the image corresponding to the search window and the template image, as well as the maximum adjacent point distance MCD; S5. Output the predicted coordinates of the target in the current frame, and determine whether the video input is finished; if so, complete the target tracking process; if not, determine whether the similarity corresponding to the predicted coordinates of the current frame is within the set threshold interval; if so, use the image at the current predicted coordinates to perform weighted update on the template image, and return to step S4; if not and the similarity is below the minimum value of the threshold interval, it is considered that the frame tracking fails, and the template is not updated; if not and the similarity is above the maximum value of the threshold interval, it is considered that the frame tracking is successful and the template is not updated, and the execution of step S4 is directly returned; Step S5 uses the image at the current prediction coordinates to perform weighted update on the template image, specifically: T n and T n+1 are the template images of the current frame and the next frame respectively, α is the update weight of the template, x0 and y0 are the row and column coordinates of the search box with the highest similarity, represents the image corresponding to the search box with the highest similarity in the neighborhood, |G| is the number of pixels in the foreground area of ​​the template; MCD(x0,y0) is the MCD distance of the search window image F at the coordinate (x0,y0) of the template image T in the neighborhood; T MCD =min{T(i,j) / 4,T0} Among them, T MCD is the actual threshold of the MCD distance, T(i,j) / 4 is the relative threshold of the pixel in the image at the position with the highest similarity, T0 is the fixed threshold, i and j are the row and column coordinate counts of the pixel in the template image, m and n are the row and column lengths of the template image, and R(T(i,j),F(i,j)) represents the binary value of the template image at each pixel.

2. The template matching target tracking method based on the fusion of Otsu method and SAD-MCD according to claim 1 is characterized in that: Step S2 is specifically as follows: According to the formula g = ω a ·ω b ·(μ a -μ b ) 2 Calculate the inter-class variance of all gray levels of the template image one by one; where ω a , μ a They represent the proportion of the number of pixels belonging to the foreground in the entire template image and the average grayscale, ω b , μ b They respectively represent the proportion of the number of pixels belonging to the background in the entire template image and the average grayscale; The grayscale corresponding to the maximum inter-class variance is selected as the desired Otsu image segmentation threshold.

3. The template matching target tracking method based on the fusion of Otsu method and SAD-MCD according to claim 1 is characterized in that: The similarity calculation formula in step S4 is: I=C1·I1+C2(1-I2) I represents the similarity, C1 and C2 are weight coefficients, I1 and I2 are the normalized MCD distance and SAD distance of the matching area, respectively.

4. A template matching target tracking system based on Otsu's method and SAD-MCD fusion, characterized in that: include: The first module is used to use the grayscale image of the target area in the first frame of the video as a template image; The second module is used to solve the Otsu image segmentation threshold corresponding to the template image according to the grayscale histogram of the template image; The third module is used to binarize the template image according to the Otsu image segmentation threshold, and then perform dilation filtering to obtain a weight matrix corresponding to the template image; the weight matrix is ​​composed of the weights of each pixel point of the template image; The third module is specifically used for: sampling and calculating the average grayscale of the pixels in the central area of ​​the template image and comparing it with the grayscale of the overall template image; if the average grayscale of the central area is greater than the grayscale of the overall template image, the pixels greater than the Otsu image segmentation threshold are identified as foreground, and their weights are reset to 1, and the remaining pixels are set to 0; otherwise, the pixels less than the segmentation threshold are identified as foreground, and their weights are set to 1, and the remaining pixels are set to 0; The fourth module is used to use the neighborhood of the target position in the previous frame image as the search area in the next frame image of the video; In the search area, the weight matrix is ​​used to match the image corresponding to each search window with the foreground point in the template image, and the coordinates of the search window with the highest similarity are used as the predicted coordinates of the target in the current frame; the size of the search window is the same as the size of the template image, and the similarity is calculated by the fusion of the absolute error and distance SAD between the image corresponding to the search window and the template image, as well as the maximum adjacent point distance MCD; The fifth module is used to output the predicted coordinates of the target in the current frame and determine whether the video input is completed; if so, the target tracking process is completed; if not, it is determined whether the similarity corresponding to the predicted coordinates of the current frame is within the set threshold interval; if so, the template image is weighted updated using the image at the current predicted coordinates, and then enter the fourth module; if not and the similarity is below the minimum value of the threshold interval, it is considered that the frame tracking fails and the template update is not performed; if not and the similarity is above the maximum value of the threshold interval, it is considered that the frame tracking is successful and the template update is not performed, and the fourth module is directly entered; The fifth module uses the image at the current prediction coordinate to perform weighted update on the template image, specifically: T n and T n+1 are the template images of the current frame and the next frame respectively, α is the update weight of the template, x0 and y0 are the row and column coordinates of the search box with the highest similarity, represents the image corresponding to the search box with the highest similarity in the neighborhood, |G| is the number of pixels in the foreground area of ​​the template; MCD(x0,y0) is the MCD distance of the search window image F at the coordinate (x0,y0) of the template image T in the neighborhood; T MCD =min{T(i,j) / 4,T0} Among them, T MCD is the actual threshold of the MCD distance, T(i,j) / 4 is the relative threshold of the pixel in the image at the position with the highest similarity, T0 is the fixed threshold, i and j are the row and column coordinate counts of the pixel in the template image, m and n are the row and column lengths of the template image, and R(T(i,j),F(i,j)) represents the binary value of the template image at each pixel.

5. The template matching target tracking system based on the Otsu method and SAD-MCD fusion according to claim 4 is characterized in that: The system is implemented based on FPGA.