I think they can see ghosts but to my opinion not all of them... I think that just like us Humans some have the gift and others don't...
I do believe in ghosts but the most common reason for your dog to bark can something as small as a mice traveling through your walls... Animals outside ect...
My friend has a dog. (I think he is simply crazy) but he barks all the time in empty space for no reason day or night... He is special though! Other than the unexplained barking he is a sweet heart...