Recovering 6D object pose at the level of instances and categories