Globally Optimal O(n) Solution to the PnP Problem for General Camera Models.