Noname manuscript No. (will be inserted by the editor) Globally Optimal Affine and Metric Upgrades in Stratified