Generalised discriminative optimisation algorithms for augmented reality: theory and practice