I don't always talk to dogs in vehicles. If their human is there, I mostly do, and if they get worked up about anyone being around their vehicle (doing the guard thing) I might say, "It's all right, darling. I'm not going to hurt your car."
But I do talk to all dogs on the street, particularly if they are tied up outside a store. I'll approach with a happy face and ask if they talk to strangers, and the vast majority of them make it quite clear that they'd looooooooooove a conversation. So we chat for a few minutes, and I deliver whatever scritches they invite and reassure them that their human won't be long, because who could leave such a lovely person for more than a few minutes, etc, etc.
If they decline the conversation, I'll just say, "Not sure, eh? That's Ok." and move on.