| Target detection and localization has a wide range of applications in daily life and industrial manufacturing.The main process is based on the image data collected by vision sensors and the target location marking is realized by the vision algorithms.Template matching is a classical technique in the field of target localization,which finds the most similar matching region to the template image in the image to be matched based only on the a priori knowledge of the template image.Fast and accurate template matching algorithms are commonly used in electronic chips,medicine,defense equipment and other fields.The traditional template matching methods have three matching ideas based on grayscale,based on feature points,and based on shape edges.The grayscale based matching methods are simple and straightforward,among which Normalized Cross-Correlation(NCC)has a good performance in dealing with noise and illumination changes,and is the most classical matching method and the basis for the improvement of subsequent grayscale related algorithms,but these algorithms rely on sliding window pixel-by-pixel traversal and the computational volume increases exponentially when dealing with the matching task involving image rotation.The feature point-based and shape-edge-based matching methods are more robust to image rotation,scaling,and distortion,but these methods are matched in units of feature descriptors,and the matching process is more computing and memory usage.For target localization on actual industrial production lines,the biggest challenge is to detect the rotation of the target and the matching time consumption problem,to address the above issues,the work in this paper is presented in three parts.In the first part,to solve the problem of excessive computation of the fixed-angle template matching method,a template matching method based on local variance and a posteriori probability classification is proposed in this paper to reduce the computational effort.The method filters out part of the candidate windows by local variance in the matching process and calculates window correlation by comparing the gray size of coordinate points in the posteriori probability classification module.The window correlation calculation based on posterior probability classification accomplishes the matching task with as few candidate windows as possible by increasing the number of positive sample windows for training.In the second part,to solve the problem that traditional template matching methods take too much time when considering target rotation,this paper based on the single-angle template matching method based on local variance and posterior probability classification,the rotation invariant of the algorithm is achieved by training the positive sample features of rotation in the local variance module and the posterior probability classification module separately.Moreover,the rotation invariant of the algorithm is achieved in the preconditioning process,so it does not affect the matching speed,and the window correlation is calculated by the grayscale comparison between the feature point pairs to ensure the window features are more representative.In the third part,to solve the target localization task of the real industrial line,the region gradient-based on Local stable feature point pairs is proposed for the problem of overconcentrated feature distribution of template images,and the window correlation is calculated in the posterior probability classification module by comparing the grayscale of different region stable feature point pairs.The experimental results show that the matching time can be reduced to less than 10 ms and the accuracy is guaranteed to be above 95% after choosing a suitable window shift step on an arbitrary angle matching image of 800,000-pixel level,which is faster compared with the existing algorithms and has a broad application prospect. |