And yes, of course don't try to speak with people who obviously don't want to be spoken to. Quick way to find out, is to ask "Can I ask you a question?" and then you leave space both for the people who don't want to chat, and the ones that do :)
I used to judge that based on people's faces, but the faces lie a lot, and some people basically default to looking pissed off, while they can be very warm people, and also vice-versa, so in the end asking up front seems to be the nicest way for everyone to be OK with it.