In production and life, the existence of motion blur increases the difficulty of Quick Response code (QR code) recognition. To solve this problem, a motion blur removal algorithm for QR code images based on blur kernel estimation and alternating Transformer was proposed. Firstly, in order to solve the problem that the current motion blur removal algorithms lack explanation of the intermediate degradation process, a blur Kernel Estimation Network (KEN) was used to estimate the shapes and parameters of the blur kernel dynamically, and after performing Wiener filtering on KEN output and the original image, the subsequent restoration networks were guided to better remove motion blur. Then, aiming at the problems that the window-based Transformer has a weak ability to capture global features and the traditional Transformer has high computational complexity, an Alternating Transformer Block (ATB) that combines Local-window Transformer Block (LTB) and Global-axis Transformer Block (GTB) was proposed to extract local and global features alternately. Finally, since when the input is a single-scale image, the model cannot handle with different levels of blur, a Multi-Scale Feature Fusion Block (MSFFB) was proposed. In this way, the model was able to extract features from multi-scale input images, utilize contextual information effectively, and retain and restore image details better. Experimental results on a motion blurred QR code image dataset show that for the linear blur kernel test set, compared with Uformer (U-shaped Transformer)-B, which has the second best restoration effect, the proposed algorithm has better performance in Peak Signal-to-Noise Ratio (PSNR) and Structural SIMilarity (SSIM) with 3.11% and 1.23% improvements respectively; for the nonlinear blur kernel test set, compared with Uformer-B, the proposed algorithm has the PSNR and SSIM indicators increased by 7.13% and 2.19% respectively. At the same time, the Multiply ACcumulate operations (MAC) of the proposed algorithm is decreased by 77.22%, obtaining the best among all comparison algorithms, and the proposed algorithm has a decrease of 83.5% in the model Parameter (Param). Besides, YOLOv4 and ZBar were used for object detection and recognition experiments, and the results show that the proposed algorithm has certain practical significance for improving the efficiency of QR code detection and recognition.