Model accuracy with contrastive loss and triplet loss

Is there a way to calculate some sort of accuracy when I have to deal with loss functions which calculates distance beetwen pairs? Siamese networks outputs embedded representations of input data and then these are fed to the contrastive loss which calculates their dissimilarity. How can I say that these representations belongs to the same class according to the margin I choose? For triplet networks I think a possible metric to calculate accuracy would be to check if the distance between anchor and positive has to be less than the distance between anchor and negative for each input of my data. Here is an article which talks about these types of loss functions. Would you share your opinion about this? Thanks.