In this paper, we propose a self-supervised algorithm based on VQ-VAE-2 for the automated detection of concrete structural apparent cracks. The algorithm demonstrates the capability to effectively detect cracks without available crack samples. By taking the reconstruction error as detection index, VQ-VAE-2 is trained on crack-free images. When applied to images with cracks, VQ-VAE-2 produces higher reconstruction errors. The original and reconstructed images are partitioned into blocks for calculating the reconstruction error. The maximum value of the reconstruction error between corresponding blocks is taken as the reconstruction error of the image. This approach increases the difference in reconstruction error between the two types of images. The results show that the algorithm achieves a precision of 0.954, a recall of 0.959, an accuracy of 0.956, and an F1 score of 0.957. These results indicate that the algorithm can effectively detect concrete structural apparent cracks even without crack samples in the training set.