CN109685827B - Target detection and tracking method based on DSP - Google Patents
Target detection and tracking method based on DSP Download PDFInfo
- Publication number
- CN109685827B CN109685827B CN201811453586.1A CN201811453586A CN109685827B CN 109685827 B CN109685827 B CN 109685827B CN 201811453586 A CN201811453586 A CN 201811453586A CN 109685827 B CN109685827 B CN 109685827B
- Authority
- CN
- China
- Prior art keywords
- target
- image
- pixel
- template
- wave gate
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 38
- 238000001514 detection method Methods 0.000 title claims abstract description 26
- 229910003460 diamond Inorganic materials 0.000 claims description 16
- 239000010432 diamond Substances 0.000 claims description 16
- 238000010845 search algorithm Methods 0.000 claims description 10
- 238000002372 labelling Methods 0.000 claims description 8
- 238000001914 filtration Methods 0.000 claims description 6
- 238000010586 diagram Methods 0.000 description 3
- 230000000694 effects Effects 0.000 description 2
- 230000003190 augmentative effect Effects 0.000 description 1
- 230000002902 bimodal effect Effects 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 238000004088 simulation Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/20—Analysis of motion
- G06T7/246—Analysis of motion using feature-based methods, e.g. the tracking of corners or segments
- G06T7/251—Analysis of motion using feature-based methods, e.g. the tracking of corners or segments involving models
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/187—Segmentation; Edge detection involving region growing; involving region merging; involving connected component labelling
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/70—Arrangements for image or video recognition or understanding using pattern recognition or machine learning
- G06V10/74—Image or video pattern matching; Proximity measures in feature spaces
- G06V10/75—Organisation of the matching processes, e.g. simultaneous or sequential comparisons of image or video features; Coarse-fine approaches, e.g. multi-scale approaches; using context analysis; Selection of dictionaries
- G06V10/751—Comparing pixel values or logical combinations thereof, or feature values having positional relevance, e.g. template matching
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/10—Image acquisition modality
- G06T2207/10016—Video; Image sequence
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/20—Special algorithmic details
- G06T2207/20024—Filtering details
Landscapes
- Engineering & Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Physics & Mathematics (AREA)
- Multimedia (AREA)
- Evolutionary Computation (AREA)
- General Health & Medical Sciences (AREA)
- Medical Informatics (AREA)
- Software Systems (AREA)
- Databases & Information Systems (AREA)
- Computing Systems (AREA)
- Artificial Intelligence (AREA)
- Health & Medical Sciences (AREA)
- Image Analysis (AREA)
Abstract
本发明公开了一种基于DSP的目标检测与跟踪方法,包括以下步骤:首先初始化波门以及其四周背景的大小,并设置波门在图像中的位置使其包含待跟踪目标;之后对波门内图像进行二值化和滤波处理;然后标记连通域并确定目标模板;再根据连续两帧图像中目标的位置获取后一帧图像中目标的位置;最后求取后一帧图像中目标与目标模板之间的相关系数,并判断是继续跟踪还是停止跟踪。本发明的目标检测与跟踪方法运算复杂度低,且放大了目标模板与图像中目标的相关性,保证了图像跟踪的稳定性,跟踪精度高,实时性好,能满足图像跟踪系统对跟踪方法的要求。
The invention discloses a DSP-based target detection and tracking method, comprising the following steps: firstly initialize the size of the wave gate and its surrounding background, and set the position of the wave gate in the image to include the target to be tracked; The inner image is binarized and filtered; then the connected domain is marked and the target template is determined; then the position of the target in the next frame of image is obtained according to the position of the target in two consecutive frames of images; finally, the target and the target in the next frame of image are obtained. Correlation coefficient between templates, and determine whether to continue tracking or stop tracking. The target detection and tracking method of the invention has low computational complexity, enlarges the correlation between the target template and the target in the image, ensures the stability of the image tracking, has high tracking accuracy and good real-time performance, and can satisfy the tracking method of the image tracking system. requirements.
Description
技术领域technical field
本发明属于图像实时处理与跟踪控制技术,特别是一种基于DSP的目标检测与跟踪方法。The invention belongs to the real-time image processing and tracking control technology, in particular to a DSP-based target detection and tracking method.
背景技术Background technique
在数字视频处理和计算机视觉领域的各项应用中,目标检测和跟踪是一个重基本且重要的任务。一些发展前景较好的领域,机器人控制、基于运动的识别、基于视觉的控制、增强现实、视频场景监控、导航制导都需要用到目标检测与跟踪技术。在计算机视觉领域,目标的检测与跟踪依旧是热度较高的研究领域。研究的重点也由单纯追求高精度高稳定性的仿真分析,向实时性运算量小的工业应用方向发展,如何在尽可能多满足性能指标的前提下,降低对硬件的要求是实际目标检测与跟踪研究方向的难点。为了降低对硬件的要求,中国专利CN201010121006.6提出了一种基于DSP的目标检测与跟踪方法以及数字图像处理系统,但是该方法运算量大,通用性和实时性差,在现在以多核DSP为主要硬件平台的视频图像处理系统里难以得到较好的应用。研究一种精度高、运算复杂性低、实用性好的目标检测与跟踪方法具有重要的意义。Object detection and tracking is a fundamental and important task in various applications in the fields of digital video processing and computer vision. In some promising fields, robot control, motion-based recognition, vision-based control, augmented reality, video scene monitoring, and navigation and guidance all require target detection and tracking technology. In the field of computer vision, target detection and tracking is still a hot research field. The focus of the research is also from the simple pursuit of high-precision and high-stability simulation analysis, to the direction of industrial applications with small real-time computation. How to reduce the hardware requirements while meeting as many performance indicators as possible is the actual target detection and Difficulties in tracking research directions. In order to reduce the requirements for hardware, Chinese patent CN201010121006.6 proposes a DSP-based target detection and tracking method and a digital image processing system, but this method has a large amount of computation, poor generality and real-time performance, and is now mainly based on multi-core DSP. It is difficult to get a better application in the video image processing system of the hardware platform. It is of great significance to study a target detection and tracking method with high precision, low computational complexity and good practicability.
发明内容SUMMARY OF THE INVENTION
本发明所解决的技术问题在于提供一种运算量低、易于实现且能满足高实时性系统要求的目标检测与跟踪方法。The technical problem solved by the present invention is to provide a target detection and tracking method with low computational complexity, easy implementation and high real-time system requirements.
实现本发明目的的技术解决方案为:一种基于DSP的目标检测与跟踪方法,包括以下步骤:The technical solution for realizing the object of the present invention is: a DSP-based target detection and tracking method, comprising the following steps:
步骤1、采集视频中的第一帧图像;Step 1. Collect the first frame image in the video;
步骤2、根据采集的第一帧图像初始化波门的大小,之后根据波门的大小初始化波门四周背景的大小,并设置波门在第一帧图像中的位置使其包含待跟踪目标,统计波门和波门四周背景的灰度直方图;Step 2. Initialize the size of the wave gate according to the first frame image collected, then initialize the size of the background around the wave gate according to the size of the wave gate, and set the position of the wave gate in the first frame image to include the target to be tracked. The grayscale histogram of the wave gate and the background around the wave gate;
步骤3、根据所述灰度直方图确定二值化的阈值,并根据该阈值对波门内图像进行二值化处理;Step 3. Determine a binarization threshold according to the grayscale histogram, and perform binarization processing on the image in the wave gate according to the threshold;
步骤4、对二值化处理后的波门内图像进行滤波处理;Step 4, filtering the image in the gate after binarization;
步骤5、利用邻域标记算法标记滤波后的波门内图像的各个区域,获得若干个连通区域;Step 5, use the neighborhood labeling algorithm to mark each area of the filtered wave gate image, and obtain several connected areas;
步骤6、统计步骤5中所有连通区域的大小,并对连通区域大小进行降序排列,获取其中最大连通区域的最小外接矩形,并将其作为目标模板;Step 6, count the size of all connected regions in step 5, and arrange the size of the connected regions in descending order, obtain the minimum circumscribed rectangle of the largest connected region among them, and use it as the target template;
步骤7、获取所述最大连通区域的中心即第一帧图像中目标所在位置,之后根据该中心获取第二帧图像中目标所在位置,并更新目标模板;Step 7, obtaining the center of the maximum connected area, that is, the location of the target in the first frame image, then obtaining the location of the target in the second frame image according to the center, and updating the target template;
步骤8、根据连续两帧图像中目标所在位置获取后一帧图像中目标所在位置;Step 8, obtain the target position in the next frame image according to the target position in two consecutive frames of images;
步骤9、求取所述后一帧图像中的目标与目标模板之间的相关系数,并根据相关系数判断是重复步骤8继续跟踪还是停止跟踪;若相关系数Q大于等于预设阈值p则重复步骤8继续跟踪;反之将失败次数n递增1,并判断n与失败次数预设阈值q的关系,若n≥q,则停止跟踪,反之以像素级为单位扩大波门的大小,重复步骤8继续跟踪。Step 9, obtain the correlation coefficient between the target and the target template in the next frame of image, and determine whether to repeat step 8 to continue tracking or stop tracking according to the correlation coefficient; if the correlation coefficient Q is greater than or equal to the preset threshold p, then repeat Step 8 Continue tracking; otherwise, increase the number of failures n by 1, and judge the relationship between n and the preset threshold q of the number of failures, if n≥q, stop tracking, otherwise expand the size of the wave gate in pixel-level units, repeat Step 8 continue following.
本发明与现有技术相比,其显著优点:1)本发明通过采用菱形搜索算法提高了匹配效率,能在保证搜索效果的前提下降低运算量;2)本发明中将目标模板更新的权值的取值与相关系数关联,避免了在跟踪效果不佳时将错误信息更新到目标模板中,保证了后续图像跟踪的稳定性;3)本发明中通过去均值法求取相关系数,在降低运算量的同时,放大目标模板与图像中目标的相关性。Compared with the prior art, the present invention has significant advantages: 1) the present invention improves the matching efficiency by adopting the diamond search algorithm, and can reduce the amount of computation on the premise of ensuring the search effect; 2) the right to update the target template in the present invention The value of the value is associated with the correlation coefficient, which avoids updating the error information to the target template when the tracking effect is not good, and ensures the stability of subsequent image tracking; 3) In the present invention, the correlation coefficient is obtained by the de-average method, and in the While reducing the amount of computation, enlarge the correlation between the target template and the target in the image.
下面结合附图对本发明作进一步详细的描述。The present invention will be described in further detail below with reference to the accompanying drawings.
附图说明Description of drawings
图1为本发明基于DSP的目标检测与跟踪方法的流程图。FIG. 1 is a flow chart of the DSP-based target detection and tracking method of the present invention.
图2为本发明实施例中某一帧图像中待检测跟踪目标示意图。FIG. 2 is a schematic diagram of a tracking target to be detected in a certain frame of image according to an embodiment of the present invention.
图3为本发明实施例中采用菱形搜索算法所用的搜索模板示意图,其中图3(a)为5×5的菱形搜索模板,图3(b)为3×3的菱形搜索模板。3 is a schematic diagram of a search template used by a diamond search algorithm in an embodiment of the present invention, wherein FIG. 3( a ) is a 5×5 diamond search template, and FIG. 3( b ) is a 3×3 diamond search template.
图4为本发明实施例中某一帧图像中目标跟踪结果示意图。FIG. 4 is a schematic diagram of a target tracking result in a certain frame of images in an embodiment of the present invention.
具体实施方式Detailed ways
结合图1,本发明一种基于DSP的目标检测与跟踪方法,包括以下步骤:1, a DSP-based target detection and tracking method of the present invention includes the following steps:
步骤1、采集视频中的第一帧图像。Step 1. Collect the first frame image in the video.
步骤2、根据采集的第一帧图像初始化波门的大小,之后根据波门的大小初始化波门四周背景的大小,并设置波门在第一帧图像中的位置使其包含待跟踪目标,统计波门和波门四周背景的灰度直方图。Step 2. Initialize the size of the wave gate according to the first frame image collected, then initialize the size of the background around the wave gate according to the size of the wave gate, and set the position of the wave gate in the first frame image to include the target to be tracked. Grayscale histogram of the wave gate and the background around the wave gate.
进一步地,根据采集的第一帧图像初始化波门的大小,具体为:根据第一帧图像的大小以及图像中待跟踪目标的大小初始化波门的大小,假设采集的图像的大小为w×h,待跟踪目标最小外接矩形的大小为x×y,波门大小为w'×h',其中x<w'≤w,y<h'≤h;Further, initialize the size of the wave gate according to the first frame image collected, specifically: initialize the size of the wave gate according to the size of the first frame image and the size of the target to be tracked in the image, assuming that the size of the collected image is w×h , the size of the minimum circumscribed rectangle of the target to be tracked is x×y, and the size of the wave gate is w'×h', where x<w'≤w, y<h'≤h;
进一步地,根据波门的大小确定波门四周背景大小,具体为:将波门的边界扩展若干像素。Further, the size of the background around the wave gate is determined according to the size of the wave gate, specifically: extending the boundary of the wave gate by several pixels.
步骤3、根据灰度直方图确定二值化的阈值,并根据该阈值对波门内图像进行二值化处理。Step 3: Determine a binarization threshold according to the grayscale histogram, and perform binarization processing on the image in the wave gate according to the threshold.
进一步地,根据灰度直方图确定二值化的阈值,具体为:将灰度直方图中代表待跟踪目标以及其背景的两个波峰之间的低谷对应的灰度值作为二值化的阈值。Further, the threshold value of binarization is determined according to the grayscale histogram, specifically: the grayscale value corresponding to the valley between the two peaks representing the target to be tracked and its background in the grayscale histogram is used as the threshold value of binarization. .
步骤4、对二值化后的波门内图像进行滤波处理。Step 4: Perform filtering processing on the binarized inner image of the wave gate.
进一步地,滤波处理具体采用开运算处理。Further, the filtering process specifically adopts the open operation process.
步骤5、利用邻域标记算法标记滤波后的波门内图像的各个区域,获得若干个连通区域。Step 5. Use the neighborhood labeling algorithm to label each area of the filtered wave gate image to obtain several connected areas.
进一步地,利用邻域标记算法标记滤波后的波门内的图像的各个区域,其中邻域标记算法具体为:Further, each area of the image in the filtered wave gate is marked with a neighborhood labeling algorithm, wherein the neighborhood labeling algorithm is specifically:
对滤波后的波门内图像以从左至右、从上至下的方式进行逐像素扫描,直至扫描完波门内图像的所有像素,若当前扫描的像素值为0,则直接移动至下一个像素;若当前扫描的像素值为1,则根据当前像素的左侧像素、上侧像素进行标记,其中标记值的大小随着新的连通域的出现增大,具体包括以下4种情况:Scan the filtered image in the wave gate pixel by pixel from left to right and from top to bottom until all the pixels in the image in the wave gate are scanned, if the current scanned pixel value is 0, move directly to the bottom One pixel; if the current scanned pixel value is 1, it is marked according to the left pixel and the upper pixel of the current pixel, and the size of the marked value increases with the appearance of a new connected domain, including the following four situations:
(1)左侧和上侧的像素值均为0,表示当前扫描的像素为一个新的连通域的边界,则赋予当前扫描的像素一个新的标记值;(1) The pixel values on the left side and the upper side are both 0, indicating that the currently scanned pixel is the boundary of a new connected domain, and then a new label value is given to the currently scanned pixel;
(2)左侧和上侧的像素值中只存在一个像素值为1,则赋予当前扫描的像素与像素值为1的像素标记值相同的标记值;(2) There is only one pixel value of 1 in the pixel values of the left side and the upper side, then the currently scanned pixel is given the same mark value as the pixel mark value of the pixel value of 1;
(3)左侧和上侧的像素值均为1且标记值相同,则赋予当前扫描的像素与标记值相同的标记值;(3) The pixel values on the left side and the upper side are both 1 and the mark value is the same, then the currently scanned pixel is given the same mark value as the mark value;
(4)左侧和上侧的像素值均为1但标记值不同,则赋予当前扫描的像素的标记值为标记值中最小的标记值。(4) The pixel values on the left side and the upper side are both 1 but the flag values are different, and the flag value assigned to the currently scanned pixel is the smallest flag value among the flag values.
步骤6、统计步骤5中所有连通区域的大小,并对连通区域大小进行降序排列,获取其中最大连通区域的最小外接矩形,并将其作为目标模板。Step 6: Count the sizes of all connected regions in step 5, and sort the connected regions in descending order to obtain the smallest circumscribed rectangle of the largest connected region, and use it as the target template.
步骤7、获取最大连通区域的中心即第一帧图像中目标所在位置,之后根据该中心获取第二帧图像中目标所在位置,并更新目标模板。Step 7: Obtain the center of the largest connected area, that is, the position of the target in the first frame of image, then obtain the position of the target in the second frame of image according to the center, and update the target template.
进一步地,根据最大连通区域的中心获取第二帧图像中目标所在位置,具体为:Further, the position of the target in the second frame of image is obtained according to the center of the largest connected area, specifically:
步骤7-1、将波门的中心移动至最大连通区域的中心;Step 7-1. Move the center of the wave gate to the center of the maximum connected area;
步骤7-2、通过模板匹配算法对波门内图像与目标模板进行匹配获取第二帧图像中目标所在位置。Step 7-2: Match the image in the wave gate with the target template through a template matching algorithm to obtain the position of the target in the second frame of image.
进一步地,步骤7-2中模板匹配算法具体采用菱形搜索算法。Further, the template matching algorithm in step 7-2 specifically adopts a diamond search algorithm.
进一步地,更新目标模板,具体为:Further, update the target template, specifically:
假设Tk为用于第k帧图像进行模板匹配的目标模板,Tk+1为更新后用于第k+1帧图像进行模板匹配的目标模板,更新目标模板的公式为:Suppose T k is the target template used for template matching of the k-th frame image, and T k+1 is the updated target template used for template matching of the k+1-th frame image. The formula for updating the target template is:
式中,Mk为第k帧图像中通过模板匹配算法获得的以目标位置为中心、以模板大小为覆盖范围的目标模板Tk的最佳匹配,α为更新权值,cmax为模板匹配输出的相关系数,τt为设定的目标模板是否更新的阈值,由公式可知,当相关系数cmax大于阈值τt时,对目标模板进行更新,否则保持不变。In the formula, M k is the best matching of the target template T k obtained by the template matching algorithm in the kth frame image with the target position as the center and the template size as the coverage, α is the update weight, c max is the template matching The output correlation coefficient, τ t is the threshold for whether the set target template is updated. It can be seen from the formula that when the correlation coefficient c max is greater than the threshold τ t , the target template is updated, otherwise it remains unchanged.
步骤8、根据连续两帧图像中目标所在位置获取后一帧图像中目标所在位置。Step 8: Acquire the position of the target in the next frame of images according to the position of the target in the two consecutive frames of images.
进一步地,根据连续两帧图像中目标所在位置获取后一帧图像中目标所在位置,具体为:Further, obtain the location of the target in the next frame of images according to the location of the target in the two consecutive frames of images, specifically:
步骤8-1、利用最小二乘法处理连续两帧图像中目标所在位置,由此获取后一帧图像中目标所处的区域;Step 8-1. Use the least squares method to process the location of the target in two consecutive frames of images, thereby obtaining the area where the target is located in the next frame of image;
步骤8-2、将波门移动到区域的中心,对波门内图像与更新后的目标模板进行模板匹配,获取当前帧图像中目标所在位置。Step 8-2, move the wave gate to the center of the area, perform template matching between the image in the wave gate and the updated target template, and obtain the position of the target in the current frame image.
步骤9、求取后一帧图像中的目标与目标模板之间的相关系数,并根据相关系数判断是重复步骤8继续跟踪还是停止跟踪。Step 9: Obtain the correlation coefficient between the target in the next frame of image and the target template, and determine whether to repeat Step 8 to continue tracking or stop tracking according to the correlation coefficient.
进一步地,步骤9求取后一帧图像中的目标与目标模板之间的相关系数,并根据相关系数判断是重复步骤8继续跟踪还是停止跟踪,具体为:Further, step 9 obtains the correlation coefficient between the target in the next frame of image and the target template, and judges whether to repeat step 8 to continue tracking or stop tracking according to the correlation coefficient, specifically:
步骤9-1、以步骤8中后一帧图像中目标所在位置为中心,截取与目标模板相同大小的区域作为后一帧图像中的目标;Step 9-1, taking the position of the target in the next frame image in step 8 as the center, intercept the area of the same size as the target template as the target in the next frame image;
步骤9-2、求取后一帧图像中的目标与目标模板之间的相关系数Q,所用公式为:Step 9-2, to obtain the correlation coefficient Q between the target and the target template in the next frame of image, the formula used is:
式中,xi为目标模板中第i个像素的灰度值,为目标模板的像素灰度均值,yi为图像中的目标中第i个像素的灰度值,为图像中的目标的像素灰度均值;In the formula, x i is the gray value of the ith pixel in the target template, is the pixel gray mean value of the target template, y i is the gray value of the ith pixel in the target in the image, is the pixel gray mean value of the target in the image;
步骤9-3、判断相关系数Q与预设阈值p的关系,若Q≥p,则重复步骤8继续跟踪;反之将失败次数n递增1,并执行步骤9-4;其中,失败次数n的初始值为0;Step 9-3, determine the relationship between the correlation coefficient Q and the preset threshold p, if Q≥p, repeat step 8 to continue tracking; otherwise, increase the number of failures n by 1, and perform step 9-4; The initial value is 0;
步骤9-4、判断n与失败次数预设阈值q的关系,若n≥q,则停止跟踪,反之以像素级为单位扩大波门的大小,重复步骤8继续跟踪。Step 9-4: Determine the relationship between n and the preset threshold q for the number of failures. If n ≥ q, stop tracking, otherwise expand the size of the wave gate in pixel-level units, and repeat step 8 to continue tracking.
实施例Example
结合图1,本发明基于DSP的目标检测与跟踪方法,包括以下内容:1, the DSP-based target detection and tracking method of the present invention includes the following contents:
1、初始化波门大小和波门四周背景大小1. Initialize the wave gate size and the background size around the wave gate
波门的大小由采集的图像大小和目标的大小而定,主要要求为波门能够完整地标出目标的位置。本实施例中采集的某一帧图像如图2所示,大小为1600像素*900像素,图像中目标大小为80像素*60像素,将波门大小设置为120像素*120像素,波门四周背景大小设置为120像素*30像素。The size of the wave gate is determined by the size of the collected image and the size of the target. The main requirement is that the wave gate can completely mark the position of the target. A certain frame of image collected in this embodiment is shown in Figure 2, the size is 1600 pixels * 900 pixels, the target size in the image is 80 pixels * 60 pixels, the size of the wave gate is set to 120 pixels * 120 pixels, and the surrounding area of the wave gate is 120 pixels * 120 pixels. The background size is set to 120px*30px.
2、确定二值化阈值2. Determine the binarization threshold
统计波门和波门四周背景的灰度直方图,得到具有双峰分布的直方图,选取波门之间的低谷对应的灰度值20作为二值化的阈值。The grayscale histogram of the wave gate and the background surrounding the wave gate is counted to obtain a histogram with a bimodal distribution, and the gray value 20 corresponding to the trough between the wave gates is selected as the binarization threshold.
3、二值化波门内图像3. Binarize the inner image of the wave gate
根据确定的二值化阈值对波门内图像进行如下二值化处理:According to the determined binarization threshold, the following binarization processing is performed on the image in the wave gate:
其中,f(x,y)是波门内像素原有的灰度值,fT(x,y)是处理后波门内像素的灰度值。Among them, f(x, y) is the original gray value of the pixel in the wave gate, and f T (x, y) is the gray value of the pixel in the wave gate after processing.
4、对二值化的波门内图像进行滤波处理4. Filter the binarized wave gate image
采用开运算处理,具体为先采用大小为3×3的结构元素扫描图像中的每一个像素,用结构元素中的每一个像素与其覆盖的像素相“与”,如果都为0,则该像素为0,否则为1。再采用大小为3×3的结构元素扫描图像中的每一个像素,用结构元素中的每一个像素与其覆盖的像素相“与”,如果都为1,则该像素为1,否则为0。The open operation is used to process, specifically, first scan each pixel in the image with a structuring element with a size of 3 × 3, and use each pixel in the structuring element to "AND" the pixels it covers. If both are 0, then the pixel is 0, otherwise 1. Then use a structuring element with a size of 3 × 3 to scan each pixel in the image, and use each pixel in the structuring element to "AND" the pixels it covers. If both are 1, the pixel is 1, otherwise it is 0.
5、利用邻域标记算法标记滤波后的波门内的图像的各个区域,获得若干个连通区域;5. Use the neighborhood labeling algorithm to mark each area of the image in the filtered wave gate, and obtain several connected areas;
6、统计标记的所有连通区域的大小,并对连通区域大小进行降序排列,获取其中最大连通区域的外接矩形,并将其作为目标模板;6. Count the sizes of all connected regions marked, and sort the connected regions in descending order to obtain the circumscribed rectangle of the largest connected region, and use it as the target template;
7、获取最大连通区域的中心即第一帧图像中目标所在位置,采用菱形搜索算法根据该中心获取第二帧图像中目标所在位置。具体操作为:7. Obtain the center of the largest connected area, that is, the position of the target in the first frame of image, and use the diamond search algorithm to obtain the position of the target in the second frame of image according to the center. The specific operations are:
以模板图像和目标图像为输出,先以大菱形搜索算法找到目标所在的最佳区域,以此位置作为小菱形搜索的中心位置,再以小菱形搜索算法找到目标的精确位置。大菱形搜索算法使用的搜索模板为5×5大小的模板,小菱形搜索算法使用的搜索模板为3×3大小的模板,大菱形搜索模板和小菱形搜索模板如图3所示。菱形搜索算法反复使用菱形搜索模板进行搜索,直至本次搜索误差最小的那个点出现在模板的中心,得到的搜索误差最小的点即为最佳匹配点。Taking the template image and the target image as the output, first use the large diamond search algorithm to find the best area where the target is located, use this position as the center position of the small diamond search, and then use the small diamond search algorithm to find the exact position of the target. The search template used by the large diamond search algorithm is a 5 × 5 template, and the search template used by the small diamond search algorithm is a 3 × 3 template. The large diamond search template and the small diamond search template are shown in Figure 3. The diamond search algorithm repeatedly uses the diamond search template to search until the point with the smallest search error appears in the center of the template, and the obtained point with the smallest search error is the best matching point.
8、目标模板更新方法8. Target template update method
其中Tk为用于第k帧图像进行模板匹配的目标模板,Tk+1为更新后用于第k+1帧图像进行模板匹配的目标模板,Mk为第k帧图像中通过模板匹配算法获得的以目标位置为中心、以模板大小为覆盖范围的目标模板Tk的最佳匹配。α为更新权值,cmax为模板匹配输出的相关系数,本实施例中α=0.1cmax,τt为设定的目标模板是否更新的阈值,本实施例中τt=0.75,当相关系数cmax大于阈值τt时,对目标模板进行更新,否则保持不变。where T k is the target template used for template matching of the kth frame image, T k+1 is the updated target template used for template matching of the k+1 frame image, M k is the template matching in the kth frame image The algorithm obtains the best match of the target template Tk centered on the target position and covering the template size. α is the update weight, c max is the correlation coefficient of template matching output, in this embodiment α=0.1c max , τ t is the threshold for whether the set target template is updated, in this embodiment τ t =0.75, when the correlation When the coefficient c max is greater than the threshold τ t , the target template is updated, otherwise it remains unchanged.
9、根据连续两帧图像中目标所在位置获取后一帧图像中目标所在位置;9. Obtain the location of the target in the next frame of images according to the location of the target in two consecutive frames of images;
利用前两帧图像中目标所在的位置,采用最小二乘法推算出后一帧图像中目标所处的区域。最小二乘法公式如下:Using the position of the target in the first two frames of images, the least squares method is used to calculate the area of the target in the next frame of image. The least squares formula is as follows:
y=ax+by=ax+b
其中a为拟合曲线的斜率,b为拟合曲线的截距,x为目标所在水平方向上的像素坐标,y为目标所在垂直方向上的像素坐标,为前两帧目标所在水平方向上的像素坐标均值,为目标所在垂直方向上的像素坐标均值。where a is the slope of the fitted curve, b is the intercept of the fitted curve, x is the pixel coordinate in the horizontal direction where the target is located, y is the pixel coordinate in the vertical direction where the target is located, is the mean of pixel coordinates in the horizontal direction of the target in the first two frames, is the mean of pixel coordinates in the vertical direction of the target.
10、将波门移动到目标所处区域的中心,对波门内的图像与上一帧更新后的目标模板进行模板匹配,获取当前帧图像中目标所在位置。10. Move the wave gate to the center of the area where the target is located, perform template matching between the image in the wave gate and the target template updated in the previous frame, and obtain the position of the target in the current frame image.
11、计算图像中的目标与目标模板之间的相关系数,所用公式为:11. Calculate the correlation coefficient between the target in the image and the target template. The formula used is:
式中,xi为目标模板中第i个像素的灰度值,为目标模板的像素灰度均值,yi为图像中的目标中第i个像素的灰度值,为图像中的目标的像素灰度均值;相关系数Q∈[-1,1],且Q越大,相关性越高。In the formula, x i is the gray value of the ith pixel in the target template, is the pixel gray mean value of the target template, y i is the gray value of the ith pixel in the target in the image, is the pixel gray mean value of the target in the image; the correlation coefficient Q∈[-1,1], and the larger the Q, the higher the correlation.
12、判断相关系数与所设阈值的关系12. Determine the relationship between the correlation coefficient and the set threshold
本实施例中将相关系数预设阈值p设置为0.75,将失败次数预设阈值q设置为50,判断相关系数Q与预设阈值p的关系,若Q≥p,则清空失败计数,继续跟踪,目标跟踪结果如图4所示;若Q<p,则将失败计数n递增1,判断n与失败次数预设阈值q的关系,若n≥q,则停止跟踪,若n<q,则将波门扩大为180像素*180像素,继续跟踪。In this embodiment, the preset threshold p of the correlation coefficient is set to 0.75, the preset threshold q of the number of failures is set to 50, and the relationship between the correlation coefficient Q and the preset threshold p is determined. If Q≥p, the failure count is cleared and the tracking is continued. , the target tracking result is shown in Figure 4; if Q<p, increment the failure count n by 1, and judge the relationship between n and the preset threshold q for the number of failures, if n≥q, stop tracking, if n<q, then Expand the wave gate to 180 pixels * 180 pixels and continue tracking.
本发明的基于DSP的目标检测与跟踪方法,运算复杂度低,且放大了目标模板与图像中目标的相关性,保证了图像跟踪的稳定性,跟踪精度高,实时性好,能满足图像跟踪系统对跟踪方法的要求。The DSP-based target detection and tracking method of the present invention has low computational complexity, amplifies the correlation between the target template and the target in the image, ensures the stability of image tracking, has high tracking accuracy and good real-time performance, and can meet the requirements of image tracking. System requirements for tracking methods.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811453586.1A CN109685827B (en) | 2018-11-30 | 2018-11-30 | Target detection and tracking method based on DSP |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811453586.1A CN109685827B (en) | 2018-11-30 | 2018-11-30 | Target detection and tracking method based on DSP |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109685827A CN109685827A (en) | 2019-04-26 |
CN109685827B true CN109685827B (en) | 2022-09-06 |
Family
ID=66185165
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811453586.1A Active CN109685827B (en) | 2018-11-30 | 2018-11-30 | Target detection and tracking method based on DSP |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109685827B (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110543809A (en) * | 2019-06-24 | 2019-12-06 | 台州宏达电力建设有限公司 | A video identification method for risk supervision and intrusion in electric power operation site |
CN111145218B (en) * | 2019-12-30 | 2023-04-07 | 华南理工大学 | Mini-LED chip precision positioning method based on YOLO algorithm |
CN110930428B (en) * | 2020-02-19 | 2020-08-14 | 成都纵横大鹏无人机科技有限公司 | Target tracking method and device, electronic equipment and storage medium |
CN112199972A (en) * | 2020-10-28 | 2021-01-08 | 普联技术有限公司 | Method for identifying positioning point |
WO2024065389A1 (en) * | 2022-09-29 | 2024-04-04 | 京东方科技集团股份有限公司 | Method and system for detecting camera interference, and electronic device |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102831617A (en) * | 2012-07-17 | 2012-12-19 | 聊城大学 | Method and system for detecting and tracking moving object |
CN106296725A (en) * | 2015-06-12 | 2017-01-04 | 富泰华工业(深圳)有限公司 | Moving target detects and tracking and object detecting device in real time |
-
2018
- 2018-11-30 CN CN201811453586.1A patent/CN109685827B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102831617A (en) * | 2012-07-17 | 2012-12-19 | 聊城大学 | Method and system for detecting and tracking moving object |
CN106296725A (en) * | 2015-06-12 | 2017-01-04 | 富泰华工业(深圳)有限公司 | Moving target detects and tracking and object detecting device in real time |
Also Published As
Publication number | Publication date |
---|---|
CN109685827A (en) | 2019-04-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109685827B (en) | Target detection and tracking method based on DSP | |
WO2021196294A1 (en) | Cross-video person location tracking method and system, and device | |
Kang et al. | Road lane segmentation using dynamic programming for active safety vehicles | |
Yuan et al. | Robust lane detection for complicated road environment based on normal map | |
CN103268480B (en) | A kind of Visual Tracking System and method | |
CN104200461B (en) | The remote sensing image registration method of block and sift features is selected based on mutual information image | |
CN110728200A (en) | Real-time pedestrian detection method and system based on deep learning | |
CN106203433A (en) | In a kind of vehicle monitoring image, car plate position automatically extracts and the method for perspective correction | |
CN107705322A (en) | Motion estimate tracking and system | |
CN107480603B (en) | Synchronous mapping and object segmentation method based on SLAM and depth camera | |
CN103136525B (en) | High-precision positioning method for special-shaped extended target by utilizing generalized Hough transformation | |
CN106327502A (en) | Multi-scene multi-target recognition and tracking method in security video | |
TW202121331A (en) | Object recognition system based on machine learning and method thereof | |
CN107341490A (en) | A kind of shielding automobile detection method and system based on convex closure analysis | |
CN106558051A (en) | A kind of improved method for detecting road from single image | |
Chen et al. | Method on water level ruler reading recognition based on image processing | |
CN104143197A (en) | A detection method for moving vehicles in aerial photography scenes | |
CN114333023A (en) | Face gait multi-mode weighting fusion identity recognition method and system based on angle estimation | |
WO2020001631A1 (en) | Visual camera-based method for identifying edge of self-shadowing object, device, and vehicle | |
CN109325487B (en) | Full-category license plate recognition method based on target detection | |
CN104599291A (en) | Structural similarity and significance analysis based infrared motion target detection method | |
CN103337080A (en) | Registration technology of infrared image and visible image based on Hausdorff distance in gradient direction | |
CN110211150B (en) | Real-time visual target identification method with scale coordination mechanism | |
WO2019041447A1 (en) | 3d video frame feature point extraction method and system | |
CN106934832A (en) | A kind of simple straight line automatic positioning method towards vision line walking |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |