Chameleons eyes are very well developed. They also have some special abilities that most other animals don't have. They can alter the polarization of light hitting the retina, they have a sort of zoom lens system, and they can see in different spectrums of light than we can. Its quite possible that that boy can detect some visual or even pheromonal signal that there is a girl in the next cage.
They really are amazing creatures.