I used to have a dane, who did the same. Well she was older, but the same kind of reaction. When people came near the house, she went up to the fence and started to bark after a little while, it was strange because she absolutely loved everyone. After having studied her a lot from the window, and spoke to one of my obedience instructors. I think we pinned down why she did it. She went up to the fence, and I guess expected whoever was walking by, to stop and talk to her, when they didnt, she tried to make them pay attention to her by barking. That very rarely had the effect she was hoping for
sometimes they speeded up and went by real fast, others were standing there, looking at her, but did not approach, so she kinda felt like, okay you are here, you are looking at me, why are you not talking to me?
So she barked even more to try and get them to come closer and pet her. Unfortunately they did not understand her language
When people actually did go up to her and started to talk to her, she was all tail wagging and lovable.
So the advice I got from this instructor, was to have people walk by, when she barked just ignore her, and when we got her to be quiet, they came up to talk to her and greet her. The idea was to make her realize that if she wanted attention and petting, she had to be a good girl, bad behavior did not get her that. We did make her change, but it never went away totally.
Good Luck to you,
Marit