| Nowadays, commodity packaging is still with one dimension barcode most widely in the traditional packaging barcode printing, two-dimensional barcode only has been applied in the part of drug supervision, but has trend to the food and drug packaging and other aspects more and more widely. Due to mechanical vibration or printing technology or other reasons, some defects often occur in the surface of printing process. Due to the two-dimensional barcode has not been large-scale applications as regulatory code, company and academics researchers haven’t research achievements in defect detection of two-dimensional barcode. This is a challenging subject for the author in defect detection of two-dimensional barcode, so, the research has important guiding significance and economic value.For the problem of traditional mathematical morphology operation difficult to control and mathematical morphological method proposed based on edge pixel width and grayscale operation double-controlled. Edge pixel of the two-dimensional barcode can be adjusted respectively width and grayscale of operation, effective to improve the accuracy of defect detection algorithm. Based on mathematical morphology, results of mathematical morphology operation as templates, the template matching method is proposed based on two-dimensional barcode, to achieve a precise match to be detected two-dimensional barcode and two-dimensional code templates, and without defect type (black or white defect) to determine and improve the overall accuracy and efficiency of defect detection algorithms.For the problem of industrial requirement and lack of research achievement for two-dimensional code defect detection, a algorithms proposed for two-dimensional barcode defect detection based on template matching to effectively solve the problem of defect detection of two-dimensional code. On the basis of the proposed methods for mathematical morphology and template matching, according to the characteristics of two-dimensional code defects, two algorithms are proposed that line defect detection algorithm based on projection and block defect detection algorithm based on Blob analysis. New algorithms called two-dimensional code defect detection algorithm based on template matching after integration of two algorithms and achieved system design.In this paper, we propose the procedure by a serial of carefully designed preprocessing methods. Due to establish the sample database, the algorithm is tested by robustness test, efficiency test and efficiency test. The experiment results show that the algorithm has stronger robustness and higher efficient. Moreover, experiment results on two-dimensional barcode images show that the prediction accuracy of proposed method reaches 99.95% with an average execution time of 4.855ms. Our method can detect defect of these images in real time. L.e. the algorithm can complete detect 17796086 samples per when the time overhead not be calculated in the detection system in the ideal case. |