We propose a visual recognition system for robotic applications in which distance to the visual objects can change a lot (for instance, trying to recognize a distant object learned from a short distance). Our system takes advantage of a single pan-tilt camera controllable in zoom and focus. Focus control allows to detect plans of sharpness in the scene and indirectly to compute a distance. Hence, this information can be used to gain structural information of the visual scene (to segment objects from the ground, to count the number of depth plans in the visual field...) without complex computation. This distance information is then used to control either a software or a hardware zoom to keep the size of the object invariant. The image thus created can be used by view based recognition systems. In a second time we show how by using focus points and neural networks we can improve the detection of sharpness plans in complex scenes. Finally we present a simple method to dynamically control the focus and stabilize it on the plan of sharpness of an object in the scene.