The main difference is the emotion. It is therefore important to pay close attention to the body language of a dog who wishes to interact (soft eyes, eagerness) which is different from a dog who doesn't want to interact (stiffness, hard eyes). It takes quite some practice to learn how to read dogs to see the difference. To make things more complicated, sometimes dogs may seem like they want to interact and then make an abrupt change once they are closer. Knowing the history of the dog is helpful too (dog loves to play with dogs and gets along, but just gets frustrated when he cannot greet them).