1. A computer-implemented method for training a convolutional neural network (CNN), the method comprising: extracting coordinates of corresponding points in first and second locations; identifying positive points in the first and second locations; identifying negative points in the first and second locations; training features that correspond to positive points of the first and second locations to move closer to each other; and training features that correspond to negative points in the first and second locations to move away from each other; wherein a contrastive loss layer is trained with hard negative mining and by reusing activations in overlapping regions.