In nailfold capillary imaging, tremors cause image blurring and prevent accurate measurement, while capillary bundle distributions can diminish vascular information. As a comprehensive solution, we combined the YOLOv8 detection model with a Laplacian clarity evaluation function for real-time tracking of focus changes during capillary imaging. Normalized cross-correlation template matching was used to calculate the optimal matching position of adjacent frames, determine the position with the highest vascular similarity, and obtain the optimal offset between frames for accurate registration. Compared with the original video, mean squared error (MSE) decreased by 64.5%, peak signal-to-noise ratio (PSNR) increased by 3.88 dB, and structural similarity index (SSIM) increased by 4.7% in zooming experiments. MSE decreased by 57.9%, PSNR increased by 3.99 dB, and SSIM increased by 3.19% in fixed-focus experiments. Compared with state-of-the-art registration algorithms, our proposal provides better overall performance across three evaluation indicators, achieving the best registration effect for capillary images.