Infrared photometry of compact objects in the Magellanic Clouds