If a cop has initiated an interaction with you, it's not for no reason. They can never assume that you're not a random nutcase that hates police and has no impulse control. They might stop someone and say "hey, your shoe's untied!" and get stabbed in the neck because that person hates cops. Being a cop makes you a target to anyone that hates authority and has violent tendencies, every time they they talk to someone they probably have little boost of adrenaline because they don't know what's going to happen. Every time they talk to a new person, they're going to be a little on edge until that person gives them a reason not to be.
That's the person you have to be, because you don't know what mental or emotional issues any given cop has, you don't know if they're a racist or a sexist or some other kind of bigot who's going to have some kind of preconceived notion about you. You don't know what's happened in their day or what's going on in their home life that might tilt their attitude into the red. You have to remember that almost every person they interact with while in uniform they're having some level of confrontation with. You also have to remember that they have a government entity telling them that they have authority over you, and they expect respect from you, whatever their idea of respect is.
Think from the point of view of their stresses, not just your own. Let that inform how you act around them and toward them. None of that is taking away their responsibility in not acting like a walking talking piece of excrement, but even if they are you can't let that make you act like anything other than a polite person to them.
Keep in mind that none of what I'm saying has any bearing on the issues this country has with our police forces, what I'm saying is for individuals.