If you don't have consent from an animal's owner, do not interact with the animal. That's not something good that you should do. Instead, get consent first.
I can imagine when society sees you as a problem rather than the situation you're in, having a companion who loves you unconditionally becomes a lot more important.
I am a homeless advocate in San Diego. They do have some sweet dogs, but some are not at all sweet. I've been bitten by a couple of them while handing out water and snacks.
The real problem is that there is an entire subculture of breeders among the homeless that refuse to get their pets spayed or neutered. I will be the first to admit that no one that is homeless, that I have ever met, would ever think about their needs before their dogs' needs, so those pets aren't living nearly as hard a life as their owners. That being said, we have too many dogs and cats in this country. I don't know what the solution is. It's inhumane to take their pets from them. It's also inhumane to allow them to breed their pets willy-nilly, causing even more stray and feral dogs.
Speak for yourself, I wanna know the dog's name, their breed, how old they are, and their favourite treats, and the owner has to talk for me to learn that info. Also, you know, asking permission to pet first is important.